1 // SPDX-License-Identifier: GPL-2.0-only
3 * This file defines data structures and functions used in Machine
4 * Driver for Intel platforms with Nuvoton Codecs.
6 * Copyright 2023 Intel Corporation.
8 #include <linux/module.h>
10 #include "sof_nuvoton_common.h"
15 static const struct snd_kcontrol_new nau8318_kcontrols[] = {
16 SOC_DAPM_PIN_SWITCH("Spk"),
19 static const struct snd_soc_dapm_widget nau8318_widgets[] = {
20 SND_SOC_DAPM_SPK("Spk", NULL),
23 static const struct snd_soc_dapm_route nau8318_routes[] = {
24 { "Spk", NULL, "Speaker" },
27 static struct snd_soc_dai_link_component nau8318_components[] = {
29 .name = NAU8318_DEV0_NAME,
30 .dai_name = NAU8318_CODEC_DAI,
34 static int nau8318_init(struct snd_soc_pcm_runtime *rtd)
36 struct snd_soc_card *card = rtd->card;
39 ret = snd_soc_dapm_new_controls(&card->dapm, nau8318_widgets,
40 ARRAY_SIZE(nau8318_widgets));
42 dev_err(rtd->dev, "fail to add nau8318 widgets, ret %d\n", ret);
46 ret = snd_soc_add_card_controls(card, nau8318_kcontrols,
47 ARRAY_SIZE(nau8318_kcontrols));
49 dev_err(rtd->dev, "fail to add nau8318 kcontrols, ret %d\n", ret);
53 ret = snd_soc_dapm_add_routes(&card->dapm, nau8318_routes,
54 ARRAY_SIZE(nau8318_routes));
57 dev_err(rtd->dev, "fail to add nau8318 routes, ret %d\n", ret);
64 void nau8318_set_dai_link(struct snd_soc_dai_link *link)
66 link->codecs = nau8318_components;
67 link->num_codecs = ARRAY_SIZE(nau8318_components);
68 link->init = nau8318_init;
70 EXPORT_SYMBOL_NS(nau8318_set_dai_link, SND_SOC_INTEL_SOF_NUVOTON_COMMON);
72 MODULE_DESCRIPTION("ASoC Intel SOF Nuvoton helpers");
73 MODULE_LICENSE("GPL");