aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-02-17 09:25:37 -0500
committerTakashi Iwai <tiwai@suse.de>2015-02-23 03:16:06 -0500
commitd8a766a16ed90c4b3bd7afa6e1417f8d715db507 (patch)
tree2810742bf71c851726f27e99f9984fe334f97b8d
parent327ef4f02582d01f7eedb291794106823b44a0cf (diff)
ALSA: hda - Bind codecs via standard bus
Now we create the standard HD-audio bus (/sys/bus/hdaudio), and bind the codec driver with the codec device over there. This is the first step of the whole transition so that the changes to each codec driver are kept as minimal as possible. Each codec driver needs to register hda_codec_driver struct containing the currently existing preset via the new helper macro module_hda_codec_driver(). The old hda_codec_preset_list is replaced with this infrastructure. The generic parsers (for HDMI and other) are also included in the preset with the special IDs to bind uniquely. In HD-audio core side, the device binding code is split to hda_bind.c. It provides the snd_hda_bus_type implementation to match the codec driver with the given codec vendor ID. It also manages the module auto-loading by itself like before: when the matching isn't found, it tries to probe the corresponding codec modules, and finally falls back to the generic drivers. (The special ID mentioned above is set at this stage.) The only visible change to outside is that the hdaudio sysfs entry now appears in /sys/bus/devices, not as a sound class device. More works to move the suspend/resume and remove ops will be (hopefully) done in later patches. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/Makefile2
-rw-r--r--sound/pci/hda/hda_bind.c320
-rw-r--r--sound/pci/hda/hda_codec.c307
-rw-r--r--sound/pci/hda/hda_codec.h27
-rw-r--r--sound/pci/hda/hda_generic.c18
-rw-r--r--sound/pci/hda/hda_local.h18
-rw-r--r--sound/pci/hda/patch_analog.c16
-rw-r--r--sound/pci/hda/patch_ca0110.c16
-rw-r--r--sound/pci/hda/patch_ca0132.c16
-rw-r--r--sound/pci/hda/patch_cirrus.c16
-rw-r--r--sound/pci/hda/patch_cmedia.c16
-rw-r--r--sound/pci/hda/patch_conexant.c16
-rw-r--r--sound/pci/hda/patch_hdmi.c27
-rw-r--r--sound/pci/hda/patch_realtek.c16
-rw-r--r--sound/pci/hda/patch_si3054.c16
-rw-r--r--sound/pci/hda/patch_sigmatel.c16
-rw-r--r--sound/pci/hda/patch_via.c16
17 files changed, 401 insertions, 478 deletions
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 194f30935e77..96caaebfc19d 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -4,7 +4,7 @@ snd-hda-tegra-objs := hda_tegra.o
4# for haswell power well 4# for haswell power well
5snd-hda-intel-$(CONFIG_SND_HDA_I915) += hda_i915.o 5snd-hda-intel-$(CONFIG_SND_HDA_I915) += hda_i915.o
6 6
7snd-hda-codec-y := hda_codec.o hda_jack.o hda_auto_parser.o hda_sysfs.o 7snd-hda-codec-y := hda_bind.o hda_codec.o hda_jack.o hda_auto_parser.o hda_sysfs.o
8snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o 8snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
9snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 9snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
10snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o 10snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c
new file mode 100644
index 000000000000..adf6b475dee1
--- /dev/null
+++ b/sound/pci/hda/hda_bind.c
@@ -0,0 +1,320 @@
1/*
2 * HD-audio codec driver binding
3 * Copyright (c) Takashi Iwai <tiwai@suse.de>
4 */
5
6#include <linux/init.h>
7#include <linux/slab.h>
8#include <linux/mutex.h>
9#include <linux/module.h>
10#include <linux/export.h>
11#include <sound/core.h>
12#include "hda_codec.h"
13#include "hda_local.h"
14
15/* codec vendor labels */
16struct hda_vendor_id {
17 unsigned int id;
18 const char *name;
19};
20
21static struct hda_vendor_id hda_vendor_ids[] = {
22 { 0x1002, "ATI" },
23 { 0x1013, "Cirrus Logic" },
24 { 0x1057, "Motorola" },
25 { 0x1095, "Silicon Image" },
26 { 0x10de, "Nvidia" },
27 { 0x10ec, "Realtek" },
28 { 0x1102, "Creative" },
29 { 0x1106, "VIA" },
30 { 0x111d, "IDT" },
31 { 0x11c1, "LSI" },
32 { 0x11d4, "Analog Devices" },
33 { 0x13f6, "C-Media" },
34 { 0x14f1, "Conexant" },
35 { 0x17e8, "Chrontel" },
36 { 0x1854, "LG" },
37 { 0x1aec, "Wolfson Microelectronics" },
38 { 0x1af4, "QEMU" },
39 { 0x434d, "C-Media" },
40 { 0x8086, "Intel" },
41 { 0x8384, "SigmaTel" },
42 {} /* terminator */
43};
44
45/*
46 * find a matching codec preset
47 */
48static int hda_bus_match(struct device *dev, struct device_driver *drv)
49{
50 struct hda_codec *codec = container_of(dev, struct hda_codec, dev);
51 struct hda_codec_driver *driver =
52 container_of(drv, struct hda_codec_driver, driver);
53 const struct hda_codec_preset *preset;
54 /* check probe_id instead of vendor_id if set */
55 u32 id = codec->probe_id ? codec->probe_id : codec->vendor_id;
56
57 for (preset = driver->preset; preset->id; preset++) {
58 u32 mask = preset->mask;
59
60 if (preset->afg && preset->afg != codec->afg)
61 continue;
62 if (preset->mfg && preset->mfg != codec->mfg)
63 continue;
64 if (!mask)
65 mask = ~0;
66 if (preset->id == (id & mask) &&
67 (!preset->rev || preset->rev == codec->revision_id)) {
68 codec->preset = preset;
69 return 1;
70 }
71 }
72 return 0;
73}
74
75/* reset the codec name from the preset */
76static int codec_refresh_name(struct hda_codec *codec, const char *name)
77{
78 char tmp[16];
79
80 kfree(codec->chip_name);
81 if (!name) {
82 sprintf(tmp, "ID %x", codec->vendor_id & 0xffff);
83 name = tmp;
84 }
85 codec->chip_name = kstrdup(name, GFP_KERNEL);
86 return codec->chip_name ? 0 : -ENOMEM;
87}
88
89static int hda_codec_driver_probe(struct device *dev)
90{
91 struct hda_codec *codec = dev_to_hda_codec(dev);
92 struct module *owner = dev->driver->owner;
93 int err;
94
95 if (WARN_ON(!codec->preset))
96 return -EINVAL;
97
98 err = codec_refresh_name(codec, codec->preset->name);
99 if (err < 0)
100 goto error;
101
102 if (!try_module_get(owner)) {
103 err = -EINVAL;
104 goto error;
105 }
106
107 err = codec->preset->patch(codec);
108 if (err < 0) {
109 module_put(owner);
110 goto error;
111 }
112
113 return 0;
114
115 error:
116 codec->preset = NULL;
117 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops));
118 return err;
119}
120
121static int hda_codec_driver_remove(struct device *dev)
122{
123 struct hda_codec *codec = dev_to_hda_codec(dev);
124
125 if (codec->patch_ops.free)
126 codec->patch_ops.free(codec);
127 codec->preset = NULL;
128 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops));
129 module_put(dev->driver->owner);
130 return 0;
131}
132
133int __hda_codec_driver_register(struct hda_codec_driver *drv, const char *name,
134 struct module *owner)
135{
136 drv->driver.name = name;
137 drv->driver.owner = owner;
138 drv->driver.bus = &snd_hda_bus_type;
139 drv->driver.probe = hda_codec_driver_probe;
140 drv->driver.remove = hda_codec_driver_remove;
141 /* TODO: PM and others */
142 return driver_register(&drv->driver);
143}
144EXPORT_SYMBOL_GPL(__hda_codec_driver_register);
145
146void hda_codec_driver_unregister(struct hda_codec_driver *drv)
147{
148 driver_unregister(&drv->driver);
149}
150EXPORT_SYMBOL_GPL(hda_codec_driver_unregister);
151
152static inline bool codec_probed(struct hda_codec *codec)
153{
154 return device_attach(hda_codec_dev(codec)) > 0 && codec->preset;
155}
156
157/* try to auto-load and bind the codec module */
158static void codec_bind_module(struct hda_codec *codec)
159{
160#ifdef MODULE
161 request_module("snd-hda-codec-id:%08x", codec->vendor_id);
162 if (codec_probed(codec))
163 return;
164 request_module("snd-hda-codec-id:%04x*",
165 (codec->vendor_id >> 16) & 0xffff);
166 if (codec_probed(codec))
167 return;
168#endif
169}
170
171/* store the codec vendor name */
172static int get_codec_vendor_name(struct hda_codec *codec)
173{
174 const struct hda_vendor_id *c;
175 const char *vendor = NULL;
176 u16 vendor_id = codec->vendor_id >> 16;
177 char tmp[16];
178
179 for (c = hda_vendor_ids; c->id; c++) {
180 if (c->id == vendor_id) {
181 vendor = c->name;
182 break;
183 }
184 }
185 if (!vendor) {
186 sprintf(tmp, "Generic %04x", vendor_id);
187 vendor = tmp;
188 }
189 codec->vendor_name = kstrdup(vendor, GFP_KERNEL);
190 if (!codec->vendor_name)
191 return -ENOMEM;
192 return 0;
193}
194
195#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
196/* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */
197static bool is_likely_hdmi_codec(struct hda_codec *codec)
198{
199 hda_nid_t nid = codec->start_nid;
200 int i;
201
202 for (i = 0; i < codec->num_nodes; i++, nid++) {
203 unsigned int wcaps = get_wcaps(codec, nid);
204 switch (get_wcaps_type(wcaps)) {
205 case AC_WID_AUD_IN:
206 return false; /* HDMI parser supports only HDMI out */
207 case AC_WID_AUD_OUT:
208 if (!(wcaps & AC_WCAP_DIGITAL))
209 return false;
210 break;
211 }
212 }
213 return true;
214}
215#else
216/* no HDMI codec parser support */
217#define is_likely_hdmi_codec(codec) false
218#endif /* CONFIG_SND_HDA_CODEC_HDMI */
219
220static int codec_bind_generic(struct hda_codec *codec)
221{
222 if (codec->probe_id)
223 return -ENODEV;
224
225 if (is_likely_hdmi_codec(codec)) {
226 codec->probe_id = HDA_CODEC_ID_GENERIC_HDMI;
227#if IS_MODULE(CONFIG_SND_HDA_CODEC_HDMI)
228 request_module("snd-hda-codec-hdmi");
229#endif
230 if (codec_probed(codec))
231 return 0;
232 }
233
234 codec->probe_id = HDA_CODEC_ID_GENERIC;
235#if IS_MODULE(CONFIG_SND_HDA_GENERIC)
236 request_module("snd-hda-codec-generic");
237#endif
238 if (codec_probed(codec))
239 return 0;
240 return -ENODEV;
241}
242
243#if IS_ENABLED(CONFIG_SND_HDA_GENERIC)
244#define is_generic_config(codec) \
245 (codec->modelname && !strcmp(codec->modelname, "generic"))
246#else
247#define is_generic_config(codec) 0
248#endif
249
250/**
251 * snd_hda_codec_configure - (Re-)configure the HD-audio codec
252 * @codec: the HDA codec
253 *
254 * Start parsing of the given codec tree and (re-)initialize the whole
255 * patch instance.
256 *
257 * Returns 0 if successful or a negative error code.
258 */
259int snd_hda_codec_configure(struct hda_codec *codec)
260{
261 int err;
262
263 if (!codec->vendor_name) {
264 err = get_codec_vendor_name(codec);
265 if (err < 0)
266 return err;
267 }
268
269 if (is_generic_config(codec))
270 codec->probe_id = HDA_CODEC_ID_GENERIC;
271 else
272 codec->probe_id = 0;
273
274 err = device_add(hda_codec_dev(codec));
275 if (err < 0)
276 return err;
277
278 if (!codec->preset)
279 codec_bind_module(codec);
280 if (!codec->preset) {
281 err = codec_bind_generic(codec);
282 if (err < 0) {
283 codec_err(codec, "Unable to bind the codec\n");
284 goto error;
285 }
286 }
287
288 /* audio codec should override the mixer name */
289 if (codec->afg || !*codec->bus->card->mixername)
290 snprintf(codec->bus->card->mixername,
291 sizeof(codec->bus->card->mixername),
292 "%s %s", codec->vendor_name, codec->chip_name);
293 return 0;
294
295 error:
296 device_del(hda_codec_dev(codec));
297 return err;
298}
299EXPORT_SYMBOL_GPL(snd_hda_codec_configure);
300
301/*
302 * bus registration
303 */
304struct bus_type snd_hda_bus_type = {
305 .name = "hdaudio",
306 .match = hda_bus_match,
307};
308
309static int __init hda_codec_init(void)
310{
311 return bus_register(&snd_hda_bus_type);
312}
313
314static void __exit hda_codec_exit(void)
315{
316 bus_unregister(&snd_hda_bus_type);
317}
318
319module_init(hda_codec_init);
320module_exit(hda_codec_exit);
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 5e755eb6f19a..61c8174e8013 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -40,69 +40,6 @@
40#define CREATE_TRACE_POINTS 40#define CREATE_TRACE_POINTS
41#include "hda_trace.h" 41#include "hda_trace.h"
42 42
43/*
44 * vendor / preset table
45 */
46
47struct hda_vendor_id {
48 unsigned int id;
49 const char *name;
50};
51
52/* codec vendor labels */
53static struct hda_vendor_id hda_vendor_ids[] = {
54 { 0x1002, "ATI" },
55 { 0x1013, "Cirrus Logic" },
56 { 0x1057, "Motorola" },
57 { 0x1095, "Silicon Image" },
58 { 0x10de, "Nvidia" },
59 { 0x10ec, "Realtek" },
60 { 0x1102, "Creative" },
61 { 0x1106, "VIA" },
62 { 0x111d, "IDT" },
63 { 0x11c1, "LSI" },
64 { 0x11d4, "Analog Devices" },
65 { 0x13f6, "C-Media" },
66 { 0x14f1, "Conexant" },
67 { 0x17e8, "Chrontel" },
68 { 0x1854, "LG" },
69 { 0x1aec, "Wolfson Microelectronics" },
70 { 0x1af4, "QEMU" },
71 { 0x434d, "C-Media" },
72 { 0x8086, "Intel" },
73 { 0x8384, "SigmaTel" },
74 {} /* terminator */
75};
76
77static DEFINE_MUTEX(preset_mutex);
78static LIST_HEAD(hda_preset_tables);
79
80/**
81 * snd_hda_add_codec_preset - Add a codec preset to the chain
82 * @preset: codec preset table to add
83 */
84int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset)
85{
86 mutex_lock(&preset_mutex);
87 list_add_tail(&preset->list, &hda_preset_tables);
88 mutex_unlock(&preset_mutex);
89 return 0;
90}
91EXPORT_SYMBOL_GPL(snd_hda_add_codec_preset);
92
93/**
94 * snd_hda_delete_codec_preset - Delete a codec preset from the chain
95 * @preset: codec preset table to delete
96 */
97int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset)
98{
99 mutex_lock(&preset_mutex);
100 list_del(&preset->list);
101 mutex_unlock(&preset_mutex);
102 return 0;
103}
104EXPORT_SYMBOL_GPL(snd_hda_delete_codec_preset);
105
106#ifdef CONFIG_PM 43#ifdef CONFIG_PM
107#define codec_in_pm(codec) ((codec)->in_pm) 44#define codec_in_pm(codec) ((codec)->in_pm)
108static void hda_power_work(struct work_struct *work); 45static void hda_power_work(struct work_struct *work);
@@ -885,111 +822,6 @@ int snd_hda_bus_new(struct snd_card *card,
885} 822}
886EXPORT_SYMBOL_GPL(snd_hda_bus_new); 823EXPORT_SYMBOL_GPL(snd_hda_bus_new);
887 824
888#if IS_ENABLED(CONFIG_SND_HDA_GENERIC)
889#define is_generic_config(codec) \
890 (codec->modelname && !strcmp(codec->modelname, "generic"))
891#else
892#define is_generic_config(codec) 0
893#endif
894
895#ifdef MODULE
896#define HDA_MODREQ_MAX_COUNT 2 /* two request_modules()'s */
897#else
898#define HDA_MODREQ_MAX_COUNT 0 /* all presets are statically linked */
899#endif
900
901/*
902 * find a matching codec preset
903 */
904static const struct hda_codec_preset *
905find_codec_preset(struct hda_codec *codec)
906{
907 struct hda_codec_preset_list *tbl;
908 const struct hda_codec_preset *preset;
909 unsigned int mod_requested = 0;
910
911 again:
912 mutex_lock(&preset_mutex);
913 list_for_each_entry(tbl, &hda_preset_tables, list) {
914 if (!try_module_get(tbl->owner)) {
915 codec_err(codec, "cannot module_get\n");
916 continue;
917 }
918 for (preset = tbl->preset; preset->id; preset++) {
919 u32 mask = preset->mask;
920 if (preset->afg && preset->afg != codec->afg)
921 continue;
922 if (preset->mfg && preset->mfg != codec->mfg)
923 continue;
924 if (!mask)
925 mask = ~0;
926 if (preset->id == (codec->vendor_id & mask) &&
927 (!preset->rev ||
928 preset->rev == codec->revision_id)) {
929 mutex_unlock(&preset_mutex);
930 codec->owner = tbl->owner;
931 return preset;
932 }
933 }
934 module_put(tbl->owner);
935 }
936 mutex_unlock(&preset_mutex);
937
938 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
939 if (!mod_requested)
940 request_module("snd-hda-codec-id:%08x",
941 codec->vendor_id);
942 else
943 request_module("snd-hda-codec-id:%04x*",
944 (codec->vendor_id >> 16) & 0xffff);
945 mod_requested++;
946 goto again;
947 }
948 return NULL;
949}
950
951/*
952 * get_codec_name - store the codec name
953 */
954static int get_codec_name(struct hda_codec *codec)
955{
956 const struct hda_vendor_id *c;
957 const char *vendor = NULL;
958 u16 vendor_id = codec->vendor_id >> 16;
959 char tmp[16];
960
961 if (codec->vendor_name)
962 goto get_chip_name;
963
964 for (c = hda_vendor_ids; c->id; c++) {
965 if (c->id == vendor_id) {
966 vendor = c->name;
967 break;
968 }
969 }
970 if (!vendor) {
971 sprintf(tmp, "Generic %04x", vendor_id);
972 vendor = tmp;
973 }
974 codec->vendor_name = kstrdup(vendor, GFP_KERNEL);
975 if (!codec->vendor_name)
976 return -ENOMEM;
977
978 get_chip_name:
979 if (codec->chip_name)
980 return 0;
981
982 if (codec->preset && codec->preset->name)
983 codec->chip_name = kstrdup(codec->preset->name, GFP_KERNEL);
984 else {
985 sprintf(tmp, "ID %x", codec->vendor_id & 0xffff);
986 codec->chip_name = kstrdup(tmp, GFP_KERNEL);
987 }
988 if (!codec->chip_name)
989 return -ENOMEM;
990 return 0;
991}
992
993/* 825/*
994 * look for an AFG and MFG nodes 826 * look for an AFG and MFG nodes
995 */ 827 */
@@ -1301,20 +1133,6 @@ get_hda_cvt_setup(struct hda_codec *codec, hda_nid_t nid)
1301} 1133}
1302 1134
1303/* 1135/*
1304 * Dynamic symbol binding for the codec parsers
1305 */
1306
1307#define load_parser(codec, sym) \
1308 ((codec)->parser = (int (*)(struct hda_codec *))symbol_request(sym))
1309
1310static void unload_parser(struct hda_codec *codec)
1311{
1312 if (codec->parser)
1313 symbol_put_addr(codec->parser);
1314 codec->parser = NULL;
1315}
1316
1317/*
1318 * codec destructor 1136 * codec destructor
1319 */ 1137 */
1320static void snd_hda_codec_free(struct hda_codec *codec) 1138static void snd_hda_codec_free(struct hda_codec *codec)
@@ -1322,6 +1140,8 @@ static void snd_hda_codec_free(struct hda_codec *codec)
1322 if (!codec) 1140 if (!codec)
1323 return; 1141 return;
1324 cancel_delayed_work_sync(&codec->jackpoll_work); 1142 cancel_delayed_work_sync(&codec->jackpoll_work);
1143 if (device_is_registered(hda_codec_dev(codec)))
1144 device_del(hda_codec_dev(codec));
1325 snd_hda_jack_tbl_clear(codec); 1145 snd_hda_jack_tbl_clear(codec);
1326 free_init_pincfgs(codec); 1146 free_init_pincfgs(codec);
1327#ifdef CONFIG_PM 1147#ifdef CONFIG_PM
@@ -1335,12 +1155,8 @@ static void snd_hda_codec_free(struct hda_codec *codec)
1335 snd_array_free(&codec->spdif_out); 1155 snd_array_free(&codec->spdif_out);
1336 remove_conn_list(codec); 1156 remove_conn_list(codec);
1337 codec->bus->caddr_tbl[codec->addr] = NULL; 1157 codec->bus->caddr_tbl[codec->addr] = NULL;
1338 if (codec->patch_ops.free)
1339 codec->patch_ops.free(codec);
1340 hda_call_pm_notify(codec, false); /* cancel leftover refcounts */ 1158 hda_call_pm_notify(codec, false); /* cancel leftover refcounts */
1341 snd_hda_sysfs_clear(codec); 1159 snd_hda_sysfs_clear(codec);
1342 unload_parser(codec);
1343 module_put(codec->owner);
1344 free_hda_cache(&codec->amp_cache); 1160 free_hda_cache(&codec->amp_cache);
1345 free_hda_cache(&codec->cmd_cache); 1161 free_hda_cache(&codec->cmd_cache);
1346 kfree(codec->vendor_name); 1162 kfree(codec->vendor_name);
@@ -1348,7 +1164,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
1348 kfree(codec->modelname); 1164 kfree(codec->modelname);
1349 kfree(codec->wcaps); 1165 kfree(codec->wcaps);
1350 codec->bus->num_codecs--; 1166 codec->bus->num_codecs--;
1351 put_device(&codec->dev); 1167 put_device(hda_codec_dev(codec));
1352} 1168}
1353 1169
1354static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, 1170static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
@@ -1360,10 +1176,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,
1360static int snd_hda_codec_dev_register(struct snd_device *device) 1176static int snd_hda_codec_dev_register(struct snd_device *device)
1361{ 1177{
1362 struct hda_codec *codec = device->device_data; 1178 struct hda_codec *codec = device->device_data;
1363 int err = device_add(&codec->dev);
1364 1179
1365 if (err < 0)
1366 return err;
1367 snd_hda_register_beep_device(codec); 1180 snd_hda_register_beep_device(codec);
1368 return 0; 1181 return 0;
1369} 1182}
@@ -1373,7 +1186,6 @@ static int snd_hda_codec_dev_disconnect(struct snd_device *device)
1373 struct hda_codec *codec = device->device_data; 1186 struct hda_codec *codec = device->device_data;
1374 1187
1375 snd_hda_detach_beep_device(codec); 1188 snd_hda_detach_beep_device(codec);
1376 device_del(&codec->dev);
1377 return 0; 1189 return 0;
1378} 1190}
1379 1191
@@ -1386,7 +1198,7 @@ static int snd_hda_codec_dev_free(struct snd_device *device)
1386/* just free the container */ 1198/* just free the container */
1387static void snd_hda_codec_dev_release(struct device *dev) 1199static void snd_hda_codec_dev_release(struct device *dev)
1388{ 1200{
1389 kfree(container_of(dev, struct hda_codec, dev)); 1201 kfree(dev_to_hda_codec(dev));
1390} 1202}
1391 1203
1392/** 1204/**
@@ -1402,6 +1214,7 @@ int snd_hda_codec_new(struct hda_bus *bus,
1402 struct hda_codec **codecp) 1214 struct hda_codec **codecp)
1403{ 1215{
1404 struct hda_codec *codec; 1216 struct hda_codec *codec;
1217 struct device *dev;
1405 char component[31]; 1218 char component[31];
1406 hda_nid_t fg; 1219 hda_nid_t fg;
1407 int err; 1220 int err;
@@ -1429,14 +1242,14 @@ int snd_hda_codec_new(struct hda_bus *bus,
1429 return -ENOMEM; 1242 return -ENOMEM;
1430 } 1243 }
1431 1244
1432 device_initialize(&codec->dev); 1245 dev = hda_codec_dev(codec);
1433 codec->dev.parent = &bus->card->card_dev; 1246 device_initialize(dev);
1434 codec->dev.class = sound_class; 1247 dev->parent = bus->card->dev;
1435 codec->dev.release = snd_hda_codec_dev_release; 1248 dev->bus = &snd_hda_bus_type;
1436 codec->dev.groups = snd_hda_dev_attr_groups; 1249 dev->release = snd_hda_codec_dev_release;
1437 dev_set_name(&codec->dev, "hdaudioC%dD%d", bus->card->number, 1250 dev->groups = snd_hda_dev_attr_groups;
1438 codec_addr); 1251 dev_set_name(dev, "hdaudioC%dD%d", bus->card->number, codec_addr);
1439 dev_set_drvdata(&codec->dev, codec); /* for sysfs */ 1252 dev_set_drvdata(dev, codec); /* for sysfs */
1440 1253
1441 codec->bus = bus; 1254 codec->bus = bus;
1442 codec->addr = codec_addr; 1255 codec->addr = codec_addr;
@@ -1587,92 +1400,6 @@ int snd_hda_codec_update_widgets(struct hda_codec *codec)
1587} 1400}
1588EXPORT_SYMBOL_GPL(snd_hda_codec_update_widgets); 1401EXPORT_SYMBOL_GPL(snd_hda_codec_update_widgets);
1589 1402
1590
1591#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
1592/* if all audio out widgets are digital, let's assume the codec as a HDMI/DP */
1593static bool is_likely_hdmi_codec(struct hda_codec *codec)
1594{
1595 hda_nid_t nid = codec->start_nid;
1596 int i;
1597
1598 for (i = 0; i < codec->num_nodes; i++, nid++) {
1599 unsigned int wcaps = get_wcaps(codec, nid);
1600 switch (get_wcaps_type(wcaps)) {
1601 case AC_WID_AUD_IN:
1602 return false; /* HDMI parser supports only HDMI out */
1603 case AC_WID_AUD_OUT:
1604 if (!(wcaps & AC_WCAP_DIGITAL))
1605 return false;
1606 break;
1607 }
1608 }
1609 return true;
1610}
1611#else
1612/* no HDMI codec parser support */
1613#define is_likely_hdmi_codec(codec) false
1614#endif /* CONFIG_SND_HDA_CODEC_HDMI */
1615
1616/**
1617 * snd_hda_codec_configure - (Re-)configure the HD-audio codec
1618 * @codec: the HDA codec
1619 *
1620 * Start parsing of the given codec tree and (re-)initialize the whole
1621 * patch instance.
1622 *
1623 * Returns 0 if successful or a negative error code.
1624 */
1625int snd_hda_codec_configure(struct hda_codec *codec)
1626{
1627 int (*patch)(struct hda_codec *) = NULL;
1628 int err;
1629
1630 codec->preset = find_codec_preset(codec);
1631 if (!codec->vendor_name || !codec->chip_name) {
1632 err = get_codec_name(codec);
1633 if (err < 0)
1634 return err;
1635 }
1636
1637 if (!is_generic_config(codec) && codec->preset)
1638 patch = codec->preset->patch;
1639 if (!patch) {
1640 unload_parser(codec); /* to be sure */
1641 if (is_likely_hdmi_codec(codec)) {
1642#if IS_MODULE(CONFIG_SND_HDA_CODEC_HDMI)
1643 patch = load_parser(codec, snd_hda_parse_hdmi_codec);
1644#elif IS_BUILTIN(CONFIG_SND_HDA_CODEC_HDMI)
1645 patch = snd_hda_parse_hdmi_codec;
1646#endif
1647 }
1648 if (!patch) {
1649#if IS_MODULE(CONFIG_SND_HDA_GENERIC)
1650 patch = load_parser(codec, snd_hda_parse_generic_codec);
1651#elif IS_BUILTIN(CONFIG_SND_HDA_GENERIC)
1652 patch = snd_hda_parse_generic_codec;
1653#endif
1654 }
1655 if (!patch) {
1656 codec_err(codec, "No codec parser is available\n");
1657 return -ENODEV;
1658 }
1659 }
1660
1661 err = patch(codec);
1662 if (err < 0) {
1663 unload_parser(codec);
1664 return err;
1665 }
1666
1667 /* audio codec should override the mixer name */
1668 if (codec->afg || !*codec->bus->card->mixername)
1669 snprintf(codec->bus->card->mixername,
1670 sizeof(codec->bus->card->mixername),
1671 "%s %s", codec->vendor_name, codec->chip_name);
1672 return 0;
1673}
1674EXPORT_SYMBOL_GPL(snd_hda_codec_configure);
1675
1676/* update the stream-id if changed */ 1403/* update the stream-id if changed */
1677static void update_pcm_stream_id(struct hda_codec *codec, 1404static void update_pcm_stream_id(struct hda_codec *codec,
1678 struct hda_cvt_setup *p, hda_nid_t nid, 1405 struct hda_cvt_setup *p, hda_nid_t nid,
@@ -2739,8 +2466,9 @@ int snd_hda_codec_reset(struct hda_codec *codec)
2739 } 2466 }
2740 } 2467 }
2741 snd_hda_detach_beep_device(codec); 2468 snd_hda_detach_beep_device(codec);
2742 if (codec->patch_ops.free) 2469 if (device_is_registered(hda_codec_dev(codec)))
2743 codec->patch_ops.free(codec); 2470 device_del(hda_codec_dev(codec));
2471
2744 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops)); 2472 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops));
2745 snd_hda_jack_tbl_clear(codec); 2473 snd_hda_jack_tbl_clear(codec);
2746 codec->proc_widget_hook = NULL; 2474 codec->proc_widget_hook = NULL;
@@ -2759,9 +2487,6 @@ int snd_hda_codec_reset(struct hda_codec *codec)
2759 codec->preset = NULL; 2487 codec->preset = NULL;
2760 codec->slave_dig_outs = NULL; 2488 codec->slave_dig_outs = NULL;
2761 codec->spdif_status_reset = 0; 2489 codec->spdif_status_reset = 0;
2762 unload_parser(codec);
2763 module_put(codec->owner);
2764 codec->owner = NULL;
2765 2490
2766 /* allow device access again */ 2491 /* allow device access again */
2767 snd_hda_unlock_devices(bus); 2492 snd_hda_unlock_devices(bus);
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 96421a3b32cd..3d42717e0e65 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -174,15 +174,22 @@ struct hda_codec_preset {
174 int (*patch)(struct hda_codec *codec); 174 int (*patch)(struct hda_codec *codec);
175}; 175};
176 176
177struct hda_codec_preset_list { 177#define HDA_CODEC_ID_GENERIC_HDMI 0x00000101
178#define HDA_CODEC_ID_GENERIC 0x00000201
179
180struct hda_codec_driver {
181 struct device_driver driver;
178 const struct hda_codec_preset *preset; 182 const struct hda_codec_preset *preset;
179 struct module *owner;
180 struct list_head list;
181}; 183};
182 184
183/* initial hook */ 185int __hda_codec_driver_register(struct hda_codec_driver *drv, const char *name,
184int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset); 186 struct module *owner);
185int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset); 187#define hda_codec_driver_register(drv) \
188 __hda_codec_driver_register(drv, KBUILD_MODNAME, THIS_MODULE)
189void hda_codec_driver_unregister(struct hda_codec_driver *drv);
190#define module_hda_codec_driver(drv) \
191 module_driver(drv, hda_codec_driver_register, \
192 hda_codec_driver_unregister)
186 193
187/* ops set by the preset patch */ 194/* ops set by the preset patch */
188struct hda_codec_ops { 195struct hda_codec_ops {
@@ -286,11 +293,10 @@ struct hda_codec {
286 u32 vendor_id; 293 u32 vendor_id;
287 u32 subsystem_id; 294 u32 subsystem_id;
288 u32 revision_id; 295 u32 revision_id;
296 u32 probe_id; /* overridden id for probing */
289 297
290 /* detected preset */ 298 /* detected preset */
291 const struct hda_codec_preset *preset; 299 const struct hda_codec_preset *preset;
292 struct module *owner;
293 int (*parser)(struct hda_codec *codec);
294 const char *vendor_name; /* codec vendor name */ 300 const char *vendor_name; /* codec vendor name */
295 const char *chip_name; /* codec chip name */ 301 const char *chip_name; /* codec chip name */
296 const char *modelname; /* model name for preset */ 302 const char *modelname; /* model name for preset */
@@ -408,6 +414,11 @@ struct hda_codec {
408 struct snd_array verbs; 414 struct snd_array verbs;
409}; 415};
410 416
417#define dev_to_hda_codec(_dev) container_of(_dev, struct hda_codec, dev)
418#define hda_codec_dev(_dev) (&(_dev)->dev)
419
420extern struct bus_type snd_hda_bus_type;
421
411/* direction */ 422/* direction */
412enum { 423enum {
413 HDA_INPUT, HDA_OUTPUT 424 HDA_INPUT, HDA_OUTPUT
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index b680b4ec6331..947d1a50f384 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -5493,13 +5493,11 @@ static const struct hda_codec_ops generic_patch_ops = {
5493#endif 5493#endif
5494}; 5494};
5495 5495
5496/** 5496/*
5497 * snd_hda_parse_generic_codec - Generic codec parser 5497 * snd_hda_parse_generic_codec - Generic codec parser
5498 * @codec: the HDA codec 5498 * @codec: the HDA codec
5499 *
5500 * This should be called from the HDA codec core.
5501 */ 5499 */
5502int snd_hda_parse_generic_codec(struct hda_codec *codec) 5500static int snd_hda_parse_generic_codec(struct hda_codec *codec)
5503{ 5501{
5504 struct hda_gen_spec *spec; 5502 struct hda_gen_spec *spec;
5505 int err; 5503 int err;
@@ -5525,7 +5523,17 @@ error:
5525 snd_hda_gen_free(codec); 5523 snd_hda_gen_free(codec);
5526 return err; 5524 return err;
5527} 5525}
5528EXPORT_SYMBOL_GPL(snd_hda_parse_generic_codec); 5526
5527static const struct hda_codec_preset snd_hda_preset_generic[] = {
5528 { .id = HDA_CODEC_ID_GENERIC, .patch = snd_hda_parse_generic_codec },
5529 {} /* terminator */
5530};
5531
5532static struct hda_codec_driver generic_driver = {
5533 .preset = snd_hda_preset_generic,
5534};
5535
5536module_hda_codec_driver(generic_driver);
5529 5537
5530MODULE_LICENSE("GPL"); 5538MODULE_LICENSE("GPL");
5531MODULE_DESCRIPTION("Generic HD-audio codec parser"); 5539MODULE_DESCRIPTION("Generic HD-audio codec parser");
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 49c08a7278c4..2f7d9646a41d 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -351,12 +351,6 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec,
351 struct hda_multi_out *mout); 351 struct hda_multi_out *mout);
352 352
353/* 353/*
354 * generic codec parser
355 */
356int snd_hda_parse_generic_codec(struct hda_codec *codec);
357int snd_hda_parse_hdmi_codec(struct hda_codec *codec);
358
359/*
360 * generic proc interface 354 * generic proc interface
361 */ 355 */
362#ifdef CONFIG_PROC_FS 356#ifdef CONFIG_PROC_FS
@@ -783,9 +777,13 @@ void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
783 777
784/* 778/*
785 */ 779 */
786#define codec_err(codec, fmt, args...) dev_err(&(codec)->dev, fmt, ##args) 780#define codec_err(codec, fmt, args...) \
787#define codec_warn(codec, fmt, args...) dev_warn(&(codec)->dev, fmt, ##args) 781 dev_err(hda_codec_dev(codec), fmt, ##args)
788#define codec_info(codec, fmt, args...) dev_info(&(codec)->dev, fmt, ##args) 782#define codec_warn(codec, fmt, args...) \
789#define codec_dbg(codec, fmt, args...) dev_dbg(&(codec)->dev, fmt, ##args) 783 dev_warn(hda_codec_dev(codec), fmt, ##args)
784#define codec_info(codec, fmt, args...) \
785 dev_info(hda_codec_dev(codec), fmt, ##args)
786#define codec_dbg(codec, fmt, args...) \
787 dev_dbg(hda_codec_dev(codec), fmt, ##args)
790 788
791#endif /* __SOUND_HDA_LOCAL_H */ 789#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index d285904cdb64..af4c7be86c27 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -1194,20 +1194,8 @@ MODULE_ALIAS("snd-hda-codec-id:11d4*");
1194MODULE_LICENSE("GPL"); 1194MODULE_LICENSE("GPL");
1195MODULE_DESCRIPTION("Analog Devices HD-audio codec"); 1195MODULE_DESCRIPTION("Analog Devices HD-audio codec");
1196 1196
1197static struct hda_codec_preset_list analog_list = { 1197static struct hda_codec_driver analog_driver = {
1198 .preset = snd_hda_preset_analog, 1198 .preset = snd_hda_preset_analog,
1199 .owner = THIS_MODULE,
1200}; 1199};
1201 1200
1202static int __init patch_analog_init(void) 1201module_hda_codec_driver(analog_driver);
1203{
1204 return snd_hda_add_codec_preset(&analog_list);
1205}
1206
1207static void __exit patch_analog_exit(void)
1208{
1209 snd_hda_delete_codec_preset(&analog_list);
1210}
1211
1212module_init(patch_analog_init)
1213module_exit(patch_analog_exit)
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c
index 5e65999e0d8e..447302695195 100644
--- a/sound/pci/hda/patch_ca0110.c
+++ b/sound/pci/hda/patch_ca0110.c
@@ -98,20 +98,8 @@ MODULE_ALIAS("snd-hda-codec-id:1102000d");
98MODULE_LICENSE("GPL"); 98MODULE_LICENSE("GPL");
99MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec"); 99MODULE_DESCRIPTION("Creative CA0110-IBG HD-audio codec");
100 100
101static struct hda_codec_preset_list ca0110_list = { 101static struct hda_codec_driver ca0110_driver = {
102 .preset = snd_hda_preset_ca0110, 102 .preset = snd_hda_preset_ca0110,
103 .owner = THIS_MODULE,
104}; 103};
105 104
106static int __init patch_ca0110_init(void) 105module_hda_codec_driver(ca0110_driver);
107{
108 return snd_hda_add_codec_preset(&ca0110_list);
109}
110
111static void __exit patch_ca0110_exit(void)
112{
113 snd_hda_delete_codec_preset(&ca0110_list);
114}
115
116module_init(patch_ca0110_init)
117module_exit(patch_ca0110_exit)
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index e0383eea9880..81991b4134cd 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -4702,20 +4702,8 @@ MODULE_ALIAS("snd-hda-codec-id:11020011");
4702MODULE_LICENSE("GPL"); 4702MODULE_LICENSE("GPL");
4703MODULE_DESCRIPTION("Creative Sound Core3D codec"); 4703MODULE_DESCRIPTION("Creative Sound Core3D codec");
4704 4704
4705static struct hda_codec_preset_list ca0132_list = { 4705static struct hda_codec_driver ca0132_driver = {
4706 .preset = snd_hda_preset_ca0132, 4706 .preset = snd_hda_preset_ca0132,
4707 .owner = THIS_MODULE,
4708}; 4707};
4709 4708
4710static int __init patch_ca0132_init(void) 4709module_hda_codec_driver(ca0132_driver);
4711{
4712 return snd_hda_add_codec_preset(&ca0132_list);
4713}
4714
4715static void __exit patch_ca0132_exit(void)
4716{
4717 snd_hda_delete_codec_preset(&ca0132_list);
4718}
4719
4720module_init(patch_ca0132_init)
4721module_exit(patch_ca0132_exit)
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 1589c9bcce3e..1af133933bc0 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -1219,20 +1219,8 @@ MODULE_ALIAS("snd-hda-codec-id:10134213");
1219MODULE_LICENSE("GPL"); 1219MODULE_LICENSE("GPL");
1220MODULE_DESCRIPTION("Cirrus Logic HD-audio codec"); 1220MODULE_DESCRIPTION("Cirrus Logic HD-audio codec");
1221 1221
1222static struct hda_codec_preset_list cirrus_list = { 1222static struct hda_codec_driver cirrus_driver = {
1223 .preset = snd_hda_preset_cirrus, 1223 .preset = snd_hda_preset_cirrus,
1224 .owner = THIS_MODULE,
1225}; 1224};
1226 1225
1227static int __init patch_cirrus_init(void) 1226module_hda_codec_driver(cirrus_driver);
1228{
1229 return snd_hda_add_codec_preset(&cirrus_list);
1230}
1231
1232static void __exit patch_cirrus_exit(void)
1233{
1234 snd_hda_delete_codec_preset(&cirrus_list);
1235}
1236
1237module_init(patch_cirrus_init)
1238module_exit(patch_cirrus_exit)
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index c895a8f21192..617d9012e78a 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -137,20 +137,8 @@ MODULE_ALIAS("snd-hda-codec-id:434d4980");
137MODULE_LICENSE("GPL"); 137MODULE_LICENSE("GPL");
138MODULE_DESCRIPTION("C-Media HD-audio codec"); 138MODULE_DESCRIPTION("C-Media HD-audio codec");
139 139
140static struct hda_codec_preset_list cmedia_list = { 140static struct hda_codec_driver cmedia_driver = {
141 .preset = snd_hda_preset_cmedia, 141 .preset = snd_hda_preset_cmedia,
142 .owner = THIS_MODULE,
143}; 142};
144 143
145static int __init patch_cmedia_init(void) 144module_hda_codec_driver(cmedia_driver);
146{
147 return snd_hda_add_codec_preset(&cmedia_list);
148}
149
150static void __exit patch_cmedia_exit(void)
151{
152 snd_hda_delete_codec_preset(&cmedia_list);
153}
154
155module_init(patch_cmedia_init)
156module_exit(patch_cmedia_exit)
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index fd3ed18670e9..15a0a7d38c35 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -1007,20 +1007,8 @@ MODULE_ALIAS("snd-hda-codec-id:14f151d7");
1007MODULE_LICENSE("GPL"); 1007MODULE_LICENSE("GPL");
1008MODULE_DESCRIPTION("Conexant HD-audio codec"); 1008MODULE_DESCRIPTION("Conexant HD-audio codec");
1009 1009
1010static struct hda_codec_preset_list conexant_list = { 1010static struct hda_codec_driver conexant_driver = {
1011 .preset = snd_hda_preset_conexant, 1011 .preset = snd_hda_preset_conexant,
1012 .owner = THIS_MODULE,
1013}; 1012};
1014 1013
1015static int __init patch_conexant_init(void) 1014module_hda_codec_driver(conexant_driver);
1016{
1017 return snd_hda_add_codec_preset(&conexant_list);
1018}
1019
1020static void __exit patch_conexant_exit(void)
1021{
1022 snd_hda_delete_codec_preset(&conexant_list);
1023}
1024
1025module_init(patch_conexant_init)
1026module_exit(patch_conexant_exit)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index b422e406a9cb..f1812aabd63e 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -3301,15 +3301,6 @@ static int patch_via_hdmi(struct hda_codec *codec)
3301} 3301}
3302 3302
3303/* 3303/*
3304 * called from hda_codec.c for generic HDMI support
3305 */
3306int snd_hda_parse_hdmi_codec(struct hda_codec *codec)
3307{
3308 return patch_generic_hdmi(codec);
3309}
3310EXPORT_SYMBOL_GPL(snd_hda_parse_hdmi_codec);
3311
3312/*
3313 * patch entries 3304 * patch entries
3314 */ 3305 */
3315static const struct hda_codec_preset snd_hda_preset_hdmi[] = { 3306static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
@@ -3373,6 +3364,8 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
3373{ .id = 0x80862882, .name = "Valleyview2 HDMI", .patch = patch_generic_hdmi }, 3364{ .id = 0x80862882, .name = "Valleyview2 HDMI", .patch = patch_generic_hdmi },
3374{ .id = 0x80862883, .name = "Braswell HDMI", .patch = patch_generic_hdmi }, 3365{ .id = 0x80862883, .name = "Braswell HDMI", .patch = patch_generic_hdmi },
3375{ .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi }, 3366{ .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi },
3367/* special ID for generic HDMI */
3368{ .id = HDA_CODEC_ID_GENERIC_HDMI, .patch = patch_generic_hdmi },
3376{} /* terminator */ 3369{} /* terminator */
3377}; 3370};
3378 3371
@@ -3442,20 +3435,8 @@ MODULE_ALIAS("snd-hda-codec-intelhdmi");
3442MODULE_ALIAS("snd-hda-codec-nvhdmi"); 3435MODULE_ALIAS("snd-hda-codec-nvhdmi");
3443MODULE_ALIAS("snd-hda-codec-atihdmi"); 3436MODULE_ALIAS("snd-hda-codec-atihdmi");
3444 3437
3445static struct hda_codec_preset_list intel_list = { 3438static struct hda_codec_driver hdmi_driver = {
3446 .preset = snd_hda_preset_hdmi, 3439 .preset = snd_hda_preset_hdmi,
3447 .owner = THIS_MODULE,
3448}; 3440};
3449 3441
3450static int __init patch_hdmi_init(void) 3442module_hda_codec_driver(hdmi_driver);
3451{
3452 return snd_hda_add_codec_preset(&intel_list);
3453}
3454
3455static void __exit patch_hdmi_exit(void)
3456{
3457 snd_hda_delete_codec_preset(&intel_list);
3458}
3459
3460module_init(patch_hdmi_init)
3461module_exit(patch_hdmi_exit)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index b2b24a8b3dac..70808f92276a 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6514,20 +6514,8 @@ MODULE_ALIAS("snd-hda-codec-id:10ec*");
6514MODULE_LICENSE("GPL"); 6514MODULE_LICENSE("GPL");
6515MODULE_DESCRIPTION("Realtek HD-audio codec"); 6515MODULE_DESCRIPTION("Realtek HD-audio codec");
6516 6516
6517static struct hda_codec_preset_list realtek_list = { 6517static struct hda_codec_driver realtek_driver = {
6518 .preset = snd_hda_preset_realtek, 6518 .preset = snd_hda_preset_realtek,
6519 .owner = THIS_MODULE,
6520}; 6519};
6521 6520
6522static int __init patch_realtek_init(void) 6521module_hda_codec_driver(realtek_driver);
6523{
6524 return snd_hda_add_codec_preset(&realtek_list);
6525}
6526
6527static void __exit patch_realtek_exit(void)
6528{
6529 snd_hda_delete_codec_preset(&realtek_list);
6530}
6531
6532module_init(patch_realtek_init)
6533module_exit(patch_realtek_exit)
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index 3208ad69583e..38a477333321 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -319,20 +319,8 @@ MODULE_ALIAS("snd-hda-codec-id:18540018");
319MODULE_LICENSE("GPL"); 319MODULE_LICENSE("GPL");
320MODULE_DESCRIPTION("Si3054 HD-audio modem codec"); 320MODULE_DESCRIPTION("Si3054 HD-audio modem codec");
321 321
322static struct hda_codec_preset_list si3054_list = { 322static struct hda_codec_driver si3054_driver = {
323 .preset = snd_hda_preset_si3054, 323 .preset = snd_hda_preset_si3054,
324 .owner = THIS_MODULE,
325}; 324};
326 325
327static int __init patch_si3054_init(void) 326module_hda_codec_driver(si3054_driver);
328{
329 return snd_hda_add_codec_preset(&si3054_list);
330}
331
332static void __exit patch_si3054_exit(void)
333{
334 snd_hda_delete_codec_preset(&si3054_list);
335}
336
337module_init(patch_si3054_init)
338module_exit(patch_si3054_exit)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 87eff3173ce9..6a2163056216 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -5091,20 +5091,8 @@ MODULE_ALIAS("snd-hda-codec-id:111d*");
5091MODULE_LICENSE("GPL"); 5091MODULE_LICENSE("GPL");
5092MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec"); 5092MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
5093 5093
5094static struct hda_codec_preset_list sigmatel_list = { 5094static struct hda_codec_driver sigmatel_driver = {
5095 .preset = snd_hda_preset_sigmatel, 5095 .preset = snd_hda_preset_sigmatel,
5096 .owner = THIS_MODULE,
5097}; 5096};
5098 5097
5099static int __init patch_sigmatel_init(void) 5098module_hda_codec_driver(sigmatel_driver);
5100{
5101 return snd_hda_add_codec_preset(&sigmatel_list);
5102}
5103
5104static void __exit patch_sigmatel_exit(void)
5105{
5106 snd_hda_delete_codec_preset(&sigmatel_list);
5107}
5108
5109module_init(patch_sigmatel_init)
5110module_exit(patch_sigmatel_exit)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 3de6d3d779c9..2045f33b1ace 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -1884,23 +1884,11 @@ static const struct hda_codec_preset snd_hda_preset_via[] = {
1884 1884
1885MODULE_ALIAS("snd-hda-codec-id:1106*"); 1885MODULE_ALIAS("snd-hda-codec-id:1106*");
1886 1886
1887static struct hda_codec_preset_list via_list = { 1887static struct hda_codec_driver via_driver = {
1888 .preset = snd_hda_preset_via, 1888 .preset = snd_hda_preset_via,
1889 .owner = THIS_MODULE,
1890}; 1889};
1891 1890
1892MODULE_LICENSE("GPL"); 1891MODULE_LICENSE("GPL");
1893MODULE_DESCRIPTION("VIA HD-audio codec"); 1892MODULE_DESCRIPTION("VIA HD-audio codec");
1894 1893
1895static int __init patch_via_init(void) 1894module_hda_codec_driver(via_driver);
1896{
1897 return snd_hda_add_codec_preset(&via_list);
1898}
1899
1900static void __exit patch_via_exit(void)
1901{
1902 snd_hda_delete_codec_preset(&via_list);
1903}
1904
1905module_init(patch_via_init)
1906module_exit(patch_via_exit)