Commit 4fdef47a authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown

ASoC: SOF: ipc4-topology: Add new tokens for input/output pin format count

In preparation for handling processing modules with different
input/output pin counts, introduce two new tokens for input/output
audio format counts. Use these token values to parse all the available
audio formats from topology.
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
Reviewed-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230313124856.8140-11-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f534a94c
...@@ -96,6 +96,8 @@ ...@@ -96,6 +96,8 @@
*/ */
#define SOF_TKN_COMP_INPUT_PIN_BINDING_WNAME 413 #define SOF_TKN_COMP_INPUT_PIN_BINDING_WNAME 413
#define SOF_TKN_COMP_OUTPUT_PIN_BINDING_WNAME 414 #define SOF_TKN_COMP_OUTPUT_PIN_BINDING_WNAME 414
#define SOF_TKN_COMP_NUM_INPUT_AUDIO_FORMATS 415
#define SOF_TKN_COMP_NUM_OUTPUT_AUDIO_FORMATS 416
/* SSP */ /* SSP */
......
This diff is collapsed.
...@@ -164,12 +164,14 @@ struct sof_ipc4_pin_format { ...@@ -164,12 +164,14 @@ struct sof_ipc4_pin_format {
* struct sof_ipc4_available_audio_format - Available audio formats * struct sof_ipc4_available_audio_format - Available audio formats
* @output_pin_fmts: Available output pin formats * @output_pin_fmts: Available output pin formats
* @input_pin_fmts: Available input pin formats * @input_pin_fmts: Available input pin formats
* @audio_fmt_num: Number of available audio formats * @num_input_formats: Number of input pin formats
* @num_output_formats: Number of output pin formats
*/ */
struct sof_ipc4_available_audio_format { struct sof_ipc4_available_audio_format {
struct sof_ipc4_pin_format *output_pin_fmts; struct sof_ipc4_pin_format *output_pin_fmts;
struct sof_ipc4_pin_format *input_pin_fmts; struct sof_ipc4_pin_format *input_pin_fmts;
int audio_fmt_num; u32 num_input_formats;
u32 num_output_formats;
}; };
/** /**
......
...@@ -1231,35 +1231,43 @@ static int sof_widget_parse_tokens(struct snd_soc_component *scomp, struct snd_s ...@@ -1231,35 +1231,43 @@ static int sof_widget_parse_tokens(struct snd_soc_component *scomp, struct snd_s
continue; continue;
case SOF_IN_AUDIO_FORMAT_TOKENS: case SOF_IN_AUDIO_FORMAT_TOKENS:
case SOF_OUT_AUDIO_FORMAT_TOKENS: num_sets = sof_get_token_value(SOF_TKN_COMP_NUM_INPUT_AUDIO_FORMATS,
num_sets = sof_get_token_value(SOF_TKN_COMP_NUM_AUDIO_FORMATS,
swidget->tuples, swidget->num_tuples); swidget->tuples, swidget->num_tuples);
if (num_sets < 0) { if (num_sets < 0) {
dev_err(sdev->dev, "Invalid audio format count for %s\n", dev_err(sdev->dev, "Invalid input audio format count for %s\n",
swidget->widget->name); swidget->widget->name);
ret = num_sets; ret = num_sets;
goto err; goto err;
} }
break;
if (num_sets > 1) { case SOF_OUT_AUDIO_FORMAT_TOKENS:
struct snd_sof_tuple *new_tuples; num_sets = sof_get_token_value(SOF_TKN_COMP_NUM_OUTPUT_AUDIO_FORMATS,
swidget->tuples, swidget->num_tuples);
num_tuples += token_list[object_token_list[i]].count * num_sets; if (num_sets < 0) {
new_tuples = krealloc(swidget->tuples, dev_err(sdev->dev, "Invalid output audio format count for %s\n",
sizeof(*new_tuples) * num_tuples, GFP_KERNEL); swidget->widget->name);
if (!new_tuples) { ret = num_sets;
ret = -ENOMEM; goto err;
goto err;
}
swidget->tuples = new_tuples;
} }
break; break;
default: default:
break; break;
} }
if (num_sets > 1) {
struct snd_sof_tuple *new_tuples;
num_tuples += token_list[object_token_list[i]].count * num_sets;
new_tuples = krealloc(swidget->tuples,
sizeof(*new_tuples) * num_tuples, GFP_KERNEL);
if (!new_tuples) {
ret = -ENOMEM;
goto err;
}
swidget->tuples = new_tuples;
}
/* copy one set of tuples per token ID into swidget->tuples */ /* copy one set of tuples per token ID into swidget->tuples */
ret = sof_copy_tuples(sdev, private->array, le32_to_cpu(private->size), ret = sof_copy_tuples(sdev, private->array, le32_to_cpu(private->size),
object_token_list[i], num_sets, swidget->tuples, object_token_list[i], num_sets, swidget->tuples,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment