ASoC: dapm: Add a flag for not having widget name in kcontrol name
authorJyri Sarha <jyri.sarha@intel.com>
Mon, 14 Aug 2023 23:23:24 +0000 (18:23 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 15 Aug 2023 12:25:55 +0000 (13:25 +0100)
The existing soc-dapm code may add a prefix to control names, which in
some cases is useful but in others leads to long and confusing kcontrol
names such as "gain 2.1 Main Playback Volume".

This patch suggests an added flag to prevent the widget name prefix
from being added. That flag will be set in the topology file on a
per-widget basis.

The flag no_wname_in_kcontrol_name is added to struct snd_soc_dapm_widget,
and the logic in dapm_create_or_share_kcontrol() is changed to not to
add widget name if the flag is set.

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-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc-dapm.h
sound/soc/soc-dapm.c

index 2e38dff16779ac839c253d6705c4fef3b7785fda..d2faec9a323ea3e87c99fc04dcdfd93c59c5d8fc 100644 (file)
@@ -650,6 +650,7 @@ struct snd_soc_dapm_widget {
        unsigned char power_checked:1;          /* power checked this run */
        unsigned char is_supply:1;              /* Widget is a supply type widget */
        unsigned char is_ep:2;                  /* Widget is a endpoint type widget */
+       unsigned char no_wname_in_kcontrol_name:1; /* No widget name prefix in kcontrol name */
        int subseq;                             /* sort within widget type */
 
        int (*power_check)(struct snd_soc_dapm_widget *w);
index 3091e8160bad77c22255e2655273051601994fee..f07e836783737ba4d54c948a88f103483853de9e 100644 (file)
@@ -916,6 +916,8 @@ static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w,
                                return -EINVAL;
                        }
                }
+               if (w->no_wname_in_kcontrol_name)
+                       wname_in_long_name = false;
 
                if (wname_in_long_name && kcname_in_long_name) {
                        /*