ALSA: Reorganize HD-audio driver code
Subsystems (8)
PATCH 23/27 ALSA: hda/hdmi: Rewrite to new probe method
In reply to Takashi IwaiConvert the HDMI codec drivers to use the new hda_codec_ops probe.
The Intel and Nvidia-MCP HDMI drivers needed slightly more changes to deal with the unified callbacks among all models.
Also another non-trivial change is Intel driver's set_power_state callback. An additional NULL check of codec->spec is needed there since the set_power_state() may be called before the probe gets called (e.g. in ASoC hda codec hda_codec_probe()).
Other than that, no functional changes.
--- sound/hda/codecs/hdmi/atihdmi.c | 31 +++-- sound/hda/codecs/hdmi/hdmi.c | 130 ++++++++++---------- sound/hda/codecs/hdmi/hdmi_local.h | 10 +- sound/hda/codecs/hdmi/intelhdmi.c | 185 ++++++++++++++++++----------- sound/hda/codecs/hdmi/nvhdmi-mcp.c | 96 +++++++-------- sound/hda/codecs/hdmi/nvhdmi.c | 183 ++++++++++++++-------------- sound/hda/codecs/hdmi/simplehdmi.c | 58 +++++---- sound/hda/codecs/hdmi/tegrahdmi.c | 69 ++++++----- 8 files changed, 424 insertions(+), 338 deletions(-)
sound/hda/codecs/hdmi/atihdmi.c +20 -11
@@ -528,19 +528,16 @@ static const struct drm_audio_component_audio_ops atihdmi_audio_ops = { .master_unbind = snd_hda_hdmi_acomp_master_unbind, }; -static int patch_atihdmi (struct hda_codec *codec) +static int atihdmi_probe (struct hda_codec *codec,const struct hda_device_id *id) {struct hdmi_spec *spec;struct hdmi_spec_per_cvt *per_cvt;int err, cvt_idx; - err =patch_generic_hdmi (codec); - + err =snd_hda_hdmi_generic_probe (codec);if (err)return err; - codec->patch_ops.init = atihdmi_init; - spec = codec->spec; spec->static_pcm_mapping = true;
@@ -583,15 +580,26 @@ static int patch_atihdmi(struct hda_codec *codec)return 0 ; } +static const struct hda_codec_ops atihdmi_codec_ops = { + .probe = atihdmi_probe, + .remove = snd_hda_hdmi_generic_remove, + .init = atihdmi_init, + .build_pcms = snd_hda_hdmi_generic_build_pcms, + .build_controls = snd_hda_hdmi_generic_build_controls, + .unsol_event = snd_hda_hdmi_generic_unsol_event, + .suspend = snd_hda_hdmi_generic_suspend, + .resume = snd_hda_hdmi_generic_resume, +}; +/* -* patch entries +* driver entries */ static const struct hda_device_id snd_hda_id_atihdmi[] = { -HDA_CODEC_ENTRY (0x1002793c ,"RS600 HDMI" , patch_atihdmi), -HDA_CODEC_ENTRY (0x10027919 ,"RS600 HDMI" , patch_atihdmi), -HDA_CODEC_ENTRY (0x1002791a ,"RS690/780 HDMI" , patch_atihdmi), -HDA_CODEC_ENTRY (0x1002aa01 ,"R6xx HDMI" , patch_atihdmi), -{}/* terminator */ +HDA_CODEC_ID (0x1002793c ,"RS600 HDMI" ), +HDA_CODEC_ID (0x10027919 ,"RS600 HDMI" ), +HDA_CODEC_ID (0x1002791a ,"RS690/780 HDMI" ), +HDA_CODEC_ID (0x1002aa01 ,"R6xx HDMI" ), + {}/* terminator */ };MODULE_DEVICE_TABLE (hdaudio, snd_hda_id_atihdmi);
@@ -601,6 +609,7 @@ MODULE_IMPORT_NS("SND_HDA_CODEC_HDMI");static struct hda_codec_driver atihdmi_driver = { .id = snd_hda_id_atihdmi, + .ops = &atihdmi_codec_ops, };module_hda_codec_driver (atihdmi_driver);
sound/hda/codecs/hdmi/hdmi.c +68 -62
191 lines not on this page · raw message
sound/hda/codecs/hdmi/hdmi_local.h +5 -5
@@ -237,8 +237,8 @@ union audio_infoframe {/* Generic HDMI codec support */ int snd_hda_hdmi_generic_alloc (struct hda_codec *codec);int snd_hda_hdmi_parse_codec (struct hda_codec *codec); -int patch_generic_hdmi (struct hda_codec *codec); -void snd_hda_hdmi_generic_free (struct hda_codec *codec); +int snd_hda_hdmi_generic_probe (struct hda_codec *codec); +void snd_hda_hdmi_generic_remove (struct hda_codec *codec);int snd_hda_hdmi_generic_build_pcms (struct hda_codec *codec);int snd_hda_hdmi_generic_build_controls (struct hda_codec *codec);
@@ -286,9 +286,9 @@ void snd_hda_hdmi_acomp_master_unbind(struct device *dev, struct drm_audio_component *acomp);/* Simple / legacy HDMI codec support */ -int patch_simple_hdmi (struct hda_codec *codec, -hda_nid_t cvt_nid,hda_nid_t pin_nid); -void snd_hda_hdmi_simple_free (struct hda_codec *codec); +int snd_hda_hdmi_simple_probe (struct hda_codec *codec, +hda_nid_t cvt_nid,hda_nid_t pin_nid); +void snd_hda_hdmi_simple_remove (struct hda_codec *codec);int snd_hda_hdmi_simple_build_pcms (struct hda_codec *codec);int snd_hda_hdmi_simple_build_controls (struct hda_codec *codec);
sound/hda/codecs/hdmi/intelhdmi.c +118 -67
315 lines not on this page · raw message
sound/hda/codecs/hdmi/nvhdmi-mcp.c +49 -47
161 lines not on this page · raw message
sound/hda/codecs/hdmi/nvhdmi.c +94 -89
218 lines not on this page · raw message
sound/hda/codecs/hdmi/simplehdmi.c +34 -24
105 lines not on this page · raw message
sound/hda/codecs/hdmi/tegrahdmi.c +36 -33
104 lines not on this page · raw message
Signature · 1 line
2.50.0
Re: [PATCH 23/27] ALSA: hda/hdmi: Rewrite to new probe method
Quoted 45 lines · Takashi Iwai
sound/hda/codecs/hdmi/intelhdmi.c +29
-2@@ -701,51 +698,104 @@ static int patch_i915_byt_hdmi(struct hda_codec *codec) }/* Intel IronLake, SandyBIridge and IvyBridge; with eld notifier */ -static int patch_i915_cpt_hdmi (struct hda_codec *codec) +static int probe_i915_cpt_hdmi (struct hda_codec *codec) +{ +return parse_intel_hdmi (codec); +} + +/* +* common driver probe +*/ +static int intelhdmi_probe (struct hda_codec *codec,const struct hda_device_id *id) {int err; err =alloc_intel_hdmi (codec);if (err <0 )return err; -return parse_intel_hdmi (codec); + +switch (id->driver_data) { +case MODEL_HSW : + err =probe_i915_hsw_hdmi (codec); +break ; +case MODEL_GLK : + err =probe_i915_glk_hdmi (codec); +break ; +case MODEL_ICL : + err =probe_i915_icl_hdmi (codec); +break ; +case MODEL_TGL : + err =probe_i915_tgl_hdmi (codec); +break ; +case MODEL_ADLP : + err =probe_i915_adlp_hdmi (codec); +break ; +case MODEL_BYT : + err =probe_i915_byt_hdmi (codec); +break ;
sound/hda/codecs/hdmi/intelhdmi.c static int patch_i915_byt_hdmi(struct hda_codec *codec) · line 745
Quoted 10 lines
sound/hda/codecs/hdmi/intelhdmi.c +10
-0+case MODEL_CPT : + err =probe_i915_cpt_hdmi (codec); +break ; +default : + err = -EINVAL ; +break ; + } + +if (err <0 ) { +snd_hda_hdmi_generic_spec_free (codec);
Is this the intended behavior? It modifies the codec state even when it does not match any Intel model. We have reports from users on 6.17-rc1 with AMD BC-250 hardware experiencing HDMI audio detection issues. Adding a check for |EINVAL| resolves the problem.
Quoted 1 line
sound/hda/codecs/hdmi/intelhdmi.c +0
-1- if (err < 0) { > + if (err < 0 && err != -EINVAL) {
Re: [PATCH 23/27] ALSA: hda/hdmi: Rewrite to new probe method
Quoted 53 lines · Mikhail Paulyshka
Quoted 51 lines · Takashi Iwai
sound/hda/codecs/hdmi/intelhdmi.c +36
-2@@ -701,51 +698,104 @@ static int patch_i915_byt_hdmi(struct hda_codec *codec) }/* Intel IronLake, SandyBIridge and IvyBridge; with eld notifier */ -static int patch_i915_cpt_hdmi (struct hda_codec *codec) +static int probe_i915_cpt_hdmi (struct hda_codec *codec) +{ +return parse_intel_hdmi (codec); +} + +/* +* common driver probe +*/ +static int intelhdmi_probe (struct hda_codec *codec,const struct hda_device_id *id) {int err; err =alloc_intel_hdmi (codec);if (err <0 )return err; -return parse_intel_hdmi (codec); + +switch (id->driver_data) { +case MODEL_HSW : + err =probe_i915_hsw_hdmi (codec); +break ; +case MODEL_GLK : + err =probe_i915_glk_hdmi (codec); +break ; +case MODEL_ICL : + err =probe_i915_icl_hdmi (codec); +break ; +case MODEL_TGL : + err =probe_i915_tgl_hdmi (codec); +break ; +case MODEL_ADLP : + err =probe_i915_adlp_hdmi (codec); +break ; +case MODEL_BYT : + err =probe_i915_byt_hdmi (codec); +break ; +case MODEL_CPT : + err =probe_i915_cpt_hdmi (codec); +break ; +default : + err = -EINVAL ; +break ; + }
Quoted 8 lines
sound/hda/codecs/hdmi/intelhdmi.c static int patch_i915_byt_hdmi(struct hda_codec *codec) · line 745
Quoted 3 lines
sound/hda/codecs/hdmi/intelhdmi.c +3
-0+ +if (err <0 ) { +snd_hda_hdmi_generic_spec_free (codec);Is this the intended behavior? It modifies the codec state even when it does not match any Intel model. We have reports from users on 6.17-rc1 with AMD BC-250 hardware experiencing HDMI audio detection issues. Adding a check for |EINVAL| resolves the problem.
Have you enabled CONFIG_SND_HDA_CODEC_HDMI_ATI?
The probe of intelhdmi.c is only for Intel chips, and no other devices will be probed, as you can find in snd_hda_id_intelhdmi[] array.
thanks,
Takashi
PATCH 24/27 ALSA: hda: Drop old codec binding method
In reply to Takashi IwaiNow that all patch_ops usage have been converted to the new hda_codec_ops probe, we can drop patch_ops from the hda_codec, together with the calls of patch_ops callbacks.
The hda_codec_ops.free callback is removed as all have been replaced with the new remove callback.
Also, correct comments mentioning "patch"; it's replaced with "codec driver".
--- include/sound/hda_codec.h | 22 ++------------------- sound/hda/Makefile | 2 +- sound/hda/codecs/generic.c | 12 ------------ sound/hda/codecs/generic.h | 1 - sound/hda/codecs/hdmi/hdmi_local.h | 2 +- sound/hda/common/bind.c | 26 +++++++------------------ sound/hda/common/codec.c | 20 ++----------------- sound/hda/common/hda_local.h | 2 -- sound/soc/codecs/hda.c | 20 ++++--------------- sound/soc/codecs/hdac_hda.c | 31 +++++++++--------------------- 10 files changed, 26 insertions(+), 112 deletions(-)
include/sound/hda_codec.h +2 -20
@@ -70,12 +70,8 @@ struct hda_bus {/* * codec preset -* -* Known codecs have the patch to build and set up the controls/PCMs -* better than the generic parser. */ -typedef int (*hda_codec_patch_t )(struct hda_codec *); - +#define HDA_CODEC_ID_SKIP_PROBE 0x00000001#define HDA_CODEC_ID_GENERIC_HDMI 0x00000101#define HDA_CODEC_ID_GENERIC 0x00000201
@@ -90,14 +86,6 @@ typedef int (*hda_codec_patch_t)(struct hda_codec *);#define HDA_CODEC_ID (_vid, _name) \ HDA_CODEC_ID_REV(_vid, 0, _name) -/* old macros for patch_ops -- to be deprecated */ -#define HDA_CODEC_REV_ENTRY (_vid, _rev, _name, _patch) \ - { .vendor_id = (_vid), .rev_id = (_rev), .name = (_name), \ - .api_version = HDA_DEV_LEGACY, \ - .driver_data = (unsigned long)(_patch) } -#define HDA_CODEC_ENTRY (_vid, _name, _patch) \ - HDA_CODEC_REV_ENTRY(_vid, 0, _name, _patch) -struct hda_codec_driver {struct hdac_driver core;const struct hda_device_id *id;
@@ -116,14 +104,13 @@ void hda_codec_driver_unregister(struct hda_codec_driver *drv);module_driver (drv, hda_codec_driver_register, \ hda_codec_driver_unregister) -/* ops set by the preset patch */ +/* ops for hda codec driver */struct hda_codec_ops {int (*probe)(struct hda_codec *codec,const struct hda_device_id *id);void (*remove)(struct hda_codec *codec);int (*build_controls)(struct hda_codec *codec);int (*build_pcms)(struct hda_codec *codec);int (*init)(struct hda_codec *codec); -void (*free)(struct hda_codec *codec);void (*unsol_event)(struct hda_codec *codec,unsigned int res);void (*set_power_state)(struct hda_codec *codec,hda_nid_t fg,unsigned int power_state);
@@ -199,9 +186,6 @@ struct hda_codec {const struct hda_device_id *preset;const char *modelname;/* model name for preset */ -/* set by patch */ -struct hda_codec_ops patch_ops; -/* PCM to create, set by hda_codec_ops.build_pcms callback */ struct list_head pcm_list_head;refcount_t pcm_ref;
@@ -500,8 +484,6 @@ int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid)if (driver->ops && driver->ops->check_power_status)return driver->ops->check_power_status (codec, nid); -else if (codec->patch_ops.check_power_status) -return codec->patch_ops.check_power_status (codec, nid);return 0 ; }
sound/hda/Makefile +1 -1
@@ -3,6 +3,6 @@ obj-y += core/ obj-$(CONFIG_SND_HDA) += common/ obj-$(CONFIG_SND_HDA) += codecs/ # this must be the last entry after codec drivers; -# otherwise the codec patches won't be hooked before the PCI probe +# otherwise the codec drivers won't be hooked before the PCI probe # when built in kernel obj-$(CONFIG_SND_HDA) += controllers/
sound/hda/codecs/generic.c +0 -12
@@ -5190,8 +5190,6 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec,if (spec->power_down_unused || codec->power_save_node) {if (!codec->power_filter) codec->power_filter = snd_hda_gen_path_power_filter; -if (!codec->patch_ops.stream_pm) - codec->patch_ops.stream_pm = snd_hda_gen_stream_pm; }if (!spec->no_analog && spec->beep_nid) {
@@ -6103,15 +6101,6 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_check_power_status);* the generic codec support */ -static const struct hda_codec_ops generic_patch_ops = { - .build_controls = snd_hda_gen_build_controls, - .build_pcms = snd_hda_gen_build_pcms, - .init = snd_hda_gen_init, - .free = snd_hda_gen_free, - .unsol_event = snd_hda_jack_unsol_event, - .check_power_status = snd_hda_gen_check_power_status, -}; -static int snd_hda_gen_probe (struct hda_codec *codec,const struct hda_device_id *id) {
@@ -6132,7 +6121,6 @@ static int snd_hda_gen_probe(struct hda_codec *codec,if (err <0 ) goto error; - codec->patch_ops = generic_patch_ops;return 0 ; error:
sound/hda/codecs/generic.h +0 -1
@@ -312,7 +312,6 @@ int snd_hda_gen_spec_init(struct hda_gen_spec *spec);int snd_hda_gen_init (struct hda_codec *codec);void snd_hda_gen_remove (struct hda_codec *codec); -#define snd_hda_gen_free snd_hda_gen_removeint snd_hda_get_path_idx (struct hda_codec *codec,struct nid_path *path);struct nid_path *snd_hda_get_path_from_idx (struct hda_codec *codec,int idx);
sound/hda/codecs/hdmi/hdmi_local.h +1 -1
@@ -57,7 +57,7 @@ struct hdmi_spec_per_pin {#endif }; -/* operations used by generic code that can be overridden by patches */ +/* operations used by generic code that can be overridden by codec drivers */ struct hdmi_ops {int (*pin_get_eld)(struct hda_codec *codec,hda_nid_t pin_nid,int dev_id,unsigned char *buf,int *eld_size);
sound/hda/common/bind.c +7 -19
@@ -54,8 +54,6 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)if (driver->ops && driver->ops->unsol_event) driver->ops->unsol_event (codec, ev); -else if (codec->patch_ops.unsol_event) - codec->patch_ops.unsol_event (codec, ev); }/**
@@ -91,7 +89,6 @@ static int hda_codec_driver_probe(struct device *dev)struct hda_codec *codec =dev_to_hda_codec (dev);struct module *owner = dev->driver->owner;struct hda_codec_driver *driver =hda_codec_to_driver (codec); -hda_codec_patch_t patch;int err;if (codec->bus->core.ext_ops) {
@@ -115,19 +112,14 @@ static int hda_codec_driver_probe(struct device *dev) goto error; } -if (driver->ops && driver->ops->probe) { - err = driver->ops->probe (codec, codec->preset); -if (err <0 ) - goto error_module_put; - }else { - patch = (hda_codec_patch_t )codec->preset->driver_data; -if (patch) { - err =patch (codec); -if (err <0 ) - goto error_module_put; - } +if (WARN_ON (!(driver->ops && driver->ops->probe))) { + err = -EINVAL ; + goto error_module_put; } + err = driver->ops->probe (codec, codec->preset); +if (err <0 ) + goto error_module_put; err =snd_hda_codec_build_pcms (codec);if (err <0 ) goto error_module;
@@ -148,8 +140,6 @@ static int hda_codec_driver_probe(struct device *dev) error_module:if (driver->ops && driver->ops->remove) driver->ops->remove (codec); -else if (codec->patch_ops.free) - codec->patch_ops.free (codec); error_module_put:module_put (owner);
@@ -178,8 +168,6 @@ static int hda_codec_driver_remove(struct device *dev)if (driver->ops && driver->ops->remove) driver->ops->remove (codec); -else if (codec->patch_ops.free) - codec->patch_ops.free (codec);snd_hda_codec_cleanup_for_unbind (codec); codec->preset =NULL ;module_put (dev->driver->owner);
@@ -320,7 +308,7 @@ static int codec_bind_generic(struct hda_codec *codec)* @codec: the HDA codec * * Start parsing of the given codec tree and (re-)initialize the whole -* patch instance. +* codec driver binding. * * Returns 0 if successful or a negative error code. */
sound/hda/common/codec.c +2 -18
@@ -766,7 +766,6 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)snd_hda_ctls_clear (codec);codec_release_pcms (codec);snd_hda_detach_beep_device (codec); -memset (&codec->patch_ops,0 ,sizeof (codec->patch_ops));snd_hda_jack_tbl_clear (codec); codec->proc_widget_hook =NULL ; codec->spec =NULL ;
@@ -1132,8 +1131,6 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,if (driver->ops && driver->ops->stream_pm) driver->ops->stream_pm (codec, nid, true); -else if (codec->patch_ops.stream_pm) - codec->patch_ops.stream_pm (codec, nid, true);if (codec->pcm_format_first)update_pcm_format (codec, p, nid, format);update_pcm_stream_id (codec, p, nid, stream_tag, channel_id);
@@ -1205,8 +1202,6 @@ static void really_cleanup_stream(struct hda_codec *codec, q->nid = nid;if (driver->ops && driver->ops->stream_pm) driver->ops->stream_pm (codec, nid, false); -else if (codec->patch_ops.stream_pm) - codec->patch_ops.stream_pm (codec, nid, false); }/* clean up the all conflicting obsolete streams */
@@ -2397,7 +2392,7 @@ static const struct snd_kcontrol_new dig_mixes[] = {* @cvt_nid: converter NID * @type: HDA_PCM_TYPE_* * Creates controls related with the digital output. -* Called from each patch supporting the digital out. +* Called from each codec driver supporting the digital out. * * Returns 0 if successful, or a negative error code. */
@@ -2656,7 +2651,7 @@ static const struct snd_kcontrol_new dig_in_ctls[] = {* @nid: audio in widget NID * * Creates controls related with the SPDIF input. -* Called from each patch supporting the SPDIF in. +* Called from each codec driver supporting the SPDIF in. * * Returns 0 if successful, or a negative error code. */
@@ -2773,9 +2768,6 @@ static unsigned int hda_set_power_state(struct hda_codec *codec,/* might be called before binding to driver, too */ if (driver && driver->ops && driver->ops->set_power_state) driver->ops->set_power_state (codec, fg, power_state); -else if (codec->patch_ops.set_power_state) - codec->patch_ops.set_power_state (codec, fg, - power_state);else { state = power_state;if (codec->power_filter)
@@ -2859,8 +2851,6 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)snd_hdac_enter_pm (&codec->core);if (driver->ops && driver->ops->suspend) driver->ops->suspend (codec); -else if (codec->patch_ops.suspend) - codec->patch_ops.suspend (codec);if (!codec->no_stream_clean_at_suspend)hda_cleanup_all_streams (codec); state =hda_set_power_state (codec,AC_PWRST_D3 );
@@ -2888,8 +2878,6 @@ static void hda_call_codec_resume(struct hda_codec *codec)snd_hda_jack_set_dirty_all (codec);if (driver->ops && driver->ops->resume) driver->ops->resume (codec); -else if (codec->patch_ops.resume) - codec->patch_ops.resume (codec);else {snd_hda_codec_init (codec);snd_hda_regmap_sync (codec);
@@ -3085,8 +3073,6 @@ int snd_hda_codec_build_controls(struct hda_codec *codec)if (!err) {if (driver->ops && driver->ops->build_controls) err = driver->ops->build_controls (codec); -else if (codec->patch_ops.build_controls) - err = codec->patch_ops.build_controls (codec);if (err <0 )return err; }
@@ -3284,8 +3270,6 @@ int snd_hda_codec_parse_pcms(struct hda_codec *codec)if (driver->ops && driver->ops->build_pcms) err = driver->ops->build_pcms (codec); -else if (codec->patch_ops.build_pcms) - err = codec->patch_ops.build_pcms (codec);else return 0 ;
sound/hda/common/hda_local.h +0 -2
@@ -658,8 +658,6 @@ static inline int snd_hda_codec_init(struct hda_codec *codec)if (driver->ops && driver->ops->init)return driver->ops->init (codec); -else if (codec->patch_ops.init) -return codec->patch_ops.init (codec);return 0 ; }
sound/soc/codecs/hda.c +4 -16
@@ -177,7 +177,6 @@ static int hda_codec_probe(struct snd_soc_component *component)struct hdac_device *hdev = &codec->core;struct hdac_bus *bus = hdev->bus;struct hdac_ext_link *hlink; -hda_codec_patch_t patch;int ret;#ifdef CONFIG_PM
@@ -215,19 +214,12 @@ static int hda_codec_probe(struct snd_soc_component *component) goto err; } -if (driver->ops && driver->ops->probe) { - ret = driver->ops->probe (codec, codec->preset); - }else { - patch = (hda_codec_patch_t )codec->preset->driver_data; -if (!patch) { -dev_err (&hdev->dev,"no patch specified\n" ); - ret = -EINVAL ; - goto err; - } - - ret =patch (codec); +if (WARN_ON (!(driver->ops && driver->ops->probe))) { + ret = -EINVAL ; + goto err; } + ret = driver->ops->probe (codec, codec->preset);if (ret <0 ) {dev_err (&hdev->dev,"codec init failed: %d\n" , ret); goto err;
@@ -260,8 +252,6 @@ static int hda_codec_probe(struct snd_soc_component *component) parse_pcms_err:if (driver->ops && driver->ops->remove) driver->ops->remove (codec); -else if (codec->patch_ops.free) - codec->patch_ops.free (codec); err:snd_hda_codec_cleanup_for_unbind (codec); device_new_err:
@@ -292,8 +282,6 @@ static void hda_codec_remove(struct snd_soc_component *component)if (driver->ops && driver->ops->remove) driver->ops->remove (codec); -else if (codec->patch_ops.free) - codec->patch_ops.free (codec);snd_hda_codec_cleanup_for_unbind (codec);pm_runtime_put_noidle (&hdev->dev);
sound/soc/codecs/hdac_hda.c +9 -22
@@ -411,7 +411,6 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)struct hda_codec *hcodec = hda_pvt->codec;struct hda_codec_driver *driver =hda_codec_to_driver (hcodec);struct hdac_ext_link *hlink; -hda_codec_patch_t patch;int ret; hlink =snd_hdac_ext_bus_get_hlink_by_name (hdev->bus,dev_name (&hdev->dev));
@@ -485,23 +484,15 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) goto error_pm; } -if (driver->ops && driver->ops->probe) { - ret = driver->ops->probe (hcodec, hcodec->preset); -if (ret <0 ) { -dev_err (&hdev->dev,"%s: probe failed %d\n" , __func__, ret); - goto error_regmap; - } - }else { - patch = (hda_codec_patch_t )hcodec->preset->driver_data; -if (patch) { - ret =patch (hcodec); -if (ret <0 ) { -dev_err (&hdev->dev,"%s: patch failed %d\n" , __func__, ret); - goto error_regmap; - } - }else { -dev_dbg (&hdev->dev,"%s: no patch file found\n" , __func__); - } +if (WARN_ON (!(driver->ops && driver->ops->probe))) { + ret = -EINVAL ; + goto error_regmap; + } + + ret = driver->ops->probe (hcodec, hcodec->preset); +if (ret <0 ) { +dev_err (&hdev->dev,"%s: probe failed %d\n" , __func__, ret); + goto error_regmap; } ret =snd_hda_codec_parse_pcms (hcodec);
@@ -542,8 +533,6 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) error_patch:if (driver->ops && driver->ops->remove) driver->ops->remove (hcodec); -else if (hcodec->patch_ops.free) - hcodec->patch_ops.free (hcodec); error_regmap:snd_hdac_regmap_exit (hdev); error_pm:
@@ -573,8 +562,6 @@ static void hdac_hda_codec_remove(struct snd_soc_component *component)if (driver->ops && driver->ops->remove) driver->ops->remove (codec); -else if (codec->patch_ops.free) - codec->patch_ops.free (codec);snd_hda_codec_cleanup_for_unbind (codec); }
Signature · 1 line
2.50.0
PATCH 25/27 ALSA: hda: Drop superfluous driver->ops NULL checks
In reply to Takashi IwaiAfter all conversions, driver->ops became a must in most places (except for the codec power setup which might be called before binding to the codec driver), hence we can get rid of the superfluous driver->ops NULL checks, too.
--- sound/hda/common/bind.c | 6 +++--- sound/hda/common/codec.c | 15 +++++++-------- sound/hda/common/hda_local.h | 2 +- sound/soc/codecs/hda.c | 4 ++-- sound/soc/codecs/hdac_hda.c | 4 ++-- 5 files changed, 15 insertions(+), 16 deletions(-)
sound/hda/common/bind.c +3 -3
@@ -52,7 +52,7 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev)if (codec->core.dev.power.power_state.event !=PM_EVENT_ON )return ; -if (driver->ops && driver->ops->unsol_event) +if (driver->ops->unsol_event) driver->ops->unsol_event (codec, ev); }
@@ -138,7 +138,7 @@ static int hda_codec_driver_probe(struct device *dev)return 0 ; error_module: -if (driver->ops && driver->ops->remove) +if (driver->ops->remove) driver->ops->remove (codec); error_module_put:module_put (owner);
@@ -166,7 +166,7 @@ static int hda_codec_driver_remove(struct device *dev)wait_event (codec->remove_sleep, !refcount_read (&codec->pcm_ref));snd_power_sync_ref (codec->bus->card); -if (driver->ops && driver->ops->remove) +if (driver->ops->remove) driver->ops->remove (codec);snd_hda_codec_cleanup_for_unbind (codec); codec->preset =NULL ;
sound/hda/common/codec.c +7 -8
@@ -1129,7 +1129,7 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,if (!p)return ; -if (driver->ops && driver->ops->stream_pm) +if (driver->ops->stream_pm) driver->ops->stream_pm (codec, nid, true);if (codec->pcm_format_first)update_pcm_format (codec, p, nid, format);
@@ -1200,7 +1200,7 @@ static void really_cleanup_stream(struct hda_codec *codec, );memset (q,0 ,sizeof (*q)); q->nid = nid; -if (driver->ops && driver->ops->stream_pm) +if (driver->ops->stream_pm) driver->ops->stream_pm (codec, nid, false); }
@@ -2849,7 +2849,7 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec)unsigned int state;snd_hdac_enter_pm (&codec->core); -if (driver->ops && driver->ops->suspend) +if (driver->ops->suspend) driver->ops->suspend (codec);if (!codec->no_stream_clean_at_suspend)hda_cleanup_all_streams (codec);
@@ -2876,7 +2876,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)restore_shutup_pins (codec);hda_exec_init_verbs (codec);snd_hda_jack_set_dirty_all (codec); -if (driver->ops && driver->ops->resume) +if (driver->ops->resume) driver->ops->resume (codec);else {snd_hda_codec_init (codec);
@@ -3071,7 +3071,7 @@ int snd_hda_codec_build_controls(struct hda_codec *codec)/* continue to initialize... */ err =snd_hda_codec_init (codec);if (!err) { -if (driver->ops && driver->ops->build_controls) +if (driver->ops->build_controls) err = driver->ops->build_controls (codec);if (err <0 )return err;
@@ -3268,11 +3268,10 @@ int snd_hda_codec_parse_pcms(struct hda_codec *codec)if (!list_empty (&codec->pcm_list_head))return 0 ;/* already parsed */ -if (driver->ops && driver->ops->build_pcms) - err = driver->ops->build_pcms (codec); -else +if (!driver->ops->build_pcms)return 0 ; + err = driver->ops->build_pcms (codec);if (err <0 ) {codec_err (codec,"cannot build PCMs for #%d (error %d)\n" , codec->core.addr, err);
sound/hda/common/hda_local.h +1 -1
@@ -656,7 +656,7 @@ static inline int snd_hda_codec_init(struct hda_codec *codec) {struct hda_codec_driver *driver =hda_codec_to_driver (codec); -if (driver->ops && driver->ops->init) +if (driver->ops->init)return driver->ops->init (codec);return 0 ; }
sound/soc/codecs/hda.c +2 -2
@@ -250,7 +250,7 @@ static int hda_codec_probe(struct snd_soc_component *component) complete_err:hda_codec_unregister_dais (codec, component); parse_pcms_err: -if (driver->ops && driver->ops->remove) +if (driver->ops->remove) driver->ops->remove (codec); err:snd_hda_codec_cleanup_for_unbind (codec);
@@ -280,7 +280,7 @@ static void hda_codec_remove(struct snd_soc_component *component)hda_codec_unregister_dais (codec, component); -if (driver->ops && driver->ops->remove) +if (driver->ops->remove) driver->ops->remove (codec);snd_hda_codec_cleanup_for_unbind (codec);
sound/soc/codecs/hdac_hda.c +2 -2
@@ -531,7 +531,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)return 0 ; error_patch: -if (driver->ops && driver->ops->remove) +if (driver->ops->remove) driver->ops->remove (hcodec); error_regmap:snd_hdac_regmap_exit (hdev);
@@ -560,7 +560,7 @@ static void hdac_hda_codec_remove(struct snd_soc_component *component)pm_runtime_disable (&hdev->dev);snd_hdac_ext_bus_link_put (hdev->bus, hlink); -if (driver->ops && driver->ops->remove) +if (driver->ops->remove) driver->ops->remove (codec);snd_hda_codec_cleanup_for_unbind (codec);
Signature · 1 line
2.50.0
PATCH 26/27 MAINTAINERS: Adjust to the new HD-audio driver paths
In reply to Takashi IwaiThe HD-audio drivers are moved under sound/hda now. Correct the locations.
--- MAINTAINERS | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
MAINTAINERS +5 -5
@@ -5741,9 +5741,9 @@ F: drivers/spi/spi-cs42l43* F: include/dt-bindings/sound/cs* F: include/linux/mfd/cs42l43* F: include/sound/cs* -F: sound/pci/hda/cirrus* -F: sound/pci/hda/cs* -F: sound/pci/hda/hda_component* +F: sound/hda/codecs/cirrus* +F: sound/hda/codecs/side-codecs/cs* +F: sound/hda/codecs/side-codecs/hda_component* F: sound/soc/codecs/cs* CIRRUS LOGIC HAPTIC DRIVERS
@@ -24533,7 +24533,7 @@ F: Documentation/devicetree/bindings/sound/ti,tlv320*.yaml F: Documentation/devicetree/bindings/sound/ti,tlv320adcx140.yaml F: include/sound/tas2*.h F: include/sound/tlv320*.h -F: sound/pci/hda/tas2781_hda_i2c.c +F: sound/hda/codecs/side-codecs/tas2781_hda_i2c.c F: sound/soc/codecs/pcm1681.c F: sound/soc/codecs/pcm1789*.* F: sound/soc/codecs/pcm179x*.*
@@ -27473,7 +27473,7 @@ SENARYTECH AUDIO CODEC DRIVER M: bo liu <[email protected]> S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git -F: sound/pci/hda/patch_senarytech.c +F: sound/hda/codecs/senarytech.c THE REST M: Linus Torvalds <[email protected]>
Signature · 1 line
2.50.0
Richard Fitzgerald
maintainerRe: [PATCH 26/27] MAINTAINERS: Adjust to the new HD-audio driver paths
Quoted 13 lines · Takashi Iwai
The HD-audio drivers are moved under
sound/hdanow. Correct the locations.Signed-off-by Takashi Iwai <[email protected]>--- MAINTAINERS | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)MAINTAINERS +0
-0
MAINTAINERS F: drivers/spi/spi-cs42l43* · line 5744
Quoted 7 lines
MAINTAINERS +1
-3@@ -5741,9 +5741,9 @@ F: drivers/spi/spi-cs42l43* F: include/dt-bindings/sound/cs* F: include/linux/mfd/cs42l43* F: include/sound/cs* -F: sound/pci/hda/cirrus* -F: sound/pci/hda/cs* -F: sound/pci/hda/hda_component* +F: sound/hda/codecs/cirrus*
This should be sound/hda/codecs/side-codecs/cirrus* It's to pick up the cirrus_scodec* files.
Quoted 3 lines
MAINTAINERS +2
-0+F: sound/hda/codecs/side-codecs/cs* +F: sound/hda/codecs/side-codecs/hda_component* F: sound/soc/codecs/cs*
PATCH 27/27 ALSA: hda: Return the codec init error properly at snd_hda_codec_build_controls()
In reply to Takashi IwaiThe error from snd_hda_codec_init() was ignored in snd_hda_codec_build_controls(), which should have been taken account and abort the flow. Fix it now.
--- sound/hda/common/codec.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
sound/hda/common/codec.c +6 -4
@@ -3065,14 +3065,16 @@ EXPORT_SYMBOL_GPL(snd_pcm_2_1_chmaps);int snd_hda_codec_build_controls (struct hda_codec *codec) {struct hda_codec_driver *driver =hda_codec_to_driver (codec); -int err =0 ; +int err;hda_exec_init_verbs (codec);/* continue to initialize... */ err =snd_hda_codec_init (codec); -if (!err) { -if (driver->ops->build_controls) - err = driver->ops->build_controls (codec); +if (err <0 ) +return err; + +if (driver->ops->build_controls) { + err = driver->ops->build_controls (codec);if (err <0 )return err; }
Signature · 1 line
2.50.0
Quoted 37 lines · Takashi Iwai
HD-audio driver is known to be quite messy in both file structures and its design, but until now I haven't touched its files paths so much because I set a higher priority for the easiness of backport to stable kernels. But, you can't leave garbages forever, it's been already high time for a large clean up -- so here it is.
The basic idea is to move the code from
sound/pci/hda/*into different subdirectories insound/hda/per functionality, as most of the stuff are independent from PCI, but rather HD-audio bus specific.So, now the all HD-audio driver code are moved under
sound/hda:% ls
sound/hda
codecs/ common/ controllers/ core/KconfigMakefile* The former hda core code is found in
sound/hda/core.
* The former snd-hda-codec code is found insound/hda/common.
* The former snd-hda-intel, tegra and acpi are put insound/hda/controllers.
* The former patch_* and co are put tosound/hda/codecs.
* Realtek codec driver is split to several modules assound/hda/codecs/realtek/alc*.
* Cirrus codec driver is split to cs420x and cs421x, put undersound/hda/codecs/cirrustogether with cs8409.
* HDMI codec driver is split to several modules undersound/hda/codecs/hdmi
* Cirrus and TI sub-codecs are put undersound/hda/codecs/side-codecsAlso, the probe of the HD-audio codec driver is moved into the driver's ops instead of the ugly
patch_opsembedded inhda_codecobject. (As of now, hda_codec_driver.ops is a pointer, but it can be embedded later, too.)This change required some code to be modified without the dynamic override of callbacks.
Quoted 7 lines
In future, we may convert the runtime PM handling to use the standard
pm_ops, too. This was raised some time ago during the discussion with Realtek devs.The tree applying those patches is found in topic/hda-reorg branch of sound git tree:
https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/log/?h=topic/hda-reorg
I merged this change to for-next branch now, destined for 6.17.
It means that there may be some merge conflict in future in linux-next because of many file renames from sound/pci/hda/* -> sound/hda/*. So adding Stephen to Cc. The conflict resolution should be relatively easy, though.
thanks,
Takashi