.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * wm8991.c -- WM8991 ALSA Soc Audio driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2007-2010 Wolfson Microelectronics PLC. |
---|
5 | 6 | * Author: Graeme Gregory |
---|
6 | 7 | * Graeme.Gregory@wolfsonmicro.com |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify it |
---|
9 | | - * under the terms of the GNU General Public License as published by the |
---|
10 | | - * Free Software Foundation; either version 2 of the License, or (at your |
---|
11 | | - * option) any later version. |
---|
12 | 8 | */ |
---|
13 | 9 | |
---|
14 | 10 | #include <linux/module.h> |
---|
.. | .. |
---|
143 | 139 | return ret; |
---|
144 | 140 | |
---|
145 | 141 | /* now hit the volume update bits (always bit 8) */ |
---|
146 | | - val = snd_soc_component_read32(component, reg); |
---|
| 142 | + val = snd_soc_component_read(component, reg); |
---|
147 | 143 | return snd_soc_component_write(component, reg, val | 0x0100); |
---|
148 | 144 | } |
---|
149 | 145 | |
---|
.. | .. |
---|
368 | 364 | |
---|
369 | 365 | switch (reg_shift) { |
---|
370 | 366 | case WM8991_SPEAKER_MIXER | (WM8991_LDSPK_BIT << 8): |
---|
371 | | - reg = snd_soc_component_read32(component, WM8991_OUTPUT_MIXER1); |
---|
| 367 | + reg = snd_soc_component_read(component, WM8991_OUTPUT_MIXER1); |
---|
372 | 368 | if (reg & WM8991_LDLO) { |
---|
373 | 369 | printk(KERN_WARNING |
---|
374 | 370 | "Cannot set as Output Mixer 1 LDLO Set\n"); |
---|
.. | .. |
---|
377 | 373 | break; |
---|
378 | 374 | |
---|
379 | 375 | case WM8991_SPEAKER_MIXER | (WM8991_RDSPK_BIT << 8): |
---|
380 | | - reg = snd_soc_component_read32(component, WM8991_OUTPUT_MIXER2); |
---|
| 376 | + reg = snd_soc_component_read(component, WM8991_OUTPUT_MIXER2); |
---|
381 | 377 | if (reg & WM8991_RDRO) { |
---|
382 | 378 | printk(KERN_WARNING |
---|
383 | 379 | "Cannot set as Output Mixer 2 RDRO Set\n"); |
---|
.. | .. |
---|
386 | 382 | break; |
---|
387 | 383 | |
---|
388 | 384 | case WM8991_OUTPUT_MIXER1 | (WM8991_LDLO_BIT << 8): |
---|
389 | | - reg = snd_soc_component_read32(component, WM8991_SPEAKER_MIXER); |
---|
| 385 | + reg = snd_soc_component_read(component, WM8991_SPEAKER_MIXER); |
---|
390 | 386 | if (reg & WM8991_LDSPK) { |
---|
391 | 387 | printk(KERN_WARNING |
---|
392 | 388 | "Cannot set as Speaker Mixer LDSPK Set\n"); |
---|
.. | .. |
---|
395 | 391 | break; |
---|
396 | 392 | |
---|
397 | 393 | case WM8991_OUTPUT_MIXER2 | (WM8991_RDRO_BIT << 8): |
---|
398 | | - reg = snd_soc_component_read32(component, WM8991_SPEAKER_MIXER); |
---|
| 394 | + reg = snd_soc_component_read(component, WM8991_SPEAKER_MIXER); |
---|
399 | 395 | if (reg & WM8991_RDSPK) { |
---|
400 | 396 | printk(KERN_WARNING |
---|
401 | 397 | "Cannot set as Speaker Mixer RDSPK Set\n"); |
---|
.. | .. |
---|
479 | 475 | |
---|
480 | 476 | static const struct snd_kcontrol_new wm8991_dapm_ainrmux_controls = |
---|
481 | 477 | SOC_DAPM_ENUM("Route", wm8991_ainrmux_enum); |
---|
482 | | - |
---|
483 | | -/* RXVOICE */ |
---|
484 | | -static const struct snd_kcontrol_new wm8991_dapm_rxvoice_controls[] = { |
---|
485 | | - SOC_DAPM_SINGLE_TLV("LIN4RXN", WM8991_INPUT_MIXER5, WM8991_LR4BVOL_SHIFT, |
---|
486 | | - WM8991_LR4BVOL_MASK, 0, in_mix_tlv), |
---|
487 | | - SOC_DAPM_SINGLE_TLV("RIN4RXP", WM8991_INPUT_MIXER6, WM8991_RL4BVOL_SHIFT, |
---|
488 | | - WM8991_RL4BVOL_MASK, 0, in_mix_tlv), |
---|
489 | | -}; |
---|
490 | 478 | |
---|
491 | 479 | /* LOMIX */ |
---|
492 | 480 | static const struct snd_kcontrol_new wm8991_dapm_lomix_controls[] = { |
---|
.. | .. |
---|
934 | 922 | pll_factors(&pll_div, freq_out * 4, freq_in); |
---|
935 | 923 | |
---|
936 | 924 | /* Turn on PLL */ |
---|
937 | | - reg = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_2); |
---|
| 925 | + reg = snd_soc_component_read(component, WM8991_POWER_MANAGEMENT_2); |
---|
938 | 926 | reg |= WM8991_PLL_ENA; |
---|
939 | 927 | snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_2, reg); |
---|
940 | 928 | |
---|
941 | 929 | /* sysclk comes from PLL */ |
---|
942 | | - reg = snd_soc_component_read32(component, WM8991_CLOCKING_2); |
---|
| 930 | + reg = snd_soc_component_read(component, WM8991_CLOCKING_2); |
---|
943 | 931 | snd_soc_component_write(component, WM8991_CLOCKING_2, reg | WM8991_SYSCLK_SRC); |
---|
944 | 932 | |
---|
945 | 933 | /* set up N , fractional mode and pre-divisor if necessary */ |
---|
.. | .. |
---|
949 | 937 | snd_soc_component_write(component, WM8991_PLL3, (u8)(pll_div.k & 0xFF)); |
---|
950 | 938 | } else { |
---|
951 | 939 | /* Turn on PLL */ |
---|
952 | | - reg = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_2); |
---|
| 940 | + reg = snd_soc_component_read(component, WM8991_POWER_MANAGEMENT_2); |
---|
953 | 941 | reg &= ~WM8991_PLL_ENA; |
---|
954 | 942 | snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_2, reg); |
---|
955 | 943 | } |
---|
.. | .. |
---|
965 | 953 | struct snd_soc_component *component = codec_dai->component; |
---|
966 | 954 | u16 audio1, audio3; |
---|
967 | 955 | |
---|
968 | | - audio1 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_1); |
---|
969 | | - audio3 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_3); |
---|
| 956 | + audio1 = snd_soc_component_read(component, WM8991_AUDIO_INTERFACE_1); |
---|
| 957 | + audio3 = snd_soc_component_read(component, WM8991_AUDIO_INTERFACE_3); |
---|
970 | 958 | |
---|
971 | 959 | /* set master/slave audio interface */ |
---|
972 | 960 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
---|
.. | .. |
---|
1020 | 1008 | |
---|
1021 | 1009 | switch (div_id) { |
---|
1022 | 1010 | case WM8991_MCLK_DIV: |
---|
1023 | | - reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) & |
---|
| 1011 | + reg = snd_soc_component_read(component, WM8991_CLOCKING_2) & |
---|
1024 | 1012 | ~WM8991_MCLK_DIV_MASK; |
---|
1025 | 1013 | snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div); |
---|
1026 | 1014 | break; |
---|
1027 | 1015 | case WM8991_DACCLK_DIV: |
---|
1028 | | - reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) & |
---|
| 1016 | + reg = snd_soc_component_read(component, WM8991_CLOCKING_2) & |
---|
1029 | 1017 | ~WM8991_DAC_CLKDIV_MASK; |
---|
1030 | 1018 | snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div); |
---|
1031 | 1019 | break; |
---|
1032 | 1020 | case WM8991_ADCCLK_DIV: |
---|
1033 | | - reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) & |
---|
| 1021 | + reg = snd_soc_component_read(component, WM8991_CLOCKING_2) & |
---|
1034 | 1022 | ~WM8991_ADC_CLKDIV_MASK; |
---|
1035 | 1023 | snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div); |
---|
1036 | 1024 | break; |
---|
1037 | 1025 | case WM8991_BCLK_DIV: |
---|
1038 | | - reg = snd_soc_component_read32(component, WM8991_CLOCKING_1) & |
---|
| 1026 | + reg = snd_soc_component_read(component, WM8991_CLOCKING_1) & |
---|
1039 | 1027 | ~WM8991_BCLK_DIV_MASK; |
---|
1040 | 1028 | snd_soc_component_write(component, WM8991_CLOCKING_1, reg | div); |
---|
1041 | 1029 | break; |
---|
.. | .. |
---|
1054 | 1042 | struct snd_soc_dai *dai) |
---|
1055 | 1043 | { |
---|
1056 | 1044 | struct snd_soc_component *component = dai->component; |
---|
1057 | | - u16 audio1 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_1); |
---|
| 1045 | + u16 audio1 = snd_soc_component_read(component, WM8991_AUDIO_INTERFACE_1); |
---|
1058 | 1046 | |
---|
1059 | 1047 | audio1 &= ~WM8991_AIF_WL_MASK; |
---|
1060 | 1048 | /* bit size */ |
---|
.. | .. |
---|
1076 | 1064 | return 0; |
---|
1077 | 1065 | } |
---|
1078 | 1066 | |
---|
1079 | | -static int wm8991_mute(struct snd_soc_dai *dai, int mute) |
---|
| 1067 | +static int wm8991_mute(struct snd_soc_dai *dai, int mute, int direction) |
---|
1080 | 1068 | { |
---|
1081 | 1069 | struct snd_soc_component *component = dai->component; |
---|
1082 | 1070 | u16 val; |
---|
1083 | 1071 | |
---|
1084 | | - val = snd_soc_component_read32(component, WM8991_DAC_CTRL) & ~WM8991_DAC_MUTE; |
---|
| 1072 | + val = snd_soc_component_read(component, WM8991_DAC_CTRL) & ~WM8991_DAC_MUTE; |
---|
1085 | 1073 | if (mute) |
---|
1086 | 1074 | snd_soc_component_write(component, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); |
---|
1087 | 1075 | else |
---|
.. | .. |
---|
1101 | 1089 | |
---|
1102 | 1090 | case SND_SOC_BIAS_PREPARE: |
---|
1103 | 1091 | /* VMID=2*50k */ |
---|
1104 | | - val = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_1) & |
---|
| 1092 | + val = snd_soc_component_read(component, WM8991_POWER_MANAGEMENT_1) & |
---|
1105 | 1093 | ~WM8991_VMID_MODE_MASK; |
---|
1106 | 1094 | snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, val | 0x2); |
---|
1107 | 1095 | break; |
---|
.. | .. |
---|
1158 | 1146 | } |
---|
1159 | 1147 | |
---|
1160 | 1148 | /* VMID=2*250k */ |
---|
1161 | | - val = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_1) & |
---|
| 1149 | + val = snd_soc_component_read(component, WM8991_POWER_MANAGEMENT_1) & |
---|
1162 | 1150 | ~WM8991_VMID_MODE_MASK; |
---|
1163 | 1151 | snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, val | 0x4); |
---|
1164 | 1152 | break; |
---|
.. | .. |
---|
1174 | 1162 | WM8991_BUFIOEN); |
---|
1175 | 1163 | |
---|
1176 | 1164 | /* mute DAC */ |
---|
1177 | | - val = snd_soc_component_read32(component, WM8991_DAC_CTRL); |
---|
| 1165 | + val = snd_soc_component_read(component, WM8991_DAC_CTRL); |
---|
1178 | 1166 | snd_soc_component_write(component, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); |
---|
1179 | 1167 | |
---|
1180 | 1168 | /* Enable any disabled outputs */ |
---|
.. | .. |
---|
1208 | 1196 | |
---|
1209 | 1197 | static const struct snd_soc_dai_ops wm8991_ops = { |
---|
1210 | 1198 | .hw_params = wm8991_hw_params, |
---|
1211 | | - .digital_mute = wm8991_mute, |
---|
| 1199 | + .mute_stream = wm8991_mute, |
---|
1212 | 1200 | .set_fmt = wm8991_set_dai_fmt, |
---|
1213 | 1201 | .set_clkdiv = wm8991_set_dai_clkdiv, |
---|
1214 | | - .set_pll = wm8991_set_dai_pll |
---|
| 1202 | + .set_pll = wm8991_set_dai_pll, |
---|
| 1203 | + .no_capture_mute = 1, |
---|
1215 | 1204 | }; |
---|
1216 | 1205 | |
---|
1217 | 1206 | /* |
---|