[v2-,ALSA,1/3] HDA - Allow hda_jack_tbl to use another nid for pin sense
diff mbox

Message ID CAN8cciYNotgS=1qis4ciOQqoYwjND4y=tpxJGmZt1HGahTV3+Q@mail.gmail.com
State New
Headers show

Commit Message

Raymond Yau Sept. 23, 2015, 2:40 a.m. UTC
- add sense_nid to __snd_hda_jack_add_kctl for pin sense

- update slave pin sense when master pin sense change

- enable unsolicited event when widcap support UNSOL

Signed-off-by: Raymond Yau <superquad.vortex2@gmail.com>

Comments

Takashi Iwai Sept. 23, 2015, 1:37 p.m. UTC | #1
On Wed, 23 Sep 2015 04:40:45 +0200,
Raymond Yau wrote:
> 
> - add sense_nid to __snd_hda_jack_add_kctl for pin sense
> 
> - update slave pin sense when master pin sense change
> 
> - enable unsolicited event when widcap support UNSOL

Again, please describe at first the reason you need this change.  Then
start explaining about the implementation details.  For example,
what's the difference from the existing gated_jack.


thanks,

Takashi

> 
> Signed-off-by: Raymond Yau <superquad.vortex2@gmail.com>
> 
> diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c
> index 366efbf..d81d65f 100644
> --- a/sound/pci/hda/hda_jack.c
> +++ b/sound/pci/hda/hda_jack.c
> @@ -19,6 +19,7 @@
>  #include "hda_local.h"
>  #include "hda_auto_parser.h"
>  #include "hda_jack.h"
> +#include "hda_generic.h"
> 
>  /**
>   * is_jack_detectable - Check whether the given pin is jack-detectable
> @@ -157,7 +158,14 @@ static void jack_detect_update(struct hda_codec *codec,
>      if (jack->phantom_jack)
>          jack->pin_sense = AC_PINSENSE_PRESENCE;
>      else
> -        jack->pin_sense = read_pin_sense(codec, jack->nid);
> +        jack->pin_sense = read_pin_sense(codec,
> +            jack->sense_nid ? jack->sense_nid : jack->nid);
> +
> +    if (jack->slave_nid) {
> +        struct hda_jack_tbl *slave = snd_hda_jack_tbl_get(codec,
> +                jack->slave_nid);
> +        slave->pin_sense = jack->pin_sense;
> +    }
> 
>      /* A gating jack indicates the jack is invalid if gating is unplugged
> */
>      if (jack->gating_jack && !snd_hda_jack_detect(codec,
> jack->gating_jack))
> @@ -269,11 +277,13 @@ snd_hda_jack_detect_enable_callback(struct hda_codec
> *codec, hda_nid_t nid,
>      jack->jack_detect = 1;
>      if (codec->jackpoll_interval > 0)
>          return callback; /* No unsol if we're polling instead */
> -    err = snd_hda_codec_write_cache(codec, nid, 0,
> +    if (is_jack_detectable(codec, nid)) {
> +        err = snd_hda_codec_write_cache(codec, nid, 0,
>                       AC_VERB_SET_UNSOLICITED_ENABLE,
>                       AC_USRSP_EN | jack->tag);
> -    if (err < 0)
> -        return ERR_PTR(err);
> +        if (err < 0)
> +            return ERR_PTR(err);
> +    }
>      return callback;
>  }
>  EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable_callback);
> @@ -384,7 +394,7 @@ static void hda_free_jack_priv(struct snd_jack *jack)
>   * will have the given name and index.
>   */
>  static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
> -              const char *name, bool phantom_jack)
> +          const char *name, bool phantom_jack, hda_nid_t sense_nid)
>  {
>      struct hda_jack_tbl *jack;
>      int err, state, type;
> @@ -403,6 +413,7 @@ static int __snd_hda_jack_add_kctl(struct hda_codec
> *codec, hda_nid_t nid,
> 
>      jack->phantom_jack = !!phantom_jack;
>      jack->type = type;
> +    jack->sense_nid = sense_nid;
>      jack->jack->private_data = jack;
>      jack->jack->private_free = hda_free_jack_priv;
>      state = snd_hda_jack_detect(codec, nid);
> @@ -422,7 +433,7 @@ static int __snd_hda_jack_add_kctl(struct hda_codec
> *codec, hda_nid_t nid,
>  int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
>                const char *name)
>  {
> -    return __snd_hda_jack_add_kctl(codec, nid, name, false);
> +    return __snd_hda_jack_add_kctl(codec, nid, name, false, nid);
>  }
>  EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctl);
> 
> @@ -451,7 +462,7 @@ static int add_jack_kctl(struct hda_codec *codec,
> hda_nid_t nid,
>      if (phantom_jack)
>          /* Example final name: "Internal Mic Phantom Jack" */
>          strncat(name, " Phantom", sizeof(name) - strlen(name) - 1);
> -    err = __snd_hda_jack_add_kctl(codec, nid, name, phantom_jack);
> +    err = __snd_hda_jack_add_kctl(codec, nid, name, phantom_jack, nid);
>      if (err < 0)
>          return err;
> 
> diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
> index 387d309..ef3d162 100644
> --- a/sound/pci/hda/hda_jack.h
> +++ b/sound/pci/hda/hda_jack.h
> @@ -41,6 +41,8 @@ struct hda_jack_tbl {
>      hda_nid_t gated_jack;        /* gated is dependent on this jack */
>      int type;
>      struct snd_jack *jack;
> +    hda_nid_t sense_nid;
> +    hda_nid_t slave_nid;
>  };
> 
>  struct hda_jack_tbl *
> -- 
> 2.5.0
Raymond Yau Sept. 23, 2015, 4:34 p.m. UTC | #2
> >
> > - add sense_nid to __snd_hda_jack_add_kctl for pin sense
> >
> > - update slave pin sense when master pin sense change
> >
> > - enable unsolicited event when widcap support UNSOL
>
> Again, please describe at first the reason you need this change.  Then
> start explaining about the implementation details.  For example,
> what's the difference from the existing gated_jack.
>
>

I don't understand how gated jack work, but those headset mic in alc668
dell-headset-multi does not  use its own pin sense and won't need to enable
unsol event of the headset mic node.

As pulseaudio don't expect jack kctl can be repesent the state of headphone
and mic

This force the driver to create a headset mic kctl which is just a copy of
the headphone jack kctl
Takashi Iwai Sept. 24, 2015, 8:10 a.m. UTC | #3
On Wed, 23 Sep 2015 18:34:34 +0200,
Raymond Yau wrote:
> 
> > >
> > > - add sense_nid to __snd_hda_jack_add_kctl for pin sense
> > >
> > > - update slave pin sense when master pin sense change
> > >
> > > - enable unsolicited event when widcap support UNSOL
> >
> > Again, please describe at first the reason you need this change.  Then
> > start explaining about the implementation details.  For example,
> > what's the difference from the existing gated_jack.
> >
> >
> 
> I don't understand how gated jack work, but those headset mic in alc668
> dell-headset-multi does not  use its own pin sense and won't need to enable
> unsol event of the headset mic node.
> 
> As pulseaudio don't expect jack kctl can be repesent the state of headphone
> and mic
> 
> This force the driver to create a headset mic kctl which is just a copy of
> the headphone jack kctl

See what you wrote now in the above?  It's a nice introduction of the
things you're trying to solve.  This kind of information is exactly
what I asked for.  Please rephrase and put it in the changelog at the
next time.

About gated_jack: this was introduced for Chromebook for a headset.
This should work similarly like your case.  The behavior of gated /
gating jacks are:

- When a jack A has gating_jack = B: the presence of jack A depends on
  gating_jack B.  Namely, if gating_jack B is unplugged, jack A is
  treated as unplugged.

- When a jack B has gated_jack = A: jack B doesn't give an unsol event
  by itself, but it's triggered together with gated_jack A when jack A
  is plugged/unplugged.  The plug status of jack B can be read from B
  itself.

For Chromebook, A (gated) is mic pin and B (gating) is HP pin.
That is, a headset mic is detected only when the HP pin is detected.


Takashi
Raymond Yau Sept. 25, 2015, 4:06 a.m. UTC | #4
> >
> > > >
> > > > - add sense_nid to __snd_hda_jack_add_kctl for pin sense
> > > >
> > > > - update slave pin sense when master pin sense change
> > > >
> > > > - enable unsolicited event when widcap support UNSOL
> > >
> > > Again, please describe at first the reason you need this change.  Then
> > > start explaining about the implementation details.  For example,
> > > what's the difference from the existing gated_jack.
> > >
> > >
> >
> > I don't understand how gated jack work, but those headset mic in alc668
> > dell-headset-multi does not  use its own pin sense and won't need to
enable
> > unsol event of the headset mic node.
> >
> > As pulseaudio don't expect jack kctl can be repesent the state of
headphone
> > and mic
> >
> > This force the driver to create a headset mic kctl which is just a copy
of
> > the headphone jack kctl
>
> See what you wrote now in the above?  It's a nice introduction of the
> things you're trying to solve.  This kind of information is exactly
> what I asked for.  Please rephrase and put it in the changelog at the
> next time.
>
> About gated_jack: this was introduced for Chromebook for a headset.
> This should work similarly like your case.  The behavior of gated /
> gating jacks are:
>
> - When a jack A has gating_jack = B: the presence of jack A depends on
>   gating_jack B.  Namely, if gating_jack B is unplugged, jack A is
>   treated as unplugged.
>
> - When a jack B has gated_jack = A: jack B doesn't give an unsol event
>   by itself, but it's triggered together with gated_jack A when jack A
>   is plugged/unplugged.  The plug status of jack B can be read from B
>   itself.
>
> For Chromebook, A (gated) is mic pin and B (gating) is HP pin.
> That is, a headset mic is detected only when the HP pin is detected.
>
>

The other possible usage of __snd_hda_jack_add_kctl() with different
sense_nid may be those asus N series notebook with ALC663 codec which seem
to use the hidden pin sense of node 0x1e of Digital Out pin for the
external Sonic Master Subwoofer

it just add subwoofer jack kctl at subwoofer node but use the hidden jack
sense of node 0x1e,  while driver still create SPDIF phantom jack

What is missing is the timer queue to check the jack state similar to vt1708

https://bugs.freedesktop.org/show_bug.cgi?id=91568#c11

WITHOUT subwoofer:
sudo ./hdajacksensetest -a
Pin 0x11 (Not connected): present = No
Pin 0x12 (Not connected): present = No
Pin 0x13 (Not connected): present = No
Pin 0x14 (Internal Speaker, ATAPI): present = No
Pin 0x15 (Not connected): present = No
Pin 0x16 (Internal Speaker, ATAPI): present = No
Pin 0x17 (Not connected): present = No
Pin 0x18 (Pink Mic, Rear side): present = No
Pin 0x19 (Internal Mic, ATAPI): present = No
Pin 0x1a (Not connected): present = No
Pin 0x1b (Not connected): present = No
Pin 0x1d (Not connected): present = No
Pin 0x1e (Black SPDIF Out, Right side): present = No
Pin 0x21 (Green Headphone, Rear side): present = No

WITH subwoofer:
sudo ./hdajacksensetest -a
Pin 0x11 (Not connected): present = No
Pin 0x12 (Not connected): present = No
Pin 0x13 (Not connected): present = No
Pin 0x14 (Internal Speaker, ATAPI): present = No
Pin 0x15 (Not connected): present = No
Pin 0x16 (Internal Speaker, ATAPI): present = No
Pin 0x17 (Not connected): present = No
Pin 0x18 (Pink Mic, Rear side): present = No
Pin 0x19 (Internal Mic, ATAPI): present = No
Pin 0x1a (Not connected): present = No
Pin 0x1b (Not connected): present = No
Pin 0x1d (Not connected): present = No
Pin 0x1e (Black SPDIF Out, Right side): present = Yes
Pin 0x21 (Green Headphone, Rear side): present = No
Arthur Borsboom Oct. 4, 2015, 2:53 p.m. UTC | #5
Hi Raymond,

Do you need any testing from my side to be able to finish the developing?

On 25 September 2015 at 06:06, Raymond Yau <superquad.vortex2@gmail.com>
wrote:

>
> > >
> > > > >
> > > > > - add sense_nid to __snd_hda_jack_add_kctl for pin sense
> > > > >
> > > > > - update slave pin sense when master pin sense change
> > > > >
> > > > > - enable unsolicited event when widcap support UNSOL
> > > >
> > > > Again, please describe at first the reason you need this change.
> Then
> > > > start explaining about the implementation details.  For example,
> > > > what's the difference from the existing gated_jack.
> > > >
> > > >
> > >
> > > I don't understand how gated jack work, but those headset mic in alc668
> > > dell-headset-multi does not  use its own pin sense and won't need to
> enable
> > > unsol event of the headset mic node.
> > >
> > > As pulseaudio don't expect jack kctl can be repesent the state of
> headphone
> > > and mic
> > >
> > > This force the driver to create a headset mic kctl which is just a
> copy of
> > > the headphone jack kctl
> >
> > See what you wrote now in the above?  It's a nice introduction of the
> > things you're trying to solve.  This kind of information is exactly
> > what I asked for.  Please rephrase and put it in the changelog at the
> > next time.
> >
> > About gated_jack: this was introduced for Chromebook for a headset.
> > This should work similarly like your case.  The behavior of gated /
> > gating jacks are:
> >
> > - When a jack A has gating_jack = B: the presence of jack A depends on
> >   gating_jack B.  Namely, if gating_jack B is unplugged, jack A is
> >   treated as unplugged.
> >
> > - When a jack B has gated_jack = A: jack B doesn't give an unsol event
> >   by itself, but it's triggered together with gated_jack A when jack A
> >   is plugged/unplugged.  The plug status of jack B can be read from B
> >   itself.
> >
> > For Chromebook, A (gated) is mic pin and B (gating) is HP pin.
> > That is, a headset mic is detected only when the HP pin is detected.
> >
> >
>
> The other possible usage of __snd_hda_jack_add_kctl() with different
> sense_nid may be those asus N series notebook with ALC663 codec which seem
> to use the hidden pin sense of node 0x1e of Digital Out pin for the
> external Sonic Master Subwoofer
>
> it just add subwoofer jack kctl at subwoofer node but use the hidden jack
> sense of node 0x1e,  while driver still create SPDIF phantom jack
>
> What is missing is the timer queue to check the jack state similar to
> vt1708
>
> https://bugs.freedesktop.org/show_bug.cgi?id=91568#c11
>
> WITHOUT subwoofer:
> sudo ./hdajacksensetest -a
> Pin 0x11 (Not connected): present = No
> Pin 0x12 (Not connected): present = No
> Pin 0x13 (Not connected): present = No
> Pin 0x14 (Internal Speaker, ATAPI): present = No
> Pin 0x15 (Not connected): present = No
> Pin 0x16 (Internal Speaker, ATAPI): present = No
> Pin 0x17 (Not connected): present = No
> Pin 0x18 (Pink Mic, Rear side): present = No
> Pin 0x19 (Internal Mic, ATAPI): present = No
> Pin 0x1a (Not connected): present = No
> Pin 0x1b (Not connected): present = No
> Pin 0x1d (Not connected): present = No
> Pin 0x1e (Black SPDIF Out, Right side): present = No
> Pin 0x21 (Green Headphone, Rear side): present = No
>
> WITH subwoofer:
> sudo ./hdajacksensetest -a
> Pin 0x11 (Not connected): present = No
> Pin 0x12 (Not connected): present = No
> Pin 0x13 (Not connected): present = No
> Pin 0x14 (Internal Speaker, ATAPI): present = No
> Pin 0x15 (Not connected): present = No
> Pin 0x16 (Internal Speaker, ATAPI): present = No
> Pin 0x17 (Not connected): present = No
> Pin 0x18 (Pink Mic, Rear side): present = No
> Pin 0x19 (Internal Mic, ATAPI): present = No
> Pin 0x1a (Not connected): present = No
> Pin 0x1b (Not connected): present = No
> Pin 0x1d (Not connected): present = No
> Pin 0x1e (Black SPDIF Out, Right side): present = Yes
> Pin 0x21 (Green Headphone, Rear side): present = No
>
Raymond Yau Oct. 5, 2015, 4:51 a.m. UTC | #6
>
> Do you need any testing from my side to be able to finish the developing?
>

https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1451170/comments/22

It seem that asus n550lf which also use alc668 codec but headset mic pin
node 0x1b is detectable

Can you confirm that your headset mic node is not detectable by
hdajacksensetest ?

This mean that the model "headset-sonicmaster" will be quite confusing when
asus notebooks have different ways of headset implementation
Arthur Borsboom Oct. 6, 2015, 8:22 a.m. UTC | #7
Asus N751JK - ALC668 - hdajacksenseresults:

-----

Nothing plugged in:

Pin 0x12 (Internal Mic): present = No
Pin 0x14 (Internal Speaker): present = No
Pin 0x15 (Black Headphone, Left side): present = No
Pin 0x16 (Not connected): present = No
Pin 0x18 (Not connected): present = No
Pin 0x19 (Pink Mic, Left side): present = No
Pin 0x1a (Internal Speaker): present = No
Pin 0x1b (Black Mic, Left side): present = No
Pin 0x1d (Not connected): present = No
Pin 0x1e (Not connected): present = No
Pin 0x1f (Not connected): present = No

---

Only headset plugged in:

Pin 0x12 (Internal Mic): present = No
Pin 0x14 (Internal Speaker): present = No
Pin 0x15 (Black Headphone, Left side): present = Yes
Pin 0x16 (Not connected): present = No
Pin 0x18 (Not connected): present = No
Pin 0x19 (Pink Mic, Left side): present = No
Pin 0x1a (Internal Speaker): present = No
Pin 0x1b (Black Mic, Left side): present = No
Pin 0x1d (Not connected): present = No
Pin 0x1e (Not connected): present = No
Pin 0x1f (Not connected): present = No

---

Only headphones plugged in:

Pin 0x12 (Internal Mic): present = No
Pin 0x14 (Internal Speaker): present = No
Pin 0x15 (Black Headphone, Left side): present = Yes
Pin 0x16 (Not connected): present = No
Pin 0x18 (Not connected): present = No
Pin 0x19 (Pink Mic, Left side): present = No
Pin 0x1a (Internal Speaker): present = No
Pin 0x1b (Black Mic, Left side): present = No
Pin 0x1d (Not connected): present = No
Pin 0x1e (Not connected): present = No
Pin 0x1f (Not connected): present = No

---

Only microphone plugged in:

Pin 0x12 (Internal Mic): present = No
Pin 0x14 (Internal Speaker): present = No
Pin 0x15 (Black Headphone, Left side): present = Yes
Pin 0x16 (Not connected): present = No
Pin 0x18 (Not connected): present = No
Pin 0x19 (Pink Mic, Left side): present = No
Pin 0x1a (Internal Speaker): present = No
Pin 0x1b (Black Mic, Left side): present = No
Pin 0x1d (Not connected): present = No
Pin 0x1e (Not connected): present = No
Pin 0x1f (Not connected): present = No

---

Only subwoofer plugged in:

Pin 0x12 (Internal Mic): present = No
Pin 0x14 (Internal Speaker): present = No
Pin 0x15 (Black Headphone, Left side): present = No
Pin 0x16 (Not connected): present = No
Pin 0x18 (Not connected): present = No
Pin 0x19 (Pink Mic, Left side): present = No
Pin 0x1a (Internal Speaker): present = Yes
Pin 0x1b (Black Mic, Left side): present = No
Pin 0x1d (Not connected): present = No
Pin 0x1e (Not connected): present = No
Pin 0x1f (Not connected): present = No

Note that I have used hdajackretask to assing pin 0x1a -> LFE, apparently
resulting in jack detection for the subwoofer.

On 5 October 2015 at 06:51, Raymond Yau <superquad.vortex2@gmail.com> wrote:

>
> >
> > Do you need any testing from my side to be able to finish the developing?
> >
>
>
> https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1451170/comments/22
>
> It seem that asus n550lf which also use alc668 codec but headset mic pin
> node 0x1b is detectable
>
> Can you confirm that your headset mic node is not detectable by
> hdajacksensetest ?
>
> This mean that the model "headset-sonicmaster" will be quite confusing
> when asus notebooks have different ways of headset implementation
>
Arthur Borsboom Oct. 10, 2015, 1:21 p.m. UTC | #8
Hi Raymond,

Do you need more testing on the Asus N751JK by me?
Do you need help from other developers?

On 6 October 2015 at 10:22, Arthur Borsboom <arthurborsboom@gmail.com>
wrote:

> Asus N751JK - ALC668 - hdajacksenseresults:
>
> -----
>
> Nothing plugged in:
>
> Pin 0x12 (Internal Mic): present = No
> Pin 0x14 (Internal Speaker): present = No
> Pin 0x15 (Black Headphone, Left side): present = No
> Pin 0x16 (Not connected): present = No
> Pin 0x18 (Not connected): present = No
> Pin 0x19 (Pink Mic, Left side): present = No
> Pin 0x1a (Internal Speaker): present = No
> Pin 0x1b (Black Mic, Left side): present = No
> Pin 0x1d (Not connected): present = No
> Pin 0x1e (Not connected): present = No
> Pin 0x1f (Not connected): present = No
>
> ---
>
> Only headset plugged in:
>
> Pin 0x12 (Internal Mic): present = No
> Pin 0x14 (Internal Speaker): present = No
> Pin 0x15 (Black Headphone, Left side): present = Yes
> Pin 0x16 (Not connected): present = No
> Pin 0x18 (Not connected): present = No
> Pin 0x19 (Pink Mic, Left side): present = No
> Pin 0x1a (Internal Speaker): present = No
> Pin 0x1b (Black Mic, Left side): present = No
> Pin 0x1d (Not connected): present = No
> Pin 0x1e (Not connected): present = No
> Pin 0x1f (Not connected): present = No
>
> ---
>
> Only headphones plugged in:
>
> Pin 0x12 (Internal Mic): present = No
> Pin 0x14 (Internal Speaker): present = No
> Pin 0x15 (Black Headphone, Left side): present = Yes
> Pin 0x16 (Not connected): present = No
> Pin 0x18 (Not connected): present = No
> Pin 0x19 (Pink Mic, Left side): present = No
> Pin 0x1a (Internal Speaker): present = No
> Pin 0x1b (Black Mic, Left side): present = No
> Pin 0x1d (Not connected): present = No
> Pin 0x1e (Not connected): present = No
> Pin 0x1f (Not connected): present = No
>
> ---
>
> Only microphone plugged in:
>
> Pin 0x12 (Internal Mic): present = No
> Pin 0x14 (Internal Speaker): present = No
> Pin 0x15 (Black Headphone, Left side): present = Yes
> Pin 0x16 (Not connected): present = No
> Pin 0x18 (Not connected): present = No
> Pin 0x19 (Pink Mic, Left side): present = No
> Pin 0x1a (Internal Speaker): present = No
> Pin 0x1b (Black Mic, Left side): present = No
> Pin 0x1d (Not connected): present = No
> Pin 0x1e (Not connected): present = No
> Pin 0x1f (Not connected): present = No
>
> ---
>
> Only subwoofer plugged in:
>
> Pin 0x12 (Internal Mic): present = No
> Pin 0x14 (Internal Speaker): present = No
> Pin 0x15 (Black Headphone, Left side): present = No
> Pin 0x16 (Not connected): present = No
> Pin 0x18 (Not connected): present = No
> Pin 0x19 (Pink Mic, Left side): present = No
> Pin 0x1a (Internal Speaker): present = Yes
> Pin 0x1b (Black Mic, Left side): present = No
> Pin 0x1d (Not connected): present = No
> Pin 0x1e (Not connected): present = No
> Pin 0x1f (Not connected): present = No
>
> Note that I have used hdajackretask to assing pin 0x1a -> LFE, apparently
> resulting in jack detection for the subwoofer.
>
> On 5 October 2015 at 06:51, Raymond Yau <superquad.vortex2@gmail.com>
> wrote:
>
>>
>> >
>> > Do you need any testing from my side to be able to finish the
>> developing?
>> >
>>
>>
>> https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1451170/comments/22
>>
>> It seem that asus n550lf which also use alc668 codec but headset mic pin
>> node 0x1b is detectable
>>
>> Can you confirm that your headset mic node is not detectable by
>> hdajacksensetest ?
>>
>> This mean that the model "headset-sonicmaster" will be quite confusing
>> when asus notebooks have different ways of headset implementation
>>
>
>
>
> --
> Arthur Borsboom
> Mob: +31629089953
> Email: arthurborsboom@gmail.com
> Skype: Arthur Borsboom, The Hague, The Netherlands
>
> [image: View Arthur's LinkedIn profile]
> <http://uk.linkedin.com/in/arthurborsboom>
>
Raymond Yau Oct. 13, 2015, 11:35 p.m. UTC | #9
>
> Do you need more testing on the Asus N751JK by me?
> Do you need help from other developers?

Do all speakers of quad speaker array work as expected ?

If ASUS N550LF can use headset by default, it is strange that your N750JK
need any modification for the headset mic pin since they are using same
codec ALC668 with similar BIOS pin default, quad speaker array and Sonic
Master Subwoofer

If you only test CTIA headset, it is better to name the model according to
what you have tested
Arthur Borsboom Oct. 14, 2015, 6:50 a.m. UTC | #10
I don't understand what you mean by quad speak array. Please keep in mind
that I am not a driver developer / sound guru.
The Asus N751JK laptop has two built-in speakers, 1 external base speaker
(with a yellow jack) and 1 combo jack for headset, headphones or microphone.

The headset I am using is a headset which I received with my LG phone.
The only thing written on it is: "LG" and "Made in Indonesia" :)

But let me rephrase what I currently do to make everything work
(workarounds) with the mainline kernel (4.2.2)

To enable the base speaker, I use hdajackretask and I assign unconnected
pin 0x1a to Internal Speaker (LFE).
To switch to the microphone of my headset after plugin, I open pavucontrol
and change from Internal Microphone to Headset Microphone (due to missing
jack detection).
To switch to the microphone of my laptop after unplug, I do the opposite. :)

Does this help?

On 14 October 2015 at 01:35, Raymond Yau <superquad.vortex2@gmail.com>
wrote:

> >
> > Do you need more testing on the Asus N751JK by me?
> > Do you need help from other developers?
>
> Do all speakers of quad speaker array work as expected ?
>
> If ASUS N550LF can use headset by default, it is strange that your N750JK
> need any modification for the headset mic pin since they are using same
> codec ALC668 with similar BIOS pin default, quad speaker array and Sonic
> Master Subwoofer
>
> If you only test CTIA headset, it is better to name the model according to
> what you have tested
>
Arthur Borsboom Oct. 28, 2015, 9:24 p.m. UTC | #11
Hi Raymond,

Just to refresh, for the Asus N751JK (ALC668) I currently make everything
work with the following workarounds (mainline kernel 4.2.4)

To enable the base speaker, I use hdajackretask and I assign unconnected
pin 0x1a to Internal Speaker (LFE).
To switch to the microphone of my headset after plugin, I open pavucontrol
and change from Internal Microphone to Headset Microphone (due to missing
jack detection).
To switch to the microphone of my laptop after unplug, I do the opposite. :)

