Skip to content

Commit 75af419

Browse files
reddysujithbroonie
authored andcommitted
ASoC: SOF: Add DAI configuration support for AMD platforms.
Add support for configuring sp and hs DAI from topology. Signed-off-by: V sujith kumar Reddy <[email protected]> Link: https://lore.kernel.org/r/20221129100102.826781-1-vsujithkumar.reddy@amd.corp-partner.google.com Signed-off-by: Mark Brown <[email protected]>
1 parent aeb2e9c commit 75af419

File tree

7 files changed

+49
-8
lines changed

7 files changed

+49
-8
lines changed

include/sound/sof/dai-amd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct sof_ipc_dai_acp_params {
1717

1818
uint32_t fsync_rate; /* FSYNC frequency in Hz */
1919
uint32_t tdm_slots;
20+
uint32_t tdm_mode;
2021
} __packed;
2122

2223
/* ACPDMIC Configuration Request - SOF_IPC_DAI_AMD_CONFIG */

include/sound/sof/dai.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ enum sof_ipc_dai_type {
8686
SOF_DAI_AMD_DMIC, /**< AMD ACP DMIC */
8787
SOF_DAI_MEDIATEK_AFE, /**< Mediatek AFE */
8888
SOF_DAI_AMD_HS, /**< Amd HS */
89+
SOF_DAI_AMD_SP_VIRTUAL, /**< AMD ACP SP VIRTUAL */
90+
SOF_DAI_AMD_HS_VIRTUAL, /**< AMD ACP HS VIRTUAL */
8991
};
9092

9193
/* general purpose DAI configuration */

include/uapi/sound/sof/tokens.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,9 @@
198198
/* COPIER */
199199
#define SOF_TKN_INTEL_COPIER_NODE_TYPE 1980
200200

201+
/* ACP I2S */
202+
#define SOF_TKN_AMD_ACPI2S_RATE 1700
203+
#define SOF_TKN_AMD_ACPI2S_CH 1701
204+
#define SOF_TKN_AMD_ACPI2S_TDM_MODE 1702
205+
201206
#endif

sound/soc/sof/ipc3-pcm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ static int sof_ipc3_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
336336
channels->min, channels->max);
337337
break;
338338
case SOF_DAI_AMD_SP:
339+
case SOF_DAI_AMD_SP_VIRTUAL:
339340
rate->min = private->dai_config->acpsp.fsync_rate;
340341
rate->max = private->dai_config->acpsp.fsync_rate;
341342
channels->min = private->dai_config->acpsp.tdm_slots;
@@ -347,6 +348,7 @@ static int sof_ipc3_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
347348
channels->min, channels->max);
348349
break;
349350
case SOF_DAI_AMD_HS:
351+
case SOF_DAI_AMD_HS_VIRTUAL:
350352
rate->min = private->dai_config->acphs.fsync_rate;
351353
rate->max = private->dai_config->acphs.fsync_rate;
352354
channels->min = private->dai_config->acphs.tdm_slots;

sound/soc/sof/ipc3-topology.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ static const struct sof_topology_token acpdmic_tokens[] = {
276276
offsetof(struct sof_ipc_dai_acpdmic_params, pdm_ch)},
277277
};
278278

