ASoC: tas2781: Add "Acoustic Tuning" kcontrol for acoustic application
Subsystems (3)
Shenghao Ding
maintainerPATCH 1/1 ASoC: tas2781: Add "Acoustic Tuning" kcontrol for acoustic application
"Acoustic Tuning" kcontrol is a bridge to the acoustic tuning application tool which can tune the chips' acoustic effect.
--- include/sound/tas2781.h | 13 ++++ sound/soc/codecs/tas2781-i2c.c | 138 ++++++++++++++++++++++++++++++++- 2 files changed, 149 insertions(+), 2 deletions(-)
include/sound/tas2781.h +13 -0
@@ -32,6 +32,8 @@ SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE) +#define TASDEV_DATA_PAYLOAD_SIZE 128 +/* PAGE Control Register (available in page0 of each book) */ #define TASDEVICE_PAGE_SELECT 0x00#define TASDEVICE_BOOKCTL_PAGE 0x00
@@ -159,10 +161,21 @@ struct calidata {unsigned int cali_dat_sz_per_dev; }; +struct acoustic_data { +unsigned char len; +unsigned char id; +unsigned char addr; +unsigned char book; +unsigned char page; +unsigned char reg; +unsigned char data[TASDEV_DATA_PAYLOAD_SIZE ]; +}; +struct tasdevice_priv {struct tasdevice tasdevice[TASDEVICE_MAX_CHANNELS ];struct tasdevice_rca rcabin;struct calidata cali_data; +struct acoustic_data acou_data;struct tasdevice_fw *fmw;struct gpio_desc *speaker_id;struct gpio_desc *reset;
sound/soc/codecs/tas2781-i2c.c +136 -2
164 lines not on this page · raw message
Signature · 1 line
2.34.1
Mark Brown
maintainersound/soc/codecs/tas2781-i2c.c static int tasdev_tf_data_get(struct snd_kcontrol *kcontrol, · line 776
Quoted 13 lines · Shenghao Ding
"Acoustic Tuning" kcontrol is a bridge to the acoustic tuning application tool which can tune the chips' acoustic effect.
sound/soc/codecs/tas2781-i2c.c +10
-0+ reg =TASDEVICE_REG (src[3 ], src[4 ], src[5 ]); + +guard (mutex)(&priv->codec_lock); + +if (src[1 ] =='w' ) { +if (len >1 ) + ret =tasdevice_dev_bulk_write (priv, chn, reg, + &src[6 ], len); +else + ret =tasdevice_dev_write (priv, chn, reg, src[6 ]);
So, this is basically just unrestricted register I/O to the device. That's not a great interface - it just lets userspace do anything, including conflicting with things that the driver is managing itself. Usually a coefficient interface would just expose a specific set of registers with the coefficient data as a control.
I know other CODEC vendors use the regmap debugfs interface for this, if you change the kernel to define REGMAP_ALLOW_WRITE_DEBUGFS then you can do both writes and reads for the tuning. The tuning tool then produces a file with just the coefficients which is loaded at runtime, with anything that's normal routing or whatever being configured via the control API.