* [PATCH] ASoC: ak4642: Add Playback Volume control
@ 2010-06-25 7:57 Kuninori Morimoto
2010-06-25 10:50 ` Liam Girdwood
0 siblings, 1 reply; 6+ messages in thread
From: Kuninori Morimoto @ 2010-06-25 7:57 UTC (permalink / raw)
To: Mark Brown; +Cc: Linux-ALSA
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
This patch works for me.
But I'm not sure it is correct settings.
Please check it carefully
sound/soc/codecs/ak4642.c | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 9a6157f..ce4e6ec 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -28,6 +28,7 @@
#include <linux/slab.h>
#include <sound/soc-dapm.h>
#include <sound/initval.h>
+#include <sound/tlv.h>
#include "ak4642.h"
@@ -103,6 +104,23 @@
struct snd_soc_codec_device soc_codec_dev_ak4642;
+/*
+ * Playback Volume (table 39)
+ *
+ * max : 0x00 : +12.0 dB
+ * ( 0.5 dB step )
+ * min : 0xFE : -115.0 dB
+ * mute: 0xFF
+ */
+static const DECLARE_TLV_DB_SCALE(out_tlv, -11500, 50, 1);
+
+static const struct snd_kcontrol_new ak4642_snd_controls[] = {
+
+ SOC_DOUBLE_R_TLV("Playback Volume", L_DVC, R_DVC,
+ 0, 0xFF, 1, out_tlv),
+};
+
+
/* codec private data */
struct ak4642_priv {
struct snd_soc_codec codec;
@@ -190,7 +208,6 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
*
* PLL, Master Mode
* Audio I/F Format :MSB justified (ADC & DAC)
- * Digital Volume: -8dB
* Bass Boost Level : Middle
*
* This operation came from example code of
@@ -200,8 +217,6 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
ak4642_write(codec, 0x0e, 0x19);
ak4642_write(codec, 0x09, 0x91);
ak4642_write(codec, 0x0c, 0x91);
- ak4642_write(codec, 0x0a, 0x28);
- ak4642_write(codec, 0x0d, 0x28);
ak4642_write(codec, 0x00, 0x64);
snd_soc_update_bits(codec, PW_MGMT2, PMHP_MASK, PMHP);
snd_soc_update_bits(codec, PW_MGMT2, HPMTN, HPMTN);
@@ -446,6 +461,10 @@ static int ak4642_init(struct ak4642_priv *ak4642)
return ret;
}
+ /* default volume */
+ ak4642_write(codec, L_DVC, 0x28);
+ ak4642_write(codec, R_DVC, 0x28);
+
return ret;
}
@@ -524,6 +543,9 @@ static int ak4642_probe(struct platform_device *pdev)
goto pcm_err;
}
+ snd_soc_add_controls(ak4642_codec, ak4642_snd_controls,
+ ARRAY_SIZE(ak4642_snd_controls));
+
dev_info(&pdev->dev, "AK4642 Audio Codec %s", AK4642_VERSION);
return ret;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: ak4642: Add Playback Volume control
2010-06-25 7:57 [PATCH] ASoC: ak4642: Add Playback Volume control Kuninori Morimoto
@ 2010-06-25 10:50 ` Liam Girdwood
2010-06-28 0:30 ` Kuninori Morimoto
0 siblings, 1 reply; 6+ messages in thread
From: Liam Girdwood @ 2010-06-25 10:50 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown
On Fri, 2010-06-25 at 16:57 +0900, Kuninori Morimoto wrote:
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
> This patch works for me.
> But I'm not sure it is correct settings.
> Please check it carefully
>
> sound/soc/codecs/ak4642.c | 28 +++++++++++++++++++++++++---
> 1 files changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
> index 9a6157f..ce4e6ec 100644
> --- a/sound/soc/codecs/ak4642.c
> +++ b/sound/soc/codecs/ak4642.c
> @@ -28,6 +28,7 @@
> #include <linux/slab.h>
> #include <sound/soc-dapm.h>
> #include <sound/initval.h>
> +#include <sound/tlv.h>
>
> #include "ak4642.h"
>
> @@ -103,6 +104,23 @@
>
> struct snd_soc_codec_device soc_codec_dev_ak4642;
>
> +/*
> + * Playback Volume (table 39)
> + *
> + * max : 0x00 : +12.0 dB
> + * ( 0.5 dB step )
> + * min : 0xFE : -115.0 dB
> + * mute: 0xFF
> + */
> +static const DECLARE_TLV_DB_SCALE(out_tlv, -11500, 50, 1);
> +
> +static const struct snd_kcontrol_new ak4642_snd_controls[] = {
> +
> + SOC_DOUBLE_R_TLV("Playback Volume", L_DVC, R_DVC,
> + 0, 0xFF, 1, out_tlv),
Is this for the "Master Playback Volume" ? If so, It should be "Master
Playback Volume"
> +};
> +
> +
> /* codec private data */
> struct ak4642_priv {
> struct snd_soc_codec codec;
> @@ -190,7 +208,6 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
> *
> * PLL, Master Mode
> * Audio I/F Format :MSB justified (ADC & DAC)
> - * Digital Volume: -8dB
Any reason for this ?
> * Bass Boost Level : Middle
> *
> * This operation came from example code of
> @@ -200,8 +217,6 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
> ak4642_write(codec, 0x0e, 0x19);
> ak4642_write(codec, 0x09, 0x91);
> ak4642_write(codec, 0x0c, 0x91);
> - ak4642_write(codec, 0x0a, 0x28);
> - ak4642_write(codec, 0x0d, 0x28);
and this. Both are not mentioned in the commit message.
> ak4642_write(codec, 0x00, 0x64);
> snd_soc_update_bits(codec, PW_MGMT2, PMHP_MASK, PMHP);
> snd_soc_update_bits(codec, PW_MGMT2, HPMTN, HPMTN);
> @@ -446,6 +461,10 @@ static int ak4642_init(struct ak4642_priv *ak4642)
> return ret;
> }
>
> + /* default volume */
> + ak4642_write(codec, L_DVC, 0x28);
> + ak4642_write(codec, R_DVC, 0x28);
> +
> return ret;
> }
>
> @@ -524,6 +543,9 @@ static int ak4642_probe(struct platform_device *pdev)
> goto pcm_err;
> }
>
> + snd_soc_add_controls(ak4642_codec, ak4642_snd_controls,
> + ARRAY_SIZE(ak4642_snd_controls));
> +
> dev_info(&pdev->dev, "AK4642 Audio Codec %s", AK4642_VERSION);
> return ret;
>
Thanks
Liam
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: ak4642: Add Playback Volume control
2010-06-25 10:50 ` Liam Girdwood
@ 2010-06-28 0:30 ` Kuninori Morimoto
2010-06-28 3:07 ` Kuninori Morimoto
2010-06-28 3:10 ` Kuninori Morimoto
0 siblings, 2 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2010-06-28 0:30 UTC (permalink / raw)
To: Liam Girdwood; +Cc: Linux-ALSA, Mark Brown
Dear Liam
Thanks for checking patch
> > + SOC_DOUBLE_R_TLV("Playback Volume", L_DVC, R_DVC,
> > + 0, 0xFF, 1, out_tlv),
>
> Is this for the "Master Playback Volume" ? If so, It should be "Master
> Playback Volume"
I understand. Thanks
I will send V2 patch
> > * PLL, Master Mode
> > * Audio I/F Format :MSB justified (ADC & DAC)
> > - * Digital Volume: -8dB
>
> Any reason for this ?
>
> > * Bass Boost Level : Middle
> > *
> > * This operation came from example code of
> > @@ -200,8 +217,6 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
> > ak4642_write(codec, 0x0e, 0x19);
> > ak4642_write(codec, 0x09, 0x91);
> > ak4642_write(codec, 0x0c, 0x91);
> > - ak4642_write(codec, 0x0a, 0x28);
> > - ak4642_write(codec, 0x0d, 0x28);
>
> and this. Both are not mentioned in the commit message.
Sorry. Both are "L_DVC" and "R_DVC". and 0x28 mean -8 dB
I removed it because if ak4642_dai_startup have it,
user can not change Playback Volume.
Best regards
--
Kuninori Morimoto
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: ak4642: Add Playback Volume control
2010-06-28 0:30 ` Kuninori Morimoto
@ 2010-06-28 3:07 ` Kuninori Morimoto
2010-06-28 8:47 ` Mark Brown
2010-06-28 3:10 ` Kuninori Morimoto
1 sibling, 1 reply; 6+ messages in thread
From: Kuninori Morimoto @ 2010-06-28 3:07 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood; +Cc: Linux-ALSA
Dear Liam, Mark
> > Is this for the "Master Playback Volume" ? If so, It should be "Master
> > Playback Volume"
Now I'm creating V2 patch.
And I have 2 questions
1) name
Manual said this register name is "Digital Volume Control".
In this case, should I use "Digital Playback Volume" ?
or "Master Playback Volume" ?
2) settings
This chip is
> +/*
> + * Playback Volume (table 39)
> + *
> + * max : 0x00 : +12.0 dB
> + * ( 0.5 dB step )
> + * min : 0xFE : -115.0 dB
> + * mute: 0xFF
> + */
min is 0xFE (-115.0 dB)
and last 0xFF mean "mute".
and DECLARE_TLV_DB_SCALE have "mute" flag.
In this case,
> +static const DECLARE_TLV_DB_SCALE(out_tlv, -11500, 50, 1);
Is this -11500 correct ?
it should be -11550 ?
> +static const struct snd_kcontrol_new ak4642_snd_controls[] = {
> +
> + SOC_DOUBLE_R_TLV("Playback Volume", L_DVC, R_DVC,
> + 0, 0xFF, 1, out_tlv),
And here, Is 0xFF correct here ?
Is it 0xFE ?
I asked because I noticed amixer's output seems not correct.
There is 0.5db difference between register and amixer's output.
Best regards
--
Kuninori Morimoto
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: ak4642: Add Playback Volume control
2010-06-28 3:07 ` Kuninori Morimoto
@ 2010-06-28 8:47 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2010-06-28 8:47 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: Linux-ALSA, Liam Girdwood
On Mon, Jun 28, 2010 at 12:07:05PM +0900, Kuninori Morimoto wrote:
> Manual said this register name is "Digital Volume Control".
> In this case, should I use "Digital Playback Volume" ?
> or "Master Playback Volume" ?
Either is fine.
> > +static const DECLARE_TLV_DB_SCALE(out_tlv, -11500, 50, 1);
> Is this -11500 correct ?
> it should be -11550 ?
Should be -11600. You can check this by using an application like
alsamixer and looking at the dB values displayed in the UI.
> > +static const struct snd_kcontrol_new ak4642_snd_controls[] = {
> > + SOC_DOUBLE_R_TLV("Playback Volume", L_DVC, R_DVC,
> > + 0, 0xFF, 1, out_tlv),
> And here, Is 0xFF correct here ?
> Is it 0xFE ?
No, 0xff is still a valid value.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: ak4642: Add Playback Volume control
2010-06-28 0:30 ` Kuninori Morimoto
2010-06-28 3:07 ` Kuninori Morimoto
@ 2010-06-28 3:10 ` Kuninori Morimoto
1 sibling, 0 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2010-06-28 3:10 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood; +Cc: Linux-ALSA
Dear Liam, Mark
> > Is this for the "Master Playback Volume" ? If so, It should be "Master
> > Playback Volume"
Now I'm creating V2 patch.
And I have 2 questions
1) name
Manual said this register name is "Digital Volume Control".
In this case, should I use "Digital Playback Volume" ?
or "Master Playback Volume" ?
2) settings
This chip is
> +/*
> + * Playback Volume (table 39)
> + *
> + * max : 0x00 : +12.0 dB
> + * ( 0.5 dB step )
> + * min : 0xFE : -115.0 dB
> + * mute: 0xFF
> + */
min is 0xFE (-115.0 dB)
and last 0xFF mean "mute".
and DECLARE_TLV_DB_SCALE have "mute" flag.
In this case,
> +static const DECLARE_TLV_DB_SCALE(out_tlv, -11500, 50, 1);
Is this -11500 correct ?
it should be -11550 ?
> +static const struct snd_kcontrol_new ak4642_snd_controls[] = {
> +
> + SOC_DOUBLE_R_TLV("Playback Volume", L_DVC, R_DVC,
> + 0, 0xFF, 1, out_tlv),
And here, Is 0xFF correct here ?
Is it 0xFE ?
I asked because I noticed amixer's output seems not correct.
There is 0.5db difference between register and amixer's output.
Best regards
--
Kuninori Morimoto
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-06-28 8:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-25 7:57 [PATCH] ASoC: ak4642: Add Playback Volume control Kuninori Morimoto
2010-06-25 10:50 ` Liam Girdwood
2010-06-28 0:30 ` Kuninori Morimoto
2010-06-28 3:07 ` Kuninori Morimoto
2010-06-28 8:47 ` Mark Brown
2010-06-28 3:10 ` Kuninori Morimoto
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).