This patch adds "FM-In" and "Line-In" playback mixer controls to 
sun4i-codec in <https://github.com/torvalds/linux.git>. It was 
successfully tested on A20-OLinuXino-LIME2. Muting works and the 
volume controls work. Note that enabling audio on LIME2 requires 
a minimal 'status = "okay"' dts patch which is not included. 

I tested the new mixer controls using alsamixer.

Signed-off-by: Danny Milosavljevic <danny...@scratchpost.org>
---
 sound/soc/sunxi/sun4i-codec.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index 1bb896d..4a5beaa 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -58,6 +58,12 @@
 #define SUN4I_CODEC_DAC_ACTL_DACAENR                   (31)
 #define SUN4I_CODEC_DAC_ACTL_DACAENL                   (30)
 #define SUN4I_CODEC_DAC_ACTL_MIXEN                     (29)
+#define SUN4I_CODEC_DAC_LINEIN_OUTPUT_VOLUME            (26) /* 1 bit */
+#define SUN4I_CODEC_DAC_FMIN_OUTPUT_VOLUME              (23) /* 3 bit */
+#define SUN4I_CODEC_DAC_LINEIN_L_SWITCH                 (19) /* 1 bit */
+#define SUN4I_CODEC_DAC_LINEIN_R_SWITCH                 (18) /* 1 bit */
+#define SUN4I_CODEC_DAC_FMIN_L_SWITCH                   (17) /* 1 bit */
+#define SUN4I_CODEC_DAC_FMIN_R_SWITCH                   (16) /* 1 bit */
 #define SUN4I_CODEC_DAC_ACTL_LDACLMIXS                 (15)
 #define SUN4I_CODEC_DAC_ACTL_RDACRMIXS                 (14)
 #define SUN4I_CODEC_DAC_ACTL_LDACRMIXS                 (13)
@@ -404,10 +410,40 @@ static const struct snd_kcontrol_new sun4i_codec_pa_mute =
 
 static DECLARE_TLV_DB_SCALE(sun4i_codec_pa_volume_scale, -6300, 100, 1);
 
+/* min = -1.5 dB, step = 1.5 dB, doesn't mute */
+static DECLARE_TLV_DB_SCALE(sun4i_codec_linein_volume_scale, -150, 150, 0);
+
+/* min = -4.5 dB, step = 1.5 dB, doesn't mute */
+static DECLARE_TLV_DB_SCALE(sun4i_codec_fmin_volume_scale, -450, 150, 0);
+
 static const struct snd_kcontrol_new sun4i_codec_widgets[] = {
        SOC_SINGLE_TLV("Power Amplifier Volume", SUN4I_CODEC_DAC_ACTL,
                       SUN4I_CODEC_DAC_ACTL_PA_VOL, 0x3F, 0,
                       sun4i_codec_pa_volume_scale),
+       SOC_SINGLE_TLV("Line-In Playback Volume",
+                      SUN4I_CODEC_DAC_ACTL,
+                      SUN4I_CODEC_DAC_LINEIN_OUTPUT_VOLUME,
+                      1,
+                      0,
+                      sun4i_codec_linein_volume_scale),
+       SOC_SINGLE_TLV("FM-In Playback Volume",
+                      SUN4I_CODEC_DAC_ACTL,
+                      SUN4I_CODEC_DAC_FMIN_OUTPUT_VOLUME,
+                      3,
+                      0,
+                      sun4i_codec_fmin_volume_scale),
+       SOC_DOUBLE("Line-In Playback Switch",
+                  SUN4I_CODEC_DAC_ACTL,
+                  SUN4I_CODEC_DAC_LINEIN_L_SWITCH,
+                  SUN4I_CODEC_DAC_LINEIN_R_SWITCH,
+                  1,
+                  0),
+       SOC_DOUBLE("FM-In Playback Switch",
+                  SUN4I_CODEC_DAC_ACTL,
+                  SUN4I_CODEC_DAC_FMIN_L_SWITCH,
+                  SUN4I_CODEC_DAC_FMIN_R_SWITCH,
+                  1,
+                  0),
 };
 
 static const struct snd_kcontrol_new sun4i_codec_left_mixer_controls[] = {
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to