Comment 127 for bug 1516025

Revision history for this message
In , superquad.vortex2 (superquad.vortex2-linux-kernel-bugs) wrote :

http://mailman.alsa-project.org/pipermail/alsa-devel/2015-September/097841.html

> the most important piece of information is missing: *why* this change
is needed. I can guess, but it has to be clarified to all readers.
At best, give the background information why the current code doesn't
work for some cases and how your change will help.

the purpose of the patch is to make the combo jack of those laptops using alc668 to support headset only and drop support of headphone mic and headphone in order to enable auto mic selection by creating headset jack which report the state of both headphone and headset mic of the combo jack

> + unsigned int hs_mic_use_hp_sense:1;

> Please give a comment to this new field what it indicates.

flag to indicate the headset mic pin does not support jack sense and rely on the headphone pin jack sense

> > static int get_input_jack_type(struct hda_codec *codec, hda_nid_t nid)
> {
> unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
> + struct hda_gen_spec *spec = codec->spec;
> switch (get_defcfg_device(def_conf)) {
> case AC_JACK_LINE_OUT:
> case AC_JACK_SPEAKER:
> return SND_JACK_LINEOUT;
> case AC_JACK_HP_OUT:
> + if (spec->hs_mic_use_hp_sense)
> + return SND_JACK_HEADSET;
> return SND_JACK_HEADPHONE;

. No, this won't work for all cases. The code in hda_jack.c can't
assume that codec->spec points to a hda_gen_spec object. This can be
other codec drivers like ca0132 or hdmi.

> It means that you need either to move the flag into hda_codec struct
or to handle this check differently.

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/sound/pci/hda/hda_codec.h

/* codec information */
struct hda_codec {
 struct hdac_device core;

+ unsigned int hs_mic_use_hp_sense:1;
#ifdef CONFIG_PM
 unsigned long power_on_acct;
 unsigned long power_off_acct;
 unsigned long power_jiffies;
#endif

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/sound/pci/hda/hda_jack.c

static int get_input_jack_type(struct hda_codec *codec, hda_nid_t nid)
 {
     unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
+ struct hda_gen_spec *spec = codec->spec;
+ struct auto_pin_cfg *cfg = &spec->autocfg;
     switch (get_defcfg_device(def_conf)) {
     case AC_JACK_LINE_OUT:
     case AC_JACK_SPEAKER:
         return SND_JACK_LINEOUT;
     case AC_JACK_HP_OUT:
+ if (codec->hs_mic_use_hp_sense && (nid == cfg->hp_pins[0]))
+ return SND_JACK_HEADSET;
         return SND_JACK_HEADPHONE;
     case AC_JACK_SPDIF_OUT:
     case AC_JACK_DIG_OTHER_OUT: