ASoC: rt1015: add rt1015 amplifier driver
Subsystems (4)
PATCH 1/1 ASoC: rt1015: add rt1015 amplifier driver
From: Jack Yu <[email protected]>
This is initial amplifier driver for rt1015.
--- .../devicetree/bindings/sound/rt1015.txt | 17 + sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt1015.c | 1016 +++++++++++++++++ sound/soc/codecs/rt1015.h | 368 ++++++ 5 files changed, 1409 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/rt1015.txt create mode 100644 sound/soc/codecs/rt1015.c create mode 100644 sound/soc/codecs/rt1015.h
Documentation/devicetree/bindings/sound/rt1015.txt new file +17 -0
@@ -0,0 +1,17 @@ +RT1015 Mono Class D Audio Amplifier + +This device supports I2C only. + +Required properties: + +- compatible : "realtek,rt1015". + +- reg : The I2C address of the device. + + +Example: + +rt1015: codec@28 { + compatible = "realtek,rt1015"; + reg = <0x28>; +};
sound/soc/codecs/Kconfig +6 -0
@@ -149,6 +149,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_RT286 if I2C select SND_SOC_RT298 if I2C select SND_SOC_RT1011 if I2C + select SND_SOC_RT1015 if I2C select SND_SOC_RT1305 if I2C select SND_SOC_RT1308 if I2C select SND_SOC_RT5514 if I2C
@@ -956,6 +957,7 @@ config SND_SOC_RL6231 default y if SND_SOC_RT5677=y default y if SND_SOC_RT5682=y default y if SND_SOC_RT1011=y + default y if SND_SOC_RT1015=y default y if SND_SOC_RT1305=y default y if SND_SOC_RT1308=y default m if SND_SOC_RT5514=m
@@ -972,6 +974,7 @@ config SND_SOC_RL6231 default m if SND_SOC_RT5677=m default m if SND_SOC_RT5682=m default m if SND_SOC_RT1011=m + default m if SND_SOC_RT1015=m default m if SND_SOC_RT1305=m default m if SND_SOC_RT1308=m
@@ -999,6 +1002,9 @@ config SND_SOC_RT298 config SND_SOC_RT1011 tristate +config SND_SOC_RT1015 + tristate + config SND_SOC_RT1305 tristate
sound/soc/codecs/Makefile +2 -0
@@ -152,6 +152,7 @@ snd-soc-rk3328-objs := rk3328_codec.o snd-soc-rl6231-objs := rl6231.o snd-soc-rl6347a-objs := rl6347a.o snd-soc-rt1011-objs := rt1011.o +snd-soc-rt1015-objs := rt1015.o snd-soc-rt1305-objs := rt1305.o snd-soc-rt1308-objs := rt1308.o snd-soc-rt274-objs := rt274.o
@@ -446,6 +447,7 @@ obj-$(CONFIG_SND_SOC_RK3328) += snd-soc-rk3328.o obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o obj-$(CONFIG_SND_SOC_RL6347A) += snd-soc-rl6347a.o obj-$(CONFIG_SND_SOC_RT1011) += snd-soc-rt1011.o +obj-$(CONFIG_SND_SOC_RT1015) += snd-soc-rt1015.o obj-$(CONFIG_SND_SOC_RT1305) += snd-soc-rt1305.o obj-$(CONFIG_SND_SOC_RT1308) += snd-soc-rt1308.o obj-$(CONFIG_SND_SOC_RT274) += snd-soc-rt274.o
sound/soc/codecs/rt1015.c new file +1016 -0
1,016 lines not on this page · raw message
sound/soc/codecs/rt1015.h new file +368 -0
368 lines not on this page · raw message
Signature · 6 lines
2.24.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Mark Brown
maintainersound/soc/codecs/rt1015.c line 4
Quoted 6 lines · On Tue, Jan 14, 2020 at 10:56:28AM +0800, [email protected] wrote:
+++
b/sound/soc/codecs/rt1015.csound/soc/codecs/rt1015.c new file +4
-0@@ -0,0 +1,1016 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* rt1015.c -- RT1015 ALSA SoC audio amplifier driver +*
Please make the entire comment a C++ so things look more consistent.
sound/soc/codecs/rt1015.c line 42
Quoted 11 lines
sound/soc/codecs/rt1015.c new file +11
-0+static const struct reg_sequence init_list[] = { + {0x0000 ,0x0000 }, + {0x0104 ,0xA213 }, + {0x010E ,0x0058 }, + {0x0111 ,0x2000 }, + {0x0322 ,0xF7DF }, + {0x1302 ,0x12F7 }, + {0x0336 ,0x0010 }, + {0x04FC ,0x35CF }, + {0x0102 ,0xed02 }, +};
What's this doing? Some of these (all that I checked) are normal registers not undocumented registers or anything and you're changing their default values in here as well as doing a reset. If we're setting values on normal registers we should at least do it through explicit, documented writes.
sound/soc/codecs/rt1015.c line 43
Quoted 1 line
sound/soc/codecs/rt1015.c new file +1
-0+#define RT1015_INIT_REG_LEN ARRAY_SIZE(init_list)
Not sure this define is worth the effort?
Quoted 13 lines
sound/soc/codecs/rt1015.c new file +13
-0+ rt1015->boost_mode = ucontrol->value.integer.value[0 ]; +if (rt1015->boost_mode ==0 ) { +/* Bypass */ +snd_soc_component_update_bits (component, +RT1015_SMART_BST_CTRL1 ,RT1015_ABST_AUTO_EN_MASK | +RT1015_ABST_FIX_TGT_MASK |RT1015_BYPASS_SWR_REG_MASK , +RT1015_ABST_REG_MODE |RT1015_ABST_FIX_TGT_DIS | +RT1015_BYPASS_SWRREG_BYPASS ); + }else if (rt1015->boost_mode ==1 ) { +/* Adaptive */ + snd_soc_component_update_bits(component, + RT1015_SMART_BST_CTRL1, RT1015_ABST_AUTO_EN_MASK | + RT1015_ABST_FIX_TGT_MASK | RT1015_BYPASS_SWR_REG_MASK,
sound/soc/codecs/rt1015.c line 458
Quoted 10 lines
sound/soc/codecs/rt1015.c new file +10
-0+RT1015_ABST_AUTO_MODE |RT1015_ABST_FIX_TGT_DIS | + RT1015_BYPASS_SWRREG_PASS); + }else { +/* Fixed Adaptive */ +snd_soc_component_update_bits (component, +RT1015_SMART_BST_CTRL1 ,RT1015_ABST_AUTO_EN_MASK | +RT1015_ABST_FIX_TGT_MASK |RT1015_BYPASS_SWR_REG_MASK , +RT1015_ABST_AUTO_MODE |RT1015_ABST_FIX_TGT_EN | +RT1015_BYPASS_SWRREG_PASS ); + }
This should be a switch statement and should reject invalid values.
sound/soc/codecs/rt1015.c line 547
Quoted 12 lines
sound/soc/codecs/rt1015.c new file +12
-0+switch (event) { +case SND_SOC_DAPM_PRE_PMU : +if (rt1015->bypass_boost ==0 ) { +snd_soc_component_write (component, +RT1015_SYS_RST1 ,0x05f7 ); +snd_soc_component_write (component, +RT1015_GAT_BOOST ,0xacfe ); +snd_soc_component_write (component, +RT1015_PWR9 ,0xaa00 ); +snd_soc_component_write (component, +RT1015_GAT_BOOST ,0xecfe ); + }else {
Do we need some sort of lock out to prevent applications changing the bypass boost mode while the amp is powered up?
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Now that we have a machine driver based on this rt1015 amplifier, our sparse checks report two minor issues with this driver:
sound/soc/codecs/rt1015.c line 870
Quoted 4 lines
sound/soc/codecs/rt1015.c new file +4
-0+struct snd_soc_dai_ops rt1015_aif_dai_ops = { + .hw_params = rt1015_hw_params, + .set_fmt = rt1015_set_dai_fmt, +};
This structure is not defined so could be static, but doing so shows it's not used either?
sound/soc/codecs/rt1015.c line 884
Quoted 13 lines
sound/soc/codecs/rt1015.c new file +13
-0+struct snd_soc_dai_driver rt1015_dai[] = { + { + .name ="rt1015-aif" , + .id =0 , + .playback = { + .stream_name ="AIF Playback" , + .channels_min =1 , + .channels_max =4 , + .rates =RT1015_STEREO_RATES , + .formats =RT1015_FORMATS , + }, + } +};
This should be declared as static.
see logs below for reference.
CHECK sound/soc/codecs/rt1015.c
/soc/codecs/rt1015.c:844:24: warning: symbol 'rt1015_aif_dai_ops' was not declared. Should it be static? sound/soc/codecs/rt1015.c:849:27: warning: symbol 'rt1015_dai' was not declared. Should it be static?
CC [M] sound/soc/codecs/rt1015.osound/soc/codecs/rt1015.c:844:31: warning: ‘rt1015_aif_dai_ops’ defined but not used [-Wunused-variable]
844 | static struct snd_soc_dai_ops rt1015_aif_dai_ops = {
|Thanks!