]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ASoC: arizona: Basic support for ISRC rate selection
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 18 Feb 2013 19:09:23 +0000 (19:09 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 21 Mar 2013 17:55:14 +0000 (18:55 +0100)
Since ASoC does not yet really have the framework features needed to
support propagating sample rates through the device well yet implement
basic support for the ISRCs equivalent to that we currently have for the
ASRCs. The user can opt for 8kHz or 16kHz as the rate for the DSP blocks
in addition to the main audio rate, these being the primary use cases.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/arizona.c
sound/soc/codecs/arizona.h
sound/soc/codecs/wm5102.c
sound/soc/codecs/wm_adsp.c

index 6c773804ffe0cc3eb0bcc37d176686632e1545d6..26e1579c36cbef7e824beb19eb401bac7b3590c0 100644 (file)
@@ -433,6 +433,33 @@ EXPORT_SYMBOL_GPL(arizona_mixer_values);
 const DECLARE_TLV_DB_SCALE(arizona_mixer_tlv, -3200, 100, 0);
 EXPORT_SYMBOL_GPL(arizona_mixer_tlv);
 
+const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE] = {
+       "SYNCCLK rate", "8kHz", "16kHz", "ASYNCCLK rate",
+};
+EXPORT_SYMBOL_GPL(arizona_rate_text);
+
+const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE] = {
+       0, 1, 2, 8,
+};
+EXPORT_SYMBOL_GPL(arizona_rate_val);
+
+
+const struct soc_enum arizona_isrc_fsl[] = {
+       SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_1_CTRL_2,
+                             ARIZONA_ISRC1_FSL_SHIFT, 0xf,
+                             ARIZONA_RATE_ENUM_SIZE,
+                             arizona_rate_text, arizona_rate_val),
+       SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_2_CTRL_2,
+                             ARIZONA_ISRC2_FSL_SHIFT, 0xf,
+                             ARIZONA_RATE_ENUM_SIZE,
+                             arizona_rate_text, arizona_rate_val),
+       SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_3_CTRL_2,
+                             ARIZONA_ISRC3_FSL_SHIFT, 0xf,
+                             ARIZONA_RATE_ENUM_SIZE,
+                             arizona_rate_text, arizona_rate_val),
+};
+EXPORT_SYMBOL_GPL(arizona_isrc_fsl);
+
 static const char *arizona_vol_ramp_text[] = {
        "0ms/6dB", "0.5ms/6dB", "1ms/6dB", "2ms/6dB", "4ms/6dB", "8ms/6dB",
        "15ms/6dB", "30ms/6dB",
index 9399940f700d931f6373e8fac93fb4c514c0d6e2..a754a1c0217f3e4b846c63401ba59c9a7d1a51bb 100644 (file)
@@ -180,6 +180,12 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
        ARIZONA_MIXER_ROUTES(name, name "L"), \
        ARIZONA_MIXER_ROUTES(name, name "R")
 
+#define ARIZONA_RATE_ENUM_SIZE 4
+extern const char *arizona_rate_text[ARIZONA_RATE_ENUM_SIZE];
+extern const int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE];
+
+extern const struct soc_enum arizona_isrc_fsl[];
+
 extern const struct soc_enum arizona_in_vi_ramp;
 extern const struct soc_enum arizona_in_vd_ramp;
 
index 97757bc5fd0ec4632edbdef938a2434d969ba639..a0084b1febdbe98a8fd61a2f0715e49a8a468797 100644 (file)
@@ -731,6 +731,9 @@ SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
 SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
 SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
 
+SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]),
+SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]),
+
 ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE),
 ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE),
 
@@ -1532,7 +1535,7 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec)
        if (ret != 0)
                return ret;
 
-       ret = snd_soc_add_codec_controls(codec, wm_adsp_fw_controls, 1);
+       ret = snd_soc_add_codec_controls(codec, wm_adsp_fw_controls, 2);
        if (ret != 0)
                return ret;
 
@@ -1624,6 +1627,12 @@ static int wm5102_probe(struct platform_device *pdev)
                         ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK,
                         &wm5102->fll[1]);
 
+       /* SR2 fixed at 8kHz, SR3 fixed at 16kHz */
+       regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_2,
+                          ARIZONA_SAMPLE_RATE_2_MASK, 0x11);
+       regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_3,
+                          ARIZONA_SAMPLE_RATE_3_MASK, 0x12);
+
        for (i = 0; i < ARRAY_SIZE(wm5102_dai); i++)
                arizona_init_dai(&wm5102->core, i);
 
index f3f7e75f86280ef5160facc2a7f3cfa7972c6b91..3a481fd1bf9a25465723482e78891e7176ec2301 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <linux/mfd/arizona/registers.h>
 
+#include "arizona.h"
 #include "wm_adsp.h"
 
 #define adsp_crit(_dsp, fmt, ...) \
@@ -246,15 +247,38 @@ static const struct soc_enum wm_adsp_fw_enum[] = {
        SOC_ENUM_SINGLE(0, 3, ARRAY_SIZE(wm_adsp_fw_text), wm_adsp_fw_text),
 };
 
+static const struct soc_enum wm_adsp_rate_enum[] = {
+       SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP1_CONTROL_1,
+                             ARIZONA_DSP1_RATE_SHIFT, 0xf,
+                             ARIZONA_RATE_ENUM_SIZE,
+                             arizona_rate_text, arizona_rate_val),
+       SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP2_CONTROL_1,
+                             ARIZONA_DSP1_RATE_SHIFT, 0xf,
+                             ARIZONA_RATE_ENUM_SIZE,
+                             arizona_rate_text, arizona_rate_val),
+       SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP3_CONTROL_1,
+                             ARIZONA_DSP1_RATE_SHIFT, 0xf,
+                             ARIZONA_RATE_ENUM_SIZE,
+                             arizona_rate_text, arizona_rate_val),
+       SOC_VALUE_ENUM_SINGLE(ARIZONA_DSP3_CONTROL_1,
+                             ARIZONA_DSP1_RATE_SHIFT, 0xf,
+                             ARIZONA_RATE_ENUM_SIZE,
+                             arizona_rate_text, arizona_rate_val),
+};
+
 const struct snd_kcontrol_new wm_adsp_fw_controls[] = {
        SOC_ENUM_EXT("DSP1 Firmware", wm_adsp_fw_enum[0],
                     wm_adsp_fw_get, wm_adsp_fw_put),
+       SOC_ENUM("DSP1 Rate", wm_adsp_rate_enum[0]),
        SOC_ENUM_EXT("DSP2 Firmware", wm_adsp_fw_enum[1],
                     wm_adsp_fw_get, wm_adsp_fw_put),
+       SOC_ENUM("DSP2 Rate", wm_adsp_rate_enum[1]),
        SOC_ENUM_EXT("DSP3 Firmware", wm_adsp_fw_enum[2],
                     wm_adsp_fw_get, wm_adsp_fw_put),
+       SOC_ENUM("DSP3 Rate", wm_adsp_rate_enum[2]),
        SOC_ENUM_EXT("DSP4 Firmware", wm_adsp_fw_enum[3],
                     wm_adsp_fw_get, wm_adsp_fw_put),
+       SOC_ENUM("DSP4 Rate", wm_adsp_rate_enum[3]),
 };
 EXPORT_SYMBOL_GPL(wm_adsp_fw_controls);