Skip to contentSkip to conversation

ASoC: rt722-sdca: Add RT722 SDCA driver

PATCH Superseded Jack Yu 2 participants 2 messages Apr 19, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jack Yu

author
#0 lore raw

PATCH 1/1 ASoC: rt722-sdca: Add RT722 SDCA driver

This is the initial codec driver for rt722-sdca.

---
 sound/soc/codecs/Kconfig          |    7 +
 sound/soc/codecs/Makefile         |    2 +
 sound/soc/codecs/rt722-sdca-sdw.c |  505 ++++++++++
 sound/soc/codecs/rt722-sdca-sdw.h |  124 +++
 sound/soc/codecs/rt722-sdca.c     | 1549 +++++++++++++++++++++++++++++
 sound/soc/codecs/rt722-sdca.h     |  237 +++++
 6 files changed, 2424 insertions(+)
 create mode 100644 sound/soc/codecs/rt722-sdca-sdw.c
 create mode 100644 sound/soc/codecs/rt722-sdca-sdw.h
 create mode 100644 sound/soc/codecs/rt722-sdca.c
 create mode 100644 sound/soc/codecs/rt722-sdca.h
sound/soc/codecs/Kconfig +7 -0
index 79d2362ad055..a163e2afdf72 100644
@@ -207,6 +207,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_RT712_SDCA_DMIC_SDW
 	imply SND_SOC_RT715_SDW
 	imply SND_SOC_RT715_SDCA_SDW
+	imply SND_SOC_RT722_SDCA_SDW
 	imply SND_SOC_RT1308_SDW
 	imply SND_SOC_RT1316_SDW
 	imply SND_SOC_RT1318_SDW
@@ -1539,6 +1540,12 @@ config SND_SOC_RT712_SDCA_DMIC_SDW
 	select REGMAP_SOUNDWIRE
 	select REGMAP_SOUNDWIRE_MBQ
 
+config SND_SOC_RT722_SDCA_SDW
+	tristate "Realtek RT722 SDCA Codec - SDW"
+	depends on SOUNDWIRE
+	select REGMAP_SOUNDWIRE
+	select REGMAP_SOUNDWIRE_MBQ
+
 config SND_SOC_RT715
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 5cdbae88e6e3..cd799306331c 100644
@@ -237,6 +237,7 @@ snd-soc-rt712-sdca-objs := rt712-sdca.o rt712-sdca-sdw.o
 snd-soc-rt712-sdca-dmic-objs := rt712-sdca-dmic.o
 snd-soc-rt715-objs := rt715.o rt715-sdw.o
 snd-soc-rt715-sdca-objs := rt715-sdca.o rt715-sdca-sdw.o
+snd-soc-rt722-sdca-objs := rt722-sdca.o rt722-sdca-sdw.o
 snd-soc-rt9120-objs := rt9120.o
 snd-soc-sdw-mockup-objs := sdw-mockup.o
 snd-soc-sgtl5000-objs := sgtl5000.o
@@ -607,6 +608,7 @@ obj-$(CONFIG_SND_SOC_RT712_SDCA_SDW)     += snd-soc-rt712-sdca.o
 obj-$(CONFIG_SND_SOC_RT712_SDCA_DMIC_SDW)     += snd-soc-rt712-sdca-dmic.o
 obj-$(CONFIG_SND_SOC_RT715)     += snd-soc-rt715.o
 obj-$(CONFIG_SND_SOC_RT715_SDCA_SDW)     += snd-soc-rt715-sdca.o
+obj-$(CONFIG_SND_SOC_RT722_SDCA_SDW)     += snd-soc-rt722-sdca.o
 obj-$(CONFIG_SND_SOC_RT9120)	+= snd-soc-rt9120.o
 obj-$(CONFIG_SND_SOC_SDW_MOCKUP)     += snd-soc-sdw-mockup.o
 obj-$(CONFIG_SND_SOC_SGTL5000)  += snd-soc-sgtl5000.o
sound/soc/codecs/rt722-sdca-sdw.c new file +505 -0

505 lines not on this page · raw message

sound/soc/codecs/rt722-sdca-sdw.h new file +124 -0

124 lines not on this page · raw message

sound/soc/codecs/rt722-sdca.c new file +1549 -0

1,549 lines not on this page · raw message

sound/soc/codecs/rt722-sdca.h new file +237 -0

