All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs
@ 2014-02-23 15:10 Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 01/11] ASoC: Remove unused 'reg2' field from soc_enum struct Lars-Peter Clausen
                   ` (11 more replies)
  0 siblings, 12 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

We currently have 5 nearly identical implementations of enum controls. Two for
normal controls and three for DAPM controls. The only difference between them is
how and if the selected enum item is mapped to a register value.
For normal enums there is a direct mapping of the selected item to the register
value, for value enums there is an additional look-up table that maps the
selected item to a register value. DAPM also as a virtual enum which is not
backed by any hardware register and the enum is solely used to influence DAPM
routing decisions. The different implementations can easily be consolidating by
making a few small changes. The series first introduces two helper functions to
translate between the selected item and the register value. These functions will
do the right thing depending on whether the enum has a direct mapping or is a
value enum. These functions will be used to consolidate enums and value enums as
well as MUXs and value MUXs. The next step is consolidate MUXs and virtual MUXs.
This requires enums that are only used as virtual enums to be marked as such.
This is done the same way as for virtual mixer controls by setting reg to
SND_SOC_NOPM. All users of virtual MUXs are updated accordingly and then virtual
MUXs and MUXs are updated to share the same implementation. The last patch in
the series does cleanup of dapm_set_path_status() on top of all this.

Once this has been merged I'll send a second patch-set replacing and removing
the now deprecated ENUM and MUX macros.

The series depends on topic/dapm, topic/enum, topic/sign, topic/adau1373,
topic/max98090, topic/mc13783, fix/wm8994, topic/wm8995

- Lars

Lars-Peter Clausen (11):
  ASoC: Remove unused 'reg2' field from soc_enum struct
  ASoC: Consolidate enum and value enum controls
  ASoC: dapm: Consolidate MUXs and value MUXs
  ASoC: Add macros for defining virtual enums
  ASoC: adau1373: Use SOC_ENUM_SINGLE_VIRT_DECL()
  ASoC: max98090: Use SOC_ENUM_SINGLE_VIRT_DECL()
  ASoC: mc13783: Use SOC_ENUM_SINGLE_VIRT_DECL()
  ASoC: wm8994: Use SOC_ENUM_SINGLE_VIRT_DECL()
  ASoC: wm8995: Use SOC_ENUM_SINGLE_VIRT_DECL()
  ASoC: dapm: Consolidate MUXs and virtual MUXs
  ASoC: dapm: Break dapm_set_path_status() appart

 include/sound/soc-dapm.h    |  38 +----
 include/sound/soc.h         |  41 +++--
 sound/soc/codecs/adau1373.c |   4 +-
 sound/soc/codecs/max98090.c |   2 +-
 sound/soc/codecs/mc13783.c  |   6 +-
 sound/soc/codecs/wm8994.c   |   3 +-
 sound/soc/codecs/wm8995.c   |   2 +-
 sound/soc/soc-core.c        | 101 ++----------
 sound/soc/soc-dapm.c        | 369 +++++++++-----------------------------------
 9 files changed, 136 insertions(+), 430 deletions(-)

-- 
1.8.0

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 01/11] ASoC: Remove unused 'reg2' field from soc_enum struct
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 02/11] ASoC: Consolidate enum and value enum controls Lars-Peter Clausen
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index d350519..8ffaa46 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1099,7 +1099,6 @@ struct soc_mreg_control {
 /* enumerated kcontrol */
 struct soc_enum {
 	unsigned short reg;
-	unsigned short reg2;
 	unsigned char shift_l;
 	unsigned char shift_r;
 	unsigned int items;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 02/11] ASoC: Consolidate enum and value enum controls
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 01/11] ASoC: Remove unused 'reg2' field from soc_enum struct Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 03/11] ASoC: dapm: Consolidate MUXs and value MUXs Lars-Peter Clausen
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

The implementations for enum and value enum controls are almost identical. The
only difference is that the value enum uses an additional look-up table to map
the control value to the register value, while the enum control uses a direct
mapping. Enums and value enums can easily be distinguished at runtime, for value
enums the values field of the snd_soc_enum struct contains the look-up table,
while for enums it is NULL. This patch adds two new small helper functions
called snd_soc_enum_item_to_val() and snd_soc_enum_val_to_item() which map
between register value and control item. If the items field of the snd_soc_enum
struct is NULL the function will do a direct mapping otherwise they'll use the
look-up table to do the mapping. Using these small helper functions it is
possible to use the same kcontrol handlers for both enums and value enums. The
functions are added a inline functions in soc.h so they can also be used by the
DAPM code to accomplish similar consolidation.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc.h  |  34 ++++++++++++-----
 sound/soc/soc-core.c | 101 ++++++++-------------------------------------------
 2 files changed, 41 insertions(+), 94 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 8ffaa46..e005196 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -195,11 +195,7 @@
 	.get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
 	.private_value = (unsigned long)&xenum }
 #define SOC_VALUE_ENUM(xname, xenum) \
-{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
-	.info = snd_soc_info_enum_double, \
-	.get = snd_soc_get_value_enum_double, \
-	.put = snd_soc_put_value_enum_double, \
-	.private_value = (unsigned long)&xenum }
+	SOC_ENUM(xname, xenum)
 #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
 	 xhandler_get, xhandler_put) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
@@ -508,10 +504,6 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_value *ucontrol);
 int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_value *ucontrol);
-int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol);
-int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol);
 int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_info *uinfo);
 #define snd_soc_info_bool_ext		snd_ctl_boolean_mono_info
@@ -1180,6 +1172,30 @@ static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
 	return 1;
 }
 
+static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
+	unsigned int val)
+{
+	unsigned int i;
+
+	if (!e->values)
+		return val;
+
+	for (i = 0; i < e->items; i++)
+		if (val == e->values[i])
+			return i;
+
+	return 0;
+}
+
+static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
+	unsigned int item)
+{
+	if (!e->values)
+		return item;
+
+	return e->values[item];
+}
+
 int snd_soc_util_init(void);
 void snd_soc_util_exit(void);
 
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 0911856..bc8da80 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2596,14 +2596,18 @@ int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
 {
 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int val;
+	unsigned int val, item;
+	unsigned int reg_val;
 
-	val = snd_soc_read(codec, e->reg);
-	ucontrol->value.enumerated.item[0]
-		= (val >> e->shift_l) & e->mask;
-	if (e->shift_l != e->shift_r)
-		ucontrol->value.enumerated.item[1] =
-			(val >> e->shift_r) & e->mask;
+	reg_val = snd_soc_read(codec, e->reg);
+	val = (reg_val >> e->shift_l) & e->mask;
+	item = snd_soc_enum_val_to_item(e, val);
+	ucontrol->value.enumerated.item[0] = item;
+	if (e->shift_l != e->shift_r) {
+		val = (reg_val >> e->shift_l) & e->mask;
+		item = snd_soc_enum_val_to_item(e, val);
+		ucontrol->value.enumerated.item[1] = item;
+	}
 
 	return 0;
 }
@@ -2623,17 +2627,18 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
 {
 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+	unsigned int *item = ucontrol->value.enumerated.item;
 	unsigned int val;
 	unsigned int mask;
 
-	if (ucontrol->value.enumerated.item[0] >= e->items)
+	if (item[0] >= e->items)
 		return -EINVAL;
-	val = ucontrol->value.enumerated.item[0] << e->shift_l;
+	val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l;
 	mask = e->mask << e->shift_l;
 	if (e->shift_l != e->shift_r) {
-		if (ucontrol->value.enumerated.item[1] >= e->items)
+		if (item[1] >= e->items)
 			return -EINVAL;
-		val |= ucontrol->value.enumerated.item[1] << e->shift_r;
+		val |= snd_soc_enum_item_to_val(e, item[1]) << e->shift_r;
 		mask |= e->mask << e->shift_r;
 	}
 
@@ -2642,80 +2647,6 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
 EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
 
 /**
- * snd_soc_get_value_enum_double - semi enumerated double mixer get callback
- * @kcontrol: mixer control
- * @ucontrol: control element information
- *
- * Callback to get the value of a double semi enumerated mixer.
- *
- * Semi enumerated mixer: the enumerated items are referred as values. Can be
- * used for handling bitfield coded enumeration for example.
- *
- * Returns 0 for success.
- */
-int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int reg_val, val, mux;
-
-	reg_val = snd_soc_read(codec, e->reg);
-	val = (reg_val >> e->shift_l) & e->mask;
-	for (mux = 0; mux < e->items; mux++) {
-		if (val == e->values[mux])
-			break;
-	}
-	ucontrol->value.enumerated.item[0] = mux;
-	if (e->shift_l != e->shift_r) {
-		val = (reg_val >> e->shift_r) & e->mask;
-		for (mux = 0; mux < e->items; mux++) {
-			if (val == e->values[mux])
-				break;
-		}
-		ucontrol->value.enumerated.item[1] = mux;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(snd_soc_get_value_enum_double);
-
-/**
- * snd_soc_put_value_enum_double - semi enumerated double mixer put callback
- * @kcontrol: mixer control
- * @ucontrol: control element information
- *
- * Callback to set the value of a double semi enumerated mixer.
- *
- * Semi enumerated mixer: the enumerated items are referred as values. Can be
- * used for handling bitfield coded enumeration for example.
- *
- * Returns 0 for success.
- */
-int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int val;
-	unsigned int mask;
-
-	if (ucontrol->value.enumerated.item[0] >= e->items)
-		return -EINVAL;
-	val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
-	mask = e->mask << e->shift_l;
-	if (e->shift_l != e->shift_r) {
-		if (ucontrol->value.enumerated.item[1] >= e->items)
-			return -EINVAL;
-		val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
-		mask |= e->mask << e->shift_r;
-	}
-
-	return snd_soc_update_bits_locked(codec, e->reg, mask, val);
-}
-EXPORT_SYMBOL_GPL(snd_soc_put_value_enum_double);
-
-/**
  * snd_soc_read_signed - Read a codec register and interprete as signed value
  * @codec: codec
  * @reg: Register to read
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 03/11] ASoC: dapm: Consolidate MUXs and value MUXs
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 01/11] ASoC: Remove unused 'reg2' field from soc_enum struct Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 02/11] ASoC: Consolidate enum and value enum controls Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 04/11] ASoC: Add macros for defining virtual enums Lars-Peter Clausen
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

MUXs and value MUXs are almost identical, the only difference is that a value
MUX uses a look-up table to map from the selected control item to a register
value, while MUXs use a direct mapping. This patch uses
snd_soc_enum_item_to_val() and snd_soc_enum_val_to_item(), which where earlier
introduced during the consolidation of enum and value enum controls, to hide
this difference. This allows us to use the same code path for both MUXs and
value MUXs and a lot of nearly duplicated code can be removed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc-dapm.h |  15 +----
 sound/soc/soc-dapm.c     | 157 ++++++-----------------------------------------
 2 files changed, 21 insertions(+), 151 deletions(-)

diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 3b99176..2ec14cb 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -112,9 +112,7 @@ struct device;
 	SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
 	.kcontrol_news = wcontrols, .num_kcontrols = 1}
 #define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \
-{	.id = snd_soc_dapm_value_mux, .name = wname, \
-	SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
-	.kcontrol_news = wcontrols, .num_kcontrols = 1}
+	SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols)
 
 /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
 #define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\
@@ -324,11 +322,7 @@ struct device;
 	.put = xput, \
 	.private_value = (unsigned long)&xenum }
 #define SOC_DAPM_VALUE_ENUM(xname, xenum) \
-{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
-	.info = snd_soc_info_enum_double, \
-	.get = snd_soc_dapm_get_value_enum_double, \
-	.put = snd_soc_dapm_put_value_enum_double, \
-	.private_value = (unsigned long)&xenum }
+	SOC_DAPM_ENUM(xname, xenum)
 #define SOC_DAPM_PIN_SWITCH(xname) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname " Switch", \
 	.info = snd_soc_dapm_info_pin_switch, \
@@ -396,10 +390,6 @@ int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_value *ucontrol);
 int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_value *ucontrol);
-int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol);
-int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol);
 int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_info *uinfo);
 int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
@@ -486,7 +476,6 @@ enum snd_soc_dapm_type {
 	snd_soc_dapm_output,		/* output pin */
 	snd_soc_dapm_mux,			/* selects 1 analog signal from many inputs */
 	snd_soc_dapm_virt_mux,			/* virtual version of snd_soc_dapm_mux */
-	snd_soc_dapm_value_mux,			/* selects 1 analog signal from many inputs */
 	snd_soc_dapm_mixer,			/* mixes several analog signals together */
 	snd_soc_dapm_mixer_named_ctl,		/* mixer with named controls */
 	snd_soc_dapm_pga,			/* programmable gain/attenuation (volume) */
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 96a97a3df..f23eeee 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -71,7 +71,6 @@ static int dapm_up_seq[] = {
 	[snd_soc_dapm_mic] = 5,
 	[snd_soc_dapm_mux] = 6,
 	[snd_soc_dapm_virt_mux] = 6,
-	[snd_soc_dapm_value_mux] = 6,
 	[snd_soc_dapm_dac] = 7,
 	[snd_soc_dapm_switch] = 8,
 	[snd_soc_dapm_mixer] = 8,
@@ -103,7 +102,6 @@ static int dapm_down_seq[] = {
 	[snd_soc_dapm_micbias] = 8,
 	[snd_soc_dapm_mux] = 9,
 	[snd_soc_dapm_virt_mux] = 9,
-	[snd_soc_dapm_value_mux] = 9,
 	[snd_soc_dapm_aif_in] = 10,
 	[snd_soc_dapm_aif_out] = 10,
 	[snd_soc_dapm_dai_in] = 10,
@@ -534,7 +532,8 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
 		unsigned int val, item;
 
 		soc_widget_read(w, e->reg, &val);
-		item = (val >> e->shift_l) & e->mask;
+		val = (val >> e->shift_l) & e->mask;
+		item = snd_soc_enum_val_to_item(e, val);
 
 		if (item < e->items && !strcmp(p->name, e->texts[item]))
 			p->connect = 1;
@@ -557,24 +556,6 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
 			p->connect = 1;
 	}
 	break;
-	case snd_soc_dapm_value_mux: {
-		struct soc_enum *e = (struct soc_enum *)
-			w->kcontrol_news[i].private_value;
-		unsigned int val, item;
-
-		soc_widget_read(w, e->reg, &val);
-		val = (val >> e->shift_l) & e->mask;
-		for (item = 0; item < e->items; item++) {
-			if (val == e->values[item])
-				break;
-		}
-
-		if (item < e->items && !strcmp(p->name, e->texts[item]))
-			p->connect = 1;
-		else
-			p->connect = 0;
-	}
-	break;
 	/* does not affect routing - always connected */
 	case snd_soc_dapm_pga:
 	case snd_soc_dapm_out_drv:
@@ -725,7 +706,6 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w,
 				break;
 			case snd_soc_dapm_mux:
 			case snd_soc_dapm_virt_mux:
-			case snd_soc_dapm_value_mux:
 				wname_in_long_name = true;
 				kcname_in_long_name = false;
 				break;
@@ -2463,7 +2443,6 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
 		return 0;
 	case snd_soc_dapm_mux:
 	case snd_soc_dapm_virt_mux:
-	case snd_soc_dapm_value_mux:
 		ret = dapm_connect_mux(dapm, wsource, wsink, path, control,
 			&wsink->kcontrol_news[0]);
 		if (ret != 0)
@@ -2791,7 +2770,6 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
 			break;
 		case snd_soc_dapm_mux:
 		case snd_soc_dapm_virt_mux:
-		case snd_soc_dapm_value_mux:
 			dapm_new_mux(w);
 			break;
 		case snd_soc_dapm_pga:
@@ -2953,13 +2931,16 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
 {
 	struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol);
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int val;
+	unsigned int reg_val, val;
 
-	val = snd_soc_read(codec, e->reg);
-	ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & e->mask;
-	if (e->shift_l != e->shift_r)
-		ucontrol->value.enumerated.item[1] =
-			(val >> e->shift_r) & e->mask;
+	reg_val = snd_soc_read(codec, e->reg);
+	val = (reg_val >> e->shift_l) & e->mask;
+	ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val);
+	if (e->shift_l != e->shift_r) {
+		val = (reg_val >> e->shift_r) & e->mask;
+		val = snd_soc_enum_val_to_item(e, val);
+		ucontrol->value.enumerated.item[1] = val;
+	}
 
 	return 0;
 }
@@ -2980,20 +2961,21 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
 	struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol);
 	struct snd_soc_card *card = codec->card;
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int val, mux, change;
+	unsigned int *item = ucontrol->value.enumerated.item;
+	unsigned int val, change;
 	unsigned int mask;
 	struct snd_soc_dapm_update update;
 	int ret = 0;
 
-	if (ucontrol->value.enumerated.item[0] >= e->items)
+	if (item[0] >= e->items)
 		return -EINVAL;
-	mux = ucontrol->value.enumerated.item[0];
-	val = mux << e->shift_l;
+
+	val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l;
 	mask = e->mask << e->shift_l;
 	if (e->shift_l != e->shift_r) {
-		if (ucontrol->value.enumerated.item[1] >= e->items)
+		if (item[1] > e->items)
 			return -EINVAL;
-		val |= ucontrol->value.enumerated.item[1] << e->shift_r;
+		val |= snd_soc_enum_item_to_val(e, item[1]) << e->shift_l;
 		mask |= e->mask << e->shift_r;
 	}
 
@@ -3007,7 +2989,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
 		update.val = val;
 		card->update = &update;
 
-		ret = soc_dapm_mux_update_power(card, kcontrol, mux, e);
+		ret = soc_dapm_mux_update_power(card, kcontrol, item[0], e);
 
 		card->update = NULL;
 	}
@@ -3074,106 +3056,6 @@ int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt);
 
 /**
- * snd_soc_dapm_get_value_enum_double - dapm semi enumerated double mixer get
- *					callback
- * @kcontrol: mixer control
- * @ucontrol: control element information
- *
- * Callback to get the value of a dapm semi enumerated double mixer control.
- *
- * Semi enumerated mixer: the enumerated items are referred as values. Can be
- * used for handling bitfield coded enumeration for example.
- *
- * Returns 0 for success.
- */
-int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol);
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int reg_val, val, mux;
-
-	reg_val = snd_soc_read(codec, e->reg);
-	val = (reg_val >> e->shift_l) & e->mask;
-	for (mux = 0; mux < e->items; mux++) {
-		if (val == e->values[mux])
-			break;
-	}
-	ucontrol->value.enumerated.item[0] = mux;
-	if (e->shift_l != e->shift_r) {
-		val = (reg_val >> e->shift_r) & e->mask;
-		for (mux = 0; mux < e->items; mux++) {
-			if (val == e->values[mux])
-				break;
-		}
-		ucontrol->value.enumerated.item[1] = mux;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(snd_soc_dapm_get_value_enum_double);
-
-/**
- * snd_soc_dapm_put_value_enum_double - dapm semi enumerated double mixer set
- *					callback
- * @kcontrol: mixer control
- * @ucontrol: control element information
- *
- * Callback to set the value of a dapm semi enumerated double mixer control.
- *
- * Semi enumerated mixer: the enumerated items are referred as values. Can be
- * used for handling bitfield coded enumeration for example.
- *
- * Returns 0 for success.
- */
-int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol);
-	struct snd_soc_card *card = codec->card;
-	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
-	unsigned int val, mux, change;
-	unsigned int mask;
-	struct snd_soc_dapm_update update;
-	int ret = 0;
-
-	if (ucontrol->value.enumerated.item[0] >= e->items)
-		return -EINVAL;
-	mux = ucontrol->value.enumerated.item[0];
-	val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
-	mask = e->mask << e->shift_l;
-	if (e->shift_l != e->shift_r) {
-		if (ucontrol->value.enumerated.item[1] >= e->items)
-			return -EINVAL;
-		val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
-		mask |= e->mask << e->shift_r;
-	}
-
-	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
-
-	change = snd_soc_test_bits(codec, e->reg, mask, val);
-	if (change) {
-		update.kcontrol = kcontrol;
-		update.reg = e->reg;
-		update.mask = mask;
-		update.val = val;
-		card->update = &update;
-
-		ret = soc_dapm_mux_update_power(card, kcontrol, mux, e);
-
-		card->update = NULL;
-	}
-
-	mutex_unlock(&card->dapm_mutex);
-
-	if (ret > 0)
-		soc_dpcm_runtime_update(card);
-
-	return change;
-}
-EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double);
-
-/**
  * snd_soc_dapm_info_pin_switch - Info for a pin switch
  *
  * @kcontrol: mixer control
@@ -3302,7 +3184,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
 		break;
 	case snd_soc_dapm_mux:
 	case snd_soc_dapm_virt_mux:
-	case snd_soc_dapm_value_mux:
 		w->power_check = dapm_generic_check_power;
 		break;
 	case snd_soc_dapm_dai_out:
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 04/11] ASoC: Add macros for defining virtual enums
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
                   ` (2 preceding siblings ...)
  2014-02-23 15:10 ` [PATCH 03/11] ASoC: dapm: Consolidate MUXs and value MUXs Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-24  9:29   ` Takashi Iwai
  2014-02-23 15:10 ` [PATCH 05/11] ASoC: adau1373: Use SOC_ENUM_SINGLE_VIRT_DECL() Lars-Peter Clausen
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

With the upcoming consolidation of normal MUXs and virtual MUXs we need to be
able to distinguish between enums with and without a backing register at the
enum level. Use the same approach as used for virtual mixer controls by setting
the reg field of the enum to SND_SOC_NOPM for enums without a backing register.
This patch adds a set of helper macros that can be used to define such enums.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index e005196..a25de13 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -189,6 +189,8 @@
 	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
 #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xnitmes, xtexts, xvalues) \
 	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues)
+#define SOC_ENUM_SINGLE_VIRT(xmax, xtexts) \
+	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xmax, xtexts)
 #define SOC_ENUM(xname, xenum) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
 	.info = snd_soc_info_enum_double, \
@@ -293,6 +295,8 @@
 							ARRAY_SIZE(xtexts), xtexts, xvalues)
 #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
 	SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
+#define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
+	const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
 
 /*
  * Component probe and remove ordering levels for components with runtime
@@ -1090,7 +1094,7 @@ struct soc_mreg_control {
 
 /* enumerated kcontrol */
 struct soc_enum {
-	unsigned short reg;
+	int reg;
 	unsigned char shift_l;
 	unsigned char shift_r;
 	unsigned int items;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 05/11] ASoC: adau1373: Use SOC_ENUM_SINGLE_VIRT_DECL()
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
                   ` (3 preceding siblings ...)
  2014-02-23 15:10 ` [PATCH 04/11] ASoC: Add macros for defining virtual enums Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 06/11] ASoC: max98090: " Lars-Peter Clausen
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

For the upcoming consolidation for MUXs and virtual MUXs we need to mark virtual
enums as such.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/codecs/adau1373.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c
index 5765c22..5223800 100644
--- a/sound/soc/codecs/adau1373.c
+++ b/sound/soc/codecs/adau1373.c
@@ -576,8 +576,8 @@ static const char *adau1373_decimator_text[] = {
 	"DMIC1",
 };
 
-static SOC_ENUM_SINGLE_DECL(adau1373_decimator_enum,
-			    0, 0, adau1373_decimator_text);
+static SOC_ENUM_SINGLE_VIRT_DECL(adau1373_decimator_enum,
+	adau1373_decimator_text);
 
 static const struct snd_kcontrol_new adau1373_decimator_mux =
 	SOC_DAPM_ENUM_VIRT("Decimator Mux", adau1373_decimator_enum);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 06/11] ASoC: max98090: Use SOC_ENUM_SINGLE_VIRT_DECL()
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
                   ` (4 preceding siblings ...)
  2014-02-23 15:10 ` [PATCH 05/11] ASoC: adau1373: Use SOC_ENUM_SINGLE_VIRT_DECL() Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 07/11] ASoC: mc13783: " Lars-Peter Clausen
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

For the upcoming consolidation for MUXs and virtual MUXs we need to mark virtual
enums as such.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/codecs/max98090.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index a75752f..f363de1 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -872,7 +872,7 @@ static const struct snd_kcontrol_new max98090_mic2_mux =
 
 static const char *dmic_mux_text[] = { "ADC", "DMIC" };
 
-static SOC_ENUM_SINGLE_EXT_DECL(dmic_mux_enum, dmic_mux_text);
+static SOC_ENUM_SINGLE_VIRT_DECL(dmic_mux_enum, dmic_mux_text);
 
 static const struct snd_kcontrol_new max98090_dmic_mux =
 	SOC_DAPM_ENUM_VIRT("DMIC Mux", dmic_mux_enum);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 07/11] ASoC: mc13783: Use SOC_ENUM_SINGLE_VIRT_DECL()
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
                   ` (5 preceding siblings ...)
  2014-02-23 15:10 ` [PATCH 06/11] ASoC: max98090: " Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-24 14:28   ` Philippe Rétornaz
  2014-02-23 15:10 ` [PATCH 08/11] ASoC: wm8994: " Lars-Peter Clausen
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

For the upcoming consolidation for MUXs and virtual MUXs we need to mark virtual
enums as such.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/codecs/mc13783.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c
index c605036..ec89b8f 100644
--- a/sound/soc/codecs/mc13783.c
+++ b/sound/soc/codecs/mc13783.c
@@ -408,8 +408,7 @@ static const char * const adcl_enum_text[] = {
 	"MC1L", "RXINL",
 };
 
-static SOC_ENUM_SINGLE_DECL(adcl_enum,
-			    0, 0, adcl_enum_text);
+static SOC_ENUM_SINGLE_VIRT_DECL(adcl_enum, adcl_enum_text);
 
 static const struct snd_kcontrol_new left_input_mux =
 	SOC_DAPM_ENUM_VIRT("Route", adcl_enum);
@@ -418,8 +417,7 @@ static const char * const adcr_enum_text[] = {
 	"MC1R", "MC2", "RXINR", "TXIN",
 };
 
-static SOC_ENUM_SINGLE_DECL(adcr_enum,
-			    0, 0, adcr_enum_text);
+static SOC_ENUM_SINGLE_VIRT_DECL(adcr_enum, adcr_enum_text);
 
 static const struct snd_kcontrol_new right_input_mux =
 	SOC_DAPM_ENUM_VIRT("Route", adcr_enum);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 08/11] ASoC: wm8994: Use SOC_ENUM_SINGLE_VIRT_DECL()
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
                   ` (6 preceding siblings ...)
  2014-02-23 15:10 ` [PATCH 07/11] ASoC: mc13783: " Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-25  9:47   ` Charles Keepax
  2014-02-23 15:10 ` [PATCH 09/11] ASoC: wm8995: " Lars-Peter Clausen
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

For the upcoming consolidation for MUXs and virtual MUXs we need to mark virtual
enums as such.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/codecs/wm8994.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 699b527..79854cb 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -1344,8 +1344,7 @@ static const char *adc_mux_text[] = {
 	"DMIC",
 };
 
-static SOC_ENUM_SINGLE_DECL(adc_enum,
-			    0, 0, adc_mux_text);
+static SOC_ENUM_SINGLE_VIRT_DECL(adc_enum, adc_mux_text);
 
 static const struct snd_kcontrol_new adcl_mux =
 	SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 09/11] ASoC: wm8995: Use SOC_ENUM_SINGLE_VIRT_DECL()
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
                   ` (7 preceding siblings ...)
  2014-02-23 15:10 ` [PATCH 08/11] ASoC: wm8994: " Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-25  9:47   ` Charles Keepax
  2014-02-23 15:10 ` [PATCH 10/11] ASoC: dapm: Consolidate MUXs and virtual MUXs Lars-Peter Clausen
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

For the upcoming consolidation for MUXs and virtual MUXs we need to mark virtual
enums as such.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/codecs/wm8995.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c
index 33ff361..ddb197d 100644
--- a/sound/soc/codecs/wm8995.c
+++ b/sound/soc/codecs/wm8995.c
@@ -882,7 +882,7 @@ static const char *adc_mux_text[] = {
 	"DMIC",
 };
 
-static const SOC_ENUM_SINGLE_DECL(adc_enum, 0, 0, adc_mux_text);
+static SOC_ENUM_SINGLE_VIRT_DECL(adc_enum, adc_mux_text);
 
 static const struct snd_kcontrol_new adcl_mux =
 	SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 10/11] ASoC: dapm: Consolidate MUXs and virtual MUXs
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
                   ` (8 preceding siblings ...)
  2014-02-23 15:10 ` [PATCH 09/11] ASoC: wm8995: " Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-23 15:10 ` [PATCH 11/11] ASoC: dapm: Break dapm_set_path_status() appart Lars-Peter Clausen
  2014-02-25  1:57 ` [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Mark Brown
  11 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

MUXs and virtual MUXs are almost identical, the only difference is that for
virtual MUX there is no hardware backing register in which setting is stored.
This patch adds code, which is similar to what we already do for DAPM mixer
controls to support virtual mixer controls, to DAPM enum controls. The new code
will check if the enum does a hardware backing register and skip over reading
and writing to the register if it has not.  This allows us to use the same code
path for both MUXs and virtual MUXs and a lot of nearly identical code can be
removed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc-dapm.h |  23 +++-------
 sound/soc/soc-dapm.c     | 113 +++++++++++++----------------------------------
 2 files changed, 35 insertions(+), 101 deletions(-)

diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 2ec14cb..04d32d8 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -108,9 +108,7 @@ struct device;
 	SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
 	.kcontrol_news = wcontrols, .num_kcontrols = 1}
 #define SND_SOC_DAPM_VIRT_MUX(wname, wreg, wshift, winvert, wcontrols) \
-{	.id = snd_soc_dapm_virt_mux, .name = wname, \
-	SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
-	.kcontrol_news = wcontrols, .num_kcontrols = 1}
+	SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols)
 #define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \
 	SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols)
 
@@ -170,10 +168,8 @@ struct device;
 	.event = wevent, .event_flags = wflags}
 #define SND_SOC_DAPM_VIRT_MUX_E(wname, wreg, wshift, winvert, wcontrols, \
 	wevent, wflags) \
-{	.id = snd_soc_dapm_virt_mux, .name = wname, \
-	SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
-	.kcontrol_news = wcontrols, .num_kcontrols = 1, \
-	.event = wevent, .event_flags = wflags}
+	SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, wevent, \
+		wflags)
 
 /* additional sequencing control within an event type */
 #define SND_SOC_DAPM_PGA_S(wname, wsubseq, wreg, wshift, winvert, \
@@ -309,12 +305,8 @@ struct device;
  	.get = snd_soc_dapm_get_enum_double, \
  	.put = snd_soc_dapm_put_enum_double, \
   	.private_value = (unsigned long)&xenum }
-#define SOC_DAPM_ENUM_VIRT(xname, xenum)		    \
-{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
-	.info = snd_soc_info_enum_double, \
-	.get = snd_soc_dapm_get_enum_virt, \
-	.put = snd_soc_dapm_put_enum_virt, \
-	.private_value = (unsigned long)&xenum }
+#define SOC_DAPM_ENUM_VIRT(xname, xenum) \
+	SOC_DAPM_ENUM(xname, xenum)
 #define SOC_DAPM_ENUM_EXT(xname, xenum, xget, xput) \
 {	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
 	.info = snd_soc_info_enum_double, \
@@ -386,10 +378,6 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_value *ucontrol);
 int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_value *ucontrol);
-int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol);
-int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
-	struct snd_ctl_elem_value *ucontrol);
 int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
 	struct snd_ctl_elem_info *uinfo);
 int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
@@ -475,7 +463,6 @@ enum snd_soc_dapm_type {
 	snd_soc_dapm_input = 0,		/* input pin */
 	snd_soc_dapm_output,		/* output pin */
 	snd_soc_dapm_mux,			/* selects 1 analog signal from many inputs */
-	snd_soc_dapm_virt_mux,			/* virtual version of snd_soc_dapm_mux */
 	snd_soc_dapm_mixer,			/* mixes several analog signals together */
 	snd_soc_dapm_mixer_named_ctl,		/* mixer with named controls */
 	snd_soc_dapm_pga,			/* programmable gain/attenuation (volume) */
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index f23eeee..c07c7fb 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -70,7 +70,6 @@ static int dapm_up_seq[] = {
 	[snd_soc_dapm_aif_out] = 4,
 	[snd_soc_dapm_mic] = 5,
 	[snd_soc_dapm_mux] = 6,
-	[snd_soc_dapm_virt_mux] = 6,
 	[snd_soc_dapm_dac] = 7,
 	[snd_soc_dapm_switch] = 8,
 	[snd_soc_dapm_mixer] = 8,
@@ -101,7 +100,6 @@ static int dapm_down_seq[] = {
 	[snd_soc_dapm_mic] = 7,
 	[snd_soc_dapm_micbias] = 8,
 	[snd_soc_dapm_mux] = 9,
-	[snd_soc_dapm_virt_mux] = 9,
 	[snd_soc_dapm_aif_in] = 10,
 	[snd_soc_dapm_aif_out] = 10,
 	[snd_soc_dapm_dai_in] = 10,
@@ -531,9 +529,19 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
 			w->kcontrol_news[i].private_value;
 		unsigned int val, item;
 
-		soc_widget_read(w, e->reg, &val);
-		val = (val >> e->shift_l) & e->mask;
-		item = snd_soc_enum_val_to_item(e, val);
+		if (e->reg != SND_SOC_NOPM) {
+			soc_widget_read(w, e->reg, &val);
+			val = (val >> e->shift_l) & e->mask;
+			item = snd_soc_enum_val_to_item(e, val);
+		} else {
+			/* since a virtual mux has no backing registers to
+			 * decide which path to connect, it will try to match
+			 * with the first enumeration.  This is to ensure
+			 * that the default mux choice (the first) will be
+			 * correctly powered up during initialization.
+			 */
+			item = 0;
+		}
 
 		if (item < e->items && !strcmp(p->name, e->texts[item]))
 			p->connect = 1;
@@ -541,21 +549,6 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
 			p->connect = 0;
 	}
 	break;
-	case snd_soc_dapm_virt_mux: {
-		struct soc_enum *e = (struct soc_enum *)
-			w->kcontrol_news[i].private_value;
-
-		p->connect = 0;
-		/* since a virtual mux has no backing registers to
-		 * decide which path to connect, it will try to match
-		 * with the first enumeration.  This is to ensure
-		 * that the default mux choice (the first) will be
-		 * correctly powered up during initialization.
-		 */
-		if (!strcmp(p->name, e->texts[0]))
-			p->connect = 1;
-	}
-	break;
 	/* does not affect routing - always connected */
 	case snd_soc_dapm_pga:
 	case snd_soc_dapm_out_drv:
@@ -705,7 +698,6 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w,
 				kcname_in_long_name = true;
 				break;
 			case snd_soc_dapm_mux:
-			case snd_soc_dapm_virt_mux:
 				wname_in_long_name = true;
 				kcname_in_long_name = false;
 				break;
@@ -2442,7 +2434,6 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
 		path->connect = 1;
 		return 0;
 	case snd_soc_dapm_mux:
-	case snd_soc_dapm_virt_mux:
 		ret = dapm_connect_mux(dapm, wsource, wsink, path, control,
 			&wsink->kcontrol_news[0]);
 		if (ret != 0)
@@ -2769,7 +2760,6 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
 			dapm_new_mixer(w);
 			break;
 		case snd_soc_dapm_mux:
-		case snd_soc_dapm_virt_mux:
 			dapm_new_mux(w);
 			break;
 		case snd_soc_dapm_pga:
@@ -2933,7 +2923,11 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	unsigned int reg_val, val;
 
-	reg_val = snd_soc_read(codec, e->reg);
+	if (e->reg != SND_SOC_NOPM)
+		reg_val = snd_soc_read(codec, e->reg);
+	else
+		reg_val = dapm_kcontrol_get_value(kcontrol);
+
 	val = (reg_val >> e->shift_l) & e->mask;
 	ucontrol->value.enumerated.item[0] = snd_soc_enum_val_to_item(e, val);
 	if (e->shift_l != e->shift_r) {
@@ -2981,13 +2975,19 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
 
 	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
 
-	change = snd_soc_test_bits(codec, e->reg, mask, val);
+	if (e->reg != SND_SOC_NOPM)
+		change = snd_soc_test_bits(codec, e->reg, mask, val);
+	else
+		change = dapm_kcontrol_set_value(kcontrol, val);
+
 	if (change) {
-		update.kcontrol = kcontrol;
-		update.reg = e->reg;
-		update.mask = mask;
-		update.val = val;
-		card->update = &update;
+		if (e->reg != SND_SOC_NOPM) {
+			update.kcontrol = kcontrol;
+			update.reg = e->reg;
+			update.mask = mask;
+			update.val = val;
+			card->update = &update;
+		}
 
 		ret = soc_dapm_mux_update_power(card, kcontrol, item[0], e);
 
@@ -3004,58 +3004,6 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
 
 /**
- * snd_soc_dapm_get_enum_virt - Get virtual DAPM mux
- * @kcontrol: mixer control
- * @ucontrol: control element information
- *
- * Returns 0 for success.
- */
-int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	ucontrol->value.enumerated.item[0] = dapm_kcontrol_get_value(kcontrol);
-	return 0;
-}
-EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt);
-
-/**
- * snd_soc_dapm_put_enum_virt - Set virtual DAPM mux
- * @kcontrol: mixer control
- * @ucontrol: control element information
- *
- * Returns 0 for success.
- */
-int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
-			       struct snd_ctl_elem_value *ucontrol)
-{
-	struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol);
-	struct snd_soc_card *card = codec->card;
-	unsigned int value;
-	struct soc_enum *e =
-		(struct soc_enum *)kcontrol->private_value;
-	int change;
-	int ret = 0;
-
-	if (ucontrol->value.enumerated.item[0] >= e->items)
-		return -EINVAL;
-
-	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
-
-	value = ucontrol->value.enumerated.item[0];
-	change = dapm_kcontrol_set_value(kcontrol, value);
-	if (change)
-		ret = soc_dapm_mux_update_power(card, kcontrol, value, e);
-
-	mutex_unlock(&card->dapm_mutex);
-
-	if (ret > 0)
-		soc_dpcm_runtime_update(card);
-
-	return change;
-}
-EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt);
-
-/**
  * snd_soc_dapm_info_pin_switch - Info for a pin switch
  *
  * @kcontrol: mixer control
@@ -3183,7 +3131,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
 		w->power_check = dapm_generic_check_power;
 		break;
 	case snd_soc_dapm_mux:
-	case snd_soc_dapm_virt_mux:
 		w->power_check = dapm_generic_check_power;
 		break;
 	case snd_soc_dapm_dai_out:
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 11/11] ASoC: dapm: Break dapm_set_path_status() appart
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
                   ` (9 preceding siblings ...)
  2014-02-23 15:10 ` [PATCH 10/11] ASoC: dapm: Consolidate MUXs and virtual MUXs Lars-Peter Clausen
@ 2014-02-23 15:10 ` Lars-Peter Clausen
  2014-02-25  1:57 ` [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Mark Brown
  11 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-23 15:10 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: alsa-devel, Lars-Peter Clausen, patches, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong

There are three different completely independent code paths in
dapm_set_path_status(). One of them is never used at all and the other two (one
for mixers, one for MUXs) have their distincive callsites that always go onto
the same path. Breaking the function into two parts allows us to reduce the code
size and in the MUX case also do some optimizations to avoid having to calcualte
the selected item for each item again.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/soc-dapm.c | 133 +++++++++++++++++----------------------------------
 1 file changed, 44 insertions(+), 89 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index c07c7fb..3651a37 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -495,93 +495,6 @@ out:
 	return ret;
 }
 
-/* set up initial codec paths */
-static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
-	struct snd_soc_dapm_path *p, int i)
-{
-	switch (w->id) {
-	case snd_soc_dapm_switch:
-	case snd_soc_dapm_mixer:
-	case snd_soc_dapm_mixer_named_ctl: {
-		unsigned int val;
-		struct soc_mixer_control *mc = (struct soc_mixer_control *)
-			w->kcontrol_news[i].private_value;
-		int reg = mc->reg;
-		unsigned int shift = mc->shift;
-		int max = mc->max;
-		unsigned int mask = (1 << fls(max)) - 1;
-		unsigned int invert = mc->invert;
-
-		if (reg != SND_SOC_NOPM) {
-			soc_widget_read(w, reg, &val);
-			val = (val >> shift) & mask;
-			if (invert)
-				val = max - val;
-			p->connect = !!val;
-		} else {
-			p->connect = 0;
-		}
-
-	}
-	break;
-	case snd_soc_dapm_mux: {
-		struct soc_enum *e = (struct soc_enum *)
-			w->kcontrol_news[i].private_value;
-		unsigned int val, item;
-
-		if (e->reg != SND_SOC_NOPM) {
-			soc_widget_read(w, e->reg, &val);
-			val = (val >> e->shift_l) & e->mask;
-			item = snd_soc_enum_val_to_item(e, val);
-		} else {
-			/* since a virtual mux has no backing registers to
-			 * decide which path to connect, it will try to match
-			 * with the first enumeration.  This is to ensure
-			 * that the default mux choice (the first) will be
-			 * correctly powered up during initialization.
-			 */
-			item = 0;
-		}
-
-		if (item < e->items && !strcmp(p->name, e->texts[item]))
-			p->connect = 1;
-		else
-			p->connect = 0;
-	}
-	break;
-	/* does not affect routing - always connected */
-	case snd_soc_dapm_pga:
-	case snd_soc_dapm_out_drv:
-	case snd_soc_dapm_output:
-	case snd_soc_dapm_adc:
-	case snd_soc_dapm_input:
-	case snd_soc_dapm_siggen:
-	case snd_soc_dapm_dac:
-	case snd_soc_dapm_micbias:
-	case snd_soc_dapm_vmid:
-	case snd_soc_dapm_supply:
-	case snd_soc_dapm_regulator_supply:
-	case snd_soc_dapm_clock_supply:
-	case snd_soc_dapm_aif_in:
-	case snd_soc_dapm_aif_out:
-	case snd_soc_dapm_dai_in:
-	case snd_soc_dapm_dai_out:
-	case snd_soc_dapm_hp:
-	case snd_soc_dapm_mic:
-	case snd_soc_dapm_spk:
-	case snd_soc_dapm_line:
-	case snd_soc_dapm_dai_link:
-	case snd_soc_dapm_kcontrol:
-		p->connect = 1;
-	break;
-	/* does affect routing - dynamically connected */
-	case snd_soc_dapm_pre:
-	case snd_soc_dapm_post:
-		p->connect = 0;
-	break;
-	}
-}
-
 /* connect mux widget to its interconnecting audio paths */
 static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
 	struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
@@ -589,15 +502,33 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
 	const struct snd_kcontrol_new *kcontrol)
 {
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+	unsigned int val, item;
 	int i;
 
+	if (e->reg != SND_SOC_NOPM) {
+		soc_widget_read(dest, e->reg, &val);
+		val = (val >> e->shift_l) & e->mask;
+		item = snd_soc_enum_val_to_item(e, val);
+	} else {
+		/* since a virtual mux has no backing registers to
+		 * decide which path to connect, it will try to match
+		 * with the first enumeration.  This is to ensure
+		 * that the default mux choice (the first) will be
+		 * correctly powered up during initialization.
+		 */
+		item = 0;
+	}
+
 	for (i = 0; i < e->items; i++) {
 		if (!(strcmp(control_name, e->texts[i]))) {
 			list_add(&path->list, &dapm->card->paths);
 			list_add(&path->list_sink, &dest->sources);
 			list_add(&path->list_source, &src->sinks);
 			path->name = (char*)e->texts[i];
-			dapm_set_path_status(dest, path, 0);
+			if (i == item)
+				path->connect = 1;
+			else
+				path->connect = 0;
 			return 0;
 		}
 	}
@@ -605,6 +536,30 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
 	return -ENODEV;
 }
 
+/* set up initial codec paths */
+static void dapm_set_mixer_path_status(struct snd_soc_dapm_widget *w,
+	struct snd_soc_dapm_path *p, int i)
+{
+	struct soc_mixer_control *mc = (struct soc_mixer_control *)
+		w->kcontrol_news[i].private_value;
+	unsigned int reg = mc->reg;
+	unsigned int shift = mc->shift;
+	unsigned int max = mc->max;
+	unsigned int mask = (1 << fls(max)) - 1;
+	unsigned int invert = mc->invert;
+	unsigned int val;
+
+	if (reg != SND_SOC_NOPM) {
+		soc_widget_read(w, reg, &val);
+		val = (val >> shift) & mask;
+		if (invert)
+			val = max - val;
+		p->connect = !!val;
+	} else {
+		p->connect = 0;
+	}
+}
+
 /* connect mixer widget to its interconnecting audio paths */
 static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm,
 	struct snd_soc_dapm_widget *src, struct snd_soc_dapm_widget *dest,
@@ -619,7 +574,7 @@ static int dapm_connect_mixer(struct snd_soc_dapm_context *dapm,
 			list_add(&path->list_sink, &dest->sources);
 			list_add(&path->list_source, &src->sinks);
 			path->name = dest->kcontrol_news[i].name;
-			dapm_set_path_status(dest, path, i);
+			dapm_set_mixer_path_status(dest, path, i);
 			return 0;
 		}
 	}
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 04/11] ASoC: Add macros for defining virtual enums
  2014-02-23 15:10 ` [PATCH 04/11] ASoC: Add macros for defining virtual enums Lars-Peter Clausen
@ 2014-02-24  9:29   ` Takashi Iwai
  2014-02-24 11:50     ` Lars-Peter Clausen
  0 siblings, 1 reply; 19+ messages in thread
From: Takashi Iwai @ 2014-02-24  9:29 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: alsa-devel, patches, Liam Girdwood, Mark Brown,
	Philippe Rétornaz, Charles Keepax, Steffen Trumtrar,
	Jerry Wong

At Sun, 23 Feb 2014 16:10:14 +0100,
Lars-Peter Clausen wrote:
> 
> With the upcoming consolidation of normal MUXs and virtual MUXs we need to be
> able to distinguish between enums with and without a backing register at the
> enum level. Use the same approach as used for virtual mixer controls by setting
> the reg field of the enum to SND_SOC_NOPM for enums without a backing register.
> This patch adds a set of helper macros that can be used to define such enums.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
>  include/sound/soc.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index e005196..a25de13 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -189,6 +189,8 @@
>  	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
>  #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xnitmes, xtexts, xvalues) \
>  	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues)
> +#define SOC_ENUM_SINGLE_VIRT(xmax, xtexts) \
> +	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xmax, xtexts)

Could you replace "max" with "items"?


Takashi

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 04/11] ASoC: Add macros for defining virtual enums
  2014-02-24  9:29   ` Takashi Iwai
@ 2014-02-24 11:50     ` Lars-Peter Clausen
  0 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-24 11:50 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: alsa-devel, patches, Liam Girdwood, Mark Brown,
	Philippe Rétornaz, Charles Keepax, Steffen Trumtrar,
	Jerry Wong

On 02/24/2014 10:29 AM, Takashi Iwai wrote:
> At Sun, 23 Feb 2014 16:10:14 +0100,
> Lars-Peter Clausen wrote:
>>
>> With the upcoming consolidation of normal MUXs and virtual MUXs we need to be
>> able to distinguish between enums with and without a backing register at the
>> enum level. Use the same approach as used for virtual mixer controls by setting
>> the reg field of the enum to SND_SOC_NOPM for enums without a backing register.
>> This patch adds a set of helper macros that can be used to define such enums.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> ---
>>   include/sound/soc.h | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/sound/soc.h b/include/sound/soc.h
>> index e005196..a25de13 100644
>> --- a/include/sound/soc.h
>> +++ b/include/sound/soc.h
>> @@ -189,6 +189,8 @@
>>   	.mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
>>   #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xnitmes, xtexts, xvalues) \
>>   	SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xnitmes, xtexts, xvalues)
>> +#define SOC_ENUM_SINGLE_VIRT(xmax, xtexts) \
>> +	SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xmax, xtexts)
>
> Could you replace "max" with "items"?

Yep, missed that one when I rebased things on top of your changes.

- Lars

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 07/11] ASoC: mc13783: Use SOC_ENUM_SINGLE_VIRT_DECL()
  2014-02-23 15:10 ` [PATCH 07/11] ASoC: mc13783: " Lars-Peter Clausen
@ 2014-02-24 14:28   ` Philippe Rétornaz
  2014-02-28  7:19     ` Lars-Peter Clausen
  0 siblings, 1 reply; 19+ messages in thread
From: Philippe Rétornaz @ 2014-02-24 14:28 UTC (permalink / raw)
  To: Lars-Peter Clausen, Mark Brown, Liam Girdwood
  Cc: Charles Keepax, Steffen Trumtrar, Jerry Wong, alsa-devel, patches

Le 23/02/2014 16:10, Lars-Peter Clausen a écrit :
> For the upcoming consolidation for MUXs and virtual MUXs we need to mark virtual
> enums as such.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

Tested on mx31moboard, no regression.

Thanks,

Philippe


> ---
>   sound/soc/codecs/mc13783.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c
> index c605036..ec89b8f 100644
> --- a/sound/soc/codecs/mc13783.c
> +++ b/sound/soc/codecs/mc13783.c
> @@ -408,8 +408,7 @@ static const char * const adcl_enum_text[] = {
>   	"MC1L", "RXINL",
>   };
>
> -static SOC_ENUM_SINGLE_DECL(adcl_enum,
> -			    0, 0, adcl_enum_text);
> +static SOC_ENUM_SINGLE_VIRT_DECL(adcl_enum, adcl_enum_text);
>
>   static const struct snd_kcontrol_new left_input_mux =
>   	SOC_DAPM_ENUM_VIRT("Route", adcl_enum);
> @@ -418,8 +417,7 @@ static const char * const adcr_enum_text[] = {
>   	"MC1R", "MC2", "RXINR", "TXIN",
>   };
>
> -static SOC_ENUM_SINGLE_DECL(adcr_enum,
> -			    0, 0, adcr_enum_text);
> +static SOC_ENUM_SINGLE_VIRT_DECL(adcr_enum, adcr_enum_text);
>
>   static const struct snd_kcontrol_new right_input_mux =
>   	SOC_DAPM_ENUM_VIRT("Route", adcr_enum);
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs
  2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
                   ` (10 preceding siblings ...)
  2014-02-23 15:10 ` [PATCH 11/11] ASoC: dapm: Break dapm_set_path_status() appart Lars-Peter Clausen
@ 2014-02-25  1:57 ` Mark Brown
  11 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2014-02-25  1:57 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: alsa-devel, patches, Liam Girdwood, Philippe Rétornaz,
	Charles Keepax, Steffen Trumtrar, Jerry Wong


[-- Attachment #1.1: Type: text/plain, Size: 382 bytes --]

On Sun, Feb 23, 2014 at 04:10:10PM +0100, Lars-Peter Clausen wrote:
> We currently have 5 nearly identical implementations of enum controls. Two for
> normal controls and three for DAPM controls. The only difference between them is
> how and if the selected enum item is mapped to a register value.

This all looks like progress modulo the issue Takashi identified with
the rename.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 08/11] ASoC: wm8994: Use SOC_ENUM_SINGLE_VIRT_DECL()
  2014-02-23 15:10 ` [PATCH 08/11] ASoC: wm8994: " Lars-Peter Clausen
@ 2014-02-25  9:47   ` Charles Keepax
  0 siblings, 0 replies; 19+ messages in thread
From: Charles Keepax @ 2014-02-25  9:47 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: alsa-devel, patches, Liam Girdwood, Mark Brown,
	Philippe Rétornaz, Steffen Trumtrar, Jerry Wong

On Sun, Feb 23, 2014 at 04:10:18PM +0100, Lars-Peter Clausen wrote:
> For the upcoming consolidation for MUXs and virtual MUXs we need to mark virtual
> enums as such.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 09/11] ASoC: wm8995: Use SOC_ENUM_SINGLE_VIRT_DECL()
  2014-02-23 15:10 ` [PATCH 09/11] ASoC: wm8995: " Lars-Peter Clausen
@ 2014-02-25  9:47   ` Charles Keepax
  0 siblings, 0 replies; 19+ messages in thread
From: Charles Keepax @ 2014-02-25  9:47 UTC (permalink / raw)
  To: Lars-Peter Clausen
  Cc: alsa-devel, patches, Liam Girdwood, Mark Brown,
	Philippe Rétornaz, Steffen Trumtrar, Jerry Wong

On Sun, Feb 23, 2014 at 04:10:19PM +0100, Lars-Peter Clausen wrote:
> For the upcoming consolidation for MUXs and virtual MUXs we need to mark virtual
> enums as such.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 07/11] ASoC: mc13783: Use SOC_ENUM_SINGLE_VIRT_DECL()
  2014-02-24 14:28   ` Philippe Rétornaz
@ 2014-02-28  7:19     ` Lars-Peter Clausen
  0 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2014-02-28  7:19 UTC (permalink / raw)
  To: Philippe Rétornaz
  Cc: alsa-devel, patches, Liam Girdwood, Mark Brown, Charles Keepax,
	Steffen Trumtrar, Jerry Wong

On 02/24/2014 03:28 PM, Philippe Rétornaz wrote:
> Le 23/02/2014 16:10, Lars-Peter Clausen a écrit :
>> For the upcoming consolidation for MUXs and virtual MUXs we need to mark
>> virtual
>> enums as such.
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>
> Tested on mx31moboard, no regression.
>
> Thanks,
>
> Philippe
>

Thanks, I'll add a Tested-by tag from you.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-02-28  7:19 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-23 15:10 [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Lars-Peter Clausen
2014-02-23 15:10 ` [PATCH 01/11] ASoC: Remove unused 'reg2' field from soc_enum struct Lars-Peter Clausen
2014-02-23 15:10 ` [PATCH 02/11] ASoC: Consolidate enum and value enum controls Lars-Peter Clausen
2014-02-23 15:10 ` [PATCH 03/11] ASoC: dapm: Consolidate MUXs and value MUXs Lars-Peter Clausen
2014-02-23 15:10 ` [PATCH 04/11] ASoC: Add macros for defining virtual enums Lars-Peter Clausen
2014-02-24  9:29   ` Takashi Iwai
2014-02-24 11:50     ` Lars-Peter Clausen
2014-02-23 15:10 ` [PATCH 05/11] ASoC: adau1373: Use SOC_ENUM_SINGLE_VIRT_DECL() Lars-Peter Clausen
2014-02-23 15:10 ` [PATCH 06/11] ASoC: max98090: " Lars-Peter Clausen
2014-02-23 15:10 ` [PATCH 07/11] ASoC: mc13783: " Lars-Peter Clausen
2014-02-24 14:28   ` Philippe Rétornaz
2014-02-28  7:19     ` Lars-Peter Clausen
2014-02-23 15:10 ` [PATCH 08/11] ASoC: wm8994: " Lars-Peter Clausen
2014-02-25  9:47   ` Charles Keepax
2014-02-23 15:10 ` [PATCH 09/11] ASoC: wm8995: " Lars-Peter Clausen
2014-02-25  9:47   ` Charles Keepax
2014-02-23 15:10 ` [PATCH 10/11] ASoC: dapm: Consolidate MUXs and virtual MUXs Lars-Peter Clausen
2014-02-23 15:10 ` [PATCH 11/11] ASoC: dapm: Break dapm_set_path_status() appart Lars-Peter Clausen
2014-02-25  1:57 ` [PATCH 00/11] ASoC: Consolidate enum controls and DAPM MUXs Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.