|
| 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 | + int ret; |
| 44 | + |
| 45 | + ret = snd_soc_dapm_new_controls(&card->dapm, tas2563_spk_dapm_widgets, |
| 46 | + ARRAY_SIZE(tas2563_spk_dapm_widgets)); |
| 47 | + if (ret) { |
| 48 | + dev_err(rtd->dev, "unable to add dapm widgets, ret %d\n", ret); |
| 49 | + return ret; |
| 50 | + } |
| 51 | + |
| 52 | + ret = snd_soc_add_card_controls(card, tas2563_spk_kcontrols, |
| 53 | + ARRAY_SIZE(tas2563_spk_kcontrols)); |
| 54 | + if (ret) { |
| 55 | + dev_err(rtd->dev, "unable to add controls, ret %d\n", ret); |
| 56 | + return ret; |
| 57 | + } |
| 58 | + |
| 59 | + ret = snd_soc_dapm_add_routes(&card->dapm, tas2563_spk_dapm_routes, |
| 60 | + ARRAY_SIZE(tas2563_spk_dapm_routes)); |
| 61 | + if (ret) |
| 62 | + dev_err(rtd->dev, "unable to add dapm routes, ret %d\n", ret); |
| 63 | + |
| 64 | + return ret; |
| 65 | +} |
| 66 | + |
| 67 | +void sof_tas2563_dai_link(struct snd_soc_dai_link *link) |
| 68 | +{ |
| 69 | + link->codecs = tas2563_dai_link_components; |
| 70 | + link->num_codecs = ARRAY_SIZE(tas2563_dai_link_components); |
| 71 | + link->init = tas2563_init; |
| 72 | +} |
| 73 | +EXPORT_SYMBOL_NS(sof_tas2563_dai_link, "SND_SOC_INTEL_SOF_TI_COMMON"); |
| 74 | + |
| 75 | +MODULE_DESCRIPTION("ASoC Intel SOF Texas Instruments helpers"); |
| 76 | +MODULE_LICENSE("GPL"); |
0 commit comments