Merge branches 'topic/sta350', 'topic/core', 'topic/dapm' and 'topic/cache' of git...
authorMark Brown <broonie@linaro.org>
Tue, 22 Apr 2014 12:22:52 +0000 (13:22 +0100)
committerMark Brown <broonie@linaro.org>
Tue, 22 Apr 2014 12:22:52 +0000 (13:22 +0100)
65 files changed:
Documentation/devicetree/bindings/sound/st,sta350.txt [new file with mode: 0644]
include/sound/soc.h
include/sound/sta350.h [new file with mode: 0644]
sound/soc/codecs/88pm860x-codec.c
sound/soc/codecs/Kconfig
sound/soc/codecs/Makefile
sound/soc/codecs/ab8500-codec.c
sound/soc/codecs/adav80x.c
sound/soc/codecs/ak4641.c
sound/soc/codecs/cq93vc.c
sound/soc/codecs/cs4270.c
sound/soc/codecs/cs4271.c
sound/soc/codecs/cs42l51.c
sound/soc/codecs/da7210.c
sound/soc/codecs/da7213.c
sound/soc/codecs/da732x.c
sound/soc/codecs/da9055.c
sound/soc/codecs/lm4857.c
sound/soc/codecs/max9768.c
sound/soc/codecs/max98088.c
sound/soc/codecs/max98090.c
sound/soc/codecs/max98095.c
sound/soc/codecs/mc13783.c
sound/soc/codecs/pcm1681.c
sound/soc/codecs/rt5631.c
sound/soc/codecs/sgtl5000.c
sound/soc/codecs/si476x.c
sound/soc/codecs/sta32x.c
sound/soc/codecs/sta350.c [new file with mode: 0644]
sound/soc/codecs/sta350.h [new file with mode: 0644]
sound/soc/codecs/tas5086.c
sound/soc/codecs/tlv320aic23.c
sound/soc/codecs/tlv320dac33.c
sound/soc/codecs/twl4030.c
sound/soc/codecs/twl6040.c
sound/soc/codecs/wl1273.c
sound/soc/codecs/wm2000.c
sound/soc/codecs/wm5102.c
sound/soc/codecs/wm5110.c
sound/soc/codecs/wm8350.c
sound/soc/codecs/wm8400.c
sound/soc/codecs/wm8580.c
sound/soc/codecs/wm8731.c
sound/soc/codecs/wm8753.c
sound/soc/codecs/wm8804.c
sound/soc/codecs/wm8903.c
sound/soc/codecs/wm8904.c
sound/soc/codecs/wm8955.c
sound/soc/codecs/wm8958-dsp2.c
sound/soc/codecs/wm8960.c
sound/soc/codecs/wm8962.c
sound/soc/codecs/wm8983.c
sound/soc/codecs/wm8985.c
sound/soc/codecs/wm8990.c
sound/soc/codecs/wm8991.c
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm8996.c
sound/soc/codecs/wm8997.c
sound/soc/codecs/wm9081.c
sound/soc/codecs/wm_adsp.c
sound/soc/codecs/wm_hubs.c
sound/soc/intel/sst-haswell-pcm.c
sound/soc/soc-cache.c
sound/soc/soc-core.c
sound/soc/soc-io.c

diff --git a/Documentation/devicetree/bindings/sound/st,sta350.txt b/Documentation/devicetree/bindings/sound/st,sta350.txt
new file mode 100644 (file)
index 0000000..9501888
--- /dev/null
@@ -0,0 +1,107 @@
+STA350 audio CODEC
+
+The driver for this device only supports I2C.
+
+Required properties:
+
+  - compatible: "st,sta350"
+  - reg: the I2C address of the device for I2C
+  - reset-gpios: a GPIO spec for the reset pin. If specified, it will be
+                deasserted before communication to the codec starts.
+
+  - power-down-gpios: a GPIO spec for the power down pin. If specified,
+                     it will be deasserted before communication to the codec
+                     starts.
+
+  - vdd-dig-supply: regulator spec, providing 3.3V
+  - vdd-pll-supply: regulator spec, providing 3.3V
+  - vcc-supply: regulator spec, providing 5V - 26V
+
+Optional properties:
+
+  -  st,output-conf: number, Selects the output configuration:
+       0: 2-channel (full-bridge) power, 2-channel data-out
+       1: 2 (half-bridge). 1 (full-bridge) on-board power
+       2: 2 Channel (Full-Bridge) Power, 1 Channel FFX
+       3: 1 Channel Mono-Parallel
+       If parameter is missing, mode 0 will be enabled.
+
+  -  st,ch1-output-mapping: Channel 1 output mapping
+  -  st,ch2-output-mapping: Channel 2 output mapping
+  -  st,ch3-output-mapping: Channel 3 output mapping
+       0: Channel 1
+       1: Channel 2
+       2: Channel 3
+       If parameter is missing, channel 1 is choosen.
+
+  -  st,thermal-warning-recover:
+       If present, thermal warning recovery is enabled.
+
+  -  st,thermal-warning-adjustment:
+       If present, thermal warning adjustment is enabled.
+
+  -  st,fault-detect-recovery:
+       If present, then fault recovery will be enabled.
+
+  -  st,ffx-power-output-mode: string
+       The FFX power output mode selects how the FFX output timing is
+       configured. Must be one of these values:
+         -  "drop-compensation"
+         -  "tapered-compensation"
+         -  "full-power-mode"
+         -  "variable-drop-compensation" (default)
+
+  -  st,drop-compensation-ns: number
+       Only required for "st,ffx-power-output-mode" ==
+       "variable-drop-compensation".
+       Specifies the drop compensation in nanoseconds.
+       The value must be in the range of 0..300, and only
+       multiples of 20 are allowed. Default is 140ns.
+
+  -  st,overcurrent-warning-adjustment:
+       If present, overcurrent warning adjustment is enabled.
+
+  -  st,max-power-use-mpcc:
+       If present, then MPCC bits are used for MPC coefficients,
+       otherwise standard MPC coefficients are used.
+
+  -  st,max-power-corr:
+       If present, power bridge correction for THD reduction near maximum
+       power output is enabled.
+
+  -  st,am-reduction-mode:
+       If present, FFX mode runs in AM reduction mode, otherwise normal
+       FFX mode is used.
+
+  -  st,odd-pwm-speed-mode:
+       If present, PWM speed mode run on odd speed mode (341.3 kHz) on all
+       channels. If not present, normal PWM spped mode (384 kHz) will be used.
+
+  -  st,distortion-compensation:
+       If present, distortion compensation variable uses DCC coefficient.
+       If not present, preset DC coefficient is used.
+
+  -  st,invalid-input-detect-mute:
+       If not present, automatic invalid input detect mute is enabled.
+
+
+
+Example:
+
+codec: sta350@38 {
+       compatible = "st,sta350";
+       reg = <0x1c>;
+       reset-gpios = <&gpio1 19 0>;
+       power-down-gpios = <&gpio1 16 0>;
+       st,output-conf = <0x3>;                 // set output to 2-channel
+                                               // (full-bridge) power,
+                                               // 2-channel data-out
+       st,ch1-output-mapping = <0>;            // set channel 1 output ch 1
+       st,ch2-output-mapping = <0>;            // set channel 2 output ch 1
+       st,ch3-output-mapping = <0>;            // set channel 3 output ch 1
+       st,max-power-correction;                // enables power bridge
+                                               // correction for THD reduction
+                                               // near maximum power output
+       st,invalid-input-detect-mute;           // mute if no valid digital
+                                               // audio signal is provided.
+};
index 0b83168d8ff45a2ff394057ef0d172ab783f84d8..8148c98b5f8fa0f22377a9413163d6f75c52ce8d 100644 (file)
@@ -393,12 +393,6 @@ int devm_snd_soc_register_component(struct device *dev,
                         const struct snd_soc_component_driver *cmpnt_drv,
                         struct snd_soc_dai_driver *dai_drv, int num_dai);
 void snd_soc_unregister_component(struct device *dev);
-int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
-                                   unsigned int reg);
-int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
-                                   unsigned int reg);
-int snd_soc_codec_writable_register(struct snd_soc_codec *codec,
-                                   unsigned int reg);
 int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
                               struct regmap *regmap);
 int snd_soc_cache_sync(struct snd_soc_codec *codec);
@@ -469,12 +463,12 @@ static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
 #endif
 
 /* codec register bit access */
-int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
+int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg,
                                unsigned int mask, unsigned int value);
 int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
-                              unsigned short reg, unsigned int mask,
+                              unsigned int reg, unsigned int mask,
                               unsigned int value);
-int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
+int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
                                unsigned int mask, unsigned int value);
 
 int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
@@ -668,6 +662,7 @@ struct snd_soc_component {
        unsigned int active;
 
        unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
+       unsigned int registered_as_component:1;
 
        struct list_head list;
 
@@ -692,9 +687,6 @@ struct snd_soc_codec {
        struct list_head list;
        struct list_head card_list;
        int num_dai;
-       int (*volatile_register)(struct snd_soc_codec *, unsigned int);
-       int (*readable_register)(struct snd_soc_codec *, unsigned int);
-       int (*writable_register)(struct snd_soc_codec *, unsigned int);
 
        /* runtime */
        struct snd_ac97 *ac97;  /* for ad-hoc ac97 devices */
@@ -754,13 +746,9 @@ struct snd_soc_codec_driver {
                unsigned int freq_in, unsigned int freq_out);
 
        /* codec IO */
+       struct regmap *(*get_regmap)(struct device *);
        unsigned int (*read)(struct snd_soc_codec *, unsigned int);
        int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
-       int (*display_register)(struct snd_soc_codec *, char *,
-                               size_t, unsigned int);
-       int (*volatile_register)(struct snd_soc_codec *, unsigned int);
-       int (*readable_register)(struct snd_soc_codec *, unsigned int);
-       int (*writable_register)(struct snd_soc_codec *, unsigned int);
        unsigned int reg_cache_size;
        short reg_cache_step;
        short reg_word_size;
@@ -791,6 +779,7 @@ struct snd_soc_platform_driver {
        int (*remove)(struct snd_soc_platform *);
        int (*suspend)(struct snd_soc_dai *dai);
        int (*resume)(struct snd_soc_dai *dai);
+       struct snd_soc_component_driver component_driver;
 
        /* pcm creation and destruction */
        int (*pcm_new)(struct snd_soc_pcm_runtime *);
@@ -844,6 +833,8 @@ struct snd_soc_platform {
        struct list_head list;
        struct list_head card_list;
 
+       struct snd_soc_component component;
+
        struct snd_soc_dapm_context dapm;
 
 #ifdef CONFIG_DEBUG_FS
@@ -1120,10 +1111,23 @@ static inline struct snd_soc_codec *snd_soc_component_to_codec(
        return container_of(component, struct snd_soc_codec, component);
 }
 
+/**
+ * snd_soc_component_to_platform() - Casts a component to the platform it is embedded in
+ * @component: The component to cast to a platform
+ *
+ * This function must only be used on components that are known to be platforms.
+ * Otherwise the behavior is undefined.
+ */
+static inline struct snd_soc_platform *snd_soc_component_to_platform(
+       struct snd_soc_component *component)
+{
+       return container_of(component, struct snd_soc_platform, component);
+}
+
 /* codec IO */
 unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
-unsigned int snd_soc_write(struct snd_soc_codec *codec,
-                          unsigned int reg, unsigned int val);
+int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
+       unsigned int val);
 
 /* device driver data */
 
@@ -1228,6 +1232,34 @@ static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec)
        return snd_soc_component_is_active(&codec->component);
 }
 
+/**
+ * snd_soc_kcontrol_codec() - Returns the CODEC that registered the control
+ * @kcontrol: The control for which to get the CODEC
+ *
+ * Note: This function will only work correctly if the control has been
+ * registered with snd_soc_add_codec_controls() or via table based setup of
+ * snd_soc_codec_driver. Otherwise the behavior is undefined.
+ */
+static inline struct snd_soc_codec *snd_soc_kcontrol_codec(
+       struct snd_kcontrol *kcontrol)
+{
+       return snd_kcontrol_chip(kcontrol);
+}
+
+/**
+ * snd_soc_kcontrol_platform() - Returns the platform that registerd the control
+ * @kcontrol: The control for which to get the platform
+ *
+ * Note: This function will only work correctly if the control has been
+ * registered with snd_soc_add_platform_controls() or via table based setup of
+ * a snd_soc_platform_driver. Otherwise the behavior is undefined.
+ */
+static inline struct snd_soc_platform *snd_soc_kcontrol_platform(
+       struct snd_kcontrol *kcontrol)
+{
+       return snd_kcontrol_chip(kcontrol);
+}
+
 int snd_soc_util_init(void);
 void snd_soc_util_exit(void);
 
diff --git a/include/sound/sta350.h b/include/sound/sta350.h
new file mode 100644 (file)
index 0000000..3a32981
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Platform data for ST STA350 ASoC codec driver.
+ *
+ * Copyright: 2014 Raumfeld GmbH
+ * Author: Sven Brandau <info@brandau.biz>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+#ifndef __LINUX_SND__STA350_H
+#define __LINUX_SND__STA350_H
+
+#define STA350_OCFG_2CH                0
+#define STA350_OCFG_2_1CH      1
+#define STA350_OCFG_1CH                3
+
+#define STA350_OM_CH1          0
+#define STA350_OM_CH2          1
+#define STA350_OM_CH3          2
+
+#define STA350_THERMAL_ADJUSTMENT_ENABLE       1
+#define STA350_THERMAL_RECOVERY_ENABLE         2
+#define STA350_FAULT_DETECT_RECOVERY_BYPASS    1
+
+#define STA350_FFX_PM_DROP_COMP                        0
+#define STA350_FFX_PM_TAPERED_COMP             1
+#define STA350_FFX_PM_FULL_POWER               2
+#define STA350_FFX_PM_VARIABLE_DROP_COMP       3
+
+
+struct sta350_platform_data {
+       u8 output_conf;
+       u8 ch1_output_mapping;
+       u8 ch2_output_mapping;
+       u8 ch3_output_mapping;
+       u8 ffx_power_output_mode;
+       u8 drop_compensation_ns;
+       unsigned int thermal_warning_recovery:1;
+       unsigned int thermal_warning_adjustment:1;
+       unsigned int fault_detect_recovery:1;
+       unsigned int oc_warning_adjustment:1;
+       unsigned int max_power_use_mpcc:1;
+       unsigned int max_power_correction:1;
+       unsigned int am_reduction_mode:1;
+       unsigned int odd_pwm_speed_mode:1;
+       unsigned int distortion_compensation:1;
+       unsigned int invalid_input_detect_mute:1;
+};
+
+#endif /* __LINUX_SND__STA350_H */
index b07e17160f94a0453cf080cc487da4874f930673..3c4b10ff48c1c94cc15432d8f945d8a486376a75 100644 (file)
@@ -276,7 +276,7 @@ static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
        int val[2], val2[2], i;
@@ -300,7 +300,7 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
        int err;
@@ -333,7 +333,7 @@ static int snd_soc_get_volsw_2r_out(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
        unsigned int shift = mc->shift;
@@ -353,7 +353,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
        unsigned int shift = mc->shift;
@@ -1327,10 +1327,6 @@ static int pm860x_probe(struct snd_soc_codec *codec)
 
        pm860x->codec = codec;
 
-       ret = snd_soc_codec_set_cache_io(codec, pm860x->regmap);
-       if (ret)
-               return ret;
-
        for (i = 0; i < 4; i++) {
                ret = request_threaded_irq(pm860x->irq[i], NULL,
                                           pm860x_codec_handler, IRQF_ONESHOT,
@@ -1362,10 +1358,18 @@ static int pm860x_remove(struct snd_soc_codec *codec)
        return 0;
 }
 
+static struct regmap *pm860x_get_regmap(struct device *dev)
+{
+       struct pm860x_priv *pm860x = dev_get_drvdata(dev);
+
+       return pm860x->regmap;
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_pm860x = {
        .probe          = pm860x_probe,
        .remove         = pm860x_remove,
        .set_bias_level = pm860x_set_bias_level,
+       .get_regmap     = pm860x_get_regmap,
 
        .controls = pm860x_snd_controls,
        .num_controls = ARRAY_SIZE(pm860x_snd_controls),
index f0e8401378873721f0e69e7fe338fe00afe29fb5..c7b853f520cf17454a80d0ab81e671cccf972609 100644 (file)
@@ -80,6 +80,7 @@ config SND_SOC_ALL_CODECS
        select SND_SOC_SSM2602_SPI if SPI_MASTER
        select SND_SOC_SSM2602_I2C if I2C
        select SND_SOC_STA32X if I2C
+       select SND_SOC_STA350 if I2C
        select SND_SOC_STA529 if I2C
        select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
        select SND_SOC_TAS5086 if I2C
@@ -435,6 +436,10 @@ config SND_SOC_SSM2602_I2C
 config SND_SOC_STA32X
        tristate
 
+config SND_SOC_STA350
+       tristate "STA350 speaker amplifier"
+       depends on I2C
+
 config SND_SOC_STA529
        tristate
 
index 3c4d275d064bf8cc921c754a2dc577bdf72f4fe8..efdb4d0602015ab08669eff3b122f705ba9a4227 100644 (file)
@@ -74,6 +74,7 @@ snd-soc-ssm2602-objs := ssm2602.o
 snd-soc-ssm2602-spi-objs := ssm2602-spi.o
 snd-soc-ssm2602-i2c-objs := ssm2602-i2c.o
 snd-soc-sta32x-objs := sta32x.o
+snd-soc-sta350-objs := sta350.o
 snd-soc-sta529-objs := sta529.o
 snd-soc-stac9766-objs := stac9766.o
 snd-soc-tas5086-objs := tas5086.o
@@ -221,6 +222,7 @@ obj-$(CONFIG_SND_SOC_SSM2602)       += snd-soc-ssm2602.o
 obj-$(CONFIG_SND_SOC_SSM2602_SPI)      += snd-soc-ssm2602-spi.o
 obj-$(CONFIG_SND_SOC_SSM2602_I2C)      += snd-soc-ssm2602-i2c.o
 obj-$(CONFIG_SND_SOC_STA32X)   += snd-soc-sta32x.o
+obj-$(CONFIG_SND_SOC_STA350)   += snd-soc-sta350.o
 obj-$(CONFIG_SND_SOC_STA529)   += snd-soc-sta529.o
 obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o
 obj-$(CONFIG_SND_SOC_TAS5086)  += snd-soc-tas5086.o
index 1ad92cbf0b24dfba1f97ecad1a8eca1b56940fad..1fb4402bf72d3047c38fdca362700d4c65739dd7 100644 (file)
@@ -1139,7 +1139,7 @@ static void anc_configure(struct snd_soc_codec *codec,
 static int sid_status_control_get(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
 
        mutex_lock(&codec->mutex);
@@ -1153,7 +1153,7 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol,
 static int sid_status_control_put(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
        unsigned int param, sidconf, val;
        int status = 1;
@@ -1208,7 +1208,7 @@ out:
 static int anc_status_control_get(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
 
        mutex_lock(&codec->mutex);
@@ -1221,7 +1221,7 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol,
 static int anc_status_control_put(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
        struct device *dev = codec->dev;
        bool apply_fir, apply_iir;
@@ -1306,7 +1306,7 @@ static int filter_control_info(struct snd_kcontrol *kcontrol,
 static int filter_control_get(struct snd_kcontrol *kcontrol,
                        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct filter_control *fc =
                        (struct filter_control *)kcontrol->private_value;
        unsigned int i;
@@ -1322,7 +1322,7 @@ static int filter_control_get(struct snd_kcontrol *kcontrol,
 static int filter_control_put(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct filter_control *fc =
                        (struct filter_control *)kcontrol->private_value;
        unsigned int i;
index 5062e34ee8dcbdec1849ce83c299409b4ee6d582..cf170b5ef4260e63a24038a07d5694d4dc887d28 100644 (file)
@@ -315,7 +315,7 @@ static int adav80x_set_deemph(struct snd_soc_codec *codec)
 static int adav80x_put_deemph(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
        unsigned int deemph = ucontrol->value.enumerated.item[0];
 
@@ -330,7 +330,7 @@ static int adav80x_put_deemph(struct snd_kcontrol *kcontrol,
 static int adav80x_get_deemph(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = adav80x->deemph;
index 868c0e2da1ece12102dc7f6a1ecc2aa6d50a66ab..7afe8f4820887b695cb20912f9f68e0c17de7de1 100644 (file)
@@ -74,7 +74,7 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec)
 static int ak4641_put_deemph(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec);
        int deemph = ucontrol->value.enumerated.item[0];
 
@@ -89,7 +89,7 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol,
 static int ak4641_get_deemph(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = ak4641->deemph;
index 1e25c7af853bcdb7c40b7c94d4cb2ca6e878b8be..5ee48c8e48490948847333d3a650a875e19421ff 100644 (file)
@@ -139,8 +139,6 @@ static int cq93vc_probe(struct snd_soc_codec *codec)
 
        davinci_vc->cq93vc.codec = codec;
 
-       snd_soc_codec_set_cache_io(codec, davinci_vc->regmap);
-
        /* Off, with power on */
        cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
@@ -154,11 +152,19 @@ static int cq93vc_remove(struct snd_soc_codec *codec)
        return 0;
 }
 
+static struct regmap *cq93vc_get_regmap(struct device *dev)
+{
+       struct davinci_vc *davinci_vc = codec->dev->platform_data;
+
+       return davinci_vc->regmap;
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_cq93vc = {
        .set_bias_level = cq93vc_set_bias_level,
        .probe = cq93vc_probe,
        .remove = cq93vc_remove,
        .resume = cq93vc_resume,
+       .get_regmap = cq93vc_get_regmap,
        .controls = cq93vc_snd_controls,
        .num_controls = ARRAY_SIZE(cq93vc_snd_controls),
 };
index 3920e626494885947853fd856f9d5ed37bc443ed..9947a95836794f382b8bf60110c6dee857bde4e2 100644 (file)
@@ -438,7 +438,7 @@ static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute)
 static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec);
        int left = !ucontrol->value.integer.value[0];
        int right = !ucontrol->value.integer.value[1];
index aef4965750c780ec52bea5d0285fe1142e1ba83d..93cec52f473332fbd37cc28be97c03c4696d1780 100644 (file)
@@ -284,7 +284,7 @@ static int cs4271_set_deemph(struct snd_soc_codec *codec)
 static int cs4271_get_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = cs4271->deemph;
@@ -294,7 +294,7 @@ static int cs4271_get_deemph(struct snd_kcontrol *kcontrol,
 static int cs4271_put_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
 
        cs4271->deemph = ucontrol->value.enumerated.item[0];
index 6c0da2baa154e2a79a1baaf4392efacf4a7694af..23acaa0263dcd37c0222550fba0032e313bc99bd 100644 (file)
@@ -55,7 +55,7 @@ struct cs42l51_private {
 static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol,
                        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned long value = snd_soc_read(codec, CS42L51_PCM_MIXER)&3;
 
        switch (value) {
@@ -83,7 +83,7 @@ static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol,
 static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol,
                        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned char val;
 
        switch (ucontrol->value.integer.value[0]) {
index 137e8ebc092c5a9f2c1264723211ba7e8405871f..21810e5f3321c863c48ec00bab4f1bbfddc203d8 100644 (file)
@@ -335,7 +335,7 @@ static SOC_ENUM_SINGLE_DECL(da7210_hp_mode_sel,
 static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
 
        if (ucontrol->value.integer.value[0]) {
                /* Check if noise suppression is enabled */
@@ -358,7 +358,7 @@ static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol,
 static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol,
                                   struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        u8 val;
 
        if (ucontrol->value.integer.value[0]) {
index 738fa18a50d2a82c900c49fbc68f3c07c7dd2c07..9ec577f0edb4c061197e75b932f671c43577b208 100644 (file)
@@ -345,7 +345,7 @@ static void da7213_alc_calib(struct snd_soc_codec *codec)
 static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec);
        int ret;
 
@@ -361,7 +361,7 @@ static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol,
 static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol,
                            struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec);
 
        /* Force ALC offset calibration if enabling ALC */
index 48f3fef6848451cecb80c586a742d4ccaa619dbd..2fae31cb006745587e0fb1a51491dd10e0facea5 100644 (file)
@@ -332,7 +332,7 @@ static SOC_ENUM_SINGLE_DECL(da732x_adc2_voice_filter_enum,
 static int da732x_hpf_set(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value;
        unsigned int reg = enum_ctrl->reg;
        unsigned int sel = ucontrol->value.integer.value[0];
@@ -360,7 +360,7 @@ static int da732x_hpf_set(struct snd_kcontrol *kcontrol,
 static int da732x_hpf_get(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value;
        unsigned int reg = enum_ctrl->reg;
        int val;
index 4ff06b50fbba78342b596058bfac5a9ce973d097..ad19cc56702b46fda1d98045730ae27bd3a2b633 100644 (file)
@@ -484,7 +484,7 @@ static int da9055_get_alc_data(struct snd_soc_codec *codec, u8 reg_val)
 static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        u8 reg_val, adc_left, adc_right, mic_left, mic_right;
        int avg_left_data, avg_right_data, offset_l, offset_r;
 
index 4f048db9f55f1aa0953f4c971c0425a3178a159c..a924bb9d78860c11c84d7420f46c54929d3b7eb8 100644 (file)
@@ -49,7 +49,7 @@ static const struct reg_default lm4857_default_regs[] = {
 static int lm4857_get_mode(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = lm4857->mode;
@@ -60,7 +60,7 @@ static int lm4857_get_mode(struct snd_kcontrol *kcontrol,
 static int lm4857_set_mode(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec);
        uint8_t value = ucontrol->value.integer.value[0];
 
index ec481fc428c7c9fcb7a963fbabd1e9f34c1ace7b..e1c196a4193033c2cb033c6116076c4269b7dd33 100644 (file)
@@ -43,7 +43,7 @@ static struct reg_default max9768_default_regs[] = {
 static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec);
        int val = gpio_get_value_cansleep(max9768->mute_gpio);
 
@@ -55,7 +55,7 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
 static int max9768_set_gpio(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec);
 
        gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]);
index ef7cf89f562342307828eafbe0c7b9094b5546e1..9134982807b5dbab87a36581b10454b39f7ba791 100644 (file)
@@ -635,7 +635,7 @@ static SOC_ENUM_SINGLE_DECL(max98088_dai1_adc_filter_enum,
 static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
        unsigned int sel = ucontrol->value.integer.value[0];
 
@@ -649,7 +649,7 @@ static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol,
 static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = max98088->mic1pre;
@@ -659,7 +659,7 @@ static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol,
 static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
        unsigned int sel = ucontrol->value.integer.value[0];
 
@@ -673,7 +673,7 @@ static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol,
 static int max98088_mic2pre_get(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = max98088->mic2pre;
@@ -1750,7 +1750,7 @@ static void max98088_setup_eq2(struct snd_soc_codec *codec)
 static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
        struct max98088_pdata *pdata = max98088->pdata;
        int channel = max98088_get_channel(codec, kcontrol->id.name);
@@ -1782,7 +1782,7 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol,
 static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec);
        int channel = max98088_get_channel(codec, kcontrol->id.name);
        struct max98088_cdata *cdata;
index f7b0b37aa85827e7cd45a8afda039078c7079f0e..49d12387ac2fcac80b06dd37cc6c45fe2a464d89 100644 (file)
@@ -426,7 +426,7 @@ static const unsigned int max98090_rcv_lout_tlv[] = {
 static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
@@ -466,7 +466,7 @@ static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol,
 static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
index 03f0536e6f6185cf72178fad877484a4eb1dc679..5d4c621dbf99de031abb5d2b1a341fda24d11448 100644 (file)
@@ -612,7 +612,7 @@ static SOC_ENUM_SINGLE_DECL(max98095_dai3_dac_filter_enum,
 static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
        unsigned int sel = ucontrol->value.integer.value[0];
 
@@ -626,7 +626,7 @@ static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol,
 static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = max98095->mic1pre;
@@ -636,7 +636,7 @@ static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol,
 static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
        unsigned int sel = ucontrol->value.integer.value[0];
 
@@ -650,7 +650,7 @@ static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol,
 static int max98095_mic2pre_get(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = max98095->mic2pre;
@@ -1737,7 +1737,7 @@ static int max98095_get_eq_channel(const char *name)
 static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
        struct max98095_pdata *pdata = max98095->pdata;
        int channel = max98095_get_eq_channel(kcontrol->id.name);
@@ -1801,7 +1801,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
 static int max98095_get_eq_enum(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
        int channel = max98095_get_eq_channel(kcontrol->id.name);
        struct max98095_cdata *cdata;
@@ -1891,7 +1891,7 @@ static int max98095_get_bq_channel(struct snd_soc_codec *codec,
 static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
        struct max98095_pdata *pdata = max98095->pdata;
        int channel = max98095_get_bq_channel(codec, kcontrol->id.name);
@@ -1952,7 +1952,7 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
 static int max98095_get_bq_enum(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec);
        int channel = max98095_get_bq_channel(codec, kcontrol->id.name);
        struct max98095_cdata *cdata;
index 2c59b1fb69dc98368035e2c4d05a4db9f1cc167b..9029e20514e16c07ca929d71ff884cbf3369ada5 100644 (file)
@@ -608,14 +608,6 @@ static struct snd_kcontrol_new mc13783_control_list[] = {
 static int mc13783_probe(struct snd_soc_codec *codec)
 {
        struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec);
-       int ret;
-
-       ret = snd_soc_codec_set_cache_io(codec,
-                       dev_get_regmap(codec->dev->parent, NULL));
-       if (ret != 0) {
-               dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
-               return ret;
-       }
 
        /* these are the reset values */
        mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893);
@@ -735,9 +727,15 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = {
        }
 };
 
+static struct regmap *mc13783_get_regmap(struct device *dev)
+{
+       return dev_get_regmap(dev->parent, NULL);
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_mc13783 = {
        .probe          = mc13783_probe,
        .remove         = mc13783_remove,
+       .get_regmap     = mc13783_get_regmap,
        .controls       = mc13783_control_list,
        .num_controls   = ARRAY_SIZE(mc13783_control_list),
        .dapm_widgets   = mc13783_dapm_widgets,
index e427544183d7f2ee095913adc0a8ad7104f4ebd4..a722a023c26280a3c89f7a198e95c818f0c2fe6a 100644 (file)
@@ -115,7 +115,7 @@ static int pcm1681_set_deemph(struct snd_soc_codec *codec)
 static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = priv->deemph;
@@ -126,7 +126,7 @@ static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol,
 static int pcm1681_put_deemph(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec);
 
        priv->deemph = ucontrol->value.enumerated.item[0];
index d4c229f0233ff34c0e474a26b584606f414e6195..30e23470857949232092f3c6ef1c3e13abf46d25 100644 (file)
@@ -188,7 +188,7 @@ static unsigned int mic_bst_tlv[] = {
 static int rt5631_dmic_get(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = rt5631->dmic_used_flag;
@@ -199,7 +199,7 @@ static int rt5631_dmic_get(struct snd_kcontrol *kcontrol,
 static int rt5631_dmic_put(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
 
        rt5631->dmic_used_flag = ucontrol->value.integer.value[0];
index d3ed1be5a186c50fdaab98e0cf725dce53cb4f32..b56caefcf6644d153bb72d0b2d616c12904a1124 100644 (file)
@@ -296,7 +296,7 @@ static int dac_info_volsw(struct snd_kcontrol *kcontrol,
 static int dac_get_volsw(struct snd_kcontrol *kcontrol,
                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        int reg;
        int l;
        int r;
@@ -349,7 +349,7 @@ static int dac_get_volsw(struct snd_kcontrol *kcontrol,
 static int dac_put_volsw(struct snd_kcontrol *kcontrol,
                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        int reg;
        int l;
        int r;
index 244c097cd9053948d43b13c77fee6d6a8b6c7342..f26befb0c297d5f4d99040424195d376e7a384ce 100644 (file)
@@ -208,13 +208,6 @@ out:
        return err;
 }
 
-static int si476x_codec_probe(struct snd_soc_codec *codec)
-{
-       struct regmap *regmap = dev_get_regmap(codec->dev->parent, NULL);
-
-       return snd_soc_codec_set_cache_io(codec, regmap);
-}
-
 static struct snd_soc_dai_ops si476x_dai_ops = {
        .hw_params      = si476x_codec_hw_params,
        .set_fmt        = si476x_codec_set_dai_fmt,
@@ -238,8 +231,13 @@ static struct snd_soc_dai_driver si476x_dai = {
        .ops            = &si476x_dai_ops,
 };
 
+static struct regmap *si476x_get_regmap(struct device *dev)
+{
+       return dev_get_regmap(dev->parent, NULL);
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_si476x = {
-       .probe  = si476x_codec_probe,
+       .get_regmap = si476x_get_regmap,
        .dapm_widgets = si476x_dapm_widgets,
        .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets),
        .dapm_routes = si476x_dapm_routes,
index 12577749b17b3b0c0b0298b66758934ae4e87bdd..0579d187135b1d3932fd20fa19317f5f76cf43c2 100644 (file)
@@ -243,7 +243,7 @@ static int sta32x_coefficient_info(struct snd_kcontrol *kcontrol,
 static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol,
                                  struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        int numcoef = kcontrol->private_value >> 16;
        int index = kcontrol->private_value & 0xffff;
        unsigned int cfud;
@@ -272,7 +272,7 @@ static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol,
 static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol,
                                  struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);
        int numcoef = kcontrol->private_value >> 16;
        int index = kcontrol->private_value & 0xffff;
diff --git a/sound/soc/codecs/sta350.c b/sound/soc/codecs/sta350.c
new file mode 100644 (file)
index 0000000..12ebbaf
--- /dev/null
@@ -0,0 +1,1266 @@
+/*
+ * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system
+ *
+ * Copyright: 2014 Raumfeld GmbH
+ * Author: Sven Brandau <info@brandau.biz>
+ *
+ * based on code from:
+ *     Raumfeld GmbH
+ *       Johannes Stezenbach <js@sig21.net>
+ *     Wolfson Microelectronics PLC.
+ *       Mark Brown <broonie@opensource.wolfsonmicro.com>
+ *     Freescale Semiconductor, Inc.
+ *       Timur Tabi <timur@freescale.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ":%s:%d: " fmt, __func__, __LINE__
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/i2c.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/gpio/consumer.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/initval.h>
+#include <sound/tlv.h>
+
+#include <sound/sta350.h>
+#include "sta350.h"
+
+#define STA350_RATES (SNDRV_PCM_RATE_32000 | \
+                     SNDRV_PCM_RATE_44100 | \
+                     SNDRV_PCM_RATE_48000 | \
+                     SNDRV_PCM_RATE_88200 | \
+                     SNDRV_PCM_RATE_96000 | \
+                     SNDRV_PCM_RATE_176400 | \
+                     SNDRV_PCM_RATE_192000)
+
+#define STA350_FORMATS \
+       (SNDRV_PCM_FMTBIT_S16_LE  | SNDRV_PCM_FMTBIT_S16_BE  | \
+        SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE | \
+        SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE | \
+        SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \
+        SNDRV_PCM_FMTBIT_S24_LE  | SNDRV_PCM_FMTBIT_S24_BE  | \
+        SNDRV_PCM_FMTBIT_S32_LE  | SNDRV_PCM_FMTBIT_S32_BE)
+
+/* Power-up register defaults */
+static const struct reg_default sta350_regs[] = {
+       {  0x0, 0x63 },
+       {  0x1, 0x80 },
+       {  0x2, 0xdf },
+       {  0x3, 0x40 },
+       {  0x4, 0xc2 },
+       {  0x5, 0x5c },
+       {  0x6, 0x00 },
+       {  0x7, 0xff },
+       {  0x8, 0x60 },
+       {  0x9, 0x60 },
+       {  0xa, 0x60 },
+       {  0xb, 0x00 },
+       {  0xc, 0x00 },
+       {  0xd, 0x00 },
+       {  0xe, 0x00 },
+       {  0xf, 0x40 },
+       { 0x10, 0x80 },
+       { 0x11, 0x77 },
+       { 0x12, 0x6a },
+       { 0x13, 0x69 },
+       { 0x14, 0x6a },
+       { 0x15, 0x69 },
+       { 0x16, 0x00 },
+       { 0x17, 0x00 },
+       { 0x18, 0x00 },
+       { 0x19, 0x00 },
+       { 0x1a, 0x00 },
+       { 0x1b, 0x00 },
+       { 0x1c, 0x00 },
+       { 0x1d, 0x00 },
+       { 0x1e, 0x00 },
+       { 0x1f, 0x00 },
+       { 0x20, 0x00 },
+       { 0x21, 0x00 },
+       { 0x22, 0x00 },
+       { 0x23, 0x00 },
+       { 0x24, 0x00 },
+       { 0x25, 0x00 },
+       { 0x26, 0x00 },
+       { 0x27, 0x2a },
+       { 0x28, 0xc0 },
+       { 0x29, 0xf3 },
+       { 0x2a, 0x33 },
+       { 0x2b, 0x00 },
+       { 0x2c, 0x0c },
+       { 0x31, 0x00 },
+       { 0x36, 0x00 },
+       { 0x37, 0x00 },
+       { 0x38, 0x00 },
+       { 0x39, 0x01 },
+       { 0x3a, 0xee },
+       { 0x3b, 0xff },
+       { 0x3c, 0x7e },
+       { 0x3d, 0xc0 },
+       { 0x3e, 0x26 },
+       { 0x3f, 0x00 },
+       { 0x48, 0x00 },
+       { 0x49, 0x00 },
+       { 0x4a, 0x00 },
+       { 0x4b, 0x04 },
+       { 0x4c, 0x00 },
+};
+
+static const struct regmap_range sta350_write_regs_range[] = {
+       regmap_reg_range(STA350_CONFA,  STA350_AUTO2),
+       regmap_reg_range(STA350_C1CFG,  STA350_FDRC2),
+       regmap_reg_range(STA350_EQCFG,  STA350_EVOLRES),
+       regmap_reg_range(STA350_NSHAPE, STA350_MISC2),
+};
+
+static const struct regmap_range sta350_read_regs_range[] = {
+       regmap_reg_range(STA350_CONFA,  STA350_AUTO2),
+       regmap_reg_range(STA350_C1CFG,  STA350_STATUS),
+       regmap_reg_range(STA350_EQCFG,  STA350_EVOLRES),
+       regmap_reg_range(STA350_NSHAPE, STA350_MISC2),
+};
+
+static const struct regmap_range sta350_volatile_regs_range[] = {
+       regmap_reg_range(STA350_CFADDR2, STA350_CFUD),
+       regmap_reg_range(STA350_STATUS,  STA350_STATUS),
+};
+
+static const struct regmap_access_table sta350_write_regs = {
+       .yes_ranges =   sta350_write_regs_range,
+       .n_yes_ranges = ARRAY_SIZE(sta350_write_regs_range),
+};
+
+static const struct regmap_access_table sta350_read_regs = {
+       .yes_ranges =   sta350_read_regs_range,
+       .n_yes_ranges = ARRAY_SIZE(sta350_read_regs_range),
+};
+
+static const struct regmap_access_table sta350_volatile_regs = {
+       .yes_ranges =   sta350_volatile_regs_range,
+       .n_yes_ranges = ARRAY_SIZE(sta350_volatile_regs_range),
+};
+
+/* regulator power supply names */
+static const char * const sta350_supply_names[] = {
+       "vdd-dig",      /* digital supply, 3.3V */
+       "vdd-pll",      /* pll supply, 3.3V */
+       "vcc"           /* power amp supply, 5V - 26V */
+};
+
+/* codec private data */
+struct sta350_priv {
+       struct regmap *regmap;
+       struct regulator_bulk_data supplies[ARRAY_SIZE(sta350_supply_names)];
+       struct sta350_platform_data *pdata;
+
+       unsigned int mclk;
+       unsigned int format;
+
+       u32 coef_shadow[STA350_COEF_COUNT];
+       int shutdown;
+
+       struct gpio_desc *gpiod_nreset;
+       struct gpio_desc *gpiod_power_down;
+
+       struct mutex coeff_lock;
+};
+
+static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12750, 50, 1);
+static const DECLARE_TLV_DB_SCALE(chvol_tlv, -7950, 50, 1);
+static const DECLARE_TLV_DB_SCALE(tone_tlv, -1200, 200, 0);
+
+static const char * const sta350_drc_ac[] = {
+       "Anti-Clipping", "Dynamic Range Compression"
+};
+static const char * const sta350_auto_gc_mode[] = {
+       "User", "AC no clipping", "AC limited clipping (10%)",
+       "DRC nighttime listening mode"
+};
+static const char * const sta350_auto_xo_mode[] = {
+       "User", "80Hz", "100Hz", "120Hz", "140Hz", "160Hz", "180Hz",
+       "200Hz", "220Hz", "240Hz", "260Hz", "280Hz", "300Hz", "320Hz",
+       "340Hz", "360Hz"
+};
+static const char * const sta350_binary_output[] = {
+       "FFX 3-state output - normal operation", "Binary output"
+};
+static const char * const sta350_limiter_select[] = {
+       "Limiter Disabled", "Limiter #1", "Limiter #2"
+};
+static const char * const sta350_limiter_attack_rate[] = {
+       "3.1584", "2.7072", "2.2560", "1.8048", "1.3536", "0.9024",
+       "0.4512", "0.2256", "0.1504", "0.1123", "0.0902", "0.0752",
+       "0.0645", "0.0564", "0.0501", "0.0451"
+};
+static const char * const sta350_limiter_release_rate[] = {
+       "0.5116", "0.1370", "0.0744", "0.0499", "0.0360", "0.0299",
+       "0.0264", "0.0208", "0.0198", "0.0172", "0.0147", "0.0137",
+       "0.0134", "0.0117", "0.0110", "0.0104"
+};
+static const char * const sta350_noise_shaper_type[] = {
+       "Third order", "Fourth order"
+};
+
+static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_attack_tlv,
+       0, 7, TLV_DB_SCALE_ITEM(-1200, 200, 0),
+       8, 16, TLV_DB_SCALE_ITEM(300, 100, 0),
+);
+
+static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_release_tlv,
+       0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
+       1, 1, TLV_DB_SCALE_ITEM(-2900, 0, 0),
+       2, 2, TLV_DB_SCALE_ITEM(-2000, 0, 0),
+       3, 8, TLV_DB_SCALE_ITEM(-1400, 200, 0),
+       8, 16, TLV_DB_SCALE_ITEM(-700, 100, 0),
+);
+
+static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_attack_tlv,
+       0, 7, TLV_DB_SCALE_ITEM(-3100, 200, 0),
+       8, 13, TLV_DB_SCALE_ITEM(-1600, 100, 0),
+       14, 16, TLV_DB_SCALE_ITEM(-1000, 300, 0),
+);
+
+static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_release_tlv,
+       0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0),
+       1, 2, TLV_DB_SCALE_ITEM(-3800, 200, 0),
+       3, 4, TLV_DB_SCALE_ITEM(-3300, 200, 0),
+       5, 12, TLV_DB_SCALE_ITEM(-3000, 200, 0),
+       13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0),
+);
+
+static SOC_ENUM_SINGLE_DECL(sta350_drc_ac_enum,
+                           STA350_CONFD, STA350_CONFD_DRC_SHIFT,
+                           sta350_drc_ac);
+static SOC_ENUM_SINGLE_DECL(sta350_noise_shaper_enum,
+                           STA350_CONFE, STA350_CONFE_NSBW_SHIFT,
+                           sta350_noise_shaper_type);
+static SOC_ENUM_SINGLE_DECL(sta350_auto_gc_enum,
+                           STA350_AUTO1, STA350_AUTO1_AMGC_SHIFT,
+                           sta350_auto_gc_mode);
+static SOC_ENUM_SINGLE_DECL(sta350_auto_xo_enum,
+                           STA350_AUTO2, STA350_AUTO2_XO_SHIFT,
+                           sta350_auto_xo_mode);
+static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch1_enum,
+                           STA350_C1CFG, STA350_CxCFG_BO_SHIFT,
+                           sta350_binary_output);
+static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch2_enum,
+                           STA350_C2CFG, STA350_CxCFG_BO_SHIFT,
+                           sta350_binary_output);
+static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch3_enum,
+                           STA350_C3CFG, STA350_CxCFG_BO_SHIFT,
+                           sta350_binary_output);
+static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch1_enum,
+                           STA350_C1CFG, STA350_CxCFG_LS_SHIFT,
+                           sta350_limiter_select);
+static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch2_enum,
+                           STA350_C2CFG, STA350_CxCFG_LS_SHIFT,
+                           sta350_limiter_select);
+static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch3_enum,
+                           STA350_C3CFG, STA350_CxCFG_LS_SHIFT,
+                           sta350_limiter_select);
+static SOC_ENUM_SINGLE_DECL(sta350_limiter1_attack_rate_enum,
+                           STA350_L1AR, STA350_LxA_SHIFT,
+                           sta350_limiter_attack_rate);
+static SOC_ENUM_SINGLE_DECL(sta350_limiter2_attack_rate_enum,
+                           STA350_L2AR, STA350_LxA_SHIFT,
+                           sta350_limiter_attack_rate);
+static SOC_ENUM_SINGLE_DECL(sta350_limiter1_release_rate_enum,
+                           STA350_L1AR, STA350_LxR_SHIFT,
+                           sta350_limiter_release_rate);
+static SOC_ENUM_SINGLE_DECL(sta350_limiter2_release_rate_enum,
+                           STA350_L2AR, STA350_LxR_SHIFT,
+                           sta350_limiter_release_rate);
+
+/*
+ * byte array controls for setting biquad, mixer, scaling coefficients;
+ * for biquads all five coefficients need to be set in one go,
+ * mixer and pre/postscale coefs can be set individually;
+ * each coef is 24bit, the bytes are ordered in the same way
+ * as given in the STA350 data sheet (big endian; b1, b2, a1, a2, b0)
+ */
+
+static int sta350_coefficient_info(struct snd_kcontrol *kcontrol,
+                                  struct snd_ctl_elem_info *uinfo)
+{
+       int numcoef = kcontrol->private_value >> 16;
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
+       uinfo->count = 3 * numcoef;
+       return 0;
+}
+
+static int sta350_coefficient_get(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+       int numcoef = kcontrol->private_value >> 16;
+       int index = kcontrol->private_value & 0xffff;
+       unsigned int cfud, val;
+       int i, ret = 0;
+
+       mutex_lock(&sta350->coeff_lock);
+
+       /* preserve reserved bits in STA350_CFUD */
+       regmap_read(sta350->regmap, STA350_CFUD, &cfud);
+       cfud &= 0xf0;
+       /*
+        * chip documentation does not say if the bits are self clearing,
+        * so do it explicitly
+        */
+       regmap_write(sta350->regmap, STA350_CFUD, cfud);
+
+       regmap_write(sta350->regmap, STA350_CFADDR2, index);
+       if (numcoef == 1) {
+               regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x04);
+       } else if (numcoef == 5) {
+               regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x08);
+       } else {
+               ret = -EINVAL;
+               goto exit_unlock;
+       }
+
+       for (i = 0; i < 3 * numcoef; i++) {
+               regmap_read(sta350->regmap, STA350_B1CF1 + i, &val);
+               ucontrol->value.bytes.data[i] = val;
+       }
+
+exit_unlock:
+       mutex_unlock(&sta350->coeff_lock);
+
+       return ret;
+}
+
+static int sta350_coefficient_put(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+       int numcoef = kcontrol->private_value >> 16;
+       int index = kcontrol->private_value & 0xffff;
+       unsigned int cfud;
+       int i;
+
+       /* preserve reserved bits in STA350_CFUD */
+       regmap_read(sta350->regmap, STA350_CFUD, &cfud);
+       cfud &= 0xf0;
+       /*
+        * chip documentation does not say if the bits are self clearing,
+        * so do it explicitly
+        */
+       regmap_write(sta350->regmap, STA350_CFUD, cfud);
+
+       regmap_write(sta350->regmap, STA350_CFADDR2, index);
+       for (i = 0; i < numcoef && (index + i < STA350_COEF_COUNT); i++)
+               sta350->coef_shadow[index + i] =
+                         (ucontrol->value.bytes.data[3 * i] << 16)
+                       | (ucontrol->value.bytes.data[3 * i + 1] << 8)
+                       | (ucontrol->value.bytes.data[3 * i + 2]);
+       for (i = 0; i < 3 * numcoef; i++)
+               regmap_write(sta350->regmap, STA350_B1CF1 + i,
+                            ucontrol->value.bytes.data[i]);
+       if (numcoef == 1)
+               regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01);
+       else if (numcoef == 5)
+               regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x02);
+       else
+               return -EINVAL;
+
+       return 0;
+}
+
+static int sta350_sync_coef_shadow(struct snd_soc_codec *codec)
+{
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+       unsigned int cfud;
+       int i;
+
+       /* preserve reserved bits in STA350_CFUD */
+       regmap_read(sta350->regmap, STA350_CFUD, &cfud);
+       cfud &= 0xf0;
+
+       for (i = 0; i < STA350_COEF_COUNT; i++) {
+               regmap_write(sta350->regmap, STA350_CFADDR2, i);
+               regmap_write(sta350->regmap, STA350_B1CF1,
+                            (sta350->coef_shadow[i] >> 16) & 0xff);
+               regmap_write(sta350->regmap, STA350_B1CF2,
+                            (sta350->coef_shadow[i] >> 8) & 0xff);
+               regmap_write(sta350->regmap, STA350_B1CF3,
+                            (sta350->coef_shadow[i]) & 0xff);
+               /*
+                * chip documentation does not say if the bits are
+                * self-clearing, so do it explicitly
+                */
+               regmap_write(sta350->regmap, STA350_CFUD, cfud);
+               regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01);
+       }
+       return 0;
+}
+
+static int sta350_cache_sync(struct snd_soc_codec *codec)
+{
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+       unsigned int mute;
+       int rc;
+
+       /* mute during register sync */
+       regmap_read(sta350->regmap, STA350_CFUD, &mute);
+       regmap_write(sta350->regmap, STA350_MMUTE, mute | STA350_MMUTE_MMUTE);
+       sta350_sync_coef_shadow(codec);
+       rc = regcache_sync(sta350->regmap);
+       regmap_write(sta350->regmap, STA350_MMUTE, mute);
+       return rc;
+}
+
+#define SINGLE_COEF(xname, index) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+       .info = sta350_coefficient_info, \
+       .get = sta350_coefficient_get,\
+       .put = sta350_coefficient_put, \
+       .private_value = index | (1 << 16) }
+
+#define BIQUAD_COEFS(xname, index) \
+{      .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+       .info = sta350_coefficient_info, \
+       .get = sta350_coefficient_get,\
+       .put = sta350_coefficient_put, \
+       .private_value = index | (5 << 16) }
+
+static const struct snd_kcontrol_new sta350_snd_controls[] = {
+SOC_SINGLE_TLV("Master Volume", STA350_MVOL, 0, 0xff, 1, mvol_tlv),
+/* VOL */
+SOC_SINGLE_TLV("Ch1 Volume", STA350_C1VOL, 0, 0xff, 1, chvol_tlv),
+SOC_SINGLE_TLV("Ch2 Volume", STA350_C2VOL, 0, 0xff, 1, chvol_tlv),
+SOC_SINGLE_TLV("Ch3 Volume", STA350_C3VOL, 0, 0xff, 1, chvol_tlv),
+/* CONFD */
+SOC_SINGLE("High Pass Filter Bypass Switch",
+          STA350_CONFD, STA350_CONFD_HPB_SHIFT, 1, 1),
+SOC_SINGLE("De-emphasis Filter Switch",
+          STA350_CONFD, STA350_CONFD_DEMP_SHIFT, 1, 0),
+SOC_SINGLE("DSP Bypass Switch",
+          STA350_CONFD, STA350_CONFD_DSPB_SHIFT, 1, 0),
+SOC_SINGLE("Post-scale Link Switch",
+          STA350_CONFD, STA350_CONFD_PSL_SHIFT, 1, 0),
+SOC_SINGLE("Biquad Coefficient Link Switch",
+          STA350_CONFD, STA350_CONFD_BQL_SHIFT, 1, 0),
+SOC_ENUM("Compressor/Limiter Switch", sta350_drc_ac_enum),
+SOC_ENUM("Noise Shaper Bandwidth", sta350_noise_shaper_enum),
+SOC_SINGLE("Zero-detect Mute Enable Switch",
+          STA350_CONFD, STA350_CONFD_ZDE_SHIFT, 1, 0),
+SOC_SINGLE("Submix Mode Switch",
+          STA350_CONFD, STA350_CONFD_SME_SHIFT, 1, 0),
+/* CONFE */
+SOC_SINGLE("Zero Cross Switch", STA350_CONFE, STA350_CONFE_ZCE_SHIFT, 1, 0),
+SOC_SINGLE("Soft Ramp Switch", STA350_CONFE, STA350_CONFE_SVE_SHIFT, 1, 0),
+/* MUTE */
+SOC_SINGLE("Master Switch", STA350_MMUTE, STA350_MMUTE_MMUTE_SHIFT, 1, 1),
+SOC_SINGLE("Ch1 Switch", STA350_MMUTE, STA350_MMUTE_C1M_SHIFT, 1, 1),
+SOC_SINGLE("Ch2 Switch", STA350_MMUTE, STA350_MMUTE_C2M_SHIFT, 1, 1),
+SOC_SINGLE("Ch3 Switch", STA350_MMUTE, STA350_MMUTE_C3M_SHIFT, 1, 1),
+/* AUTOx */
+SOC_ENUM("Automode GC", sta350_auto_gc_enum),
+SOC_ENUM("Automode XO", sta350_auto_xo_enum),
+/* CxCFG */
+SOC_SINGLE("Ch1 Tone Control Bypass Switch",
+          STA350_C1CFG, STA350_CxCFG_TCB_SHIFT, 1, 0),
+SOC_SINGLE("Ch2 Tone Control Bypass Switch",
+          STA350_C2CFG, STA350_CxCFG_TCB_SHIFT, 1, 0),
+SOC_SINGLE("Ch1 EQ Bypass Switch",
+          STA350_C1CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0),
+SOC_SINGLE("Ch2 EQ Bypass Switch",
+          STA350_C2CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0),
+SOC_SINGLE("Ch1 Master Volume Bypass Switch",
+          STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
+SOC_SINGLE("Ch2 Master Volume Bypass Switch",
+          STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
+SOC_SINGLE("Ch3 Master Volume Bypass Switch",
+          STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0),
+SOC_ENUM("Ch1 Binary Output Select", sta350_binary_output_ch1_enum),
+SOC_ENUM("Ch2 Binary Output Select", sta350_binary_output_ch2_enum),
+SOC_ENUM("Ch3 Binary Output Select", sta350_binary_output_ch3_enum),
+SOC_ENUM("Ch1 Limiter Select", sta350_limiter_ch1_enum),
+SOC_ENUM("Ch2 Limiter Select", sta350_limiter_ch2_enum),
+SOC_ENUM("Ch3 Limiter Select", sta350_limiter_ch3_enum),
+/* TONE */
+SOC_SINGLE_RANGE_TLV("Bass Tone Control Volume",
+                    STA350_TONE, STA350_TONE_BTC_SHIFT, 1, 13, 0, tone_tlv),
+SOC_SINGLE_RANGE_TLV("Treble Tone Control Volume",
+                    STA350_TONE, STA350_TONE_TTC_SHIFT, 1, 13, 0, tone_tlv),
+SOC_ENUM("Limiter1 Attack Rate (dB/ms)", sta350_limiter1_attack_rate_enum),
+SOC_ENUM("Limiter2 Attack Rate (dB/ms)", sta350_limiter2_attack_rate_enum),
+SOC_ENUM("Limiter1 Release Rate (dB/ms)", sta350_limiter1_release_rate_enum),
+SOC_ENUM("Limiter2 Release Rate (dB/ms)", sta350_limiter2_release_rate_enum),
+
+/*
+ * depending on mode, the attack/release thresholds have
+ * two different enum definitions; provide both
+ */
+SOC_SINGLE_TLV("Limiter1 Attack Threshold (AC Mode)",
+              STA350_L1ATRT, STA350_LxA_SHIFT,
+              16, 0, sta350_limiter_ac_attack_tlv),
+SOC_SINGLE_TLV("Limiter2 Attack Threshold (AC Mode)",
+              STA350_L2ATRT, STA350_LxA_SHIFT,
+              16, 0, sta350_limiter_ac_attack_tlv),
+SOC_SINGLE_TLV("Limiter1 Release Threshold (AC Mode)",
+              STA350_L1ATRT, STA350_LxR_SHIFT,
+              16, 0, sta350_limiter_ac_release_tlv),
+SOC_SINGLE_TLV("Limiter2 Release Threshold (AC Mode)",
+              STA350_L2ATRT, STA350_LxR_SHIFT,
+              16, 0, sta350_limiter_ac_release_tlv),
+SOC_SINGLE_TLV("Limiter1 Attack Threshold (DRC Mode)",
+              STA350_L1ATRT, STA350_LxA_SHIFT,
+              16, 0, sta350_limiter_drc_attack_tlv),
+SOC_SINGLE_TLV("Limiter2 Attack Threshold (DRC Mode)",
+              STA350_L2ATRT, STA350_LxA_SHIFT,
+              16, 0, sta350_limiter_drc_attack_tlv),
+SOC_SINGLE_TLV("Limiter1 Release Threshold (DRC Mode)",
+              STA350_L1ATRT, STA350_LxR_SHIFT,
+              16, 0, sta350_limiter_drc_release_tlv),
+SOC_SINGLE_TLV("Limiter2 Release Threshold (DRC Mode)",
+              STA350_L2ATRT, STA350_LxR_SHIFT,
+              16, 0, sta350_limiter_drc_release_tlv),
+
+BIQUAD_COEFS("Ch1 - Biquad 1", 0),
+BIQUAD_COEFS("Ch1 - Biquad 2", 5),
+BIQUAD_COEFS("Ch1 - Biquad 3", 10),
+BIQUAD_COEFS("Ch1 - Biquad 4", 15),
+BIQUAD_COEFS("Ch2 - Biquad 1", 20),
+BIQUAD_COEFS("Ch2 - Biquad 2", 25),
+BIQUAD_COEFS("Ch2 - Biquad 3", 30),
+BIQUAD_COEFS("Ch2 - Biquad 4", 35),
+BIQUAD_COEFS("High-pass", 40),
+BIQUAD_COEFS("Low-pass", 45),
+SINGLE_COEF("Ch1 - Prescale", 50),
+SINGLE_COEF("Ch2 - Prescale", 51),
+SINGLE_COEF("Ch1 - Postscale", 52),
+SINGLE_COEF("Ch2 - Postscale", 53),
+SINGLE_COEF("Ch3 - Postscale", 54),
+SINGLE_COEF("Thermal warning - Postscale", 55),
+SINGLE_COEF("Ch1 - Mix 1", 56),
+SINGLE_COEF("Ch1 - Mix 2", 57),
+SINGLE_COEF("Ch2 - Mix 1", 58),
+SINGLE_COEF("Ch2 - Mix 2", 59),
+SINGLE_COEF("Ch3 - Mix 1", 60),
+SINGLE_COEF("Ch3 - Mix 2", 61),
+};
+
+static const struct snd_soc_dapm_widget sta350_dapm_widgets[] = {
+SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0),
+SND_SOC_DAPM_OUTPUT("LEFT"),
+SND_SOC_DAPM_OUTPUT("RIGHT"),
+SND_SOC_DAPM_OUTPUT("SUB"),
+};
+
+static const struct snd_soc_dapm_route sta350_dapm_routes[] = {
+       { "LEFT", NULL, "DAC" },
+       { "RIGHT", NULL, "DAC" },
+       { "SUB", NULL, "DAC" },
+       { "DAC", NULL, "Playback" },
+};
+
+/* MCLK interpolation ratio per fs */
+static struct {
+       int fs;
+       int ir;
+} interpolation_ratios[] = {
+       { 32000, 0 },
+       { 44100, 0 },
+       { 48000, 0 },
+       { 88200, 1 },
+       { 96000, 1 },
+       { 176400, 2 },
+       { 192000, 2 },
+};
+
+/* MCLK to fs clock ratios */
+static int mcs_ratio_table[3][6] = {
+       { 768, 512, 384, 256, 128, 576 },
+       { 384, 256, 192, 128,  64,   0 },
+       { 192, 128,  96,  64,  32,   0 },
+};
+
+/**
+ * sta350_set_dai_sysclk - configure MCLK
+ * @codec_dai: the codec DAI
+ * @clk_id: the clock ID (ignored)
+ * @freq: the MCLK input frequency
+ * @dir: the clock direction (ignored)
+ *
+ * The value of MCLK is used to determine which sample rates are supported
+ * by the STA350, based on the mcs_ratio_table.
+ *
+ * This function must be called by the machine driver's 'startup' function,
+ * otherwise the list of supported sample rates will not be available in
+ * time for ALSA.
+ */
+static int sta350_set_dai_sysclk(struct snd_soc_dai *codec_dai,
+                                int clk_id, unsigned int freq, int dir)
+{
+       struct snd_soc_codec *codec = codec_dai->codec;
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+
+       dev_dbg(codec->dev, "mclk=%u\n", freq);
+       sta350->mclk = freq;
+
+       return 0;
+}
+
+/**
+ * sta350_set_dai_fmt - configure the codec for the selected audio format
+ * @codec_dai: the codec DAI
+ * @fmt: a SND_SOC_DAIFMT_x value indicating the data format
+ *
+ * This function takes a bitmask of SND_SOC_DAIFMT_x bits and programs the
+ * codec accordingly.
+ */
+static int sta350_set_dai_fmt(struct snd_soc_dai *codec_dai,
+                             unsigned int fmt)
+{
+       struct snd_soc_codec *codec = codec_dai->codec;
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+       unsigned int confb = 0;
+
+       switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+       case SND_SOC_DAIFMT_CBS_CFS:
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+       case SND_SOC_DAIFMT_I2S:
+       case SND_SOC_DAIFMT_RIGHT_J:
+       case SND_SOC_DAIFMT_LEFT_J:
+               sta350->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+       case SND_SOC_DAIFMT_NB_NF:
+               confb |= STA350_CONFB_C2IM;
+               break;
+       case SND_SOC_DAIFMT_NB_IF:
+               confb |= STA350_CONFB_C1IM;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return regmap_update_bits(sta350->regmap, STA350_CONFB,
+                                 STA350_CONFB_C1IM | STA350_CONFB_C2IM, confb);
+}
+
+/**
+ * sta350_hw_params - program the STA350 with the given hardware parameters.
+ * @substream: the audio stream
+ * @params: the hardware parameters to set
+ * @dai: the SOC DAI (ignored)
+ *
+ * This function programs the hardware with the values provided.
+ * Specifically, the sample rate and the data format.
+ */
+static int sta350_hw_params(struct snd_pcm_substream *substream,
+                           struct snd_pcm_hw_params *params,
+                           struct snd_soc_dai *dai)
+{
+       struct snd_soc_codec *codec = dai->codec;
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+       int i, mcs = -EINVAL, ir = -EINVAL;
+       unsigned int confa, confb;
+       unsigned int rate, ratio;
+       int ret;
+
+       if (!sta350->mclk) {
+               dev_err(codec->dev,
+                       "sta350->mclk is unset. Unable to determine ratio\n");
+               return -EIO;
+       }
+
+       rate = params_rate(params);
+       ratio = sta350->mclk / rate;
+       dev_dbg(codec->dev, "rate: %u, ratio: %u\n", rate, ratio);
+
+       for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) {
+               if (interpolation_ratios[i].fs == rate) {
+                       ir = interpolation_ratios[i].ir;
+                       break;
+               }
+       }
+
+       if (ir < 0) {
+               dev_err(codec->dev, "Unsupported samplerate: %u\n", rate);
+               return -EINVAL;
+       }
+
+       for (i = 0; i < 6; i++) {
+               if (mcs_ratio_table[ir][i] == ratio) {
+                       mcs = i;
+                       break;
+               }
+       }
+
+       if (mcs < 0) {
+               dev_err(codec->dev, "Unresolvable ratio: %u\n", ratio);
+               return -EINVAL;
+       }
+
+       confa = (ir << STA350_CONFA_IR_SHIFT) |
+               (mcs << STA350_CONFA_MCS_SHIFT);
+       confb = 0;
+
+       switch (params_width(params)) {
+       case 24:
+               dev_dbg(codec->dev, "24bit\n");
+               /* fall through */
+       case 32:
+               dev_dbg(codec->dev, "24bit or 32bit\n");
+               switch (sta350->format) {
+               case SND_SOC_DAIFMT_I2S:
+                       confb |= 0x0;
+                       break;
+               case SND_SOC_DAIFMT_LEFT_J:
+                       confb |= 0x1;
+                       break;
+               case SND_SOC_DAIFMT_RIGHT_J:
+                       confb |= 0x2;
+                       break;
+               }
+
+               break;
+       case 20:
+               dev_dbg(codec->dev, "20bit\n");
+               switch (sta350->format) {
+               case SND_SOC_DAIFMT_I2S:
+                       confb |= 0x4;
+                       break;
+               case SND_SOC_DAIFMT_LEFT_J:
+                       confb |= 0x5;
+                       break;
+               case SND_SOC_DAIFMT_RIGHT_J:
+                       confb |= 0x6;
+                       break;
+               }
+
+               break;
+       case 18:
+               dev_dbg(codec->dev, "18bit\n");
+               switch (sta350->format) {
+               case SND_SOC_DAIFMT_I2S:
+                       confb |= 0x8;
+                       break;
+               case SND_SOC_DAIFMT_LEFT_J:
+                       confb |= 0x9;
+                       break;
+               case SND_SOC_DAIFMT_RIGHT_J:
+                       confb |= 0xa;
+                       break;
+               }
+
+               break;
+       case 16:
+               dev_dbg(codec->dev, "16bit\n");
+               switch (sta350->format) {
+               case SND_SOC_DAIFMT_I2S:
+                       confb |= 0x0;
+                       break;
+               case SND_SOC_DAIFMT_LEFT_J:
+                       confb |= 0xd;
+                       break;
+               case SND_SOC_DAIFMT_RIGHT_J:
+                       confb |= 0xe;
+                       break;
+               }
+
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       ret = regmap_update_bits(sta350->regmap, STA350_CONFA,
+                                STA350_CONFA_MCS_MASK | STA350_CONFA_IR_MASK,
+                                confa);
+       if (ret < 0)
+               return ret;
+
+       ret = regmap_update_bits(sta350->regmap, STA350_CONFB,
+                                STA350_CONFB_SAI_MASK | STA350_CONFB_SAIFB,
+                                confb);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int sta350_startup_sequence(struct sta350_priv *sta350)
+{
+       if (sta350->gpiod_power_down)
+               gpiod_set_value(sta350->gpiod_power_down, 1);
+
+       if (sta350->gpiod_nreset) {
+               gpiod_set_value(sta350->gpiod_nreset, 0);
+               mdelay(1);
+               gpiod_set_value(sta350->gpiod_nreset, 1);
+               mdelay(1);
+       }
+
+       return 0;
+}
+
+/**
+ * sta350_set_bias_level - DAPM callback
+ * @codec: the codec device
+ * @level: DAPM power level
+ *
+ * This is called by ALSA to put the codec into low power mode
+ * or to wake it up.  If the codec is powered off completely
+ * all registers must be restored after power on.
+ */
+static int sta350_set_bias_level(struct snd_soc_codec *codec,
+                                enum snd_soc_bias_level level)
+{
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+       int ret;
+
+       dev_dbg(codec->dev, "level = %d\n", level);
+       switch (level) {
+       case SND_SOC_BIAS_ON:
+               break;
+
+       case SND_SOC_BIAS_PREPARE:
+               /* Full power on */
+               regmap_update_bits(sta350->regmap, STA350_CONFF,
+                                  STA350_CONFF_PWDN | STA350_CONFF_EAPD,
+                                  STA350_CONFF_PWDN | STA350_CONFF_EAPD);
+               break;
+
+       case SND_SOC_BIAS_STANDBY:
+               if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
+                       ret = regulator_bulk_enable(
+                               ARRAY_SIZE(sta350->supplies),
+                               sta350->supplies);
+                       if (ret < 0) {
+                               dev_err(codec->dev,
+                                       "Failed to enable supplies: %d\n",
+                                       ret);
+                               return ret;
+                       }
+                       sta350_startup_sequence(sta350);
+                       sta350_cache_sync(codec);
+               }
+
+               /* Power down */
+               regmap_update_bits(sta350->regmap, STA350_CONFF,
+                                  STA350_CONFF_PWDN | STA350_CONFF_EAPD,
+                                  0);
+
+               break;
+
+       case SND_SOC_BIAS_OFF:
+               /* The chip runs through the power down sequence for us */
+               regmap_update_bits(sta350->regmap, STA350_CONFF,
+                                  STA350_CONFF_PWDN | STA350_CONFF_EAPD, 0);
+
+               /* power down: low */
+               if (sta350->gpiod_power_down)
+                       gpiod_set_value(sta350->gpiod_power_down, 0);
+
+               if (sta350->gpiod_nreset)
+                       gpiod_set_value(sta350->gpiod_nreset, 0);
+
+               regulator_bulk_disable(ARRAY_SIZE(sta350->supplies),
+                                      sta350->supplies);
+               break;
+       }
+       codec->dapm.bias_level = level;
+       return 0;
+}
+
+static const struct snd_soc_dai_ops sta350_dai_ops = {
+       .hw_params      = sta350_hw_params,
+       .set_sysclk     = sta350_set_dai_sysclk,
+       .set_fmt        = sta350_set_dai_fmt,
+};
+
+static struct snd_soc_dai_driver sta350_dai = {
+       .name = "sta350-hifi",
+       .playback = {
+               .stream_name = "Playback",
+               .channels_min = 2,
+               .channels_max = 2,
+               .rates = STA350_RATES,
+               .formats = STA350_FORMATS,
+       },
+       .ops = &sta350_dai_ops,
+};
+
+#ifdef CONFIG_PM
+static int sta350_suspend(struct snd_soc_codec *codec)
+{
+       sta350_set_bias_level(codec, SND_SOC_BIAS_OFF);
+       return 0;
+}
+
+static int sta350_resume(struct snd_soc_codec *codec)
+{
+       sta350_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
+       return 0;
+}
+#else
+#define sta350_suspend NULL
+#define sta350_resume NULL
+#endif
+
+static int sta350_probe(struct snd_soc_codec *codec)
+{
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+       struct sta350_platform_data *pdata = sta350->pdata;
+       int i, ret = 0, thermal = 0;
+
+       ret = regulator_bulk_enable(ARRAY_SIZE(sta350->supplies),
+                                   sta350->supplies);
+       if (ret < 0) {
+               dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
+               return ret;
+       }
+
+       ret = sta350_startup_sequence(sta350);
+       if (ret < 0) {
+               dev_err(codec->dev, "Failed to startup device\n");
+               return ret;
+       }
+
+       /* CONFA */
+       if (!pdata->thermal_warning_recovery)
+               thermal |= STA350_CONFA_TWAB;
+       if (!pdata->thermal_warning_adjustment)
+               thermal |= STA350_CONFA_TWRB;
+       if (!pdata->fault_detect_recovery)
+               thermal |= STA350_CONFA_FDRB;
+       regmap_update_bits(sta350->regmap, STA350_CONFA,
+                          STA350_CONFA_TWAB | STA350_CONFA_TWRB |
+                          STA350_CONFA_FDRB,
+                          thermal);
+
+       /* CONFC */
+       regmap_update_bits(sta350->regmap, STA350_CONFC,
+                          STA350_CONFC_OM_MASK,
+                          pdata->ffx_power_output_mode
+                               << STA350_CONFC_OM_SHIFT);
+       regmap_update_bits(sta350->regmap, STA350_CONFC,
+                          STA350_CONFC_CSZ_MASK,
+                          pdata->drop_compensation_ns
+                               << STA350_CONFC_CSZ_SHIFT);
+       regmap_update_bits(sta350->regmap,
+                          STA350_CONFC,
+                          STA350_CONFC_OCRB,
+                          pdata->oc_warning_adjustment ?
+                               STA350_CONFC_OCRB : 0);
+
+       /* CONFE */
+       regmap_update_bits(sta350->regmap, STA350_CONFE,
+                          STA350_CONFE_MPCV,
+                          pdata->max_power_use_mpcc ?
+                               STA350_CONFE_MPCV : 0);
+       regmap_update_bits(sta350->regmap, STA350_CONFE,
+                          STA350_CONFE_MPC,
+                          pdata->max_power_correction ?
+                               STA350_CONFE_MPC : 0);
+       regmap_update_bits(sta350->regmap, STA350_CONFE,
+                          STA350_CONFE_AME,
+                          pdata->am_reduction_mode ?
+                               STA350_CONFE_AME : 0);
+       regmap_update_bits(sta350->regmap, STA350_CONFE,
+                          STA350_CONFE_PWMS,
+                          pdata->odd_pwm_speed_mode ?
+                               STA350_CONFE_PWMS : 0);
+       regmap_update_bits(sta350->regmap, STA350_CONFE,
+                          STA350_CONFE_DCCV,
+                          pdata->distortion_compensation ?
+                               STA350_CONFE_DCCV : 0);
+       /*  CONFF */
+       regmap_update_bits(sta350->regmap, STA350_CONFF,
+                          STA350_CONFF_IDE,
+                          pdata->invalid_input_detect_mute ?
+                               STA350_CONFF_IDE : 0);
+       regmap_update_bits(sta350->regmap, STA350_CONFF,
+                          STA350_CONFF_OCFG_MASK,
+                          pdata->output_conf
+                               << STA350_CONFF_OCFG_SHIFT);
+
+       /* channel to output mapping */
+       regmap_update_bits(sta350->regmap, STA350_C1CFG,
+                          STA350_CxCFG_OM_MASK,
+                          pdata->ch1_output_mapping
+                               << STA350_CxCFG_OM_SHIFT);
+       regmap_update_bits(sta350->regmap, STA350_C2CFG,
+                          STA350_CxCFG_OM_MASK,
+                          pdata->ch2_output_mapping
+                               << STA350_CxCFG_OM_SHIFT);
+       regmap_update_bits(sta350->regmap, STA350_C3CFG,
+                          STA350_CxCFG_OM_MASK,
+                          pdata->ch3_output_mapping
+                               << STA350_CxCFG_OM_SHIFT);
+
+       /* initialize coefficient shadow RAM with reset values */
+       for (i = 4; i <= 49; i += 5)
+               sta350->coef_shadow[i] = 0x400000;
+       for (i = 50; i <= 54; i++)
+               sta350->coef_shadow[i] = 0x7fffff;
+       sta350->coef_shadow[55] = 0x5a9df7;
+       sta350->coef_shadow[56] = 0x7fffff;
+       sta350->coef_shadow[59] = 0x7fffff;
+       sta350->coef_shadow[60] = 0x400000;
+       sta350->coef_shadow[61] = 0x400000;
+
+       sta350_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
+       /* Bias level configuration will have done an extra enable */
+       regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies);
+
+       return 0;
+}
+
+static int sta350_remove(struct snd_soc_codec *codec)
+{
+       struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec);
+
+       sta350_set_bias_level(codec, SND_SOC_BIAS_OFF);
+       regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies);
+
+       return 0;
+}
+
+static const struct snd_soc_codec_driver sta350_codec = {
+       .probe =                sta350_probe,
+       .remove =               sta350_remove,
+       .suspend =              sta350_suspend,
+       .resume =               sta350_resume,
+       .set_bias_level =       sta350_set_bias_level,
+       .controls =             sta350_snd_controls,
+       .num_controls =         ARRAY_SIZE(sta350_snd_controls),
+       .dapm_widgets =         sta350_dapm_widgets,
+       .num_dapm_widgets =     ARRAY_SIZE(sta350_dapm_widgets),
+       .dapm_routes =          sta350_dapm_routes,
+       .num_dapm_routes =      ARRAY_SIZE(sta350_dapm_routes),
+};
+
+static const struct regmap_config sta350_regmap = {
+       .reg_bits =             8,
+       .val_bits =             8,
+       .max_register =         STA350_MISC2,
+       .reg_defaults =         sta350_regs,
+       .num_reg_defaults =     ARRAY_SIZE(sta350_regs),
+       .cache_type =           REGCACHE_RBTREE,
+       .wr_table =             &sta350_write_regs,
+       .rd_table =             &sta350_read_regs,
+       .volatile_table =       &sta350_volatile_regs,
+};
+
+#ifdef CONFIG_OF
+static const struct of_device_id st350_dt_ids[] = {
+       { .compatible = "st,sta350", },
+       { }
+};
+MODULE_DEVICE_TABLE(of, st350_dt_ids);
+
+static const char * const sta350_ffx_modes[] = {
+       [STA350_FFX_PM_DROP_COMP]               = "drop-compensation",
+       [STA350_FFX_PM_TAPERED_COMP]            = "tapered-compensation",
+       [STA350_FFX_PM_FULL_POWER]              = "full-power-mode",
+       [STA350_FFX_PM_VARIABLE_DROP_COMP]      = "variable-drop-compensation",
+};
+
+static int sta350_probe_dt(struct device *dev, struct sta350_priv *sta350)
+{
+       struct device_node *np = dev->of_node;
+       struct sta350_platform_data *pdata;
+       const char *ffx_power_mode;
+       u16 tmp;
+
+       pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+       if (!pdata)
+               return -ENOMEM;
+
+       of_property_read_u8(np, "st,output-conf",
+                           &pdata->output_conf);
+       of_property_read_u8(np, "st,ch1-output-mapping",
+                           &pdata->ch1_output_mapping);
+       of_property_read_u8(np, "st,ch2-output-mapping",
+                           &pdata->ch2_output_mapping);
+       of_property_read_u8(np, "st,ch3-output-mapping",
+                           &pdata->ch3_output_mapping);
+
+       if (of_get_property(np, "st,thermal-warning-recovery", NULL))
+               pdata->thermal_warning_recovery = 1;
+       if (of_get_property(np, "st,thermal-warning-adjustment", NULL))
+               pdata->thermal_warning_adjustment = 1;
+       if (of_get_property(np, "st,fault-detect-recovery", NULL))
+               pdata->fault_detect_recovery = 1;
+
+       pdata->ffx_power_output_mode = STA350_FFX_PM_VARIABLE_DROP_COMP;
+       if (!of_property_read_string(np, "st,ffx-power-output-mode",
+                                    &ffx_power_mode)) {
+               int i, mode = -EINVAL;
+
+               for (i = 0; i < ARRAY_SIZE(sta350_ffx_modes); i++)
+                       if (!strcasecmp(ffx_power_mode, sta350_ffx_modes[i]))
+                               mode = i;
+
+               if (mode < 0)
+                       dev_warn(dev, "Unsupported ffx output mode: %s\n",
+                                ffx_power_mode);
+               else
+                       pdata->ffx_power_output_mode = mode;
+       }
+
+       tmp = 140;
+       of_property_read_u16(np, "st,drop-compensation-ns", &tmp);
+       pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20;
+
+       if (of_get_property(np, "st,overcurrent-warning-adjustment", NULL))
+               pdata->oc_warning_adjustment = 1;
+
+       /* CONFE */
+       if (of_get_property(np, "st,max-power-use-mpcc", NULL))
+               pdata->max_power_use_mpcc = 1;
+
+       if (of_get_property(np, "st,max-power-correction", NULL))
+               pdata->max_power_correction = 1;
+
+       if (of_get_property(np, "st,am-reduction-mode", NULL))
+               pdata->am_reduction_mode = 1;
+
+       if (of_get_property(np, "st,odd-pwm-speed-mode", NULL))
+               pdata->odd_pwm_speed_mode = 1;
+
+       if (of_get_property(np, "st,distortion-compensation", NULL))
+               pdata->distortion_compensation = 1;
+
+       /* CONFF */
+       if (of_get_property(np, "st,invalid-input-detect-mute", NULL))
+               pdata->invalid_input_detect_mute = 1;
+
+       sta350->pdata = pdata;
+
+       return 0;
+}
+#endif
+
+static int sta350_i2c_probe(struct i2c_client *i2c,
+                           const struct i2c_device_id *id)
+{
+       struct device *dev = &i2c->dev;
+       struct sta350_priv *sta350;
+       int ret, i;
+
+       sta350 = devm_kzalloc(dev, sizeof(struct sta350_priv), GFP_KERNEL);
+       if (!sta350)
+               return -ENOMEM;
+
+       mutex_init(&sta350->coeff_lock);
+       sta350->pdata = dev_get_platdata(dev);
+
+#ifdef CONFIG_OF
+       if (dev->of_node) {
+               ret = sta350_probe_dt(dev, sta350);
+               if (ret < 0)
+                       return ret;
+       }
+#endif
+
+       /* GPIOs */
+       sta350->gpiod_nreset = devm_gpiod_get(dev, "reset");
+       if (IS_ERR(sta350->gpiod_nreset)) {
+               ret = PTR_ERR(sta350->gpiod_nreset);
+               if (ret != -ENOENT && ret != -ENOSYS)
+                       return ret;
+
+               sta350->gpiod_nreset = NULL;
+       } else {
+               gpiod_direction_output(sta350->gpiod_nreset, 0);
+       }
+
+       sta350->gpiod_power_down = devm_gpiod_get(dev, "power-down");
+       if (IS_ERR(sta350->gpiod_power_down)) {
+               ret = PTR_ERR(sta350->gpiod_power_down);
+               if (ret != -ENOENT && ret != -ENOSYS)
+                       return ret;
+
+               sta350->gpiod_power_down = NULL;
+       } else {
+               gpiod_direction_output(sta350->gpiod_power_down, 0);
+       }
+
+       /* regulators */
+       for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++)
+               sta350->supplies[i].supply = sta350_supply_names[i];
+
+       ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(sta350->supplies),
+                                     sta350->supplies);
+       if (ret < 0) {
+               dev_err(dev, "Failed to request supplies: %d\n", ret);
+               return ret;
+       }
+
+       sta350->regmap = devm_regmap_init_i2c(i2c, &sta350_regmap);
+       if (IS_ERR(sta350->regmap)) {
+               ret = PTR_ERR(sta350->regmap);
+               dev_err(dev, "Failed to init regmap: %d\n", ret);
+               return ret;
+       }
+
+       i2c_set_clientdata(i2c, sta350);
+
+       ret = snd_soc_register_codec(dev, &sta350_codec, &sta350_dai, 1);
+       if (ret < 0)
+               dev_err(dev, "Failed to register codec (%d)\n", ret);
+
+       return ret;
+}
+
+static int sta350_i2c_remove(struct i2c_client *client)
+{
+       snd_soc_unregister_codec(&client->dev);
+       return 0;
+}
+
+static const struct i2c_device_id sta350_i2c_id[] = {
+       { "sta350", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, sta350_i2c_id);
+
+static struct i2c_driver sta350_i2c_driver = {
+       .driver = {
+               .name = "sta350",
+               .owner = THIS_MODULE,
+               .of_match_table = of_match_ptr(st350_dt_ids),
+       },
+       .probe =    sta350_i2c_probe,
+       .remove =   sta350_i2c_remove,
+       .id_table = sta350_i2c_id,
+};
+
+module_i2c_driver(sta350_i2c_driver);
+
+MODULE_DESCRIPTION("ASoC STA350 driver");
+MODULE_AUTHOR("Sven Brandau <info@brandau.biz>");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/sta350.h b/sound/soc/codecs/sta350.h
new file mode 100644 (file)
index 0000000..c3248f0
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system
+ *
+ * Copyright: 2011 Raumfeld GmbH
+ * Author: Sven Brandau <info@brandau.biz>
+ *
+ * based on code from:
+ *      Raumfeld GmbH
+ *        Johannes Stezenbach <js@sig21.net>
+ *     Wolfson Microelectronics PLC.
+ *       Mark Brown <broonie@opensource.wolfsonmicro.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+#ifndef _ASOC_STA_350_H
+#define _ASOC_STA_350_H
+
+/* STA50 register addresses */
+
+#define STA350_REGISTER_COUNT  0x4D
+#define STA350_COEF_COUNT 62
+
+#define STA350_CONFA   0x00
+#define STA350_CONFB    0x01
+#define STA350_CONFC    0x02
+#define STA350_CONFD    0x03
+#define STA350_CONFE    0x04
+#define STA350_CONFF    0x05
+#define STA350_MMUTE    0x06
+#define STA350_MVOL     0x07
+#define STA350_C1VOL    0x08
+#define STA350_C2VOL    0x09
+#define STA350_C3VOL    0x0a
+#define STA350_AUTO1    0x0b
+#define STA350_AUTO2    0x0c
+#define STA350_AUTO3    0x0d
+#define STA350_C1CFG    0x0e
+#define STA350_C2CFG    0x0f
+#define STA350_C3CFG    0x10
+#define STA350_TONE     0x11
+#define STA350_L1AR     0x12
+#define STA350_L1ATRT   0x13
+#define STA350_L2AR     0x14
+#define STA350_L2ATRT   0x15
+#define STA350_CFADDR2  0x16
+#define STA350_B1CF1    0x17
+#define STA350_B1CF2    0x18
+#define STA350_B1CF3    0x19
+#define STA350_B2CF1    0x1a
+#define STA350_B2CF2    0x1b
+#define STA350_B2CF3    0x1c
+#define STA350_A1CF1    0x1d
+#define STA350_A1CF2    0x1e
+#define STA350_A1CF3    0x1f
+#define STA350_A2CF1    0x20
+#define STA350_A2CF2    0x21
+#define STA350_A2CF3    0x22
+#define STA350_B0CF1    0x23
+#define STA350_B0CF2    0x24
+#define STA350_B0CF3    0x25
+#define STA350_CFUD     0x26
+#define STA350_MPCC1    0x27
+#define STA350_MPCC2    0x28
+#define STA350_DCC1     0x29
+#define STA350_DCC2     0x2a
+#define STA350_FDRC1    0x2b
+#define STA350_FDRC2    0x2c
+#define STA350_STATUS   0x2d
+/* reserved: 0x2d - 0x30 */
+#define STA350_EQCFG    0x31
+#define STA350_EATH1    0x32
+#define STA350_ERTH1    0x33
+#define STA350_EATH2    0x34
+#define STA350_ERTH2    0x35
+#define STA350_CONFX    0x36
+#define STA350_SVCA     0x37
+#define STA350_SVCB     0x38
+#define STA350_RMS0A    0x39
+#define STA350_RMS0B    0x3a
+#define STA350_RMS0C    0x3b
+#define STA350_RMS1A    0x3c
+#define STA350_RMS1B    0x3d
+#define STA350_RMS1C    0x3e
+#define STA350_EVOLRES  0x3f
+/* reserved: 0x40 - 0x47 */
+#define STA350_NSHAPE   0x48
+#define STA350_CTXB4B1  0x49
+#define STA350_CTXB7B5  0x4a
+#define STA350_MISC1    0x4b
+#define STA350_MISC2    0x4c
+
+/* 0x00 CONFA */
+#define STA350_CONFA_MCS_MASK  0x03
+#define STA350_CONFA_MCS_SHIFT 0
+#define STA350_CONFA_IR_MASK   0x18
+#define STA350_CONFA_IR_SHIFT  3
+#define STA350_CONFA_TWRB      BIT(5)
+#define STA350_CONFA_TWAB      BIT(6)
+#define STA350_CONFA_FDRB      BIT(7)
+
+/* 0x01 CONFB */
+#define STA350_CONFB_SAI_MASK  0x0f
+#define STA350_CONFB_SAI_SHIFT 0
+#define STA350_CONFB_SAIFB     BIT(4)
+#define STA350_CONFB_DSCKE     BIT(5)
+#define STA350_CONFB_C1IM      BIT(6)
+#define STA350_CONFB_C2IM      BIT(7)
+
+/* 0x02 CONFC */
+#define STA350_CONFC_OM_MASK   0x03
+#define STA350_CONFC_OM_SHIFT  0
+#define STA350_CONFC_CSZ_MASK  0x3c
+#define STA350_CONFC_CSZ_SHIFT 2
+#define STA350_CONFC_OCRB      BIT(7)
+
+/* 0x03 CONFD */
+#define STA350_CONFD_HPB_SHIFT 0
+#define STA350_CONFD_DEMP_SHIFT        1
+#define STA350_CONFD_DSPB_SHIFT        2
+#define STA350_CONFD_PSL_SHIFT 3
+#define STA350_CONFD_BQL_SHIFT 4
+#define STA350_CONFD_DRC_SHIFT 5
+#define STA350_CONFD_ZDE_SHIFT 6
+#define STA350_CONFD_SME_SHIFT 7
+
+/* 0x04 CONFE */
+#define STA350_CONFE_MPCV      BIT(0)
+#define STA350_CONFE_MPCV_SHIFT        0
+#define STA350_CONFE_MPC       BIT(1)
+#define STA350_CONFE_MPC_SHIFT 1
+#define STA350_CONFE_NSBW      BIT(2)
+#define STA350_CONFE_NSBW_SHIFT        2
+#define STA350_CONFE_AME       BIT(3)
+#define STA350_CONFE_AME_SHIFT 3
+#define STA350_CONFE_PWMS      BIT(4)
+#define STA350_CONFE_PWMS_SHIFT        4
+#define STA350_CONFE_DCCV      BIT(5)
+#define STA350_CONFE_DCCV_SHIFT        5
+#define STA350_CONFE_ZCE       BIT(6)
+#define STA350_CONFE_ZCE_SHIFT 6
+#define STA350_CONFE_SVE       BIT(7)
+#define STA350_CONFE_SVE_SHIFT 7
+
+/* 0x05 CONFF */
+#define STA350_CONFF_OCFG_MASK 0x03
+#define STA350_CONFF_OCFG_SHIFT        0
+#define STA350_CONFF_IDE       BIT(2)
+#define STA350_CONFF_BCLE      BIT(3)
+#define STA350_CONFF_LDTE      BIT(4)
+#define STA350_CONFF_ECLE      BIT(5)
+#define STA350_CONFF_PWDN      BIT(6)
+#define STA350_CONFF_EAPD      BIT(7)
+
+/* 0x06 MMUTE */
+#define STA350_MMUTE_MMUTE             0x01
+#define STA350_MMUTE_MMUTE_SHIFT       0
+#define STA350_MMUTE_C1M               0x02
+#define STA350_MMUTE_C1M_SHIFT         1
+#define STA350_MMUTE_C2M               0x04
+#define STA350_MMUTE_C2M_SHIFT         2
+#define STA350_MMUTE_C3M               0x08
+#define STA350_MMUTE_C3M_SHIFT         3
+#define STA350_MMUTE_LOC_MASK          0xC0
+#define STA350_MMUTE_LOC_SHIFT         6
+
+/* 0x0b AUTO1 */
+#define STA350_AUTO1_AMGC_MASK 0x30
+#define STA350_AUTO1_AMGC_SHIFT        4
+
+/* 0x0c AUTO2 */
+#define STA350_AUTO2_AMAME     0x01
+#define STA350_AUTO2_AMAM_MASK 0x0e
+#define STA350_AUTO2_AMAM_SHIFT        1
+#define STA350_AUTO2_XO_MASK   0xf0
+#define STA350_AUTO2_XO_SHIFT  4
+
+/* 0x0d AUTO3 */
+#define STA350_AUTO3_PEQ_MASK  0x1f
+#define STA350_AUTO3_PEQ_SHIFT 0
+
+/* 0x0e 0x0f 0x10 CxCFG */
+#define STA350_CxCFG_TCB_SHIFT 0
+#define STA350_CxCFG_EQBP_SHIFT        1
+#define STA350_CxCFG_VBP_SHIFT 2
+#define STA350_CxCFG_BO_SHIFT  3
+#define STA350_CxCFG_LS_SHIFT  4
+#define STA350_CxCFG_OM_MASK   0xc0
+#define STA350_CxCFG_OM_SHIFT  6
+
+/* 0x11 TONE */
+#define STA350_TONE_BTC_SHIFT  0
+#define STA350_TONE_TTC_SHIFT  4
+
+/* 0x12 0x13 0x14 0x15 limiter attack/release */
+#define STA350_LxA_SHIFT       0
+#define STA350_LxR_SHIFT       4
+
+/* 0x26 CFUD */
+#define STA350_CFUD_W1         0x01
+#define STA350_CFUD_WA         0x02
+#define STA350_CFUD_R1         0x04
+#define STA350_CFUD_RA         0x08
+
+
+/* biquad filter coefficient table offsets */
+#define STA350_C1_BQ_BASE      0
+#define STA350_C2_BQ_BASE      20
+#define STA350_CH_BQ_NUM       4
+#define STA350_BQ_NUM_COEF     5
+#define STA350_XO_HP_BQ_BASE   40
+#define STA350_XO_LP_BQ_BASE   45
+#define STA350_C1_PRESCALE     50
+#define STA350_C2_PRESCALE     51
+#define STA350_C1_POSTSCALE    52
+#define STA350_C2_POSTSCALE    53
+#define STA350_C3_POSTSCALE    54
+#define STA350_TW_POSTSCALE    55
+#define STA350_C1_MIX1         56
+#define STA350_C1_MIX2         57
+#define STA350_C2_MIX1         58
+#define STA350_C2_MIX2         59
+#define STA350_C3_MIX1         60
+#define STA350_C3_MIX2         61
+
+#endif /* _ASOC_STA_350_H */
index a895a5e4bdf207eee6387bc00e8452ae2385233d..d48491a4a19db93d8b496d6f8899d88dd44fa3c0 100644 (file)
@@ -272,7 +272,7 @@ static int tas5086_set_deemph(struct snd_soc_codec *codec)
 static int tas5086_get_deemph(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = priv->deemph;
@@ -283,7 +283,7 @@ static int tas5086_get_deemph(struct snd_kcontrol *kcontrol,
 static int tas5086_put_deemph(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec);
 
        priv->deemph = ucontrol->value.enumerated.item[0];
index 20864ee8793b5e24be689f6686a2217d9c5c13b9..686b8b85b95696008da32492f9b2108da2f63b1d 100644 (file)
@@ -82,7 +82,7 @@ static const DECLARE_TLV_DB_SCALE(sidetone_vol_tlv, -1800, 300, 0);
 static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        u16 val, reg;
 
        val = (ucontrol->value.integer.value[0] & 0x07);
@@ -105,7 +105,7 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol,
 static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        u16 val;
 
        val = snd_soc_read(codec, TLV320AIC23_ANLG) & (0x1C0);
index 6bfc8a17331b05c887a80199f05fa4fb38baac31..517055ab65ef4889d4a3c4565b51712bc4bbc396 100644 (file)
@@ -442,7 +442,7 @@ static int dac33_playback_event(struct snd_soc_dapm_widget *w,
 static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol,
                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = dac33->fifo_mode;
@@ -453,7 +453,7 @@ static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol,
 static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol,
                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec);
        int ret = 0;
 
index 975e0f760ac1b74d01289fed1016278ae5c66f8e..69e12a311ba20009fe489960800f95798eecbbc3 100644 (file)
@@ -830,7 +830,7 @@ static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int shift = mc->shift;
        unsigned int rshift = mc->rshift;
@@ -859,7 +859,7 @@ static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int shift = mc->shift;
        unsigned int rshift = mc->rshift;
@@ -888,7 +888,7 @@ static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
        unsigned int shift = mc->shift;
@@ -915,7 +915,7 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
        unsigned int shift = mc->shift;
@@ -956,7 +956,7 @@ static SOC_ENUM_SINGLE_DECL(twl4030_op_modes_enum,
 static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
 
        if (twl4030->configured) {
index bd3a20647fdff04c0071bc9f77061eea457e77de..0f6067f04e291fa0b323db8ae77bcd31ea420c51 100644 (file)
@@ -484,7 +484,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(twl6040_power_mode_enum,
 static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = priv->hs_power_mode;
@@ -495,7 +495,7 @@ static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol,
 static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
        int high_perf = ucontrol->value.enumerated.item[0];
        int ret = 0;
@@ -512,7 +512,7 @@ static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol,
 static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = priv->pll_power_mode;
@@ -523,7 +523,7 @@ static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol,
 static int twl6040_pll_put_enum(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
 
        priv->pll_power_mode = ucontrol->value.enumerated.item[0];
index 6be5f80b65f1ad632eeab797bfa6349c1ae800dc..4ead0dc02b87428e15e160032e3b9ef8fab6f925 100644 (file)
@@ -172,7 +172,7 @@ out:
 static int snd_wl1273_get_audio_route(struct snd_kcontrol *kcontrol,
                                      struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = wl1273->mode;
@@ -190,7 +190,7 @@ static const char * const wl1273_audio_route[] = { "Bt", "FmRx", "FmTx" };
 static int snd_wl1273_set_audio_route(struct snd_kcontrol *kcontrol,
                                      struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
 
        if (wl1273->mode == ucontrol->value.integer.value[0])
@@ -214,7 +214,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(wl1273_enum, wl1273_audio_route);
 static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol,
                                   struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
 
        dev_dbg(codec->dev, "%s: enter.\n", __func__);
@@ -227,7 +227,7 @@ static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol,
 static int snd_wl1273_fm_audio_put(struct snd_kcontrol *kcontrol,
                                   struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
        int val, r = 0;
 
@@ -251,7 +251,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(wl1273_audio_enum, wl1273_audio_strings);
 static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol,
                                    struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
 
        dev_dbg(codec->dev, "%s: enter.\n", __func__);
@@ -264,7 +264,7 @@ static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol,
 static int snd_wl1273_fm_volume_put(struct snd_kcontrol *kcontrol,
                                    struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
        int r;
 
index 83a2c872925c4bbd9a844ea36f8b5127fd72fd41..a4c352cc3464959bc8be67066ae41fe321e698ab 100644 (file)
@@ -607,7 +607,7 @@ static int wm2000_anc_set_mode(struct wm2000_priv *wm2000)
 static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev);
 
        ucontrol->value.enumerated.item[0] = wm2000->anc_active;
@@ -618,7 +618,7 @@ static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol,
 static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev);
        int anc_active = ucontrol->value.enumerated.item[0];
        int ret;
@@ -640,7 +640,7 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol,
 static int wm2000_speaker_get(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev);
 
        ucontrol->value.enumerated.item[0] = wm2000->spk_ena;
@@ -651,7 +651,7 @@ static int wm2000_speaker_get(struct snd_kcontrol *kcontrol,
 static int wm2000_speaker_put(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev);
        int val = ucontrol->value.enumerated.item[0];
        int ret;
index dcf1d12cfef8f7bd5cb835d995eef1cb71e1ad93..7a046536ea681cfaef382569b3b6b7bafa5cf4ca 100644 (file)
@@ -1760,10 +1760,6 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec)
        struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
        int ret;
 
-       ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap);
-       if (ret != 0)
-               return ret;
-
        ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 2);
        if (ret != 0)
                return ret;
@@ -1802,9 +1798,17 @@ static unsigned int wm5102_digital_vu[] = {
        ARIZONA_DAC_DIGITAL_VOLUME_5R,
 };
 
+static struct regmap *wm5102_get_regmap(struct device *dev)
+{
+       struct wm5102_priv *priv = dev_get_drvdata(dev);
+
+       return priv->core.arizona->regmap;
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_wm5102 = {
        .probe = wm5102_codec_probe,
        .remove = wm5102_codec_remove,
+       .get_regmap = wm5102_get_regmap,
 
        .idle_bias_off = true,
 
index df5a38dd8328db5922a4db96758b50d81e6255ee..97eb1bc5bea70f367b5e3200c7f75a2296ef5760 100644 (file)
@@ -1589,10 +1589,6 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec)
 
        priv->core.arizona->dapm = &codec->dapm;
 
-       ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap);
-       if (ret != 0)
-               return ret;
-
        arizona_init_spk(codec);
        arizona_init_gpio(codec);
 
@@ -1633,9 +1629,17 @@ static unsigned int wm5110_digital_vu[] = {
        ARIZONA_DAC_DIGITAL_VOLUME_6R,
 };
 
+static struct regmap *wm5110_get_regmap(struct device *dev)
+{
+       struct wm5110_priv *priv = dev_get_drvdata(dev);
+
+       return priv->core.arizona->regmap;
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_wm5110 = {
        .probe = wm5110_codec_probe,
        .remove = wm5110_codec_remove,
+       .get_regmap = wm5110_get_regmap,
 
        .idle_bias_off = true,
 
index 757256bf7672ef9a44d156d895ca0537018ab852..392285edb59545787f336bdc59babdbb5e15e69f 100644 (file)
@@ -302,7 +302,7 @@ static int pga_event(struct snd_soc_dapm_widget *w,
 static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol,
                                  struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec);
        struct wm8350_output *out = NULL;
        struct soc_mixer_control *mc =
@@ -345,7 +345,7 @@ static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol,
 static int wm8350_get_volsw_2r(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec);
        struct wm8350_output *out1 = &wm8350_priv->out1;
        struct wm8350_output *out2 = &wm8350_priv->out2;
@@ -1505,8 +1505,6 @@ static  int wm8350_codec_probe(struct snd_soc_codec *codec)
        if (ret != 0)
                return ret;
 
-       snd_soc_codec_set_cache_io(codec, wm8350->regmap);
-
        /* Put the codec into reset if it wasn't already */
        wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);
 
@@ -1608,11 +1606,19 @@ static int  wm8350_codec_remove(struct snd_soc_codec *codec)
        return 0;
 }
 
+static struct regmap *wm8350_get_regmap(struct device *dev)
+{
+       struct wm8350 *wm8350 = dev_get_platdata(dev);
+
+       return wm8350->regmap;
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_wm8350 = {
        .probe =        wm8350_codec_probe,
        .remove =       wm8350_codec_remove,
        .suspend =      wm8350_suspend,
        .resume =       wm8350_resume,
+       .get_regmap =   wm8350_get_regmap,
        .set_bias_level = wm8350_set_bias_level,
 
        .controls = wm8350_snd_controls,
index 146564feaea04156d8d0d2fe5608390047b4cad0..06e913d3fea15bbfb231fb87b46ee8571e0c7ea8 100644 (file)
@@ -93,7 +93,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0);
 static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
         struct snd_ctl_elem_value *ucontrol)
 {
-        struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
        int reg = mc->reg;
@@ -1318,8 +1318,6 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec)
        priv->wm8400 = wm8400;
        priv->codec = codec;
 
-       snd_soc_codec_set_cache_io(codec, wm8400->regmap);
-
        ret = devm_regulator_bulk_get(wm8400->dev,
                                 ARRAY_SIZE(power), &power[0]);
        if (ret != 0) {
@@ -1361,11 +1359,19 @@ static int  wm8400_codec_remove(struct snd_soc_codec *codec)
        return 0;
 }
 
+static struct regmap *wm8400_get_regmap(struct device *dev)
+{
+       struct wm8400 *wm8400 = dev_get_platdata(dev);
+
+       return wm8400->regmap;
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_wm8400 = {
        .probe =        wm8400_codec_probe,
        .remove =       wm8400_codec_remove,
        .suspend =      wm8400_suspend,
        .resume =       wm8400_resume,
+       .get_regmap =   wm8400_get_regmap,
        .set_bias_level = wm8400_set_bias_level,
 
        .controls = wm8400_snd_controls,
index af7ed8b5d4e187e5b85dc6f3d47b9f7711ca86b2..7665ff6aea6de913081ea1b5ad52c28f518a5cde 100644 (file)
@@ -252,7 +252,7 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec);
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
index d74f43975b90fb3e90a5b7b36b0239e4f6e52aeb..763b265d952888fb978a8b2ec8779962266e025b 100644 (file)
@@ -119,7 +119,7 @@ static int wm8731_set_deemph(struct snd_soc_codec *codec)
 static int wm8731_get_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8731->deemph;
@@ -130,7 +130,7 @@ static int wm8731_get_deemph(struct snd_kcontrol *kcontrol,
 static int wm8731_put_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec);
        int deemph = ucontrol->value.enumerated.item[0];
        int ret = 0;
index cbb8d55052a44a56bcfc22c00d1b64beeeb47da9..53e57b4049a8f559da49621b1d333d6898d10157 100644 (file)
@@ -234,7 +234,7 @@ SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase),
 static int wm8753_get_dai(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = wm8753->dai_func;
@@ -244,7 +244,7 @@ static int wm8753_get_dai(struct snd_kcontrol *kcontrol,
 static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec =  snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
        u16 ioctl;
 
index ee76f0fb429967c4f563450a111d3ce651540fd0..589455c3bfcd9b7ac430abe138169fa6b6606a1f 100644 (file)
@@ -106,7 +106,7 @@ static int txsrc_get(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec;
        unsigned int src;
 
-       codec = snd_kcontrol_chip(kcontrol);
+       codec = snd_soc_kcontrol_codec(kcontrol);
        src = snd_soc_read(codec, WM8804_SPDTX4);
        if (src & 0x40)
                ucontrol->value.integer.value[0] = 1;
@@ -122,7 +122,7 @@ static int txsrc_put(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec;
        unsigned int src, txpwr;
 
-       codec = snd_kcontrol_chip(kcontrol);
+       codec = snd_soc_kcontrol_codec(kcontrol);
 
        if (ucontrol->value.integer.value[0] != 0
                        && ucontrol->value.integer.value[0] != 1)
index b0084a127d18c6214636ed96ef40f3ae8b4b56ae..b84940c359a127fd1330146b21ef50cda605ac0d 100644 (file)
@@ -439,7 +439,7 @@ static int wm8903_set_deemph(struct snd_soc_codec *codec)
 static int wm8903_get_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8903->deemph;
@@ -450,7 +450,7 @@ static int wm8903_get_deemph(struct snd_kcontrol *kcontrol,
 static int wm8903_put_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec);
        int deemph = ucontrol->value.enumerated.item[0];
        int ret = 0;
index 49c35c36935e45ed478191ac063c8816fd618a27..f7c549949c542203c954cb89b2a1f8552212e98a 100644 (file)
@@ -391,7 +391,7 @@ static void wm8904_set_drc(struct snd_soc_codec *codec)
 static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
        struct wm8904_pdata *pdata = wm8904->pdata;
        int value = ucontrol->value.integer.value[0];
@@ -409,7 +409,7 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol,
 static int wm8904_get_drc_enum(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8904->drc_cfg;
@@ -462,7 +462,7 @@ static void wm8904_set_retune_mobile(struct snd_soc_codec *codec)
 static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
                                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
        struct wm8904_pdata *pdata = wm8904->pdata;
        int value = ucontrol->value.integer.value[0];
@@ -480,7 +480,7 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
 static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol,
                                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg;
@@ -520,7 +520,7 @@ static int wm8904_set_deemph(struct snd_soc_codec *codec)
 static int wm8904_get_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8904->deemph;
@@ -530,7 +530,7 @@ static int wm8904_get_deemph(struct snd_kcontrol *kcontrol,
 static int wm8904_put_deemph(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
        int deemph = ucontrol->value.enumerated.item[0];
 
@@ -570,7 +570,7 @@ static SOC_ENUM_SINGLE_DECL(hpf_mode, WM8904_ADC_DIGITAL_0, 5,
 static int wm8904_adc_osr_put(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int val;
        int ret;
 
index fecd4e4f4c5731c6d9cbeefaa782bbef632e1daa..7e443c4f6f85050867447081481ae5daec57344e 100644 (file)
@@ -390,7 +390,7 @@ static int wm8955_set_deemph(struct snd_soc_codec *codec)
 static int wm8955_get_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8955->deemph;
@@ -400,7 +400,7 @@ static int wm8955_get_deemph(struct snd_kcontrol *kcontrol,
 static int wm8955_put_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec);
        int deemph = ucontrol->value.enumerated.item[0];
 
index 7ac2e511403ce595963bd38cd9ce48401555f88d..b2ebb104d8794fb14c289b798f6b7b7a7bbcf588 100644 (file)
@@ -456,7 +456,7 @@ static int wm8958_dsp2_busy(struct wm8994_priv *wm8994, int aif)
 static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
        int value = ucontrol->value.integer.value[0];
@@ -478,7 +478,7 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol,
 static int wm8958_get_mbc_enum(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8994->mbc_cfg;
@@ -500,7 +500,7 @@ static int wm8958_mbc_get(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
        int mbc = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = wm8994->mbc_ena[mbc];
@@ -512,7 +512,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
        int mbc = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0])
@@ -546,7 +546,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol,
 static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
        int value = ucontrol->value.integer.value[0];
@@ -568,7 +568,7 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol,
 static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8994->vss_cfg;
@@ -579,7 +579,7 @@ static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol,
 static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol,
                                   struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
        int value = ucontrol->value.integer.value[0];
@@ -601,7 +601,7 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol,
 static int wm8958_get_vss_hpf_enum(struct snd_kcontrol *kcontrol,
                                   struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8994->vss_hpf_cfg;
@@ -623,7 +623,7 @@ static int wm8958_vss_get(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
        int vss = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = wm8994->vss_ena[vss];
@@ -635,7 +635,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
        int vss = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0])
@@ -684,7 +684,7 @@ static int wm8958_hpf_get(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
        int hpf = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        if (hpf < 3)
@@ -699,7 +699,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
        int hpf = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        if (hpf < 3) {
@@ -746,7 +746,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol,
 static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol,
                                  struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
        int value = ucontrol->value.integer.value[0];
@@ -768,7 +768,7 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol,
 static int wm8958_get_enh_eq_enum(struct snd_kcontrol *kcontrol,
                                  struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8994->enh_eq_cfg;
@@ -790,7 +790,7 @@ static int wm8958_enh_eq_get(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
        int eq = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = wm8994->enh_eq_ena[eq];
@@ -802,7 +802,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
        int eq = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
 
        if (wm8994->enh_eq_ena[eq] == ucontrol->value.integer.value[0])
index d04e9cad445c391046f0d586005668e62d1e997b..a145d0431b63dbc11c975f8b226a6f250ed17008 100644 (file)
@@ -178,7 +178,7 @@ static int wm8960_set_deemph(struct snd_soc_codec *codec)
 static int wm8960_get_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.enumerated.item[0] = wm8960->deemph;
@@ -188,7 +188,7 @@ static int wm8960_get_deemph(struct snd_kcontrol *kcontrol,
 static int wm8960_put_deemph(struct snd_kcontrol *kcontrol,
                             struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
        int deemph = ucontrol->value.enumerated.item[0];
 
index 5522d2566c6742d5ee19f91b4358b30f51276b62..37986c84cbffe011f0e8a484754eb2db03a714b0 100644 (file)
@@ -1552,7 +1552,7 @@ static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
        int shift = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
 
        ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift);
@@ -1564,7 +1564,7 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
        int shift = kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
        int old = wm8962->dsp2_ena;
        int ret = 0;
@@ -1602,7 +1602,7 @@ out:
 static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol,
                            struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        int ret;
 
        /* Apply the update (if any) */
@@ -1632,7 +1632,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol,
 static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol,
                            struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        int ret;
 
        /* Apply the update (if any) */
index 2b9bfa53efbfeea53d4d8033f10b0d50e4074f38..19d5baa38f5c15e7f53b3430618620ca260f0471 100644 (file)
@@ -552,7 +552,7 @@ static const struct snd_soc_dapm_route wm8983_audio_map[] = {
 static int eqmode_get(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg;
 
        reg = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF);
@@ -567,7 +567,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol,
 static int eqmode_put(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int regpwr2, regpwr3;
        unsigned int reg_eq;
 
index 5473dc969585de3852feb6cbbdca7d09b4ace49f..ad23ffb8346cc3c498f67fd5eb2d237adb3f79fa 100644 (file)
@@ -526,7 +526,7 @@ static const struct snd_soc_dapm_route wm8985_dapm_routes[] = {
 static int eqmode_get(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg;
 
        reg = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF);
@@ -541,7 +541,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol,
 static int eqmode_put(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int regpwr2, regpwr3;
        unsigned int reg_eq;
 
index c413c19914534c4fe34e55778a474691743e156f..b5c1f0f070585bd8238178a4187d9b8e567135d4 100644 (file)
@@ -132,7 +132,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0);
 static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
        int reg = mc->reg;
index 844cc4a60d667ef8f67dd7b35f29b3834c07b938..b8fd284fc0c023bdb83ea4f87dbc87656608e5d5 100644 (file)
@@ -154,7 +154,7 @@ static const unsigned int out_sidetone_tlv[] = {
 static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
                                      struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        int reg = kcontrol->private_value & 0xff;
        int ret;
        u16 val;
index 6303537f54c6d0dde224f7f1c2ee028a7c5c930b..29f40a90fa79b817537c7c44a7e5cc7487805c7b 100644 (file)
@@ -298,7 +298,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol,
 {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        int mask, ret;
 
        /* Can't enable both ADC and DAC paths simultaneously */
@@ -355,7 +355,7 @@ static int wm8994_get_drc(const char *name)
 static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
        struct wm8994_pdata *pdata = &control->pdata;
@@ -378,7 +378,7 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol,
 static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        int drc = wm8994_get_drc(kcontrol->id.name);
 
@@ -462,7 +462,7 @@ static int wm8994_get_retune_mobile_block(const char *name)
 static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
                                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
        struct wm8994_pdata *pdata = &control->pdata;
@@ -485,7 +485,7 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
 static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol,
                                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        int block = wm8994_get_retune_mobile_block(kcontrol->id.name);
 
@@ -3999,8 +3999,6 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
 
        wm8994->hubs.codec = codec;
 
-       snd_soc_codec_set_cache_io(codec, control->regmap);
-
        mutex_init(&wm8994->accdet_lock);
        INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap,
                          wm1811_jackdet_bootstrap);
@@ -4434,11 +4432,19 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec)
        return 0;
 }
 
+static struct regmap *wm8994_get_regmap(struct device *dev)
+{
+       struct wm8994 *control = dev_get_drvdata(dev->parent);
+
+       return control->regmap;
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_wm8994 = {
        .probe =        wm8994_codec_probe,
        .remove =       wm8994_codec_remove,
        .suspend =      wm8994_codec_suspend,
        .resume =       wm8994_codec_resume,
+       .get_regmap =   wm8994_get_regmap,
        .set_bias_level = wm8994_set_bias_level,
 };
 
index c6cbb3b8ace96a8d462159d975ae5525b5ac7ed4..69266332760ebad71bed763449afa2f8eb8079a9 100644 (file)
@@ -412,7 +412,7 @@ static int wm8996_get_retune_mobile_block(const char *name)
 static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
                                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec);
        struct wm8996_pdata *pdata = &wm8996->pdata;
        int block = wm8996_get_retune_mobile_block(kcontrol->id.name);
@@ -434,7 +434,7 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
 static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol,
                                         struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec);
        int block = wm8996_get_retune_mobile_block(kcontrol->id.name);
 
index 004186b6bd48131932ac8fceca088548b9df9eb5..09c4150840a320a8182ea496f91fa298b7ba0c75 100644 (file)
@@ -1051,11 +1051,6 @@ static struct snd_soc_dai_driver wm8997_dai[] = {
 static int wm8997_codec_probe(struct snd_soc_codec *codec)
 {
        struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec);
-       int ret;
-
-       ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap);
-       if (ret != 0)
-               return ret;
 
        arizona_init_spk(codec);
 
@@ -1086,9 +1081,17 @@ static unsigned int wm8997_digital_vu[] = {
        ARIZONA_DAC_DIGITAL_VOLUME_5R,
 };
 
+static struct regmap *wm8997_get_regmap(struct device *dev)
+{
+       struct wm8997_priv *priv = dev_get_drvdata(dev);
+
+       return priv->core.arizona->regmap;
+}
+
 static struct snd_soc_codec_driver soc_codec_dev_wm8997 = {
        .probe = wm8997_codec_probe,
        .remove = wm8997_codec_remove,
+       .get_regmap =   wm8997_get_regmap,
 
        .idle_bias_off = true,
 
index d18eff31fbbc618243a9b0db38e603e7af92bb30..185eb97769e730d3a4c7d40ac7abbd8b3046ae32 100644 (file)
@@ -340,7 +340,7 @@ static SOC_ENUM_SINGLE_DECL(speaker_mode, WM9081_ANALOGUE_SPEAKER_2, 6,
 static int speaker_mode_get(struct snd_kcontrol *kcontrol,
                            struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg;
 
        reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2);
@@ -361,7 +361,7 @@ static int speaker_mode_get(struct snd_kcontrol *kcontrol,
 static int speaker_mode_put(struct snd_kcontrol *kcontrol,
                            struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned int reg_pwr = snd_soc_read(codec, WM9081_POWER_MANAGEMENT);
        unsigned int reg2 = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2);
 
index bb5f7b4e3ebbfe016146343c9c1178f568c93517..d9686dcd024c756e3efd8db5596d2c3e8d37adba 100644 (file)
@@ -242,7 +242,7 @@ struct wm_coeff_ctl {
 static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
        struct wm_adsp *adsp = snd_soc_codec_get_drvdata(codec);
 
@@ -254,7 +254,7 @@ static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol,
 static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
        struct wm_adsp *adsp = snd_soc_codec_get_drvdata(codec);
 
index b6209662ab13f8c5031908a0408494064d7b5299..916817fe6632f573848f5a7a69bf95aa87072313 100644 (file)
@@ -337,7 +337,7 @@ static void enable_dc_servo(struct snd_soc_codec *codec)
 static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
        int ret;
 
index 0a32dd13a23d28ab96282b75592c20d5b133ee9f..67a5eb3c6196e22ed142fa276651e0945b53c022 100644 (file)
@@ -136,7 +136,7 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value)
 static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
        struct hsw_priv_data *pdata =
@@ -174,7 +174,7 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol,
 static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
        struct hsw_priv_data *pdata =
@@ -206,7 +206,7 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol,
 static int hsw_volume_put(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
        struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform);
        struct sst_hsw *hsw = pdata->hsw;
        u32 volume;
@@ -231,7 +231,7 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol,
 static int hsw_volume_get(struct snd_kcontrol *kcontrol,
                                struct snd_ctl_elem_value *ucontrol)
 {
-       struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol);
        struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform);
        struct sst_hsw *hsw = pdata->hsw;
        unsigned int volume = 0;
index bfed3e4c45ffa708910e580bf02359a7b6b3c509..3fa77d5f9b75c0b7f442669301f4bf667eab8f7c 100644 (file)
@@ -162,8 +162,6 @@ static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec)
                                                  i, codec_drv->reg_word_size) == val)
                                continue;
 
-               WARN_ON(!snd_soc_codec_writable_register(codec, i));
-
                ret = snd_soc_write(codec, i, val);
                if (ret)
                        return ret;
index 051c006281f5c2c003583f7104c9ec02dc886dfc..db577e4cdf497a1fa79f4d3138af45a841dd179d 100644 (file)
@@ -154,22 +154,15 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf,
                step = codec->driver->reg_cache_step;
 
        for (i = 0; i < codec->driver->reg_cache_size; i += step) {
-               if (!snd_soc_codec_readable_register(codec, i))
-                       continue;
-               if (codec->driver->display_register) {
-                       count += codec->driver->display_register(codec, buf + count,
-                                                        PAGE_SIZE - count, i);
-               } else {
-                       /* only support larger than PAGE_SIZE bytes debugfs
-                        * entries for the default case */
-                       if (p >= pos) {
-                               if (total + len >= count - 1)
-                                       break;
-                               format_register_str(codec, i, buf + total, len);
-                               total += len;
-                       }
-                       p += len;
+               /* only support larger than PAGE_SIZE bytes debugfs
+                * entries for the default case */
+               if (p >= pos) {
+                       if (total + len >= count - 1)
+                               break;
+                       format_register_str(codec, i, buf + total, len);
+                       total += len;
                }
+               p += len;
        }
 
        total = min(total, count - 1);
@@ -1127,26 +1120,31 @@ static int soc_probe_codec(struct snd_soc_card *card,
 
        soc_init_codec_debugfs(codec);
 
-       if (driver->dapm_widgets)
-               snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets,
-                                         driver->num_dapm_widgets);
+       if (driver->dapm_widgets) {
+               ret = snd_soc_dapm_new_controls(&codec->dapm,
+                                               driver->dapm_widgets,
+                                               driver->num_dapm_widgets);
 
-       /* Create DAPM widgets for each DAI stream */
-       list_for_each_entry(dai, &codec->component.dai_list, list)
-               snd_soc_dapm_new_dai_widgets(&codec->dapm, dai);
+               if (ret != 0) {
+                       dev_err(codec->dev,
+                               "Failed to create new controls %d\n", ret);
+                       goto err_probe;
+               }
+       }
 
-       codec->dapm.idle_bias_off = driver->idle_bias_off;
+       /* Create DAPM widgets for each DAI stream */
+       list_for_each_entry(dai, &codec->component.dai_list, list) {
+               ret = snd_soc_dapm_new_dai_widgets(&codec->dapm, dai);
 
-       if (!codec->write && dev_get_regmap(codec->dev, NULL)) {
-               /* Set the default I/O up try regmap */
-               ret = snd_soc_codec_set_cache_io(codec, NULL);
-               if (ret < 0) {
+               if (ret != 0) {
                        dev_err(codec->dev,
-                               "Failed to set cache I/O: %d\n", ret);
+                               "Failed to create DAI widgets %d\n", ret);
                        goto err_probe;
                }
        }
 
+       codec->dapm.idle_bias_off = driver->idle_bias_off;
+
        if (driver->probe) {
                ret = driver->probe(codec);
                if (ret < 0) {
@@ -1979,92 +1977,6 @@ static struct platform_driver soc_driver = {
        .remove         = soc_remove,
 };
 
-/**
- * snd_soc_codec_volatile_register: Report if a register is volatile.
- *
- * @codec: CODEC to query.
- * @reg: Register to query.
- *
- * Boolean function indiciating if a CODEC register is volatile.
- */
-int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
-                                   unsigned int reg)
-{
-       if (codec->volatile_register)
-               return codec->volatile_register(codec, reg);
-       else
-               return 0;
-}
-EXPORT_SYMBOL_GPL(snd_soc_codec_volatile_register);
-
-/**
- * snd_soc_codec_readable_register: Report if a register is readable.
- *
- * @codec: CODEC to query.
- * @reg: Register to query.
- *
- * Boolean function indicating if a CODEC register is readable.
- */
-int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
-                                   unsigned int reg)
-{
-       if (codec->readable_register)
-               return codec->readable_register(codec, reg);
-       else
-               return 1;
-}
-EXPORT_SYMBOL_GPL(snd_soc_codec_readable_register);
-
-/**
- * snd_soc_codec_writable_register: Report if a register is writable.
- *
- * @codec: CODEC to query.
- * @reg: Register to query.
- *
- * Boolean function indicating if a CODEC register is writable.
- */
-int snd_soc_codec_writable_register(struct snd_soc_codec *codec,
-                                   unsigned int reg)
-{
-       if (codec->writable_register)
-               return codec->writable_register(codec, reg);
-       else
-               return 1;
-}
-EXPORT_SYMBOL_GPL(snd_soc_codec_writable_register);
-
-int snd_soc_platform_read(struct snd_soc_platform *platform,
-                                       unsigned int reg)
-{
-       unsigned int ret;
-
-       if (!platform->driver->read) {
-               dev_err(platform->dev, "ASoC: platform has no read back\n");
-               return -1;
-       }
-
-       ret = platform->driver->read(platform, reg);
-       dev_dbg(platform->dev, "read %x => %x\n", reg, ret);
-       trace_snd_soc_preg_read(platform, reg, ret);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_platform_read);
-
-int snd_soc_platform_write(struct snd_soc_platform *platform,
-                                        unsigned int reg, unsigned int val)
-{
-       if (!platform->driver->write) {
-               dev_err(platform->dev, "ASoC: platform has no write back\n");
-               return -1;
-       }
-
-       dev_dbg(platform->dev, "write %x = %x\n", reg, val);
-       trace_snd_soc_preg_write(platform, reg, val);
-       return platform->driver->write(platform, reg, val);
-}
-EXPORT_SYMBOL_GPL(snd_soc_platform_write);
-
 /**
  * snd_soc_new_ac97_codec - initailise AC97 device
  * @codec: audio codec
@@ -2153,28 +2065,28 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev,
        p = devm_pinctrl_get(dev);
        if (IS_ERR(p)) {
                dev_err(dev, "Failed to get pinctrl\n");
-               return PTR_RET(p);
+               return PTR_ERR(p);
        }
        cfg->pctl = p;
 
        state = pinctrl_lookup_state(p, "ac97-reset");
        if (IS_ERR(state)) {
                dev_err(dev, "Can't find pinctrl state ac97-reset\n");
-               return PTR_RET(state);
+               return PTR_ERR(state);
        }
        cfg->pstate_reset = state;
 
        state = pinctrl_lookup_state(p, "ac97-warm-reset");
        if (IS_ERR(state)) {
                dev_err(dev, "Can't find pinctrl state ac97-warm-reset\n");
-               return PTR_RET(state);
+               return PTR_ERR(state);
        }
        cfg->pstate_warm_reset = state;
 
        state = pinctrl_lookup_state(p, "ac97-running");
        if (IS_ERR(state)) {
                dev_err(dev, "Can't find pinctrl state ac97-running\n");
-               return PTR_RET(state);
+               return PTR_ERR(state);
        }
        cfg->pstate_run = state;
 
@@ -2283,118 +2195,6 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)
 }
 EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec);
 
-unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg)
-{
-       unsigned int ret;
-
-       ret = codec->read(codec, reg);
-       dev_dbg(codec->dev, "read %x => %x\n", reg, ret);
-       trace_snd_soc_reg_read(codec, reg, ret);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(snd_soc_read);
-
-unsigned int snd_soc_write(struct snd_soc_codec *codec,
-                          unsigned int reg, unsigned int val)
-{
-       dev_dbg(codec->dev, "write %x = %x\n", reg, val);
-       trace_snd_soc_reg_write(codec, reg, val);
-       return codec->write(codec, reg, val);
-}
-EXPORT_SYMBOL_GPL(snd_soc_write);
-
-/**
- * snd_soc_update_bits - update codec register bits
- * @codec: audio codec
- * @reg: codec register
- * @mask: register mask
- * @value: new value
- *
- * Writes new register value.
- *
- * Returns 1 for change, 0 for no change, or negative error code.
- */
-int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
-                               unsigned int mask, unsigned int value)
-{
-       bool change;
-       unsigned int old, new;
-       int ret;
-
-       if (codec->using_regmap) {
-               ret = regmap_update_bits_check(codec->control_data, reg,
-                                              mask, value, &change);
-       } else {
-               ret = snd_soc_read(codec, reg);
-               if (ret < 0)
-                       return ret;
-
-               old = ret;
-               new = (old & ~mask) | (value & mask);
-               change = old != new;
-               if (change)
-                       ret = snd_soc_write(codec, reg, new);
-       }
-
-       if (ret < 0)
-               return ret;
-
-       return change;
-}
-EXPORT_SYMBOL_GPL(snd_soc_update_bits);
-
-/**
- * snd_soc_update_bits_locked - update codec register bits
- * @codec: audio codec
- * @reg: codec register
- * @mask: register mask
- * @value: new value
- *
- * Writes new register value, and takes the codec mutex.
- *
- * Returns 1 for change else 0.
- */
-int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
-                              unsigned short reg, unsigned int mask,
-                              unsigned int value)
-{
-       int change;
-
-       mutex_lock(&codec->mutex);
-       change = snd_soc_update_bits(codec, reg, mask, value);
-       mutex_unlock(&codec->mutex);
-
-       return change;
-}
-EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked);
-
-/**
- * snd_soc_test_bits - test register for change
- * @codec: audio codec
- * @reg: codec register
- * @mask: register mask
- * @value: new value
- *
- * Tests a register with a new value and checks if the new value is
- * different from the old value.
- *
- * Returns 1 for change else 0.
- */
-int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
-                               unsigned int mask, unsigned int value)
-{
-       int change;
-       unsigned int old, new;
-
-       old = snd_soc_read(codec, reg);
-       new = (old & ~mask) | value;
-       change = old != new;
-
-       return change;
-}
-EXPORT_SYMBOL_GPL(snd_soc_test_bits);
-
 /**
  * snd_soc_cnew - create new control
  * @_template: control template
@@ -2896,7 +2696,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
        int min = mc->min;
        int mask = (1 << (fls(min + max) - 1)) - 1;
        int err = 0;
-       unsigned short val, val_mask, val2 = 0;
+       unsigned int val, val_mask, val2 = 0;
 
        val_mask = mask << shift;
        val = (ucontrol->value.integer.value[0] + min) & mask;
@@ -3343,7 +3143,7 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int regbase = mc->regbase;
        unsigned int regcount = mc->regcount;
-       unsigned int regwshift = codec->driver->reg_word_size * BITS_PER_BYTE;
+       unsigned int regwshift = codec->val_bytes * BITS_PER_BYTE;
        unsigned int regwmask = (1<<regwshift)-1;
        unsigned int invert = mc->invert;
        unsigned long mask = (1UL<<mc->nbits)-1;
@@ -3389,7 +3189,7 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int regbase = mc->regbase;
        unsigned int regcount = mc->regcount;
-       unsigned int regwshift = codec->driver->reg_word_size * BITS_PER_BYTE;
+       unsigned int regwshift = codec->val_bytes * BITS_PER_BYTE;
        unsigned int regwmask = (1<<regwshift)-1;
        unsigned int invert = mc->invert;
        unsigned long mask = (1UL<<mc->nbits)-1;
@@ -4084,6 +3884,7 @@ int snd_soc_register_component(struct device *dev,
        }
 
        cmpnt->ignore_pmdown_time = true;
+       cmpnt->registered_as_component = true;
 
        return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, NULL,
                                            dai_drv, num_dai, true);
@@ -4099,7 +3900,7 @@ void snd_soc_unregister_component(struct device *dev)
        struct snd_soc_component *cmpnt;
 
        list_for_each_entry(cmpnt, &component_list, list) {
-               if (dev == cmpnt->dev)
+               if (dev == cmpnt->dev && cmpnt->registered_as_component)
                        goto found;
        }
        return;
@@ -4125,6 +3926,8 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
 int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
                const struct snd_soc_platform_driver *platform_drv)
 {
+       int ret;
+
        /* create platform component name */
        platform->name = fmt_single_name(dev, &platform->id);
        if (platform->name == NULL)
@@ -4137,6 +3940,16 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform,
        platform->dapm.stream_event = platform_drv->stream_event;
        mutex_init(&platform->mutex);
 
+       /* register component */
+       ret = __snd_soc_register_component(dev, &platform->component,
+                                          &platform_drv->component_driver,
+                                          NULL, NULL, 0, false);
+       if (ret < 0) {
+               dev_err(platform->component.dev,
+                       "ASoC: Failed to register component: %d\n", ret);
+               return ret;
+       }
+
        mutex_lock(&client_mutex);
        list_add(&platform->list, &platform_list);
        mutex_unlock(&client_mutex);
@@ -4178,6 +3991,8 @@ EXPORT_SYMBOL_GPL(snd_soc_register_platform);
  */
 void snd_soc_remove_platform(struct snd_soc_platform *platform)
 {
+       snd_soc_unregister_component(platform->dev);
+
        mutex_lock(&client_mutex);
        list_del(&platform->list);
        mutex_unlock(&client_mutex);
@@ -4263,6 +4078,7 @@ int snd_soc_register_codec(struct device *dev,
                           int num_dai)
 {
        struct snd_soc_codec *codec;
+       struct regmap *regmap;
        int ret, i;
 
        dev_dbg(dev, "codec register %s\n", dev_name(dev));
@@ -4280,9 +4096,6 @@ int snd_soc_register_codec(struct device *dev,
 
        codec->write = codec_drv->write;
        codec->read = codec_drv->read;
-       codec->volatile_register = codec_drv->volatile_register;
-       codec->readable_register = codec_drv->readable_register;
-       codec->writable_register = codec_drv->writable_register;
        codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time;
        codec->dapm.bias_level = SND_SOC_BIAS_OFF;
        codec->dapm.dev = dev;
@@ -4292,8 +4105,26 @@ int snd_soc_register_codec(struct device *dev,
        codec->dev = dev;
        codec->driver = codec_drv;
        codec->num_dai = num_dai;
+       codec->val_bytes = codec_drv->reg_word_size;
        mutex_init(&codec->mutex);
 
+       if (!codec->write) {
+               if (codec_drv->get_regmap)
+                       regmap = codec_drv->get_regmap(dev);
+               else
+                       regmap = dev_get_regmap(dev, NULL);
+
+               if (regmap) {
+                       ret = snd_soc_codec_set_cache_io(codec, regmap);
+                       if (ret && ret != -ENOTSUPP) {
+                               dev_err(codec->dev,
+                                               "Failed to set cache I/O:%d\n",
+                                               ret);
+                               return ret;
+                       }
+               }
+       }
+
        for (i = 0; i < num_dai; i++) {
                fixup_codec_formats(&dai_drv[i].playback);
                fixup_codec_formats(&dai_drv[i].capture);
index 260efc8466fc352cf70d08663799c7fde0758a2e..dc0c09d2682a9c9ccd86caa8051107956f11935f 100644 (file)
 
 #include <trace/events/asoc.h>
 
+unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg)
+{
+       unsigned int ret;
+
+       ret = codec->read(codec, reg);
+       dev_dbg(codec->dev, "read %x => %x\n", reg, ret);
+       trace_snd_soc_reg_read(codec, reg, ret);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_read);
+
+int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
+       unsigned int val)
+{
+       dev_dbg(codec->dev, "write %x = %x\n", reg, val);
+       trace_snd_soc_reg_write(codec, reg, val);
+       return codec->write(codec, reg, val);
+}
+EXPORT_SYMBOL_GPL(snd_soc_write);
+
+/**
+ * snd_soc_update_bits - update codec register bits
+ * @codec: audio codec
+ * @reg: codec register
+ * @mask: register mask
+ * @value: new value
+ *
+ * Writes new register value.
+ *
+ * Returns 1 for change, 0 for no change, or negative error code.
+ */
+int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg,
+                               unsigned int mask, unsigned int value)
+{
+       bool change;
+       unsigned int old, new;
+       int ret;
+
+       if (codec->using_regmap) {
+               ret = regmap_update_bits_check(codec->control_data, reg,
+                                              mask, value, &change);
+       } else {
+               ret = snd_soc_read(codec, reg);
+               if (ret < 0)
+                       return ret;
+
+               old = ret;
+               new = (old & ~mask) | (value & mask);
+               change = old != new;
+               if (change)
+                       ret = snd_soc_write(codec, reg, new);
+       }
+
+       if (ret < 0)
+               return ret;
+
+       return change;
+}
+EXPORT_SYMBOL_GPL(snd_soc_update_bits);
+
+/**
+ * snd_soc_update_bits_locked - update codec register bits
+ * @codec: audio codec
+ * @reg: codec register
+ * @mask: register mask
+ * @value: new value
+ *
+ * Writes new register value, and takes the codec mutex.
+ *
+ * Returns 1 for change else 0.
+ */
+int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
+                              unsigned int reg, unsigned int mask,
+                              unsigned int value)
+{
+       int change;
+
+       mutex_lock(&codec->mutex);
+       change = snd_soc_update_bits(codec, reg, mask, value);
+       mutex_unlock(&codec->mutex);
+
+       return change;
+}
+EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked);
+
+/**
+ * snd_soc_test_bits - test register for change
+ * @codec: audio codec
+ * @reg: codec register
+ * @mask: register mask
+ * @value: new value
+ *
+ * Tests a register with a new value and checks if the new value is
+ * different from the old value.
+ *
+ * Returns 1 for change else 0.
+ */
+int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
+                               unsigned int mask, unsigned int value)
+{
+       int change;
+       unsigned int old, new;
+
+       old = snd_soc_read(codec, reg);
+       new = (old & ~mask) | value;
+       change = old != new;
+
+       return change;
+}
+EXPORT_SYMBOL_GPL(snd_soc_test_bits);
+
+int snd_soc_platform_read(struct snd_soc_platform *platform,
+                                       unsigned int reg)
+{
+       unsigned int ret;
+
+       if (!platform->driver->read) {
+               dev_err(platform->dev, "ASoC: platform has no read back\n");
+               return -1;
+       }
+
+       ret = platform->driver->read(platform, reg);
+       dev_dbg(platform->dev, "read %x => %x\n", reg, ret);
+       trace_snd_soc_preg_read(platform, reg, ret);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_platform_read);
+
+int snd_soc_platform_write(struct snd_soc_platform *platform,
+                                        unsigned int reg, unsigned int val)
+{
+       if (!platform->driver->write) {
+               dev_err(platform->dev, "ASoC: platform has no write back\n");
+               return -1;
+       }
+
+       dev_dbg(platform->dev, "write %x = %x\n", reg, val);
+       trace_snd_soc_preg_write(platform, reg, val);
+       return platform->driver->write(platform, reg, val);
+}
+EXPORT_SYMBOL_GPL(snd_soc_platform_write);
+
 #ifdef CONFIG_REGMAP
 static int hw_write(struct snd_soc_codec *codec, unsigned int reg,
                    unsigned int value)
@@ -60,14 +204,11 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
 {
        int ret;
 
-       /* Device has made its own regmap arrangements */
        if (!regmap)
-               codec->control_data = dev_get_regmap(codec->dev, NULL);
-       else
-               codec->control_data = regmap;
+               return -EINVAL;
 
-       if (IS_ERR(codec->control_data))
-               return PTR_ERR(codec->control_data);
+       /* Device has made its own regmap arrangements */
+       codec->control_data = regmap;
 
        codec->write = hw_write;
        codec->read = hw_read;
This page took 0.248156 seconds and 5 git commands to generate.