All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: auto_mute for early patch issue
@ 2019-01-31  8:00 Kailang
  2019-01-31  8:23 ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Kailang @ 2019-01-31  8:00 UTC (permalink / raw)
  To: Takashi Iwai (tiwai@suse.de); +Cc:  (alsa-devel@alsa-project.org)

Hi Takashi,

I move check line to below. It will show value for hp_pins[0].
As I know, search from verb table in function snd_hda_parse_pin_defcfg().
It will fill pins at auto_pin_cfg.
Why it need to run below function to get cfg->hp_pins?

static int check_auto_mute_availability(struct hda_codec *codec)
{
	struct hda_gen_spec *spec = codec->spec;
	struct auto_pin_cfg *cfg = &spec->autocfg;
	int present = 0;
	int i, err;

-	if (spec->suppress_auto_mute)
-		return 0;

	if (cfg->hp_pins[0])
		present++;
	if (cfg->line_out_pins[0])
		present++;
	if (cfg->speaker_pins[0])
		present++;
	if (present < 2) /* need two different output types */
		return 0;

	if (!cfg->speaker_pins[0] &&
	    cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
		memcpy(cfg->speaker_pins, cfg->line_out_pins,
		       sizeof(cfg->speaker_pins));
		cfg->speaker_outs = cfg->line_outs;
	}

	if (!cfg->hp_pins[0] &&
	    cfg->line_out_type == AUTO_PIN_HP_OUT) {
		memcpy(cfg->hp_pins, cfg->line_out_pins,
		       sizeof(cfg->hp_pins));
		cfg->hp_outs = cfg->line_outs;
	}

+	if (spec->suppress_auto_mute)
+		return 0;

......
.....
......
}

BR,
Kailang

-----Original Message-----
From: Kailang 
Sent: Thursday, January 31, 2019 12:08 PM
To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
Subject: auto_mute for early patch issue

Hi Takashi,

Chrome OS use early patch firmware file to load model and use auto_mute =no hint options.
I find an issue for early patch issue about hint option auto_mute = no.

This will cause all spec->init_hook can't get hp_pin values.

For example: alc225_init() alc225_shutup() alc256_init() alc256_shutup() Early patch file hint auto_mute = no equal spec->suppress_auto_mute = 1 It will return function check_auto_mute_availability() in had_generic.c.

hp_pin = spec->gen.autocfg.hp_pins[0];  ==> It will get value 0.

I think this issue was for a long time.
Please see the attach dmesg. One is kill hint auto_mute option. 

BR,
Kailang

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: auto_mute for early patch issue
  2019-01-31  8:00 auto_mute for early patch issue Kailang
@ 2019-01-31  8:23 ` Takashi Iwai
  2019-01-31  8:33   ` Kailang
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Takashi Iwai @ 2019-01-31  8:23 UTC (permalink / raw)
  To: Kailang; +Cc:  (alsa-devel@alsa-project.org)

On Thu, 31 Jan 2019 09:00:36 +0100,
Kailang wrote:
> 
> Hi Takashi,
> 
> I move check line to below. It will show value for hp_pins[0].
> As I know, search from verb table in function snd_hda_parse_pin_defcfg().
> It will fill pins at auto_pin_cfg.
> Why it need to run below function to get cfg->hp_pins?

It's just because hp_pins[] and speaker_pins[] are used for the case
with the auto-mute, so far, not for other evaluations :)

The change below looks safe, so if this works for you, feel fee to
apply like that.


thanks,

Takashi


> static int check_auto_mute_availability(struct hda_codec *codec)
> {
> 	struct hda_gen_spec *spec = codec->spec;
> 	struct auto_pin_cfg *cfg = &spec->autocfg;
> 	int present = 0;
> 	int i, err;
> 
> -	if (spec->suppress_auto_mute)
> -		return 0;
> 
> 	if (cfg->hp_pins[0])
> 		present++;
> 	if (cfg->line_out_pins[0])
> 		present++;
> 	if (cfg->speaker_pins[0])
> 		present++;
> 	if (present < 2) /* need two different output types */
> 		return 0;
> 
> 	if (!cfg->speaker_pins[0] &&
> 	    cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
> 		memcpy(cfg->speaker_pins, cfg->line_out_pins,
> 		       sizeof(cfg->speaker_pins));
> 		cfg->speaker_outs = cfg->line_outs;
> 	}
> 
> 	if (!cfg->hp_pins[0] &&
> 	    cfg->line_out_type == AUTO_PIN_HP_OUT) {
> 		memcpy(cfg->hp_pins, cfg->line_out_pins,
> 		       sizeof(cfg->hp_pins));
> 		cfg->hp_outs = cfg->line_outs;
> 	}
> 
> +	if (spec->suppress_auto_mute)
> +		return 0;
> 
> ......
> .....
> ......
> }
> 
> BR,
> Kailang
> 
> -----Original Message-----
> From: Kailang 
> Sent: Thursday, January 31, 2019 12:08 PM
> To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: auto_mute for early patch issue
> 
> Hi Takashi,
> 
> Chrome OS use early patch firmware file to load model and use auto_mute =no hint options.
> I find an issue for early patch issue about hint option auto_mute = no.
> 
> This will cause all spec->init_hook can't get hp_pin values.
> 
> For example: alc225_init() alc225_shutup() alc256_init() alc256_shutup() Early patch file hint auto_mute = no equal spec->suppress_auto_mute = 1 It will return function check_auto_mute_availability() in had_generic.c.
> 
> hp_pin = spec->gen.autocfg.hp_pins[0];  ==> It will get value 0.
> 
> I think this issue was for a long time.
> Please see the attach dmesg. One is kill hint auto_mute option. 
> 
> BR,
> Kailang
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: auto_mute for early patch issue
  2019-01-31  8:23 ` Takashi Iwai
@ 2019-01-31  8:33   ` Kailang
  2019-01-31  9:28   ` Kailang
  2019-01-31 10:50   ` Kailang
  2 siblings, 0 replies; 10+ messages in thread
From: Kailang @ 2019-01-31  8:33 UTC (permalink / raw)
  To: Takashi Iwai; +Cc:  (alsa-devel@alsa-project.org)

OK!
I go to generate patch now.

Thanks.

-----Original Message-----
From: Takashi Iwai <tiwai@suse.de> 
Sent: Thursday, January 31, 2019 4:23 PM
To: Kailang <kailang@realtek.com>
Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
Subject: Re: auto_mute for early patch issue

On Thu, 31 Jan 2019 09:00:36 +0100,
Kailang wrote:
> 
> Hi Takashi,
> 
> I move check line to below. It will show value for hp_pins[0].
> As I know, search from verb table in function snd_hda_parse_pin_defcfg().
> It will fill pins at auto_pin_cfg.
> Why it need to run below function to get cfg->hp_pins?

