* [PATCH 1/2] sound: soc: tlv320aic32x4: Fix problem with first capture.
@ 2012-10-30 15:29 Javier Martin
2012-10-30 15:29 ` [PATCH 2/2] sound: soc: tlv320aic32x4: Add rstn gpio to platform data Javier Martin
0 siblings, 1 reply; 3+ messages in thread
From: Javier Martin @ 2012-10-30 15:29 UTC (permalink / raw)
To: alsa-devel; +Cc: lrg, lars, w.sang, Javier Martin, broonie
In its previous status, the first capture didn't work properly;
nothing was actually recorded from the microphone. This
behaviour was observed using a Visstrim M10 board.
In order to solve this BUG a workaround has been added that,
during the initialization process of the codec, powers on and
off the ADC.
The issue seems related to a HW BUG or some behavior that
is not documented in the datasheet.
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
---
sound/soc/codecs/tlv320aic32x4.c | 10 ++++++++++
sound/soc/codecs/tlv320aic32x4.h | 3 +++
2 files changed, 13 insertions(+)
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index b0a73d3..aad92f9 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -675,6 +675,16 @@ static int aic32x4_probe(struct snd_soc_codec *codec)
ARRAY_SIZE(aic32x4_snd_controls));
aic32x4_add_widgets(codec);
+ /*
+ * Workaround: for an unknown reason, the ADC needs to be powered up
+ * and down for the first capture to work properly. It seems related to
+ * a HW BUG or some kind of behavior not documented in the datasheet.
+ */
+ tmp_reg = snd_soc_read(codec, AIC32X4_ADCSETUP);
+ snd_soc_write(codec, AIC32X4_ADCSETUP, tmp_reg |
+ AIC32X4_LADC_EN | AIC32X4_RADC_EN);
+ snd_soc_write(codec, AIC32X4_ADCSETUP, tmp_reg);
+
return 0;
}
diff --git a/sound/soc/codecs/tlv320aic32x4.h b/sound/soc/codecs/tlv320aic32x4.h
index aae2b24..3577422 100644
--- a/sound/soc/codecs/tlv320aic32x4.h
+++ b/sound/soc/codecs/tlv320aic32x4.h
@@ -94,6 +94,9 @@
#define AIC32X4_WORD_LEN_24BITS 0x02
#define AIC32X4_WORD_LEN_32BITS 0x03
+#define AIC32X4_LADC_EN (1 << 7)
+#define AIC32X4_RADC_EN (1 << 6)
+
#define AIC32X4_I2S_MODE 0x00
#define AIC32X4_DSP_MODE 0x01
#define AIC32X4_RIGHT_JUSTIFIED_MODE 0x02
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] sound: soc: tlv320aic32x4: Add rstn gpio to platform data.
2012-10-30 15:29 [PATCH 1/2] sound: soc: tlv320aic32x4: Fix problem with first capture Javier Martin
@ 2012-10-30 15:29 ` Javier Martin
2012-10-30 16:02 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Javier Martin @ 2012-10-30 15:29 UTC (permalink / raw)
To: alsa-devel; +Cc: lrg, lars, w.sang, Javier Martin, broonie
Add the possibility to specify a gpio through platform data
so that a HW reset can be issued to the codec.
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
---
include/sound/tlv320aic32x4.h | 1 +
sound/soc/codecs/tlv320aic32x4.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/sound/tlv320aic32x4.h b/include/sound/tlv320aic32x4.h
index c009f70..24e5d99 100644
--- a/include/sound/tlv320aic32x4.h
+++ b/include/sound/tlv320aic32x4.h
@@ -26,6 +26,7 @@ struct aic32x4_pdata {
u32 power_cfg;
u32 micpga_routing;
bool swapdacs;
+ int rstn_gpio;
};
#endif
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index aad92f9..be04cd4 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -28,6 +28,7 @@
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
+#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/cdev.h>
#include <linux/slab.h>
@@ -65,6 +66,7 @@ struct aic32x4_priv {
u32 power_cfg;
u32 micpga_routing;
bool swapdacs;
+ int rstn_gpio;
};
/* 0dB min, 1dB steps */
@@ -627,10 +629,21 @@ static int aic32x4_probe(struct snd_soc_codec *codec)
{
struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
u32 tmp_reg;
+ int ret;
codec->hw_write = (hw_write_t) i2c_master_send;
codec->control_data = aic32x4->control_data;
+ if (aic32x4->rstn_gpio >= 0) {
+ ret = gpio_request(aic32x4->rstn_gpio, "tlv320aic32x4 rstn");
+ if (ret != 0)
+ return ret;
+ gpio_direction_output(aic32x4->rstn_gpio, 1);
+ gpio_set_value(aic32x4->rstn_gpio, 0);
+ ndelay(10);
+ gpio_set_value(aic32x4->rstn_gpio, 1);
+ }
+
snd_soc_write(codec, AIC32X4_RESET, 0x01);
/* Power platform configuration */
@@ -690,6 +703,10 @@ static int aic32x4_probe(struct snd_soc_codec *codec)
static int aic32x4_remove(struct snd_soc_codec *codec)
{
+ struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
+
+ if (aic32x4->rstn_gpio != -1)
+ gpio_free(aic32x4->rstn_gpio);
aic32x4_set_bias_level(codec, SND_SOC_BIAS_OFF);
return 0;
}
@@ -723,10 +740,12 @@ static __devinit int aic32x4_i2c_probe(struct i2c_client *i2c,
aic32x4->power_cfg = pdata->power_cfg;
aic32x4->swapdacs = pdata->swapdacs;
aic32x4->micpga_routing = pdata->micpga_routing;
+ aic32x4->rstn_gpio = pdata->rstn_gpio;
} else {
aic32x4->power_cfg = 0;
aic32x4->swapdacs = false;
aic32x4->micpga_routing = 0;
+ aic32x4->rstn_gpio = -1;
}
ret = snd_soc_register_codec(&i2c->dev,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] sound: soc: tlv320aic32x4: Add rstn gpio to platform data.
2012-10-30 15:29 ` [PATCH 2/2] sound: soc: tlv320aic32x4: Add rstn gpio to platform data Javier Martin
@ 2012-10-30 16:02 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-10-30 16:02 UTC (permalink / raw)
To: Javier Martin; +Cc: alsa-devel, lars, w.sang, lrg
[-- Attachment #1.1: Type: text/plain, Size: 885 bytes --]
On Tue, Oct 30, 2012 at 04:29:34PM +0100, Javier Martin wrote:
> Add the possibility to specify a gpio through platform data
> so that a HW reset can be issued to the codec.
Please use subject lines appropriate for the subsystem you're submitting
against.
> + ret = gpio_request(aic32x4->rstn_gpio, "tlv320aic32x4 rstn");
> + if (ret != 0)
> + return ret;
Should be devm_gpio_request_one(), saving code for cleanup and making
sure there aren't any leaks (I think you have some in error cases here).
gpio_request_one() is better style in general.
> + gpio_direction_output(aic32x4->rstn_gpio, 1);
> + gpio_set_value(aic32x4->rstn_gpio, 0);
> + ndelay(10);
> + gpio_set_value(aic32x4->rstn_gpio, 1);
This looks weird - you request the GPIO active high then immediately
transition it to low. I'd expect the code to set the output low when
putting the GPIO into output mode.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-30 16:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-30 15:29 [PATCH 1/2] sound: soc: tlv320aic32x4: Fix problem with first capture Javier Martin
2012-10-30 15:29 ` [PATCH 2/2] sound: soc: tlv320aic32x4: Add rstn gpio to platform data Javier Martin
2012-10-30 16:02 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.