From 93ed8560e98afc486df94f5a6238c1f0894b38b8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 15 Oct 2015 21:35:53 +0200 Subject: ALSA: hda - Add api_version to hda_device_id struct For distinguishing the difference between HDA legacy and ext codec driver entries, we need to expose the value corresponding to type field. This patch adds a new field, api_version, to hda_device_id struct, so that this information is embedded in modalias string. Although the information is basically redundant (struct hdac_device already has type field), the helper that extracts from MODULE_DEVICE_TABLE() won't take it account except for the exported table entries themselves. So we need to put the same information in the table, too. Reviewed-by: Vinod Koul Tested-by: Subhransu S Prusty Signed-off-by: Takashi Iwai --- include/sound/hdaudio.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/sound') diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 49df61c7afdc..b35bf59a1ecc 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -33,6 +33,7 @@ extern struct bus_type snd_hda_bus_type; struct hda_device_id { __u32 vendor_id; __u32 rev_id; + __u8 api_version; const char *name; unsigned long driver_data; }; -- cgit v1.2.3-59-g8ed1b From da23ac1e40ce844d1a9553906bdacce160af76f6 Mon Sep 17 00:00:00 2001 From: "Subhransu S. Prusty" Date: Tue, 29 Sep 2015 13:56:10 +0530 Subject: ALSA: hda - Add hduadio support to DEVTABLE For generating modalias entries automatically, move the definition of struct hda_device_id to linux/mod_devicetable.h and add the handling of this record in file2alias helper. The new modalias is represented with combination of vendor id, device id, and api version as "hdaudio:vNrNaN". This patch itself doesn't convert the existing modaliases. Since they were added manually, this patch won't give any regression by itself at this point. [Modified the modalias format to adapt the api_version field, and drop invalid ANY_ID definition by tiwai] Signed-off-by: Subhransu S. Prusty Reviewed-by: Vinod Koul Tested-by: Subhransu S Prusty Signed-off-by: Takashi Iwai --- include/linux/mod_devicetable.h | 8 ++++++++ include/sound/hdaudio.h | 12 +----------- scripts/mod/devicetable-offsets.c | 5 +++++ scripts/mod/file2alias.c | 17 +++++++++++++++++ sound/hda/hda_bus_type.c | 1 + 5 files changed, 32 insertions(+), 11 deletions(-) (limited to 'include/sound') diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 688997a24aad..00825672d256 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -219,6 +219,14 @@ struct serio_device_id { __u8 proto; }; +struct hda_device_id { + __u32 vendor_id; + __u32 rev_id; + __u8 api_version; + const char *name; + unsigned long driver_data; +}; + /* * Struct used for matching a device */ diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index b35bf59a1ecc..ddca48eb02e0 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -21,23 +21,13 @@ struct hdac_stream; struct hdac_device; struct hdac_driver; struct hdac_widget_tree; +struct hda_device_id; /* * exported bus type */ extern struct bus_type snd_hda_bus_type; -/* - * HDA device table - */ -struct hda_device_id { - __u32 vendor_id; - __u32 rev_id; - __u8 api_version; - const char *name; - unsigned long driver_data; -}; - /* * generic arrays */ diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index e70fcd12eeeb..e1a5110bd63b 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -196,5 +196,10 @@ int main(void) DEVID_FIELD(ulpi_device_id, vendor); DEVID_FIELD(ulpi_device_id, product); + DEVID(hda_device_id); + DEVID_FIELD(hda_device_id, vendor_id); + DEVID_FIELD(hda_device_id, rev_id); + DEVID_FIELD(hda_device_id, api_version); + return 0; } diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 5f2088209132..fc51d4bff3f8 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1250,6 +1250,23 @@ static int do_ulpi_entry(const char *filename, void *symval, } ADD_TO_DEVTABLE("ulpi", ulpi_device_id, do_ulpi_entry); +/* Looks like: hdaudio:vNrNaN */ +static int do_hda_entry(const char *filename, void *symval, char *alias) +{ + DEF_FIELD(symval, hda_device_id, vendor_id); + DEF_FIELD(symval, hda_device_id, rev_id); + DEF_FIELD(symval, hda_device_id, api_version); + + strcpy(alias, "hdaudio:"); + ADD(alias, "v", vendor_id != 0, vendor_id); + ADD(alias, "r", rev_id != 0, rev_id); + ADD(alias, "a", api_version != 0, api_version); + + add_wildcard(alias); + return 1; +} +ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hda_entry); + /* Does namelen bytes of name exactly match the symbol? */ static bool sym_is(const char *name, unsigned namelen, const char *symbol) { diff --git a/sound/hda/hda_bus_type.c b/sound/hda/hda_bus_type.c index 89c2711baaaf..bcb1a79eec38 100644 --- a/sound/hda/hda_bus_type.c +++ b/sound/hda/hda_bus_type.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3-59-g8ed1b From 4f9e0c38c5e991e2d050d13e28be74b93ab704c0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 16 Oct 2015 11:35:49 +0200 Subject: ALSA: hda - Add a common helper to give the codec modalias string This patch provide a new common helper function, snd_hdac_codec_modalias(), to give the codec modalias name string. This function will be used by multiple places in the later patches. Reviewed-by: Vinod Koul Tested-by: Subhransu S Prusty Signed-off-by: Takashi Iwai --- include/sound/hdaudio.h | 1 + sound/hda/hdac_device.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'include/sound') diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index ddca48eb02e0..e2b712c90d3f 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -109,6 +109,7 @@ void snd_hdac_device_exit(struct hdac_device *dev); int snd_hdac_device_register(struct hdac_device *codec); void snd_hdac_device_unregister(struct hdac_device *codec); int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name); +int snd_hdac_codec_modalias(struct hdac_device *hdac, char *buf, size_t size); int snd_hdac_refresh_widgets(struct hdac_device *codec); int snd_hdac_refresh_widget_sysfs(struct hdac_device *codec); diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index 4b06b26cee06..bbdb25f5bbb9 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -185,6 +185,21 @@ int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name) } EXPORT_SYMBOL_GPL(snd_hdac_device_set_chip_name); +/** + * snd_hdac_codec_modalias - give the module alias name + * @codec: HDAC device + * @buf: string buffer to store + * @size: string buffer size + * + * Returns the size of string, like snprintf(), or a negative error code. + */ +int snd_hdac_codec_modalias(struct hdac_device *codec, char *buf, size_t size) +{ + return snprintf(buf, size, "hdaudio:v%08Xr%08Xa%02X\n", + codec->vendor_id, codec->revision_id, codec->type); +} +EXPORT_SYMBOL_GPL(snd_hdac_codec_modalias); + /** * snd_hdac_make_cmd - compose a 32bit command word to be sent to the * HD-audio controller -- cgit v1.2.3-59-g8ed1b From b6e84c99b121fcba34166842987be96956148bb8 Mon Sep 17 00:00:00 2001 From: "Subhransu S. Prusty" Date: Mon, 19 Oct 2015 16:58:46 +0530 Subject: ALSA: hdac: Add macro for hda ext devices entry With the new modalias infrastructure support added for hda, create a macro for ext devices similar to legacy to add the device entry. Signed-off-by: Subhransu S. Prusty Signed-off-by: Vinod Koul Signed-off-by: Takashi Iwai --- include/sound/hdaudio_ext.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/sound') diff --git a/include/sound/hdaudio_ext.h b/include/sound/hdaudio_ext.h index 94210dcdb6ea..a4cadd9c297a 100644 --- a/include/sound/hdaudio_ext.h +++ b/include/sound/hdaudio_ext.h @@ -40,6 +40,13 @@ void snd_hdac_ext_bus_device_remove(struct hdac_ext_bus *ebus); #define hbus_to_ebus(_bus) \ container_of(_bus, struct hdac_ext_bus, bus) +#define HDA_CODEC_REV_EXT_ENTRY(_vid, _rev, _name, drv_data) \ + { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \ + .api_version = HDA_DEV_ASOC, \ + .driver_data = (unsigned long)(drv_data) } +#define HDA_CODEC_EXT_ENTRY(_vid, _revid, _name, _drv_data) \ + HDA_CODEC_REV_EXT_ENTRY(_vid, _revid, _name, _drv_data) + int snd_hdac_ext_bus_parse_capabilities(struct hdac_ext_bus *sbus); void snd_hdac_ext_bus_ppcap_enable(struct hdac_ext_bus *chip, bool enable); void snd_hdac_ext_bus_ppcap_int_enable(struct hdac_ext_bus *chip, bool enable); -- cgit v1.2.3-59-g8ed1b