It's just because hp_pins[] and speaker_pins[] are used for the case with the auto-mute, so far, not for other evaluations :)

The change below looks safe, so if this works for you, feel fee to apply like that.


thanks,

Takashi


> static int check_auto_mute_availability(struct hda_codec *codec) {
> 	struct hda_gen_spec *spec = codec->spec;
> 	struct auto_pin_cfg *cfg = &spec->autocfg;
> 	int present = 0;
> 	int i, err;
> 
> -	if (spec->suppress_auto_mute)
> -		return 0;
> 
> 	if (cfg->hp_pins[0])
> 		present++;
> 	if (cfg->line_out_pins[0])
> 		present++;
> 	if (cfg->speaker_pins[0])
> 		present++;
> 	if (present < 2) /* need two different output types */
> 		return 0;
> 
> 	if (!cfg->speaker_pins[0] &&
> 	    cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
> 		memcpy(cfg->speaker_pins, cfg->line_out_pins,
> 		       sizeof(cfg->speaker_pins));
> 		cfg->speaker_outs = cfg->line_outs;
> 	}
> 
> 	if (!cfg->hp_pins[0] &&
> 	    cfg->line_out_type == AUTO_PIN_HP_OUT) {
> 		memcpy(cfg->hp_pins, cfg->line_out_pins,
> 		       sizeof(cfg->hp_pins));
> 		cfg->hp_outs = cfg->line_outs;
> 	}
> 
> +	if (spec->suppress_auto_mute)
> +		return 0;
> 
> ......
> .....
> ......
> }
> 
> BR,
> Kailang
> 
> -----Original Message-----
> From: Kailang
> Sent: Thursday, January 31, 2019 12:08 PM
> To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: auto_mute for early patch issue
> 
> Hi Takashi,
> 
> Chrome OS use early patch firmware file to load model and use auto_mute =no hint options.
> I find an issue for early patch issue about hint option auto_mute = no.
> 
> This will cause all spec->init_hook can't get hp_pin values.
> 
> For example: alc225_init() alc225_shutup() alc256_init() alc256_shutup() Early patch file hint auto_mute = no equal spec->suppress_auto_mute = 1 It will return function check_auto_mute_availability() in had_generic.c.
> 
> hp_pin = spec->gen.autocfg.hp_pins[0];  ==> It will get value 0.
> 
> I think this issue was for a long time.
> Please see the attach dmesg. One is kill hint auto_mute option. 
> 
> BR,
> Kailang
> 

------Please consider the environment before printing this e-mail.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: auto_mute for early patch issue
  2019-01-31  8:23 ` Takashi Iwai
  2019-01-31  8:33   ` Kailang
@ 2019-01-31  9:28   ` Kailang
  2019-01-31 10:50   ` Kailang
  2 siblings, 0 replies; 10+ messages in thread
From: Kailang @ 2019-01-31  9:28 UTC (permalink / raw)
  To: Takashi Iwai; +Cc:  (alsa-devel@alsa-project.org)

Hi Takashi,

spec->suppress_auto_mute = 1;
This will cause spec->gen.autocfg.hp_pins [0] = 0.
This will cause alc2??_init() and alc2??_shutup() and dell headset mode not run errors.

Do it has other place to store pin NID? 
Or just only this place hp_pin = spec->gen.autocfg.hp_pins[0]; to get headphone NID.

BR,
Kailang

-----Original Message-----
From: Takashi Iwai <tiwai@suse.de> 
Sent: Thursday, January 31, 2019 4:23 PM
To: Kailang <kailang@realtek.com>
Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
Subject: Re: auto_mute for early patch issue

On Thu, 31 Jan 2019 09:00:36 +0100,
Kailang wrote:
> 
> Hi Takashi,
> 
> I move check line to below. It will show value for hp_pins[0].
> As I know, search from verb table in function snd_hda_parse_pin_defcfg().
> It will fill pins at auto_pin_cfg.
> Why it need to run below function to get cfg->hp_pins?

It's just because hp_pins[] and speaker_pins[] are used for the case with the auto-mute, so far, not for other evaluations :)

The change below looks safe, so if this works for you, feel fee to apply like that.


thanks,

Takashi


> static int check_auto_mute_availability(struct hda_codec *codec) {
> 	struct hda_gen_spec *spec = codec->spec;
> 	struct auto_pin_cfg *cfg = &spec->autocfg;
> 	int present = 0;
> 	int i, err;
> 
> -	if (spec->suppress_auto_mute)
> -		return 0;
> 
> 	if (cfg->hp_pins[0])
> 		present++;
> 	if (cfg->line_out_pins[0])
> 		present++;
> 	if (cfg->speaker_pins[0])
> 		present++;
> 	if (present < 2) /* need two different output types */
> 		return 0;
> 
> 	if (!cfg->speaker_pins[0] &&
> 	    cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
> 		memcpy(cfg->speaker_pins, cfg->line_out_pins,
> 		       sizeof(cfg->speaker_pins));
> 		cfg->speaker_outs = cfg->line_outs;
> 	}
> 
> 	if (!cfg->hp_pins[0] &&
> 	    cfg->line_out_type == AUTO_PIN_HP_OUT) {
> 		memcpy(cfg->hp_pins, cfg->line_out_pins,
> 		       sizeof(cfg->hp_pins));
> 		cfg->hp_outs = cfg->line_outs;
> 	}
> 
> +	if (spec->suppress_auto_mute)
> +		return 0;
> 
> ......
> .....
> ......
> }
> 
> BR,
> Kailang
> 
> -----Original Message-----
> From: Kailang
> Sent: Thursday, January 31, 2019 12:08 PM
> To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: auto_mute for early patch issue
> 
> Hi Takashi,
> 
> Chrome OS use early patch firmware file to load model and use auto_mute =no hint options.
> I find an issue for early patch issue about hint option auto_mute = no.
> 
> This will cause all spec->init_hook can't get hp_pin values.
> 
> For example: alc225_init() alc225_shutup() alc256_init() alc256_shutup() Early patch file hint auto_mute = no equal spec->suppress_auto_mute = 1 It will return function check_auto_mute_availability() in had_generic.c.
> 
> hp_pin = spec->gen.autocfg.hp_pins[0];  ==> It will get value 0.
> 
> I think this issue was for a long time.
> Please see the attach dmesg. One is kill hint auto_mute option. 
> 
> BR,
> Kailang
> 

------Please consider the environment before printing this e-mail.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: auto_mute for early patch issue
  2019-01-31  8:23 ` Takashi Iwai
  2019-01-31  8:33   ` Kailang
  2019-01-31  9:28   ` Kailang
@ 2019-01-31 10:50   ` Kailang
  2019-01-31 11:02     ` Takashi Iwai
  2 siblings, 1 reply; 10+ messages in thread
From: Kailang @ 2019-01-31 10:50 UTC (permalink / raw)
  To: Takashi Iwai; +Cc:  (alsa-devel@alsa-project.org)

Hi Takashi,

spec->suppress_auto_mute = 1;
This will cause spec->gen.autocfg.hp_pins [0] = 0.
This will cause alc2??_init() and alc2??_shutup() and dell headset mode not run errors.

Does it has other place to store pin NID? 
Or just only this place hp_pin = spec->gen.autocfg.hp_pins[0]; to get headphone NID.

BR,
Kailang

-----Original Message-----
From: Takashi Iwai <tiwai@suse.de> 
Sent: Thursday, January 31, 2019 4:23 PM
To: Kailang <kailang@realtek.com>
Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
Subject: Re: auto_mute for early patch issue

On Thu, 31 Jan 2019 09:00:36 +0100,
Kailang wrote:
> 
> Hi Takashi,
> 
> I move check line to below. It will show value for hp_pins[0].
> As I know, search from verb table in function snd_hda_parse_pin_defcfg().
> It will fill pins at auto_pin_cfg.
> Why it need to run below function to get cfg->hp_pins?

It's just because hp_pins[] and speaker_pins[] are used for the case with the auto-mute, so far, not for other evaluations :)

The change below looks safe, so if this works for you, feel fee to apply like that.


thanks,

Takashi


> static int check_auto_mute_availability(struct hda_codec *codec) {
> 	struct hda_gen_spec *spec = codec->spec;
> 	struct auto_pin_cfg *cfg = &spec->autocfg;
> 	int present = 0;
> 	int i, err;
> 
> -	if (spec->suppress_auto_mute)
> -		return 0;
> 
> 	if (cfg->hp_pins[0])
> 		present++;
> 	if (cfg->line_out_pins[0])
> 		present++;
> 	if (cfg->speaker_pins[0])
> 		present++;
> 	if (present < 2) /* need two different output types */
> 		return 0;
> 
> 	if (!cfg->speaker_pins[0] &&
> 	    cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
> 		memcpy(cfg->speaker_pins, cfg->line_out_pins,
> 		       sizeof(cfg->speaker_pins));
> 		cfg->speaker_outs = cfg->line_outs;
> 	}
> 
> 	if (!cfg->hp_pins[0] &&
> 	    cfg->line_out_type == AUTO_PIN_HP_OUT) {
> 		memcpy(cfg->hp_pins, cfg->line_out_pins,
> 		       sizeof(cfg->hp_pins));
> 		cfg->hp_outs = cfg->line_outs;
> 	}
> 
> +	if (spec->suppress_auto_mute)
> +		return 0;
> 
> ......
> .....
> ......
> }
> 
> BR,
> Kailang
> 
> -----Original Message-----
> From: Kailang
> Sent: Thursday, January 31, 2019 12:08 PM
> To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: auto_mute for early patch issue
> 
> Hi Takashi,
> 
> Chrome OS use early patch firmware file to load model and use auto_mute =no hint options.
> I find an issue for early patch issue about hint option auto_mute = no.
> 
> This will cause all spec->init_hook can't get hp_pin values.
> 
> For example: alc225_init() alc225_shutup() alc256_init() alc256_shutup() Early patch file hint auto_mute = no equal spec->suppress_auto_mute = 1 It will return function check_auto_mute_availability() in had_generic.c.
> 
> hp_pin = spec->gen.autocfg.hp_pins[0];  ==> It will get value 0.
> 
> I think this issue was for a long time.
> Please see the attach dmesg. One is kill hint auto_mute option. 
> 
> BR,
> Kailang
> 

------Please consider the environment before printing this e-mail.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: auto_mute for early patch issue
  2019-01-31 10:50   ` Kailang
@ 2019-01-31 11:02     ` Takashi Iwai
  2019-02-01  9:18       ` Kailang
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2019-01-31 11:02 UTC (permalink / raw)
  To: Kailang; +Cc:  (alsa-devel@alsa-project.org)

On Thu, 31 Jan 2019 11:50:26 +0100,
Kailang wrote:
> 
> Hi Takashi,
> 
> spec->suppress_auto_mute = 1;
> This will cause spec->gen.autocfg.hp_pins [0] = 0.
> This will cause alc2??_init() and alc2??_shutup() and dell headset mode not run errors.

That's the result with your suggested change (moving
spec->supress_auto_mute_mode in check_auto_mute_availability()) ??


Takashi

> 
> Does it has other place to store pin NID? 
> Or just only this place hp_pin = spec->gen.autocfg.hp_pins[0]; to get headphone NID.
> 
> BR,
> Kailang
> 
> -----Original Message-----
> From: Takashi Iwai <tiwai@suse.de> 
> Sent: Thursday, January 31, 2019 4:23 PM
> To: Kailang <kailang@realtek.com>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: Re: auto_mute for early patch issue
> 
> On Thu, 31 Jan 2019 09:00:36 +0100,
> Kailang wrote:
> > 
> > Hi Takashi,
> > 
> > I move check line to below. It will show value for hp_pins[0].
> > As I know, search from verb table in function snd_hda_parse_pin_defcfg().
> > It will fill pins at auto_pin_cfg.
> > Why it need to run below function to get cfg->hp_pins?
> 
> It's just because hp_pins[] and speaker_pins[] are used for the case with the auto-mute, so far, not for other evaluations :)
> 
> The change below looks safe, so if this works for you, feel fee to apply like that.
> 
> 
> thanks,
> 
> Takashi
> 
> 
> > static int check_auto_mute_availability(struct hda_codec *codec) {
> > 	struct hda_gen_spec *spec = codec->spec;
> > 	struct auto_pin_cfg *cfg = &spec->autocfg;
> > 	int present = 0;
> > 	int i, err;
> > 
> > -	if (spec->suppress_auto_mute)
> > -		return 0;
> > 
> > 	if (cfg->hp_pins[0])
> > 		present++;
> > 	if (cfg->line_out_pins[0])
> > 		present++;
> > 	if (cfg->speaker_pins[0])
> > 		present++;
> > 	if (present < 2) /* need two different output types */
> > 		return 0;
> > 
> > 	if (!cfg->speaker_pins[0] &&
> > 	    cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
> > 		memcpy(cfg->speaker_pins, cfg->line_out_pins,
> > 		       sizeof(cfg->speaker_pins));
> > 		cfg->speaker_outs = cfg->line_outs;
> > 	}
> > 
> > 	if (!cfg->hp_pins[0] &&
> > 	    cfg->line_out_type == AUTO_PIN_HP_OUT) {
> > 		memcpy(cfg->hp_pins, cfg->line_out_pins,
> > 		       sizeof(cfg->hp_pins));
> > 		cfg->hp_outs = cfg->line_outs;
> > 	}
> > 
> > +	if (spec->suppress_auto_mute)
> > +		return 0;
> > 
> > ......
> > .....
> > ......
> > }
> > 
> > BR,
> > Kailang
> > 
> > -----Original Message-----
> > From: Kailang
> > Sent: Thursday, January 31, 2019 12:08 PM
> > To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > Subject: auto_mute for early patch issue
> > 
> > Hi Takashi,
> > 
> > Chrome OS use early patch firmware file to load model and use auto_mute =no hint options.
> > I find an issue for early patch issue about hint option auto_mute = no.
> > 
> > This will cause all spec->init_hook can't get hp_pin values.
> > 
> > For example: alc225_init() alc225_shutup() alc256_init() alc256_shutup() Early patch file hint auto_mute = no equal spec->suppress_auto_mute = 1 It will return function check_auto_mute_availability() in had_generic.c.
> > 
> > hp_pin = spec->gen.autocfg.hp_pins[0];  ==> It will get value 0.
> > 
> > I think this issue was for a long time.
> > Please see the attach dmesg. One is kill hint auto_mute option. 
> > 
> > BR,
> > Kailang
> > 
> 
> ------Please consider the environment before printing this e-mail.
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: auto_mute for early patch issue
  2019-01-31 11:02     ` Takashi Iwai
@ 2019-02-01  9:18       ` Kailang
  2019-02-01  9:33         ` Takashi Iwai
       [not found]         ` <6FAB7C47BCF00940BB0999A99BE3547A18DB88B0@RTITMBSVM07.realtek.com.tw>
  0 siblings, 2 replies; 10+ messages in thread
From: Kailang @ 2019-02-01  9:18 UTC (permalink / raw)
  To: Takashi Iwai; +Cc:  (alsa-devel@alsa-project.org)

[-- Attachment #1: Type: text/plain, Size: 4073 bytes --]

Hi Takashi,

I forgot it solved this issue for ALC283 before. It was also chrome OS case.
I cooked attach patch. It will not need to move spec->suppress_auto_mute check line.
Many thanks.

BR,
Kailang

-----Original Message-----
From: Takashi Iwai <tiwai@suse.de> 
Sent: Thursday, January 31, 2019 7:02 PM
To: Kailang <kailang@realtek.com>
Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
Subject: Re: auto_mute for early patch issue

On Thu, 31 Jan 2019 11:50:26 +0100,
Kailang wrote:
> 
> Hi Takashi,
> 
> spec->suppress_auto_mute = 1;
> This will cause spec->gen.autocfg.hp_pins [0] = 0.
> This will cause alc2??_init() and alc2??_shutup() and dell headset mode not run errors.

That's the result with your suggested change (moving
spec->supress_auto_mute_mode in check_auto_mute_availability()) ??


Takashi

> 
> Does it has other place to store pin NID? 
> Or just only this place hp_pin = spec->gen.autocfg.hp_pins[0]; to get headphone NID.
> 
> BR,
> Kailang
> 
> -----Original Message-----
> From: Takashi Iwai <tiwai@suse.de> 
> Sent: Thursday, January 31, 2019 4:23 PM
> To: Kailang <kailang@realtek.com>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: Re: auto_mute for early patch issue
> 
> On Thu, 31 Jan 2019 09:00:36 +0100,
> Kailang wrote:
> > 
> > Hi Takashi,
> > 
> > I move check line to below. It will show value for hp_pins[0].
> > As I know, search from verb table in function snd_hda_parse_pin_defcfg().
> > It will fill pins at auto_pin_cfg.
> > Why it need to run below function to get cfg->hp_pins?
> 
> It's just because hp_pins[] and speaker_pins[] are used for the case with the auto-mute, so far, not for other evaluations :)
> 
> The change below looks safe, so if this works for you, feel fee to apply like that.
> 
> 
> thanks,
> 
> Takashi
> 
> 
> > static int check_auto_mute_availability(struct hda_codec *codec) {
> > 	struct hda_gen_spec *spec = codec->spec;
> > 	struct auto_pin_cfg *cfg = &spec->autocfg;
> > 	int present = 0;
> > 	int i, err;
> > 
> > -	if (spec->suppress_auto_mute)
> > -		return 0;
> > 
> > 	if (cfg->hp_pins[0])
> > 		present++;
> > 	if (cfg->line_out_pins[0])
> > 		present++;
> > 	if (cfg->speaker_pins[0])
> > 		present++;
> > 	if (present < 2) /* need two different output types */
> > 		return 0;
> > 
> > 	if (!cfg->speaker_pins[0] &&
> > 	    cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
> > 		memcpy(cfg->speaker_pins, cfg->line_out_pins,
> > 		       sizeof(cfg->speaker_pins));
> > 		cfg->speaker_outs = cfg->line_outs;
> > 	}
> > 
> > 	if (!cfg->hp_pins[0] &&
> > 	    cfg->line_out_type == AUTO_PIN_HP_OUT) {
> > 		memcpy(cfg->hp_pins, cfg->line_out_pins,
> > 		       sizeof(cfg->hp_pins));
> > 		cfg->hp_outs = cfg->line_outs;
> > 	}
> > 
> > +	if (spec->suppress_auto_mute)
> > +		return 0;
> > 
> > ......
> > .....
> > ......
> > }
> > 
> > BR,
> > Kailang
> > 
> > -----Original Message-----
> > From: Kailang
> > Sent: Thursday, January 31, 2019 12:08 PM
> > To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > Subject: auto_mute for early patch issue
> > 
> > Hi Takashi,
> > 
> > Chrome OS use early patch firmware file to load model and use auto_mute =no hint options.
> > I find an issue for early patch issue about hint option auto_mute = no.
> > 
> > This will cause all spec->init_hook can't get hp_pin values.
> > 
> > For example: alc225_init() alc225_shutup() alc256_init() alc256_shutup() Early patch file hint auto_mute = no equal spec->suppress_auto_mute = 1 It will return function check_auto_mute_availability() in had_generic.c.
> > 
> > hp_pin = spec->gen.autocfg.hp_pins[0];  ==> It will get value 0.
> > 
> > I think this issue was for a long time.
> > Please see the attach dmesg. One is kill hint auto_mute option. 
> > 
> > BR,
> > Kailang
> > 
> 
> ------Please consider the environment before printing this e-mail.
> 

