Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: amd: Add Soundwire DAI configuration support for AMD platforms

Add support for configuring AMD Soundwire DAI from topology.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Link: https://msgid.link/r/20240129055147.1493853-10-Vijendar.Mukunda@amd.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Vijendar Mukunda and committed by
Mark Brown
14d89e55 96eb8185

+84
+7
include/sound/sof/dai-amd.h
··· 26 26 uint32_t pdm_ch; 27 27 } __packed; 28 28 29 + /* ACP_SDW Configuration Request - SOF_IPC_DAI_AMD_SDW_CONFIG */ 30 + struct sof_ipc_dai_acp_sdw_params { 31 + struct sof_ipc_hdr hdr; 32 + u32 rate; 33 + u32 channels; 34 + } __packed; 35 + 29 36 #endif
+2
include/sound/sof/dai.h
··· 89 89 SOF_DAI_AMD_SP_VIRTUAL, /**< AMD ACP SP VIRTUAL */ 90 90 SOF_DAI_AMD_HS_VIRTUAL, /**< AMD ACP HS VIRTUAL */ 91 91 SOF_DAI_IMX_MICFIL, /** < i.MX MICFIL PDM */ 92 + SOF_DAI_AMD_SDW, /**< AMD ACP SDW */ 92 93 }; 93 94 94 95 /* general purpose DAI configuration */ ··· 120 119 struct sof_ipc_dai_acp_params acphs; 121 120 struct sof_ipc_dai_mtk_afe_params afe; 122 121 struct sof_ipc_dai_micfil_params micfil; 122 + struct sof_ipc_dai_acp_sdw_params acp_sdw; 123 123 }; 124 124 } __packed; 125 125
+4
include/uapi/sound/sof/tokens.h
··· 218 218 #define SOF_TKN_IMX_MICFIL_RATE 2000 219 219 #define SOF_TKN_IMX_MICFIL_CH 2001 220 220 221 + /* ACP SDW */ 222 + #define SOF_TKN_AMD_ACP_SDW_RATE 2100 223 + #define SOF_TKN_AMD_ACP_SDW_CH 2101 224 + 221 225 #endif
+25
sound/soc/sof/ipc3-pcm.c
··· 395 395 dev_dbg(component->dev, "MICFIL PDM channels_min: %d channels_max: %d\n", 396 396 channels->min, channels->max); 397 397 break; 398 + case SOF_DAI_AMD_SDW: 399 + /* change the default trigger sequence as per HW implementation */ 400 + for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) { 401 + struct snd_soc_pcm_runtime *fe = dpcm->fe; 402 + 403 + fe->dai_link->trigger[SNDRV_PCM_STREAM_PLAYBACK] = 404 + SND_SOC_DPCM_TRIGGER_POST; 405 + } 406 + 407 + for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) { 408 + struct snd_soc_pcm_runtime *fe = dpcm->fe; 409 + 410 + fe->dai_link->trigger[SNDRV_PCM_STREAM_CAPTURE] = 411 + SND_SOC_DPCM_TRIGGER_POST; 412 + } 413 + rate->min = private->dai_config->acp_sdw.rate; 414 + rate->max = private->dai_config->acp_sdw.rate; 415 + channels->min = private->dai_config->acp_sdw.channels; 416 + channels->max = private->dai_config->acp_sdw.channels; 417 + 418 + dev_dbg(component->dev, 419 + "AMD_SDW rate_min: %d rate_max: %d\n", rate->min, rate->max); 420 + dev_dbg(component->dev, "AMD_SDW channels_min: %d channels_max: %d\n", 421 + channels->min, channels->max); 422 + break; 398 423 default: 399 424 dev_err(component->dev, "Invalid DAI type %d\n", private->dai_config->type); 400 425 break;
+40
sound/soc/sof/ipc3-topology.c
··· 298 298 offsetof(struct sof_ipc_dai_micfil_params, pdm_ch)}, 299 299 }; 300 300 301 + /* ACP_SDW */ 302 + static const struct sof_topology_token acp_sdw_tokens[] = { 303 + {SOF_TKN_AMD_ACP_SDW_RATE, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, 304 + offsetof(struct sof_ipc_dai_acp_sdw_params, rate)}, 305 + {SOF_TKN_AMD_ACP_SDW_CH, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, 306 + offsetof(struct sof_ipc_dai_acp_sdw_params, channels)}, 307 + }; 308 + 301 309 /* Core tokens */ 302 310 static const struct sof_topology_token core_tokens[] = { 303 311 {SOF_TKN_COMP_CORE_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32, ··· 344 336 [SOF_ACPI2S_TOKENS] = {"ACPI2S tokens", acpi2s_tokens, ARRAY_SIZE(acpi2s_tokens)}, 345 337 [SOF_MICFIL_TOKENS] = {"MICFIL PDM tokens", 346 338 micfil_pdm_tokens, ARRAY_SIZE(micfil_pdm_tokens)}, 339 + [SOF_ACP_SDW_TOKENS] = {"ACP_SDW tokens", acp_sdw_tokens, ARRAY_SIZE(acp_sdw_tokens)}, 347 340 }; 348 341 349 342 /** ··· 1324 1315 return 0; 1325 1316 } 1326 1317 1318 + static int sof_link_acp_sdw_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink, 1319 + struct sof_ipc_dai_config *config, struct snd_sof_dai *dai) 1320 + { 1321 + struct sof_dai_private_data *private = dai->private; 1322 + u32 size = sizeof(*config); 1323 + int ret; 1324 + 1325 + /* parse the required set of ACP_SDW tokens based on num_hw_cfgs */ 1326 + ret = sof_update_ipc_object(scomp, &config->acp_sdw, SOF_ACP_SDW_TOKENS, slink->tuples, 1327 + slink->num_tuples, size, slink->num_hw_configs); 1328 + if (ret < 0) 1329 + return ret; 1330 + 1331 + /* init IPC */ 1332 + config->hdr.size = size; 1333 + dev_dbg(scomp->dev, "ACP SDW config rate %d channels %d\n", 1334 + config->acp_sdw.rate, config->acp_sdw.channels); 1335 + 1336 + /* set config for all DAI's with name matching the link name */ 1337 + dai->number_configs = 1; 1338 + dai->current_config = 0; 1339 + private->dai_config = kmemdup(config, size, GFP_KERNEL); 1340 + if (!private->dai_config) 1341 + return -ENOMEM; 1342 + 1343 + return 0; 1344 + } 1345 + 1327 1346 static int sof_link_afe_load(struct snd_soc_component *scomp, struct snd_sof_dai_link *slink, 1328 1347 struct sof_ipc_dai_config *config, struct snd_sof_dai *dai) 1329 1348 { ··· 1665 1628 break; 1666 1629 case SOF_DAI_MEDIATEK_AFE: 1667 1630 ret = sof_link_afe_load(scomp, slink, config, dai); 1631 + break; 1632 + case SOF_DAI_AMD_SDW: 1633 + ret = sof_link_acp_sdw_load(scomp, slink, config, dai); 1668 1634 break; 1669 1635 default: 1670 1636 break;
+1
sound/soc/sof/sof-audio.h
··· 276 276 SOF_ACPDMIC_TOKENS, 277 277 SOF_ACPI2S_TOKENS, 278 278 SOF_MICFIL_TOKENS, 279 + SOF_ACP_SDW_TOKENS, 279 280 280 281 /* this should be the last */ 281 282 SOF_TOKEN_COUNT,
+5
sound/soc/sof/topology.c
··· 297 297 {"ACPSP_VIRTUAL", SOF_DAI_AMD_SP_VIRTUAL}, 298 298 {"ACPHS_VIRTUAL", SOF_DAI_AMD_HS_VIRTUAL}, 299 299 {"MICFIL", SOF_DAI_IMX_MICFIL}, 300 + {"ACP_SDW", SOF_DAI_AMD_SDW}, 300 301 301 302 }; 302 303 ··· 1968 1967 case SOF_DAI_IMX_MICFIL: 1969 1968 token_id = SOF_MICFIL_TOKENS; 1970 1969 num_tuples += token_list[SOF_MICFIL_TOKENS].count; 1970 + break; 1971 + case SOF_DAI_AMD_SDW: 1972 + token_id = SOF_ACP_SDW_TOKENS; 1973 + num_tuples += token_list[SOF_ACP_SDW_TOKENS].count; 1971 1974 break; 1972 1975 default: 1973 1976 break;