]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
ASoC: TLV320AIC3X: Add TLV information for volume controls
authorJarkko Nikula <jarkko.nikula@nokia.com>
Mon, 9 Feb 2009 12:27:07 +0000 (14:27 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 9 Feb 2009 18:27:59 +0000 (18:27 +0000)
TLV320AIC3X volume controls are logarithmic. Export their dB ranges.

Signed-off-by: Jarkko Nikula <jarkko.nikula@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/tlv320aic3x.c

index cdb6dec14e1c80f77d3a2d4e81235ddfac14a753..d638e3f0728bd89d6f508ac9e1ee994900ba6ca0 100644 (file)
@@ -45,6 +45,7 @@
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
 #include <sound/initval.h>
+#include <sound/tlv.h>
 
 #include "tlv320aic3x.h"
 
@@ -250,56 +251,86 @@ static const struct soc_enum aic3x_enum[] = {
        SOC_ENUM_DOUBLE(AIC3X_CODEC_DFILT_CTRL, 6, 4, 4, aic3x_adc_hpf),
 };
 
+/*
+ * DAC digital volumes. From -63.5 to 0 dB in 0.5 dB steps
+ */
+static DECLARE_TLV_DB_SCALE(dac_tlv, -6350, 50, 0);
+/* ADC PGA gain volumes. From 0 to 59.5 dB in 0.5 dB steps */
+static DECLARE_TLV_DB_SCALE(adc_tlv, 0, 50, 0);
+/*
+ * Output stage volumes. From -78.3 to 0 dB. Muted below -78.3 dB.
+ * Step size is approximately 0.5 dB over most of the scale but increasing
+ * near the very low levels.
+ * Define dB scale so that it is mostly correct for range about -55 to 0 dB
+ * but having increasing dB difference below that (and where it doesn't count
+ * so much). This setting shows -50 dB (actual is -50.3 dB) for register
+ * value 100 and -58.5 dB (actual is -78.3 dB) for register value 117.
+ */
+static DECLARE_TLV_DB_SCALE(output_stage_tlv, -5900, 50, 1);
+
 static const struct snd_kcontrol_new aic3x_snd_controls[] = {
        /* Output */
-       SOC_DOUBLE_R("PCM Playback Volume", LDAC_VOL, RDAC_VOL, 0, 0x7f, 1),
+       SOC_DOUBLE_R_TLV("PCM Playback Volume",
+                        LDAC_VOL, RDAC_VOL, 0, 0x7f, 1, dac_tlv),
 
-       SOC_DOUBLE_R("Line DAC Playback Volume", DACL1_2_LLOPM_VOL,
-                    DACR1_2_RLOPM_VOL, 0, 118, 1),
+       SOC_DOUBLE_R_TLV("Line DAC Playback Volume",
+                        DACL1_2_LLOPM_VOL, DACR1_2_RLOPM_VOL,
+                        0, 118, 1, output_stage_tlv),
        SOC_SINGLE("LineL Playback Switch", LLOPM_CTRL, 3, 0x01, 0),
        SOC_SINGLE("LineR Playback Switch", RLOPM_CTRL, 3, 0x01, 0),
-       SOC_DOUBLE_R("LineL DAC Playback Volume", DACL1_2_LLOPM_VOL,
-                    DACR1_2_LLOPM_VOL, 0, 118, 1),
-       SOC_SINGLE("LineL Left PGA Bypass Playback Volume", PGAL_2_LLOPM_VOL,
-                    0, 118, 1),
-       SOC_SINGLE("LineR Right PGA Bypass Playback Volume", PGAR_2_RLOPM_VOL,
-                    0, 118, 1),
-       SOC_DOUBLE_R("LineL Line2 Bypass Playback Volume", LINE2L_2_LLOPM_VOL,
-                    LINE2R_2_LLOPM_VOL, 0, 118, 1),
-       SOC_DOUBLE_R("LineR Line2 Bypass Playback Volume", LINE2L_2_RLOPM_VOL,
-                    LINE2R_2_RLOPM_VOL, 0, 118, 1),
-
-       SOC_DOUBLE_R("Mono DAC Playback Volume", DACL1_2_MONOLOPM_VOL,
-                    DACR1_2_MONOLOPM_VOL, 0, 118, 1),
+       SOC_DOUBLE_R_TLV("LineL DAC Playback Volume",
+                        DACL1_2_LLOPM_VOL, DACR1_2_LLOPM_VOL,
+                        0, 118, 1, output_stage_tlv),
+       SOC_SINGLE_TLV("LineL Left PGA Bypass Playback Volume",
+                      PGAL_2_LLOPM_VOL, 0, 118, 1, output_stage_tlv),
+       SOC_SINGLE_TLV("LineR Right PGA Bypass Playback Volume",
+                      PGAR_2_RLOPM_VOL, 0, 118, 1, output_stage_tlv),
+       SOC_DOUBLE_R_TLV("LineL Line2 Bypass Playback Volume",
+                        LINE2L_2_LLOPM_VOL, LINE2R_2_LLOPM_VOL,
+                        0, 118, 1, output_stage_tlv),
+       SOC_DOUBLE_R_TLV("LineR Line2 Bypass Playback Volume",
+                        LINE2L_2_RLOPM_VOL, LINE2R_2_RLOPM_VOL,
+                        0, 118, 1, output_stage_tlv),
+
+       SOC_DOUBLE_R_TLV("Mono DAC Playback Volume",
+                        DACL1_2_MONOLOPM_VOL, DACR1_2_MONOLOPM_VOL,
+                        0, 118, 1, output_stage_tlv),
        SOC_SINGLE("Mono DAC Playback Switch", MONOLOPM_CTRL, 3, 0x01, 0),
-       SOC_DOUBLE_R("Mono PGA Bypass Playback Volume", PGAL_2_MONOLOPM_VOL,
-                    PGAR_2_MONOLOPM_VOL, 0, 118, 1),
-       SOC_DOUBLE_R("Mono Line2 Bypass Playback Volume", LINE2L_2_MONOLOPM_VOL,
-                    LINE2R_2_MONOLOPM_VOL, 0, 118, 1),
-
-       SOC_DOUBLE_R("HP DAC Playback Volume", DACL1_2_HPLOUT_VOL,
-                    DACR1_2_HPROUT_VOL, 0, 118, 1),
+       SOC_DOUBLE_R_TLV("Mono PGA Bypass Playback Volume",
+                        PGAL_2_MONOLOPM_VOL, PGAR_2_MONOLOPM_VOL,
+                        0, 118, 1, output_stage_tlv),
+       SOC_DOUBLE_R_TLV("Mono Line2 Bypass Playback Volume",
+                        LINE2L_2_MONOLOPM_VOL, LINE2R_2_MONOLOPM_VOL,
+                        0, 118, 1, output_stage_tlv),
+
+       SOC_DOUBLE_R_TLV("HP DAC Playback Volume",
+                        DACL1_2_HPLOUT_VOL, DACR1_2_HPROUT_VOL,
+                        0, 118, 1, output_stage_tlv),
        SOC_DOUBLE_R("HP DAC Playback Switch", HPLOUT_CTRL, HPROUT_CTRL, 3,
                     0x01, 0),
-       SOC_DOUBLE_R("HP Right PGA Bypass Playback Volume", PGAR_2_HPLOUT_VOL,
-                    PGAR_2_HPROUT_VOL, 0, 118, 1),
-       SOC_SINGLE("HPL PGA Bypass Playback Volume", PGAL_2_HPLOUT_VOL,
-                    0, 118, 1),
-       SOC_SINGLE("HPR PGA Bypass Playback Volume", PGAL_2_HPROUT_VOL,
-                    0, 118, 1),
-       SOC_DOUBLE_R("HP Line2 Bypass Playback Volume", LINE2L_2_HPLOUT_VOL,
-                    LINE2R_2_HPROUT_VOL, 0, 118, 1),
-
-       SOC_DOUBLE_R("HPCOM DAC Playback Volume", DACL1_2_HPLCOM_VOL,
-                    DACR1_2_HPRCOM_VOL, 0, 118, 1),
+       SOC_DOUBLE_R_TLV("HP Right PGA Bypass Playback Volume",
+                        PGAR_2_HPLOUT_VOL, PGAR_2_HPROUT_VOL,
+                        0, 118, 1, output_stage_tlv),
+       SOC_SINGLE_TLV("HPL PGA Bypass Playback Volume",
+                      PGAL_2_HPLOUT_VOL, 0, 118, 1, output_stage_tlv),
+       SOC_SINGLE_TLV("HPR PGA Bypass Playback Volume",
+                      PGAL_2_HPROUT_VOL, 0, 118, 1, output_stage_tlv),
+       SOC_DOUBLE_R_TLV("HP Line2 Bypass Playback Volume",
+                        LINE2L_2_HPLOUT_VOL, LINE2R_2_HPROUT_VOL,
+                        0, 118, 1, output_stage_tlv),
+
+       SOC_DOUBLE_R_TLV("HPCOM DAC Playback Volume",
+                        DACL1_2_HPLCOM_VOL, DACR1_2_HPRCOM_VOL,
+                        0, 118, 1, output_stage_tlv),
        SOC_DOUBLE_R("HPCOM DAC Playback Switch", HPLCOM_CTRL, HPRCOM_CTRL, 3,
                     0x01, 0),
-       SOC_SINGLE("HPLCOM PGA Bypass Playback Volume", PGAL_2_HPLCOM_VOL,
-                    0, 118, 1),
-       SOC_SINGLE("HPRCOM PGA Bypass Playback Volume", PGAL_2_HPRCOM_VOL,
-                    0, 118, 1),
-       SOC_DOUBLE_R("HPCOM Line2 Bypass Playback Volume", LINE2L_2_HPLCOM_VOL,
-                    LINE2R_2_HPRCOM_VOL, 0, 118, 1),
+       SOC_SINGLE_TLV("HPLCOM PGA Bypass Playback Volume",
+                      PGAL_2_HPLCOM_VOL, 0, 118, 1, output_stage_tlv),
+       SOC_SINGLE_TLV("HPRCOM PGA Bypass Playback Volume",
+                      PGAL_2_HPRCOM_VOL, 0, 118, 1, output_stage_tlv),
+       SOC_DOUBLE_R_TLV("HPCOM Line2 Bypass Playback Volume",
+                        LINE2L_2_HPLCOM_VOL, LINE2R_2_HPRCOM_VOL,
+                        0, 118, 1, output_stage_tlv),
 
        /*
         * Note: enable Automatic input Gain Controller with care. It can
@@ -308,7 +339,8 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = {
        SOC_DOUBLE_R("AGC Switch", LAGC_CTRL_A, RAGC_CTRL_A, 7, 0x01, 0),
 
        /* Input */
-       SOC_DOUBLE_R("PGA Capture Volume", LADC_VOL, RADC_VOL, 0, 119, 0),
+       SOC_DOUBLE_R_TLV("PGA Capture Volume", LADC_VOL, RADC_VOL,
+                        0, 119, 0, adc_tlv),
        SOC_DOUBLE_R("PGA Capture Switch", LADC_VOL, RADC_VOL, 7, 0x01, 1),
 
        SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]),