All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/16] ASoC: codecs: qcom fix validation failures
@ 2022-02-22 11:59 ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

Thanks for pointing out to mixer kselftest and VALIDATION Kconfig.

This patchset addresses some of the issues in Qualcomm codecs that are
discovered with recent mixer kselftest and validations added to ASoC.

Mostly these are under
1. accessing integer value type for enum controls, which is clearly an array out of bounds access.
2. Fix incorrect ranges.
3. Fix incorrect min max for tlv controls. (I can see that other codecs also suffer same issue)
4. Fix return values for put functions.

thanks,
srini

Srinivas Kandagatla (9):
  ASoC: codecs: rx-macro: fix accessing compander for aux
  ASoC: codecs: rx-macro: fix accessing array out of bounds for enum
    type
  ASoC: codecs: tx-macro: fix accessing array out of bounds for enum
    type
  ASoC: codecs: va-macro: fix accessing array out of bounds for enum
    type
  ASoC: codecs: wsa-macro: fix accessing array out of bounds for enum
    type
  ASoC: codecs: wc938x: fix accessing array out of bounds for enum type
  ASoC: codecs: wcd938x: fix kcontrol max values
  ASoC: codecs: wcd934x: fix kcontrol max values
  ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put
  ASoC: codecs: rx-macro: fix tlv min max range
  ASoC: codecs: tx-macro: fix tlv min max range
  ASoC: codecs: va-macro: fix tlv min max range
  ASoC: codecs: wsa-macro: fix tlv min max range
  ASoC: codecs: wcd938x: fix tlv min max range
  ASoC: codecs: wcd9335: fix tlv min max range
  ASoC: codecs: msm8916-wcd-digital: fix tlv min max range

 sound/soc/codecs/lpass-rx-macro.c      | 40 ++++++++-------
 sound/soc/codecs/lpass-tx-macro.c      | 24 ++++-----
 sound/soc/codecs/lpass-va-macro.c      | 12 ++---
 sound/soc/codecs/lpass-wsa-macro.c     | 14 +++---
 sound/soc/codecs/msm8916-wcd-digital.c | 14 +++---
 sound/soc/codecs/wcd9335.c             | 36 ++++++-------
 sound/soc/codecs/wcd934x.c             | 70 +++++++++++++-------------
 sound/soc/codecs/wcd938x.c             | 10 ++--
 8 files changed, 112 insertions(+), 108 deletions(-)

-- 
2.21.0


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

* [PATCH 00/16] ASoC: codecs: qcom fix validation failures
@ 2022-02-22 11:59 ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

Thanks for pointing out to mixer kselftest and VALIDATION Kconfig.

This patchset addresses some of the issues in Qualcomm codecs that are
discovered with recent mixer kselftest and validations added to ASoC.

Mostly these are under
1. accessing integer value type for enum controls, which is clearly an array out of bounds access.
2. Fix incorrect ranges.
3. Fix incorrect min max for tlv controls. (I can see that other codecs also suffer same issue)
4. Fix return values for put functions.

thanks,
srini

Srinivas Kandagatla (9):
  ASoC: codecs: rx-macro: fix accessing compander for aux
  ASoC: codecs: rx-macro: fix accessing array out of bounds for enum
    type
  ASoC: codecs: tx-macro: fix accessing array out of bounds for enum
    type
  ASoC: codecs: va-macro: fix accessing array out of bounds for enum
    type
  ASoC: codecs: wsa-macro: fix accessing array out of bounds for enum
    type
  ASoC: codecs: wc938x: fix accessing array out of bounds for enum type
  ASoC: codecs: wcd938x: fix kcontrol max values
  ASoC: codecs: wcd934x: fix kcontrol max values
  ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put
  ASoC: codecs: rx-macro: fix tlv min max range
  ASoC: codecs: tx-macro: fix tlv min max range
  ASoC: codecs: va-macro: fix tlv min max range
  ASoC: codecs: wsa-macro: fix tlv min max range
  ASoC: codecs: wcd938x: fix tlv min max range
  ASoC: codecs: wcd9335: fix tlv min max range
  ASoC: codecs: msm8916-wcd-digital: fix tlv min max range

 sound/soc/codecs/lpass-rx-macro.c      | 40 ++++++++-------
 sound/soc/codecs/lpass-tx-macro.c      | 24 ++++-----
 sound/soc/codecs/lpass-va-macro.c      | 12 ++---
 sound/soc/codecs/lpass-wsa-macro.c     | 14 +++---
 sound/soc/codecs/msm8916-wcd-digital.c | 14 +++---
 sound/soc/codecs/wcd9335.c             | 36 ++++++-------
 sound/soc/codecs/wcd934x.c             | 70 +++++++++++++-------------
 sound/soc/codecs/wcd938x.c             | 10 ++--
 8 files changed, 112 insertions(+), 108 deletions(-)

-- 
2.21.0


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

* [PATCH 01/16] ASoC: codecs: rx-macro: fix accessing compander for aux
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

AUX interpolator does not have compander, so check before accessing
compander data for this.

Without this checkan array of out bounds access will be made in
comp_enabled[] array.

Fixes: 4f692926f562 ("ASoC: codecs: lpass-rx-macro: add dapm widgets and route")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-rx-macro.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index fadf3c99c89d..a7f86b094a4f 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -2040,6 +2040,10 @@ static int rx_macro_load_compander_coeff(struct snd_soc_component *component,
 	int i;
 	int hph_pwr_mode;
 
+	/* AUX does not have compander */
+	if (comp == INTERP_AUX)
+		return 0;
+
 	if (!rx->comp_enabled[comp])
 		return 0;
 
-- 
2.21.0


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

* [PATCH 01/16] ASoC: codecs: rx-macro: fix accessing compander for aux
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

AUX interpolator does not have compander, so check before accessing
compander data for this.

Without this checkan array of out bounds access will be made in
comp_enabled[] array.

Fixes: 4f692926f562 ("ASoC: codecs: lpass-rx-macro: add dapm widgets and route")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-rx-macro.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index fadf3c99c89d..a7f86b094a4f 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -2040,6 +2040,10 @@ static int rx_macro_load_compander_coeff(struct snd_soc_component *component,
 	int i;
 	int hph_pwr_mode;
 
+	/* AUX does not have compander */
+	if (comp == INTERP_AUX)
+		return 0;
+
 	if (!rx->comp_enabled[comp])
 		return 0;
 
-- 
2.21.0


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

* [PATCH 02/16] ASoC: codecs: rx-macro: fix accessing array out of bounds for enum type
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Fixes: 4f692926f562 ("ASoC: codecs: lpass-rx-macro: add dapm widgets and route")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-rx-macro.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index a7f86b094a4f..058d8634ce40 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -2273,7 +2273,7 @@ static int rx_macro_mux_get(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
 	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] =
+	ucontrol->value.enumerated.item[0] =
 			rx->rx_port_value[widget->shift];
 	return 0;
 }
@@ -2285,7 +2285,7 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	struct snd_soc_dapm_update *update = NULL;
-	u32 rx_port_value = ucontrol->value.integer.value[0];
+	u32 rx_port_value = ucontrol->value.enumerated.item[0];
 	u32 aif_rst;
 	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
 
@@ -2397,7 +2397,7 @@ static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] = rx->hph_pwr_mode;
+	ucontrol->value.enumerated.item[0] = rx->hph_pwr_mode;
 	return 0;
 }
 
@@ -2407,7 +2407,7 @@ static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
 
-	rx->hph_pwr_mode = ucontrol->value.integer.value[0];
+	rx->hph_pwr_mode = ucontrol->value.enumerated.item[0];
 	return 0;
 }
 
-- 
2.21.0


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

