forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
Showing
10 changed files
with
113 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* HD-audio core stuff | ||
*/ | ||
|
||
#ifndef __SOUND_HDAUDIO_H | ||
#define __SOUND_HDAUDIO_H | ||
|
||
#include <linux/device.h> | ||
|
||
/* | ||
* exported bus type | ||
*/ | ||
extern struct bus_type snd_hda_bus_type; | ||
|
||
/* | ||
* HD-audio codec base device | ||
*/ | ||
struct hdac_device { | ||
struct device dev; | ||
int type; | ||
}; | ||
|
||
/* device/driver type used for matching */ | ||
enum { | ||
HDA_DEV_CORE, | ||
HDA_DEV_LEGACY, | ||
}; | ||
|
||
#define dev_to_hdac_dev(_dev) container_of(_dev, struct hdac_device, dev) | ||
|
||
/* | ||
* HD-audio codec base driver | ||
*/ | ||
struct hdac_driver { | ||
struct device_driver driver; | ||
int type; | ||
int (*match)(struct hdac_device *dev, struct hdac_driver *drv); | ||
}; | ||
|
||
#define drv_to_hdac_driver(_drv) container_of(_drv, struct hdac_driver, driver) | ||
|
||
#endif /* __SOUND_HDAUDIO_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
config SND_HDA_CORE | ||
tristate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
snd-hda-core-objs := hda_bus_type.o | ||
|
||
obj-$(CONFIG_SND_HDA_CORE) += snd-hda-core.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* HD-audio bus | ||
*/ | ||
#include <linux/init.h> | ||
#include <linux/device.h> | ||
#include <linux/module.h> | ||
#include <linux/export.h> | ||
#include <sound/hdaudio.h> | ||
|
||
MODULE_DESCRIPTION("HD-audio bus"); | ||
MODULE_LICENSE("GPL"); | ||
|
||
static int hda_bus_match(struct device *dev, struct device_driver *drv) | ||
{ | ||
struct hdac_device *hdev = dev_to_hdac_dev(dev); | ||
struct hdac_driver *hdrv = drv_to_hdac_driver(drv); | ||
|
||
if (hdev->type != hdrv->type) | ||
return 0; | ||
if (hdrv->match) | ||
return hdrv->match(hdev, hdrv); | ||
return 1; | ||
} | ||
|
||
struct bus_type snd_hda_bus_type = { | ||
.name = "hdaudio", | ||
.match = hda_bus_match, | ||
}; | ||
EXPORT_SYMBOL_GPL(snd_hda_bus_type); | ||
|
||
static int __init hda_bus_init(void) | ||
{ | ||
return bus_register(&snd_hda_bus_type); | ||
} | ||
|
||
static void __exit hda_bus_exit(void) | ||
{ | ||
bus_unregister(&snd_hda_bus_type); | ||
} | ||
|
||
subsys_initcall(hda_bus_init); | ||
module_exit(hda_bus_exit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters