Skip to content

Commit 64b366f

Browse files
jsarhaJyri Sarha
authored andcommitted
ASoC: SOF: topology: Add a token for dropping widget name in kcontrol name
Adds SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME token, and implements sof_dapm_widget_init() function, and calls the functions from sof_widget_ready(). sof_dapm_widget_init() copies the token's tuple value to the no_wname_in_kcontrol_name flag in struct snd_soc_dapm_widget. If the tuple value for the token in the topology is true, then the widget name is not added to the mixer name. In practice "gain.2.1 Post Mixer Analog Playback Volume" becomes just "Post Mixer Analog Playback Volume". Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
1 parent 44de36b commit 64b366f

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

include/uapi/sound/sof/tokens.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@
9999
#define SOF_TKN_COMP_OUTPUT_PIN_BINDING_WNAME 414
100100
#define SOF_TKN_COMP_NUM_INPUT_AUDIO_FORMATS 415
101101
#define SOF_TKN_COMP_NUM_OUTPUT_AUDIO_FORMATS 416
102-
102+
/*
103+
* The token value is copied to the dapm_widget's
104+
* no_wname_in_kcontrol_name.
105+
*/
106+
#define SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME 417
103107

104108
/* SSP */
105109
#define SOF_TKN_INTEL_SSP_CLKS_CONTROL 500

sound/soc/sof/topology.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,60 @@ static int sof_parse_tokens(struct snd_soc_component *scomp, void *object,
809809
array_size, 1, 0);
810810
}
811811

812+
static void sof_w_no_wname_in_long_name(struct snd_soc_component *scomp,
813+
struct snd_soc_dapm_widget *w, int type,
814+
struct snd_soc_tplg_vendor_value_elem *v)
815+
{
816+
if (type == SND_SOC_TPLG_TUPLE_TYPE_WORD ||
817+
type == SND_SOC_TPLG_TUPLE_TYPE_SHORT ||
818+
type == SND_SOC_TPLG_TUPLE_TYPE_BYTE ||
819+
type == SND_SOC_TPLG_TUPLE_TYPE_BOOL)
820+
w->no_wname_in_kcontrol_name = le32_to_cpu(v->token);
821+
else
822+
dev_warn(scomp->dev, "Bad tuple type %d\n", type);
823+
}
824+
825+
static int sof_dapm_widget_init(struct snd_soc_component *scomp,
826+
struct snd_soc_dapm_widget *w,
827+
struct snd_soc_tplg_vendor_array *array,
828+
int array_size)
829+
{
830+
while (array_size > 0) {
831+
int asize, type, i;
832+
833+
asize = le32_to_cpu(array->size);
834+
835+
/* validate asize */
836+
if (asize <= 0) {
837+
dev_err(scomp->dev, "error: invalid array size 0x%x\n",
838+
asize);
839+
return -EINVAL;
840+
}
841+
842+
/* make sure there is enough data before parsing */
843+
array_size -= asize;
844+
if (array_size < 0) {
845+
dev_err(scomp->dev, "error: invalid array size 0x%x\n",
846+
asize);
847+
return -EINVAL;
848+
}
849+
type = le32_to_cpu(array->type);
850+
851+
for (i = 0; i < le32_to_cpu(array->num_elems); i++) {
852+
switch (le32_to_cpu(array->value[i].token)) {
853+
case SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME:
854+
sof_w_no_wname_in_long_name(scomp, w, type, &array->value[i]);
855+
break;
856+
default:
857+
}
858+
}
859+
860+
/* next array */
861+
array = (struct snd_soc_tplg_vendor_array *)((u8 *)array + asize);
862+
}
863+
return 0;
864+
}
865+
812866
/*
813867
* Standard Kcontrols.
814868
*/
@@ -1396,6 +1450,10 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
13961450
ida_init(&swidget->output_queue_ida);
13971451
ida_init(&swidget->input_queue_ida);
13981452

1453+
ret = sof_dapm_widget_init(scomp, w, priv->array, le32_to_cpu(priv->size));
1454+
if (ret < 0)
1455+
goto widget_free;
1456+
13991457
ret = sof_parse_tokens(scomp, swidget, comp_pin_tokens,
14001458
ARRAY_SIZE(comp_pin_tokens), priv->array,
14011459
le32_to_cpu(priv->size));

0 commit comments

Comments
 (0)