mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
ALSA: hda/realtek: More robust component matching for CS35L41
As the previous commit implies, a system may have a different SPI bus
number that is embedded in the device string. And, assuming the fixed
bus number is rather fragile; it may be assigned differently depending
on the configuration or on the boot environment. Once when a bus
number change happens, the binding fails, resulting in the silence.
This patch tries to make the matching a bit more relaxed, allowing to
bind with a different bus number (or without it). So the previous
fix, the introduction of ALC245_FIXUP_CS35L41_SPI1_2 fixup became
superfluous, and this is unified to ALC245_FIXUP_CS35L41_SPI_2.
Fixes: 225f6e1bc1
("ALSA: hda/realtek: Add quirk for HP Zbook Firefly 14 G9 model")
Link: https://lore.kernel.org/r/20220930084810.10435-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
225f6e1bc1
commit
35a1744423
@ -18,6 +18,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/jack.h>
|
||||
#include <sound/hda_codec.h>
|
||||
@ -6704,23 +6705,51 @@ static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct hda_
|
||||
}
|
||||
}
|
||||
|
||||
struct cs35l41_dev_name {
|
||||
const char *bus;
|
||||
const char *hid;
|
||||
int index;
|
||||
};
|
||||
|
||||
/* match the device name in a slightly relaxed manner */
|
||||
static int comp_match_cs35l41_dev_name(struct device *dev, void *data)
|
||||
{
|
||||
struct cs35l41_dev_name *p = data;
|
||||
const char *d = dev_name(dev);
|
||||
int n = strlen(p->bus);
|
||||
char tmp[32];
|
||||
|
||||
/* check the bus name */
|
||||
if (strncmp(d, p->bus, n))
|
||||
return 0;
|
||||
/* skip the bus number */
|
||||
if (isdigit(d[n]))
|
||||
n++;
|
||||
/* the rest must be exact matching */
|
||||
snprintf(tmp, sizeof(tmp), "-%s:00-cs35l41-hda.%d", p->hid, p->index);
|
||||
return !strcmp(d + n, tmp);
|
||||
}
|
||||
|
||||
static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char *bus,
|
||||
const char *hid, int count)
|
||||
{
|
||||
struct device *dev = hda_codec_dev(cdc);
|
||||
struct alc_spec *spec = cdc->spec;
|
||||
char *name;
|
||||
struct cs35l41_dev_name *rec;
|
||||
int ret, i;
|
||||
|
||||
switch (action) {
|
||||
case HDA_FIXUP_ACT_PRE_PROBE:
|
||||
for (i = 0; i < count; i++) {
|
||||
name = devm_kasprintf(dev, GFP_KERNEL,
|
||||
"%s-%s:00-cs35l41-hda.%d", bus, hid, i);
|
||||
if (!name)
|
||||
rec = devm_kmalloc(dev, sizeof(*rec), GFP_KERNEL);
|
||||
if (!rec)
|
||||
return;
|
||||
rec->bus = bus;
|
||||
rec->hid = hid;
|
||||
rec->index = i;
|
||||
spec->comps[i].codec = cdc;
|
||||
component_match_add(dev, &spec->match, component_compare_dev_name, name);
|
||||
component_match_add(dev, &spec->match,
|
||||
comp_match_cs35l41_dev_name, rec);
|
||||
}
|
||||
ret = component_master_add_with_match(dev, &comp_master_ops, spec->match);
|
||||
if (ret)
|
||||
@ -6738,17 +6767,12 @@ static void cs35l41_fixup_i2c_two(struct hda_codec *cdc, const struct hda_fixup
|
||||
|
||||
static void cs35l41_fixup_spi_two(struct hda_codec *codec, const struct hda_fixup *fix, int action)
|
||||
{
|
||||
cs35l41_generic_fixup(codec, action, "spi0", "CSC3551", 2);
|
||||
}
|
||||
|
||||
static void cs35l41_fixup_spi1_two(struct hda_codec *codec, const struct hda_fixup *fix, int action)
|
||||
{
|
||||
cs35l41_generic_fixup(codec, action, "spi1", "CSC3551", 2);
|
||||
cs35l41_generic_fixup(codec, action, "spi", "CSC3551", 2);
|
||||
}
|
||||
|
||||
static void cs35l41_fixup_spi_four(struct hda_codec *codec, const struct hda_fixup *fix, int action)
|
||||
{
|
||||
cs35l41_generic_fixup(codec, action, "spi0", "CSC3551", 4);
|
||||
cs35l41_generic_fixup(codec, action, "spi", "CSC3551", 4);
|
||||
}
|
||||
|
||||
static void alc287_fixup_legion_16achg6_speakers(struct hda_codec *cdc, const struct hda_fixup *fix,
|
||||
@ -7137,8 +7161,6 @@ enum {
|
||||
ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED,
|
||||
ALC245_FIXUP_CS35L41_SPI_2,
|
||||
ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED,
|
||||
ALC245_FIXUP_CS35L41_SPI1_2,
|
||||
ALC245_FIXUP_CS35L41_SPI1_2_HP_GPIO_LED,
|
||||
ALC245_FIXUP_CS35L41_SPI_4,
|
||||
ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED,
|
||||
ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED,
|
||||
@ -8986,16 +9008,6 @@ static const struct hda_fixup alc269_fixups[] = {
|
||||
.chained = true,
|
||||
.chain_id = ALC285_FIXUP_HP_GPIO_LED,
|
||||
},
|
||||
[ALC245_FIXUP_CS35L41_SPI1_2] = {
|
||||
.type = HDA_FIXUP_FUNC,
|
||||
.v.func = cs35l41_fixup_spi1_two,
|
||||
},
|
||||
[ALC245_FIXUP_CS35L41_SPI1_2_HP_GPIO_LED] = {
|
||||
.type = HDA_FIXUP_FUNC,
|
||||
.v.func = cs35l41_fixup_spi1_two,
|
||||
.chained = true,
|
||||
.chain_id = ALC285_FIXUP_HP_GPIO_LED,
|
||||
},
|
||||
[ALC245_FIXUP_CS35L41_SPI_4] = {
|
||||
.type = HDA_FIXUP_FUNC,
|
||||
.v.func = cs35l41_fixup_spi_four,
|
||||
@ -9358,7 +9370,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
|
||||
SND_PCI_QUIRK(0x103c, 0x8aa3, "HP ProBook 450 G9 (MB 8AA1)", ALC236_FIXUP_HP_GPIO_LED),
|
||||
SND_PCI_QUIRK(0x103c, 0x8aa8, "HP EliteBook 640 G9 (MB 8AA6)", ALC236_FIXUP_HP_GPIO_LED),
|
||||
SND_PCI_QUIRK(0x103c, 0x8aab, "HP EliteBook 650 G9 (MB 8AA9)", ALC236_FIXUP_HP_GPIO_LED),
|
||||
SND_PCI_QUIRK(0x103c, 0x8abb, "HP ZBook Firefly 14 G9", ALC245_FIXUP_CS35L41_SPI1_2_HP_GPIO_LED),
|
||||
SND_PCI_QUIRK(0x103c, 0x8abb, "HP ZBook Firefly 14 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
|
||||
SND_PCI_QUIRK(0x103c, 0x8ad1, "HP EliteBook 840 14 inch G9 Notebook PC", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
|
||||
SND_PCI_QUIRK(0x103c, 0x8ad2, "HP EliteBook 860 16 inch G9 Notebook PC", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
|
||||
SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC),
|
||||
|
Loading…
Reference in New Issue
Block a user