[alsa-devel] [PATCH v3 2/3] ASoC: twl6040: Add jack support for headset and handset

Mark Brown broonie at opensource.wolfsonmicro.com
Wed Dec 8 18:09:32 CET 2010

On Wed, Dec 08, 2010 at 10:55:08AM -0600, Olaya, Margarita wrote:

>  	case TWL6040_PLUGINT:
> +		/* Debounce */
> +		msleep(200);

Hrm.  We're blocking the interrupt thread for an extended period, and
since we don't re-read the status after the debounce period the debounce
effectiveness will be substantially reduced, and may go very wrong if we
also get a removal interrupt queued up in the meantime as the removal
IRQ would then get processed even if the jack was actually inserted.

Scheduling a work item which checks the jack status (like hs_jack_detect
below does) for both plug and unplug IRQs would deal with this - the
work will get deferred each time we bounce, and the final status will
be whatever it stabalises at.

> +		report = jack->report;
> +		/*
> +		 * Early interrupt, CODEC driver cannot report jack status
> +		 * since jack is not registered yet. MACHINE driver will
> +		 * register jack and report status thru twl6040_hs_jack_detect
> +		 */
> +		if (jack->jack)
> +			snd_soc_jack_report(jack->jack, report, jack->report);

The jack API should handle null jacks happily.

> +struct twl6040_setup_data {
> +	void (*codec_enable)(int enable);
> +	void *jack;
> +};

The jack doesn't look to be used in this, and I guess the codec enable
belongs with something else?

More information about the Alsa-devel mailing list