]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
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 | |
6 | References: bnc#460478 | |
7 | ||
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. | |
10 | ||
11 | This is what is found at lspci -vnn: | |
12 | ||
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] | |
15 | ||
16 | Yet, autodetection is possible, since the codec properly reflects the vendor at | |
17 | the Subsystem ID: | |
18 | ||
19 | $ cat /proc/asound/card0/codec#0 |head -4 | |
20 | ||
21 | Codec: SigmaTel STAC9250 | |
22 | Address: 0 | |
23 | Vendor Id: 0x83847634 | |
24 | Subsystem Id: 0x107b0367 | |
25 | ||
26 | This patch adds a new autodetection function that seeks for codec subsystem ID. | |
27 | ||
28 | Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org> | |
29 | Signed-off-by: Takashi Iwai <tiwai@suse.de> | |
30 | ||
31 | --- | |
32 | sound/pci/hda/hda_codec.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ | |
33 | sound/pci/hda/hda_local.h | 3 ++ | |
34 | 2 files changed, 63 insertions(+), 0 deletions(-) | |
35 | ||
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 | |
41 | } | |
42 | ||
43 | /** | |
44 | + * snd_hda_check_board_codec_sid_config - compare the current codec | |
45 | + subsystem ID with the | |
46 | + config table | |
47 | + | |
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. | |
52 | + | |
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 | |
57 | + * | |
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). | |
61 | + * | |
62 | + * If no entries are matching, the function returns a negative value. | |
63 | + */ | |
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) | |
67 | +{ | |
68 | + const struct snd_pci_quirk *q; | |
69 | + | |
70 | + /* Search for codec ID */ | |
71 | + for (q = tbl; q->subvendor; q++) { | |
72 | + unsigned long vendorid = (q->subdevice) | (q->subvendor << 16); | |
73 | + | |
74 | + if (vendorid == codec->subsystem_id) | |
75 | + break; | |
76 | + } | |
77 | + | |
78 | + if (!q->subvendor) | |
79 | + return -1; | |
80 | + | |
81 | + tbl = q; | |
82 | + | |
83 | + if (tbl->value >= 0 && tbl->value < num_configs) { | |
84 | +#ifdef CONFIG_SND_DEBUG_DETECT | |
85 | + char tmp[10]; | |
86 | + const char *model = NULL; | |
87 | + if (models) | |
88 | + model = models[tbl->value]; | |
89 | + if (!model) { | |
90 | + sprintf(tmp, "#%d", tbl->value); | |
91 | + model = tmp; | |
92 | + } | |
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")); | |
97 | +#endif | |
98 | + return tbl->value; | |
99 | + } | |
100 | + return -1; | |
101 | +} | |
102 | + | |
103 | +/** | |
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); | |
120 | ||
121 | -- | |
122 | 1.6.1 | |
123 |