aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/adau1373.c32
-rw-r--r--sound/soc/codecs/arizona.c71
-rw-r--r--sound/soc/codecs/da732x.h3
-rw-r--r--sound/soc/codecs/lm49453.c16
-rw-r--r--sound/soc/codecs/max98088.c2
-rw-r--r--sound/soc/codecs/max98090.c172
-rw-r--r--sound/soc/codecs/max98095.c4
-rw-r--r--sound/soc/codecs/mc13783.c22
-rw-r--r--sound/soc/codecs/rt5631.c75
-rw-r--r--sound/soc/codecs/rt5640.c75
-rw-r--r--sound/soc/codecs/ssm2518.c14
-rw-r--r--sound/soc/codecs/sta529.c2
-rw-r--r--sound/soc/codecs/twl4030.c17
-rw-r--r--sound/soc/codecs/wm8804.c2
-rw-r--r--sound/soc/codecs/wm8904.c4
-rw-r--r--sound/soc/codecs/wm8958-dsp2.c8
-rw-r--r--sound/soc/codecs/wm8978.c30
-rw-r--r--sound/soc/codecs/wm8983.c39
-rw-r--r--sound/soc/codecs/wm8985.c39
-rw-r--r--sound/soc/codecs/wm8994.c139
-rw-r--r--sound/soc/codecs/wm8995.c43
-rw-r--r--sound/soc/codecs/wm8996.c2
-rw-r--r--sound/soc/omap/ams-delta.c2
-rw-r--r--sound/soc/soc-core.c86
-rw-r--r--sound/soc/soc-dapm.c22
25 files changed, 478 insertions, 443 deletions
diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c
index eb836ed5271f..5765c224cd9a 100644
--- a/sound/soc/codecs/adau1373.c
+++ b/sound/soc/codecs/adau1373.c
@@ -345,15 +345,15 @@ static const char *adau1373_fdsp_sel_text[] = {
345 "Channel 5", 345 "Channel 5",
346}; 346};
347 347
348static const SOC_ENUM_SINGLE_DECL(adau1373_drc1_channel_enum, 348static SOC_ENUM_SINGLE_DECL(adau1373_drc1_channel_enum,
349 ADAU1373_FDSP_SEL1, 4, adau1373_fdsp_sel_text); 349 ADAU1373_FDSP_SEL1, 4, adau1373_fdsp_sel_text);
350static const SOC_ENUM_SINGLE_DECL(adau1373_drc2_channel_enum, 350static SOC_ENUM_SINGLE_DECL(adau1373_drc2_channel_enum,
351 ADAU1373_FDSP_SEL1, 0, adau1373_fdsp_sel_text); 351 ADAU1373_FDSP_SEL1, 0, adau1373_fdsp_sel_text);
352static const SOC_ENUM_SINGLE_DECL(adau1373_drc3_channel_enum, 352static SOC_ENUM_SINGLE_DECL(adau1373_drc3_channel_enum,
353 ADAU1373_FDSP_SEL2, 0, adau1373_fdsp_sel_text); 353 ADAU1373_FDSP_SEL2, 0, adau1373_fdsp_sel_text);
354static const SOC_ENUM_SINGLE_DECL(adau1373_hpf_channel_enum, 354static SOC_ENUM_SINGLE_DECL(adau1373_hpf_channel_enum,
355 ADAU1373_FDSP_SEL3, 0, adau1373_fdsp_sel_text); 355 ADAU1373_FDSP_SEL3, 0, adau1373_fdsp_sel_text);
356static const SOC_ENUM_SINGLE_DECL(adau1373_bass_channel_enum, 356static SOC_ENUM_SINGLE_DECL(adau1373_bass_channel_enum,
357 ADAU1373_FDSP_SEL4, 4, adau1373_fdsp_sel_text); 357 ADAU1373_FDSP_SEL4, 4, adau1373_fdsp_sel_text);
358 358
359static const char *adau1373_hpf_cutoff_text[] = { 359static const char *adau1373_hpf_cutoff_text[] = {
@@ -362,7 +362,7 @@ static const char *adau1373_hpf_cutoff_text[] = {
362 "800Hz", 362 "800Hz",
363}; 363};
364 364
365static const SOC_ENUM_SINGLE_DECL(adau1373_hpf_cutoff_enum, 365static SOC_ENUM_SINGLE_DECL(adau1373_hpf_cutoff_enum,
366 ADAU1373_HPF_CTRL, 3, adau1373_hpf_cutoff_text); 366 ADAU1373_HPF_CTRL, 3, adau1373_hpf_cutoff_text);
367 367
368static const char *adau1373_bass_lpf_cutoff_text[] = { 368static const char *adau1373_bass_lpf_cutoff_text[] = {
@@ -388,14 +388,14 @@ static const unsigned int adau1373_bass_tlv[] = {
388 5, 7, TLV_DB_SCALE_ITEM(1400, 150, 0), 388 5, 7, TLV_DB_SCALE_ITEM(1400, 150, 0),
389}; 389};
390 390
391static const SOC_ENUM_SINGLE_DECL(adau1373_bass_lpf_cutoff_enum, 391static SOC_ENUM_SINGLE_DECL(adau1373_bass_lpf_cutoff_enum,
392 ADAU1373_BASS1, 5, adau1373_bass_lpf_cutoff_text); 392 ADAU1373_BASS1, 5, adau1373_bass_lpf_cutoff_text);
393 393
394static const SOC_VALUE_ENUM_SINGLE_DECL(adau1373_bass_clip_level_enum, 394static SOC_VALUE_ENUM_SINGLE_DECL(adau1373_bass_clip_level_enum,
395 ADAU1373_BASS1, 2, 7, adau1373_bass_clip_level_text, 395 ADAU1373_BASS1, 2, 7, adau1373_bass_clip_level_text,
396 adau1373_bass_clip_level_values); 396 adau1373_bass_clip_level_values);
397 397
398static const SOC_ENUM_SINGLE_DECL(adau1373_bass_hpf_cutoff_enum, 398static SOC_ENUM_SINGLE_DECL(adau1373_bass_hpf_cutoff_enum,
399 ADAU1373_BASS1, 0, adau1373_bass_hpf_cutoff_text); 399 ADAU1373_BASS1, 0, adau1373_bass_hpf_cutoff_text);
400 400
401static const char *adau1373_3d_level_text[] = { 401static const char *adau1373_3d_level_text[] = {
@@ -409,9 +409,9 @@ static const char *adau1373_3d_cutoff_text[] = {
409 "0.16875 fs", "0.27083 fs" 409 "0.16875 fs", "0.27083 fs"
410}; 410};
411 411
412static const SOC_ENUM_SINGLE_DECL(adau1373_3d_level_enum, 412static SOC_ENUM_SINGLE_DECL(adau1373_3d_level_enum,
413 ADAU1373_3D_CTRL1, 4, adau1373_3d_level_text); 413 ADAU1373_3D_CTRL1, 4, adau1373_3d_level_text);
414static const SOC_ENUM_SINGLE_DECL(adau1373_3d_cutoff_enum, 414static SOC_ENUM_SINGLE_DECL(adau1373_3d_cutoff_enum,
415 ADAU1373_3D_CTRL1, 0, adau1373_3d_cutoff_text); 415 ADAU1373_3D_CTRL1, 0, adau1373_3d_cutoff_text);
416 416
417static const unsigned int adau1373_3d_tlv[] = { 417static const unsigned int adau1373_3d_tlv[] = {
@@ -427,11 +427,11 @@ static const char *adau1373_lr_mux_text[] = {
427 "Stereo", 427 "Stereo",
428}; 428};
429 429
430static const SOC_ENUM_SINGLE_DECL(adau1373_lineout1_lr_mux_enum, 430static SOC_ENUM_SINGLE_DECL(adau1373_lineout1_lr_mux_enum,
431 ADAU1373_OUTPUT_CTRL, 4, adau1373_lr_mux_text); 431 ADAU1373_OUTPUT_CTRL, 4, adau1373_lr_mux_text);
432static const SOC_ENUM_SINGLE_DECL(adau1373_lineout2_lr_mux_enum, 432static SOC_ENUM_SINGLE_DECL(adau1373_lineout2_lr_mux_enum,
433 ADAU1373_OUTPUT_CTRL, 6, adau1373_lr_mux_text); 433 ADAU1373_OUTPUT_CTRL, 6, adau1373_lr_mux_text);
434static const SOC_ENUM_SINGLE_DECL(adau1373_speaker_lr_mux_enum, 434static SOC_ENUM_SINGLE_DECL(adau1373_speaker_lr_mux_enum,
435 ADAU1373_LS_CTRL, 4, adau1373_lr_mux_text); 435 ADAU1373_LS_CTRL, 4, adau1373_lr_mux_text);
436 436
437static const struct snd_kcontrol_new adau1373_controls[] = { 437static const struct snd_kcontrol_new adau1373_controls[] = {
@@ -576,8 +576,8 @@ static const char *adau1373_decimator_text[] = {
576 "DMIC1", 576 "DMIC1",
577}; 577};
578 578
579static const struct soc_enum adau1373_decimator_enum = 579static SOC_ENUM_SINGLE_DECL(adau1373_decimator_enum,
580 SOC_ENUM_SINGLE(0, 0, 2, adau1373_decimator_text); 580 0, 0, adau1373_decimator_text);
581 581
582static const struct snd_kcontrol_new adau1373_decimator_mux = 582static const struct snd_kcontrol_new adau1373_decimator_mux =
583 SOC_DAPM_ENUM_VIRT("Decimator Mux", adau1373_decimator_enum); 583 SOC_DAPM_ENUM_VIRT("Decimator Mux", adau1373_decimator_enum);
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index e4295fee8f13..a32b84ac03f6 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -542,67 +542,76 @@ static const char *arizona_vol_ramp_text[] = {
542 "15ms/6dB", "30ms/6dB", 542 "15ms/6dB", "30ms/6dB",
543}; 543};
544 544
545const struct soc_enum arizona_in_vd_ramp = 545SOC_ENUM_SINGLE_DECL(arizona_in_vd_ramp,
546 SOC_ENUM_SINGLE(ARIZONA_INPUT_VOLUME_RAMP, 546 ARIZONA_INPUT_VOLUME_RAMP,
547 ARIZONA_IN_VD_RAMP_SHIFT, 7, arizona_vol_ramp_text); 547 ARIZONA_IN_VD_RAMP_SHIFT,
548 arizona_vol_ramp_text);
548EXPORT_SYMBOL_GPL(arizona_in_vd_ramp); 549EXPORT_SYMBOL_GPL(arizona_in_vd_ramp);
549 550
550const struct soc_enum arizona_in_vi_ramp = 551SOC_ENUM_SINGLE_DECL(arizona_in_vi_ramp,
551 SOC_ENUM_SINGLE(ARIZONA_INPUT_VOLUME_RAMP, 552 ARIZONA_INPUT_VOLUME_RAMP,
552 ARIZONA_IN_VI_RAMP_SHIFT, 7, arizona_vol_ramp_text); 553 ARIZONA_IN_VI_RAMP_SHIFT,
554 arizona_vol_ramp_text);
553EXPORT_SYMBOL_GPL(arizona_in_vi_ramp); 555EXPORT_SYMBOL_GPL(arizona_in_vi_ramp);
554 556
555const struct soc_enum arizona_out_vd_ramp = 557SOC_ENUM_SINGLE_DECL(arizona_out_vd_ramp,
556 SOC_ENUM_SINGLE(ARIZONA_OUTPUT_VOLUME_RAMP, 558 ARIZONA_OUTPUT_VOLUME_RAMP,
557 ARIZONA_OUT_VD_RAMP_SHIFT, 7, arizona_vol_ramp_text); 559 ARIZONA_OUT_VD_RAMP_SHIFT,
560 arizona_vol_ramp_text);
558EXPORT_SYMBOL_GPL(arizona_out_vd_ramp); 561EXPORT_SYMBOL_GPL(arizona_out_vd_ramp);
559 562
560const struct soc_enum arizona_out_vi_ramp = 563SOC_ENUM_SINGLE_DECL(arizona_out_vi_ramp,
561 SOC_ENUM_SINGLE(ARIZONA_OUTPUT_VOLUME_RAMP, 564 ARIZONA_OUTPUT_VOLUME_RAMP,
562 ARIZONA_OUT_VI_RAMP_SHIFT, 7, arizona_vol_ramp_text); 565 ARIZONA_OUT_VI_RAMP_SHIFT,
566 arizona_vol_ramp_text);
563EXPORT_SYMBOL_GPL(arizona_out_vi_ramp); 567EXPORT_SYMBOL_GPL(arizona_out_vi_ramp);
564 568
565static const char *arizona_lhpf_mode_text[] = { 569static const char *arizona_lhpf_mode_text[] = {
566 "Low-pass", "High-pass" 570 "Low-pass", "High-pass"
567}; 571};
568 572
569const struct soc_enum arizona_lhpf1_mode = 573SOC_ENUM_SINGLE_DECL(arizona_lhpf1_mode,
570 SOC_ENUM_SINGLE(ARIZONA_HPLPF1_1, ARIZONA_LHPF1_MODE_SHIFT, 2, 574 ARIZONA_HPLPF1_1,
571 arizona_lhpf_mode_text); 575 ARIZONA_LHPF1_MODE_SHIFT,
576 arizona_lhpf_mode_text);
572EXPORT_SYMBOL_GPL(arizona_lhpf1_mode); 577EXPORT_SYMBOL_GPL(arizona_lhpf1_mode);
573 578
574const struct soc_enum arizona_lhpf2_mode = 579SOC_ENUM_SINGLE_DECL(arizona_lhpf2_mode,
575 SOC_ENUM_SINGLE(ARIZONA_HPLPF2_1, ARIZONA_LHPF2_MODE_SHIFT, 2, 580 ARIZONA_HPLPF2_1,
576 arizona_lhpf_mode_text); 581 ARIZONA_LHPF2_MODE_SHIFT,
582 arizona_lhpf_mode_text);
577EXPORT_SYMBOL_GPL(arizona_lhpf2_mode); 583EXPORT_SYMBOL_GPL(arizona_lhpf2_mode);
578 584
579const struct soc_enum arizona_lhpf3_mode = 585SOC_ENUM_SINGLE_DECL(arizona_lhpf3_mode,
580 SOC_ENUM_SINGLE(ARIZONA_HPLPF3_1, ARIZONA_LHPF3_MODE_SHIFT, 2, 586 ARIZONA_HPLPF3_1,
581 arizona_lhpf_mode_text); 587 ARIZONA_LHPF3_MODE_SHIFT,
588 arizona_lhpf_mode_text);
582EXPORT_SYMBOL_GPL(arizona_lhpf3_mode); 589EXPORT_SYMBOL_GPL(arizona_lhpf3_mode);
583 590
584const struct soc_enum arizona_lhpf4_mode = 591SOC_ENUM_SINGLE_DECL(arizona_lhpf4_mode,
585 SOC_ENUM_SINGLE(ARIZONA_HPLPF4_1, ARIZONA_LHPF4_MODE_SHIFT, 2, 592 ARIZONA_HPLPF4_1,
586 arizona_lhpf_mode_text); 593 ARIZONA_LHPF4_MODE_SHIFT,
594 arizona_lhpf_mode_text);
587EXPORT_SYMBOL_GPL(arizona_lhpf4_mode); 595EXPORT_SYMBOL_GPL(arizona_lhpf4_mode);
588 596
589static const char *arizona_ng_hold_text[] = { 597static const char *arizona_ng_hold_text[] = {
590 "30ms", "120ms", "250ms", "500ms", 598 "30ms", "120ms", "250ms", "500ms",
591}; 599};
592 600
593const struct soc_enum arizona_ng_hold = 601SOC_ENUM_SINGLE_DECL(arizona_ng_hold,
594 SOC_ENUM_SINGLE(ARIZONA_NOISE_GATE_CONTROL, ARIZONA_NGATE_HOLD_SHIFT, 602 ARIZONA_NOISE_GATE_CONTROL,
595 4, arizona_ng_hold_text); 603 ARIZONA_NGATE_HOLD_SHIFT,
604 arizona_ng_hold_text);
596EXPORT_SYMBOL_GPL(arizona_ng_hold); 605EXPORT_SYMBOL_GPL(arizona_ng_hold);
597 606
598static const char * const arizona_in_hpf_cut_text[] = { 607static const char * const arizona_in_hpf_cut_text[] = {
599 "2.5Hz", "5Hz", "10Hz", "20Hz", "40Hz" 608 "2.5Hz", "5Hz", "10Hz", "20Hz", "40Hz"
600}; 609};
601 610
602const struct soc_enum arizona_in_hpf_cut_enum = 611SOC_ENUM_SINGLE_DECL(arizona_in_hpf_cut_enum,
603 SOC_ENUM_SINGLE(ARIZONA_HPF_CONTROL, ARIZONA_IN_HPF_CUT_SHIFT, 612 ARIZONA_HPF_CONTROL,
604 ARRAY_SIZE(arizona_in_hpf_cut_text), 613 ARIZONA_IN_HPF_CUT_SHIFT,
605 arizona_in_hpf_cut_text); 614 arizona_in_hpf_cut_text);
606EXPORT_SYMBOL_GPL(arizona_in_hpf_cut_enum); 615EXPORT_SYMBOL_GPL(arizona_in_hpf_cut_enum);
607 616
608static const char * const arizona_in_dmic_osr_text[] = { 617static const char * const arizona_in_dmic_osr_text[] = {
diff --git a/sound/soc/codecs/da732x.h b/sound/soc/codecs/da732x.h
index c8ce5475de22..1dceafeec415 100644
--- a/sound/soc/codecs/da732x.h
+++ b/sound/soc/codecs/da732x.h
@@ -113,9 +113,6 @@
113#define DA732X_EQ_OVERALL_VOL_DB_MIN -1800 113#define DA732X_EQ_OVERALL_VOL_DB_MIN -1800
114#define DA732X_EQ_OVERALL_VOL_DB_INC 600 114#define DA732X_EQ_OVERALL_VOL_DB_INC 600
115 115
116#define DA732X_SOC_ENUM_DOUBLE_R(xreg, xrreg, xmax, xtext) \
117 {.reg = xreg, .reg2 = xrreg, .max = xmax, .texts = xtext}
118
119enum da732x_sysctl { 116enum da732x_sysctl {
120 DA732X_SR_8KHZ = 0x1, 117 DA732X_SR_8KHZ = 0x1,
121 DA732X_SR_11_025KHZ = 0x2, 118 DA732X_SR_11_025KHZ = 0x2,
diff --git a/sound/soc/codecs/lm49453.c b/sound/soc/codecs/lm49453.c
index e19490cfb3a8..6b7fe5e54881 100644
--- a/sound/soc/codecs/lm49453.c
+++ b/sound/soc/codecs/lm49453.c
@@ -195,18 +195,18 @@ struct lm49453_priv {
195 195
196static const char *lm49453_mic2mode_text[] = {"Single Ended", "Differential"}; 196static const char *lm49453_mic2mode_text[] = {"Single Ended", "Differential"};
197 197
198static const SOC_ENUM_SINGLE_DECL(lm49453_mic2mode_enum, LM49453_P0_MICR_REG, 5, 198static SOC_ENUM_SINGLE_DECL(lm49453_mic2mode_enum, LM49453_P0_MICR_REG, 5,
199 lm49453_mic2mode_text); 199 lm49453_mic2mode_text);
200 200
201static const char *lm49453_dmic_cfg_text[] = {"DMICDAT1", "DMICDAT2"}; 201static const char *lm49453_dmic_cfg_text[] = {"DMICDAT1", "DMICDAT2"};
202 202
203static const SOC_ENUM_SINGLE_DECL(lm49453_dmic12_cfg_enum, 203static SOC_ENUM_SINGLE_DECL(lm49453_dmic12_cfg_enum,
204 LM49453_P0_DIGITAL_MIC1_CONFIG_REG, 204 LM49453_P0_DIGITAL_MIC1_CONFIG_REG, 7,
205 7, lm49453_dmic_cfg_text); 205 lm49453_dmic_cfg_text);
206 206
207static const SOC_ENUM_SINGLE_DECL(lm49453_dmic34_cfg_enum, 207static SOC_ENUM_SINGLE_DECL(lm49453_dmic34_cfg_enum,
208 LM49453_P0_DIGITAL_MIC2_CONFIG_REG, 208 LM49453_P0_DIGITAL_MIC2_CONFIG_REG, 7,
209 7, lm49453_dmic_cfg_text); 209 lm49453_dmic_cfg_text);
210 210
211/* MUX Controls */ 211/* MUX Controls */
212static const char *lm49453_adcl_mux_text[] = { "MIC1", "Aux_L" }; 212static const char *lm49453_adcl_mux_text[] = { "MIC1", "Aux_L" };
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index ee660e2d3df3..bb1ecfc4459b 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -1849,7 +1849,7 @@ static void max98088_handle_eq_pdata(struct snd_soc_codec *codec)
1849 1849
1850 /* Now point the soc_enum to .texts array items */ 1850 /* Now point the soc_enum to .texts array items */
1851 max98088->eq_enum.texts = max98088->eq_texts; 1851 max98088->eq_enum.texts = max98088->eq_texts;
1852 max98088->eq_enum.max = max98088->eq_textcnt; 1852 max98088->eq_enum.items = max98088->eq_textcnt;
1853 1853
1854 ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); 1854 ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls));
1855 if (ret != 0) 1855 if (ret != 0)
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 51f9b3d16b41..c7b9e901bdac 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -512,65 +512,75 @@ static const char *max98090_perf_pwr_text[] =
512static const char *max98090_pwr_perf_text[] = 512static const char *max98090_pwr_perf_text[] =
513 { "Low Power", "High Performance" }; 513 { "Low Power", "High Performance" };
514 514
515static const struct soc_enum max98090_vcmbandgap_enum = 515static SOC_ENUM_SINGLE_DECL(max98090_vcmbandgap_enum,
516 SOC_ENUM_SINGLE(M98090_REG_BIAS_CONTROL, M98090_VCM_MODE_SHIFT, 516 M98090_REG_BIAS_CONTROL,
517 ARRAY_SIZE(max98090_pwr_perf_text), max98090_pwr_perf_text); 517 M98090_VCM_MODE_SHIFT,
518 max98090_pwr_perf_text);
518 519
519static const char *max98090_osr128_text[] = { "64*fs", "128*fs" }; 520static const char *max98090_osr128_text[] = { "64*fs", "128*fs" };
520 521
521static const struct soc_enum max98090_osr128_enum = 522static SOC_ENUM_SINGLE_DECL(max98090_osr128_enum,
522 SOC_ENUM_SINGLE(M98090_REG_ADC_CONTROL, M98090_OSR128_SHIFT, 523 M98090_REG_ADC_CONTROL,
523 ARRAY_SIZE(max98090_osr128_text), max98090_osr128_text); 524 M98090_OSR128_SHIFT,
525 max98090_osr128_text);
524 526
525static const char *max98090_mode_text[] = { "Voice", "Music" }; 527static const char *max98090_mode_text[] = { "Voice", "Music" };
526 528
527static const struct soc_enum max98090_mode_enum = 529static SOC_ENUM_SINGLE_DECL(max98090_mode_enum,
528 SOC_ENUM_SINGLE(M98090_REG_FILTER_CONFIG, M98090_MODE_SHIFT, 530 M98090_REG_FILTER_CONFIG,
529 ARRAY_SIZE(max98090_mode_text), max98090_mode_text); 531 M98090_MODE_SHIFT,
532 max98090_mode_text);
530 533
531static const struct soc_enum max98090_filter_dmic34mode_enum = 534static SOC_ENUM_SINGLE_DECL(max98090_filter_dmic34mode_enum,
532 SOC_ENUM_SINGLE(M98090_REG_FILTER_CONFIG, 535 M98090_REG_FILTER_CONFIG,
533 M98090_FLT_DMIC34MODE_SHIFT, 536 M98090_FLT_DMIC34MODE_SHIFT,
534 ARRAY_SIZE(max98090_mode_text), max98090_mode_text); 537 max98090_mode_text);
535 538
536static const char *max98090_drcatk_text[] = 539static const char *max98090_drcatk_text[] =
537 { "0.5ms", "1ms", "5ms", "10ms", "25ms", "50ms", "100ms", "200ms" }; 540 { "0.5ms", "1ms", "5ms", "10ms", "25ms", "50ms", "100ms", "200ms" };
538 541
539static const struct soc_enum max98090_drcatk_enum = 542static SOC_ENUM_SINGLE_DECL(max98090_drcatk_enum,
540 SOC_ENUM_SINGLE(M98090_REG_DRC_TIMING, M98090_DRCATK_SHIFT, 543 M98090_REG_DRC_TIMING,
541 ARRAY_SIZE(max98090_drcatk_text), max98090_drcatk_text); 544 M98090_DRCATK_SHIFT,
545 max98090_drcatk_text);
542 546
543static const char *max98090_drcrls_text[] = 547static const char *max98090_drcrls_text[] =
544 { "8s", "4s", "2s", "1s", "0.5s", "0.25s", "0.125s", "0.0625s" }; 548 { "8s", "4s", "2s", "1s", "0.5s", "0.25s", "0.125s", "0.0625s" };
545 549
546static const struct soc_enum max98090_drcrls_enum = 550static SOC_ENUM_SINGLE_DECL(max98090_drcrls_enum,
547 SOC_ENUM_SINGLE(M98090_REG_DRC_TIMING, M98090_DRCRLS_SHIFT, 551 M98090_REG_DRC_TIMING,
548 ARRAY_SIZE(max98090_drcrls_text), max98090_drcrls_text); 552 M98090_DRCRLS_SHIFT,
553 max98090_drcrls_text);
549 554
550static const char *max98090_alccmp_text[] = 555static const char *max98090_alccmp_text[] =
551 { "1:1", "1:1.5", "1:2", "1:4", "1:INF" }; 556 { "1:1", "1:1.5", "1:2", "1:4", "1:INF" };
552 557
553static const struct soc_enum max98090_alccmp_enum = 558static SOC_ENUM_SINGLE_DECL(max98090_alccmp_enum,
554 SOC_ENUM_SINGLE(M98090_REG_DRC_COMPRESSOR, M98090_DRCCMP_SHIFT, 559 M98090_REG_DRC_COMPRESSOR,
555 ARRAY_SIZE(max98090_alccmp_text), max98090_alccmp_text); 560 M98090_DRCCMP_SHIFT,
561 max98090_alccmp_text);
556 562
557static const char *max98090_drcexp_text[] = { "1:1", "2:1", "3:1" }; 563static const char *max98090_drcexp_text[] = { "1:1", "2:1", "3:1" };
558 564
559static const struct soc_enum max98090_drcexp_enum = 565static SOC_ENUM_SINGLE_DECL(max98090_drcexp_enum,
560 SOC_ENUM_SINGLE(M98090_REG_DRC_EXPANDER, M98090_DRCEXP_SHIFT, 566 M98090_REG_DRC_EXPANDER,
561 ARRAY_SIZE(max98090_drcexp_text), max98090_drcexp_text); 567 M98090_DRCEXP_SHIFT,
568 max98090_drcexp_text);
562 569
563static const struct soc_enum max98090_dac_perfmode_enum = 570static SOC_ENUM_SINGLE_DECL(max98090_dac_perfmode_enum,
564 SOC_ENUM_SINGLE(M98090_REG_DAC_CONTROL, M98090_PERFMODE_SHIFT, 571 M98090_REG_DAC_CONTROL,
565 ARRAY_SIZE(max98090_perf_pwr_text), max98090_perf_pwr_text); 572 M98090_PERFMODE_SHIFT,
573 max98090_perf_pwr_text);
566 574
567static const struct soc_enum max98090_dachp_enum = 575static SOC_ENUM_SINGLE_DECL(max98090_dachp_enum,
568 SOC_ENUM_SINGLE(M98090_REG_DAC_CONTROL, M98090_DACHP_SHIFT, 576 M98090_REG_DAC_CONTROL,
569 ARRAY_SIZE(max98090_pwr_perf_text), max98090_pwr_perf_text); 577 M98090_DACHP_SHIFT,
578 max98090_pwr_perf_text);
570 579
571static const struct soc_enum max98090_adchp_enum = 580static SOC_ENUM_SINGLE_DECL(max98090_adchp_enum,
572 SOC_ENUM_SINGLE(M98090_REG_ADC_CONTROL, M98090_ADCHP_SHIFT, 581 M98090_REG_ADC_CONTROL,
573 ARRAY_SIZE(max98090_pwr_perf_text), max98090_pwr_perf_text); 582 M98090_ADCHP_SHIFT,
583 max98090_pwr_perf_text);
574 584
575static const struct snd_kcontrol_new max98090_snd_controls[] = { 585static const struct snd_kcontrol_new max98090_snd_controls[] = {
576 SOC_ENUM("MIC Bias VCM Bandgap", max98090_vcmbandgap_enum), 586 SOC_ENUM("MIC Bias VCM Bandgap", max98090_vcmbandgap_enum),
@@ -841,39 +851,42 @@ static int max98090_micinput_event(struct snd_soc_dapm_widget *w,
841 851
842static const char *mic1_mux_text[] = { "IN12", "IN56" }; 852static const char *mic1_mux_text[] = { "IN12", "IN56" };
843 853
844static const struct soc_enum mic1_mux_enum = 854static SOC_ENUM_SINGLE_DECL(mic1_mux_enum,
845 SOC_ENUM_SINGLE(M98090_REG_INPUT_MODE, M98090_EXTMIC1_SHIFT, 855 M98090_REG_INPUT_MODE,
846 ARRAY_SIZE(mic1_mux_text), mic1_mux_text); 856 M98090_EXTMIC1_SHIFT,
857 mic1_mux_text);
847 858
848static const struct snd_kcontrol_new max98090_mic1_mux = 859static const struct snd_kcontrol_new max98090_mic1_mux =
849 SOC_DAPM_ENUM("MIC1 Mux", mic1_mux_enum); 860 SOC_DAPM_ENUM("MIC1 Mux", mic1_mux_enum);
850 861
851static const char *mic2_mux_text[] = { "IN34", "IN56" }; 862static const char *mic2_mux_text[] = { "IN34", "IN56" };
852 863
853static const struct soc_enum mic2_mux_enum = 864static SOC_ENUM_SINGLE_DECL(mic2_mux_enum,
854 SOC_ENUM_SINGLE(M98090_REG_INPUT_MODE, M98090_EXTMIC2_SHIFT, 865 M98090_REG_INPUT_MODE,
855 ARRAY_SIZE(mic2_mux_text), mic2_mux_text); 866 M98090_EXTMIC2_SHIFT,
867 mic2_mux_text);
856 868
857static const struct snd_kcontrol_new max98090_mic2_mux = 869static const struct snd_kcontrol_new max98090_mic2_mux =
858 SOC_DAPM_ENUM("MIC2 Mux", mic2_mux_enum); 870 SOC_DAPM_ENUM("MIC2 Mux", mic2_mux_enum);
859 871
860static const char *dmic_mux_text[] = { "ADC", "DMIC" }; 872static const char *dmic_mux_text[] = { "ADC", "DMIC" };
861 873
862static const struct soc_enum dmic_mux_enum = 874static SOC_ENUM_SINGLE_EXT_DECL(dmic_mux_enum, dmic_mux_text);
863 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(dmic_mux_text), dmic_mux_text);
864 875
865static const struct snd_kcontrol_new max98090_dmic_mux = 876static const struct snd_kcontrol_new max98090_dmic_mux =
866 SOC_DAPM_ENUM_VIRT("DMIC Mux", dmic_mux_enum); 877 SOC_DAPM_ENUM_VIRT("DMIC Mux", dmic_mux_enum);
867 878
868static const char *max98090_micpre_text[] = { "Off", "On" }; 879static const char *max98090_micpre_text[] = { "Off", "On" };
869 880
870static const struct soc_enum max98090_pa1en_enum = 881static SOC_ENUM_SINGLE_DECL(max98090_pa1en_enum,
871 SOC_ENUM_SINGLE(M98090_REG_MIC1_INPUT_LEVEL, M98090_MIC_PA1EN_SHIFT, 882 M98090_REG_MIC1_INPUT_LEVEL,
872 ARRAY_SIZE(max98090_micpre_text), max98090_micpre_text); 883 M98090_MIC_PA1EN_SHIFT,
884 max98090_micpre_text);
873 885
874static const struct soc_enum max98090_pa2en_enum = 886static SOC_ENUM_SINGLE_DECL(max98090_pa2en_enum,
875 SOC_ENUM_SINGLE(M98090_REG_MIC2_INPUT_LEVEL, M98090_MIC_PA2EN_SHIFT, 887 M98090_REG_MIC2_INPUT_LEVEL,
876 ARRAY_SIZE(max98090_micpre_text), max98090_micpre_text); 888 M98090_MIC_PA2EN_SHIFT,
889 max98090_micpre_text);
877 890
878/* LINEA mixer switch */ 891/* LINEA mixer switch */
879static const struct snd_kcontrol_new max98090_linea_mixer_controls[] = { 892static const struct snd_kcontrol_new max98090_linea_mixer_controls[] = {
@@ -937,13 +950,15 @@ static const struct snd_kcontrol_new max98090_right_adc_mixer_controls[] = {
937 950
938static const char *lten_mux_text[] = { "Normal", "Loopthrough" }; 951static const char *lten_mux_text[] = { "Normal", "Loopthrough" };
939 952
940static const struct soc_enum ltenl_mux_enum = 953static SOC_ENUM_SINGLE_DECL(ltenl_mux_enum,
941 SOC_ENUM_SINGLE(M98090_REG_IO_CONFIGURATION, M98090_LTEN_SHIFT, 954 M98090_REG_IO_CONFIGURATION,
942 ARRAY_SIZE(lten_mux_text), lten_mux_text); 955 M98090_LTEN_SHIFT,
956 lten_mux_text);
943 957
944static const struct soc_enum ltenr_mux_enum = 958static SOC_ENUM_SINGLE_DECL(ltenr_mux_enum,
945 SOC_ENUM_SINGLE(M98090_REG_IO_CONFIGURATION, M98090_LTEN_SHIFT, 959 M98090_REG_IO_CONFIGURATION,
946 ARRAY_SIZE(lten_mux_text), lten_mux_text); 960 M98090_LTEN_SHIFT,
961 lten_mux_text);
947 962
948static const struct snd_kcontrol_new max98090_ltenl_mux = 963static const struct snd_kcontrol_new max98090_ltenl_mux =
949 SOC_DAPM_ENUM("LTENL Mux", ltenl_mux_enum); 964 SOC_DAPM_ENUM("LTENL Mux", ltenl_mux_enum);
@@ -953,13 +968,15 @@ static const struct snd_kcontrol_new max98090_ltenr_mux =
953 968
954static const char *lben_mux_text[] = { "Normal", "Loopback" }; 969static const char *lben_mux_text[] = { "Normal", "Loopback" };
955 970
956static const struct soc_enum lbenl_mux_enum = 971static SOC_ENUM_SINGLE_DECL(lbenl_mux_enum,
957 SOC_ENUM_SINGLE(M98090_REG_IO_CONFIGURATION, M98090_LBEN_SHIFT, 972 M98090_REG_IO_CONFIGURATION,
958 ARRAY_SIZE(lben_mux_text), lben_mux_text); 973 M98090_LBEN_SHIFT,
974 lben_mux_text);
959 975
960static const struct soc_enum lbenr_mux_enum = 976static SOC_ENUM_SINGLE_DECL(lbenr_mux_enum,
961 SOC_ENUM_SINGLE(M98090_REG_IO_CONFIGURATION, M98090_LBEN_SHIFT, 977 M98090_REG_IO_CONFIGURATION,
962 ARRAY_SIZE(lben_mux_text), lben_mux_text); 978 M98090_LBEN_SHIFT,
979 lben_mux_text);
963 980
964static const struct snd_kcontrol_new max98090_lbenl_mux = 981static const struct snd_kcontrol_new max98090_lbenl_mux =
965 SOC_DAPM_ENUM("LBENL Mux", lbenl_mux_enum); 982 SOC_DAPM_ENUM("LBENL Mux", lbenl_mux_enum);
@@ -971,13 +988,15 @@ static const char *stenl_mux_text[] = { "Normal", "Sidetone Left" };
971 988
972static const char *stenr_mux_text[] = { "Normal", "Sidetone Right" }; 989static const char *stenr_mux_text[] = { "Normal", "Sidetone Right" };
973 990
974static const struct soc_enum stenl_mux_enum = 991static SOC_ENUM_SINGLE_DECL(stenl_mux_enum,
975 SOC_ENUM_SINGLE(M98090_REG_ADC_SIDETONE, M98090_DSTSL_SHIFT, 992 M98090_REG_ADC_SIDETONE,
976 ARRAY_SIZE(stenl_mux_text), stenl_mux_text); 993 M98090_DSTSL_SHIFT,
994 stenl_mux_text);
977 995
978static const struct soc_enum stenr_mux_enum = 996static SOC_ENUM_SINGLE_DECL(stenr_mux_enum,
979 SOC_ENUM_SINGLE(M98090_REG_ADC_SIDETONE, M98090_DSTSR_SHIFT, 997 M98090_REG_ADC_SIDETONE,
980 ARRAY_SIZE(stenr_mux_text), stenr_mux_text); 998 M98090_DSTSR_SHIFT,
999 stenr_mux_text);
981 1000
982static const struct snd_kcontrol_new max98090_stenl_mux = 1001static const struct snd_kcontrol_new max98090_stenl_mux =
983 SOC_DAPM_ENUM("STENL Mux", stenl_mux_enum); 1002 SOC_DAPM_ENUM("STENL Mux", stenl_mux_enum);
@@ -1085,9 +1104,10 @@ static const struct snd_kcontrol_new max98090_right_rcv_mixer_controls[] = {
1085 1104
1086static const char *linmod_mux_text[] = { "Left Only", "Left and Right" }; 1105static const char *linmod_mux_text[] = { "Left Only", "Left and Right" };
1087 1106
1088static const struct soc_enum linmod_mux_enum = 1107static SOC_ENUM_SINGLE_DECL(linmod_mux_enum,
1089 SOC_ENUM_SINGLE(M98090_REG_LOUTR_MIXER, M98090_LINMOD_SHIFT, 1108 M98090_REG_LOUTR_MIXER,
1090 ARRAY_SIZE(linmod_mux_text), linmod_mux_text); 1109 M98090_LINMOD_SHIFT,
1110 linmod_mux_text);
1091 1111
1092static const struct snd_kcontrol_new max98090_linmod_mux = 1112static const struct snd_kcontrol_new max98090_linmod_mux =
1093 SOC_DAPM_ENUM("LINMOD Mux", linmod_mux_enum); 1113 SOC_DAPM_ENUM("LINMOD Mux", linmod_mux_enum);
@@ -1097,16 +1117,18 @@ static const char *mixhpsel_mux_text[] = { "DAC Only", "HP Mixer" };
1097/* 1117/*
1098 * This is a mux as it selects the HP output, but to DAPM it is a Mixer enable 1118 * This is a mux as it selects the HP output, but to DAPM it is a Mixer enable
1099 */ 1119 */
1100static const struct soc_enum mixhplsel_mux_enum = 1120static SOC_ENUM_SINGLE_DECL(mixhplsel_mux_enum,
1101 SOC_ENUM_SINGLE(M98090_REG_HP_CONTROL, M98090_MIXHPLSEL_SHIFT, 1121 M98090_REG_HP_CONTROL,
1102 ARRAY_SIZE(mixhpsel_mux_text), mixhpsel_mux_text); 1122 M98090_MIXHPLSEL_SHIFT,
1123 mixhpsel_mux_text);
1103 1124
1104static const struct snd_kcontrol_new max98090_mixhplsel_mux = 1125static const struct snd_kcontrol_new max98090_mixhplsel_mux =
1105 SOC_DAPM_ENUM("MIXHPLSEL Mux", mixhplsel_mux_enum); 1126 SOC_DAPM_ENUM("MIXHPLSEL Mux", mixhplsel_mux_enum);
1106 1127
1107static const struct soc_enum mixhprsel_mux_enum = 1128static SOC_ENUM_SINGLE_DECL(mixhprsel_mux_enum,
1108 SOC_ENUM_SINGLE(M98090_REG_HP_CONTROL, M98090_MIXHPRSEL_SHIFT, 1129 M98090_REG_HP_CONTROL,
1109 ARRAY_SIZE(mixhpsel_mux_text), mixhpsel_mux_text); 1130 M98090_MIXHPRSEL_SHIFT,
1131 mixhpsel_mux_text);
1110 1132
1111static const struct snd_kcontrol_new max98090_mixhprsel_mux = 1133static const struct snd_kcontrol_new max98090_mixhprsel_mux =
1112 SOC_DAPM_ENUM("MIXHPRSEL Mux", mixhprsel_mux_enum); 1134 SOC_DAPM_ENUM("MIXHPRSEL Mux", mixhprsel_mux_enum);
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index 3ba1170ebb53..5bce9cde4a6d 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -1861,7 +1861,7 @@ static void max98095_handle_eq_pdata(struct snd_soc_codec *codec)
1861 1861
1862 /* Now point the soc_enum to .texts array items */ 1862 /* Now point the soc_enum to .texts array items */
1863 max98095->eq_enum.texts = max98095->eq_texts; 1863 max98095->eq_enum.texts = max98095->eq_texts;
1864 max98095->eq_enum.max = max98095->eq_textcnt; 1864 max98095->eq_enum.items = max98095->eq_textcnt;
1865 1865
1866 ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); 1866 ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls));
1867 if (ret != 0) 1867 if (ret != 0)
@@ -2016,7 +2016,7 @@ static void max98095_handle_bq_pdata(struct snd_soc_codec *codec)
2016 2016
2017 /* Now point the soc_enum to .texts array items */ 2017 /* Now point the soc_enum to .texts array items */
2018 max98095->bq_enum.texts = max98095->bq_texts; 2018 max98095->bq_enum.texts = max98095->bq_texts;
2019 max98095->bq_enum.max = max98095->bq_textcnt; 2019 max98095->bq_enum.items = max98095->bq_textcnt;
2020 2020
2021 ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); 2021 ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls));
2022 if (ret != 0) 2022 if (ret != 0)
diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c
index 582c2bbd42cb..c605036cc0b0 100644
--- a/sound/soc/codecs/mc13783.c
+++ b/sound/soc/codecs/mc13783.c
@@ -408,8 +408,8 @@ static const char * const adcl_enum_text[] = {
408 "MC1L", "RXINL", 408 "MC1L", "RXINL",
409}; 409};
410 410
411static const struct soc_enum adcl_enum = 411static SOC_ENUM_SINGLE_DECL(adcl_enum,
412 SOC_ENUM_SINGLE(0, 0, ARRAY_SIZE(adcl_enum_text), adcl_enum_text); 412 0, 0, adcl_enum_text);
413 413
414static const struct snd_kcontrol_new left_input_mux = 414static const struct snd_kcontrol_new left_input_mux =
415 SOC_DAPM_ENUM_VIRT("Route", adcl_enum); 415 SOC_DAPM_ENUM_VIRT("Route", adcl_enum);
@@ -418,8 +418,8 @@ static const char * const adcr_enum_text[] = {
418 "MC1R", "MC2", "RXINR", "TXIN", 418 "MC1R", "MC2", "RXINR", "TXIN",
419}; 419};
420 420
421static const struct soc_enum adcr_enum = 421static SOC_ENUM_SINGLE_DECL(adcr_enum,
422 SOC_ENUM_SINGLE(0, 0, ARRAY_SIZE(adcr_enum_text), adcr_enum_text); 422 0, 0, adcr_enum_text);
423 423
424static const struct snd_kcontrol_new right_input_mux = 424static const struct snd_kcontrol_new right_input_mux =
425 SOC_DAPM_ENUM_VIRT("Route", adcr_enum); 425 SOC_DAPM_ENUM_VIRT("Route", adcr_enum);
@@ -430,8 +430,8 @@ static const struct snd_kcontrol_new samp_ctl =
430static const char * const speaker_amp_source_text[] = { 430static const char * const speaker_amp_source_text[] = {
431 "CODEC", "Right" 431 "CODEC", "Right"
432}; 432};
433static const SOC_ENUM_SINGLE_DECL(speaker_amp_source, MC13783_AUDIO_RX0, 4, 433static SOC_ENUM_SINGLE_DECL(speaker_amp_source, MC13783_AUDIO_RX0, 4,
434 speaker_amp_source_text); 434 speaker_amp_source_text);
435static const struct snd_kcontrol_new speaker_amp_source_mux = 435static const struct snd_kcontrol_new speaker_amp_source_mux =
436 SOC_DAPM_ENUM("Speaker Amp Source MUX", speaker_amp_source); 436 SOC_DAPM_ENUM("Speaker Amp Source MUX", speaker_amp_source);
437 437
@@ -439,8 +439,8 @@ static const char * const headset_amp_source_text[] = {
439 "CODEC", "Mixer" 439 "CODEC", "Mixer"
440}; 440};
441 441
442static const SOC_ENUM_SINGLE_DECL(headset_amp_source, MC13783_AUDIO_RX0, 11, 442static SOC_ENUM_SINGLE_DECL(headset_amp_source, MC13783_AUDIO_RX0, 11,
443 headset_amp_source_text); 443 headset_amp_source_text);
444static const struct snd_kcontrol_new headset_amp_source_mux = 444static const struct snd_kcontrol_new headset_amp_source_mux =
445 SOC_DAPM_ENUM("Headset Amp Source MUX", headset_amp_source); 445 SOC_DAPM_ENUM("Headset Amp Source MUX", headset_amp_source);
446 446
@@ -580,9 +580,9 @@ static struct snd_soc_dapm_route mc13783_routes[] = {
580static const char * const mc13783_3d_mixer[] = {"Stereo", "Phase Mix", 580static const char * const mc13783_3d_mixer[] = {"Stereo", "Phase Mix",
581 "Mono", "Mono Mix"}; 581 "Mono", "Mono Mix"};
582 582
583static const struct soc_enum mc13783_enum_3d_mixer = 583static SOC_ENUM_SINGLE_DECL(mc13783_enum_3d_mixer,
584 SOC_ENUM_SINGLE(MC13783_AUDIO_RX1, 16, ARRAY_SIZE(mc13783_3d_mixer), 584 MC13783_AUDIO_RX1, 16,
585 mc13783_3d_mixer); 585 mc13783_3d_mixer);
586 586
587static struct snd_kcontrol_new mc13783_control_list[] = { 587static struct snd_kcontrol_new mc13783_control_list[] = {
588 SOC_SINGLE("Loudspeaker enable", MC13783_AUDIO_RX0, 5, 1, 0), 588 SOC_SINGLE("Loudspeaker enable", MC13783_AUDIO_RX0, 5, 1, 0),
diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c
index 912c9cbc2724..ce199d375209 100644
--- a/sound/soc/codecs/rt5631.c
+++ b/sound/soc/codecs/rt5631.c
@@ -210,26 +210,22 @@ static int rt5631_dmic_put(struct snd_kcontrol *kcontrol,
210static const char *rt5631_input_mode[] = { 210static const char *rt5631_input_mode[] = {
211 "Single ended", "Differential"}; 211 "Single ended", "Differential"};
212 212
213static const SOC_ENUM_SINGLE_DECL( 213static SOC_ENUM_SINGLE_DECL(rt5631_mic1_mode_enum, RT5631_MIC_CTRL_1,
214 rt5631_mic1_mode_enum, RT5631_MIC_CTRL_1, 214 RT5631_MIC1_DIFF_INPUT_SHIFT, rt5631_input_mode);
215 RT5631_MIC1_DIFF_INPUT_SHIFT, rt5631_input_mode);
216 215
217static const SOC_ENUM_SINGLE_DECL( 216static SOC_ENUM_SINGLE_DECL(rt5631_mic2_mode_enum, RT5631_MIC_CTRL_1,
218 rt5631_mic2_mode_enum, RT5631_MIC_CTRL_1, 217 RT5631_MIC2_DIFF_INPUT_SHIFT, rt5631_input_mode);
219 RT5631_MIC2_DIFF_INPUT_SHIFT, rt5631_input_mode);
220 218
221/* MONO Input Type */ 219/* MONO Input Type */
222static const SOC_ENUM_SINGLE_DECL( 220static SOC_ENUM_SINGLE_DECL(rt5631_monoin_mode_enum, RT5631_MONO_INPUT_VOL,
223 rt5631_monoin_mode_enum, RT5631_MONO_INPUT_VOL, 221 RT5631_MONO_DIFF_INPUT_SHIFT, rt5631_input_mode);
224 RT5631_MONO_DIFF_INPUT_SHIFT, rt5631_input_mode);
225 222
226/* SPK Ratio Gain Control */ 223/* SPK Ratio Gain Control */
227static const char *rt5631_spk_ratio[] = {"1.00x", "1.09x", "1.27x", "1.44x", 224static const char *rt5631_spk_ratio[] = {"1.00x", "1.09x", "1.27x", "1.44x",
228 "1.56x", "1.68x", "1.99x", "2.34x"}; 225 "1.56x", "1.68x", "1.99x", "2.34x"};
229 226
230static const SOC_ENUM_SINGLE_DECL( 227static SOC_ENUM_SINGLE_DECL(rt5631_spk_ratio_enum, RT5631_GEN_PUR_CTRL_REG,
231 rt5631_spk_ratio_enum, RT5631_GEN_PUR_CTRL_REG, 228 RT5631_SPK_AMP_RATIO_CTRL_SHIFT, rt5631_spk_ratio);
232 RT5631_SPK_AMP_RATIO_CTRL_SHIFT, rt5631_spk_ratio);
233 229
234static const struct snd_kcontrol_new rt5631_snd_controls[] = { 230static const struct snd_kcontrol_new rt5631_snd_controls[] = {
235 /* MIC */ 231 /* MIC */
@@ -759,9 +755,8 @@ static const struct snd_kcontrol_new rt5631_monomix_mixer_controls[] = {
759/* Left SPK Volume Input */ 755/* Left SPK Volume Input */
760static const char *rt5631_spkvoll_sel[] = {"Vmid", "SPKMIXL"}; 756static const char *rt5631_spkvoll_sel[] = {"Vmid", "SPKMIXL"};
761 757
762static const SOC_ENUM_SINGLE_DECL( 758static SOC_ENUM_SINGLE_DECL(rt5631_spkvoll_enum, RT5631_SPK_OUT_VOL,
763 rt5631_spkvoll_enum, RT5631_SPK_OUT_VOL, 759 RT5631_L_EN_SHIFT, rt5631_spkvoll_sel);
764 RT5631_L_EN_SHIFT, rt5631_spkvoll_sel);
765 760
766static const struct snd_kcontrol_new rt5631_spkvoll_mux_control = 761static const struct snd_kcontrol_new rt5631_spkvoll_mux_control =
767 SOC_DAPM_ENUM("Left SPKVOL SRC", rt5631_spkvoll_enum); 762 SOC_DAPM_ENUM("Left SPKVOL SRC", rt5631_spkvoll_enum);
@@ -769,9 +764,8 @@ static const struct snd_kcontrol_new rt5631_spkvoll_mux_control =
769/* Left HP Volume Input */ 764/* Left HP Volume Input */
770static const char *rt5631_hpvoll_sel[] = {"Vmid", "OUTMIXL"}; 765static const char *rt5631_hpvoll_sel[] = {"Vmid", "OUTMIXL"};
771 766
772static const SOC_ENUM_SINGLE_DECL( 767static SOC_ENUM_SINGLE_DECL(rt5631_hpvoll_enum, RT5631_HP_OUT_VOL,
773 rt5631_hpvoll_enum, RT5631_HP_OUT_VOL, 768 RT5631_L_EN_SHIFT, rt5631_hpvoll_sel);
774 RT5631_L_EN_SHIFT, rt5631_hpvoll_sel);
775 769
776static const struct snd_kcontrol_new rt5631_hpvoll_mux_control = 770static const struct snd_kcontrol_new rt5631_hpvoll_mux_control =
777 SOC_DAPM_ENUM("Left HPVOL SRC", rt5631_hpvoll_enum); 771 SOC_DAPM_ENUM("Left HPVOL SRC", rt5631_hpvoll_enum);
@@ -779,9 +773,8 @@ static const struct snd_kcontrol_new rt5631_hpvoll_mux_control =
779/* Left Out Volume Input */ 773/* Left Out Volume Input */
780static const char *rt5631_outvoll_sel[] = {"Vmid", "OUTMIXL"}; 774static const char *rt5631_outvoll_sel[] = {"Vmid", "OUTMIXL"};
781 775
782static const SOC_ENUM_SINGLE_DECL( 776static SOC_ENUM_SINGLE_DECL(rt5631_outvoll_enum, RT5631_MONO_AXO_1_2_VOL,
783 rt5631_outvoll_enum, RT5631_MONO_AXO_1_2_VOL, 777 RT5631_L_EN_SHIFT, rt5631_outvoll_sel);
784 RT5631_L_EN_SHIFT, rt5631_outvoll_sel);
785 778
786static const struct snd_kcontrol_new rt5631_outvoll_mux_control = 779static const struct snd_kcontrol_new rt5631_outvoll_mux_control =
787 SOC_DAPM_ENUM("Left OUTVOL SRC", rt5631_outvoll_enum); 780 SOC_DAPM_ENUM("Left OUTVOL SRC", rt5631_outvoll_enum);
@@ -789,9 +782,8 @@ static const struct snd_kcontrol_new rt5631_outvoll_mux_control =
789/* Right Out Volume Input */ 782/* Right Out Volume Input */
790static const char *rt5631_outvolr_sel[] = {"Vmid", "OUTMIXR"}; 783static const char *rt5631_outvolr_sel[] = {"Vmid", "OUTMIXR"};
791 784
792static const SOC_ENUM_SINGLE_DECL( 785static SOC_ENUM_SINGLE_DECL(rt5631_outvolr_enum, RT5631_MONO_AXO_1_2_VOL,
793 rt5631_outvolr_enum, RT5631_MONO_AXO_1_2_VOL, 786 RT5631_R_EN_SHIFT, rt5631_outvolr_sel);
794 RT5631_R_EN_SHIFT, rt5631_outvolr_sel);
795 787
796static const struct snd_kcontrol_new rt5631_outvolr_mux_control = 788static const struct snd_kcontrol_new rt5631_outvolr_mux_control =
797 SOC_DAPM_ENUM("Right OUTVOL SRC", rt5631_outvolr_enum); 789 SOC_DAPM_ENUM("Right OUTVOL SRC", rt5631_outvolr_enum);
@@ -799,9 +791,8 @@ static const struct snd_kcontrol_new rt5631_outvolr_mux_control =
799/* Right HP Volume Input */ 791/* Right HP Volume Input */
800static const char *rt5631_hpvolr_sel[] = {"Vmid", "OUTMIXR"}; 792static const char *rt5631_hpvolr_sel[] = {"Vmid", "OUTMIXR"};
801 793
802static const SOC_ENUM_SINGLE_DECL( 794static SOC_ENUM_SINGLE_DECL(rt5631_hpvolr_enum, RT5631_HP_OUT_VOL,
803 rt5631_hpvolr_enum, RT5631_HP_OUT_VOL, 795 RT5631_R_EN_SHIFT, rt5631_hpvolr_sel);
804 RT5631_R_EN_SHIFT, rt5631_hpvolr_sel);
805 796
806static const struct snd_kcontrol_new rt5631_hpvolr_mux_control = 797static const struct snd_kcontrol_new rt5631_hpvolr_mux_control =
807 SOC_DAPM_ENUM("Right HPVOL SRC", rt5631_hpvolr_enum); 798 SOC_DAPM_ENUM("Right HPVOL SRC", rt5631_hpvolr_enum);
@@ -809,9 +800,8 @@ static const struct snd_kcontrol_new rt5631_hpvolr_mux_control =
809/* Right SPK Volume Input */ 800/* Right SPK Volume Input */
810static const char *rt5631_spkvolr_sel[] = {"Vmid", "SPKMIXR"}; 801static const char *rt5631_spkvolr_sel[] = {"Vmid", "SPKMIXR"};
811 802
812static const SOC_ENUM_SINGLE_DECL( 803static SOC_ENUM_SINGLE_DECL(rt5631_spkvolr_enum, RT5631_SPK_OUT_VOL,
813 rt5631_spkvolr_enum, RT5631_SPK_OUT_VOL, 804 RT5631_R_EN_SHIFT, rt5631_spkvolr_sel);
814 RT5631_R_EN_SHIFT, rt5631_spkvolr_sel);
815 805
816static const struct snd_kcontrol_new rt5631_spkvolr_mux_control = 806static const struct snd_kcontrol_new rt5631_spkvolr_mux_control =
817 SOC_DAPM_ENUM("Right SPKVOL SRC", rt5631_spkvolr_enum); 807 SOC_DAPM_ENUM("Right SPKVOL SRC", rt5631_spkvolr_enum);
@@ -820,9 +810,8 @@ static const struct snd_kcontrol_new rt5631_spkvolr_mux_control =
820static const char *rt5631_spol_src_sel[] = { 810static const char *rt5631_spol_src_sel[] = {
821 "SPOLMIX", "MONOIN_RX", "VDAC", "DACL"}; 811 "SPOLMIX", "MONOIN_RX", "VDAC", "DACL"};
822 812
823static const SOC_ENUM_SINGLE_DECL( 813static SOC_ENUM_SINGLE_DECL(rt5631_spol_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
824 rt5631_spol_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL, 814 RT5631_SPK_L_MUX_SEL_SHIFT, rt5631_spol_src_sel);
825 RT5631_SPK_L_MUX_SEL_SHIFT, rt5631_spol_src_sel);
826 815
827static const struct snd_kcontrol_new rt5631_spol_mux_control = 816static const struct snd_kcontrol_new rt5631_spol_mux_control =
828 SOC_DAPM_ENUM("SPOL SRC", rt5631_spol_src_enum); 817 SOC_DAPM_ENUM("SPOL SRC", rt5631_spol_src_enum);
@@ -831,9 +820,8 @@ static const struct snd_kcontrol_new rt5631_spol_mux_control =
831static const char *rt5631_spor_src_sel[] = { 820static const char *rt5631_spor_src_sel[] = {
832 "SPORMIX", "MONOIN_RX", "VDAC", "DACR"}; 821 "SPORMIX", "MONOIN_RX", "VDAC", "DACR"};
833 822
834static const SOC_ENUM_SINGLE_DECL( 823static SOC_ENUM_SINGLE_DECL(rt5631_spor_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
835 rt5631_spor_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL, 824 RT5631_SPK_R_MUX_SEL_SHIFT, rt5631_spor_src_sel);
836 RT5631_SPK_R_MUX_SEL_SHIFT, rt5631_spor_src_sel);
837 825
838static const struct snd_kcontrol_new rt5631_spor_mux_control = 826static const struct snd_kcontrol_new rt5631_spor_mux_control =
839 SOC_DAPM_ENUM("SPOR SRC", rt5631_spor_src_enum); 827 SOC_DAPM_ENUM("SPOR SRC", rt5631_spor_src_enum);
@@ -841,9 +829,8 @@ static const struct snd_kcontrol_new rt5631_spor_mux_control =
841/* MONO Input */ 829/* MONO Input */
842static const char *rt5631_mono_src_sel[] = {"MONOMIX", "MONOIN_RX", "VDAC"}; 830static const char *rt5631_mono_src_sel[] = {"MONOMIX", "MONOIN_RX", "VDAC"};
843 831
844static const SOC_ENUM_SINGLE_DECL( 832static SOC_ENUM_SINGLE_DECL(rt5631_mono_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
845 rt5631_mono_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL, 833 RT5631_MONO_MUX_SEL_SHIFT, rt5631_mono_src_sel);
846 RT5631_MONO_MUX_SEL_SHIFT, rt5631_mono_src_sel);
847 834
848static const struct snd_kcontrol_new rt5631_mono_mux_control = 835static const struct snd_kcontrol_new rt5631_mono_mux_control =
849 SOC_DAPM_ENUM("MONO SRC", rt5631_mono_src_enum); 836 SOC_DAPM_ENUM("MONO SRC", rt5631_mono_src_enum);
@@ -851,9 +838,8 @@ static const struct snd_kcontrol_new rt5631_mono_mux_control =
851/* Left HPO Input */ 838/* Left HPO Input */
852static const char *rt5631_hpl_src_sel[] = {"Left HPVOL", "Left DAC"}; 839static const char *rt5631_hpl_src_sel[] = {"Left HPVOL", "Left DAC"};
853 840
854static const SOC_ENUM_SINGLE_DECL( 841static SOC_ENUM_SINGLE_DECL(rt5631_hpl_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
855 rt5631_hpl_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL, 842 RT5631_HP_L_MUX_SEL_SHIFT, rt5631_hpl_src_sel);
856 RT5631_HP_L_MUX_SEL_SHIFT, rt5631_hpl_src_sel);
857 843
858static const struct snd_kcontrol_new rt5631_hpl_mux_control = 844static const struct snd_kcontrol_new rt5631_hpl_mux_control =
859 SOC_DAPM_ENUM("HPL SRC", rt5631_hpl_src_enum); 845 SOC_DAPM_ENUM("HPL SRC", rt5631_hpl_src_enum);
@@ -861,9 +847,8 @@ static const struct snd_kcontrol_new rt5631_hpl_mux_control =
861/* Right HPO Input */ 847/* Right HPO Input */
862static const char *rt5631_hpr_src_sel[] = {"Right HPVOL", "Right DAC"}; 848static const char *rt5631_hpr_src_sel[] = {"Right HPVOL", "Right DAC"};
863 849
864static const SOC_ENUM_SINGLE_DECL( 850static SOC_ENUM_SINGLE_DECL(rt5631_hpr_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
865 rt5631_hpr_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL, 851 RT5631_HP_R_MUX_SEL_SHIFT, rt5631_hpr_src_sel);
866 RT5631_HP_R_MUX_SEL_SHIFT, rt5631_hpr_src_sel);
867 852
868static const struct snd_kcontrol_new rt5631_hpr_mux_control = 853static const struct snd_kcontrol_new rt5631_hpr_mux_control =
869 SOC_DAPM_ENUM("HPR SRC", rt5631_hpr_src_enum); 854 SOC_DAPM_ENUM("HPR SRC", rt5631_hpr_src_enum);
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index a3fb41179636..fe4a5c2d4845 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -361,25 +361,24 @@ static unsigned int bst_tlv[] = {
361static const char * const rt5640_data_select[] = { 361static const char * const rt5640_data_select[] = {
362 "Normal", "left copy to right", "right copy to left", "Swap"}; 362 "Normal", "left copy to right", "right copy to left", "Swap"};
363 363
364static const SOC_ENUM_SINGLE_DECL(rt5640_if1_dac_enum, RT5640_DIG_INF_DATA, 364static SOC_ENUM_SINGLE_DECL(rt5640_if1_dac_enum, RT5640_DIG_INF_DATA,
365 RT5640_IF1_DAC_SEL_SFT, rt5640_data_select); 365 RT5640_IF1_DAC_SEL_SFT, rt5640_data_select);
366 366
367static const SOC_ENUM_SINGLE_DECL(rt5640_if1_adc_enum, RT5640_DIG_INF_DATA, 367static SOC_ENUM_SINGLE_DECL(rt5640_if1_adc_enum, RT5640_DIG_INF_DATA,
368 RT5640_IF1_ADC_SEL_SFT, rt5640_data_select); 368 RT5640_IF1_ADC_SEL_SFT, rt5640_data_select);
369 369
370static const SOC_ENUM_SINGLE_DECL(rt5640_if2_dac_enum, RT5640_DIG_INF_DATA, 370static SOC_ENUM_SINGLE_DECL(rt5640_if2_dac_enum, RT5640_DIG_INF_DATA,
371 RT5640_IF2_DAC_SEL_SFT, rt5640_data_select); 371 RT5640_IF2_DAC_SEL_SFT, rt5640_data_select);
372 372
373static const SOC_ENUM_SINGLE_DECL(rt5640_if2_adc_enum, RT5640_DIG_INF_DATA, 373static SOC_ENUM_SINGLE_DECL(rt5640_if2_adc_enum, RT5640_DIG_INF_DATA,
374 RT5640_IF2_ADC_SEL_SFT, rt5640_data_select); 374 RT5640_IF2_ADC_SEL_SFT, rt5640_data_select);
375 375
376/* Class D speaker gain ratio */ 376/* Class D speaker gain ratio */
377static const char * const rt5640_clsd_spk_ratio[] = {"1.66x", "1.83x", "1.94x", 377static const char * const rt5640_clsd_spk_ratio[] = {"1.66x", "1.83x", "1.94x",
378 "2x", "2.11x", "2.22x", "2.33x", "2.44x", "2.55x", "2.66x", "2.77x"}; 378 "2x", "2.11x", "2.22x", "2.33x", "2.44x", "2.55x", "2.66x", "2.77x"};
379 379
380static const SOC_ENUM_SINGLE_DECL( 380static SOC_ENUM_SINGLE_DECL(rt5640_clsd_spk_ratio_enum, RT5640_CLS_D_OUT,
381 rt5640_clsd_spk_ratio_enum, RT5640_CLS_D_OUT, 381 RT5640_CLSD_RATIO_SFT, rt5640_clsd_spk_ratio);
382 RT5640_CLSD_RATIO_SFT, rt5640_clsd_spk_ratio);
383 382
384static const struct snd_kcontrol_new rt5640_snd_controls[] = { 383static const struct snd_kcontrol_new rt5640_snd_controls[] = {
385 /* Speaker Output Volume */ 384 /* Speaker Output Volume */
@@ -753,9 +752,8 @@ static const char * const rt5640_stereo_adc1_src[] = {
753 "DIG MIX", "ADC" 752 "DIG MIX", "ADC"
754}; 753};
755 754
756static const SOC_ENUM_SINGLE_DECL( 755static SOC_ENUM_SINGLE_DECL(rt5640_stereo_adc1_enum, RT5640_STO_ADC_MIXER,
757 rt5640_stereo_adc1_enum, RT5640_STO_ADC_MIXER, 756 RT5640_ADC_1_SRC_SFT, rt5640_stereo_adc1_src);
758 RT5640_ADC_1_SRC_SFT, rt5640_stereo_adc1_src);
759 757
760static const struct snd_kcontrol_new rt5640_sto_adc_1_mux = 758static const struct snd_kcontrol_new rt5640_sto_adc_1_mux =
761 SOC_DAPM_ENUM("Stereo ADC1 Mux", rt5640_stereo_adc1_enum); 759 SOC_DAPM_ENUM("Stereo ADC1 Mux", rt5640_stereo_adc1_enum);
@@ -764,9 +762,8 @@ static const char * const rt5640_stereo_adc2_src[] = {
764 "DMIC1", "DMIC2", "DIG MIX" 762 "DMIC1", "DMIC2", "DIG MIX"
765}; 763};
766 764
767static const SOC_ENUM_SINGLE_DECL( 765static SOC_ENUM_SINGLE_DECL(rt5640_stereo_adc2_enum, RT5640_STO_ADC_MIXER,
768 rt5640_stereo_adc2_enum, RT5640_STO_ADC_MIXER, 766 RT5640_ADC_2_SRC_SFT, rt5640_stereo_adc2_src);
769 RT5640_ADC_2_SRC_SFT, rt5640_stereo_adc2_src);
770 767
771static const struct snd_kcontrol_new rt5640_sto_adc_2_mux = 768static const struct snd_kcontrol_new rt5640_sto_adc_2_mux =
772 SOC_DAPM_ENUM("Stereo ADC2 Mux", rt5640_stereo_adc2_enum); 769 SOC_DAPM_ENUM("Stereo ADC2 Mux", rt5640_stereo_adc2_enum);
@@ -776,9 +773,8 @@ static const char * const rt5640_mono_adc_l1_src[] = {
776 "Mono DAC MIXL", "ADCL" 773 "Mono DAC MIXL", "ADCL"
777}; 774};
778 775
779static const SOC_ENUM_SINGLE_DECL( 776static SOC_ENUM_SINGLE_DECL(rt5640_mono_adc_l1_enum, RT5640_MONO_ADC_MIXER,
780 rt5640_mono_adc_l1_enum, RT5640_MONO_ADC_MIXER, 777 RT5640_MONO_ADC_L1_SRC_SFT, rt5640_mono_adc_l1_src);
781 RT5640_MONO_ADC_L1_SRC_SFT, rt5640_mono_adc_l1_src);
782 778
783static const struct snd_kcontrol_new rt5640_mono_adc_l1_mux = 779static const struct snd_kcontrol_new rt5640_mono_adc_l1_mux =
784 SOC_DAPM_ENUM("Mono ADC1 left source", rt5640_mono_adc_l1_enum); 780 SOC_DAPM_ENUM("Mono ADC1 left source", rt5640_mono_adc_l1_enum);
@@ -787,9 +783,8 @@ static const char * const rt5640_mono_adc_l2_src[] = {
787 "DMIC L1", "DMIC L2", "Mono DAC MIXL" 783 "DMIC L1", "DMIC L2", "Mono DAC MIXL"
788}; 784};
789 785
790static const SOC_ENUM_SINGLE_DECL( 786static SOC_ENUM_SINGLE_DECL(rt5640_mono_adc_l2_enum, RT5640_MONO_ADC_MIXER,
791 rt5640_mono_adc_l2_enum, RT5640_MONO_ADC_MIXER, 787 RT5640_MONO_ADC_L2_SRC_SFT, rt5640_mono_adc_l2_src);
792 RT5640_MONO_ADC_L2_SRC_SFT, rt5640_mono_adc_l2_src);
793 788
794static const struct snd_kcontrol_new rt5640_mono_adc_l2_mux = 789static const struct snd_kcontrol_new rt5640_mono_adc_l2_mux =
795 SOC_DAPM_ENUM("Mono ADC2 left source", rt5640_mono_adc_l2_enum); 790 SOC_DAPM_ENUM("Mono ADC2 left source", rt5640_mono_adc_l2_enum);
@@ -798,9 +793,8 @@ static const char * const rt5640_mono_adc_r1_src[] = {
798 "Mono DAC MIXR", "ADCR" 793 "Mono DAC MIXR", "ADCR"
799}; 794};
800 795
801static const SOC_ENUM_SINGLE_DECL( 796static SOC_ENUM_SINGLE_DECL(rt5640_mono_adc_r1_enum, RT5640_MONO_ADC_MIXER,
802 rt5640_mono_adc_r1_enum, RT5640_MONO_ADC_MIXER, 797 RT5640_MONO_ADC_R1_SRC_SFT, rt5640_mono_adc_r1_src);
803 RT5640_MONO_ADC_R1_SRC_SFT, rt5640_mono_adc_r1_src);
804 798
805static const struct snd_kcontrol_new rt5640_mono_adc_r1_mux = 799static const struct snd_kcontrol_new rt5640_mono_adc_r1_mux =
806 SOC_DAPM_ENUM("Mono ADC1 right source", rt5640_mono_adc_r1_enum); 800 SOC_DAPM_ENUM("Mono ADC1 right source", rt5640_mono_adc_r1_enum);
@@ -809,9 +803,8 @@ static const char * const rt5640_mono_adc_r2_src[] = {
809 "DMIC R1", "DMIC R2", "Mono DAC MIXR" 803 "DMIC R1", "DMIC R2", "Mono DAC MIXR"
810}; 804};
811 805
812static const SOC_ENUM_SINGLE_DECL( 806static SOC_ENUM_SINGLE_DECL(rt5640_mono_adc_r2_enum, RT5640_MONO_ADC_MIXER,
813 rt5640_mono_adc_r2_enum, RT5640_MONO_ADC_MIXER, 807 RT5640_MONO_ADC_R2_SRC_SFT, rt5640_mono_adc_r2_src);
814 RT5640_MONO_ADC_R2_SRC_SFT, rt5640_mono_adc_r2_src);
815 808
816static const struct snd_kcontrol_new rt5640_mono_adc_r2_mux = 809static const struct snd_kcontrol_new rt5640_mono_adc_r2_mux =
817 SOC_DAPM_ENUM("Mono ADC2 right source", rt5640_mono_adc_r2_enum); 810 SOC_DAPM_ENUM("Mono ADC2 right source", rt5640_mono_adc_r2_enum);
@@ -826,9 +819,9 @@ static int rt5640_dac_l2_values[] = {
826 3, 819 3,
827}; 820};
828 821
829static const SOC_VALUE_ENUM_SINGLE_DECL( 822static SOC_VALUE_ENUM_SINGLE_DECL(rt5640_dac_l2_enum,
830 rt5640_dac_l2_enum, RT5640_DSP_PATH2, RT5640_DAC_L2_SEL_SFT, 823 RT5640_DSP_PATH2, RT5640_DAC_L2_SEL_SFT,
831 0x3, rt5640_dac_l2_src, rt5640_dac_l2_values); 824 0x3, rt5640_dac_l2_src, rt5640_dac_l2_values);
832 825
833static const struct snd_kcontrol_new rt5640_dac_l2_mux = 826static const struct snd_kcontrol_new rt5640_dac_l2_mux =
834 SOC_DAPM_VALUE_ENUM("DAC2 left channel source", rt5640_dac_l2_enum); 827 SOC_DAPM_VALUE_ENUM("DAC2 left channel source", rt5640_dac_l2_enum);
@@ -841,9 +834,9 @@ static int rt5640_dac_r2_values[] = {
841 0, 834 0,
842}; 835};
843 836
844static const SOC_VALUE_ENUM_SINGLE_DECL( 837static SOC_VALUE_ENUM_SINGLE_DECL(rt5640_dac_r2_enum,
845 rt5640_dac_r2_enum, RT5640_DSP_PATH2, RT5640_DAC_R2_SEL_SFT, 838 RT5640_DSP_PATH2, RT5640_DAC_R2_SEL_SFT,
846 0x3, rt5640_dac_r2_src, rt5640_dac_r2_values); 839 0x3, rt5640_dac_r2_src, rt5640_dac_r2_values);
847 840
848static const struct snd_kcontrol_new rt5640_dac_r2_mux = 841static const struct snd_kcontrol_new rt5640_dac_r2_mux =
849 SOC_DAPM_ENUM("DAC2 right channel source", rt5640_dac_r2_enum); 842 SOC_DAPM_ENUM("DAC2 right channel source", rt5640_dac_r2_enum);
@@ -860,9 +853,10 @@ static int rt5640_dai_iis_map_values[] = {
860 7, 853 7,
861}; 854};
862 855
863static const SOC_VALUE_ENUM_SINGLE_DECL( 856static SOC_VALUE_ENUM_SINGLE_DECL(rt5640_dai_iis_map_enum,
864 rt5640_dai_iis_map_enum, RT5640_I2S1_SDP, RT5640_I2S_IF_SFT, 857 RT5640_I2S1_SDP, RT5640_I2S_IF_SFT,
865 0x7, rt5640_dai_iis_map, rt5640_dai_iis_map_values); 858 0x7, rt5640_dai_iis_map,
859 rt5640_dai_iis_map_values);
866 860
867static const struct snd_kcontrol_new rt5640_dai_mux = 861static const struct snd_kcontrol_new rt5640_dai_mux =
868 SOC_DAPM_VALUE_ENUM("DAI select", rt5640_dai_iis_map_enum); 862 SOC_DAPM_VALUE_ENUM("DAI select", rt5640_dai_iis_map_enum);
@@ -872,9 +866,8 @@ static const char * const rt5640_sdi_sel[] = {
872 "IF1", "IF2" 866 "IF1", "IF2"
873}; 867};
874 868
875static const SOC_ENUM_SINGLE_DECL( 869static SOC_ENUM_SINGLE_DECL(rt5640_sdi_sel_enum, RT5640_I2S2_SDP,
876 rt5640_sdi_sel_enum, RT5640_I2S2_SDP, 870 RT5640_I2S2_SDI_SFT, rt5640_sdi_sel);
877 RT5640_I2S2_SDI_SFT, rt5640_sdi_sel);
878 871
879static const struct snd_kcontrol_new rt5640_sdi_mux = 872static const struct snd_kcontrol_new rt5640_sdi_mux =
880 SOC_DAPM_ENUM("SDI select", rt5640_sdi_sel_enum); 873 SOC_DAPM_ENUM("SDI select", rt5640_sdi_sel_enum);
diff --git a/sound/soc/codecs/ssm2518.c b/sound/soc/codecs/ssm2518.c
index cc8debce752f..806f3d826ffb 100644
--- a/sound/soc/codecs/ssm2518.c
+++ b/sound/soc/codecs/ssm2518.c
@@ -169,19 +169,19 @@ static const char * const ssm2518_drc_hold_time_text[] = {
169 "682.24 ms", "1364 ms", 169 "682.24 ms", "1364 ms",
170}; 170};
171 171
172static const SOC_ENUM_SINGLE_DECL(ssm2518_drc_peak_detector_attack_time_enum, 172static SOC_ENUM_SINGLE_DECL(ssm2518_drc_peak_detector_attack_time_enum,
173 SSM2518_REG_DRC_2, 4, ssm2518_drc_peak_detector_attack_time_text); 173 SSM2518_REG_DRC_2, 4, ssm2518_drc_peak_detector_attack_time_text);
174static const SOC_ENUM_SINGLE_DECL(ssm2518_drc_peak_detector_release_time_enum, 174static SOC_ENUM_SINGLE_DECL(ssm2518_drc_peak_detector_release_time_enum,
175 SSM2518_REG_DRC_2, 0, ssm2518_drc_peak_detector_release_time_text); 175 SSM2518_REG_DRC_2, 0, ssm2518_drc_peak_detector_release_time_text);
176static const SOC_ENUM_SINGLE_DECL(ssm2518_drc_attack_time_enum, 176static SOC_ENUM_SINGLE_DECL(ssm2518_drc_attack_time_enum,
177 SSM2518_REG_DRC_6, 4, ssm2518_drc_peak_detector_attack_time_text); 177 SSM2518_REG_DRC_6, 4, ssm2518_drc_peak_detector_attack_time_text);
178static const SOC_ENUM_SINGLE_DECL(ssm2518_drc_decay_time_enum, 178static SOC_ENUM_SINGLE_DECL(ssm2518_drc_decay_time_enum,
179 SSM2518_REG_DRC_6, 0, ssm2518_drc_peak_detector_release_time_text); 179 SSM2518_REG_DRC_6, 0, ssm2518_drc_peak_detector_release_time_text);
180static const SOC_ENUM_SINGLE_DECL(ssm2518_drc_hold_time_enum, 180static SOC_ENUM_SINGLE_DECL(ssm2518_drc_hold_time_enum,
181 SSM2518_REG_DRC_7, 4, ssm2518_drc_hold_time_text); 181 SSM2518_REG_DRC_7, 4, ssm2518_drc_hold_time_text);
182static const SOC_ENUM_SINGLE_DECL(ssm2518_drc_noise_gate_hold_time_enum, 182static SOC_ENUM_SINGLE_DECL(ssm2518_drc_noise_gate_hold_time_enum,
183 SSM2518_REG_DRC_7, 0, ssm2518_drc_hold_time_text); 183 SSM2518_REG_DRC_7, 0, ssm2518_drc_hold_time_text);
184static const SOC_ENUM_SINGLE_DECL(ssm2518_drc_rms_averaging_time_enum, 184static SOC_ENUM_SINGLE_DECL(ssm2518_drc_rms_averaging_time_enum,
185 SSM2518_REG_DRC_9, 0, ssm2518_drc_peak_detector_release_time_text); 185 SSM2518_REG_DRC_9, 0, ssm2518_drc_peak_detector_release_time_text);
186 186
187static const struct snd_kcontrol_new ssm2518_snd_controls[] = { 187static const struct snd_kcontrol_new ssm2518_snd_controls[] = {
diff --git a/sound/soc/codecs/sta529.c b/sound/soc/codecs/sta529.c
index 40c07be9b581..f15b0e37274c 100644
--- a/sound/soc/codecs/sta529.c
+++ b/sound/soc/codecs/sta529.c
@@ -141,7 +141,7 @@ static const char *pwm_mode_text[] = { "Binary", "Headphone", "Ternary",
141 141
142static const DECLARE_TLV_DB_SCALE(out_gain_tlv, -9150, 50, 0); 142static const DECLARE_TLV_DB_SCALE(out_gain_tlv, -9150, 50, 0);
143static const DECLARE_TLV_DB_SCALE(master_vol_tlv, -12750, 50, 0); 143static const DECLARE_TLV_DB_SCALE(master_vol_tlv, -12750, 50, 0);
144static const SOC_ENUM_SINGLE_DECL(pwm_src, STA529_FFXCFG1, 4, pwm_mode_text); 144static SOC_ENUM_SINGLE_DECL(pwm_src, STA529_FFXCFG1, 4, pwm_mode_text);
145 145
146static const struct snd_kcontrol_new sta529_snd_controls[] = { 146static const struct snd_kcontrol_new sta529_snd_controls[] = {
147 SOC_DOUBLE_R_TLV("Digital Playback Volume", STA529_LVOL, STA529_RVOL, 0, 147 SOC_DOUBLE_R_TLV("Digital Playback Volume", STA529_LVOL, STA529_RVOL, 0,
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 00665ada23e2..682e4ac88939 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -965,9 +965,6 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
965{ 965{
966 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 966 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
967 struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); 967 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 968
972 if (twl4030->configured) { 969 if (twl4030->configured) {
973 dev_err(codec->dev, 970 dev_err(codec->dev,
@@ -975,19 +972,7 @@ static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
975 return -EBUSY; 972 return -EBUSY;
976 } 973 }
977 974
978 if (ucontrol->value.enumerated.item[0] > e->max - 1) 975 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} 976}
992 977
993/* 978/*
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index 9bc8206a6807..72d12bbe1a56 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -92,7 +92,7 @@ WM8804_REGULATOR_EVENT(0)
92WM8804_REGULATOR_EVENT(1) 92WM8804_REGULATOR_EVENT(1)
93 93
94static const char *txsrc_text[] = { "S/PDIF RX", "AIF" }; 94static const char *txsrc_text[] = { "S/PDIF RX", "AIF" };
95static const SOC_ENUM_SINGLE_EXT_DECL(txsrc, txsrc_text); 95static SOC_ENUM_SINGLE_EXT_DECL(txsrc, txsrc_text);
96 96
97static const struct snd_kcontrol_new wm8804_snd_controls[] = { 97static const struct snd_kcontrol_new wm8804_snd_controls[] = {
98 SOC_ENUM_EXT("Input Source", txsrc, txsrc_get, txsrc_put), 98 SOC_ENUM_EXT("Input Source", txsrc, txsrc_get, txsrc_put),
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c
index 53bbfac6a83a..b2664ec901b9 100644
--- a/sound/soc/codecs/wm8904.c
+++ b/sound/soc/codecs/wm8904.c
@@ -1981,7 +1981,7 @@ static void wm8904_handle_retune_mobile_pdata(struct snd_soc_codec *codec)
1981 dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", 1981 dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n",
1982 wm8904->num_retune_mobile_texts); 1982 wm8904->num_retune_mobile_texts);
1983 1983
1984 wm8904->retune_mobile_enum.max = wm8904->num_retune_mobile_texts; 1984 wm8904->retune_mobile_enum.items = wm8904->num_retune_mobile_texts;
1985 wm8904->retune_mobile_enum.texts = wm8904->retune_mobile_texts; 1985 wm8904->retune_mobile_enum.texts = wm8904->retune_mobile_texts;
1986 1986
1987 ret = snd_soc_add_codec_controls(codec, &control, 1); 1987 ret = snd_soc_add_codec_controls(codec, &control, 1);
@@ -2022,7 +2022,7 @@ static void wm8904_handle_pdata(struct snd_soc_codec *codec)
2022 for (i = 0; i < pdata->num_drc_cfgs; i++) 2022 for (i = 0; i < pdata->num_drc_cfgs; i++)
2023 wm8904->drc_texts[i] = pdata->drc_cfgs[i].name; 2023 wm8904->drc_texts[i] = pdata->drc_cfgs[i].name;
2024 2024
2025 wm8904->drc_enum.max = pdata->num_drc_cfgs; 2025 wm8904->drc_enum.items = pdata->num_drc_cfgs;
2026 wm8904->drc_enum.texts = wm8904->drc_texts; 2026 wm8904->drc_enum.texts = wm8904->drc_texts;
2027 2027
2028 ret = snd_soc_add_codec_controls(codec, &control, 1); 2028 ret = snd_soc_add_codec_controls(codec, &control, 1);
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
index b7488f190d2b..19743779bf4d 100644
--- a/sound/soc/codecs/wm8958-dsp2.c
+++ b/sound/soc/codecs/wm8958-dsp2.c
@@ -944,7 +944,7 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
944 for (i = 0; i < pdata->num_mbc_cfgs; i++) 944 for (i = 0; i < pdata->num_mbc_cfgs; i++)
945 wm8994->mbc_texts[i] = pdata->mbc_cfgs[i].name; 945 wm8994->mbc_texts[i] = pdata->mbc_cfgs[i].name;
946 946
947 wm8994->mbc_enum.max = pdata->num_mbc_cfgs; 947 wm8994->mbc_enum.items = pdata->num_mbc_cfgs;
948 wm8994->mbc_enum.texts = wm8994->mbc_texts; 948 wm8994->mbc_enum.texts = wm8994->mbc_texts;
949 949
950 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, 950 ret = snd_soc_add_codec_controls(wm8994->hubs.codec,
@@ -973,7 +973,7 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
973 for (i = 0; i < pdata->num_vss_cfgs; i++) 973 for (i = 0; i < pdata->num_vss_cfgs; i++)
974 wm8994->vss_texts[i] = pdata->vss_cfgs[i].name; 974 wm8994->vss_texts[i] = pdata->vss_cfgs[i].name;
975 975
976 wm8994->vss_enum.max = pdata->num_vss_cfgs; 976 wm8994->vss_enum.items = pdata->num_vss_cfgs;
977 wm8994->vss_enum.texts = wm8994->vss_texts; 977 wm8994->vss_enum.texts = wm8994->vss_texts;
978 978
979 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, 979 ret = snd_soc_add_codec_controls(wm8994->hubs.codec,
@@ -1003,7 +1003,7 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
1003 for (i = 0; i < pdata->num_vss_hpf_cfgs; i++) 1003 for (i = 0; i < pdata->num_vss_hpf_cfgs; i++)
1004 wm8994->vss_hpf_texts[i] = pdata->vss_hpf_cfgs[i].name; 1004 wm8994->vss_hpf_texts[i] = pdata->vss_hpf_cfgs[i].name;
1005 1005
1006 wm8994->vss_hpf_enum.max = pdata->num_vss_hpf_cfgs; 1006 wm8994->vss_hpf_enum.items = pdata->num_vss_hpf_cfgs;
1007 wm8994->vss_hpf_enum.texts = wm8994->vss_hpf_texts; 1007 wm8994->vss_hpf_enum.texts = wm8994->vss_hpf_texts;
1008 1008
1009 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, 1009 ret = snd_soc_add_codec_controls(wm8994->hubs.codec,
@@ -1034,7 +1034,7 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
1034 for (i = 0; i < pdata->num_enh_eq_cfgs; i++) 1034 for (i = 0; i < pdata->num_enh_eq_cfgs; i++)
1035 wm8994->enh_eq_texts[i] = pdata->enh_eq_cfgs[i].name; 1035 wm8994->enh_eq_texts[i] = pdata->enh_eq_cfgs[i].name;
1036 1036
1037 wm8994->enh_eq_enum.max = pdata->num_enh_eq_cfgs; 1037 wm8994->enh_eq_enum.items = pdata->num_enh_eq_cfgs;
1038 wm8994->enh_eq_enum.texts = wm8994->enh_eq_texts; 1038 wm8994->enh_eq_enum.texts = wm8994->enh_eq_texts;
1039 1039
1040 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, 1040 ret = snd_soc_add_codec_controls(wm8994->hubs.codec,
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index d8fc531c0e59..a9e2f465c331 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -117,21 +117,21 @@ static const char *wm8978_eq5[] = {"5.3kHz", "6.9kHz", "9kHz", "11.7kHz"};
117static const char *wm8978_alc3[] = {"ALC", "Limiter"}; 117static const char *wm8978_alc3[] = {"ALC", "Limiter"};
118static const char *wm8978_alc1[] = {"Off", "Right", "Left", "Both"}; 118static const char *wm8978_alc1[] = {"Off", "Right", "Left", "Both"};
119 119
120static const SOC_ENUM_SINGLE_DECL(adc_compand, WM8978_COMPANDING_CONTROL, 1, 120static SOC_ENUM_SINGLE_DECL(adc_compand, WM8978_COMPANDING_CONTROL, 1,
121 wm8978_companding); 121 wm8978_companding);
122static const SOC_ENUM_SINGLE_DECL(dac_compand, WM8978_COMPANDING_CONTROL, 3, 122static SOC_ENUM_SINGLE_DECL(dac_compand, WM8978_COMPANDING_CONTROL, 3,
123 wm8978_companding); 123 wm8978_companding);
124static const SOC_ENUM_SINGLE_DECL(eqmode, WM8978_EQ1, 8, wm8978_eqmode); 124static SOC_ENUM_SINGLE_DECL(eqmode, WM8978_EQ1, 8, wm8978_eqmode);
125static const SOC_ENUM_SINGLE_DECL(eq1, WM8978_EQ1, 5, wm8978_eq1); 125static SOC_ENUM_SINGLE_DECL(eq1, WM8978_EQ1, 5, wm8978_eq1);
126static const SOC_ENUM_SINGLE_DECL(eq2bw, WM8978_EQ2, 8, wm8978_bw); 126static SOC_ENUM_SINGLE_DECL(eq2bw, WM8978_EQ2, 8, wm8978_bw);
127static const SOC_ENUM_SINGLE_DECL(eq2, WM8978_EQ2, 5, wm8978_eq2); 127static SOC_ENUM_SINGLE_DECL(eq2, WM8978_EQ2, 5, wm8978_eq2);
128static const SOC_ENUM_SINGLE_DECL(eq3bw, WM8978_EQ3, 8, wm8978_bw); 128static SOC_ENUM_SINGLE_DECL(eq3bw, WM8978_EQ3, 8, wm8978_bw);
129static const SOC_ENUM_SINGLE_DECL(eq3, WM8978_EQ3, 5, wm8978_eq3); 129static SOC_ENUM_SINGLE_DECL(eq3, WM8978_EQ3, 5, wm8978_eq3);
130static const SOC_ENUM_SINGLE_DECL(eq4bw, WM8978_EQ4, 8, wm8978_bw); 130static SOC_ENUM_SINGLE_DECL(eq4bw, WM8978_EQ4, 8, wm8978_bw);
131static const SOC_ENUM_SINGLE_DECL(eq4, WM8978_EQ4, 5, wm8978_eq4); 131static SOC_ENUM_SINGLE_DECL(eq4, WM8978_EQ4, 5, wm8978_eq4);
132static const SOC_ENUM_SINGLE_DECL(eq5, WM8978_EQ5, 5, wm8978_eq5); 132static SOC_ENUM_SINGLE_DECL(eq5, WM8978_EQ5, 5, wm8978_eq5);
133static const SOC_ENUM_SINGLE_DECL(alc3, WM8978_ALC_CONTROL_3, 8, wm8978_alc3); 133static SOC_ENUM_SINGLE_DECL(alc3, WM8978_ALC_CONTROL_3, 8, wm8978_alc3);
134static const SOC_ENUM_SINGLE_DECL(alc1, WM8978_ALC_CONTROL_1, 7, wm8978_alc1); 134static SOC_ENUM_SINGLE_DECL(alc1, WM8978_ALC_CONTROL_1, 7, wm8978_alc1);
135 135
136static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1); 136static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);
137static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); 137static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c
index aa41ba0dfff4..770e5a705851 100644
--- a/sound/soc/codecs/wm8983.c
+++ b/sound/soc/codecs/wm8983.c
@@ -205,49 +205,44 @@ static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
205static const DECLARE_TLV_DB_SCALE(pga_boost_tlv, 0, 2000, 0); 205static const DECLARE_TLV_DB_SCALE(pga_boost_tlv, 0, 2000, 0);
206 206
207static const char *alc_sel_text[] = { "Off", "Right", "Left", "Stereo" }; 207static const char *alc_sel_text[] = { "Off", "Right", "Left", "Stereo" };
208static const SOC_ENUM_SINGLE_DECL(alc_sel, WM8983_ALC_CONTROL_1, 7, 208static SOC_ENUM_SINGLE_DECL(alc_sel, WM8983_ALC_CONTROL_1, 7, alc_sel_text);
209 alc_sel_text);
210 209
211static const char *alc_mode_text[] = { "ALC", "Limiter" }; 210static const char *alc_mode_text[] = { "ALC", "Limiter" };
212static const SOC_ENUM_SINGLE_DECL(alc_mode, WM8983_ALC_CONTROL_3, 8, 211static SOC_ENUM_SINGLE_DECL(alc_mode, WM8983_ALC_CONTROL_3, 8, alc_mode_text);
213 alc_mode_text);
214 212
215static const char *filter_mode_text[] = { "Audio", "Application" }; 213static const char *filter_mode_text[] = { "Audio", "Application" };
216static const SOC_ENUM_SINGLE_DECL(filter_mode, WM8983_ADC_CONTROL, 7, 214static SOC_ENUM_SINGLE_DECL(filter_mode, WM8983_ADC_CONTROL, 7,
217 filter_mode_text); 215 filter_mode_text);
218 216
219static const char *eq_bw_text[] = { "Narrow", "Wide" }; 217static const char *eq_bw_text[] = { "Narrow", "Wide" };
220static const char *eqmode_text[] = { "Capture", "Playback" }; 218static const char *eqmode_text[] = { "Capture", "Playback" };
221static const SOC_ENUM_SINGLE_EXT_DECL(eqmode, eqmode_text); 219static SOC_ENUM_SINGLE_EXT_DECL(eqmode, eqmode_text);
222 220
223static const char *eq1_cutoff_text[] = { 221static const char *eq1_cutoff_text[] = {
224 "80Hz", "105Hz", "135Hz", "175Hz" 222 "80Hz", "105Hz", "135Hz", "175Hz"
225}; 223};
226static const SOC_ENUM_SINGLE_DECL(eq1_cutoff, WM8983_EQ1_LOW_SHELF, 5, 224static SOC_ENUM_SINGLE_DECL(eq1_cutoff, WM8983_EQ1_LOW_SHELF, 5,
227 eq1_cutoff_text); 225 eq1_cutoff_text);
228static const char *eq2_cutoff_text[] = { 226static const char *eq2_cutoff_text[] = {
229 "230Hz", "300Hz", "385Hz", "500Hz" 227 "230Hz", "300Hz", "385Hz", "500Hz"
230}; 228};
231static const SOC_ENUM_SINGLE_DECL(eq2_bw, WM8983_EQ2_PEAK_1, 8, eq_bw_text); 229static SOC_ENUM_SINGLE_DECL(eq2_bw, WM8983_EQ2_PEAK_1, 8, eq_bw_text);
232static const SOC_ENUM_SINGLE_DECL(eq2_cutoff, WM8983_EQ2_PEAK_1, 5, 230static SOC_ENUM_SINGLE_DECL(eq2_cutoff, WM8983_EQ2_PEAK_1, 5, eq2_cutoff_text);
233 eq2_cutoff_text);
234static const char *eq3_cutoff_text[] = { 231static const char *eq3_cutoff_text[] = {
235 "650Hz", "850Hz", "1.1kHz", "1.4kHz" 232 "650Hz", "850Hz", "1.1kHz", "1.4kHz"
236}; 233};
237static const SOC_ENUM_SINGLE_DECL(eq3_bw, WM8983_EQ3_PEAK_2, 8, eq_bw_text); 234static SOC_ENUM_SINGLE_DECL(eq3_bw, WM8983_EQ3_PEAK_2, 8, eq_bw_text);
238static const SOC_ENUM_SINGLE_DECL(eq3_cutoff, WM8983_EQ3_PEAK_2, 5, 235static SOC_ENUM_SINGLE_DECL(eq3_cutoff, WM8983_EQ3_PEAK_2, 5, eq3_cutoff_text);
239 eq3_cutoff_text);
240static const char *eq4_cutoff_text[] = { 236static const char *eq4_cutoff_text[] = {
241 "1.8kHz", "2.4kHz", "3.2kHz", "4.1kHz" 237 "1.8kHz", "2.4kHz", "3.2kHz", "4.1kHz"
242}; 238};
243static const SOC_ENUM_SINGLE_DECL(eq4_bw, WM8983_EQ4_PEAK_3, 8, eq_bw_text); 239static SOC_ENUM_SINGLE_DECL(eq4_bw, WM8983_EQ4_PEAK_3, 8, eq_bw_text);
244static const SOC_ENUM_SINGLE_DECL(eq4_cutoff, WM8983_EQ4_PEAK_3, 5, 240static SOC_ENUM_SINGLE_DECL(eq4_cutoff, WM8983_EQ4_PEAK_3, 5, eq4_cutoff_text);
245 eq4_cutoff_text);
246static const char *eq5_cutoff_text[] = { 241static const char *eq5_cutoff_text[] = {
247 "5.3kHz", "6.9kHz", "9kHz", "11.7kHz" 242 "5.3kHz", "6.9kHz", "9kHz", "11.7kHz"
248}; 243};
249static const SOC_ENUM_SINGLE_DECL(eq5_cutoff, WM8983_EQ5_HIGH_SHELF, 5, 244static SOC_ENUM_SINGLE_DECL(eq5_cutoff, WM8983_EQ5_HIGH_SHELF, 5,
250 eq5_cutoff_text); 245 eq5_cutoff_text);
251 246
252static const char *depth_3d_text[] = { 247static const char *depth_3d_text[] = {
253 "Off", 248 "Off",
@@ -267,8 +262,8 @@ static const char *depth_3d_text[] = {
267 "93.3%", 262 "93.3%",
268 "100%" 263 "100%"
269}; 264};
270static const SOC_ENUM_SINGLE_DECL(depth_3d, WM8983_3D_CONTROL, 0, 265static SOC_ENUM_SINGLE_DECL(depth_3d, WM8983_3D_CONTROL, 0,
271 depth_3d_text); 266 depth_3d_text);
272 267
273static const struct snd_kcontrol_new wm8983_snd_controls[] = { 268static const struct snd_kcontrol_new wm8983_snd_controls[] = {
274 SOC_SINGLE("Digital Loopback Switch", WM8983_COMPANDING_CONTROL, 269 SOC_SINGLE("Digital Loopback Switch", WM8983_COMPANDING_CONTROL,
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c
index 271b517911a4..d786f2b39764 100644
--- a/sound/soc/codecs/wm8985.c
+++ b/sound/soc/codecs/wm8985.c
@@ -226,52 +226,48 @@ static const DECLARE_TLV_DB_SCALE(bypass_tlv, -1500, 300, 0);
226static const DECLARE_TLV_DB_SCALE(pga_boost_tlv, 0, 2000, 0); 226static const DECLARE_TLV_DB_SCALE(pga_boost_tlv, 0, 2000, 0);
227 227
228static const char *alc_sel_text[] = { "Off", "Right", "Left", "Stereo" }; 228static const char *alc_sel_text[] = { "Off", "Right", "Left", "Stereo" };
229static const SOC_ENUM_SINGLE_DECL(alc_sel, WM8985_ALC_CONTROL_1, 7, 229static SOC_ENUM_SINGLE_DECL(alc_sel, WM8985_ALC_CONTROL_1, 7, alc_sel_text);
230 alc_sel_text);
231 230
232static const char *alc_mode_text[] = { "ALC", "Limiter" }; 231static const char *alc_mode_text[] = { "ALC", "Limiter" };
233static const SOC_ENUM_SINGLE_DECL(alc_mode, WM8985_ALC_CONTROL_3, 8, 232static SOC_ENUM_SINGLE_DECL(alc_mode, WM8985_ALC_CONTROL_3, 8, alc_mode_text);
234 alc_mode_text);
235 233
236static const char *filter_mode_text[] = { "Audio", "Application" }; 234static const char *filter_mode_text[] = { "Audio", "Application" };
237static const SOC_ENUM_SINGLE_DECL(filter_mode, WM8985_ADC_CONTROL, 7, 235static SOC_ENUM_SINGLE_DECL(filter_mode, WM8985_ADC_CONTROL, 7,
238 filter_mode_text); 236 filter_mode_text);
239 237
240static const char *eq_bw_text[] = { "Narrow", "Wide" }; 238static const char *eq_bw_text[] = { "Narrow", "Wide" };
241static const char *eqmode_text[] = { "Capture", "Playback" }; 239static const char *eqmode_text[] = { "Capture", "Playback" };
242static const SOC_ENUM_SINGLE_EXT_DECL(eqmode, eqmode_text); 240static SOC_ENUM_SINGLE_EXT_DECL(eqmode, eqmode_text);
243 241
244static const char *eq1_cutoff_text[] = { 242static const char *eq1_cutoff_text[] = {
245 "80Hz", "105Hz", "135Hz", "175Hz" 243 "80Hz", "105Hz", "135Hz", "175Hz"
246}; 244};
247static const SOC_ENUM_SINGLE_DECL(eq1_cutoff, WM8985_EQ1_LOW_SHELF, 5, 245static SOC_ENUM_SINGLE_DECL(eq1_cutoff, WM8985_EQ1_LOW_SHELF, 5,
248 eq1_cutoff_text); 246 eq1_cutoff_text);
249static const char *eq2_cutoff_text[] = { 247static const char *eq2_cutoff_text[] = {
250 "230Hz", "300Hz", "385Hz", "500Hz" 248 "230Hz", "300Hz", "385Hz", "500Hz"
251}; 249};
252static const SOC_ENUM_SINGLE_DECL(eq2_bw, WM8985_EQ2_PEAK_1, 8, eq_bw_text); 250static SOC_ENUM_SINGLE_DECL(eq2_bw, WM8985_EQ2_PEAK_1, 8, eq_bw_text);
253static const SOC_ENUM_SINGLE_DECL(eq2_cutoff, WM8985_EQ2_PEAK_1, 5, 251static SOC_ENUM_SINGLE_DECL(eq2_cutoff, WM8985_EQ2_PEAK_1, 5, eq2_cutoff_text);
254 eq2_cutoff_text);
255static const char *eq3_cutoff_text[] = { 252static const char *eq3_cutoff_text[] = {
256 "650Hz", "850Hz", "1.1kHz", "1.4kHz" 253 "650Hz", "850Hz", "1.1kHz", "1.4kHz"
257}; 254};
258static const SOC_ENUM_SINGLE_DECL(eq3_bw, WM8985_EQ3_PEAK_2, 8, eq_bw_text); 255static SOC_ENUM_SINGLE_DECL(eq3_bw, WM8985_EQ3_PEAK_2, 8, eq_bw_text);
259static const SOC_ENUM_SINGLE_DECL(eq3_cutoff, WM8985_EQ3_PEAK_2, 5, 256static SOC_ENUM_SINGLE_DECL(eq3_cutoff, WM8985_EQ3_PEAK_2, 5,
260 eq3_cutoff_text); 257 eq3_cutoff_text);
261static const char *eq4_cutoff_text[] = { 258static const char *eq4_cutoff_text[] = {
262 "1.8kHz", "2.4kHz", "3.2kHz", "4.1kHz" 259 "1.8kHz", "2.4kHz", "3.2kHz", "4.1kHz"
263}; 260};
264static const SOC_ENUM_SINGLE_DECL(eq4_bw, WM8985_EQ4_PEAK_3, 8, eq_bw_text); 261static SOC_ENUM_SINGLE_DECL(eq4_bw, WM8985_EQ4_PEAK_3, 8, eq_bw_text);
265static const SOC_ENUM_SINGLE_DECL(eq4_cutoff, WM8985_EQ4_PEAK_3, 5, 262static SOC_ENUM_SINGLE_DECL(eq4_cutoff, WM8985_EQ4_PEAK_3, 5, eq4_cutoff_text);
266 eq4_cutoff_text);
267static const char *eq5_cutoff_text[] = { 263static const char *eq5_cutoff_text[] = {
268 "5.3kHz", "6.9kHz", "9kHz", "11.7kHz" 264 "5.3kHz", "6.9kHz", "9kHz", "11.7kHz"
269}; 265};
270static const SOC_ENUM_SINGLE_DECL(eq5_cutoff, WM8985_EQ5_HIGH_SHELF, 5, 266static SOC_ENUM_SINGLE_DECL(eq5_cutoff, WM8985_EQ5_HIGH_SHELF, 5,
271 eq5_cutoff_text); 267 eq5_cutoff_text);
272 268
273static const char *speaker_mode_text[] = { "Class A/B", "Class D" }; 269static const char *speaker_mode_text[] = { "Class A/B", "Class D" };
274static const SOC_ENUM_SINGLE_DECL(speaker_mode, 0x17, 8, speaker_mode_text); 270static SOC_ENUM_SINGLE_DECL(speaker_mode, 0x17, 8, speaker_mode_text);
275 271
276static const char *depth_3d_text[] = { 272static const char *depth_3d_text[] = {
277 "Off", 273 "Off",
@@ -291,8 +287,7 @@ static const char *depth_3d_text[] = {
291 "93.3%", 287 "93.3%",
292 "100%" 288 "100%"
293}; 289};
294static const SOC_ENUM_SINGLE_DECL(depth_3d, WM8985_3D_CONTROL, 0, 290static SOC_ENUM_SINGLE_DECL(depth_3d, WM8985_3D_CONTROL, 0, depth_3d_text);
295 depth_3d_text);
296 291
297static const struct snd_kcontrol_new wm8985_snd_controls[] = { 292static const struct snd_kcontrol_new wm8985_snd_controls[] = {
298 SOC_SINGLE("Digital Loopback Switch", WM8985_COMPANDING_CONTROL, 293 SOC_SINGLE("Digital Loopback Switch", WM8985_COMPANDING_CONTROL,
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index e8daf55d37e3..699b527e2a77 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -265,21 +265,21 @@ static const char *sidetone_hpf_text[] = {
265 "2.7kHz", "1.35kHz", "675Hz", "370Hz", "180Hz", "90Hz", "45Hz" 265 "2.7kHz", "1.35kHz", "675Hz", "370Hz", "180Hz", "90Hz", "45Hz"
266}; 266};
267 267
268static const struct soc_enum sidetone_hpf = 268static SOC_ENUM_SINGLE_DECL(sidetone_hpf,
269 SOC_ENUM_SINGLE(WM8994_SIDETONE, 7, 7, sidetone_hpf_text); 269 WM8994_SIDETONE, 7, sidetone_hpf_text);
270 270
271static const char *adc_hpf_text[] = { 271static const char *adc_hpf_text[] = {
272 "HiFi", "Voice 1", "Voice 2", "Voice 3" 272 "HiFi", "Voice 1", "Voice 2", "Voice 3"
273}; 273};
274 274
275static const struct soc_enum aif1adc1_hpf = 275static SOC_ENUM_SINGLE_DECL(aif1adc1_hpf,
276 SOC_ENUM_SINGLE(WM8994_AIF1_ADC1_FILTERS, 13, 4, adc_hpf_text); 276 WM8994_AIF1_ADC1_FILTERS, 13, adc_hpf_text);
277 277
278static const struct soc_enum aif1adc2_hpf = 278static SOC_ENUM_SINGLE_DECL(aif1adc2_hpf,
279 SOC_ENUM_SINGLE(WM8994_AIF1_ADC2_FILTERS, 13, 4, adc_hpf_text); 279 WM8994_AIF1_ADC2_FILTERS, 13, adc_hpf_text);
280 280
281static const struct soc_enum aif2adc_hpf = 281static SOC_ENUM_SINGLE_DECL(aif2adc_hpf,
282 SOC_ENUM_SINGLE(WM8994_AIF2_ADC_FILTERS, 13, 4, adc_hpf_text); 282 WM8994_AIF2_ADC_FILTERS, 13, adc_hpf_text);
283 283
284static const DECLARE_TLV_DB_SCALE(aif_tlv, 0, 600, 0); 284static const DECLARE_TLV_DB_SCALE(aif_tlv, 0, 600, 0);
285static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1); 285static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
@@ -501,39 +501,39 @@ static const char *aif_chan_src_text[] = {
501 "Left", "Right" 501 "Left", "Right"
502}; 502};
503 503
504static const struct soc_enum aif1adcl_src = 504static SOC_ENUM_SINGLE_DECL(aif1adcl_src,
505 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_1, 15, 2, aif_chan_src_text); 505 WM8994_AIF1_CONTROL_1, 15, aif_chan_src_text);
506 506
507static const struct soc_enum aif1adcr_src = 507static SOC_ENUM_SINGLE_DECL(aif1adcr_src,
508 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_1, 14, 2, aif_chan_src_text); 508 WM8994_AIF1_CONTROL_1, 14, aif_chan_src_text);
509 509
510static const struct soc_enum aif2adcl_src = 510static SOC_ENUM_SINGLE_DECL(aif2adcl_src,
511 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_1, 15, 2, aif_chan_src_text); 511 WM8994_AIF2_CONTROL_1, 15, aif_chan_src_text);
512 512
513static const struct soc_enum aif2adcr_src = 513static SOC_ENUM_SINGLE_DECL(aif2adcr_src,
514 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_1, 14, 2, aif_chan_src_text); 514 WM8994_AIF2_CONTROL_1, 14, aif_chan_src_text);
515 515
516static const struct soc_enum aif1dacl_src = 516static SOC_ENUM_SINGLE_DECL(aif1dacl_src,
517 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_2, 15, 2, aif_chan_src_text); 517 WM8994_AIF1_CONTROL_2, 15, aif_chan_src_text);
518 518
519static const struct soc_enum aif1dacr_src = 519static SOC_ENUM_SINGLE_DECL(aif1dacr_src,
520 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_2, 14, 2, aif_chan_src_text); 520 WM8994_AIF1_CONTROL_2, 14, aif_chan_src_text);
521 521
522static const struct soc_enum aif2dacl_src = 522static SOC_ENUM_SINGLE_DECL(aif2dacl_src,
523 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_2, 15, 2, aif_chan_src_text); 523 WM8994_AIF2_CONTROL_2, 15, aif_chan_src_text);
524 524
525static const struct soc_enum aif2dacr_src = 525static SOC_ENUM_SINGLE_DECL(aif2dacr_src,
526 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_2, 14, 2, aif_chan_src_text); 526 WM8994_AIF2_CONTROL_2, 14, aif_chan_src_text);
527 527
528static const char *osr_text[] = { 528static const char *osr_text[] = {
529 "Low Power", "High Performance", 529 "Low Power", "High Performance",
530}; 530};
531 531
532static const struct soc_enum dac_osr = 532static SOC_ENUM_SINGLE_DECL(dac_osr,
533 SOC_ENUM_SINGLE(WM8994_OVERSAMPLING, 0, 2, osr_text); 533 WM8994_OVERSAMPLING, 0, osr_text);
534 534
535static const struct soc_enum adc_osr = 535static SOC_ENUM_SINGLE_DECL(adc_osr,
536 SOC_ENUM_SINGLE(WM8994_OVERSAMPLING, 1, 2, osr_text); 536 WM8994_OVERSAMPLING, 1, osr_text);
537 537
538static const struct snd_kcontrol_new wm8994_snd_controls[] = { 538static const struct snd_kcontrol_new wm8994_snd_controls[] = {
539SOC_DOUBLE_R_TLV("AIF1ADC1 Volume", WM8994_AIF1_ADC1_LEFT_VOLUME, 539SOC_DOUBLE_R_TLV("AIF1ADC1 Volume", WM8994_AIF1_ADC1_LEFT_VOLUME,
@@ -690,17 +690,20 @@ static const char *wm8958_ng_text[] = {
690 "30ms", "125ms", "250ms", "500ms", 690 "30ms", "125ms", "250ms", "500ms",
691}; 691};
692 692
693static const struct soc_enum wm8958_aif1dac1_ng_hold = 693static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac1_ng_hold,
694 SOC_ENUM_SINGLE(WM8958_AIF1_DAC1_NOISE_GATE, 694 WM8958_AIF1_DAC1_NOISE_GATE,
695 WM8958_AIF1DAC1_NG_THR_SHIFT, 4, wm8958_ng_text); 695 WM8958_AIF1DAC1_NG_THR_SHIFT,
696 wm8958_ng_text);
696 697
697static const struct soc_enum wm8958_aif1dac2_ng_hold = 698static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac2_ng_hold,
698 SOC_ENUM_SINGLE(WM8958_AIF1_DAC2_NOISE_GATE, 699 WM8958_AIF1_DAC2_NOISE_GATE,
699 WM8958_AIF1DAC2_NG_THR_SHIFT, 4, wm8958_ng_text); 700 WM8958_AIF1DAC2_NG_THR_SHIFT,
701 wm8958_ng_text);
700 702
701static const struct soc_enum wm8958_aif2dac_ng_hold = 703static SOC_ENUM_SINGLE_DECL(wm8958_aif2dac_ng_hold,
702 SOC_ENUM_SINGLE(WM8958_AIF2_DAC_NOISE_GATE, 704 WM8958_AIF2_DAC_NOISE_GATE,
703 WM8958_AIF2DAC_NG_THR_SHIFT, 4, wm8958_ng_text); 705 WM8958_AIF2DAC_NG_THR_SHIFT,
706 wm8958_ng_text);
704 707
705static const struct snd_kcontrol_new wm8958_snd_controls[] = { 708static const struct snd_kcontrol_new wm8958_snd_controls[] = {
706SOC_SINGLE_TLV("AIF3 Boost Volume", WM8958_AIF3_CONTROL_2, 10, 3, 0, aif_tlv), 709SOC_SINGLE_TLV("AIF3 Boost Volume", WM8958_AIF3_CONTROL_2, 10, 3, 0, aif_tlv),
@@ -1341,8 +1344,8 @@ static const char *adc_mux_text[] = {
1341 "DMIC", 1344 "DMIC",
1342}; 1345};
1343 1346
1344static const struct soc_enum adc_enum = 1347static SOC_ENUM_SINGLE_DECL(adc_enum,
1345 SOC_ENUM_SINGLE(0, 0, 2, adc_mux_text); 1348 0, 0, adc_mux_text);
1346 1349
1347static const struct snd_kcontrol_new adcl_mux = 1350static const struct snd_kcontrol_new adcl_mux =
1348 SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum); 1351 SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum);
@@ -1478,14 +1481,14 @@ static const char *sidetone_text[] = {
1478 "ADC/DMIC1", "DMIC2", 1481 "ADC/DMIC1", "DMIC2",
1479}; 1482};
1480 1483
1481static const struct soc_enum sidetone1_enum = 1484static SOC_ENUM_SINGLE_DECL(sidetone1_enum,
1482 SOC_ENUM_SINGLE(WM8994_SIDETONE, 0, 2, sidetone_text); 1485 WM8994_SIDETONE, 0, sidetone_text);
1483 1486
1484static const struct snd_kcontrol_new sidetone1_mux = 1487static const struct snd_kcontrol_new sidetone1_mux =
1485 SOC_DAPM_ENUM("Left Sidetone Mux", sidetone1_enum); 1488 SOC_DAPM_ENUM("Left Sidetone Mux", sidetone1_enum);
1486 1489
1487static const struct soc_enum sidetone2_enum = 1490static SOC_ENUM_SINGLE_DECL(sidetone2_enum,
1488 SOC_ENUM_SINGLE(WM8994_SIDETONE, 1, 2, sidetone_text); 1491 WM8994_SIDETONE, 1, sidetone_text);
1489 1492
1490static const struct snd_kcontrol_new sidetone2_mux = 1493static const struct snd_kcontrol_new sidetone2_mux =
1491 SOC_DAPM_ENUM("Right Sidetone Mux", sidetone2_enum); 1494 SOC_DAPM_ENUM("Right Sidetone Mux", sidetone2_enum);
@@ -1498,22 +1501,24 @@ static const char *loopback_text[] = {
1498 "None", "ADCDAT", 1501 "None", "ADCDAT",
1499}; 1502};
1500 1503
1501static const struct soc_enum aif1_loopback_enum = 1504static SOC_ENUM_SINGLE_DECL(aif1_loopback_enum,
1502 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_2, WM8994_AIF1_LOOPBACK_SHIFT, 2, 1505 WM8994_AIF1_CONTROL_2,
1503 loopback_text); 1506 WM8994_AIF1_LOOPBACK_SHIFT,
1507 loopback_text);
1504 1508
1505static const struct snd_kcontrol_new aif1_loopback = 1509static const struct snd_kcontrol_new aif1_loopback =
1506 SOC_DAPM_ENUM("AIF1 Loopback", aif1_loopback_enum); 1510 SOC_DAPM_ENUM("AIF1 Loopback", aif1_loopback_enum);
1507 1511
1508static const struct soc_enum aif2_loopback_enum = 1512static SOC_ENUM_SINGLE_DECL(aif2_loopback_enum,
1509 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_2, WM8994_AIF2_LOOPBACK_SHIFT, 2, 1513 WM8994_AIF2_CONTROL_2,
1510 loopback_text); 1514 WM8994_AIF2_LOOPBACK_SHIFT,
1515 loopback_text);
1511 1516
1512static const struct snd_kcontrol_new aif2_loopback = 1517static const struct snd_kcontrol_new aif2_loopback =
1513 SOC_DAPM_ENUM("AIF2 Loopback", aif2_loopback_enum); 1518 SOC_DAPM_ENUM("AIF2 Loopback", aif2_loopback_enum);
1514 1519
1515static const struct soc_enum aif1dac_enum = 1520static SOC_ENUM_SINGLE_DECL(aif1dac_enum,
1516 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 0, 2, aif1dac_text); 1521 WM8994_POWER_MANAGEMENT_6, 0, aif1dac_text);
1517 1522
1518static const struct snd_kcontrol_new aif1dac_mux = 1523static const struct snd_kcontrol_new aif1dac_mux =
1519 SOC_DAPM_ENUM("AIF1DAC Mux", aif1dac_enum); 1524 SOC_DAPM_ENUM("AIF1DAC Mux", aif1dac_enum);
@@ -1522,8 +1527,8 @@ static const char *aif2dac_text[] = {
1522 "AIF2DACDAT", "AIF3DACDAT", 1527 "AIF2DACDAT", "AIF3DACDAT",
1523}; 1528};
1524 1529
1525static const struct soc_enum aif2dac_enum = 1530static SOC_ENUM_SINGLE_DECL(aif2dac_enum,
1526 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 1, 2, aif2dac_text); 1531 WM8994_POWER_MANAGEMENT_6, 1, aif2dac_text);
1527 1532
1528static const struct snd_kcontrol_new aif2dac_mux = 1533static const struct snd_kcontrol_new aif2dac_mux =
1529 SOC_DAPM_ENUM("AIF2DAC Mux", aif2dac_enum); 1534 SOC_DAPM_ENUM("AIF2DAC Mux", aif2dac_enum);
@@ -1532,8 +1537,8 @@ static const char *aif2adc_text[] = {
1532 "AIF2ADCDAT", "AIF3DACDAT", 1537 "AIF2ADCDAT", "AIF3DACDAT",
1533}; 1538};
1534 1539
1535static const struct soc_enum aif2adc_enum = 1540static SOC_ENUM_SINGLE_DECL(aif2adc_enum,
1536 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 2, 2, aif2adc_text); 1541 WM8994_POWER_MANAGEMENT_6, 2, aif2adc_text);
1537 1542
1538static const struct snd_kcontrol_new aif2adc_mux = 1543static const struct snd_kcontrol_new aif2adc_mux =
1539 SOC_DAPM_ENUM("AIF2ADC Mux", aif2adc_enum); 1544 SOC_DAPM_ENUM("AIF2ADC Mux", aif2adc_enum);
@@ -1542,14 +1547,14 @@ static const char *aif3adc_text[] = {
1542 "AIF1ADCDAT", "AIF2ADCDAT", "AIF2DACDAT", "Mono PCM", 1547 "AIF1ADCDAT", "AIF2ADCDAT", "AIF2DACDAT", "Mono PCM",
1543}; 1548};
1544 1549
1545static const struct soc_enum wm8994_aif3adc_enum = 1550static SOC_ENUM_SINGLE_DECL(wm8994_aif3adc_enum,
1546 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 3, 3, aif3adc_text); 1551 WM8994_POWER_MANAGEMENT_6, 3, aif3adc_text);
1547 1552
1548static const struct snd_kcontrol_new wm8994_aif3adc_mux = 1553static const struct snd_kcontrol_new wm8994_aif3adc_mux =
1549 SOC_DAPM_ENUM("AIF3ADC Mux", wm8994_aif3adc_enum); 1554 SOC_DAPM_ENUM("AIF3ADC Mux", wm8994_aif3adc_enum);
1550 1555
1551static const struct soc_enum wm8958_aif3adc_enum = 1556static SOC_ENUM_SINGLE_DECL(wm8958_aif3adc_enum,
1552 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 3, 4, aif3adc_text); 1557 WM8994_POWER_MANAGEMENT_6, 3, aif3adc_text);
1553 1558
1554static const struct snd_kcontrol_new wm8958_aif3adc_mux = 1559static const struct snd_kcontrol_new wm8958_aif3adc_mux =
1555 SOC_DAPM_ENUM("AIF3ADC Mux", wm8958_aif3adc_enum); 1560 SOC_DAPM_ENUM("AIF3ADC Mux", wm8958_aif3adc_enum);
@@ -1558,8 +1563,8 @@ static const char *mono_pcm_out_text[] = {
1558 "None", "AIF2ADCL", "AIF2ADCR", 1563 "None", "AIF2ADCL", "AIF2ADCR",
1559}; 1564};
1560 1565
1561static const struct soc_enum mono_pcm_out_enum = 1566static SOC_ENUM_SINGLE_DECL(mono_pcm_out_enum,
1562 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 9, 3, mono_pcm_out_text); 1567 WM8994_POWER_MANAGEMENT_6, 9, mono_pcm_out_text);
1563 1568
1564static const struct snd_kcontrol_new mono_pcm_out_mux = 1569static const struct snd_kcontrol_new mono_pcm_out_mux =
1565 SOC_DAPM_ENUM("Mono PCM Out Mux", mono_pcm_out_enum); 1570 SOC_DAPM_ENUM("Mono PCM Out Mux", mono_pcm_out_enum);
@@ -1569,14 +1574,14 @@ static const char *aif2dac_src_text[] = {
1569}; 1574};
1570 1575
1571/* Note that these two control shouldn't be simultaneously switched to AIF3 */ 1576/* Note that these two control shouldn't be simultaneously switched to AIF3 */
1572static const struct soc_enum aif2dacl_src_enum = 1577static SOC_ENUM_SINGLE_DECL(aif2dacl_src_enum,
1573 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 7, 2, aif2dac_src_text); 1578 WM8994_POWER_MANAGEMENT_6, 7, aif2dac_src_text);
1574 1579
1575static const struct snd_kcontrol_new aif2dacl_src_mux = 1580static const struct snd_kcontrol_new aif2dacl_src_mux =
1576 SOC_DAPM_ENUM("AIF2DACL Mux", aif2dacl_src_enum); 1581 SOC_DAPM_ENUM("AIF2DACL Mux", aif2dacl_src_enum);
1577 1582
1578static const struct soc_enum aif2dacr_src_enum = 1583static SOC_ENUM_SINGLE_DECL(aif2dacr_src_enum,
1579 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 8, 2, aif2dac_src_text); 1584 WM8994_POWER_MANAGEMENT_6, 8, aif2dac_src_text);
1580 1585
1581static const struct snd_kcontrol_new aif2dacr_src_mux = 1586static const struct snd_kcontrol_new aif2dacr_src_mux =
1582 SOC_DAPM_ENUM("AIF2DACR Mux", aif2dacr_src_enum); 1587 SOC_DAPM_ENUM("AIF2DACR Mux", aif2dacr_src_enum);
@@ -3246,7 +3251,7 @@ static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994)
3246 dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", 3251 dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n",
3247 wm8994->num_retune_mobile_texts); 3252 wm8994->num_retune_mobile_texts);
3248 3253
3249 wm8994->retune_mobile_enum.max = wm8994->num_retune_mobile_texts; 3254 wm8994->retune_mobile_enum.items = wm8994->num_retune_mobile_texts;
3250 wm8994->retune_mobile_enum.texts = wm8994->retune_mobile_texts; 3255 wm8994->retune_mobile_enum.texts = wm8994->retune_mobile_texts;
3251 3256
3252 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls, 3257 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls,
@@ -3302,7 +3307,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
3302 for (i = 0; i < pdata->num_drc_cfgs; i++) 3307 for (i = 0; i < pdata->num_drc_cfgs; i++)
3303 wm8994->drc_texts[i] = pdata->drc_cfgs[i].name; 3308 wm8994->drc_texts[i] = pdata->drc_cfgs[i].name;
3304 3309
3305 wm8994->drc_enum.max = pdata->num_drc_cfgs; 3310 wm8994->drc_enum.items = pdata->num_drc_cfgs;
3306 wm8994->drc_enum.texts = wm8994->drc_texts; 3311 wm8994->drc_enum.texts = wm8994->drc_texts;
3307 3312
3308 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls, 3313 ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls,
diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c
index 4300caff1783..33ff361250a8 100644
--- a/sound/soc/codecs/wm8995.c
+++ b/sound/soc/codecs/wm8995.c
@@ -423,24 +423,24 @@ static const char *in1l_text[] = {
423 "Differential", "Single-ended IN1LN", "Single-ended IN1LP" 423 "Differential", "Single-ended IN1LN", "Single-ended IN1LP"
424}; 424};
425 425
426static const SOC_ENUM_SINGLE_DECL(in1l_enum, WM8995_LEFT_LINE_INPUT_CONTROL, 426static SOC_ENUM_SINGLE_DECL(in1l_enum, WM8995_LEFT_LINE_INPUT_CONTROL,
427 2, in1l_text); 427 2, in1l_text);
428 428
429static const char *in1r_text[] = { 429static const char *in1r_text[] = {
430 "Differential", "Single-ended IN1RN", "Single-ended IN1RP" 430 "Differential", "Single-ended IN1RN", "Single-ended IN1RP"
431}; 431};
432 432
433static const SOC_ENUM_SINGLE_DECL(in1r_enum, WM8995_LEFT_LINE_INPUT_CONTROL, 433static SOC_ENUM_SINGLE_DECL(in1r_enum, WM8995_LEFT_LINE_INPUT_CONTROL,
434 0, in1r_text); 434 0, in1r_text);
435 435
436static const char *dmic_src_text[] = { 436static const char *dmic_src_text[] = {
437 "DMICDAT1", "DMICDAT2", "DMICDAT3" 437 "DMICDAT1", "DMICDAT2", "DMICDAT3"
438}; 438};
439 439
440static const SOC_ENUM_SINGLE_DECL(dmic_src1_enum, WM8995_POWER_MANAGEMENT_5, 440static SOC_ENUM_SINGLE_DECL(dmic_src1_enum, WM8995_POWER_MANAGEMENT_5,
441 8, dmic_src_text); 441 8, dmic_src_text);
442static const SOC_ENUM_SINGLE_DECL(dmic_src2_enum, WM8995_POWER_MANAGEMENT_5, 442static SOC_ENUM_SINGLE_DECL(dmic_src2_enum, WM8995_POWER_MANAGEMENT_5,
443 6, dmic_src_text); 443 6, dmic_src_text);
444 444
445static const struct snd_kcontrol_new wm8995_snd_controls[] = { 445static const struct snd_kcontrol_new wm8995_snd_controls[] = {
446 SOC_DOUBLE_R_TLV("DAC1 Volume", WM8995_DAC1_LEFT_VOLUME, 446 SOC_DOUBLE_R_TLV("DAC1 Volume", WM8995_DAC1_LEFT_VOLUME,
@@ -561,10 +561,8 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w,
561 struct snd_kcontrol *kcontrol, int event) 561 struct snd_kcontrol *kcontrol, int event)
562{ 562{
563 struct snd_soc_codec *codec; 563 struct snd_soc_codec *codec;
564 struct wm8995_priv *wm8995;
565 564
566 codec = w->codec; 565 codec = w->codec;
567 wm8995 = snd_soc_codec_get_drvdata(codec);
568 566
569 switch (event) { 567 switch (event) {
570 case SND_SOC_DAPM_PRE_PMU: 568 case SND_SOC_DAPM_PRE_PMU:
@@ -783,14 +781,12 @@ static const char *sidetone_text[] = {
783 "ADC/DMIC1", "DMIC2", 781 "ADC/DMIC1", "DMIC2",
784}; 782};
785 783
786static const struct soc_enum sidetone1_enum = 784static SOC_ENUM_SINGLE_DECL(sidetone1_enum, WM8995_SIDETONE, 0, sidetone_text);
787 SOC_ENUM_SINGLE(WM8995_SIDETONE, 0, 2, sidetone_text);
788 785
789static const struct snd_kcontrol_new sidetone1_mux = 786static const struct snd_kcontrol_new sidetone1_mux =
790 SOC_DAPM_ENUM("Left Sidetone Mux", sidetone1_enum); 787 SOC_DAPM_ENUM("Left Sidetone Mux", sidetone1_enum);
791 788
792static const struct soc_enum sidetone2_enum = 789static SOC_ENUM_SINGLE_DECL(sidetone2_enum, WM8995_SIDETONE, 1, sidetone_text);
793 SOC_ENUM_SINGLE(WM8995_SIDETONE, 1, 2, sidetone_text);
794 790
795static const struct snd_kcontrol_new sidetone2_mux = 791static const struct snd_kcontrol_new sidetone2_mux =
796 SOC_DAPM_ENUM("Right Sidetone Mux", sidetone2_enum); 792 SOC_DAPM_ENUM("Right Sidetone Mux", sidetone2_enum);
@@ -886,8 +882,7 @@ static const char *adc_mux_text[] = {
886 "DMIC", 882 "DMIC",
887}; 883};
888 884
889static const struct soc_enum adc_enum = 885static const SOC_ENUM_SINGLE_DECL(adc_enum, 0, 0, adc_mux_text);
890 SOC_ENUM_SINGLE(0, 0, 2, adc_mux_text);
891 886
892static const struct snd_kcontrol_new adcl_mux = 887static const struct snd_kcontrol_new adcl_mux =
893 SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum); 888 SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum);
@@ -899,14 +894,14 @@ static const char *spk_src_text[] = {
899 "DAC1L", "DAC1R", "DAC2L", "DAC2R" 894 "DAC1L", "DAC1R", "DAC2L", "DAC2R"
900}; 895};
901 896
902static const SOC_ENUM_SINGLE_DECL(spk1l_src_enum, WM8995_LEFT_PDM_SPEAKER_1, 897static SOC_ENUM_SINGLE_DECL(spk1l_src_enum, WM8995_LEFT_PDM_SPEAKER_1,
903 0, spk_src_text); 898 0, spk_src_text);
904static const SOC_ENUM_SINGLE_DECL(spk1r_src_enum, WM8995_RIGHT_PDM_SPEAKER_1, 899static SOC_ENUM_SINGLE_DECL(spk1r_src_enum, WM8995_RIGHT_PDM_SPEAKER_1,
905 0, spk_src_text); 900 0, spk_src_text);
906static const SOC_ENUM_SINGLE_DECL(spk2l_src_enum, WM8995_LEFT_PDM_SPEAKER_2, 901static SOC_ENUM_SINGLE_DECL(spk2l_src_enum, WM8995_LEFT_PDM_SPEAKER_2,
907 0, spk_src_text); 902 0, spk_src_text);
908static const SOC_ENUM_SINGLE_DECL(spk2r_src_enum, WM8995_RIGHT_PDM_SPEAKER_2, 903static SOC_ENUM_SINGLE_DECL(spk2r_src_enum, WM8995_RIGHT_PDM_SPEAKER_2,
909 0, spk_src_text); 904 0, spk_src_text);
910 905
911static const struct snd_kcontrol_new spk1l_mux = 906static const struct snd_kcontrol_new spk1l_mux =
912 SOC_DAPM_ENUM("SPK1L SRC", spk1l_src_enum); 907 SOC_DAPM_ENUM("SPK1L SRC", spk1l_src_enum);
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c
index d565d0ac7a11..0330165079a4 100644
--- a/sound/soc/codecs/wm8996.c
+++ b/sound/soc/codecs/wm8996.c
@@ -2600,7 +2600,7 @@ static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec)
2600 dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", 2600 dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n",
2601 wm8996->num_retune_mobile_texts); 2601 wm8996->num_retune_mobile_texts);
2602 2602
2603 wm8996->retune_mobile_enum.max = wm8996->num_retune_mobile_texts; 2603 wm8996->retune_mobile_enum.items = wm8996->num_retune_mobile_texts;
2604 wm8996->retune_mobile_enum.texts = wm8996->retune_mobile_texts; 2604 wm8996->retune_mobile_enum.texts = wm8996->retune_mobile_texts;
2605 2605
2606 ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); 2606 ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls));
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index 5750de197d0d..8a5363674075 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -103,7 +103,7 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol,
103 if (!codec->hw_write) 103 if (!codec->hw_write)
104 return -EUNATCH; 104 return -EUNATCH;
105 105
106 if (ucontrol->value.enumerated.item[0] >= control->max) 106 if (ucontrol->value.enumerated.item[0] >= control->items)
107 return -EINVAL; 107 return -EINVAL;
108 108
109 snd_soc_dapm_mutex_lock(dapm); 109 snd_soc_dapm_mutex_lock(dapm);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fe1df50805a3..851733897206 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2571,10 +2571,10 @@ int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
2571 2571
2572 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2572 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2573 uinfo->count = e->shift_l == e->shift_r ? 1 : 2; 2573 uinfo->count = e->shift_l == e->shift_r ? 1 : 2;
2574 uinfo->value.enumerated.items = e->max; 2574 uinfo->value.enumerated.items = e->items;
2575 2575
2576 if (uinfo->value.enumerated.item > e->max - 1) 2576 if (uinfo->value.enumerated.item >= e->items)
2577 uinfo->value.enumerated.item = e->max - 1; 2577 uinfo->value.enumerated.item = e->items - 1;
2578 strlcpy(uinfo->value.enumerated.name, 2578 strlcpy(uinfo->value.enumerated.name,
2579 e->texts[uinfo->value.enumerated.item], 2579 e->texts[uinfo->value.enumerated.item],
2580 sizeof(uinfo->value.enumerated.name)); 2580 sizeof(uinfo->value.enumerated.name));
@@ -2626,12 +2626,12 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
2626 unsigned int val; 2626 unsigned int val;
2627 unsigned int mask; 2627 unsigned int mask;
2628 2628
2629 if (ucontrol->value.enumerated.item[0] > e->max - 1) 2629 if (ucontrol->value.enumerated.item[0] >= e->items)
2630 return -EINVAL; 2630 return -EINVAL;
2631 val = ucontrol->value.enumerated.item[0] << e->shift_l; 2631 val = ucontrol->value.enumerated.item[0] << e->shift_l;
2632 mask = e->mask << e->shift_l; 2632 mask = e->mask << e->shift_l;
2633 if (e->shift_l != e->shift_r) { 2633 if (e->shift_l != e->shift_r) {
2634 if (ucontrol->value.enumerated.item[1] > e->max - 1) 2634 if (ucontrol->value.enumerated.item[1] >= e->items)
2635 return -EINVAL; 2635 return -EINVAL;
2636 val |= ucontrol->value.enumerated.item[1] << e->shift_r; 2636 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
2637 mask |= e->mask << e->shift_r; 2637 mask |= e->mask << e->shift_r;
@@ -2662,14 +2662,14 @@ int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
2662 2662
2663 reg_val = snd_soc_read(codec, e->reg); 2663 reg_val = snd_soc_read(codec, e->reg);
2664 val = (reg_val >> e->shift_l) & e->mask; 2664 val = (reg_val >> e->shift_l) & e->mask;
2665 for (mux = 0; mux < e->max; mux++) { 2665 for (mux = 0; mux < e->items; mux++) {
2666 if (val == e->values[mux]) 2666 if (val == e->values[mux])
2667 break; 2667 break;
2668 } 2668 }
2669 ucontrol->value.enumerated.item[0] = mux; 2669 ucontrol->value.enumerated.item[0] = mux;
2670 if (e->shift_l != e->shift_r) { 2670 if (e->shift_l != e->shift_r) {
2671 val = (reg_val >> e->shift_r) & e->mask; 2671 val = (reg_val >> e->shift_r) & e->mask;
2672 for (mux = 0; mux < e->max; mux++) { 2672 for (mux = 0; mux < e->items; mux++) {
2673 if (val == e->values[mux]) 2673 if (val == e->values[mux])
2674 break; 2674 break;
2675 } 2675 }
@@ -2700,12 +2700,12 @@ int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
2700 unsigned int val; 2700 unsigned int val;
2701 unsigned int mask; 2701 unsigned int mask;
2702 2702
2703 if (ucontrol->value.enumerated.item[0] > e->max - 1) 2703 if (ucontrol->value.enumerated.item[0] >= e->items)
2704 return -EINVAL; 2704 return -EINVAL;
2705 val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l; 2705 val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
2706 mask = e->mask << e->shift_l; 2706 mask = e->mask << e->shift_l;
2707 if (e->shift_l != e->shift_r) { 2707 if (e->shift_l != e->shift_r) {
2708 if (ucontrol->value.enumerated.item[1] > e->max - 1) 2708 if (ucontrol->value.enumerated.item[1] >= e->items)
2709 return -EINVAL; 2709 return -EINVAL;
2710 val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r; 2710 val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
2711 mask |= e->mask << e->shift_r; 2711 mask |= e->mask << e->shift_r;
@@ -2716,6 +2716,48 @@ int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
2716EXPORT_SYMBOL_GPL(snd_soc_put_value_enum_double); 2716EXPORT_SYMBOL_GPL(snd_soc_put_value_enum_double);
2717 2717
2718/** 2718/**
2719 * snd_soc_read_signed - Read a codec register and interprete as signed value
2720 * @codec: codec
2721 * @reg: Register to read
2722 * @mask: Mask to use after shifting the register value
2723 * @shift: Right shift of register value
2724 * @sign_bit: Bit that describes if a number is negative or not.
2725 *
2726 * This functions reads a codec register. The register value is shifted right
2727 * by 'shift' bits and masked with the given 'mask'. Afterwards it translates
2728 * the given registervalue into a signed integer if sign_bit is non-zero.
2729 *
2730 * Returns the register value as signed int.
2731 */
2732static int snd_soc_read_signed(struct snd_soc_codec *codec, unsigned int reg,
2733 unsigned int mask, unsigned int shift, unsigned int sign_bit)
2734{
2735 int ret;
2736 unsigned int val;
2737
2738 val = (snd_soc_read(codec, reg) >> shift) & mask;
2739
2740 if (!sign_bit)
2741 return val;
2742
2743 /* non-negative number */
2744 if (!(val & BIT(sign_bit)))
2745 return val;
2746
2747 ret = val;
2748
2749 /*
2750 * The register most probably does not contain a full-sized int.
2751 * Instead we have an arbitrary number of bits in a signed
2752 * representation which has to be translated into a full-sized int.
2753 * This is done by filling up all bits above the sign-bit.
2754 */
2755 ret |= ~((int)(BIT(sign_bit) - 1));
2756
2757 return ret;
2758}
2759
2760/**
2719 * snd_soc_info_volsw - single mixer info callback 2761 * snd_soc_info_volsw - single mixer info callback
2720 * @kcontrol: mixer control 2762 * @kcontrol: mixer control
2721 * @uinfo: control element information 2763 * @uinfo: control element information
@@ -2743,7 +2785,7 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
2743 2785
2744 uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1; 2786 uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
2745 uinfo->value.integer.min = 0; 2787 uinfo->value.integer.min = 0;
2746 uinfo->value.integer.max = platform_max; 2788 uinfo->value.integer.max = platform_max - mc->min;
2747 return 0; 2789 return 0;
2748} 2790}
2749EXPORT_SYMBOL_GPL(snd_soc_info_volsw); 2791EXPORT_SYMBOL_GPL(snd_soc_info_volsw);
@@ -2769,11 +2811,16 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
2769 unsigned int shift = mc->shift; 2811 unsigned int shift = mc->shift;
2770 unsigned int rshift = mc->rshift; 2812 unsigned int rshift = mc->rshift;
2771 int max = mc->max; 2813 int max = mc->max;
2814 int min = mc->min;
2815 int sign_bit = mc->sign_bit;
2772 unsigned int mask = (1 << fls(max)) - 1; 2816 unsigned int mask = (1 << fls(max)) - 1;
2773 unsigned int invert = mc->invert; 2817 unsigned int invert = mc->invert;
2774 2818
2775 ucontrol->value.integer.value[0] = 2819 if (sign_bit)
2776 (snd_soc_read(codec, reg) >> shift) & mask; 2820 mask = BIT(sign_bit + 1) - 1;
2821
2822 ucontrol->value.integer.value[0] = snd_soc_read_signed(codec, reg, mask,
2823 shift, sign_bit) - min;
2777 if (invert) 2824 if (invert)
2778 ucontrol->value.integer.value[0] = 2825 ucontrol->value.integer.value[0] =
2779 max - ucontrol->value.integer.value[0]; 2826 max - ucontrol->value.integer.value[0];
@@ -2781,10 +2828,12 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
2781 if (snd_soc_volsw_is_stereo(mc)) { 2828 if (snd_soc_volsw_is_stereo(mc)) {
2782 if (reg == reg2) 2829 if (reg == reg2)
2783 ucontrol->value.integer.value[1] = 2830 ucontrol->value.integer.value[1] =
2784 (snd_soc_read(codec, reg) >> rshift) & mask; 2831 snd_soc_read_signed(codec, reg, mask, rshift,
2832 sign_bit) - min;
2785 else 2833 else
2786 ucontrol->value.integer.value[1] = 2834 ucontrol->value.integer.value[1] =
2787 (snd_soc_read(codec, reg2) >> shift) & mask; 2835 snd_soc_read_signed(codec, reg2, mask, shift,
2836 sign_bit) - min;
2788 if (invert) 2837 if (invert)
2789 ucontrol->value.integer.value[1] = 2838 ucontrol->value.integer.value[1] =
2790 max - ucontrol->value.integer.value[1]; 2839 max - ucontrol->value.integer.value[1];
@@ -2815,6 +2864,8 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
2815 unsigned int shift = mc->shift; 2864 unsigned int shift = mc->shift;
2816 unsigned int rshift = mc->rshift; 2865 unsigned int rshift = mc->rshift;
2817 int max = mc->max; 2866 int max = mc->max;
2867 int min = mc->min;
2868 unsigned int sign_bit = mc->sign_bit;
2818 unsigned int mask = (1 << fls(max)) - 1; 2869 unsigned int mask = (1 << fls(max)) - 1;
2819 unsigned int invert = mc->invert; 2870 unsigned int invert = mc->invert;
2820 int err; 2871 int err;
@@ -2822,13 +2873,16 @@ int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
2822 unsigned int val2 = 0; 2873 unsigned int val2 = 0;
2823 unsigned int val, val_mask; 2874 unsigned int val, val_mask;
2824 2875
2825 val = (ucontrol->value.integer.value[0] & mask); 2876 if (sign_bit)
2877 mask = BIT(sign_bit + 1) - 1;
2878
2879 val = ((ucontrol->value.integer.value[0] + min) & mask);
2826 if (invert) 2880 if (invert)
2827 val = max - val; 2881 val = max - val;
2828 val_mask = mask << shift; 2882 val_mask = mask << shift;
2829 val = val << shift; 2883 val = val << shift;
2830 if (snd_soc_volsw_is_stereo(mc)) { 2884 if (snd_soc_volsw_is_stereo(mc)) {
2831 val2 = (ucontrol->value.integer.value[1] & mask); 2885 val2 = ((ucontrol->value.integer.value[1] + min) & mask);
2832 if (invert) 2886 if (invert)
2833 val2 = max - val2; 2887 val2 = max - val2;
2834 if (reg == reg2) { 2888 if (reg == reg2) {
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 4200f96a1483..96a97a3dfb68 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -536,7 +536,7 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
536 soc_widget_read(w, e->reg, &val); 536 soc_widget_read(w, e->reg, &val);
537 item = (val >> e->shift_l) & e->mask; 537 item = (val >> e->shift_l) & e->mask;
538 538
539 if (item < e->max && !strcmp(p->name, e->texts[item])) 539 if (item < e->items && !strcmp(p->name, e->texts[item]))
540 p->connect = 1; 540 p->connect = 1;
541 else 541 else
542 p->connect = 0; 542 p->connect = 0;
@@ -564,12 +564,12 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w,
564 564
565 soc_widget_read(w, e->reg, &val); 565 soc_widget_read(w, e->reg, &val);
566 val = (val >> e->shift_l) & e->mask; 566 val = (val >> e->shift_l) & e->mask;
567 for (item = 0; item < e->max; item++) { 567 for (item = 0; item < e->items; item++) {
568 if (val == e->values[item]) 568 if (val == e->values[item])
569 break; 569 break;
570 } 570 }
571 571
572 if (item < e->max && !strcmp(p->name, e->texts[item])) 572 if (item < e->items && !strcmp(p->name, e->texts[item]))
573 p->connect = 1; 573 p->connect = 1;
574 else 574 else
575 p->connect = 0; 575 p->connect = 0;
@@ -617,7 +617,7 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm,
617 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; 617 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
618 int i; 618 int i;
619 619
620 for (i = 0; i < e->max; i++) { 620 for (i = 0; i < e->items; i++) {
621 if (!(strcmp(control_name, e->texts[i]))) { 621 if (!(strcmp(control_name, e->texts[i]))) {
622 list_add(&path->list, &dapm->card->paths); 622 list_add(&path->list, &dapm->card->paths);
623 list_add(&path->list_sink, &dest->sources); 623 list_add(&path->list_sink, &dest->sources);
@@ -2985,13 +2985,13 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
2985 struct snd_soc_dapm_update update; 2985 struct snd_soc_dapm_update update;
2986 int ret = 0; 2986 int ret = 0;
2987 2987
2988 if (ucontrol->value.enumerated.item[0] > e->max - 1) 2988 if (ucontrol->value.enumerated.item[0] >= e->items)
2989 return -EINVAL; 2989 return -EINVAL;
2990 mux = ucontrol->value.enumerated.item[0]; 2990 mux = ucontrol->value.enumerated.item[0];
2991 val = mux << e->shift_l; 2991 val = mux << e->shift_l;
2992 mask = e->mask << e->shift_l; 2992 mask = e->mask << e->shift_l;
2993 if (e->shift_l != e->shift_r) { 2993 if (e->shift_l != e->shift_r) {
2994 if (ucontrol->value.enumerated.item[1] > e->max - 1) 2994 if (ucontrol->value.enumerated.item[1] >= e->items)
2995 return -EINVAL; 2995 return -EINVAL;
2996 val |= ucontrol->value.enumerated.item[1] << e->shift_r; 2996 val |= ucontrol->value.enumerated.item[1] << e->shift_r;
2997 mask |= e->mask << e->shift_r; 2997 mask |= e->mask << e->shift_r;
@@ -3054,7 +3054,7 @@ int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
3054 int change; 3054 int change;
3055 int ret = 0; 3055 int ret = 0;
3056 3056
3057 if (ucontrol->value.enumerated.item[0] >= e->max) 3057 if (ucontrol->value.enumerated.item[0] >= e->items)
3058 return -EINVAL; 3058 return -EINVAL;
3059 3059
3060 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 3060 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
@@ -3095,14 +3095,14 @@ int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol,
3095 3095
3096 reg_val = snd_soc_read(codec, e->reg); 3096 reg_val = snd_soc_read(codec, e->reg);
3097 val = (reg_val >> e->shift_l) & e->mask; 3097 val = (reg_val >> e->shift_l) & e->mask;
3098 for (mux = 0; mux < e->max; mux++) { 3098 for (mux = 0; mux < e->items; mux++) {
3099 if (val == e->values[mux]) 3099 if (val == e->values[mux])
3100 break; 3100 break;
3101 } 3101 }
3102 ucontrol->value.enumerated.item[0] = mux; 3102 ucontrol->value.enumerated.item[0] = mux;
3103 if (e->shift_l != e->shift_r) { 3103 if (e->shift_l != e->shift_r) {
3104 val = (reg_val >> e->shift_r) & e->mask; 3104 val = (reg_val >> e->shift_r) & e->mask;
3105 for (mux = 0; mux < e->max; mux++) { 3105 for (mux = 0; mux < e->items; mux++) {
3106 if (val == e->values[mux]) 3106 if (val == e->values[mux])
3107 break; 3107 break;
3108 } 3108 }
@@ -3137,13 +3137,13 @@ int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
3137 struct snd_soc_dapm_update update; 3137 struct snd_soc_dapm_update update;
3138 int ret = 0; 3138 int ret = 0;
3139 3139
3140 if (ucontrol->value.enumerated.item[0] > e->max - 1) 3140 if (ucontrol->value.enumerated.item[0] >= e->items)
3141 return -EINVAL; 3141 return -EINVAL;
3142 mux = ucontrol->value.enumerated.item[0]; 3142 mux = ucontrol->value.enumerated.item[0];
3143 val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l; 3143 val = e->values[ucontrol->value.enumerated.item[0]] << e->shift_l;
3144 mask = e->mask << e->shift_l; 3144 mask = e->mask << e->shift_l;
3145 if (e->shift_l != e->shift_r) { 3145 if (e->shift_l != e->shift_r) {
3146 if (ucontrol->value.enumerated.item[1] > e->max - 1) 3146 if (ucontrol->value.enumerated.item[1] >= e->items)
3147 return -EINVAL; 3147 return -EINVAL;
3148 val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r; 3148 val |= e->values[ucontrol->value.enumerated.item[1]] << e->shift_r;
3149 mask |= e->mask << e->shift_r; 3149 mask |= e->mask << e->shift_r;