Skip to content

Commit 9fa6a69

Browse files
Shenghao-Dingtiwai
authored andcommitted
ALSA: hda/tas2781: Remove tas2781_spi_fwlib.c and leverage SND_SOC_TAS2781_FMWLIB
Most codes in tas2781_spi_fwlib.c are same as tas2781-fmwlib.c, mainly for firmware parsing, only differece is the register reading, bit update and book switching in i2c and spi. The main purpose of this patch is for code cleaup and arrange the shared part for i2c and spi. Signed-off-by: Shenghao Ding <shenghao-ding@ti.com> Acked-by: Mark Brown <broonie@kernel.org> Link: https://patch.msgid.link/20250429111055.567-1-shenghao-ding@ti.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 849c83f commit 9fa6a69

15 files changed

Lines changed: 768 additions & 2863 deletions

include/sound/tas2781-comlib-i2c.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
//
3+
// ALSA SoC Texas Instruments TAS2563/TAS2781 Audio Smart Amplifier
4+
//
5+
// Copyright (C) 2025 Texas Instruments Incorporated
6+
// https://www.ti.com
7+
//
8+
// The TAS2563/TAS2781 driver implements a flexible and configurable
9+
// algo coefficient setting for one, two, or even multiple
10+
// TAS2563/TAS2781 chips.
11+
//
12+
// Author: Shenghao Ding <shenghao-ding@ti.com>
13+
//
14+
15+
#ifndef __TAS2781_COMLIB_I2C_H__
16+
#define __TAS2781_COMLIB_I2C_H__
17+
18+
void tasdevice_reset(struct tasdevice_priv *tas_dev);
19+
int tascodec_init(struct tasdevice_priv *tas_priv, void *codec,
20+
struct module *module,
21+
void (*cont)(const struct firmware *fw, void *context));
22+
struct tasdevice_priv *tasdevice_kzalloc(struct i2c_client *i2c);
23+
int tasdevice_init(struct tasdevice_priv *tas_priv);
24+
int tasdev_chn_switch(struct tasdevice_priv *tas_priv,
25+
unsigned short chn);
26+
int tasdevice_dev_update_bits(
27+
struct tasdevice_priv *tasdevice, unsigned short chn,
28+
unsigned int reg, unsigned int mask, unsigned int value);
29+
int tasdevice_amp_putvol(struct tasdevice_priv *tas_priv,
30+
struct snd_ctl_elem_value *ucontrol, struct soc_mixer_control *mc);
31+
int tasdevice_amp_getvol(struct tasdevice_priv *tas_priv,
32+
struct snd_ctl_elem_value *ucontrol, struct soc_mixer_control *mc);
33+
int tasdevice_digital_getvol(struct tasdevice_priv *tas_priv,
34+
struct snd_ctl_elem_value *ucontrol, struct soc_mixer_control *mc);
35+
int tasdevice_digital_putvol(struct tasdevice_priv *tas_priv,
36+
struct snd_ctl_elem_value *ucontrol, struct soc_mixer_control *mc);
37+
#endif /* __TAS2781_COMLIB_I2C_H__ */

include/sound/tas2781.h

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
SNDRV_PCM_FMTBIT_S24_LE | \
3333
SNDRV_PCM_FMTBIT_S32_LE)
3434

35+
#define TASDEVICE_CRC8_POLYNOMIAL 0x4d
36+
3537
/* PAGE Control Register (available in page0 of each book) */
3638
#define TASDEVICE_PAGE_SELECT 0x00
3739
#define TASDEVICE_BOOKCTL_PAGE 0x00
@@ -193,6 +195,7 @@ struct tasdevice_priv {
193195
bool force_fwload_status;
194196
bool playback_started;
195197
bool isacpi;
198+
bool isspi;
196199
bool is_user_space_calidata;
197200
unsigned int global_addr;
198201

@@ -210,41 +213,31 @@ struct tasdevice_priv {
210213
int (*tasdevice_load_block)(struct tasdevice_priv *tas_priv,
211214
struct tasdev_blk *block);
212215

216+
int (*change_chn_book)(struct tasdevice_priv *tas_priv,
217+
unsigned short chn, int book);
218+
int (*update_bits)(struct tasdevice_priv *tas_priv,
219+
unsigned short chn, unsigned int reg, unsigned int mask,
220+
unsigned int value);
221+
int (*dev_read)(struct tasdevice_priv *tas_priv,
222+
unsigned short chn, unsigned int reg, unsigned int *value);
223+
int (*dev_bulk_read)(struct tasdevice_priv *tas_priv,
224+
unsigned short chn, unsigned int reg, unsigned char *p_data,
225+
unsigned int n_length);
213226
int (*save_calibration)(struct tasdevice_priv *tas_priv);
214227
void (*apply_calibration)(struct tasdevice_priv *tas_priv);
215228
};
216229

217-
void tasdevice_reset(struct tasdevice_priv *tas_dev);
218-
int tascodec_init(struct tasdevice_priv *tas_priv, void *codec,
219-
struct module *module,
220-
void (*cont)(const struct firmware *fw, void *context));
221-
struct tasdevice_priv *tasdevice_kzalloc(struct i2c_client *i2c);
222-
int tasdevice_init(struct tasdevice_priv *tas_priv);
223-
void tasdevice_remove(struct tasdevice_priv *tas_priv);
224-
int tasdevice_save_calibration(struct tasdevice_priv *tas_priv);
225-
void tasdevice_apply_calibration(struct tasdevice_priv *tas_priv);
226-
int tasdev_chn_switch(struct tasdevice_priv *tas_priv,
227-
unsigned short chn);
228230
int tasdevice_dev_read(struct tasdevice_priv *tas_priv,
229231
unsigned short chn, unsigned int reg, unsigned int *value);
232+
int tasdevice_dev_bulk_read(struct tasdevice_priv *tas_priv,
233+
unsigned short chn, unsigned int reg, unsigned char *p_data,
234+
unsigned int n_length);
230235
int tasdevice_dev_write(struct tasdevice_priv *tas_priv,
231236
unsigned short chn, unsigned int reg, unsigned int value);
232237
int tasdevice_dev_bulk_write(
233238
struct tasdevice_priv *tas_priv, unsigned short chn,
234239
unsigned int reg, unsigned char *p_data, unsigned int n_length);
235-
int tasdevice_dev_bulk_read(struct tasdevice_priv *tas_priv,
236-
unsigned short chn, unsigned int reg, unsigned char *p_data,
237-
unsigned int n_length);
238-
int tasdevice_dev_update_bits(
239-
struct tasdevice_priv *tasdevice, unsigned short chn,
240-
unsigned int reg, unsigned int mask, unsigned int value);
241-
int tasdevice_amp_putvol(struct tasdevice_priv *tas_priv,
242-
struct snd_ctl_elem_value *ucontrol, struct soc_mixer_control *mc);
243-
int tasdevice_amp_getvol(struct tasdevice_priv *tas_priv,
244-
struct snd_ctl_elem_value *ucontrol, struct soc_mixer_control *mc);
245-
int tasdevice_digital_putvol(struct tasdevice_priv *tas_priv,
246-
struct snd_ctl_elem_value *ucontrol, struct soc_mixer_control *mc);
247-
int tasdevice_digital_getvol(struct tasdevice_priv *tas_priv,
248-
struct snd_ctl_elem_value *ucontrol, struct soc_mixer_control *mc);
249-
240+
void tasdevice_remove(struct tasdevice_priv *tas_priv);
241+
int tasdevice_save_calibration(struct tasdevice_priv *tas_priv);
242+
void tasdevice_apply_calibration(struct tasdevice_priv *tas_priv);
250243
#endif /* __TAS2781_H__ */

sound/pci/hda/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ config SND_HDA_SCODEC_TAS2781_I2C
186186
depends on ACPI
187187
depends on EFI
188188
depends on SND_SOC
189-
select SND_SOC_TAS2781_COMLIB
189+
select SND_SOC_TAS2781_COMLIB_I2C
190190
select SND_SOC_TAS2781_FMWLIB
191191
select CRC32
192192
help
@@ -202,6 +202,8 @@ config SND_HDA_SCODEC_TAS2781_SPI
202202
depends on ACPI
203203
depends on EFI
204204
depends on SND_SOC
205+
select SND_SOC_TAS2781_FMWLIB
206+
select CRC8
205207
select CRC32
206208
help
207209
Say Y or M here to include TAS2781 SPI HD-audio side codec support

sound/pci/hda/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ snd-hda-scodec-cs35l56-i2c-y := cs35l56_hda_i2c.o
3939
snd-hda-scodec-cs35l56-spi-y := cs35l56_hda_spi.o
4040
snd-hda-scodec-component-y := hda_component.o
4141
snd-hda-scodec-tas2781-i2c-y := tas2781_hda_i2c.o
42-
snd-hda-scodec-tas2781-spi-y := tas2781_hda_spi.o tas2781_spi_fwlib.o
42+
snd-hda-scodec-tas2781-spi-y := tas2781_hda_spi.o
4343

4444
# common driver
4545
obj-$(CONFIG_SND_HDA) := snd-hda-codec.o

sound/pci/hda/tas2781-spi.h

Lines changed: 0 additions & 157 deletions
This file was deleted.

sound/pci/hda/tas2781_hda.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
#include <sound/asound.h>
1111

12+
#define TASDEVICE_CALIBRATION_DATA_NAME L"CALI_DATA"
13+
#define TASDEV_CALIB_N 5
14+
1215
/*
1316
* No standard control callbacks for SNDRV_CTL_ELEM_IFACE_CARD
1417
* Define two controls, one is Volume control callbacks, the other is

0 commit comments

Comments
 (0)