ALSA: hda/tas2563: Add tas253 HDA driver
Subsystems (3)
cover ALSA: hda/tas2563: Add tas253 HDA driver
The ta2563 is a smart amplifier. Similar to tas2562 but with DSP. Some Lenovo laptops have it to drive the bass speakers. By default, it is in software shutdown state.
To make the DSP work it needs a firmware and some calibration data. The latter can be read from the EFI in Lenovo laptops.
For the correct configuration it needs additional register data. It captured after running the Windows driver.
The firmware can be extracted as TAS2563Firmware.bin from the Windows driver with innoextract.
https://download.lenovo.com/consumer/mobiles/h5yd037fbfyy7kd0.exe
The driver will search for it as TAS2563-17AA3870.bin with the 14ARB7.
It uses the default program/configuration, and has no controls for these yet.
The amplifier works without firmware, but I don't know how safe is it, that's why the firmware is required.
Gergo Koteles (2):
ASoc: tas2563: DSP Firmware loading support
ALSA: hda/tas2563: Add tas2563 HDA driver
{sound/soc/codecs => include/sound}/tas2562.h | 8 +
include/sound/tas25xx-dsp.h | 100 ++++
sound/pci/hda/Kconfig | 14 +
sound/pci/hda/Makefile | 2 +
sound/pci/hda/patch_realtek.c | 22 +-
sound/pci/hda/tas2563_hda_i2c.c | 508 ++++++++++++++++++
sound/soc/codecs/Kconfig | 7 +
sound/soc/codecs/Makefile | 2 +
sound/soc/codecs/tas2562.c | 2 +-
sound/soc/codecs/tas25xx-dsp.c | 282 ++++++++++
10 files changed, 942 insertions(+), 5 deletions(-)
rename {sound/soc/codecs => include/sound}/tas2562.h (90%)
create mode 100644 include/sound/tas25xx-dsp.h
create mode 100644 sound/pci/hda/tas2563_hda_i2c.c
create mode 100644 sound/soc/codecs/tas25xx-dsp.cbase-commit: ffc253263a1375a65fa6c9f62a893e9767fbebfa
Signature · 1 line
2.43.0
PATCH 1/2 ASoc: tas2563: DSP Firmware loading support
The TAS2563 device has a DSP that can run firmware.
The firmware can contain up to 5 programs and 10 configurations to support alternate audio processing.
Firmware loading is done dymacally and the program and configuration selection is done by the user.
The binary itself contains a list of instructions for either a single mode write or a burst write. The single mode write is list of register writes to different books and pages within the register map. The burst writes is a block of data that is written to a specific location in memory.
The firmware loader must parse and load the blocks in real time as the binary may contain different audio profiles.
If the DSP is not needed to do audio preocessing then the DSP program can be turned off and the device will effectively turn off the DSP.
RFC patch:
https://lore.kernel.org/lkml/[email protected]/T/
---
{sound/soc/codecs => include/sound}/tas2562.h | 3 +
include/sound/tas25xx-dsp.h | 100 +++++++
sound/soc/codecs/Kconfig | 7 +
sound/soc/codecs/Makefile | 2 +
sound/soc/codecs/tas2562.c | 2 +-
sound/soc/codecs/tas25xx-dsp.c | 282 ++++++++++++++++++
6 files changed, 395 insertions(+), 1 deletion(-)
rename {sound/soc/codecs => include/sound}/tas2562.h (97%)
create mode 100644 include/sound/tas25xx-dsp.h
create mode 100644 sound/soc/codecs/tas25xx-dsp.cinclude/sound/tas2562.h renamed from sound/soc/codecs/tas2562.h +3 -0
@@ -11,6 +11,7 @@#define __TAS2562_H__#define TAS2562_PAGE_CTRL 0x00 +#define TAS2562_BOOK_CTRL 0x7f#define TAS2562_REG (page, reg) ((page * 128) + reg)
@@ -44,6 +45,8 @@#define TAS2562_DVC_CFG3 TAS2562_REG(2, 0x0e)#define TAS2562_DVC_CFG4 TAS2562_REG(2, 0x0f) +#define TAS25XX_DSP_MODE TAS2562_REG(1, 0x02) +#define TAS2562_RESET BIT(0)#define TAS2562_MODE_MASK GENMASK(1,0)
include/sound/tas25xx-dsp.h new file +100 -0
100 lines not on this page · raw message
sound/soc/codecs/Kconfig +7 -0
@@ -238,6 +238,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_STI_SAS imply SND_SOC_TAS2552 imply SND_SOC_TAS2562 + imply SND_SOC_TAS2562_DSP imply SND_SOC_TAS2764 imply SND_SOC_TAS2770 imply SND_SOC_TAS2780
@@ -1761,6 +1762,12 @@ config SND_SOC_TAS2552 tristate "Texas Instruments TAS2552 Mono Audio amplifier" depends on I2C +config SND_SOC_TAS25XX_DSP + depends on I2C + select REGMAP_I2C + tristate + default n + config SND_SOC_TAS2562 tristate "Texas Instruments TAS2562 Mono Audio amplifier" depends on I2C
sound/soc/codecs/Makefile +2 -0
@@ -378,6 +378,7 @@ snd-soc-max98504-objs := max98504.o snd-soc-simple-amplifier-objs := simple-amplifier.o snd-soc-tpa6130a2-objs := tpa6130a2.o snd-soc-tas2552-objs := tas2552.o +snd-soc-tas25xx-dsp-objs := tas25xx-dsp.o snd-soc-tas2562-objs := tas2562.o snd-soc-tas2764-objs := tas2764.o snd-soc-tas2780-objs := tas2780.o
@@ -651,6 +652,7 @@ obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o obj-$(CONFIG_SND_SOC_STI_SAS) += snd-soc-sti-sas.o obj-$(CONFIG_SND_SOC_TAS2552) += snd-soc-tas2552.o obj-$(CONFIG_SND_SOC_TAS2562) += snd-soc-tas2562.o +obj-$(CONFIG_SND_SOC_TAS25XX_DSP) += snd-soc-tas25xx-dsp.o obj-$(CONFIG_SND_SOC_TAS2764) += snd-soc-tas2764.o obj-$(CONFIG_SND_SOC_TAS2780) += snd-soc-tas2780.o obj-$(CONFIG_SND_SOC_TAS2781_COMLIB) += snd-soc-tas2781-comlib.o
sound/soc/codecs/tas2562.c +1 -1
@@ -20,7 +20,7 @@#include <sound/soc-dapm.h> #include <sound/tlv.h> -#include "tas2562.h" +#include <sound/tas2562.h> #define TAS2562_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |\ SNDRV_PCM_FORMAT_S32_LE)
sound/soc/codecs/tas25xx-dsp.c new file +282 -0
282 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH 1/2] ASoc: tas2563: DSP Firmware loading support
Quoted 3 lines
Firmware loading is done dymacally and the program and configuration
dynamically
Quoted 8 lines
selection is done by the user.
The binary itself contains a list of instructions for either a single mode write or a burst write. The single mode write is list of register writes to different books and pages within the register map. The burst writes is a block of data that is written to a specific location in memory.
Quoted 4 lines
The firmware loader must parse and load the blocks in real time as the binary may contain different audio profiles.
If the DSP is not needed to do audio preocessing then the DSP program
preprocessing
Quoted 8 lines
can be turned off and the device will effectively turn off the DSP.
--- {sound/soc/codecs => include/sound}/tas2562.h | 3 + include/sound/tas25xx-dsp.h | 100 +++++++ sound/soc/codecs/Kconfig | 7 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tas2562.c | 2 +-
are tas2562 and tas2563 (from commit subject) the same?
Quoted 20 lines
sound/soc/codecs/tas25xx-dsp.c | 282 ++++++++++++++++++ 6 files changed, 395 insertions(+), 1 deletion(-) rename {sound/soc/codecs => include/sound}/tas2562.h (97%) create mode 100644 include/sound/tas25xx-dsp.h create mode 100644 sound/soc/codecs/tas25xx-dsp.cinclude/sound/tas2562.h renamed from sound/soc/codecs/tas2562.h +0
-0sound/soc/codecs/tas25xx-dsp.c new file +3
-0@@ -0,0 +1,282 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Firmware loader for the Texas Instruments TAS25XX DSP
sound/soc/codecs/tas25xx-dsp.c line 13
Quoted 10 lines
sound/soc/codecs/tas25xx-dsp.c new file +10
-0+// Copyright (C) 2020 Texas Instruments Inc. + +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/device.h> +#include <linux/firmware.h> +#include <linux/i2c.h> +#include <linux/regmap.h> +#include <linux/slab.h> +#include <linux/delay.h>
nit-pick: alphabetical order?
sound/soc/codecs/tas25xx-dsp.c line 21
Quoted 8 lines
sound/soc/codecs/tas25xx-dsp.c new file +8
-0+ +#include <sound/tas2562.h> +#include <sound/tas25xx-dsp.h> + + +static void tas25xx_process_fw_delay (struct tas25xx_cmd *cmd) +{ +mdelay (cpu_to_be16 (cmd->hdr.length));
is this the length of the header, or the duration of the delay?
Someone will get it wrong with this naming...
sound/soc/codecs/tas25xx-dsp.c line 29
Quoted 8 lines
sound/soc/codecs/tas25xx-dsp.c new file +8
-0+} + +static int tas25xx_process_fw_single (struct regmap *regmap, +struct tas25xx_cmd *cmd) +{ +int ret; +int num_writes =cpu_to_be16 (cmd->hdr.length); +struct tas25xx_cmd_reg *reg = &cmd->reg;
reverse x-mas style recommended, e.g. move 'int ret;' last
Quoted 97 lines
sound/soc/codecs/tas25xx-dsp.c new file +97
-0+ +for (int i =0 ; i < num_writes; i++, reg++) { +/* Reset Page to 0 to access BOOK_CTRL */ + ret =regmap_write (regmap,TAS2562_PAGE_CTRL ,0 ); +if (ret) +return ret; + + ret =regmap_write (regmap,TAS2562_BOOK_CTRL , reg->book); +if (ret) +return ret; + + ret =regmap_write (regmap,TAS2562_REG (reg->page, reg->offset), + reg->data); +if (ret) +return ret; + } + +return 0 ; +} + +static int tas25xx_process_fw_burst (struct regmap *regmap, +struct tas25xx_cmd *cmd) +{ +int ret; + +/* Reset Page to 0 to access BOOK_CTRL */ + ret =regmap_write (regmap,TAS2562_PAGE_CTRL ,0 ); +if (ret) +return ret; + + ret =regmap_write (regmap,TAS2562_BOOK_CTRL , cmd->reg.book); +if (ret) +return ret; + + ret =regmap_bulk_write (regmap,TAS2562_REG (cmd->reg.page, cmd->reg.offset), &cmd[1 ], +cpu_to_be16 (cmd->hdr.length)); +if (ret) +return ret; + +return 0 ; +} + +static int tas25xx_process_block (struct device *dev,struct regmap *regmap, +struct tas25xx_cmd *cmd,int max_block_size) +{ +int ret; +int block_read; + +const int hdr_size =sizeof (struct tas25xx_cmd_hdr ); +const int reg_size =sizeof (struct tas25xx_cmd_reg ); +const int cmd_size =sizeof (struct tas25xx_cmd ); + +switch (cpu_to_be16 (cmd->hdr.cmd_type)) { +case TAS25XX_CMD_SING_W : + block_read =cpu_to_be16 (cmd->hdr.length) * reg_size + hdr_size; +break ; +case TAS25XX_CMD_BURST : + block_read =cpu_to_be16 (cmd->hdr.length) + cmd_size; +break ; +case TAS25XX_CMD_DELAY : + block_read =4 ; +break ; +default : + block_read =0 ; + } + +if (block_read > max_block_size) { +dev_err (dev, +"Corrupt firmware: block_read > max_block_size %d %d\n" , + block_read, max_block_size); +return -EINVAL ; + } + +switch (cpu_to_be16 (cmd->hdr.cmd_type)) { +case TAS25XX_CMD_SING_W : + ret =tas25xx_process_fw_single (regmap, cmd); +if (ret) { +dev_err (dev,"Failed to process single write %d\n" , + ret); +return ret; + } +break ; +case TAS25XX_CMD_BURST : + ret =tas25xx_process_fw_burst (regmap, cmd); +if (ret) { +dev_err (dev,"Failed to process burst write %d\n" , ret); +return ret; + } +break ; +case TAS25XX_CMD_DELAY : +tas25xx_process_fw_delay (cmd); +break ; +default : +dev_warn (dev,"Unknown cmd type %d\n" , +cpu_to_be16 (cmd->hdr.cmd_type)); +break ; + };
sound/soc/codecs/tas25xx-dsp.c line 136
Quoted 10 lines
sound/soc/codecs/tas25xx-dsp.c new file +10
-0+ +return block_read; +} + + +int tas25xx_write_program (struct device *dev,struct regmap *regmap, +struct tas25xx_fw_data *fw_data,int prog_num) +{ +int offset =0 ; +int length =0 ;
useless init
sound/soc/codecs/tas25xx-dsp.c line 139
Quoted 3 lines
sound/soc/codecs/tas25xx-dsp.c new file +3
-0+struct tas25xx_program_info *prog_info; +struct tas25xx_fw_hdr *hdr = fw_data->hdr; +struct tas25xx_cmd *cmd;
again reverse x-mas style would look much better
sound/soc/codecs/tas25xx-dsp.c line 151
Quoted 12 lines
sound/soc/codecs/tas25xx-dsp.c new file +12
-0+ +if (prog_num >cpu_to_be32 (hdr->num_programs)) +return -EINVAL ; + +for (int i =0 ; i < prog_num; i++) + offset +=cpu_to_be32 (hdr->prog_size[i]); + + prog_info = (struct tas25xx_program_info *)&fw_data->prog_data[offset]; +dev_info (dev,"Write program %d: %s\n" , prog_num, prog_info->name); + +int max_offset = offset +cpu_to_be32 (hdr->prog_size[prog_num]); +int num_subblocks =cpu_to_be32 (prog_info->blk_data.num_subblocks);
It's not illegal but not consistent to declare variables in the middle of code for no good reason.
Quoted 15 lines
sound/soc/codecs/tas25xx-dsp.c new file +15
-0+ offset +=sizeof (struct tas25xx_program_info ); + +for (int i =0 ; i < num_subblocks; i++) { + cmd = (struct tas25xx_cmd *)&fw_data->prog_data[offset]; + length =tas25xx_process_block (dev, regmap, cmd, + max_offset - offset); +if (length <0 ) +return length; + + offset += length; + } + +/* Reset Book to 0 */ +regmap_write (regmap,TAS2562_PAGE_CTRL ,0 ); +regmap_write (regmap,TAS2562_BOOK_CTRL ,0 );
sound/soc/codecs/tas25xx-dsp.c line 177
Quoted 10 lines
sound/soc/codecs/tas25xx-dsp.c new file +10
-0+ +return 0 ; +} +EXPORT_SYMBOL_GPL (tas25xx_write_program); + +int tas25xx_write_config (struct device *dev,struct regmap *regmap, +struct tas25xx_fw_data *fw_data,int config_num) +{ +int offset =0 ; +int length =0 ;
useless init again
Quoted 34 lines
sound/soc/codecs/tas25xx-dsp.c new file +34
-0+struct tas25xx_config_info *cfg_info; +struct tas25xx_fw_hdr *hdr = fw_data->hdr; +struct tas25xx_cmd *cmd; + +if (config_num >cpu_to_be32 (hdr->num_configs)) +return -EINVAL ; + +for (int i =0 ; i < config_num; i++) + offset +=cpu_to_be32 (hdr->config_size[i]); + + cfg_info = (struct tas25xx_config_info *)&fw_data->config_data[offset]; +dev_info (dev,"Write config %d: %s\n" , config_num, cfg_info->name); + +int max_offset = offset +cpu_to_be32 (hdr->config_size[config_num]); +int num_subblocks =cpu_to_be32 (cfg_info->blk_data.num_subblocks); + + offset +=sizeof (struct tas25xx_config_info ); + +for (int i =0 ; i < num_subblocks; i++) { + cmd = (struct tas25xx_cmd *)&fw_data->config_data[offset]; + length =tas25xx_process_block (dev, regmap, cmd, + max_offset - offset); +if (length <0 ) +return length; + + offset += length; + } + +/* Reset Book to 0 */ +regmap_write (regmap,TAS2562_PAGE_CTRL ,0 ); +regmap_write (regmap,TAS2562_BOOK_CTRL ,0 ); + +return 0 ; +}
sound/soc/codecs/tas25xx-dsp.c line 221
Quoted 10 lines
sound/soc/codecs/tas25xx-dsp.c new file +10
-0+EXPORT_SYMBOL_GPL (tas25xx_write_config); + + +struct tas25xx_fw_data *tas25xx_parse_fw (struct device *dev, +const struct firmware *fw) +{ +u32 total_prog_sz =0 ; +u32 total_config_sz =0 ; +u32 prog_num =0 ; +u32 config_num =0 ;
last two inits are useless
Quoted 61 lines
sound/soc/codecs/tas25xx-dsp.c new file +61
-0+int hdr_size =sizeof (struct tas25xx_fw_hdr ); +struct tas25xx_fw_data *fw_data =NULL ; + + fw_data =devm_kzalloc (dev,sizeof (struct tas25xx_fw_data ),GFP_KERNEL ); +if (!fw_data) + goto err_fw; + +if (fw->size < hdr_size) + goto err_data; + + fw_data->hdr =devm_kzalloc (dev, hdr_size,GFP_KERNEL ); +if (!fw_data->hdr) + goto err_data; + +memcpy (fw_data->hdr, &fw->data[0 ], hdr_size); + +for (int i =0 ; i <cpu_to_be32 (fw_data->hdr->num_programs); i++) + total_prog_sz +=cpu_to_be32 (fw_data->hdr->prog_size[i]); + +for (int i =0 ; i <cpu_to_be32 (fw_data->hdr->num_configs); i++) + total_config_sz +=cpu_to_be32 (fw_data->hdr->config_size[i]); + +if (fw->size < hdr_size + total_prog_sz + total_config_sz) + goto err_hdr; + + fw_data->prog_data =devm_kzalloc (dev, total_prog_sz,GFP_KERNEL ); +if (!fw_data->prog_data) + goto err_hdr; + +memcpy (fw_data->prog_data, &fw->data[hdr_size], total_prog_sz); + + fw_data->config_data =devm_kzalloc (dev, total_config_sz,GFP_KERNEL ); +if (!fw_data->config_data) + goto err_prog; + +memcpy (fw_data->config_data, &fw->data[hdr_size + total_prog_sz], + total_config_sz); + + prog_num =cpu_to_be32 (fw_data->hdr->num_programs); + config_num =cpu_to_be32 (fw_data->hdr->num_configs); +dev_info (dev,"Firmware loaded: programs %d, configs %d\n" , + prog_num, config_num); + +return fw_data; + +err_prog: +devm_kfree (dev, fw_data->prog_data); +err_hdr: +devm_kfree (dev, fw_data->hdr); +err_data: +devm_kfree (dev, fw_data); +err_fw: +release_firmware (fw); + +return NULL ; +} +EXPORT_SYMBOL_GPL (tas25xx_parse_fw); + +MODULE_DESCRIPTION ("TAS25xx DSP library" ); +MODULE_AUTHOR ("Dan Murphy <[email protected]>" ); +MODULE_LICENSE ("GPL" );
Re: [PATCH 1/2] ASoc: tas2563: DSP Firmware loading support
Hi Pierre-Louis,
Thank you for your review.
Quoted 5 lines · Pierre-Louis Bossart
Quoted 2 lines
sound/soc/codecs/tas2562.c | 2 +-are tas2562 and tas2563 (from commit subject) the same?
No, tas2563 is register compatible with tas2562.
Quoted 6 lines
sound/soc/codecs/tas25xx-dsp.c line 13
Quoted 3 lines
sound/soc/codecs/tas25xx-dsp.c new file +2
-0+#include <linux/slab.h> +#include <linux/delay.h> nit-pick: alphabetical order?
Good idea, I'll fix it and the others in the next version.
Quoted 11 lines
sound/soc/codecs/tas25xx-dsp.c line 21
Quoted 8 lines
sound/soc/codecs/tas25xx-dsp.c new file +8
-0+ +#include <sound/tas2562.h> +#include <sound/tas25xx-dsp.h> + + +static void tas25xx_process_fw_delay (struct tas25xx_cmd *cmd) +{ +mdelay (cpu_to_be16 (cmd->hdr.length));is this the length of the header, or the duration of the delay?
Quoted 2 lines
Someone will get it wrong with this naming...
I think this is because of the format.
If cmd_type is TAS25XX_CMD_DELAY, then hdr.length is the length of the delay.
At least I think so, based on
https://lore.kernel.org/lkml/[email protected]/T/
https://github.com/torvalds/linux/blob/bee0e7762ad2c6025b9f5245c040fcc36ef2bde8/sound/soc/codecs/tas2781-fmwlib.c#L769
But I don't see any TAS25XX_CMD_DELAY command in the firmware I'm using.
Quoted 6 lines
sound/soc/codecs/tas25xx-dsp.c line 264
Quoted 6 lines
sound/soc/codecs/tas25xx-dsp.c new file +5
-0+ prog_num =cpu_to_be32 (fw_data->hdr->num_programs); + config_num =cpu_to_be32 (fw_data->hdr->num_configs); +dev_info (dev,"Firmware loaded: programs %d, configs %d\n" , + prog_num, config_num); +
For me:release_firmware(fw) is missing from here
Quoted 6 lines
Quoted 6 lines
sound/soc/codecs/tas25xx-dsp.c new file +6
-0+return fw_data; + +err_prog: +devm_kfree (dev, fw_data->prog_data); +err_hdr: +devm_kfree (dev, fw_data->hdr);
Quoted 8 lines
sound/soc/codecs/tas25xx-dsp.c line 277
Quoted 8 lines
sound/soc/codecs/tas25xx-dsp.c new file +7
-0+err_data: +devm_kfree (dev, fw_data); +err_fw: +release_firmware (fw); + +return NULL ; +}
Regards,
Gergo
PATCH 2/2 ALSA: hda/tas2563: Add tas2563 HDA driver
In reply to Gergo KotelesCreate tas2563 side codec HDA driver for Lenovo Yoga 7 14ARB7 laptops. It has two smart amplifiers that can load firmware (tuning file) and calibration data. The calibration data can be read from EFI variables. All of the tas2563s in the laptop will be aggregated as one audio speaker. The code supports realtek codec as the primary codec.
--- include/sound/tas2562.h | 5 + sound/pci/hda/Kconfig | 14 + sound/pci/hda/Makefile | 2 + sound/pci/hda/patch_realtek.c | 22 +- sound/pci/hda/tas2563_hda_i2c.c | 508 ++++++++++++++++++++++++++++++++ 5 files changed, 547 insertions(+), 4 deletions(-) create mode 100644 sound/pci/hda/tas2563_hda_i2c.c
include/sound/tas2562.h +5 -0
@@ -33,6 +33,11 @@#define TAS2562_TDM_CFG9 TAS2562_REG(0, 0x0f)#define TAS2562_TDM_CFG10 TAS2562_REG(0, 0x10)#define TAS2562_TDM_DET TAS2562_REG(0, 0x11) +#define TAS2562_BOOST_CFG1 TAS2562_REG(0, 0x33) +#define TAS2562_BOOST_CFG2 TAS2562_REG(0, 0x34) +#define TAS2562_BOOST_CFG3 TAS2562_REG(0, 0x35) +#define TAS2562_BOOST_CFG4 TAS2562_REG(0, 0x40) +#define TAS2562_ASI_CONFIG3 TAS2562_REG(0, 0x46)#define TAS2562_REV_ID TAS2562_REG(0, 0x7d)#define TAS2562_RX_OFF_MASK GENMASK(5, 1)
sound/pci/hda/Kconfig +14 -0
@@ -179,6 +179,20 @@ config SND_HDA_SCODEC_TAS2781_I2C comment "Set to Y if you want auto-loading the side codec driver" depends on SND_HDA=y && SND_HDA_SCODEC_TAS2781_I2C=m +config SND_HDA_SCODEC_TAS2563_I2C + tristate "Build TAS2563 HD-audio side codec support for I2C Bus" + depends on I2C + depends on ACPI + depends on EFI + depends on SND_SOC + select SND_SOC_TAS25XX_DSP + help + Say Y or M here to include TAS2563 I2C HD-audio side codec support + in snd-hda-intel driver, such as ALC287. + +comment "Set to Y if you want auto-loading the side codec driver" + depends on SND_HDA=y && SND_HDA_SCODEC_TAS2562_I2C=m + config SND_HDA_CODEC_REALTEK tristate "Build Realtek HD-audio codec support" select SND_HDA_GENERIC
sound/pci/hda/Makefile +2 -0
@@ -36,6 +36,7 @@ snd-hda-scodec-cs35l56-i2c-objs := cs35l56_hda_i2c.o snd-hda-scodec-cs35l56-spi-objs := cs35l56_hda_spi.o snd-hda-cs-dsp-ctls-objs := hda_cs_dsp_ctl.o snd-hda-scodec-tas2781-i2c-objs := tas2781_hda_i2c.o +snd-hda-scodec-tas2563-i2c-objs := tas2563_hda_i2c.o # common driver obj-$(CONFIG_SND_HDA) := snd-hda-codec.o
@@ -64,6 +65,7 @@ obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_I2C) += snd-hda-scodec-cs35l56-i2c.o obj-$(CONFIG_SND_HDA_SCODEC_CS35L56_SPI) += snd-hda-scodec-cs35l56-spi.o obj-$(CONFIG_SND_HDA_CS_DSP_CONTROLS) += snd-hda-cs-dsp-ctls.o obj-$(CONFIG_SND_HDA_SCODEC_TAS2781_I2C) += snd-hda-scodec-tas2781-i2c.o +obj-$(CONFIG_SND_HDA_SCODEC_TAS2563_I2C) += snd-hda-scodec-tas2563-i2c.o # this must be the last entry after codec drivers; # otherwise the codec patches won't be hooked before the PCI probe
sound/pci/hda/patch_realtek.c +18 -4
@@ -6770,7 +6770,7 @@ static int comp_match_cs35l41_dev_name(struct device *dev, void *data)return !strcmp (d + n, tmp); } -static int comp_match_tas2781_dev_name (struct device *dev, +static int comp_match_tas2xxx_dev_name (struct device *dev,void *data) {struct scodec_dev_name *p = data;
@@ -6823,7 +6823,7 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char } } -static void tas2781_generic_fixup (struct hda_codec *cdc,int action, +static void tas2xxx_generic_fixup (struct hda_codec *cdc,int action,const char *bus,const char *hid) {struct device *dev =hda_codec_dev (cdc);
@@ -6841,7 +6841,7 @@ static void tas2781_generic_fixup(struct hda_codec *cdc, int action, rec->index =0 ; spec->comps[0 ].codec = cdc;component_match_add (dev, &spec->match, - comp_match_tas2781_dev_name, rec); + comp_match_tas2xxx_dev_name, rec); ret =component_master_add_with_match (dev, &comp_master_ops, spec->match);if (ret)
@@ -6888,7 +6888,13 @@ static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const ststatic void tas2781_fixup_i2c (struct hda_codec *cdc,const struct hda_fixup *fix,int action) { -tas2781_generic_fixup (cdc, action,"i2c" ,"TIAS2781" ); +tas2xxx_generic_fixup (cdc, action,"i2c" ,"TIAS2781" ); +} + +static void tas2563_fixup_i2c (struct hda_codec *cdc, +const struct hda_fixup *fix,int action) +{ +tas2xxx_generic_fixup (cdc, action,"i2c" ,"INT8866" ); }/* for alc295_fixup_hp_top_speakers */
@@ -7358,6 +7364,7 @@ enum {ALC236_FIXUP_DELL_DUAL_CODECS ,ALC287_FIXUP_CS35L41_I2C_2_THINKPAD_ACPI ,ALC287_FIXUP_TAS2781_I2C , +ALC287_FIXUP_TAS2563_I2C ,ALC245_FIXUP_HP_MUTE_LED_COEFBIT ,ALC245_FIXUP_HP_X360_MUTE_LEDS , ALC287_FIXUP_THINKPAD_I2S_SPK,
@@ -9447,6 +9454,12 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC269_FIXUP_THINKPAD_ACPI, }, + [ALC287_FIXUP_TAS2563_I2C] = { + .type = HDA_FIXUP_FUNC, + .v.func = tas2563_fixup_i2c, + .chained = true, + .chain_id = ALC285_FIXUP_THINKPAD_HEADSET_JACK, + }, [ALC245_FIXUP_HP_MUTE_LED_COEFBIT] = { .type = HDA_FIXUP_FUNC, .v.func = alc245_fixup_hp_mute_led_coefbit,
@@ -10056,6 +10069,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x3853 ,"Lenovo Yoga 7 15ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3855 ,"Legion 7 16ITHG6" ,ALC287_FIXUP_LEGION_16ITHG6 ),SND_PCI_QUIRK (0x17aa ,0x3869 ,"Lenovo Yoga7 14IAL7" ,ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN ), +SND_PCI_QUIRK (0x17aa ,0x3870 ,"Lenovo Yoga 7 14ARB7" ,ALC287_FIXUP_TAS2563_I2C ),SND_PCI_QUIRK (0x17aa ,0x387d ,"Yoga S780-16 pro Quad AAC" ,ALC287_FIXUP_TAS2781_I2C ),SND_PCI_QUIRK (0x17aa ,0x387e ,"Yoga S780-16 pro Quad YC" ,ALC287_FIXUP_TAS2781_I2C ), SND_PCI_QUIRK(0x17aa, 0x3881, "YB9 dual power mode2 YC", ALC287_FIXUP_TAS2781_I2C),
sound/pci/hda/tas2563_hda_i2c.c new file +508 -0
508 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
Quoted 35 lines
sound/pci/hda/patch_realtek.c +3
-3@@ -6770,7 +6770,7 @@ static int comp_match_cs35l41_dev_name(struct device *dev, void *data)return !strcmp (d + n, tmp); } -static int comp_match_tas2781_dev_name (struct device *dev, +static int comp_match_tas2xxx_dev_name (struct device *dev,void *data) {struct scodec_dev_name *p = data;@@ -6823,7 +6823,7 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char } } -static void tas2781_generic_fixup (struct hda_codec *cdc,int action, +static void tas2xxx_generic_fixup (struct hda_codec *cdc,int action,const char *bus,const char *hid) {struct device *dev =hda_codec_dev (cdc);@@ -6841,7 +6841,7 @@ static void tas2781_generic_fixup(struct hda_codec *cdc, int action, rec->index =0 ; spec->comps[0 ].codec = cdc;component_match_add (dev, &spec->match, - comp_match_tas2781_dev_name, rec); + comp_match_tas2xxx_dev_name, rec); ret =component_master_add_with_match (dev, &comp_master_ops, spec->match);if (ret)
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st · line 6892
Quoted 6 lines
sound/pci/hda/patch_realtek.c +2
-1@@ -6888,7 +6888,13 @@ static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const ststatic void tas2781_fixup_i2c (struct hda_codec *cdc,const struct hda_fixup *fix,int action) { -tas2781_generic_fixup (cdc, action,"i2c" ,"TIAS2781" ); +tas2xxx_generic_fixup (cdc, action,"i2c" ,"TIAS2781" ); +}
this sort of rename should be part of a separate patch IMHO, it'd be easier to review.
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st · line 6897
Quoted 5 lines
sound/pci/hda/patch_realtek.c +5
-0+ +static void tas2563_fixup_i2c (struct hda_codec *cdc, +const struct hda_fixup *fix,int action) +{ +tas2xxx_generic_fixup (cdc, action,"i2c" ,"INT8866" );
Any specific reason to use an Intel ACPI identifier? Why not use "TIAS2563" ?
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st · line 6898
Quoted 1 line
sound/pci/hda/patch_realtek.c +1
-0+#define TAS2563_REG_INIT_N 12
newline
Quoted 7 lines
sound/pci/hda/patch_realtek.c +7
-0+static const struct reg_default tas2563_reg_init[TAS2563_MAX_CHANNELS ] + [TAS2563_REG_INIT_N ] = { + { + {TAS2562_TDM_CFG2 ,0x5a }, + {TAS2562_TDM_CFG4 ,0xf3 }, + {TAS2562_TDM_CFG5 ,0x42 }, + {TAS2562_TDM_CFG6 ,0x40 },
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st
Quoted 10 lines
sound/pci/hda/patch_realtek.c +9
-0+ { TAS2562_BOOST_CFG1, 0xd4 }, + { TAS2562_BOOST_CFG3, 0xa4 }, + { TAS2562_REG(0x00, 0x36), 0x0b }, + { TAS2562_REG(0x00, 0x38), 0x21 }, + { TAS2562_REG(0x00, 0x3c), 0x58 }, + { TAS2562_BOOST_CFG4, 0xb6 }, + { TAS2562_ASI_CONFIG3, 0x04}, + { TAS2562_REG(0x00, 0x47), 0xb1 }, +/* Update the calibrate data, including speaker impedance, f0, etc, into algo.
update the calibration data,
Quoted 1 line
+ * Calibrate data is done by manufacturer in the factory. These data are used
The manufacturer calibrates the data in the factory.
Quoted 1 line
+ * by Algo for calucating the speaker temperature, speaker membrance excursion
calculating
membrane
Quoted 33 lines
sound/pci/hda/patch_realtek.c +33
-0+static int tas2563_hda_i2c_probe (struct i2c_client *client) +{ +struct tas2563_data *tas2563; +int ret; + + tas2563 =devm_kzalloc (&client->dev,sizeof (struct tas2563_data ), +GFP_KERNEL ); +if (!tas2563) +return -ENOMEM ; + tas2563->dev = &client->dev; + tas2563->client = client; + +dev_set_drvdata (tas2563->dev, tas2563); + + ret =tas2563_read_acpi (tas2563); +if (ret) +return dev_err_probe (tas2563->dev, ret, +"Platform not supported\n" ); + +for (int i =0 ; i < tas2563->ndev; ++i) { +struct tas2563_dev *tasdev = &tas2563->tasdevs[i]; + + ret =tas2563_tasdev_read_efi (tas2563, tasdev); +if (ret) +return dev_err_probe (tas2563->dev, ret, +"Calibration data cannot be read from EFI\n" ); + + ret =tas2563_tasdev_init_client (tas2563, tasdev); +if (ret) +return dev_err_probe (tas2563->dev, ret, +"Failed to init i2c client\n" ); + + ret =tas2563_tasdev_init_regmap (tas2563, tasdev);
sound/pci/hda/patch_realtek.c
Quoted 10 lines
sound/pci/hda/patch_realtek.c +10
-0+if (ret) +return dev_err_probe (tas2563->dev, ret, +"Failed to allocate register map\n" ); + } + + ret =component_add (tas2563->dev, &tas2563_hda_comp_ops); +if (ret) { +return dev_err_probe (tas2563->dev, ret, +"Register component failed\n" ); + }
I wonder how many of those tests actually depend on deferred probe, and if this isn't a case of copy-paste "just in case"?
sound/pci/hda/patch_realtek.c
Quoted 9 lines
sound/pci/hda/patch_realtek.c +9
-0+ +pm_runtime_set_autosuspend_delay (tas2563->dev,3000 ); +pm_runtime_use_autosuspend (tas2563->dev); +pm_runtime_mark_last_busy (tas2563->dev); +pm_runtime_set_active (tas2563->dev); +pm_runtime_get_noresume (tas2563->dev); +pm_runtime_enable (tas2563->dev); + +pm_runtime_put_autosuspend (tas2563->dev);
the sequence get_noresume/enable/put_autosuspend makes no sense to me. doing a get_noresume *before* enable should do exactly nothing, and releasing the resource would already be handled with autosuspend based on the last_busy mark.
Quoted 4 lines
sound/pci/hda/patch_realtek.c +4
-0+ +return 0 ; +} +
sound/pci/hda/patch_realtek.c
Quoted 10 lines
sound/pci/hda/patch_realtek.c +10
-0+static void tas2563_hda_i2c_remove (struct i2c_client *client) +{ +struct tas2563_data *tas2563 =dev_get_drvdata (&client->dev); + +pm_runtime_get_sync (tas2563->dev); +pm_runtime_disable (tas2563->dev); + +component_del (tas2563->dev, &tas2563_hda_comp_ops); + +pm_runtime_put_noidle (tas2563->dev);
that pm_runtime sequence also makes no sense to me, if you disable pm_runtime the last command is useless/no-op.
Quoted 25 lines
sound/pci/hda/patch_realtek.c +25
-0+} + +static int tas2563_system_suspend (struct device *dev) +{ +struct tas2563_data *tas2563 =dev_get_drvdata (dev); +int ret; + +dev_dbg (tas2563->dev,"System Suspend\n" ); + + ret =pm_runtime_force_suspend (dev); +if (ret) +return ret; + +return 0 ; +} + +static int tas2563_system_resume (struct device *dev) +{ +int ret; +struct tas2563_data *tas2563 =dev_get_drvdata (dev); + +dev_dbg (tas2563->dev,"System Resume\n" ); + + ret =pm_runtime_force_resume (dev); +if (ret)
sound/pci/hda/patch_realtek.c
Quoted 10 lines
sound/pci/hda/patch_realtek.c +10
-0+return ret; + +for (int i =0 ; i < tas2563->ndev; ++i) +tas2563_tasdev_setup (tas2563, &tas2563->tasdevs[i]); + +return 0 ; +} + +static const struct dev_pm_ops tas2563_hda_pm_ops = { +SYSTEM_SLEEP_PM_OPS (tas2563_system_suspend, tas2563_system_resume)
where's the pm_runtime stuff?
Quoted 1 line
+};
Re: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
Hi Pierre-Louis,
Quoted 10 lines · Pierre-Louis Bossart
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st · line 6892
Quoted 6 lines
sound/pci/hda/patch_realtek.c +2
-1-tas2781_generic_fixup (cdc, action,"i2c" ,"TIAS2781" ); +tas2xxx_generic_fixup (cdc, action,"i2c" ,"TIAS2781" ); +}this sort of rename should be part of a separate patch IMHO, it'd be easier to review.
Okey.
Quoted 9 lines
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st · line 6897
Quoted 5 lines
sound/pci/hda/patch_realtek.c +5
-0+ +static void tas2563_fixup_i2c (struct hda_codec *cdc, +const struct hda_fixup *fix,int action) +{ +tas2xxx_generic_fixup (cdc, action,"i2c" ,"INT8866" );Any specific reason to use an Intel ACPI identifier? Why not use "TIAS2563" ?
INT8866 is in the ACPI.
I don't know why Lenovo uses this name.
I think it's more internal than intel.
Scope (_SB.I2CD)
{
Device (TAS)
{
Name (_HID, "INT8866") // _HID: Hardware ID
Name (_UID, Zero) // _UID: Unique ID
Method (_CRS, 0, NotSerialized) // _CRS: Current Resource
Settings
{
Name (RBUF, ResourceTemplate ()
{
I2cSerialBusV2 (0x004C, ControllerInitiated,
0x00061A80,
AddressingMode7Bit, "\\_SB.I2CD",
0x00, ResourceConsumer, , Exclusive,
)
I2cSerialBusV2 (0x004D, ControllerInitiated,
0x00061A80,
AddressingMode7Bit, "\\_SB.I2CD",
0x00, ResourceConsumer, , Exclusive,
)
GpioInt (Edge, ActiveLow, SharedAndWake, PullNone,
0x0000,
"\\_SB.GPIO", 0x00, ResourceConsumer, ,
)
{ // Pin list
0x0020
}
})
Return (RBUF) /* \_SB_.I2CD.TAS_._CRS.RBUF */
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
Return (0x0F)
}
}
}Quoted 82 lines
Quoted 1 line
+#define
TAS2563_REG_INIT_N12newline
Quoted 7 lines
sound/pci/hda/tas2563_hda_i2c.c new file +7
-0+static const struct reg_default tas2563_reg_init[TAS2563_MAX_CHANNELS ] + [TAS2563_REG_INIT_N ] = { + { + {TAS2562_TDM_CFG2 ,0x5a }, + {TAS2562_TDM_CFG4 ,0xf3 }, + {TAS2562_TDM_CFG5 ,0x42 }, + {TAS2562_TDM_CFG6 ,0x40 },sound/pci/hda/tas2563_hda_i2c.c
Quoted 10 lines
sound/pci/hda/tas2563_hda_i2c.c new file +9
-0+ { TAS2562_BOOST_CFG1, 0xd4 }, + { TAS2562_BOOST_CFG3, 0xa4 }, + { TAS2562_REG(0x00, 0x36), 0x0b }, + { TAS2562_REG(0x00, 0x38), 0x21 }, + { TAS2562_REG(0x00, 0x3c), 0x58 }, + { TAS2562_BOOST_CFG4, 0xb6 }, + { TAS2562_ASI_CONFIG3, 0x04}, + { TAS2562_REG(0x00, 0x47), 0xb1 }, +/* Update the calibrate data, including speaker impedance, f0, etc, into algo. update the calibration data,
Quoted 1 line
+ * Calibrate data is done by manufacturer in the factory. These data are used
The manufacturer calibrates the data in the factory.
Quoted 1 line
+ * by Algo for calucating the speaker temperature, speaker membrance excursion
calculating
membrane
Quoted 33 lines
sound/pci/hda/tas2563_hda_i2c.c new file +33
-0+static int tas2563_hda_i2c_probe (struct i2c_client *client) +{ +struct tas2563_data *tas2563; +int ret; + + tas2563 =devm_kzalloc (&client->dev,sizeof (struct tas2563_data ), +GFP_KERNEL ); +if (!tas2563) +return -ENOMEM ; + tas2563->dev = &client->dev; + tas2563->client = client; + +dev_set_drvdata (tas2563->dev, tas2563); + + ret =tas2563_read_acpi (tas2563); +if (ret) +return dev_err_probe (tas2563->dev, ret, +"Platform not supported\n" ); + +for (int i =0 ; i < tas2563->ndev; ++i) { +struct tas2563_dev *tasdev = &tas2563->tasdevs[i]; + + ret =tas2563_tasdev_read_efi (tas2563, tasdev); +if (ret) +return dev_err_probe (tas2563->dev, ret, +"Calibration data cannot be read from EFI\n" ); + + ret =tas2563_tasdev_init_client (tas2563, tasdev); +if (ret) +return dev_err_probe (tas2563->dev, ret, +"Failed to init i2c client\n" ); + + ret =tas2563_tasdev_init_regmap (tas2563, tasdev);sound/pci/hda/tas2563_hda_i2c.c line 421
Quoted 10 lines
sound/pci/hda/tas2563_hda_i2c.c new file +10
-0+if (ret) +return dev_err_probe (tas2563->dev, ret, +"Failed to allocate register map\n" ); + } + + ret =component_add (tas2563->dev, &tas2563_hda_comp_ops); +if (ret) { +return dev_err_probe (tas2563->dev, ret, +"Register component failed\n" ); + }I wonder how many of those tests actually depend on deferred probe, and if this isn't a case of copy-paste "just in case"?
Quoted 15 lines
sound/pci/hda/tas2563_hda_i2c.c line 430
Quoted 9 lines
sound/pci/hda/tas2563_hda_i2c.c new file +9
-0+ +pm_runtime_set_autosuspend_delay (tas2563->dev,3000 ); +pm_runtime_use_autosuspend (tas2563->dev); +pm_runtime_mark_last_busy (tas2563->dev); +pm_runtime_set_active (tas2563->dev); +pm_runtime_get_noresume (tas2563->dev); +pm_runtime_enable (tas2563->dev); + +pm_runtime_put_autosuspend (tas2563->dev);the sequence get_noresume/enable/put_autosuspend makes no sense to me. doing a
get_noresume*before* enable should do exactly nothing, and releasing the resource would already be handled with autosuspend based on thelast_busymark.
I copied this from the tas2781-hda driver, I'll dig into this more.
Quoted 47 lines
Quoted 4 lines
sound/pci/hda/tas2563_hda_i2c.c new file +4
-0+ +return 0 ; +} +sound/pci/hda/tas2563_hda_i2c.c line 444
Quoted 10 lines
sound/pci/hda/tas2563_hda_i2c.c new file +10
-0+static void tas2563_hda_i2c_remove (struct i2c_client *client) +{ +struct tas2563_data *tas2563 =dev_get_drvdata (&client->dev); + +pm_runtime_get_sync (tas2563->dev); +pm_runtime_disable (tas2563->dev); + +component_del (tas2563->dev, &tas2563_hda_comp_ops); + +pm_runtime_put_noidle (tas2563->dev);that
pm_runtimesequence also makes no sense to me, if you disablepm_runtimethe last command is useless/no-op.Quoted 29 lines
sound/pci/hda/tas2563_hda_i2c.c new file +29
-0+} + +static int tas2563_system_suspend (struct device *dev) +{ +struct tas2563_data *tas2563 =dev_get_drvdata (dev); +int ret; + +dev_dbg (tas2563->dev,"System Suspend\n" ); + + ret =pm_runtime_force_suspend (dev); +if (ret) +return ret; + +return 0 ; +} + +static int tas2563_system_resume (struct device *dev) +{ +int ret; +struct tas2563_data *tas2563 =dev_get_drvdata (dev); + +dev_dbg (tas2563->dev,"System Resume\n" ); + + ret =pm_runtime_force_resume (dev); +if (ret) +return ret; + +for (int i =0 ; i < tas2563->ndev; ++i) +tas2563_tasdev_setup (tas2563, &tas2563->tasdevs[i]);
Quoted 9 lines
sound/pci/hda/tas2563_hda_i2c.c line 479
Quoted 6 lines
sound/pci/hda/tas2563_hda_i2c.c new file +6
-0+ +return 0 ; +} + +static const struct dev_pm_ops tas2563_hda_pm_ops = { +SYSTEM_SLEEP_PM_OPS (tas2563_system_suspend, tas2563_system_resume)where's the
pm_runtimestuff?
The amp stores its state in software shutdown mode. The tas2563_hda_playback_hook wakes/shutdowns the amp, not the pm_runtime.
Quoted 2 lines
Quoted 1 line
+};
Regards,
Gergo
Re: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
Quoted 14 lines
Quoted 10 lines
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st · line 6897
Quoted 6 lines
sound/pci/hda/patch_realtek.c +5
-0+ +static void tas2563_fixup_i2c (struct hda_codec *cdc, +const struct hda_fixup *fix,int action) +{ +tas2xxx_generic_fixup (cdc, action,"i2c" ,"INT8866" );Any specific reason to use an Intel ACPI identifier? Why not use "TIAS2563" ?
INT8866 is in the ACPI.
I don't know why Lenovo uses this name.
I think it's more internal than intel.
Quoted 5 lines
Scope (_SB.I2CD)
{
Device (TAS)
{
Name (_HID, "INT8866") // _HID: Hardware IDOuch, I hope they checked with Intel that this isn't an HID already in use...
Quoted 57 lines
Name (
_UID, Zero) //_UID: Unique ID
Method (_CRS, 0, NotSerialized) //_CRS: Current Resource
Settings{ Name (RBUF, ResourceTemplate () { I2cSerialBusV2 (0x004C, ControllerInitiated, 0x00061A80, AddressingMode7Bit, "\\_SB.I2CD", 0x00, ResourceConsumer, , Exclusive, ) I2cSerialBusV2 (0x004D, ControllerInitiated, 0x00061A80, AddressingMode7Bit, "\\_SB.I2CD", 0x00, ResourceConsumer, , Exclusive, ) GpioInt (Edge, ActiveLow, SharedAndWake, PullNone, 0x0000, "\\_SB.GPIO", 0x00, ResourceConsumer, , ) { // Pin list 0x0020 } }) Return (RBUF) /* \_SB_.I2CD.TAS_._CRS.RBUF */ } Method (_STA, 0, NotSerialized) // _STA: Status { Return (0x0F) } } }Quoted 13 lines
Quoted 13 lines
sound/pci/hda/tas2563_hda_i2c.c new file +13
-0+static int tas2563_system_resume (struct device *dev) +{ +int ret; +struct tas2563_data *tas2563 =dev_get_drvdata (dev); + +dev_dbg (tas2563->dev,"System Resume\n" ); + + ret =pm_runtime_force_resume (dev); +if (ret) +return ret; + +for (int i =0 ; i < tas2563->ndev; ++i) +tas2563_tasdev_setup (tas2563, &tas2563->tasdevs[i]);Quoted 9 lines
sound/pci/hda/tas2563_hda_i2c.c line 479
Quoted 6 lines
sound/pci/hda/tas2563_hda_i2c.c new file +6
-0+ +return 0 ; +} + +static const struct dev_pm_ops tas2563_hda_pm_ops = { +SYSTEM_SLEEP_PM_OPS (tas2563_system_suspend, tas2563_system_resume)where's the
pm_runtimestuff?
Quoted 3 lines
The amp stores its state in software shutdown mode. The
tas2563_hda_playback_hookwakes/shutdowns the amp, not thepm_runtime.
My point was that you have all these pm_runtime_ calls in the code, but nothing that provides pm_runtime suspend-resume functions so not sure what exactly the result is?
Re: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
sound/pci/hda/tas2563_hda_i2c.c line 479
Quoted 3 lines
sound/pci/hda/tas2563_hda_i2c.c new file +2
-0+static const struct dev_pm_ops tas2563_hda_pm_ops = { +SYSTEM_SLEEP_PM_OPS (tas2563_system_suspend, tas2563_system_resume)where's the
pm_runtimestuff?
Quoted 7 lines
Quoted 3 lines
The amp stores its state in software shutdown mode. The
tas2563_hda_playback_hookwakes/shutdowns the amp, not thepm_runtime.My point was that you have all these
pm_runtime_calls in the code, but nothing that providespm_runtimesuspend-resume functions so not sure what exactly the result is?
if the inspiration was the tas2781, then see below it does have a RUNTIME_PM_OPS line as well as runtime_suspend/resume routines.
static const struct dev_pm_ops tas2781_hda_pm_ops = {
RUNTIME_PM_OPS(tas2781_runtime_suspend, tas2781_runtime_resume, NULL)
SYSTEM_SLEEP_PM_OPS(tas2781_system_suspend, tas2781_system_resume)
};Mark Brown
maintainerRe: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
In reply to Pierre-Louis BossartQuoted 5 lines · Pierre-Louis Bossart
Quoted 4 lines
Quoted 4 lines
sound/pci/hda/tas2563_hda_i2c.c line 479
Quoted 2 lines
sound/pci/hda/tas2563_hda_i2c.c new file +2
-0+static const struct dev_pm_ops tas2563_hda_pm_ops = { +SYSTEM_SLEEP_PM_OPS (tas2563_system_suspend, tas2563_system_resume)where's the
pm_runtimestuff?
Quoted 7 lines
Quoted 3 lines
The amp stores its state in software shutdown mode. The
tas2563_hda_playback_hookwakes/shutdowns the amp, not thepm_runtime.My point was that you have all these
pm_runtime_calls in the code, but nothing that providespm_runtimesuspend-resume functions so not sure what exactly the result is?
It *could* be ACPI doing something I guess...
Re: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
In reply to Pierre-Louis BossartQuoted 13 lines · Pierre-Louis Bossart
Quoted 13 lines
Quoted 9 lines
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st · line 6897
Quoted 5 lines
sound/pci/hda/patch_realtek.c +5
-0+ +static void tas2563_fixup_i2c (struct hda_codec *cdc, +const struct hda_fixup *fix,int action) +{ +tas2xxx_generic_fixup (cdc, action,"i2c" ,"INT8866" );Any specific reason to use an Intel ACPI identifier? Why not use "TIAS2563" ?
INT8866 is in the ACPI.
I don't know why Lenovo uses this name.
I think it's more internal than intel.
Quoted 9 lines
Quoted 5 lines
Scope (_SB.I2CD)
{
Device (TAS)
{
Name (_HID, "INT8866") //_HID: Hardware IDOuch, I hope they checked with Intel that this isn't an HID already in use...
It looks the INT prefix is not reserved. (yet)
https://uefi.org/ACPI_ID_List?acpi_search=INT
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
sound/pci/hda/tas2563_hda_i2c.c line 479
Quoted 6 lines
sound/pci/hda/tas2563_hda_i2c.c new file +5
-0+return 0 ; +} + +static const struct dev_pm_ops tas2563_hda_pm_ops = { +SYSTEM_SLEEP_PM_OPS (tas2563_system_suspend, tas2563_system_resume)where's the
pm_runtimestuff?
Quoted 9 lines
Quoted 3 lines
The amp stores its state in software shutdown mode. The
tas2563_hda_playback_hookwakes/shutdowns the amp, not thepm_runtime.My point was that you have all these
pm_runtime_calls in the code, but nothing that providespm_runtimesuspend-resume functions so not sure what exactly the result is?
I think nothing. I haven't experienced anything unusual recently.
Re: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 10 lines
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st · line 6897
Quoted 6 lines
sound/pci/hda/patch_realtek.c +4
-0+static void tas2563_fixup_i2c (struct hda_codec *cdc, +const struct hda_fixup *fix,int action) +{ +tas2xxx_generic_fixup (cdc, action,"i2c" ,"INT8866" );Any specific reason to use an Intel ACPI identifier? Why not use "TIAS2563" ?
INT8866 is in the ACPI.
I don't know why Lenovo uses this name.
I think it's more internal than intel.Scope (_SB.I2CD)
{
Device (TAS)
{
Name (_HID, "INT8866") //_HID: Hardware ID
Quoted 5 lines
Quoted 3 lines
Ouch, I hope they checked with Intel that this isn't an HID already in use...
It looks the INT prefix is not reserved. (yet)
https://uefi.org/ACPI_ID_List?acpi_search=INT
It's been de-facto reclaimed by Intel over the years, apparently using INTC or INTL was too hard for some of my colleagues...
There are lots of INT devices in the kernel today, here's a small list for sound/soc/codecs only
rt274.c: { "INT34C2", 0 },
rt286.c: { "INT343A", 0 },
rt298.c: { "INT343A", 0 },
ssm4567.c: { "INT343B", 0 },Those INT values were added by Intel teams though, it's really odd to see Lenovo use an INT-based HID. Should really use 104C2563 or something.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 8 lines
sound/pci/hda/tas2563_hda_i2c.c line 479
Quoted 5 lines
sound/pci/hda/tas2563_hda_i2c.c new file +5
-0+return 0 ; +} + +static const struct dev_pm_ops tas2563_hda_pm_ops = { +SYSTEM_SLEEP_PM_OPS (tas2563_system_suspend, tas2563_system_resume)where's the
pm_runtimestuff?The amp stores its state in software shutdown mode. The
tas2563_hda_playback_hookwakes/shutdowns the amp, not thepm_runtime.
Quoted 6 lines
Quoted 5 lines
My point was that you have all these
pm_runtime_calls in the code, but nothing that providespm_runtimesuspend-resume functions so not sure what exactly the result is?I think nothing. I haven't experienced anything unusual recently.
you can probably see from the /sys directory what the pm_runtime power state is, most likely the status is 'unknown'.
Re: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
Quoted 10 lines · Pierre-Louis Bossart
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
sound/pci/hda/patch_realtek.c static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const st · line 6897
Quoted 6 lines
sound/pci/hda/patch_realtek.c +4
-0+static void tas2563_fixup_i2c (struct hda_codec *cdc, +const struct hda_fixup *fix,int action) +{ +tas2xxx_generic_fixup (cdc, action,"i2c" ,"INT8866" );Any specific reason to use an Intel ACPI identifier? Why not use "TIAS2563" ?
Will just note that prefix should probably be TXNW (not TIAS) as discussed recently on list.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
INT8866 is in the ACPI.
I don't know why Lenovo uses this name.
I think it's more internal than intel.Scope (_SB.I2CD)
{
Device (TAS)
{
Name (_HID, "INT8866") //_HID: Hardware ID
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
Ouch, I hope they checked with Intel that this isn't an HID already in use...
It looks the INT prefix is not reserved. (yet)
https://uefi.org/ACPI_ID_List?acpi_search=INTIt's been de-facto reclaimed by Intel over the years, apparently using INTC or INTL was too hard for some of my colleagues...
Perhaps it should be reserved then, so it is present on above list?
Quoted 10 lines
There are lots of INT devices in the kernel today, here's a small list for
sound/soc/codecsonlyrt274.c: { "INT34C2", 0 }, rt286.c: { "INT343A", 0 }, rt298.c: { "INT343A", 0 }, ssm4567.c: { "INT343B", 0 },Those INT values were added by Intel teams though, it's really odd to see Lenovo use an INT-based HID. Should really use 104C2563 or something.
I will just note that those RT ones are used on quite old RVPs, and yes I would have also preferred if they had used "real" IDs, but it is unlikely that anyone fixes it after all this time ;).
Adding Andy to CC, as he commented recently about problematic assignments of ACPI IDs on this list, maybe he can shed some light on the "INT" prefix.
Re: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
Quoted 1 line · Amadeusz Sławiński
On 12/5/2023 6:22 PM, Pierre-Louis Bossart wrote:
...
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ tas2xxx_generic_fixup(cdc, action, "i2c", "INT8866");Any specific reason to use an Intel ACPI identifier? Why not use "TIAS2563" ?
Will just note that prefix should probably be TXNW (not TIAS) as discussed recently on list.
...which should come directly from TI as it's their responsibility to allocate an ACPI ID.
...
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
INT8866 is in the ACPI.
I don't know why Lenovo uses this name.
I think it's more internal than intel.
This is wrong (PNP) ID.
...
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Name (
_HID, "INT8866") //_HID: Hardware IDOuch, I hope they checked with Intel that this isn't an HID already in use...
It looks the INT prefix is not reserved. (yet)
https://uefi.org/ACPI_ID_List?acpi_search=INT
You are looking into wrong registry, and yeah, Intel used wrong PNP ID for years...
Quoted 4 lines
Quoted 2 lines
It's been de-facto reclaimed by Intel over the years, apparently using INTC or INTL was too hard for some of my colleagues...
Perhaps it should be reserved then, so it is present on above list?
Signature · 2 lines
With Best Regards, Andy Shevchenko
kernel test robot
build botRe: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver
In reply to Gergo Koteleskernel test robot noticed the following build warnings:
Hi Gergo,
kernel test robot noticed the following build warnings:
[auto build test WARNING on ffc253263a1375a65fa6c9f62a893e9767fbebfa]
url: https://github.com/intel-lab-lkp/linux/commits/Gergo-Koteles/ASoc-tas2563-DSP-Firmware-loading-support/20231205-074901 base: ffc253263a1375a65fa6c9f62a893e9767fbebfa patch link: https://lore.kernel.org/r/4a2f31d4eb8479789ceb1daf2e93ec0e25c23171.1701733441.git.soyer%40irl.hu patch subject: [PATCH 2/2] ALSA: hda/tas2563: Add tas2563 HDA driver config: x86_64-randconfig-r121-20231210 (https://download.01.org/0day-ci/archive/20231210/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231210/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> sound/soc/codecs/tas25xx-dsp.c:21:9: sparse: sparse: restricted __be16 degrades to integer >> sound/soc/codecs/tas25xx-dsp.c:21:9: sparse: sparse: incorrect type in initializer (different base types) @@ expected unsigned long __ms @@ got restricted __be16 [usertype] @@ sound/soc/codecs/tas25xx-dsp.c:21:9: sparse: expected unsigned long __ms sound/soc/codecs/tas25xx-dsp.c:21:9: sparse: got restricted __be16 [usertype] >> sound/soc/codecs/tas25xx-dsp.c:21:9: sparse: sparse: restricted __be16 degrades to integer >> sound/soc/codecs/tas25xx-dsp.c:21:9: sparse: sparse: restricted __be16 degrades to integer >> sound/soc/codecs/tas25xx-dsp.c:21:9: sparse: sparse: restricted __be16 degrades to integer >> sound/soc/codecs/tas25xx-dsp.c:21:9: sparse: sparse: restricted __be16 degrades to integer >> sound/soc/codecs/tas25xx-dsp.c:28:26: sparse: sparse: incorrect type in initializer (different base types) @@ expected int num_writes @@ got restricted __be16 [usertype] @@ sound/soc/codecs/tas25xx-dsp.c:28:26: sparse: expected int num_writes sound/soc/codecs/tas25xx-dsp.c:28:26: sparse: got restricted __be16 [usertype] >> sound/soc/codecs/tas25xx-dsp.c:65:33: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected unsigned long [usertype] val_count @@ got restricted __be16 [usertype] @@ sound/soc/codecs/tas25xx-dsp.c:65:33: sparse: expected unsigned long [usertype] val_count sound/soc/codecs/tas25xx-dsp.c:65:33: sparse: got restricted __be16 [usertype] sound/soc/codecs/tas25xx-dsp.c:84:30: sparse: sparse: restricted __be16 degrades to integer sound/soc/codecs/tas25xx-dsp.c:87:30: sparse: sparse: restricted __be16 degrades to integer sound/soc/codecs/tas25xx-dsp.c:82:17: sparse: sparse: restricted __be16 degrades to integer sound/soc/codecs/tas25xx-dsp.c:82:17: sparse: sparse: restricted __be16 degrades to integer sound/soc/codecs/tas25xx-dsp.c:82:17: sparse: sparse: restricted __be16 degrades to integer sound/soc/codecs/tas25xx-dsp.c:103:17: sparse: sparse: restricted __be16 degrades to integer sound/soc/codecs/tas25xx-dsp.c:103:17: sparse: sparse: restricted __be16 degrades to integer sound/soc/codecs/tas25xx-dsp.c:103:17: sparse: sparse: restricted __be16 degrades to integer >> sound/soc/codecs/tas25xx-dsp.c:141:24: sparse: sparse: restricted __be32 degrades to integer >> sound/soc/codecs/tas25xx-dsp.c:145:24: sparse: sparse: invalid assignment: += >> sound/soc/codecs/tas25xx-dsp.c:145:24: sparse: left side has type int >> sound/soc/codecs/tas25xx-dsp.c:145:24: sparse: right side has type restricted __be32 sound/soc/codecs/tas25xx-dsp.c:150:35: sparse: sparse: restricted __be32 degrades to integer >> sound/soc/codecs/tas25xx-dsp.c:151:29: sparse: sparse: incorrect type in initializer (different base types) @@ expected int num_subblocks @@ got restricted __be32 [usertype] @@ sound/soc/codecs/tas25xx-dsp.c:151:29: sparse: expected int num_subblocks sound/soc/codecs/tas25xx-dsp.c:151:29: sparse: got restricted __be32 [usertype] sound/soc/codecs/tas25xx-dsp.c:182:26: sparse: sparse: restricted __be32 degrades to integer sound/soc/codecs/tas25xx-dsp.c:186:24: sparse: sparse: invalid assignment: += sound/soc/codecs/tas25xx-dsp.c:186:24: sparse: left side has type int sound/soc/codecs/tas25xx-dsp.c:186:24: sparse: right side has type restricted __be32 sound/soc/codecs/tas25xx-dsp.c:191:35: sparse: sparse: restricted __be32 degrades to integer sound/soc/codecs/tas25xx-dsp.c:192:29: sparse: sparse: incorrect type in initializer (different base types) @@ expected int num_subblocks @@ got restricted __be32 [usertype] @@ sound/soc/codecs/tas25xx-dsp.c:192:29: sparse: expected int num_subblocks sound/soc/codecs/tas25xx-dsp.c:192:29: sparse: got restricted __be32 [usertype] sound/soc/codecs/tas25xx-dsp.c:238:29: sparse: sparse: restricted __be32 degrades to integer sound/soc/codecs/tas25xx-dsp.c:239:31: sparse: sparse: invalid assignment: += >> sound/soc/codecs/tas25xx-dsp.c:239:31: sparse: left side has type unsigned int sound/soc/codecs/tas25xx-dsp.c:239:31: sparse: right side has type restricted __be32 sound/soc/codecs/tas25xx-dsp.c:241:29: sparse: sparse: restricted __be32 degrades to integer sound/soc/codecs/tas25xx-dsp.c:242:33: sparse: sparse: invalid assignment: += sound/soc/codecs/tas25xx-dsp.c:242:33: sparse: left side has type unsigned int sound/soc/codecs/tas25xx-dsp.c:242:33: sparse: right side has type restricted __be32 >> sound/soc/codecs/tas25xx-dsp.c:260:18: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] prog_num @@ got restricted __be32 [usertype] @@ sound/soc/codecs/tas25xx-dsp.c:260:18: sparse: expected unsigned int [usertype] prog_num sound/soc/codecs/tas25xx-dsp.c:260:18: sparse: got restricted __be32 [usertype] >> sound/soc/codecs/tas25xx-dsp.c:261:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] config_num @@ got restricted __be32 [usertype] @@ sound/soc/codecs/tas25xx-dsp.c:261:20: sparse: expected unsigned int [usertype] config_num sound/soc/codecs/tas25xx-dsp.c:261:20: sparse: got restricted __be32 [usertype] -- >> sound/pci/hda/tas2563_hda_i2c.c:325:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int @@ got restricted __be32 [usertype] @@
sound/pci/hda/tas2563_hda_i2c.c:325:37: sparse: expected unsigned int
sound/pci/hda/tas2563_hda_i2c.c:325:37: sparse: got restricted __be32 [usertype]
vim +325 sound/pci/hda/tas2563_hda_i2c.c
306
307 /* Update the calibrate data, including speaker impedance, f0, etc, into algo.
308 * Calibrate data is done by manufacturer in the factory. These data are used
309 * by Algo for calucating the speaker temperature, speaker membrance excursion
310 * and f0 in real time during playback.
311 */
312 static int tas2563_tasdev_read_efi(struct tas2563_data *tas2563,
313 struct tas2563_dev *tasdev)
314 {
315 efi_status_t status;
316 unsigned int attr;
317 unsigned long max_size = TAS2563_CAL_DATA_SIZE;
318
319 for (int i = 0; i < TAS2563_CAL_N; ++i) {
320 status = efi.get_variable(efi_var_names[tasdev->dev_id][i],
321 &efi_guid, &attr, &max_size,
322 &tasdev->cal_data[i]);
323 if (status != EFI_SUCCESS)
324 return -EINVAL;
> 325 tasdev->cal_data[i] = cpu_to_be32(tasdev->cal_data[i]);
326 }
327
328 dev_info(tas2563->dev,
329 "Calibration data %d: power:%08x r0:%08x inv_r0:%08x r0_low:%08x tlim:%08x\n",
330 tasdev->dev_id, tasdev->cal_data[0], tasdev->cal_data[1],
331 tasdev->cal_data[2], tasdev->cal_data[3], tasdev->cal_data[4]);
332
333 return 0;
334 }
335
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Please disregard this patch.
The tas2781-hda driver will handle this.
https://lore.kernel.org/all/[email protected]/
Quoted 43 lines · Gergo Koteles
The ta2563 is a smart amplifier. Similar to tas2562 but with DSP. Some Lenovo laptops have it to drive the bass speakers. By default, it is in software shutdown state.
To make the DSP work it needs a firmware and some calibration data. The latter can be read from the EFI in Lenovo laptops.
For the correct configuration it needs additional register data. It captured after running the Windows driver.
The firmware can be extracted as TAS2563Firmware.bin from the Windows driver with innoextract.
https://download.lenovo.com/consumer/mobiles/h5yd037fbfyy7kd0.exeThe driver will search for it as TAS2563-17AA3870.bin with the 14ARB7.
It uses the default program/configuration, and has no controls for these yet.
The amplifier works without firmware, but I don't know how safe is it, that's why the firmware is required.
Gergo Koteles (2):
ASoc: tas2563: DSP Firmware loading support
ALSA: hda/tas2563: Add tas2563 HDA driver{sound/soc/codecs => include/sound}/tas2562.h | 8 + include/sound/tas25xx-dsp.h | 100 ++++ sound/pci/hda/Kconfig | 14 + sound/pci/hda/Makefile | 2 + sound/pci/hda/patch_realtek.c | 22 +- sound/pci/hda/tas2563_hda_i2c.c | 508 ++++++++++++++++++ sound/soc/codecs/Kconfig | 7 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tas2562.c | 2 +- sound/soc/codecs/tas25xx-dsp.c | 282 ++++++++++ 10 files changed, 942 insertions(+), 5 deletions(-) rename {sound/soc/codecs => include/sound}/tas2562.h (90%) create mode 100644 include/sound/tas25xx-dsp.h create mode 100644 sound/pci/hda/tas2563_hda_i2c.c create mode 100644 sound/soc/codecs/tas25xx-dsp.cbase-commit:
ffc253263a1375a65fa6c9f62a893e9767fbebfa