If dealing with the microphone issue is too time consuming, would you mind
to at least offer the patch for the sub woofer to the Alsa mailinglist?

If necessary, I still have the patchset of 7 patches which worked on my
system.

On 14 October 2015 at 08:50, Arthur Borsboom <arthurborsboom@gmail.com>
wrote:

> I don't understand what you mean by quad speak array. Please keep in mind
> that I am not a driver developer / sound guru.
> The Asus N751JK laptop has two built-in speakers, 1 external base speaker
> (with a yellow jack) and 1 combo jack for headset, headphones or microphone.
>
> The headset I am using is a headset which I received with my LG phone.
> The only thing written on it is: "LG" and "Made in Indonesia" :)
>
> But let me rephrase what I currently do to make everything work
> (workarounds) with the mainline kernel (4.2.2)
>
> To enable the base speaker, I use hdajackretask and I assign unconnected
> pin 0x1a to Internal Speaker (LFE).
> To switch to the microphone of my headset after plugin, I open pavucontrol
> and change from Internal Microphone to Headset Microphone (due to missing
> jack detection).
> To switch to the microphone of my laptop after unplug, I do the opposite.
> :)
>
> Does this help?
>
> On 14 October 2015 at 01:35, Raymond Yau <superquad.vortex2@gmail.com>
> wrote:
>
>> >
>> > Do you need more testing on the Asus N751JK by me?
>> > Do you need help from other developers?
>>
>> Do all speakers of quad speaker array work as expected ?
>>
>> If ASUS N550LF can use headset by default, it is strange that your N750JK
>> need any modification for the headset mic pin since they are using same
>> codec ALC668 with similar BIOS pin default, quad speaker array and Sonic
>> Master Subwoofer
>>
>> If you only test CTIA headset, it is better to name the model according
>> to what you have tested
>>
>
>
>
> --
> Arthur Borsboom
> Mob: +31629089953
> Email: arthurborsboom@gmail.com
> Skype: Arthur Borsboom, The Hague, The Netherlands
>
> [image: View Arthur's LinkedIn profile]
> <http://uk.linkedin.com/in/arthurborsboom>
>

Patch
diff mbox

diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c
index 366efbf..d81d65f 100644
--- a/sound/pci/hda/hda_jack.c
+++ b/sound/pci/hda/hda_jack.c
@@ -19,6 +19,7 @@ 
 #include "hda_local.h"
 #include "hda_auto_parser.h"
 #include "hda_jack.h"
+#include "hda_generic.h"

 /**
  * is_jack_detectable - Check whether the given pin is jack-detectable
@@ -157,7 +158,14 @@  static void jack_detect_update(struct hda_codec *codec,
     if (jack->phantom_jack)
         jack->pin_sense = AC_PINSENSE_PRESENCE;
     else
-        jack->pin_sense = read_pin_sense(codec, jack->nid);
+        jack->pin_sense = read_pin_sense(codec,
+            jack->sense_nid ? jack->sense_nid : jack->nid);
+
+    if (jack->slave_nid) {
+        struct hda_jack_tbl *slave = snd_hda_jack_tbl_get(codec,
+                jack->slave_nid);
+        slave->pin_sense = jack->pin_sense;
+    }

     /* A gating jack indicates the jack is invalid if gating is unplugged
*/
     if (jack->gating_jack && !snd_hda_jack_detect(codec,
jack->gating_jack))
@@ -269,11 +277,13 @@  snd_hda_jack_detect_enable_callback(struct hda_codec
*codec, hda_nid_t nid,
     jack->jack_detect = 1;
     if (codec->jackpoll_interval > 0)
         return callback; /* No unsol if we're polling instead */
-    err = snd_hda_codec_write_cache(codec, nid, 0,
+    if (is_jack_detectable(codec, nid)) {
+        err = snd_hda_codec_write_cache(codec, nid, 0,
                      AC_VERB_SET_UNSOLICITED_ENABLE,
                      AC_USRSP_EN | jack->tag);
-    if (err < 0)
-        return ERR_PTR(err);
+        if (err < 0)
+            return ERR_PTR(err);
+    }
     return callback;
 }
 EXPORT_SYMBOL_GPL(snd_hda_jack_detect_enable_callback);
@@ -384,7 +394,7 @@  static void hda_free_jack_priv(struct snd_jack *jack)
  * will have the given name and index.
  */
 static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
-              const char *name, bool phantom_jack)
+          const char *name, bool phantom_jack, hda_nid_t sense_nid)
 {
     struct hda_jack_tbl *jack;
     int err, state, type;
@@ -403,6 +413,7 @@  static int __snd_hda_jack_add_kctl(struct hda_codec
*codec, hda_nid_t nid,

     jack->phantom_jack = !!phantom_jack;
     jack->type = type;
+    jack->sense_nid = sense_nid;
     jack->jack->private_data = jack;
     jack->jack->private_free = hda_free_jack_priv;
     state = snd_hda_jack_detect(codec, nid);
@@ -422,7 +433,7 @@  static int __snd_hda_jack_add_kctl(struct hda_codec
*codec, hda_nid_t nid,
 int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
               const char *name)
 {
-    return __snd_hda_jack_add_kctl(codec, nid, name, false);
+    return __snd_hda_jack_add_kctl(codec, nid, name, false, nid);
 }
 EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctl);

@@ -451,7 +462,7 @@  static int add_jack_kctl(struct hda_codec *codec,
hda_nid_t nid,
     if (phantom_jack)
         /* Example final name: "Internal Mic Phantom Jack" */
         strncat(name, " Phantom", sizeof(name) - strlen(name) - 1);
-    err = __snd_hda_jack_add_kctl(codec, nid, name, phantom_jack);
+    err = __snd_hda_jack_add_kctl(codec, nid, name, phantom_jack, nid);
     if (err < 0)
         return err;

diff --git a/sound/pci/hda/hda_jack.h b/sound/pci/hda/hda_jack.h
index 387d309..ef3d162 100644
--- a/sound/pci/hda/hda_jack.h
+++ b/sound/pci/hda/hda_jack.h
@@ -41,6 +41,8 @@  struct hda_jack_tbl {
     hda_nid_t gated_jack;        /* gated is dependent on this jack */
     int type;
     struct snd_jack *jack;
+    hda_nid_t sense_nid;
+    hda_nid_t slave_nid;
 };

 struct hda_jack_tbl *