forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/codecs/wm8350.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * wm8350.c -- WM8350 ALSA SoC audio driver
34 *
45 * Copyright (C) 2007-12 Wolfson Microelectronics PLC.
56 *
67 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
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/module.h>
....@@ -334,7 +331,7 @@
334331 return ret;
335332
336333 /* now hit the volume update bits (always bit 8) */
337
- val = snd_soc_component_read32(component, reg);
334
+ val = snd_soc_component_read(component, reg);
338335 snd_soc_component_write(component, reg, val | WM8350_OUT1_VU);
339336 return 1;
340337 }
....@@ -769,7 +766,7 @@
769766 case WM8350_MCLK_SEL_PLL_32K:
770767 wm8350_set_bits(wm8350, WM8350_CLOCK_CONTROL_1,
771768 WM8350_MCLK_SEL);
772
- fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) &
769
+ fll_4 = snd_soc_component_read(component, WM8350_FLL_CONTROL_4) &
773770 ~WM8350_FLL_CLK_SRC_MASK;
774771 snd_soc_component_write(component, WM8350_FLL_CONTROL_4, fll_4 | clk_id);
775772 break;
....@@ -793,37 +790,37 @@
793790
794791 switch (div_id) {
795792 case WM8350_ADC_CLKDIV:
796
- val = snd_soc_component_read32(component, WM8350_ADC_DIVIDER) &
793
+ val = snd_soc_component_read(component, WM8350_ADC_DIVIDER) &
797794 ~WM8350_ADC_CLKDIV_MASK;
798795 snd_soc_component_write(component, WM8350_ADC_DIVIDER, val | div);
799796 break;
800797 case WM8350_DAC_CLKDIV:
801
- val = snd_soc_component_read32(component, WM8350_DAC_CLOCK_CONTROL) &
798
+ val = snd_soc_component_read(component, WM8350_DAC_CLOCK_CONTROL) &
802799 ~WM8350_DAC_CLKDIV_MASK;
803800 snd_soc_component_write(component, WM8350_DAC_CLOCK_CONTROL, val | div);
804801 break;
805802 case WM8350_BCLK_CLKDIV:
806
- val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) &
803
+ val = snd_soc_component_read(component, WM8350_CLOCK_CONTROL_1) &
807804 ~WM8350_BCLK_DIV_MASK;
808805 snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div);
809806 break;
810807 case WM8350_OPCLK_CLKDIV:
811
- val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) &
808
+ val = snd_soc_component_read(component, WM8350_CLOCK_CONTROL_1) &
812809 ~WM8350_OPCLK_DIV_MASK;
813810 snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div);
814811 break;
815812 case WM8350_SYS_CLKDIV:
816
- val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) &
813
+ val = snd_soc_component_read(component, WM8350_CLOCK_CONTROL_1) &
817814 ~WM8350_MCLK_DIV_MASK;
818815 snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div);
819816 break;
820817 case WM8350_DACLR_CLKDIV:
821
- val = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) &
818
+ val = snd_soc_component_read(component, WM8350_DAC_LR_RATE) &
822819 ~WM8350_DACLRC_RATE_MASK;
823820 snd_soc_component_write(component, WM8350_DAC_LR_RATE, val | div);
824821 break;
825822 case WM8350_ADCLR_CLKDIV:
826
- val = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) &
823
+ val = snd_soc_component_read(component, WM8350_ADC_LR_RATE) &
827824 ~WM8350_ADCLRC_RATE_MASK;
828825 snd_soc_component_write(component, WM8350_ADC_LR_RATE, val | div);
829826 break;
....@@ -837,13 +834,13 @@
837834 static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
838835 {
839836 struct snd_soc_component *component = codec_dai->component;
840
- u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) &
837
+ u16 iface = snd_soc_component_read(component, WM8350_AI_FORMATING) &
841838 ~(WM8350_AIF_BCLK_INV | WM8350_AIF_LRCLK_INV | WM8350_AIF_FMT_MASK);
842
- u16 master = snd_soc_component_read32(component, WM8350_AI_DAC_CONTROL) &
839
+ u16 master = snd_soc_component_read(component, WM8350_AI_DAC_CONTROL) &
843840 ~WM8350_BCLK_MSTR;
844
- u16 dac_lrc = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) &
841
+ u16 dac_lrc = snd_soc_component_read(component, WM8350_DAC_LR_RATE) &
845842 ~WM8350_DACLRC_ENA;
846
- u16 adc_lrc = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) &
843
+ u16 adc_lrc = snd_soc_component_read(component, WM8350_ADC_LR_RATE) &
847844 ~WM8350_ADCLRC_ENA;
848845
849846 /* set master/slave audio interface */
....@@ -910,7 +907,7 @@
910907 struct snd_soc_component *component = codec_dai->component;
911908 struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component);
912909 struct wm8350 *wm8350 = wm8350_data->wm8350;
913
- u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) &
910
+ u16 iface = snd_soc_component_read(component, WM8350_AI_FORMATING) &
914911 ~WM8350_AIF_WL_MASK;
915912
916913 /* bit size */
....@@ -945,7 +942,7 @@
945942 return 0;
946943 }
947944
948
-static int wm8350_mute(struct snd_soc_dai *dai, int mute)
945
+static int wm8350_mute(struct snd_soc_dai *dai, int mute, int direction)
949946 {
950947 struct snd_soc_component *component = dai->component;
951948 unsigned int val;
....@@ -1050,7 +1047,7 @@
10501047 fll_div.ratio);
10511048
10521049 /* set up N.K & dividers */
1053
- fll_1 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_1) &
1050
+ fll_1 = snd_soc_component_read(component, WM8350_FLL_CONTROL_1) &
10541051 ~(WM8350_FLL_OUTDIV_MASK | WM8350_FLL_RSP_RATE_MASK | 0xc000);
10551052 snd_soc_component_write(component, WM8350_FLL_CONTROL_1,
10561053 fll_1 | (fll_div.div << 8) | 0x50);
....@@ -1058,7 +1055,7 @@
10581055 (fll_div.ratio << 11) | (fll_div.
10591056 n & WM8350_FLL_N_MASK));
10601057 snd_soc_component_write(component, WM8350_FLL_CONTROL_3, fll_div.k);
1061
- fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) &
1058
+ fll_4 = snd_soc_component_read(component, WM8350_FLL_CONTROL_4) &
10621059 ~(WM8350_FLL_FRAC | WM8350_FLL_SLOW_LOCK_REF);
10631060 snd_soc_component_write(component, WM8350_FLL_CONTROL_4,
10641061 fll_4 | (fll_div.k ? WM8350_FLL_FRAC : 0) |
....@@ -1429,11 +1426,12 @@
14291426
14301427 static const struct snd_soc_dai_ops wm8350_dai_ops = {
14311428 .hw_params = wm8350_pcm_hw_params,
1432
- .digital_mute = wm8350_mute,
1429
+ .mute_stream = wm8350_mute,
14331430 .set_fmt = wm8350_set_dai_fmt,
14341431 .set_sysclk = wm8350_set_dai_sysclk,
14351432 .set_pll = wm8350_set_fll,
14361433 .set_clkdiv = wm8350_set_clkdiv,
1434
+ .no_capture_mute = 1,
14371435 };
14381436
14391437 static struct snd_soc_dai_driver wm8350_dai = {
....@@ -1538,18 +1536,38 @@
15381536 wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
15391537 WM8350_JDL_ENA | WM8350_JDR_ENA);
15401538
1541
- wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L,
1539
+ ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L,
15421540 wm8350_hpl_jack_handler, 0, "Left jack detect",
15431541 priv);
1544
- wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R,
1542
+ if (ret != 0)
1543
+ goto err;
1544
+
1545
+ ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R,
15451546 wm8350_hpr_jack_handler, 0, "Right jack detect",
15461547 priv);
1547
- wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD,
1548
+ if (ret != 0)
1549
+ goto free_jck_det_l;
1550
+
1551
+ ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD,
15481552 wm8350_mic_handler, 0, "Microphone short", priv);
1549
- wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD,
1553
+ if (ret != 0)
1554
+ goto free_jck_det_r;
1555
+
1556
+ ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD,
15501557 wm8350_mic_handler, 0, "Microphone detect", priv);
1558
+ if (ret != 0)
1559
+ goto free_micscd;
15511560
15521561 return 0;
1562
+
1563
+free_micscd:
1564
+ wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, priv);
1565
+free_jck_det_r:
1566
+ wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, priv);
1567
+free_jck_det_l:
1568
+ wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, priv);
1569
+err:
1570
+ return ret;
15531571 }
15541572
15551573 static void wm8350_component_remove(struct snd_soc_component *component)