Skip to contentSkip to conversation

ASoC: da7210: Add support for line out and DAC

PATCH Superseded Ashish Chavan 3 participants 9 messages Oct 20, 2011 – Oct 21, 2011

Subsystems (3)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v7 2/3 ASoC: da7210: Add support for line out and DAC

DA7210 has three line outputs. OUT1 Left, OUT1 Right and OUT2 (mono). This patch adds support for gain controls for these three line outs. It also adds support for overall DAC gain control.

---
Changes since v1:
- Removed explicit setting of default gains
- Renamed "DAC Playback" to "Digital Playback"

---
 sound/soc/codecs/da7210.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
sound/soc/codecs/da7210.c +42 -0
index 2187db9..eaec60a 100644
@@ -54,6 +54,8 @@
 #define DA7210_DAC_EQ5			0x1B
 #define DA7210_OUTMIX_L			0x1C
 #define DA7210_OUTMIX_R			0x1D
+#define DA7210_OUT1_L			0x1E
+#define DA7210_OUT1_R			0x1F
 #define DA7210_OUT2			0x20
 #define DA7210_HP_L_VOL			0x21
 #define DA7210_HP_R_VOL			0x22
@@ -187,6 +189,17 @@
 #define DA7210_INPGA_MIN_VOL_NS		0x0A  /* 10.5dB */
 #define DA7210_AUX1_MIN_VOL_NS		0x35  /* 6dB */
 
+/* OUT1_L bit fields */
+#define DA7210_OUT1_L_EN		(1 << 7)
+
+/* OUT1_R bit fields */
+#define DA7210_OUT1_R_EN		(1 << 7)
+
+/* OUT2 bit fields */
+#define DA7210_OUT2_OUTMIX_R		(1 << 5)
+#define DA7210_OUT2_OUTMIX_L		(1 << 6)
+#define DA7210_OUT2_EN			(1 << 7)
+
 #define DA7210_VERSION "0.0.1"
 
 /*
@@ -207,8 +220,23 @@ static const unsigned int hp_out_tlv[] = {
 	0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0),
 };
 
+static const unsigned int lineout_vol_tlv[] = {
+	TLV_DB_RANGE_HEAD(2),
+	0x0, 0x10, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
+	/* -54dB to 15dB */
+	0x11, 0x3f, TLV_DB_SCALE_ITEM(-5400, 150, 0)
+};
+
+static const unsigned int mono_vol_tlv[] = {
+	TLV_DB_RANGE_HEAD(2),
+	0x0, 0x2, TLV_DB_SCALE_ITEM(-1800, 0, 1),
+	/* -18dB to 6dB */
+	0x3, 0x7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
+};
+
 static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0);
 static const DECLARE_TLV_DB_SCALE(adc_eq_master_gain_tlv, -1800, 600, 1);
+static const DECLARE_TLV_DB_SCALE(dac_gain_tlv, -7725, 75, 0);
 
 /* ADC and DAC high pass filter f0 value */
 static const char const *da7210_hpf_cutoff_txt[] = {
@@ -307,6 +335,14 @@ static const struct snd_kcontrol_new da7210_snd_controls[] = {
 	SOC_DOUBLE_R_TLV("HeadPhone Playback Volume",
 			 DA7210_HP_L_VOL, DA7210_HP_R_VOL,
 			 0, 0x3F, 0, hp_out_tlv),
+	SOC_DOUBLE_R_TLV("Digital Playback Volume",
+			 DA7210_DAC_L, DA7210_DAC_R,
+			 0, 0x77, 1, dac_gain_tlv),
+	SOC_DOUBLE_R_TLV("Lineout Playback Volume",
+			 DA7210_OUT1_L, DA7210_OUT1_R,
+			 0, 0x3f, 0, lineout_vol_tlv),
+	SOC_SINGLE_TLV("Mono Playback Volume", DA7210_OUT2, 0, 0x7, 0,
+		       mono_vol_tlv),
 
 	/* DAC Equalizer  controls */
 	SOC_SINGLE("DAC EQ Switch", DA7210_DAC_EQ5, 7, 1, 0),
@@ -886,6 +922,12 @@ static int da7210_probe(struct snd_soc_codec *codec)
 	/* Enable ramp mode for DAC gain update */
 	snd_soc_write(codec, DA7210_SOFTMUTE, DA7210_RAMP_EN);
 
+	/* Enable Line out amplifiers */
+	snd_soc_write(codec, DA7210_OUT1_L, DA7210_OUT1_L_EN);
+	snd_soc_write(codec, DA7210_OUT1_R, DA7210_OUT1_R_EN);
+	snd_soc_write(codec, DA7210_OUT2, DA7210_OUT2_EN |
+		     DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R);
+
 	/* Diable PLL and bypass it */
 	snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000);
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 16 lines · Ashish Chavan

DA7210 has three line outputs. OUT1 Left, OUT1 Right and OUT2 (mono). This patch adds support for gain controls for these three line outs. It also adds support for overall DAC gain control.

---
Changes since v1:
- Removed explicit setting of default gains
- Renamed "DAC Playback" to "Digital Playback"
---
 sound/soc/codecs/da7210.c |   42 ++++++++++++++++++++++++++++++++++++++++++

 1 files changed, 42 insertions(+), 0 deletions(-)
Quoted 6 lines

+       /* Enable Line out amplifiers */
+       snd_soc_write(codec, DA7210_OUT1_L, DA7210_OUT1_L_EN);
+       snd_soc_write(codec, DA7210_OUT1_R, DA7210_OUT1_R_EN);
+       snd_soc_write(codec, DA7210_OUT2, DA7210_OUT2_EN |
+                    DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R); +

Any reason for not using DAPM here ? Otherwise they are always on making your chip burn mW.....

Thanks

Liam

#2 lore raw
Quoted 24 lines · Liam
Quoted 16 lines · Ashish Chavan

DA7210 has three line outputs. OUT1 Left, OUT1 Right and OUT2 (mono). This patch adds support for gain controls for these three line outs. It also adds support for overall DAC gain control.

---
Changes since v1:
- Removed explicit setting of default gains
- Renamed "DAC Playback" to "Digital Playback"

---
 sound/soc/codecs/da7210.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

sound/soc/codecs/da7210.c static int da7210_probe(struct snd_soc_codec *codec) · line 930

Quoted 6 lines
sound/soc/codecs/da7210.c +6 -0
+       /* Enable Line out amplifiers */
+       snd_soc_write(codec, DA7210_OUT1_L, DA7210_OUT1_L_EN);
+       snd_soc_write(codec, DA7210_OUT1_R, DA7210_OUT1_R_EN);
+       snd_soc_write(codec, DA7210_OUT2, DA7210_OUT2_EN |
+                    DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R);
+
Quoted 3 lines

Any reason for not using DAPM here ? Otherwise they are always on making your chip burn mW.....

Not really. As explained in the comment in DAPM patch, this enables will be effective (burn mW) only after respective IO is taken out from STANDBY mode. DAPM takes care of managing STANDBY mode for all IOs and ADC/DAC. I know this way of handling low power mode is bit non-trivial, but it is what is recommended by chip designers. Actually Mark was also initially confused with this and requested to put enough documentation into code. After that I tried explaining the logic in source code comment in DAPM patch. Let me know if it is not clear and doesn't convey clearly what is should.

Thanks,

-- Ashish (GNU FAN)

#3 lore raw
Quoted 5 lines · Ashish Chavan
Quoted 2 lines · Liam

Any reason for not using DAPM here ? Otherwise they are always on making your chip burn mW.....

Quoted 9 lines

Not really. As explained in the comment in DAPM patch, this enables will be effective (burn mW) only after respective IO is taken out from STANDBY mode. DAPM takes care of managing STANDBY mode for all IOs and ADC/DAC. I know this way of handling low power mode is bit non-trivial, but it is what is recommended by chip designers. Actually Mark was also initially confused with this and requested to put enough documentation into code. After that I tried explaining the logic in source code comment in DAPM patch. Let me know if it is not clear and doesn't convey clearly what is should.

That'd be fine but there's no DAPM code in the patch, only code to unconditionally enable on init.

#4 lore raw
Quoted 16 lines · Mark Brown
Quoted 5 lines · Ashish Chavan
Quoted 2 lines · Liam

Any reason for not using DAPM here ? Otherwise they are always on making your chip burn mW.....

Quoted 9 lines

Not really. As explained in the comment in DAPM patch, this enables will be effective (burn mW) only after respective IO is taken out from STANDBY mode. DAPM takes care of managing STANDBY mode for all IOs and ADC/DAC. I know this way of handling low power mode is bit non-trivial, but it is what is recommended by chip designers. Actually Mark was also initially confused with this and requested to put enough documentation into code. After that I tried explaining the logic in source code comment in DAPM patch. Let me know if it is not clear and doesn't convey clearly what is should.

Quoted 3 lines

That'd be fine but there's no DAPM code in the patch, only code to unconditionally enable on init.

Yes, because DAPM part for those IOs is already covered by DAPM patch.

#5 lore raw
Quoted 6 lines · Ashish Chavan
Quoted 2 lines · Mark Brown

That'd be fine but there's no DAPM code in the patch, only code to unconditionally enable on init.

Yes, because DAPM part for those IOs is already covered by DAPM patch.

Ah, you should split that out of the DAPM patch into here - the DAPM bit won't work without the enable bits (as I understand it).

#6 lore raw
Quoted 11 lines · Mark Brown
Quoted 6 lines · Ashish Chavan
Quoted 2 lines · Mark Brown

That'd be fine but there's no DAPM code in the patch, only code to unconditionally enable on init.

Yes, because DAPM part for those IOs is already covered by DAPM patch.

Ah, you should split that out of the DAPM patch into here - the DAPM bit won't work without the enable bits (as I understand it).

Yes, your understanding is correct. Actually I acted bit lazy here by not splitting, assuming that both patches are going to get merged shortly. Do you think is it mandatory to do that? Or can I repost the patch after just resolving merge issue?

Thanks,

-- Ashish (GNU FAN)

#7 lore raw
Quoted 4 lines · Ashish Chavan

Yes, your understanding is correct. Actually I acted bit lazy here by not splitting, assuming that both patches are going to get merged shortly. Do you think is it mandatory to do that? Or can I repost the patch after just resolving merge issue?

It's better to refactor, it makes review much easier.

#8 lore raw
Quoted 9 lines · Mark Brown
Quoted 4 lines · Ashish Chavan

Yes, your understanding is correct. Actually I acted bit lazy here by not splitting, assuming that both patches are going to get merged shortly. Do you think is it mandatory to do that? Or can I repost the patch after just resolving merge issue?

It's better to refactor, it makes review much easier.

OK. I am moving out line out and mic/aux related stuff from DAPM patch and adding them in to other respective patches.