hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/codecs/wm8753.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * wm8753.c -- WM8753 ALSA Soc Audio driver
34 *
45 * Copyright 2003-11 Wolfson Microelectronics PLC.
56 * 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.
117 *
128 * Notes:
139 * The WM8753 is a low power, high quality stereo codec with integrated PCM
....@@ -28,7 +24,6 @@
2824 *
2925 * The driver can now fast switch between the DAI configurations via a
3026 * an alsa kcontrol. This allows the PCM to remain open.
31
- *
3227 */
3328
3429 #include <linux/module.h>
....@@ -246,10 +241,10 @@
246241 if (wm8753->dai_func == ucontrol->value.enumerated.item[0])
247242 return 0;
248243
249
- if (snd_soc_component_is_active(component))
244
+ if (snd_soc_component_active(component))
250245 return -EBUSY;
251246
252
- ioctl = snd_soc_component_read32(component, WM8753_IOCTL);
247
+ ioctl = snd_soc_component_read(component, WM8753_IOCTL);
253248
254249 wm8753->dai_func = ucontrol->value.enumerated.item[0];
255250
....@@ -753,11 +748,11 @@
753748 if (pll_id == WM8753_PLL1) {
754749 offset = 0;
755750 enable = 0x10;
756
- reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xffef;
751
+ reg = snd_soc_component_read(component, WM8753_CLOCK) & 0xffef;
757752 } else {
758753 offset = 4;
759754 enable = 0x8;
760
- reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfff7;
755
+ reg = snd_soc_component_read(component, WM8753_CLOCK) & 0xfff7;
761756 }
762757
763758 if (!freq_in || !freq_out) {
....@@ -893,7 +888,7 @@
893888 static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_component *component,
894889 unsigned int fmt)
895890 {
896
- u16 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x01ec;
891
+ u16 voice = snd_soc_component_read(component, WM8753_PCM) & 0x01ec;
897892
898893 /* interface format */
899894 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
....@@ -928,8 +923,8 @@
928923 {
929924 struct snd_soc_component *component = dai->component;
930925 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;
933928
934929 /* bit size */
935930 switch (params_width(params)) {
....@@ -963,15 +958,16 @@
963958 {
964959 u16 voice, ioctl;
965960
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;
968963
969964 /* set master/slave audio interface */
970965 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
971966 case SND_SOC_DAIFMT_CBS_CFS:
972967 break;
973968 case SND_SOC_DAIFMT_CBM_CFM:
974
- ioctl |= 0x2; /* fall through */
969
+ ioctl |= 0x2;
970
+ fallthrough;
975971 case SND_SOC_DAIFMT_CBM_CFS:
976972 voice |= 0x0040;
977973 break;
....@@ -1031,15 +1027,15 @@
10311027
10321028 switch (div_id) {
10331029 case WM8753_PCMDIV:
1034
- reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0x003f;
1030
+ reg = snd_soc_component_read(component, WM8753_CLOCK) & 0x003f;
10351031 snd_soc_component_write(component, WM8753_CLOCK, reg | div);
10361032 break;
10371033 case WM8753_BCLKDIV:
1038
- reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x01c7;
1034
+ reg = snd_soc_component_read(component, WM8753_SRATE2) & 0x01c7;
10391035 snd_soc_component_write(component, WM8753_SRATE2, reg | div);
10401036 break;
10411037 case WM8753_VXCLKDIV:
1042
- reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x003f;
1038
+ reg = snd_soc_component_read(component, WM8753_SRATE2) & 0x003f;
10431039 snd_soc_component_write(component, WM8753_SRATE2, reg | div);
10441040 break;
10451041 default:
....@@ -1054,7 +1050,7 @@
10541050 static int wm8753_hdac_set_dai_fmt(struct snd_soc_component *component,
10551051 unsigned int fmt)
10561052 {
1057
- u16 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x01e0;
1053
+ u16 hifi = snd_soc_component_read(component, WM8753_HIFI) & 0x01e0;
10581054
10591055 /* interface format */
10601056 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
....@@ -1088,15 +1084,16 @@
10881084 {
10891085 u16 ioctl, hifi;
10901086
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;
10931089
10941090 /* set master/slave audio interface */
10951091 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
10961092 case SND_SOC_DAIFMT_CBS_CFS:
10971093 break;
10981094 case SND_SOC_DAIFMT_CBM_CFM:
1099
- ioctl |= 0x1; /* fall through */
1095
+ ioctl |= 0x1;
1096
+ fallthrough;
11001097 case SND_SOC_DAIFMT_CBM_CFS:
11011098 hifi |= 0x0040;
11021099 break;
....@@ -1157,8 +1154,8 @@
11571154 {
11581155 struct snd_soc_component *component = dai->component;
11591156 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;
11621159 int coeff;
11631160
11641161 /* is digital filter coefficient valid ? */
....@@ -1195,7 +1192,7 @@
11951192 u16 clock;
11961193
11971194 /* 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;
11991196 snd_soc_component_write(component, WM8753_CLOCK, clock);
12001197
12011198 return wm8753_vdac_adc_set_dai_fmt(component, fmt);
....@@ -1213,7 +1210,7 @@
12131210 u16 clock;
12141211
12151212 /* 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;
12171214 snd_soc_component_write(component, WM8753_CLOCK, clock);
12181215
12191216 return wm8753_vdac_adc_set_dai_fmt(component, fmt);
....@@ -1225,7 +1222,7 @@
12251222 u16 clock;
12261223
12271224 /* 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;
12291226 snd_soc_component_write(component, WM8753_CLOCK, clock | 0x4);
12301227
12311228 if (wm8753_hdac_set_dai_fmt(component, fmt) < 0)
....@@ -1300,16 +1297,16 @@
13001297 return wm8753_voice_write_dai_fmt(component, fmt);
13011298 };
13021299
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)
13041301 {
13051302 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;
13071304 struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component);
13081305
13091306 /* the digital mute covers the HiFi and Voice DAC's on the WM8753.
13101307 * make sure we check if they are not both active when we mute */
13111308 if (mute && wm8753->dai_func == 1) {
1312
- if (!snd_soc_component_is_active(component))
1309
+ if (!snd_soc_component_active(component))
13131310 snd_soc_component_write(component, WM8753_DAC, mute_reg | 0x8);
13141311 } else {
13151312 if (mute)
....@@ -1334,7 +1331,7 @@
13341331 enum snd_soc_bias_level level)
13351332 {
13361333 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;
13381335
13391336 switch (level) {
13401337 case SND_SOC_BIAS_ON:
....@@ -1385,20 +1382,22 @@
13851382 */
13861383 static const struct snd_soc_dai_ops wm8753_dai_ops_hifi_mode = {
13871384 .hw_params = wm8753_i2s_hw_params,
1388
- .digital_mute = wm8753_mute,
1385
+ .mute_stream = wm8753_mute,
13891386 .set_fmt = wm8753_hifi_set_dai_fmt,
13901387 .set_clkdiv = wm8753_set_dai_clkdiv,
13911388 .set_pll = wm8753_set_dai_pll,
13921389 .set_sysclk = wm8753_set_dai_sysclk,
1390
+ .no_capture_mute = 1,
13931391 };
13941392
13951393 static const struct snd_soc_dai_ops wm8753_dai_ops_voice_mode = {
13961394 .hw_params = wm8753_pcm_hw_params,
1397
- .digital_mute = wm8753_mute,
1395
+ .mute_stream = wm8753_mute,
13981396 .set_fmt = wm8753_voice_set_dai_fmt,
13991397 .set_clkdiv = wm8753_set_dai_clkdiv,
14001398 .set_pll = wm8753_set_dai_pll,
14011399 .set_sysclk = wm8753_set_dai_sysclk,
1400
+ .no_capture_mute = 1,
14021401 };
14031402
14041403 static struct snd_soc_dai_driver wm8753_dai[] = {