All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: cs42l42: Correct definition of ADC Volume control
@ 2021-07-29 17:09 ` Richard Fitzgerald
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Fitzgerald @ 2021-07-29 17:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, patches, linux-kernel, Richard Fitzgerald

The ADC volume is a signed 8-bit number with range -97 to +12,
with -97 being mute. Use a SOC_SINGLE_S8_TLV() to define this
and fix the DECLARE_TLV_DB_SCALE() to have the correct start and
mute flag.

Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index eff013f295be..2fd20511f246 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -405,7 +405,7 @@ static const struct regmap_config cs42l42_regmap = {
 	.use_single_write = true,
 };
 
-static DECLARE_TLV_DB_SCALE(adc_tlv, -9600, 100, false);
+static DECLARE_TLV_DB_SCALE(adc_tlv, -9700, 100, true);
 static DECLARE_TLV_DB_SCALE(mixer_tlv, -6300, 100, true);
 
 static const char * const cs42l42_hpf_freq_text[] = {
@@ -444,8 +444,7 @@ static const struct snd_kcontrol_new cs42l42_snd_controls[] = {
 				CS42L42_ADC_INV_SHIFT, true, false),
 	SOC_SINGLE("ADC Boost Switch", CS42L42_ADC_CTL,
 				CS42L42_ADC_DIG_BOOST_SHIFT, true, false),
-	SOC_SINGLE_SX_TLV("ADC Volume", CS42L42_ADC_VOLUME,
-				CS42L42_ADC_VOL_SHIFT, 0xA0, 0x6C, adc_tlv),
+	SOC_SINGLE_S8_TLV("ADC Volume", CS42L42_ADC_VOLUME, -97, 12, adc_tlv),
 	SOC_SINGLE("ADC WNF Switch", CS42L42_ADC_WNF_HPF_CTL,
 				CS42L42_ADC_WNF_EN_SHIFT, true, false),
 	SOC_SINGLE("ADC HPF Switch", CS42L42_ADC_WNF_HPF_CTL,
-- 
2.11.0


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

* [PATCH 1/3] ASoC: cs42l42: Correct definition of ADC Volume control
@ 2021-07-29 17:09 ` Richard Fitzgerald
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Fitzgerald @ 2021-07-29 17:09 UTC (permalink / raw)
  To: broonie; +Cc: patches, alsa-devel, Richard Fitzgerald, linux-kernel

The ADC volume is a signed 8-bit number with range -97 to +12,
with -97 being mute. Use a SOC_SINGLE_S8_TLV() to define this
and fix the DECLARE_TLV_DB_SCALE() to have the correct start and
mute flag.

Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index eff013f295be..2fd20511f246 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -405,7 +405,7 @@ static const struct regmap_config cs42l42_regmap = {
 	.use_single_write = true,
 };
 
