Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Wurmsdobler <peter@wurmsdobler.org>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: ioctl request code for specific alsa control
Date: Fri, 16 May 2008 10:16:34 +0100	[thread overview]
Message-ID: <482D50F2.2050706@wurmsdobler.org> (raw)
In-Reply-To: <482BE617.30207@ladisch.de>

Hello,

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)
> ioctl(SNDRV_CTL_IOCTL_ELEM_WRITE)
> snd_ctl_ioctl() (linux/sound/core/control.c)
> snd_ctl_elem_write_user()
> snd_ctl_elem_write()
> kctl->put()
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.

Regards,
peter

      reply	other threads:[~2008-05-16  9:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-13 18:31 ioctl request code for specific alsa control Peter Wurmsdobler
2008-05-14  9:17 ` Clemens Ladisch
     [not found]   ` <482AB7A1.6090303@wurmsdobler.org>
2008-05-15  7:28     ` Clemens Ladisch
2008-05-16  9:16       ` Peter Wurmsdobler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=482D50F2.2050706@wurmsdobler.org \
    --to=peter@wurmsdobler.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox