TDA7419 audio processor driver
Subsystems (3)
cover TDA7419 audio processor driver
This series adds an ASoC component driver for the ST TDA7419 audio processor which is commonly used in automotive audio applications. The datasheet can be found at
http://www.st.com/resource/en/datasheet/tda7419.pdf
Matt Porter (2):
ASoC: add tda7419 audio processor binding
ASoC: add tda7419 audio processor driver
.../devicetree/bindings/sound/tda7419.txt | 15 + sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tda7419.c | 571 +++++++++++++++++++++ 4 files changed, 594 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/tda7419.txt create mode 100644 sound/soc/codecs/tda7419.c
Signature · 1 line
2.11.0
PATCH 1/2 ASoC: add tda7419 audio processor binding
DeviceTree binding for the tda7419 audio processor.
--- Documentation/devicetree/bindings/sound/tda7419.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/tda7419.txt
Documentation/devicetree/bindings/sound/tda7419.txt new file +15 -0
@@ -0,0 +1,15 @@ +TDA7419 audio processor + +This device supports I2C only. + +Required properties: + +- compatible : "st,tda7419" +- reg : the I2C address of the device. + +Example: + +ap: tda7419@44 { + compatible = "st,tda7419"; + reg = <0x44>; +};
Signature · 1 line
2.11.0
Rob Herring
maintainerRe: [PATCH 1/2] ASoC: add tda7419 audio processor binding
Quoted 14 lines · Matt Porter
DeviceTree binding for the tda7419 audio processor.
Signed-off-by Matt Porter <[email protected]>--- Documentation/devicetree/bindings/sound/tda7419.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/tda7419.txtDocumentation/devicetree/bindings/sound/tda7419.txt new file +0
-0
Documentation/devicetree/bindings/sound/tda7419.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/sound/tda7419.txt new file +8
-0@@ -0,0 +1,15 @@ +TDA7419 audio processor + +This device supports I2C only. + +Required properties: + +- compatible : "st,tda7419" +- reg : the I2C address of the device.
For completeness:
st,mute-gpios for MUTE pin?
vdd-supply?
Quoted 10 lines
Documentation/devicetree/bindings/sound/tda7419.txt new file +7
-0+ +Example: + +ap: tda7419@44 { + compatible = "st,tda7419"; + reg = <0x44>; +};Signature · 1 line
2.11.0
Re: [PATCH 1/2] ASoC: add tda7419 audio processor binding
Quoted 26 lines · Rob Herring
Quoted 14 lines · Matt Porter
DeviceTree binding for the tda7419 audio processor.
Signed-off-by Matt Porter <[email protected]>--- Documentation/devicetree/bindings/sound/tda7419.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/tda7419.txtDocumentation/devicetree/bindings/sound/tda7419.txt new file +0
-0Documentation/devicetree/bindings/sound/tda7419.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/sound/tda7419.txt new file +8
-0@@ -0,0 +1,15 @@ +TDA7419 audio processor + +This device supports I2C only. + +Required properties: + +- compatible : "st,tda7419" +- reg : the I2C address of the device.For completeness:
Quoted 1 line
st,mute-gpios for MUTE pin?
I'll add mute in as an optional property.
Quoted 2 lines
vdd-supply?
Yes, there's a required ~8.5V supply so I'll add the regulator reference.
Thanks,
Matt
PATCH 2/2 ASoC: add tda7419 audio processor driver
In reply to Matt PorterComponent driver for the tda7419 audio processor.
--- sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tda7419.c | 571 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 579 insertions(+) create mode 100644 sound/soc/codecs/tda7419.c
sound/soc/codecs/Kconfig +6 -0
@@ -151,6 +151,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_TAS571X if I2C select SND_SOC_TAS5720 if I2C select SND_SOC_TAS6424 if I2C + select SND_SOC_TDA7419 if I2C select SND_SOC_TFA9879 if I2C select SND_SOC_TLV320AIC23_I2C if I2C select SND_SOC_TLV320AIC23_SPI if SPI_MASTER
@@ -910,6 +911,11 @@ config SND_SOC_TAS6424 Enable support for Texas Instruments TAS6424 high-efficiency digital input quad-channel Class-D audio power amplifiers. +config SND_SOC_TDA7419 + tristate "ST TDA7419 audio processor" + depends on I2C + select REGMAP_I2C + config SND_SOC_TFA9879 tristate "NXP Semiconductors TFA9879 amplifier" depends on I2C
sound/soc/codecs/Makefile +2 -0
@@ -160,6 +160,7 @@ snd-soc-tas5086-objs := tas5086.o snd-soc-tas571x-objs := tas571x.o snd-soc-tas5720-objs := tas5720.o snd-soc-tas6424-objs := tas6424.o +snd-soc-tda7419-objs := tda7419.o snd-soc-tfa9879-objs := tfa9879.o snd-soc-tlv320aic23-objs := tlv320aic23.o snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o
@@ -405,6 +406,7 @@ obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o obj-$(CONFIG_SND_SOC_TAS6424) += snd-soc-tas6424.o +obj-$(CONFIG_SND_SOC_TDA7419) += snd-soc-tda7419.o obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o
sound/soc/codecs/tda7419.c new file +571 -0
571 lines not on this page · raw message
Signature · 1 line
2.11.0
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: add tda7419 audio processor driver
sound/soc/codecs/tda7419.c line 103
Quoted 4 lines · Matt Porter
sound/soc/codecs/tda7419.c new file +4
-0+static bool tda7419_writeable_reg (struct device *dev,unsigned int reg) +{ +return true; +}
This is the default behaviour, may as well omit it (but equally it does no harm).
sound/soc/codecs/tda7419.c line 177
Quoted 8 lines
sound/soc/codecs/tda7419.c new file +8
-0+static inline int tda7419_vol_get_value (int val,unsigned int mask, +int thresh,unsigned int invert) +{ + val &= mask; +if (val < thresh) { +if (invert) + val =0 - val; + }else if (val > thresh) {
This feels like something some other device might want to use so might warrant pulling out into a general control at some point but I'd not insist on doing it now.
sound/soc/codecs/tda7419.c line 395
Quoted 2 lines
sound/soc/codecs/tda7419.c new file +2
-0+static struct snd_kcontrol_new tda7419_controls[] = { +SOC_ENUM ("Main Source Select" , soc_enum_main_src_sel),
Should this be a DAPM route?
sound/soc/codecs/tda7419.c line 399
Quoted 2 lines
sound/soc/codecs/tda7419.c new file +2
-0+SOC_SINGLE ("Main Source AutoZero" ,TDA7419_MAIN_SRC_REG , + TDA7419_MAIN_SRC_AUTOZERO, 1, 1),
There's a lot of on/off switches for various things in here - these should all have Switch at the end of their names so that userspace can see how it's expected to display them. Most of the controls with a max value of 1 probably fall into this category.
sound/soc/codecs/tda7419.c line 412
Quoted 2 lines
sound/soc/codecs/tda7419.c new file +2
-0+SOC_SINGLE ("Clock Fast Mode" ,TDA7419_MUTE_CLK_REG , + TDA7419_CLK_FAST_MODE, 1, 1),
What does this do - should it be in set_sysclk() or something?
sound/soc/codecs/tda7419.c line 520
Quoted 9 lines
sound/soc/codecs/tda7419.c new file +9
-0+/* Configure registers */ +regmap_write (tda7419->regmap,TDA7419_VOLUME_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_MIXING_GAIN_REG ,0x0f ); +regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_LF_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_RF_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_LR_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_RR_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_MIXING_LEVEL_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_SUB_REG ,0xe0 );
This looks like it's setting default volumes - just leave those at the chip defaults and let userspace handle setting them, what works for one board may be totally inappropriate on another board and using the chip default means we've got some fixed thing we don't need to discuss.
sound/soc/codecs/tda7419.c line 541
Quoted 10 lines
sound/soc/codecs/tda7419.c new file +10
-0+static int tda7419_remove (struct i2c_client *i2c) +{ +int i; +struct tda7419_data *tda7419 =i2c_get_clientdata (i2c); + +/* Reset registers to defaults */ +for (i =0 ; i <ARRAY_SIZE (tda7419_regmap_defaults); i++) +regmap_write (tda7419->regmap, + tda7419_regmap_defaults[i].reg, + tda7419_regmap_defaults[i].def);
Why are we doing this? Other drivers don't do it... if anything I'd expect a reset on probe in case the bootloader or something left the chip configured.
Re: [PATCH 2/2] ASoC: add tda7419 audio processor driver
Quoted 9 lines · Mark Brown
sound/soc/codecs/tda7419.c line 103
Quoted 4 lines · Matt Porter
sound/soc/codecs/tda7419.c new file +4
-0+static bool tda7419_writeable_reg (struct device *dev,unsigned int reg) +{ +return true; +}This is the default behaviour, may as well omit it (but equally it does no harm).
Ok.
Quoted 13 lines
sound/soc/codecs/tda7419.c line 177
Quoted 9 lines
sound/soc/codecs/tda7419.c new file +8
-0+static inline int tda7419_vol_get_value (int val,unsigned int mask, +int thresh,unsigned int invert) +{ + val &= mask; +if (val < thresh) { +if (invert) + val =0 - val; + }else if (val > thresh) {This feels like something some other device might want to use so might warrant pulling out into a general control at some point but I'd not insist on doing it now.
Ok, yeah, I was also thinking it should be moved to a general helper when the next user shows up. The most likely case is another part in this family may have a similar register layout.
Quoted 4 lines
sound/soc/codecs/tda7419.c line 395
Quoted 2 lines
sound/soc/codecs/tda7419.c new file +2
-0+static struct snd_kcontrol_new tda7419_controls[] = { +SOC_ENUM ("Main Source Select" , soc_enum_main_src_sel),Should this be a DAPM route?
Ultimately yes. I initially took the path of ignoring DAPM support in interests of getting some clean done. Is it ok to merge DAPM support later or do you prefer just having it in the intitial driver? For routes, it'll include Main/Second source selects, the Rear Source switch, and Mix enable at least.
Quoted 7 lines
sound/soc/codecs/tda7419.c line 399
Quoted 2 lines
sound/soc/codecs/tda7419.c new file +2
-0+SOC_SINGLE ("Main Source AutoZero" ,TDA7419_MAIN_SRC_REG , + TDA7419_MAIN_SRC_AUTOZERO, 1, 1),There's a lot of on/off switches for various things in here - these should all have Switch at the end of their names so that userspace can see how it's expected to display them. Most of the controls with a max value of 1 probably fall into this category.
I see. I'll fix that.
Quoted 4 lines
sound/soc/codecs/tda7419.c line 412
Quoted 2 lines
sound/soc/codecs/tda7419.c new file +2
-0+SOC_SINGLE ("Clock Fast Mode" ,TDA7419_MUTE_CLK_REG , + TDA7419_CLK_FAST_MODE, 1, 1),What does this do - should it be in
set_sysclk()or something?
This is where things get hazy, unfortunately. The datasheet is partially garbage. So there's no description or guidance on clock management at all. It's not clear what clock this is or what specifically "fast" does. Because there's no concept of an external clock, the sysclk is clearly internally generated. Because of the register labeling of clock generator, it's probably sysclk but I'm not 100% sure what the relevance is of fast mode. The working settings were divined from trial and error as well a couple microcontroller projects scattered across the interwebs.
On second look at this, I think I should at least remove this switch and hard code it for now or move to set_sysclk(). I'm hesistant of the latter because of the lack of information on this setting.
Quoted 6 lines
Quoted 6 lines
sound/soc/codecs/tda7419.c new file +6
-0+/* Configure registers */ +regmap_write (tda7419->regmap,TDA7419_VOLUME_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_MIXING_GAIN_REG ,0x0f ); +regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_LF_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_RF_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_LR_REG ,0xe0 );
Quoted 8 lines
sound/soc/codecs/tda7419.c line 520
Quoted 3 lines
sound/soc/codecs/tda7419.c new file +3
-0+regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_RR_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_MIXING_LEVEL_REG ,0xe0 ); +regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_SUB_REG ,0xe0 );This looks like it's setting default volumes - just leave those at the chip defaults and let userspace handle setting them, what works for one board may be totally inappropriate on another board and using the chip default means we've got some fixed thing we don't need to discuss.
This is actually setting the default/cache to the first mute value due to the assumption in my implementation of the tda7419-specific get/set for these registers. It simplified the code a bit to have these initialized like this. e.g. for the attenuator group of registers, x11xxxxx are all mute values, so 0xe0 is setting these regs to that first mute value to simplify things. I'll take another look at eliminating this. As it is, it does not change the fact that the actual reset value of 0xff is also mute from a user POV.
Quoted 6 lines
Quoted 6 lines
sound/soc/codecs/tda7419.c new file +6
-0+static int tda7419_remove (struct i2c_client *i2c) +{ +int i; +struct tda7419_data *tda7419 =i2c_get_clientdata (i2c); + +/* Reset registers to defaults */
Quoted 8 lines
sound/soc/codecs/tda7419.c line 541
Quoted 4 lines
sound/soc/codecs/tda7419.c new file +4
-0+for (i =0 ; i <ARRAY_SIZE (tda7419_regmap_defaults); i++) +regmap_write (tda7419->regmap, + tda7419_regmap_defaults[i].reg, + tda7419_regmap_defaults[i].def);Why are we doing this? Other drivers don't do it... if anything I'd expect a reset on probe in case the bootloader or something left the chip configured.
Good point, I'll move this into probe. The part doesn't have a soft reset provision so we need to do it manually like this.
-Matt
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: add tda7419 audio processor driver
Quoted 8 lines · Matt Porter
Quoted 6 lines · Mark Brown
sound/soc/codecs/tda7419.c line 395
Quoted 2 lines · Matt Porter
sound/soc/codecs/tda7419.c new file +2
-0+static struct snd_kcontrol_new tda7419_controls[] = { +SOC_ENUM ("Main Source Select" , soc_enum_main_src_sel),Should this be a DAPM route?
Quoted 5 lines
Ultimately yes. I initially took the path of ignoring DAPM support in interests of getting some clean done. Is it ok to merge DAPM support later or do you prefer just having it in the intitial driver? For routes, it'll include Main/Second source selects, the Rear Source switch, and Mix enable at least.
You definitely shouldn't be implementing things that should be in DAPM as non-DAPM controls.
Quoted 7 lines
Quoted 6 lines
sound/soc/codecs/tda7419.c line 520
Quoted 1 line
sound/soc/codecs/tda7419.c new file +1
-0+regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_SUB_REG ,0xe0 );This looks like it's setting default volumes - just leave those at the chip defaults and let userspace handle setting them, what works for one board may be totally inappropriate on another board and using the chip default means we've got some fixed thing we don't need to discuss.
Quoted 8 lines
This is actually setting the default/cache to the first mute value due to the assumption in my implementation of the tda7419-specific get/set for these registers. It simplified the code a bit to have these initialized like this. e.g. for the attenuator group of registers, x11xxxxx are all mute values, so
0xe0is setting these regs to that first mute value to simplify things. I'll take another look at eliminating this. As it is, it does not change the fact that the actual reset value of0xffis also mute from a user POV.
If it is useful it definitely needs a comment explaining what's happening and that there's no practical change to the configuration. It would be nicer to be robust against the device getting a wider range of values in the register but that seems plausible.
Re: [PATCH 2/2] ASoC: add tda7419 audio processor driver
Quoted 9 lines · Mark Brown
Quoted 7 lines · Matt Porter
Quoted 6 lines · Mark Brown
sound/soc/codecs/tda7419.c line 395
Quoted 2 lines · Matt Porter
sound/soc/codecs/tda7419.c new file +2
-0+static struct snd_kcontrol_new tda7419_controls[] = { +SOC_ENUM ("Main Source Select" , soc_enum_main_src_sel),Should this be a DAPM route?
Quoted 8 lines
Quoted 5 lines
Ultimately yes. I initially took the path of ignoring DAPM support in interests of getting some clean done. Is it ok to merge DAPM support later or do you prefer just having it in the intitial driver? For routes, it'll include Main/Second source selects, the Rear Source switch, and Mix enable at least.
You definitely shouldn't be implementing things that should be in DAPM as non-DAPM controls.
Ok, I addressed this by adding DAPM support in v2.
Quoted 16 lines
Quoted 7 lines
Quoted 6 lines
sound/soc/codecs/tda7419.c line 520
Quoted 1 line
sound/soc/codecs/tda7419.c new file +1
-0+regmap_write (tda7419->regmap,TDA7419_ATTENUATOR_SUB_REG ,0xe0 );This looks like it's setting default volumes - just leave those at the chip defaults and let userspace handle setting them, what works for one board may be totally inappropriate on another board and using the chip default means we've got some fixed thing we don't need to discuss.
Quoted 8 lines
This is actually setting the default/cache to the first mute value due to the assumption in my implementation of the tda7419-specific get/set for these registers. It simplified the code a bit to have these initialized like this. e.g. for the attenuator group of registers, x11xxxxx are all mute values, so
0xe0is setting these regs to that first mute value to simplify things. I'll take another look at eliminating this. As it is, it does not change the fact that the actual reset value of0xffis also mute from a user POV.
Quoted 4 lines
If it is useful it definitely needs a comment explaining what's happening and that there's no practical change to the configuration. It would be nicer to be robust against the device getting a wider range of values in the register but that seems plausible.
I did some rework to make this unnecessary in v2.
Thanks,
Matt
kbuild test robot
build bot[PATCH] ASoC: fix boolreturn.cocci warnings
In reply to Matt Portersound/soc/codecs/tda7419.c:151:9-10: WARNING: return of 0/1 in function 'tda7419_vol_is_stereo' with return type bool
From: Fengguang Wu <[email protected]>
sound/soc/codecs/tda7419.c:151:9-10: WARNING: return of 0/1 in function 'tda7419_vol_is_stereo' with return type bool
Return statements in functions returning bool should use true/false instead of 1/0.
Generated by: scripts/coccinelle/misc/boolreturn.cocci
---
tda7419.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/tda7419.c +2 -2
@@ -148,9 +148,9 @@ struct tda7419_vol_control {static inline bool tda7419_vol_is_stereo (struct tda7419_vol_control *tvc) {if (tvc->reg == tvc->rreg) -return 0 ; +return false; -return 1 ; +return true; } static int tda7419_vol_info(struct snd_kcontrol *kcontrol,
kbuild test robot
build botRe: [PATCH 2/2] ASoC: add tda7419 audio processor driver
In reply to Matt PorterI love your patch! Perhaps something to improve:
Hi Matt,
I love your patch! Perhaps something to improve:
[auto build test WARNING on asoc/for-next]
[also build test WARNING on v4.16-rc3 next-20180302]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Matt-Porter/TDA7419-audio-processor-driver/20180303-042824 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
coccinelle warnings: (new ones prefixed by >>)
>> sound/soc/codecs/tda7419.c:151:9-10: WARNING: return of 0/1 in function 'tda7419_vol_is_stereo' with return type bool
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation