ASoC: dapm: Fix snd_soc_dapm_put_volsw() connect
PATCH 1/1 ASoC: dapm: Fix snd_soc_dapm_put_volsw() connect
snd_soc_dapm_put_volsw() sets connect incorrectly in the case max > 1 with invert. In that case, the raw disconnect value should be max, which corresponds to the userspace value 0.
This use case currently does not appear upstream, but it could break SOC_DAPM_SINGLE() or SOC_DAPM_SINGLE_TLV() elsewhere or in the future.
--- .../sound/soc/soc-dapm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
sound/soc/soc-dapm.c +1 -7
@@ -2515,19 +2515,13 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,int wi; val = (ucontrol->value.integer.value[0 ] & mask); + connect = !!val;if (invert) val = max - val; mask = mask << shift; val = val << shift; -if (val) -/* new connection */ - connect = invert ?0 :1 ; -else -/* old connection must be powered down */ - connect = invert ?1 :0 ; -mutex_lock_nested (&card->dapm_mutex,SND_SOC_DAPM_CLASS_RUNTIME ); change =snd_soc_test_bits (widget->codec, reg, mask, val);
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
AppliedQuoted 3 lines · Benoît Thébaudeau
snd_soc_dapm_put_volsw()sets connect incorrectly in the case max > 1 with invert. In that case, the raw disconnect value should be max, which corresponds to the userspace value 0.
Applied, thanks.
At Mon, 18 Jun 2012 22:41:28 +0200 (CEST),
Quoted 28 lines · Benoît Thébaudeau
snd_soc_dapm_put_volsw()sets connect incorrectly in the case max > 1 with invert. In that case, the raw disconnect value should be max, which corresponds to the userspace value 0.This use case currently does not appear upstream, but it could break
SOC_DAPM_SINGLE()orSOC_DAPM_SINGLE_TLV()elsewhere or in the future.Cc Liam Girdwood <[email protected]>Cc Mark Brown <[email protected]>Cc <[email protected]>Signed-off-by Benoît Thébaudeau <[email protected]>--- .../sound/soc/soc-dapm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)sound/soc/soc-dapm.c +1
-0@@ -2515,19 +2515,13 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,int wi; val = (ucontrol->value.integer.value[0 ] & mask); + connect = !!val;if (invert) val = max - val;
sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, · line 2530
Quoted 10 lines
sound/soc/soc-dapm.c +0
-7mask = mask << shift; val = val << shift; -if (val) -/* new connection */ - connect = invert ?0 :1 ; -else -/* old connection must be powered down */ - connect = invert ?1 :0 ; -
Doesn't this result in the same value of connect?
(given value, invert) --> (raw value, connect)
old code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0)
(max, 0) -> (max, 1)
(max, 1) -> (0, 1)new code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0)
(max, 0) --> (max, 1)
(max, 1) --> (0, 1)I'd understand if the line "connect = !!val;" were after the invert conversion...
if (invert)
val = max - val; connect = !!val;
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 1 line · Takashi Iwai
Doesn't this result in the same value of connect?
If nothing else it's a massive readability improvement... I've pulled the change over to 3.6 for now, I need to rush out the door right now and probably won't be able to do anything else for the rest of today.
At Fri, 29 Jun 2012 08:23:18 +0100,
Quoted 6 lines · Mark Brown
Quoted 1 line · Takashi Iwai
Doesn't this result in the same value of connect?
If nothing else it's a massive readability improvement...
Yeah, but it's a very secret bonus, not what the changelog says :)
Quoted 3 lines
I've pulled
the change over to 3.6 for now, I need to rush out the door right now and probably won't be able to do anything else for the rest of today.
OK.
thanks,
Takashi
Quoted 61 lines · Takashi Iwai
At Mon, 18 Jun 2012 22:41:28 +0200 (CEST),
Quoted 34 lines · Benoît Thébaudeau
snd_soc_dapm_put_volsw()sets connect incorrectly in the case max > 1 with
invert. In that case, the raw disconnect value should be max, which corresponds
to the userspace value 0.This use case currently does not appear upstream, but it could break
SOC_DAPM_SINGLE()orSOC_DAPM_SINGLE_TLV()elsewhere or in the future.Cc Liam Girdwood <[email protected]>Cc Mark Brown <[email protected]>Cc <[email protected]>Signed-off-by Benoît Thébaudeau <[email protected]>--- .../sound/soc/soc-dapm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)(quoted diff) +0
-0
linux-next-HEAD-6c86b58/sound/soc/soc-dapm.c
index 405841c..5ef082f 100644sound/soc/soc-dapm.c +1
-0@@ -2515,19 +2515,13 @@ int snd_soc_dapm_put_volsw(structsnd_kcontrol *kcontrol, int wi; val = (ucontrol->value.integer.value[0 ] & mask); + connect = !!val;if (invert) val = max - val;sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct · line 2531
Quoted 10 lines
sound/soc/soc-dapm.c +0
-7mask = mask << shift; val = val << shift; -if (val) -/* new connection */ - connect = invert ?0 :1 ; -else -/* old connection must be powered down */ - connect = invert ?1 :0 ; -Doesn't this result in the same value of connect?
(given value, invert) --> (raw value, connect)
old code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) -> (max, 1) (max, 1) -> (0, 1)new code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) --> (max, 1) (max, 1) --> (0, 1)
Quoted 6 lines
I'd understand if the line "connect = !!val;" were after the invert conversion...
if (invert)
val = max - val; connect = !!val;
Take max = 5, invert = 1, user val = 2:
old code: connect = 0
new code: connect = 1
Regards,
Benoît
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Fri, 29 Jun 2012 13:53:56 +0200 (CEST),
Quoted 66 lines · Benoît Thébaudeau
Quoted 64 lines · Takashi Iwai
At Mon, 18 Jun 2012 22:41:28 +0200 (CEST),
Quoted 34 lines · Benoît Thébaudeau
snd_soc_dapm_put_volsw()sets connect incorrectly in the case max > 1 with
invert. In that case, the raw disconnect value should be max, which corresponds
to the userspace value 0.This use case currently does not appear upstream, but it could break
SOC_DAPM_SINGLE()orSOC_DAPM_SINGLE_TLV()elsewhere or in the future.Cc Liam Girdwood <[email protected]>Cc Mark Brown <[email protected]>Cc <[email protected]>Signed-off-by Benoît Thébaudeau <[email protected]>--- .../sound/soc/soc-dapm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)(quoted diff) +0
-0
linux-next-HEAD-6c86b58/sound/soc/soc-dapm.c
index 405841c..5ef082f 100644sound/soc/soc-dapm.c +1
-0@@ -2515,19 +2515,13 @@ int snd_soc_dapm_put_volsw(structsnd_kcontrol *kcontrol, int wi; val = (ucontrol->value.integer.value[0 ] & mask); + connect = !!val;if (invert) val = max - val;sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct · line 2531
Quoted 10 lines
sound/soc/soc-dapm.c +0
-7mask = mask << shift; val = val << shift; -if (val) -/* new connection */ - connect = invert ?0 :1 ; -else -/* old connection must be powered down */ - connect = invert ?1 :0 ; -Doesn't this result in the same value of connect?
(given value, invert) --> (raw value, connect)
old code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) -> (max, 1) (max, 1) -> (0, 1)new code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) --> (max, 1) (max, 1) --> (0, 1)I'd understand if the line "connect = !!val;" were after the invert conversion...
Quoted 7 lines
Quoted 3 lines
if (invert)
val = max - val; connect = !!val;Take max = 5, invert = 1, user val = 2:
old code: connect = 0
new code: connect = 1
OK, then you need to fix dapm_set_path_status() as well, too. Otherwise the logic becomes inconsistent.
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 77 lines · Takashi Iwai
At Fri, 29 Jun 2012 13:53:56 +0200 (CEST),
Quoted 75 lines · Benoît Thébaudeau
Quoted 72 lines · Takashi Iwai
At Mon, 18 Jun 2012 22:41:28 +0200 (CEST),
Quoted 38 lines · Benoît Thébaudeau
snd_soc_dapm_put_volsw()sets connect incorrectly in the case max >
1 with
invert. In that case, the raw disconnect value should be max, which
corresponds
to the userspace value 0.This use case currently does not appear upstream, but it could break
SOC_DAPM_SINGLE()orSOC_DAPM_SINGLE_TLV()elsewhere or in the future.Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: <[email protected]>
Signed-off-by: Benoît Thébaudeau <[email protected]>--- .../sound/soc/soc-dapm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)(quoted diff) +0
-0
linux-next-HEAD-6c86b58/sound/soc/soc-dapm.c
index 405841c..5ef082f 100644sound/soc/soc-dapm.c +1
-0@@ -2515,19 +2515,13 @@ int snd_soc_dapm_put_volsw(structsnd_kcontrol *kcontrol, int wi; val = (ucontrol->value.integer.value[0 ] & mask); + connect = !!val;if (invert) val = max - val;sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct · line 2531
Quoted 10 lines
sound/soc/soc-dapm.c +0
-7mask = mask << shift; val = val << shift; -if (val) -/* new connection */ - connect = invert ?0 :1 ; -else -/* old connection must be powered down */ - connect = invert ?1 :0 ; -Doesn't this result in the same value of connect?
(given value, invert) --> (raw value, connect)
old code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) -> (max, 1) (max, 1) -> (0, 1)new code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) --> (max, 1) (max, 1) --> (0, 1)I'd understand if the line "connect = !!val;" were after the invert
conversion...if (invert)
val = max - val; connect = !!val;
Quoted 6 lines
Quoted 3 lines
Take max = 5, invert = 1, user val = 2:
old code: connect = 0
new code: connect = 1OK, then you need to fix
dapm_set_path_status()as well, too. Otherwise the logic becomes inconsistent.
Indeed, I missed that. But the issue is even worse in this function: It uses the control register value to determine if connect should be set while only the userspace value can tell that, and it has no way of deriving the userspace value apart from calling the get function, while here it assumes that the register value will be more or less compatible with snd_soc_dapm_get_volsw.
Hence, I think that the fix here should be to call get, then to deduce connect from the returned value. Do you agree?
Regards,
Benoît
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Fri, 29 Jun 2012 16:29:22 +0200 (CEST),
Quoted 83 lines · Benoît Thébaudeau
Quoted 81 lines · Takashi Iwai
At Fri, 29 Jun 2012 13:53:56 +0200 (CEST),
Quoted 78 lines · Benoît Thébaudeau
Quoted 65 lines · Takashi Iwai
At Mon, 18 Jun 2012 22:41:28 +0200 (CEST),
Quoted 38 lines · Benoît Thébaudeau
snd_soc_dapm_put_volsw()sets connect incorrectly in the case max >
1 with
invert. In that case, the raw disconnect value should be max, which
corresponds
to the userspace value 0.This use case currently does not appear upstream, but it could break
SOC_DAPM_SINGLE()orSOC_DAPM_SINGLE_TLV()elsewhere or in the future.Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: <[email protected]>
Signed-off-by: Benoît Thébaudeau <[email protected]>--- .../sound/soc/soc-dapm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)(quoted diff) +0
-0
linux-next-HEAD-6c86b58/sound/soc/soc-dapm.c
index 405841c..5ef082f 100644sound/soc/soc-dapm.c +1
-0@@ -2515,19 +2515,13 @@ int snd_soc_dapm_put_volsw(structsnd_kcontrol *kcontrol, int wi; val = (ucontrol->value.integer.value[0 ] & mask); + connect = !!val;if (invert) val = max - val;sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct · line 2531
Quoted 10 lines
sound/soc/soc-dapm.c +0
-7mask = mask << shift; val = val << shift; -if (val) -/* new connection */ - connect = invert ?0 :1 ; -else -/* old connection must be powered down */ - connect = invert ?1 :0 ; -Doesn't this result in the same value of connect?
(given value, invert) --> (raw value, connect)
old code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) -> (max, 1) (max, 1) -> (0, 1)new code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) --> (max, 1) (max, 1) --> (0, 1)Quoted 7 lines
I'd understand if the line "connect = !!val;" were after the invert
conversion...if (invert)
val = max - val; connect = !!val;Take max = 5, invert = 1, user val = 2:
old code: connect = 0
new code: connect = 1
Quoted 8 lines
Quoted 2 lines
OK, then you need to fix
dapm_set_path_status()as well, too. Otherwise the logic becomes inconsistent.Indeed, I missed that. But the issue is even worse in this function: It uses the control register value to determine if connect should be set while only the userspace value can tell that, and it has no way of deriving the userspace value apart from calling the get function, while here it assumes that the register value will be more or less compatible with
snd_soc_dapm_get_volsw.
That's a valid assumption. Usually get and put callbacks must be paired well.
Quoted 2 lines
Hence, I think that the fix here should be to call get, then to deduce connect from the returned value. Do you agree?
Well, calling a control callback internally is a bit worrisome.
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Fri, 29 Jun 2012 17:43:09 +0200,
Quoted 95 lines · Takashi Iwai
At Fri, 29 Jun 2012 16:29:22 +0200 (CEST),
Quoted 83 lines · Benoît Thébaudeau
Quoted 81 lines · Takashi Iwai
At Fri, 29 Jun 2012 13:53:56 +0200 (CEST),
Quoted 78 lines · Benoît Thébaudeau
Quoted 65 lines · Takashi Iwai
At Mon, 18 Jun 2012 22:41:28 +0200 (CEST),
Quoted 38 lines · Benoît Thébaudeau
snd_soc_dapm_put_volsw()sets connect incorrectly in the case max >
1 with
invert. In that case, the raw disconnect value should be max, which
corresponds
to the userspace value 0.This use case currently does not appear upstream, but it could break
SOC_DAPM_SINGLE()orSOC_DAPM_SINGLE_TLV()elsewhere or in the future.Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: <[email protected]>
Signed-off-by: Benoît Thébaudeau <[email protected]>--- .../sound/soc/soc-dapm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)(quoted diff) +0
-0
linux-next-HEAD-6c86b58/sound/soc/soc-dapm.c
index 405841c..5ef082f 100644sound/soc/soc-dapm.c +1
-0@@ -2515,19 +2515,13 @@ int snd_soc_dapm_put_volsw(structsnd_kcontrol *kcontrol, int wi; val = (ucontrol->value.integer.value[0 ] & mask); + connect = !!val;if (invert) val = max - val;sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct · line 2531
Quoted 10 lines
sound/soc/soc-dapm.c +0
-7mask = mask << shift; val = val << shift; -if (val) -/* new connection */ - connect = invert ?0 :1 ; -else -/* old connection must be powered down */ - connect = invert ?1 :0 ; -Doesn't this result in the same value of connect?
(given value, invert) --> (raw value, connect)
old code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) -> (max, 1) (max, 1) -> (0, 1)new code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) --> (max, 1) (max, 1) --> (0, 1)Quoted 7 lines
I'd understand if the line "connect = !!val;" were after the invert
conversion...if (invert)
val = max - val; connect = !!val;Take max = 5, invert = 1, user val = 2:
old code: connect = 0
new code: connect = 1Quoted 8 lines
Quoted 2 lines
OK, then you need to fix
dapm_set_path_status()as well, too. Otherwise the logic becomes inconsistent.Indeed, I missed that. But the issue is even worse in this function: It uses the control register value to determine if connect should be set while only the userspace value can tell that, and it has no way of deriving the userspace value apart from calling the get function, while here it assumes that the register value will be more or less compatible with
snd_soc_dapm_get_volsw.
Quoted 7 lines
That's a valid assumption. Usually get and put callbacks must be paired well.
Quoted 2 lines
Hence, I think that the fix here should be to call get, then to deduce connect from the returned value. Do you agree?
Well, calling a control callback internally is a bit worrisome.
BTW, looking at snd_soc_dapm_vol_getsw(), I found that snd_soc_dapm_vol_putsw() doesn't handle a stereo case. This needs a fix, too...
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 3 lines · Takashi Iwai
BTW, looking at
snd_soc_dapm_vol_getsw(), I found thatsnd_soc_dapm_vol_putsw()doesn't handle a stereo case. This needs a fix, too...
I saw that too. Is it the stereo case that should be added to put or removed from get, i.e. is it possible to handle a stereo case with only one connect flag?
Regards,
Benoît
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Fri, 29 Jun 2012 18:09:35 +0200 (CEST),
Quoted 9 lines · Benoît Thébaudeau
Quoted 3 lines · Takashi Iwai
BTW, looking at
snd_soc_dapm_vol_getsw(), I found thatsnd_soc_dapm_vol_putsw()doesn't handle a stereo case. This needs a fix, too...I saw that too. Is it the stereo case that should be added to put or removed from get, i.e. is it possible to handle a stereo case with only one connect flag?
I would assume that connect should be up when either left or right is on. A stereo widget doesn't mean multiple connections.
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 8 lines · Takashi Iwai
At Fri, 29 Jun 2012 18:09:35 +0200 (CEST),
Quoted 6 lines · Benoît Thébaudeau
Quoted 3 lines · Takashi Iwai
BTW, looking at
snd_soc_dapm_vol_getsw(), I found thatsnd_soc_dapm_vol_putsw()doesn't handle a stereo case. This needs a fix, too...
Quoted 8 lines
Quoted 5 lines
I saw that too. Is it the stereo case that should be added to put or removed
from get, i.e. is it possible to handle a stereo case with only one connect
flag?I would assume that connect should be up when either left or right is on. A stereo widget doesn't mean multiple connections.
I have started to look into that:
- Give a choice between reg and shift stereo for snd_soc_dapm_get_volsw(), like in snd_soc_get_volsw().
- Add stereo to the first case of dapm_set_path_status().
- Add stereo to dapm_widget_update() and struct snd_soc_dapm_update.
- Then comes snd_soc_dapm_get_volsw(): What should we do with "widget->value = val;"? Add an rvalue to struct snd_soc_dapm_widget? This field does not seem to be read anywhere except for enums. There is also saved_value and other fields that do not seem to be used anywhere.
Regards,
Benoît
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 20 lines · Benoît Thébaudeau
Quoted 15 lines · Takashi Iwai
At Fri, 29 Jun 2012 18:09:35 +0200 (CEST),
Quoted 6 lines · Benoît Thébaudeau
Quoted 3 lines · Takashi Iwai
BTW, looking at
snd_soc_dapm_vol_getsw(), I found thatsnd_soc_dapm_vol_putsw()doesn't handle a stereo case. This needs a fix, too...Quoted 6 lines
I saw that too. Is it the stereo case that should be added to put or removed
from get, i.e. is it possible to handle a stereo case with only one
connect
flag?Quoted 3 lines
I would assume that connect should be up when either left or right is
on. A stereo widget doesn't mean multiple connections.
Quoted 12 lines
I have started to look into that:
- Give a choice between reg and shift stereo forsnd_soc_dapm_get_volsw(), like
insnd_soc_get_volsw().
- Add stereo to the first case ofdapm_set_path_status().
- Add stereo todapm_widget_update()and structsnd_soc_dapm_update.
- Then comessnd_soc_dapm_get_volsw(): What should we do with "widget->value= val;"? Add an rvalue to structsnd_soc_dapm_widget? This
field does not seem to be read anywhere except for enums. There is also
saved_valueand other fields that do not seem to be used anywhere.
I've finished. The following patch should be applied after my patch "ASoC: dapm: Fix dapm_set_path_status() connect".
Regards,
Benoît
[PATCH] ASoC: dapm: Fix/add support for stereo widgets
This patch:
* adds a choice in snd_soc_dapm_get_volsw_mut() for stereo between 1 and 2 registers, like in snd_soc_get_volsw().
* fixes the missing stereo in other parts of dapm.
* removes the unused saved_value from struct snd_soc_dapm_widget.
--- .../include/sound/soc-dapm.h | 10 +-- .../sound/soc/soc-dapm.c | 92 ++++++++++++++++---- 2 files changed, 82 insertions(+), 20 deletions(-)
include/sound/soc-dapm.h +5 -5
@@ -508,8 +508,8 @@ struct snd_soc_dapm_widget {/* dapm control */ int reg;/* negative reg = no direct dapm */ unsigned char shift;/* bits to shift */ -unsigned int saved_value;/* widget saved value */ -unsigned int value;/* widget current value */ +unsigned int value;/* widget current value */ +unsigned int rvalue;/* widget current value of right channel */ unsigned int mask;/* non-shifted mask */ unsigned int on_val;/* on state value */ unsigned int off_val;/* off state value */
@@ -552,9 +552,9 @@ struct snd_soc_dapm_widget {struct snd_soc_dapm_update {struct snd_soc_dapm_widget *widget;struct snd_kcontrol *kcontrol; -int reg; -int mask; -int val; +int reg, rreg; +int mask, rmask; +int val, rval; };/* DAPM context */
sound/soc/soc-dapm.c +77 -15
172 lines not on this page · raw message
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 2 lines · Benoît Thébaudeau
I've finished. The following patch should be applied after my patch "ASoC: dapm: Fix
dapm_set_path_status()connect".
Don't submit patches in the middle of discussions, but please bear in mind what I just said about not doing stereo.
Quoted 8 lines · Mark Brown
Quoted 2 lines · Benoît Thébaudeau
I've finished. The following patch should be applied after my patch "ASoC: dapm: Fix
dapm_set_path_status()connect".Don't submit patches in the middle of discussions, but please bear in mind what I just said about not doing stereo.
Quoted 6 lines
Actually I'd really expect it to mean exactly that. DAPM is fairly fundamentally dealing with single channel audio streams and I'd expect that if we did implement stereo controls they'd allow these streams to pass through without getting merged. There's a couple of things that stop us doing that right now but I don't think we should add stereo controls that don't do that.
Can you be more specific about what stops us doing that right now?
Should we drop this idea for now and simply remove stereo from snd_soc_dapm_get_volsw()?
Regards,
Benoît
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 10 lines · Benoît Thébaudeau
Quoted 6 lines · Mark Brown
Actually I'd really expect it to mean exactly that. DAPM is fairly fundamentally dealing with single channel audio streams and I'd expect that if we did implement stereo controls they'd allow these streams to pass through without getting merged. There's a couple of things that stop us doing that right now but I don't think we should add stereo controls that don't do that.
Can you be more specific about what stops us doing that right now?
Nothing if someone wants to implement it.
Quoted 2 lines
Should we drop this idea for now and simply remove stereo from
snd_soc_dapm_get_volsw()?
It's going to be easier to remove the code if we're going to do anything at all, though there's no great urgency.
[RFC/PATCH] ASoC: dapm: Fix/add support for stereo widgets
This patch:
* adds a choice in snd_soc_dapm_get_volsw_mut() for stereo between 1 and 2 registers, like in snd_soc_get_volsw().
* fixes the missing stereo in other parts of dapm.
* removes the unused saved_value from struct snd_soc_dapm_widget.
--- .../include/sound/soc-dapm.h | 10 +-- .../sound/soc/soc-dapm.c | 92 ++++++++++++++++---- 2 files changed, 82 insertions(+), 20 deletions(-)
include/sound/soc-dapm.h +5 -5
@@ -508,8 +508,8 @@ struct snd_soc_dapm_widget {/* dapm control */ int reg;/* negative reg = no direct dapm */ unsigned char shift;/* bits to shift */ -unsigned int saved_value;/* widget saved value */ -unsigned int value;/* widget current value */ +unsigned int value;/* widget current value */ +unsigned int rvalue;/* widget current value of right channel */ unsigned int mask;/* non-shifted mask */ unsigned int on_val;/* on state value */ unsigned int off_val;/* off state value */
@@ -552,9 +552,9 @@ struct snd_soc_dapm_widget {struct snd_soc_dapm_update {struct snd_soc_dapm_widget *widget;struct snd_kcontrol *kcontrol; -int reg; -int mask; -int val; +int reg, rreg; +int mask, rmask; +int val, rval; };/* DAPM context */
sound/soc/soc-dapm.c +77 -15
172 lines not on this page · raw message
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [RFC/PATCH] ASoC: dapm: Fix/add support for stereo widgets
Quoted 5 lines · Benoît Thébaudeau
This patch:
* adds a choice insnd_soc_dapm_get_volsw_mut()for stereo between 1 and 2 registers, like insnd_soc_get_volsw().
* fixes the missing stereo in other parts of dapm.
* removes the unusedsaved_valuefrom structsnd_soc_dapm_widget.
There's a couple of high level problems here.
One is that you've got multiple different things in a single commit which isn't great practice for review, especially with such a vauge changelog.
The other is that while you say that this "fixes the missing stereo in other parts of dapm" I can't see any sign of any changes to (for example) the path setup code which would seem to be essential for supporting more than one channel in controls.
At Sat, 30 Jun 2012 19:24:47 +0100,
Quoted 13 lines · Mark Brown
Quoted 10 lines · Benoît Thébaudeau
Quoted 6 lines · Mark Brown
Actually I'd really expect it to mean exactly that. DAPM is fairly fundamentally dealing with single channel audio streams and I'd expect that if we did implement stereo controls they'd allow these streams to pass through without getting merged. There's a couple of things that stop us doing that right now but I don't think we should add stereo controls that don't do that.
Can you be more specific about what stops us doing that right now?
Quoted 7 lines
Nothing if someone wants to implement it.
Quoted 2 lines
Should we drop this idea for now and simply remove stereo from
snd_soc_dapm_get_volsw()?It's going to be easier to remove the code if we're going to do anything at all, though there's no great urgency.
Then it'd be also better to put a sanity check to warn if snd_soc_volsw_is_stereo() returns true.
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 8 lines · Takashi Iwai
Quoted 3 lines · Benoît Thébaudeau
I saw that too. Is it the stereo case that should be added to put or removed from get, i.e. is it possible to handle a stereo case with only one connect flag?
I would assume that connect should be up when either left or right is on. A stereo widget doesn't mean multiple connections.
Actually I'd really expect it to mean exactly that. DAPM is fairly fundamentally dealing with single channel audio streams and I'd expect that if we did implement stereo controls they'd allow these streams to pass through without getting merged. There's a couple of things that stop us doing that right now but I don't think we should add stereo controls that don't do that.
Quoted 103 lines · Takashi Iwai
At Fri, 29 Jun 2012 16:29:22 +0200 (CEST),
Quoted 91 lines · Benoît Thébaudeau
Quoted 82 lines · Takashi Iwai
At Fri, 29 Jun 2012 13:53:56 +0200 (CEST),
Quoted 80 lines · Benoît Thébaudeau
Quoted 77 lines · Takashi Iwai
At Mon, 18 Jun 2012 22:41:28 +0200 (CEST),
Quoted 43 lines · Benoît Thébaudeau
snd_soc_dapm_put_volsw()sets connect incorrectly in the case
max >
1 with
invert. In that case, the raw disconnect value should be max,
which
corresponds
to the userspace value 0.This use case currently does not appear upstream, but it could
breakSOC_DAPM_SINGLE()orSOC_DAPM_SINGLE_TLV()elsewhere or in the
future.Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: <[email protected]>
Signed-off-by: Benoît Thébaudeau <[email protected]>--- .../sound/soc/soc-dapm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)diff --git
linux-next-HEAD-6c86b58.orig/sound/soc/soc-dapm.clinux-next-HEAD-6c86b58/sound/soc/soc-dapm.c
index 405841c..5ef082f 100644sound/soc/soc-dapm.c +1
-0@@ -2515,19 +2515,13 @@ int snd_soc_dapm_put_volsw(structsnd_kcontrol *kcontrol, int wi; val = (ucontrol->value.integer.value[0 ] & mask); + connect = !!val;if (invert) val = max - val;sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct · line 2531
Quoted 10 lines
sound/soc/soc-dapm.c +0
-7mask = mask << shift; val = val << shift; -if (val) -/* new connection */ - connect = invert ?0 :1 ; -else -/* old connection must be powered down */ - connect = invert ?1 :0 ; -Doesn't this result in the same value of connect?
(given value, invert) --> (raw value, connect)
old code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) -> (max, 1) (max, 1) -> (0, 1)new code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) --> (max, 1) (max, 1) --> (0, 1)I'd understand if the line "connect = !!val;" were after the invert
conversion...if (invert)
val = max - val; connect = !!val;Quoted 6 lines
Quoted 3 lines
Take max = 5, invert = 1, user val = 2:
old code: connect = 0
new code: connect = 1OK, then you need to fix
dapm_set_path_status()as well, too. Otherwise the logic becomes inconsistent.Quoted 9 lines
Indeed, I missed that. But the issue is even worse in this
function: It uses the
control register value to determine if connect should be set while only the
userspace value can tell that, and it has no way of deriving the userspace value
apart from calling the get function, while here it assumes that the register
value will be more or less compatible withsnd_soc_dapm_get_volsw.
Quoted 2 lines
That's a valid assumption. Usually get and put callbacks must be paired well.
Yes, except that some codec drivers customize these callbacks for specific register encodings (e.g. snd_soc_dapm_put_volsw_aic3x). By chance, only the put callbacks seem to have been customized so far.
What is the point of having customizable get/put callbacks if dapm_set_path_status() ignores them and duplicates their core behavior?
In the aic3x example, the bit-field is actually a mixer volume control, and not only a boolean, so I was planning to post a fix for that. The issue is that the encoding of register values for this volume has holes that should not be duplicated in userspace raw values, so custom get and put callbacks have to be used here that will not be compatible with snd_soc_dapm_get_volsw(), which will be blocking for dapm_set_path_status(). Do you have a simple solution for that?
Quoted 5 lines
Quoted 3 lines
Hence, I think that the fix here should be to call get, then to deduce connect
from the returned value. Do you agree?Well, calling a control callback internally is a bit worrisome.
Yes, and there is another issue: kcontrol may not be available for get at this point.
In the meantime, please find below a quick patch for the consistency issue.
Regards,
Benoît
[PATCH] ASoC: dapm: Fix dapm_set_path_status() connect
dapm_set_path_status() sets connect incorrectly in the case max > 1 with invert. In that case, the raw disconnect value should be max, which corresponds to the userspace value 0.
This use case currently does not appear upstream, but it could break SOC_DAPM_SINGLE() or SOC_DAPM_SINGLE_TLV() elsewhere or in the future.
This patch completes commit 3a9abe8.
--- .../sound/soc/soc-dapm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/soc-dapm.c +3 -4
@@ -324,11 +324,10 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, val =soc_widget_read (w, reg); val = (val >> shift) & mask; +if (invert) + val = max - val; -if ((invert && !val) || (!invert && val)) - p->connect =1 ; -else - p->connect =0 ; + p->connect = !!val; }break ;case snd_soc_dapm_mux: {
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Fri, 29 Jun 2012 18:05:44 +0200 (CEST),
Quoted 105 lines · Benoît Thébaudeau
Quoted 103 lines · Takashi Iwai
At Fri, 29 Jun 2012 16:29:22 +0200 (CEST),
Quoted 100 lines · Benoît Thébaudeau
Quoted 82 lines · Takashi Iwai
At Fri, 29 Jun 2012 13:53:56 +0200 (CEST),
Quoted 80 lines · Benoît Thébaudeau
Quoted 77 lines · Takashi Iwai
At Mon, 18 Jun 2012 22:41:28 +0200 (CEST),
Quoted 43 lines · Benoît Thébaudeau
snd_soc_dapm_put_volsw()sets connect incorrectly in the case
max >
1 with
invert. In that case, the raw disconnect value should be max,
which
corresponds
to the userspace value 0.This use case currently does not appear upstream, but it could
breakSOC_DAPM_SINGLE()orSOC_DAPM_SINGLE_TLV()elsewhere or in the
future.Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: <[email protected]>
Signed-off-by: Benoît Thébaudeau <[email protected]>--- .../sound/soc/soc-dapm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)diff --git
linux-next-HEAD-6c86b58.orig/sound/soc/soc-dapm.clinux-next-HEAD-6c86b58/sound/soc/soc-dapm.c
index 405841c..5ef082f 100644sound/soc/soc-dapm.c +1
-0@@ -2515,19 +2515,13 @@ int snd_soc_dapm_put_volsw(structsnd_kcontrol *kcontrol, int wi; val = (ucontrol->value.integer.value[0 ] & mask); + connect = !!val;if (invert) val = max - val;sound/soc/soc-dapm.c int snd_soc_dapm_put_volsw(struct · line 2531
Quoted 10 lines
sound/soc/soc-dapm.c +0
-7mask = mask << shift; val = val << shift; -if (val) -/* new connection */ - connect = invert ?0 :1 ; -else -/* old connection must be powered down */ - connect = invert ?1 :0 ; -Doesn't this result in the same value of connect?
(given value, invert) --> (raw value, connect)
old code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) -> (max, 1) (max, 1) -> (0, 1)new code: (0, 0) --> (0, 0)
(0, 1) --> (max, 0) (max, 0) --> (max, 1) (max, 1) --> (0, 1)I'd understand if the line "connect = !!val;" were after the invert
conversion...if (invert)
val = max - val; connect = !!val;Quoted 6 lines
Quoted 3 lines
Take max = 5, invert = 1, user val = 2:
old code: connect = 0
new code: connect = 1OK, then you need to fix
dapm_set_path_status()as well, too. Otherwise the logic becomes inconsistent.Indeed, I missed that. But the issue is even worse in this
function: It uses the
control register value to determine if connect should be set while only the
userspace value can tell that, and it has no way of deriving the userspace value
apart from calling the get function, while here it assumes that the register
value will be more or less compatible withsnd_soc_dapm_get_volsw.
Quoted 6 lines
Quoted 2 lines
That's a valid assumption. Usually get and put callbacks must be paired well.
Yes, except that some codec drivers customize these callbacks for specific register encodings (e.g.
snd_soc_dapm_put_volsw_aic3x). By chance, only the put callbacks seem to have been customized so far.
Hm, that's bad.
Quoted 2 lines
What is the point of having customizable get/put callbacks if
dapm_set_path_status()ignores them and duplicates their core behavior?
It's a design flaw :)
Quoted 6 lines
In the aic3x example, the bit-field is actually a mixer volume control, and not only a boolean, so I was planning to post a fix for that. The issue is that the encoding of register values for this volume has holes that should not be duplicated in userspace raw values, so custom get and put callbacks have to be used here that will not be compatible with
snd_soc_dapm_get_volsw(), which will be blocking fordapm_set_path_status(). Do you have a simple solution for that?
One option is to create a new hook in struct soc_mixer_control or whatever, e.g.
int (*connect_update)(struct soc_mixer_control *mc);
that returns the connect value.
Then give the own callback when you set the customized get/put things that are incompatible with the default one.
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
Hence, I think that the fix here should be to call get, then to deduce connect
from the returned value. Do you agree?Well, calling a control callback internally is a bit worrisome.
Yes, and there is another issue: kcontrol may not be available for get at this point.
In the meantime, please find below a quick patch for the consistency issue.
Looks good to me.
Takashi
Quoted 34 lines
Regards,
Benoît[PATCH] ASoC: dapm: Fix
dapm_set_path_status()connect
dapm_set_path_status()sets connect incorrectly in the case max > 1 with invert. In that case, the raw disconnect value should be max, which corresponds to the userspace value 0.This use case currently does not appear upstream, but it could break
SOC_DAPM_SINGLE()orSOC_DAPM_SINGLE_TLV()elsewhere or in the future.This patch completes commit 3a9abe8.
Cc Liam Girdwood <[email protected]>Cc Mark Brown <[email protected]>Cc <[email protected]>Signed-off-by Benoît Thébaudeau <[email protected]>--- .../sound/soc/soc-dapm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)sound/soc/soc-dapm.c +1
-0@@ -324,11 +324,10 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, val =soc_widget_read (w, reg); val = (val >> shift) & mask; +if (invert)
sound/soc/soc-dapm.c static void dapm_set_path_status(struct snd_soc_dapm_widget *w, · line 333
Quoted 10 lines
sound/soc/soc-dapm.c +2
-4+ val = max - val; -if ((invert && !val) || (!invert && val)) - p->connect =1 ; -else - p->connect =0 ; + p->connect = !!val; }break ;case snd_soc_dapm_mux: {
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 7 lines · Benoît Thébaudeau
Quoted 2 lines · Takashi Iwai
That's a valid assumption. Usually get and put callbacks must be paired well.
What is the point of having customizable get/put callbacks if
dapm_set_path_status()ignores them and duplicates their core behavior?
Nobody needed to do that yet.
Quoted 6 lines
In the aic3x example, the bit-field is actually a mixer volume control, and not only a boolean, so I was planning to post a fix for that. The issue is that the encoding of register values for this volume has holes that should not be duplicated in userspace raw values, so custom get and put callbacks have to be used here that will not be compatible with
snd_soc_dapm_get_volsw(), which will be blocking fordapm_set_path_status(). Do you have a simple solution for that?
Clearly the driver is just buggy and should implement get for itself too. As far as reading back the path status is concerned so long as the mapping looks OK as a boolean we're fine, it doesn't matter what the individual volumes are as all the code is interested in is on/off.
Quoted 1 line
In the meantime, please find below a quick patch for the consistency issue.
Stop doing this, send patches for review rather than burying them in the middle of e-mails where they're at best a pain to apply.
Quoted 6 lines · Mark Brown
Quoted 2 lines
In the meantime, please find below a quick patch for the consistency issue.
Stop doing this, send patches for review rather than burying them in the
middle of e-mails where they're at best a pain to apply.
OK, I'll repost it separately on Monday.
Regards,
Benoît
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH 1/1 ASoC: dapm: Fix dapm_set_path_status() connect
dapm_set_path_status() sets connect incorrectly in the case max > 1 with invert. In that case, the raw disconnect value should be max, which corresponds to the userspace value 0.
This use case currently does not appear upstream, but it could break SOC_DAPM_SINGLE() or SOC_DAPM_SINGLE_TLV() elsewhere or in the future.
This patch completes commit 3a9abe8.
--- .../sound/soc/soc-dapm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/soc-dapm.c +3 -4
@@ -324,11 +324,10 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, val =soc_widget_read (w, reg); val = (val >> shift) & mask; +if (invert) + val = max - val; -if ((invert && !val) || (!invert && val)) - p->connect =1 ; -else - p->connect =0 ; + p->connect = !!val; }break ;case snd_soc_dapm_mux: {
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
AppliedRe: [PATCH] ASoC: dapm: Fix dapm_set_path_status() connect
Quoted 3 lines · Benoît Thébaudeau
dapm_set_path_status()sets connect incorrectly in the case max > 1 with invert. In that case, the raw disconnect value should be max, which corresponds to the userspace value 0.
Applied, thanks.