History

ASoC: SOF: Add DAI configuration support for AMD platforms.

Add support for configuring sp and hs DAI from topology.

V sujith kumar Reddy committed 3 years ago

Commit 75af4191 parent aeb2e9c7 files · +49 −8Browse files

Unified · Split

7 files
  1. include/sound/sof/dai-amd.h +1 −0
  2. include/sound/sof/dai.h +2 −0
  3. include/uapi/sound/sof/tokens.h +5 −0
  4. sound/soc/sof/ipc3-pcm.c +2 −0
  5. sound/soc/sof/ipc3-topology.c +28 −8
  6. sound/soc/sof/sof-audio.h +1 −0
  7. sound/soc/sof/topology.c +10 −0
include/sound/sof/dai-amd.h+1−0
@@ -17,6 +17,7 @@ struct sof_ipc_dai_acp_params { · 16 unmodified lines
17 17
18 uint32_t fsync_rate; /* FSYNC frequency in Hz */18 uint32_t fsync_rate; /* FSYNC frequency in Hz */
19 uint32_t tdm_slots;19 uint32_t tdm_slots;
20 uint32_t tdm_mode;
20} __packed;21} __packed;
21 22
22/* ACPDMIC Configuration Request - SOF_IPC_DAI_AMD_CONFIG */23/* ACPDMIC Configuration Request - SOF_IPC_DAI_AMD_CONFIG */
include/sound/sof/dai.h+2−0
@@ -86,6 +86,8 @@ enum sof_ipc_dai_type { · 85 unmodified lines
86 SOF_DAI_AMD_DMIC, /**< AMD ACP DMIC */86 SOF_DAI_AMD_DMIC, /**< AMD ACP DMIC */
87 SOF_DAI_MEDIATEK_AFE, /**< Mediatek AFE */87 SOF_DAI_MEDIATEK_AFE, /**< Mediatek AFE */
88 SOF_DAI_AMD_HS, /**< Amd HS */88 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 */
89};91};
90 92
91/* general purpose DAI configuration */93/* general purpose DAI configuration */
include/uapi/sound/sof/tokens.h+5−0
@@ -198,4 +198,9 @@ · 197 unmodified lines
198/* COPIER */198/* COPIER */
199#define SOF_TKN_INTEL_COPIER_NODE_TYPE 1980199#define SOF_TKN_INTEL_COPIER_NODE_TYPE 1980
200 200
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
201#endif206#endif
sound/soc/sof/ipc3-pcm.c+2−0
@@ -336,6 +336,7 @@ static int sof_ipc3_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, · 335 unmodified lines
336 channels->min, channels->max);336 channels->min, channels->max);
337 break;337 break;
338 case SOF_DAI_AMD_SP:338 case SOF_DAI_AMD_SP:
339 case SOF_DAI_AMD_SP_VIRTUAL:
339 rate->min = private->dai_config->acpsp.fsync_rate;340 rate->min = private->dai_config->acpsp.fsync_rate;
340 rate->max = private->dai_config->acpsp.fsync_rate;341 rate->max = private->dai_config->acpsp.fsync_rate;
341 channels->min = private->dai_config->acpsp.tdm_slots;342 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, · 5 unmodified lines
347 channels->min, channels->max);348 channels->min, channels->max);
348 break;349 break;
349 case SOF_DAI_AMD_HS:350 case SOF_DAI_AMD_HS:
351 case SOF_DAI_AMD_HS_VIRTUAL:
350 rate->min = private->dai_config->acphs.fsync_rate;352 rate->min = private->dai_config->acphs.fsync_rate;
351 rate->max = private->dai_config->acphs.fsync_rate;353 rate->max = private->dai_config->acphs.fsync_rate;
352 channels->min = private->dai_config->acphs.tdm_slots;354 channels->min = private->dai_config->acphs.tdm_slots;
sound/soc/sof/ipc3-topology.c+28−8
@@ -276,6 +276,16 @@ static const struct sof_topology_token acpdmic_tokens[] = { · 275 unmodified lines
276 offsetof(struct sof_ipc_dai_acpdmic_params, pdm_ch)},276 offsetof(struct sof_ipc_dai_acpdmic_params, pdm_ch)},
277};277};
278 278
279/* ACPI2S */
280static 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
279/* Core tokens */289/* Core tokens */
280static const struct sof_topology_token core_tokens[] = {290static const struct sof_topology_token core_tokens[] = {
281 {SOF_TKN_COMP_CORE_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,291 {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] = { · 29 unmodified lines
311 [SOF_SAI_TOKENS] = {"SAI tokens", sai_tokens, ARRAY_SIZE(sai_tokens)},321 [SOF_SAI_TOKENS] = {"SAI tokens", sai_tokens, ARRAY_SIZE(sai_tokens)},
312 [SOF_AFE_TOKENS] = {"AFE tokens", afe_tokens, ARRAY_SIZE(afe_tokens)},322 [SOF_AFE_TOKENS] = {"AFE tokens", afe_tokens, ARRAY_SIZE(afe_tokens)},
313 [SOF_ACPDMIC_TOKENS] = {"ACPDMIC tokens", acpdmic_tokens, ARRAY_SIZE(acpdmic_tokens)},323 [SOF_ACPDMIC_TOKENS] = {"ACPDMIC tokens", acpdmic_tokens, ARRAY_SIZE(acpdmic_tokens)},
324 [SOF_ACPI2S_TOKENS] = {"ACPI2S tokens", acpi2s_tokens, ARRAY_SIZE(acpi2s_tokens)},
314};325};
315 326
316/**327/**
@@ -1193,6 +1204,7 @@ static int sof_link_acp_sp_load(struct snd_soc_component *scomp, struct snd_sof_ · 876 unmodified lines
1193 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;1204 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
1194 struct sof_dai_private_data *private = dai->private;1205 struct sof_dai_private_data *private = dai->private;
1195 u32 size = sizeof(*config);1206 u32 size = sizeof(*config);
1207 int ret;
1196 1208
1197 /* handle master/slave and inverted clocks */1209 /* handle master/slave and inverted clocks */
1198 sof_dai_set_format(hw_config, config);1210 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_ · 2 unmodified lines
1201 memset(&config->acpsp, 0, sizeof(config->acpsp));1213 memset(&config->acpsp, 0, sizeof(config->acpsp));
1202 config->hdr.size = size;1214 config->hdr.size = size;
1203 1215
1204 config->acpsp.fsync_rate = le32_to_cpu(hw_config->fsync_rate);1216 ret = sof_update_ipc_object(scomp, &config->acpsp, SOF_ACPI2S_TOKENS, slink->tuples,
1205 config->acpsp.tdm_slots = le32_to_cpu(hw_config->tdm_slots);1217 slink->num_tuples, size, slink->num_hw_configs);
1218 if (ret < 0)
1219 return ret;
1206 1220
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",
1208 config->dai_index, config->acpsp.tdm_slots,1223 config->dai_index, config->acpsp.tdm_slots,
1209 config->acpsp.fsync_rate);1224 config->acpsp.fsync_rate, config->acpsp.tdm_mode);
1210 1225
1211 dai->number_configs = 1;1226 dai->number_configs = 1;
1212 dai->current_config = 0;1227 dai->current_config = 0;
@@ -1223,6 +1238,7 @@ static int sof_link_acp_hs_load(struct snd_soc_component *scomp, struct snd_sof_ · 10 unmodified lines
1223 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;1238 struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
1224 struct sof_dai_private_data *private = dai->private;1239 struct sof_dai_private_data *private = dai->private;
1225 u32 size = sizeof(*config);1240 u32 size = sizeof(*config);
1241 int ret;
1226 1242
1227 /* Configures the DAI hardware format and inverted clocks */1243 /* Configures the DAI hardware format and inverted clocks */
1228 sof_dai_set_format(hw_config, config);1244 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_ · 2 unmodified lines
1231 memset(&config->acphs, 0, sizeof(config->acphs));1247 memset(&config->acphs, 0, sizeof(config->acphs));
1232 config->hdr.size = size;1248 config->hdr.size = size;
1233 1249
1234 config->acphs.fsync_rate = le32_to_cpu(hw_config->fsync_rate);1250 ret = sof_update_ipc_object(scomp, &config->acphs, SOF_ACPI2S_TOKENS, slink->tuples,
1235 config->acphs.tdm_slots = le32_to_cpu(hw_config->tdm_slots);1251 slink->num_tuples, size, slink->num_hw_configs);
1252 if (ret < 0)
1253 return ret;
1236 1254
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",
1238 config->dai_index, config->acphs.tdm_slots,1256 config->dai_index, config->acphs.tdm_slots,
1239 config->acphs.fsync_rate);1257 config->acphs.fsync_rate, config->acphs.tdm_mode);
1240 1258
1241 dai->number_configs = 1;1259 dai->number_configs = 1;
1242 dai->current_config = 0;1260 dai->current_config = 0;
@@ -1545,9 +1563,11 @@ static int sof_ipc3_widget_setup_comp_dai(struct snd_sof_widget *swidget) · 302 unmodified lines
1545 ret = sof_link_acp_bt_load(scomp, slink, config, dai);1563 ret = sof_link_acp_bt_load(scomp, slink, config, dai);
1546 break;1564 break;
1547 case SOF_DAI_AMD_SP:1565 case SOF_DAI_AMD_SP:
1566 case SOF_DAI_AMD_SP_VIRTUAL:
1548 ret = sof_link_acp_sp_load(scomp, slink, config, dai);1567 ret = sof_link_acp_sp_load(scomp, slink, config, dai);
1549 break;1568 break;
1550 case SOF_DAI_AMD_HS:1569 case SOF_DAI_AMD_HS:
1570 case SOF_DAI_AMD_HS_VIRTUAL:
1551 ret = sof_link_acp_hs_load(scomp, slink, config, dai);1571 ret = sof_link_acp_hs_load(scomp, slink, config, dai);
1552 break;1572 break;
1553 case SOF_DAI_AMD_DMIC:1573 case SOF_DAI_AMD_DMIC:
sound/soc/sof/sof-audio.h+1−0
@@ -248,6 +248,7 @@ enum sof_tokens { · 247 unmodified lines
248 SOF_COPIER_FORMAT_TOKENS,248 SOF_COPIER_FORMAT_TOKENS,
249 SOF_GAIN_TOKENS,249 SOF_GAIN_TOKENS,
250 SOF_ACPDMIC_TOKENS,250 SOF_ACPDMIC_TOKENS,
251 SOF_ACPI2S_TOKENS,
251 252
252 /* this should be the last */253 /* this should be the last */
253 SOF_TOKEN_COUNT,254 SOF_TOKEN_COUNT,
sound/soc/sof/topology.c+10−0
@@ -289,6 +289,9 @@ static const struct sof_dai_types sof_dais[] = { · 288 unmodified lines
289 {"ACPDMIC", SOF_DAI_AMD_DMIC},289 {"ACPDMIC", SOF_DAI_AMD_DMIC},
290 {"ACPHS", SOF_DAI_AMD_HS},290 {"ACPHS", SOF_DAI_AMD_HS},
291 {"AFE", SOF_DAI_MEDIATEK_AFE},291 {"AFE", SOF_DAI_MEDIATEK_AFE},
292 {"ACPSP_VIRTUAL", SOF_DAI_AMD_SP_VIRTUAL},
293 {"ACPHS_VIRTUAL", SOF_DAI_AMD_HS_VIRTUAL},
294
292};295};
293 296
294static enum sof_ipc_dai_type find_dai(const char *name)297static 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_ · 1600 unmodified lines
1895 token_id = SOF_ACPDMIC_TOKENS;1898 token_id = SOF_ACPDMIC_TOKENS;
1896 num_tuples += token_list[SOF_ACPDMIC_TOKENS].count;1899 num_tuples += token_list[SOF_ACPDMIC_TOKENS].count;
1897 break;1900 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;
1898 default:1908 default:
1899 break;1909 break;
1900 }1910 }