Skip to contentSkip to conversation

ASoC: Add ADAU1X61 and ADAU1X81 CODECs common code

PATCH In review Lars-Peter Clausen 2 participants 12 messages Aug 28, 2013 – Aug 29, 2013

Subsystems (3)
lore
Share & tools
lore

Lars-Peter Clausen

author maintainer
#0 lore raw

PATCH 1/5 ASoC: Add ADAU1X61 and ADAU1X81 CODECs common code

The ADAU1X61 and ADAU1X81 are very similar in the digital domain, but are quite different in the analog domain. This patch adds support for the common parts of the ADAU1X61 and ADAU1X81 CODECs.

---
 include/linux/platform_data/adau17x1.h |  23 +
 sound/soc/codecs/Kconfig               |   4 +
 sound/soc/codecs/Makefile              |   2 +
 sound/soc/codecs/adau17x1.c            | 895 +++++++++++++++++++++++++++++++++
 sound/soc/codecs/adau17x1.h            | 148 ++++++
 5 files changed, 1072 insertions(+)
 create mode 100644 include/linux/platform_data/adau17x1.h
 create mode 100644 sound/soc/codecs/adau17x1.c
 create mode 100644 sound/soc/codecs/adau17x1.h
include/linux/platform_data/adau17x1.h new file +23 -0
new file mode 100644
index 0000000..fdf419a
@@ -0,0 +1,23 @@
+/*
+ * Driver for ADAU1761/ADAU1461/ADAU1761/ADAU1961/ADAU1781/ADAU1781 codecs
+ *
+ * Copyright 2011-2013 Analog Devices Inc.
+ * Author: Lars-Peter Clausen <[email protected]>
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#ifndef __LINUX_PLATFORM_DATA_ADAU17X1_H__
+#define __LINUX_PLATFORM_DATA_ADAU17X1_H__
+
+/**
+ * enum adau17x1_micbias_voltage - Microphone bias voltage
+ * @ADAU17X1_MICBIAS_0_90_AVDD: 0.9 * AVDD
+ * @ADAU17X1_MICBIAS_0_65_AVDD: 0.65 * AVDD
+ */
+enum adau17x1_micbias_voltage {
+	ADAU17X1_MICBIAS_0_90_AVDD = 0,
+	ADAU17X1_MICBIAS_0_65_AVDD = 1,
+};
+
+#endif
sound/soc/codecs/Kconfig +4 -0
index 15106c0..56137d4 100644
@@ -193,6 +193,10 @@ config SND_SOC_ADAU1701
 config SND_SOC_ADAU1373
 	tristate
 
+config SND_SOC_ADAU17X1
+	select SND_SOC_SIGMADSP
+	tristate
+
 config SND_SOC_ADAV80X
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index bc12676..b4ecf6c 100644
@@ -7,6 +7,7 @@ snd-soc-ad1980-objs := ad1980.o
 snd-soc-ad73311-objs := ad73311.o
 snd-soc-adau1701-objs := adau1701.o
 snd-soc-adau1373-objs := adau1373.o
+snd-soc-adau17x1-objs := adau17x1.o
 snd-soc-adav80x-objs := adav80x.o
 snd-soc-ads117x-objs := ads117x.o
 snd-soc-ak4104-objs := ak4104.o
@@ -138,6 +139,7 @@ obj-$(CONFIG_SND_SOC_AD1980)	+= snd-soc-ad1980.o
 obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o
 obj-$(CONFIG_SND_SOC_ADAU1373)	+= snd-soc-adau1373.o
 obj-$(CONFIG_SND_SOC_ADAU1701)  += snd-soc-adau1701.o
+obj-$(CONFIG_SND_SOC_ADAU17X1)	+= snd-soc-adau17x1.o
 obj-$(CONFIG_SND_SOC_ADAV80X)  += snd-soc-adav80x.o
 obj-$(CONFIG_SND_SOC_ADS117X)	+= snd-soc-ads117x.o
 obj-$(CONFIG_SND_SOC_AK4104)	+= snd-soc-ak4104.o
sound/soc/codecs/adau17x1.c new file +895 -0

895 lines not on this page · raw message

sound/soc/codecs/adau17x1.h new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
1.8.0
author maintainer
#1 lore raw

PATCH 2/5 ASoC: Add ADAU1361/ADAU1761 audio CODEC support

This patch adds support for the Analog Devices ADAU1361 and ADAU1761 CODECs. The device is a a low-power, 24-bit stereo audio CODEC with multiple analog input and outputs, one digital microphone input and an I2S interface. The device can be controlled either via I2C or SPI. The main difference between the two variants is that the ADAU1761 has a built-in SigmaDSP, while the ADAU1361 has not.

---
 include/linux/platform_data/adau17x1.h |  67 +++
 sound/soc/codecs/Kconfig               |   5 +
 sound/soc/codecs/Makefile              |   2 +
 sound/soc/codecs/adau1761.c            | 981 +++++++++++++++++++++++++++++++++
 4 files changed, 1055 insertions(+)
 create mode 100644 sound/soc/codecs/adau1761.c
include/linux/platform_data/adau17x1.h +67 -0
index fdf419a..5f559db 100644
@@ -20,4 +20,71 @@ enum adau17x1_micbias_voltage {
 	ADAU17X1_MICBIAS_0_65_AVDD = 1,
 };
 
+/**
+ * enum adau1761_digmic_jackdet_pin_mode - Configuration of the JACKDET/MICIN pin
+ * @ADAU1761_DIGMIC_JACKDET_PIN_MODE_NONE:	Disable the pin
+ * @ADAU1761_DIGMIC_JACKDET_PIN_MODE_DIGMIC:	Configure the pin for usage as
+ *	digital microphone input.
+ * @ADAU1761_DIGMIC_JACKDET_PIN_MODE_JACKDETECT: Configure the pin for jack
+ *	insertion detection.
+*/
+enum adau1761_digmic_jackdet_pin_mode {
+	ADAU1761_DIGMIC_JACKDET_PIN_MODE_NONE,
+	ADAU1761_DIGMIC_JACKDET_PIN_MODE_DIGMIC,
+	ADAU1761_DIGMIC_JACKDET_PIN_MODE_JACKDETECT,
+};
+
+/**
+ * adau1761_jackdetect_debounce_time - Jack insertion detection debounce time
+ * @ADAU1761_JACKDETECT_DEBOUNCE_5MS:  5 milliseconds
+ * @ADAU1761_JACKDETECT_DEBOUNCE_10MS: 10 milliseconds
+ * @ADAU1761_JACKDETECT_DEBOUNCE_20MS: 20 milliseconds
+ * @ADAU1761_JACKDETECT_DEBOUNCE_40MS: 40 milliseconds
+ */
+enum adau1761_jackdetect_debounce_time {
+	ADAU1761_JACKDETECT_DEBOUNCE_5MS = 0,
+	ADAU1761_JACKDETECT_DEBOUNCE_10MS = 1,
+	ADAU1761_JACKDETECT_DEBOUNCE_20MS = 2,
+	ADAU1761_JACKDETECT_DEBOUNCE_40MS = 3,
+};
+
+/**
+ * enum adau1761_output_mode - Output mode configuration
+ * @ADAU1761_OUTPUT_MODE_HEADPHONE:		Headphone output
+ * @ADAU1761_OUTPUT_MODE_HEADPHONE_CAPLESS:	Capless headphone output
+ * @ADAU1761_OUTPUT_MODE_LINE:			Line output
+ */
+enum adau1761_output_mode {
+	ADAU1761_OUTPUT_MODE_HEADPHONE,
+	ADAU1761_OUTPUT_MODE_HEADPHONE_CAPLESS,
+	ADAU1761_OUTPUT_MODE_LINE,
+};
+
+/**
+ * struct adau1761_platform_data - ADAU1761 Codec driver platform data
+ * @input_differential:		If true the input pins will be configured in
+ *	differential mode.
+ * @lineout_mode:		Output mode for the LOUT/ROUT pins
+ * @headphone_mode:		Output mode for the LHP/RHP pins
+ * @digmic_jackdetect_pin_mode: JACKDET/MICIN pin configuration
+ * @jackdetect_debounce_time:	Jack insertion detection debounce time.
+ *	Note: This value will only be used, if the JACKDET/MICIN pin is
+ *	configured for jack insertion detection.
+ * @jackdetect_active_low:	If true the jack insertion detection is active
+ *	low. Othwise it will be active high.
+ * @micbias_voltage:		Microphone voltage bias
+ */
+struct adau1761_platform_data {
+	bool input_differential;
+	enum adau1761_output_mode lineout_mode;
+	enum adau1761_output_mode headphone_mode;
+
+	enum adau1761_digmic_jackdet_pin_mode digmic_jackdetect_pin_mode;
+
+	enum adau1761_jackdetect_debounce_time jackdetect_debounce_time;
+	bool jackdetect_active_low;
+
+	enum adau17x1_micbias_voltage micbias_voltage;
+};
+
 #endif
sound/soc/codecs/Kconfig +5 -0
index 56137d4..d93a984 100644
@@ -20,6 +20,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_AD1980 if SND_SOC_AC97_BUS
 	select SND_SOC_AD73311
 	select SND_SOC_ADAU1373 if I2C
+	select SND_SOC_ADAU1761 if SND_SOC_I2C_AND_SPI
 	select SND_SOC_ADAV80X if SND_SOC_I2C_AND_SPI
 	select SND_SOC_ADAU1701 if I2C
 	select SND_SOC_ADS117X
@@ -197,6 +198,10 @@ config SND_SOC_ADAU17X1
 	select SND_SOC_SIGMADSP
 	tristate
 
+config SND_SOC_ADAU1761
+	select SND_SOC_ADAU17X1
+	tristate
+
 config SND_SOC_ADAV80X
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index b4ecf6c..6aec0af 100644
@@ -8,6 +8,7 @@ snd-soc-ad73311-objs := ad73311.o
 snd-soc-adau1701-objs := adau1701.o
 snd-soc-adau1373-objs := adau1373.o
 snd-soc-adau17x1-objs := adau17x1.o
+snd-soc-adau1761-objs := adau1761.o
 snd-soc-adav80x-objs := adav80x.o
 snd-soc-ads117x-objs := ads117x.o
 snd-soc-ak4104-objs := ak4104.o
@@ -140,6 +141,7 @@ obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o
 obj-$(CONFIG_SND_SOC_ADAU1373)	+= snd-soc-adau1373.o
 obj-$(CONFIG_SND_SOC_ADAU1701)  += snd-soc-adau1701.o
 obj-$(CONFIG_SND_SOC_ADAU17X1)	+= snd-soc-adau17x1.o
+obj-$(CONFIG_SND_SOC_ADAU1761)	+= snd-soc-adau1761.o
 obj-$(CONFIG_SND_SOC_ADAV80X)  += snd-soc-adav80x.o
 obj-$(CONFIG_SND_SOC_ADS117X)	+= snd-soc-ads117x.o
 obj-$(CONFIG_SND_SOC_AK4104)	+= snd-soc-ak4104.o
sound/soc/codecs/adau1761.c new file +981 -0

981 lines not on this page · raw message

Signature · 1 line
1.8.0
maintainer
#2 lore raw

Re: [PATCH 2/5] ASoC: Add ADAU1361/ADAU1761 audio CODEC support

sound/soc/codecs/adau1761.c line 125

Quoted 8 lines · Lars-Peter Clausen
sound/soc/codecs/adau1761.c new file +8 -0
+static const char * const adau1761_bias_select_text[] = {
+	"Normal operation", "Enhanced performance", "Power saving",
+};
+
+static const char * const adau1761_bias_select_extreme_text[] = {
+	"Normal operation", "Extreme power saving", "Enhanced performance",
+	"Power saving",
+};

Not a requirement and perhaps it has no effect but these seem like they ought to integrate with the bias level configuration - since only the clocks seem to be managed by set_bias_level() the driver could presumably save a bit of power by dropping down to the minimal power consumption bias while the device is idle. This is what the STANDBY to ON transition is all about.

sound/soc/codecs/adau1761.c line 142

Quoted 3 lines
sound/soc/codecs/adau1761.c new file +3 -0
+static const struct snd_kcontrol_new adau1761_jack_detect_controls[] = {
+	SOC_SINGLE("Jack Detect Switch", ADAU1761_DIGMIC_JACKDETECT, 4, 1, 0),
+};

Why is this a user visible control and not using the jack detection framework support?

author maintainer
#3 lore raw

Re: [PATCH 2/5] ASoC: Add ADAU1361/ADAU1761 audio CODEC support

Quoted 17 lines · Mark Brown

sound/soc/codecs/adau1761.c line 125

Quoted 8 lines · Lars-Peter Clausen
sound/soc/codecs/adau1761.c new file +8 -0
+static const char * const adau1761_bias_select_text[] = {
+	"Normal operation", "Enhanced performance", "Power saving",
+};
+
+static const char * const adau1761_bias_select_extreme_text[] = {
+	"Normal operation", "Extreme power saving", "Enhanced performance",
+	"Power saving",
+};

Not a requirement and perhaps it has no effect but these seem like they ought to integrate with the bias level configuration - since only the clocks seem to be managed by set_bias_level() the driver could presumably save a bit of power by dropping down to the minimal power consumption bias while the device is idle. This is what the STANDBY to ON transition is all about.

Hm, I'm not sure if it makes a difference since all the components have individual power control bits that are managed by DAPM. I would expect the bias current setting to only make a difference if the component is actually powered up. I'll check with the designers, but I think this can still be improved later on if it turns out that it saves power.

Quoted 8 lines

sound/soc/codecs/adau1761.c line 142

Quoted 4 lines
sound/soc/codecs/adau1761.c new file +3 -0
+static const struct snd_kcontrol_new adau1761_jack_detect_controls[] = {
+	SOC_SINGLE("Jack Detect Switch", ADAU1761_DIGMIC_JACKDETECT, 4, 1, 0),
+};

Why is this a user visible control and not using the jack detection framework support?

The CODEC unfortunately does not support reporting the jack state. All it can do is mute the speaker output in hardware if something is plugged into the headphone jack. The switch allows the users to control whether the output should be auto-muted or not.

maintainer
#4 lore raw

Re: [PATCH 2/5] ASoC: Add ADAU1361/ADAU1761 audio CODEC support

Quoted 9 lines · Lars-Peter Clausen
Quoted 6 lines · Mark Brown

Not a requirement and perhaps it has no effect but these seem like they ought to integrate with the bias level configuration - since only the clocks seem to be managed by set_bias_level() the driver could presumably save a bit of power by dropping down to the minimal power consumption bias while the device is idle. This is what the STANDBY to ON transition is all about.

Quoted 5 lines

Hm, I'm not sure if it makes a difference since all the components have individual power control bits that are managed by DAPM. I would expect the bias current setting to only make a difference if the component is actually powered up. I'll check with the designers, but I think this can still be improved later on if it turns out that it saves power.

Given that the device has non-capless headphone outputs I'd expect there's something being maintained normally, though it's possible that it's still ground referenced.

Quoted 11 lines
Quoted 6 lines

sound/soc/codecs/adau1761.c line 142

Quoted 3 lines
sound/soc/codecs/adau1761.c new file +3 -0
+static const struct snd_kcontrol_new adau1761_jack_detect_controls[] = {
+	SOC_SINGLE("Jack Detect Switch", ADAU1761_DIGMIC_JACKDETECT, 4, 1, 0),
+};

Why is this a user visible control and not using the jack detection framework support?

The CODEC unfortunately does not support reporting the jack state. All it can do is mute the speaker output in hardware if something is plugged into the headphone jack. The switch allows the users to control whether the output should be auto-muted or not.

In that case it should be called something like "Speaker Automute Switch" or similar. It's a bit unfortuante that there's not even any readback for the function.

author maintainer
#5 lore raw

PATCH 3/5 ASoC: Add ADAU1381/ADAU1781 audio CODEC support

In reply to Lars-Peter Clausen

This patch adds support for the Analog Devices ADAU1381 and ADAU1781 audio CODECs. The device is a low-power, 24-bit stereo audio CODEC with multiple analog inputs and outputs, two digital microphone inputs and an I2S interface. The device can be controlled either using I2C or SPI. The main difference between the two variants is that the ADAU1781 has a freely programmable SigmaDSP processor, while the ADAU1381 has a fixed function wind noise reduction filter.

---
 include/linux/platform_data/adau17x1.h |  19 +
 sound/soc/codecs/Kconfig               |   5 +
 sound/soc/codecs/Makefile              |   2 +
 sound/soc/codecs/adau1781.c            | 675 +++++++++++++++++++++++++++++++++
 4 files changed, 701 insertions(+)
 create mode 100644 sound/soc/codecs/adau1781.c
include/linux/platform_data/adau17x1.h +19 -0
index 5f559db..b890507 100644
@@ -87,4 +87,23 @@ struct adau1761_platform_data {
 	enum adau17x1_micbias_voltage micbias_voltage;
 };
 
+/**
+ * struct adau1781_platform_data - ADAU1781 Codec driver platform data
+ * @left_input_differential:	If true configure the left input as
+	differential input.
+ * @right_input_differential:	If true configure the right input as
+ *	differntial input.
+ * @use_dmic:			If true configure the MIC pins as digital
+ *	microphone pins instead of analog microphone pins.
+ * @micbias_voltage:		Microphone voltage bias
+ */
+struct adau1781_platform_data {
+	bool left_input_differential;
+	bool right_input_differential;
+
+	bool use_dmic;
+
+	enum adau17x1_micbias_voltage micbias_voltage;
+};
+
 #endif
sound/soc/codecs/Kconfig +5 -0
index d93a984..503f57f 100644
@@ -21,6 +21,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_AD73311
 	select SND_SOC_ADAU1373 if I2C
 	select SND_SOC_ADAU1761 if SND_SOC_I2C_AND_SPI
+	select SND_SOC_ADAU1781 if SND_SOC_I2C_AND_SPI
 	select SND_SOC_ADAV80X if SND_SOC_I2C_AND_SPI
 	select SND_SOC_ADAU1701 if I2C
 	select SND_SOC_ADS117X
@@ -202,6 +203,10 @@ config SND_SOC_ADAU1761
 	select SND_SOC_ADAU17X1
 	tristate
 
+config SND_SOC_ADAU1781
+	select SND_SOC_ADAU17X1
+	tristate
+
 config SND_SOC_ADAV80X
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 6aec0af..3f6c3a9 100644
@@ -9,6 +9,7 @@ snd-soc-adau1701-objs := adau1701.o
 snd-soc-adau1373-objs := adau1373.o
 snd-soc-adau17x1-objs := adau17x1.o
 snd-soc-adau1761-objs := adau1761.o
+snd-soc-adau1781-objs := adau1781.o
 snd-soc-adav80x-objs := adav80x.o
 snd-soc-ads117x-objs := ads117x.o
 snd-soc-ak4104-objs := ak4104.o
@@ -142,6 +143,7 @@ obj-$(CONFIG_SND_SOC_ADAU1373)	+= snd-soc-adau1373.o
 obj-$(CONFIG_SND_SOC_ADAU1701)  += snd-soc-adau1701.o
 obj-$(CONFIG_SND_SOC_ADAU17X1)	+= snd-soc-adau17x1.o
 obj-$(CONFIG_SND_SOC_ADAU1761)	+= snd-soc-adau1761.o
+obj-$(CONFIG_SND_SOC_ADAU1781)	+= snd-soc-adau1781.o
 obj-$(CONFIG_SND_SOC_ADAV80X)  += snd-soc-adav80x.o
 obj-$(CONFIG_SND_SOC_ADS117X)	+= snd-soc-ads117x.o
 obj-$(CONFIG_SND_SOC_AK4104)	+= snd-soc-ak4104.o
sound/soc/codecs/adau1781.c new file +675 -0

675 lines not on this page · raw message

Signature · 1 line
1.8.0
author maintainer
#6 lore raw

PATCH 4/5 ASoC: Blackfin: ADAU1X61 eval board support

In reply to Lars-Peter Clausen

This patch adds a ASoC machine driver to support the EVAL-ADAU1X61 board connected to a Analog Devices BF5XX evaluation board.

---
 sound/soc/blackfin/Kconfig              |  13 +++
 sound/soc/blackfin/Makefile             |   2 +
 sound/soc/blackfin/bfin-eval-adau1x61.c | 151 ++++++++++++++++++++++++++++++++
 3 files changed, 166 insertions(+)
 create mode 100644 sound/soc/blackfin/bfin-eval-adau1x61.c
sound/soc/blackfin/Kconfig +13 -0
index 54f74f8..30e3fb9 100644
@@ -43,6 +43,19 @@ config SND_SOC_BFIN_EVAL_ADAU1373
 	  Note: This driver assumes that first ADAU1373 DAI is connected to the
 	  first SPORT port on the BF5XX board.
 
+config SND_SOC_BFIN_EVAL_ADAU1X61
+	tristate "Support for the EVAL-ADAU1X61 board on Blackfin eval boards"
+	depends on SND_BF5XX_I2S && I2C
+	select SND_BF5XX_SOC_I2S
+	select SND_SOC_ADAU1761
+	help
+	  Say Y if you want to add support for the Analog Devices EVAL-ADAU1X61
+	  board connected to one of the Blackfin evaluation boards like the
+	  BF5XX-STAMP or BF5XX-EZKIT.
+
+	  Note: This driver assumes that the ADAU1X61 is connected to the
+	  first SPORT port on the BF5XX board.
+
 config SND_SOC_BFIN_EVAL_ADAV80X
 	tristate "Support for the EVAL-ADAV80X boards on Blackfin eval boards"
 	depends on SND_BF5XX_I2S && (SPI_MASTER || I2C)
sound/soc/blackfin/Makefile +2 -0
index ad0a6e9..91eb0e7 100644
@@ -22,6 +22,7 @@ snd-ssm2602-objs := bf5xx-ssm2602.o
 snd-ad73311-objs := bf5xx-ad73311.o
 snd-ad193x-objs := bf5xx-ad193x.o
 snd-soc-bfin-eval-adau1373-objs := bfin-eval-adau1373.o
+snd-soc-bfin-eval-adau1x61-objs := bfin-eval-adau1x61.o
 snd-soc-bfin-eval-adau1701-objs := bfin-eval-adau1701.o
 snd-soc-bfin-eval-adav80x-objs := bfin-eval-adav80x.o
 
@@ -31,5 +32,6 @@ obj-$(CONFIG_SND_BF5XX_SOC_SSM2602) += snd-ssm2602.o
 obj-$(CONFIG_SND_BF5XX_SOC_AD73311) += snd-ad73311.o
 obj-$(CONFIG_SND_BF5XX_SOC_AD193X) += snd-ad193x.o
 obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373) += snd-soc-bfin-eval-adau1373.o
+obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61) += snd-soc-bfin-eval-adau1x61.o
 obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701) += snd-soc-bfin-eval-adau1701.o
 obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X) += snd-soc-bfin-eval-adav80x.o
sound/soc/blackfin/bfin-eval-adau1x61.c new file +151 -0

151 lines not on this page · raw message

Signature · 1 line
1.8.0
maintainer
#7 lore raw

Re: [PATCH 4/5] ASoC: Blackfin: ADAU1X61 eval board support

Quoted 2 lines · Lars-Peter Clausen

This patch adds a ASoC machine driver to support the EVAL-ADAU1X61 board connected to a Analog Devices BF5XX evaluation board.

The machine drivers look good.

author maintainer
#8 lore raw

PATCH 5/5 ASoC: Blackfin: ADAU1X81 eval board support

In reply to Lars-Peter Clausen

This patch adds a ASoC machine driver to support the EVAL-ADAU1X81 board connected to a Analog Devices BF5XX evaluation board.

---
 sound/soc/blackfin/Kconfig              |  13 +++
 sound/soc/blackfin/Makefile             |   2 +
 sound/soc/blackfin/bfin-eval-adau1x81.c | 139 ++++++++++++++++++++++++++++++++
 3 files changed, 154 insertions(+)
 create mode 100644 sound/soc/blackfin/bfin-eval-adau1x81.c
sound/soc/blackfin/Kconfig +13 -0
index 30e3fb9..87c3980 100644
@@ -56,6 +56,19 @@ config SND_SOC_BFIN_EVAL_ADAU1X61
 	  Note: This driver assumes that the ADAU1X61 is connected to the
 	  first SPORT port on the BF5XX board.
 
+config SND_SOC_BFIN_EVAL_ADAU1X81
+	tristate "Support for the EVAL-ADAU1X81 boards on Blackfin eval boards"
+	depends on SND_BF5XX_I2S && I2C
+	select SND_BF5XX_SOC_I2S
+	select SND_SOC_ADAU1781
+	help
+	  Say Y if you want to add support for the Analog Devices EVAL-ADAU1X81
+	  board connected to one of the Blackfin evaluation boards like the
+	  BF5XX-STAMP or BF5XX-EZKIT.
+
+	  Note: This driver assumes that the ADAU1X81 is connected to the
+	  first SPORT port on the BF5XX board.
+
 config SND_SOC_BFIN_EVAL_ADAV80X
 	tristate "Support for the EVAL-ADAV80X boards on Blackfin eval boards"
 	depends on SND_BF5XX_I2S && (SPI_MASTER || I2C)
sound/soc/blackfin/Makefile +2 -0
index 91eb0e7..f21e948 100644
@@ -23,6 +23,7 @@ snd-ad73311-objs := bf5xx-ad73311.o
 snd-ad193x-objs := bf5xx-ad193x.o
 snd-soc-bfin-eval-adau1373-objs := bfin-eval-adau1373.o
 snd-soc-bfin-eval-adau1x61-objs := bfin-eval-adau1x61.o
+snd-soc-bfin-eval-adau1x81-objs := bfin-eval-adau1x81.o
 snd-soc-bfin-eval-adau1701-objs := bfin-eval-adau1701.o
 snd-soc-bfin-eval-adav80x-objs := bfin-eval-adav80x.o
 
@@ -33,5 +34,6 @@ obj-$(CONFIG_SND_BF5XX_SOC_AD73311) += snd-ad73311.o
 obj-$(CONFIG_SND_BF5XX_SOC_AD193X) += snd-ad193x.o
 obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373) += snd-soc-bfin-eval-adau1373.o
 obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61) += snd-soc-bfin-eval-adau1x61.o
+obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X81) += snd-soc-bfin-eval-adau1x81.o
 obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701) += snd-soc-bfin-eval-adau1701.o
 obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X) += snd-soc-bfin-eval-adav80x.o
sound/soc/blackfin/bfin-eval-adau1x81.c new file +139 -0

139 lines not on this page · raw message

Signature · 1 line
1.8.0
maintainer
#9 lore raw
In reply to Lars-Peter Clausen

sound/soc/codecs/adau17x1.c line 272

Quoted 12 lines · Lars-Peter Clausen
sound/soc/codecs/adau17x1.c new file +12 -0
+static void adau17x1_check_aifclk(struct snd_soc_codec *codec)
+{
+	struct adau *adau = snd_soc_codec_get_drvdata(codec);
+
+	/* If we are in master mode we need to generate bit- and frameclock,
+	 * regardless of whether there is an active path or not */
+	if (codec->active && adau->master)
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "AIFCLK");
+	else
+		snd_soc_dapm_disable_pin(&codec->dapm, "AIFCLK");
+	snd_soc_dapm_sync(&codec->dapm);
+}

I think this is eminently sensible but it seems like it should be a framework feature. That'd have to enable an actual AIF slot though which is a bit fun, which slot do we enable for example?

sound/soc/codecs/adau17x1.c line 471

Quoted 12 lines
sound/soc/codecs/adau17x1.c new file +12 -0
+static int adau17x1_set_dai_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
+{
+	struct adau *adau = snd_soc_codec_get_drvdata(dai->codec);
+
+	if (div < 0 || div > 4)
+		return -EINVAL;
+
+	adau->sysclk_div = div;
+
+	return regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL,
+		ADAU17X1_CLOCK_CONTROL_INFREQ_MASK, (div - 1) << 1);
+}

What's this doing? It'd be better to have a specific ID and check that too.

Quoted 8 lines
sound/soc/codecs/adau17x1.c new file +8 -0
+int adau17x1_set_micbias_voltage(struct snd_soc_codec *codec,
+	enum adau17x1_micbias_voltage micbias)
+{
+	struct adau *adau = snd_soc_codec_get_drvdata(codec);
+
+	switch (micbias) {
+	case ADAU17X1_MICBIAS_0_90_AVDD:
+	case ADAU17X1_MICBIAS_0_65_AVDD:

sound/soc/codecs/adau17x1.c line 697

Quoted 10 lines
sound/soc/codecs/adau17x1.c new file +10 -0
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	regmap_write(adau->regmap, ADAU17X1_MICBIAS, micbias << 2);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(adau17x1_set_micbias_voltage);

When would a machine driver use this (as opposed to just letting it be set by platform data)?

author maintainer
#10 lore raw
Quoted 18 lines · Mark Brown

sound/soc/codecs/adau17x1.c line 272

Quoted 12 lines · Lars-Peter Clausen
sound/soc/codecs/adau17x1.c new file +12 -0
+static void adau17x1_check_aifclk(struct snd_soc_codec *codec)
+{
+	struct adau *adau = snd_soc_codec_get_drvdata(codec);
+
+	/* If we are in master mode we need to generate bit- and frameclock,
+	 * regardless of whether there is an active path or not */
+	if (codec->active && adau->master)
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "AIFCLK");
+	else
+		snd_soc_dapm_disable_pin(&codec->dapm, "AIFCLK");
+	snd_soc_dapm_sync(&codec->dapm);
+}

I think this is eminently sensible but it seems like it should be a framework feature. That'd have to enable an actual AIF slot though which is a bit fun, which slot do we enable for example?

It would be nice if this could be handled by the core. But how? One option might be tracking the the DAI format in the core and power up the DAI widget in DAPM if the stream is active regardless of if there is an active path if the DAI is in master mode. That may power up more than what is needed though. E.g. for this CODEC the clock generator and the rest of the DAI can be powered up independently and we only need to power up the clock generator.

Quoted 16 lines

sound/soc/codecs/adau17x1.c line 471

Quoted 13 lines
sound/soc/codecs/adau17x1.c new file +12 -0
+static int adau17x1_set_dai_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
+{
+	struct adau *adau = snd_soc_codec_get_drvdata(dai->codec);
+
+	if (div < 0 || div > 4)
+		return -EINVAL;
+
+	adau->sysclk_div = div;
+
+	return regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL,
+		ADAU17X1_CLOCK_CONTROL_INFREQ_MASK, (div - 1) << 1);
+}

What's this doing? It'd be better to have a specific ID and check that too.

Setting the relationship between the external clock rate and the internal base sample rate. There might be a better way to do this though.

Quoted 14 lines
Quoted 14 lines
sound/soc/codecs/adau17x1.c new file +13 -0
+int adau17x1_set_micbias_voltage(struct snd_soc_codec *codec,
+	enum adau17x1_micbias_voltage micbias)
+{
+	struct adau *adau = snd_soc_codec_get_drvdata(codec);
+
+	switch (micbias) {
+	case ADAU17X1_MICBIAS_0_90_AVDD:
+	case ADAU17X1_MICBIAS_0_65_AVDD:
+		break;
+	default:
+		return -EINVAL;
+	}
+
Quoted 8 lines

sound/soc/codecs/adau17x1.c line 697

Quoted 5 lines
sound/soc/codecs/adau17x1.c new file +5 -0
+	regmap_write(adau->regmap, ADAU17X1_MICBIAS, micbias << 2);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(adau17x1_set_micbias_voltage);

When would a machine driver use this (as opposed to just letting it be set by platform data)?

It is not meant to be used by machine drivers, but by the adau1761 and adau1781 CODEC drivers, which set the micbias based on platform data.

Thanks for the fast review,
- Lars

maintainer
#11 lore raw
Quoted 6 lines · Lars-Peter Clausen

It would be nice if this could be handled by the core. But how? One option might be tracking the the DAI format in the core and power up the DAI widget in DAPM if the stream is active regardless of if there is an active path if the DAI is in master mode. That may power up more than what is needed though. E.g. for this CODEC the clock generator and the rest of the DAI can be powered up independently and we only need to power up the clock generator.

Yes, that was what I was thinking of. We can provide a mechanism to allow the driver to specify a specific widget for the clocks if one exists and fall back on the DAI widgets otherwise.

Quoted 8 lines
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+static int adau17x1_set_dai_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
+{

What's this doing? It'd be better to have a specific ID and check that too.

Setting the relationship between the external clock rate and the internal base sample rate. There might be a better way to do this though.

If it's specifying two clock rates then specifying them both as actual rates might make sense. I take it it's not possible for the driver to automatically figure out what the most sensible rate is?

Quoted 8 lines
Quoted 5 lines

sound/soc/codecs/adau17x1.c line 681

Quoted 2 lines
sound/soc/codecs/adau17x1.c new file +2 -0
+int adau17x1_set_micbias_voltage(struct snd_soc_codec *codec,
+	enum adau17x1_micbias_voltage micbias)

When would a machine driver use this (as opposed to just letting it be set by platform data)?

It is not meant to be used by machine drivers, but by the adau1761 and adau1781 CODEC drivers, which set the micbias based on platform data.

Ah, in that case how about having generic platform data for the core and just passing that through to a platform data parsing function?