[alsa-devel] [RFC][PATCH 1/3] ASoC: ak4642: make sure snd_soc_codec value for ak4642

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Wed Jul 14 02:59:31 CEST 2010


If snd_soc_card has some dai_link,
there is a possibility that the snd_coc_codec value
which came from function is not ak4642's codec.
This patch make sure it for ak4642

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
 sound/soc/codecs/ak4642.c |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index 60b83b4..fb44787 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -150,7 +150,11 @@ static const u16 ak4642_reg[AK4642_CACHEREGNUM] = {
 static inline unsigned int ak4642_read_reg_cache(struct snd_soc_codec *codec,
 	unsigned int reg)
 {
-	u16 *cache = codec->reg_cache;
+	u16 *cache;
+
+	codec = ak4642_codec;
+	cache = codec->reg_cache;
+
 	if (reg >= AK4642_CACHEREGNUM)
 		return -1;
 	return cache[reg];
@@ -162,7 +166,10 @@ static inline unsigned int ak4642_read_reg_cache(struct snd_soc_codec *codec,
 static inline void ak4642_write_reg_cache(struct snd_soc_codec *codec,
 	u16 reg, unsigned int value)
 {
-	u16 *cache = codec->reg_cache;
+	u16 *cache;
+
+	codec = ak4642_codec;
+	cache = codec->reg_cache;
 	if (reg >= AK4642_CACHEREGNUM)
 		return;
 
@@ -177,6 +184,8 @@ static int ak4642_write(struct snd_soc_codec *codec, unsigned int reg,
 {
 	u8 data[2];
 
+	codec = ak4642_codec;
+
 	/* data is
 	 *   D15..D8 AK4642 register offset
 	 *   D7...D0 register data
@@ -193,9 +202,12 @@ static int ak4642_write(struct snd_soc_codec *codec, unsigned int reg,
 
 static int ak4642_sync(struct snd_soc_codec *codec)
 {
-	u16 *cache = codec->reg_cache;
+	u16 *cache;
 	int i, r = 0;
 
+	codec = ak4642_codec;
+	cache = codec->reg_cache;
+
 	for (i = 0; i < AK4642_CACHEREGNUM; i++)
 		r |= ak4642_write(codec, i, cache[i]);
 
@@ -206,7 +218,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream,
 			      struct snd_soc_dai *dai)
 {
 	int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
-	struct snd_soc_codec *codec = dai->codec;
+	struct snd_soc_codec *codec = ak4642_codec;
 
 	if (is_play) {
 		/*
@@ -256,7 +268,7 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream,
 			       struct snd_soc_dai *dai)
 {
 	int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
-	struct snd_soc_codec *codec = dai->codec;
+	struct snd_soc_codec *codec = ak4642_codec;
 
 	if (is_play) {
 		/* stop headphone output */
@@ -276,7 +288,8 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream,
 static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai,
 	int clk_id, unsigned int freq, int dir)
 {
-	struct snd_soc_codec *codec = codec_dai->codec;
+	struct snd_soc_codec *codec = ak4642_codec;
+
 	u8 pll;
 
 	switch (freq) {
@@ -308,7 +321,7 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai,
 
 static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 {
-	struct snd_soc_codec *codec = dai->codec;
+	struct snd_soc_codec *codec = ak4642_codec;
 	u8 data;
 	u8 bcko;
 
@@ -336,7 +349,7 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream,
 				struct snd_pcm_hw_params *params,
 				struct snd_soc_dai *dai)
 {
-	struct snd_soc_codec *codec = dai->codec;
+	struct snd_soc_codec *codec = ak4642_codec;
 	u8 rate;
 
 	switch (params_rate(params)) {
-- 
1.7.0.4



More information about the Alsa-devel mailing list