Lines Matching +full:codec +full:- +full:1
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.
43 …ESC(patch, "Patch file array for Intel HD audio interface. The array index is the codec address.");
74 .name = "Analog Codec DAI",
77 .stream_name = "Analog Codec Playback",
78 .channels_min = 1,
85 .stream_name = "Analog Codec Capture",
86 .channels_min = 1,
95 .name = "Digital Codec DAI",
98 .stream_name = "Digital Codec Playback",
99 .channels_min = 1,
106 .stream_name = "Digital Codec Capture",
107 .channels_min = 1,
116 .name = "Alt Analog Codec DAI",
119 .stream_name = "Alt Analog Codec Playback",
120 .channels_min = 1,
127 .stream_name = "Alt Analog Codec Capture",
128 .channels_min = 1,
140 .name = "intel-hdmi-hifi1",
144 .channels_min = 1,
153 .name = "intel-hdmi-hifi2",
157 .channels_min = 1,
166 .name = "intel-hdmi-hifi3",
170 .channels_min = 1,
179 .name = "intel-hdmi-hifi4",
183 .channels_min = 1,
196 struct snd_soc_component *component = dai->component; in hdac_hda_dai_set_stream()
202 return -EINVAL; in hdac_hda_dai_set_stream()
205 pcm = &hda_pvt->pcm[dai->id]; in hdac_hda_dai_set_stream()
208 pcm->stream_tag[direction] = hstream->stream_tag; in hdac_hda_dai_set_stream()
217 struct snd_soc_component *component = dai->component; in hdac_hda_dai_hw_params()
223 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in hdac_hda_dai_hw_params()
224 maxbps = dai->driver->playback.sig_bits; in hdac_hda_dai_hw_params()
226 maxbps = dai->driver->capture.sig_bits; in hdac_hda_dai_hw_params()
232 dev_err(dai->dev, in hdac_hda_dai_hw_params()
238 return -EINVAL; in hdac_hda_dai_hw_params()
241 hda_pvt->pcm[dai->id].format_val[substream->stream] = format_val; in hdac_hda_dai_hw_params()
248 struct snd_soc_component *component = dai->component; in hdac_hda_dai_hw_free()
256 return -EINVAL; in hdac_hda_dai_hw_free()
258 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_hw_free()
259 snd_hda_codec_cleanup(hda_pvt->codec, hda_stream, substream); in hdac_hda_dai_hw_free()
267 struct snd_soc_component *component = dai->component; in hdac_hda_dai_prepare()
278 return -EINVAL; in hdac_hda_dai_prepare()
280 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_prepare()
282 stream = hda_pvt->pcm[dai->id].stream_tag[substream->stream]; in hdac_hda_dai_prepare()
283 format_val = hda_pvt->pcm[dai->id].format_val[substream->stream]; in hdac_hda_dai_prepare()
285 ret = snd_hda_codec_prepare(hda_pvt->codec, hda_stream, in hdac_hda_dai_prepare()
288 dev_err(dai->dev, "%s: failed %d\n", __func__, ret); in hdac_hda_dai_prepare()
296 struct snd_soc_component *component = dai->component; in hdac_hda_dai_open()
305 return -EINVAL; in hdac_hda_dai_open()
309 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_open()
311 ret = hda_stream->ops.open(hda_stream, hda_pvt->codec, substream); in hdac_hda_dai_open()
313 dev_err(dai->dev, "%s: failed %d\n", __func__, ret); in hdac_hda_dai_open()
321 struct snd_soc_component *component = dai->component; in hdac_hda_dai_close()
331 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_close()
333 hda_stream->ops.close(hda_stream, hda_pvt->codec, substream); in hdac_hda_dai_close()
341 struct hda_codec *hcodec = hda_pvt->codec; in snd_soc_find_pcm_from_dai()
347 * scheme used by hda-codec snd_hda_gen_build_pcms() and for in snd_soc_find_pcm_from_dai()
351 switch (dai->id) { in snd_soc_find_pcm_from_dai()
365 pcm_name = "HDMI 1"; in snd_soc_find_pcm_from_dai()
374 dev_err(dai->dev, "%s: invalid dai id %d\n", __func__, dai->id); in snd_soc_find_pcm_from_dai()
378 list_for_each_entry(cpcm, &hcodec->pcm_list_head, list) { in snd_soc_find_pcm_from_dai()
379 if (strstr(cpcm->name, pcm_name)) { in snd_soc_find_pcm_from_dai()
381 if (strstr(cpcm->name, "Alt Analog")) in snd_soc_find_pcm_from_dai()
388 dev_err(dai->dev, "%s: didn't find PCM for DAI %s\n", __func__, dai->name); in snd_soc_find_pcm_from_dai()
396 list_for_each_entry(cpcm, &hcodec->pcm_list_head, list) { in is_hdmi_codec()
397 if (cpcm->pcm_type == HDA_PCM_TYPE_HDMI) in is_hdmi_codec()
410 struct hdac_device *hdev = &hda_pvt->codec->core; in hdac_hda_codec_probe()
411 struct hda_codec *hcodec = hda_pvt->codec; in hdac_hda_codec_probe()
416 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdac_hda_codec_probe()
418 dev_err(&hdev->dev, "%s: hdac link not found\n", __func__); in hdac_hda_codec_probe()
419 return -EIO; in hdac_hda_codec_probe()
422 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdac_hda_codec_probe()
425 * Ensure any HDA display is powered at codec probe. in hdac_hda_codec_probe()
429 if (hda_pvt->need_display_power) in hdac_hda_codec_probe()
430 snd_hdac_display_power(hdev->bus, in hdac_hda_codec_probe()
433 ret = snd_hda_codec_device_new(hcodec->bus, component->card->snd_card, in hdac_hda_codec_probe()
434 hdev->addr, hcodec, true); in hdac_hda_codec_probe()
436 dev_err(&hdev->dev, "%s: failed to create hda codec %d\n", __func__, ret); in hdac_hda_codec_probe()
441 if (loadable_patch[hda_pvt->dev_index] && *loadable_patch[hda_pvt->dev_index]) { in hdac_hda_codec_probe()
444 dev_info(&hdev->dev, "Applying patch firmware '%s'\n", in hdac_hda_codec_probe()
445 loadable_patch[hda_pvt->dev_index]); in hdac_hda_codec_probe()
446 ret = request_firmware(&fw, loadable_patch[hda_pvt->dev_index], in hdac_hda_codec_probe()
447 &hdev->dev); in hdac_hda_codec_probe()
451 ret = snd_hda_load_patch(hcodec->bus, fw->size, fw->data); in hdac_hda_codec_probe()
453 dev_err(&hdev->dev, "%s: failed to load hda patch %d\n", __func__, ret); in hdac_hda_codec_probe()
465 hdev->type = HDA_DEV_ASOC; in hdac_hda_codec_probe()
471 pm_runtime_get_noresume(&hdev->dev); in hdac_hda_codec_probe()
473 hcodec->bus->card = dapm->card->snd_card; in hdac_hda_codec_probe()
475 ret = snd_hda_codec_set_name(hcodec, hcodec->preset->name); in hdac_hda_codec_probe()
477 dev_err(&hdev->dev, "%s: name failed %s\n", __func__, hcodec->preset->name); in hdac_hda_codec_probe()
481 ret = snd_hdac_regmap_init(&hcodec->core); in hdac_hda_codec_probe()
483 dev_err(&hdev->dev, "%s: regmap init failed\n", __func__); in hdac_hda_codec_probe()
487 patch = (hda_codec_patch_t)hcodec->preset->driver_data; in hdac_hda_codec_probe()
491 dev_err(&hdev->dev, "%s: patch failed %d\n", __func__, ret); in hdac_hda_codec_probe()
495 dev_dbg(&hdev->dev, "%s: no patch file found\n", __func__); in hdac_hda_codec_probe()
500 dev_err(&hdev->dev, "%s: unable to map pcms to dai %d\n", __func__, ret); in hdac_hda_codec_probe()
508 dev_err(&hdev->dev, "%s: unable to create controls %d\n", in hdac_hda_codec_probe()
514 hcodec->core.lazy_cache = true; in hdac_hda_codec_probe()
516 if (hda_pvt->need_display_power) in hdac_hda_codec_probe()
517 snd_hdac_display_power(hdev->bus, in hdac_hda_codec_probe()
521 pm_runtime_allow(&hdev->dev); in hdac_hda_codec_probe()
526 * pm_runtime_enable is also called during codec registeration in hdac_hda_codec_probe()
528 pm_runtime_put(&hdev->dev); in hdac_hda_codec_probe()
529 pm_runtime_suspend(&hdev->dev); in hdac_hda_codec_probe()
534 if (hcodec->patch_ops.free) in hdac_hda_codec_probe()
535 hcodec->patch_ops.free(hcodec); in hdac_hda_codec_probe()
539 pm_runtime_put(&hdev->dev); in hdac_hda_codec_probe()
541 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hda_codec_probe()
549 struct hdac_device *hdev = &hda_pvt->codec->core; in hdac_hda_codec_remove()
550 struct hda_codec *codec = hda_pvt->codec; in hdac_hda_codec_remove() local
553 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdac_hda_codec_remove()
555 dev_err(&hdev->dev, "%s: hdac link not found\n", __func__); in hdac_hda_codec_remove()
559 pm_runtime_disable(&hdev->dev); in hdac_hda_codec_remove()
560 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hda_codec_remove()
562 if (codec->patch_ops.free) in hdac_hda_codec_remove()
563 codec->patch_ops.free(codec); in hdac_hda_codec_remove()
565 snd_hda_codec_cleanup_for_unbind(codec); in hdac_hda_codec_remove()
569 {"AIF1TX", NULL, "Codec Input Pin1"},
570 {"AIF2TX", NULL, "Codec Input Pin2"},
571 {"AIF3TX", NULL, "Codec Input Pin3"},
573 {"Codec Output Pin1", NULL, "AIF1RX"},
574 {"Codec Output Pin2", NULL, "AIF2RX"},
575 {"Codec Output Pin3", NULL, "AIF3RX"},
580 SND_SOC_DAPM_AIF_IN("AIF1RX", "Analog Codec Playback", 0,
582 SND_SOC_DAPM_AIF_IN("AIF2RX", "Digital Codec Playback", 0,
584 SND_SOC_DAPM_AIF_IN("AIF3RX", "Alt Analog Codec Playback", 0,
586 SND_SOC_DAPM_AIF_OUT("AIF1TX", "Analog Codec Capture", 0,
588 SND_SOC_DAPM_AIF_OUT("AIF2TX", "Digital Codec Capture", 0,
590 SND_SOC_DAPM_AIF_OUT("AIF3TX", "Alt Analog Codec Capture", 0,
594 SND_SOC_DAPM_INPUT("Codec Input Pin1"),
595 SND_SOC_DAPM_INPUT("Codec Input Pin2"),
596 SND_SOC_DAPM_INPUT("Codec Input Pin3"),
599 SND_SOC_DAPM_OUTPUT("Codec Output Pin1"),
600 SND_SOC_DAPM_OUTPUT("Codec Output Pin2"),
601 SND_SOC_DAPM_OUTPUT("Codec Output Pin3"),
612 .endianness = 1,
619 .endianness = 1,
624 struct hdac_hda_priv *hda_pvt = dev_get_drvdata(&hdev->dev); in hdac_hda_dev_probe()
629 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdac_hda_dev_probe()
631 dev_err(&hdev->dev, "%s: hdac link not found\n", __func__); in hdac_hda_dev_probe()
632 return -EIO; in hdac_hda_dev_probe()
634 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdac_hda_dev_probe()
637 if (hda_pvt->need_display_power) in hdac_hda_dev_probe()
638 ret = devm_snd_soc_register_component(&hdev->dev, in hdac_hda_dev_probe()
642 ret = devm_snd_soc_register_component(&hdev->dev, in hdac_hda_dev_probe()
647 dev_err(&hdev->dev, "%s: failed to register HDA codec %d\n", __func__, ret); in hdac_hda_dev_probe()
651 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hda_dev_probe()