[alsa-devel] question on snd_soc_jack_report

Mark Brown broonie at opensource.wolfsonmicro.com
Fri Jan 14 13:00:23 CET 2011

On Fri, Jan 14, 2011 at 05:10:01PM +0530, Harsha, Priya wrote:

> struct snd_soc_jack *soc_jack;
> snd_soc_jack_report (soc_jack, SND_JACK_HEADPHONE, SND_JACK_HEADPHONE);

> I don't find the reporting to be happening. When I looked at the snd_jack_report 
> code, I found that jack->type needs to be set and that was not being set.
> So when I added the following line in my code, it started reporting.
> soc_jack->jack->type = SND_JACK_HEADPHONE;

> Is it expected that the driver sets the 'type' of the instance of 'snd_jack' inside 
> snd_soc_jack structure. I was actually thinking that snd_soc_jack_report would 
> need to do this.

> I did not find any other drivers doing that. Is there something that I am 
> missing?

No, you should be passing the full set of capabilities for the jack in
when you call snd_soc_jack_new().  It's not possible to change the
capabilities dynamically at runtime, these need to be fixed when
registering the jack.

> Also, to report button press events, I had to add the following line of code
> soc_jack->jack->key[0] = BTN_0;
> Is this also an expected thing to be set.

You've not said where you did this but the API for configuring button
types is snd_jac_set_key().  BTN_0 should be being used as a default
when the jack is registered if nothing has been explicitly configured
(see snd_jack_register()).  If you're not specifying the capabilities as
your above issue suggests this won't happen.

More information about the Alsa-devel mailing list