All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ASOC: wm8991/stac9766: fix wrong usage of TLV-related macro
@ 2016-09-26 23:25 Takashi Sakamoto
  2016-09-26 23:25 ` [PATCH 1/3] ASOC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Takashi Sakamoto @ 2016-09-26 23:25 UTC (permalink / raw)
  To: tiwai, broonie, lgirdwood; +Cc: alsa-devel

Hi,

This patchset is for Linux 4.8-rc8.

In current implementation of drivers for wm899a and stac9766,
DECLARE_TLV_DB_LINEAR() is used to represent information about attenuation
and gain of volumes. According to their datasheet, the attenuation and
volumes are first-degree equation with dB coefficiency. It's not linear and
usage of the macro is wrong[1].

This patchset fixes the bug. As of 2016, these CODECs seem to EOL. So this
patchset is just for maintenance purpose to remove misuse of TLV-related
macros from tree.

[1] Re: [RFC] TLV entry for linear volume
http://www.spinics.net/lists/alsa-devel/msg03485.html

Takashi Sakamoto (3):
  ASOC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR()
  ASOC: wm8991: remove unused variable
  ASOC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR()

 sound/soc/codecs/stac9766.c |  8 ++++----
 sound/soc/codecs/wm8991.c   | 28 +++++++++++++++++++---------
 2 files changed, 23 insertions(+), 13 deletions(-)

-- 
2.7.4

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

* [PATCH 1/3] ASOC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR()
  2016-09-26 23:25 [PATCH 0/3] ASOC: wm8991/stac9766: fix wrong usage of TLV-related macro Takashi Sakamoto
@ 2016-09-26 23:25 ` Takashi Sakamoto
  2016-09-27  8:48   ` Charles Keepax
  2016-09-27 16:24   ` Applied "ASoC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR()" to the asoc tree Mark Brown
  2016-09-26 23:25 ` [PATCH 2/3] ASOC: wm8991: remove unused variable Takashi Sakamoto
  2016-09-26 23:25 ` [PATCH 3/3] ASOC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
  2 siblings, 2 replies; 9+ messages in thread
From: Takashi Sakamoto @ 2016-09-26 23:25 UTC (permalink / raw)
  To: tiwai, broonie, lgirdwood; +Cc: alsa-devel, patches

As long as reading datasheet of WM8991, this driver includes wrong usage
of DECLARE_TLV_DB_LINEAR().

In "Table 6 Input PGA Volume Range", volume is represented in 5 bits by
1.5 dB/step between -16.5/30.0 dB. Thus, 'in_pga_tlv' should be dB step
representation.

In "Table 34 LOMIX and ROMIX Volume Range", volume is represented in three
bits by -3 dB/step from 0 to -21 dB. Thus, 'out_mix_tlv' should be dB step
represenation.

In "Table 36 LOPGA, ROPGA, LOUT, ROUT and SPKVOL Volume Range", volume is
represented in 7 bits by 1 dB/step from -73 to 6 dB, including mute. Thus,
'out_pga_tlv' should be dB step representation.

In "Table 26 Digital Volume Range", volume is represented in 8 bits by
3/8 dB/step from -71.625 to 0 dB. Thus, 'out_dac_tlv' should be dB step
representation.

In "Table 16 ADC Digital Volume Range", volume is represented in 8 bits by
3/8 dB/step from -71.625 to 17.625 dB. Thus, 'in_adc_tlv' should be dB step
representation.

In "Table 23 Digital Sidetone Volume", volume is represented in 5 bits by
3 dB/step from -36 to 0 dB. Thus, 'out_sidetone_tlv' should be dB step
representation.

In "Table 12 Left Input Mixer Volume Control", volume is represented in
3 bits by 3 dB/step from -12 to 6 dB

Totally, current implementation includes misuse of TLV-related macro.

This commit replaces usage of DECLARE_TLV_DB_LINEAR() with proper macros,
to give proper information to applications in user land.

Fixes: 203db220718c ("ASoC: WM8991: Add initial WM8991 driver")
Cc: patches@opensource.wolfsonmicro.com
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/soc/codecs/wm8991.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index c9ee0ac..483b953 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -112,13 +112,25 @@ static bool wm8991_volatile(struct device *dev, unsigned int reg)
 }
 
 static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv, -1500, 600);
