alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: dapm: fixup dapm kcontrol widget
       [not found] <CGME20200418041321epcas2p1ceed010fde93a35e763a9db436e1c63b@epcas2p1.samsung.com>
@ 2020-04-18  4:13 ` Gyeongtaek Lee
  2020-04-20 13:36   ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Gyeongtaek Lee @ 2020-04-18  4:13 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, khw0178.kim, kimty, lgirdwood, tiwai, hmseo, tkjung,
	pilsun.jang

snd_soc_dapm_kcontrol widget which is created by autodisable control
should contain correct on_val, mask and shift because it is set when the
widget is powered and changed value is applied on registers by following
code in dapm_seq_run_coalesced().

		mask |= w->mask << w->shift;
		if (w->power)
			value |= w->on_val << w->shift;
		else
			value |= w->off_val << w->shift;

Shift on the mask in dapm_kcontrol_data_alloc() is removed to prevent
double shift.
And, on_val in dapm_kcontrol_set_value() is modified to get correct
value in the dapm_seq_run_coalesced().

Signed-off-by: Gyeongtaek Lee <gt82.lee@samsung.com>
Cc: stable@vger.kernel.org
---
 sound/soc/soc-dapm.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a4143ca190d0..e2632841b321 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -423,7 +423,7 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
 
 			memset(&template, 0, sizeof(template));
 			template.reg = e->reg;
-			template.mask = e->mask << e->shift_l;
+			template.mask = e->mask;
 			template.shift = e->shift_l;
 			template.off_val = snd_soc_enum_item_to_val(e, 0);
 			template.on_val = template.off_val;
@@ -546,8 +546,22 @@ static bool dapm_kcontrol_set_value(const struct snd_kcontrol *kcontrol,
 	if (data->value == value)
 		return false;
 
-	if (data->widget)
-		data->widget->on_val = value;
+	if (data->widget) {
+		switch (dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->id) {
+		case snd_soc_dapm_switch:
+		case snd_soc_dapm_mixer:
+		case snd_soc_dapm_mixer_named_ctl:
+			data->widget->on_val = value & data->widget->mask;
+			break;
+		case snd_soc_dapm_demux:
+		case snd_soc_dapm_mux:
+			data->widget->on_val = value >> data->widget->shift;
+			break;
+		default:
+			data->widget->on_val = value;
+			break;
+		}
+	}
 
 	data->value = value;
 

base-commit: ecdcf8a833d770347115f739a37583cdc6ddbf7a
-- 
2.21.0



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

* Re: [PATCH] ASoC: dapm: fixup dapm kcontrol widget
  2020-04-18  4:13 ` [PATCH] ASoC: dapm: fixup dapm kcontrol widget Gyeongtaek Lee
@ 2020-04-20 13:36   ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-04-20 13:36 UTC (permalink / raw)
  To: Gyeongtaek Lee
  Cc: alsa-devel, khw0178.kim, kimty, tiwai, lgirdwood, hmseo, tkjung,
	pilsun.jang

On Sat, 18 Apr 2020 13:13:20 +0900, Gyeongtaek Lee wrote:
> snd_soc_dapm_kcontrol widget which is created by autodisable control
> should contain correct on_val, mask and shift because it is set when the
> widget is powered and changed value is applied on registers by following
> code in dapm_seq_run_coalesced().
> 
> 		mask |= w->mask << w->shift;
> 		if (w->power)
> 			value |= w->on_val << w->shift;
> 		else
> 			value |= w->off_val << w->shift;
> 
> [...]

Applied to

	broonie/sound.git for-5.7

Thanks!

[1/1] ASoC: dapm: fixup dapm kcontrol widget
      commit: ebf1474745b4373fdde0fcf32d9d1f369b50b212

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] 2+ messages in thread

end of thread, other threads:[~2020-04-20 13:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20200418041321epcas2p1ceed010fde93a35e763a9db436e1c63b@epcas2p1.samsung.com>
2020-04-18  4:13 ` [PATCH] ASoC: dapm: fixup dapm kcontrol widget Gyeongtaek Lee
2020-04-20 13:36   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).