Lines Matching +full:hdmi +full:- +full:switch
1 // SPDX-License-Identifier: GPL-2.0-only
3 * hdac_hdmi.c - ASoc HDA-HDMI codec driver for Intel platforms
5 * Copyright (C) 2014-2015 Intel Corp
17 #include <linux/hdmi.h>
109 unsigned char chmap[8]; /* ALSA API channel-map */
142 #define hdev_to_hdmi_priv(_hdev) dev_get_drvdata(&(_hdev)->dev)
145 hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi, in hdac_hdmi_get_pcm_from_cvt() argument
150 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_get_pcm_from_cvt()
151 if (pcm->cvt == cvt) in hdac_hdmi_get_pcm_from_cvt()
161 struct hdac_device *hdev = port->pin->hdev; in hdac_hdmi_jack_report()
163 port->is_connect = is_connect; in hdac_hdmi_jack_report()
170 if (pcm->jack_event == 0) { in hdac_hdmi_jack_report()
171 dev_dbg(&hdev->dev, in hdac_hdmi_jack_report()
173 pcm->pcm_id); in hdac_hdmi_jack_report()
174 snd_soc_jack_report(pcm->jack, SND_JACK_AVOUT, in hdac_hdmi_jack_report()
177 pcm->jack_event++; in hdac_hdmi_jack_report()
184 if (pcm->jack_event == 1) in hdac_hdmi_jack_report()
185 snd_soc_jack_report(pcm->jack, 0, SND_JACK_AVOUT); in hdac_hdmi_jack_report()
186 if (pcm->jack_event > 0) in hdac_hdmi_jack_report()
187 pcm->jack_event--; in hdac_hdmi_jack_report()
193 if (port->is_connect) in hdac_hdmi_port_dapm_update()
194 snd_soc_dapm_enable_pin(port->dapm, port->jack_pin); in hdac_hdmi_port_dapm_update()
196 snd_soc_dapm_disable_pin(port->dapm, port->jack_pin); in hdac_hdmi_port_dapm_update()
197 snd_soc_dapm_sync(port->dapm); in hdac_hdmi_port_dapm_update()
231 if (param == -1) in hdac_hdmi_get_port_len()
245 return snd_hdac_codec_read(hdev, port->pin->nid, in hdac_hdmi_port_select_get()
258 if (!port->pin->mst_capable) in hdac_hdmi_port_select_set()
262 num_ports = hdac_hdmi_get_port_len(hdev, port->pin->nid); in hdac_hdmi_port_select_set()
264 return -EIO; in hdac_hdmi_port_select_set()
269 if (num_ports + 1 < port->id) in hdac_hdmi_port_select_set()
272 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_port_select_set()
273 AC_VERB_SET_DEVICE_SEL, port->id); in hdac_hdmi_port_select_set()
275 if (port->id != hdac_hdmi_port_select_get(hdev, port)) in hdac_hdmi_port_select_set()
276 return -EIO; in hdac_hdmi_port_select_set()
278 dev_dbg(&hdev->dev, "Selected the port=%d\n", port->id); in hdac_hdmi_port_select_set()
283 static struct hdac_hdmi_pcm *get_hdmi_pcm_from_id(struct hdac_hdmi_priv *hdmi, in get_hdmi_pcm_from_id() argument
288 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in get_hdmi_pcm_from_id()
289 if (pcm->pcm_id == pcm_idx) in get_hdmi_pcm_from_id()
317 for (i = drm_eld_sad_count(eld_buf); i > 0; i--, sad += 3) { in hdac_hdmi_eld_limit_formats()
350 u8 CC02_CT47; /* match with HDMI infoframe from this on */
362 struct hdac_hdmi_pin *pin = port->pin; in hdac_hdmi_setup_audio_infoframe()
364 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_setup_audio_infoframe() local
365 struct hdac_hdmi_cvt *cvt = pcm->cvt; in hdac_hdmi_setup_audio_infoframe()
373 ca = snd_hdac_channel_allocation(hdev, port->eld.info.spk_alloc, in hdac_hdmi_setup_audio_infoframe()
374 pcm->channels, pcm->chmap_set, true, pcm->chmap); in hdac_hdmi_setup_audio_infoframe()
377 hdmi->chmap.ops.set_channel_count(hdev, cvt->nid, channels); in hdac_hdmi_setup_audio_infoframe()
379 snd_hdac_setup_channel_mapping(&hdmi->chmap, pin->nid, false, ca, in hdac_hdmi_setup_audio_infoframe()
380 pcm->channels, pcm->chmap, pcm->chmap_set); in hdac_hdmi_setup_audio_infoframe()
382 eld_buf = port->eld.eld_buffer; in hdac_hdmi_setup_audio_infoframe()
385 switch (conn_type) { in hdac_hdmi_setup_audio_infoframe()
403 dp_ai.CC02_CT47 = channels - 1; in hdac_hdmi_setup_audio_infoframe()
410 dev_err(&hdev->dev, "Invalid connection type: %d\n", conn_type); in hdac_hdmi_setup_audio_infoframe()
411 return -EIO; in hdac_hdmi_setup_audio_infoframe()
415 hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); in hdac_hdmi_setup_audio_infoframe()
416 snd_hdac_codec_write(hdev, pin->nid, 0, in hdac_hdmi_setup_audio_infoframe()
420 /* Fill infoframe. Index auto-incremented */ in hdac_hdmi_setup_audio_infoframe()
421 hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); in hdac_hdmi_setup_audio_infoframe()
424 snd_hdac_codec_write(hdev, pin->nid, 0, in hdac_hdmi_setup_audio_infoframe()
428 snd_hdac_codec_write(hdev, pin->nid, 0, in hdac_hdmi_setup_audio_infoframe()
433 hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); in hdac_hdmi_setup_audio_infoframe()
434 snd_hdac_codec_write(hdev, pin->nid, 0, in hdac_hdmi_setup_audio_infoframe()
443 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_set_stream() local
444 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_set_stream()
450 return -EINVAL; in hdac_hdmi_set_stream()
454 dev_dbg(&hdev->dev, "%s: strm_tag: %d\n", __func__, hstream->stream_tag); in hdac_hdmi_set_stream()
456 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_set_stream()
458 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); in hdac_hdmi_set_stream()
461 pcm->stream_tag = (hstream->stream_tag << 4); in hdac_hdmi_set_stream()
469 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_set_hw_params() local
475 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_set_hw_params()
478 dai->driver->playback.sig_bits); in hdac_hdmi_set_hw_params()
481 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); in hdac_hdmi_set_hw_params()
483 return -EIO; in hdac_hdmi_set_hw_params()
485 pcm->format = format; in hdac_hdmi_set_hw_params()
486 pcm->channels = params_channels(hparams); in hdac_hdmi_set_hw_params()
495 if (!(get_wcaps(hdev, pin->nid) & AC_WCAP_CONN_LIST)) { in hdac_hdmi_query_port_connlist()
496 dev_warn(&hdev->dev, in hdac_hdmi_query_port_connlist()
497 "HDMI: pin %d wcaps %#x does not support connection list\n", in hdac_hdmi_query_port_connlist()
498 pin->nid, get_wcaps(hdev, pin->nid)); in hdac_hdmi_query_port_connlist()
499 return -EINVAL; in hdac_hdmi_query_port_connlist()
503 return -EIO; in hdac_hdmi_query_port_connlist()
505 port->num_mux_nids = snd_hdac_get_connections(hdev, pin->nid, in hdac_hdmi_query_port_connlist()
506 port->mux_nids, HDA_MAX_CONNECTIONS); in hdac_hdmi_query_port_connlist()
507 if (port->num_mux_nids == 0) in hdac_hdmi_query_port_connlist()
508 dev_warn(&hdev->dev, in hdac_hdmi_query_port_connlist()
510 pin->nid, port->id); in hdac_hdmi_query_port_connlist()
512 dev_dbg(&hdev->dev, "num_mux_nids %d for pin:port %d:%d\n", in hdac_hdmi_query_port_connlist()
513 port->num_mux_nids, pin->nid, port->id); in hdac_hdmi_query_port_connlist()
515 return port->num_mux_nids; in hdac_hdmi_query_port_connlist()
529 struct hdac_hdmi_priv *hdmi, in hdac_hdmi_get_port_from_cvt() argument
536 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_get_port_from_cvt()
537 if (pcm->cvt == cvt) { in hdac_hdmi_get_port_from_cvt()
538 if (list_empty(&pcm->port_list)) in hdac_hdmi_get_port_from_cvt()
541 list_for_each_entry(port, &pcm->port_list, head) { in hdac_hdmi_get_port_from_cvt()
542 mutex_lock(&pcm->lock); in hdac_hdmi_get_port_from_cvt()
544 port->pin, port); in hdac_hdmi_get_port_from_cvt()
545 mutex_unlock(&pcm->lock); in hdac_hdmi_get_port_from_cvt()
549 for (i = 0; i < port->num_mux_nids; i++) { in hdac_hdmi_get_port_from_cvt()
550 if (port->mux_nids[i] == cvt->nid && in hdac_hdmi_get_port_from_cvt()
551 port->eld.monitor_present && in hdac_hdmi_get_port_from_cvt()
552 port->eld.eld_valid) in hdac_hdmi_get_port_from_cvt()
568 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_verify_connect_sel_all_pins() local
573 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_verify_connect_sel_all_pins()
574 port = hdac_hdmi_get_port_from_cvt(hdev, hdmi, cvt); in hdac_hdmi_verify_connect_sel_all_pins()
575 if (port && port->pin) { in hdac_hdmi_verify_connect_sel_all_pins()
576 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_verify_connect_sel_all_pins()
578 dev_dbg(&hdev->dev, "%s: %s set connect %d -> %d\n", in hdac_hdmi_verify_connect_sel_all_pins()
579 __func__, cvt->name, port->pin->nid, cvt_idx); in hdac_hdmi_verify_connect_sel_all_pins()
593 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_pcm_open() local
594 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_pcm_open()
600 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_pcm_open()
602 cvt = dai_map->cvt; in hdac_hdmi_pcm_open()
603 port = hdac_hdmi_get_port_from_cvt(hdev, hdmi, cvt); in hdac_hdmi_pcm_open()
611 if ((!port->eld.monitor_present) || in hdac_hdmi_pcm_open()
612 (!port->eld.eld_valid)) { in hdac_hdmi_pcm_open()
614 dev_warn(&hdev->dev, in hdac_hdmi_pcm_open()
616 port->eld.monitor_present, port->eld.eld_valid, in hdac_hdmi_pcm_open()
617 port->pin->nid, port->id); in hdac_hdmi_pcm_open()
622 dai_map->port = port; in hdac_hdmi_pcm_open()
624 ret = hdac_hdmi_eld_limit_formats(substream->runtime, in hdac_hdmi_pcm_open()
625 port->eld.eld_buffer); in hdac_hdmi_pcm_open()
629 return snd_pcm_hw_constraint_eld(substream->runtime, in hdac_hdmi_pcm_open()
630 port->eld.eld_buffer); in hdac_hdmi_pcm_open()
636 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_pcm_close() local
640 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_pcm_close()
642 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); in hdac_hdmi_pcm_close()
645 mutex_lock(&pcm->lock); in hdac_hdmi_pcm_close()
646 pcm->chmap_set = false; in hdac_hdmi_pcm_close()
647 memset(pcm->chmap, 0, sizeof(pcm->chmap)); in hdac_hdmi_pcm_close()
648 pcm->channels = 0; in hdac_hdmi_pcm_close()
649 mutex_unlock(&pcm->lock); in hdac_hdmi_pcm_close()
652 if (dai_map->port) in hdac_hdmi_pcm_close()
653 dai_map->port = NULL; in hdac_hdmi_pcm_close()
660 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_query_cvt_params() local
663 chans = get_wcaps(hdev, cvt->nid); in hdac_hdmi_query_cvt_params()
666 cvt->params.channels_min = 2; in hdac_hdmi_query_cvt_params()
668 cvt->params.channels_max = chans; in hdac_hdmi_query_cvt_params()
669 if (chans > hdmi->chmap.channels_max) in hdac_hdmi_query_cvt_params()
670 hdmi->chmap.channels_max = chans; in hdac_hdmi_query_cvt_params()
672 err = snd_hdac_query_supported_pcm(hdev, cvt->nid, in hdac_hdmi_query_cvt_params()
673 &cvt->params.rates, in hdac_hdmi_query_cvt_params()
674 &cvt->params.formats, in hdac_hdmi_query_cvt_params()
676 &cvt->params.maxbps); in hdac_hdmi_query_cvt_params()
678 dev_err(&hdev->dev, in hdac_hdmi_query_cvt_params()
680 cvt->nid, err); in hdac_hdmi_query_cvt_params()
692 w->id = id; in hdac_hdmi_fill_widget_info()
693 w->name = devm_kstrdup(dev, wname, GFP_KERNEL); in hdac_hdmi_fill_widget_info()
694 if (!w->name) in hdac_hdmi_fill_widget_info()
695 return -ENOMEM; in hdac_hdmi_fill_widget_info()
697 w->sname = stream; in hdac_hdmi_fill_widget_info()
698 w->reg = SND_SOC_NOPM; in hdac_hdmi_fill_widget_info()
699 w->shift = 0; in hdac_hdmi_fill_widget_info()
700 w->kcontrol_news = wc; in hdac_hdmi_fill_widget_info()
701 w->num_kcontrols = numkc; in hdac_hdmi_fill_widget_info()
702 w->priv = priv; in hdac_hdmi_fill_widget_info()
703 w->event = event; in hdac_hdmi_fill_widget_info()
704 w->event_flags = event_flags; in hdac_hdmi_fill_widget_info()
714 route->sink = sink; in hdac_hdmi_fill_route()
715 route->source = src; in hdac_hdmi_fill_route()
716 route->control = control; in hdac_hdmi_fill_route()
717 route->connected = handler; in hdac_hdmi_fill_route()
723 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_get_pcm() local
727 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_get_pcm()
728 if (list_empty(&pcm->port_list)) in hdac_hdmi_get_pcm()
731 list_for_each_entry(p, &pcm->port_list, head) { in hdac_hdmi_get_pcm()
732 if (p->id == port->id && port->pin == p->pin) in hdac_hdmi_get_pcm()
773 struct hdac_hdmi_port *port = w->priv; in hdac_hdmi_pin_output_widget_event()
774 struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); in hdac_hdmi_pin_output_widget_event()
777 dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", in hdac_hdmi_pin_output_widget_event()
778 __func__, w->name, event); in hdac_hdmi_pin_output_widget_event()
782 return -EIO; in hdac_hdmi_pin_output_widget_event()
786 return -EIO; in hdac_hdmi_pin_output_widget_event()
788 switch (event) { in hdac_hdmi_pin_output_widget_event()
790 hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D0); in hdac_hdmi_pin_output_widget_event()
793 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_pin_output_widget_event()
796 hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_UNMUTE); in hdac_hdmi_pin_output_widget_event()
801 hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_MUTE); in hdac_hdmi_pin_output_widget_event()
804 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_pin_output_widget_event()
807 hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D3); in hdac_hdmi_pin_output_widget_event()
818 struct hdac_hdmi_cvt *cvt = w->priv; in hdac_hdmi_cvt_output_widget_event()
819 struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); in hdac_hdmi_cvt_output_widget_event()
820 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_cvt_output_widget_event() local
823 dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", in hdac_hdmi_cvt_output_widget_event()
824 __func__, w->name, event); in hdac_hdmi_cvt_output_widget_event()
826 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, cvt); in hdac_hdmi_cvt_output_widget_event()
828 return -EIO; in hdac_hdmi_cvt_output_widget_event()
830 switch (event) { in hdac_hdmi_cvt_output_widget_event()
832 hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D0); in hdac_hdmi_cvt_output_widget_event()
835 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
839 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
842 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
843 AC_VERB_SET_CHANNEL_STREAMID, pcm->stream_tag); in hdac_hdmi_cvt_output_widget_event()
844 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
845 AC_VERB_SET_STREAM_FORMAT, pcm->format); in hdac_hdmi_cvt_output_widget_event()
857 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
859 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
862 hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D3); in hdac_hdmi_cvt_output_widget_event()
873 struct hdac_hdmi_port *port = w->priv; in hdac_hdmi_pin_mux_widget_event()
874 struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); in hdac_hdmi_pin_mux_widget_event()
877 dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", in hdac_hdmi_pin_mux_widget_event()
878 __func__, w->name, event); in hdac_hdmi_pin_mux_widget_event()
881 kc = w->kcontrols[0]; in hdac_hdmi_pin_mux_widget_event()
887 return -EIO; in hdac_hdmi_pin_mux_widget_event()
890 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_pin_mux_widget_event()
891 AC_VERB_SET_CONNECT_SEL, (mux_idx - 1)); in hdac_hdmi_pin_mux_widget_event()
905 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in hdac_hdmi_set_pin_port_mux()
907 struct snd_soc_dapm_context *dapm = w->dapm; in hdac_hdmi_set_pin_port_mux()
908 struct hdac_hdmi_port *port = w->priv; in hdac_hdmi_set_pin_port_mux()
909 struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); in hdac_hdmi_set_pin_port_mux()
910 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_set_pin_port_mux() local
912 const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0]]; in hdac_hdmi_set_pin_port_mux()
919 return -EINVAL; in hdac_hdmi_set_pin_port_mux()
921 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_set_pin_port_mux()
922 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_set_pin_port_mux()
923 if (list_empty(&pcm->port_list)) in hdac_hdmi_set_pin_port_mux()
926 list_for_each_entry_safe(p, p_next, &pcm->port_list, head) { in hdac_hdmi_set_pin_port_mux()
927 if (p == port && p->id == port->id && in hdac_hdmi_set_pin_port_mux()
928 p->pin == port->pin) { in hdac_hdmi_set_pin_port_mux()
930 list_del(&p->head); in hdac_hdmi_set_pin_port_mux()
939 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_set_pin_port_mux()
940 if (!strcmp(cvt_name, pcm->cvt->name)) { in hdac_hdmi_set_pin_port_mux()
941 list_add_tail(&port->head, &pcm->port_list); in hdac_hdmi_set_pin_port_mux()
942 if (port->eld.monitor_present && port->eld.eld_valid) { in hdac_hdmi_set_pin_port_mux()
944 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_set_pin_port_mux()
949 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_set_pin_port_mux()
968 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_create_pin_port_muxs() local
969 struct hdac_hdmi_pin *pin = port->pin; in hdac_hdmi_create_pin_port_muxs()
978 int num_items = hdmi->num_cvt + 1; in hdac_hdmi_create_pin_port_muxs()
980 kc = devm_kzalloc(&hdev->dev, sizeof(*kc), GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
982 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
984 se = devm_kzalloc(&hdev->dev, sizeof(*se), GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
986 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
989 pin->nid, port->id); in hdac_hdmi_create_pin_port_muxs()
990 kc->name = devm_kstrdup(&hdev->dev, kc_name, GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
991 if (!kc->name) in hdac_hdmi_create_pin_port_muxs()
992 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
994 kc->private_value = (long)se; in hdac_hdmi_create_pin_port_muxs()
995 kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in hdac_hdmi_create_pin_port_muxs()
996 kc->access = 0; in hdac_hdmi_create_pin_port_muxs()
997 kc->info = snd_soc_info_enum_double; in hdac_hdmi_create_pin_port_muxs()
998 kc->put = hdac_hdmi_set_pin_port_mux; in hdac_hdmi_create_pin_port_muxs()
999 kc->get = snd_soc_dapm_get_enum_double; in hdac_hdmi_create_pin_port_muxs()
1001 se->reg = SND_SOC_NOPM; in hdac_hdmi_create_pin_port_muxs()
1004 se->items = num_items; in hdac_hdmi_create_pin_port_muxs()
1005 se->mask = roundup_pow_of_two(se->items) - 1; in hdac_hdmi_create_pin_port_muxs()
1008 items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
1010 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
1012 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_create_pin_port_muxs()
1014 sprintf(mux_items, "cvt %d", cvt->nid); in hdac_hdmi_create_pin_port_muxs()
1015 items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
1017 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
1020 se->texts = devm_kmemdup(&hdev->dev, items, in hdac_hdmi_create_pin_port_muxs()
1022 if (!se->texts) in hdac_hdmi_create_pin_port_muxs()
1023 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
1025 return hdac_hdmi_fill_widget_info(&hdev->dev, widget, in hdac_hdmi_create_pin_port_muxs()
1031 /* Add cvt <- input <- mux route map */
1036 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_add_pinmux_cvt_route() local
1039 int mux_index = hdmi->num_cvt + hdmi->num_ports; in hdac_hdmi_add_pinmux_cvt_route()
1042 for (i = 0; i < hdmi->num_ports; i++) { in hdac_hdmi_add_pinmux_cvt_route()
1044 se = (struct soc_enum *)kc->private_value; in hdac_hdmi_add_pinmux_cvt_route()
1045 for (j = 0; j < hdmi->num_cvt; j++) { in hdac_hdmi_add_pinmux_cvt_route()
1048 se->texts[j + 1], in hdac_hdmi_add_pinmux_cvt_route()
1061 * Pin-port widgets for num ports for Pins enumerated
1062 * Pin-port mux widgets to represent connenction list of pin widget
1068 * pin-port mux -> pin (based on num_ports)
1069 * cvt -> "Input sel control" -> pin-port_mux
1078 struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); in create_fill_widget_route_map()
1079 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in create_fill_widget_route_map() local
1080 struct snd_soc_dai_driver *dai_drv = hdmi->dai_drv; in create_fill_widget_route_map()
1086 if (list_empty(&hdmi->cvt_list) || list_empty(&hdmi->pin_list)) in create_fill_widget_route_map()
1087 return -EINVAL; in create_fill_widget_route_map()
1089 widgets = devm_kzalloc(dapm->dev, (sizeof(*widgets) * in create_fill_widget_route_map()
1090 ((2 * hdmi->num_ports) + hdmi->num_cvt)), in create_fill_widget_route_map()
1094 return -ENOMEM; in create_fill_widget_route_map()
1097 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in create_fill_widget_route_map()
1098 sprintf(widget_name, "Converter %d", cvt->nid); in create_fill_widget_route_map()
1099 ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], in create_fill_widget_route_map()
1109 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_widget_route_map()
1110 for (j = 0; j < pin->num_ports; j++) { in create_fill_widget_route_map()
1111 sprintf(widget_name, "hif%d-%d Output", in create_fill_widget_route_map()
1112 pin->nid, pin->ports[j].id); in create_fill_widget_route_map()
1113 ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], in create_fill_widget_route_map()
1114 snd_soc_dapm_output, &pin->ports[j], in create_fill_widget_route_map()
1121 pin->ports[j].output_pin = widgets[i].name; in create_fill_widget_route_map()
1127 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_widget_route_map()
1128 for (j = 0; j < pin->num_ports; j++) { in create_fill_widget_route_map()
1129 sprintf(widget_name, "Pin%d-Port%d Mux", in create_fill_widget_route_map()
1130 pin->nid, pin->ports[j].id); in create_fill_widget_route_map()
1132 &pin->ports[j], &widgets[i], in create_fill_widget_route_map()
1139 num_routes += hdmi->num_cvt; in create_fill_widget_route_map()
1146 route = devm_kzalloc(dapm->dev, (sizeof(*route) * num_routes), in create_fill_widget_route_map()
1149 return -ENOMEM; in create_fill_widget_route_map()
1152 /* Add pin <- NULL <- mux route map */ in create_fill_widget_route_map()
1153 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_widget_route_map()
1154 for (j = 0; j < pin->num_ports; j++) { in create_fill_widget_route_map()
1155 int sink_index = i + hdmi->num_cvt; in create_fill_widget_route_map()
1156 int src_index = sink_index + pin->num_ports * in create_fill_widget_route_map()
1157 hdmi->num_pin; in create_fill_widget_route_map()
1169 ((2 * hdmi->num_ports) + hdmi->num_cvt)); in create_fill_widget_route_map()
1172 snd_soc_dapm_new_widgets(dapm->card); in create_fill_widget_route_map()
1180 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_init_dai_map() local
1185 if (list_empty(&hdmi->cvt_list)) in hdac_hdmi_init_dai_map()
1186 return -EINVAL; in hdac_hdmi_init_dai_map()
1188 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_init_dai_map()
1189 dai_map = &hdmi->dai_map[dai_id]; in hdac_hdmi_init_dai_map()
1190 dai_map->dai_id = dai_id; in hdac_hdmi_init_dai_map()
1191 dai_map->cvt = cvt; in hdac_hdmi_init_dai_map()
1196 dev_warn(&hdev->dev, in hdac_hdmi_init_dai_map()
1207 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_add_cvt() local
1211 cvt = devm_kzalloc(&hdev->dev, sizeof(*cvt), GFP_KERNEL); in hdac_hdmi_add_cvt()
1213 return -ENOMEM; in hdac_hdmi_add_cvt()
1215 cvt->nid = nid; in hdac_hdmi_add_cvt()
1216 sprintf(name, "cvt %d", cvt->nid); in hdac_hdmi_add_cvt()
1217 cvt->name = devm_kstrdup(&hdev->dev, name, GFP_KERNEL); in hdac_hdmi_add_cvt()
1218 if (!cvt->name) in hdac_hdmi_add_cvt()
1219 return -ENOMEM; in hdac_hdmi_add_cvt()
1221 list_add_tail(&cvt->head, &hdmi->cvt_list); in hdac_hdmi_add_cvt()
1222 hdmi->num_cvt++; in hdac_hdmi_add_cvt()
1232 ver = (port->eld.eld_buffer[DRM_ELD_VER] & DRM_ELD_VER_MASK) in hdac_hdmi_parse_eld()
1236 dev_err(&hdev->dev, "HDMI: Unknown ELD version %d\n", ver); in hdac_hdmi_parse_eld()
1237 return -EINVAL; in hdac_hdmi_parse_eld()
1240 mnl = (port->eld.eld_buffer[DRM_ELD_CEA_EDID_VER_MNL] & in hdac_hdmi_parse_eld()
1244 dev_err(&hdev->dev, "HDMI: MNL Invalid %d\n", mnl); in hdac_hdmi_parse_eld()
1245 return -EINVAL; in hdac_hdmi_parse_eld()
1248 port->eld.info.spk_alloc = port->eld.eld_buffer[DRM_ELD_SPEAKER]; in hdac_hdmi_parse_eld()
1256 struct hdac_device *hdev = pin->hdev; in hdac_hdmi_present_sense()
1257 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_present_sense() local
1260 int port_id = -1; in hdac_hdmi_present_sense()
1263 if (!hdmi) in hdac_hdmi_present_sense()
1268 * to be -1. in hdac_hdmi_present_sense()
1270 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_present_sense()
1271 port->eld.monitor_present = false; in hdac_hdmi_present_sense()
1273 if (pin->mst_capable) in hdac_hdmi_present_sense()
1274 port_id = port->id; in hdac_hdmi_present_sense()
1276 size = snd_hdac_acomp_get_eld(hdev, pin->nid, port_id, in hdac_hdmi_present_sense()
1277 &port->eld.monitor_present, in hdac_hdmi_present_sense()
1278 port->eld.eld_buffer, in hdac_hdmi_present_sense()
1284 size = -EINVAL; in hdac_hdmi_present_sense()
1287 eld_valid = port->eld.eld_valid; in hdac_hdmi_present_sense()
1290 port->eld.eld_valid = true; in hdac_hdmi_present_sense()
1291 port->eld.eld_size = size; in hdac_hdmi_present_sense()
1293 port->eld.eld_valid = false; in hdac_hdmi_present_sense()
1294 port->eld.eld_size = 0; in hdac_hdmi_present_sense()
1297 eld_changed = (eld_valid != port->eld.eld_valid); in hdac_hdmi_present_sense()
1301 if (!port->eld.monitor_present || !port->eld.eld_valid) { in hdac_hdmi_present_sense()
1303 dev_err(&hdev->dev, "%s: disconnect for pin:port %d:%d\n", in hdac_hdmi_present_sense()
1304 __func__, pin->nid, port->id); in hdac_hdmi_present_sense()
1313 schedule_work(&port->dapm_work); in hdac_hdmi_present_sense()
1316 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_present_sense()
1320 if (port->eld.monitor_present && port->eld.eld_valid) { in hdac_hdmi_present_sense()
1323 schedule_work(&port->dapm_work); in hdac_hdmi_present_sense()
1327 port->eld.eld_buffer, port->eld.eld_size, false); in hdac_hdmi_present_sense()
1330 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_present_sense()
1333 snd_ctl_notify(hdmi->card, in hdac_hdmi_present_sense()
1336 &pcm->eld_ctl->id); in hdac_hdmi_present_sense()
1352 ports = devm_kcalloc(&hdev->dev, max_ports, sizeof(*ports), GFP_KERNEL); in hdac_hdmi_add_ports()
1354 return -ENOMEM; in hdac_hdmi_add_ports()
1361 pin->ports = ports; in hdac_hdmi_add_ports()
1362 pin->num_ports = max_ports; in hdac_hdmi_add_ports()
1368 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_add_pin() local
1372 pin = devm_kzalloc(&hdev->dev, sizeof(*pin), GFP_KERNEL); in hdac_hdmi_add_pin()
1374 return -ENOMEM; in hdac_hdmi_add_pin()
1376 pin->nid = nid; in hdac_hdmi_add_pin()
1377 pin->mst_capable = false; in hdac_hdmi_add_pin()
1378 pin->hdev = hdev; in hdac_hdmi_add_pin()
1383 list_add_tail(&pin->head, &hdmi->pin_list); in hdac_hdmi_add_pin()
1384 hdmi->num_pin++; in hdac_hdmi_add_pin()
1385 hdmi->num_ports += pin->num_ports; in hdac_hdmi_add_pin()
1400 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_skl_enable_all_pins() local
1401 unsigned int vendor_nid = hdmi->drv_data->vendor_nid; in hdac_hdmi_skl_enable_all_pins()
1405 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) in hdac_hdmi_skl_enable_all_pins()
1411 if (vendor_param == -1) in hdac_hdmi_skl_enable_all_pins()
1418 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_skl_enable_dp12() local
1419 unsigned int vendor_nid = hdmi->drv_data->vendor_nid; in hdac_hdmi_skl_enable_dp12()
1423 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) in hdac_hdmi_skl_enable_dp12()
1430 if (vendor_param == -1) in hdac_hdmi_skl_enable_dp12()
1439 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_eld_ctl_info() local
1444 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in hdac_hdmi_eld_ctl_info()
1445 uinfo->count = 0; in hdac_hdmi_eld_ctl_info()
1447 pcm = get_hdmi_pcm_from_id(hdmi, kcontrol->id.device); in hdac_hdmi_eld_ctl_info()
1449 dev_dbg(component->dev, "%s: no pcm, device %d\n", __func__, in hdac_hdmi_eld_ctl_info()
1450 kcontrol->id.device); in hdac_hdmi_eld_ctl_info()
1454 if (list_empty(&pcm->port_list)) { in hdac_hdmi_eld_ctl_info()
1455 dev_dbg(component->dev, "%s: empty port list, device %d\n", in hdac_hdmi_eld_ctl_info()
1456 __func__, kcontrol->id.device); in hdac_hdmi_eld_ctl_info()
1460 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_info()
1462 list_for_each_entry(port, &pcm->port_list, head) { in hdac_hdmi_eld_ctl_info()
1463 eld = &port->eld; in hdac_hdmi_eld_ctl_info()
1465 if (eld->eld_valid) { in hdac_hdmi_eld_ctl_info()
1466 uinfo->count = eld->eld_size; in hdac_hdmi_eld_ctl_info()
1471 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_info()
1480 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_eld_ctl_get() local
1485 memset(ucontrol->value.bytes.data, 0, sizeof(ucontrol->value.bytes.data)); in hdac_hdmi_eld_ctl_get()
1487 pcm = get_hdmi_pcm_from_id(hdmi, kcontrol->id.device); in hdac_hdmi_eld_ctl_get()
1489 dev_dbg(component->dev, "%s: no pcm, device %d\n", __func__, in hdac_hdmi_eld_ctl_get()
1490 kcontrol->id.device); in hdac_hdmi_eld_ctl_get()
1494 if (list_empty(&pcm->port_list)) { in hdac_hdmi_eld_ctl_get()
1495 dev_dbg(component->dev, "%s: empty port list, device %d\n", in hdac_hdmi_eld_ctl_get()
1496 __func__, kcontrol->id.device); in hdac_hdmi_eld_ctl_get()
1500 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_get()
1502 list_for_each_entry(port, &pcm->port_list, head) { in hdac_hdmi_eld_ctl_get()
1503 eld = &port->eld; in hdac_hdmi_eld_ctl_get()
1505 if (!eld->eld_valid) in hdac_hdmi_eld_ctl_get()
1508 if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) || in hdac_hdmi_eld_ctl_get()
1509 eld->eld_size > ELD_MAX_SIZE) { in hdac_hdmi_eld_ctl_get()
1510 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_get()
1512 dev_err(component->dev, "%s: buffer too small, device %d eld_size %d\n", in hdac_hdmi_eld_ctl_get()
1513 __func__, kcontrol->id.device, eld->eld_size); in hdac_hdmi_eld_ctl_get()
1515 return -EINVAL; in hdac_hdmi_eld_ctl_get()
1518 memcpy(ucontrol->value.bytes.data, eld->eld_buffer, in hdac_hdmi_eld_ctl_get()
1519 eld->eld_size); in hdac_hdmi_eld_ctl_get()
1523 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_get()
1538 .device = pcm->pcm_id, in hdac_hdmi_create_eld_ctl()
1544 return -ENOMEM; in hdac_hdmi_create_eld_ctl()
1546 pcm->eld_ctl = kctl; in hdac_hdmi_create_eld_ctl()
1548 return snd_ctl_add(component->card->snd_card, kctl); in hdac_hdmi_create_eld_ctl()
1564 struct hdac_hdmi_priv *hdmi, int num_dais) in hdac_hdmi_create_dais() argument
1575 hdmi_dais = devm_kzalloc(&hdev->dev, in hdac_hdmi_create_dais()
1579 return -ENOMEM; in hdac_hdmi_create_dais()
1581 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_create_dais()
1582 ret = snd_hdac_query_supported_pcm(hdev, cvt->nid, in hdac_hdmi_create_dais()
1591 return -EINVAL; in hdac_hdmi_create_dais()
1593 sprintf(dai_name, "intel-hdmi-hifi%d", i+1); in hdac_hdmi_create_dais()
1594 hdmi_dais[i].name = devm_kstrdup(&hdev->dev, in hdac_hdmi_create_dais()
1598 return -ENOMEM; in hdac_hdmi_create_dais()
1602 devm_kstrdup(&hdev->dev, name, GFP_KERNEL); in hdac_hdmi_create_dais()
1604 return -ENOMEM; in hdac_hdmi_create_dais()
1622 hdmi->dai_drv = hdmi_dais; in hdac_hdmi_create_dais()
1636 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_parse_and_map_nid() local
1642 num_nodes = snd_hdac_get_sub_nodes(hdev, hdev->afg, &nid); in hdac_hdmi_parse_and_map_nid()
1644 dev_warn(&hdev->dev, "HDMI: failed to get afg sub nodes\n"); in hdac_hdmi_parse_and_map_nid()
1645 return -EINVAL; in hdac_hdmi_parse_and_map_nid()
1658 switch (type) { in hdac_hdmi_parse_and_map_nid()
1674 if (!hdmi->num_pin || !hdmi->num_cvt) { in hdac_hdmi_parse_and_map_nid()
1675 ret = -EIO; in hdac_hdmi_parse_and_map_nid()
1676 dev_err(&hdev->dev, "Bad pin/cvt setup in %s\n", __func__); in hdac_hdmi_parse_and_map_nid()
1680 ret = hdac_hdmi_create_dais(hdev, dais, hdmi, hdmi->num_cvt); in hdac_hdmi_parse_and_map_nid()
1682 dev_err(&hdev->dev, "Failed to create dais with err: %d\n", in hdac_hdmi_parse_and_map_nid()
1687 *num_dais = hdmi->num_cvt; in hdac_hdmi_parse_and_map_nid()
1690 dev_err(&hdev->dev, "Failed to init DAI map with err: %d\n", in hdac_hdmi_parse_and_map_nid()
1697 return pin - 4; /* map NID 0x05 -> port #1 */ in hdac_hdmi_pin2port()
1703 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_eld_notify_cb() local
1706 struct snd_soc_component *component = hdmi->component; in hdac_hdmi_eld_notify_cb()
1712 dev_dbg(&hdev->dev, "%s: for pin:%d port=%d\n", __func__, in hdac_hdmi_eld_notify_cb()
1721 if (snd_power_get_state(component->card->snd_card) != in hdac_hdmi_eld_notify_cb()
1725 if (atomic_read(&hdev->in_pm)) in hdac_hdmi_eld_notify_cb()
1728 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_eld_notify_cb()
1729 if (pin->nid != pin_nid) in hdac_hdmi_eld_notify_cb()
1732 /* In case of non MST pin, pipe is -1 */ in hdac_hdmi_eld_notify_cb()
1733 if (pipe == -1) { in hdac_hdmi_eld_notify_cb()
1734 pin->mst_capable = false; in hdac_hdmi_eld_notify_cb()
1736 hport = &pin->ports[0]; in hdac_hdmi_eld_notify_cb()
1738 for (i = 0; i < pin->num_ports; i++) { in hdac_hdmi_eld_notify_cb()
1739 pin->mst_capable = true; in hdac_hdmi_eld_notify_cb()
1740 if (pin->ports[i].id == pipe) { in hdac_hdmi_eld_notify_cb()
1741 hport = &pin->ports[i]; in hdac_hdmi_eld_notify_cb()
1764 if (rtd->pcm && (rtd->pcm->device == device)) in hdac_hdmi_get_pcm_from_id()
1765 return rtd->pcm; in hdac_hdmi_get_pcm_from_id()
1779 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in create_fill_jack_kcontrols() local
1780 struct snd_soc_component *component = hdmi->component; in create_fill_jack_kcontrols()
1782 kc = devm_kcalloc(component->dev, hdmi->num_ports, in create_fill_jack_kcontrols()
1786 return -ENOMEM; in create_fill_jack_kcontrols()
1788 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_jack_kcontrols()
1789 for (j = 0; j < pin->num_ports; j++) { in create_fill_jack_kcontrols()
1790 name = devm_kasprintf(component->dev, GFP_KERNEL, in create_fill_jack_kcontrols()
1791 "hif%d-%d Jack", in create_fill_jack_kcontrols()
1792 pin->nid, pin->ports[j].id); in create_fill_jack_kcontrols()
1794 return -ENOMEM; in create_fill_jack_kcontrols()
1796 kc[i].name = devm_kasprintf(component->dev, GFP_KERNEL, in create_fill_jack_kcontrols()
1797 "%s Switch", name); in create_fill_jack_kcontrols()
1799 return -ENOMEM; in create_fill_jack_kcontrols()
1817 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_jack_port_init() local
1818 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_jack_port_init()
1825 widgets = devm_kcalloc(dapm->dev, hdmi->num_ports, in hdac_hdmi_jack_port_init()
1829 return -ENOMEM; in hdac_hdmi_jack_port_init()
1831 route = devm_kcalloc(dapm->dev, hdmi->num_ports, in hdac_hdmi_jack_port_init()
1834 return -ENOMEM; in hdac_hdmi_jack_port_init()
1837 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_jack_port_init()
1838 for (j = 0; j < pin->num_ports; j++) { in hdac_hdmi_jack_port_init()
1839 snprintf(w_name, sizeof(w_name), "hif%d-%d Jack", in hdac_hdmi_jack_port_init()
1840 pin->nid, pin->ports[j].id); in hdac_hdmi_jack_port_init()
1842 ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], in hdac_hdmi_jack_port_init()
1848 pin->ports[j].jack_pin = widgets[i].name; in hdac_hdmi_jack_port_init()
1849 pin->ports[j].dapm = dapm; in hdac_hdmi_jack_port_init()
1852 hdac_hdmi_fill_route(&route[i], pin->ports[j].jack_pin, in hdac_hdmi_jack_port_init()
1853 NULL, pin->ports[j].output_pin, NULL); in hdac_hdmi_jack_port_init()
1860 ret = snd_soc_dapm_new_controls(dapm, widgets, hdmi->num_ports); in hdac_hdmi_jack_port_init()
1864 ret = snd_soc_dapm_add_routes(dapm, route, hdmi->num_ports); in hdac_hdmi_jack_port_init()
1868 ret = snd_soc_dapm_new_widgets(dapm->card); in hdac_hdmi_jack_port_init()
1872 /* Add Jack Pin switch Kcontrol */ in hdac_hdmi_jack_port_init()
1873 ret = create_fill_jack_kcontrols(dapm->card, hdev); in hdac_hdmi_jack_port_init()
1878 /* default set the Jack Pin switch to OFF */ in hdac_hdmi_jack_port_init()
1879 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_jack_port_init()
1880 for (j = 0; j < pin->num_ports; j++) in hdac_hdmi_jack_port_init()
1881 snd_soc_dapm_disable_pin(pin->ports[j].dapm, in hdac_hdmi_jack_port_init()
1882 pin->ports[j].jack_pin); in hdac_hdmi_jack_port_init()
1892 struct snd_soc_component *component = dai->component; in hdac_hdmi_jack_init()
1893 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_jack_init() local
1894 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_jack_init()
1903 pcm = devm_kzalloc(&hdev->dev, sizeof(*pcm), GFP_KERNEL); in hdac_hdmi_jack_init()
1905 return -ENOMEM; in hdac_hdmi_jack_init()
1906 pcm->pcm_id = device; in hdac_hdmi_jack_init()
1907 pcm->cvt = hdmi->dai_map[dai->id].cvt; in hdac_hdmi_jack_init()
1908 pcm->jack_event = 0; in hdac_hdmi_jack_init()
1909 pcm->jack = jack; in hdac_hdmi_jack_init()
1910 mutex_init(&pcm->lock); in hdac_hdmi_jack_init()
1911 INIT_LIST_HEAD(&pcm->port_list); in hdac_hdmi_jack_init()
1912 snd_pcm = hdac_hdmi_get_pcm_from_id(dai->component->card, device); in hdac_hdmi_jack_init()
1914 err = snd_hdac_add_chmap_ctls(snd_pcm, device, &hdmi->chmap); in hdac_hdmi_jack_init()
1916 dev_err(&hdev->dev, in hdac_hdmi_jack_init()
1926 dev_err(&hdev->dev, in hdac_hdmi_jack_init()
1932 list_add_tail(&pcm->head, &hdmi->pcm_list); in hdac_hdmi_jack_init()
1939 struct hdac_hdmi_priv *hdmi, bool detect_pin_caps) in hdac_hdmi_present_sense_all_pins() argument
1944 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_present_sense_all_pins()
1947 if (hdac_hdmi_get_port_len(hdev, pin->nid) == 0) in hdac_hdmi_present_sense_all_pins()
1948 pin->mst_capable = false; in hdac_hdmi_present_sense_all_pins()
1950 pin->mst_capable = true; in hdac_hdmi_present_sense_all_pins()
1953 for (i = 0; i < pin->num_ports; i++) { in hdac_hdmi_present_sense_all_pins()
1954 if (!pin->mst_capable && i > 0) in hdac_hdmi_present_sense_all_pins()
1957 hdac_hdmi_present_sense(pin, &pin->ports[i]); in hdac_hdmi_present_sense_all_pins()
1964 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdmi_codec_probe() local
1965 struct hdac_device *hdev = hdmi->hdev; in hdmi_codec_probe()
1971 hdmi->component = component; in hdmi_codec_probe()
1977 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdmi_codec_probe()
1979 dev_err(&hdev->dev, "hdac link not found\n"); in hdmi_codec_probe()
1980 return -EIO; in hdmi_codec_probe()
1983 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdmi_codec_probe()
1990 ret = snd_hdac_acomp_register_notifier(hdev->bus, &aops); in hdmi_codec_probe()
1992 dev_err(&hdev->dev, "notifier register failed: err: %d\n", ret); in hdmi_codec_probe()
1996 hdac_hdmi_present_sense_all_pins(hdev, hdmi, true); in hdmi_codec_probe()
1998 hdmi->card = dapm->card->snd_card; in hdmi_codec_probe()
2001 * Setup a device_link between card device and HDMI codec device. in hdmi_codec_probe()
2002 * The card device is the consumer and the HDMI codec device is in hdmi_codec_probe()
2005 * on the HDMI audio codec registers. in hdmi_codec_probe()
2009 device_link_add(component->card->dev, &hdev->dev, DL_FLAG_RPM_ACTIVE | in hdmi_codec_probe()
2015 pm_runtime_enable(&hdev->dev); in hdmi_codec_probe()
2016 pm_runtime_put(&hdev->dev); in hdmi_codec_probe()
2017 pm_runtime_suspend(&hdev->dev); in hdmi_codec_probe()
2024 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdmi_codec_remove() local
2025 struct hdac_device *hdev = hdmi->hdev; in hdmi_codec_remove()
2028 ret = snd_hdac_acomp_register_notifier(hdev->bus, NULL); in hdmi_codec_remove()
2030 dev_err(&hdev->dev, "notifier unregister failed: err: %d\n", in hdmi_codec_remove()
2033 pm_runtime_disable(&hdev->dev); in hdmi_codec_remove()
2040 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdmi_codec_resume() local
2054 * works even if the HD-audio side is still dreaming peacefully. in hdmi_codec_resume()
2056 hdac_hdmi_present_sense_all_pins(hdev, hdmi, false); in hdmi_codec_resume()
2073 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_get_chmap() local
2074 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in hdac_hdmi_get_chmap()
2076 memcpy(chmap, pcm->chmap, ARRAY_SIZE(pcm->chmap)); in hdac_hdmi_get_chmap()
2082 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_set_chmap() local
2083 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in hdac_hdmi_set_chmap()
2089 if (list_empty(&pcm->port_list)) in hdac_hdmi_set_chmap()
2092 mutex_lock(&pcm->lock); in hdac_hdmi_set_chmap()
2093 pcm->chmap_set = true; in hdac_hdmi_set_chmap()
2094 memcpy(pcm->chmap, chmap, ARRAY_SIZE(pcm->chmap)); in hdac_hdmi_set_chmap()
2095 list_for_each_entry(port, &pcm->port_list, head) in hdac_hdmi_set_chmap()
2098 mutex_unlock(&pcm->lock); in hdac_hdmi_set_chmap()
2103 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in is_hdac_hdmi_pcm_attached() local
2104 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in is_hdac_hdmi_pcm_attached()
2109 if (list_empty(&pcm->port_list)) in is_hdac_hdmi_pcm_attached()
2117 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_get_spk_alloc() local
2118 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in hdac_hdmi_get_spk_alloc()
2124 if (list_empty(&pcm->port_list)) in hdac_hdmi_get_spk_alloc()
2127 port = list_first_entry(&pcm->port_list, struct hdac_hdmi_port, head); in hdac_hdmi_get_spk_alloc()
2129 if (!port || !port->eld.eld_valid) in hdac_hdmi_get_spk_alloc()
2132 return port->eld.info.spk_alloc; in hdac_hdmi_get_spk_alloc()
2150 struct hdac_driver *hdrv = drv_to_hdac_driver(hdev->dev.driver); in hdac_hdmi_dev_probe()
2154 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdac_hdmi_dev_probe()
2156 dev_err(&hdev->dev, "hdac link not found\n"); in hdac_hdmi_dev_probe()
2157 return -EIO; in hdac_hdmi_dev_probe()
2160 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdac_hdmi_dev_probe()
2162 hdmi_priv = devm_kzalloc(&hdev->dev, sizeof(*hdmi_priv), GFP_KERNEL); in hdac_hdmi_dev_probe()
2164 return -ENOMEM; in hdac_hdmi_dev_probe()
2166 snd_hdac_register_chmap_ops(hdev, &hdmi_priv->chmap); in hdac_hdmi_dev_probe()
2167 hdmi_priv->chmap.ops.get_chmap = hdac_hdmi_get_chmap; in hdac_hdmi_dev_probe()
2168 hdmi_priv->chmap.ops.set_chmap = hdac_hdmi_set_chmap; in hdac_hdmi_dev_probe()
2169 hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; in hdac_hdmi_dev_probe()
2170 hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; in hdac_hdmi_dev_probe()
2171 hdmi_priv->hdev = hdev; in hdac_hdmi_dev_probe()
2174 return -ENODEV; in hdac_hdmi_dev_probe()
2176 if (hdac_id->driver_data) in hdac_hdmi_dev_probe()
2177 hdmi_priv->drv_data = in hdac_hdmi_dev_probe()
2178 (struct hdac_hdmi_drv_data *)hdac_id->driver_data; in hdac_hdmi_dev_probe()
2180 hdmi_priv->drv_data = &intel_drv_data; in hdac_hdmi_dev_probe()
2182 dev_set_drvdata(&hdev->dev, hdmi_priv); in hdac_hdmi_dev_probe()
2184 INIT_LIST_HEAD(&hdmi_priv->pin_list); in hdac_hdmi_dev_probe()
2185 INIT_LIST_HEAD(&hdmi_priv->cvt_list); in hdac_hdmi_dev_probe()
2186 INIT_LIST_HEAD(&hdmi_priv->pcm_list); in hdac_hdmi_dev_probe()
2187 mutex_init(&hdmi_priv->pin_mutex); in hdac_hdmi_dev_probe()
2193 snd_hdac_display_power(hdev->bus, hdev->addr, true); in hdac_hdmi_dev_probe()
2197 dev_err(&hdev->dev, in hdac_hdmi_dev_probe()
2204 ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, in hdac_hdmi_dev_probe()
2207 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hdmi_dev_probe()
2214 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in clear_dapm_works() local
2218 list_for_each_entry(pin, &hdmi->pin_list, head) in clear_dapm_works()
2219 for (i = 0; i < pin->num_ports; i++) in clear_dapm_works()
2220 cancel_work_sync(&pin->ports[i].dapm_work); in clear_dapm_works()
2226 snd_hdac_display_power(hdev->bus, hdev->addr, false); in hdac_hdmi_dev_remove()
2235 struct hdac_bus *bus = hdev->bus; in hdac_hdmi_runtime_suspend()
2251 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, in hdac_hdmi_runtime_suspend()
2257 return -EIO; in hdac_hdmi_runtime_suspend()
2263 snd_hdac_display_power(bus, hdev->addr, false); in hdac_hdmi_runtime_suspend()
2271 struct hdac_bus *bus = hdev->bus; in hdac_hdmi_runtime_resume()
2283 return -EIO; in hdac_hdmi_runtime_resume()
2289 snd_hdac_display_power(bus, hdev->addr, true); in hdac_hdmi_runtime_resume()
2295 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, in hdac_hdmi_runtime_resume()
2311 HDA_CODEC_EXT_ENTRY(0x80862809, 0x100000, "Skylake HDMI", 0),
2312 HDA_CODEC_EXT_ENTRY(0x8086280a, 0x100000, "Broxton HDMI", 0),
2313 HDA_CODEC_EXT_ENTRY(0x8086280b, 0x100000, "Kabylake HDMI", 0),
2314 HDA_CODEC_EXT_ENTRY(0x8086280c, 0x100000, "Cannonlake HDMI",
2316 HDA_CODEC_EXT_ENTRY(0x8086280d, 0x100000, "Geminilake HDMI",
2325 .name = "HDMI HDA Codec",
2347 MODULE_DESCRIPTION("HDMI HD codec");