ALSA: hda/tas2781: Add tas2781 hda SPI driver
Subsystems (4)
PATCH v8 1/1 ALSA: hda/tas2781: Add tas2781 hda SPI driver
This patch was used to add TAS2781 devices on SPI support in sound/pci/hda. It use ACPI node descript about parameters of TAS2781 on SPI, it like:
Scope (_SB.PC00.SPI0)
{
Device (GSPK)
{
Name (_HID, "TXNW2781") // _HID: Hardware ID
Method (_CRS, 0, NotSerialized)
{
Name (RBUF, ResourceTemplate ()
{
SpiSerialBusV2 (...)
SpiSerialBusV2 (...)
}
}
}
}And in platform/x86/serial-multi-instantiate.c, those spi devices will be added into system as a single SPI device, so TAS2781 SPI driver will probe twice for every single SPI device. And driver will also parser mono DSP firmware binary and RCA binary for itself.
The code support Realtek as the primary codec.
---
v8:
- Move *-y position in sound/pci/hda/Makefile.
- Change + to | for bit operation in macro define.
- Change TASDEVICE_Checksum to TASDEVICE_CHECKSUM.
v7:
- Add new project Gemtree (0x103c8daa) support for tas2781 spi driver.
v6:
- Remove client in tasdevice_priv struct as it was not used.
- Change format for tasdevice_spi_dev_write() in tas2781_hda_spi.c.
- Change update bits function to read & write mode, as tas2781 use last bit to mask read & write, it cause regmap_update_bits work not as our expected.
- Add element in tas2781_snd_controls, tas2781_prof_ctrl, tas2781_dsp_conf_ctrl, to support second device.
Previous version add sound card for first index only.
- Change calibration registers address declaire to TASDEVICE_REG() mode.
- Add snd_ctl_new1() for second device.
- Change format for tas2781_hda_unbind() to fit 79 chars in one line.
- Remove client for spi as it was not used.
- Remove unused variables.
- Remove cur_prog clean in runtime_suspend().
- Remove unused variables.
- Add tasdevice_spi_tuning_switch() in runtime_resume.
- Remove cur_prog clean in system_resume().
- Add tuning switch if playback started in system_resume().
- Change TASDEVICE_PAGE_REG to TASDEVICE_REG_ID in tas2781_spi_fwlib.c.
- Remove calibration binary load functions as data will be loaded from EFI.
v5:
- Combined all modification into one patch for pass the compile.
- Remove old hardware id "TIAS2781" as no production on market.
- Change max page size to 256 in tas2781-spi.h.
- Change book reg from 127 to GENMASK(7, 1), as one bit shift is needed.
- Change register address define as one bit shift needed for offset.
- Change block check sum comments to Firmware block from I2C.
- Change define of (page + reg) to TASDEVICE_PAGE_REG from TASDEVICE_PGRG.
- Change to lower case in defined value.
- Add registers default value table in tas2781_hda_spi.c
- Change rang_max to 256 * 256.
- Add zero_flag_mask in regmap_config.
- Change max_register to 256 * 256.
- Add registers default table into structure regmap_config.
- Change parameter from book number to whole register address.
- Remove page 0 switch as SPI driver will do it.
- Add bit(0) for read function as tas2781 will check last bit of address, to determine operation mode is read (1) or write (0).
- Change switch case to if check in tas2781_hda_playback_hook(), as it may cause compile problem in clang-19 building.
- Change variable declaration position.
- Change order in if check.
- Remove old hardware id ("TIAS2781") support.
- Remove debug message in runtime suspend and resume.
- Remove regmap.h include in tas2781_spi_fwlib.c.
- Remove MODULE_ in fwlib as this file will work with tas2781_hda_spi.c only.
v4:
- Add old hardware id "TIAS2781" for compatible with old production
- Add 2 devices in struct smi_node tas2781_hda, to compatible with 4 AMPs
v4:
- Add old hardware id "TIAS2781" for compatible with old production
- Add 2 devices in struct smi_node tas2781_hda, to compatible with 4 AMPs
- Move include of sound/tas2781-dsp.h to c source file tas2781_hda_spi.c, tas2781_spi_fwlib.c, as it's not needed in header file tas2781-spi.h
- Use page and book number define in other micro define
- Change 4000000 to (4 * HZ_PER_MHZ)
- Add define for calibration variable name and size in UEFI.
- Remove structure tasdevice & tasdevice_irqinfo, and move variables in to structure tasdevice_priv
- Remove some unused variables in sttructure tasdevice_priv
- Remove function declare of tascodec_init(), use tascodec_spi_init()
- Remove function declare of tasdevice_remove()
- Add array_size.h included in tas2781_hda_spi.c
- Add cleanup.h included for change mutex to guard
- Add units.h included
- Include tas2781-dsp.h
- Remove unused variables in tas2781_hda structure
- Change 0xff to GENMASK(7, 0)
- Change 128 to define of max page size
- Change code as all variables was moved to tasdevice_priv structure
- Change comments for error in book write, or page write
- Remove initial of ret, and return 0 directly
- Change comments for wrong typo, add space in front and end
- Add check for bulk read, max size should be a page size
- Change usleep_rang() to fsleep()
- Change mutex_lock to guard(mutex), and remove mutex_unlock()
- Change tasdevice_spi_init() to void from int as no value return required
- Change second parameter to sizeof
- Remove tasdevice_clamp(), use clamp()
- Add compatible with old hardware id "TIAS2781"
- Remove cs_gpio and spi device in tas2781_read_acpi() as use default CS
- Change dev-index check, return -EINVAL if it's <= 0
- Change 0xFF to U8_MAX
- Remove GPIO get for chip-select, use default from SPI device
- Perform RESET in first AMP only as all AMPs share same RESET pin
- return 0 directly in some simple routine to avoid variable initial
- Change comments for function which was used by system
- Change "ON" "OFF" to function str_on_off(...)
- Change format of GUID
- Add temp buffer for first efi.get_variable()
- Free data if it was allocated
- Change format of debug message of calibration date time print
- Remove total_sz = 0, as it's not needed
- Move save_calibration to after tuning_switch to avoid calibration data overwrite
- Remove dev from structure tasdevice_hda, use dev in tasdevice_priv
- Remove 0 from { "tas2781-hda", 0}, & {"TXNW2781", 0},
- Add old hardware id "TIAS2781" for compatible with old production
- Add 2 devices in struct smi_node tas2781_hda, to compatible with 4 AMPs
v3:
- Move HID up to above /* Non-conforming _HID ... */ in scan.c, for avoid misunderstanding.
- Move HID up to above /* Non-conforming _HID ... */ in serial-multi-instantiate.c, for avoid misunderstanding.
- Change objs to y for snd-hda-scodec-tas2781-spi- in Makefile.
- Change format for some define in tas2781-spi.h.
- Add define for TASDEVICE_MAX_BOOK_NUM, TASDEVICE_MAX_PAGE.
- Move declare of "enum calib_data {" to header file from source file.
- Remove "enum device_catlog_id {" as only one platform was supported now.
- Remove "struct calidata", as we will save pure calibration data only.
- Remove "struct calidata", "enum device_catlog_id" in tasdevice_priv.
- Add calibration_data in tasdevice_priv to save pure calibration data.
- Remove declare of tasdevice_save_calibration() and tasdevice_apply_calibration(), as it will be used within same c file.
- Add below header files included in tas2781_hda_spi.c:
bits.h, mutex.h, property.h, time.h, types.h.
- Move two micro define to header file tas2781-spi.h.
- Change format of some micro define.
- Change format of some structure.
- Remove irq in tas2781_hda, as have it already in tasdevice_priv.
- Remove some local functions declare as not necessarily.
- Return error if regmap_write() failed.
- Change fixed value 2 to sizeof(data).
- Remove all of EXPORT_SYMBOL_GPL,
as all of function was called within same module.
- Remove empty line after last return in some functions.
- Remove some variable initialyzation.
- Remove variable sub, store acpi_subsystem_id directly.
- Remove wrong comments for device index, it's must, can't be NULL.
- Remove some local variables, use elements in structure directly.
- Append commas in last element of an array.
- Change calibration data process, didn't save all of calibration data in EFI, get in local, and save pure calibration data in tasdevice_priv.
- Call tasdevice_save_calibration() from function pointer in tasdevice_priv;
- Remove subid as one platform was supported only, needn't check.
- Add initialyzation for local variable.
- Move regmap initialyzation to before acpi read.
- Call tasdevice_apply_calibration() from function pointer in tasdevice_priv;
- Remove MODULE_IMPORT_NS(SND_SOC_TAS2781_FMWLIB), as all functions was performed within same module.
- Update format and variables declare order.
- Change format of multi conditions for if.
- Remove casting which is not needed.
- Change variables type to avoid casting.
- Remove Unneeded parentheses.
- Change if check to avoid goto.
- Add {} for keep same style.
- Remove some local variables, use elements in structure directly.
v2:
- Change depends on SPI to SPI_MASTER in sound/pci/hda/Kconfig
- Add select SND_HDA_SCODEC_COMPONENT in sound/pci/hda/Kconfig
- Change comp_generic_fixup() 5th parameter from "-%s:00" to "-%s:00-tas2781-hda.%d" in sound/pci/hda/patch_realtek.c
- Change chain_id from ALC285_FIXUP_THINKPAD_HEADSET_JACK to ALC285_FIXUP_HP_GPIO_LED in sound/pci/hda/patch_realtek.c
- Remove project name "Gemtree"
- Update information in file header of tas2781-spi.h.
- Remove useless micro define.
- Change TASDEVICE_I2CChecksum to TASDEVICE_Checksum
- Remove enum control_bus as current code support SPI only.
- Remove device define as current code support TAS2781 only.
- Remove spi_device **spi_devs in structure tasdevice_priv.
- Remove cal_binaryname in structure tasdevice_priv.
- Remove ndev in structure tasdevice_priv.
- Change isacpi and isspi, replace by control_bus(I2C or SPI).
- Remove void tasdevice_spi_dsp_remove(void *context).
- Add acpi_device and irq in structure tas2781_hda in tas2781_hda_spi.c.
- Remove parameter chn in all of registers access functions.
- Add tascodec_spi_init().
- Add chip select gpio set for SPI device.
- Change tasdevice_tuning_switch() to tasdevice_spi_tuning_switch().
- Change device offset from tas_priv->ndev to tas_priv->index.
- Change tasdevice_dsp_remove() to tasdevice_spi_dsp_remove().
- tasdevice_prmg_load() to tasdevice_spi_prmg_load().
- Change tasdevice_config_info_remove() to tasdevice_spi_config_info_remove().
- Add one dummy byte shift when read from page 2~127, or not book 0.
- Change tasdevice_spi_change_chn_book() to tasdevice_spi_switch_book()
- Perform put_device(physdev) before error return.
- Change calibration data id to 2781 from 2783 in EFI
- Change calibration data structure name in comments.
- Remove file name in tas2781_spi_fwlib.c.
- Remove #include <linux/i2c.h> as it not needed in SPI mode.
- Change TAB to speace in micro define in tas2781_spi_fwlib.c.
- Change to up-case for DSP.
- Change all of multi-line comments format, empty first line.
- Change all of sizeof(struct xx) to sizeof(*xx).
- Remove Explicit casting for variables compare to avoid possible fault.
- Return directly without goto.
- Change 1 << xx to BIT(xx).
- Remove deviceNumber[] as current SPI device will support one device only.
- Add memory free before return error.
- Change "buf[offset]; offset += 1" to buf[offset++].
- Remove some debug information print.
- Change firmware binary to single device mode.
- Change all bexx_to_cpup() to get_unaligned_bexx().
- Remove ndev process as current SPI device support single device only.
- Remove chn and chnend for single device support only.
- Change all of registers read/write function, remove parameter chn.
- Create new function for single write, burst write, delay, field write in tasdevice_process_block().
--- drivers/acpi/scan.c | 1 + .../platform/x86/serial-multi-instantiate.c | 12 + sound/pci/hda/Kconfig | 14 + sound/pci/hda/Makefile | 2 + sound/pci/hda/patch_realtek.c | 14 + sound/pci/hda/tas2781-spi.h | 148 ++ sound/pci/hda/tas2781_hda_spi.c | 1266 ++++++++++ sound/pci/hda/tas2781_spi_fwlib.c | 2101 +++++++++++++++++ 8 files changed, 3558 insertions(+) create mode 100644 sound/pci/hda/tas2781-spi.h create mode 100644 sound/pci/hda/tas2781_hda_spi.c create mode 100644 sound/pci/hda/tas2781_spi_fwlib.c
drivers/acpi/scan.c +1 -0
@@ -1760,6 +1760,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) {"CSC3557", }, {"INT33FE", }, {"INT3515", }, + {"TXNW2781", }, /* Non-conforming _HID for Cirrus Logic already released */ {"CLSA0100", }, {"CLSA0101", },
drivers/platform/x86/serial-multi-instantiate.c +12 -0
@@ -368,6 +368,17 @@ static const struct smi_node cs35l57_hda = { .bus_type = SMI_AUTO_DETECT, }; +static const struct smi_node tas2781_hda = { + .instances = { + {"tas2781-hda" ,IRQ_RESOURCE_AUTO ,0 }, + {"tas2781-hda" ,IRQ_RESOURCE_AUTO ,0 }, + {"tas2781-hda" ,IRQ_RESOURCE_AUTO ,0 }, + {"tas2781-hda" ,IRQ_RESOURCE_AUTO ,0 }, + {} + }, + .bus_type =SMI_AUTO_DETECT , +}; +/* * Note new device-ids must also be added to ignore_serial_bus_ids in * drivers/acpi/scan.c: acpi_device_enumeration_by_parent().
@@ -380,6 +391,7 @@ static const struct acpi_device_id smi_acpi_ids[] = { { "CSC3556", (unsigned long)&cs35l56_hda }, { "CSC3557", (unsigned long)&cs35l57_hda }, { "INT3515", (unsigned long)&int3515_data }, + { "TXNW2781", (unsigned long)&tas2781_hda },/* Non-conforming _HID for Cirrus Logic already released */ { "CLSA0100", (unsigned long)&cs35l41_hda }, { "CLSA0101", (unsigned long)&cs35l41_hda },
sound/pci/hda/Kconfig +14 -0
@@ -204,6 +204,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_TAS2781_SPI + tristate "Build TAS2781 HD-audio side codec support for SPI Bus" + depends on SPI_MASTER + depends on ACPI + depends on EFI + depends on SND_SOC + select CRC32_SARWATE + help + Say Y or M here to include TAS2781 SPI 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_TAS2781_SPI=m + config SND_HDA_CODEC_REALTEK tristate "Build Realtek HD-audio codec support" select SND_HDA_GENERIC
sound/pci/hda/Makefile +2 -0
@@ -39,6 +39,7 @@ snd-hda-scodec-cs35l56-spi-y := cs35l56_hda_spi.o snd-hda-cs-dsp-ctls-y := hda_cs_dsp_ctl.o snd-hda-scodec-component-y := hda_component.o snd-hda-scodec-tas2781-i2c-y := tas2781_hda_i2c.o +snd-hda-scodec-tas2781-spi-y := tas2781_hda_spi.o tas2781_spi_fwlib.o # common driver obj-$(CONFIG_SND_HDA) := snd-hda-codec.o
@@ -70,6 +71,7 @@ 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_COMPONENT) += snd-hda-scodec-component.o obj-$(CONFIG_SND_HDA_SCODEC_TAS2781_I2C) += snd-hda-scodec-tas2781-i2c.o +obj-$(CONFIG_SND_HDA_SCODEC_TAS2781_SPI) += snd-hda-scodec-tas2781-spi.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 +14 -0
@@ -6921,6 +6921,11 @@ static void tas2781_fixup_i2c(struct hda_codec *cdc,comp_generic_fixup (cdc, action,"i2c" ,"TIAS2781" ,"-%s:00" ,1 ); } +static void tas2781_fixup_spi (struct hda_codec *cdc,const struct hda_fixup *fix,int action) +{ +comp_generic_fixup (cdc, action,"spi" ,"TXNW2781" ,"-%s:00-tas2781-hda.%d" ,2 ); +} +static void yoga7_14arb7_fixup_i2c (struct hda_codec *cdc,const struct hda_fixup *fix,int action) {
@@ -7498,6 +7503,7 @@ enum {ALC236_FIXUP_DELL_DUAL_CODECS ,ALC287_FIXUP_CS35L41_I2C_2_THINKPAD_ACPI ,ALC287_FIXUP_TAS2781_I2C , +ALC245_FIXUP_TAS2781_SPI_2 ,ALC287_FIXUP_YOGA7_14ARB7_I2C ,ALC245_FIXUP_HP_MUTE_LED_COEFBIT , ALC245_FIXUP_HP_X360_MUTE_LEDS,
@@ -9688,6 +9694,12 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC285_FIXUP_THINKPAD_HEADSET_JACK, }, + [ALC245_FIXUP_TAS2781_SPI_2] = { + .type = HDA_FIXUP_FUNC, + .v.func = tas2781_fixup_spi, + .chained = true, + .chain_id = ALC285_FIXUP_HP_GPIO_LED, + }, [ALC287_FIXUP_YOGA7_14ARB7_I2C] = { .type = HDA_FIXUP_FUNC, .v.func = yoga7_14arb7_fixup_i2c,
@@ -10156,6 +10168,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x8b8d ,"HP" ,ALC236_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8b8f ,"HP" ,ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8b92 ,"HP" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8b93 ,"HP Varcolac" ,ALC245_FIXUP_TAS2781_SPI_2 ),SND_PCI_QUIRK (0x103c ,0x8b96 ,"HP" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ),SND_PCI_QUIRK (0x103c ,0x8b97 ,"HP" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ), SND_PCI_QUIRK(0x103c, 0x8bb3, "HP Slim OMEN", ALC287_FIXUP_CS35L41_I2C_2),
@@ -10212,6 +10225,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x8cdf ,"HP SnowWhite" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8ce0 ,"HP SnowWhite" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8cf5 ,"HP ZBook Studio 16" ,ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8daa ,"HP Gemtree" ,ALC245_FIXUP_TAS2781_SPI_2 ),SND_PCI_QUIRK (0x1043 ,0x103e ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x103f ,"ASUS TX300" ,ALC282_FIXUP_ASUS_TX300 ), SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
sound/pci/hda/tas2781-spi.h new file +148 -0
148 lines not on this page · raw message
sound/pci/hda/tas2781_hda_spi.c new file +1266 -0
1,266 lines not on this page · raw message
sound/pci/hda/tas2781_spi_fwlib.c new file +2101 -0
1,477 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.40.1
Part of the diff is not shown here. View the raw message.
Quoted 4 lines · Baojun Xu
sound/pci/hda/tas2781_spi_fwlib.c new file +4
-0+static struct tasdevice_config_info *tasdevice_add_config ( +struct tasdevice_priv *tas_priv,unsigned char *config_data, +unsigned int config_size,int *status) +{
(snip)
Quoted 4 lines
sound/pci/hda/tas2781_spi_fwlib.c new file +4
-0+/* +* convert data[offset], data[offset + 1], data[offset + 2] and +* data[offset + 3] into host +*/
sound/pci/hda/tas2781_spi_fwlib.c line 197
Quoted 10 lines
sound/pci/hda/tas2781_spi_fwlib.c new file +10
-0+ cfg_info->nblocks =get_unaligned_be32 (&config_data[config_offset]); + config_offset +=4 ; + +/* +* Several kinds of dsp/algorithm firmwares can run on tas2781, +* the number and size of blk are not fixed and different among +* these firmwares. +*/ + bk_da = cfg_info->blk_data =kcalloc (cfg_info->nblocks, +sizeof (*bk_da),GFP_KERNEL );
So the allocation size relies on the firmware data content, and it can practically any value. It'd be safer to have some sanity check for avoiding the allocation of too large pages.
Ditto for other allocations in this code; you should never trust the firmware binary.
Also, in general, the comments are missing for functions in tas2781_spi_fwlib.c completely. A brief comment for each function would be helpful for readers.
thanks,
Takashi
Hi Takashi,
Answer in line.
Best Regards
Jim
Quoted 35 lines
From: Takashi Iwai <[email protected]>
Sent: 14 June 2024 21:20
To: Xu, Baojun
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lu, Kevin; Ding, Shenghao; Navada Kanyana, Mukund; [email protected]; Hampiholi, Vallabha; P O, Vijeth; Holalu Yogendra, Niranjan; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXTERNAL] Re: [PATCH v8] ALSA: hda/tas2781: Add tas2781 hda SPI driverOn Fri, 14 Jun 2024 06: 05: 54 +0200, Baojun Xu wrote: > +static struct
tasdevice_config_info*tasdevice_add_config( > + structtasdevice_priv*tas_priv, unsigned char*config_data, > + unsigned intconfig_size, int *status) > +{ 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. If you wish to report this message to IT Security, please forward the message as an attachment to [email protected]ZjQcmQRYFpfptBannerEnd
Quoted 4 lines · Baojun Xu
sound/pci/hda/tas2781_spi_fwlib.c new file +4
-0+static struct tasdevice_config_info *tasdevice_add_config ( +struct tasdevice_priv *tas_priv,unsigned char *config_data, +unsigned int config_size,int *status) +{(snip)
Quoted 4 lines
sound/pci/hda/tas2781_spi_fwlib.c new file +4
-0+/* +* convert data[offset], data[offset + 1], data[offset + 2] and +* data[offset + 3] into host +*/ sound/pci/hda/tas2781_spi_fwlib.c line 197
Quoted 10 lines
sound/pci/hda/tas2781_spi_fwlib.c new file +10
-0+ cfg_info->nblocks =get_unaligned_be32 (&config_data[config_offset]); + config_offset +=4 ; + +/* +* Several kinds of dsp/algorithm firmwares can run on tas2781, +* the number and size of blk are not fixed and different among +* these firmwares. +*/ + bk_da = cfg_info->blk_data =kcalloc (cfg_info->nblocks, +sizeof (*bk_da),GFP_KERNEL );
Quoted 5 lines
So the allocation size relies on the firmware data content, and it can practically any value. It'd be safer to have some sanity check for avoiding the allocation of too large pages.
Ditto for other allocations in this code; you should never trust the firmware binary.
It's just size of struct tasdev_blk_data, not variable from firmware. In other kcalloc(), it's also allocate memory for structure.
Quoted 12 lines
Also, in general, the comments are missing for functions in
tas2781_spi_fwlib.ccompletely. A brief comment for each function would be helpful for readers.thanks,
Takashi
…
Quoted 1 line
It use ACPI node descript about parameters of TAS2781 on SPI, it like:
…
Quoted 3 lines
probe twice for every single SPI device. And driver will also parser mono DSP firmware binary and RCA binary for itself.
The code support Realtek as the primary codec.
* Would you like to avoid typos in such a change description?
* Please improve the changelog with imperative wordings.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc3#n94
…
Quoted 2 lines
+++
b/sound/pci/hda/tas2781_hda_spi.c(quoted diff) +0
-0@@ -0,0 +1,1266 @@
…
Quoted 2 lines
sound/pci/hda/tas2781_hda_spi.c new file +2
-0+static int tas2781_hda_spi_probe (struct spi_device *spi) +{
…
sound/pci/hda/tas2781_hda_spi.c line 1149
Quoted 12 lines
sound/pci/hda/tas2781_hda_spi.c new file +12
-0+ ret =component_add (tas_priv->dev, &tas2781_hda_comp_ops); +if (ret) { +dev_err (tas_priv->dev,"Register component failed: %d\n" , ret); +pm_runtime_disable (tas_priv->dev); + } + +err: +if (ret) +tas2781_hda_remove (&spi->dev); + +return ret; +}
…
How do you think about to adjust the control flow another bit for this function implementation?
…
Quoted 2 lines
+++
b/sound/pci/hda/tas2781_spi_fwlib.c(quoted diff) +0
-0@@ -0,0 +1,2101 @@
…
Quoted 4 lines
sound/pci/hda/tas2781_spi_fwlib.c new file +4
-0+static struct tasdevice_config_info *tasdevice_add_config ( +struct tasdevice_priv *tas_priv,unsigned char *config_data, +unsigned int config_size,int *status) +{
…
sound/pci/hda/tas2781_spi_fwlib.c line 263
Quoted 9 lines
sound/pci/hda/tas2781_spi_fwlib.c new file +9
-0+return cfg_info; +out1: +for (int j =0 ; j < i; j++) +kfree (bk_da[j]); +kfree (bk_da); +out: +kfree (cfg_info); +return NULL ; +}
* Please improve your label selection.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.10-rc3#n536
* Will development interests grow according to the application of scope-based resource management also for this function implementation?
https://elixir.bootlin.com/linux/v6.10-rc3/source/include/linux/cleanup.h#L8
Regards,
Markus
Le 14/06/2024 à 06:05, Baojun Xu a écrit :
Quoted 24 lines
This patch was used to add TAS2781 devices on SPI support in
sound/pci/hda. It use ACPI node descript about parameters of TAS2781 on SPI, it like:Scope (_SB.PC00.SPI0) { Device (GSPK) { Name (_HID, "TXNW2781") // _HID: Hardware ID Method (_CRS, 0, NotSerialized) { Name (RBUF, ResourceTemplate () { SpiSerialBusV2 (...) SpiSerialBusV2 (...) } } } }And in
platform/x86/serial-multi-instantiate.c, those spi devices will be added into system as a single SPI device, so TAS2781 SPI driver will probe twice for every single SPI device. And driver will also parser mono DSP firmware binary and RCA binary for itself.
The code support Realtek as the primary codec.
Quoted 3 lines
Signed-off-by Baojun Xu <[email protected]>---
Hi,
not a must-have but using "checkpatch.pl --strict" could slightly improve readability in some places.
Maybe at least,
- ./scripts/checkpatch.pl --strict --test-only=Blank
--> to save a few LoC
- ./scripts/checkpatch.pl --strict --test-only=parentheses
--> to improve readability and reduce the length of some lines
This is already v8, so feel free to just ignore this mail and the --strict option.
CJ
Quoted 32 lines
From: Baojun Xu <[email protected]>
Sent: Friday, June 14, 2024 5:06 AMsound/pci/hda/tas2781_hda_spi.c new file +30
-0+static int tas2781_hda_bind (struct device *dev,struct device *master, +void *master_data) +{ +struct tas2781_hda *tas_hda =dev_get_drvdata (dev); +struct hda_component *comps = master_data; +struct hda_codec *codec; +int ret; + +if (tas_hda->priv->index <0 || + tas_hda->priv->index >=HDA_MAX_COMPONENTS || + (!comps)) +return -EINVAL ; + + comps = &comps[tas_hda->priv->index]; +if (comps->dev) +return -EBUSY ; + + codec = comps->codec; + +pm_runtime_get_sync (dev); + + comps->dev = dev; + +strscpy (comps->name,dev_name (dev),sizeof (comps->name)); + + ret =tascodec_spi_init (tas_hda->priv, codec,THIS_MODULE , + tasdev_fw_ready); +if (!ret) + comps->playback_hook = tas2781_hda_playback_hook; +
...
Quoted 5 lines
sound/pci/hda/tas2781_hda_spi.c new file +5
-0+ +static void tas2781_hda_unbind (struct device *dev,struct device *master, +void *master_data) +{ +struct tas2781_hda *tas_hda =dev_get_drvdata (dev);
sound/pci/hda/tas2781_hda_spi.c line 1056
Quoted 10 lines
sound/pci/hda/tas2781_hda_spi.c new file +10
-0+struct hda_component *comps = master_data; + + comps = &comps[tas_hda->priv->index]; + +if (comps->dev == dev) { + comps->dev =NULL ; +memset (comps->name,0 ,sizeof (comps->name)); + comps->playback_hook =NULL ; + } +
I'd been making sure you're on CC but in addition to the other review comments I wanted to highlight that this in for-next will affect this patch and require similar changes to these in the i2c driver:
https://lore.kernel.org/alsa-devel/[email protected]/T/#Z2e.:..:20
240617154105.108635-3-simont::40opensource.cirrus.com:1sound:pci:hda:tas2781 _hda_i2c.c
-Simon
Hi Simon,
Answer in line.
Best Regards
Jim
Quoted 62 lines
From: Simon Trimmer <[email protected]>
Sent: 18 June 2024 19:01
To: Xu, Baojun
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Lu, Kevin; Ding, Shenghao; Navada Kanyana, Mukund; [email protected]; Hampiholi, Vallabha; P O, Vijeth; Holalu Yogendra, Niranjan; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXTERNAL] RE: [PATCH v8] ALSA: hda/tas2781: Add tas2781 hda SPI driverQuoted 1 line
From: Baojun Xu <baojun. xu@ ti. com> > Sent: Friday, June 14, 2024 5: 06 AM > +static int
tas2781_hda_bind(struct device *dev, struct device *master, > + void *master_data)> +{ > + structtas2781_hda*tas_hda=dev_get_drvdata(dev);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. If you wish to report this message to IT Security, please forward the message as an attachment to [email protected]ZjQcmQRYFpfptBannerEnd
Quoted 32 lines
From: Baojun Xu <[email protected]>
Sent: Friday, June 14, 2024 5:06 AMsound/pci/hda/tas2781_hda_spi.c new file +30
-0+static int tas2781_hda_bind (struct device *dev,struct device *master, +void *master_data) +{ +struct tas2781_hda *tas_hda =dev_get_drvdata (dev); +struct hda_component *comps = master_data; +struct hda_codec *codec; +int ret; + +if (tas_hda->priv->index <0 || + tas_hda->priv->index >=HDA_MAX_COMPONENTS || + (!comps)) +return -EINVAL ; + + comps = &comps[tas_hda->priv->index]; +if (comps->dev) +return -EBUSY ; + + codec = comps->codec; + +pm_runtime_get_sync (dev); + + comps->dev = dev; + +strscpy (comps->name,dev_name (dev),sizeof (comps->name)); + + ret =tascodec_spi_init (tas_hda->priv, codec,THIS_MODULE , + tasdev_fw_ready); +if (!ret) + comps->playback_hook = tas2781_hda_playback_hook; +...
Quoted 16 lines
sound/pci/hda/tas2781_hda_spi.c new file +15
-0+ +static void tas2781_hda_unbind (struct device *dev,struct device *master, +void *master_data) +{ +struct tas2781_hda *tas_hda =dev_get_drvdata (dev); +struct hda_component *comps = master_data; + + comps = &comps[tas_hda->priv->index]; + +if (comps->dev == dev) { + comps->dev =NULL ; +memset (comps->name,0 ,sizeof (comps->name)); + comps->playback_hook =NULL ; + } +
Quoted 8 lines
Quoted 1 line
I'd been making sure you're on CC but in addition to the other review
comments I wanted to highlight that this in for-next will affect this patch and require similar changes to these in the i2c driver:
https://urldefense.com/v3/__https://lore.kernel.org/alsa-devel/[email protected]/T/*Z2e.:..:20__;Iw!!G3vK!UGUoFkYP8jbjNbnvinbssfRhZQq52GEfg1o9tdR07b-XPFU8lyewNDXCoc4suK7HPRXwoK3rIPqJKxXLlFnE$
240617154105.108635-3-simont::40opensource.cirrus.com:1sound:pci:hda:tas2781_hda_i2c.c
I merge code to master of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.
Till now, seem your patch not applied yet, so I can't pass the compile if I apply your patch.
Quoted 3 lines
-Simon