[alsa-devel] ioctl request code for specific alsa control
peter at wurmsdobler.org
Fri May 16 11:16:34 CEST 2008
Thanks for your help.
>> What ioctl request code would I have to pass in order to reach this
>> control's put/get methods?
> snd_ctl_elem_write() (alsa-lib/src/control/control.c)
> snd_ctl_hw_elem_write() (alsa-lib/src/control/control_hw.c)
> snd_ctl_ioctl() (linux/sound/core/control.c)
This is the path in the alsa world. I have followed this code as well,
and it uses the alsa control element as payload into the ioctl.
I have taken a more pragmatic and certainly less orthodox one:
ioctl(mixerFd, SOUND_MIXER_WRITE_VOLUME, &leftright);
will eventually call the put method of a kernel control
pmic_control_pb_vol with the name "Master Playback Volume".
The function snd_mixer_oss_build_input() appears to be responsible for
creating this link, by looking through a list of words such as "Master",
"CD", etc in conjunction with expressions such as "%s Playback Volume".
It probably will then try to match the names of the alsa kernel controls
and set the put function pointer if appropriate.
Consequently, if I rename the control responsible for the output,
pmic_control_op_sw, to something for which a ioctl exists, e.g. "CD",
then it works as a pseudo volume control and I can use:
ioctl(mixerFd, SOUND_MIXER_WRITE_CD, &output);
This approach is admittedly a hack, but it works. This ioctl will result
in the call of the fake CD control and its put method.
If I had renamed the the output control "Master Output Switch", I could
not have used a volume control and hence I would not know what ioctl
request code to use.
More information about the Alsa-devel