-static DECLARE_TLV_DB_SCALE(adc_tlv, -9600, 100, false);
+static DECLARE_TLV_DB_SCALE(adc_tlv, -9700, 100, true);
 static DECLARE_TLV_DB_SCALE(mixer_tlv, -6300, 100, true);
 
 static const char * const cs42l42_hpf_freq_text[] = {
@@ -444,8 +444,7 @@ static const struct snd_kcontrol_new cs42l42_snd_controls[] = {
 				CS42L42_ADC_INV_SHIFT, true, false),
 	SOC_SINGLE("ADC Boost Switch", CS42L42_ADC_CTL,
 				CS42L42_ADC_DIG_BOOST_SHIFT, true, false),
-	SOC_SINGLE_SX_TLV("ADC Volume", CS42L42_ADC_VOLUME,
-				CS42L42_ADC_VOL_SHIFT, 0xA0, 0x6C, adc_tlv),
+	SOC_SINGLE_S8_TLV("ADC Volume", CS42L42_ADC_VOLUME, -97, 12, adc_tlv),
 	SOC_SINGLE("ADC WNF Switch", CS42L42_ADC_WNF_HPF_CTL,
 				CS42L42_ADC_WNF_EN_SHIFT, true, false),
 	SOC_SINGLE("ADC HPF Switch", CS42L42_ADC_WNF_HPF_CTL,
-- 
2.11.0


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

* [PATCH 2/3] ASoC: cs42l42: Don't allow SND_SOC_DAIFMT_LEFT_J
  2021-07-29 17:09 ` Richard Fitzgerald
@ 2021-07-29 17:09   ` Richard Fitzgerald
  -1 siblings, 0 replies; 10+ messages in thread
From: Richard Fitzgerald @ 2021-07-29 17:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, patches, linux-kernel, Richard Fitzgerald

The driver has no support for left-justified protocol so it should
not have been allowing this to be passed to cs42l42_set_dai_fmt().

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
---
 sound/soc/codecs/cs42l42.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index 2fd20511f246..38e243a815b1 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -788,7 +788,6 @@ static int cs42l42_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 	/* interface format */
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
-	case SND_SOC_DAIFMT_LEFT_J:
 		break;
 	default:
 		return -EINVAL;
-- 
2.11.0


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

* [PATCH 2/3] ASoC: cs42l42: Don't allow SND_SOC_DAIFMT_LEFT_J
@ 2021-07-29 17:09   ` Richard Fitzgerald
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Fitzgerald @ 2021-07-29 17:09 UTC (permalink / raw)
  To: broonie; +Cc: patches, alsa-devel, Richard Fitzgerald, linux-kernel

The driver has no support for left-justified protocol so it should
not have been allowing this to be passed to cs42l42_set_dai_fmt().

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 2c394ca79604 ("ASoC: Add support for CS42L42 codec")
---
 sound/soc/codecs/cs42l42.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index 2fd20511f246..38e243a815b1 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -788,7 +788,6 @@ static int cs42l42_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
 	/* interface format */
 	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
 	case SND_SOC_DAIFMT_I2S:
-	case SND_SOC_DAIFMT_LEFT_J:
 		break;
 	default:
 		return -EINVAL;
-- 
2.11.0


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

* [PATCH 3/3] ASoC: cs42l42: Fix bclk calculation for mono
  2021-07-29 17:09 ` Richard Fitzgerald
@ 2021-07-29 17:09   ` Richard Fitzgerald
  -1 siblings, 0 replies; 10+ messages in thread
From: Richard Fitzgerald @ 2021-07-29 17:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, patches, linux-kernel, Richard Fitzgerald

An I2S frame always has a left and right channel slot even if mono
data is being sent. So if channels==1 the actual bitclock frequency
is 2 * snd_soc_params_to_bclk(params).

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 2cdba9b045c7 ("ASoC: cs42l42: Use bclk from hw_params if set_sysclk was not called")
---
 sound/soc/codecs/cs42l42.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index 38e243a815b1..08ca05bfbeb3 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -830,6 +830,10 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream,
 	cs42l42->srate = params_rate(params);
 	cs42l42->bclk = snd_soc_params_to_bclk(params);
 
+	/* I2S frame always has 2 channels even for mono audio */
+	if (channels == 1)
+		cs42l42->bclk *= 2;
+
 	switch(substream->stream) {
 	case SNDRV_PCM_STREAM_CAPTURE:
 		if (channels == 2) {
-- 
2.11.0


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

* [PATCH 3/3] ASoC: cs42l42: Fix bclk calculation for mono
@ 2021-07-29 17:09   ` Richard Fitzgerald
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Fitzgerald @ 2021-07-29 17:09 UTC (permalink / raw)
  To: broonie; +Cc: patches, alsa-devel, Richard Fitzgerald, linux-kernel

An I2S frame always has a left and right channel slot even if mono
data is being sent. So if channels==1 the actual bitclock frequency
is 2 * snd_soc_params_to_bclk(params).

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 2cdba9b045c7 ("ASoC: cs42l42: Use bclk from hw_params if set_sysclk was not called")
---
 sound/soc/codecs/cs42l42.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index 38e243a815b1..08ca05bfbeb3 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -830,6 +830,10 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream,
 	cs42l42->srate = params_rate(params);
 	cs42l42->bclk = snd_soc_params_to_bclk(params);
 
+	/* I2S frame always has 2 channels even for mono audio */
+	if (channels == 1)
+		cs42l42->bclk *= 2;
+
 	switch(substream->stream) {
 	case SNDRV_PCM_STREAM_CAPTURE:
 		if (channels == 2) {
-- 
2.11.0


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

* Re: [PATCH 1/3] ASoC: cs42l42: Correct definition of ADC Volume control
  2021-07-29 17:09 ` Richard Fitzgerald
@ 2021-07-29 19:49   ` Mark Brown
  -1 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2021-07-29 19:49 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: Mark Brown, alsa-devel, linux-kernel, patches

On Thu, 29 Jul 2021 18:09:27 +0100, Richard Fitzgerald wrote:
> The ADC volume is a signed 8-bit number with range -97 to +12,
> with -97 being mute. Use a SOC_SINGLE_S8_TLV() to define this
> and fix the DECLARE_TLV_DB_SCALE() to have the correct start and
> mute flag.

Applied to

   torvalds/linux.git master

Thanks!

[1/3] ASoC: cs42l42: Correct definition of ADC Volume control
      commit: ee86f680ff4c9b406d49d4e22ddf10805b8a2137
[2/3] ASoC: cs42l42: Don't allow SND_SOC_DAIFMT_LEFT_J
      commit: 64324bac750b84ca54711fb7d332132fcdb87293
[3/3] ASoC: cs42l42: Fix bclk calculation for mono
      commit: 926ef1a4c245c093acc07807e466ad2ef0ff6ccb

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

* Re: [PATCH 1/3] ASoC: cs42l42: Correct definition of ADC Volume control
@ 2021-07-29 19:49   ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2021-07-29 19:49 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: patches, alsa-devel, Mark Brown, linux-kernel

On Thu, 29 Jul 2021 18:09:27 +0100, Richard Fitzgerald wrote:
> The ADC volume is a signed 8-bit number with range -97 to +12,
> with -97 being mute. Use a SOC_SINGLE_S8_TLV() to define this
> and fix the DECLARE_TLV_DB_SCALE() to have the correct start and
> mute flag.

Applied to

   torvalds/linux.git master

Thanks!

[1/3] ASoC: cs42l42: Correct definition of ADC Volume control
      commit: ee86f680ff4c9b406d49d4e22ddf10805b8a2137
[2/3] ASoC: cs42l42: Don't allow SND_SOC_DAIFMT_LEFT_J
      commit: 64324bac750b84ca54711fb7d332132fcdb87293
[3/3] ASoC: cs42l42: Fix bclk calculation for mono
      commit: 926ef1a4c245c093acc07807e466ad2ef0ff6ccb

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

* Re: [PATCH 1/3] ASoC: cs42l42: Correct definition of ADC Volume control
  2021-07-29 19:49   ` Mark Brown
@ 2021-07-29 19:53     ` Mark Brown
  -1 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2021-07-29 19:53 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: alsa-devel, linux-kernel, patches

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

On Thu, Jul 29, 2021 at 08:49:21PM +0100, Mark Brown wrote:
> On Thu, 29 Jul 2021 18:09:27 +0100, Richard Fitzgerald wrote:
> > The ADC volume is a signed 8-bit number with range -97 to +12,
> > with -97 being mute. Use a SOC_SINGLE_S8_TLV() to define this
> > and fix the DECLARE_TLV_DB_SCALE() to have the correct start and
> > mute flag.
> 
> Applied to
> 
>    torvalds/linux.git master
> 
> Thanks!

Ugh, sorry - the script is confused.  This is applied to the ASoC tree.

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

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

* Re: [PATCH 1/3] ASoC: cs42l42: Correct definition of ADC Volume control
@ 2021-07-29 19:53     ` Mark Brown
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2021-07-29 19:53 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: patches, alsa-devel, linux-kernel

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

On Thu, Jul 29, 2021 at 08:49:21PM +0100, Mark Brown wrote:
> On Thu, 29 Jul 2021 18:09:27 +0100, Richard Fitzgerald wrote:
> > The ADC volume is a signed 8-bit number with range -97 to +12,
> > with -97 being mute. Use a SOC_SINGLE_S8_TLV() to define this
> > and fix the DECLARE_TLV_DB_SCALE() to have the correct start and
> > mute flag.
> 
> Applied to
> 
>    torvalds/linux.git master
> 
> Thanks!

Ugh, sorry - the script is confused.  This is applied to the ASoC tree.

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

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

end of thread, other threads:[~2021-07-29 19:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 17:09 [PATCH 1/3] ASoC: cs42l42: Correct definition of ADC Volume control Richard Fitzgerald
2021-07-29 17:09 ` Richard Fitzgerald
2021-07-29 17:09 ` [PATCH 2/3] ASoC: cs42l42: Don't allow SND_SOC_DAIFMT_LEFT_J Richard Fitzgerald
2021-07-29 17:09   ` Richard Fitzgerald
2021-07-29 17:09 ` [PATCH 3/3] ASoC: cs42l42: Fix bclk calculation for mono Richard Fitzgerald
2021-07-29 17:09   ` Richard Fitzgerald
2021-07-29 19:49 ` [PATCH 1/3] ASoC: cs42l42: Correct definition of ADC Volume control Mark Brown
2021-07-29 19:49   ` Mark Brown
2021-07-29 19:53   ` Mark Brown
2021-07-29 19:53     ` 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.