Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Niranjan H Y and committed by
Mark Brown
96384a34 4cc9bd8d

+102 -1
+8
include/sound/soc_sdw_utils.h
··· 248 248 int asoc_sdw_cs42l43_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 249 249 int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai); 250 250 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); 251 259 252 260 #endif
+2 -1
sound/soc/sdw_utils/Makefile
··· 6 6 soc_sdw_bridge_cs35l56.o \ 7 7 soc_sdw_cs42l42.o soc_sdw_cs42l43.o \ 8 8 soc_sdw_cs_amp.o \ 9 - soc_sdw_maxim.o 9 + soc_sdw_maxim.o \ 10 + soc_sdw_ti_amp.o 10 11 obj-$(CONFIG_SND_SOC_SDW_UTILS) += snd-soc-sdw-utils.o
+92
sound/soc/sdw_utils/soc_sdw_ti_amp.c
··· 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");