* [PATCH 02/16] ASoC: codecs: rx-macro: fix accessing array out of bounds for enum type
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Fixes: 4f692926f562 ("ASoC: codecs: lpass-rx-macro: add dapm widgets and route")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-rx-macro.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index a7f86b094a4f..058d8634ce40 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -2273,7 +2273,7 @@ static int rx_macro_mux_get(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
 	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] =
+	ucontrol->value.enumerated.item[0] =
 			rx->rx_port_value[widget->shift];
 	return 0;
 }
@@ -2285,7 +2285,7 @@ static int rx_macro_mux_put(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	struct snd_soc_dapm_update *update = NULL;
-	u32 rx_port_value = ucontrol->value.integer.value[0];
+	u32 rx_port_value = ucontrol->value.enumerated.item[0];
 	u32 aif_rst;
 	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
 
@@ -2397,7 +2397,7 @@ static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] = rx->hph_pwr_mode;
+	ucontrol->value.enumerated.item[0] = rx->hph_pwr_mode;
 	return 0;
 }
 
@@ -2407,7 +2407,7 @@ static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
 
-	rx->hph_pwr_mode = ucontrol->value.integer.value[0];
+	rx->hph_pwr_mode = ucontrol->value.enumerated.item[0];
 	return 0;
 }
 
-- 
2.21.0


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

* [PATCH 03/16] ASoC: codecs: tx-macro: fix accessing array out of bounds for enum type
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Also few return value of put functions, so that change notifications are
sent correctly.

Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-tx-macro.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index 094756544eed..f90786100d1a 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -998,7 +998,7 @@ static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 
-	ucontrol->value.integer.value[0] = tx->dec_mode[path];
+	ucontrol->value.enumerated.item[0] = tx->dec_mode[path];
 
 	return 0;
 }
@@ -1007,14 +1007,14 @@ static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
 				 struct snd_ctl_elem_value *ucontrol)
 {
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
-	int value = ucontrol->value.integer.value[0];
+	int value = ucontrol->value.enumerated.item[0];
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 	struct tx_macro *tx = snd_soc_component_get_drvdata(component);
 
 	tx->dec_mode[path] = value;
 
-	return 0;
+	return 1;
 }
 
 static int tx_macro_get_bcs(struct snd_kcontrol *kcontrol,
@@ -1037,7 +1037,7 @@ static int tx_macro_set_bcs(struct snd_kcontrol *kcontrol,
 
 	tx->bcs_enable = value;
 
-	return 0;
+	return 1;
 }
 
 static int tx_macro_hw_params(struct snd_pcm_substream *substream,
-- 
2.21.0


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

* [PATCH 03/16] ASoC: codecs: tx-macro: fix accessing array out of bounds for enum type
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Also few return value of put functions, so that change notifications are
sent correctly.

Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-tx-macro.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index 094756544eed..f90786100d1a 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -998,7 +998,7 @@ static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 
-	ucontrol->value.integer.value[0] = tx->dec_mode[path];
+	ucontrol->value.enumerated.item[0] = tx->dec_mode[path];
 
 	return 0;
 }
@@ -1007,14 +1007,14 @@ static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
 				 struct snd_ctl_elem_value *ucontrol)
 {
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
-	int value = ucontrol->value.integer.value[0];
+	int value = ucontrol->value.enumerated.item[0];
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 	struct tx_macro *tx = snd_soc_component_get_drvdata(component);
 
 	tx->dec_mode[path] = value;
 
-	return 0;
+	return 1;
 }
 
 static int tx_macro_get_bcs(struct snd_kcontrol *kcontrol,
@@ -1037,7 +1037,7 @@ static int tx_macro_set_bcs(struct snd_kcontrol *kcontrol,
 
 	tx->bcs_enable = value;
 
-	return 0;
+	return 1;
 }
 
 static int tx_macro_hw_params(struct snd_pcm_substream *substream,
-- 
2.21.0


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

* [PATCH 04/16] ASoC: codecs: va-macro: fix accessing array out of bounds for enum type
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Fixes: 908e6b1df26e ("ASoC: codecs: lpass-va-macro: Add support to VA Macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-va-macro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
index 803e4dca0538..0fd0139e8229 100644
--- a/sound/soc/codecs/lpass-va-macro.c
+++ b/sound/soc/codecs/lpass-va-macro.c
@@ -781,7 +781,7 @@ static int va_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 
-	ucontrol->value.integer.value[0] = va->dec_mode[path];
+	ucontrol->value.enumerated.item[0] = va->dec_mode[path];
 
 	return 0;
 }
@@ -790,7 +790,7 @@ static int va_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
 				 struct snd_ctl_elem_value *ucontrol)
 {
 	struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
-	int value = ucontrol->value.integer.value[0];
+	int value = ucontrol->value.enumerated.item[0];
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 	struct va_macro *va = snd_soc_component_get_drvdata(comp);
-- 
2.21.0


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

* [PATCH 04/16] ASoC: codecs: va-macro: fix accessing array out of bounds for enum type
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Fixes: 908e6b1df26e ("ASoC: codecs: lpass-va-macro: Add support to VA Macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-va-macro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
index 803e4dca0538..0fd0139e8229 100644
--- a/sound/soc/codecs/lpass-va-macro.c
+++ b/sound/soc/codecs/lpass-va-macro.c
@@ -781,7 +781,7 @@ static int va_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 
-	ucontrol->value.integer.value[0] = va->dec_mode[path];
+	ucontrol->value.enumerated.item[0] = va->dec_mode[path];
 
 	return 0;
 }
@@ -790,7 +790,7 @@ static int va_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
 				 struct snd_ctl_elem_value *ucontrol)
 {
 	struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol);
-	int value = ucontrol->value.integer.value[0];
+	int value = ucontrol->value.enumerated.item[0];
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 	struct va_macro *va = snd_soc_component_get_drvdata(comp);
-- 
2.21.0


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

* [PATCH 05/16] ASoC: codecs: wsa-macro: fix accessing array out of bounds for enum type
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Also fix return value of put function, so that change notifications are
sent correctly.

Fixes: 2c4066e5d428 ("ASoC: codecs: lpass-wsa-macro: add dapm widgets and route")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-wsa-macro.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
index 05bf18ae10e7..7de09c46264b 100644
--- a/sound/soc/codecs/lpass-wsa-macro.c
+++ b/sound/soc/codecs/lpass-wsa-macro.c
@@ -1806,7 +1806,7 @@ static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] = wsa->ear_spkr_gain;
+	ucontrol->value.enumerated.item[0] = wsa->ear_spkr_gain;
 
 	return 0;
 }
@@ -1817,7 +1817,7 @@ static int wsa_macro_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
 
-	wsa->ear_spkr_gain =  ucontrol->value.integer.value[0];
+	wsa->ear_spkr_gain =  ucontrol->value.enumerated.item[0];
 
 	return 0;
 }
@@ -1831,7 +1831,7 @@ static int wsa_macro_rx_mux_get(struct snd_kcontrol *kcontrol,
 				snd_soc_dapm_to_component(widget->dapm);
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] =
+	ucontrol->value.enumerated.item[0] =
 			wsa->rx_port_value[widget->shift];
 	return 0;
 }
@@ -1845,7 +1845,7 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
 				snd_soc_dapm_to_component(widget->dapm);
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	struct snd_soc_dapm_update *update = NULL;
-	u32 rx_port_value = ucontrol->value.integer.value[0];
+	u32 rx_port_value = ucontrol->value.enumerated.item[0];
 	u32 bit_input;
 	u32 aif_rst;
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
@@ -1888,7 +1888,7 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
 
 	snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
 					rx_port_value, e, update);
-	return 0;
+	return 1;
 }
 
 static int wsa_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol,
-- 
2.21.0


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

* [PATCH 05/16] ASoC: codecs: wsa-macro: fix accessing array out of bounds for enum type
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Also fix return value of put function, so that change notifications are
sent correctly.

Fixes: 2c4066e5d428 ("ASoC: codecs: lpass-wsa-macro: add dapm widgets and route")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-wsa-macro.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
index 05bf18ae10e7..7de09c46264b 100644
--- a/sound/soc/codecs/lpass-wsa-macro.c
+++ b/sound/soc/codecs/lpass-wsa-macro.c
@@ -1806,7 +1806,7 @@ static int wsa_macro_ear_spkr_pa_gain_get(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] = wsa->ear_spkr_gain;
+	ucontrol->value.enumerated.item[0] = wsa->ear_spkr_gain;
 
 	return 0;
 }
@@ -1817,7 +1817,7 @@ static int wsa_macro_ear_spkr_pa_gain_put(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
 
-	wsa->ear_spkr_gain =  ucontrol->value.integer.value[0];
+	wsa->ear_spkr_gain =  ucontrol->value.enumerated.item[0];
 
 	return 0;
 }
@@ -1831,7 +1831,7 @@ static int wsa_macro_rx_mux_get(struct snd_kcontrol *kcontrol,
 				snd_soc_dapm_to_component(widget->dapm);
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] =
+	ucontrol->value.enumerated.item[0] =
 			wsa->rx_port_value[widget->shift];
 	return 0;
 }
@@ -1845,7 +1845,7 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
 				snd_soc_dapm_to_component(widget->dapm);
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	struct snd_soc_dapm_update *update = NULL;
-	u32 rx_port_value = ucontrol->value.integer.value[0];
+	u32 rx_port_value = ucontrol->value.enumerated.item[0];
 	u32 bit_input;
 	u32 aif_rst;
 	struct wsa_macro *wsa = snd_soc_component_get_drvdata(component);
@@ -1888,7 +1888,7 @@ static int wsa_macro_rx_mux_put(struct snd_kcontrol *kcontrol,
 
 	snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
 					rx_port_value, e, update);
-	return 0;
+	return 1;
 }
 
 static int wsa_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol,
-- 
2.21.0


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

* [PATCH 06/16] ASoC: codecs: wc938x: fix accessing array out of bounds for enum type
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Fix this by using enumerated items instead of integers.

Fixes: e8ba1e05bdc0 ("ASoC: codecs: wcd938x: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd938x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index cf61d23bfb1c..deecc83eb592 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -2506,7 +2506,7 @@ static int wcd938x_tx_mode_get(struct snd_kcontrol *kcontrol,
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 
-	ucontrol->value.integer.value[0] = wcd938x->tx_mode[path];
+	ucontrol->value.enumerated.item[0] = wcd938x->tx_mode[path];
 
 	return 0;
 }
@@ -2530,7 +2530,7 @@ static int wcd938x_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] = wcd938x->hph_mode;
+	ucontrol->value.enumerated.item[0] = wcd938x->hph_mode;
 
 	return 0;
 }
-- 
2.21.0


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

* [PATCH 06/16] ASoC: codecs: wc938x: fix accessing array out of bounds for enum type
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

Accessing enums using integer would result in array out of bounds access
on platforms like aarch64 where sizeof(long) is 8 compared to enum size
which is 4 bytes.

Fix this by using enumerated items instead of integers.

Fixes: e8ba1e05bdc0 ("ASoC: codecs: wcd938x: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd938x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index cf61d23bfb1c..deecc83eb592 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -2506,7 +2506,7 @@ static int wcd938x_tx_mode_get(struct snd_kcontrol *kcontrol,
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	int path = e->shift_l;
 
-	ucontrol->value.integer.value[0] = wcd938x->tx_mode[path];
+	ucontrol->value.enumerated.item[0] = wcd938x->tx_mode[path];
 
 	return 0;
 }
@@ -2530,7 +2530,7 @@ static int wcd938x_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
 	struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
 
-	ucontrol->value.integer.value[0] = wcd938x->hph_mode;
+	ucontrol->value.enumerated.item[0] = wcd938x->hph_mode;
 
 	return 0;
 }
-- 
2.21.0


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

* [PATCH 07/16] ASoC: codecs: wcd938x: fix kcontrol max values
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

set "HPH Type" Kcontrol max value of WCD_MBHC_HPH_STEREO instead of UINT_MAX.
set "HPHL/R Impedance" Kcontrols max value to INT_MAX instead of UINT_MAX as
max field is integer type.

Without this patch amixer for these controls will show -1 as max value to userspace.

Fixes: bcee7ed09b8e ("ASoC: codecs: wcd938x: add Multi Button Headset Control support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd938x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index deecc83eb592..782877db8c3c 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -3577,14 +3577,14 @@ static int wcd938x_hph_impedance_get(struct snd_kcontrol *kcontrol,
 }
 
 static const struct snd_kcontrol_new hph_type_detect_controls[] = {
-	SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPH Type", 0, 0, WCD_MBHC_HPH_STEREO, 0,
 		       wcd938x_get_hph_type, NULL),
 };
 
 static const struct snd_kcontrol_new impedance_detect_controls[] = {
-	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, INT_MAX, 0,
 		       wcd938x_hph_impedance_get, NULL),
-	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, INT_MAX, 0,
 		       wcd938x_hph_impedance_get, NULL),
 };
 
-- 
2.21.0


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

* [PATCH 07/16] ASoC: codecs: wcd938x: fix kcontrol max values
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

set "HPH Type" Kcontrol max value of WCD_MBHC_HPH_STEREO instead of UINT_MAX.
set "HPHL/R Impedance" Kcontrols max value to INT_MAX instead of UINT_MAX as
max field is integer type.

Without this patch amixer for these controls will show -1 as max value to userspace.

Fixes: bcee7ed09b8e ("ASoC: codecs: wcd938x: add Multi Button Headset Control support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd938x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index deecc83eb592..782877db8c3c 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -3577,14 +3577,14 @@ static int wcd938x_hph_impedance_get(struct snd_kcontrol *kcontrol,
 }
 
 static const struct snd_kcontrol_new hph_type_detect_controls[] = {
-	SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPH Type", 0, 0, WCD_MBHC_HPH_STEREO, 0,
 		       wcd938x_get_hph_type, NULL),
 };
 
 static const struct snd_kcontrol_new impedance_detect_controls[] = {
-	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, INT_MAX, 0,
 		       wcd938x_hph_impedance_get, NULL),
-	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, INT_MAX, 0,
 		       wcd938x_hph_impedance_get, NULL),
 };
 
-- 
2.21.0


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

* [PATCH 08/16] ASoC: codecs: wcd934x: fix kcontrol max values
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

set "HPH Type" Kcontrol max value of WCD_MBHC_HPH_STEREO instead of UINT_MAX.
set "HPHL/R Impedance" Kcontrols max value to INT_MAX instead of UINT_MAX as
max field is integer type.

Without this patch amixer for these controls will show -1 as max value to userspace.

Fixes: 9fb9b1690f0b ("ASoC: codecs: wcd934x: add mbhc support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd934x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index 6c468527fec6..f2674905a4a7 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -3023,14 +3023,14 @@ static int wcd934x_hph_impedance_get(struct snd_kcontrol *kcontrol,
 	return 0;
 }
 static const struct snd_kcontrol_new hph_type_detect_controls[] = {
-	SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPH Type", 0, 0, WCD_MBHC_HPH_STEREO, 0,
 		       wcd934x_get_hph_type, NULL),
 };
 
 static const struct snd_kcontrol_new impedance_detect_controls[] = {
-	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, INT_MAX, 0,
 		       wcd934x_hph_impedance_get, NULL),
