mbox series

[v4,0/3] ALSA: hda/tas2781: Add tas2781 driver for SPI.

Message ID 20240430072544.1877-1-baojun.xu@ti.com
Headers show
Series ALSA: hda/tas2781: Add tas2781 driver for SPI. | expand

Message

Baojun Xu April 30, 2024, 7:25 a.m. UTC
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.

Signed-off-by: Baojun Xu <baojun.xu@ti.com>

Baojun Xu (3):
  ALSA: hda/tas2781: Add tas2781 hda driver based on SPI
  ALSA: hda/tas2781: Tas2781 hda driver for SPI
  ALSA: hda/tas2781: Firmware load for tas2781 hda driver based on SPI

 drivers/acpi/scan.c                           |    2 +
 .../platform/x86/serial-multi-instantiate.c   |   13 +
 sound/pci/hda/Kconfig                         |   14 +
 sound/pci/hda/Makefile                        |    2 +
 sound/pci/hda/patch_realtek.c                 |   13 +
 sound/pci/hda/tas2781-spi.h                   |  149 ++
 sound/pci/hda/tas2781_hda_spi.c               | 1240 +++++++++
 sound/pci/hda/tas2781_spi_fwlib.c             | 2252 +++++++++++++++++
 8 files changed, 3685 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

Comments

Takashi Iwai April 30, 2024, 12:58 p.m. UTC | #1
On Tue, 30 Apr 2024 09:25:42 +0200,
Baojun Xu wrote:
> 
> Integrate tas2781 hda spi driver configs for HP (Varcolac).
> Every tas2781 SPI node was added by serial-multi-instantie.c as a SPI device.
> The code support Realtek as the primary codec.
> 
> Signed-off-by: Baojun Xu <baojun.xu@ti.com>
> 
> ---
> 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
> 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.
> ---
>  drivers/acpi/scan.c                             |  2 ++
>  drivers/platform/x86/serial-multi-instantiate.c | 13 +++++++++++++
>  sound/pci/hda/Kconfig                           | 14 ++++++++++++++
>  sound/pci/hda/Makefile                          |  2 ++
>  sound/pci/hda/patch_realtek.c                   | 13 +++++++++++++
>  5 files changed, 44 insertions(+)
> 
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index d1464324de95..51af181ccf62 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -1765,6 +1765,8 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
>  		{"CSC3557", },
>  		{"INT33FE", },
>  		{"INT3515", },
> +		{"TXNW2781", },
> +		{"TIAS2781", },
>  		/* Non-conforming _HID for Cirrus Logic already released */
>  		{"CLSA0100", },
>  		{"CLSA0101", },
> diff --git a/drivers/platform/x86/serial-multi-instantiate.c b/drivers/platform/x86/serial-multi-instantiate.c
> index 97b9c6392230..d1c766f17b26 100644
> --- a/drivers/platform/x86/serial-multi-instantiate.c
> +++ b/drivers/platform/x86/serial-multi-instantiate.c
> @@ -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,8 @@ 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 },
> +	{ "TIAS2781", (unsigned long)&tas2781_hda },
>  	/* Non-conforming _HID for Cirrus Logic already released */
>  	{ "CLSA0100", (unsigned long)&cs35l41_hda },
>  	{ "CLSA0101", (unsigned long)&cs35l41_hda },
> diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
> index f806636242ee..15f0e66b77e5 100644
> --- a/sound/pci/hda/Kconfig
> +++ b/sound/pci/hda/Kconfig
> @@ -202,6 +202,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
> diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
> index 13e04e1f65de..2d5d4d841d87 100644
> --- a/sound/pci/hda/Makefile
> +++ b/sound/pci/hda/Makefile
> @@ -39,6 +39,7 @@ snd-hda-scodec-cs35l56-spi-objs :=	cs35l56_hda_spi.o
>  snd-hda-cs-dsp-ctls-objs :=		hda_cs_dsp_ctl.o
>  snd-hda-scodec-component-objs :=	hda_component.o
>  snd-hda-scodec-tas2781-i2c-objs :=	tas2781_hda_i2c.o
> +snd-hda-scodec-tas2781-spi-y :=	tas2781_hda_spi.o tas2781_spi_fwlib.o

