0001
0002
0003
0004
0005 #include <linux/init.h>
0006 #include <linux/device.h>
0007 #include <linux/module.h>
0008 #include <linux/mod_devicetable.h>
0009 #include <linux/export.h>
0010 #include <sound/hdaudio.h>
0011
0012 MODULE_DESCRIPTION("HD-audio bus");
0013 MODULE_LICENSE("GPL");
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 const struct hda_device_id *
0024 hdac_get_device_id(struct hdac_device *hdev, struct hdac_driver *drv)
0025 {
0026 if (drv->id_table) {
0027 const struct hda_device_id *id = drv->id_table;
0028
0029 while (id->vendor_id) {
0030 if (hdev->vendor_id == id->vendor_id &&
0031 (!id->rev_id || id->rev_id == hdev->revision_id))
0032 return id;
0033 id++;
0034 }
0035 }
0036
0037 return NULL;
0038 }
0039 EXPORT_SYMBOL_GPL(hdac_get_device_id);
0040
0041 static int hdac_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
0042 {
0043 if (hdac_get_device_id(dev, drv))
0044 return 1;
0045 else
0046 return 0;
0047 }
0048
0049 static int hda_bus_match(struct device *dev, struct device_driver *drv)
0050 {
0051 struct hdac_device *hdev = dev_to_hdac_dev(dev);
0052 struct hdac_driver *hdrv = drv_to_hdac_driver(drv);
0053
0054 if (hdev->type != hdrv->type)
0055 return 0;
0056
0057
0058
0059
0060
0061 if (hdrv->match)
0062 return hdrv->match(hdev, hdrv);
0063 else
0064 return hdac_codec_match(hdev, hdrv);
0065 return 1;
0066 }
0067
0068 static int hda_uevent(struct device *dev, struct kobj_uevent_env *env)
0069 {
0070 char modalias[32];
0071
0072 snd_hdac_codec_modalias(dev_to_hdac_dev(dev), modalias,
0073 sizeof(modalias));
0074 if (add_uevent_var(env, "MODALIAS=%s", modalias))
0075 return -ENOMEM;
0076 return 0;
0077 }
0078
0079 struct bus_type snd_hda_bus_type = {
0080 .name = "hdaudio",
0081 .match = hda_bus_match,
0082 .uevent = hda_uevent,
0083 };
0084 EXPORT_SYMBOL_GPL(snd_hda_bus_type);
0085
0086 static int __init hda_bus_init(void)
0087 {
0088 return bus_register(&snd_hda_bus_type);
0089 }
0090
0091 static void __exit hda_bus_exit(void)
0092 {
0093 bus_unregister(&snd_hda_bus_type);
0094 }
0095
0096 subsys_initcall(hda_bus_init);
0097 module_exit(hda_bus_exit);