Skip to contentSkip to conversation

ASoC: rt5682s: Add driver for ALC5682I-VS codec

PATCH Superseded [email protected] 4 participants 9 messages Aug 26, 2021 – Sep 3, 2021 1 message not in the archive

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ASoC: rt5682s: Add driver for ALC5682I-VS codec

From: Derek Fang <[email protected]>

This is an initial codec driver for Realtek ALC5682I-VS codec.

---
 include/sound/rt5682s.h    |   48 +
 sound/soc/codecs/Kconfig   |    5 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/rt5682s.c | 3231 ++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt5682s.h | 1455 ++++++++++++++++
 5 files changed, 4741 insertions(+)
 create mode 100644 include/sound/rt5682s.h
 create mode 100644 sound/soc/codecs/rt5682s.c
 create mode 100644 sound/soc/codecs/rt5682s.h
include/sound/rt5682s.h new file +48 -0
new file mode 100644
index 000000000000..37ecede2becd
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * linux/sound/rt5682s.h -- Platform data for RT5682I-VS
+ *
+ * Copyright 2021 Realtek Microelectronics
+ */
+
+#ifndef __LINUX_SND_RT5682S_H
+#define __LINUX_SND_RT5682S_H
+
+enum rt5682s_dmic1_data_pin {
+	RT5682S_DMIC1_NULL,
+	RT5682S_DMIC1_DATA_GPIO2,
+	RT5682S_DMIC1_DATA_GPIO5,
+};
+
+enum rt5682s_dmic1_clk_pin {
+	RT5682S_DMIC1_CLK_GPIO1,
+	RT5682S_DMIC1_CLK_GPIO3,
+};
+
+enum rt5682s_jd_src {
+	RT5682S_JD_NULL,
+	RT5682S_JD1,
+};
+
+enum rt5682s_dai_clks {
+	RT5682S_DAI_WCLK_IDX,
+	RT5682S_DAI_BCLK_IDX,
+	RT5682S_DAI_NUM_CLKS,
+};
+
+struct rt5682s_platform_data {
+
+	int ldo1_en; /* GPIO for LDO1_EN */
+
+	enum rt5682s_dmic1_data_pin dmic1_data_pin;
+	enum rt5682s_dmic1_clk_pin dmic1_clk_pin;
+	enum rt5682s_jd_src jd_src;
+	unsigned int dmic_clk_rate;
+	unsigned int dmic_delay;
+	bool dmic_clk_driving_high;
+
+	const char *dai_clk_names[RT5682S_DAI_NUM_CLKS];
+};
+
+#endif
+
sound/soc/codecs/Kconfig +5 -0
index 82ee233a269d..6b3c2cf153db 100644
@@ -180,6 +180,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_RT5677
 	imply SND_SOC_RT5682_I2C
 	imply SND_SOC_RT5682_SDW
+	imply SND_SOC_RT5682S
 	imply SND_SOC_RT700_SDW
 	imply SND_SOC_RT711_SDW
 	imply SND_SOC_RT711_SDCA_SDW
@@ -1249,6 +1250,10 @@ config SND_SOC_RT5682_SDW
 	select SND_SOC_RT5682
 	select REGMAP_SOUNDWIRE
 
+config SND_SOC_RT5682S
+	tristate
+	depends on I2C
+
 config SND_SOC_RT700
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 8dcea2c4604a..42d00aa4ee46 100644
@@ -198,6 +198,7 @@ snd-soc-rt5677-spi-objs := rt5677-spi.o
 snd-soc-rt5682-objs := rt5682.o
 snd-soc-rt5682-sdw-objs := rt5682-sdw.o
 snd-soc-rt5682-i2c-objs := rt5682-i2c.o
+snd-soc-rt5682s-objs := rt5682s.o
 snd-soc-rt700-objs := rt700.o rt700-sdw.o
 snd-soc-rt711-objs := rt711.o rt711-sdw.o
 snd-soc-rt711-sdca-objs := rt711-sdca.o rt711-sdca-sdw.o
