aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-02-17 15:46:37 -0500
committerTakashi Iwai <tiwai@suse.de>2015-03-23 08:15:51 -0400
commite3d280fc6d42017b2379503fbda83655a05294fe (patch)
treecc89c4b22054d620163f0d6bdad901f43957dbf5 /sound/pci
parent3372dbdd8ca11f51be8c6a30b2bc79eb04c4a902 (diff)
ALSA: hda - Make snd_hda_bus_type public
Define the common hd-audio driver and device types to bind over snd_hda_bus_type publicly. This allows to implement other type of device and driver code over hd-audio bus. Now both struct hda_codec and struct hda_codec_driver inherit these new struct hdac_device and struct hdac_driver, respectively. The bus registration is done in subsys_initcall() to assure it before any other driver registrations. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/Kconfig1
-rw-r--r--sound/pci/hda/hda_bind.c47
-rw-r--r--sound/pci/hda/hda_codec.c1
-rw-r--r--sound/pci/hda/hda_codec.h11
4 files changed, 21 insertions, 39 deletions
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
index 7f0f2c5a4e97..a5ed1c181784 100644
--- a/sound/pci/hda/Kconfig
+++ b/sound/pci/hda/Kconfig
@@ -5,6 +5,7 @@ config SND_HDA
5 select SND_PCM 5 select SND_PCM
6 select SND_VMASTER 6 select SND_VMASTER
7 select SND_KCTL_JACK 7 select SND_KCTL_JACK
8 select SND_HDA_CORE
8 9
9config SND_HDA_INTEL 10config SND_HDA_INTEL
10 tristate "HD Audio PCI" 11 tristate "HD Audio PCI"
diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c
index 1f40ce3c1696..e3bd2807b644 100644
--- a/sound/pci/hda/hda_bind.c
+++ b/sound/pci/hda/hda_bind.c
@@ -47,11 +47,11 @@ static struct hda_vendor_id hda_vendor_ids[] = {
47/* 47/*
48 * find a matching codec preset 48 * find a matching codec preset
49 */ 49 */
50static int hda_bus_match(struct device *dev, struct device_driver *drv) 50static int hda_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
51{ 51{
52 struct hda_codec *codec = container_of(dev, struct hda_codec, dev); 52 struct hda_codec *codec = container_of(dev, struct hda_codec, core);
53 struct hda_codec_driver *driver = 53 struct hda_codec_driver *driver =
54 container_of(drv, struct hda_codec_driver, driver); 54 container_of(drv, struct hda_codec_driver, core);
55 const struct hda_codec_preset *preset; 55 const struct hda_codec_preset *preset;
56 /* check probe_id instead of vendor_id if set */ 56 /* check probe_id instead of vendor_id if set */
57 u32 id = codec->probe_id ? codec->probe_id : codec->vendor_id; 57 u32 id = codec->probe_id ? codec->probe_id : codec->vendor_id;
@@ -154,20 +154,22 @@ static void hda_codec_driver_shutdown(struct device *dev)
154int __hda_codec_driver_register(struct hda_codec_driver *drv, const char *name, 154int __hda_codec_driver_register(struct hda_codec_driver *drv, const char *name,
155 struct module *owner) 155 struct module *owner)
156{ 156{
157 drv->driver.name = name; 157 drv->core.driver.name = name;
158 drv->driver.owner = owner; 158 drv->core.driver.owner = owner;
159 drv->driver.bus = &snd_hda_bus_type; 159 drv->core.driver.bus = &snd_hda_bus_type;
160 drv->driver.probe = hda_codec_driver_probe; 160 drv->core.driver.probe = hda_codec_driver_probe;
161 drv->driver.remove = hda_codec_driver_remove; 161 drv->core.driver.remove = hda_codec_driver_remove;
162 drv->driver.shutdown = hda_codec_driver_shutdown; 162 drv->core.driver.shutdown = hda_codec_driver_shutdown;
163 drv->driver.pm = &hda_codec_driver_pm; 163 drv->core.driver.pm = &hda_codec_driver_pm;
164 return driver_register(&drv->driver); 164 drv->core.type = HDA_DEV_LEGACY;
165 drv->core.match = hda_codec_match;
166 return driver_register(&drv->core.driver);
165} 167}
166EXPORT_SYMBOL_GPL(__hda_codec_driver_register); 168EXPORT_SYMBOL_GPL(__hda_codec_driver_register);
167 169
168void hda_codec_driver_unregister(struct hda_codec_driver *drv) 170void hda_codec_driver_unregister(struct hda_codec_driver *drv)
169{ 171{
170 driver_unregister(&drv->driver); 172 driver_unregister(&drv->core.driver);
171} 173}
172EXPORT_SYMBOL_GPL(hda_codec_driver_unregister); 174EXPORT_SYMBOL_GPL(hda_codec_driver_unregister);
173 175
@@ -319,24 +321,3 @@ int snd_hda_codec_configure(struct hda_codec *codec)
319 return err; 321 return err;
320} 322}
321EXPORT_SYMBOL_GPL(snd_hda_codec_configure); 323EXPORT_SYMBOL_GPL(snd_hda_codec_configure);
322
323/*
324 * bus registration
325 */
326struct bus_type snd_hda_bus_type = {
327 .name = "hdaudio",
328 .match = hda_bus_match,
329};
330
331static int __init hda_codec_init(void)
332{
333 return bus_register(&snd_hda_bus_type);
334}
335
336static void __exit hda_codec_exit(void)
337{
338 bus_unregister(&snd_hda_bus_type);
339}
340
341module_init(hda_codec_init);
342module_exit(hda_codec_exit);
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 7e38d6f7314b..e14f9f562874 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1294,6 +1294,7 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
1294 dev_set_name(dev, "hdaudioC%dD%d", card->number, codec_addr); 1294 dev_set_name(dev, "hdaudioC%dD%d", card->number, codec_addr);
1295 dev_set_drvdata(dev, codec); /* for sysfs */ 1295 dev_set_drvdata(dev, codec); /* for sysfs */
1296 device_enable_async_suspend(dev); 1296 device_enable_async_suspend(dev);
1297 codec->core.type = HDA_DEV_LEGACY;
1297 1298
1298 codec->bus = bus; 1299 codec->bus = bus;
1299 codec->card = card; 1300 codec->card = card;
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index ccf355d4a8fa..31a9e10e5137 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -26,6 +26,7 @@
26#include <sound/control.h> 26#include <sound/control.h>
27#include <sound/pcm.h> 27#include <sound/pcm.h>
28#include <sound/hwdep.h> 28#include <sound/hwdep.h>
29#include <sound/hdaudio.h>
29#include <sound/hda_verbs.h> 30#include <sound/hda_verbs.h>
30 31
31/* 32/*
@@ -172,7 +173,7 @@ struct hda_codec_preset {
172#define HDA_CODEC_ID_GENERIC 0x00000201 173#define HDA_CODEC_ID_GENERIC 0x00000201
173 174
174struct hda_codec_driver { 175struct hda_codec_driver {
175 struct device_driver driver; 176 struct hdac_driver core;
176 const struct hda_codec_preset *preset; 177 const struct hda_codec_preset *preset;
177}; 178};
178 179
@@ -276,7 +277,7 @@ struct hda_pcm {
276 277
277/* codec information */ 278/* codec information */
278struct hda_codec { 279struct hda_codec {
279 struct device dev; 280 struct hdac_device core;
280 struct hda_bus *bus; 281 struct hda_bus *bus;
281 struct snd_card *card; 282 struct snd_card *card;
282 unsigned int addr; /* codec addr*/ 283 unsigned int addr; /* codec addr*/
@@ -409,10 +410,8 @@ struct hda_codec {
409 struct snd_array verbs; 410 struct snd_array verbs;
410}; 411};
411 412
412#define dev_to_hda_codec(_dev) container_of(_dev, struct hda_codec, dev) 413#define dev_to_hda_codec(_dev) container_of(_dev, struct hda_codec, core.dev)
413#define hda_codec_dev(_dev) (&(_dev)->dev) 414#define hda_codec_dev(_dev) (&(_dev)->core.dev)
414
415extern struct bus_type snd_hda_bus_type;
416 415
417/* direction */ 416/* direction */
418enum { 417enum {