stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations
@ 2019-08-15  8:30 Hui Wang
  2019-08-15  8:30 ` [PATCH 2/2] ALSA: hda - change the pintbl to undef tbl for Dell with alc289 Hui Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hui Wang @ 2019-08-15  8:30 UTC (permalink / raw)
  To: alsa-devel, tiwai; +Cc: stable

With the existing pintbl, we already have many entries in it. it is
better to figure out a new match to reduce the size of the pintbl.

For example, there are over 10 entries in the pintbl for:
0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE

If we define a new tbl like below, and with the new adding match
function, we can remove those over 10 entries:
SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
	{0x19, 0x40000000},
	{0x1a, 0x40000000},),

Here we put 0x19 and 0x1a in the tbl just because these two pins are
undefined on Dell laptops with the codec alc255, and these two pins
will be overwritten by ALC255_FIXUP_DELL1_MIC_NO_PRESENCE.

In summary: the new match will check vendor id and codec id first,
then check the pin_cfg defined in the tbl, only all pin_cfgs in the
tbl are undef and the corresponding pin_cfgs on the laptop are undef
too, this match returns true.

This new match function has lower priority than existing match
functions, so the existing tbls still work as before after applying this
patch.

My plan is to change the existing tbl to undef tbl for MIC_NO_PRESENCE
fixups gradually.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/pci/hda/hda_auto_parser.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c
index 92390d457567..cfada7401b86 100644
--- a/sound/pci/hda/hda_auto_parser.c
+++ b/sound/pci/hda/hda_auto_parser.c
@@ -915,6 +915,36 @@ static bool pin_config_match(struct hda_codec *codec,
 	return true;
 }
 
+/* match the pintbl which only contains specific pins with undef configuration */
+static bool pin_config_match_undef(struct hda_codec *codec,
+				   const struct hda_pintbl *pins)
+{
+	bool match = false;
+
+	for (; pins->nid; pins++) {
+		const struct hda_pincfg *pin;
+		int i;
+
+		if ((pins->val & 0xf0000000) != 0x40000000)
+			return false;
+
+		match = false;
+		snd_array_for_each(&codec->init_pins, i, pin) {
+			if (pin->nid != pins->nid)
+				continue;
+			if ((pin->cfg & 0xf0000000) != 0x40000000)
+				return false;
+			match = true;
+			break;
+		}
+
+		if (match == false)
+			return false;
+	}
+
+	return match;
+}
+
 /**
  * snd_hda_pick_pin_fixup - Pick up a fixup matching with the pin quirk list
  * @codec: the HDA codec
@@ -935,7 +965,7 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec,
 			continue;
 		if (codec->core.vendor_id != pq->codec)
 			continue;
-		if (pin_config_match(codec, pq->pins)) {
+		if (pin_config_match(codec, pq->pins) || pin_config_match_undef(codec, pq->pins)) {
 			codec->fixup_id = pq->value;
 #ifdef CONFIG_SND_DEBUG_VERBOSE
 			codec->fixup_name = pq->name;
-- 
2.17.1


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

* [PATCH 2/2] ALSA: hda - change the pintbl to undef tbl for Dell with alc289
  2019-08-15  8:30 [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations Hui Wang
@ 2019-08-15  8:30 ` Hui Wang
  2019-08-15  8:42   ` Greg KH
  2019-08-15  8:42 ` [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations Greg KH
  2019-08-15  8:47 ` [alsa-devel] " Hui Wang
  2 siblings, 1 reply; 5+ messages in thread
From: Hui Wang @ 2019-08-15  8:30 UTC (permalink / raw)
  To: alsa-devel, tiwai; +Cc: stable

We have another Dell laptop which needs the DELL4_MIC_NO_PRESENCE,
and this laptop has different pincfg definitions from existing
ones in the pintbl, rather adding a new entry, let us change
the exiting tbl to undef tbl. It will cover all Dell laptops
with alc289 codec and the pins of 0x19 and 0x1b are undef by default.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/pci/hda/patch_realtek.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index a1439c9a635a..50b977ea16c2 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7648,9 +7648,8 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
 		{0x14, 0x90170110},
 		{0x21, 0x0321101f}),
 	SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
-		{0x12, 0xb7a60130},
-		{0x14, 0x90170110},
-		{0x21, 0x04211020}),
+		{0x19, 0x40000000},
+		{0x1b, 0x40000000}),
 	SND_HDA_PIN_QUIRK(0x10ec0290, 0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1,
 		ALC290_STANDARD_PINS,
 		{0x15, 0x04211040},
-- 
2.17.1


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

* Re: [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations
  2019-08-15  8:30 [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations Hui Wang
  2019-08-15  8:30 ` [PATCH 2/2] ALSA: hda - change the pintbl to undef tbl for Dell with alc289 Hui Wang
@ 2019-08-15  8:42 ` Greg KH
  2019-08-15  8:47 ` [alsa-devel] " Hui Wang
  2 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2019-08-15  8:42 UTC (permalink / raw)
  To: Hui Wang; +Cc: alsa-devel, tiwai, stable

On Thu, Aug 15, 2019 at 04:30:00PM +0800, Hui Wang wrote:
> With the existing pintbl, we already have many entries in it. it is
> better to figure out a new match to reduce the size of the pintbl.
> 
> For example, there are over 10 entries in the pintbl for:
> 0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
> 
> If we define a new tbl like below, and with the new adding match
> function, we can remove those over 10 entries:
> SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
> 	{0x19, 0x40000000},
> 	{0x1a, 0x40000000},),
> 
> Here we put 0x19 and 0x1a in the tbl just because these two pins are
> undefined on Dell laptops with the codec alc255, and these two pins
> will be overwritten by ALC255_FIXUP_DELL1_MIC_NO_PRESENCE.
> 
> In summary: the new match will check vendor id and codec id first,
> then check the pin_cfg defined in the tbl, only all pin_cfgs in the
> tbl are undef and the corresponding pin_cfgs on the laptop are undef
> too, this match returns true.
> 
> This new match function has lower priority than existing match
> functions, so the existing tbls still work as before after applying this
> patch.
> 
> My plan is to change the existing tbl to undef tbl for MIC_NO_PRESENCE
> fixups gradually.
> 
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> ---
>  sound/pci/hda/hda_auto_parser.c | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)