@@ -526,6 +527,7 @@ obj-$(CONFIG_SND_SOC_RT5677_SPI)	+= snd-soc-rt5677-spi.o
 obj-$(CONFIG_SND_SOC_RT5682)	+= snd-soc-rt5682.o
 obj-$(CONFIG_SND_SOC_RT5682_I2C)	+= snd-soc-rt5682-i2c.o
 obj-$(CONFIG_SND_SOC_RT5682_SDW)	+= snd-soc-rt5682-sdw.o
+obj-$(CONFIG_SND_SOC_RT5682S)	+= snd-soc-rt5682s.o
 obj-$(CONFIG_SND_SOC_RT700)     += snd-soc-rt700.o
 obj-$(CONFIG_SND_SOC_RT711)     += snd-soc-rt711.o
 obj-$(CONFIG_SND_SOC_RT711_SDCA_SDW)     += snd-soc-rt711-sdca.o
sound/soc/codecs/rt5682s.c new file +3231 -0

2,921 lines not on this page · raw message

sound/soc/codecs/rt5682s.h new file +1455 -0

1,455 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.1

Part of the diff is not shown here. View the raw message.

#1 lore raw

PATCH 2/2 ASoC: dt-bindings: rt5682s: add bindings for rt5682s

From: Derek Fang <[email protected]>

Realtek ALC5682I-VS codec is a ALC5682I-VD variant which supports I2C only.

---
 .../bindings/sound/realtek,rt5682s.yaml       | 99 +++++++++++++++++++
 1 file changed, 99 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml
Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml new file +99 -0
new file mode 100644
index 000000000000..51fa140b1f05
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/realtek,rt5682s.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek rt5682s codec devicetree bindings
+
+maintainers:
+  - Derek Fang <[email protected]>
+
+description: |
+  Rt5682s(ALC5682I-VS) is a rt5682i variant which supports I2C only.
+
+properties:
+  compatible:
+    const: realtek,rt5682s
+
+  reg:
+    maxItems: 1
+    description: I2C address of the device.
+
+  interrupts:
+    description: The CODEC's interrupt output.
+
+  realtek,dmic1-data-pin:
+    enum:
+      - 0 # dmic1 is not used
+      - 1 # using GPIO2 pin as dmic1 data pin
+      - 2 # using GPIO5 pin as dmic1 data pin
+
+  realtek,dmic1-clk-pin:
+    enum:
+      - 0 #using GPIO1 pin as dmic1 clock pin
+      - 1 #using GPIO3 pin as dmic1 clock pin
+
+  realtek,jd-src:
+    enum:
+      - 0 # No JD is used
+      - 1 # using JD1 as JD source
+
+  realtek,ldo1-en-gpios:
+    description: |
+      The GPIO that controls the CODEC's LDO1_EN pin.
+
+  realtek,dmic-clk-rate-hz:
+    description: |
+      Set the clock rate (hz) for the requirement of the particular DMIC.
+
+  realtek,dmic-delay-ms:
+    description: |
+      Set the delay time (ms) for the requirement of the particular DMIC.
+
+  realtek,dmic-clk-driving-high:
+    type: boolean
+    description: |
+      Set the high driving of the DMIC clock out.
+
+  clocks:
+    items:
+      - description: phandle and clock specifier for codec MCLK.
+
+  clock-names:
+    items:
+      const: mclk
+
+  "#clock-cells":
+    const: 1
+
+  clock-output-names:
+    items:
+      - description: Name given for DAI word clock output.
+      - description: Name given for DAI bit clock output.
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+
+example:
+  - |
+    rt5682s {
+        compatible = "realtek,rt5682s";
+        reg = <0x1a>;
+        interrupt-parent = <&gpio>;
+        interrupts = <TEGRA_GPIO(U, 6) IRQ_TYPE_LEVEL_HIGH>;
+        realtek,ldo1-en-gpios =
+            <&gpio TEGRA_GPIO(R, 2) GPIO_ACTIVE_HIGH>;
+        realtek,dmic1-data-pin = <1>;
+        realtek,dmic1-clk-pin = <1>;
+        realtek,jd-src = <1>;
+
+        #clock-cells = <1>;
+        clock-output-names = "rt5682-dai-wclk", "rt5682-dai-bclk";
+
+        clocks = <&osc>;
+        clock-names = "mclk";
+    };
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH 2/2] ASoC: dt-bindings: rt5682s: add bindings for rt5682s

Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml line 35

