Polycom CL3200-M--Trying to read current volume setting on RaspPi 5

19 views Asked by At

I'm terribly lost and could really use some help. The background is that I'm setting up a Rhasspy install on a RaspPi5. I'm using a Polycom CL3200-M as the audio device. I have a problem that every time the system boots, it defaults to a very quiet volume level. What confounds this problem is that I can't find any way to read what the current volume of the speaker is. It seems to be possible under Windows, but I can't get it to work under Linux. (I say it works under windows because Win11 seems to react to the hardware buttons via various icons and such in the interface. I have not tried to write any code there.)

Given that I can't keep a user from touching the buttons on the speaker, I have to have a way to read the actual volume setting.

I have tried to build in an execution of amixer at boot, but that is very inconsistent. Sometimes I have to execute that command 2 or 3 times for it takes. Note that this problem isn't unique to boot. I can execute the same amixer command multiple times well after boot to reset the volume before it actually does it.

I must admit that I am perplexed by USB devices under Linux. I also am really struggling to understand all the audio stuff that goes with it.

For starters output from aplay -l

List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: P3200M [Poly Calisto 3200-M], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

With this, I can clearly see that card 2 is my audio device.

if I execute amixer -c 2, which I believe gives me the correct device:

Simple mixer control 'PCM',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 20
Mono: Playback 17 [85%] [-6.00dB] [on]
Simple mixer control 'Headset',0
Capabilities: cswitch cswitch-joined
Capture channels: Mono
Mono: Capture [on]

At this point, no matter what I do with the volume +/- on the actual speaker, this output does not change. It will never show me the actual volume setting; rather it only shows the last commanded volume from amixer (or that is what I believe it is doing).

I can set the volume with amixer -c 2 set PCM playback 17, but again, this is inconsistent. Sometimes it takes 2 or 3 tries to get it to take.

I tried to intercept the button presses via the HID device with a little code, but I can only intercept the mute and the MSTeams buttons. The volume buttons do not show up.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    FILE *fptr;
    char c;
    const char dev[]="/dev/hidraw0";
    //const char dev[]="/dev/bus/usb/001/004";

    if((fptr=fopen(dev,"r"))==NULL)
    {
        fprintf(stderr,"Cannot open /dev/hidraw0\n");
        return(1);
    }
    while(!feof(fptr))
    {
        c=getc(fptr);
        printf("0x%02x\n",c);
    }

    fclose(fptr);

    return(0);
}

Note, as shown by the comments in the code, I tried both /dev/hidraw0 and /dev/bus/usb/001/004. hidraw0 gets me the mute button, but /dev/bus/usb/001/004 gets me a long, and very cryptic series of codes that I have no clue how to interpret.

I've searched, tinkered, and guessed, but I can find no answer to this question. I simply want to know the current volume setting on the hardware. If I need to write a little C code to interrogate the USB device, I will, but I really can't figure out how I would do that.

0

There are 0 answers