forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/codecs/wm8400.c
....@@ -1,14 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * wm8400.c -- WM8400 ALSA Soc Audio driver
34 *
45 * Copyright 2008-11 Wolfson Microelectronics PLC.
56 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the
9
- * Free Software Foundation; either version 2 of the License, or (at your
10
- * option) any later version.
11
- *
127 */
138
149 #include <linux/module.h>
....@@ -72,15 +67,11 @@
7267 wm8400_reset_codec_reg_cache(wm8400->wm8400);
7368 }
7469
75
-static const DECLARE_TLV_DB_SCALE(rec_mix_tlv, -1500, 600, 0);
76
-
7770 static const DECLARE_TLV_DB_SCALE(in_pga_tlv, -1650, 3000, 0);
7871
7972 static const DECLARE_TLV_DB_SCALE(out_mix_tlv, -2100, 0, 0);
8073
8174 static const DECLARE_TLV_DB_SCALE(out_pga_tlv, -7300, 600, 0);
82
-
83
-static const DECLARE_TLV_DB_SCALE(out_omix_tlv, -600, 0, 0);
8475
8576 static const DECLARE_TLV_DB_SCALE(out_dac_tlv, -7163, 0, 0);
8677
....@@ -103,7 +94,7 @@
10394 return ret;
10495
10596 /* now hit the volume update bits (always bit 8) */
106
- val = snd_soc_component_read32(component, reg);
97
+ val = snd_soc_component_read(component, reg);
10798 return snd_soc_component_write(component, reg, val | 0x0100);
10899 }
109100
....@@ -333,7 +324,7 @@
333324
334325 switch (reg_shift) {
335326 case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) :
336
- reg = snd_soc_component_read32(component, WM8400_OUTPUT_MIXER1);
327
+ reg = snd_soc_component_read(component, WM8400_OUTPUT_MIXER1);
337328 if (reg & WM8400_LDLO) {
338329 printk(KERN_WARNING
339330 "Cannot set as Output Mixer 1 LDLO Set\n");
....@@ -341,7 +332,7 @@
341332 }
342333 break;
343334 case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8):
344
- reg = snd_soc_component_read32(component, WM8400_OUTPUT_MIXER2);
335
+ reg = snd_soc_component_read(component, WM8400_OUTPUT_MIXER2);
345336 if (reg & WM8400_RDRO) {
346337 printk(KERN_WARNING
347338 "Cannot set as Output Mixer 2 RDRO Set\n");
....@@ -349,7 +340,7 @@
349340 }
350341 break;
351342 case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8):
352
- reg = snd_soc_component_read32(component, WM8400_SPEAKER_MIXER);
343
+ reg = snd_soc_component_read(component, WM8400_SPEAKER_MIXER);
353344 if (reg & WM8400_LDSPK) {
354345 printk(KERN_WARNING
355346 "Cannot set as Speaker Mixer LDSPK Set\n");
....@@ -357,7 +348,7 @@
357348 }
358349 break;
359350 case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8):
360
- reg = snd_soc_component_read32(component, WM8400_SPEAKER_MIXER);
351
+ reg = snd_soc_component_read(component, WM8400_SPEAKER_MIXER);
361352 if (reg & WM8400_RDSPK) {
362353 printk(KERN_WARNING
363354 "Cannot set as Speaker Mixer RDSPK Set\n");
....@@ -443,14 +434,6 @@
443434
444435 static const struct snd_kcontrol_new wm8400_dapm_ainrmux_controls =
445436 SOC_DAPM_ENUM("Route", wm8400_ainrmux_enum);
446
-
447
-/* RXVOICE */
448
-static const struct snd_kcontrol_new wm8400_dapm_rxvoice_controls[] = {
449
-SOC_DAPM_SINGLE_TLV("LIN4/RXN", WM8400_INPUT_MIXER5, WM8400_LR4BVOL_SHIFT,
450
- WM8400_LR4BVOL_MASK, 0, in_mix_tlv),
451
-SOC_DAPM_SINGLE_TLV("RIN4/RXP", WM8400_INPUT_MIXER6, WM8400_RL4BVOL_SHIFT,
452
- WM8400_RL4BVOL_MASK, 0, in_mix_tlv),
453
-};
454437
455438 /* LOMIX */
456439 static const struct snd_kcontrol_new wm8400_dapm_lomix_controls[] = {
....@@ -962,11 +945,11 @@
962945 wm8400->fll_in = freq_in;
963946
964947 /* We *must* disable the FLL before any changes */
965
- reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_2);
948
+ reg = snd_soc_component_read(component, WM8400_POWER_MANAGEMENT_2);
966949 reg &= ~WM8400_FLL_ENA;
967950 snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_2, reg);
968951
969
- reg = snd_soc_component_read32(component, WM8400_FLL_CONTROL_1);
952
+ reg = snd_soc_component_read(component, WM8400_FLL_CONTROL_1);
970953 reg &= ~WM8400_FLL_OSC_ENA;
971954 snd_soc_component_write(component, WM8400_FLL_CONTROL_1, reg);
972955
....@@ -981,7 +964,7 @@
981964 snd_soc_component_write(component, WM8400_FLL_CONTROL_2, factors.k);
982965 snd_soc_component_write(component, WM8400_FLL_CONTROL_3, factors.n);
983966
984
- reg = snd_soc_component_read32(component, WM8400_FLL_CONTROL_4);
967
+ reg = snd_soc_component_read(component, WM8400_FLL_CONTROL_4);
985968 reg &= ~WM8400_FLL_OUTDIV_MASK;
986969 reg |= factors.outdiv;
987970 snd_soc_component_write(component, WM8400_FLL_CONTROL_4, reg);
....@@ -998,8 +981,8 @@
998981 struct snd_soc_component *component = codec_dai->component;
999982 u16 audio1, audio3;
1000983
1001
- audio1 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_1);
1002
- audio3 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_3);
984
+ audio1 = snd_soc_component_read(component, WM8400_AUDIO_INTERFACE_1);
985
+ audio3 = snd_soc_component_read(component, WM8400_AUDIO_INTERFACE_3);
1003986
1004987 /* set master/slave audio interface */
1005988 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
....@@ -1053,22 +1036,22 @@
10531036
10541037 switch (div_id) {
10551038 case WM8400_MCLK_DIV:
1056
- reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) &
1039
+ reg = snd_soc_component_read(component, WM8400_CLOCKING_2) &
10571040 ~WM8400_MCLK_DIV_MASK;
10581041 snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div);
10591042 break;
10601043 case WM8400_DACCLK_DIV:
1061
- reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) &
1044
+ reg = snd_soc_component_read(component, WM8400_CLOCKING_2) &
10621045 ~WM8400_DAC_CLKDIV_MASK;
10631046 snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div);
10641047 break;
10651048 case WM8400_ADCCLK_DIV:
1066
- reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) &
1049
+ reg = snd_soc_component_read(component, WM8400_CLOCKING_2) &
10671050 ~WM8400_ADC_CLKDIV_MASK;
10681051 snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div);
10691052 break;
10701053 case WM8400_BCLK_DIV:
1071
- reg = snd_soc_component_read32(component, WM8400_CLOCKING_1) &
1054
+ reg = snd_soc_component_read(component, WM8400_CLOCKING_1) &
10721055 ~WM8400_BCLK_DIV_MASK;
10731056 snd_soc_component_write(component, WM8400_CLOCKING_1, reg | div);
10741057 break;
....@@ -1087,7 +1070,7 @@
10871070 struct snd_soc_dai *dai)
10881071 {
10891072 struct snd_soc_component *component = dai->component;
1090
- u16 audio1 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_1);
1073
+ u16 audio1 = snd_soc_component_read(component, WM8400_AUDIO_INTERFACE_1);
10911074
10921075 audio1 &= ~WM8400_AIF_WL_MASK;
10931076 /* bit size */
....@@ -1109,10 +1092,10 @@
11091092 return 0;
11101093 }
11111094
1112
-static int wm8400_mute(struct snd_soc_dai *dai, int mute)
1095
+static int wm8400_mute(struct snd_soc_dai *dai, int mute, int direction)
11131096 {
11141097 struct snd_soc_component *component = dai->component;
1115
- u16 val = snd_soc_component_read32(component, WM8400_DAC_CTRL) & ~WM8400_DAC_MUTE;
1098
+ u16 val = snd_soc_component_read(component, WM8400_DAC_CTRL) & ~WM8400_DAC_MUTE;
11161099
11171100 if (mute)
11181101 snd_soc_component_write(component, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE);
....@@ -1136,7 +1119,7 @@
11361119
11371120 case SND_SOC_BIAS_PREPARE:
11381121 /* VMID=2*50k */
1139
- val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1) &
1122
+ val = snd_soc_component_read(component, WM8400_POWER_MANAGEMENT_1) &
11401123 ~WM8400_VMID_MODE_MASK;
11411124 snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val | 0x2);
11421125 break;
....@@ -1162,7 +1145,7 @@
11621145 msleep(50);
11631146
11641147 /* Enable VREF & VMID at 2x50k */
1165
- val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1);
1148
+ val = snd_soc_component_read(component, WM8400_POWER_MANAGEMENT_1);
11661149 val |= 0x2 | WM8400_VREF_ENA;
11671150 snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val);
11681151
....@@ -1176,7 +1159,7 @@
11761159 }
11771160
11781161 /* VMID=2*300k */
1179
- val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1) &
1162
+ val = snd_soc_component_read(component, WM8400_POWER_MANAGEMENT_1) &
11801163 ~WM8400_VMID_MODE_MASK;
11811164 snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val | 0x4);
11821165 break;
....@@ -1192,11 +1175,11 @@
11921175 WM8400_BUFIOEN);
11931176
11941177 /* mute DAC */
1195
- val = snd_soc_component_read32(component, WM8400_DAC_CTRL);
1178
+ val = snd_soc_component_read(component, WM8400_DAC_CTRL);
11961179 snd_soc_component_write(component, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE);
11971180
11981181 /* Enable any disabled outputs */
1199
- val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1);
1182
+ val = snd_soc_component_read(component, WM8400_POWER_MANAGEMENT_1);
12001183 val |= WM8400_SPK_ENA | WM8400_OUT3_ENA |
12011184 WM8400_OUT4_ENA | WM8400_LOUT_ENA |
12021185 WM8400_ROUT_ENA;
....@@ -1239,11 +1222,12 @@
12391222
12401223 static const struct snd_soc_dai_ops wm8400_dai_ops = {
12411224 .hw_params = wm8400_hw_params,
1242
- .digital_mute = wm8400_mute,
1225
+ .mute_stream = wm8400_mute,
12431226 .set_fmt = wm8400_set_dai_fmt,
12441227 .set_clkdiv = wm8400_set_dai_clkdiv,
12451228 .set_sysclk = wm8400_set_dai_sysclk,
12461229 .set_pll = wm8400_set_dai_pll,
1230
+ .no_capture_mute = 1,
12471231 };
12481232
12491233 /*
....@@ -1298,14 +1282,14 @@
12981282
12991283 wm8400_component_reset(component);
13001284
1301
- reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1);
1285
+ reg = snd_soc_component_read(component, WM8400_POWER_MANAGEMENT_1);
13021286 snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, reg | WM8400_CODEC_ENA);
13031287
13041288 /* Latch volume update bits */
1305
- reg = snd_soc_component_read32(component, WM8400_LEFT_LINE_INPUT_1_2_VOLUME);
1289
+ reg = snd_soc_component_read(component, WM8400_LEFT_LINE_INPUT_1_2_VOLUME);
13061290 snd_soc_component_write(component, WM8400_LEFT_LINE_INPUT_1_2_VOLUME,
13071291 reg & WM8400_IPVU);
1308
- reg = snd_soc_component_read32(component, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME);
1292
+ reg = snd_soc_component_read(component, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME);
13091293 snd_soc_component_write(component, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME,
13101294 reg & WM8400_IPVU);
13111295
....@@ -1319,7 +1303,7 @@
13191303 {
13201304 u16 reg;
13211305
1322
- reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1);
1306
+ reg = snd_soc_component_read(component, WM8400_POWER_MANAGEMENT_1);
13231307 snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1,
13241308 reg & (~WM8400_CODEC_ENA));
13251309 }