Quoted 10 lines · On Thu, Aug 26, 2021 at 04:09:38PM +0800, [email protected] wrote:
Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml new file +10 -0
+  realtek,dmic1-data-pin:
+    enum:
+      - 0 # dmic1 is not used
+      - 1 # using GPIO2 pin as dmic1 data pin
+      - 2 # using GPIO5 pin as dmic1 data pin
+
+  realtek,dmic1-clk-pin:
+    enum:
+      - 0 #using GPIO1 pin as dmic1 clock pin
+      - 1 #using GPIO3 pin as dmic1 clock pin

It works but it's a bit weird that there's no unused option on the clock
- I'd expect this to be symmetric.

Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml line 40

Quoted 4 lines
Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml new file +4 -0
+  realtek,jd-src:
+    enum:
+      - 0 # No JD is used
+      - 1 # using JD1 as JD source

Are there other possible JD sources which are not supported yet?

Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml line 52

Quoted 3 lines
Documentation/devicetree/bindings/sound/realtek,rt5682s.yaml new file +3 -0
+  realtek,dmic-delay-ms:
+    description: |
+      Set the delay time (ms) for the requirement of the particular DMIC.

Startup delay or some other delay?

maintainer
#3 lore raw
In reply to [email protected]

On Thu, Aug 26, 2021 at 04:09:37PM +0800, [email protected] wrote:

This looks good, a few small mostly style comments below but nothing substantial:

Quoted 6 lines
sound/soc/codecs/rt5682s.c new file +6 -0
+static int rt5682s_sar_power_mode(struct snd_soc_component *component,
+				int mode, int jd_step)
+{
+	struct rt5682s_priv *rt5682s =
+		snd_soc_component_get_drvdata(component);
+

sound/soc/codecs/rt5682s.c line 697

Quoted 10 lines
sound/soc/codecs/rt5682s.c new file +9 -0
+	mutex_lock(&rt5682s->sar_mutex);
+
+	switch (mode) {
+	case SAR_PWR_SAVING:
+		snd_soc_component_update_bits(component, RT5682S_CBJ_CTRL_3,
+			RT5682S_CBJ_IN_BUF_MASK, RT5682S_CBJ_IN_BUF_DIS);
 
+	default:
+		break;
+	}

Shouldn't there be some sort of warning or error if we get an invalid mode here?

sound/soc/codecs/rt5682s.c line 716

Quoted 13 lines
sound/soc/codecs/rt5682s.c new file +13 -0
+static void rt5682s_enable_push_button_irq(struct snd_soc_component *component,
+		bool enable)
+{
+	if (enable) {
+		snd_soc_component_update_bits(component, RT5682S_SAR_IL_CMD_13,
+			RT5682S_SAR_SOUR_MASK, RT5682S_SAR_SOUR_BTN);
+		snd_soc_component_write(component, RT5682S_IL_CMD_1, 0x0040);
+		snd_soc_component_update_bits(component, RT5682S_4BTN_IL_CMD_2,
+			RT5682S_4BTN_IL_MASK | RT5682S_4BTN_IL_RST_MASK,
+			RT5682S_4BTN_IL_EN | RT5682S_4BTN_IL_NOR);
+		snd_soc_component_update_bits(component, RT5682S_IRQ_CTRL_3,
+			RT5682S_IL_IRQ_MASK, RT5682S_IL_IRQ_EN);
+	} else {

Why not just have separate enable and disable functions, there's no shared code here and it avoids the boolean argument which tends to be unclear?

sound/soc/codecs/rt5682s.c line 1015

Quoted 6 lines
sound/soc/codecs/rt5682s.c new file +6 -0
+static const char * const rt5682s_sar_mode[] = {
+	"Normal", "Saving"
+};
+
+static SOC_ENUM_SINGLE_DECL(rt5682s_sar_mode_enum, 0, 0,
+	rt5682s_sar_mode);

Might be easier to make this a "SAR Power Saving Switch"? Doesn't really matter.

sound/soc/codecs/rt5682s.c line 2805

Quoted 13 lines
sound/soc/codecs/rt5682s.c new file +13 -0
+static int rt5682s_probe(struct snd_soc_component *component)
+{
+	struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
+	struct snd_soc_dapm_context *dapm = &component->dapm;
+
+#ifdef CONFIG_COMMON_CLK
+	int ret;
+#endif
+	rt5682s->component = component;
+
+#ifdef CONFIG_COMMON_CLK
+	/* Check if MCLK provided */
+	rt5682s->mclk = devm_clk_get(component->dev, "mclk");

Perhaps factor the clock init out into a _probe_clks() function and then have a stub function rather than the two ifdefs?

A message that is not in the archive (sent off-list or not yet received): [email protected]

maintainer
#5 lore raw
Quoted 8 lines · Derek [方德義]
Quoted 6 lines

sound/soc/codecs/rt5682s.c line 2805

Quoted 3 lines
sound/soc/codecs/rt5682s.c new file +3 -0
+#ifdef CONFIG_COMMON_CLK
+	/* Check if MCLK provided */
+	rt5682s->mclk = devm_clk_get(component->dev, "mclk");

Perhaps factor the clock init out into a _probe_clks() function and then have a stub function rather than the two ifdefs?

We want to factor the codes like below to reduce ifdefs. Could you give any comments?

That looks fine.

#6 lore raw
In reply to [email protected]
Thank you for the patch! Perhaps something to improve:

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on asoc/for-next]
[also build test WARNING on v5.14-rc7 next-20210826]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/derek-fang-realtek-com/ASoC-rt5682s-Add-driver-for-ALC5682I-VS-codec/20210826-161340
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: hexagon-randconfig-r013-20210826 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project ea08c4cd1c0869ec5024a8bb3f5cdf06ab03ae83)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/3d7b4fdb7110791febbe2878e436192952b2cd5b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review derek-fang-realtek-com/ASoC-rt5682s-Add-driver-for-ALC5682I-VS-codec/20210826-161340 git checkout 3d7b4fdb7110791febbe2878e436192952b2cd5b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=hexagon

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> sound/soc/codecs/rt5682s.c:64:6: warning: no previous prototype for function 'rt5682s_apply_patch_list' [-Wmissing-prototypes]
   void rt5682s_apply_patch_list(struct rt5682s_priv *rt5682s,
        ^
   sound/soc/codecs/rt5682s.c:64:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void rt5682s_apply_patch_list(struct rt5682s_priv *rt5682s,
   ^
   static 
>> sound/soc/codecs/rt5682s.c:441:6: warning: no previous prototype for function 'rt5682s_volatile_register' [-Wmissing-prototypes]
   bool rt5682s_volatile_register(struct device *dev, unsigned int reg)
        ^
   sound/soc/codecs/rt5682s.c:441:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   bool rt5682s_volatile_register(struct device *dev, unsigned int reg)
   ^
   static 
>> sound/soc/codecs/rt5682s.c:483:6: warning: no previous prototype for function 'rt5682s_readable_register' [-Wmissing-prototypes]
   bool rt5682s_readable_register(struct device *dev, unsigned int reg)
        ^
   sound/soc/codecs/rt5682s.c:483:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   bool rt5682s_readable_register(struct device *dev, unsigned int reg)
   ^
   static 
>> sound/soc/codecs/rt5682s.c:623:6: warning: no previous prototype for function 'rt5682s_reset' [-Wmissing-prototypes]
   void rt5682s_reset(struct rt5682s_priv *rt5682s)
        ^
   sound/soc/codecs/rt5682s.c:623:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void rt5682s_reset(struct rt5682s_priv *rt5682s)
   ^
   static 
>> sound/soc/codecs/rt5682s.c:735:5: warning: no previous prototype for function 'rt5682s_headset_detect' [-Wmissing-prototypes]
   int rt5682s_headset_detect(struct snd_soc_component *component, int jack_insert)
       ^
   sound/soc/codecs/rt5682s.c:735:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int rt5682s_headset_detect(struct snd_soc_component *component, int jack_insert)
   ^
   static 
>> sound/soc/codecs/rt5682s.c:822:6: warning: no previous prototype for function 'rt5682s_jack_detect_handler' [-Wmissing-prototypes]
   void rt5682s_jack_detect_handler(struct work_struct *work)
        ^
   sound/soc/codecs/rt5682s.c:822:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void rt5682s_jack_detect_handler(struct work_struct *work)
   ^
   static 
>> sound/soc/codecs/rt5682s.c:2907:5: warning: no previous prototype for function 'rt5682s_parse_dt' [-Wmissing-prototypes]
   int rt5682s_parse_dt(struct rt5682s_priv *rt5682s, struct device *dev)
       ^
   sound/soc/codecs/rt5682s.c:2907:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int rt5682s_parse_dt(struct rt5682s_priv *rt5682s, struct device *dev)
   ^
   static 
>> sound/soc/codecs/rt5682s.c:2936:6: warning: no previous prototype for function 'rt5682s_calibrate' [-Wmissing-prototypes]
   void rt5682s_calibrate(struct rt5682s_priv *rt5682s)
        ^
   sound/soc/codecs/rt5682s.c:2936:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void rt5682s_calibrate(struct rt5682s_priv *rt5682s)
   ^
   static 
>> sound/soc/codecs/rt5682s.c:1014:29: warning: unused variable 'rt5682s_sar_mode_enum' [-Wunused-const-variable]
   static SOC_ENUM_SINGLE_DECL(rt5682s_sar_mode_enum, 0, 0,
                               ^

9 warnings generated.

vim +/rt5682s_apply_patch_list +64 sound/soc/codecs/rt5682s.c

    63	
  > 64	void rt5682s_apply_patch_list(struct rt5682s_priv *rt5682s,
    65			struct device *dev)
    66	{
    67		int ret;
    68	
    69		ret = regmap_multi_reg_write(rt5682s->regmap, patch_list, ARRAY_SIZE(patch_list));
    70		if (ret)
    71			dev_warn(dev, "Failed to apply regmap patch: %d\n", ret);
    72	}
    73	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#7 lore raw
In reply to [email protected]
Thank you for the patch! Perhaps something to improve:

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on asoc/for-next]
[also build test WARNING on v5.14-rc7 next-20210826]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/derek-fang-realtek-com/ASoC-rt5682s-Add-driver-for-ALC5682I-VS-codec/20210826-161340
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: sparc64-randconfig-p002-20210826 (attached as .config)
compiler: sparc64-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/3d7b4fdb7110791febbe2878e436192952b2cd5b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review derek-fang-realtek-com/ASoC-rt5682s-Add-driver-for-ALC5682I-VS-codec/20210826-161340 git checkout 3d7b4fdb7110791febbe2878e436192952b2cd5b
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=sparc64

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> sound/soc/codecs/rt5682s.c:64:6: warning: no previous prototype for 'rt5682s_apply_patch_list' [-Wmissing-prototypes]
      64 | void rt5682s_apply_patch_list(struct rt5682s_priv *rt5682s,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~
>> sound/soc/codecs/rt5682s.c:441:6: warning: no previous prototype for 'rt5682s_volatile_register' [-Wmissing-prototypes]
     441 | bool rt5682s_volatile_register(struct device *dev, unsigned int reg)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~
>> sound/soc/codecs/rt5682s.c:483:6: warning: no previous prototype for 'rt5682s_readable_register' [-Wmissing-prototypes]
     483 | bool rt5682s_readable_register(struct device *dev, unsigned int reg)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~
>> sound/soc/codecs/rt5682s.c:623:6: warning: no previous prototype for 'rt5682s_reset' [-Wmissing-prototypes]
     623 | void rt5682s_reset(struct rt5682s_priv *rt5682s)
         |      ^~~~~~~~~~~~~
>> sound/soc/codecs/rt5682s.c:735:5: warning: no previous prototype for 'rt5682s_headset_detect' [-Wmissing-prototypes]
     735 | int rt5682s_headset_detect(struct snd_soc_component *component, int jack_insert)
         |     ^~~~~~~~~~~~~~~~~~~~~~
>> sound/soc/codecs/rt5682s.c:822:6: warning: no previous prototype for 'rt5682s_jack_detect_handler' [-Wmissing-prototypes]
     822 | void rt5682s_jack_detect_handler(struct work_struct *work)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> sound/soc/codecs/rt5682s.c:2907:5: warning: no previous prototype for 'rt5682s_parse_dt' [-Wmissing-prototypes]
    2907 | int rt5682s_parse_dt(struct rt5682s_priv *rt5682s, struct device *dev)
         |     ^~~~~~~~~~~~~~~~
>> sound/soc/codecs/rt5682s.c:2936:6: warning: no previous prototype for 'rt5682s_calibrate' [-Wmissing-prototypes]
    2936 | void rt5682s_calibrate(struct rt5682s_priv *rt5682s)
         |      ^~~~~~~~~~~~~~~~~
   In file included from sound/soc/codecs/rt5682s.c:26:
   sound/soc/codecs/rt5682s.c:1014:29: warning: 'rt5682s_sar_mode_enum' defined but not used [-Wunused-const-variable=]
    1014 | static SOC_ENUM_SINGLE_DECL(rt5682s_sar_mode_enum, 0, 0,
         |                             ^~~~~~~~~~~~~~~~~~~~~
   include/sound/soc.h:352:31: note: in definition of macro 'SOC_ENUM_DOUBLE_DECL'
     352 |         const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
         |                               ^~~~
   sound/soc/codecs/rt5682s.c:1014:8: note: in expansion of macro 'SOC_ENUM_SINGLE_DECL'
    1014 | static SOC_ENUM_SINGLE_DECL(rt5682s_sar_mode_enum, 0, 0,
         |        ^~~~~~~~~~~~~~~~~~~~

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SND_SOC_MT6359
Depends on SOUND && !UML && SND && SND_SOC && MTK_PMIC_WRAP
Selected by
- SND_SOC_MT8195_MT6359_RT1019_RT5682 && SOUND && !UML && SND && SND_SOC && I2C && SND_SOC_MT8195

vim +/rt5682s_apply_patch_list +64 sound/soc/codecs/rt5682s.c

    63	
  > 64	void rt5682s_apply_patch_list(struct rt5682s_priv *rt5682s,
    65			struct device *dev)
    66	{
    67		int ret;
    68	
    69		ret = regmap_multi_reg_write(rt5682s->regmap, patch_list, ARRAY_SIZE(patch_list));
    70		if (ret)
    71			dev_warn(dev, "Failed to apply regmap patch: %d\n", ret);
    72	}
    73	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#8 lore raw
In reply to [email protected]

sound/soc/codecs/rt5682s.c line 1277

Quoted 10 lines · On 8/26/2021 4:09 PM, [email protected] wrote:
sound/soc/codecs/rt5682s.c new file +10 -0
+
+static int is_sys_clk_from_plla(struct snd_soc_dapm_widget *w,
+		struct snd_soc_dapm_widget *sink)
+{
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+	struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
+
+	if ((rt5682s->sysclk_src == RT5682S_CLK_SRC_PLL1) ||
+	    (rt5682s->sysclk_src == RT5682S_CLK_SRC_PLL2 &&
+	     rt5682s->pll_comb == USE_PLLAB))

What about rt5682s->pll_comb == USE_PLLA?

sound/soc/codecs/rt5682s.c line 1289

Quoted 12 lines
sound/soc/codecs/rt5682s.c new file +12 -0
+		return 1;
+
+	return 0;
+}
+
+static int is_sys_clk_from_pllb(struct snd_soc_dapm_widget *w,
+		struct snd_soc_dapm_widget *sink)
+{
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+	struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
+
+	if (rt5682s->sysclk_src == RT5682S_CLK_SRC_PLL2)

Should we also test rt5682s->pll_comb here?

Quoted 5 lines
sound/soc/codecs/rt5682s.c new file +4 -0
+		return 1;
+
+	return 0;
+}
#9 lore raw
Quoted 12 lines

Subject: Re: [PATCH 1/2] ASoC: rt5682s: Add driver for ALC5682I-VS codec

sound/soc/codecs/rt5682s.c

Quoted 5 lines · On 8/26/2021 4:09 PM, [email protected] wrote:
sound/soc/codecs/rt5682s.c new file +5 -0
+
+static int is_sys_clk_from_plla(struct snd_soc_dapm_widget *w,
+		struct snd_soc_dapm_widget *sink)
+{
+	struct snd_soc_component *component =

snd_soc_dapm_to_component(w->dapm);

Review

Quoted 1 line
(quoted diff) +1 -0
+	struct rt5682s_priv *rt5682s =

snd_soc_component_get_drvdata(component);

Quoted 7 lines

sound/soc/codecs/rt5682s.c line 1277

Quoted 4 lines
sound/soc/codecs/rt5682s.c new file +4 -0
+
+	if ((rt5682s->sysclk_src == RT5682S_CLK_SRC_PLL1) ||
+	    (rt5682s->sysclk_src == RT5682S_CLK_SRC_PLL2 &&
+	     rt5682s->pll_comb == USE_PLLAB))

What about rt5682s->pll_comb == USE_PLLA?

Thanks for review.

My design thought of this check function is that pll_comb would be set via snd_soc_dai_set_pll and sysclk_src would be set via snd_soc_dai_set_sysclk.

So I want to make sure the two settings are both correct first and then power PLLA/B.
Otherwise, not power, although the chance of mistake is rare.

   ___   +-->[PLLA]-+-------------------> PLL1 out
  |Clk|  |          |    ___
  |Mux|--|          +-->|Clk|
  |___|  |	        |Mux|-->[PLLB]--> PLL2 out
	 +------------->|___|
Quoted 26 lines

sound/soc/codecs/rt5682s.c

Quoted 10 lines
sound/soc/codecs/rt5682s.c new file +9 -0
+		return 1;
+
+	return 0;
+}
+
+static int is_sys_clk_from_pllb(struct snd_soc_dapm_widget *w,
+		struct snd_soc_dapm_widget *sink)
+{
+	struct snd_soc_component *component =

snd_soc_dapm_to_component(w->dapm);

Review

Quoted 1 line
(quoted diff) +1 -0
+	struct rt5682s_priv *rt5682s =

snd_soc_component_get_drvdata(component);

sound/soc/codecs/rt5682s.c line 1289

Quoted 2 lines
sound/soc/codecs/rt5682s.c new file +2 -0
+
+	if (rt5682s->sysclk_src == RT5682S_CLK_SRC_PLL2)

Should we also test rt5682s->pll_comb here?

sound/soc/codecs/rt5682s.c line 1281

Quoted 5 lines
sound/soc/codecs/rt5682s.c new file +4 -0
+		return 1;
+
+	return 0;
+}

------Please consider the environment before printing this e-mail.