Linux Audio

Check our new training course

Loading...
Note: File does not exist in v3.15.
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * This file defines data structures and functions used in Machine
 4 * Driver for Intel platforms with Nuvoton Codecs.
 5 *
 6 * Copyright 2023 Intel Corporation.
 7 */
 8#include <linux/module.h>
 9#include <sound/sof.h>
10#include "sof_nuvoton_common.h"
11
12/*
13 * Nuvoton NAU8318
14 */
15static const struct snd_kcontrol_new nau8318_kcontrols[] = {
16	SOC_DAPM_PIN_SWITCH("Spk"),
17};
18
19static const struct snd_soc_dapm_widget nau8318_widgets[] = {
20	SND_SOC_DAPM_SPK("Spk", NULL),
21};
22
23static const struct snd_soc_dapm_route nau8318_routes[] = {
24	{ "Spk", NULL, "Speaker" },
25};
26
27static struct snd_soc_dai_link_component nau8318_components[] = {
28	{
29		.name = NAU8318_DEV0_NAME,
30		.dai_name = NAU8318_CODEC_DAI,
31	}
32};
33
34static int nau8318_init(struct snd_soc_pcm_runtime *rtd)
35{
36	struct snd_soc_card *card = rtd->card;
37	int ret;
38
39	ret = snd_soc_dapm_new_controls(&card->dapm, nau8318_widgets,
40					ARRAY_SIZE(nau8318_widgets));
41	if (ret) {
42		dev_err(rtd->dev, "fail to add nau8318 widgets, ret %d\n", ret);
43		return ret;
44	}
45
46	ret = snd_soc_add_card_controls(card, nau8318_kcontrols,
47					ARRAY_SIZE(nau8318_kcontrols));
48	if (ret) {
49		dev_err(rtd->dev, "fail to add nau8318 kcontrols, ret %d\n", ret);
50		return ret;
51	}
52
53	ret = snd_soc_dapm_add_routes(&card->dapm, nau8318_routes,
54				      ARRAY_SIZE(nau8318_routes));
55
56	if (ret) {
57		dev_err(rtd->dev, "fail to add nau8318 routes, ret %d\n", ret);
58		return ret;
59	}
60
61	return ret;
62}
63
64void nau8318_set_dai_link(struct snd_soc_dai_link *link)
65{
66	link->codecs = nau8318_components;
67	link->num_codecs = ARRAY_SIZE(nau8318_components);
68	link->init = nau8318_init;
69}
70EXPORT_SYMBOL_NS(nau8318_set_dai_link, "SND_SOC_INTEL_SOF_NUVOTON_COMMON");
71
72MODULE_DESCRIPTION("ASoC Intel SOF Nuvoton helpers");
73MODULE_LICENSE("GPL");