279+
/* ACPI2S */
280+
static const struct sof_topology_token acpi2s_tokens[] = {
281+
{SOF_TKN_AMD_ACPI2S_RATE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
282+
offsetof(struct sof_ipc_dai_acp_params, fsync_rate)},
283+
{SOF_TKN_AMD_ACPI2S_CH, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
284+
offsetof(struct sof_ipc_dai_acp_params, tdm_slots)},
285+
{SOF_TKN_AMD_ACPI2S_TDM_MODE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
286+
offsetof(struct sof_ipc_dai_acp_params, tdm_mode)},
287+
};
288+
279289
/* Core tokens */
280290
static const struct sof_topology_token core_tokens[] = {
281291
{SOF_TKN_COMP_CORE_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
@@ -311,6 +321,7 @@ static const struct sof_token_info ipc3_token_list[SOF_TOKEN_COUNT] = {
311321
[SOF_SAI_TOKENS] = {"SAI tokens", sai_tokens, ARRAY_SIZE(sai_tokens)},
312322
[SOF_AFE_TOKENS] = {"AFE tokens", afe_tokens, ARRAY_SIZE(afe_tokens)},
313323
[SOF_ACPDMIC_TOKENS] = {"ACPDMIC tokens", acpdmic_tokens, ARRAY_SIZE(acpdmic_tokens)},
324+
[SOF_ACPI2S_TOKENS] = {"ACPI2S tokens", acpi2s_tokens, ARRAY_SIZE(acpi2s_tokens)},
314325
};
315326

316327
/**
@@ -1193,6 +1204,7 @@ static int sof_link_acp_sp_load(struct snd_soc_component *scomp, struct snd_sof_
11931204
struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
11941205
struct sof_dai_private_data *private = dai->private;
11951206
u32 size = sizeof(*config);
1207+
int ret;
11961208

11971209
/* handle master/slave and inverted clocks */
11981210
sof_dai_set_format(hw_config, config);
@@ -1201,12 +1213,15 @@ static int sof_link_acp_sp_load(struct snd_soc_component *scomp, struct snd_sof_
12011213
memset(&config->acpsp, 0, sizeof(config->acpsp));
12021214
config->hdr.size = size;
12031215

1204-
config->acpsp.fsync_rate = le32_to_cpu(hw_config->fsync_rate);
1205-
config->acpsp.tdm_slots = le32_to_cpu(hw_config->tdm_slots);
1216+
ret = sof_update_ipc_object(scomp, &config->acpsp, SOF_ACPI2S_TOKENS, slink->tuples,
1217+
slink->num_tuples, size, slink->num_hw_configs);
1218+
if (ret < 0)
1219+
return ret;
12061220

1207-
dev_info(scomp->dev, "ACP_SP config ACP%d channel %d rate %d\n",
1221+
1222+
dev_info(scomp->dev, "ACP_SP config ACP%d channel %d rate %d tdm_mode %d\n",
12081223
config->dai_index, config->acpsp.tdm_slots,
1209-
config->acpsp.fsync_rate);
1224+
config->acpsp.fsync_rate, config->acpsp.tdm_mode);
12101225

12111226
dai->number_configs = 1;
12121227
dai->current_config = 0;
@@ -1223,6 +1238,7 @@ static int sof_link_acp_hs_load(struct snd_soc_component *scomp, struct snd_sof_
12231238
struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
12241239
struct sof_dai_private_data *private = dai->private;
12251240
u32 size = sizeof(*config);
1241+
int ret;
12261242

12271243
/* Configures the DAI hardware format and inverted clocks */
12281244
sof_dai_set_format(hw_config, config);
@@ -1231,12 +1247,14 @@ static int sof_link_acp_hs_load(struct snd_soc_component *scomp, struct snd_sof_
12311247
memset(&config->acphs, 0, sizeof(config->acphs));
12321248
config->hdr.size = size;
12331249

1234-
config->acphs.fsync_rate = le32_to_cpu(hw_config->fsync_rate);
1235-
config->acphs.tdm_slots = le32_to_cpu(hw_config->tdm_slots);
1250+
ret = sof_update_ipc_object(scomp, &config->acphs, SOF_ACPI2S_TOKENS, slink->tuples,
1251+
slink->num_tuples, size, slink->num_hw_configs);
1252+
if (ret < 0)
1253+
return ret;
12361254

1237-
dev_info(scomp->dev, "ACP_HS config ACP%d channel %d rate %d\n",
1255+
dev_info(scomp->dev, "ACP_HS config ACP%d channel %d rate %d tdm_mode %d\n",
12381256
config->dai_index, config->acphs.tdm_slots,
1239-
config->acphs.fsync_rate);
1257+
config->acphs.fsync_rate, config->acphs.tdm_mode);
12401258

12411259
dai->number_configs = 1;
12421260
dai->current_config = 0;
@@ -1545,9 +1563,11 @@ static int sof_ipc3_widget_setup_comp_dai(struct snd_sof_widget *swidget)
15451563
ret = sof_link_acp_bt_load(scomp, slink, config, dai);
15461564
break;
15471565
case SOF_DAI_AMD_SP:
1566+
case SOF_DAI_AMD_SP_VIRTUAL:
15481567
ret = sof_link_acp_sp_load(scomp, slink, config, dai);
15491568
break;
15501569
case SOF_DAI_AMD_HS:
1570+
case SOF_DAI_AMD_HS_VIRTUAL:
15511571
ret = sof_link_acp_hs_load(scomp, slink, config, dai);
15521572
break;
15531573
case SOF_DAI_AMD_DMIC:

sound/soc/sof/sof-audio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ enum sof_tokens {
248248
SOF_COPIER_FORMAT_TOKENS,
249249
SOF_GAIN_TOKENS,
250250
SOF_ACPDMIC_TOKENS,
251+
SOF_ACPI2S_TOKENS,
251252

252253
/* this should be the last */
253254
SOF_TOKEN_COUNT,

sound/soc/sof/topology.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ static const struct sof_dai_types sof_dais[] = {
289289
{"ACPDMIC", SOF_DAI_AMD_DMIC},
290290
{"ACPHS", SOF_DAI_AMD_HS},
291291
{"AFE", SOF_DAI_MEDIATEK_AFE},
292+
{"ACPSP_VIRTUAL", SOF_DAI_AMD_SP_VIRTUAL},
293+
{"ACPHS_VIRTUAL", SOF_DAI_AMD_HS_VIRTUAL},
294+
292295
};
293296

294297
static enum sof_ipc_dai_type find_dai(const char *name)
@@ -1895,6 +1898,13 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, struct snd_
18951898
token_id = SOF_ACPDMIC_TOKENS;
18961899
num_tuples += token_list[SOF_ACPDMIC_TOKENS].count;
18971900
break;
1901+
case SOF_DAI_AMD_SP:
1902+
case SOF_DAI_AMD_HS:
1903+
case SOF_DAI_AMD_SP_VIRTUAL:
1904+
case SOF_DAI_AMD_HS_VIRTUAL:
1905+
token_id = SOF_ACPI2S_TOKENS;
1906+
num_tuples += token_list[SOF_ACPI2S_TOKENS].count;
1907+
break;
18981908
default:
18991909
break;
19001910
}

0 commit comments

Comments
 (0)