* [PATCH] ASoC: ak4642: convert to soc-cache
@ 2011-10-11 12:20 Axel Lin
2011-10-12 10:21 ` Mark Brown
2011-10-13 9:03 ` [PATCH] ASoC: ak4642: fixup cache register table Kuninori Morimoto
0 siblings, 2 replies; 5+ messages in thread
From: Axel Lin @ 2011-10-11 12:20 UTC (permalink / raw)
To: linux-kernel; +Cc: Kuninori Morimoto, Liam Girdwood, Mark Brown, alsa-devel
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
Hi Kuninori,
This patch converts ak4642 to use soc-cache APIs.
I don't have this hardware, I'd appreciate if you can test this patch.
Thanks,
Axel
sound/soc/codecs/ak4642.c | 82 ++++++--------------------------------------
1 files changed, 12 insertions(+), 70 deletions(-)
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 68fc16c..80a9fe8 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -157,7 +157,6 @@ static const struct snd_kcontrol_new ak4642_snd_controls[] = {
struct ak4642_priv {
unsigned int sysclk;
enum snd_soc_control_type control_type;
- void *control_data;
};
/*
@@ -176,64 +175,6 @@ static const u16 ak4642_reg[AK4642_CACHEREGNUM] = {
0x0000,
};
-/*
- * read ak4642 register cache
- */
-static inline unsigned int ak4642_read_reg_cache(struct snd_soc_codec *codec,
- unsigned int reg)
-{
- u16 *cache = codec->reg_cache;
- if (reg >= AK4642_CACHEREGNUM)
- return -1;
- return cache[reg];
-}
-
-/*
- * write ak4642 register cache
- */
-static inline void ak4642_write_reg_cache(struct snd_soc_codec *codec,
- u16 reg, unsigned int value)
-{
- u16 *cache = codec->reg_cache;
- if (reg >= AK4642_CACHEREGNUM)
- return;
-
- cache[reg] = value;
-}
-
-/*
- * write to the AK4642 register space
- */
-static int ak4642_write(struct snd_soc_codec *codec, unsigned int reg,
- unsigned int value)
-{
- u8 data[2];
-
- /* data is
- * D15..D8 AK4642 register offset
- * D7...D0 register data
- */
- data[0] = reg & 0xff;
- data[1] = value & 0xff;
-
- if (codec->hw_write(codec->control_data, data, 2) == 2) {
- ak4642_write_reg_cache(codec, reg, value);
- return 0;
- } else
- return -EIO;
-}
-
-static int ak4642_sync(struct snd_soc_codec *codec)
-{
- u16 *cache = codec->reg_cache;
- int i, r = 0;
-
- for (i = 0; i < AK4642_CACHEREGNUM; i++)
- r |= ak4642_write(codec, i, cache[i]);
-
- return r;
-};
-
static int ak4642_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -253,8 +194,8 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
*/
snd_soc_update_bits(codec, MD_CTL4, DACH, DACH);
snd_soc_update_bits(codec, MD_CTL3, BST1, BST1);
- ak4642_write(codec, L_IVC, 0x91); /* volume */
- ak4642_write(codec, R_IVC, 0x91); /* volume */
+ snd_soc_write(codec, L_IVC, 0x91); /* volume */
+ snd_soc_write(codec, R_IVC, 0x91); /* volume */
snd_soc_update_bits(codec, PW_MGMT1, PMVCM | PMMIN | PMDAC,
PMVCM | PMMIN | PMDAC);
snd_soc_update_bits(codec, PW_MGMT2, PMHP_MASK, PMHP);
@@ -273,9 +214,9 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
* This operation came from example code of
* "ASAHI KASEI AK4642" (japanese) manual p94.
*/
- ak4642_write(codec, SG_SL1, PMMP | MGAIN0);
- ak4642_write(codec, TIMER, ZTM(0x3) | WTM(0x3));
- ak4642_write(codec, ALC_CTL1, ALC | LMTH0);
+ snd_soc_write(codec, SG_SL1, PMMP | MGAIN0);
+ snd_soc_write(codec, TIMER, ZTM(0x3) | WTM(0x3));
+ snd_soc_write(codec, ALC_CTL1, ALC | LMTH0);
snd_soc_update_bits(codec, PW_MGMT1, PMVCM | PMADL,
PMVCM | PMADL);
snd_soc_update_bits(codec, PW_MGMT3, PMADR, PMADR);
@@ -463,7 +404,7 @@ static struct snd_soc_dai_driver ak4642_dai = {
static int ak4642_resume(struct snd_soc_codec *codec)
{
- ak4642_sync(codec);
+ snd_soc_cache_sync(codec);
return 0;
}
@@ -471,11 +412,15 @@ static int ak4642_resume(struct snd_soc_codec *codec)
static int ak4642_probe(struct snd_soc_codec *codec)
{
struct ak4642_priv *ak4642 = snd_soc_codec_get_drvdata(codec);
+ int ret;
dev_info(codec->dev, "AK4642 Audio Codec %s", AK4642_VERSION);
- codec->hw_write = (hw_write_t)i2c_master_send;
- codec->control_data = ak4642->control_data;
+ ret = snd_soc_codec_set_cache_io(codec, 8, 8, ak4642->control_type);
+ if (ret < 0) {
+ dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
+ return ret;
+ }
snd_soc_add_controls(codec, ak4642_snd_controls,
ARRAY_SIZE(ak4642_snd_controls));
@@ -486,8 +431,6 @@ static int ak4642_probe(struct snd_soc_codec *codec)
static struct snd_soc_codec_driver soc_codec_dev_ak4642 = {
.probe = ak4642_probe,
.resume = ak4642_resume,
- .read = ak4642_read_reg_cache,
- .write = ak4642_write,
.reg_cache_size = ARRAY_SIZE(ak4642_reg),
.reg_word_size = sizeof(u8),
.reg_cache_default = ak4642_reg,
@@ -505,7 +448,6 @@ static __devinit int ak4642_i2c_probe(struct i2c_client *i2c,
return -ENOMEM;
i2c_set_clientdata(i2c, ak4642);
- ak4642->control_data = i2c;
ak4642->control_type = SND_SOC_I2C;
ret = snd_soc_register_codec(&i2c->dev,
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: ak4642: convert to soc-cache
2011-10-11 12:20 [PATCH] ASoC: ak4642: convert to soc-cache Axel Lin
@ 2011-10-12 10:21 ` Mark Brown
2011-10-13 9:03 ` [PATCH] ASoC: ak4642: fixup cache register table Kuninori Morimoto
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2011-10-12 10:21 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Kuninori Morimoto, Liam Girdwood, alsa-devel
On Tue, Oct 11, 2011 at 08:20:53PM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] ASoC: ak4642: fixup cache register table
2011-10-11 12:20 [PATCH] ASoC: ak4642: convert to soc-cache Axel Lin
2011-10-12 10:21 ` Mark Brown
@ 2011-10-13 9:03 ` Kuninori Morimoto
2011-10-13 9:16 ` Axel Lin
2011-10-13 10:58 ` Mark Brown
1 sibling, 2 replies; 5+ messages in thread
From: Kuninori Morimoto @ 2011-10-13 9:03 UTC (permalink / raw)
To: Axel Lin, Mark Brown, Liam Girdwood
Cc: linux-kernel, alsa-devel, Kuninori Morimoto
ak4642 register was 8bit, but cache table was defined as 16bit.
ak4642 doesn't work correctry without this patch.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/codecs/ak4642.c | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 5e25191..d8fc044 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -161,17 +161,17 @@ struct ak4642_priv {
/*
* ak4642 register cache
*/
-static const u16 ak4642_reg[AK4642_CACHEREGNUM] = {
- 0x0000, 0x0000, 0x0001, 0x0000,
- 0x0002, 0x0000, 0x0000, 0x0000,
- 0x00e1, 0x00e1, 0x0018, 0x0000,
- 0x00e1, 0x0018, 0x0011, 0x0008,
- 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000,
+static const u8 ak4642_reg[AK4642_CACHEREGNUM] = {
+ 0x00, 0x00, 0x01, 0x00,
+ 0x02, 0x00, 0x00, 0x00,
+ 0xe1, 0xe1, 0x18, 0x00,
+ 0xe1, 0x18, 0x11, 0x08,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00,
};
static int ak4642_dai_startup(struct snd_pcm_substream *substream,
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: ak4642: fixup cache register table
2011-10-13 9:03 ` [PATCH] ASoC: ak4642: fixup cache register table Kuninori Morimoto
@ 2011-10-13 9:16 ` Axel Lin
2011-10-13 10:58 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Axel Lin @ 2011-10-13 9:16 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: Mark Brown, Liam Girdwood, linux-kernel, alsa-devel
2011/10/13 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:
> ak4642 register was 8bit, but cache table was defined as 16bit.
> ak4642 doesn't work correctry without this patch.
>
ak4535 also has the same bug. I'm sending a patch for ak4535.
Regards,
Axel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: ak4642: fixup cache register table
2011-10-13 9:03 ` [PATCH] ASoC: ak4642: fixup cache register table Kuninori Morimoto
2011-10-13 9:16 ` Axel Lin
@ 2011-10-13 10:58 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2011-10-13 10:58 UTC (permalink / raw)
To: Kuninori Morimoto; +Cc: Axel Lin, Liam Girdwood, linux-kernel, alsa-devel
On Thu, Oct 13, 2011 at 02:03:54AM -0700, Kuninori Morimoto wrote:
> ak4642 register was 8bit, but cache table was defined as 16bit.
> ak4642 doesn't work correctry without this patch.
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-10-13 10:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-11 12:20 [PATCH] ASoC: ak4642: convert to soc-cache Axel Lin
2011-10-12 10:21 ` Mark Brown
2011-10-13 9:03 ` [PATCH] ASoC: ak4642: fixup cache register table Kuninori Morimoto
2011-10-13 9:16 ` Axel Lin
2011-10-13 10:58 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox