Lines Matching +full:use +full:- +full:rtm

1 // SPDX-License-Identifier: GPL-2.0-only
3 // Copyright(c) 2021-2022 Intel Corporation
17 #include <sound/soc-acpi.h>
21 #define SKL_NUVOTON_CODEC_DAI "nau8825-hifi"
26 struct snd_soc_dapm_context *dapm = w->dapm; in avs_nau8825_clock_control()
27 struct snd_soc_card *card = dapm->card; in avs_nau8825_clock_control()
33 dev_err(card->dev, "Codec dai not found\n"); in avs_nau8825_clock_control()
34 return -EINVAL; in avs_nau8825_clock_control()
43 dev_err(card->dev, "Set sysclk failed: %d\n", ret); in avs_nau8825_clock_control()
83 struct snd_soc_card *card = runtime->card; in avs_nau8825_codec_init()
91 pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL); in avs_nau8825_codec_init()
93 return -ENOMEM; in avs_nau8825_codec_init()
97 * The use of these buttons can be decided by the user space. in avs_nau8825_codec_init()
105 snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in avs_nau8825_codec_init()
106 snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); in avs_nau8825_codec_init()
107 snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); in avs_nau8825_codec_init()
108 snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); in avs_nau8825_codec_init()
110 return snd_soc_component_set_jack(snd_soc_rtd_to_codec(runtime, 0)->component, jack, NULL); in avs_nau8825_codec_init()
115 snd_soc_component_set_jack(snd_soc_rtd_to_codec(rtd, 0)->component, NULL, NULL); in avs_nau8825_codec_exit()
129 rate->min = rate->max = 48000; in avs_nau8825_be_fixup()
130 channels->min = channels->max = 2; in avs_nau8825_be_fixup()
141 struct snd_pcm_runtime *runtime = substream->runtime; in avs_nau8825_trigger()
142 struct snd_soc_pcm_runtime *rtm = snd_soc_substream_to_rtd(substream); in avs_nau8825_trigger() local
143 struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtm, 0); in avs_nau8825_trigger()
150 dev_err(codec_dai->dev, "can't set FS clock %d\n", ret); in avs_nau8825_trigger()
154 ret = snd_soc_dai_set_pll(codec_dai, 0, 0, runtime->rate, runtime->rate * 256); in avs_nau8825_trigger()
156 dev_err(codec_dai->dev, "can't set FLL: %d\n", ret); in avs_nau8825_trigger()
160 ret = snd_soc_dai_set_pll(codec_dai, 0, 0, runtime->rate, runtime->rate * 256); in avs_nau8825_trigger()
162 dev_err(codec_dai->dev, "can't set FLL: %d\n", ret); in avs_nau8825_trigger()
183 return -ENOMEM; in avs_create_dai_link()
185 platform->name = platform_name; in avs_create_dai_link()
187 dl->name = devm_kasprintf(dev, GFP_KERNEL, in avs_create_dai_link()
188 AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot)); in avs_create_dai_link()
189 dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL); in avs_create_dai_link()
190 dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL); in avs_create_dai_link()
191 if (!dl->name || !dl->cpus || !dl->codecs) in avs_create_dai_link()
192 return -ENOMEM; in avs_create_dai_link()
194 dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, in avs_create_dai_link()
196 dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-10508825:00"); in avs_create_dai_link()
197 dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, SKL_NUVOTON_CODEC_DAI); in avs_create_dai_link()
198 if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) in avs_create_dai_link()
199 return -ENOMEM; in avs_create_dai_link()
201 dl->num_cpus = 1; in avs_create_dai_link()
202 dl->num_codecs = 1; in avs_create_dai_link()
203 dl->platforms = platform; in avs_create_dai_link()
204 dl->num_platforms = 1; in avs_create_dai_link()
205 dl->id = 0; in avs_create_dai_link()
206 dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS; in avs_create_dai_link()
207 dl->init = avs_nau8825_codec_init; in avs_create_dai_link()
208 dl->exit = avs_nau8825_codec_exit; in avs_create_dai_link()
209 dl->be_hw_params_fixup = avs_nau8825_be_fixup; in avs_create_dai_link()
210 dl->ops = &avs_nau8825_ops; in avs_create_dai_link()
211 dl->nonatomic = 1; in avs_create_dai_link()
212 dl->no_pcm = 1; in avs_create_dai_link()
213 dl->dpcm_capture = 1; in avs_create_dai_link()
214 dl->dpcm_playback = 1; in avs_create_dai_link()
225 return snd_soc_component_set_jack(codec_dai->component, NULL, NULL); in avs_card_suspend_pre()
235 dev_err(card->dev, "Codec dai not found\n"); in avs_card_resume_post()
236 return -EINVAL; in avs_card_resume_post()
240 snd_soc_dai_get_widget(codec_dai, stream)->active) in avs_card_resume_post()
243 return snd_soc_component_set_jack(codec_dai->component, jack, NULL); in avs_card_resume_post()
252 struct device *dev = &pdev->dev; in avs_nau8825_probe()
257 pname = mach->mach_params.platform; in avs_nau8825_probe()
272 return -ENOMEM; in avs_nau8825_probe()
274 card->name = "avs_nau8825"; in avs_nau8825_probe()
275 card->dev = dev; in avs_nau8825_probe()
276 card->owner = THIS_MODULE; in avs_nau8825_probe()
277 card->suspend_pre = avs_card_suspend_pre; in avs_nau8825_probe()
278 card->resume_post = avs_card_resume_post; in avs_nau8825_probe()
279 card->dai_link = dai_link; in avs_nau8825_probe()
280 card->num_links = 1; in avs_nau8825_probe()
281 card->controls = card_controls; in avs_nau8825_probe()
282 card->num_controls = ARRAY_SIZE(card_controls); in avs_nau8825_probe()
283 card->dapm_widgets = card_widgets; in avs_nau8825_probe()
284 card->num_dapm_widgets = ARRAY_SIZE(card_widgets); in avs_nau8825_probe()
285 card->dapm_routes = card_base_routes; in avs_nau8825_probe()
286 card->num_dapm_routes = ARRAY_SIZE(card_base_routes); in avs_nau8825_probe()
287 card->fully_routed = true; in avs_nau8825_probe()