A nitpicking: better to align with other lines (i.e. with *-objs
instead of *-y).

The main problem here is, though, that this commit will break the
build, because you introduced a Kconfig that can be enabled, while the
corresponding code for snd-hda-scodec-tas2781-spi isn't present yet.
This is bad for the git-bisection.

You'd need to reorganize better how the code is added piece-by-piece.


thanks,

Takashi
Andy Shevchenko April 30, 2024, 1:45 p.m. UTC | #2
On Tue, Apr 30, 2024 at 02:58:10PM +0200, Takashi Iwai wrote:
> On Tue, 30 Apr 2024 09:25:42 +0200, Baojun Xu wrote:

...

> >  snd-hda-cs-dsp-ctls-objs :=		hda_cs_dsp_ctl.o
> >  snd-hda-scodec-component-objs :=	hda_component.o
> >  snd-hda-scodec-tas2781-i2c-objs :=	tas2781_hda_i2c.o
> > +snd-hda-scodec-tas2781-spi-y :=	tas2781_hda_spi.o tas2781_spi_fwlib.o
> 
> A nitpicking: better to align with other lines (i.e. with *-objs
> instead of *-y).

I object this. The better approach is to have a precursor patch that switches
to y over objs (the latter is for user space code / tools).
Andy Shevchenko May 6, 2024, 8:51 a.m. UTC | #3
On Mon, May 06, 2024 at 07:44:41AM +0000, Xu, Baojun wrote:
> > From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Sent: 30 April 2024 21:45
> > On Tue, Apr 30, 2024 at 02: 58: 10PM +0200, Takashi Iwai wrote:
> > On Tue, Apr 30, 2024 at 02:58:10PM +0200, Takashi Iwai wrote:
> > > On Tue, 30 Apr 2024 09:25:42 +0200, Baojun Xu wrote:

...

> > > >  snd-hda-cs-dsp-ctls-objs :=                hda_cs_dsp_ctl.o
> > > >  snd-hda-scodec-component-objs :=   hda_component.o
> > > >  snd-hda-scodec-tas2781-i2c-objs := tas2781_hda_i2c.o
> > > > +snd-hda-scodec-tas2781-spi-y :=    tas2781_hda_spi.o tas2781_spi_fwlib.o
> > >
> > > A nitpicking: better to align with other lines (i.e. with *-objs
> > > instead of *-y).
> > 
> > I object this. The better approach is to have a precursor patch that switches
> > to y over objs (the latter is for user space code / tools).
> 
> I also do not fully understand why set it as "y", as you know, I follow
> CONFIG_SND_HDA_SCODEC_TAS2781_I2C, as it do not set to "y".

While you see no side effects, the 'objs' is reserved for user space, while 'y'
should be used in the kernel code. 

See Documentation/kbuild/makefiles.rst "Composite Host Programs", mind
the word "host" meaning.
Takashi Iwai May 7, 2024, 1:05 p.m. UTC | #4
On Tue, 30 Apr 2024 15:45:28 +0200,
Andy Shevchenko wrote:
> 
> On Tue, Apr 30, 2024 at 02:58:10PM +0200, Takashi Iwai wrote:
> > On Tue, 30 Apr 2024 09:25:42 +0200, Baojun Xu wrote:
> 
> ...
> 
> > >  snd-hda-cs-dsp-ctls-objs :=		hda_cs_dsp_ctl.o
> > >  snd-hda-scodec-component-objs :=	hda_component.o
> > >  snd-hda-scodec-tas2781-i2c-objs :=	tas2781_hda_i2c.o
> > > +snd-hda-scodec-tas2781-spi-y :=	tas2781_hda_spi.o tas2781_spi_fwlib.o
> > 
> > A nitpicking: better to align with other lines (i.e. with *-objs
> > instead of *-y).
> 
> I object this. The better approach is to have a precursor patch that switches
> to y over objs (the latter is for user space code / tools).

Indeed it can be a good cleanup, yeah.  Let me try.


thanks,

Takashi