ASoC: SOF: Intel: HDA: refactor codec and multi-link suport
Subsystems (3)
cover ASoC: SOF: Intel: HDA: refactor codec and multi-link suport
Existing HDaudio controllers expose an HDAudio DMA which is used to interface with HDaudio codecs. All other interfaces supported by Intel (SoundWire, SSP, DMIC) rely for data transfers on another GP-DMA managed by the DSP firmware - the HDaudio DMA is only used for memory-to-DSP transfers.
New HDaudio extensions will enable the use of this HDaudio DMA for all of SoundWire, SSP, DMIC. These extensions will be backwards-compatible for HDaudio and iDISP codecs, but will require new programming sequences and DAI callbacks for SoundWire, SSP and DMIC.
Before we add support for 'extended audio links' and the programming sequences for the DMA, we need to refactor the code. All HDaudio codec support needs to be well identified in a separate file, and likewise all the 'multi-link' handling needs to be better split.
This patchset removes a number of 'old' Kconfig dependencies and options, adds helpers with a fallback to remove IS_ENABLED checks in the code and tries to simplify programming sequences when possible.
One indirect benefit from this refactoring is that developers can switch with a kernel parameter from HDaudio support to a variant of 'nocodec' support. This proves extremely useful to test on existing Intel RVPs and Up boards, where the same build can be used to check 3 interfaces (HDaudio, SSP, DMIC) by just removing modules, setting the kernel parameter and reloading modules.
Pierre-Louis Bossart (21):
ASoC: SOF: Intel: remove option to disable the common_hdmi handling
ASoC: SOF: Intel: remove all dependencies on SND_SOC_HDAC_HDMI
ASoC: SOF: Intel: hda-codec: simplify SND_SOC_SOF_HDA_AUDIO_CODEC
handling
ASoC: SOF: Intel: move codec state change to hda-codec.c
ASoC: SOF: Intel: start moving multi-link handling in dedicated file
ASoC: SOF: Intel: hda: add multi-link helper for LOSVID
ASoC: SOF: Intel: move all RIRB/CMD_IO helpers to hda-codec.c
ASoC: SOF: Intel: hda-ctrl: add codec wakeup helper
ASoC: SOF: Intel: hda-codec: add hda_codec_device_remove() helper
ASoC: SOF: Intel: hda-codec: add stop_cmd_io helper
ASoC: SOF: Intel: hda-stream: always allocate CORB/RIRB buffer
ASoC: SOF: Intel: hda-codec: add hda_codec_check_rirb_status() helper
ASoC: SOF: Intel: hda-ctrl: use helper to clear RIRB status
ASoC: SOF: Intel: hda-dsp: clarify dependencies on SND_SOC_SOF_HDA
ASoC: SOF: Intel: hda-codec: add helpers to suspend and resume cmd_io
ASoC: SOF: Intel: clarify bus_init and bus_exit sequences
ASoC: SOF: Intel: hda-mlink: add helpers to suspend/resume links
ASoC: SOF: Intel: add hda_bus_ml_free helper
ASoC: SOF: Intel: hda: clarify Kconfig dependencies
ASoC: SOF: Intel: hda-codec: use GPL-2.0-only license
ASoC: SOF: introduce new DEBUG_NOCODEC mode
sound/soc/sof/Kconfig | 18 ++- sound/soc/sof/intel/Kconfig | 2 +- sound/soc/sof/intel/Makefile | 2 +- sound/soc/sof/intel/hda-bus.c | 23 ++- sound/soc/sof/intel/hda-codec.c | 252 +++++++++++++++++++++++++------ sound/soc/sof/intel/hda-ctrl.c | 63 ++------ sound/soc/sof/intel/hda-dai.c | 10 +- sound/soc/sof/intel/hda-dsp.c | 44 ++---- sound/soc/sof/intel/hda-mlink.c | 89 +++++++++++ sound/soc/sof/intel/hda-stream.c | 30 +--- sound/soc/sof/intel/hda.c | 62 ++------ sound/soc/sof/intel/hda.h | 63 ++++++-- sound/soc/sof/sof-audio.c | 5 + sound/soc/sof/sof-priv.h | 3 + 14 files changed, 438 insertions(+), 228 deletions(-) create mode 100644 sound/soc/sof/intel/hda-mlink.c
Signature · 1 line
2.34.1
PATCH 1/21 ASoC: SOF: Intel: remove option to disable the common_hdmi handling
We've been using the same option for quite some time now, it's time to remove the kernel parameter to disable the common HDaudio codec handling.
--- sound/soc/sof/intel/hda-codec.c | 12 +++--------- sound/soc/sof/intel/hda.c | 10 ++-------- sound/soc/sof/intel/hda.h | 6 ++---- 3 files changed, 7 insertions(+), 21 deletions(-)
sound/soc/sof/intel/hda-codec.c +3 -9
@@ -133,8 +133,7 @@ static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, i }/* probe individual codec */ -static int hda_codec_probe (struct snd_sof_dev *sdev,int address, -bool hda_codec_use_common_hdmi) +static int hda_codec_probe (struct snd_sof_dev *sdev,int address) {#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )struct hdac_hda_priv *hda_priv;
@@ -164,10 +163,6 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address,if (!hda_priv)return -ENOMEM ; -/* only probe ASoC codec drivers for HDAC-HDMI */ -if (!hda_codec_use_common_hdmi && (resp &0xFFFF0000 ) ==IDISP_VID_INTEL ) - type =HDA_DEV_ASOC ; - codec =hda_codec_device_init (&hbus->core, address, type); ret =PTR_ERR_OR_ZERO (codec);if (ret <0 )
@@ -215,8 +210,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, }/* Codec initialization */ -void hda_codec_probe_bus (struct snd_sof_dev *sdev, -bool hda_codec_use_common_hdmi) +void hda_codec_probe_bus (struct snd_sof_dev *sdev) {struct hdac_bus *bus =sof_to_bus (sdev);int i, ret;
@@ -227,7 +221,7 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev,if (!(bus->codec_mask & (1 << i)))continue ; - ret =hda_codec_probe (sdev, i, hda_codec_use_common_hdmi); + ret =hda_codec_probe (sdev, i);if (ret <0 ) {dev_warn (bus->dev,"codec #%d probe error, ret: %d\n" , i, ret);
sound/soc/sof/intel/hda.c +2 -8
@@ -383,12 +383,6 @@ static int mclk_id_override = -1;module_param_named (mclk_id, mclk_id_override, int,0444 );MODULE_PARM_DESC (mclk_id,"SOF SSP mclk_id" ); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -static bool hda_codec_use_common_hdmi =IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ); -module_param_named (use_common_hdmi, hda_codec_use_common_hdmi, bool,0444 ); -MODULE_PARM_DESC (use_common_hdmi,"SOF HDA use common HDMI codec driver" ); -#endif -static const struct hda_dsp_msg_code hda_dsp_rom_fw_error_texts[] = { {HDA_DSP_ROM_CSE_ERROR ,"error: cse error" }, {HDA_DSP_ROM_CSE_WRONG_RESPONSE ,"error: cse wrong response" },
@@ -929,7 +923,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev)snd_hdac_ext_bus_get_ml_capabilities (bus);/* create codec instances */ -hda_codec_probe_bus (sdev, hda_codec_use_common_hdmi); +hda_codec_probe_bus (sdev);if (!HDA_IDISP_CODEC (bus->codec_mask))hda_codec_i915_display_power (sdev, false);
@@ -1335,7 +1329,7 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,if (*mach) { mach_params = &(*mach)->mach_params; mach_params->codec_mask = bus->codec_mask; - mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; + mach_params->common_hdmi_codec_drv = true; } }#else
sound/soc/sof/intel/hda.h +2 -4
@@ -714,8 +714,7 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev);/* * HDA Codec operations. */ -void hda_codec_probe_bus (struct snd_sof_dev *sdev, -bool hda_codec_use_common_hdmi); +void hda_codec_probe_bus (struct snd_sof_dev *sdev);void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable);void hda_codec_jack_check (struct snd_sof_dev *sdev);
@@ -731,8 +730,7 @@ int hda_codec_i915_exit(struct snd_sof_dev *sdev);#else -static inline void hda_codec_i915_display_power (struct snd_sof_dev *sdev, -bool enable) { } +static inline void hda_codec_i915_display_power (struct snd_sof_dev *sdev,bool enable) { }static inline int hda_codec_i915_init (struct snd_sof_dev *sdev) {return 0 ; }static inline int hda_codec_i915_exit (struct snd_sof_dev *sdev) {return 0 ; }
Signature · 1 line
2.34.1
PATCH 2/21 ASoC: SOF: Intel: remove all dependencies on SND_SOC_HDAC_HDMI
In reply to Pierre-Louis Bossartremove all dependencies on SND_SOC_HDAC_HDMI and
clean-up ifdefs. The machine driver still supports this configuration used by the Skylake driver.
--- sound/soc/sof/intel/hda-codec.c | 3 +-- sound/soc/sof/intel/hda.h | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-)
sound/soc/sof/intel/hda-codec.c +1 -2
@@ -231,8 +231,7 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS (hda_codec_probe_bus,SND_SOC_SOF_HDA_AUDIO_CODEC ); -#if IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ) || \ -IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )void hda_codec_i915_display_power (struct snd_sof_dev *sdev,bool enable) {
sound/soc/sof/intel/hda.h +1 -3
@@ -720,9 +720,7 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev);#endif /* CONFIG_SND_SOC_SOF_HDA */ -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) && \ - (IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ) || \ -IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI )) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )void hda_codec_i915_display_power (struct snd_sof_dev *sdev,bool enable);int hda_codec_i915_init (struct snd_sof_dev *sdev);
Signature · 1 line
2.34.1
PATCH 3/21 ASoC: SOF: Intel: hda-codec: simplify SND_SOC_SOF_HDA_AUDIO_CODEC handling
In reply to Pierre-Louis BossartNow that we have removed the dependency on SND_SOC_HDAC_HDMI, we can simplify the code and make the code conditional on a single #ifdef.
--- sound/soc/sof/intel/hda-codec.c | 37 +++++++++++---------------------- sound/soc/sof/intel/hda.h | 10 +++++++-- 2 files changed, 20 insertions(+), 27 deletions(-)
sound/soc/sof/intel/hda-codec.c +12 -25
@@ -16,13 +16,12 @@#include <sound/sof.h> #include "../ops.h" #include "hda.h" +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )#include "../../codecs/hdac_hda.h" -#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ #define CODEC_PROBE_RETRIES 3 -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )#define IDISP_VID_INTEL 0x80860000/* load the legacy HDA codec driver */
@@ -80,6 +79,7 @@ void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable)snd_hdac_chip_updatew (bus,WAKEEN ,STATESTS_INT_MASK , mask); } +EXPORT_SYMBOL_NS (hda_codec_jack_wake_enable,SND_SOC_SOF_HDA_AUDIO_CODEC );/* check jack status after resuming from suspend mode */ void hda_codec_jack_check (struct snd_sof_dev *sdev)
@@ -95,11 +95,6 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev)if (codec->jacktbl.used)pm_request_resume (&codec->core.dev); } -#else -void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable) {} -void hda_codec_jack_check (struct snd_sof_dev *sdev) {} -#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ -EXPORT_SYMBOL_NS (hda_codec_jack_wake_enable,SND_SOC_SOF_HDA_AUDIO_CODEC );EXPORT_SYMBOL_NS (hda_codec_jack_check,SND_SOC_SOF_HDA_AUDIO_CODEC );#if IS_ENABLED (CONFIG_SND_HDA_GENERIC )
@@ -135,10 +130,7 @@ static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, i/* probe individual codec */ static int hda_codec_probe (struct snd_sof_dev *sdev,int address) { -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )struct hdac_hda_priv *hda_priv; -int type =HDA_DEV_LEGACY ; -#endif struct hda_bus *hbus =sof_to_hbus (sdev);struct hda_codec *codec; u32 hda_cmd = (address << 28) | (AC_NODE_ROOT << 20) |
@@ -158,12 +150,11 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address)dev_dbg (sdev->dev,"HDA codec #%d probed OK: response: %x\n" , address, resp); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) hda_priv =devm_kzalloc (sdev->dev,sizeof (*hda_priv),GFP_KERNEL );if (!hda_priv)return -ENOMEM ; - codec =hda_codec_device_init (&hbus->core, address, type); + codec =hda_codec_device_init (&hbus->core, address,HDA_DEV_LEGACY ); ret =PTR_ERR_OR_ZERO (codec);if (ret <0 )return ret;
@@ -186,25 +177,19 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address)else codec->probe_id =0 ; -if (type ==HDA_DEV_LEGACY ) { - ret =hda_codec_load_module (codec); -/* -* handle ret==0 (no driver bound) as an error, but pass -* other return codes without modification -*/ -if (ret ==0 ) - ret = -ENOENT ; - } + ret =hda_codec_load_module (codec); +/* +* handle ret==0 (no driver bound) as an error, but pass +* other return codes without modification +*/ +if (ret ==0 ) + ret = -ENOENT ; out:if (ret <0 ) {snd_hdac_device_unregister (&codec->core);put_device (&codec->core.dev); } -#else - codec =hda_codec_device_init (&hbus->core, address,HDA_DEV_ASOC ); - ret =PTR_ERR_OR_ZERO (codec); -#endif return ret; }
@@ -231,6 +216,8 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS (hda_codec_probe_bus,SND_SOC_SOF_HDA_AUDIO_CODEC ); +#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )void hda_codec_i915_display_power (struct snd_sof_dev *sdev,bool enable)
sound/soc/sof/intel/hda.h +8 -2
@@ -710,7 +710,7 @@ void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev);*/ void sof_hda_bus_init (struct hdac_bus *bus,struct device *dev); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )/* * HDA Codec operations. */
@@ -718,7 +718,13 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev);void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable);void hda_codec_jack_check (struct snd_sof_dev *sdev); -#endif /* CONFIG_SND_SOC_SOF_HDA */ +#else + +static inline void hda_codec_probe_bus (struct snd_sof_dev *sdev) { } +static inline void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable) { } +static inline void hda_codec_jack_check (struct snd_sof_dev *sdev) { } + +#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )
Signature · 1 line
2.34.1
PATCH 4/21 ASoC: SOF: Intel: move codec state change to hda-codec.c
In reply to Pierre-Louis BossartThe codec_mask and codec-related handling should depend on SOF_HDA_AUDIO_CODEC, not SOF_HDA.
--- sound/soc/sof/intel/hda-codec.c | 13 +++++++++++++ sound/soc/sof/intel/hda.c | 16 +--------------- sound/soc/sof/intel/hda.h | 2 ++ 3 files changed, 16 insertions(+), 15 deletions(-)
sound/soc/sof/intel/hda-codec.c +13 -0
@@ -216,6 +216,19 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS (hda_codec_probe_bus,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_check_for_state_change (struct snd_sof_dev *sdev) +{ +struct hdac_bus *bus =sof_to_bus (sdev); +unsigned int codec_mask; + + codec_mask =snd_hdac_chip_readw (bus,STATESTS ); +if (codec_mask) { +hda_codec_jack_check (sdev); +snd_hdac_chip_writew (bus,STATESTS , codec_mask); + } +} +EXPORT_SYMBOL_NS (hda_codec_check_for_state_change,SND_SOC_SOF_HDA_AUDIO_CODEC ); +#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )
sound/soc/sof/intel/hda.c +1 -15
@@ -937,20 +937,6 @@ static int hda_init_caps(struct snd_sof_dev *sdev)return 0 ; } -static void hda_check_for_state_change (struct snd_sof_dev *sdev) -{ -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -struct hdac_bus *bus =sof_to_bus (sdev); -unsigned int codec_mask; - - codec_mask =snd_hdac_chip_readw (bus,STATESTS ); -if (codec_mask) { -hda_codec_jack_check (sdev); -snd_hdac_chip_writew (bus,STATESTS , codec_mask); - } -#endif -} -static irqreturn_t hda_dsp_interrupt_handler (int irq,void *context) {struct snd_sof_dev *sdev = context;
@@ -1000,7 +986,7 @@ static irqreturn_t hda_dsp_interrupt_thread(int irq, void *context)hda_sdw_process_wakeen (sdev); } -hda_check_for_state_change (sdev); +hda_codec_check_for_state_change (sdev);/* enable GIE interrupt */ snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR,
sound/soc/sof/intel/hda.h +2 -0
@@ -717,12 +717,14 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev);void hda_codec_probe_bus (struct snd_sof_dev *sdev);void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable);void hda_codec_jack_check (struct snd_sof_dev *sdev); +void hda_codec_check_for_state_change (struct snd_sof_dev *sdev);#else static inline void hda_codec_probe_bus (struct snd_sof_dev *sdev) { }static inline void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable) { }static inline void hda_codec_jack_check (struct snd_sof_dev *sdev) { } +static inline void hda_codec_check_for_state_change (struct snd_sof_dev *sdev) { }#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */
Signature · 1 line
2.34.1
PATCH 5/21 ASoC: SOF: Intel: start moving multi-link handling in dedicated file
In reply to Pierre-Louis BossartThe multi-link handling needs to be handled with dedicated helpers before cleanups and extensions.
--- sound/soc/sof/intel/Makefile | 2 +- sound/soc/sof/intel/hda-mlink.c | 45 +++++++++++++++++++++++++++++++++ sound/soc/sof/intel/hda.c | 15 +++-------- sound/soc/sof/intel/hda.h | 12 +++++++++ 4 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 sound/soc/sof/intel/hda-mlink.c
sound/soc/sof/intel/Makefile +1 -1
@@ -5,7 +5,7 @@ snd-sof-acpi-intel-bdw-objs := bdw.o snd-sof-intel-hda-common-objs := hda.o hda-loader.o hda-stream.o hda-trace.o \ hda-dsp.o hda-ipc.o hda-ctrl.o hda-pcm.o \ - hda-dai.o hda-bus.o \ + hda-dai.o hda-bus.o hda-mlink.o \ skl.o hda-loader-skl.o \ apl.o cnl.o tgl.o icl.o mtl.o hda-common-ops.o
sound/soc/sof/intel/hda-mlink.c new file +45 -0
45 lines not on this page · raw message
sound/soc/sof/intel/hda.c +3 -12
@@ -871,9 +871,6 @@ static int hda_init_caps(struct snd_sof_dev *sdev) {struct hdac_bus *bus =sof_to_bus (sdev);struct snd_sof_pdata *pdata = sdev->pdata; -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -struct hdac_ext_link *hlink; -#endif struct sof_intel_hda_dev *hdev = pdata->hw_pdata;u32 link_mask;int ret =0 ;
@@ -918,9 +915,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev) skip_soundwire: -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -if (bus->mlcap) -snd_hdac_ext_bus_get_ml_capabilities (bus); +hda_bus_ml_get_capabilities (bus);/* create codec instances */ hda_codec_probe_bus (sdev);
@@ -928,12 +923,8 @@ static int hda_init_caps(struct snd_sof_dev *sdev)if (!HDA_IDISP_CODEC (bus->codec_mask))hda_codec_i915_display_power (sdev, false); -/* -* we are done probing so decrement link counts -*/ -list_for_each_entry (hlink, &bus->hlink_list, list) -snd_hdac_ext_bus_link_put (bus, hlink); -#endif +hda_bus_ml_put_all (bus); +return 0 ; }
sound/soc/sof/intel/hda.h +12 -0
@@ -742,6 +742,18 @@ static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }#endif +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) + +void hda_bus_ml_get_capabilities (struct hdac_bus *bus); +void hda_bus_ml_put_all (struct hdac_bus *bus); + +#else + +static inline void hda_bus_ml_get_capabilities (struct hdac_bus *bus) { } +static inline void hda_bus_ml_put_all (struct hdac_bus *bus) { } + +#endif /* CONFIG_SND_SOC_SOF_HDA */ +/* * Trace Control. */
Signature · 1 line
2.34.1
PATCH 6/21 ASoC: SOF: Intel: hda: add multi-link helper for LOSVID
In reply to Pierre-Louis BossartAdd new helper to deal with LOSVID.
--- sound/soc/sof/intel/hda-ctrl.c | 9 +-------- sound/soc/sof/intel/hda-mlink.c | 9 +++++++++ sound/soc/sof/intel/hda.h | 2 ++ 3 files changed, 12 insertions(+), 8 deletions(-)
sound/soc/sof/intel/hda-ctrl.c +1 -8
@@ -185,9 +185,6 @@ int hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable)int hda_dsp_ctrl_init_chip (struct snd_sof_dev *sdev) {struct hdac_bus *bus =sof_to_bus (sdev); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -struct hdac_ext_link *hlink; -#endif struct hdac_stream *stream;int sd_offset, ret =0 ;
@@ -269,11 +266,7 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev) upper_32_bits(bus->posbuf.addr)); } -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* Reset stream-to-link mapping */ -list_for_each_entry (hlink, &bus->hlink_list, list) -writel (0 , hlink->ml_addr +AZX_REG_ML_LOSIDV ); -#endif +hda_bus_ml_reset_losidv (bus); bus->chip_init = true;
sound/soc/sof/intel/hda-mlink.c +9 -0
@@ -42,4 +42,13 @@ void hda_bus_ml_put_all(struct hdac_bus *bus) snd_hdac_ext_bus_link_put(bus, hlink); } +void hda_bus_ml_reset_losidv (struct hdac_bus *bus) +{ +struct hdac_ext_link *hlink; + +/* Reset stream-to-link mapping */ +list_for_each_entry (hlink, &bus->hlink_list, list) +writel (0 , hlink->ml_addr +AZX_REG_ML_LOSIDV ); +} +#endif
sound/soc/sof/intel/hda.h +2 -0
@@ -746,11 +746,13 @@ static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }void hda_bus_ml_get_capabilities (struct hdac_bus *bus);void hda_bus_ml_put_all (struct hdac_bus *bus); +void hda_bus_ml_reset_losidv (struct hdac_bus *bus);#else static inline void hda_bus_ml_get_capabilities (struct hdac_bus *bus) { }static inline void hda_bus_ml_put_all (struct hdac_bus *bus) { } +static inline void hda_bus_ml_reset_losidv (struct hdac_bus *bus) { }#endif /* CONFIG_SND_SOC_SOF_HDA */
Signature · 1 line
2.34.1
PATCH 7/21 ASoC: SOF: Intel: move all RIRB/CMD_IO helpers to hda-codec.c
In reply to Pierre-Louis BossartWe need to split basic stream functionality from RIRB/CORB, which are completely codec-related.
--- sound/soc/sof/intel/hda-codec.c | 43 +++++++++++++++++++++++++++++++++ sound/soc/sof/intel/hda-ctrl.c | 33 +++---------------------- sound/soc/sof/intel/hda.h | 6 +++++ 3 files changed, 52 insertions(+), 30 deletions(-)
sound/soc/sof/intel/hda-codec.c +43 -0
@@ -24,6 +24,10 @@#define IDISP_VID_INTEL 0x80860000 +static int hda_codec_mask =-1 ; +module_param_named (codec_mask, hda_codec_mask, int,0444 ); +MODULE_PARM_DESC (codec_mask,"SOF HDA codec mask for probing" ); +/* load the legacy HDA codec driver */ static int request_codec_module (struct hda_codec *codec) {
@@ -229,6 +233,45 @@ void hda_codec_check_for_state_change(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS (hda_codec_check_for_state_change,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_detect_mask (struct snd_sof_dev *sdev) +{ +struct hdac_bus *bus =sof_to_bus (sdev); + +/* Accept unsolicited responses */ +snd_hdac_chip_updatel (bus,GCTL ,AZX_GCTL_UNSOL ,AZX_GCTL_UNSOL ); + +/* detect codecs */ +if (!bus->codec_mask) { + bus->codec_mask =snd_hdac_chip_readw (bus,STATESTS ); +dev_dbg (bus->dev,"codec_mask = 0x%lx\n" , bus->codec_mask); + } + +if (hda_codec_mask !=-1 ) { + bus->codec_mask &= hda_codec_mask; +dev_dbg (bus->dev,"filtered codec_mask = 0x%lx\n" , + bus->codec_mask); + } +} +EXPORT_SYMBOL_NS_GPL (hda_codec_detect_mask,SND_SOC_SOF_HDA_AUDIO_CODEC ); + +void hda_codec_init_cmd_io (struct snd_sof_dev *sdev) +{ +struct hdac_bus *bus =sof_to_bus (sdev); + +/* initialize the codec command I/O */ +snd_hdac_bus_init_cmd_io (bus); +} +EXPORT_SYMBOL_NS_GPL (hda_codec_init_cmd_io,SND_SOC_SOF_HDA_AUDIO_CODEC ); + +void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev) +{ +struct hdac_bus *bus =sof_to_bus (sdev); + +/* clear rirb status */ +snd_hdac_chip_writeb (bus,RIRBSTS ,RIRB_INT_MASK ); +} +EXPORT_SYMBOL_NS_GPL (hda_codec_rirb_status_clear,SND_SOC_SOF_HDA_AUDIO_CODEC ); +#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )
sound/soc/sof/intel/hda-ctrl.c +3 -30
@@ -22,12 +22,6 @@#include "../ops.h" #include "hda.h" -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -static int hda_codec_mask =-1 ; -module_param_named (codec_mask, hda_codec_mask, int,0444 ); -MODULE_PARM_DESC (codec_mask,"SOF HDA codec mask for probing" ); -#endif -/* * HDA Operations. */
@@ -210,22 +204,7 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev) goto err; } -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* Accept unsolicited responses */ -snd_hdac_chip_updatel (bus,GCTL ,AZX_GCTL_UNSOL ,AZX_GCTL_UNSOL ); - -/* detect codecs */ -if (!bus->codec_mask) { - bus->codec_mask =snd_hdac_chip_readw (bus,STATESTS ); -dev_dbg (bus->dev,"codec_mask = 0x%lx\n" , bus->codec_mask); - } - -if (hda_codec_mask !=-1 ) { - bus->codec_mask &= hda_codec_mask; -dev_dbg (bus->dev,"filtered codec_mask = 0x%lx\n" , - bus->codec_mask); - } -#endif +hda_codec_detect_mask (sdev);/* clear stream status */ list_for_each_entry (stream, &bus->stream_list, list) {
@@ -239,19 +218,13 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev)snd_sof_dsp_write (sdev,HDA_DSP_HDA_BAR ,SOF_HDA_WAKESTS ,SOF_HDA_WAKESTS_INT_MASK ); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* clear rirb status */ -snd_hdac_chip_writeb (bus,RIRBSTS ,RIRB_INT_MASK ); -#endif +hda_codec_rirb_status_clear (sdev);/* clear interrupt status register */ snd_sof_dsp_write (sdev,HDA_DSP_HDA_BAR ,SOF_HDA_INTSTS ,SOF_HDA_INT_CTRL_EN |SOF_HDA_INT_ALL_STREAM ); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* initialize the codec command I/O */ -snd_hdac_bus_init_cmd_io (bus); -#endif +hda_codec_init_cmd_io (sdev);/* enable CIE and GIE interrupts */ snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL,
sound/soc/sof/intel/hda.h +6 -0
@@ -718,6 +718,9 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev);void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable);void hda_codec_jack_check (struct snd_sof_dev *sdev);void hda_codec_check_for_state_change (struct snd_sof_dev *sdev); +void hda_codec_init_cmd_io (struct snd_sof_dev *sdev); +void hda_codec_detect_mask (struct snd_sof_dev *sdev); +void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev);#else
@@ -725,6 +728,9 @@ static inline void hda_codec_probe_bus(struct snd_sof_dev *sdev) { }static inline void hda_codec_jack_wake_enable (struct snd_sof_dev *sdev,bool enable) { }static inline void hda_codec_jack_check (struct snd_sof_dev *sdev) { }static inline void hda_codec_check_for_state_change (struct snd_sof_dev *sdev) { } +static inline void hda_codec_init_cmd_io (struct snd_sof_dev *sdev) { } +static inline void hda_codec_detect_mask (struct snd_sof_dev *sdev) { } +static inline void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev) { }#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */
Signature · 1 line
2.34.1
PATCH 8/21 ASoC: SOF: Intel: hda-ctrl: add codec wakeup helper
In reply to Pierre-Louis BossartAdd new helper in hda-codec.c for a clean split between controller and codec.
--- sound/soc/sof/intel/hda-codec.c | 8 ++++++++ sound/soc/sof/intel/hda-ctrl.c | 10 ++++------ sound/soc/sof/intel/hda.h | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-)
sound/soc/sof/intel/hda-codec.c +8 -0
@@ -272,6 +272,14 @@ void hda_codec_rirb_status_clear(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS_GPL (hda_codec_rirb_status_clear,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_set_codec_wakeup (struct snd_sof_dev *sdev,bool status) +{ +struct hdac_bus *bus =sof_to_bus (sdev); + +snd_hdac_set_codec_wakeup (bus, status); +} +EXPORT_SYMBOL_NS_GPL (hda_codec_set_codec_wakeup,SND_SOC_SOF_HDA_AUDIO_CODEC ); +#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )
sound/soc/sof/intel/hda-ctrl.c +4 -6
@@ -185,9 +185,8 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev)if (bus->chip_init)return 0 ; -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -snd_hdac_set_codec_wakeup (bus, true); -#endif +hda_codec_set_codec_wakeup (sdev, true); +hda_dsp_ctrl_misc_clock_gating (sdev, false);/* reset HDA controller */
@@ -245,9 +244,8 @@ int hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev) err:hda_dsp_ctrl_misc_clock_gating (sdev, true); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -snd_hdac_set_codec_wakeup (bus, false); -#endif + +hda_codec_set_codec_wakeup (sdev, false);return ret; }
sound/soc/sof/intel/hda.h +2 -0
@@ -721,6 +721,7 @@ void hda_codec_check_for_state_change(struct snd_sof_dev *sdev);void hda_codec_init_cmd_io (struct snd_sof_dev *sdev);void hda_codec_detect_mask (struct snd_sof_dev *sdev);void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev); +void hda_codec_set_codec_wakeup (struct snd_sof_dev *sdev,bool status);#else
@@ -731,6 +732,7 @@ static inline void hda_codec_check_for_state_change(struct snd_sof_dev *sdev) {static inline void hda_codec_init_cmd_io (struct snd_sof_dev *sdev) { }static inline void hda_codec_detect_mask (struct snd_sof_dev *sdev) { }static inline void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev) { } +static inline void hda_codec_set_codec_wakeup (struct snd_sof_dev *sdev,bool status) { }#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */
Signature · 1 line
2.34.1
PATCH 9/21 ASoC: SOF: Intel: hda-codec: add hda_codec_device_remove() helper
In reply to Pierre-Louis BossartContinue split between controller and codec.
--- sound/soc/sof/intel/hda-codec.c | 9 +++++++++ sound/soc/sof/intel/hda.c | 5 +---- sound/soc/sof/intel/hda.h | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-)
sound/soc/sof/intel/hda-codec.c +9 -0
@@ -280,6 +280,15 @@ void hda_codec_set_codec_wakeup(struct snd_sof_dev *sdev, bool status) }EXPORT_SYMBOL_NS_GPL (hda_codec_set_codec_wakeup,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_device_remove (struct snd_sof_dev *sdev) +{ +struct hdac_bus *bus =sof_to_bus (sdev); + +/* codec removal, invoke bus_device_remove */ +snd_hdac_ext_bus_device_remove (bus); +} +EXPORT_SYMBOL_NS_GPL (hda_codec_device_remove,SND_SOC_SOF_HDA_AUDIO_CODEC ); +#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ #if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) &&IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI )
sound/soc/sof/intel/hda.c +1 -4
@@ -1173,10 +1173,7 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)/* cancel any attempt for DSP D0I3 */ cancel_delayed_work_sync (&hda->d0i3_work); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* codec removal, invoke bus_device_remove */ -snd_hdac_ext_bus_device_remove (bus); -#endif +hda_codec_device_remove (sdev);hda_sdw_exit (sdev);
sound/soc/sof/intel/hda.h +2 -0
@@ -722,6 +722,7 @@ void hda_codec_init_cmd_io(struct snd_sof_dev *sdev);void hda_codec_detect_mask (struct snd_sof_dev *sdev);void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev);void hda_codec_set_codec_wakeup (struct snd_sof_dev *sdev,bool status); +void hda_codec_device_remove (struct snd_sof_dev *sdev);#else
@@ -733,6 +734,7 @@ static inline void hda_codec_init_cmd_io(struct snd_sof_dev *sdev) { }static inline void hda_codec_detect_mask (struct snd_sof_dev *sdev) { }static inline void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev) { }static inline void hda_codec_set_codec_wakeup (struct snd_sof_dev *sdev,bool status) { } +static inline void hda_codec_device_remove (struct snd_sof_dev *sdev) { }#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */
Signature · 1 line
2.34.1
PATCH 10/21 ASoC: SOF: Intel: hda-codec: add stop_cmd_io helper
In reply to Pierre-Louis BossartOne more helper to split controller and codec
--- sound/soc/sof/intel/hda-codec.c | 9 +++++++++ sound/soc/sof/intel/hda-ctrl.c | 6 ++---- sound/soc/sof/intel/hda.h | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-)
sound/soc/sof/intel/hda-codec.c +9 -0
@@ -263,6 +263,15 @@ void hda_codec_init_cmd_io(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS_GPL (hda_codec_init_cmd_io,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_stop_cmd_io (struct snd_sof_dev *sdev) +{ +struct hdac_bus *bus =sof_to_bus (sdev); + +/* initialize the codec command I/O */ +snd_hdac_bus_stop_cmd_io (bus); +} +EXPORT_SYMBOL_NS_GPL (hda_codec_stop_cmd_io,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev) {struct hdac_bus *bus =sof_to_bus (sdev);
sound/soc/sof/intel/hda-ctrl.c +2 -4
@@ -299,10 +299,8 @@ void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev)snd_sof_dsp_write (sdev,HDA_DSP_HDA_BAR ,SOF_HDA_INTSTS ,SOF_HDA_INT_CTRL_EN |SOF_HDA_INT_ALL_STREAM ); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* disable CORB/RIRB */ -snd_hdac_bus_stop_cmd_io (bus); -#endif +hda_codec_stop_cmd_io (sdev); +/* disable position buffer */ if (bus->use_posbuf && bus->posbuf.addr) { snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR,
sound/soc/sof/intel/hda.h +2 -0
@@ -719,6 +719,7 @@ void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable);void hda_codec_jack_check (struct snd_sof_dev *sdev);void hda_codec_check_for_state_change (struct snd_sof_dev *sdev);void hda_codec_init_cmd_io (struct snd_sof_dev *sdev); +void hda_codec_stop_cmd_io (struct snd_sof_dev *sdev);void hda_codec_detect_mask (struct snd_sof_dev *sdev);void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev);void hda_codec_set_codec_wakeup (struct snd_sof_dev *sdev,bool status);
@@ -731,6 +732,7 @@ static inline void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enastatic inline void hda_codec_jack_check (struct snd_sof_dev *sdev) { }static inline void hda_codec_check_for_state_change (struct snd_sof_dev *sdev) { }static inline void hda_codec_init_cmd_io (struct snd_sof_dev *sdev) { } +static inline void hda_codec_stop_cmd_io (struct snd_sof_dev *sdev) { }static inline void hda_codec_detect_mask (struct snd_sof_dev *sdev) { }static inline void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev) { }static inline void hda_codec_set_codec_wakeup (struct snd_sof_dev *sdev,bool status) { }
Signature · 1 line
2.34.1
PATCH 11/21 ASoC: SOF: Intel: hda-stream: always allocate CORB/RIRB buffer
In reply to Pierre-Louis BossartThere is no real reason to filter out this allocation at build time. Let's allocate it always, so that we can have a more dynamic way of disabling HDaudio codec support without having to recompile.
--- sound/soc/sof/intel/hda-stream.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
sound/soc/sof/intel/hda-stream.c +5 -6
@@ -854,15 +854,16 @@ int hda_dsp_stream_init(struct snd_sof_dev *sdev)return -ENOMEM ; } -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* mem alloc for the CORB/RIRB ringbuffers */ +/* +* mem alloc for the CORB/RIRB ringbuffers - this will be used only for +* HDAudio codecs +*/ ret =snd_dma_alloc_pages (SNDRV_DMA_TYPE_DEV , &pci->dev,PAGE_SIZE , &bus->rb);if (ret <0 ) {dev_err (sdev->dev,"error: RB alloc failed\n" );return -ENOMEM ; } -#endif /* create capture streams */ for (i =0 ; i < num_capture; i++) {
@@ -995,11 +996,9 @@ void hda_dsp_stream_free(struct snd_sof_dev *sdev)if (bus->posbuf.area)snd_dma_free_pages (&bus->posbuf); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* free position buffer */ +/* free CORB/RIRB buffer - only used for HDaudio codecs */ if (bus->rb.area)snd_dma_free_pages (&bus->rb); -#endif list_for_each_entry_safe (s, _s, &bus->stream_list, list) {/* TODO: decouple */
Signature · 1 line
2.34.1
PATCH 12/21 ASoC: SOF: Intel: hda-codec: add hda_codec_check_rirb_status() helper
In reply to Pierre-Louis Bossartmove existing functionality to new helper.
--- sound/soc/sof/intel/hda-codec.c | 23 +++++++++++++++++++++++ sound/soc/sof/intel/hda-stream.c | 19 +------------------ sound/soc/sof/intel/hda.h | 2 ++ 3 files changed, 26 insertions(+), 18 deletions(-)
sound/soc/sof/intel/hda-codec.c +23 -0
@@ -289,6 +289,29 @@ void hda_codec_set_codec_wakeup(struct snd_sof_dev *sdev, bool status) }EXPORT_SYMBOL_NS_GPL (hda_codec_set_codec_wakeup,SND_SOC_SOF_HDA_AUDIO_CODEC ); +bool hda_codec_check_rirb_status (struct snd_sof_dev *sdev) +{ +struct hdac_bus *bus =sof_to_bus (sdev); +bool active = false; +u32 rirb_status; + + rirb_status =snd_hdac_chip_readb (bus,RIRBSTS ); +if (rirb_status &RIRB_INT_MASK ) { +/* +* Clearing the interrupt status here ensures +* that no interrupt gets masked after the RIRB +* wp is read in snd_hdac_bus_update_rirb. +*/ +snd_hdac_chip_writeb (bus,RIRBSTS , +RIRB_INT_MASK ); + active = true; +if (rirb_status &RIRB_INT_RESPONSE ) +snd_hdac_bus_update_rirb (bus); + } +return active; +} +EXPORT_SYMBOL_NS_GPL (hda_codec_check_rirb_status,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_device_remove (struct snd_sof_dev *sdev) {struct hdac_bus *bus =sof_to_bus (sdev);
sound/soc/sof/intel/hda-stream.c +1 -18
@@ -765,9 +765,6 @@ irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context) {struct snd_sof_dev *sdev = context;struct hdac_bus *bus =sof_to_bus (sdev); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -u32 rirb_status; -#endif bool active;u32 status;int i;
@@ -785,23 +782,9 @@ irqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context) active =hda_dsp_stream_check (bus, status);/* check and clear RIRB interrupt */ -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )if (status &AZX_INT_CTRL_EN ) { - rirb_status =snd_hdac_chip_readb (bus,RIRBSTS ); -if (rirb_status &RIRB_INT_MASK ) { -/* -* Clearing the interrupt status here ensures -* that no interrupt gets masked after the RIRB -* wp is read in snd_hdac_bus_update_rirb. -*/ -snd_hdac_chip_writeb (bus,RIRBSTS , -RIRB_INT_MASK ); - active = true; -if (rirb_status &RIRB_INT_RESPONSE ) -snd_hdac_bus_update_rirb (bus); - } + active |=hda_codec_check_rirb_status (sdev); } -#endif spin_unlock_irq (&bus->reg_lock); }
sound/soc/sof/intel/hda.h +2 -0
@@ -722,6 +722,7 @@ void hda_codec_init_cmd_io(struct snd_sof_dev *sdev);void hda_codec_stop_cmd_io (struct snd_sof_dev *sdev);void hda_codec_detect_mask (struct snd_sof_dev *sdev);void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev); +bool hda_codec_check_rirb_status (struct snd_sof_dev *sdev);void hda_codec_set_codec_wakeup (struct snd_sof_dev *sdev,bool status);void hda_codec_device_remove (struct snd_sof_dev *sdev);
@@ -735,6 +736,7 @@ static inline void hda_codec_init_cmd_io(struct snd_sof_dev *sdev) { }static inline void hda_codec_stop_cmd_io (struct snd_sof_dev *sdev) { }static inline void hda_codec_detect_mask (struct snd_sof_dev *sdev) { }static inline void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev) { } +static inline bool hda_codec_check_rirb_status (struct snd_sof_dev *sdev) {return false; }static inline void hda_codec_set_codec_wakeup (struct snd_sof_dev *sdev,bool status) { }static inline void hda_codec_device_remove (struct snd_sof_dev *sdev) { }
Signature · 1 line
2.34.1
PATCH 13/21 ASoC: SOF: Intel: hda-ctrl: use helper to clear RIRB status
In reply to Pierre-Louis BossartChange to use helper and avoid conditional compilation.
--- sound/soc/sof/intel/hda-ctrl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
sound/soc/sof/intel/hda-ctrl.c +1 -4
@@ -290,10 +290,7 @@ void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev)snd_sof_dsp_write (sdev,HDA_DSP_HDA_BAR ,SOF_HDA_WAKESTS ,SOF_HDA_WAKESTS_INT_MASK ); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* clear rirb status */ -snd_hdac_chip_writeb (bus,RIRBSTS ,RIRB_INT_MASK ); -#endif +hda_codec_rirb_status_clear (sdev);/* clear interrupt status register */ snd_sof_dsp_write(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS,
Signature · 1 line
2.34.1
PATCH 14/21 ASoC: SOF: Intel: hda-dsp: clarify dependencies on SND_SOC_SOF_HDA
In reply to Pierre-Louis BossartIS_ENABLED is not always in the right places, the codec parts depend on SND_SOC_SOF_HDAUDIO_CODEC
--- sound/soc/sof/intel/hda-dsp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
sound/soc/sof/intel/hda-dsp.c +1 -3
@@ -635,9 +635,9 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)if (ret <0 )return ret; -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )hda_codec_jack_wake_enable (sdev, runtime_suspend); +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )/* power down all hda link */ snd_hdac_ext_bus_link_power_down_all (bus);#endif
@@ -698,14 +698,12 @@ static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume) goto cleanup; } -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )/* check jack status */ if (runtime_resume) {hda_codec_jack_wake_enable (sdev, false);if (sdev->system_suspend_target ==SOF_SUSPEND_NONE )hda_codec_jack_check (sdev); } -#endif /* enable ppcap interrupt */ hda_dsp_ctrl_ppcap_enable (sdev, true);
Signature · 1 line
2.34.1
PATCH 15/21 ASoC: SOF: Intel: hda-codec: add helpers to suspend and resume cmd_io
In reply to Pierre-Louis BossartNo functionality change, code move to have better split between HDaudio codec management and core parts.
--- sound/soc/sof/intel/hda-codec.c | 21 +++++++++++++++++++++ sound/soc/sof/intel/hda-dsp.c | 10 ++++------ sound/soc/sof/intel/hda.h | 4 ++++ 3 files changed, 29 insertions(+), 6 deletions(-)
sound/soc/sof/intel/hda-codec.c +21 -0
@@ -263,6 +263,16 @@ void hda_codec_init_cmd_io(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS_GPL (hda_codec_init_cmd_io,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_resume_cmd_io (struct snd_sof_dev *sdev) +{ +struct hdac_bus *bus =sof_to_bus (sdev); + +/* set up CORB/RIRB buffers if was on before suspend */ +if (bus->cmd_dma_state) +snd_hdac_bus_init_cmd_io (bus); +} +EXPORT_SYMBOL_NS_GPL (hda_codec_resume_cmd_io,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_stop_cmd_io (struct snd_sof_dev *sdev) {struct hdac_bus *bus =sof_to_bus (sdev);
@@ -272,6 +282,17 @@ void hda_codec_stop_cmd_io(struct snd_sof_dev *sdev) }EXPORT_SYMBOL_NS_GPL (hda_codec_stop_cmd_io,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_suspend_cmd_io (struct snd_sof_dev *sdev) +{ +struct hdac_bus *bus =sof_to_bus (sdev); + +/* stop the CORB/RIRB DMA if it is On */ +if (bus->cmd_dma_state) +snd_hdac_bus_stop_cmd_io (bus); + +} +EXPORT_SYMBOL_NS_GPL (hda_codec_suspend_cmd_io,SND_SOC_SOF_HDA_AUDIO_CODEC ); +void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev) {struct hdac_bus *bus =sof_to_bus (sdev);
sound/soc/sof/intel/hda-dsp.c +4 -6
@@ -745,11 +745,10 @@ int hda_dsp_resume(struct snd_sof_dev *sdev) } } } +#endif /* set up CORB/RIRB buffers if was on before suspend */ -if (bus->cmd_dma_state) -snd_hdac_bus_init_cmd_io (bus); -#endif +hda_codec_resume_cmd_io (sdev);/* Set DSP power state */ ret =snd_sof_dsp_set_power_state (sdev, &target_state);
@@ -858,11 +857,10 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)HDA_VS_INTEL_EM2_L1SEN , HDA_VS_INTEL_EM2_L1SEN); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )/* stop the CORB/RIRB DMA if it is On */ -if (bus->cmd_dma_state) -snd_hdac_bus_stop_cmd_io (bus); +hda_codec_suspend_cmd_io (sdev); +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )/* no link can be powered in s0ix state */ ret =snd_hdac_ext_bus_link_power_down_all (bus);if (ret <0 ) {
sound/soc/sof/intel/hda.h +4 -0
@@ -719,7 +719,9 @@ void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable);void hda_codec_jack_check (struct snd_sof_dev *sdev);void hda_codec_check_for_state_change (struct snd_sof_dev *sdev);void hda_codec_init_cmd_io (struct snd_sof_dev *sdev); +void hda_codec_resume_cmd_io (struct snd_sof_dev *sdev);void hda_codec_stop_cmd_io (struct snd_sof_dev *sdev); +void hda_codec_suspend_cmd_io (struct snd_sof_dev *sdev);void hda_codec_detect_mask (struct snd_sof_dev *sdev);void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev);bool hda_codec_check_rirb_status (struct snd_sof_dev *sdev);
@@ -733,7 +735,9 @@ static inline void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enastatic inline void hda_codec_jack_check (struct snd_sof_dev *sdev) { }static inline void hda_codec_check_for_state_change (struct snd_sof_dev *sdev) { }static inline void hda_codec_init_cmd_io (struct snd_sof_dev *sdev) { } +static inline void hda_codec_resume_cmd_io (struct snd_sof_dev *sdev) { }static inline void hda_codec_stop_cmd_io (struct snd_sof_dev *sdev) { } +static inline void hda_codec_suspend_cmd_io (struct snd_sof_dev *sdev) { }static inline void hda_codec_detect_mask (struct snd_sof_dev *sdev) { }static inline void hda_codec_rirb_status_clear (struct snd_sof_dev *sdev) { }static inline bool hda_codec_check_rirb_status (struct snd_sof_dev *sdev) {return false; }
Signature · 1 line
2.34.1
PATCH 16/21 ASoC: SOF: Intel: clarify bus_init and bus_exit sequences
In reply to Pierre-Louis BossartThe dependencies are on SND_SOC_SOF_HDA_AUDIO_CODEC and the bus_exit sequence should be well identified.
--- sound/soc/sof/intel/hda-bus.c | 23 +++++++++++++++-------- sound/soc/sof/intel/hda.c | 7 +++---- sound/soc/sof/intel/hda.h | 3 ++- 3 files changed, 20 insertions(+), 13 deletions(-)
sound/soc/sof/intel/hda-bus.c +15 -8
@@ -18,11 +18,7 @@#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )#include "../../codecs/hdac_hda.h" #define sof_hda_ext_ops snd_soc_hdac_hda_get_ops() -#else -#define sof_hda_ext_ops NULL -#endif -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )static void update_codec_wake_enable (struct hdac_bus *bus,unsigned int addr,bool link_power) {unsigned int mask =snd_hdac_chip_readw (bus,WAKEEN );
@@ -70,11 +66,13 @@ static const struct hdac_bus_ops bus_core_ops = {/* * This can be used for both with/without hda link support. */ -void sof_hda_bus_init (struct hdac_bus *bus,struct device *dev) +void sof_hda_bus_init (struct snd_sof_dev *sdev,struct device *dev) { -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) +struct hdac_bus *bus =sof_to_bus (sdev); + +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )snd_hdac_ext_bus_init (bus, dev, &bus_core_ops, sof_hda_ext_ops); -#else /* CONFIG_SND_SOC_SOF_HDA */ +#else /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ memset (bus,0 ,sizeof (*bus)); bus->dev = dev;
@@ -89,5 +87,14 @@ void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev) bus->idx =0 ;spin_lock_init (&bus->reg_lock); -#endif /* CONFIG_SND_SOC_SOF_HDA */ +#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */ +} + +void sof_hda_bus_exit (struct snd_sof_dev *sdev) +{ +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) +struct hdac_bus *bus =sof_to_bus (sdev); + +snd_hdac_ext_bus_exit (bus); +#endif }
sound/soc/sof/intel/hda.c +3 -4
@@ -696,7 +696,7 @@ static int hda_init(struct snd_sof_dev *sdev) bus =sof_to_bus (sdev);/* HDA bus init */ -sof_hda_bus_init (bus, &pci->dev); +sof_hda_bus_init (sdev, &pci->dev);if (sof_hda_position_quirk ==SOF_HDA_POSITION_QUIRK_USE_DPIB_REGISTERS ) bus->use_posbuf =0 ;
@@ -1208,9 +1208,8 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)iounmap (sdev->bar[HDA_DSP_BAR ]);iounmap (bus->remap_addr); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -snd_hdac_ext_bus_exit (bus); -#endif +sof_hda_bus_exit (sdev); +hda_codec_i915_exit (sdev);return 0 ;
sound/soc/sof/intel/hda.h +2 -1
@@ -708,7 +708,8 @@ void hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev);/* * HDA bus operations. */ -void sof_hda_bus_init (struct hdac_bus *bus,struct device *dev); +void sof_hda_bus_init (struct snd_sof_dev *sdev,struct device *dev); +void sof_hda_bus_exit (struct snd_sof_dev *sdev);#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )/*
Signature · 1 line
2.34.1
PATCH 17/21 ASoC: SOF: Intel: hda-mlink: add helpers to suspend/resume links
In reply to Pierre-Louis BossartNo functionality change, just move the code in hda-mlink.
--- sound/soc/sof/intel/hda-dsp.c | 36 +++++++++------------------------ sound/soc/sof/intel/hda-mlink.c | 21 +++++++++++++++++++ sound/soc/sof/intel/hda.h | 4 ++++ 3 files changed, 35 insertions(+), 26 deletions(-)
sound/soc/sof/intel/hda-dsp.c +10 -26
@@ -614,9 +614,7 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend) {struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;const struct sof_intel_dsp_desc *chip = hda->desc; -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )struct hdac_bus *bus =sof_to_bus (sdev); -#endif int ret, j;/*
@@ -637,10 +635,8 @@ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend)hda_codec_jack_wake_enable (sdev, runtime_suspend); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* power down all hda link */ -snd_hdac_ext_bus_link_power_down_all (bus); -#endif +/* power down all hda links */ +hda_bus_ml_suspend (bus); ret = chip->power_down_dsp (sdev);if (ret <0 ) {
@@ -719,33 +715,23 @@ static int hda_resume(struct snd_sof_dev *sdev, bool runtime_resume)int hda_dsp_resume (struct snd_sof_dev *sdev) {struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; +struct hdac_bus *bus =sof_to_bus (sdev);struct pci_dev *pci =to_pci_dev (sdev->dev);const struct sof_dsp_power_state target_state = { .state =SOF_DSP_PM_D0 , .substate =SOF_HDA_DSP_PM_D0I0 , }; -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -struct hdac_bus *bus =sof_to_bus (sdev); -struct hdac_ext_link *hlink =NULL ; -#endif int ret;/* resume from D0I3 */ if (sdev->dsp_power_state.state ==SOF_DSP_PM_D0 ) { -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -/* power up links that were active before suspend */ -list_for_each_entry (hlink, &bus->hlink_list, list) { -if (hlink->ref_count) { - ret =snd_hdac_ext_bus_link_power_up (hlink); -if (ret <0 ) { -dev_err (sdev->dev, -"error %d in %s: failed to power up links" , - ret, __func__); -return ret; - } - } + ret =hda_bus_ml_resume (bus); +if (ret <0 ) { +dev_err (sdev->dev, +"error %d in %s: failed to power up links" , + ret, __func__); +return ret; } -#endif /* set up CORB/RIRB buffers if was on before suspend */ hda_codec_resume_cmd_io (sdev);
@@ -860,16 +846,14 @@ int hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state)/* stop the CORB/RIRB DMA if it is On */ hda_codec_suspend_cmd_io (sdev); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )/* no link can be powered in s0ix state */ - ret =snd_hdac_ext_bus_link_power_down_all (bus); + ret =hda_bus_ml_suspend (bus);if (ret <0 ) {dev_err (sdev->dev,"error %d in %s: failed to power down links" , ret, __func__);return ret; } -#endif /* enable the system waking up via IPC IRQ */ enable_irq_wake (pci->irq);
sound/soc/sof/intel/hda-mlink.c +21 -0
@@ -51,4 +51,25 @@ void hda_bus_ml_reset_losidv(struct hdac_bus *bus) writel(0, hlink->ml_addr + AZX_REG_ML_LOSIDV); } +int hda_bus_ml_resume (struct hdac_bus *bus) +{ +struct hdac_ext_link *hlink; +int ret; + +/* power up links that were active before suspend */ +list_for_each_entry (hlink, &bus->hlink_list, list) { +if (hlink->ref_count) { + ret =snd_hdac_ext_bus_link_power_up (hlink); +if (ret <0 ) +return ret; + } + } +return 0 ; +} + +int hda_bus_ml_suspend (struct hdac_bus *bus) +{ +return snd_hdac_ext_bus_link_power_down_all (bus); +} +#endif
sound/soc/sof/intel/hda.h +4 -0
@@ -766,12 +766,16 @@ static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }void hda_bus_ml_get_capabilities (struct hdac_bus *bus);void hda_bus_ml_put_all (struct hdac_bus *bus);void hda_bus_ml_reset_losidv (struct hdac_bus *bus); +int hda_bus_ml_resume (struct hdac_bus *bus); +int hda_bus_ml_suspend (struct hdac_bus *bus);#else static inline void hda_bus_ml_get_capabilities (struct hdac_bus *bus) { }static inline void hda_bus_ml_put_all (struct hdac_bus *bus) { }static inline void hda_bus_ml_reset_losidv (struct hdac_bus *bus) { } +static inline int hda_bus_ml_resume (struct hdac_bus *bus) {return 0 ; } +static inline int hda_bus_ml_suspend (struct hdac_bus *bus) {return 0 ; }#endif /* CONFIG_SND_SOC_SOF_HDA */
Signature · 1 line
2.34.1
PATCH 18/21 ASoC: SOF: Intel: add hda_bus_ml_free helper
In reply to Pierre-Louis BossartAdd helper matching allocation done in hda_bus_ml_get_capabilities().
No functionality change, just clearer code partitioning.
--- sound/soc/sof/intel/hda-mlink.c | 14 ++++++++++++++ sound/soc/sof/intel/hda.c | 5 ++--- sound/soc/sof/intel/hda.h | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-)
sound/soc/sof/intel/hda-mlink.c +14 -0
@@ -34,6 +34,20 @@ void hda_bus_ml_get_capabilities(struct hdac_bus *bus)snd_hdac_ext_bus_get_ml_capabilities (bus); } +void hda_bus_ml_free (struct hdac_bus *bus) +{ +struct hdac_ext_link *hlink; + +if (!bus->mlcap) +return ; + +while (!list_empty (&bus->hlink_list)) { + hlink = list_first_entry(&bus->hlink_list, struct hdac_ext_link, list); +list_del (&hlink->list); +kfree (hlink); + } +} +void hda_bus_ml_put_all (struct hdac_bus *bus) {struct hdac_ext_link *hlink;
sound/soc/sof/intel/hda.c +2 -3
@@ -1201,9 +1201,8 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)pci_free_irq_vectors (pci);hda_dsp_stream_free (sdev); -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) -snd_hdac_ext_link_free_all (bus); -#endif + +hda_bus_ml_free (sof_to_bus (sdev));iounmap (sdev->bar[HDA_DSP_BAR ]);iounmap (bus->remap_addr);
sound/soc/sof/intel/hda.h +2 -0
@@ -764,6 +764,7 @@ static inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )void hda_bus_ml_get_capabilities (struct hdac_bus *bus); +void hda_bus_ml_free (struct hdac_bus *bus);void hda_bus_ml_put_all (struct hdac_bus *bus);void hda_bus_ml_reset_losidv (struct hdac_bus *bus);int hda_bus_ml_resume (struct hdac_bus *bus);
@@ -772,6 +773,7 @@ int hda_bus_ml_suspend(struct hdac_bus *bus);#else static inline void hda_bus_ml_get_capabilities (struct hdac_bus *bus) { } +static inline void hda_bus_ml_free (struct hdac_bus *bus) { }static inline void hda_bus_ml_put_all (struct hdac_bus *bus) { }static inline void hda_bus_ml_reset_losidv (struct hdac_bus *bus) { }static inline int hda_bus_ml_resume (struct hdac_bus *bus) {return 0 ; }
Signature · 1 line
2.34.1
PATCH 19/21 ASoC: SOF: Intel: hda: clarify Kconfig dependencies
In reply to Pierre-Louis BossartSince we've moved to the same flows for HDaudio and iDISP codecs, we need to be more consistent about dependencies.
--- sound/soc/sof/intel/hda-dai.c | 10 +++++----- sound/soc/sof/intel/hda.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
sound/soc/sof/intel/hda-dai.c +5 -5
@@ -27,7 +27,7 @@ static bool hda_use_tplg_nhlt;module_param_named (sof_use_tplg_nhlt, hda_use_tplg_nhlt, bool,0444 );MODULE_PARM_DESC (sof_use_tplg_nhlt,"SOF topology nhlt override" ); -#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) +#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) struct hda_pipe_params { u32 ch;
@@ -772,7 +772,7 @@ void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops) ops->drv[i].ops = &ipc3_ssp_dai_ops;continue ; } -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )if (strstr (ops->drv[i].name,"iDisp" ) ||strstr (ops->drv[i].name,"Analog" ) ||strstr (ops->drv[i].name,"Digital" ))
@@ -793,7 +793,7 @@ void hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops) ops->drv[i].ops = &ipc4_ssp_dai_ops;continue ; } -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )if (strstr (ops->drv[i].name,"iDisp" ) ||strstr (ops->drv[i].name,"Analog" ) ||strstr (ops->drv[i].name,"Digital" ))
@@ -911,7 +911,7 @@ struct snd_soc_dai_driver skl_dai[] = { .channels_max = 4, }, }, -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) { .name = "iDisp1 Pin", .playback = {
@@ -984,7 +984,7 @@ int hda_dsp_dais_suspend(struct snd_sof_dev *sdev)* Since the component suspend is called last, we can trap this corner case * and force the DAIs to release their resources. */ -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )int ret; ret =hda_dai_suspend (sof_to_bus (sdev));
sound/soc/sof/intel/hda.c +2 -2
@@ -791,7 +791,7 @@ static int check_nhlt_ssp_mclk_mask(struct snd_sof_dev *sdev, int ssp_num)return intel_nhlt_ssp_mclk_mask (nhlt, ssp_num); } -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) ||IS_ENABLED (CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC ) ||IS_ENABLED (CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE ) static const char *fixup_tplg_name(struct snd_sof_dev *sdev, const char *sof_tplg_filename,
@@ -1222,7 +1222,7 @@ int hda_power_down_dsp(struct snd_sof_dev *sdev)return hda_dsp_core_reset_power_down (sdev, chip->host_managed_cores_mask); } -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )static void hda_generic_machine_select (struct snd_sof_dev *sdev,struct snd_soc_acpi_mach **mach) {
Signature · 1 line
2.34.1
PATCH 20/21 ASoC: SOF: Intel: hda-codec: use GPL-2.0-only license
In reply to Pierre-Louis BossartAll the HDAudio codec handling is completely specific to Linux and completely dependency on GPL2.0 code, specifically the snd_hdac_ library.
There was no intention to have a dual-license for this code, this was an oversight that needs to be corrected. Update the SPDX and EXPORT_SYMBOL information, no functionality change otherwise.
--- sound/soc/sof/intel/hda-codec.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
sound/soc/sof/intel/hda-codec.c +8 -11
@@ -1,7 +1,4 @@ -// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) -// -// This file is provided under a dual BSD/GPLv2 license. When using or -// redistributing this file, you may do so under either license. +// SPDX-License-Identifier: GPL-2.0-only // // Copyright(c) 2018 Intel Corporation. All rights reserved. //
@@ -83,7 +80,7 @@ void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable)snd_hdac_chip_updatew (bus,WAKEEN ,STATESTS_INT_MASK , mask); } -EXPORT_SYMBOL_NS (hda_codec_jack_wake_enable,SND_SOC_SOF_HDA_AUDIO_CODEC ); +EXPORT_SYMBOL_NS_GPL (hda_codec_jack_wake_enable,SND_SOC_SOF_HDA_AUDIO_CODEC );/* check jack status after resuming from suspend mode */ void hda_codec_jack_check (struct snd_sof_dev *sdev)
@@ -99,7 +96,7 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev)if (codec->jacktbl.used)pm_request_resume (&codec->core.dev); } -EXPORT_SYMBOL_NS (hda_codec_jack_check,SND_SOC_SOF_HDA_AUDIO_CODEC ); +EXPORT_SYMBOL_NS_GPL (hda_codec_jack_check,SND_SOC_SOF_HDA_AUDIO_CODEC );#if IS_ENABLED (CONFIG_SND_HDA_GENERIC )#define is_generic_config (bus) \
@@ -218,7 +215,7 @@ void hda_codec_probe_bus(struct snd_sof_dev *sdev) } } } -EXPORT_SYMBOL_NS (hda_codec_probe_bus,SND_SOC_SOF_HDA_AUDIO_CODEC ); +EXPORT_SYMBOL_NS_GPL (hda_codec_probe_bus,SND_SOC_SOF_HDA_AUDIO_CODEC );void hda_codec_check_for_state_change (struct snd_sof_dev *sdev) {
@@ -231,7 +228,7 @@ void hda_codec_check_for_state_change(struct snd_sof_dev *sdev)snd_hdac_chip_writew (bus,STATESTS , codec_mask); } } -EXPORT_SYMBOL_NS (hda_codec_check_for_state_change,SND_SOC_SOF_HDA_AUDIO_CODEC ); +EXPORT_SYMBOL_NS_GPL (hda_codec_check_for_state_change,SND_SOC_SOF_HDA_AUDIO_CODEC );void hda_codec_detect_mask (struct snd_sof_dev *sdev) {
@@ -355,7 +352,7 @@ void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable)snd_hdac_display_power (bus,HDA_CODEC_IDX_CONTROLLER , enable); } } -EXPORT_SYMBOL_NS (hda_codec_i915_display_power,SND_SOC_SOF_HDA_AUDIO_CODEC_I915 ); +EXPORT_SYMBOL_NS_GPL (hda_codec_i915_display_power,SND_SOC_SOF_HDA_AUDIO_CODEC_I915 );int hda_codec_i915_init (struct snd_sof_dev *sdev) {
@@ -372,7 +369,7 @@ int hda_codec_i915_init(struct snd_sof_dev *sdev)return 0 ; } -EXPORT_SYMBOL_NS (hda_codec_i915_init,SND_SOC_SOF_HDA_AUDIO_CODEC_I915 ); +EXPORT_SYMBOL_NS_GPL (hda_codec_i915_init,SND_SOC_SOF_HDA_AUDIO_CODEC_I915 );int hda_codec_i915_exit (struct snd_sof_dev *sdev) {
@@ -386,7 +383,7 @@ int hda_codec_i915_exit(struct snd_sof_dev *sdev) return snd_hdac_i915_exit(bus); } -EXPORT_SYMBOL_NS (hda_codec_i915_exit,SND_SOC_SOF_HDA_AUDIO_CODEC_I915 ); +EXPORT_SYMBOL_NS_GPL (hda_codec_i915_exit,SND_SOC_SOF_HDA_AUDIO_CODEC_I915 );#endif
Signature · 1 line
2.34.1
PATCH 21/21 ASoC: SOF: introduce new DEBUG_NOCODEC mode
In reply to Pierre-Louis BossartThe existing NOCODEC mode enforces a build-time mutual exclusion with the HDaudio link support, mostly to avoid any dependency on the snd_hdac library and references to HDAudio codec/i915 stuff.
This is very useful to track dependencies and test a minimal configuration, but very painful for developers and CI: a recompilation and reinstall of the kernel modules is required.
This patch suggests an alternate middle ground where the selection of the machine driver and all codec-related actions are bypassed at run-time, contingent on a kernel module parameter being set.
For example setting BIT(10) with
'options snd_sof sof_debug=0x401'
is enough to switch from an HDaudio card to a nocodec one.
This new DEBUG_NOCODEC mode is not suitable for distributions and end-users. It's not even recommended on all platforms, i.e. the NOCODEC mode is known not to work on specific devices where the BIOS did not configure support for I2S/DMIC interfaces. The usual development devices such as Chromebooks, Up boards and Intel RVP are the only recommended platforms where this mode can be supported.
Note that the dynamic switch between HDaudio and nocodec may not always possible depending on hardware layout, pin-mux options, and BIOS settings. The audio subsustems on Intel platforms has to support 4 types of interfaces and pin-mux can be complicated.
Reviewers might ask: why didn't we do this earlier? The main reason is that all the codec-related configurations were not cleanly separated out in the sof/intel directory. With all the cleanups done recently, adding this opt-in behavior is relatively straightforward.
Tested on UpExtreme (WHL) and UpExtreme i11 (TGL).
--- sound/soc/sof/Kconfig | 18 ++++++++-- sound/soc/sof/intel/Kconfig | 2 +- sound/soc/sof/intel/hda-codec.c | 59 +++++++++++++++++++++++++++++++++ sound/soc/sof/sof-audio.c | 5 +++ sound/soc/sof/sof-priv.h | 3 ++ 5 files changed, 84 insertions(+), 3 deletions(-)
sound/soc/sof/Kconfig +16 -2
@@ -97,13 +97,13 @@ config SND_SOC_SOF_NOCODEC tristate config SND_SOC_SOF_NOCODEC_SUPPORT - bool "SOF nocodec mode support" + bool "SOF nocodec static mode support" help This adds support for a dummy/nocodec machine driver fallback option if no known codec is detected. This is typically only enabled for developers or devices where the sound card is controlled externally. - This option is mutually exclusive with the Intel HDAudio support. + This option is mutually exclusive at build time with the Intel HDAudio support. Selecting it may have negative impacts and prevent e.g. microphone functionality from being enabled on Intel CoffeeLake and later platforms.
@@ -136,6 +136,19 @@ config SND_SOC_SOF_DEBUG if SND_SOC_SOF_DEBUG +config SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT + bool "SOF nocodec debug mode support" + depends on !SND_SOC_SOF_NOCODEC_SUPPORT + help + This adds support for a dummy/nocodec machine driver fallback + option. + Unlike the SND_SOC_SOF_NOCODEC_SUPPORT, this option is NOT + mutually exclusive at build with the Intel HDAudio support. The + selection will be done depending on command line or modprobe.d settings + Distributions should not select this option! + Say Y if you need this nocodec debug fallback option. + If unsure select "N". + config SND_SOC_SOF_FORCE_NOCODEC_MODE bool "SOF force nocodec Mode" depends on SND_SOC_SOF_NOCODEC_SUPPORT
@@ -239,6 +252,7 @@ config SND_SOC_SOF tristate select SND_SOC_TOPOLOGY select SND_SOC_SOF_NOCODEC if SND_SOC_SOF_NOCODEC_SUPPORT + select SND_SOC_SOF_NOCODEC if SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT help This option is not user-selectable but automagically handled by 'select' statements at a higher level.
sound/soc/sof/intel/Kconfig +1 -1
@@ -277,7 +277,7 @@ if SND_SOC_SOF_HDA_COMMON config SND_SOC_SOF_HDA_LINK bool "SOF support for HDA Links(HDA/HDMI)" - depends on SND_SOC_SOF_NOCODEC=n + depends on SND_SOC_SOF_NOCODEC_SUPPORT=n select SND_SOC_SOF_PROBE_WORK_QUEUE help This adds support for HDA links(HDA/HDMI) with Sound Open Firmware
sound/soc/sof/intel/hda-codec.c +59 -0
149 lines not on this page · raw message
sound/soc/sof/sof-audio.c +5 -0
@@ -826,6 +826,10 @@ int sof_machine_check(struct snd_sof_dev *sdev)if (!IS_ENABLED (CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE )) {const struct snd_sof_of_mach *of_mach; +if (IS_ENABLED (CONFIG_SND_SOC_SOF_NOCODEC_DEBUG_SUPPORT ) && +sof_debug_check_flag (SOF_DBG_FORCE_NOCODEC )) + goto nocodec; +/* find machine */ mach =snd_sof_machine_select (sdev);if (mach) {
@@ -848,6 +852,7 @@ int sof_machine_check(struct snd_sof_dev *sdev)dev_warn (sdev->dev,"Force to use nocodec mode\n" ); } +nocodec:/* select nocodec mode */ dev_warn (sdev->dev,"Using nocodec machine driver\n" ); mach =devm_kzalloc (sdev->dev,sizeof (*mach),GFP_KERNEL );
sound/soc/sof/sof-priv.h +3 -0
@@ -43,6 +43,9 @@#define SOF_DBG_PRINT_IPC_SUCCESS_LOGS BIT(9)/* print IPC success * in dmesg logs */ +#define SOF_DBG_FORCE_NOCODEC BIT(10)/* ignore all codec-related +* configurations +*/ /* Flag definitions used for controlling the DSP dump behavior */ #define SOF_DBG_DUMP_REGS BIT(0)
Signature · 1 line
2.34.1
Mark Brown
maintainerQuoted 6 lines · Pierre-Louis Bossart
Existing HDaudio controllers expose an HDAudio DMA which is used to interface with HDaudio codecs. All other interfaces supported by Intel (SoundWire, SSP, DMIC) rely for data transfers on another GP-DMA managed by the DSP firmware - the HDaudio DMA is only used for memory-to-DSP transfers.
Quoted 6 lines
New HDaudio extensions will enable the use of this HDaudio DMA for all of SoundWire, SSP, DMIC. These extensions will be backwards-compatible for HDaudio and iDISP codecs, but will require new programming sequences and DAI callbacks for SoundWire, SSP and DMIC.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/21] ASoC: SOF: Intel: remove option to disable the common_hdmi handling
commit: 834c69d3b849625d5c5bb81a3425fc8deef5f16d
[02/21] ASoC: SOF: Intel: remove all dependencies on SND_SOC_HDAC_HDMI
commit: 2c6c809cc00b71b3195d76a69d603cc761716ab7
[03/21] ASoC: SOF: Intel: hda-codec: simplify SND_SOC_SOF_HDA_AUDIO_CODEC handling
commit: dc1d964a44dd9eb236f4e98b7b1eaa776093ca8b
[04/21] ASoC: SOF: Intel: move codec state change to hda-codec.c
commit: 580803a70332f6858245498aaf32f59011d8715b
[05/21] ASoC: SOF: Intel: start moving multi-link handling in dedicated file
commit: 52f1610370e3a283adc7bf2b39311be7865f671c
[06/21] ASoC: SOF: Intel: hda: add multi-link helper for LOSVID
commit: 1a7d06ae5dfbaa3dcd801826933531602754338f
[07/21] ASoC: SOF: Intel: move all RIRB/CMD_IO helpers to hda-codec.c
commit: ad09e4465844547c5046e66025b5a468345a96a5
[08/21] ASoC: SOF: Intel: hda-ctrl: add codec wakeup helper
commit: 3246a6c9f09eb244c1f9111a288ab010df2be6de
[09/21] ASoC: SOF: Intel: hda-codec: add hda_codec_device_remove() helper
commit: d4bfba1e754678c51602898ea71570cf6b7cd284
[10/21] ASoC: SOF: Intel: hda-codec: add stop_cmd_io helper
commit: bf2d764b84abfd880eee50d6982dade9224d1734
[11/21] ASoC: SOF: Intel: hda-stream: always allocate CORB/RIRB buffer
commit: 8da5bceb8c4a8d5c06807b32cea94b278e925d22
[12/21] ASoC: SOF: Intel: hda-codec: add hda_codec_check_rirb_status() helper
commit: 87f4230047fc1960377875ff1f1b8f60f736f698
[13/21] ASoC: SOF: Intel: hda-ctrl: use helper to clear RIRB status
commit: 5079aa924fadb9fd811d1a465f034681fe1d074c
[14/21] ASoC: SOF: Intel: hda-dsp: clarify dependencies on SND_SOC_SOF_HDA
commit: d191009f77d8ef53d3b75959a4d7db9fcc0ed1d1
[15/21] ASoC: SOF: Intel: hda-codec: add helpers to suspend and resume cmd_io
commit: 3400afcf6800af0be25bf076862dce9a8eac776e
[16/21] ASoC: SOF: Intel: clarify bus_init and bus_exit sequences
commit: afae09429956b9481d0788385c90238d8d2d038f
[17/21] ASoC: SOF: Intel: hda-mlink: add helpers to suspend/resume links
commit: f402a974aa0ae2b9abcccf49d5ac7c093e86a073
[18/21] ASoC: SOF: Intel: add hda_bus_ml_free helper
commit: 02785b892c2203c08d49811cc67be2775c4e1f32
[19/21] ASoC: SOF: Intel: hda: clarify Kconfig dependencies
commit: a4203256e46932e74984c6554d0c502c8994e0b8
[20/21] ASoC: SOF: Intel: hda-codec: use GPL-2.0-only license
commit: e8b7479d06d565432f87d684d2876d0b0d1f0210
[21/21] ASoC: SOF: introduce new DEBUG_NOCODEC mode
commit: 4bd1adb85a09c249ddb4610e8412bf0f4484a371All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark