| From f7e70b10a3bd4a0ed64ae9bf24d0bfe00bee523f Mon Sep 17 00:00:00 2001 |
| From: V sujith kumar Reddy <vsujithkumar.reddy@amd.corp-partner.google.com> |
| Date: Fri, 20 May 2022 15:19:26 +0530 |
| Subject: [PATCH] CHROMIUM: ASoC: SOF: Adding HS functionality to the sof core |
| |
| Add I2S HS control instance to the sof core. |
| This will help the amd topology to use the I2S HS Dai |
| |
| BUG=b:228921710 |
| TEST=SOF audio on Skyrim |
| |
| Signed-off-by: V sujith kumar Reddy <Vsujithkumar.Reddy@amd.com> |
| Change-Id: I32aa04346430d3585736fb8464ef888f4cb8d88a |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3655792 |
| Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org> |
| Tested-by: Yu-Hsuan Hsu <yuhsuan@chromium.org> |
| Commit-Queue: Yu-Hsuan Hsu <yuhsuan@chromium.org> |
| --- |
| include/sound/sof/dai.h | 2 ++ |
| sound/soc/sof/ipc3-pcm.c | 11 +++++++++++ |
| sound/soc/sof/ipc3-topology.c | 33 +++++++++++++++++++++++++++++++++ |
| sound/soc/sof/topology.c | 1 + |
| 4 files changed, 47 insertions(+) |
| |
| diff --git a/include/sound/sof/dai.h b/include/sound/sof/dai.h |
| index 21d98f31a9ca..83fd81c82e4c 100644 |
| --- a/include/sound/sof/dai.h |
| +++ b/include/sound/sof/dai.h |
| @@ -84,6 +84,7 @@ enum sof_ipc_dai_type { |
| SOF_DAI_AMD_BT, /**< AMD ACP BT*/ |
| SOF_DAI_AMD_SP, /**< AMD ACP SP */ |
| SOF_DAI_AMD_DMIC, /**< AMD ACP DMIC */ |
| + SOF_DAI_AMD_HS, /**< Amd HS */ |
| SOF_DAI_MEDIATEK_AFE, /**< Mediatek AFE */ |
| }; |
| |
| @@ -112,6 +113,7 @@ struct sof_ipc_dai_config { |
| struct sof_ipc_dai_acp_params acpbt; |
| struct sof_ipc_dai_acp_params acpsp; |
| struct sof_ipc_dai_acpdmic_params acpdmic; |
| + struct sof_ipc_dai_acp_params acphs; |
| struct sof_ipc_dai_mtk_afe_params afe; |
| }; |
| } __packed; |
| diff --git a/sound/soc/sof/ipc3-pcm.c b/sound/soc/sof/ipc3-pcm.c |
| index 9c6a84bdeca7..40fc1d6f0d0e 100644 |
| --- a/sound/soc/sof/ipc3-pcm.c |
| +++ b/sound/soc/sof/ipc3-pcm.c |
| @@ -346,6 +346,17 @@ static int sof_ipc3_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, |
| dev_dbg(component->dev, "AMD_SP channels_min: %d channels_max: %d\n", |
| channels->min, channels->max); |
| break; |
| + case SOF_DAI_AMD_HS: |
| + rate->min = private->dai_config->acphs.fsync_rate; |
| + rate->max = private->dai_config->acphs.fsync_rate; |
| + channels->min = private->dai_config->acphs.tdm_slots; |
| + channels->max = private->dai_config->acphs.tdm_slots; |
| + |
| + dev_dbg(component->dev, |
| + "AMD_HS rate_min: %d rate_max: %d\n", rate->min, rate->max); |
| + dev_dbg(component->dev, "AMD_HS channels_min: %d channels_max: %d\n", |
| + channels->min, channels->max); |
| + break; |
| case SOF_DAI_AMD_DMIC: |
| rate->min = private->dai_config->acpdmic.pdm_rate; |
| rate->max = private->dai_config->acpdmic.pdm_rate; |
| diff --git a/sound/soc/sof/ipc3-topology.c b/sound/soc/sof/ipc3-topology.c |
| index b2cc046b9f60..057f4077d78a 100644 |
| --- a/sound/soc/sof/ipc3-topology.c |
| +++ b/sound/soc/sof/ipc3-topology.c |
| @@ -1217,6 +1217,36 @@ static int sof_link_acp_sp_load(struct snd_soc_component *scomp, struct snd_sof_ |
| return 0; |
| } |
| |
| +static int sof_link_acp_hs_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink, |
| + struct sof_ipc_dai_config *config, struct snd_sof_dai *dai) |
| +{ |
| + struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs; |
| + struct sof_dai_private_data *private = dai->private; |
| + u32 size = sizeof(*config); |
| + |
| + /* handle master/slave and inverted clocks */ |
| + sof_dai_set_format(hw_config, config); |
| + |
| + /* init IPC */ |
| + memset(&config->acphs, 0, sizeof(config->acphs)); |
| + config->hdr.size = size; |
| + |
| + config->acphs.fsync_rate = le32_to_cpu(hw_config->fsync_rate); |
| + config->acphs.tdm_slots = le32_to_cpu(hw_config->tdm_slots); |
| + |
| + dev_info(scomp->dev, "ACP_HS config ACP%d channel %d rate %d\n", |
| + config->dai_index, config->acphs.tdm_slots, |
| + config->acphs.fsync_rate); |
| + |
| + dai->number_configs = 1; |
| + dai->current_config = 0; |
| + private->dai_config = kmemdup(config, size, GFP_KERNEL); |
| + if (!private->dai_config) |
| + return -ENOMEM; |
| + |
| + return 0; |
| +} |
| + |
| static int sof_link_afe_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink, |
| struct sof_ipc_dai_config *config, struct snd_sof_dai *dai) |
| { |
| @@ -1510,6 +1540,9 @@ static int sof_ipc3_widget_setup_comp_dai(struct snd_sof_widget *swidget) |
| case SOF_DAI_AMD_SP: |
| ret = sof_link_acp_sp_load(scomp, slink, config, dai); |
| break; |
| + case SOF_DAI_AMD_HS: |
| + ret = sof_link_acp_hs_load(scomp, slink, config, dai); |
| + break; |
| case SOF_DAI_AMD_DMIC: |
| ret = sof_link_acp_dmic_load(scomp, slink, config, dai); |
| break; |
| diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c |
| index 9273a70fec25..f7b3302ec202 100644 |
| --- a/sound/soc/sof/topology.c |
| +++ b/sound/soc/sof/topology.c |
| @@ -287,6 +287,7 @@ static const struct sof_dai_types sof_dais[] = { |
| {"ACP", SOF_DAI_AMD_BT}, |
| {"ACPSP", SOF_DAI_AMD_SP}, |
| {"ACPDMIC", SOF_DAI_AMD_DMIC}, |
| + {"ACPHS", SOF_DAI_AMD_HS}, |
| {"AFE", SOF_DAI_MEDIATEK_AFE}, |
| }; |
| |
| -- |
| 2.37.1.595.g718a3a8f04-goog |
| |