<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

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

* Re: [PATCH 2/2] ALSA: hda - change the pintbl to undef tbl for Dell with alc289
  2019-08-15  8:30 ` [PATCH 2/2] ALSA: hda - change the pintbl to undef tbl for Dell with alc289 Hui Wang
@ 2019-08-15  8:42   ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2019-08-15  8:42 UTC (permalink / raw)
  To: Hui Wang; +Cc: alsa-devel, tiwai, stable

On Thu, Aug 15, 2019 at 04:30:01PM +0800, Hui Wang wrote:
> We have another Dell laptop which needs the DELL4_MIC_NO_PRESENCE,
> and this laptop has different pincfg definitions from existing
> ones in the pintbl, rather adding a new entry, let us change
> the exiting tbl to undef tbl. It will cover all Dell laptops
> with alc289 codec and the pins of 0x19 and 0x1b are undef by default.
> 
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> ---
>  sound/pci/hda/patch_realtek.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)


<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

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

* Re: [alsa-devel] [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations
  2019-08-15  8:30 [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations Hui Wang
  2019-08-15  8:30 ` [PATCH 2/2] ALSA: hda - change the pintbl to undef tbl for Dell with alc289 Hui Wang
  2019-08-15  8:42 ` [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations Greg KH
@ 2019-08-15  8:47 ` Hui Wang
  2 siblings, 0 replies; 5+ messages in thread
From: Hui Wang @ 2019-08-15  8:47 UTC (permalink / raw)
  To: alsa-devel, tiwai; +Cc: stable

Sorry, please ignore this patchset, don't plan to send this patchset to 
stable and there is some issue in the patch, will send v2.

On 2019/8/15 下午4:30, Hui Wang wrote:
> With the existing pintbl, we already have many entries in it. it is
> better to figure out a new match to reduce the size of the pintbl.
>
> For example, there are over 10 entries in the pintbl for:
> 0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
>
> If we define a new tbl like below, and with the new adding match
> function, we can remove those over 10 entries:
> SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
> 	{0x19, 0x40000000},
> 	{0x1a, 0x40000000},),
>
> Here we put 0x19 and 0x1a in the tbl just because these two pins are
> undefined on Dell laptops with the codec alc255, and these two pins
> will be overwritten by ALC255_FIXUP_DELL1_MIC_NO_PRESENCE.
>
> In summary: the new match will check vendor id and codec id first,
> then check the pin_cfg defined in the tbl, only all pin_cfgs in the
> tbl are undef and the corresponding pin_cfgs on the laptop are undef
> too, this match returns true.
>
> This new match function has lower priority than existing match
> functions, so the existing tbls still work as before after applying this
> patch.
>
> My plan is to change the existing tbl to undef tbl for MIC_NO_PRESENCE
> fixups gradually.
>
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> ---
>   sound/pci/hda/hda_auto_parser.c | 32 +++++++++++++++++++++++++++++++-
>   1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c
> index 92390d457567..cfada7401b86 100644
> --- a/sound/pci/hda/hda_auto_parser.c
> +++ b/sound/pci/hda/hda_auto_parser.c
> @@ -915,6 +915,36 @@ static bool pin_config_match(struct hda_codec *codec,
>   	return true;
>   }
>   
> +/* match the pintbl which only contains specific pins with undef configuration */
> +static bool pin_config_match_undef(struct hda_codec *codec,
> +				   const struct hda_pintbl *pins)
> +{
> +	bool match = false;
> +
> +	for (; pins->nid; pins++) {
> +		const struct hda_pincfg *pin;
> +		int i;
> +
> +		if ((pins->val & 0xf0000000) != 0x40000000)
> +			return false;
> +
> +		match = false;
> +		snd_array_for_each(&codec->init_pins, i, pin) {
> +			if (pin->nid != pins->nid)
> +				continue;
> +			if ((pin->cfg & 0xf0000000) != 0x40000000)
> +				return false;
> +			match = true;
> +			break;
> +		}
> +
> +		if (match == false)
> +			return false;
> +	}
> +
> +	return match;
> +}
> +
>   /**
>    * snd_hda_pick_pin_fixup - Pick up a fixup matching with the pin quirk list
>    * @codec: the HDA codec
> @@ -935,7 +965,7 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec,
>   			continue;
>   		if (codec->core.vendor_id != pq->codec)
>   			continue;
> -		if (pin_config_match(codec, pq->pins)) {
> +		if (pin_config_match(codec, pq->pins) || pin_config_match_undef(codec, pq->pins)) {
>   			codec->fixup_id = pq->value;
>   #ifdef CONFIG_SND_DEBUG_VERBOSE
>   			codec->fixup_name = pq->name;

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

end of thread, other threads:[~2019-08-15  8:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-15  8:30 [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations Hui Wang
2019-08-15  8:30 ` [PATCH 2/2] ALSA: hda - change the pintbl to undef tbl for Dell with alc289 Hui Wang
2019-08-15  8:42   ` Greg KH
2019-08-15  8:42 ` [PATCH 1/2] ALSA: hda - Add a new match function for only undef configurations Greg KH
2019-08-15  8:47 ` [alsa-devel] " Hui Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).