aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/twl4030.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-03-13 04:53:25 -0400
committerTakashi Iwai <tiwai@suse.de>2014-03-13 04:53:25 -0400
commit5fdb83f190ee2218d113a46b190b70aa1c979325 (patch)
treefbb95a73b111c2e4d0320393754c11a9ec026b39 /sound/soc/codecs/twl4030.c
parent4c16ecc4c0715e0b6b3c7b72976c05b0e212cd0f (diff)
parentdeeed33850c8a376addabbf971df433b2a1ba74c (diff)
Merge tag 'asoc-v3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v3.15 Quite a busy release for ASoC this time, more on janitorial work than exciting new features but welcome nontheless: - Lots of cleanups from Takashi for enumerations; the original API for these was error prone so he's refactored lots of code to use more modern APIs which avoid issues. - Elimination of the ASoC level wrappers for I2C and SPI moving us closer to converting to regmap completely and avoiding some randconfig hassle. - Provide both manually and transparently locked DAPM APIs rather than a mix of the two fixing some concurrency issues. - Start converting CODEC drivers to use separate bus interface drivers rather than having them all in one file helping avoid dependency issues. - DPCM support for Intel Haswell and Bay Trail platforms. - Lots of work on improvements for simple-card, DaVinci and the Renesas rcar drivers. - New drivers for Analog Devices ADAU1977, TI PCM512x and parts of the CSR SiRF SoC.
Diffstat (limited to 'sound/soc/codecs/twl4030.c')
-rw-r--r--sound/soc/codecs/twl4030.c101
1 files changed, 37 insertions, 64 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 00665ada23e2..975e0f760ac1 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -415,10 +415,9 @@ static const struct snd_kcontrol_new twl4030_dapm_carkitr_controls[] = {
415static const char *twl4030_handsfreel_texts[] = 415static const char *twl4030_handsfreel_texts[] =
416 {"Voice", "AudioL1", "AudioL2", "AudioR2"}; 416 {"Voice", "AudioL1", "AudioL2", "AudioR2"};
417 417
418static const struct soc_enum twl4030_handsfreel_enum = 418static SOC_ENUM_SINGLE_DECL(twl4030_handsfreel_enum,
419 SOC_ENUM_SINGLE(TWL4030_REG_HFL_CTL, 0, 419 TWL4030_REG_HFL_CTL, 0,
420 ARRAY_SIZE(twl4030_handsfreel_texts), 420 twl4030_handsfreel_texts);
421 twl4030_handsfreel_texts);
422 421
423static const struct snd_kcontrol_new twl4030_dapm_handsfreel_control = 422static const struct snd_kcontrol_new twl4030_dapm_handsfreel_control =
424SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum); 423SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum);
@@ -431,10 +430,9 @@ static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control =
431static const char *twl4030_handsfreer_texts[] = 430static const char *twl4030_handsfreer_texts[] =
432 {"Voice", "AudioR1", "AudioR2", "AudioL2"}; 431 {"Voice", "AudioR1", "AudioR2", "AudioL2"};
433 432
434static const struct soc_enum twl4030_handsfreer_enum = 433static SOC_ENUM_SINGLE_DECL(twl4030_handsfreer_enum,
435 SOC_ENUM_SINGLE(TWL4030_REG_HFR_CTL, 0, 434 TWL4030_REG_HFR_CTL, 0,
436 ARRAY_SIZE(twl4030_handsfreer_texts), 435 twl4030_handsfreer_texts);
437 twl4030_handsfreer_texts);
438 436
439static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control = 437static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control =
440SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); 438SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum);
@@ -448,10 +446,9 @@ static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control =
448static const char *twl4030_vibra_texts[] = 446static const char *twl4030_vibra_texts[] =
449 {"AudioL1", "AudioR1", "AudioL2", "AudioR2"}; 447 {"AudioL1", "AudioR1", "AudioL2", "AudioR2"};
450 448
451static const struct soc_enum twl4030_vibra_enum = 449static SOC_ENUM_SINGLE_DECL(twl4030_vibra_enum,
452 SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 2, 450 TWL4030_REG_VIBRA_CTL, 2,
453 ARRAY_SIZE(twl4030_vibra_texts), 451 twl4030_vibra_texts);
454 twl4030_vibra_texts);
455 452
456static const struct snd_kcontrol_new twl4030_dapm_vibra_control = 453static const struct snd_kcontrol_new twl4030_dapm_vibra_control =
457SOC_DAPM_ENUM("Route", twl4030_vibra_enum); 454SOC_DAPM_ENUM("Route", twl4030_vibra_enum);
@@ -460,10 +457,9 @@ SOC_DAPM_ENUM("Route", twl4030_vibra_enum);
460static const char *twl4030_vibrapath_texts[] = 457static const char *twl4030_vibrapath_texts[] =
461 {"Local vibrator", "Audio"}; 458 {"Local vibrator", "Audio"};
462 459
463static const struct soc_enum twl4030_vibrapath_enum = 460static SOC_ENUM_SINGLE_DECL(twl4030_vibrapath_enum,
464 SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 4, 461 TWL4030_REG_VIBRA_CTL, 4,
465 ARRAY_SIZE(twl4030_vibrapath_texts), 462 twl4030_vibrapath_texts);
466 twl4030_vibrapath_texts);
467 463
468static const struct snd_kcontrol_new twl4030_dapm_vibrapath_control = 464static const struct snd_kcontrol_new twl4030_dapm_vibrapath_control =
469SOC_DAPM_ENUM("Route", twl4030_vibrapath_enum); 465SOC_DAPM_ENUM("Route", twl4030_vibrapath_enum);
@@ -490,10 +486,9 @@ static const struct snd_kcontrol_new twl4030_dapm_analogrmic_controls[] = {
490static const char *twl4030_micpathtx1_texts[] = 486static const char *twl4030_micpathtx1_texts[] =
491 {"Analog", "Digimic0"}; 487 {"Analog", "Digimic0"};
492 488
493static const struct soc_enum twl4030_micpathtx1_enum = 489static SOC_ENUM_SINGLE_DECL(twl4030_micpathtx1_enum,
494 SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 0, 490 TWL4030_REG_ADCMICSEL, 0,
495 ARRAY_SIZE(twl4030_micpathtx1_texts), 491 twl4030_micpathtx1_texts);
496 twl4030_micpathtx1_texts);
497 492
498static const struct snd_kcontrol_new twl4030_dapm_micpathtx1_control = 493static const struct snd_kcontrol_new twl4030_dapm_micpathtx1_control =
499SOC_DAPM_ENUM("Route", twl4030_micpathtx1_enum); 494SOC_DAPM_ENUM("Route", twl4030_micpathtx1_enum);
@@ -502,10 +497,9 @@ SOC_DAPM_ENUM("Route", twl4030_micpathtx1_enum);
502static const char *twl4030_micpathtx2_texts[] = 497static const char *twl4030_micpathtx2_texts[] =
503 {"Analog", "Digimic1"}; 498 {"Analog", "Digimic1"};
504 499
505static const struct soc_enum twl4030_micpathtx2_enum = 500static SOC_ENUM_SINGLE_DECL(twl4030_micpathtx2_enum,
506 SOC_ENUM_SINGLE(TWL4030_REG_ADCMICSEL, 2, 501 TWL4030_REG_ADCMICSEL, 2,
507 ARRAY_SIZE(twl4030_micpathtx2_texts), 502 twl4030_micpathtx2_texts);
508 twl4030_micpathtx2_texts);
509 503
510static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control = 504static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control =
511SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum); 505SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum);
@@ -955,19 +949,15 @@ static const char *twl4030_op_modes_texts[] = {
955 "Option 2 (voice/audio)", "Option 1 (audio)" 949 "Option 2 (voice/audio)", "Option 1 (audio)"
956}; 950};
957 951
958static const struct soc_enum twl4030_op_modes_enum = 952static SOC_ENUM_SINGLE_DECL(twl4030_op_modes_enum,
959 SOC_ENUM_SINGLE(TWL4030_REG_CODEC_MODE, 0, 953 TWL4030_REG_CODEC_MODE, 0,
960 ARRAY_SIZE(twl4030_op_modes_texts), 954 twl4030_op_modes_texts);
961 twl4030_op_modes_texts);
962 955
963static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, 956static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
964 struct snd_ctl_elem_value *ucontrol) 957 struct snd_ctl_elem_value *ucontrol)
965{ 958{
966 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 959 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
967 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 960 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
968 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
969 unsigned short val;
970 unsigned short mask;
971 961
972 if (twl4030->configured) { 962 if (twl4030->configured) {
973 dev_err(codec->dev, 963 dev_err(codec->dev,
@@ -975,19 +965,7 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
975 return -EBUSY; 965 return -EBUSY;
976 } 966 }
977 967
978 if (ucontrol->value.enumerated.item[0] > e->max - 1) 968 return snd_soc_put_enum_double(kcontrol, ucontrol);
979 return -EINVAL;
980
981 val = ucontrol->value.enumerated.item[0] << e->shift_l;
982 mask = e->mask << e->shift_l;
983 if (e->shift_l != e->shift_r) {
984 if (ucontrol->value.enumerated.item[1] > e->max - 1)
985 return -EINVAL;
986 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
987 mask |= e->mask << e->shift_r;
988 }
989
990 return snd_soc_update_bits(codec, e->reg, mask, val);
991} 969}
992 970
993/* 971/*
@@ -1044,10 +1022,9 @@ static const char *twl4030_avadc_clk_priority_texts[] = {
1044 "Voice high priority", "HiFi high priority" 1022 "Voice high priority", "HiFi high priority"
1045}; 1023};
1046 1024
1047static const struct soc_enum twl4030_avadc_clk_priority_enum = 1025static SOC_ENUM_SINGLE_DECL(twl4030_avadc_clk_priority_enum,
1048 SOC_ENUM_SINGLE(TWL4030_REG_AVADC_CTL, 2, 1026 TWL4030_REG_AVADC_CTL, 2,
1049 ARRAY_SIZE(twl4030_avadc_clk_priority_texts), 1027 twl4030_avadc_clk_priority_texts);
1050 twl4030_avadc_clk_priority_texts);
1051 1028
1052static const char *twl4030_rampdelay_texts[] = { 1029static const char *twl4030_rampdelay_texts[] = {
1053 "27/20/14 ms", "55/40/27 ms", "109/81/55 ms", "218/161/109 ms", 1030 "27/20/14 ms", "55/40/27 ms", "109/81/55 ms", "218/161/109 ms",
@@ -1055,40 +1032,36 @@ static const char *twl4030_rampdelay_texts[] = {
1055 "3495/2581/1748 ms" 1032 "3495/2581/1748 ms"
1056}; 1033};
1057 1034
1058static const struct soc_enum twl4030_rampdelay_enum = 1035static SOC_ENUM_SINGLE_DECL(twl4030_rampdelay_enum,
1059 SOC_ENUM_SINGLE(TWL4030_REG_HS_POPN_SET, 2, 1036 TWL4030_REG_HS_POPN_SET, 2,
1060 ARRAY_SIZE(twl4030_rampdelay_texts), 1037 twl4030_rampdelay_texts);
1061 twl4030_rampdelay_texts);
1062 1038
1063/* Vibra H-bridge direction mode */ 1039/* Vibra H-bridge direction mode */
1064static const char *twl4030_vibradirmode_texts[] = { 1040static const char *twl4030_vibradirmode_texts[] = {
1065 "Vibra H-bridge direction", "Audio data MSB", 1041 "Vibra H-bridge direction", "Audio data MSB",
1066}; 1042};
1067 1043
1068static const struct soc_enum twl4030_vibradirmode_enum = 1044static SOC_ENUM_SINGLE_DECL(twl4030_vibradirmode_enum,
1069 SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 5, 1045 TWL4030_REG_VIBRA_CTL, 5,
1070 ARRAY_SIZE(twl4030_vibradirmode_texts), 1046 twl4030_vibradirmode_texts);
1071 twl4030_vibradirmode_texts);
1072 1047
1073/* Vibra H-bridge direction */ 1048/* Vibra H-bridge direction */
1074static const char *twl4030_vibradir_texts[] = { 1049static const char *twl4030_vibradir_texts[] = {
1075 "Positive polarity", "Negative polarity", 1050 "Positive polarity", "Negative polarity",
1076}; 1051};
1077 1052
1078static const struct soc_enum twl4030_vibradir_enum = 1053static SOC_ENUM_SINGLE_DECL(twl4030_vibradir_enum,
1079 SOC_ENUM_SINGLE(TWL4030_REG_VIBRA_CTL, 1, 1054 TWL4030_REG_VIBRA_CTL, 1,
1080 ARRAY_SIZE(twl4030_vibradir_texts), 1055 twl4030_vibradir_texts);
1081 twl4030_vibradir_texts);
1082 1056
1083/* Digimic Left and right swapping */ 1057/* Digimic Left and right swapping */
1084static const char *twl4030_digimicswap_texts[] = { 1058static const char *twl4030_digimicswap_texts[] = {
1085 "Not swapped", "Swapped", 1059 "Not swapped", "Swapped",
1086}; 1060};
1087 1061
1088static const struct soc_enum twl4030_digimicswap_enum = 1062static SOC_ENUM_SINGLE_DECL(twl4030_digimicswap_enum,
1089 SOC_ENUM_SINGLE(TWL4030_REG_MISC_SET_1, 0, 1063 TWL4030_REG_MISC_SET_1, 0,
1090 ARRAY_SIZE(twl4030_digimicswap_texts), 1064 twl4030_digimicswap_texts);
1091 twl4030_digimicswap_texts);
1092 1065
1093static const struct snd_kcontrol_new twl4030_snd_controls[] = { 1066static const struct snd_kcontrol_new twl4030_snd_controls[] = {
1094 /* Codec operation mode control */ 1067 /* Codec operation mode control */