Title: [9013] trunk: fix some small problem to make adau1761 can work now.
Revision
9013
Author
lliubbo
Date
2010-07-26 07:05:48 -0400 (Mon, 26 Jul 2010)

Log Message

fix some small problem to make adau1761 can work now.

Modified Paths


Diff

Modified: trunk/drivers/firmware/sigma.c (9012 => 9013)


--- trunk/drivers/firmware/sigma.c	2010-07-23 08:25:03 UTC (rev 9012)
+++ trunk/drivers/firmware/sigma.c	2010-07-26 11:05:48 UTC (rev 9013)
@@ -13,12 +13,12 @@
 #include <linux/i2c.h>
 #include <linux/sigma.h>
 
-/* Return: 0==OK, <0==error, >0==no more actions */
+/* Return: 0==OK, <0==error, =1 ==no more actions */
 int process_sigma_action(struct i2c_client *client, struct sigma_firmware *ssfw)
 {
 	struct sigma_action *sa = (void *)(ssfw->fw->data + ssfw->pos);
 	size_t len = sigma_action_len(sa);
-	int ret;
+	int ret = 0;
 
 	pr_debug("%s: instr:%i addr:%#x len:%zu\n", __func__,
 		sa->instr, sa->addr, len);
@@ -30,7 +30,8 @@
 			if (ssfw->fw->size < ssfw->pos + len)
 				return -EINVAL;
 			ret = i2c_master_send(client, (void *)&sa->addr, len);
-			len -= 2;
+			if (ret < 0)
+				return -EINVAL;
 			break;
 
 		case SIGMA_ACTION_DELAY:
@@ -46,11 +47,9 @@
 			return -EINVAL;
 	}
 
-	if (!ret) {
-		ssfw->pos += sigma_action_size(sa, len);
-		return ssfw->pos == ssfw->fw->size;
-	} else
-		return ret;
+	/* when arrive here ret=0 or sent data */
+	ssfw->pos += sigma_action_size(sa, len);
+	return ssfw->pos == ssfw->fw->size;
 }
 
 int process_sigma_actions(struct i2c_client *client, struct sigma_firmware *ssfw)

Modified: trunk/sound/soc/codecs/adau1761.c (9012 => 9013)


--- trunk/sound/soc/codecs/adau1761.c	2010-07-23 08:25:03 UTC (rev 9012)
+++ trunk/sound/soc/codecs/adau1761.c	2010-07-26 11:05:48 UTC (rev 9013)
@@ -262,32 +262,28 @@
 {
 	struct snd_soc_codec *codec = dai->codec;
 	u8 reg = 0;
-
 	if (mute) {
-		/* mute outputs */
-		reg = (snd_soc_read(codec, ADAU_PLBMLC0) & 0xFE) | 0x0;
-		snd_soc_write(codec, ADAU_PLBMLC0, reg);
-		reg = (snd_soc_read(codec, ADAU_PLBMRC0) & 0xFE) | 0x0;
-		snd_soc_write(codec, ADAU_PLBMRC0, reg);
-
 		/* mute inputs */
 		reg = (snd_soc_read(codec, ADAU_RECMLC0) & 0xFE) | 0x0;
 		snd_soc_write(codec, ADAU_RECMLC0, reg);
 		reg = (snd_soc_read(codec, ADAU_RECMRC0) & 0xFE) | 0x0;
 		snd_soc_write(codec, ADAU_RECMRC0, reg);
+		/* mute outputs */
+		reg = (snd_soc_read(codec, ADAU_PLBMLC0) & 0xFE) | 0x1;
+		snd_soc_write(codec, ADAU_PLBMLC0, reg);
+		reg = (snd_soc_read(codec, ADAU_PLBMRC0) & 0xFE) | 0x1;
+		snd_soc_write(codec, ADAU_PLBMRC0, reg);
 	} else {
-
+		/* un-mute outputs */
+		reg = (snd_soc_read(codec, ADAU_PLBMLC0) & 0xFE) | 0x0;
+		snd_soc_write(codec, ADAU_PLBMLC0, reg);
+		reg = (snd_soc_read(codec, ADAU_PLBMRC0) & 0xFE) | 0x0;
+		snd_soc_write(codec, ADAU_PLBMRC0, reg);
 		/* un-mute inputs */
 		reg = (snd_soc_read(codec, ADAU_RECMLC0) & 0xFE) | 0x1;
 		snd_soc_write(codec, ADAU_RECMLC0, reg);
 		reg = (snd_soc_read(codec, ADAU_RECMRC0) & 0xFE) | 0x1;
 		snd_soc_write(codec, ADAU_RECMRC0, reg);
-
-		/* un-mute outputs */
-		reg = (snd_soc_read(codec, ADAU_PLBMLC0) & 0xFE) | 0x1;
-		snd_soc_write(codec, ADAU_PLBMLC0, reg);
-		reg = (snd_soc_read(codec, ADAU_PLBMRC0) & 0xFE) | 0x1;
-		snd_soc_write(codec, ADAU_PLBMRC0, reg);
 	}
 
 	return 0;
@@ -493,14 +489,45 @@
 
 }
 
+/*
+ * read ADAU1761 hw register and update cache
+ */
+static int adau1761_read_reg_byte(struct snd_soc_codec *codec,
+	unsigned int reg)
+{
+	u8 addr[2];
+	u8 buf[1] = {0};
+
+	if (reg < ADAU_FIRSTREG)
+		reg = reg + ADAU_FIRSTREG;
+
+	if ((reg < ADAU_FIRSTREG) || (reg > ADAU_LASTREG))
+		return -EIO;
+
+	addr[0] = (u8)(reg >> 8);
+	addr[1] = (u8)(reg & 0xFF);
+
+	/* write the 2byte read address */
+	if (codec->hw_write(codec->control_data, addr, 2) != 2) {
+		printk(KERN_ERR "read_reg_byte:address write failed.");
+		return -EIO;
+	}
+
+	if (i2c_master_recv(codec->control_data, buf, 1) != 1)
+		return -EIO;
+
+	return buf[0];
+}
+
 static int adau1761_setprogram(struct snd_soc_codec *codec)
 {
 	int ret = 0;
 
 	snd_soc_write(codec, ADAU_DSP_ENA, 0x01);
 	/* don't waste time writing program for adau1361 */
-	if (codec->hw_read(codec, ADAU_DSP_ENA) != 0x01)
+	if (adau1761_read_reg_byte(codec, ADAU_DSP_ENA) != 0x01)
 		return -ENODEV;
+
 	ret = process_sigma_firmware(codec->control_data, ADAU1761_FIRMWARE);
 
 	return ret;
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to