mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
ASoC: Intel: avs: Parse conditional path tuples
Conditional paths need information about their source and sink paths to be created which is then stored to keep track of who their parents are. That information allows to change their state accordingly to what is currently happening to their parent paths. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250729130633.310388-2-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
8f5ae30d69
commit
8bcfcb3bd3
@@ -133,6 +133,21 @@ enum avs_tplg_token {
|
||||
AVS_TKN_PATH_FE_FMT_ID_U32 = 1902,
|
||||
AVS_TKN_PATH_BE_FMT_ID_U32 = 1903,
|
||||
|
||||
/* struct avs_tplg_path_template (conditional) */
|
||||
AVS_TKN_CONDPATH_TMPL_ID_U32 = 1801,
|
||||
AVS_TKN_CONDPATH_TMPL_SOURCE_TPLG_NAME_STRING = 2002,
|
||||
AVS_TKN_CONDPATH_TMPL_SOURCE_PATH_TMPL_ID_U32 = 2003,
|
||||
AVS_TKN_CONDPATH_TMPL_SINK_TPLG_NAME_STRING = 2004,
|
||||
AVS_TKN_CONDPATH_TMPL_SINK_PATH_TMPL_ID_U32 = 2005,
|
||||
AVS_TKN_CONDPATH_TMPL_COND_TYPE_U32 = 2006,
|
||||
AVS_TKN_CONDPATH_TMPL_OVERRIDABLE_BOOL = 2007,
|
||||
AVS_TKN_CONDPATH_TMPL_PRIORITY_U8 = 2008,
|
||||
|
||||
/* struct avs_tplg_path (conditional) */
|
||||
AVS_TKN_CONDPATH_ID_U32 = 1901,
|
||||
AVS_TKN_CONDPATH_SOURCE_PATH_ID_U32 = 2102,
|
||||
AVS_TKN_CONDPATH_SINK_PATH_ID_U32 = 2103,
|
||||
|
||||
/* struct avs_tplg_pin_format */
|
||||
AVS_TKN_PIN_FMT_INDEX_U32 = 2201,
|
||||
AVS_TKN_PIN_FMT_IOBS_U32 = 2202,
|
||||
|
||||
@@ -1387,6 +1387,27 @@ static const struct avs_tplg_token_parser path_parsers[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const struct avs_tplg_token_parser condpath_parsers[] = {
|
||||
{
|
||||
.token = AVS_TKN_CONDPATH_ID_U32,
|
||||
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
|
||||
.offset = offsetof(struct avs_tplg_path, id),
|
||||
.parse = avs_parse_word_token,
|
||||
},
|
||||
{
|
||||
.token = AVS_TKN_CONDPATH_SOURCE_PATH_ID_U32,
|
||||
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
|
||||
.offset = offsetof(struct avs_tplg_path, source_path_id),
|
||||
.parse = avs_parse_word_token,
|
||||
},
|
||||
{
|
||||
.token = AVS_TKN_CONDPATH_SINK_PATH_ID_U32,
|
||||
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
|
||||
.offset = offsetof(struct avs_tplg_path, sink_path_id),
|
||||
.parse = avs_parse_word_token,
|
||||
},
|
||||
};
|
||||
|
||||
static struct avs_tplg_path *
|
||||
avs_tplg_path_create(struct snd_soc_component *comp, struct avs_tplg_path_template *owner,
|
||||
struct snd_soc_tplg_vendor_array *tuples, u32 block_size,
|
||||
@@ -1454,6 +1475,39 @@ static const struct avs_tplg_token_parser path_tmpl_parsers[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const struct avs_tplg_token_parser condpath_tmpl_parsers[] = {
|
||||
{
|
||||
.token = AVS_TKN_CONDPATH_TMPL_ID_U32,
|
||||
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
|
||||
.offset = offsetof(struct avs_tplg_path_template, id),
|
||||
.parse = avs_parse_word_token,
|
||||
},
|
||||
{
|
||||
.token = AVS_TKN_CONDPATH_TMPL_SOURCE_TPLG_NAME_STRING,
|
||||
.type = SND_SOC_TPLG_TUPLE_TYPE_STRING,
|
||||
.offset = offsetof(struct avs_tplg_path_template, source.tplg_name),
|
||||
.parse = avs_parse_string_token,
|
||||
},
|
||||
{
|
||||
.token = AVS_TKN_CONDPATH_TMPL_SOURCE_PATH_TMPL_ID_U32,
|
||||
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
|
||||
.offset = offsetof(struct avs_tplg_path_template, source.id),
|
||||
.parse = avs_parse_word_token,
|
||||
},
|
||||
{
|
||||
.token = AVS_TKN_CONDPATH_TMPL_SINK_TPLG_NAME_STRING,
|
||||
.type = SND_SOC_TPLG_TUPLE_TYPE_STRING,
|
||||
.offset = offsetof(struct avs_tplg_path_template, sink.tplg_name),
|
||||
.parse = avs_parse_string_token,
|
||||
},
|
||||
{
|
||||
.token = AVS_TKN_CONDPATH_TMPL_SINK_PATH_TMPL_ID_U32,
|
||||
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
|
||||
.offset = offsetof(struct avs_tplg_path_template, sink.id),
|
||||
.parse = avs_parse_word_token,
|
||||
},
|
||||
};
|
||||
|
||||
static int parse_path_template(struct snd_soc_component *comp,
|
||||
struct snd_soc_tplg_vendor_array *tuples, u32 block_size,
|
||||
struct avs_tplg_path_template *template,
|
||||
@@ -1524,6 +1578,56 @@ avs_tplg_path_template_create(struct snd_soc_component *comp, struct avs_tplg *o
|
||||
return template;
|
||||
}
|
||||
|
||||
static int avs_tplg_parse_condpath_templates(struct snd_soc_component *comp,
|
||||
struct snd_soc_tplg_vendor_array *tuples,
|
||||
u32 block_size)
|
||||
{
|
||||
struct avs_soc_component *acomp = to_avs_soc_component(comp);
|
||||
struct avs_tplg *tplg = acomp->tplg;
|
||||
int ret, i;
|
||||
|
||||
ret = parse_dictionary_header(comp, tuples, (void **)&tplg->condpath_tmpls,
|
||||
&tplg->num_condpath_tmpls,
|
||||
sizeof(*tplg->condpath_tmpls),
|
||||
AVS_TKN_MANIFEST_NUM_CONDPATH_TMPLS_U32);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
block_size -= le32_to_cpu(tuples->size);
|
||||
/* With header parsed, move on to parsing entries. */
|
||||
tuples = avs_tplg_vendor_array_next(tuples);
|
||||
|
||||
for (i = 0; i < tplg->num_condpath_tmpls; i++) {
|
||||
struct avs_tplg_path_template *template;
|
||||
u32 esize;
|
||||
|
||||
template = &tplg->condpath_tmpls[i];
|
||||
template->owner = tplg; /* Used when building sysfs hierarchy. */
|
||||
INIT_LIST_HEAD(&template->path_list);
|
||||
INIT_LIST_HEAD(&template->node);
|
||||
|
||||
ret = avs_tplg_vendor_entry_size(tuples, block_size,
|
||||
AVS_TKN_CONDPATH_TMPL_ID_U32, &esize);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = parse_path_template(comp, tuples, esize, template,
|
||||
condpath_tmpl_parsers,
|
||||
ARRAY_SIZE(condpath_tmpl_parsers),
|
||||
condpath_parsers,
|
||||
ARRAY_SIZE(condpath_parsers));
|
||||
if (ret < 0) {
|
||||
dev_err(comp->dev, "parse condpath_tmpl: %d failed: %d\n", i, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
block_size -= esize;
|
||||
tuples = avs_tplg_vendor_array_at(tuples, esize);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct avs_tplg_token_parser mod_init_config_parsers[] = {
|
||||
{
|
||||
.token = AVS_TKN_INIT_CONFIG_ID_U32,
|
||||
@@ -1891,6 +1995,12 @@ static int avs_manifest(struct snd_soc_component *comp, int index,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Condpaths dictionary. */
|
||||
ret = avs_tplg_parse_condpath_templates(comp, tuples,
|
||||
has_init_config ? offset : remaining);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (!has_init_config)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ struct avs_tplg {
|
||||
u32 num_pplcfgs;
|
||||
struct avs_tplg_binding *bindings;
|
||||
u32 num_bindings;
|
||||
struct avs_tplg_path_template *condpath_tmpls;
|
||||
u32 num_condpath_tmpls;
|
||||
struct avs_tplg_init_config *init_configs;
|
||||
u32 num_init_configs;
|
||||
@@ -155,6 +156,10 @@ struct avs_tplg_path_template {
|
||||
|
||||
struct snd_soc_dapm_widget *w;
|
||||
|
||||
/* Conditional path. */
|
||||
struct avs_tplg_path_template_id source;
|
||||
struct avs_tplg_path_template_id sink;
|
||||
|
||||
struct list_head path_list;
|
||||
|
||||
struct avs_tplg *owner;
|
||||
@@ -176,6 +181,9 @@ struct avs_tplg_path {
|
||||
/* Path format requirements. */
|
||||
struct avs_audio_format *fe_fmt;
|
||||
struct avs_audio_format *be_fmt;
|
||||
/* Condpath path-variant requirements. */
|
||||
u32 source_path_id;
|
||||
u32 sink_path_id;
|
||||
|
||||
struct list_head ppl_list;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user