| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * wm8753.c -- WM8753 ALSA Soc Audio driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2003-11 Wolfson Microelectronics PLC. |
|---|
| 5 | 6 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> |
|---|
| 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 | 7 | * |
|---|
| 12 | 8 | * Notes: |
|---|
| 13 | 9 | * The WM8753 is a low power, high quality stereo codec with integrated PCM |
|---|
| .. | .. |
|---|
| 28 | 24 | * |
|---|
| 29 | 25 | * The driver can now fast switch between the DAI configurations via a |
|---|
| 30 | 26 | * an alsa kcontrol. This allows the PCM to remain open. |
|---|
| 31 | | - * |
|---|
| 32 | 27 | */ |
|---|
| 33 | 28 | |
|---|
| 34 | 29 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 246 | 241 | if (wm8753->dai_func == ucontrol->value.enumerated.item[0]) |
|---|
| 247 | 242 | return 0; |
|---|
| 248 | 243 | |
|---|
| 249 | | - if (snd_soc_component_is_active(component)) |
|---|
| 244 | + if (snd_soc_component_active(component)) |
|---|
| 250 | 245 | return -EBUSY; |
|---|
| 251 | 246 | |
|---|
| 252 | | - ioctl = snd_soc_component_read32(component, WM8753_IOCTL); |
|---|
| 247 | + ioctl = snd_soc_component_read(component, WM8753_IOCTL); |
|---|
| 253 | 248 | |
|---|
| 254 | 249 | wm8753->dai_func = ucontrol->value.enumerated.item[0]; |
|---|
| 255 | 250 | |
|---|
| .. | .. |
|---|
| 753 | 748 | if (pll_id == WM8753_PLL1) { |
|---|
| 754 | 749 | offset = 0; |
|---|
| 755 | 750 | enable = 0x10; |
|---|
| 756 | | - reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xffef; |
|---|
| 751 | + reg = snd_soc_component_read(component, WM8753_CLOCK) & 0xffef; |
|---|
| 757 | 752 | } else { |
|---|
| 758 | 753 | offset = 4; |
|---|
| 759 | 754 | enable = 0x8; |
|---|
| 760 | | - reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfff7; |
|---|
| 755 | + reg = snd_soc_component_read(component, WM8753_CLOCK) & 0xfff7; |
|---|
| 761 | 756 | } |
|---|
| 762 | 757 | |
|---|
| 763 | 758 | if (!freq_in || !freq_out) { |
|---|
| .. | .. |
|---|
| 893 | 888 | static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_component *component, |
|---|
| 894 | 889 | unsigned int fmt) |
|---|
| 895 | 890 | { |
|---|
| 896 | | - u16 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x01ec; |
|---|
| 891 | + u16 voice = snd_soc_component_read(component, WM8753_PCM) & 0x01ec; |
|---|
| 897 | 892 | |
|---|
| 898 | 893 | /* interface format */ |
|---|
| 899 | 894 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
|---|
| .. | .. |
|---|
| 928 | 923 | { |
|---|
| 929 | 924 | struct snd_soc_component *component = dai->component; |
|---|
| 930 | 925 | struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); |
|---|
| 931 | | - u16 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x01f3; |
|---|
| 932 | | - u16 srate = snd_soc_component_read32(component, WM8753_SRATE1) & 0x017f; |
|---|
| 926 | + u16 voice = snd_soc_component_read(component, WM8753_PCM) & 0x01f3; |
|---|
| 927 | + u16 srate = snd_soc_component_read(component, WM8753_SRATE1) & 0x017f; |
|---|
| 933 | 928 | |
|---|
| 934 | 929 | /* bit size */ |
|---|
| 935 | 930 | switch (params_width(params)) { |
|---|
| .. | .. |
|---|
| 963 | 958 | { |
|---|
| 964 | 959 | u16 voice, ioctl; |
|---|
| 965 | 960 | |
|---|
| 966 | | - voice = snd_soc_component_read32(component, WM8753_PCM) & 0x011f; |
|---|
| 967 | | - ioctl = snd_soc_component_read32(component, WM8753_IOCTL) & 0x015d; |
|---|
| 961 | + voice = snd_soc_component_read(component, WM8753_PCM) & 0x011f; |
|---|
| 962 | + ioctl = snd_soc_component_read(component, WM8753_IOCTL) & 0x015d; |
|---|
| 968 | 963 | |
|---|
| 969 | 964 | /* set master/slave audio interface */ |
|---|
| 970 | 965 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
|---|
| 971 | 966 | case SND_SOC_DAIFMT_CBS_CFS: |
|---|
| 972 | 967 | break; |
|---|
| 973 | 968 | case SND_SOC_DAIFMT_CBM_CFM: |
|---|
| 974 | | - ioctl |= 0x2; /* fall through */ |
|---|
| 969 | + ioctl |= 0x2; |
|---|
| 970 | + fallthrough; |
|---|
| 975 | 971 | case SND_SOC_DAIFMT_CBM_CFS: |
|---|
| 976 | 972 | voice |= 0x0040; |
|---|
| 977 | 973 | break; |
|---|
| .. | .. |
|---|
| 1031 | 1027 | |
|---|
| 1032 | 1028 | switch (div_id) { |
|---|
| 1033 | 1029 | case WM8753_PCMDIV: |
|---|
| 1034 | | - reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0x003f; |
|---|
| 1030 | + reg = snd_soc_component_read(component, WM8753_CLOCK) & 0x003f; |
|---|
| 1035 | 1031 | snd_soc_component_write(component, WM8753_CLOCK, reg | div); |
|---|
| 1036 | 1032 | break; |
|---|
| 1037 | 1033 | case WM8753_BCLKDIV: |
|---|
| 1038 | | - reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x01c7; |
|---|
| 1034 | + reg = snd_soc_component_read(component, WM8753_SRATE2) & 0x01c7; |
|---|
| 1039 | 1035 | snd_soc_component_write(component, WM8753_SRATE2, reg | div); |
|---|
| 1040 | 1036 | break; |
|---|
| 1041 | 1037 | case WM8753_VXCLKDIV: |
|---|
| 1042 | | - reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x003f; |
|---|
| 1038 | + reg = snd_soc_component_read(component, WM8753_SRATE2) & 0x003f; |
|---|
| 1043 | 1039 | snd_soc_component_write(component, WM8753_SRATE2, reg | div); |
|---|
| 1044 | 1040 | break; |
|---|
| 1045 | 1041 | default: |
|---|
| .. | .. |
|---|
| 1054 | 1050 | static int wm8753_hdac_set_dai_fmt(struct snd_soc_component *component, |
|---|
| 1055 | 1051 | unsigned int fmt) |
|---|
| 1056 | 1052 | { |
|---|
| 1057 | | - u16 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x01e0; |
|---|
| 1053 | + u16 hifi = snd_soc_component_read(component, WM8753_HIFI) & 0x01e0; |
|---|
| 1058 | 1054 | |
|---|
| 1059 | 1055 | /* interface format */ |
|---|
| 1060 | 1056 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
|---|
| .. | .. |
|---|
| 1088 | 1084 | { |
|---|
| 1089 | 1085 | u16 ioctl, hifi; |
|---|
| 1090 | 1086 | |
|---|
| 1091 | | - hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x013f; |
|---|
| 1092 | | - ioctl = snd_soc_component_read32(component, WM8753_IOCTL) & 0x00ae; |
|---|
| 1087 | + hifi = snd_soc_component_read(component, WM8753_HIFI) & 0x013f; |
|---|
| 1088 | + ioctl = snd_soc_component_read(component, WM8753_IOCTL) & 0x00ae; |
|---|
| 1093 | 1089 | |
|---|
| 1094 | 1090 | /* set master/slave audio interface */ |
|---|
| 1095 | 1091 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
|---|
| 1096 | 1092 | case SND_SOC_DAIFMT_CBS_CFS: |
|---|
| 1097 | 1093 | break; |
|---|
| 1098 | 1094 | case SND_SOC_DAIFMT_CBM_CFM: |
|---|
| 1099 | | - ioctl |= 0x1; /* fall through */ |
|---|
| 1095 | + ioctl |= 0x1; |
|---|
| 1096 | + fallthrough; |
|---|
| 1100 | 1097 | case SND_SOC_DAIFMT_CBM_CFS: |
|---|
| 1101 | 1098 | hifi |= 0x0040; |
|---|
| 1102 | 1099 | break; |
|---|
| .. | .. |
|---|
| 1157 | 1154 | { |
|---|
| 1158 | 1155 | struct snd_soc_component *component = dai->component; |
|---|
| 1159 | 1156 | struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); |
|---|
| 1160 | | - u16 srate = snd_soc_component_read32(component, WM8753_SRATE1) & 0x01c0; |
|---|
| 1161 | | - u16 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x01f3; |
|---|
| 1157 | + u16 srate = snd_soc_component_read(component, WM8753_SRATE1) & 0x01c0; |
|---|
| 1158 | + u16 hifi = snd_soc_component_read(component, WM8753_HIFI) & 0x01f3; |
|---|
| 1162 | 1159 | int coeff; |
|---|
| 1163 | 1160 | |
|---|
| 1164 | 1161 | /* is digital filter coefficient valid ? */ |
|---|
| .. | .. |
|---|
| 1195 | 1192 | u16 clock; |
|---|
| 1196 | 1193 | |
|---|
| 1197 | 1194 | /* set clk source as pcmclk */ |
|---|
| 1198 | | - clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb; |
|---|
| 1195 | + clock = snd_soc_component_read(component, WM8753_CLOCK) & 0xfffb; |
|---|
| 1199 | 1196 | snd_soc_component_write(component, WM8753_CLOCK, clock); |
|---|
| 1200 | 1197 | |
|---|
| 1201 | 1198 | return wm8753_vdac_adc_set_dai_fmt(component, fmt); |
|---|
| .. | .. |
|---|
| 1213 | 1210 | u16 clock; |
|---|
| 1214 | 1211 | |
|---|
| 1215 | 1212 | /* set clk source as pcmclk */ |
|---|
| 1216 | | - clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb; |
|---|
| 1213 | + clock = snd_soc_component_read(component, WM8753_CLOCK) & 0xfffb; |
|---|
| 1217 | 1214 | snd_soc_component_write(component, WM8753_CLOCK, clock); |
|---|
| 1218 | 1215 | |
|---|
| 1219 | 1216 | return wm8753_vdac_adc_set_dai_fmt(component, fmt); |
|---|
| .. | .. |
|---|
| 1225 | 1222 | u16 clock; |
|---|
| 1226 | 1223 | |
|---|
| 1227 | 1224 | /* set clk source as mclk */ |
|---|
| 1228 | | - clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb; |
|---|
| 1225 | + clock = snd_soc_component_read(component, WM8753_CLOCK) & 0xfffb; |
|---|
| 1229 | 1226 | snd_soc_component_write(component, WM8753_CLOCK, clock | 0x4); |
|---|
| 1230 | 1227 | |
|---|
| 1231 | 1228 | if (wm8753_hdac_set_dai_fmt(component, fmt) < 0) |
|---|
| .. | .. |
|---|
| 1300 | 1297 | return wm8753_voice_write_dai_fmt(component, fmt); |
|---|
| 1301 | 1298 | }; |
|---|
| 1302 | 1299 | |
|---|
| 1303 | | -static int wm8753_mute(struct snd_soc_dai *dai, int mute) |
|---|
| 1300 | +static int wm8753_mute(struct snd_soc_dai *dai, int mute, int direction) |
|---|
| 1304 | 1301 | { |
|---|
| 1305 | 1302 | struct snd_soc_component *component = dai->component; |
|---|
| 1306 | | - u16 mute_reg = snd_soc_component_read32(component, WM8753_DAC) & 0xfff7; |
|---|
| 1303 | + u16 mute_reg = snd_soc_component_read(component, WM8753_DAC) & 0xfff7; |
|---|
| 1307 | 1304 | struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); |
|---|
| 1308 | 1305 | |
|---|
| 1309 | 1306 | /* the digital mute covers the HiFi and Voice DAC's on the WM8753. |
|---|
| 1310 | 1307 | * make sure we check if they are not both active when we mute */ |
|---|
| 1311 | 1308 | if (mute && wm8753->dai_func == 1) { |
|---|
| 1312 | | - if (!snd_soc_component_is_active(component)) |
|---|
| 1309 | + if (!snd_soc_component_active(component)) |
|---|
| 1313 | 1310 | snd_soc_component_write(component, WM8753_DAC, mute_reg | 0x8); |
|---|
| 1314 | 1311 | } else { |
|---|
| 1315 | 1312 | if (mute) |
|---|
| .. | .. |
|---|
| 1334 | 1331 | enum snd_soc_bias_level level) |
|---|
| 1335 | 1332 | { |
|---|
| 1336 | 1333 | struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); |
|---|
| 1337 | | - u16 pwr_reg = snd_soc_component_read32(component, WM8753_PWR1) & 0xfe3e; |
|---|
| 1334 | + u16 pwr_reg = snd_soc_component_read(component, WM8753_PWR1) & 0xfe3e; |
|---|
| 1338 | 1335 | |
|---|
| 1339 | 1336 | switch (level) { |
|---|
| 1340 | 1337 | case SND_SOC_BIAS_ON: |
|---|
| .. | .. |
|---|
| 1385 | 1382 | */ |
|---|
| 1386 | 1383 | static const struct snd_soc_dai_ops wm8753_dai_ops_hifi_mode = { |
|---|
| 1387 | 1384 | .hw_params = wm8753_i2s_hw_params, |
|---|
| 1388 | | - .digital_mute = wm8753_mute, |
|---|
| 1385 | + .mute_stream = wm8753_mute, |
|---|
| 1389 | 1386 | .set_fmt = wm8753_hifi_set_dai_fmt, |
|---|
| 1390 | 1387 | .set_clkdiv = wm8753_set_dai_clkdiv, |
|---|
| 1391 | 1388 | .set_pll = wm8753_set_dai_pll, |
|---|
| 1392 | 1389 | .set_sysclk = wm8753_set_dai_sysclk, |
|---|
| 1390 | + .no_capture_mute = 1, |
|---|
| 1393 | 1391 | }; |
|---|
| 1394 | 1392 | |
|---|
| 1395 | 1393 | static const struct snd_soc_dai_ops wm8753_dai_ops_voice_mode = { |
|---|
| 1396 | 1394 | .hw_params = wm8753_pcm_hw_params, |
|---|
| 1397 | | - .digital_mute = wm8753_mute, |
|---|
| 1395 | + .mute_stream = wm8753_mute, |
|---|
| 1398 | 1396 | .set_fmt = wm8753_voice_set_dai_fmt, |
|---|
| 1399 | 1397 | .set_clkdiv = wm8753_set_dai_clkdiv, |
|---|
| 1400 | 1398 | .set_pll = wm8753_set_dai_pll, |
|---|
| 1401 | 1399 | .set_sysclk = wm8753_set_dai_sysclk, |
|---|
| 1400 | + .no_capture_mute = 1, |
|---|
| 1402 | 1401 | }; |
|---|
| 1403 | 1402 | |
|---|
| 1404 | 1403 | static struct snd_soc_dai_driver wm8753_dai[] = { |
|---|