Commit ca312fda authored by Shreyas NC's avatar Shreyas NC Committed by Mark Brown

ASoC: Intel: Skylake: Commonize parsing of format tokens

Format resource tokens can be a part of either the widget or manifest
private data. In the current model, format resources come as a part of
widget private data and they come as a part of topology manifest in the
newly introduced model.

So add a common function that can fill up either of the structures.
Signed-off-by: default avatarShreyas NC <shreyas.nc@intel.com>
Signed-off-by: default avatarGuneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3d52a792
...@@ -1948,27 +1948,9 @@ static int skl_tplg_fill_pins_info(struct device *dev, ...@@ -1948,27 +1948,9 @@ static int skl_tplg_fill_pins_info(struct device *dev,
* on the direction * on the direction
*/ */
static int skl_tplg_fill_fmt(struct device *dev, static int skl_tplg_fill_fmt(struct device *dev,
struct skl_module_cfg *mconfig, u32 tkn, struct skl_module_fmt *dst_fmt,
u32 value, u32 dir, u32 pin_count) u32 tkn, u32 value)
{ {
struct skl_module_fmt *dst_fmt;
switch (dir) {
case SKL_DIR_IN:
dst_fmt = mconfig->in_fmt;
dst_fmt += pin_count;
break;
case SKL_DIR_OUT:
dst_fmt = mconfig->out_fmt;
dst_fmt += pin_count;
break;
default:
dev_err(dev, "Invalid direction value\n");
return -EINVAL;
}
switch (tkn) { switch (tkn) {
case SKL_TKN_U32_FMT_CH: case SKL_TKN_U32_FMT_CH:
dst_fmt->channels = value; dst_fmt->channels = value;
...@@ -2010,6 +1992,29 @@ static int skl_tplg_fill_fmt(struct device *dev, ...@@ -2010,6 +1992,29 @@ static int skl_tplg_fill_fmt(struct device *dev,
return 0; return 0;
} }
static int skl_tplg_widget_fill_fmt(struct device *dev,
struct skl_module_cfg *mconfig,
u32 tkn, u32 val, u32 dir, int fmt_idx)
{
struct skl_module_fmt *dst_fmt;
switch (dir) {
case SKL_DIR_IN:
dst_fmt = &mconfig->in_fmt[fmt_idx];
break;
case SKL_DIR_OUT:
dst_fmt = &mconfig->out_fmt[fmt_idx];
break;
default:
dev_err(dev, "Invalid direction: %d\n", dir);
return -EINVAL;
}
return skl_tplg_fill_fmt(dev, dst_fmt, tkn, val);
}
static int skl_tplg_get_uuid(struct device *dev, struct skl_module_cfg *mconfig, static int skl_tplg_get_uuid(struct device *dev, struct skl_module_cfg *mconfig,
struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn) struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
{ {
...@@ -2190,7 +2195,7 @@ static int skl_tplg_get_token(struct device *dev, ...@@ -2190,7 +2195,7 @@ static int skl_tplg_get_token(struct device *dev,
case SKL_TKN_U32_FMT_INTERLEAVE: case SKL_TKN_U32_FMT_INTERLEAVE:
case SKL_TKN_U32_FMT_SAMPLE_TYPE: case SKL_TKN_U32_FMT_SAMPLE_TYPE:
case SKL_TKN_U32_FMT_CH_MAP: case SKL_TKN_U32_FMT_CH_MAP:
ret = skl_tplg_fill_fmt(dev, mconfig, tkn_elem->token, ret = skl_tplg_widget_fill_fmt(dev, mconfig, tkn_elem->token,
tkn_elem->value, dir, pin_index); tkn_elem->value, dir, pin_index);
if (ret < 0) if (ret < 0)
......
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