[-- Attachment #2: 0000-fix-lose-hp-pins.patch --]
[-- Type: application/octet-stream, Size: 3960 bytes --]

From 2bfa88a66ca132ccfaebc17efb6c647b2d5c6292 Mon Sep 17 00:00:00 2001
From: Kailang Yang <kailang@realtek.com>
Date: Fri, 1 Feb 2019 16:51:10 +0800
Subject: [PATCH] ALSA: hda/realtek - Fix lose hp_pins for disable auto mute

When auto_mute = no or spec->suppress_auto_mute = 1, cfg->hp_pins will lose value.
Add this patch to find hp_pins value.
I add fixed for ALC282 ALC225 ALC256 ALC294 and alc_default_init() alc_default_shutup().

Signed-off-by: Kailang Yang <kailang@realtek.com>

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index e9dc940..74864e6 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2963,6 +2963,11 @@ static void alc282_init(struct hda_codec *codec)
 	bool hp_pin_sense;
 	int coef78;
 
+	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
+		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+			hp_pin = spec->gen.autocfg.line_out_pins[0];
+	}
+
 	alc282_restore_default_value(codec);
 
 	if (!hp_pin)
@@ -3000,6 +3005,11 @@ static void alc282_shutup(struct hda_codec *codec)
 	bool hp_pin_sense;
 	int coef78;
 
+	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
+		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+			hp_pin = spec->gen.autocfg.line_out_pins[0];
+	}
+
 	if (!hp_pin) {
 		alc269_shutup(codec);
 		return;
@@ -3159,6 +3169,11 @@ static void alc256_init(struct hda_codec *codec)
 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
 	bool hp_pin_sense;
 
+	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
+		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+			hp_pin = spec->gen.autocfg.line_out_pins[0];
+	}
+
 	if (!hp_pin)
 		return;
 
@@ -3195,6 +3210,11 @@ static void alc256_shutup(struct hda_codec *codec)
 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
 	bool hp_pin_sense;
 
+	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
+		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+			hp_pin = spec->gen.autocfg.line_out_pins[0];
+	}
+
 	if (!hp_pin) {
 		alc269_shutup(codec);
 		return;
@@ -3231,6 +3251,11 @@ static void alc225_init(struct hda_codec *codec)
 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
 	bool hp1_pin_sense, hp2_pin_sense;
 
+	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
+		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+			hp_pin = spec->gen.autocfg.line_out_pins[0];
+	}
+
 	if (!hp_pin)
 		return;
 
@@ -3274,6 +3299,11 @@ static void alc225_shutup(struct hda_codec *codec)
 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
 	bool hp1_pin_sense, hp2_pin_sense;
 
+	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
+		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+			hp_pin = spec->gen.autocfg.line_out_pins[0];
+	}
+
 	if (!hp_pin) {
 		alc269_shutup(codec);
 		return;
@@ -3318,6 +3348,11 @@ static void alc_default_init(struct hda_codec *codec)
 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
 	bool hp_pin_sense;
 
+	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
+		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+			hp_pin = spec->gen.autocfg.line_out_pins[0];
+	}
+
 	if (!hp_pin)
 		return;
 
@@ -3347,6 +3382,11 @@ static void alc_default_shutup(struct hda_codec *codec)
 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
 	bool hp_pin_sense;
 
+	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
+		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+			hp_pin = spec->gen.autocfg.line_out_pins[0];
+	}
+
 	if (!hp_pin) {
 		alc269_shutup(codec);
 		return;
@@ -3379,6 +3419,11 @@ static void alc294_hp_init(struct hda_codec *codec)
 	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
 	int i, val;
 
+	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
+		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+			hp_pin = spec->gen.autocfg.line_out_pins[0];
+	}
+
 	if (!hp_pin)
 		return;
 

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: auto_mute for early patch issue
  2019-02-01  9:18       ` Kailang
@ 2019-02-01  9:33         ` Takashi Iwai
       [not found]         ` <6FAB7C47BCF00940BB0999A99BE3547A18DB88B0@RTITMBSVM07.realtek.com.tw>
  1 sibling, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2019-02-01  9:33 UTC (permalink / raw)
  To: Kailang; +Cc:  (alsa-devel@alsa-project.org)

On Fri, 01 Feb 2019 10:18:45 +0100,
Kailang wrote:
> 
> Hi Takashi,
> 
> I forgot it solved this issue for ALC283 before. It was also chrome OS case.
> I cooked attach patch. It will not need to move spec->suppress_auto_mute check line.
> Many thanks.

OK, I'll queue this to for-linus branch, as it fixes real bugs.

OTOH, I find filling hp_pins[] unconditionally makes sense.
So, for 5.1 development, maybe it'd be better to drop this change
again and apply the change to move the spec->suppress_auto_mute
check.

But the remaining question is whether moving the check helped at all;
it wasn't clear from your previous replies...


thanks,

Takashi


> 
> BR,
> Kailang
> 
> -----Original Message-----
> From: Takashi Iwai <tiwai@suse.de> 
> Sent: Thursday, January 31, 2019 7:02 PM
> To: Kailang <kailang@realtek.com>
> Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> Subject: Re: auto_mute for early patch issue
> 
> On Thu, 31 Jan 2019 11:50:26 +0100,
> Kailang wrote:
> > 
> > Hi Takashi,
> > 
> > spec->suppress_auto_mute = 1;
> > This will cause spec->gen.autocfg.hp_pins [0] = 0.
> > This will cause alc2??_init() and alc2??_shutup() and dell headset mode not run errors.
> 
> That's the result with your suggested change (moving
> spec->supress_auto_mute_mode in check_auto_mute_availability()) ??
> 
> 
> Takashi
> 
> > 
> > Does it has other place to store pin NID? 
> > Or just only this place hp_pin = spec->gen.autocfg.hp_pins[0]; to get headphone NID.
> > 
> > BR,
> > Kailang
> > 
> > -----Original Message-----
> > From: Takashi Iwai <tiwai@suse.de> 
> > Sent: Thursday, January 31, 2019 4:23 PM
> > To: Kailang <kailang@realtek.com>
> > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > Subject: Re: auto_mute for early patch issue
> > 
> > On Thu, 31 Jan 2019 09:00:36 +0100,
> > Kailang wrote:
> > > 
> > > Hi Takashi,
> > > 
> > > I move check line to below. It will show value for hp_pins[0].
> > > As I know, search from verb table in function snd_hda_parse_pin_defcfg().
> > > It will fill pins at auto_pin_cfg.
> > > Why it need to run below function to get cfg->hp_pins?
> > 
> > It's just because hp_pins[] and speaker_pins[] are used for the case with the auto-mute, so far, not for other evaluations :)
> > 
> > The change below looks safe, so if this works for you, feel fee to apply like that.
> > 
> > 
> > thanks,
> > 
> > Takashi
> > 
> > 
> > > static int check_auto_mute_availability(struct hda_codec *codec) {
> > > 	struct hda_gen_spec *spec = codec->spec;
> > > 	struct auto_pin_cfg *cfg = &spec->autocfg;
> > > 	int present = 0;
> > > 	int i, err;
> > > 
> > > -	if (spec->suppress_auto_mute)
> > > -		return 0;
> > > 
> > > 	if (cfg->hp_pins[0])
> > > 		present++;
> > > 	if (cfg->line_out_pins[0])
> > > 		present++;
> > > 	if (cfg->speaker_pins[0])
> > > 		present++;
> > > 	if (present < 2) /* need two different output types */
> > > 		return 0;
> > > 
> > > 	if (!cfg->speaker_pins[0] &&
> > > 	    cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
> > > 		memcpy(cfg->speaker_pins, cfg->line_out_pins,
> > > 		       sizeof(cfg->speaker_pins));
> > > 		cfg->speaker_outs = cfg->line_outs;
> > > 	}
> > > 
> > > 	if (!cfg->hp_pins[0] &&
> > > 	    cfg->line_out_type == AUTO_PIN_HP_OUT) {
> > > 		memcpy(cfg->hp_pins, cfg->line_out_pins,
> > > 		       sizeof(cfg->hp_pins));
> > > 		cfg->hp_outs = cfg->line_outs;
> > > 	}
> > > 
> > > +	if (spec->suppress_auto_mute)
> > > +		return 0;
> > > 
> > > ......
> > > .....
> > > ......
> > > }
> > > 
> > > BR,
> > > Kailang
> > > 
> > > -----Original Message-----
> > > From: Kailang
> > > Sent: Thursday, January 31, 2019 12:08 PM
> > > To: Takashi Iwai (tiwai@suse.de) <tiwai@suse.de>
> > > Cc: (alsa-devel@alsa-project.org) <alsa-devel@alsa-project.org>
> > > Subject: auto_mute for early patch issue
> > > 
> > > Hi Takashi,
> > > 
> > > Chrome OS use early patch firmware file to load model and use auto_mute =no hint options.
> > > I find an issue for early patch issue about hint option auto_mute = no.
> > > 
> > > This will cause all spec->init_hook can't get hp_pin values.
> > > 
> > > For example: alc225_init() alc225_shutup() alc256_init() alc256_shutup() Early patch file hint auto_mute = no equal spec->suppress_auto_mute = 1 It will return function check_auto_mute_availability() in had_generic.c.
> > > 
> > > hp_pin = spec->gen.autocfg.hp_pins[0];  ==> It will get value 0.
> > > 
> > > I think this issue was for a long time.
> > > Please see the attach dmesg. One is kill hint auto_mute option. 
> > > 
> > > BR,
> > > Kailang
> > > 
> > 
> > ------Please consider the environment before printing this e-mail.
> > 
> [2 0000-fix-lose-hp-pins.patch <application/octet-stream (base64)>]
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: auto_mute for early patch issue
       [not found]         ` <6FAB7C47BCF00940BB0999A99BE3547A18DB88B0@RTITMBSVM07.realtek.com.tw>
@ 2019-02-01 10:25           ` Takashi Iwai
  0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2019-02-01 10:25 UTC (permalink / raw)
  To: Kailang; +Cc:  (alsa-devel@alsa-project.org)

On Fri, 01 Feb 2019 11:21:58 +0100,
Kailang wrote:
> 
> Hi Takashi,
> 
> Got it. Thanks.
> 
> Could i need to make a patch for moving spec->suppress_auto_mute check?
> 
> Because Chrome OS need to back porting from upstream commit patches.
> So, the better solution was  moving spec->suppress_auto_mute check. Right?

After checking the whole code, I think what we can do now even safely
is to clean up a patch like below.  This will reduce lots of code.

With that applied, I don't think we need the change in hda_generic.c
any longer.


thanks,

Takashi

-- 8< --
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] ALSA: hda/realtek - Use a common helper for hp pin reference

Replace the open-codes in many places with a new common helper for
performing the same thing: referring to the primary headphone pin.

This eventually fixes the potentially missing headphone pin on some
weird devices, too.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/patch_realtek.c | 96 +++++++++++--------------------------------
 1 file changed, 24 insertions(+), 72 deletions(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 5b1a71fb909c..6df758adff84 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -515,6 +515,15 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
 	}
 }
 
+/* get a primary headphone pin if available */
+static hda_nid_t alc_get_hp_pin(struct alc_spec *spec)
+{
+	if (spec->gen.autocfg.hp_pins[0])
+		return spec->gen.autocfg.hp_pins[0];
+	if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
+		return spec->gen.autocfg.line_out_pins[0];
+	return 0;
+}
 
 /*
  * Realtek SSID verification
@@ -725,9 +734,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
 	 * 15   : 1 --> enable the function "Mute internal speaker
 	 *	        when the external headphone out jack is plugged"
 	 */
-	if (!spec->gen.autocfg.hp_pins[0] &&
-	    !(spec->gen.autocfg.line_out_pins[0] &&
-	      spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
+	if (!alc_get_hp_pin(spec)) {
 		hda_nid_t nid;
 		tmp = (ass >> 11) & 0x3;	/* HP to chassis */
 		nid = ports[tmp];
@@ -2959,15 +2966,10 @@ static void alc282_restore_default_value(struct hda_codec *codec)
 static void alc282_init(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp_pin_sense;
 	int coef78;
 
-	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	alc282_restore_default_value(codec);
 
 	if (!hp_pin)
@@ -3001,15 +3003,10 @@ static void alc282_init(struct hda_codec *codec)
 static void alc282_shutup(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp_pin_sense;
 	int coef78;
 
-	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	if (!hp_pin) {
 		alc269_shutup(codec);
 		return;
@@ -3084,14 +3081,9 @@ static void alc283_restore_default_value(struct hda_codec *codec)
 static void alc283_init(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp_pin_sense;
 
-	if (!spec->gen.autocfg.hp_outs) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	alc283_restore_default_value(codec);
 
 	if (!hp_pin)
@@ -3125,14 +3117,9 @@ static void alc283_init(struct hda_codec *codec)
 static void alc283_shutup(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp_pin_sense;
 
-	if (!spec->gen.autocfg.hp_outs) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	if (!hp_pin) {
 		alc269_shutup(codec);
 		return;
@@ -3166,14 +3153,9 @@ static void alc283_shutup(struct hda_codec *codec)
 static void alc256_init(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp_pin_sense;
 
-	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	if (!hp_pin)
 		return;
 
@@ -3207,14 +3189,9 @@ static void alc256_init(struct hda_codec *codec)
 static void alc256_shutup(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp_pin_sense;
 
-	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	if (!hp_pin) {
 		alc269_shutup(codec);
 		return;
@@ -3248,14 +3225,9 @@ static void alc256_shutup(struct hda_codec *codec)
 static void alc225_init(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp1_pin_sense, hp2_pin_sense;
 
-	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	if (!hp_pin)
 		return;
 
@@ -3296,14 +3268,9 @@ static void alc225_init(struct hda_codec *codec)
 static void alc225_shutup(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp1_pin_sense, hp2_pin_sense;
 
-	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	if (!hp_pin) {
 		alc269_shutup(codec);
 		return;
@@ -3345,14 +3312,9 @@ static void alc225_shutup(struct hda_codec *codec)
 static void alc_default_init(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp_pin_sense;
 
-	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	if (!hp_pin)
 		return;
 
@@ -3379,14 +3341,9 @@ static void alc_default_init(struct hda_codec *codec)
 static void alc_default_shutup(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	bool hp_pin_sense;
 
-	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	if (!hp_pin) {
 		alc269_shutup(codec);
 		return;
@@ -3416,14 +3373,9 @@ static void alc_default_shutup(struct hda_codec *codec)
 static void alc294_hp_init(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 	int i, val;
 
-	if (!spec->gen.autocfg.hp_outs && spec->gen.suppress_auto_mute) {
-		if (spec->gen.autocfg.line_out_type == AC_JACK_HP_OUT)
-			hp_pin = spec->gen.autocfg.line_out_pins[0];
-	}
-
 	if (!hp_pin)
 		return;
 
@@ -4825,7 +4777,7 @@ static void alc_update_headset_mode(struct hda_codec *codec)
 	struct alc_spec *spec = codec->spec;
 
 	hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
-	hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
+	hda_nid_t hp_pin = alc_get_hp_pin(spec);
 
 	int new_headset_mode;
 
@@ -5104,7 +5056,7 @@ static void alc_fixup_tpt470_dock(struct hda_codec *codec,
 static void alc_shutup_dell_xps13(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
-	int hp_pin = spec->gen.autocfg.hp_pins[0];
+	int hp_pin = alc_get_hp_pin(spec);
 
 	/* Prevent pop noises when headphones are plugged in */
 	snd_hda_codec_write(codec, hp_pin, 0,
@@ -5197,7 +5149,7 @@ static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
 
 	if (action == HDA_FIXUP_ACT_PROBE) {
 		int mic_pin = find_ext_mic_pin(codec);
-		int hp_pin = spec->gen.autocfg.hp_pins[0];
+		int hp_pin = alc_get_hp_pin(spec);
 
 		if (snd_BUG_ON(!mic_pin || !hp_pin))
 			return;
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* auto_mute for early patch issue
@ 2019-01-31  4:08 Kailang
  0 siblings, 0 replies; 10+ messages in thread
From: Kailang @ 2019-01-31  4:08 UTC (permalink / raw)
  To: Takashi Iwai (tiwai@suse.de); +Cc:  (alsa-devel@alsa-project.org)

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

Hi Takashi,

Chrome OS use early patch firmware file to load model and use auto_mute =no hint options.
I find an issue for early patch issue about hint option auto_mute = no.

This will cause all spec->init_hook can't get hp_pin values.

For example: alc225_init() alc225_shutup() alc256_init() alc256_shutup()
Early patch file hint auto_mute = no equal spec->suppress_auto_mute = 1
It will return function check_auto_mute_availability() in had_generic.c.

hp_pin = spec->gen.autocfg.hp_pins[0];  ==> It will get value 0.

I think this issue was for a long time.
Please see the attach dmesg. One is kill hint auto_mute option. 

BR,
Kailang


[-- Attachment #2: hp_pin.dmesg_kill_auto_mute --]
[-- Type: application/octet-stream, Size: 3061 bytes --]

[ 3548.987078] snd_hda_intel 0000:00:1b.0: Probing card using HDA DKMS, version 0.201808050301~ubuntu18.04.1
[ 3548.987429] snd_hda_intel 0000:00:1b.0: Applying patch firmware 'hda-init.fw'
[ 3549.018402] snd_hda_codec_realtek hdaudioC0D2: SKU: Nid=0x1d sku_cfg=0x40c00001
[ 3549.018408] snd_hda_codec_realtek hdaudioC0D2: SKU: port_connectivity=0x1
[ 3549.018412] snd_hda_codec_realtek hdaudioC0D2: SKU: enable_pcbeep=0x0
[ 3549.018415] snd_hda_codec_realtek hdaudioC0D2: SKU: check_sum=0x00000000
[ 3549.018419] snd_hda_codec_realtek hdaudioC0D2: SKU: customization=0x00000000
[ 3549.018422] snd_hda_codec_realtek hdaudioC0D2: SKU: external_amp=0x0
[ 3549.018425] snd_hda_codec_realtek hdaudioC0D2: SKU: platform_type=0x0
[ 3549.018428] snd_hda_codec_realtek hdaudioC0D2: SKU: swap=0x0
[ 3549.018431] snd_hda_codec_realtek hdaudioC0D2: SKU: override=0x1
[ 3549.018692] snd_hda_codec_realtek hdaudioC0D2: autoconfig for ALC295: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[ 3549.018697] snd_hda_codec_realtek hdaudioC0D2:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[ 3549.018700] snd_hda_codec_realtek hdaudioC0D2:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[ 3549.018703] snd_hda_codec_realtek hdaudioC0D2:    mono: mono_out=0x0
[ 3549.018706] snd_hda_codec_realtek hdaudioC0D2:    inputs:
[ 3549.018710] snd_hda_codec_realtek hdaudioC0D2:      Mic=0x19
[ 3549.018713] snd_hda_codec_realtek hdaudioC0D2:      Internal Mic=0x12
[ 3549.018719] snd_hda_codec_realtek hdaudioC0D2: realtek: No valid SSID, checking pincfg 0x40c00001 for NID 0x1d
[ 3549.018723] snd_hda_codec_realtek hdaudioC0D2: realtek: Enabling init ASM_ID=0x0001 CODEC_ID=10ec0295
[ 3549.022787] snd_hda_gen_parse_auto_config cfg->hp_pins[0]=0x21
[ 3549.022794] alc_parse_auto_config cfg->hp_pins[0]=0x21 cfg->hp_outs=0x1
[ 3549.022797] patch_alc269 cfg->hp_pins[0]=0x21 cfg->hp_outs=0x1
[ 3549.023270] alc225_init hp_pin=0x21
[ 3549.060398] jack_detect_update jack->nid=0x21
[ 3549.060773] alc225_init hp=0x21
[ 3549.063183] jack_detect_update jack->nid=0x19
[ 3549.063416] jack_detect_update jack->nid=0x12
[ 3549.063418] jack_detect_update jack->nid=0x14
[ 3549.063419] snd_hda_jack_report_sync jack->nid=0x21
[ 3549.063421] snd_hda_jack_report_sync jack->nid=0x19
[ 3549.063422] snd_hda_jack_report_sync jack->nid=0x12
[ 3549.063423] snd_hda_jack_report_sync jack->nid=0x14
[ 3549.066213] alc225_shutup hp_pin=0x21
[ 3549.067980] input: HDA Intel Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
[ 3549.068863] input: HDA Intel Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input12
[ 3549.085375] alc225_init hp_pin=0x21
[ 3549.124405] jack_detect_update jack->nid=0x21
[ 3549.124737] alc225_init hp=0x21
[ 3549.125459] jack_detect_update jack->nid=0x19
[ 3549.125556] jack_detect_update jack->nid=0x12
[ 3549.125557] jack_detect_update jack->nid=0x14
[ 3549.125562] snd_hda_jack_report_sync jack->nid=0x21
[ 3549.125565] snd_hda_jack_report_sync jack->nid=0x19
[ 3549.125567] snd_hda_jack_report_sync jack->nid=0x12
[ 3549.125569] snd_hda_jack_report_sync jack->nid=0x14


[-- Attachment #3: hp_pin.dmesg_with_auto_mute_no --]
[-- Type: application/octet-stream, Size: 3015 bytes --]

[ 4013.219363] snd_hda_intel 0000:00:1b.0: Probing card using HDA DKMS, version 0.201808050301~ubuntu18.04.1
[ 4013.219939] snd_hda_intel 0000:00:1b.0: Applying patch firmware 'hda-init.fw'
[ 4013.248152] snd_hda_codec_realtek hdaudioC0D2: SKU: Nid=0x1d sku_cfg=0x40c00001
[ 4013.248158] snd_hda_codec_realtek hdaudioC0D2: SKU: port_connectivity=0x1
[ 4013.248161] snd_hda_codec_realtek hdaudioC0D2: SKU: enable_pcbeep=0x0
[ 4013.248164] snd_hda_codec_realtek hdaudioC0D2: SKU: check_sum=0x00000000
[ 4013.248167] snd_hda_codec_realtek hdaudioC0D2: SKU: customization=0x00000000
[ 4013.248171] snd_hda_codec_realtek hdaudioC0D2: SKU: external_amp=0x0
[ 4013.248174] snd_hda_codec_realtek hdaudioC0D2: SKU: platform_type=0x0
[ 4013.248177] snd_hda_codec_realtek hdaudioC0D2: SKU: swap=0x0
[ 4013.248180] snd_hda_codec_realtek hdaudioC0D2: SKU: override=0x1
[ 4013.251289] snd_hda_codec_realtek hdaudioC0D2: autoconfig for ALC295: line_outs=1 (0x14/0x0/0x0/0x0/0x0) type:speaker
[ 4013.251296] snd_hda_codec_realtek hdaudioC0D2:    speaker_outs=0 (0x0/0x0/0x0/0x0/0x0)
[ 4013.251300] snd_hda_codec_realtek hdaudioC0D2:    hp_outs=1 (0x21/0x0/0x0/0x0/0x0)
[ 4013.251304] snd_hda_codec_realtek hdaudioC0D2:    mono: mono_out=0x0
[ 4013.251306] snd_hda_codec_realtek hdaudioC0D2:    inputs:
[ 4013.251312] snd_hda_codec_realtek hdaudioC0D2:      Mic=0x19
[ 4013.251318] snd_hda_codec_realtek hdaudioC0D2:      Internal Mic=0x12
[ 4013.251324] snd_hda_codec_realtek hdaudioC0D2: realtek: No valid SSID, checking pincfg 0x40c00001 for NID 0x1d
[ 4013.251328] snd_hda_codec_realtek hdaudioC0D2: realtek: Enabling init ASM_ID=0x0001 CODEC_ID=10ec0295
[ 4013.253659] snd_hda_gen_parse_auto_config cfg->hp_pins[0]=0x0
[ 4013.253670] alc_parse_auto_config cfg->hp_pins[0]=0x0 cfg->hp_outs=0x0
[ 4013.253673] patch_alc269 cfg->hp_pins[0]=0x0 cfg->hp_outs=0x0
[ 4013.254277] alc225_init hp_pin=0x0 hp_outs=0
[ 4013.257989] jack_detect_update jack->nid=0x21
[ 4013.258045] jack_detect_update jack->nid=0x19
[ 4013.258338] jack_detect_update jack->nid=0x12
[ 4013.258340] jack_detect_update jack->nid=0x14
[ 4013.258342] snd_hda_jack_report_sync jack->nid=0x21
[ 4013.258344] snd_hda_jack_report_sync jack->nid=0x19
[ 4013.258346] snd_hda_jack_report_sync jack->nid=0x12
[ 4013.258347] snd_hda_jack_report_sync jack->nid=0x14
[ 4013.263782] alc225_shutup hp_pin=0x0 hp_outs=0
[ 4013.269326] input: HDA Intel Mic as /devices/pci0000:00/0000:00:1b.0/sound/card0/input13
[ 4013.269667] input: HDA Intel Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card0/input14
[ 4013.290078] alc225_init hp_pin=0x0 hp_outs=0
[ 4013.291842] jack_detect_update jack->nid=0x21
[ 4013.291903] jack_detect_update jack->nid=0x19
[ 4013.293636] jack_detect_update jack->nid=0x12
[ 4013.293640] jack_detect_update jack->nid=0x14
[ 4013.293645] snd_hda_jack_report_sync jack->nid=0x21
[ 4013.293648] snd_hda_jack_report_sync jack->nid=0x19
[ 4013.293650] snd_hda_jack_report_sync jack->nid=0x12
[ 4013.293652] snd_hda_jack_report_sync jack->nid=0x14


[-- Attachment #4: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-02-01 10:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-31  8:00 auto_mute for early patch issue Kailang
2019-01-31  8:23 ` Takashi Iwai
2019-01-31  8:33   ` Kailang
2019-01-31  9:28   ` Kailang
2019-01-31 10:50   ` Kailang
2019-01-31 11:02     ` Takashi Iwai
2019-02-01  9:18       ` Kailang
2019-02-01  9:33         ` Takashi Iwai
     [not found]         ` <6FAB7C47BCF00940BB0999A99BE3547A18DB88B0@RTITMBSVM07.realtek.com.tw>
2019-02-01 10:25           ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2019-01-31  4:08 Kailang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.