OSDN Git Service

ASoC: SOF: topology: Add a token for dropping widget name in kcontrol name
authorJyri Sarha <jyri.sarha@intel.com>
Mon, 14 Aug 2023 23:23:25 +0000 (18:23 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 15 Aug 2023 12:25:56 +0000 (13:25 +0100)
Adds SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME token, and 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".

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230814232325.86397-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/uapi/sound/sof/tokens.h
sound/soc/sof/topology.c

index e9ec7e4..453cab2 100644 (file)
 #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
-
+/*
+ * The token value is copied to the dapm_widget's
+ * no_wname_in_kcontrol_name.
+ */
+#define SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME 417
 
 /* SSP */
 #define SOF_TKN_INTEL_SSP_CLKS_CONTROL         500
index be63ba0..a3a3af2 100644 (file)
@@ -1367,6 +1367,20 @@ err:
        return ret;
 }
 
+static int get_w_no_wname_in_long_name(void *elem, void *object, u32 offset)
+{
+       struct snd_soc_tplg_vendor_value_elem *velem = elem;
+       struct snd_soc_dapm_widget *w = object;
+
+       w->no_wname_in_kcontrol_name = !!le32_to_cpu(velem->value);
+       return 0;
+}
+
+static const struct sof_topology_token dapm_widget_tokens[] = {
+       {SOF_TKN_COMP_NO_WNAME_IN_KCONTROL_NAME, SND_SOC_TPLG_TUPLE_TYPE_BOOL,
+        get_w_no_wname_in_long_name, 0}
+};
+
 /* external widget init - used for any driver specific init */
 static int sof_widget_ready(struct snd_soc_component *scomp, int index,
                            struct snd_soc_dapm_widget *w,
@@ -1397,6 +1411,14 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index,
        ida_init(&swidget->output_queue_ida);
        ida_init(&swidget->input_queue_ida);
 
+       ret = sof_parse_tokens(scomp, w, dapm_widget_tokens, ARRAY_SIZE(dapm_widget_tokens),
+                              priv->array, le32_to_cpu(priv->size));
+       if (ret < 0) {
+               dev_err(scomp->dev, "failed to parse dapm widget tokens for %s\n",
+                       w->name);
+               goto widget_free;
+       }
+
        ret = sof_parse_tokens(scomp, swidget, comp_pin_tokens,
                               ARRAY_SIZE(comp_pin_tokens), priv->array,
                               le32_to_cpu(priv->size));