Skip to content

Commit 96384a3

Browse files
niranjanhytibroonie
authored andcommitted
ASoc: tas2783A: machine driver amp utility for TI devices
Machine driver amp utility file to initialize and support multiple tas2783a devices are added. Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Signed-off-by: Niranjan H Y <niranjan.hy@ti.com> -- v5: - removed empty line in soc_sdw_ti_amp.c Link: https://patch.msgid.link/20250912083624.804-3-niranjan.hy@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4cc9bd8 commit 96384a3

3 files changed

Lines changed: 102 additions & 1 deletion

File tree

include/sound/soc_sdw_utils.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,5 +248,13 @@ int asoc_sdw_cs42l43_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_so
248248
int asoc_sdw_cs42l43_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
249249
int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
250250
int asoc_sdw_maxim_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
251+
/* TI */
252+
int asoc_sdw_ti_amp_init(struct snd_soc_card *card,
253+
struct snd_soc_dai_link *dai_links,
254+
struct asoc_sdw_codec_info *info,
255+
bool playback);
256+
int asoc_sdw_ti_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
257+
int asoc_sdw_ti_amp_initial_settings(struct snd_soc_card *card,
258+
const char *name_prefix);
251259

252260
#endif

sound/soc/sdw_utils/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ snd-soc-sdw-utils-y := soc_sdw_utils.o soc_sdw_dmic.o soc_sdw_rt_dmic.o \
66
soc_sdw_bridge_cs35l56.o \
77
soc_sdw_cs42l42.o soc_sdw_cs42l43.o \
88
soc_sdw_cs_amp.o \
9-
soc_sdw_maxim.o
9+
soc_sdw_maxim.o \
10+
soc_sdw_ti_amp.o
1011
obj-$(CONFIG_SND_SOC_SDW_UTILS) += snd-soc-sdw-utils.o
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
// Copyright (c) 2025 Texas Instruments Inc.
3+
4+
/*
5+
* soc_sdw_ti_amp - Helpers to handle TI's soundwire based codecs
6+
*/
7+
8+
#include <linux/device.h>
9+
#include <linux/errno.h>
10+
#include <sound/soc.h>
11+
#include <sound/soc-acpi.h>
12+
#include <sound/soc-dai.h>
13+
#include <sound/soc_sdw_utils.h>
14+
15+
#define TIAMP_SPK_VOLUME_0DB 200
16+
17+
int asoc_sdw_ti_amp_initial_settings(struct snd_soc_card *card,
18+
const char *name_prefix)
19+
{
20+
char *volume_ctl_name;
21+
int ret;
22+
23+
volume_ctl_name = kasprintf(GFP_KERNEL, "%s Speaker Volume",
24+
name_prefix);
25+
if (!volume_ctl_name)
26+
return -ENOMEM;
27+
28+
ret = snd_soc_limit_volume(card, volume_ctl_name,
29+
TIAMP_SPK_VOLUME_0DB);
30+
if (ret)
31+
dev_err(card->dev,
32+
"%s update failed %d\n",
33+
volume_ctl_name, ret);
34+
35+
kfree(volume_ctl_name);
36+
return 0;
37+
}
38+
EXPORT_SYMBOL_NS(asoc_sdw_ti_amp_initial_settings, "SND_SOC_SDW_UTILS");
39+
40+
int asoc_sdw_ti_spk_rtd_init(struct snd_soc_pcm_runtime *rtd,
41+
struct snd_soc_dai *dai)
42+
{
43+
struct snd_soc_card *card = rtd->card;
44+
char widget_name[16];
45+
char speaker[16];
46+
struct snd_soc_dapm_route route = {speaker, NULL, widget_name};
47+
struct snd_soc_dai *codec_dai;
48+
const char *prefix;
49+
int i, ret = 0;
50+
51+
for_each_rtd_codec_dais(rtd, i, codec_dai) {
52+
if (!strstr(codec_dai->name, "tas2783"))
53+
continue;
54+
55+
prefix = codec_dai->component->name_prefix;
56+
if (!strncmp(prefix, "tas2783-1", strlen("tas2783-1"))) {
57+
strscpy(speaker, "Left Spk", sizeof(speaker));
58+
} else if (!strncmp(prefix, "tas2783-2", strlen("tas2783-2"))) {
59+
strscpy(speaker, "Right Spk", sizeof(speaker));
60+
} else {
61+
ret = -EINVAL;
62+
dev_err(card->dev, "unhandled prefix %s", prefix);
63+
break;
64+
}
65+
66+
snprintf(widget_name, sizeof(widget_name), "%s SPK", prefix);
67+
ret = asoc_sdw_ti_amp_initial_settings(card, prefix);
68+
if (ret)
69+
return ret;
70+
71+
ret = snd_soc_dapm_add_routes(&card->dapm, &route, 1);
72+
if (ret)
73+
return ret;
74+
}
75+
76+
return ret;
77+
}
78+
EXPORT_SYMBOL_NS(asoc_sdw_ti_spk_rtd_init, "SND_SOC_SDW_UTILS");
79+
80+
int asoc_sdw_ti_amp_init(struct snd_soc_card *card,
81+
struct snd_soc_dai_link *dai_links,
82+
struct asoc_sdw_codec_info *info,
83+
bool playback)
84+
{
85+
if (!playback)
86+
return 0;
87+
88+
info->amp_num++;
89+
90+
return 0;
91+
}
92+
EXPORT_SYMBOL_NS(asoc_sdw_ti_amp_init, "SND_SOC_SDW_UTILS");

0 commit comments

Comments
 (0)