diff options
author | Vinod Koul <vinod.koul@intel.com> | 2015-06-03 02:54:31 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-06-03 05:58:49 -0400 |
commit | ec71efc9aaa53b8944b119f8bedd0559c8ed5453 (patch) | |
tree | 8fa129032db0ae14c7717b8d26879a6b1c90563a /sound/hda | |
parent | 03b135cebc47d75ea2dc346770374ab741966955 (diff) |
ALSA: hda - add HDA default codec match function
HDA codec drivers can be matched using vendor id and revision id typically.
So provide a match function which does this and is loaded when driver hasn't
provided one (default behaviour)
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/hda')
-rw-r--r-- | sound/hda/hda_bus_type.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/sound/hda/hda_bus_type.c b/sound/hda/hda_bus_type.c index 519914a12e8a..89c2711baaaf 100644 --- a/sound/hda/hda_bus_type.c +++ b/sound/hda/hda_bus_type.c | |||
@@ -10,6 +10,40 @@ | |||
10 | MODULE_DESCRIPTION("HD-audio bus"); | 10 | MODULE_DESCRIPTION("HD-audio bus"); |
11 | MODULE_LICENSE("GPL"); | 11 | MODULE_LICENSE("GPL"); |
12 | 12 | ||
13 | /** | ||
14 | * hdac_get_device_id - gets the hdac device id entry | ||
15 | * @hdev: HD-audio core device | ||
16 | * @drv: HD-audio codec driver | ||
17 | * | ||
18 | * Compares the hdac device vendor_id and revision_id to the hdac_device | ||
19 | * driver id_table and returns the matching device id entry. | ||
20 | */ | ||
21 | const struct hda_device_id * | ||
22 | hdac_get_device_id(struct hdac_device *hdev, struct hdac_driver *drv) | ||
23 | { | ||
24 | if (drv->id_table) { | ||
25 | const struct hda_device_id *id = drv->id_table; | ||
26 | |||
27 | while (id->vendor_id) { | ||
28 | if (hdev->vendor_id == id->vendor_id && | ||
29 | (!id->rev_id || id->rev_id == hdev->revision_id)) | ||
30 | return id; | ||
31 | id++; | ||
32 | } | ||
33 | } | ||
34 | |||
35 | return NULL; | ||
36 | } | ||
37 | EXPORT_SYMBOL_GPL(hdac_get_device_id); | ||
38 | |||
39 | static int hdac_codec_match(struct hdac_device *dev, struct hdac_driver *drv) | ||
40 | { | ||
41 | if (hdac_get_device_id(dev, drv)) | ||
42 | return 1; | ||
43 | else | ||
44 | return 0; | ||
45 | } | ||
46 | |||
13 | static int hda_bus_match(struct device *dev, struct device_driver *drv) | 47 | static int hda_bus_match(struct device *dev, struct device_driver *drv) |
14 | { | 48 | { |
15 | struct hdac_device *hdev = dev_to_hdac_dev(dev); | 49 | struct hdac_device *hdev = dev_to_hdac_dev(dev); |
@@ -17,8 +51,15 @@ static int hda_bus_match(struct device *dev, struct device_driver *drv) | |||
17 | 51 | ||
18 | if (hdev->type != hdrv->type) | 52 | if (hdev->type != hdrv->type) |
19 | return 0; | 53 | return 0; |
54 | |||
55 | /* | ||
56 | * if driver provided a match function use that otherwise we will | ||
57 | * use hdac_codec_match function | ||
58 | */ | ||
20 | if (hdrv->match) | 59 | if (hdrv->match) |
21 | return hdrv->match(hdev, hdrv); | 60 | return hdrv->match(hdev, hdrv); |
61 | else | ||
62 | return hdac_codec_match(hdev, hdrv); | ||
22 | return 1; | 63 | return 1; |
23 | } | 64 | } |
24 | 65 | ||