Path: blob/master/sound/soc/intel/boards/sof_nuvoton_common.c
26493 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* This file defines data structures and functions used in Machine3* Driver for Intel platforms with Nuvoton Codecs.4*5* Copyright 2023 Intel Corporation.6*/7#include <linux/module.h>8#include <sound/sof.h>9#include "sof_nuvoton_common.h"1011/*12* Nuvoton NAU831813*/14static const struct snd_kcontrol_new nau8318_kcontrols[] = {15SOC_DAPM_PIN_SWITCH("Spk"),16};1718static const struct snd_soc_dapm_widget nau8318_widgets[] = {19SND_SOC_DAPM_SPK("Spk", NULL),20};2122static const struct snd_soc_dapm_route nau8318_routes[] = {23{ "Spk", NULL, "Speaker" },24};2526static struct snd_soc_dai_link_component nau8318_components[] = {27{28.name = NAU8318_DEV0_NAME,29.dai_name = NAU8318_CODEC_DAI,30}31};3233static int nau8318_init(struct snd_soc_pcm_runtime *rtd)34{35struct snd_soc_card *card = rtd->card;36int ret;3738ret = snd_soc_dapm_new_controls(&card->dapm, nau8318_widgets,39ARRAY_SIZE(nau8318_widgets));40if (ret) {41dev_err(rtd->dev, "fail to add nau8318 widgets, ret %d\n", ret);42return ret;43}4445ret = snd_soc_add_card_controls(card, nau8318_kcontrols,46ARRAY_SIZE(nau8318_kcontrols));47if (ret) {48dev_err(rtd->dev, "fail to add nau8318 kcontrols, ret %d\n", ret);49return ret;50}5152ret = snd_soc_dapm_add_routes(&card->dapm, nau8318_routes,53ARRAY_SIZE(nau8318_routes));5455if (ret) {56dev_err(rtd->dev, "fail to add nau8318 routes, ret %d\n", ret);57return ret;58}5960return ret;61}6263void nau8318_set_dai_link(struct snd_soc_dai_link *link)64{65link->codecs = nau8318_components;66link->num_codecs = ARRAY_SIZE(nau8318_components);67link->init = nau8318_init;68}69EXPORT_SYMBOL_NS(nau8318_set_dai_link, "SND_SOC_INTEL_SOF_NUVOTON_COMMON");7071MODULE_DESCRIPTION("ASoC Intel SOF Nuvoton helpers");72MODULE_LICENSE("GPL");737475