ASoc: tas2783: Add tas2783 codec driver
Subsystems (3)
Shenghao Ding
maintainerPATCH v9 1/1 ASoc: tas2783: Add tas2783 codec driver
The tas2783 is a smart audio amplifier with integrated MIPI SoundWire interface (Version 1.2.1 compliant), I2C, and I2S/TDM interfaces designed for portable applications. An on-chip DSP supports Texas Instruments SmartAmp speaker protection algorithm. The integrated speaker voltage and current sense provides for real-time monitoring of lodspeakers.
The ASoC component provides the majority of the functionality of the device, all the audio functions.
---
Change in v9:
- simplify tasdevice_set_sdw_stream
- fixed some Linux coding style
- fixed the spelling mistakes
- Select left/right channel based on unique id
- a longer description has been added
- remove unused crc8 in KCONFIG
- Invert of RE here means reciprocal of RE
- correct indentation
- correct the wrong pow calibrated register
- correct comment on RESET register
- fixed usually lines don't end with an open parenthesis
- fixed tasdevice_sdw_shutdown
- use defines for function, entity, etc. for readable
- remove unnecessary codec_lock in component_probe()
- remove struct sdw_stream_data
- remove unused macro definitions
- use BIT(2) and BIT(1) instead of 0x2 and 0x1
- implement pm_runtime
- reg_start is u8, reg_start + i only adds i byte, it should be reg_start + i * 4, because the calibration values
- fixed total_sz in tas2783_calibration
- add a define for TASDEVICE_REG(0, 0, 0x0a)
- rework macro style in header file
- Add select CRC32
- rewrite the mute and the return value handling
- Add comments on bin file
- Add link_id into the fw name to distinguish the same sdw id on different sdw id.
- remove unnecessary mutex_lock
- use set_active() in tasdevice_io_init and move all other parts in the probe.
- move pm_runtime_get_noresume to the probe
- fix the return value of putvol function
- add put_noidle in tasdevice_sdw_remove
- remove unused header file(of.h)
- correct the style of the multi-line comment
- Set the readable registers in tas2783_readable_register for debugfs
- Use new PM macros
- Use default put and get inline SOC_SINGLE_RANGE_TLV and SOC_SINGLE_SX_TLV
- Use respective %pt to log the calibrated time
- Remove unnecessary struct tm
- Add trailing comma tasdevice_dapm_widgets and tasdevice_audio_map
- Rewrite the return value handling in tasdevice_sdw_probe
- use dev_num instead of id.unique_id
- rework the log
- Add code to check the size of calibrated data in UEFI
- Add description of Layout of calibrated Data in UEFI
- switch back link_id and unique_id to identify the devcie
- unique_id offset as the device index of the calibrated data
--- sound/soc/codecs/Kconfig | 16 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tas2783-sdw.c | 851 +++++++++++++++++++++++++++++++++ sound/soc/codecs/tas2783.h | 106 ++++ 4 files changed, 975 insertions(+) create mode 100644 sound/soc/codecs/tas2783-sdw.c create mode 100644 sound/soc/codecs/tas2783.h
sound/soc/codecs/Kconfig +16 -0
@@ -247,6 +247,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_TAS2781_COMLIB imply SND_SOC_TAS2781_FMWLIB imply SND_SOC_TAS2781_I2C + imply SND_SOC_TAS2783 imply SND_SOC_TAS5086 imply SND_SOC_TAS571X imply SND_SOC_TAS5720
@@ -1847,6 +1848,21 @@ config SND_SOC_TAS2781_I2C algo coefficient setting, for one, two or even multiple TAS2781 chips. +config SND_SOC_TAS2783 + tristate "Texas Instruments TAS2783 speaker amplifier (sdw)" + depends on SOUNDWIRE + depends on EFI + select REGMAP + select REGMAP_SOUNDWIRE + select CRC32 + select CRC32_SARWATE + help + Enable support for Texas Instruments TAS2783 Smart Amplifier + Digital input mono Class-D and DSP-inside audio power amplifiers. + TAS2783 supports the MIPI SoundWire v1.2 compatible interface + for audio and control data. At the end of calibrated data appends + the crc data with crc32_sarwate for error detection. + config SND_SOC_TAS5086 tristate "Texas Instruments TAS5086 speaker amplifier" depends on I2C
sound/soc/codecs/Makefile +2 -0
@@ -284,6 +284,7 @@ snd-soc-tas2770-objs := tas2770.o snd-soc-tas2781-comlib-objs := tas2781-comlib.o snd-soc-tas2781-fmwlib-objs := tas2781-fmwlib.o snd-soc-tas2781-i2c-objs := tas2781-i2c.o +snd-soc-tas2783-objs := tas2783-sdw.o snd-soc-tfa9879-objs := tfa9879.o snd-soc-tfa989x-objs := tfa989x.o snd-soc-tlv320adc3xxx-objs := tlv320adc3xxx.o
@@ -664,6 +665,7 @@ obj-$(CONFIG_SND_SOC_TAS2780) += snd-soc-tas2780.o obj-$(CONFIG_SND_SOC_TAS2781_COMLIB) += snd-soc-tas2781-comlib.o obj-$(CONFIG_SND_SOC_TAS2781_FMWLIB) += snd-soc-tas2781-fmwlib.o obj-$(CONFIG_SND_SOC_TAS2781_I2C) += snd-soc-tas2781-i2c.o +obj-$(CONFIG_SND_SOC_TAS2783) += snd-soc-tas2783.o 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
sound/soc/codecs/tas2783-sdw.c new file +851 -0
851 lines not on this page · raw message
sound/soc/codecs/tas2783.h new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 5 lines · Shenghao Ding
The tas2783 is a smart audio amplifier with integrated MIPI SoundWire interface (Version 1.2.1 compliant), I2C, and I2S/TDM interfaces designed for portable applications. An on-chip DSP supports Texas Instruments SmartAmp speaker protection algorithm. The integrated speaker voltage and current sense provides for real-time monitoring of lodspeakers.
loudspeakers.
Quoted 11 lines
sound/soc/codecs/tas2783-sdw.c new file +11
-0+static void tas2783_apply_calib (struct tasdevice_priv *tas_dev, +unsigned int *cali_data) +{ +struct regmap *map = tas_dev->regmap; +u8 *cali_start; +u16 offset; +int ret; + +if (!tas_dev->sdw_peripheral) { +dev_err (tas_dev->dev,"%s: peripheral doesn't exist.\n" , + __func__);
sound/soc/codecs/tas2783-sdw.c line 151
Quoted 10 lines
sound/soc/codecs/tas2783-sdw.c new file +10
-0+return ; + } + + offset = tas_dev->sdw_peripheral->id.unique_id - +TAS2783_UNIQUE_ID_BASE ; +if (offset >=TAS2783_MAX_DEV_NUM ) { +dev_err (tas_dev->dev,"%s: offset(%u) is out of range.\n" , + __func__, offset); +return ; + }
I think we are at the 4th iteration where I have to repeat myself...
In the SoundWire spec, the unique_id is *LINK SPECIFIC*, and only used at the bus level within the context of a link to help avoid enumeration conflicts
If you are using the unique_id as a SYSTEM-UNIQUE value to lookup EFI data, this is a TI-specific requirement that needs to be documented. That also means you need to double-check for errors so make sure there are no board configurations where the same unique_id is used in multiple links, or by devices other than tas2783.
Ding, Shenghao
maintainerHi Pierre-Louis
Thanks for your careful review.
Quoted 60 lines
-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Friday, February 23, 2024 8:14 AM
To: Ding, Shenghao <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; yung- [email protected]; Xu, Baojun <[email protected]>; Lu, Kevin <[email protected]>; [email protected]; [email protected]
Subject: [EXTERNAL] Re: [PATCH v9] ASoc: tas2783: Add tas2783 codec driverOn 2/22/24 2: 40 AM, Shenghao Ding wrote: > The tas2783 is a smart audio amplifier with integrated MIPI SoundWire > interface (Version 1. 2. 1 compliant), I2C, and I2S/TDM interfaces designed > for portable applications. An on-chip DSP ZjQcmQRYFpfptBannerStart This message was sent from outside of Texas Instruments.
Do not click links or open attachments unless you recognize the source of this email and know the content is safe.ZjQcmQRYFpfptBannerEnd
Quoted 5 lines · Shenghao Ding
The tas2783 is a smart audio amplifier with integrated MIPI SoundWire interface (Version 1.2.1 compliant), I2C, and I2S/TDM interfaces designed for portable applications. An on-chip DSP supports Texas Instruments SmartAmp speaker protection algorithm. The integrated speaker voltage and current sense provides for real-time monitoring of
lodspeakers.
loudspeakers.
Quoted 11 lines
sound/soc/codecs/tas2783-sdw.c new file +11
-0+static void tas2783_apply_calib (struct tasdevice_priv *tas_dev, +unsigned int *cali_data) +{ +struct regmap *map = tas_dev->regmap; +u8 *cali_start; +u16 offset; +int ret; + +if (!tas_dev->sdw_peripheral) { +dev_err (tas_dev->dev,"%s: peripheral doesn't exist.\n" , + __func__);sound/soc/codecs/tas2783-sdw.c line 151
Quoted 10 lines
sound/soc/codecs/tas2783-sdw.c new file +10
-0+return ; + } + + offset = tas_dev->sdw_peripheral->id.unique_id - +TAS2783_UNIQUE_ID_BASE ; +if (offset >=TAS2783_MAX_DEV_NUM ) { +dev_err (tas_dev->dev,"%s: offset(%u) is out of range.\n" , + __func__, offset); +return ; + }I think we are at the 4th iteration where I have to repeat myself...
In the SoundWire spec, the
unique_idis *LINK SPECIFIC*, and only used at the bus level within the context of a link to help avoid enumeration conflicts
Quoted 7 lines
If you are using the
unique_idas a SYSTEM-UNIQUE value to lookup EFI data, this is a TI-specific requirement that needs to be documented. That also means you need to double-check for errors so make sure there are no board configurations where the sameunique_idis used in multiple links, or by devices other than tas2783.
This code only covers the tas2783s sitting in the same bus link. As to cases of the different SWD links, customer will be required to have the secondary development on current code. I'm sure my customers have much knowledge to handle this.
Mark Brown
maintainerQuoted 12 lines · Shenghao
Hi Pierre-Louis
Quoted 9 lines
In the SoundWire spec, the
unique_idis *LINK SPECIFIC*, and only used at the bus level within the context of a link to help avoid enumeration conflictsIf you are using the
unique_idas a SYSTEM-UNIQUE value to lookup EFI data, this is a TI-specific requirement that needs to be documented. That also means you need to double-check for errors so make sure there are no board configurations where the sameunique_idis used in multiple links, or by devices other than tas2783.
Quoted 3 lines
This code only covers the tas2783s sitting in the same bus link. As to cases of the different SWD links, customer will be required to have the secondary development on current code. I'm sure my customers have much knowledge to handle this.
As Pierre says I think we really should have some sort of defensive programming here, even if you're going to leave multi-link systems to future work people will still have older versions in distributions or whtaever. While I'm not sure the consequences of getting things wrong are likely to be that bad (I'm expecting bad quality audio) it's also going to be kind of hard to figure out if we just silently pick the wrong calibration, especially if it's actually a valid calibration for another device in the system. Other vendors (eg, Cirrus) seem to have figured out a scheme here?
Quoted 13 lines · Mark Brown
Quoted 11 lines · Shenghao
Hi Pierre-Louis
Quoted 9 lines
In the SoundWire spec, the
unique_idis *LINK SPECIFIC*, and only used at the bus level within the context of a link to help avoid enumeration conflictsIf you are using the
unique_idas a SYSTEM-UNIQUE value to lookup EFI data, this is a TI-specific requirement that needs to be documented. That also means you need to double-check for errors so make sure there are no board configurations where the sameunique_idis used in multiple links, or by devices other than tas2783.
Quoted 3 lines
Quoted 3 lines
This code only covers the tas2783s sitting in the same bus link. As to cases of the different SWD links, customer will be required to have the secondary development on current code. I'm sure my customers have much knowledge to handle this.
PC OEMs don't usually have a Linux team capable of handling this sort of low-level plumbing, so the burden of this "secondary development" will come back at you...
Quoted 9 lines
As Pierre says I think we really should have some sort of defensive programming here, even if you're going to leave multi-link systems to future work people will still have older versions in distributions or whtaever. While I'm not sure the consequences of getting things wrong are likely to be that bad (I'm expecting bad quality audio) it's also going to be kind of hard to figure out if we just silently pick the wrong calibration, especially if it's actually a valid calibration for another device in the system. Other vendors (eg, Cirrus) seem to have figured out a scheme here?
Leaving multi-link aside has to be seen as as temporary step, there are a number of electrical issues that will prevent more than 4 amps to be placed on the same link. And indeed this "secondary development" has to be backwards compatible with initial calibration schemes.
Ding, Shenghao
maintainerQuoted 34 lines
-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Saturday, February 24, 2024 1:20 AM
To: Ding, Shenghao <[email protected]>
Cc: Pierre-Louis Bossart <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Xu, Baojun <[email protected]>; Lu, Kevin <[email protected]>; [email protected]; [email protected]
Subject: Re: [EXTERNAL] Re: [PATCH v9] ASoc: tas2783: Add tas2783 codec driverQuoted 12 lines · Shenghao
Hi Pierre-Louis
Quoted 9 lines
In the SoundWire spec, the
unique_idis *LINK SPECIFIC*, and only used at the bus level within the context of a link to help avoid enumeration conflictsIf you are using the
unique_idas a SYSTEM-UNIQUE value to lookup EFI data, this is a TI-specific requirement that needs to be documented. That also means you need to double-check for errors so make sure there are no board configurations where the sameunique_idis used in multiple links, or by devices other than tas2783.Quoted 3 lines
This code only covers the tas2783s sitting in the same bus link. As to cases of the different SWD links, customer will be required to have the secondary development on current code. I'm sure my customers have
much knowledge to handle this.
Quoted 8 lines
As Pierre says I think we really should have some sort of defensive programming here, even if you're going to leave multi-link systems to future work people will still have older versions in distributions or whtaever. While I'm not sure the consequences of getting things wrong are likely to be that bad (I'm expecting bad quality audio) it's also going to be kind of hard to figure out if we just silently pick the wrong calibration, especially if it's actually a valid calibration for another device in the system. Other vendors (eg, Cirrus) seem to have figured out a scheme here?
Thanks for your comments, Mark & Pierre. I will discuss with my customers on how to find a compromise between new solution and current solution already released to market.