hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/codecs/wm8974.c
....@@ -1,18 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * wm8974.c -- WM8974 ALSA Soc Audio driver
34 *
45 * Copyright 2006-2009 Wolfson Microelectronics PLC.
56 *
67 * Author: Liam Girdwood <Liam.Girdwood@wolfsonmicro.com>
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.
118 */
129
1310 #include <linux/clk.h>
1411 #include <linux/module.h>
15
-#include <linux/moduleparam.h>
1612 #include <linux/kernel.h>
1713 #include <linux/init.h>
1814 #include <linux/delay.h>
....@@ -192,7 +188,7 @@
192188
193189 /* Boost mixer */
194190 static const struct snd_kcontrol_new wm8974_boost_mixer[] = {
195
-SOC_DAPM_SINGLE("Aux Switch", WM8974_INPPGA, 6, 1, 0),
191
+SOC_DAPM_SINGLE("Aux Switch", WM8974_INPPGA, 6, 1, 1),
196192 };
197193
198194 /* Input PGA */
....@@ -201,14 +197,6 @@
201197 SOC_DAPM_SINGLE("MicN Switch", WM8974_INPUT, 1, 1, 0),
202198 SOC_DAPM_SINGLE("MicP Switch", WM8974_INPUT, 0, 1, 0),
203199 };
204
-
205
-/* AUX Input boost vol */
206
-static const struct snd_kcontrol_new wm8974_aux_boost_controls =
207
-SOC_DAPM_SINGLE("Aux Volume", WM8974_ADCBOOST, 0, 7, 0);
208
-
209
-/* Mic Input boost vol */
210
-static const struct snd_kcontrol_new wm8974_mic_boost_controls =
211
-SOC_DAPM_SINGLE("Mic Volume", WM8974_ADCBOOST, 4, 7, 0);
212200
213201 static const struct snd_soc_dapm_widget wm8974_dapm_widgets[] = {
214202 SND_SOC_DAPM_MIXER("Speaker Mixer", WM8974_POWER3, 2, 0,
....@@ -332,11 +320,11 @@
332320
333321 if (freq_in == 0 || freq_out == 0) {
334322 /* Clock CODEC directly from MCLK */
335
- reg = snd_soc_component_read32(component, WM8974_CLOCK);
323
+ reg = snd_soc_component_read(component, WM8974_CLOCK);
336324 snd_soc_component_write(component, WM8974_CLOCK, reg & 0x0ff);
337325
338326 /* Turn off PLL */
339
- reg = snd_soc_component_read32(component, WM8974_POWER1);
327
+ reg = snd_soc_component_read(component, WM8974_POWER1);
340328 snd_soc_component_write(component, WM8974_POWER1, reg & 0x1df);
341329 return 0;
342330 }
....@@ -347,11 +335,11 @@
347335 snd_soc_component_write(component, WM8974_PLLK1, pll_div.k >> 18);
348336 snd_soc_component_write(component, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff);
349337 snd_soc_component_write(component, WM8974_PLLK3, pll_div.k & 0x1ff);
350
- reg = snd_soc_component_read32(component, WM8974_POWER1);
338
+ reg = snd_soc_component_read(component, WM8974_POWER1);
351339 snd_soc_component_write(component, WM8974_POWER1, reg | 0x020);
352340
353341 /* Run CODEC from PLL instead of MCLK */
354
- reg = snd_soc_component_read32(component, WM8974_CLOCK);
342
+ reg = snd_soc_component_read(component, WM8974_CLOCK);
355343 snd_soc_component_write(component, WM8974_CLOCK, reg | 0x100);
356344
357345 return 0;
....@@ -368,15 +356,15 @@
368356
369357 switch (div_id) {
370358 case WM8974_OPCLKDIV:
371
- reg = snd_soc_component_read32(component, WM8974_GPIO) & 0x1cf;
359
+ reg = snd_soc_component_read(component, WM8974_GPIO) & 0x1cf;
372360 snd_soc_component_write(component, WM8974_GPIO, reg | div);
373361 break;
374362 case WM8974_MCLKDIV:
375
- reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x11f;
363
+ reg = snd_soc_component_read(component, WM8974_CLOCK) & 0x11f;
376364 snd_soc_component_write(component, WM8974_CLOCK, reg | div);
377365 break;
378366 case WM8974_BCLKDIV:
379
- reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1e3;
367
+ reg = snd_soc_component_read(component, WM8974_CLOCK) & 0x1e3;
380368 snd_soc_component_write(component, WM8974_CLOCK, reg | div);
381369 break;
382370 default:
....@@ -464,7 +452,7 @@
464452 {
465453 struct snd_soc_component *component = codec_dai->component;
466454 u16 iface = 0;
467
- u16 clk = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1fe;
455
+ u16 clk = snd_soc_component_read(component, WM8974_CLOCK) & 0x1fe;
468456
469457 /* set master/slave audio interface */
470458 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
....@@ -488,6 +476,10 @@
488476 iface |= 0x0008;
489477 break;
490478 case SND_SOC_DAIFMT_DSP_A:
479
+ if ((fmt & SND_SOC_DAIFMT_INV_MASK) == SND_SOC_DAIFMT_IB_IF ||
480
+ (fmt & SND_SOC_DAIFMT_INV_MASK) == SND_SOC_DAIFMT_NB_IF) {
481
+ return -EINVAL;
482
+ }
491483 iface |= 0x00018;
492484 break;
493485 default:
....@@ -522,8 +514,8 @@
522514 {
523515 struct snd_soc_component *component = dai->component;
524516 struct wm8974_priv *priv = snd_soc_component_get_drvdata(component);
525
- u16 iface = snd_soc_component_read32(component, WM8974_IFACE) & 0x19f;
526
- u16 adn = snd_soc_component_read32(component, WM8974_ADD) & 0x1f1;
517
+ u16 iface = snd_soc_component_read(component, WM8974_IFACE) & 0x19f;
518
+ u16 adn = snd_soc_component_read(component, WM8974_ADD) & 0x1f1;
527519 int err;
528520
529521 priv->fs = params_rate(params);
....@@ -573,10 +565,10 @@
573565 return 0;
574566 }
575567
576
-static int wm8974_mute(struct snd_soc_dai *dai, int mute)
568
+static int wm8974_mute(struct snd_soc_dai *dai, int mute, int direction)
577569 {
578570 struct snd_soc_component *component = dai->component;
579
- u16 mute_reg = snd_soc_component_read32(component, WM8974_DAC) & 0xffbf;
571
+ u16 mute_reg = snd_soc_component_read(component, WM8974_DAC) & 0xffbf;
580572
581573 if (mute)
582574 snd_soc_component_write(component, WM8974_DAC, mute_reg | 0x40);
....@@ -589,7 +581,7 @@
589581 static int wm8974_set_bias_level(struct snd_soc_component *component,
590582 enum snd_soc_bias_level level)
591583 {
592
- u16 power1 = snd_soc_component_read32(component, WM8974_POWER1) & ~0x3;
584
+ u16 power1 = snd_soc_component_read(component, WM8974_POWER1) & ~0x3;
593585
594586 switch (level) {
595587 case SND_SOC_BIAS_ON:
....@@ -628,7 +620,7 @@
628620 {
629621 struct snd_soc_component *component = dai->component;
630622 struct wm8974_priv *priv = snd_soc_component_get_drvdata(component);
631
- u16 power1 = snd_soc_component_read32(component, WM8974_POWER1);
623
+ u16 power1 = snd_soc_component_read(component, WM8974_POWER1);
632624
633625 clk_prepare_enable(priv->mclk_in);
634626 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
....@@ -644,7 +636,7 @@
644636 {
645637 struct snd_soc_component *component = dai->component;
646638 struct wm8974_priv *priv = snd_soc_component_get_drvdata(component);
647
- u16 power1 = snd_soc_component_read32(component, WM8974_POWER1);
639
+ u16 power1 = snd_soc_component_read(component, WM8974_POWER1);
648640
649641 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
650642 power1 &= ~0x10;
....@@ -660,13 +652,14 @@
660652
661653 static const struct snd_soc_dai_ops wm8974_ops = {
662654 .hw_params = wm8974_pcm_hw_params,
663
- .digital_mute = wm8974_mute,
655
+ .mute_stream = wm8974_mute,
664656 .set_fmt = wm8974_set_dai_fmt,
665657 .set_clkdiv = wm8974_set_dai_clkdiv,
666658 .set_pll = wm8974_set_dai_pll,
667659 .set_sysclk = wm8974_set_dai_sysclk,
668660 .startup = wm8974_startup,
669661 .shutdown = wm8974_shutdown,
662
+ .no_capture_mute = 1,
670663 };
671664
672665 static struct snd_soc_dai_driver wm8974_dai = {