Skip to content

Commit 8b89469

Browse files
committed
Merge remote-tracking branch 'takashi/for-next' into sound/upstream-20250821
2 parents 72ea103 + 0c5e2ae commit 8b89469

36 files changed

Lines changed: 4144 additions & 1472 deletions

include/sound/hda_codec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int nums,
360360
int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
361361
hda_nid_t nid, int recursive);
362362
unsigned int snd_hda_get_num_devices(struct hda_codec *codec, hda_nid_t nid);
363-
int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
364-
u8 *dev_list, int max_devices);
363+
unsigned int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
364+
u8 *dev_list, unsigned int max_devices);
365365
int snd_hda_get_dev_select(struct hda_codec *codec, hda_nid_t nid);
366366
int snd_hda_set_dev_select(struct hda_codec *codec, hda_nid_t nid, int dev_id);
367367

include/sound/tas2781-dsp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define PPC3_VERSION_TAS2781_BASIC_MIN 0x14600
3535
#define PPC3_VERSION_TAS2781_ALPHA_MIN 0x4a00
3636
#define PPC3_VERSION_TAS2781_BETA_MIN 0x19400
37+
#define PPC3_VERSION_TAS5825_BASE 0x114200
3738
#define TASDEVICE_DEVICE_SUM 8
3839
#define TASDEVICE_CONFIG_SUM 64
3940

@@ -53,6 +54,8 @@ enum tasdevice_dsp_dev_idx {
5354
TASDEVICE_DSP_TAS_2781_DUAL_MONO,
5455
TASDEVICE_DSP_TAS_2781_21,
5556
TASDEVICE_DSP_TAS_2781_QUAD,
57+
TASDEVICE_DSP_TAS_5825_MONO,
58+
TASDEVICE_DSP_TAS_5825_DUAL,
5659
TASDEVICE_DSP_TAS_MAX_DEVICE
5760
};
5861

include/sound/tas2781.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
#define TASDEVICE_REG(book, page, reg) (((book * 256 * 128) + \
5050
(page * 128)) + reg)
5151

52-
/* Software Reset */
52+
/* Software Reset, compatble with new device (TAS5825). */
5353
#define TASDEVICE_REG_SWRESET TASDEVICE_REG(0x0, 0x0, 0x01)
54-
#define TASDEVICE_REG_SWRESET_RESET BIT(0)
54+
#define TASDEVICE_REG_SWRESET_RESET (BIT(0) | BIT(4))
5555

5656
/* Checksum */
5757
#define TASDEVICE_CHECKSUM_REG TASDEVICE_REG(0x0, 0x0, 0x7e)

include/sound/tas5825-tlv.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
//
3+
// ALSA SoC Texas Instruments TAS5825 Audio Smart Amplifier
4+
//
5+
// Copyright (C) 2025 Texas Instruments Incorporated
6+
// https://www.ti.com
7+
//
8+
// The TAS5825 hda driver implements for one or two TAS5825 chips.
9+
//
10+
// Author: Baojun Xu <baojun.xu@ti.com>
11+
//
12+
13+
#ifndef __TAS5825_TLV_H__
14+
#define __TAS5825_TLV_H__
15+
16+
#define TAS5825_DVC_LEVEL TASDEVICE_REG(0x0, 0x0, 0x4c)
17+
#define TAS5825_AMP_LEVEL TASDEVICE_REG(0x0, 0x0, 0x54)
18+
19+
static const __maybe_unused DECLARE_TLV_DB_SCALE(
20+
tas5825_dvc_tlv, -10300, 50, 0);
21+
static const __maybe_unused DECLARE_TLV_DB_SCALE(
22+
tas5825_amp_tlv, -1550, 50, 0);
23+
24+
#endif

sound/hda/codecs/side-codecs/tas2781_hda_i2c.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <sound/tlv.h>
2727
#include <sound/tas2770-tlv.h>
2828
#include <sound/tas2781-tlv.h>
29+
#include <sound/tas5825-tlv.h>
2930

3031
#include "hda_local.h"
3132
#include "hda_auto_parser.h"
@@ -50,6 +51,7 @@ enum device_chip_id {
5051
HDA_TAS2563,
5152
HDA_TAS2770,
5253
HDA_TAS2781,
54+
HDA_TAS5825,
5355
HDA_OTHERS
5456
};
5557

@@ -272,6 +274,17 @@ static const struct snd_kcontrol_new tas2781_snd_controls[] = {
272274
tas2781_force_fwload_get, tas2781_force_fwload_put),
273275
};
274276

277+
static const struct snd_kcontrol_new tas5825_snd_controls[] = {
278+
ACARD_SINGLE_RANGE_EXT_TLV("Speaker Analog Volume", TAS5825_AMP_LEVEL,
279+
0, 0, 31, 1, tas2781_amp_getvol,
280+
tas2781_amp_putvol, tas5825_amp_tlv),
281+
ACARD_SINGLE_RANGE_EXT_TLV("Speaker Digital Volume", TAS5825_DVC_LEVEL,
282+
0, 0, 254, 1, tas2781_amp_getvol,
283+
tas2781_amp_putvol, tas5825_dvc_tlv),
284+
ACARD_SINGLE_BOOL_EXT("Speaker Force Firmware Load", 0,
285+
tas2781_force_fwload_get, tas2781_force_fwload_put),
286+
};
287+
275288
static const struct snd_kcontrol_new tasdevice_prof_ctrl = {
276289
.name = "Speaker Profile Id",
277290
.iface = SNDRV_CTL_ELEM_IFACE_CARD,
@@ -356,7 +369,7 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
356369
}
357370

358371
if (cd->total_sz != offset) {
359-
dev_err(p->dev, "%s: tot_size(%lu) and offset(%u) dismatch\n",
372+
dev_err(p->dev, "%s: tot_size(%lu) and offset(%u) mismatch\n",
360373
__func__, cd->total_sz, offset);
361374
return -EINVAL;
362375
}
@@ -501,6 +514,12 @@ static void tasdev_fw_ready(const struct firmware *fmw, void *context)
501514
ARRAY_SIZE(tas2781_snd_controls));
502515
tasdevice_dspfw_init(context);
503516
break;
517+
case HDA_TAS5825:
518+
tasdev_add_kcontrols(tas_priv, hda_priv->snd_ctls, codec,
519+
&tas5825_snd_controls[0],
520+
ARRAY_SIZE(tas5825_snd_controls));
521+
tasdevice_dspfw_init(context);
522+
break;
504523
case HDA_TAS2563:
505524
tasdevice_dspfw_init(context);
506525
break;
@@ -628,6 +647,7 @@ static int tas2781_hda_i2c_probe(struct i2c_client *clt)
628647
} else if (strstarts(dev_name(&clt->dev),
629648
"i2c-TXNW2781:00-tas2781-hda.0")) {
630649
device_name = "TXNW2781";
650+
hda_priv->hda_chip_id = HDA_TAS2781;
631651
hda_priv->save_calibration = tas2781_save_calibration;
632652
tas_hda->priv->global_addr = TAS2781_GLOBAL_ADDR;
633653
} else if (strstr(dev_name(&clt->dev), "INT8866")) {
@@ -639,6 +659,13 @@ static int tas2781_hda_i2c_probe(struct i2c_client *clt)
639659
hda_priv->hda_chip_id = HDA_TAS2563;
640660
hda_priv->save_calibration = tas2563_save_calibration;
641661
tas_hda->priv->global_addr = TAS2563_GLOBAL_ADDR;
662+
} else if (strstarts(dev_name(&clt->dev), "i2c-TXNW5825")) {
663+
/*
664+
* TAS5825, integrated on-chip DSP without
665+
* global I2C address and calibration supported.
666+
*/
667+
device_name = "TXNW5825";
668+
hda_priv->hda_chip_id = HDA_TAS5825;
642669
} else {
643670
return -ENODEV;
644671
}
@@ -775,6 +802,7 @@ static const struct acpi_device_id tas2781_acpi_hda_match[] = {
775802
{"TIAS2781", 0 },
776803
{"TXNW2770", 0 },
777804
{"TXNW2781", 0 },
805+
{"TXNW5825", 0 },
778806
{}
779807
};
780808
MODULE_DEVICE_TABLE(acpi, tas2781_acpi_hda_match);

sound/hda/common/codec.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/init.h>
99
#include <linux/delay.h>
1010
#include <linux/slab.h>
11+
#include <linux/minmax.h>
1112
#include <linux/mutex.h>
1213
#include <linux/module.h>
1314
#include <linux/pm.h>
@@ -300,7 +301,7 @@ EXPORT_SYMBOL_GPL(snd_hda_get_conn_index);
300301
unsigned int snd_hda_get_num_devices(struct hda_codec *codec, hda_nid_t nid)
301302
{
302303
unsigned int wcaps = get_wcaps(codec, nid);
303-
unsigned int parm;
304+
int parm;
304305

305306
if (!codec->dp_mst || !(wcaps & AC_WCAP_DIGITAL) ||
306307
get_wcaps_type(wcaps) != AC_WID_PIN)
@@ -323,18 +324,16 @@ EXPORT_SYMBOL_GPL(snd_hda_get_num_devices);
323324
* Copy the device list. This info is dynamic and so not cached.
324325
* Currently called only from hda_proc.c, so not exported.
325326
*/
326-
int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
327-
u8 *dev_list, int max_devices)
327+
unsigned int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
328+
u8 *dev_list, unsigned int max_devices)
328329
{
329-
unsigned int parm;
330-
int i, dev_len, devices;
330+
unsigned int parm, i, dev_len, devices;
331331

332332
parm = snd_hda_get_num_devices(codec, nid);
333333
if (!parm) /* not multi-stream capable */
334334
return 0;
335335

336-
dev_len = parm + 1;
337-
dev_len = dev_len < max_devices ? dev_len : max_devices;
336+
dev_len = min(parm + 1, max_devices);
338337

339338
devices = 0;
340339
while (devices < dev_len) {

sound/hda/common/proc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,16 +716,15 @@ static void print_device_list(struct snd_info_buffer *buffer,
716716
{
717717
int i, curr = -1;
718718
u8 dev_list[AC_MAX_DEV_LIST_LEN];
719-
int devlist_len;
719+
unsigned int devlist_len;
720720

721721
devlist_len = snd_hda_get_devices(codec, nid, dev_list,
722722
AC_MAX_DEV_LIST_LEN);
723-
snd_iprintf(buffer, " Devices: %d\n", devlist_len);
724-
if (devlist_len <= 0)
723+
snd_iprintf(buffer, " Devices: %u\n", devlist_len);
724+
if (devlist_len == 0)
725725
return;
726726

727-
curr = snd_hda_codec_read(codec, nid, 0,
728-
AC_VERB_GET_DEVICE_SEL, 0);
727+
curr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DEVICE_SEL, 0);
729728

730729
for (i = 0; i < devlist_len; i++) {
731730
if (i == curr)

sound/soc/codecs/tas2781-fmwlib.c

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct blktyp_devidx_map {
9191
};
9292

9393
static const char deviceNumber[TASDEVICE_DSP_TAS_MAX_DEVICE] = {
94-
1, 2, 1, 2, 1, 1, 0, 2, 4, 3, 1, 2, 3, 4
94+
1, 2, 1, 2, 1, 1, 0, 2, 4, 3, 1, 2, 3, 4, 1, 2
9595
};
9696

9797
/* fixed m68k compiling issue: mapping table can save code field */
@@ -521,6 +521,56 @@ static int fw_parse_data_kernel(struct tasdevice_fw *tas_fmw,
521521
return offset;
522522
}
523523

524+
static int fw_parse_tas5825_program_data_kernel(
525+
struct tasdevice_priv *tas_priv, struct tasdevice_fw *tas_fmw,
526+
const struct firmware *fmw, int offset)
527+
{
528+
struct tasdevice_prog *program;
529+
unsigned int i;
530+
531+
for (i = 0; i < tas_fmw->nr_programs; i++) {
532+
program = &(tas_fmw->programs[i]);
533+
if (offset + 72 > fmw->size) {
534+
dev_err(tas_priv->dev, "%s: mpName error\n", __func__);
535+
return -EINVAL;
536+
}
537+
/* Skip 65 unused byts*/
538+
offset += 65;
539+
offset = fw_parse_data_kernel(tas_fmw, &(program->dev_data),
540+
fmw, offset);
541+
if (offset < 0)
542+
return offset;
543+
}
544+
545+
return offset;
546+
}
547+
548+
static int fw_parse_tas5825_configuration_data_kernel(
549+
struct tasdevice_priv *tas_priv,
550+
struct tasdevice_fw *tas_fmw, const struct firmware *fmw, int offset)
551+
{
552+
const unsigned char *data = fmw->data;
553+
struct tasdevice_config *config;
554+
unsigned int i;
555+
556+
for (i = 0; i < tas_fmw->nr_configurations; i++) {
557+
config = &(tas_fmw->configs[i]);
558+
if (offset + 80 > fmw->size) {
559+
dev_err(tas_priv->dev, "%s: mpName error\n", __func__);
560+
return -EINVAL;
561+
}
562+
memcpy(config->name, &data[offset], 64);
563+
/* Skip extra 8 bytes*/
564+
offset += 72;
565+
offset = fw_parse_data_kernel(tas_fmw, &(config->dev_data),
566+
fmw, offset);
567+
if (offset < 0)
568+
return offset;
569+
}
570+
571+
return offset;
572+
}
573+
524574
static int fw_parse_program_data_kernel(
525575
struct tasdevice_priv *tas_priv, struct tasdevice_fw *tas_fmw,
526576
const struct firmware *fmw, int offset)
@@ -1838,7 +1888,8 @@ static void dspbin_type_check(struct tasdevice_priv *tas_priv,
18381888
else
18391889
tas_priv->dspbin_typ = TASDEV_ALPHA;
18401890
}
1841-
if (tas_priv->dspbin_typ != TASDEV_BASIC)
1891+
if ((tas_priv->dspbin_typ != TASDEV_BASIC) &&
1892+
(ppcver < PPC3_VERSION_TAS5825_BASE))
18421893
tas_priv->fw_parse_fct_param_address =
18431894
fw_parse_fct_param_address;
18441895
}
@@ -1849,7 +1900,17 @@ static int dspfw_default_callback(struct tasdevice_priv *tas_priv,
18491900
int rc = 0;
18501901

18511902
if (drv_ver == 0x100) {
1852-
if (ppcver >= PPC3_VERSION_BASE) {
1903+
if (ppcver >= PPC3_VERSION_TAS5825_BASE) {
1904+
tas_priv->fw_parse_variable_header =
1905+
fw_parse_variable_header_kernel;
1906+
tas_priv->fw_parse_program_data =
1907+
fw_parse_tas5825_program_data_kernel;
1908+
tas_priv->fw_parse_configuration_data =
1909+
fw_parse_tas5825_configuration_data_kernel;
1910+
tas_priv->tasdevice_load_block =
1911+
tasdevice_load_block_kernel;
1912+
dspbin_type_check(tas_priv, ppcver);
1913+
} else if (ppcver >= PPC3_VERSION_BASE) {
18531914
tas_priv->fw_parse_variable_header =
18541915
fw_parse_variable_header_kernel;
18551916
tas_priv->fw_parse_program_data =

sound/usb/6fire/chip.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,22 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
8888
struct snd_card *card = NULL;
8989

9090
/* look if we already serve this card and return if so */
91-
mutex_lock(&register_mutex);
92-
for (i = 0; i < SNDRV_CARDS; i++) {
93-
if (devices[i] == device) {
94-
if (chips[i])
95-
chips[i]->intf_count++;
96-
usb_set_intfdata(intf, chips[i]);
97-
mutex_unlock(&register_mutex);
98-
return 0;
99-
} else if (!devices[i] && regidx < 0)
100-
regidx = i;
101-
}
102-
if (regidx < 0) {
103-
mutex_unlock(&register_mutex);
104-
dev_err(&intf->dev, "too many cards registered.\n");
105-
return -ENODEV;
91+
scoped_guard(mutex, &register_mutex) {
92+
for (i = 0; i < SNDRV_CARDS; i++) {
93+
if (devices[i] == device) {
94+
if (chips[i])
95+
chips[i]->intf_count++;
96+
usb_set_intfdata(intf, chips[i]);
97+
return 0;
98+
} else if (!devices[i] && regidx < 0)
99+
regidx = i;
100+
}
101+
if (regidx < 0) {
102+
dev_err(&intf->dev, "too many cards registered.\n");
103+
return -ENODEV;
104+
}
105+
devices[regidx] = device;
106106
}
107-
devices[regidx] = device;
108-
mutex_unlock(&register_mutex);
109107

110108
/* check, if firmware is present on device, upload it if not */
111109
ret = usb6fire_fw_init(intf);
@@ -175,10 +173,10 @@ static void usb6fire_chip_disconnect(struct usb_interface *intf)
175173
if (chip) { /* if !chip, fw upload has been performed */
176174
chip->intf_count--;
177175
if (!chip->intf_count) {
178-
mutex_lock(&register_mutex);
179-
devices[chip->regidx] = NULL;
180-
chips[chip->regidx] = NULL;
181-
mutex_unlock(&register_mutex);
176+
scoped_guard(mutex, &register_mutex) {
177+
devices[chip->regidx] = NULL;
178+
chips[chip->regidx] = NULL;
179+
}
182180

183181
chip->shutdown = true;
184182
usb6fire_chip_abort(chip);

0 commit comments

Comments
 (0)