-	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, INT_MAX, 0,
 		       wcd934x_hph_impedance_get, NULL),
 };
 
-- 
2.21.0


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

* [PATCH 08/16] ASoC: codecs: wcd934x: fix kcontrol max values
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

set "HPH Type" Kcontrol max value of WCD_MBHC_HPH_STEREO instead of UINT_MAX.
set "HPHL/R Impedance" Kcontrols max value to INT_MAX instead of UINT_MAX as
max field is integer type.

Without this patch amixer for these controls will show -1 as max value to userspace.

Fixes: 9fb9b1690f0b ("ASoC: codecs: wcd934x: add mbhc support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd934x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index 6c468527fec6..f2674905a4a7 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -3023,14 +3023,14 @@ static int wcd934x_hph_impedance_get(struct snd_kcontrol *kcontrol,
 	return 0;
 }
 static const struct snd_kcontrol_new hph_type_detect_controls[] = {
-	SOC_SINGLE_EXT("HPH Type", 0, 0, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPH Type", 0, 0, WCD_MBHC_HPH_STEREO, 0,
 		       wcd934x_get_hph_type, NULL),
 };
 
 static const struct snd_kcontrol_new impedance_detect_controls[] = {
-	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPHL Impedance", 0, 0, INT_MAX, 0,
 		       wcd934x_hph_impedance_get, NULL),
-	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, UINT_MAX, 0,
+	SOC_SINGLE_EXT("HPHR Impedance", 0, 1, INT_MAX, 0,
 		       wcd934x_hph_impedance_get, NULL),
 };
 
-- 
2.21.0


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

* [PATCH 09/16] ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

wcd934x_rx_hph_mode_put currently returns zero eventhough it changes the value.
Fix this, so that change notifications are sent correctly.

Fixes: 1cde8b822332 ("ASoC: wcd934x: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd934x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index f2674905a4a7..ab580f37cf00 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -3314,7 +3314,7 @@ static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc,
 	}
 	wcd->hph_mode = mode_val;
 