-static const DECLARE_TLV_DB_LINEAR(in_pga_tlv, -1650, 3000);
-static const DECLARE_TLV_DB_LINEAR(out_mix_tlv, 0, -2100);
-static const DECLARE_TLV_DB_LINEAR(out_pga_tlv, -7300, 600);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(in_pga_tlv, -1650, 150, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(out_mix_tlv, -2100, 300, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_pga_tlv,
+	0x00, 0x2f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(SNDRV_CTL_TLVD_DB_GAIN_MUTE, 0, 1),
+	0x30, 0x7f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-7300, 100, 0),
+);
 static const DECLARE_TLV_DB_LINEAR(out_omix_tlv, -600, 0);
-static const DECLARE_TLV_DB_LINEAR(out_dac_tlv, -7163, 0);
-static const DECLARE_TLV_DB_LINEAR(in_adc_tlv, -7163, 1763);
-static const DECLARE_TLV_DB_LINEAR(out_sidetone_tlv, -3600, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_dac_tlv,
+	0x00, 0xbf, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-71625, 375, 1),
+	0xc0, 0xff, SNDRV_CTL_TLVD_DB_SCALE_ITEM(0, 0, 0),
+);
+static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(in_adc_tlv,
+	0x00, 0xef, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-71625, 375, 1),
+	0xf0, 0xff, SNDRV_CTL_TLVD_DB_SCALE_ITEM(17625, 0, 0),
+);
+static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_sidetone_tlv,
+	0x00, 0x0c, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-3600, 300, 0),
+	0x0d, 0x0f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(0, 0, 0),
+);
 
 static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
 				      struct snd_ctl_elem_value *ucontrol)
@@ -398,7 +410,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
 }
 
 /* INMIX dB values */
