2021-11-03 13:57:15

by Sameer Pujar

[permalink] [raw]
Subject: [PATCH v2 00/10] Fix kcontrol put callback in Tegra drivers

This series fixes kcontrol put callback in some of the Tegra drivers
which are used on platforms based on Tegra210 and later. The callback
is expected to return 1 whenever the HW update is done.

This idea is suggested by Jaroslav. Similar suggestion came from
Mark during review of series [0] and drivers under this were updated
to return 1, but missed to take care of duplicate updates. This series
updates all concerned drivers to return proper values and duplicate
updates are filtered out. I have added 'Suggested-by" tags accordingly.

[0] https://lore.kernel.org/linux-arm-kernel/[email protected]/



Changelog
=========
v1->v2:
-------
* ADMAIF, I2S, DMIC and DSPK drivers updated to take care of
duplicate updates.
* Similarly new patches are added for AHUB, MVC, SFC, AMX, ADX
and Mixer drivers.

Sameer Pujar (10):
ASoC: tegra: Fix kcontrol put callback in ADMAIF
ASoC: tegra: Fix kcontrol put callback in I2S
ASoC: tegra: Fix kcontrol put callback in DMIC
ASoC: tegra: Fix kcontrol put callback in DSPK
ASoC: tegra: Fix kcontrol put callback in AHUB
ASoC: tegra: Fix kcontrol put callback in MVC
ASoC: tegra: Fix kcontrol put callback in SFC
ASoC: tegra: Fix kcontrol put callback in AMX
ASoC: tegra: Fix kcontrol put callback in ADX
ASoC: tegra: Fix kcontrol put callback in Mixer

sound/soc/tegra/tegra186_dspk.c | 33 ++++++++++++++++++++++++++-------
sound/soc/tegra/tegra210_admaif.c | 23 ++++++++++++++++++-----
sound/soc/tegra/tegra210_adx.c | 3 +++
sound/soc/tegra/tegra210_ahub.c | 11 +++++++----
sound/soc/tegra/tegra210_amx.c | 3 +++
sound/soc/tegra/tegra210_dmic.c | 35 +++++++++++++++++++++++++++--------
sound/soc/tegra/tegra210_i2s.c | 26 +++++++++++++++++++++++++-
sound/soc/tegra/tegra210_mixer.c | 3 +++
sound/soc/tegra/tegra210_mvc.c | 18 ++++++++++++++++--
sound/soc/tegra/tegra210_sfc.c | 23 +++++++++++++++++------
10 files changed, 145 insertions(+), 33 deletions(-)

--
2.7.4


2021-11-03 13:57:36

by Sameer Pujar

[permalink] [raw]
Subject: [PATCH v2 02/10] ASoC: tegra: Fix kcontrol put callback in I2S

The kcontrol put callback is expected to return 1 when there is change
in HW or when the update is acknowledged by driver. This would ensure
that change notifications are sent to subscribed applications. Update
the I2S driver accordingly.

Fixes: c0bfa98349d1 ("ASoC: tegra: Add Tegra210 based I2S driver")
Suggested-by: Jaroslav Kysela <[email protected]>
Suggested-by: Mark Brown <[email protected]>
Signed-off-by: Sameer Pujar <[email protected]>
---
sound/soc/tegra/tegra210_i2s.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/sound/soc/tegra/tegra210_i2s.c b/sound/soc/tegra/tegra210_i2s.c
index 45f31cc..70505b5 100644
--- a/sound/soc/tegra/tegra210_i2s.c
+++ b/sound/soc/tegra/tegra210_i2s.c
@@ -347,6 +347,9 @@ static int tegra210_i2s_put_control(struct snd_kcontrol *kcontrol,
int value = ucontrol->value.integer.value[0];

if (strstr(kcontrol->id.name, "Loopback")) {
+ if (i2s->loopback == value)
+ return 0;
+
i2s->loopback = value;

regmap_update_bits(i2s->regmap, TEGRA210_I2S_CTRL,
@@ -362,6 +365,9 @@ static int tegra210_i2s_put_control(struct snd_kcontrol *kcontrol,
* cases mixer control is used to update custom values. A value
* of "N" here means, width is "N + 1" bit clock wide.
*/
+ if (i2s->fsync_width == value)
+ return 0;
+
i2s->fsync_width = value;

regmap_update_bits(i2s->regmap, TEGRA210_I2S_CTRL,
@@ -369,20 +375,38 @@ static int tegra210_i2s_put_control(struct snd_kcontrol *kcontrol,
i2s->fsync_width << I2S_FSYNC_WIDTH_SHIFT);

} else if (strstr(kcontrol->id.name, "Capture Stereo To Mono")) {
+ if (i2s->stereo_to_mono[I2S_TX_PATH] == value)
+ return 0;
+
i2s->stereo_to_mono[I2S_TX_PATH] = value;
} else if (strstr(kcontrol->id.name, "Capture Mono To Stereo")) {
+ if (i2s->mono_to_stereo[I2S_TX_PATH] == value)
+ return 0;
+
i2s->mono_to_stereo[I2S_TX_PATH] = value;
} else if (strstr(kcontrol->id.name, "Playback Stereo To Mono")) {
+ if (i2s->stereo_to_mono[I2S_RX_PATH] == value)
+ return 0;
+
i2s->stereo_to_mono[I2S_RX_PATH] = value;
} else if (strstr(kcontrol->id.name, "Playback Mono To Stereo")) {
+ if (i2s->mono_to_stereo[I2S_RX_PATH] == value)
+ return 0;
+
i2s->mono_to_stereo[I2S_RX_PATH] = value;
} else if (strstr(kcontrol->id.name, "Playback FIFO Threshold")) {
+ if (i2s->rx_fifo_th == value)
+ return 0;
+
i2s->rx_fifo_th = value;
} else if (strstr(kcontrol->id.name, "BCLK Ratio")) {
+ if (i2s->bclk_ratio == value)
+ return 0;
+
i2s->bclk_ratio = value;
}

- return 0;
+ return 1;
}

static int tegra210_i2s_set_timing_params(struct device *dev,
--
2.7.4

2021-11-03 13:57:41

by Sameer Pujar

[permalink] [raw]
Subject: [PATCH v2 03/10] ASoC: tegra: Fix kcontrol put callback in DMIC

The kcontrol put callback is expected to return 1 when there is change
in HW or when the update is acknowledged by driver. This would ensure
that change notifications are sent to subscribed applications. Update
the DMIC driver accordingly.

Fixes: 8c8ff982e9e2 ("ASoC: tegra: Add Tegra210 based DMIC driver")
Suggested-by: Jaroslav Kysela <[email protected]>
Suggested-by: Mark Brown <[email protected]>
Signed-off-by: Sameer Pujar <[email protected]>
---
sound/soc/tegra/tegra210_dmic.c | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/sound/soc/tegra/tegra210_dmic.c b/sound/soc/tegra/tegra210_dmic.c
index b096478..39a63ed 100644
--- a/sound/soc/tegra/tegra210_dmic.c
+++ b/sound/soc/tegra/tegra210_dmic.c
@@ -185,20 +185,39 @@ static int tegra210_dmic_put_control(struct snd_kcontrol *kcontrol,
struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp);
int value = ucontrol->value.integer.value[0];

- if (strstr(kcontrol->id.name, "Boost Gain Volume"))
+ if (strstr(kcontrol->id.name, "Boost Gain Volume")) {
+ if (dmic->boost_gain == value)
+ return 0;
+
dmic->boost_gain = value;
- else if (strstr(kcontrol->id.name, "Channel Select"))
- dmic->ch_select = ucontrol->value.integer.value[0];
- else if (strstr(kcontrol->id.name, "Mono To Stereo"))
+ } else if (strstr(kcontrol->id.name, "Channel Select")) {
+ if (dmic->ch_select == value)
+ return 0;
+
+ dmic->ch_select = value;
+ } else if (strstr(kcontrol->id.name, "Mono To Stereo")) {
+ if (dmic->mono_to_stereo == value)
+ return 0;
+
dmic->mono_to_stereo = value;
- else if (strstr(kcontrol->id.name, "Stereo To Mono"))
+ } else if (strstr(kcontrol->id.name, "Stereo To Mono")) {
+ if (dmic->stereo_to_mono == value)
+ return 0;
+
dmic->stereo_to_mono = value;
- else if (strstr(kcontrol->id.name, "OSR Value"))
+ } else if (strstr(kcontrol->id.name, "OSR Value")) {
+ if (dmic->osr_val == value)
+ return 0;
+
dmic->osr_val = value;
- else if (strstr(kcontrol->id.name, "LR Polarity Select"))
+ } else if (strstr(kcontrol->id.name, "LR Polarity Select")) {
+ if (dmic->lrsel == value)
+ return 0;
+
dmic->lrsel = value;
+ }

- return 0;
+ return 1;
}

static const struct snd_soc_dai_ops tegra210_dmic_dai_ops = {
--
2.7.4

2021-11-03 13:58:52

by Sameer Pujar

[permalink] [raw]
Subject: [PATCH v2 09/10] ASoC: tegra: Fix kcontrol put callback in ADX

The kcontrol put callback is expected to return 1 when there is change
in HW or when the update is acknowledged by driver. This would ensure
that change notifications are sent to subscribed applications. Filter
out duplicate updates in ADX driver.

Fixes: a99ab6f395a9 ("ASoC: tegra: Add Tegra210 based ADX driver")
Signed-off-by: Sameer Pujar <[email protected]>
Suggested-by: Jaroslav Kysela <[email protected]>
Suggested-by: Mark Brown <[email protected]>
---
sound/soc/tegra/tegra210_adx.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/sound/soc/tegra/tegra210_adx.c b/sound/soc/tegra/tegra210_adx.c
index d7c7849..933c450 100644
--- a/sound/soc/tegra/tegra210_adx.c
+++ b/sound/soc/tegra/tegra210_adx.c
@@ -193,6 +193,9 @@ static int tegra210_adx_put_byte_map(struct snd_kcontrol *kcontrol,
struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value;;

+ if (value == bytes_map[mc->reg])
+ return 0;
+
if (value >= 0 && value <= 255) {
/* update byte map and enable slot */
bytes_map[mc->reg] = value;
--
2.7.4

2021-11-03 13:58:52

by Sameer Pujar

[permalink] [raw]
Subject: [PATCH v2 06/10] ASoC: tegra: Fix kcontrol put callback in MVC

The kcontrol put callback is expected to return 1 when there is change
in HW or when the update is acknowledged by driver. This would ensure
that change notifications are sent to subscribed applications. Filter
out duplicate updates in MVC driver.

Fixes: e539891f9687 ("ASoC: tegra: Add Tegra210 based MVC driver")
Signed-off-by: Sameer Pujar <[email protected]>
Suggested-by: Jaroslav Kysela <[email protected]>
Suggested-by: Mark Brown <[email protected]>
---
sound/soc/tegra/tegra210_mvc.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/sound/soc/tegra/tegra210_mvc.c b/sound/soc/tegra/tegra210_mvc.c
index 7b9c700..380686c 100644
--- a/sound/soc/tegra/tegra210_mvc.c
+++ b/sound/soc/tegra/tegra210_mvc.c
@@ -136,7 +136,7 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol,
struct snd_soc_component *cmpnt = snd_soc_kcontrol_component(kcontrol);
struct tegra210_mvc *mvc = snd_soc_component_get_drvdata(cmpnt);
unsigned int value;
- u8 mute_mask;
+ u8 mute_mask, old_mask;
int err;

pm_runtime_get_sync(cmpnt->dev);
@@ -148,8 +148,16 @@ static int tegra210_mvc_put_mute(struct snd_kcontrol *kcontrol,
if (err < 0)
goto end;

+ regmap_read(mvc->regmap, TEGRA210_MVC_CTRL, &value);
+
+ old_mask = (value >> TEGRA210_MVC_MUTE_SHIFT) & TEGRA210_MUTE_MASK_EN;
mute_mask = ucontrol->value.integer.value[0];

+ if (mute_mask == old_mask) {
+ err = 0;
+ goto end;
+ }
+
err = regmap_update_bits(mvc->regmap, mc->reg,
TEGRA210_MVC_MUTE_MASK,
mute_mask << TEGRA210_MVC_MUTE_SHIFT);
@@ -195,7 +203,7 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol,
unsigned int reg = mc->reg;
unsigned int value;
u8 chan;
- int err;
+ int err, old_volume;

pm_runtime_get_sync(cmpnt->dev);

@@ -207,10 +215,16 @@ static int tegra210_mvc_put_vol(struct snd_kcontrol *kcontrol,
goto end;

chan = (reg - TEGRA210_MVC_TARGET_VOL) / REG_SIZE;
+ old_volume = mvc->volume[chan];

tegra210_mvc_conv_vol(mvc, chan,
ucontrol->value.integer.value[0]);

+ if (mvc->volume[chan] == old_volume) {
+ err = 0;
+ goto end;
+ }
+
/* Configure init volume same as target volume */
regmap_write(mvc->regmap,
TEGRA210_MVC_REG_OFFSET(TEGRA210_MVC_INIT_VOL, chan),
--
2.7.4

2021-11-03 13:58:54

by Sameer Pujar

[permalink] [raw]
Subject: [PATCH v2 07/10] ASoC: tegra: Fix kcontrol put callback in SFC

The kcontrol put callback is expected to return 1 when there is change
in HW or when the update is acknowledged by driver. This would ensure
that change notifications are sent to subscribed applications. Filter
out duplicate updates in SFC driver.

Fixes: b2f74ec53a6c ("ASoC: tegra: Add Tegra210 based SFC driver")
Signed-off-by: Sameer Pujar <[email protected]>
Suggested-by: Jaroslav Kysela <[email protected]>
Suggested-by: Mark Brown <[email protected]>
---
sound/soc/tegra/tegra210_sfc.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/sound/soc/tegra/tegra210_sfc.c b/sound/soc/tegra/tegra210_sfc.c
index dc477ee..ac24980 100644
--- a/sound/soc/tegra/tegra210_sfc.c
+++ b/sound/soc/tegra/tegra210_sfc.c
@@ -3273,16 +3273,27 @@ static int tegra210_sfc_put_control(struct snd_kcontrol *kcontrol,
struct tegra210_sfc *sfc = snd_soc_component_get_drvdata(cmpnt);
int value = ucontrol->value.integer.value[0];

- if (strstr(kcontrol->id.name, "Input Stereo To Mono"))
+ if (strstr(kcontrol->id.name, "Input Stereo To Mono")) {
+ if (sfc->stereo_to_mono[SFC_RX_PATH] == value)
+ return 0;
+
sfc->stereo_to_mono[SFC_RX_PATH] = value;
- else if (strstr(kcontrol->id.name, "Input Mono To Stereo"))
+ } else if (strstr(kcontrol->id.name, "Input Mono To Stereo")) {
+ if (sfc->mono_to_stereo[SFC_RX_PATH] == value)
+ return 0;
+
sfc->mono_to_stereo[SFC_RX_PATH] = value;
- else if (strstr(kcontrol->id.name, "Output Stereo To Mono"))
+ } else if (strstr(kcontrol->id.name, "Output Stereo To Mono")) {
+ if (sfc->stereo_to_mono[SFC_TX_PATH] == value)
+ return 0;
+
sfc->stereo_to_mono[SFC_TX_PATH] = value;
- else if (strstr(kcontrol->id.name, "Output Mono To Stereo"))
+ } else if (strstr(kcontrol->id.name, "Output Mono To Stereo")) {
+ if (sfc->mono_to_stereo[SFC_TX_PATH] == value)
+ return 0;
+
sfc->mono_to_stereo[SFC_TX_PATH] = value;
- else
- return 0;
+ }

return 1;
}
--
2.7.4