Skip to content

Commit 2648657

Browse files
ajitkupandeyplbossart
authored andcommitted
ASoC: SOF: topology: add code to parse config params for ACPDMIC dai
Add sof_ipc_dai_acpdmic_params and tokens to parse dmic channels and rate params from topology file Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
1 parent 04fe31c commit 2648657

7 files changed

Lines changed: 41 additions & 11 deletions

File tree

include/sound/sof/dai-amd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,11 @@ struct sof_ipc_dai_acp_params {
1818
uint32_t fsync_rate; /* FSYNC frequency in Hz */
1919
uint32_t tdm_slots;
2020
} __packed;
21+
22+
/* ACPDMIC Configuration Request - SOF_IPC_DAI_AMD_CONFIG */
23+
struct sof_ipc_dai_acpdmic_params {
24+
uint32_t pdm_rate;
25+
uint32_t pdm_ch;
26+
} __packed;
27+
2128
#endif

include/sound/sof/dai.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct sof_ipc_dai_config {
111111
struct sof_ipc_dai_sai_params sai;
112112
struct sof_ipc_dai_acp_params acpbt;
113113
struct sof_ipc_dai_acp_params acpsp;
114-
struct sof_ipc_dai_acp_params acpdmic;
114+
struct sof_ipc_dai_acpdmic_params acpdmic;
115115
struct sof_ipc_dai_mtk_afe_params afe;
116116
};
117117
} __packed;

include/uapi/sound/sof/tokens.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@
157157
/* MIXER */
158158
#define SOF_TKN_MIXER_TYPE 1700
159159

160+
/* ACPDMIC */
161+
#define SOF_TKN_AMD_ACPDMIC_RATE 1800
162+
#define SOF_TKN_AMD_ACPDMIC_CH 1801
163+
160164
/* CAVS AUDIO FORMAT */
161165
#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_RATE 1900
162166
#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_BIT_DEPTH 1901

sound/soc/sof/ipc3-pcm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,10 @@ static int sof_ipc3_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
344344
channels->min, channels->max);
345345
break;
346346
case SOF_DAI_AMD_DMIC:
347-
rate->min = private->dai_config->acpdmic.fsync_rate;
348-
rate->max = private->dai_config->acpdmic.fsync_rate;
349-
channels->min = private->dai_config->acpdmic.tdm_slots;
350-
channels->max = private->dai_config->acpdmic.tdm_slots;
347+
rate->min = private->dai_config->acpdmic.pdm_rate;
348+
rate->max = private->dai_config->acpdmic.pdm_rate;
349+
channels->min = private->dai_config->acpdmic.pdm_ch;
350+
channels->max = private->dai_config->acpdmic.pdm_ch;
351351

352352
dev_dbg(component->dev,
353353
"AMD_DMIC rate_min: %d rate_max: %d\n", rate->min, rate->max);

sound/soc/sof/ipc3-topology.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ static const struct sof_topology_token afe_tokens[] = {
262262
offsetof(struct sof_ipc_dai_mtk_afe_params, format)},
263263
};
264264

265+
266+
/* ACPDMIC */
267+
static const struct sof_topology_token acpdmic_tokens[] = {
268+
{SOF_TKN_AMD_ACPDMIC_RATE,
269+
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
270+
offsetof(struct sof_ipc_dai_acpdmic_params, pdm_rate)},
271+
{SOF_TKN_AMD_ACPDMIC_CH,
272+
SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
273+
offsetof(struct sof_ipc_dai_acpdmic_params, pdm_ch)},
274+
};
275+
265276
/* Core tokens */
266277
static const struct sof_topology_token core_tokens[] = {
267278
{SOF_TKN_COMP_CORE_ID, SND_SOC_TPLG_TUPLE_TYPE_WORD, get_token_u32,
@@ -296,6 +307,7 @@ static const struct sof_token_info ipc3_token_list[SOF_TOKEN_COUNT] = {
296307
[SOF_ESAI_TOKENS] = {"ESAI tokens", esai_tokens, ARRAY_SIZE(esai_tokens)},
297308
[SOF_SAI_TOKENS] = {"SAI tokens", sai_tokens, ARRAY_SIZE(sai_tokens)},
298309
[SOF_AFE_TOKENS] = {"AFE tokens", afe_tokens, ARRAY_SIZE(afe_tokens)},
310+
[SOF_ACPDMIC_TOKENS] = {"ACPDMIC tokens", acpdmic_tokens, ARRAY_SIZE(acpdmic_tokens)},
299311
};
300312

301313
/**
@@ -1104,20 +1116,22 @@ static int sof_link_acp_dmic_load(struct snd_soc_component *scomp, struct snd_so
11041116
struct snd_soc_tplg_hw_config *hw_config = slink->hw_configs;
11051117
struct sof_dai_private_data *private = dai->private;
11061118
u32 size = sizeof(*config);
1119+
int ret;
11071120

11081121
/* handle master/slave and inverted clocks */
11091122
sof_dai_set_format(hw_config, config);
11101123

1111-
/* init IPC */
1112-
memset(&config->acpdmic, 0, sizeof(config->acpdmic));
11131124
config->hdr.size = size;
11141125

1115-
config->acpdmic.fsync_rate = le32_to_cpu(hw_config->fsync_rate);
1116-
config->acpdmic.tdm_slots = le32_to_cpu(hw_config->tdm_slots);
1126+
/* parse the required set of ACPDMIC tokens based on num_hw_cfgs */
1127+
ret = sof_update_ipc_object(scomp, &config->acpdmic, SOF_ACPDMIC_TOKENS, slink->tuples,
1128+
slink->num_tuples, size, slink->num_hw_configs);
1129+
if (ret < 0)
1130+
return ret;
11171131

11181132
dev_info(scomp->dev, "ACP_DMIC config ACP%d channel %d rate %d\n",
1119-
config->dai_index, config->acpdmic.tdm_slots,
1120-
config->acpdmic.fsync_rate);
1133+
config->dai_index, config->acpdmic.pdm_ch,
1134+
config->acpdmic.pdm_rate);
11211135

11221136
dai->number_configs = 1;
11231137
dai->current_config = 0;

sound/soc/sof/sof-audio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ enum sof_tokens {
233233
SOF_AUDIO_FMT_NUM_TOKENS,
234234
SOF_COPIER_FORMAT_TOKENS,
235235
SOF_GAIN_TOKENS,
236+
SOF_ACPDMIC_TOKENS,
236237

237238
/* this should be the last */
238239
SOF_TOKEN_COUNT,

sound/soc/sof/topology.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,10 @@ static int sof_link_load(struct snd_soc_component *scomp, int index, struct snd_
16891689
token_id = SOF_AFE_TOKENS;
16901690
num_tuples += token_list[SOF_AFE_TOKENS].count;
16911691
break;
1692+
case SOF_DAI_AMD_DMIC:
1693+
token_id = SOF_ACPDMIC_TOKENS;
1694+
num_tuples += token_list[SOF_ACPDMIC_TOKENS].count;
1695+
break;
16921696
default:
16931697
break;
16941698
}

0 commit comments

Comments
 (0)