-static const DECLARE_TLV_DB_LINEAR(in_mix_tlv, -1200, 600);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(in_mix_tlv, -1200, 300, 1);
 
 /* Left In PGA Connections */
 static const struct snd_kcontrol_new wm8991_dapm_lin12_pga_controls[] = {
-- 
2.7.4

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

* [PATCH 2/3] ASOC: wm8991: remove unused variable
  2016-09-26 23:25 [PATCH 0/3] ASOC: wm8991/stac9766: fix wrong usage of TLV-related macro Takashi Sakamoto
  2016-09-26 23:25 ` [PATCH 1/3] ASOC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
@ 2016-09-26 23:25 ` Takashi Sakamoto
  2016-09-27  8:48   ` Charles Keepax
  2016-09-27 16:24   ` Applied "ASoC: wm8991: remove unused variable" to the asoc tree Mark Brown
  2016-09-26 23:25 ` [PATCH 3/3] ASOC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
  2 siblings, 2 replies; 9+ messages in thread
From: Takashi Sakamoto @ 2016-09-26 23:25 UTC (permalink / raw)
  To: tiwai, broonie, lgirdwood; +Cc: alsa-devel, patches

This driver has some unused variables. They should be removed.

Fixes: 203db220718c ("ASoC: WM8991: Add initial WM8991 driver")
Cc: patches@opensource.wolfsonmicro.com
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/soc/codecs/wm8991.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index 483b953..9d4b607 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -111,14 +111,12 @@ static bool wm8991_volatile(struct device *dev, unsigned int reg)
 	}
 }
 
-static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv, -1500, 600);
 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(in_pga_tlv, -1650, 150, 0);
 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(out_mix_tlv, -2100, 300, 0);
 static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_pga_tlv,
 	0x00, 0x2f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(SNDRV_CTL_TLVD_DB_GAIN_MUTE, 0, 1),
 	0x30, 0x7f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-7300, 100, 0),
 );
-static const DECLARE_TLV_DB_LINEAR(out_omix_tlv, -600, 0);
 static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_dac_tlv,
 	0x00, 0xbf, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-71625, 375, 1),
 	0xc0, 0xff, SNDRV_CTL_TLVD_DB_SCALE_ITEM(0, 0, 0),
-- 
2.7.4

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

* [PATCH 3/3] ASOC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR()
  2016-09-26 23:25 [PATCH 0/3] ASOC: wm8991/stac9766: fix wrong usage of TLV-related macro Takashi Sakamoto
  2016-09-26 23:25 ` [PATCH 1/3] ASOC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
  2016-09-26 23:25 ` [PATCH 2/3] ASOC: wm8991: remove unused variable Takashi Sakamoto
@ 2016-09-26 23:25 ` Takashi Sakamoto
  2016-09-27 16:24   ` Applied "ASoC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR()" to the asoc tree Mark Brown
  2 siblings, 1 reply; 9+ messages in thread
From: Takashi Sakamoto @ 2016-09-26 23:25 UTC (permalink / raw)
  To: tiwai, broonie, lgirdwood; +Cc: alsa-devel

As long as reading datasheet of STAC9766/9767, this driver includes wrong
usage of DECLARE_TLV_DB_LINEAR().

In "8.1.2. Master Volume Registers", attenuation of lineout volumes is
represented in 5 bits by -1.5 dB/step from 0 to -46.5 dB. Thus,
'master_tlv' should be dB step representation.

In "8.1.14. Record Gain", gain of volumes is represented in 4 bits by
1.5 dB/step from 0 to 22.5 dB. Thus, 'record_tlv' should be dB step
representation.

In "8.1.5. PC BEEP Volume", attenuation of volume is represented in 4 bits
by -3 dB/step from 0 to 45 dB. Thus, 'beep_tlv' should be dB step
representation.

In "8.1.7. Stereo or Mic Volume" and so on, gain of volumes is represented
in 5 bits by -1.5 dB from 12 to -34.5 dB. Thus, 'mix_tlv' should be dB
step representation.

Totally, current implementation includes misuse of TLV-related macro.

This commit replaces usage of DECLARE_TLV_DB_LINEAR() with
SNDRV_CTL_TLVD_DECLARE_DB_SCALE(), to give proper information to
applications in user land.

Fixes: 3c166c7f1828 ("ASoC: Codec for STAC9766 used on the Efika")
Cc: Jon Smirl <jonsmirl@gmail.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/soc/codecs/stac9766.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c
index 0945c51..a718c653 100644
--- a/sound/soc/codecs/stac9766.c
+++ b/sound/soc/codecs/stac9766.c
@@ -85,10 +85,10 @@ static SOC_ENUM_SINGLE_DECL(stac9766_boost2_enum,
 static SOC_ENUM_SINGLE_DECL(stac9766_stereo_mic_enum,
 			    AC97_STAC_STEREO_MIC, 2, stac9766_stereo_mic);
 
-static const DECLARE_TLV_DB_LINEAR(master_tlv, -4600, 0);
-static const DECLARE_TLV_DB_LINEAR(record_tlv, 0, 2250);
-static const DECLARE_TLV_DB_LINEAR(beep_tlv, -4500, 0);
-static const DECLARE_TLV_DB_LINEAR(mix_tlv, -3450, 1200);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(master_tlv, -4650, 150, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(record_tlv,     0, 150, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(beep_tlv,   -4500, 300, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(mix_tlv,    -3450, 150, 0);
 
 static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {
 	SOC_DOUBLE_TLV("Speaker Volume", AC97_MASTER, 8, 0, 31, 1, master_tlv),
-- 
2.7.4

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

* Re: [PATCH 1/3] ASOC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR()
  2016-09-26 23:25 ` [PATCH 1/3] ASOC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
@ 2016-09-27  8:48   ` Charles Keepax
  2016-09-27 16:24   ` Applied "ASoC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR()" to the asoc tree Mark Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2016-09-27  8:48 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: tiwai, alsa-devel, broonie, lgirdwood, patches

On Tue, Sep 27, 2016 at 08:25:27AM +0900, Takashi Sakamoto wrote:
> As long as reading datasheet of WM8991, this driver includes wrong usage
> of DECLARE_TLV_DB_LINEAR().
> 
> In "Table 6 Input PGA Volume Range", volume is represented in 5 bits by
> 1.5 dB/step between -16.5/30.0 dB. Thus, 'in_pga_tlv' should be dB step
> representation.
> 
> In "Table 34 LOMIX and ROMIX Volume Range", volume is represented in three
> bits by -3 dB/step from 0 to -21 dB. Thus, 'out_mix_tlv' should be dB step
> represenation.
> 
> In "Table 36 LOPGA, ROPGA, LOUT, ROUT and SPKVOL Volume Range", volume is
> represented in 7 bits by 1 dB/step from -73 to 6 dB, including mute. Thus,
> 'out_pga_tlv' should be dB step representation.
> 
> In "Table 26 Digital Volume Range", volume is represented in 8 bits by
> 3/8 dB/step from -71.625 to 0 dB. Thus, 'out_dac_tlv' should be dB step
> representation.
> 
> In "Table 16 ADC Digital Volume Range", volume is represented in 8 bits by
> 3/8 dB/step from -71.625 to 17.625 dB. Thus, 'in_adc_tlv' should be dB step
> representation.
> 
> In "Table 23 Digital Sidetone Volume", volume is represented in 5 bits by
> 3 dB/step from -36 to 0 dB. Thus, 'out_sidetone_tlv' should be dB step
> representation.
> 
> In "Table 12 Left Input Mixer Volume Control", volume is represented in
> 3 bits by 3 dB/step from -12 to 6 dB
> 
> Totally, current implementation includes misuse of TLV-related macro.
> 
> This commit replaces usage of DECLARE_TLV_DB_LINEAR() with proper macros,
> to give proper information to applications in user land.
> 
> Fixes: 203db220718c ("ASoC: WM8991: Add initial WM8991 driver")
> Cc: patches@opensource.wolfsonmicro.com
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Thanks,
Charles

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

* Re: [PATCH 2/3] ASOC: wm8991: remove unused variable
  2016-09-26 23:25 ` [PATCH 2/3] ASOC: wm8991: remove unused variable Takashi Sakamoto
@ 2016-09-27  8:48   ` Charles Keepax
  2016-09-27 16:24   ` Applied "ASoC: wm8991: remove unused variable" to the asoc tree Mark Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Charles Keepax @ 2016-09-27  8:48 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: tiwai, alsa-devel, broonie, lgirdwood, patches

On Tue, Sep 27, 2016 at 08:25:28AM +0900, Takashi Sakamoto wrote:
> This driver has some unused variables. They should be removed.
> 
> Fixes: 203db220718c ("ASoC: WM8991: Add initial WM8991 driver")
> Cc: patches@opensource.wolfsonmicro.com
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>

Thanks,
Charles

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

* Applied "ASoC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR()" to the asoc tree
  2016-09-26 23:25 ` [PATCH 3/3] ASOC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
@ 2016-09-27 16:24   ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2016-09-27 16:24 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: tiwai, alsa-devel, broonie, lgirdwood

The patch

   ASoC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR()

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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

>From f2b2f6dcd48adf81007b66e39bb7ca21d9bde250 Mon Sep 17 00:00:00 2001
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Date: Tue, 27 Sep 2016 08:25:29 +0900
Subject: [PATCH] ASoC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR()

As long as reading datasheet of STAC9766/9767, this driver includes wrong
usage of DECLARE_TLV_DB_LINEAR().

In "8.1.2. Master Volume Registers", attenuation of lineout volumes is
represented in 5 bits by -1.5 dB/step from 0 to -46.5 dB. Thus,
'master_tlv' should be dB step representation.

In "8.1.14. Record Gain", gain of volumes is represented in 4 bits by
1.5 dB/step from 0 to 22.5 dB. Thus, 'record_tlv' should be dB step
representation.

In "8.1.5. PC BEEP Volume", attenuation of volume is represented in 4 bits
by -3 dB/step from 0 to 45 dB. Thus, 'beep_tlv' should be dB step
representation.

In "8.1.7. Stereo or Mic Volume" and so on, gain of volumes is represented
in 5 bits by -1.5 dB from 12 to -34.5 dB. Thus, 'mix_tlv' should be dB
step representation.

Totally, current implementation includes misuse of TLV-related macro.

This commit replaces usage of DECLARE_TLV_DB_LINEAR() with
SNDRV_CTL_TLVD_DECLARE_DB_SCALE(), to give proper information to
applications in user land.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/stac9766.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c
index 0945c51df003..a718c653dab3 100644
--- a/sound/soc/codecs/stac9766.c
+++ b/sound/soc/codecs/stac9766.c
@@ -85,10 +85,10 @@ static SOC_ENUM_SINGLE_DECL(stac9766_boost2_enum,
 static SOC_ENUM_SINGLE_DECL(stac9766_stereo_mic_enum,
 			    AC97_STAC_STEREO_MIC, 2, stac9766_stereo_mic);
 
-static const DECLARE_TLV_DB_LINEAR(master_tlv, -4600, 0);
-static const DECLARE_TLV_DB_LINEAR(record_tlv, 0, 2250);
-static const DECLARE_TLV_DB_LINEAR(beep_tlv, -4500, 0);
-static const DECLARE_TLV_DB_LINEAR(mix_tlv, -3450, 1200);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(master_tlv, -4650, 150, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(record_tlv,     0, 150, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(beep_tlv,   -4500, 300, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(mix_tlv,    -3450, 150, 0);
 
 static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = {
 	SOC_DOUBLE_TLV("Speaker Volume", AC97_MASTER, 8, 0, 31, 1, master_tlv),
-- 
2.9.3

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

* Applied "ASoC: wm8991: remove unused variable" to the asoc tree
  2016-09-26 23:25 ` [PATCH 2/3] ASOC: wm8991: remove unused variable Takashi Sakamoto
  2016-09-27  8:48   ` Charles Keepax
@ 2016-09-27 16:24   ` Mark Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Mark Brown @ 2016-09-27 16:24 UTC (permalink / raw)
  To: Takashi Sakamoto
  Cc: alsa-devel, tiwai, patches, lgirdwood, broonie, Charles Keepax

The patch

   ASoC: wm8991: remove unused variable

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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

>From c7e9426a02699b9f0873e3c2bb383bcb1dd9ab19 Mon Sep 17 00:00:00 2001
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Date: Tue, 27 Sep 2016 08:25:28 +0900
Subject: [PATCH] ASoC: wm8991: remove unused variable

This driver has some unused variables. They should be removed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/wm8991.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index 483b9535d366..9d4b6076e9a8 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -111,14 +111,12 @@ static bool wm8991_volatile(struct device *dev, unsigned int reg)
 	}
 }
 
-static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv, -1500, 600);
 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(in_pga_tlv, -1650, 150, 0);
 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(out_mix_tlv, -2100, 300, 0);
 static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_pga_tlv,
 	0x00, 0x2f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(SNDRV_CTL_TLVD_DB_GAIN_MUTE, 0, 1),
 	0x30, 0x7f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-7300, 100, 0),
 );
-static const DECLARE_TLV_DB_LINEAR(out_omix_tlv, -600, 0);
 static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_dac_tlv,
 	0x00, 0xbf, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-71625, 375, 1),
 	0xc0, 0xff, SNDRV_CTL_TLVD_DB_SCALE_ITEM(0, 0, 0),
-- 
2.9.3

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

* Applied "ASoC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR()" to the asoc tree
  2016-09-26 23:25 ` [PATCH 1/3] ASOC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
  2016-09-27  8:48   ` Charles Keepax
@ 2016-09-27 16:24   ` Mark Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Mark Brown @ 2016-09-27 16:24 UTC (permalink / raw)
  To: Takashi Sakamoto
  Cc: alsa-devel, tiwai, patches, lgirdwood, broonie, Charles Keepax

The patch

   ASoC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR()

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

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

>From 98695eab3c2de34265ac797b1c057215f8e78a1a Mon Sep 17 00:00:00 2001
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Date: Tue, 27 Sep 2016 08:25:27 +0900
Subject: [PATCH] ASoC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR()

As long as reading datasheet of WM8991, this driver includes wrong usage
of DECLARE_TLV_DB_LINEAR().

In "Table 6 Input PGA Volume Range", volume is represented in 5 bits by
1.5 dB/step between -16.5/30.0 dB. Thus, 'in_pga_tlv' should be dB step
representation.

In "Table 34 LOMIX and ROMIX Volume Range", volume is represented in three
bits by -3 dB/step from 0 to -21 dB. Thus, 'out_mix_tlv' should be dB step
represenation.

In "Table 36 LOPGA, ROPGA, LOUT, ROUT and SPKVOL Volume Range", volume is
represented in 7 bits by 1 dB/step from -73 to 6 dB, including mute. Thus,
'out_pga_tlv' should be dB step representation.

In "Table 26 Digital Volume Range", volume is represented in 8 bits by
3/8 dB/step from -71.625 to 0 dB. Thus, 'out_dac_tlv' should be dB step
representation.

In "Table 16 ADC Digital Volume Range", volume is represented in 8 bits by
3/8 dB/step from -71.625 to 17.625 dB. Thus, 'in_adc_tlv' should be dB step
representation.

In "Table 23 Digital Sidetone Volume", volume is represented in 5 bits by
3 dB/step from -36 to 0 dB. Thus, 'out_sidetone_tlv' should be dB step
representation.

In "Table 12 Left Input Mixer Volume Control", volume is represented in
3 bits by 3 dB/step from -12 to 6 dB

Totally, current implementation includes misuse of TLV-related macro.

This commit replaces usage of DECLARE_TLV_DB_LINEAR() with proper macros,
to give proper information to applications in user land.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/wm8991.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c
index c9ee0ac6a654..483b9535d366 100644
--- a/sound/soc/codecs/wm8991.c
+++ b/sound/soc/codecs/wm8991.c
@@ -112,13 +112,25 @@ static bool wm8991_volatile(struct device *dev, unsigned int reg)
 }
 
 static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv, -1500, 600);
-static const DECLARE_TLV_DB_LINEAR(in_pga_tlv, -1650, 3000);
-static const DECLARE_TLV_DB_LINEAR(out_mix_tlv, 0, -2100);
-static const DECLARE_TLV_DB_LINEAR(out_pga_tlv, -7300, 600);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(in_pga_tlv, -1650, 150, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(out_mix_tlv, -2100, 300, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_pga_tlv,
+	0x00, 0x2f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(SNDRV_CTL_TLVD_DB_GAIN_MUTE, 0, 1),
+	0x30, 0x7f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-7300, 100, 0),
+);
 static const DECLARE_TLV_DB_LINEAR(out_omix_tlv, -600, 0);
-static const DECLARE_TLV_DB_LINEAR(out_dac_tlv, -7163, 0);
-static const DECLARE_TLV_DB_LINEAR(in_adc_tlv, -7163, 1763);
-static const DECLARE_TLV_DB_LINEAR(out_sidetone_tlv, -3600, 0);
+static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_dac_tlv,
+	0x00, 0xbf, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-71625, 375, 1),
+	0xc0, 0xff, SNDRV_CTL_TLVD_DB_SCALE_ITEM(0, 0, 0),
+);
+static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(in_adc_tlv,
+	0x00, 0xef, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-71625, 375, 1),
+	0xf0, 0xff, SNDRV_CTL_TLVD_DB_SCALE_ITEM(17625, 0, 0),
+);
+static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_sidetone_tlv,
+	0x00, 0x0c, SNDRV_CTL_TLVD_DB_SCALE_ITEM(-3600, 300, 0),
+	0x0d, 0x0f, SNDRV_CTL_TLVD_DB_SCALE_ITEM(0, 0, 0),
+);
 
 static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
 				      struct snd_ctl_elem_value *ucontrol)
@@ -398,7 +410,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
 }
 
 /* INMIX dB values */
-static const DECLARE_TLV_DB_LINEAR(in_mix_tlv, -1200, 600);
+static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(in_mix_tlv, -1200, 300, 1);
 
 /* Left In PGA Connections */
 static const struct snd_kcontrol_new wm8991_dapm_lin12_pga_controls[] = {
-- 
2.9.3

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

end of thread, other threads:[~2016-09-27 16:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-26 23:25 [PATCH 0/3] ASOC: wm8991/stac9766: fix wrong usage of TLV-related macro Takashi Sakamoto
2016-09-26 23:25 ` [PATCH 1/3] ASOC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
2016-09-27  8:48   ` Charles Keepax
2016-09-27 16:24   ` Applied "ASoC: wm8991: fix wrong usage of DECLARE_TLV_DB_LINEAR()" to the asoc tree Mark Brown
2016-09-26 23:25 ` [PATCH 2/3] ASOC: wm8991: remove unused variable Takashi Sakamoto
2016-09-27  8:48   ` Charles Keepax
2016-09-27 16:24   ` Applied "ASoC: wm8991: remove unused variable" to the asoc tree Mark Brown
2016-09-26 23:25 ` [PATCH 3/3] ASOC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR() Takashi Sakamoto
2016-09-27 16:24   ` Applied "ASoC: stac9766: fix wrong usage of DECLARE_TLV_DB_LINEAR()" to the asoc tree 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.