1 // SPDX-License-Identifier: GPL-2.0-only 2 // 3 // Copyright(c) 2025 Intel Corporation 4 #include <linux/module.h> 5 #include <linux/string.h> 6 #include <sound/pcm.h> 7 #include <sound/pcm_params.h> 8 #include <sound/soc.h> 9 #include <sound/soc-acpi.h> 10 #include <sound/soc-dai.h> 11 #include <sound/soc-dapm.h> 12 #include <sound/sof.h> 13 #include <uapi/sound/asound.h> 14 #include "../common/soc-intel-quirks.h" 15 #include "sof_ti_common.h" 16 17 /* 18 * Texas Instruments TAS2563 just mount one device to manage multiple devices, 19 * so the kcontrols, widgets and routes just keep one item, respectively. 20 */ 21 static const struct snd_kcontrol_new tas2563_spk_kcontrols[] = { 22 SOC_DAPM_PIN_SWITCH("Spk"), 23 }; 24 25 static const struct snd_soc_dapm_widget tas2563_spk_dapm_widgets[] = { 26 SND_SOC_DAPM_SPK("Spk", NULL), 27 }; 28 29 static const struct snd_soc_dapm_route tas2563_spk_dapm_routes[] = { 30 { "Spk", NULL, "OUT" }, 31 }; 32 33 static struct snd_soc_dai_link_component tas2563_dai_link_components[] = { 34 { 35 .name = TAS2563_DEV0_NAME, 36 .dai_name = TAS2563_CODEC_DAI, 37 }, 38 }; 39 40 static int tas2563_init(struct snd_soc_pcm_runtime *rtd) 41 { 42 struct snd_soc_card *card = rtd->card; 43 struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card); 44 int ret; 45 46 ret = snd_soc_dapm_new_controls(dapm, tas2563_spk_dapm_widgets, 47 ARRAY_SIZE(tas2563_spk_dapm_widgets)); 48 if (ret) { 49 dev_err(rtd->dev, "unable to add dapm widgets, ret %d\n", ret); 50 return ret; 51 } 52 53 ret = snd_soc_add_card_controls(card, tas2563_spk_kcontrols, 54 ARRAY_SIZE(tas2563_spk_kcontrols)); 55 if (ret) { 56 dev_err(rtd->dev, "unable to add controls, ret %d\n", ret); 57 return ret; 58 } 59 60 ret = snd_soc_dapm_add_routes(dapm, tas2563_spk_dapm_routes, 61 ARRAY_SIZE(tas2563_spk_dapm_routes)); 62 if (ret) 63 dev_err(rtd->dev, "unable to add dapm routes, ret %d\n", ret); 64 65 return ret; 66 } 67 68 void sof_tas2563_dai_link(struct snd_soc_dai_link *link) 69 { 70 link->codecs = tas2563_dai_link_components; 71 link->num_codecs = ARRAY_SIZE(tas2563_dai_link_components); 72 link->init = tas2563_init; 73 } 74 EXPORT_SYMBOL_NS(sof_tas2563_dai_link, "SND_SOC_INTEL_SOF_TI_COMMON"); 75 76 MODULE_DESCRIPTION("ASoC Intel SOF Texas Instruments helpers"); 77 MODULE_LICENSE("GPL"); 78