Path: blob/master/sound/soc/intel/boards/sof_nuvoton_common.c
51261 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;36struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card);37int ret;3839ret = snd_soc_dapm_new_controls(dapm, nau8318_widgets,40ARRAY_SIZE(nau8318_widgets));41if (ret) {42dev_err(rtd->dev, "fail to add nau8318 widgets, ret %d\n", ret);43return ret;44}4546ret = snd_soc_add_card_controls(card, nau8318_kcontrols,47ARRAY_SIZE(nau8318_kcontrols));48if (ret) {49dev_err(rtd->dev, "fail to add nau8318 kcontrols, ret %d\n", ret);50return ret;51}5253ret = snd_soc_dapm_add_routes(dapm, nau8318_routes,54ARRAY_SIZE(nau8318_routes));5556if (ret) {57dev_err(rtd->dev, "fail to add nau8318 routes, ret %d\n", ret);58return ret;59}6061return ret;62}6364void nau8318_set_dai_link(struct snd_soc_dai_link *link)65{66link->codecs = nau8318_components;67link->num_codecs = ARRAY_SIZE(nau8318_components);68link->init = nau8318_init;69}70EXPORT_SYMBOL_NS(nau8318_set_dai_link, "SND_SOC_INTEL_SOF_NUVOTON_COMMON");7172MODULE_DESCRIPTION("ASoC Intel SOF Nuvoton helpers");73MODULE_LICENSE("GPL");747576