• Home
  • Raw
  • Download

Lines Matching +full:hdmi +full:- +full:codec

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",
129 .name = "intel-hdmi-hifi1",
142 .name = "intel-hdmi-hifi2",
155 .name = "intel-hdmi-hifi3",
168 .name = "intel-hdmi-hifi4",
185 struct snd_soc_component *component = dai->component; in hdac_hda_dai_set_stream()
191 return -EINVAL; in hdac_hda_dai_set_stream()
194 pcm = &hda_pvt->pcm[dai->id]; in hdac_hda_dai_set_stream()
197 pcm->stream_tag[direction] = hstream->stream_tag; in hdac_hda_dai_set_stream()
206 struct snd_soc_component *component = dai->component; in hdac_hda_dai_hw_params()
211 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in hdac_hda_dai_hw_params()
212 maxbps = dai->driver->playback.sig_bits; in hdac_hda_dai_hw_params()
214 maxbps = dai->driver->capture.sig_bits; in hdac_hda_dai_hw_params()
223 dev_err(dai->dev, in hdac_hda_dai_hw_params()
228 return -EINVAL; in hdac_hda_dai_hw_params()
231 hda_pvt->pcm[dai->id].format_val[substream->stream] = format_val; in hdac_hda_dai_hw_params()
238 struct snd_soc_component *component = dai->component; in hdac_hda_dai_hw_free()
246 return -EINVAL; in hdac_hda_dai_hw_free()
248 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_hw_free()
249 snd_hda_codec_cleanup(&hda_pvt->codec, hda_stream, substream); in hdac_hda_dai_hw_free()
257 struct snd_soc_component *component = dai->component; in hdac_hda_dai_prepare()
267 hdev = &hda_pvt->codec.core; in hdac_hda_dai_prepare()
270 return -EINVAL; in hdac_hda_dai_prepare()
272 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_prepare()
274 stream = hda_pvt->pcm[dai->id].stream_tag[substream->stream]; in hdac_hda_dai_prepare()
275 format_val = hda_pvt->pcm[dai->id].format_val[substream->stream]; in hdac_hda_dai_prepare()
277 ret = snd_hda_codec_prepare(&hda_pvt->codec, hda_stream, in hdac_hda_dai_prepare()
280 dev_err(&hdev->dev, "codec prepare failed %d\n", ret); in hdac_hda_dai_prepare()
288 struct snd_soc_component *component = dai->component; in hdac_hda_dai_open()
296 return -EINVAL; in hdac_hda_dai_open()
300 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_open()
302 return hda_stream->ops.open(hda_stream, &hda_pvt->codec, substream); in hdac_hda_dai_open()
308 struct snd_soc_component *component = dai->component; in hdac_hda_dai_close()
318 hda_stream = &pcm->stream[substream->stream]; in hdac_hda_dai_close()
320 hda_stream->ops.close(hda_stream, &hda_pvt->codec, substream); in hdac_hda_dai_close()
328 struct hda_codec *hcodec = &hda_pvt->codec; in snd_soc_find_pcm_from_dai()
334 * scheme used by hda-codec snd_hda_gen_build_pcms() and for in snd_soc_find_pcm_from_dai()
335 * HDMI in hda_codec patch_hdmi.c) in snd_soc_find_pcm_from_dai()
338 switch (dai->id) { in snd_soc_find_pcm_from_dai()
349 pcm_name = "HDMI 0"; in snd_soc_find_pcm_from_dai()
352 pcm_name = "HDMI 1"; in snd_soc_find_pcm_from_dai()
355 pcm_name = "HDMI 2"; in snd_soc_find_pcm_from_dai()
358 pcm_name = "HDMI 3"; in snd_soc_find_pcm_from_dai()
361 dev_err(&hcodec->core.dev, "invalid dai id %d\n", dai->id); in snd_soc_find_pcm_from_dai()
365 list_for_each_entry(cpcm, &hcodec->pcm_list_head, list) { in snd_soc_find_pcm_from_dai()
366 if (strstr(cpcm->name, pcm_name)) in snd_soc_find_pcm_from_dai()
370 dev_err(&hcodec->core.dev, "didn't find PCM for DAI %s\n", dai->name); in snd_soc_find_pcm_from_dai()
378 list_for_each_entry(cpcm, &hcodec->pcm_list_head, list) { in is_hdmi_codec()
379 if (cpcm->pcm_type == HDA_PCM_TYPE_HDMI) in is_hdmi_codec()
392 struct hdac_device *hdev = &hda_pvt->codec.core; in hdac_hda_codec_probe()
393 struct hda_codec *hcodec = &hda_pvt->codec; in hdac_hda_codec_probe()
398 hlink = snd_hdac_ext_bus_get_link(hdev->bus, dev_name(&hdev->dev)); in hdac_hda_codec_probe()
400 dev_err(&hdev->dev, "hdac link not found\n"); in hdac_hda_codec_probe()
401 return -EIO; in hdac_hda_codec_probe()
404 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdac_hda_codec_probe()
407 * Ensure any HDA display is powered at codec probe. in hdac_hda_codec_probe()
411 if (hda_pvt->need_display_power) in hdac_hda_codec_probe()
412 snd_hdac_display_power(hdev->bus, in hdac_hda_codec_probe()
415 ret = snd_hda_codec_device_new(hcodec->bus, component->card->snd_card, in hdac_hda_codec_probe()
416 hdev->addr, hcodec); in hdac_hda_codec_probe()
418 dev_err(&hdev->dev, "failed to create hda codec %d\n", ret); in hdac_hda_codec_probe()
426 hdev->type = HDA_DEV_ASOC; in hdac_hda_codec_probe()
432 pm_runtime_get_noresume(&hdev->dev); in hdac_hda_codec_probe()
434 hcodec->bus->card = dapm->card->snd_card; in hdac_hda_codec_probe()
436 ret = snd_hda_codec_set_name(hcodec, hcodec->preset->name); in hdac_hda_codec_probe()
438 dev_err(&hdev->dev, "name failed %s\n", hcodec->preset->name); in hdac_hda_codec_probe()
442 ret = snd_hdac_regmap_init(&hcodec->core); in hdac_hda_codec_probe()
444 dev_err(&hdev->dev, "regmap init failed\n"); in hdac_hda_codec_probe()
448 patch = (hda_codec_patch_t)hcodec->preset->driver_data; in hdac_hda_codec_probe()
452 dev_err(&hdev->dev, "patch failed %d\n", ret); in hdac_hda_codec_probe()
456 dev_dbg(&hdev->dev, "no patch file found\n"); in hdac_hda_codec_probe()
459 /* configure codec for 1:1 PCM:DAI mapping */ in hdac_hda_codec_probe()
460 hcodec->mst_no_extra_pcms = 1; in hdac_hda_codec_probe()
464 dev_err(&hdev->dev, "unable to map pcms to dai %d\n", ret); in hdac_hda_codec_probe()
468 /* HDMI controls need to be created in machine drivers */ in hdac_hda_codec_probe()
472 dev_err(&hdev->dev, "unable to create controls %d\n", in hdac_hda_codec_probe()
478 hcodec->core.lazy_cache = true; in hdac_hda_codec_probe()
480 if (hda_pvt->need_display_power) in hdac_hda_codec_probe()
481 snd_hdac_display_power(hdev->bus, in hdac_hda_codec_probe()
485 pm_runtime_allow(&hdev->dev); in hdac_hda_codec_probe()
490 * pm_runtime_enable is also called during codec registeration in hdac_hda_codec_probe()
492 pm_runtime_put(&hdev->dev); in hdac_hda_codec_probe()
493 pm_runtime_suspend(&hdev->dev); in hdac_hda_codec_probe()
498 if (hcodec->patch_ops.free) in hdac_hda_codec_probe()
499 hcodec->patch_ops.free(hcodec); in hdac_hda_codec_probe()
503 pm_runtime_put(&hdev->dev); in hdac_hda_codec_probe()
505 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hda_codec_probe()
513 struct hdac_device *hdev = &hda_pvt->codec.core; in hdac_hda_codec_remove()
514 struct hda_codec *codec = &hda_pvt->codec; in hdac_hda_codec_remove() local
517 hlink = snd_hdac_ext_bus_get_link(hdev->bus, dev_name(&hdev->dev)); in hdac_hda_codec_remove()
519 dev_err(&hdev->dev, "hdac link not found\n"); in hdac_hda_codec_remove()
523 pm_runtime_disable(&hdev->dev); in hdac_hda_codec_remove()
524 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hda_codec_remove()
526 if (codec->patch_ops.free) in hdac_hda_codec_remove()
527 codec->patch_ops.free(codec); in hdac_hda_codec_remove()
529 snd_hda_codec_cleanup_for_unbind(codec); in hdac_hda_codec_remove()
533 {"AIF1TX", NULL, "Codec Input Pin1"},
534 {"AIF2TX", NULL, "Codec Input Pin2"},
535 {"AIF3TX", NULL, "Codec Input Pin3"},
537 {"Codec Output Pin1", NULL, "AIF1RX"},
538 {"Codec Output Pin2", NULL, "AIF2RX"},
539 {"Codec Output Pin3", NULL, "AIF3RX"},
544 SND_SOC_DAPM_AIF_IN("AIF1RX", "Analog Codec Playback", 0,
546 SND_SOC_DAPM_AIF_IN("AIF2RX", "Digital Codec Playback", 0,
548 SND_SOC_DAPM_AIF_IN("AIF3RX", "Alt Analog Codec Playback", 0,
550 SND_SOC_DAPM_AIF_OUT("AIF1TX", "Analog Codec Capture", 0,
552 SND_SOC_DAPM_AIF_OUT("AIF2TX", "Digital Codec Capture", 0,
554 SND_SOC_DAPM_AIF_OUT("AIF3TX", "Alt Analog Codec Capture", 0,
558 SND_SOC_DAPM_INPUT("Codec Input Pin1"),
559 SND_SOC_DAPM_INPUT("Codec Input Pin2"),
560 SND_SOC_DAPM_INPUT("Codec Input Pin3"),
563 SND_SOC_DAPM_OUTPUT("Codec Output Pin1"),
564 SND_SOC_DAPM_OUTPUT("Codec Output Pin2"),
565 SND_SOC_DAPM_OUTPUT("Codec Output Pin3"),
585 hlink = snd_hdac_ext_bus_get_link(hdev->bus, dev_name(&hdev->dev)); in hdac_hda_dev_probe()
587 dev_err(&hdev->dev, "hdac link not found\n"); in hdac_hda_dev_probe()
588 return -EIO; in hdac_hda_dev_probe()
590 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdac_hda_dev_probe()
594 return -ENOMEM; in hdac_hda_dev_probe()
597 ret = devm_snd_soc_register_component(&hdev->dev, in hdac_hda_dev_probe()
601 dev_err(&hdev->dev, "failed to register HDA codec %d\n", ret); in hdac_hda_dev_probe()
605 dev_set_drvdata(&hdev->dev, hda_pvt); in hdac_hda_dev_probe()
606 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hda_dev_probe()