Commit 1fba2036 authored by Cezary Rojewski's avatar Cezary Rojewski Committed by Mark Brown

ASoC: Intel: avs: Parse pplcfg and binding tuples

Path in ADSP firmware is represented by one or more pipelines. Just like
modules, these are described by a config structure. Add parsing helpers
to support loading such information from the topology file.
Signed-off-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220331135246.993089-5-cezary.rojewski@intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 9e85ec40
...@@ -345,6 +345,8 @@ avs_parse_##name##_ptr(struct snd_soc_component *comp, void *elem, void *object, ...@@ -345,6 +345,8 @@ avs_parse_##name##_ptr(struct snd_soc_component *comp, void *elem, void *object,
AVS_DEFINE_PTR_PARSER(audio_format, struct avs_audio_format, fmts); AVS_DEFINE_PTR_PARSER(audio_format, struct avs_audio_format, fmts);
AVS_DEFINE_PTR_PARSER(modcfg_base, struct avs_tplg_modcfg_base, modcfgs_base); AVS_DEFINE_PTR_PARSER(modcfg_base, struct avs_tplg_modcfg_base, modcfgs_base);
AVS_DEFINE_PTR_PARSER(modcfg_ext, struct avs_tplg_modcfg_ext, modcfgs_ext); AVS_DEFINE_PTR_PARSER(modcfg_ext, struct avs_tplg_modcfg_ext, modcfgs_ext);
AVS_DEFINE_PTR_PARSER(pplcfg, struct avs_tplg_pplcfg, pplcfgs);
AVS_DEFINE_PTR_PARSER(binding, struct avs_tplg_binding, bindings);
static int static int
parse_audio_format_bitfield(struct snd_soc_component *comp, void *elem, void *object, u32 offset) parse_audio_format_bitfield(struct snd_soc_component *comp, void *elem, void *object, u32 offset)
...@@ -890,3 +892,115 @@ static int avs_tplg_parse_modcfgs_ext(struct snd_soc_component *comp, ...@@ -890,3 +892,115 @@ static int avs_tplg_parse_modcfgs_ext(struct snd_soc_component *comp,
return 0; return 0;
} }
static const struct avs_tplg_token_parser pplcfg_parsers[] = {
{
.token = AVS_TKN_PPLCFG_REQ_SIZE_U16,
.type = SND_SOC_TPLG_TUPLE_TYPE_SHORT,
.offset = offsetof(struct avs_tplg_pplcfg, req_size),
.parse = avs_parse_short_token,
},
{
.token = AVS_TKN_PPLCFG_PRIORITY_U8,
.type = SND_SOC_TPLG_TUPLE_TYPE_BYTE,
.offset = offsetof(struct avs_tplg_pplcfg, priority),
.parse = avs_parse_byte_token,
},
{
.token = AVS_TKN_PPLCFG_LOW_POWER_BOOL,
.type = SND_SOC_TPLG_TUPLE_TYPE_BOOL,
.offset = offsetof(struct avs_tplg_pplcfg, lp),
.parse = avs_parse_bool_token,
},
{
.token = AVS_TKN_PPLCFG_ATTRIBUTES_U16,
.type = SND_SOC_TPLG_TUPLE_TYPE_SHORT,
.offset = offsetof(struct avs_tplg_pplcfg, attributes),
.parse = avs_parse_short_token,
},
{
.token = AVS_TKN_PPLCFG_TRIGGER_U32,
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
.offset = offsetof(struct avs_tplg_pplcfg, trigger),
.parse = avs_parse_word_token,
},
};
static int avs_tplg_parse_pplcfgs(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;
return parse_dictionary(comp, tuples, block_size, (void **)&tplg->pplcfgs,
&tplg->num_pplcfgs, sizeof(*tplg->pplcfgs),
AVS_TKN_MANIFEST_NUM_PPLCFGS_U32,
AVS_TKN_PPLCFG_ID_U32,
pplcfg_parsers, ARRAY_SIZE(pplcfg_parsers));
}
static const struct avs_tplg_token_parser binding_parsers[] = {
{
.token = AVS_TKN_BINDING_TARGET_TPLG_NAME_STRING,
.type = SND_SOC_TPLG_TUPLE_TYPE_STRING,
.offset = offsetof(struct avs_tplg_binding, target_tplg_name),
.parse = parse_link_formatted_string,
},
{
.token = AVS_TKN_BINDING_TARGET_PATH_TMPL_ID_U32,
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
.offset = offsetof(struct avs_tplg_binding, target_path_tmpl_id),
.parse = avs_parse_word_token,
},
{
.token = AVS_TKN_BINDING_TARGET_PPL_ID_U32,
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
.offset = offsetof(struct avs_tplg_binding, target_ppl_id),
.parse = avs_parse_word_token,
},
{
.token = AVS_TKN_BINDING_TARGET_MOD_ID_U32,
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
.offset = offsetof(struct avs_tplg_binding, target_mod_id),
.parse = avs_parse_word_token,
},
{
.token = AVS_TKN_BINDING_TARGET_MOD_PIN_U8,
.type = SND_SOC_TPLG_TUPLE_TYPE_BYTE,
.offset = offsetof(struct avs_tplg_binding, target_mod_pin),
.parse = avs_parse_byte_token,
},
{
.token = AVS_TKN_BINDING_MOD_ID_U32,
.type = SND_SOC_TPLG_TUPLE_TYPE_WORD,
.offset = offsetof(struct avs_tplg_binding, mod_id),
.parse = avs_parse_word_token,
},
{
.token = AVS_TKN_BINDING_MOD_PIN_U8,
.type = SND_SOC_TPLG_TUPLE_TYPE_BYTE,
.offset = offsetof(struct avs_tplg_binding, mod_pin),
.parse = avs_parse_byte_token,
},
{
.token = AVS_TKN_BINDING_IS_SINK_U8,
.type = SND_SOC_TPLG_TUPLE_TYPE_BYTE,
.offset = offsetof(struct avs_tplg_binding, is_sink),
.parse = avs_parse_byte_token,
},
};
static int avs_tplg_parse_bindings(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;
return parse_dictionary(comp, tuples, block_size, (void **)&tplg->bindings,
&tplg->num_bindings, sizeof(*tplg->bindings),
AVS_TKN_MANIFEST_NUM_BINDINGS_U32,
AVS_TKN_BINDING_ID_U32,
binding_parsers, ARRAY_SIZE(binding_parsers));
}
...@@ -29,6 +29,10 @@ struct avs_tplg { ...@@ -29,6 +29,10 @@ struct avs_tplg {
u32 num_modcfgs_base; u32 num_modcfgs_base;
struct avs_tplg_modcfg_ext *modcfgs_ext; struct avs_tplg_modcfg_ext *modcfgs_ext;
u32 num_modcfgs_ext; u32 num_modcfgs_ext;
struct avs_tplg_pplcfg *pplcfgs;
u32 num_pplcfgs;
struct avs_tplg_binding *bindings;
u32 num_bindings;
}; };
struct avs_tplg_library { struct avs_tplg_library {
...@@ -100,4 +104,28 @@ struct avs_tplg_modcfg_ext { ...@@ -100,4 +104,28 @@ struct avs_tplg_modcfg_ext {
}; };
}; };
/* Specifies path behaviour during PCM ->trigger(START) command. */
enum avs_tplg_trigger {
AVS_TPLG_TRIGGER_AUTO = 0,
};
struct avs_tplg_pplcfg {
u16 req_size;
u8 priority;
bool lp;
u16 attributes;
enum avs_tplg_trigger trigger;
};
struct avs_tplg_binding {
char target_tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
u32 target_path_tmpl_id;
u32 target_ppl_id;
u32 target_mod_id;
u8 target_mod_pin;
u32 mod_id;
u8 mod_pin;
u8 is_sink;
};
#endif #endif
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