Skip to contentSkip to conversation

ASoC: tlv320dac33: Burst mode BCLK divider fixes

PATCH Applied Peter Ujfalusi 3 participants 5 messages Jan 20, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ASoC: tlv320dac33: Burst mode BCLK divider fixes

Hello,

The following patches provides fixes for the BCLK clock divider configuration in tlv320dac33 codec.
BCLK divider is used to specify the speed of the serial bus.
The speed of the bus can be (must be) faster than the actual stream's sample rate in order to use the system in burst mode.

With the introduction of mode7 FIFO mode, the BCLK handling got broken in this mode, the first patch fixes this issue.
The second patch adds support for configuring the burst mode BCLK through platform data.

---
Peter Ujfalusi (2):
ASoC: tlv320dac33: BCLK divider fix
ASoC: tlv320dac33: Burst mode BCLK divider configuration

 include/sound/tlv320dac33-plat.h |    1 +
 sound/soc/codecs/tlv320dac33.c   |   22 +++++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)
#1 lore raw

PATCH 1/2 ASoC: tlv320dac33: BCLK divider fix

The BCLK divider was not configured in case of mode7.
This leads to unpredictable behavior when switching between FIFO modes. Configure the BCLK divider depending on the fifo_mode (FIFO is in use, or FIFO bypass).

---
 sound/soc/codecs/tlv320dac33.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
sound/soc/codecs/tlv320dac33.c +6 -5
index 65683aa..e1aa66f 100644
@@ -845,11 +845,14 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream)
 	dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_A, aictrl_a);
 	dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_B, aictrl_b);
 
-	switch (dac33->fifo_mode) {
-	case DAC33_FIFO_MODE1:
-		/* 20: BCLK divide ratio */
+	/* BCLK divide ratio */
+	if (dac33->fifo_mode)
 		dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, 3);
+	else
+		dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, 32);
 
+	switch (dac33->fifo_mode) {
+	case DAC33_FIFO_MODE1:
 		dac33_write16(codec, DAC33_ATHR_MSB,
 			      DAC33_THRREG(dac33->alarm_threshold));
 		break;
@@ -864,8 +867,6 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream)
 			DAC33_THRREG(10));
 		break;
 	default:
-		/* BYPASS mode */
-		dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, 32);
 		break;
 	}
 
Signature · 1 line
1.6.6
#2 lore raw

PATCH 2/2 ASoC: tlv320dac33: Burst mode BCLK divider configuration

Add possibility to configure the burst mode BCLK divider through platform data structure.
The BCLK divider changes the actual speed of the serial bus in burst mode, which is faster than the sampling frequency of the running stream. In this way platforms can experiment with the optimal burst speed without the need to modify the codec driver itself.

---
 include/sound/tlv320dac33-plat.h |    1 +
 sound/soc/codecs/tlv320dac33.c   |   15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
include/sound/tlv320dac33-plat.h +1 -0
index 5858d06..ac06652 100644
@@ -15,6 +15,7 @@
 
 struct tlv320dac33_platform_data {
 	int power_gpio;
+	u8 burst_bclkdiv;
 };
 
 #endif /* __TLV320DAC33_PLAT_H */
sound/soc/codecs/tlv320dac33.c +13 -2
index e1aa66f..1b35d0c 100644
@@ -91,6 +91,7 @@ struct tlv320dac33_priv {
 					 * this */
 	enum dac33_fifo_modes fifo_mode;/* FIFO mode selection */
 	unsigned int nsample;		/* burst read amount from host */
+	u8 burst_bclkdiv;		/* BCLK divider value in burst mode */
 
 	enum dac33_state state;
 };
@@ -845,9 +846,18 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream)
 	dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_A, aictrl_a);
 	dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_B, aictrl_b);
 
-	/* BCLK divide ratio */
+	/*
+	 * BCLK divide ratio
+	 * 0: 1.5
+	 * 1: 1
+	 * 2: 2
+	 * ...
+	 * 254: 254
+	 * 255: 255
+	 */
 	if (dac33->fifo_mode)
-		dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, 3);
+		dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C,
+							dac33->burst_bclkdiv);
 	else
 		dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, 32);
 
@@ -1239,6 +1249,7 @@ static int __devinit dac33_i2c_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, dac33);
 
 	dac33->power_gpio = pdata->power_gpio;
+	dac33->burst_bclkdiv = pdata->burst_bclkdiv;
 	dac33->irq = client->irq;
 	dac33->nsample = NSAMPLE_MAX;
 	/* Disable FIFO use by default */
Signature · 1 line
1.6.6
Acked-by on the v1 series
#3 lore raw
In reply to Peter Ujfalusi
Quoted 13 lines · Peter Ujfalusi

Hello,

The following patches provides fixes for the BCLK clock divider configuration in tlv320dac33 codec.
BCLK divider is used to specify the speed of the serial bus.
The speed of the bus can be (must be) faster than the actual stream's sample rate in order to use the system in burst mode.

With the introduction of mode7 FIFO mode, the BCLK handling got broken in this mode, the first patch fixes this issue.
The second patch adds support for configuring the burst mode BCLK through platform data.

Quoted 9 lines

---
Peter Ujfalusi (2):
ASoC: tlv320dac33: BCLK divider fix
ASoC: tlv320dac33: Burst mode BCLK divider configuration

 include/sound/tlv320dac33-plat.h |    1 +
 sound/soc/codecs/tlv320dac33.c   |   22 +++++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)
Applied
#4 lore raw
In reply to Peter Ujfalusi
Quoted 2 lines · Peter Ujfalusi

The following patches provides fixes for the BCLK clock divider configuration in tlv320dac33 codec.

Applied both, thanks.