forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/codecs/wm9081.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * wm9081.c -- WM9081 ALSA SoC Audio driver
34 *
45 * Author: Mark Brown
56 *
67 * Copyright 2009-12 Wolfson Microelectronics plc
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
11
- *
128 */
139
1410 #include <linux/module.h>
....@@ -342,7 +338,7 @@
342338 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
343339 unsigned int reg;
344340
345
- reg = snd_soc_component_read32(component, WM9081_ANALOGUE_SPEAKER_2);
341
+ reg = snd_soc_component_read(component, WM9081_ANALOGUE_SPEAKER_2);
346342 if (reg & WM9081_SPK_MODE)
347343 ucontrol->value.enumerated.item[0] = 1;
348344 else
....@@ -361,8 +357,8 @@
361357 struct snd_ctl_elem_value *ucontrol)
362358 {
363359 struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
364
- unsigned int reg_pwr = snd_soc_component_read32(component, WM9081_POWER_MANAGEMENT);
365
- unsigned int reg2 = snd_soc_component_read32(component, WM9081_ANALOGUE_SPEAKER_2);
360
+ unsigned int reg_pwr = snd_soc_component_read(component, WM9081_POWER_MANAGEMENT);
361
+ unsigned int reg2 = snd_soc_component_read(component, WM9081_ANALOGUE_SPEAKER_2);
366362
367363 /* Are we changing anything? */
368364 if (ucontrol->value.enumerated.item[0] ==
....@@ -572,7 +568,7 @@
572568 if (ret != 0)
573569 return ret;
574570
575
- reg5 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_5);
571
+ reg5 = snd_soc_component_read(component, WM9081_FLL_CONTROL_5);
576572 reg5 &= ~WM9081_FLL_CLK_SRC_MASK;
577573
578574 switch (fll_id) {
....@@ -586,14 +582,14 @@
586582 }
587583
588584 /* Disable CLK_SYS while we reconfigure */
589
- clk_sys_reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_3);
585
+ clk_sys_reg = snd_soc_component_read(component, WM9081_CLOCK_CONTROL_3);
590586 if (clk_sys_reg & WM9081_CLK_SYS_ENA)
591587 snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3,
592588 clk_sys_reg & ~WM9081_CLK_SYS_ENA);
593589
594590 /* Any FLL configuration change requires that the FLL be
595591 * disabled first. */
596
- reg1 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_1);
592
+ reg1 = snd_soc_component_read(component, WM9081_FLL_CONTROL_1);
597593 reg1 &= ~WM9081_FLL_ENA;
598594 snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1);
599595
....@@ -609,7 +605,7 @@
609605 (fll_div.fll_fratio << WM9081_FLL_FRATIO_SHIFT));
610606 snd_soc_component_write(component, WM9081_FLL_CONTROL_3, fll_div.k);
611607
612
- reg4 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_4);
608
+ reg4 = snd_soc_component_read(component, WM9081_FLL_CONTROL_4);
613609 reg4 &= ~WM9081_FLL_N_MASK;
614610 reg4 |= fll_div.n << WM9081_FLL_N_SHIFT;
615611 snd_soc_component_write(component, WM9081_FLL_CONTROL_4, reg4);
....@@ -711,14 +707,14 @@
711707 return -EINVAL;
712708 }
713709
714
- reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_1);
710
+ reg = snd_soc_component_read(component, WM9081_CLOCK_CONTROL_1);
715711 if (mclkdiv)
716712 reg |= WM9081_MCLKDIV2;
717713 else
718714 reg &= ~WM9081_MCLKDIV2;
719715 snd_soc_component_write(component, WM9081_CLOCK_CONTROL_1, reg);
720716
721
- reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_3);
717
+ reg = snd_soc_component_read(component, WM9081_CLOCK_CONTROL_3);
722718 if (fll)
723719 reg |= WM9081_CLK_SRC_SEL;
724720 else
....@@ -905,7 +901,7 @@
905901 {
906902 struct snd_soc_component *component = dai->component;
907903 struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
908
- unsigned int aif2 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_2);
904
+ unsigned int aif2 = snd_soc_component_read(component, WM9081_AUDIO_INTERFACE_2);
909905
910906 aif2 &= ~(WM9081_AIF_BCLK_INV | WM9081_AIF_LRCLK_INV |
911907 WM9081_BCLK_DIR | WM9081_LRCLK_DIR | WM9081_AIF_FMT_MASK);
....@@ -933,7 +929,7 @@
933929 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
934930 case SND_SOC_DAIFMT_DSP_B:
935931 aif2 |= WM9081_AIF_LRCLK_INV;
936
- /* fall through */
932
+ fallthrough;
937933 case SND_SOC_DAIFMT_DSP_A:
938934 aif2 |= 0x3;
939935 break;
....@@ -1001,18 +997,18 @@
1001997 int ret, i, best, best_val, cur_val;
1002998 unsigned int clk_ctrl2, aif1, aif2, aif3, aif4;
1003999
1004
- clk_ctrl2 = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_2);
1000
+ clk_ctrl2 = snd_soc_component_read(component, WM9081_CLOCK_CONTROL_2);
10051001 clk_ctrl2 &= ~(WM9081_CLK_SYS_RATE_MASK | WM9081_SAMPLE_RATE_MASK);
10061002
1007
- aif1 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_1);
1003
+ aif1 = snd_soc_component_read(component, WM9081_AUDIO_INTERFACE_1);
10081004
1009
- aif2 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_2);
1005
+ aif2 = snd_soc_component_read(component, WM9081_AUDIO_INTERFACE_2);
10101006 aif2 &= ~WM9081_AIF_WL_MASK;
10111007
1012
- aif3 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_3);
1008
+ aif3 = snd_soc_component_read(component, WM9081_AUDIO_INTERFACE_3);
10131009 aif3 &= ~WM9081_BCLK_DIV_MASK;
10141010
1015
- aif4 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_4);
1011
+ aif4 = snd_soc_component_read(component, WM9081_AUDIO_INTERFACE_4);
10161012 aif4 &= ~WM9081_LRCLK_RATE_MASK;
10171013
10181014 wm9081->fs = params_rate(params);
....@@ -1131,7 +1127,7 @@
11311127 s->name, s->rate);
11321128
11331129 /* If the EQ is enabled then disable it while we write out */
1134
- eq1 = snd_soc_component_read32(component, WM9081_EQ_1) & WM9081_EQ_ENA;
1130
+ eq1 = snd_soc_component_read(component, WM9081_EQ_1) & WM9081_EQ_ENA;
11351131 if (eq1 & WM9081_EQ_ENA)
11361132 snd_soc_component_write(component, WM9081_EQ_1, 0);
11371133
....@@ -1151,12 +1147,12 @@
11511147 return 0;
11521148 }
11531149
1154
-static int wm9081_digital_mute(struct snd_soc_dai *codec_dai, int mute)
1150
+static int wm9081_mute(struct snd_soc_dai *codec_dai, int mute, int direction)
11551151 {
11561152 struct snd_soc_component *component = codec_dai->component;
11571153 unsigned int reg;
11581154
1159
- reg = snd_soc_component_read32(component, WM9081_DAC_DIGITAL_2);
1155
+ reg = snd_soc_component_read(component, WM9081_DAC_DIGITAL_2);
11601156
11611157 if (mute)
11621158 reg |= WM9081_DAC_MUTE;
....@@ -1192,7 +1188,7 @@
11921188 {
11931189 struct snd_soc_component *component = dai->component;
11941190 struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
1195
- unsigned int aif1 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_1);
1191
+ unsigned int aif1 = snd_soc_component_read(component, WM9081_AUDIO_INTERFACE_1);
11961192
11971193 aif1 &= ~(WM9081_AIFDAC_TDM_SLOT_MASK | WM9081_AIFDAC_TDM_MODE_MASK);
11981194
....@@ -1236,8 +1232,9 @@
12361232 static const struct snd_soc_dai_ops wm9081_dai_ops = {
12371233 .hw_params = wm9081_hw_params,
12381234 .set_fmt = wm9081_set_dai_fmt,
1239
- .digital_mute = wm9081_digital_mute,
1235
+ .mute_stream = wm9081_mute,
12401236 .set_tdm_slot = wm9081_set_tdm_slot,
1237
+ .no_capture_mute = 1,
12411238 };
12421239
12431240 /* We report two channels because the CODEC processes a stereo signal, even