Lines Matching +full:codec +full:- +full:analog +full:- +full:controls
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright(c) 2015-18 Intel Corporation.
5 * hdac_hda.c - ASoC extensions to reuse the legacy HDA codec drivers
7 * codec drivers using hdac_ext_bus_ops ops.
66 .name = "Analog Codec DAI",
69 .stream_name = "Analog Codec Playback",
77 .stream_name = "Analog Codec Capture",
87 .name = "Digital Codec DAI",
90 .stream_name = "Digital Codec Playback",
98 .stream_name = "Digital Codec Capture",
108 .name = "Alt Analog Codec DAI",
111 .stream_name = "Alt Analog Codec Playback",
119 .stream_name = "Alt Analog Codec Capture",
132 .name = "intel-hdmi-hifi1",
145 .name = "intel-hdmi-hifi2",
158 .name = "intel-hdmi-hifi3",
171 .name = "intel-hdmi-hifi4",
188 struct snd_soc_component *component = dai->component; in hdac_hda_dai_set_stream()
194 return -EINVAL; in hdac_hda_dai_set_stream()
197 pcm = &hda_pvt->pcm[dai->id]; in hdac_hda_dai_set_stream()
200 pcm->stream_tag[direction] = hstream->stream_tag; in hdac_hda_dai_set_stream()
209 struct snd_soc_component *component = dai->component; in hdac_hda_dai_hw_params()
214 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in hdac_hda_dai_hw_params()
215 maxbps = dai->driver->playback.sig_bits; in hdac_hda_dai_hw_params()
217 maxbps = dai->driver->capture.sig_bits; in hdac_hda_dai_hw_params()
226 dev_err(dai->dev, in hdac_hda_dai_hw_params()
231 return -EINVAL; in hdac_hda_dai_hw_params()
234 hda_pvt->pcm[dai->id].format_val[substream->stream] = format_val; in hdac_hda_dai_hw_params()
241 struct snd_soc_component *component = dai->component; in hdac_hda_dai_hw_free()
249 return -EINVAL; in hdac_hda_dai_hw_free()
251 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_hw_free()
252 snd_hda_codec_cleanup(hda_pvt->codec, hda_stream, substream); in hdac_hda_dai_hw_free()
260 struct snd_soc_component *component = dai->component; in hdac_hda_dai_prepare()
270 hdev = &hda_pvt->codec->core; in hdac_hda_dai_prepare()
273 return -EINVAL; in hdac_hda_dai_prepare()
275 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_prepare()
277 stream = hda_pvt->pcm[dai->id].stream_tag[substream->stream]; in hdac_hda_dai_prepare()
278 format_val = hda_pvt->pcm[dai->id].format_val[substream->stream]; in hdac_hda_dai_prepare()
280 ret = snd_hda_codec_prepare(hda_pvt->codec, hda_stream, in hdac_hda_dai_prepare()
283 dev_err(&hdev->dev, "codec prepare failed %d\n", ret); in hdac_hda_dai_prepare()
291 struct snd_soc_component *component = dai->component; in hdac_hda_dai_open()
299 return -EINVAL; in hdac_hda_dai_open()
303 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_open()
305 return hda_stream->ops.open(hda_stream, hda_pvt->codec, substream); in hdac_hda_dai_open()
311 struct snd_soc_component *component = dai->component; in hdac_hda_dai_close()
321 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_close()
323 hda_stream->ops.close(hda_stream, hda_pvt->codec, substream); in hdac_hda_dai_close()
331 struct hda_codec *hcodec = hda_pvt->codec; in snd_soc_find_pcm_from_dai()
337 * scheme used by hda-codec snd_hda_gen_build_pcms() and for in snd_soc_find_pcm_from_dai()
341 switch (dai->id) { in snd_soc_find_pcm_from_dai()
343 pcm_name = "Analog"; in snd_soc_find_pcm_from_dai()
349 pcm_name = "Alt Analog"; in snd_soc_find_pcm_from_dai()
364 dev_err(&hcodec->core.dev, "invalid dai id %d\n", dai->id); in snd_soc_find_pcm_from_dai()
368 list_for_each_entry(cpcm, &hcodec->pcm_list_head, list) { in snd_soc_find_pcm_from_dai()
369 if (strstr(cpcm->name, pcm_name)) { in snd_soc_find_pcm_from_dai()
370 if (strcmp(pcm_name, "Analog") == 0) { in snd_soc_find_pcm_from_dai()
371 if (strstr(cpcm->name, "Alt Analog")) in snd_soc_find_pcm_from_dai()
378 dev_err(&hcodec->core.dev, "didn't find PCM for DAI %s\n", dai->name); in snd_soc_find_pcm_from_dai()
386 list_for_each_entry(cpcm, &hcodec->pcm_list_head, list) { in is_hdmi_codec()
387 if (cpcm->pcm_type == HDA_PCM_TYPE_HDMI) in is_hdmi_codec()
400 struct hdac_device *hdev = &hda_pvt->codec->core; in hdac_hda_codec_probe()
401 struct hda_codec *hcodec = hda_pvt->codec; in hdac_hda_codec_probe()
406 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdac_hda_codec_probe()
408 dev_err(&hdev->dev, "hdac link not found\n"); in hdac_hda_codec_probe()
409 return -EIO; in hdac_hda_codec_probe()
412 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdac_hda_codec_probe()
415 * Ensure any HDA display is powered at codec probe. in hdac_hda_codec_probe()
419 if (hda_pvt->need_display_power) in hdac_hda_codec_probe()
420 snd_hdac_display_power(hdev->bus, in hdac_hda_codec_probe()
423 ret = snd_hda_codec_device_new(hcodec->bus, component->card->snd_card, in hdac_hda_codec_probe()
424 hdev->addr, hcodec, true); in hdac_hda_codec_probe()
426 dev_err(&hdev->dev, "failed to create hda codec %d\n", ret); in hdac_hda_codec_probe()
434 hdev->type = HDA_DEV_ASOC; in hdac_hda_codec_probe()
440 pm_runtime_get_noresume(&hdev->dev); in hdac_hda_codec_probe()
442 hcodec->bus->card = dapm->card->snd_card; in hdac_hda_codec_probe()
444 ret = snd_hda_codec_set_name(hcodec, hcodec->preset->name); in hdac_hda_codec_probe()
446 dev_err(&hdev->dev, "name failed %s\n", hcodec->preset->name); in hdac_hda_codec_probe()
450 ret = snd_hdac_regmap_init(&hcodec->core); in hdac_hda_codec_probe()
452 dev_err(&hdev->dev, "regmap init failed\n"); in hdac_hda_codec_probe()
456 patch = (hda_codec_patch_t)hcodec->preset->driver_data; in hdac_hda_codec_probe()
460 dev_err(&hdev->dev, "patch failed %d\n", ret); in hdac_hda_codec_probe()
464 dev_dbg(&hdev->dev, "no patch file found\n"); in hdac_hda_codec_probe()
469 dev_err(&hdev->dev, "unable to map pcms to dai %d\n", ret); in hdac_hda_codec_probe()
473 /* HDMI controls need to be created in machine drivers */ in hdac_hda_codec_probe()
477 dev_err(&hdev->dev, "unable to create controls %d\n", in hdac_hda_codec_probe()
483 hcodec->core.lazy_cache = true; in hdac_hda_codec_probe()
485 if (hda_pvt->need_display_power) in hdac_hda_codec_probe()
486 snd_hdac_display_power(hdev->bus, in hdac_hda_codec_probe()
490 pm_runtime_allow(&hdev->dev); in hdac_hda_codec_probe()
495 * pm_runtime_enable is also called during codec registeration in hdac_hda_codec_probe()
497 pm_runtime_put(&hdev->dev); in hdac_hda_codec_probe()
498 pm_runtime_suspend(&hdev->dev); in hdac_hda_codec_probe()
503 if (hcodec->patch_ops.free) in hdac_hda_codec_probe()
504 hcodec->patch_ops.free(hcodec); in hdac_hda_codec_probe()
508 pm_runtime_put(&hdev->dev); in hdac_hda_codec_probe()
510 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hda_codec_probe()
518 struct hdac_device *hdev = &hda_pvt->codec->core; in hdac_hda_codec_remove()
519 struct hda_codec *codec = hda_pvt->codec; in hdac_hda_codec_remove() local
522 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdac_hda_codec_remove()
524 dev_err(&hdev->dev, "hdac link not found\n"); in hdac_hda_codec_remove()
528 pm_runtime_disable(&hdev->dev); in hdac_hda_codec_remove()
529 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hda_codec_remove()
531 if (codec->patch_ops.free) in hdac_hda_codec_remove()
532 codec->patch_ops.free(codec); in hdac_hda_codec_remove()
534 snd_hda_codec_cleanup_for_unbind(codec); in hdac_hda_codec_remove()
538 {"AIF1TX", NULL, "Codec Input Pin1"},
539 {"AIF2TX", NULL, "Codec Input Pin2"},
540 {"AIF3TX", NULL, "Codec Input Pin3"},
542 {"Codec Output Pin1", NULL, "AIF1RX"},
543 {"Codec Output Pin2", NULL, "AIF2RX"},
544 {"Codec Output Pin3", NULL, "AIF3RX"},
549 SND_SOC_DAPM_AIF_IN("AIF1RX", "Analog Codec Playback", 0,
551 SND_SOC_DAPM_AIF_IN("AIF2RX", "Digital Codec Playback", 0,
553 SND_SOC_DAPM_AIF_IN("AIF3RX", "Alt Analog Codec Playback", 0,
555 SND_SOC_DAPM_AIF_OUT("AIF1TX", "Analog Codec Capture", 0,
557 SND_SOC_DAPM_AIF_OUT("AIF2TX", "Digital Codec Capture", 0,
559 SND_SOC_DAPM_AIF_OUT("AIF3TX", "Alt Analog Codec Capture", 0,
563 SND_SOC_DAPM_INPUT("Codec Input Pin1"),
564 SND_SOC_DAPM_INPUT("Codec Input Pin2"),
565 SND_SOC_DAPM_INPUT("Codec Input Pin3"),
568 SND_SOC_DAPM_OUTPUT("Codec Output Pin1"),
569 SND_SOC_DAPM_OUTPUT("Codec Output Pin2"),
570 SND_SOC_DAPM_OUTPUT("Codec Output Pin3"),
593 struct hdac_hda_priv *hda_pvt = dev_get_drvdata(&hdev->dev); in hdac_hda_dev_probe()
598 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdac_hda_dev_probe()
600 dev_err(&hdev->dev, "hdac link not found\n"); in hdac_hda_dev_probe()
601 return -EIO; in hdac_hda_dev_probe()
603 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdac_hda_dev_probe()
606 if (hda_pvt->need_display_power) in hdac_hda_dev_probe()
607 ret = devm_snd_soc_register_component(&hdev->dev, in hdac_hda_dev_probe()
611 ret = devm_snd_soc_register_component(&hdev->dev, in hdac_hda_dev_probe()
616 dev_err(&hdev->dev, "failed to register HDA codec %d\n", ret); in hdac_hda_dev_probe()
620 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hda_dev_probe()