aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/twl4030.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/twl4030.c')
-rw-r--r--sound/soc/codecs/twl4030.c69
1 files changed, 19 insertions, 50 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 71674bec9604..f798247ac1b2 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -863,34 +863,6 @@ static int digimic_event(struct snd_soc_dapm_widget *w,
863 * Inverting not going to help with these. 863 * Inverting not going to help with these.
864 * Custom volsw and volsw_2r get/put functions to handle these gain bits. 864 * Custom volsw and volsw_2r get/put functions to handle these gain bits.
865 */ 865 */
866#define SOC_DOUBLE_TLV_TWL4030(xname, xreg, shift_left, shift_right, xmax,\
867 xinvert, tlv_array) \
868{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
869 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
870 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
871 .tlv.p = (tlv_array), \
872 .info = snd_soc_info_volsw, \
873 .get = snd_soc_get_volsw_twl4030, \
874 .put = snd_soc_put_volsw_twl4030, \
875 .private_value = (unsigned long)&(struct soc_mixer_control) \
876 {.reg = xreg, .shift = shift_left, .rshift = shift_right,\
877 .max = xmax, .invert = xinvert} }
878#define SOC_DOUBLE_R_TLV_TWL4030(xname, reg_left, reg_right, xshift, xmax,\
879 xinvert, tlv_array) \
880{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
881 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
882 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
883 .tlv.p = (tlv_array), \
884 .info = snd_soc_info_volsw_2r, \
885 .get = snd_soc_get_volsw_r2_twl4030,\
886 .put = snd_soc_put_volsw_r2_twl4030, \
887 .private_value = (unsigned long)&(struct soc_mixer_control) \
888 {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
889 .rshift = xshift, .max = xmax, .invert = xinvert} }
890#define SOC_SINGLE_TLV_TWL4030(xname, xreg, xshift, xmax, xinvert, tlv_array) \
891 SOC_DOUBLE_TLV_TWL4030(xname, xreg, xshift, xshift, xmax, \
892 xinvert, tlv_array)
893
894static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol, 866static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol,
895 struct snd_ctl_elem_value *ucontrol) 867 struct snd_ctl_elem_value *ucontrol)
896{ 868{
@@ -1197,19 +1169,23 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = {
1197 TWL4030_REG_VDL_APGA_CTL, 1, 1, 0), 1169 TWL4030_REG_VDL_APGA_CTL, 1, 1, 0),
1198 1170
1199 /* Separate output gain controls */ 1171 /* Separate output gain controls */
1200 SOC_DOUBLE_R_TLV_TWL4030("PreDriv Playback Volume", 1172 SOC_DOUBLE_R_EXT_TLV("PreDriv Playback Volume",
1201 TWL4030_REG_PREDL_CTL, TWL4030_REG_PREDR_CTL, 1173 TWL4030_REG_PREDL_CTL, TWL4030_REG_PREDR_CTL,
1202 4, 3, 0, output_tvl), 1174 4, 3, 0, snd_soc_get_volsw_r2_twl4030,
1175 snd_soc_put_volsw_r2_twl4030, output_tvl),
1203 1176
1204 SOC_DOUBLE_TLV_TWL4030("Headset Playback Volume", 1177 SOC_DOUBLE_EXT_TLV("Headset Playback Volume",
1205 TWL4030_REG_HS_GAIN_SET, 0, 2, 3, 0, output_tvl), 1178 TWL4030_REG_HS_GAIN_SET, 0, 2, 3, 0, snd_soc_get_volsw_twl4030,
1179 snd_soc_put_volsw_twl4030, output_tvl),
1206 1180
1207 SOC_DOUBLE_R_TLV_TWL4030("Carkit Playback Volume", 1181 SOC_DOUBLE_R_EXT_TLV("Carkit Playback Volume",
1208 TWL4030_REG_PRECKL_CTL, TWL4030_REG_PRECKR_CTL, 1182 TWL4030_REG_PRECKL_CTL, TWL4030_REG_PRECKR_CTL,
1209 4, 3, 0, output_tvl), 1183 4, 3, 0, snd_soc_get_volsw_r2_twl4030,
1184 snd_soc_put_volsw_r2_twl4030, output_tvl),
1210 1185
1211 SOC_SINGLE_TLV_TWL4030("Earpiece Playback Volume", 1186 SOC_SINGLE_EXT_TLV("Earpiece Playback Volume",
1212 TWL4030_REG_EAR_CTL, 4, 3, 0, output_ear_tvl), 1187 TWL4030_REG_EAR_CTL, 4, 3, 0, snd_soc_get_volsw_twl4030,
1188 snd_soc_put_volsw_twl4030, output_ear_tvl),
1213 1189
1214 /* Common capture gain controls */ 1190 /* Common capture gain controls */
1215 SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume", 1191 SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume",
@@ -1633,17 +1609,6 @@ static const struct snd_soc_dapm_route intercon[] = {
1633 1609
1634}; 1610};
1635 1611
1636static int twl4030_add_widgets(struct snd_soc_codec *codec)
1637{
1638 struct snd_soc_dapm_context *dapm = &codec->dapm;
1639
1640 snd_soc_dapm_new_controls(dapm, twl4030_dapm_widgets,
1641 ARRAY_SIZE(twl4030_dapm_widgets));
1642 snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
1643
1644 return 0;
1645}
1646
1647static int twl4030_set_bias_level(struct snd_soc_codec *codec, 1612static int twl4030_set_bias_level(struct snd_soc_codec *codec,
1648 enum snd_soc_bias_level level) 1613 enum snd_soc_bias_level level)
1649{ 1614{
@@ -2265,9 +2230,6 @@ static int twl4030_soc_probe(struct snd_soc_codec *codec)
2265 2230
2266 twl4030_init_chip(codec); 2231 twl4030_init_chip(codec);
2267 2232
2268 snd_soc_add_controls(codec, twl4030_snd_controls,
2269 ARRAY_SIZE(twl4030_snd_controls));
2270 twl4030_add_widgets(codec);
2271 return 0; 2233 return 0;
2272} 2234}
2273 2235
@@ -2293,6 +2255,13 @@ static struct snd_soc_codec_driver soc_codec_dev_twl4030 = {
2293 .reg_cache_size = sizeof(twl4030_reg), 2255 .reg_cache_size = sizeof(twl4030_reg),
2294 .reg_word_size = sizeof(u8), 2256 .reg_word_size = sizeof(u8),
2295 .reg_cache_default = twl4030_reg, 2257 .reg_cache_default = twl4030_reg,
2258
2259 .controls = twl4030_snd_controls,
2260 .num_controls = ARRAY_SIZE(twl4030_snd_controls),
2261 .dapm_widgets = twl4030_dapm_widgets,
2262 .num_dapm_widgets = ARRAY_SIZE(twl4030_dapm_widgets),
2263 .dapm_routes = intercon,
2264 .num_dapm_routes = ARRAY_SIZE(intercon),
2296}; 2265};
2297 2266
2298static int __devinit twl4030_codec_probe(struct platform_device *pdev) 2267static int __devinit twl4030_codec_probe(struct platform_device *pdev)