-	return 0;
+	return 1;
 }
 
 static int slim_rx_mux_get(struct snd_kcontrol *kc,
-- 
2.21.0


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

* [PATCH 09/16] ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

wcd934x_rx_hph_mode_put currently returns zero eventhough it changes the value.
Fix this, so that change notifications are sent correctly.

Fixes: 1cde8b822332 ("ASoC: wcd934x: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd934x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index f2674905a4a7..ab580f37cf00 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -3314,7 +3314,7 @@ static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc,
 	}
 	wcd->hph_mode = mode_val;
 
-	return 0;
+	return 1;
 }
 
 static int slim_rx_mux_get(struct snd_kcontrol *kc,
-- 
2.21.0


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

* [PATCH 10/16] ASoC: codecs: rx-macro: fix tlv min max range
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: af3d54b99764 ("ASoC: codecs: lpass-rx-macro: add support for lpass rx macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-rx-macro.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index 058d8634ce40..d31d4d45ba01 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -2800,17 +2800,17 @@ static int rx_macro_iir_filter_info(struct snd_kcontrol *kcontrol,
 
 static const struct snd_kcontrol_new rx_macro_snd_controls[] = {
 	SOC_SINGLE_S8_TLV("RX_RX0 Digital Volume", CDC_RX_RX0_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX1 Digital Volume", CDC_RX_RX1_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX2 Digital Volume", CDC_RX_RX2_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX0 Mix Digital Volume", CDC_RX_RX0_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX1 Mix Digital Volume", CDC_RX_RX1_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX2 Mix Digital Volume", CDC_RX_RX2_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_SINGLE_EXT("RX_COMP1 Switch", SND_SOC_NOPM, RX_MACRO_COMP1, 1, 0,
 		rx_macro_get_compander, rx_macro_set_compander),
@@ -2834,28 +2834,28 @@ static const struct snd_kcontrol_new rx_macro_snd_controls[] = {
 			rx_macro_aux_hpf_mode_put),
 
 	SOC_SINGLE_S8_TLV("IIR0 INP0 Volume",
-		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP1 Volume",
-		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP2 Volume",
-		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP3 Volume",
-		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP0 Volume",
-		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP1 Volume",
-		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP2 Volume",
-		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP3 Volume",
-		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, 124,
 		digital_gain),
 
 	SOC_SINGLE("IIR1 Band1 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL,
-- 
2.21.0


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

* [PATCH 10/16] ASoC: codecs: rx-macro: fix tlv min max range
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: af3d54b99764 ("ASoC: codecs: lpass-rx-macro: add support for lpass rx macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-rx-macro.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index 058d8634ce40..d31d4d45ba01 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -2800,17 +2800,17 @@ static int rx_macro_iir_filter_info(struct snd_kcontrol *kcontrol,
 
 static const struct snd_kcontrol_new rx_macro_snd_controls[] = {
 	SOC_SINGLE_S8_TLV("RX_RX0 Digital Volume", CDC_RX_RX0_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX1 Digital Volume", CDC_RX_RX1_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX2 Digital Volume", CDC_RX_RX2_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX0 Mix Digital Volume", CDC_RX_RX0_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX1 Mix Digital Volume", CDC_RX_RX1_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX_RX2 Mix Digital Volume", CDC_RX_RX2_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_SINGLE_EXT("RX_COMP1 Switch", SND_SOC_NOPM, RX_MACRO_COMP1, 1, 0,
 		rx_macro_get_compander, rx_macro_set_compander),
@@ -2834,28 +2834,28 @@ static const struct snd_kcontrol_new rx_macro_snd_controls[] = {
 			rx_macro_aux_hpf_mode_put),
 
 	SOC_SINGLE_S8_TLV("IIR0 INP0 Volume",
-		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP1 Volume",
-		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP2 Volume",
-		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP3 Volume",
-		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP0 Volume",
-		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP1 Volume",
-		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP2 Volume",
-		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, 124,
 		digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP3 Volume",
-		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, -84, 40,
+		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, 124,
 		digital_gain),
 
 	SOC_SINGLE("IIR1 Band1 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL,
-- 
2.21.0


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

* [PATCH 11/16] ASoC: codecs: tx-macro: fix tlv min max range
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-tx-macro.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index f90786100d1a..56c1f3cf73f8 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -1600,28 +1600,28 @@ static const struct snd_soc_dapm_route tx_audio_map[] = {
 static const struct snd_kcontrol_new tx_macro_snd_controls[] = {
 	SOC_SINGLE_S8_TLV("TX_DEC0 Volume",
 			  CDC_TX0_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC1 Volume",
 			  CDC_TX1_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC2 Volume",
 			  CDC_TX2_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC3 Volume",
 			  CDC_TX3_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC4 Volume",
 			  CDC_TX4_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC5 Volume",
 			  CDC_TX5_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC6 Volume",
 			  CDC_TX6_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC7 Volume",
 			  CDC_TX7_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_ENUM_EXT("DEC0 MODE", dec_mode_mux_enum[0],
 			tx_macro_dec_mode_get, tx_macro_dec_mode_put),
-- 
2.21.0


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

* [PATCH 11/16] ASoC: codecs: tx-macro: fix tlv min max range
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: c39667ddcfc5 ("ASoC: codecs: lpass-tx-macro: add support for lpass tx macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-tx-macro.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index f90786100d1a..56c1f3cf73f8 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -1600,28 +1600,28 @@ static const struct snd_soc_dapm_route tx_audio_map[] = {
 static const struct snd_kcontrol_new tx_macro_snd_controls[] = {
 	SOC_SINGLE_S8_TLV("TX_DEC0 Volume",
 			  CDC_TX0_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC1 Volume",
 			  CDC_TX1_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC2 Volume",
 			  CDC_TX2_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC3 Volume",
 			  CDC_TX3_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC4 Volume",
 			  CDC_TX4_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC5 Volume",
 			  CDC_TX5_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC6 Volume",
 			  CDC_TX6_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("TX_DEC7 Volume",
 			  CDC_TX7_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_ENUM_EXT("DEC0 MODE", dec_mode_mux_enum[0],
 			tx_macro_dec_mode_get, tx_macro_dec_mode_put),
-- 
2.21.0


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

* [PATCH 12/16] ASoC: codecs: va-macro: fix tlv min max range
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: 908e6b1df26e ("ASoC: codecs: lpass-va-macro: Add support to VA Macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-va-macro.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
index 0fd0139e8229..555675690166 100644
--- a/sound/soc/codecs/lpass-va-macro.c
+++ b/sound/soc/codecs/lpass-va-macro.c
@@ -1256,13 +1256,13 @@ static const struct soc_enum dec_mode_mux_enum[] = {
 
 static const struct snd_kcontrol_new va_macro_snd_controls[] = {
 	SOC_SINGLE_S8_TLV("VA_DEC0 Volume", CDC_VA_TX0_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("VA_DEC1 Volume", CDC_VA_TX1_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("VA_DEC2 Volume", CDC_VA_TX2_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("VA_DEC3 Volume", CDC_VA_TX3_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_ENUM_EXT("VA_DEC0 MODE", dec_mode_mux_enum[0],
 		     va_macro_dec_mode_get, va_macro_dec_mode_put),
-- 
2.21.0


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

* [PATCH 12/16] ASoC: codecs: va-macro: fix tlv min max range
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: 908e6b1df26e ("ASoC: codecs: lpass-va-macro: Add support to VA Macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-va-macro.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
index 0fd0139e8229..555675690166 100644
--- a/sound/soc/codecs/lpass-va-macro.c
+++ b/sound/soc/codecs/lpass-va-macro.c
@@ -1256,13 +1256,13 @@ static const struct soc_enum dec_mode_mux_enum[] = {
 
 static const struct snd_kcontrol_new va_macro_snd_controls[] = {
 	SOC_SINGLE_S8_TLV("VA_DEC0 Volume", CDC_VA_TX0_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("VA_DEC1 Volume", CDC_VA_TX1_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("VA_DEC2 Volume", CDC_VA_TX2_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("VA_DEC3 Volume", CDC_VA_TX3_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_ENUM_EXT("VA_DEC0 MODE", dec_mode_mux_enum[0],
 		     va_macro_dec_mode_get, va_macro_dec_mode_put),
-- 
2.21.0


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

* [PATCH 13/16] ASoC: codecs: wsa-macro: fix tlv min max range
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: 809bcbcecebf ("ASoC: codecs: lpass-wsa-macro: Add support to WSA Macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-wsa-macro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
index 7de09c46264b..b769fb2ef2f6 100644
--- a/sound/soc/codecs/lpass-wsa-macro.c
+++ b/sound/soc/codecs/lpass-wsa-macro.c
@@ -1929,9 +1929,9 @@ static const struct snd_kcontrol_new wsa_macro_snd_controls[] = {
 			wsa_macro_soft_clip_enable_put),
 
 	SOC_SINGLE_S8_TLV("WSA_RX0 Digital Volume", CDC_WSA_RX0_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("WSA_RX1 Digital Volume", CDC_WSA_RX1_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_SINGLE("WSA_RX0 Digital Mute", CDC_WSA_RX0_RX_PATH_CTL, 4, 1, 0),
 	SOC_SINGLE("WSA_RX1 Digital Mute", CDC_WSA_RX1_RX_PATH_CTL, 4, 1, 0),
-- 
2.21.0


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

* [PATCH 13/16] ASoC: codecs: wsa-macro: fix tlv min max range
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: 809bcbcecebf ("ASoC: codecs: lpass-wsa-macro: Add support to WSA Macro")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-wsa-macro.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c
index 7de09c46264b..b769fb2ef2f6 100644
--- a/sound/soc/codecs/lpass-wsa-macro.c
+++ b/sound/soc/codecs/lpass-wsa-macro.c
@@ -1929,9 +1929,9 @@ static const struct snd_kcontrol_new wsa_macro_snd_controls[] = {
 			wsa_macro_soft_clip_enable_put),
 
 	SOC_SINGLE_S8_TLV("WSA_RX0 Digital Volume", CDC_WSA_RX0_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("WSA_RX1 Digital Volume", CDC_WSA_RX1_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_SINGLE("WSA_RX0 Digital Mute", CDC_WSA_RX0_RX_PATH_CTL, 4, 1, 0),
 	SOC_SINGLE("WSA_RX1 Digital Mute", CDC_WSA_RX1_RX_PATH_CTL, 4, 1, 0),
-- 
2.21.0


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

* [PATCH 14/16] ASoC: codecs: wcd938x: fix tlv min max range
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: 1cde8b822332 ("ASoC: wcd934x: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd934x.c | 62 +++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index ab580f37cf00..5e45d5eec7c2 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -3996,83 +3996,83 @@ static const struct snd_kcontrol_new wcd934x_snd_controls[] = {
 	SOC_SINGLE_TLV("ADC4 Volume", WCD934X_ANA_AMIC4, 0, 20, 0, analog_gain),
 
 	SOC_SINGLE_S8_TLV("RX0 Digital Volume", WCD934X_CDC_RX0_RX_VOL_CTL,
-			  -84, 40, digital_gain), /* -84dB min - 40dB max */
+			  0, 124, digital_gain), /* -84dB min - 40dB max */
 	SOC_SINGLE_S8_TLV("RX1 Digital Volume", WCD934X_CDC_RX1_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX2 Digital Volume", WCD934X_CDC_RX2_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX3 Digital Volume", WCD934X_CDC_RX3_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX4 Digital Volume", WCD934X_CDC_RX4_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX7 Digital Volume", WCD934X_CDC_RX7_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX8 Digital Volume", WCD934X_CDC_RX8_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX0 Mix Digital Volume",
 			  WCD934X_CDC_RX0_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX1 Mix Digital Volume",
 			  WCD934X_CDC_RX1_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX2 Mix Digital Volume",
 			  WCD934X_CDC_RX2_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX3 Mix Digital Volume",
 			  WCD934X_CDC_RX3_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX4 Mix Digital Volume",
 			  WCD934X_CDC_RX4_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX7 Mix Digital Volume",
 			  WCD934X_CDC_RX7_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX8 Mix Digital Volume",
 			  WCD934X_CDC_RX8_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_SINGLE_S8_TLV("DEC0 Volume", WCD934X_CDC_TX0_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC1 Volume", WCD934X_CDC_TX1_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC2 Volume", WCD934X_CDC_TX2_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC3 Volume", WCD934X_CDC_TX3_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC4 Volume", WCD934X_CDC_TX4_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC5 Volume", WCD934X_CDC_TX5_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC6 Volume", WCD934X_CDC_TX6_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC7 Volume", WCD934X_CDC_TX7_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC8 Volume", WCD934X_CDC_TX8_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_SINGLE_S8_TLV("IIR0 INP0 Volume",
-			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP1 Volume",
-			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP2 Volume",
-			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP3 Volume",
-			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP0 Volume",
-			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP1 Volume",
-			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP2 Volume",
-			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP3 Volume",
-			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, 124,
 			  digital_gain),
 
 	SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
-- 
2.21.0


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

* [PATCH 14/16] ASoC: codecs: wcd938x: fix tlv min max range
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: 1cde8b822332 ("ASoC: wcd934x: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd934x.c | 62 +++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/sound/soc/codecs/wcd934x.c b/sound/soc/codecs/wcd934x.c
index ab580f37cf00..5e45d5eec7c2 100644
--- a/sound/soc/codecs/wcd934x.c
+++ b/sound/soc/codecs/wcd934x.c
@@ -3996,83 +3996,83 @@ static const struct snd_kcontrol_new wcd934x_snd_controls[] = {
 	SOC_SINGLE_TLV("ADC4 Volume", WCD934X_ANA_AMIC4, 0, 20, 0, analog_gain),
 
 	SOC_SINGLE_S8_TLV("RX0 Digital Volume", WCD934X_CDC_RX0_RX_VOL_CTL,
-			  -84, 40, digital_gain), /* -84dB min - 40dB max */
+			  0, 124, digital_gain), /* -84dB min - 40dB max */
 	SOC_SINGLE_S8_TLV("RX1 Digital Volume", WCD934X_CDC_RX1_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX2 Digital Volume", WCD934X_CDC_RX2_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX3 Digital Volume", WCD934X_CDC_RX3_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX4 Digital Volume", WCD934X_CDC_RX4_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX7 Digital Volume", WCD934X_CDC_RX7_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX8 Digital Volume", WCD934X_CDC_RX8_RX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX0 Mix Digital Volume",
 			  WCD934X_CDC_RX0_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX1 Mix Digital Volume",
 			  WCD934X_CDC_RX1_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX2 Mix Digital Volume",
 			  WCD934X_CDC_RX2_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX3 Mix Digital Volume",
 			  WCD934X_CDC_RX3_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX4 Mix Digital Volume",
 			  WCD934X_CDC_RX4_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX7 Mix Digital Volume",
 			  WCD934X_CDC_RX7_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("RX8 Mix Digital Volume",
 			  WCD934X_CDC_RX8_RX_VOL_MIX_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_SINGLE_S8_TLV("DEC0 Volume", WCD934X_CDC_TX0_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC1 Volume", WCD934X_CDC_TX1_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC2 Volume", WCD934X_CDC_TX2_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC3 Volume", WCD934X_CDC_TX3_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC4 Volume", WCD934X_CDC_TX4_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC5 Volume", WCD934X_CDC_TX5_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC6 Volume", WCD934X_CDC_TX6_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC7 Volume", WCD934X_CDC_TX7_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 	SOC_SINGLE_S8_TLV("DEC8 Volume", WCD934X_CDC_TX8_TX_VOL_CTL,
-			  -84, 40, digital_gain),
+			  0, 124, digital_gain),
 
 	SOC_SINGLE_S8_TLV("IIR0 INP0 Volume",
-			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP1 Volume",
-			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP2 Volume",
-			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR0 INP3 Volume",
-			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP0 Volume",
-			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP1 Volume",
-			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP2 Volume",
-			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0, 124,
 			  digital_gain),
 	SOC_SINGLE_S8_TLV("IIR1 INP3 Volume",
-			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, -84, 40,
+			  WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0, 124,
 			  digital_gain),
 
 	SOC_ENUM("TX0 HPF cut off", cf_dec0_enum),
-- 
2.21.0


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

* [PATCH 15/16] ASoC: codecs: wcd9335: fix tlv min max range
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_SX_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_SX_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: 8c4f021d806a ("ASoC: wcd9335: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd9335.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
index 1e60db4056ad..cf7bdd309f70 100644
--- a/sound/soc/codecs/wcd9335.c
+++ b/sound/soc/codecs/wcd9335.c
@@ -2254,50 +2254,50 @@ static int wcd9335_rx_hph_mode_put(struct snd_kcontrol *kc,
 static const struct snd_kcontrol_new wcd9335_snd_controls[] = {
 	/* -84dB min - 40dB max */
 	SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
 			  WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
 			  WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
 			  WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
 			  WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
 			  WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
 			  WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
 			  WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
 			  WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
 			  WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
 	SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
 	SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
-- 
2.21.0


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

* [PATCH 15/16] ASoC: codecs: wcd9335: fix tlv min max range
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_SX_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_SX_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: 8c4f021d806a ("ASoC: wcd9335: add basic controls")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/wcd9335.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
index 1e60db4056ad..cf7bdd309f70 100644
--- a/sound/soc/codecs/wcd9335.c
+++ b/sound/soc/codecs/wcd9335.c
@@ -2254,50 +2254,50 @@ static int wcd9335_rx_hph_mode_put(struct snd_kcontrol *kc,
 static const struct snd_kcontrol_new wcd9335_snd_controls[] = {
 	/* -84dB min - 40dB max */
 	SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
-		0, -84, 40, digital_gain),
+		0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
 			  WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
 			  WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
 			  WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
 			  WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
 			  WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
 			  WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
 			  WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
 			  WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
 			  WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
-			  0, -84, 40, digital_gain),
+			  0, 0, 124, digital_gain),
 	SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
 	SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
 	SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
-- 
2.21.0


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

* [PATCH 16/16] ASoC: codecs: msm8916-wcd-digital: fix tlv min max range
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam, Srinivas Kandagatla

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_SX_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_SX_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: ef8a4757a6db ("ASoC: msm8916-wcd-digital: Add sidetone support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/msm8916-wcd-digital.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c
index fcc10c8bc625..b32803bf6f63 100644
--- a/sound/soc/codecs/msm8916-wcd-digital.c
+++ b/sound/soc/codecs/msm8916-wcd-digital.c
@@ -554,21 +554,21 @@ static const struct snd_kcontrol_new msm8916_wcd_digital_snd_controls[] = {
 	WCD_IIR_FILTER_CTL("IIR2 Band4", IIR2, BAND4),
 	WCD_IIR_FILTER_CTL("IIR2 Band5", IIR2, BAND5),
 	SOC_SINGLE_SX_TLV("IIR1 INP1 Volume", LPASS_CDC_IIR1_GAIN_B1_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR1 INP2 Volume", LPASS_CDC_IIR1_GAIN_B2_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR1 INP3 Volume", LPASS_CDC_IIR1_GAIN_B3_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR1 INP4 Volume", LPASS_CDC_IIR1_GAIN_B4_CTL,
 			0,  -84,	40, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR2 INP1 Volume", LPASS_CDC_IIR2_GAIN_B1_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR2 INP2 Volume", LPASS_CDC_IIR2_GAIN_B2_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR2 INP3 Volume", LPASS_CDC_IIR2_GAIN_B3_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR2 INP4 Volume", LPASS_CDC_IIR2_GAIN_B4_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 
 };
 
-- 
2.21.0


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

* [PATCH 16/16] ASoC: codecs: msm8916-wcd-digital: fix tlv min max range
@ 2022-02-22 11:59   ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 11:59 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	Srinivas Kandagatla, quic_srivasam

on Qualcomm codecs gain tlv control specifies min max range as both
negative to positive numbers like

SOC_SINGLE_SX_TLV("... Volume", ..,  -84, 40, gain)

However with recent boundary checks added in commit 817f7c9335ec0
("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
setting a value above 40 gain will fail.

So fix this min max range correctly to
SOC_SINGLE_SX_TLV("... Volume", ..,  0, 124, gain)
so that users can now set gain correctly

Fixes: ef8a4757a6db ("ASoC: msm8916-wcd-digital: Add sidetone support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/msm8916-wcd-digital.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c
index fcc10c8bc625..b32803bf6f63 100644
--- a/sound/soc/codecs/msm8916-wcd-digital.c
+++ b/sound/soc/codecs/msm8916-wcd-digital.c
@@ -554,21 +554,21 @@ static const struct snd_kcontrol_new msm8916_wcd_digital_snd_controls[] = {
 	WCD_IIR_FILTER_CTL("IIR2 Band4", IIR2, BAND4),
 	WCD_IIR_FILTER_CTL("IIR2 Band5", IIR2, BAND5),
 	SOC_SINGLE_SX_TLV("IIR1 INP1 Volume", LPASS_CDC_IIR1_GAIN_B1_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR1 INP2 Volume", LPASS_CDC_IIR1_GAIN_B2_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR1 INP3 Volume", LPASS_CDC_IIR1_GAIN_B3_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR1 INP4 Volume", LPASS_CDC_IIR1_GAIN_B4_CTL,
 			0,  -84,	40, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR2 INP1 Volume", LPASS_CDC_IIR2_GAIN_B1_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR2 INP2 Volume", LPASS_CDC_IIR2_GAIN_B2_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR2 INP3 Volume", LPASS_CDC_IIR2_GAIN_B3_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 	SOC_SINGLE_SX_TLV("IIR2 INP4 Volume", LPASS_CDC_IIR2_GAIN_B4_CTL,
-			0,  -84, 40, digital_gain),
+			0,  0, 124, digital_gain),
 
 };
 
-- 
2.21.0


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

* Re: [PATCH 09/16] ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put
  2022-02-22 11:59   ` Srinivas Kandagatla
@ 2022-02-22 17:54     ` Mark Brown
  -1 siblings, 0 replies; 44+ messages in thread
From: Mark Brown @ 2022-02-22 17:54 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam

[-- Attachment #1: Type: text/plain, Size: 472 bytes --]

On Tue, Feb 22, 2022 at 11:59:26AM +0000, Srinivas Kandagatla wrote:
> wcd934x_rx_hph_mode_put currently returns zero eventhough it changes the value.
> Fix this, so that change notifications are sent correctly.

> -	return 0;
> +	return 1;

This now has the opposite issue where it will unconditionally flag a
change even if none occurred, that's less bad but still an issue.  It
should check to see if the value written is different to that already
set and report that.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 09/16] ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put
@ 2022-02-22 17:54     ` Mark Brown
  0 siblings, 0 replies; 44+ messages in thread
From: Mark Brown @ 2022-02-22 17:54 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	quic_srivasam

[-- Attachment #1: Type: text/plain, Size: 472 bytes --]

On Tue, Feb 22, 2022 at 11:59:26AM +0000, Srinivas Kandagatla wrote:
> wcd934x_rx_hph_mode_put currently returns zero eventhough it changes the value.
> Fix this, so that change notifications are sent correctly.

> -	return 0;
> +	return 1;

This now has the opposite issue where it will unconditionally flag a
change even if none occurred, that's less bad but still an issue.  It
should check to see if the value written is different to that already
set and report that.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 10/16] ASoC: codecs: rx-macro: fix tlv min max range
  2022-02-22 11:59   ` Srinivas Kandagatla
@ 2022-02-22 18:04     ` Mark Brown
  -1 siblings, 0 replies; 44+ messages in thread
From: Mark Brown @ 2022-02-22 18:04 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam

[-- Attachment #1: Type: text/plain, Size: 911 bytes --]

On Tue, Feb 22, 2022 at 11:59:27AM +0000, Srinivas Kandagatla wrote:
> on Qualcomm codecs gain tlv control specifies min max range as both
> negative to positive numbers like
> 
> SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)
> 
> However with recent boundary checks added in commit 817f7c9335ec0
> ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
> setting a value above 40 gain will fail.
> 
> So fix this min max range correctly to
> SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
> so that users can now set gain correctly

Are you sure this isn't a bug in the core?  -84..40 should be a valid
range for a signed control.  See Marek's fix in 9bdd10d57a ("ASoC: ops:
Shift tested values in snd_soc_put_volsw() by +min") though that only
kicks in for systems with a platform_max.  I can't immediately spot any
other issues for S8 but I could be missing something.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 10/16] ASoC: codecs: rx-macro: fix tlv min max range
@ 2022-02-22 18:04     ` Mark Brown
  0 siblings, 0 replies; 44+ messages in thread
From: Mark Brown @ 2022-02-22 18:04 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	quic_srivasam

[-- Attachment #1: Type: text/plain, Size: 911 bytes --]

On Tue, Feb 22, 2022 at 11:59:27AM +0000, Srinivas Kandagatla wrote:
> on Qualcomm codecs gain tlv control specifies min max range as both
> negative to positive numbers like
> 
> SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)
> 
> However with recent boundary checks added in commit 817f7c9335ec0
> ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
> setting a value above 40 gain will fail.
> 
> So fix this min max range correctly to
> SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
> so that users can now set gain correctly

Are you sure this isn't a bug in the core?  -84..40 should be a valid
range for a signed control.  See Marek's fix in 9bdd10d57a ("ASoC: ops:
Shift tested values in snd_soc_put_volsw() by +min") though that only
kicks in for systems with a platform_max.  I can't immediately spot any
other issues for S8 but I could be missing something.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 10/16] ASoC: codecs: rx-macro: fix tlv min max range
  2022-02-22 18:04     ` Mark Brown
@ 2022-02-22 18:21       ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 18:21 UTC (permalink / raw)
  To: Mark Brown
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam



On 22/02/2022 18:04, Mark Brown wrote:
> On Tue, Feb 22, 2022 at 11:59:27AM +0000, Srinivas Kandagatla wrote:
>> on Qualcomm codecs gain tlv control specifies min max range as both
>> negative to positive numbers like
>>
>> SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)
>>
>> However with recent boundary checks added in commit 817f7c9335ec0
>> ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
>> setting a value above 40 gain will fail.
>>
>> So fix this min max range correctly to
>> SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
>> so that users can now set gain correctly
> 
> Are you sure this isn't a bug in the core?  -84..40 should be a valid
> range for a signed control.  See Marek's fix in 9bdd10d57a ("ASoC: ops:
> Shift tested values in snd_soc_put_volsw() by +min") though that onlyNice, This works for me. Will drop all he tlv patches.

--srini

> kicks in for systems with a platform_max.  I can't immediately spot any
> other issues for S8 but I could be missing something.

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

* Re: [PATCH 10/16] ASoC: codecs: rx-macro: fix tlv min max range
@ 2022-02-22 18:21       ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 18:21 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	quic_srivasam



On 22/02/2022 18:04, Mark Brown wrote:
> On Tue, Feb 22, 2022 at 11:59:27AM +0000, Srinivas Kandagatla wrote:
>> on Qualcomm codecs gain tlv control specifies min max range as both
>> negative to positive numbers like
>>
>> SOC_SINGLE_S8_TLV("... Volume", ..,  -84, 40, gain)
>>
>> However with recent boundary checks added in commit 817f7c9335ec0
>> ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw())
>> setting a value above 40 gain will fail.
>>
>> So fix this min max range correctly to
>> SOC_SINGLE_S8_TLV("... Volume", ..,  0, 124, gain)
>> so that users can now set gain correctly
> 
> Are you sure this isn't a bug in the core?  -84..40 should be a valid
> range for a signed control.  See Marek's fix in 9bdd10d57a ("ASoC: ops:
> Shift tested values in snd_soc_put_volsw() by +min") though that onlyNice, This works for me. Will drop all he tlv patches.

--srini

> kicks in for systems with a platform_max.  I can't immediately spot any
> other issues for S8 but I could be missing something.

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

* Re: [PATCH 09/16] ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put
  2022-02-22 17:54     ` Mark Brown
@ 2022-02-22 18:22       ` Srinivas Kandagatla
  -1 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 18:22 UTC (permalink / raw)
  To: Mark Brown
  Cc: lgirdwood, perex, tiwai, pierre-louis.bossart, alsa-devel,
	linux-kernel, quic_srivasam



On 22/02/2022 17:54, Mark Brown wrote:
> On Tue, Feb 22, 2022 at 11:59:26AM +0000, Srinivas Kandagatla wrote:
>> wcd934x_rx_hph_mode_put currently returns zero eventhough it changes the value.
>> Fix this, so that change notifications are sent correctly.
> 
>> -	return 0;
>> +	return 1;
> 
> This now has the opposite issue where it will unconditionally flag a
> change even if none occurred, that's less bad but still an issue.  It
> should check to see if the value written is different to that already
> set and report that.
Thanks for spotting this, Yes, that is another issue, Will fix those in 
next spin.

--srini

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

* Re: [PATCH 09/16] ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put
@ 2022-02-22 18:22       ` Srinivas Kandagatla
  0 siblings, 0 replies; 44+ messages in thread
From: Srinivas Kandagatla @ 2022-02-22 18:22 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, lgirdwood, linux-kernel, pierre-louis.bossart, tiwai,
	quic_srivasam



On 22/02/2022 17:54, Mark Brown wrote:
> On Tue, Feb 22, 2022 at 11:59:26AM +0000, Srinivas Kandagatla wrote:
>> wcd934x_rx_hph_mode_put currently returns zero eventhough it changes the value.
>> Fix this, so that change notifications are sent correctly.
> 
>> -	return 0;
>> +	return 1;
> 
> This now has the opposite issue where it will unconditionally flag a
> change even if none occurred, that's less bad but still an issue.  It
> should check to see if the value written is different to that already
> set and report that.
Thanks for spotting this, Yes, that is another issue, Will fix those in 
next spin.

--srini

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

* Re: (subset) [PATCH 00/16] ASoC: codecs: qcom fix validation failures
  2022-02-22 11:59 ` Srinivas Kandagatla
@ 2022-02-23  4:08   ` Mark Brown
  -1 siblings, 0 replies; 44+ messages in thread
From: Mark Brown @ 2022-02-23  4:08 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: alsa-devel, perex, tiwai, quic_srivasam, lgirdwood, linux-kernel,
	pierre-louis.bossart

On Tue, 22 Feb 2022 11:59:17 +0000, Srinivas Kandagatla wrote:
> Thanks for pointing out to mixer kselftest and VALIDATION Kconfig.
> 
> This patchset addresses some of the issues in Qualcomm codecs that are
> discovered with recent mixer kselftest and validations added to ASoC.
> 
> Mostly these are under
> 1. accessing integer value type for enum controls, which is clearly an array out of bounds access.
> 2. Fix incorrect ranges.
> 3. Fix incorrect min max for tlv controls. (I can see that other codecs also suffer same issue)
> 4. Fix return values for put functions.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-linus

Thanks!

[01/16] ASoC: codecs: rx-macro: fix accessing compander for aux
        commit: 42c709c4e1ce4c136891530646c9abd5dff3524f
[02/16] ASoC: codecs: rx-macro: fix accessing array out of bounds for enum type
        commit: bcfe5f76cc4051ea3f9eb5d2c8ea621641f290a5
[04/16] ASoC: codecs: va-macro: fix accessing array out of bounds for enum type
        commit: 0ea5eff7c6063a8f124188424f8e4c6727f35051
[06/16] ASoC: codecs: wc938x: fix accessing array out of bounds for enum type
        commit: cc587b7c8fbbe128f6bd0dad025a0caea5e6d164
[07/16] ASoC: codecs: wcd938x: fix kcontrol max values
        commit: b0217519236924f77a8382b4004e43ef8fd0dcbb
[08/16] ASoC: codecs: wcd934x: fix kcontrol max values
        commit: 61163c3e7480106804269182e24db05244866493

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

* Re: (subset) [PATCH 00/16] ASoC: codecs: qcom fix validation failures
@ 2022-02-23  4:08   ` Mark Brown
  0 siblings, 0 replies; 44+ messages in thread
From: Mark Brown @ 2022-02-23  4:08 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: pierre-louis.bossart, alsa-devel, linux-kernel, lgirdwood, tiwai,
	quic_srivasam

On Tue, 22 Feb 2022 11:59:17 +0000, Srinivas Kandagatla wrote:
> Thanks for pointing out to mixer kselftest and VALIDATION Kconfig.
> 
> This patchset addresses some of the issues in Qualcomm codecs that are
> discovered with recent mixer kselftest and validations added to ASoC.
> 
> Mostly these are under
> 1. accessing integer value type for enum controls, which is clearly an array out of bounds access.
> 2. Fix incorrect ranges.
> 3. Fix incorrect min max for tlv controls. (I can see that other codecs also suffer same issue)
> 4. Fix return values for put functions.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-linus

Thanks!

[01/16] ASoC: codecs: rx-macro: fix accessing compander for aux
        commit: 42c709c4e1ce4c136891530646c9abd5dff3524f
[02/16] ASoC: codecs: rx-macro: fix accessing array out of bounds for enum type
        commit: bcfe5f76cc4051ea3f9eb5d2c8ea621641f290a5
[04/16] ASoC: codecs: va-macro: fix accessing array out of bounds for enum type
        commit: 0ea5eff7c6063a8f124188424f8e4c6727f35051
[06/16] ASoC: codecs: wc938x: fix accessing array out of bounds for enum type
        commit: cc587b7c8fbbe128f6bd0dad025a0caea5e6d164
[07/16] ASoC: codecs: wcd938x: fix kcontrol max values
        commit: b0217519236924f77a8382b4004e43ef8fd0dcbb
[08/16] ASoC: codecs: wcd934x: fix kcontrol max values
        commit: 61163c3e7480106804269182e24db05244866493

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

end of thread, other threads:[~2022-02-23  4:09 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 11:59 [PATCH 00/16] ASoC: codecs: qcom fix validation failures Srinivas Kandagatla
2022-02-22 11:59 ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 01/16] ASoC: codecs: rx-macro: fix accessing compander for aux Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 02/16] ASoC: codecs: rx-macro: fix accessing array out of bounds for enum type Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 03/16] ASoC: codecs: tx-macro: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 04/16] ASoC: codecs: va-macro: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 05/16] ASoC: codecs: wsa-macro: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 06/16] ASoC: codecs: wc938x: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 07/16] ASoC: codecs: wcd938x: fix kcontrol max values Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 08/16] ASoC: codecs: wcd934x: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 09/16] ASoC: codecs: wcd934x: fix return value of wcd934x_rx_hph_mode_put Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 17:54   ` Mark Brown
2022-02-22 17:54     ` Mark Brown
2022-02-22 18:22     ` Srinivas Kandagatla
2022-02-22 18:22       ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 10/16] ASoC: codecs: rx-macro: fix tlv min max range Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 18:04   ` Mark Brown
2022-02-22 18:04     ` Mark Brown
2022-02-22 18:21     ` Srinivas Kandagatla
2022-02-22 18:21       ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 11/16] ASoC: codecs: tx-macro: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 12/16] ASoC: codecs: va-macro: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 13/16] ASoC: codecs: wsa-macro: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 14/16] ASoC: codecs: wcd938x: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 15/16] ASoC: codecs: wcd9335: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-22 11:59 ` [PATCH 16/16] ASoC: codecs: msm8916-wcd-digital: " Srinivas Kandagatla
2022-02-22 11:59   ` Srinivas Kandagatla
2022-02-23  4:08 ` (subset) [PATCH 00/16] ASoC: codecs: qcom fix validation failures Mark Brown
2022-02-23  4:08   ` 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.