[alsa-devel] [PATCH] ALSA: HDA: Create phantom jacks for fixed inputs and outputs
Takashi Iwai
tiwai at suse.de
Fri Jun 8 10:52:51 CEST 2012
At Thu, 7 Jun 2012 15:52:08 +0200,
David Henningsson wrote:
>
> PulseAudio sometimes have difficulties knowing that there is a
> "Speaker" or "Internal Mic", if they have no individual volume
> controls or selectors. As a result, only e g "Headphone" might
> be created for a laptop, but no "Speaker".
> To help out, create phantom jacks (that are always present,
> at least for now) for "Speaker", "Internal Mic" etc, in case we
> detect them.
> The naming convention is e g "Speaker Phantom Jack".
>
> In order not to pollute the /dev/input namespace with even more
> devices, these are added to the kcontrols only, not the input devices.
>
> An implementation note:
> The possibility to override how to actually do jack sensing opens
> up for more advanced usage of the jack infrastructure in the future
> (e g letting the headphone jack detection set presence status for
> both headphone and mic in case of a headset jack, among other things).
>
> Signed-off-by: David Henningsson <david.henningsson at canonical.com>
> ---
> sound/pci/hda/hda_jack.c | 64 ++++++++++++++++++++++++++++++++++------------
> sound/pci/hda/hda_jack.h | 5 ++++
> 2 files changed, 52 insertions(+), 17 deletions(-)
>
> diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c
> index 2dd1c11..c5569f1 100644
> --- a/sound/pci/hda/hda_jack.c
> +++ b/sound/pci/hda/hda_jack.c
> @@ -133,6 +133,13 @@ static void jack_detect_update(struct hda_codec *codec,
> }
> }
>
> +static void jack_detect_always_present(struct hda_codec *codec,
> + struct hda_jack_tbl *jack)
> +{
> + jack->pin_sense = AC_PINSENSE_PRESENCE;
> + jack->jack_dirty = 0;
> +}
> +
> /**
> * snd_hda_set_dirty_all - Mark all the cached as dirty
> *
> @@ -162,7 +169,8 @@ u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid)
> {
> struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid);
> if (jack) {
> - jack_detect_update(codec, jack);
> + if (jack->update_func)
> + jack->update_func(codec, jack);
IMO, it's easier to modify jack_detect_update().
Instead of adding update_func pointer, add a new flag phantom_jack
(can be a bit field), then in jack_detect_update():
static void jack_detect_update(struct hda_codec *codec,
struct hda_jack_tbl *jack)
{
if (jack->phantom_jack) {
jack->pin_sense = AC_PINSENSE_PRESENCE;
jack->jack_dirty = 0;
} else ...
}
thanks,
Takashi
More information about the Alsa-devel
mailing list