hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/codecs/wm8940.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * wm8940.c -- WM8940 ALSA Soc Audio driver
34 *
....@@ -6,10 +7,6 @@
67 * Based on wm8510.c
78 * Copyright 2006 Wolfson Microelectronics PLC.
89 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License version 2 as
12
- * published by the Free Software Foundation.
1310 *
1411 * Not currently handled:
1512 * Notch filter control
....@@ -340,8 +337,8 @@
340337 unsigned int fmt)
341338 {
342339 struct snd_soc_component *component = codec_dai->component;
343
- u16 iface = snd_soc_component_read32(component, WM8940_IFACE) & 0xFE67;
344
- u16 clk = snd_soc_component_read32(component, WM8940_CLOCK) & 0x1fe;
340
+ u16 iface = snd_soc_component_read(component, WM8940_IFACE) & 0xFE67;
341
+ u16 clk = snd_soc_component_read(component, WM8940_CLOCK) & 0x1fe;
345342
346343 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
347344 case SND_SOC_DAIFMT_CBM_CFM:
....@@ -395,9 +392,9 @@
395392 struct snd_soc_dai *dai)
396393 {
397394 struct snd_soc_component *component = dai->component;
398
- u16 iface = snd_soc_component_read32(component, WM8940_IFACE) & 0xFD9F;
399
- u16 addcntrl = snd_soc_component_read32(component, WM8940_ADDCNTRL) & 0xFFF1;
400
- u16 companding = snd_soc_component_read32(component,
395
+ u16 iface = snd_soc_component_read(component, WM8940_IFACE) & 0xFD9F;
396
+ u16 addcntrl = snd_soc_component_read(component, WM8940_ADDCNTRL) & 0xFFF1;
397
+ u16 companding = snd_soc_component_read(component,
401398 WM8940_COMPANDINGCTL) & 0xFFDF;
402399 int ret;
403400
....@@ -455,10 +452,10 @@
455452 return ret;
456453 }
457454
458
-static int wm8940_mute(struct snd_soc_dai *dai, int mute)
455
+static int wm8940_mute(struct snd_soc_dai *dai, int mute, int direction)
459456 {
460457 struct snd_soc_component *component = dai->component;
461
- u16 mute_reg = snd_soc_component_read32(component, WM8940_DAC) & 0xffbf;
458
+ u16 mute_reg = snd_soc_component_read(component, WM8940_DAC) & 0xffbf;
462459
463460 if (mute)
464461 mute_reg |= 0x40;
....@@ -471,7 +468,7 @@
471468 {
472469 struct wm8940_priv *wm8940 = snd_soc_component_get_drvdata(component);
473470 u16 val;
474
- u16 pwr_reg = snd_soc_component_read32(component, WM8940_POWER1) & 0x1F0;
471
+ u16 pwr_reg = snd_soc_component_read(component, WM8940_POWER1) & 0x1F0;
475472 int ret = 0;
476473
477474 switch (level) {
....@@ -479,7 +476,7 @@
479476 /* ensure bufioen and biasen */
480477 pwr_reg |= (1 << 2) | (1 << 3);
481478 /* Enable thermal shutdown */
482
- val = snd_soc_component_read32(component, WM8940_OUTPUTCTL);
479
+ val = snd_soc_component_read(component, WM8940_OUTPUTCTL);
483480 ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, val | 0x2);
484481 if (ret)
485482 break;
....@@ -580,12 +577,12 @@
580577 u16 reg;
581578
582579 /* Turn off PLL */
583
- reg = snd_soc_component_read32(component, WM8940_POWER1);
580
+ reg = snd_soc_component_read(component, WM8940_POWER1);
584581 snd_soc_component_write(component, WM8940_POWER1, reg & 0x1df);
585582
586583 if (freq_in == 0 || freq_out == 0) {
587584 /* Clock CODEC directly from MCLK */
588
- reg = snd_soc_component_read32(component, WM8940_CLOCK);
585
+ reg = snd_soc_component_read(component, WM8940_CLOCK);
589586 snd_soc_component_write(component, WM8940_CLOCK, reg & 0x0ff);
590587 /* Pll power down */
591588 snd_soc_component_write(component, WM8940_PLLN, (1 << 7));
....@@ -604,11 +601,11 @@
604601 snd_soc_component_write(component, WM8940_PLLK2, (pll_div.k >> 9) & 0x1ff);
605602 snd_soc_component_write(component, WM8940_PLLK3, pll_div.k & 0x1ff);
606603 /* Enable the PLL */
607
- reg = snd_soc_component_read32(component, WM8940_POWER1);
604
+ reg = snd_soc_component_read(component, WM8940_POWER1);
608605 snd_soc_component_write(component, WM8940_POWER1, reg | 0x020);
609606
610607 /* Run CODEC from PLL instead of MCLK */
611
- reg = snd_soc_component_read32(component, WM8940_CLOCK);
608
+ reg = snd_soc_component_read(component, WM8940_CLOCK);
612609 snd_soc_component_write(component, WM8940_CLOCK, reg | 0x100);
613610
614611 return 0;
....@@ -641,15 +638,15 @@
641638
642639 switch (div_id) {
643640 case WM8940_BCLKDIV:
644
- reg = snd_soc_component_read32(component, WM8940_CLOCK) & 0xFFE3;
641
+ reg = snd_soc_component_read(component, WM8940_CLOCK) & 0xFFE3;
645642 ret = snd_soc_component_write(component, WM8940_CLOCK, reg | (div << 2));
646643 break;
647644 case WM8940_MCLKDIV:
648
- reg = snd_soc_component_read32(component, WM8940_CLOCK) & 0xFF1F;
645
+ reg = snd_soc_component_read(component, WM8940_CLOCK) & 0xFF1F;
649646 ret = snd_soc_component_write(component, WM8940_CLOCK, reg | (div << 5));
650647 break;
651648 case WM8940_OPCLKDIV:
652
- reg = snd_soc_component_read32(component, WM8940_GPIO) & 0xFFCF;
649
+ reg = snd_soc_component_read(component, WM8940_GPIO) & 0xFFCF;
653650 ret = snd_soc_component_write(component, WM8940_GPIO, reg | (div << 4));
654651 break;
655652 }
....@@ -667,10 +664,11 @@
667664 static const struct snd_soc_dai_ops wm8940_dai_ops = {
668665 .hw_params = wm8940_i2s_hw_params,
669666 .set_sysclk = wm8940_set_dai_sysclk,
670
- .digital_mute = wm8940_mute,
667
+ .mute_stream = wm8940_mute,
671668 .set_fmt = wm8940_set_dai_fmt,
672669 .set_clkdiv = wm8940_set_dai_clkdiv,
673670 .set_pll = wm8940_set_dai_pll,
671
+ .no_capture_mute = 1,
674672 };
675673
676674 static struct snd_soc_dai_driver wm8940_dai = {
....@@ -714,7 +712,7 @@
714712 if (!pdata)
715713 dev_warn(component->dev, "No platform data supplied\n");
716714 else {
717
- reg = snd_soc_component_read32(component, WM8940_OUTPUTCTL);
715
+ reg = snd_soc_component_read(component, WM8940_OUTPUTCTL);
718716 ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, reg | pdata->vroi);
719717 if (ret < 0)
720718 return ret;