diff options
author | Mark Brown <broonie@kernel.org> | 2021-10-05 17:25:23 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-10-05 17:25:23 +0200 |
commit | 6d0c1f787c907058916058ecb9cbd1a8113f3c10 (patch) | |
tree | 994453b7bf9f7eeadd80b24dd7e1ddb8b1ad5a1d | |
parent | Merge series "ASoC: SOF: topology: minor updates" from Pierre-Louis Bossart <... (diff) | |
parent | ASoC: SOF: Intel: hda-dai: improve SSP DAI handling for dynamic pipelines (diff) | |
download | linux-6d0c1f787c907058916058ecb9cbd1a8113f3c10.tar.xz linux-6d0c1f787c907058916058ecb9cbd1a8113f3c10.zip |
Merge series "ASoC: SOF: Intel: add flags to turn on SSP clocks early" from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:
With the chip shortage, some GeminiLake Intel-based designs were
respun and now rely on codecs that need the SSP bit clock turned on in
the hw_params stage, not the trigger stage. This patchset mirrors the
flags added in the SOF DAI_CONFIG IPC, and sets the flags when this
capability is indicated as necessary in the topology files where the
SSP configuration is stored.
We initially considered a more generic solution with an on-demand SSP
clock activation using the common clock framework. This would be a
more elegant solution indeed, but it would have required more
intrusive changes that would conflict with the SOF multi-client
support (in-development), and more backport hassles on product
branches. The on-demand activation of clocks is still a desired
feature that will be enabled at a later point.
Bard Liao (1):
ASoC: SOF: dai-intel: add SOF_DAI_INTEL_SSP_CLKCTRL_MCLK/BCLK_ES bits
Pierre-Louis Bossart (4):
ASoC: SOF: dai: mirror group_id definition added in firmware
ASoC: SOF: dai: include new flags for DAI_CONFIG
ASoC: SOF: Intel: hda: add new flags for DAI_CONFIG
ASoC: SOF: Intel: hda-dai: improve SSP DAI handling for dynamic
pipelines
include/sound/sof/dai-intel.h | 4 ++
include/sound/sof/dai.h | 10 ++++-
sound/soc/sof/intel/hda-dai.c | 82 ++++++++++++++++++++++++++++++++++-
sound/soc/sof/intel/hda.c | 6 +++
sound/soc/sof/sof-audio.c | 4 ++
5 files changed, 103 insertions(+), 3 deletions(-)
--
2.25.1
-rw-r--r-- | include/sound/sof/dai-intel.h | 4 | ||||
-rw-r--r-- | include/sound/sof/dai.h | 10 | ||||
-rw-r--r-- | sound/soc/sof/intel/hda-dai.c | 82 | ||||
-rw-r--r-- | sound/soc/sof/intel/hda.c | 6 | ||||
-rw-r--r-- | sound/soc/sof/sof-audio.c | 4 |
5 files changed, 103 insertions, 3 deletions
diff --git a/include/sound/sof/dai-intel.h b/include/sound/sof/dai-intel.h index 136adf6686e2..7a266f41983c 100644 --- a/include/sound/sof/dai-intel.h +++ b/include/sound/sof/dai-intel.h @@ -48,6 +48,10 @@ #define SOF_DAI_INTEL_SSP_CLKCTRL_FS_KA BIT(4) /* bclk idle */ #define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_IDLE_HIGH BIT(5) +/* mclk early start */ +#define SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_ES BIT(6) +/* bclk early start */ +#define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_ES BIT(7) /* DMIC max. four controllers for eight microphone channels */ #define SOF_DAI_INTEL_DMIC_NUM_CTRL 4 diff --git a/include/sound/sof/dai.h b/include/sound/sof/dai.h index 6bb403e8c5ee..9625f47557b8 100644 --- a/include/sound/sof/dai.h +++ b/include/sound/sof/dai.h @@ -50,6 +50,13 @@ #define SOF_DAI_FMT_INV_MASK 0x0f00 #define SOF_DAI_FMT_CLOCK_PROVIDER_MASK 0xf000 +/* DAI_CONFIG flags */ +#define SOF_DAI_CONFIG_FLAGS_MASK 0x3 +#define SOF_DAI_CONFIG_FLAGS_NONE (0 << 0) /**< DAI_CONFIG sent without stage information */ +#define SOF_DAI_CONFIG_FLAGS_HW_PARAMS (1 << 0) /**< DAI_CONFIG sent during hw_params stage */ +#define SOF_DAI_CONFIG_FLAGS_HW_FREE (2 << 0) /**< DAI_CONFIG sent during hw_free stage */ +#define SOF_DAI_CONFIG_FLAGS_RFU (3 << 0) /**< not used, reserved for future use */ + /** \brief Types of DAI */ enum sof_ipc_dai_type { SOF_DAI_INTEL_NONE = 0, /**< None */ @@ -69,7 +76,8 @@ struct sof_ipc_dai_config { /* physical protocol and clocking */ uint16_t format; /**< SOF_DAI_FMT_ */ - uint16_t reserved16; /**< alignment */ + uint8_t group_id; /**< group ID, 0 means no group (ABI 3.17) */ + uint8_t flags; /**< SOF_DAI_CONFIG_FLAGS_ (ABI 3.19) */ /* reserved for future use */ uint32_t reserved[8]; diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 59d6750c6a20..dfd2df0b1bc3 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -440,6 +440,11 @@ static const struct snd_soc_dai_ops hda_link_dai_ops = { #endif +/* only one flag used so far to harden hw_params/hw_free/trigger/prepare */ +struct ssp_dai_dma_data { + bool setup; +}; + static int ssp_dai_setup_or_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai, bool setup) { @@ -469,22 +474,95 @@ static int ssp_dai_setup_or_free(struct snd_pcm_substream *substream, struct snd return hda_ctrl_dai_widget_free(w); } +static int ssp_dai_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct ssp_dai_dma_data *dma_data; + + dma_data = kzalloc(sizeof(*dma_data), GFP_KERNEL); + if (!dma_data) + return -ENOMEM; + + snd_soc_dai_set_dma_data(dai, substream, dma_data); + + return 0; +} + +static int ssp_dai_setup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai, + bool setup) +{ + struct ssp_dai_dma_data *dma_data; + int ret = 0; + + dma_data = snd_soc_dai_get_dma_data(dai, substream); + if (!dma_data) { + dev_err(dai->dev, "%s: failed to get dma_data\n", __func__); + return -EIO; + } + + if (dma_data->setup != setup) { + ret = ssp_dai_setup_or_free(substream, dai, setup); + if (!ret) + dma_data->setup = setup; + } + return ret; +} + static int ssp_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - return ssp_dai_setup_or_free(substream, dai, true); + /* params are ignored for now */ + return ssp_dai_setup(substream, dai, true); +} + +static int ssp_dai_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + /* + * the SSP will only be reconfigured during resume operations and + * not in case of xruns + */ + return ssp_dai_setup(substream, dai, true); +} + +static int ssp_dai_trigger(struct snd_pcm_substream *substream, + int cmd, struct snd_soc_dai *dai) +{ + if (cmd != SNDRV_PCM_TRIGGER_SUSPEND) + return 0; + + return ssp_dai_setup(substream, dai, false); } static int ssp_dai_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - return ssp_dai_setup_or_free(substream, dai, false); + return ssp_dai_setup(substream, dai, false); +} + +static void ssp_dai_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct ssp_dai_dma_data *dma_data; + + dma_data = snd_soc_dai_get_dma_data(dai, substream); + if (!dma_data) { + dev_err(dai->dev, "%s: failed to get dma_data\n", __func__); + return; + } + snd_soc_dai_set_dma_data(dai, substream, NULL); + kfree(dma_data); } static const struct snd_soc_dai_ops ssp_dai_ops = { + .startup = ssp_dai_startup, .hw_params = ssp_dai_hw_params, + .prepare = ssp_dai_prepare, + .trigger = ssp_dai_trigger, .hw_free = ssp_dai_hw_free, + .shutdown = ssp_dai_shutdown, }; /* diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 066e90506ae6..1463f3de01bc 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -71,6 +71,9 @@ int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w) return ret; } + /* set HW_PARAMS flag */ + config->flags = FIELD_PREP(SOF_DAI_CONFIG_FLAGS_MASK, SOF_DAI_CONFIG_FLAGS_HW_PARAMS); + /* send DAI_CONFIG IPC */ ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size, &reply, sizeof(reply)); @@ -107,6 +110,9 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w) config = &sof_dai->dai_config[sof_dai->current_config]; + /* set HW_FREE flag */ + config->flags = FIELD_PREP(SOF_DAI_CONFIG_FLAGS_MASK, SOF_DAI_CONFIG_FLAGS_HW_FREE); + ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size, &reply, sizeof(reply)); if (ret < 0) diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index c4cabe26b157..262cb3ad4674 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -8,6 +8,7 @@ // Author: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> // +#include <linux/bitfield.h> #include "sof-audio.h" #include "ops.h" @@ -55,6 +56,9 @@ static int sof_dai_config_setup(struct snd_sof_dev *sdev, struct snd_sof_dai *da return -EINVAL; } + /* set NONE flag to clear all previous settings */ + config->flags = FIELD_PREP(SOF_DAI_CONFIG_FLAGS_MASK, SOF_DAI_CONFIG_FLAGS_NONE); + ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size, &reply, sizeof(reply)); |