1 From 2eda344546caaf9168e778a4007f4609e95106e0 Mon Sep 17 00:00:00 2001
2 From: Mauro Carvalho Chehab <mchehab@infradead.org>
3 Date: Mon, 11 Aug 2008 10:18:39 +0200
4 Subject: ALSA: hda - Add a new function to seek for a codec ID
5 Patch-mainline: 2.6.29-rc1
8 Gateway notebooks have their ID inside codec vendor ID, not at PCI ID. Due to
9 that, model auto-detection were not possible with the standard seek method.
11 This is what is found at lspci -vnn:
13 00:14.2 Audio device [0403]: ATI Technologies Inc SB450 HDA Audio [1002:437b] (rev 01)
14 Subsystem: ATI Technologies Inc SB450 HDA Audio [1002:437b]
16 Yet, autodetection is possible, since the codec properly reflects the vendor at
19 $ cat /proc/asound/card0/codec#0 |head -4
21 Codec: SigmaTel STAC9250
24 Subsystem Id: 0x107b0367
26 This patch adds a new autodetection function that seeks for codec subsystem ID.
28 Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
29 Signed-off-by: Takashi Iwai <tiwai@suse.de>
32 sound/pci/hda/hda_codec.c | 60 +++++++++++++++++++++++++++++++++++++++++++++
33 sound/pci/hda/hda_local.h | 3 ++
34 2 files changed, 63 insertions(+), 0 deletions(-)
36 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
37 index 0043448..9c1af01 100644
38 --- a/sound/pci/hda/hda_codec.c
39 +++ b/sound/pci/hda/hda_codec.c
40 @@ -2364,6 +2364,66 @@ int snd_hda_check_board_config(struct hd
44 + * snd_hda_check_board_codec_sid_config - compare the current codec
45 + subsystem ID with the
48 + This is important for Gateway notebooks with SB450 HDA Audio
49 + where the vendor ID of the PCI device is:
50 + ATI Technologies Inc SB450 HDA Audio [1002:437b]
51 + and the vendor/subvendor are found only at the codec.
53 + * @codec: the HDA codec
54 + * @num_configs: number of config enums
55 + * @models: array of model name strings
56 + * @tbl: configuration table, terminated by null entries
58 + * Compares the modelname or PCI subsystem id of the current codec with the
59 + * given configuration table. If a matching entry is found, returns its
60 + * config value (supposed to be 0 or positive).
62 + * If no entries are matching, the function returns a negative value.
64 +int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
65 + int num_configs, const char **models,
66 + const struct snd_pci_quirk *tbl)
68 + const struct snd_pci_quirk *q;
70 + /* Search for codec ID */
71 + for (q = tbl; q->subvendor; q++) {
72 + unsigned long vendorid = (q->subdevice) | (q->subvendor << 16);
74 + if (vendorid == codec->subsystem_id)
83 + if (tbl->value >= 0 && tbl->value < num_configs) {
84 +#ifdef CONFIG_SND_DEBUG_DETECT
86 + const char *model = NULL;
88 + model = models[tbl->value];
90 + sprintf(tmp, "#%d", tbl->value);
93 + snd_printdd(KERN_INFO "hda_codec: model '%s' is selected "
94 + "for config %x:%x (%s)\n",
95 + model, tbl->subvendor, tbl->subdevice,
96 + (tbl->name ? tbl->name : "Unknown device"));
104 * snd_hda_add_new_ctls - create controls from the array
105 * @codec: the HDA codec
106 * @knew: the array of struct snd_kcontrol_new
107 diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
108 index 6f2fe0f..1dd8716 100644
109 --- a/sound/pci/hda/hda_local.h
110 +++ b/sound/pci/hda/hda_local.h
111 @@ -288,6 +288,9 @@ static inline int snd_hda_codec_proc_new
112 int snd_hda_check_board_config(struct hda_codec *codec, int num_configs,
113 const char **modelnames,
114 const struct snd_pci_quirk *pci_list);
115 +int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
116 + int num_configs, const char **models,
117 + const struct snd_pci_quirk *tbl);
118 int snd_hda_add_new_ctls(struct hda_codec *codec,
119 struct snd_kcontrol_new *knew);