237 lines not on this page · raw message

Signature · 1 line
2.40.0
#1 lore raw
kernel test robot noticed the following build warnings:

Hi Jack,

kernel test robot noticed the following build warnings:

[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on next-20230418]
[cannot apply to linus/master v6.3-rc7]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jack-Yu/ASoC-rt722-sdca-Add-RT722-SDCA-driver/20230419-155442
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
patch link:    https://lore.kernel.org/r/20230419075130.29895-1-jack.yu%40realtek.com
patch subject: [PATCH] ASoC: rt722-sdca: Add RT722 SDCA driver
config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230419/[email protected]/config)
compiler: sparc64-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/8921f6bb62a04f5186b44864be481588925383a8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jack-Yu/ASoC-rt722-sdca-Add-RT722-SDCA-driver/20230419-155442 git checkout 8921f6bb62a04f5186b44864be481588925383a8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash sound/soc/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

sound/soc/codecs/rt722-sdca.c: In function 'rt722_sdca_set_gain_put':

>> sound/soc/codecs/rt722-sdca.c:355:40: warning: variable 'changed' set but not used [-Wunused-but-set-variable]
     355 |         unsigned int adc_vol_flag = 0, changed = 0;
         |                                        ^~~~~~~

vim +/changed +355 sound/soc/codecs/rt722-sdca.c

345
346 /* For SDCA control DAC/ADC Gain */
347 static int rt722_sdca_set_gain_put(struct snd_kcontrol *kcontrol,
348 struct snd_ctl_elem_value *ucontrol)
349 {
350 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
351 struct soc_mixer_control *mc =
352 (struct soc_mixer_control *)kcontrol->private_value;
353 struct rt722_sdca_priv *rt722 = snd_soc_component_get_drvdata(component);
354 unsigned int read_l, read_r, gain_l_val, gain_r_val;

 > 355		unsigned int adc_vol_flag = 0, changed = 0;

356 unsigned int lvalue, rvalue;
357 const unsigned int interval_offset = 0xc0;
358 const unsigned int tendB = 0xa00;
359
360 if (strstr(ucontrol->id.name, "FU1E Capture Volume") ||
361 strstr(ucontrol->id.name, "FU0F Capture Volume"))
362 adc_vol_flag = 1;
363
364 regmap_read(rt722->mbq_regmap, mc->reg, &lvalue);
365 regmap_read(rt722->mbq_regmap, mc->rreg, &rvalue);
366
367 /* L Channel */
368 gain_l_val = ucontrol->value.integer.value[0];
369 if (gain_l_val > mc->max)
370 gain_l_val = mc->max;
371
372 if (mc->shift == 8) /* boost gain */
373 gain_l_val = gain_l_val * tendB;
374 else {
375 /* ADC/DAC gain */
376 if (adc_vol_flag)
377 gain_l_val = 0x1e00 - ((mc->max - gain_l_val) * interval_offset);
378 else
379 gain_l_val = 0 - ((mc->max - gain_l_val) * interval_offset);
380 gain_l_val &= 0xffff;
381 }
382
383 /* R Channel */
384 gain_r_val = ucontrol->value.integer.value[1];
385 if (gain_r_val > mc->max)
386 gain_r_val = mc->max;
387
388 if (mc->shift == 8) /* boost gain */
389 gain_r_val = gain_r_val * tendB;
390 else {
391 /* ADC/DAC gain */
392 if (adc_vol_flag)
393 gain_r_val = 0x1e00 - ((mc->max - gain_r_val) * interval_offset);
394 else
395 gain_r_val = 0 - ((mc->max - gain_r_val) * interval_offset);
396 gain_r_val &= 0xffff;
397 }
398
399 if (lvalue != gain_l_val || rvalue != gain_r_val)
400 changed = 1;
401 else
402 return 0;
403
404 /* Lch*/
405 regmap_write(rt722->mbq_regmap, mc->reg, gain_l_val);
406
407 /* Rch */
408 regmap_write(rt722->mbq_regmap, mc->rreg, gain_r_val);
409
410 regmap_read(rt722->mbq_regmap, mc->reg, &read_l);
411 regmap_read(rt722->mbq_regmap, mc->rreg, &read_r);
412 if (read_r == gain_r_val && read_l == gain_l_val)
413 return 1;
414
415 return -EIO;
416 }
417

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests