FILE
sof_nuvoton_common.c
File preview with syntax highlighting.
linux-6.19.14/sound/soc/intel/boards/sof_nuvoton_common.c
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 struct snd_soc_dapm_context *dapm = snd_soc_card_to_dapm(card); 38 int ret; 39 40 ret = snd_soc_dapm_new_controls(dapm, nau8318_widgets, 41 ARRAY_SIZE(nau8318_widgets)); 42 if (ret) { 43 dev_err(rtd->dev, "fail to add nau8318 widgets, ret %d\n", ret); 44 return ret; 45 } 46 47 ret = snd_soc_add_card_controls(card, nau8318_kcontrols, 48 ARRAY_SIZE(nau8318_kcontrols)); 49 if (ret) { 50 dev_err(rtd->dev, "fail to add nau8318 kcontrols, ret %d\n", ret); 51 return ret; 52 } 53 54 ret = snd_soc_dapm_add_routes(dapm, nau8318_routes, 55 ARRAY_SIZE(nau8318_routes)); 56 57 if (ret) { 58 dev_err(rtd->dev, "fail to add nau8318 routes, ret %d\n", ret); 59 return ret; 60 } 61 62 return ret; 63} 64 65void nau8318_set_dai_link(struct snd_soc_dai_link *link) 66{ 67 link->codecs = nau8318_components; 68 link->num_codecs = ARRAY_SIZE(nau8318_components); 69 link->init = nau8318_init; 70} 71EXPORT_SYMBOL_NS(nau8318_set_dai_link, "SND_SOC_INTEL_SOF_NUVOTON_COMMON"); 72 73MODULE_DESCRIPTION("ASoC Intel SOF Nuvoton helpers"); 74MODULE_LICENSE("GPL");
~/
Read-only file preview.