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>
108 unsigned char chmap[8]; /* ALSA API channel-map */
141 #define hdev_to_hdmi_priv(_hdev) dev_get_drvdata(&(_hdev)->dev)
144 hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi, in hdac_hdmi_get_pcm_from_cvt() argument
149 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_get_pcm_from_cvt()
150 if (pcm->cvt == cvt) in hdac_hdmi_get_pcm_from_cvt()
160 struct hdac_device *hdev = port->pin->hdev; in hdac_hdmi_jack_report()
162 port->is_connect = is_connect; in hdac_hdmi_jack_report()
169 if (pcm->jack_event == 0) { in hdac_hdmi_jack_report()
170 dev_dbg(&hdev->dev, in hdac_hdmi_jack_report()
172 pcm->pcm_id); in hdac_hdmi_jack_report()
173 snd_soc_jack_report(pcm->jack, SND_JACK_AVOUT, in hdac_hdmi_jack_report()
176 pcm->jack_event++; in hdac_hdmi_jack_report()
183 if (pcm->jack_event == 1) in hdac_hdmi_jack_report()
184 snd_soc_jack_report(pcm->jack, 0, SND_JACK_AVOUT); in hdac_hdmi_jack_report()
185 if (pcm->jack_event > 0) in hdac_hdmi_jack_report()
186 pcm->jack_event--; in hdac_hdmi_jack_report()
192 if (port->is_connect) in hdac_hdmi_port_dapm_update()
193 snd_soc_dapm_enable_pin(port->dapm, port->jack_pin); in hdac_hdmi_port_dapm_update()
195 snd_soc_dapm_disable_pin(port->dapm, port->jack_pin); in hdac_hdmi_port_dapm_update()
196 snd_soc_dapm_sync(port->dapm); in hdac_hdmi_port_dapm_update()
230 if (param == -1) in hdac_hdmi_get_port_len()
244 return snd_hdac_codec_read(hdev, port->pin->nid, in hdac_hdmi_port_select_get()
257 if (!port->pin->mst_capable) in hdac_hdmi_port_select_set()
261 num_ports = hdac_hdmi_get_port_len(hdev, port->pin->nid); in hdac_hdmi_port_select_set()
263 return -EIO; in hdac_hdmi_port_select_set()
268 if (num_ports + 1 < port->id) in hdac_hdmi_port_select_set()
271 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_port_select_set()
272 AC_VERB_SET_DEVICE_SEL, port->id); in hdac_hdmi_port_select_set()
274 if (port->id != hdac_hdmi_port_select_get(hdev, port)) in hdac_hdmi_port_select_set()
275 return -EIO; in hdac_hdmi_port_select_set()
277 dev_dbg(&hdev->dev, "Selected the port=%d\n", port->id); in hdac_hdmi_port_select_set()
282 static struct hdac_hdmi_pcm *get_hdmi_pcm_from_id(struct hdac_hdmi_priv *hdmi, in get_hdmi_pcm_from_id() argument
287 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in get_hdmi_pcm_from_id()
288 if (pcm->pcm_id == pcm_idx) in get_hdmi_pcm_from_id()
316 for (i = drm_eld_sad_count(eld_buf); i > 0; i--, sad += 3) { in hdac_hdmi_eld_limit_formats()
349 u8 CC02_CT47; /* match with HDMI infoframe from this on */
361 struct hdac_hdmi_pin *pin = port->pin; in hdac_hdmi_setup_audio_infoframe()
363 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_setup_audio_infoframe() local
364 struct hdac_hdmi_cvt *cvt = pcm->cvt; in hdac_hdmi_setup_audio_infoframe()
372 ca = snd_hdac_channel_allocation(hdev, port->eld.info.spk_alloc, in hdac_hdmi_setup_audio_infoframe()
373 pcm->channels, pcm->chmap_set, true, pcm->chmap); in hdac_hdmi_setup_audio_infoframe()
376 hdmi->chmap.ops.set_channel_count(hdev, cvt->nid, channels); in hdac_hdmi_setup_audio_infoframe()
378 snd_hdac_setup_channel_mapping(&hdmi->chmap, pin->nid, false, ca, in hdac_hdmi_setup_audio_infoframe()
379 pcm->channels, pcm->chmap, pcm->chmap_set); in hdac_hdmi_setup_audio_infoframe()
381 eld_buf = port->eld.eld_buffer; in hdac_hdmi_setup_audio_infoframe()
384 switch (conn_type) { in hdac_hdmi_setup_audio_infoframe()
402 dp_ai.CC02_CT47 = channels - 1; in hdac_hdmi_setup_audio_infoframe()
409 dev_err(&hdev->dev, "Invalid connection type: %d\n", conn_type); in hdac_hdmi_setup_audio_infoframe()
410 return -EIO; in hdac_hdmi_setup_audio_infoframe()
414 hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); in hdac_hdmi_setup_audio_infoframe()
415 snd_hdac_codec_write(hdev, pin->nid, 0, in hdac_hdmi_setup_audio_infoframe()
419 /* Fill infoframe. Index auto-incremented */ in hdac_hdmi_setup_audio_infoframe()
420 hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); in hdac_hdmi_setup_audio_infoframe()
423 snd_hdac_codec_write(hdev, pin->nid, 0, in hdac_hdmi_setup_audio_infoframe()
427 snd_hdac_codec_write(hdev, pin->nid, 0, in hdac_hdmi_setup_audio_infoframe()
432 hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); in hdac_hdmi_setup_audio_infoframe()
433 snd_hdac_codec_write(hdev, pin->nid, 0, in hdac_hdmi_setup_audio_infoframe()
442 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_set_stream() local
443 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_set_stream()
449 return -EINVAL; in hdac_hdmi_set_stream()
453 dev_dbg(&hdev->dev, "%s: strm_tag: %d\n", __func__, hstream->stream_tag); in hdac_hdmi_set_stream()
455 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_set_stream()
457 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); in hdac_hdmi_set_stream()
460 pcm->stream_tag = (hstream->stream_tag << 4); in hdac_hdmi_set_stream()
468 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_set_hw_params() local
473 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_set_hw_params()
477 dai->driver->playback.sig_bits, 0); in hdac_hdmi_set_hw_params()
479 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); in hdac_hdmi_set_hw_params()
481 return -EIO; in hdac_hdmi_set_hw_params()
483 pcm->format = format; in hdac_hdmi_set_hw_params()
484 pcm->channels = params_channels(hparams); in hdac_hdmi_set_hw_params()
493 if (!(get_wcaps(hdev, pin->nid) & AC_WCAP_CONN_LIST)) { in hdac_hdmi_query_port_connlist()
494 dev_warn(&hdev->dev, in hdac_hdmi_query_port_connlist()
495 "HDMI: pin %d wcaps %#x does not support connection list\n", in hdac_hdmi_query_port_connlist()
496 pin->nid, get_wcaps(hdev, pin->nid)); in hdac_hdmi_query_port_connlist()
497 return -EINVAL; in hdac_hdmi_query_port_connlist()
501 return -EIO; in hdac_hdmi_query_port_connlist()
503 port->num_mux_nids = snd_hdac_get_connections(hdev, pin->nid, in hdac_hdmi_query_port_connlist()
504 port->mux_nids, HDA_MAX_CONNECTIONS); in hdac_hdmi_query_port_connlist()
505 if (port->num_mux_nids == 0) in hdac_hdmi_query_port_connlist()
506 dev_warn(&hdev->dev, in hdac_hdmi_query_port_connlist()
508 pin->nid, port->id); in hdac_hdmi_query_port_connlist()
510 dev_dbg(&hdev->dev, "num_mux_nids %d for pin:port %d:%d\n", in hdac_hdmi_query_port_connlist()
511 port->num_mux_nids, pin->nid, port->id); in hdac_hdmi_query_port_connlist()
513 return port->num_mux_nids; in hdac_hdmi_query_port_connlist()
527 struct hdac_hdmi_priv *hdmi, in hdac_hdmi_get_port_from_cvt() argument
534 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_get_port_from_cvt()
535 if (pcm->cvt == cvt) { in hdac_hdmi_get_port_from_cvt()
536 if (list_empty(&pcm->port_list)) in hdac_hdmi_get_port_from_cvt()
539 list_for_each_entry(port, &pcm->port_list, head) { in hdac_hdmi_get_port_from_cvt()
540 mutex_lock(&pcm->lock); in hdac_hdmi_get_port_from_cvt()
542 port->pin, port); in hdac_hdmi_get_port_from_cvt()
543 mutex_unlock(&pcm->lock); in hdac_hdmi_get_port_from_cvt()
547 for (i = 0; i < port->num_mux_nids; i++) { in hdac_hdmi_get_port_from_cvt()
548 if (port->mux_nids[i] == cvt->nid && in hdac_hdmi_get_port_from_cvt()
549 port->eld.monitor_present && in hdac_hdmi_get_port_from_cvt()
550 port->eld.eld_valid) in hdac_hdmi_get_port_from_cvt()
566 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_verify_connect_sel_all_pins() local
571 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_verify_connect_sel_all_pins()
572 port = hdac_hdmi_get_port_from_cvt(hdev, hdmi, cvt); in hdac_hdmi_verify_connect_sel_all_pins()
573 if (port && port->pin) { in hdac_hdmi_verify_connect_sel_all_pins()
574 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_verify_connect_sel_all_pins()
576 dev_dbg(&hdev->dev, "%s: %s set connect %d -> %d\n", in hdac_hdmi_verify_connect_sel_all_pins()
577 __func__, cvt->name, port->pin->nid, cvt_idx); in hdac_hdmi_verify_connect_sel_all_pins()
591 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_pcm_open() local
592 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_pcm_open()
598 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_pcm_open()
600 cvt = dai_map->cvt; in hdac_hdmi_pcm_open()
601 port = hdac_hdmi_get_port_from_cvt(hdev, hdmi, cvt); in hdac_hdmi_pcm_open()
609 if ((!port->eld.monitor_present) || in hdac_hdmi_pcm_open()
610 (!port->eld.eld_valid)) { in hdac_hdmi_pcm_open()
612 dev_warn(&hdev->dev, in hdac_hdmi_pcm_open()
614 port->eld.monitor_present, port->eld.eld_valid, in hdac_hdmi_pcm_open()
615 port->pin->nid, port->id); in hdac_hdmi_pcm_open()
620 dai_map->port = port; in hdac_hdmi_pcm_open()
622 ret = hdac_hdmi_eld_limit_formats(substream->runtime, in hdac_hdmi_pcm_open()
623 port->eld.eld_buffer); in hdac_hdmi_pcm_open()
627 return snd_pcm_hw_constraint_eld(substream->runtime, in hdac_hdmi_pcm_open()
628 port->eld.eld_buffer); in hdac_hdmi_pcm_open()
634 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_pcm_close() local
638 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_pcm_close()
640 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); in hdac_hdmi_pcm_close()
643 mutex_lock(&pcm->lock); in hdac_hdmi_pcm_close()
644 pcm->chmap_set = false; in hdac_hdmi_pcm_close()
645 memset(pcm->chmap, 0, sizeof(pcm->chmap)); in hdac_hdmi_pcm_close()
646 pcm->channels = 0; in hdac_hdmi_pcm_close()
647 mutex_unlock(&pcm->lock); in hdac_hdmi_pcm_close()
650 if (dai_map->port) in hdac_hdmi_pcm_close()
651 dai_map->port = NULL; in hdac_hdmi_pcm_close()
658 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_query_cvt_params() local
661 chans = get_wcaps(hdev, cvt->nid); in hdac_hdmi_query_cvt_params()
664 cvt->params.channels_min = 2; in hdac_hdmi_query_cvt_params()
666 cvt->params.channels_max = chans; in hdac_hdmi_query_cvt_params()
667 if (chans > hdmi->chmap.channels_max) in hdac_hdmi_query_cvt_params()
668 hdmi->chmap.channels_max = chans; in hdac_hdmi_query_cvt_params()
670 err = snd_hdac_query_supported_pcm(hdev, cvt->nid, in hdac_hdmi_query_cvt_params()
671 &cvt->params.rates, in hdac_hdmi_query_cvt_params()
672 &cvt->params.formats, in hdac_hdmi_query_cvt_params()
673 &cvt->params.maxbps); in hdac_hdmi_query_cvt_params()
675 dev_err(&hdev->dev, in hdac_hdmi_query_cvt_params()
677 cvt->nid, err); in hdac_hdmi_query_cvt_params()
689 w->id = id; in hdac_hdmi_fill_widget_info()
690 w->name = devm_kstrdup(dev, wname, GFP_KERNEL); in hdac_hdmi_fill_widget_info()
691 if (!w->name) in hdac_hdmi_fill_widget_info()
692 return -ENOMEM; in hdac_hdmi_fill_widget_info()
694 w->sname = stream; in hdac_hdmi_fill_widget_info()
695 w->reg = SND_SOC_NOPM; in hdac_hdmi_fill_widget_info()
696 w->shift = 0; in hdac_hdmi_fill_widget_info()
697 w->kcontrol_news = wc; in hdac_hdmi_fill_widget_info()
698 w->num_kcontrols = numkc; in hdac_hdmi_fill_widget_info()
699 w->priv = priv; in hdac_hdmi_fill_widget_info()
700 w->event = event; in hdac_hdmi_fill_widget_info()
701 w->event_flags = event_flags; in hdac_hdmi_fill_widget_info()
711 route->sink = sink; in hdac_hdmi_fill_route()
712 route->source = src; in hdac_hdmi_fill_route()
713 route->control = control; in hdac_hdmi_fill_route()
714 route->connected = handler; in hdac_hdmi_fill_route()
720 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_get_pcm() local
724 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_get_pcm()
725 if (list_empty(&pcm->port_list)) in hdac_hdmi_get_pcm()
728 list_for_each_entry(p, &pcm->port_list, head) { in hdac_hdmi_get_pcm()
729 if (p->id == port->id && port->pin == p->pin) in hdac_hdmi_get_pcm()
770 struct hdac_hdmi_port *port = w->priv; in hdac_hdmi_pin_output_widget_event()
771 struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); in hdac_hdmi_pin_output_widget_event()
774 dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", in hdac_hdmi_pin_output_widget_event()
775 __func__, w->name, event); in hdac_hdmi_pin_output_widget_event()
779 return -EIO; in hdac_hdmi_pin_output_widget_event()
783 return -EIO; in hdac_hdmi_pin_output_widget_event()
785 switch (event) { in hdac_hdmi_pin_output_widget_event()
787 hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D0); in hdac_hdmi_pin_output_widget_event()
790 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_pin_output_widget_event()
793 hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_UNMUTE); in hdac_hdmi_pin_output_widget_event()
798 hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_MUTE); in hdac_hdmi_pin_output_widget_event()
801 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_pin_output_widget_event()
804 hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D3); in hdac_hdmi_pin_output_widget_event()
815 struct hdac_hdmi_cvt *cvt = w->priv; in hdac_hdmi_cvt_output_widget_event()
816 struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); in hdac_hdmi_cvt_output_widget_event()
817 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_cvt_output_widget_event() local
820 dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", in hdac_hdmi_cvt_output_widget_event()
821 __func__, w->name, event); in hdac_hdmi_cvt_output_widget_event()
823 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, cvt); in hdac_hdmi_cvt_output_widget_event()
825 return -EIO; in hdac_hdmi_cvt_output_widget_event()
827 switch (event) { in hdac_hdmi_cvt_output_widget_event()
829 hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D0); in hdac_hdmi_cvt_output_widget_event()
832 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
836 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()
840 AC_VERB_SET_CHANNEL_STREAMID, pcm->stream_tag); in hdac_hdmi_cvt_output_widget_event()
841 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
842 AC_VERB_SET_STREAM_FORMAT, pcm->format); in hdac_hdmi_cvt_output_widget_event()
854 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
856 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
859 hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D3); in hdac_hdmi_cvt_output_widget_event()
870 struct hdac_hdmi_port *port = w->priv; in hdac_hdmi_pin_mux_widget_event()
871 struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); in hdac_hdmi_pin_mux_widget_event()
874 dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", in hdac_hdmi_pin_mux_widget_event()
875 __func__, w->name, event); in hdac_hdmi_pin_mux_widget_event()
878 kc = w->kcontrols[0]; in hdac_hdmi_pin_mux_widget_event()
884 return -EIO; in hdac_hdmi_pin_mux_widget_event()
887 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_pin_mux_widget_event()
888 AC_VERB_SET_CONNECT_SEL, (mux_idx - 1)); in hdac_hdmi_pin_mux_widget_event()
902 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in hdac_hdmi_set_pin_port_mux()
904 struct snd_soc_dapm_context *dapm = w->dapm; in hdac_hdmi_set_pin_port_mux()
905 struct hdac_hdmi_port *port = w->priv; in hdac_hdmi_set_pin_port_mux()
906 struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); in hdac_hdmi_set_pin_port_mux()
907 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_set_pin_port_mux() local
909 const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0]]; in hdac_hdmi_set_pin_port_mux()
916 return -EINVAL; in hdac_hdmi_set_pin_port_mux()
918 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_set_pin_port_mux()
919 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_set_pin_port_mux()
920 if (list_empty(&pcm->port_list)) in hdac_hdmi_set_pin_port_mux()
923 list_for_each_entry_safe(p, p_next, &pcm->port_list, head) { in hdac_hdmi_set_pin_port_mux()
924 if (p == port && p->id == port->id && in hdac_hdmi_set_pin_port_mux()
925 p->pin == port->pin) { in hdac_hdmi_set_pin_port_mux()
927 list_del(&p->head); in hdac_hdmi_set_pin_port_mux()
936 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_set_pin_port_mux()
937 if (!strcmp(cvt_name, pcm->cvt->name)) { in hdac_hdmi_set_pin_port_mux()
938 list_add_tail(&port->head, &pcm->port_list); in hdac_hdmi_set_pin_port_mux()
939 if (port->eld.monitor_present && port->eld.eld_valid) { in hdac_hdmi_set_pin_port_mux()
941 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_set_pin_port_mux()
946 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_set_pin_port_mux()
965 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_create_pin_port_muxs() local
966 struct hdac_hdmi_pin *pin = port->pin; in hdac_hdmi_create_pin_port_muxs()
975 int num_items = hdmi->num_cvt + 1; in hdac_hdmi_create_pin_port_muxs()
977 kc = devm_kzalloc(&hdev->dev, sizeof(*kc), GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
979 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
981 se = devm_kzalloc(&hdev->dev, sizeof(*se), GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
983 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
986 pin->nid, port->id); in hdac_hdmi_create_pin_port_muxs()
987 kc->name = devm_kstrdup(&hdev->dev, kc_name, GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
988 if (!kc->name) in hdac_hdmi_create_pin_port_muxs()
989 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
991 kc->private_value = (long)se; in hdac_hdmi_create_pin_port_muxs()
992 kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in hdac_hdmi_create_pin_port_muxs()
993 kc->access = 0; in hdac_hdmi_create_pin_port_muxs()
994 kc->info = snd_soc_info_enum_double; in hdac_hdmi_create_pin_port_muxs()
995 kc->put = hdac_hdmi_set_pin_port_mux; in hdac_hdmi_create_pin_port_muxs()
996 kc->get = snd_soc_dapm_get_enum_double; in hdac_hdmi_create_pin_port_muxs()
998 se->reg = SND_SOC_NOPM; in hdac_hdmi_create_pin_port_muxs()
1001 se->items = num_items; in hdac_hdmi_create_pin_port_muxs()
1002 se->mask = roundup_pow_of_two(se->items) - 1; in hdac_hdmi_create_pin_port_muxs()
1005 items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
1007 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
1009 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_create_pin_port_muxs()
1011 sprintf(mux_items, "cvt %d", cvt->nid); in hdac_hdmi_create_pin_port_muxs()
1012 items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
1014 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
1017 se->texts = devm_kmemdup(&hdev->dev, items, in hdac_hdmi_create_pin_port_muxs()
1019 if (!se->texts) in hdac_hdmi_create_pin_port_muxs()
1020 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
1022 return hdac_hdmi_fill_widget_info(&hdev->dev, widget, in hdac_hdmi_create_pin_port_muxs()
1028 /* Add cvt <- input <- mux route map */
1033 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_add_pinmux_cvt_route() local
1036 int mux_index = hdmi->num_cvt + hdmi->num_ports; in hdac_hdmi_add_pinmux_cvt_route()
1039 for (i = 0; i < hdmi->num_ports; i++) { in hdac_hdmi_add_pinmux_cvt_route()
1041 se = (struct soc_enum *)kc->private_value; in hdac_hdmi_add_pinmux_cvt_route()
1042 for (j = 0; j < hdmi->num_cvt; j++) { in hdac_hdmi_add_pinmux_cvt_route()
1045 se->texts[j + 1], in hdac_hdmi_add_pinmux_cvt_route()
1058 * Pin-port widgets for num ports for Pins enumerated
1059 * Pin-port mux widgets to represent connenction list of pin widget
1065 * pin-port mux -> pin (based on num_ports)
1066 * cvt -> "Input sel control" -> pin-port_mux
1075 struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); in create_fill_widget_route_map()
1076 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in create_fill_widget_route_map() local
1077 struct snd_soc_dai_driver *dai_drv = hdmi->dai_drv; in create_fill_widget_route_map()
1083 if (list_empty(&hdmi->cvt_list) || list_empty(&hdmi->pin_list)) in create_fill_widget_route_map()
1084 return -EINVAL; in create_fill_widget_route_map()
1086 widgets = devm_kzalloc(dapm->dev, (sizeof(*widgets) * in create_fill_widget_route_map()
1087 ((2 * hdmi->num_ports) + hdmi->num_cvt)), in create_fill_widget_route_map()
1091 return -ENOMEM; in create_fill_widget_route_map()
1094 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in create_fill_widget_route_map()
1095 sprintf(widget_name, "Converter %d", cvt->nid); in create_fill_widget_route_map()
1096 ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], in create_fill_widget_route_map()
1106 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_widget_route_map()
1107 for (j = 0; j < pin->num_ports; j++) { in create_fill_widget_route_map()
1108 sprintf(widget_name, "hif%d-%d Output", in create_fill_widget_route_map()
1109 pin->nid, pin->ports[j].id); in create_fill_widget_route_map()
1110 ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], in create_fill_widget_route_map()
1111 snd_soc_dapm_output, &pin->ports[j], in create_fill_widget_route_map()
1118 pin->ports[j].output_pin = widgets[i].name; in create_fill_widget_route_map()
1124 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_widget_route_map()
1125 for (j = 0; j < pin->num_ports; j++) { in create_fill_widget_route_map()
1126 sprintf(widget_name, "Pin%d-Port%d Mux", in create_fill_widget_route_map()
1127 pin->nid, pin->ports[j].id); in create_fill_widget_route_map()
1129 &pin->ports[j], &widgets[i], in create_fill_widget_route_map()
1136 num_routes += hdmi->num_cvt; in create_fill_widget_route_map()
1143 route = devm_kzalloc(dapm->dev, (sizeof(*route) * num_routes), in create_fill_widget_route_map()
1146 return -ENOMEM; in create_fill_widget_route_map()
1149 /* Add pin <- NULL <- mux route map */ in create_fill_widget_route_map()
1150 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_widget_route_map()
1151 for (j = 0; j < pin->num_ports; j++) { in create_fill_widget_route_map()
1152 int sink_index = i + hdmi->num_cvt; in create_fill_widget_route_map()
1153 int src_index = sink_index + pin->num_ports * in create_fill_widget_route_map()
1154 hdmi->num_pin; in create_fill_widget_route_map()
1166 ((2 * hdmi->num_ports) + hdmi->num_cvt)); in create_fill_widget_route_map()
1169 snd_soc_dapm_new_widgets(dapm->card); in create_fill_widget_route_map()
1177 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_init_dai_map() local
1182 if (list_empty(&hdmi->cvt_list)) in hdac_hdmi_init_dai_map()
1183 return -EINVAL; in hdac_hdmi_init_dai_map()
1185 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_init_dai_map()
1186 dai_map = &hdmi->dai_map[dai_id]; in hdac_hdmi_init_dai_map()
1187 dai_map->dai_id = dai_id; in hdac_hdmi_init_dai_map()
1188 dai_map->cvt = cvt; in hdac_hdmi_init_dai_map()
1193 dev_warn(&hdev->dev, in hdac_hdmi_init_dai_map()
1204 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_add_cvt() local
1208 cvt = devm_kzalloc(&hdev->dev, sizeof(*cvt), GFP_KERNEL); in hdac_hdmi_add_cvt()
1210 return -ENOMEM; in hdac_hdmi_add_cvt()
1212 cvt->nid = nid; in hdac_hdmi_add_cvt()
1213 sprintf(name, "cvt %d", cvt->nid); in hdac_hdmi_add_cvt()
1214 cvt->name = devm_kstrdup(&hdev->dev, name, GFP_KERNEL); in hdac_hdmi_add_cvt()
1215 if (!cvt->name) in hdac_hdmi_add_cvt()
1216 return -ENOMEM; in hdac_hdmi_add_cvt()
1218 list_add_tail(&cvt->head, &hdmi->cvt_list); in hdac_hdmi_add_cvt()
1219 hdmi->num_cvt++; in hdac_hdmi_add_cvt()
1229 ver = (port->eld.eld_buffer[DRM_ELD_VER] & DRM_ELD_VER_MASK) in hdac_hdmi_parse_eld()
1233 dev_err(&hdev->dev, "HDMI: Unknown ELD version %d\n", ver); in hdac_hdmi_parse_eld()
1234 return -EINVAL; in hdac_hdmi_parse_eld()
1237 mnl = (port->eld.eld_buffer[DRM_ELD_CEA_EDID_VER_MNL] & in hdac_hdmi_parse_eld()
1241 dev_err(&hdev->dev, "HDMI: MNL Invalid %d\n", mnl); in hdac_hdmi_parse_eld()
1242 return -EINVAL; in hdac_hdmi_parse_eld()
1245 port->eld.info.spk_alloc = port->eld.eld_buffer[DRM_ELD_SPEAKER]; in hdac_hdmi_parse_eld()
1253 struct hdac_device *hdev = pin->hdev; in hdac_hdmi_present_sense()
1254 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_present_sense() local
1257 int port_id = -1; in hdac_hdmi_present_sense()
1260 if (!hdmi) in hdac_hdmi_present_sense()
1265 * to be -1. in hdac_hdmi_present_sense()
1267 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_present_sense()
1268 port->eld.monitor_present = false; in hdac_hdmi_present_sense()
1270 if (pin->mst_capable) in hdac_hdmi_present_sense()
1271 port_id = port->id; in hdac_hdmi_present_sense()
1273 size = snd_hdac_acomp_get_eld(hdev, pin->nid, port_id, in hdac_hdmi_present_sense()
1274 &port->eld.monitor_present, in hdac_hdmi_present_sense()
1275 port->eld.eld_buffer, in hdac_hdmi_present_sense()
1281 size = -EINVAL; in hdac_hdmi_present_sense()
1284 eld_valid = port->eld.eld_valid; in hdac_hdmi_present_sense()
1287 port->eld.eld_valid = true; in hdac_hdmi_present_sense()
1288 port->eld.eld_size = size; in hdac_hdmi_present_sense()
1290 port->eld.eld_valid = false; in hdac_hdmi_present_sense()
1291 port->eld.eld_size = 0; in hdac_hdmi_present_sense()
1294 eld_changed = (eld_valid != port->eld.eld_valid); in hdac_hdmi_present_sense()
1298 if (!port->eld.monitor_present || !port->eld.eld_valid) { in hdac_hdmi_present_sense()
1300 dev_err(&hdev->dev, "%s: disconnect for pin:port %d:%d\n", in hdac_hdmi_present_sense()
1301 __func__, pin->nid, port->id); in hdac_hdmi_present_sense()
1310 schedule_work(&port->dapm_work); in hdac_hdmi_present_sense()
1313 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_present_sense()
1317 if (port->eld.monitor_present && port->eld.eld_valid) { in hdac_hdmi_present_sense()
1320 schedule_work(&port->dapm_work); in hdac_hdmi_present_sense()
1324 port->eld.eld_buffer, port->eld.eld_size, false); in hdac_hdmi_present_sense()
1327 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_present_sense()
1330 snd_ctl_notify(hdmi->card, in hdac_hdmi_present_sense()
1333 &pcm->eld_ctl->id); in hdac_hdmi_present_sense()
1349 ports = devm_kcalloc(&hdev->dev, max_ports, sizeof(*ports), GFP_KERNEL); in hdac_hdmi_add_ports()
1351 return -ENOMEM; in hdac_hdmi_add_ports()
1358 pin->ports = ports; in hdac_hdmi_add_ports()
1359 pin->num_ports = max_ports; in hdac_hdmi_add_ports()
1365 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_add_pin() local
1369 pin = devm_kzalloc(&hdev->dev, sizeof(*pin), GFP_KERNEL); in hdac_hdmi_add_pin()
1371 return -ENOMEM; in hdac_hdmi_add_pin()
1373 pin->nid = nid; in hdac_hdmi_add_pin()
1374 pin->mst_capable = false; in hdac_hdmi_add_pin()
1375 pin->hdev = hdev; in hdac_hdmi_add_pin()
1380 list_add_tail(&pin->head, &hdmi->pin_list); in hdac_hdmi_add_pin()
1381 hdmi->num_pin++; in hdac_hdmi_add_pin()
1382 hdmi->num_ports += pin->num_ports; in hdac_hdmi_add_pin()
1397 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_skl_enable_all_pins() local
1398 unsigned int vendor_nid = hdmi->drv_data->vendor_nid; in hdac_hdmi_skl_enable_all_pins()
1402 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) in hdac_hdmi_skl_enable_all_pins()
1408 if (vendor_param == -1) in hdac_hdmi_skl_enable_all_pins()
1415 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_skl_enable_dp12() local
1416 unsigned int vendor_nid = hdmi->drv_data->vendor_nid; in hdac_hdmi_skl_enable_dp12()
1420 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) in hdac_hdmi_skl_enable_dp12()
1427 if (vendor_param == -1) in hdac_hdmi_skl_enable_dp12()
1436 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_eld_ctl_info() local
1441 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in hdac_hdmi_eld_ctl_info()
1442 uinfo->count = 0; in hdac_hdmi_eld_ctl_info()
1444 pcm = get_hdmi_pcm_from_id(hdmi, kcontrol->id.device); in hdac_hdmi_eld_ctl_info()
1446 dev_dbg(component->dev, "%s: no pcm, device %d\n", __func__, in hdac_hdmi_eld_ctl_info()
1447 kcontrol->id.device); in hdac_hdmi_eld_ctl_info()
1451 if (list_empty(&pcm->port_list)) { in hdac_hdmi_eld_ctl_info()
1452 dev_dbg(component->dev, "%s: empty port list, device %d\n", in hdac_hdmi_eld_ctl_info()
1453 __func__, kcontrol->id.device); in hdac_hdmi_eld_ctl_info()
1457 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_info()
1459 list_for_each_entry(port, &pcm->port_list, head) { in hdac_hdmi_eld_ctl_info()
1460 eld = &port->eld; in hdac_hdmi_eld_ctl_info()
1462 if (eld->eld_valid) { in hdac_hdmi_eld_ctl_info()
1463 uinfo->count = eld->eld_size; in hdac_hdmi_eld_ctl_info()
1468 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_info()
1477 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_eld_ctl_get() local
1482 memset(ucontrol->value.bytes.data, 0, sizeof(ucontrol->value.bytes.data)); in hdac_hdmi_eld_ctl_get()
1484 pcm = get_hdmi_pcm_from_id(hdmi, kcontrol->id.device); in hdac_hdmi_eld_ctl_get()
1486 dev_dbg(component->dev, "%s: no pcm, device %d\n", __func__, in hdac_hdmi_eld_ctl_get()
1487 kcontrol->id.device); in hdac_hdmi_eld_ctl_get()
1491 if (list_empty(&pcm->port_list)) { in hdac_hdmi_eld_ctl_get()
1492 dev_dbg(component->dev, "%s: empty port list, device %d\n", in hdac_hdmi_eld_ctl_get()
1493 __func__, kcontrol->id.device); in hdac_hdmi_eld_ctl_get()
1497 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_get()
1499 list_for_each_entry(port, &pcm->port_list, head) { in hdac_hdmi_eld_ctl_get()
1500 eld = &port->eld; in hdac_hdmi_eld_ctl_get()
1502 if (!eld->eld_valid) in hdac_hdmi_eld_ctl_get()
1505 if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) || in hdac_hdmi_eld_ctl_get()
1506 eld->eld_size > ELD_MAX_SIZE) { in hdac_hdmi_eld_ctl_get()
1507 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_get()
1509 dev_err(component->dev, "%s: buffer too small, device %d eld_size %d\n", in hdac_hdmi_eld_ctl_get()
1510 __func__, kcontrol->id.device, eld->eld_size); in hdac_hdmi_eld_ctl_get()
1512 return -EINVAL; in hdac_hdmi_eld_ctl_get()
1515 memcpy(ucontrol->value.bytes.data, eld->eld_buffer, in hdac_hdmi_eld_ctl_get()
1516 eld->eld_size); in hdac_hdmi_eld_ctl_get()
1520 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_get()
1535 .device = pcm->pcm_id, in hdac_hdmi_create_eld_ctl()
1541 return -ENOMEM; in hdac_hdmi_create_eld_ctl()
1543 pcm->eld_ctl = kctl; in hdac_hdmi_create_eld_ctl()
1545 return snd_ctl_add(component->card->snd_card, kctl); in hdac_hdmi_create_eld_ctl()
1561 struct hdac_hdmi_priv *hdmi, int num_dais) in hdac_hdmi_create_dais() argument
1572 hdmi_dais = devm_kzalloc(&hdev->dev, in hdac_hdmi_create_dais()
1576 return -ENOMEM; in hdac_hdmi_create_dais()
1578 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_create_dais()
1579 ret = snd_hdac_query_supported_pcm(hdev, cvt->nid, in hdac_hdmi_create_dais()
1588 return -EINVAL; in hdac_hdmi_create_dais()
1590 sprintf(dai_name, "intel-hdmi-hifi%d", i+1); in hdac_hdmi_create_dais()
1591 hdmi_dais[i].name = devm_kstrdup(&hdev->dev, in hdac_hdmi_create_dais()
1595 return -ENOMEM; in hdac_hdmi_create_dais()
1599 devm_kstrdup(&hdev->dev, name, GFP_KERNEL); in hdac_hdmi_create_dais()
1601 return -ENOMEM; in hdac_hdmi_create_dais()
1619 hdmi->dai_drv = hdmi_dais; in hdac_hdmi_create_dais()
1633 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_parse_and_map_nid() local
1639 num_nodes = snd_hdac_get_sub_nodes(hdev, hdev->afg, &nid); in hdac_hdmi_parse_and_map_nid()
1641 dev_warn(&hdev->dev, "HDMI: failed to get afg sub nodes\n"); in hdac_hdmi_parse_and_map_nid()
1642 return -EINVAL; in hdac_hdmi_parse_and_map_nid()
1655 switch (type) { in hdac_hdmi_parse_and_map_nid()
1671 if (!hdmi->num_pin || !hdmi->num_cvt) { in hdac_hdmi_parse_and_map_nid()
1672 ret = -EIO; in hdac_hdmi_parse_and_map_nid()
1673 dev_err(&hdev->dev, "Bad pin/cvt setup in %s\n", __func__); in hdac_hdmi_parse_and_map_nid()
1677 ret = hdac_hdmi_create_dais(hdev, dais, hdmi, hdmi->num_cvt); in hdac_hdmi_parse_and_map_nid()
1679 dev_err(&hdev->dev, "Failed to create dais with err: %d\n", in hdac_hdmi_parse_and_map_nid()
1684 *num_dais = hdmi->num_cvt; in hdac_hdmi_parse_and_map_nid()
1687 dev_err(&hdev->dev, "Failed to init DAI map with err: %d\n", in hdac_hdmi_parse_and_map_nid()
1694 return pin - 4; /* map NID 0x05 -> port #1 */ in hdac_hdmi_pin2port()
1700 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_eld_notify_cb() local
1703 struct snd_soc_component *component = hdmi->component; in hdac_hdmi_eld_notify_cb()
1709 dev_dbg(&hdev->dev, "%s: for pin:%d port=%d\n", __func__, in hdac_hdmi_eld_notify_cb()
1718 if (snd_power_get_state(component->card->snd_card) != in hdac_hdmi_eld_notify_cb()
1722 if (atomic_read(&hdev->in_pm)) in hdac_hdmi_eld_notify_cb()
1725 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_eld_notify_cb()
1726 if (pin->nid != pin_nid) in hdac_hdmi_eld_notify_cb()
1729 /* In case of non MST pin, pipe is -1 */ in hdac_hdmi_eld_notify_cb()
1730 if (pipe == -1) { in hdac_hdmi_eld_notify_cb()
1731 pin->mst_capable = false; in hdac_hdmi_eld_notify_cb()
1733 hport = &pin->ports[0]; in hdac_hdmi_eld_notify_cb()
1735 for (i = 0; i < pin->num_ports; i++) { in hdac_hdmi_eld_notify_cb()
1736 pin->mst_capable = true; in hdac_hdmi_eld_notify_cb()
1737 if (pin->ports[i].id == pipe) { in hdac_hdmi_eld_notify_cb()
1738 hport = &pin->ports[i]; in hdac_hdmi_eld_notify_cb()
1761 if (rtd->pcm && (rtd->pcm->device == device)) in hdac_hdmi_get_pcm_from_id()
1762 return rtd->pcm; in hdac_hdmi_get_pcm_from_id()
1777 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in create_fill_jack_kcontrols() local
1778 struct snd_soc_component *component = hdmi->component; in create_fill_jack_kcontrols()
1780 kc = devm_kcalloc(component->dev, hdmi->num_ports, in create_fill_jack_kcontrols()
1784 return -ENOMEM; in create_fill_jack_kcontrols()
1786 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_jack_kcontrols()
1787 for (j = 0; j < pin->num_ports; j++) { in create_fill_jack_kcontrols()
1788 snprintf(xname, sizeof(xname), "hif%d-%d Jack", in create_fill_jack_kcontrols()
1789 pin->nid, pin->ports[j].id); in create_fill_jack_kcontrols()
1790 name = devm_kstrdup(component->dev, xname, GFP_KERNEL); in create_fill_jack_kcontrols()
1792 return -ENOMEM; in create_fill_jack_kcontrols()
1793 snprintf(kc_name, sizeof(kc_name), "%s Switch", xname); in create_fill_jack_kcontrols()
1794 kc[i].name = devm_kstrdup(component->dev, kc_name, in create_fill_jack_kcontrols()
1797 return -ENOMEM; in create_fill_jack_kcontrols()
1815 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_jack_port_init() local
1816 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_jack_port_init()
1823 widgets = devm_kcalloc(dapm->dev, hdmi->num_ports, in hdac_hdmi_jack_port_init()
1827 return -ENOMEM; in hdac_hdmi_jack_port_init()
1829 route = devm_kcalloc(dapm->dev, hdmi->num_ports, in hdac_hdmi_jack_port_init()
1832 return -ENOMEM; in hdac_hdmi_jack_port_init()
1835 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_jack_port_init()
1836 for (j = 0; j < pin->num_ports; j++) { in hdac_hdmi_jack_port_init()
1837 snprintf(w_name, sizeof(w_name), "hif%d-%d Jack", in hdac_hdmi_jack_port_init()
1838 pin->nid, pin->ports[j].id); in hdac_hdmi_jack_port_init()
1840 ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], in hdac_hdmi_jack_port_init()
1846 pin->ports[j].jack_pin = widgets[i].name; in hdac_hdmi_jack_port_init()
1847 pin->ports[j].dapm = dapm; in hdac_hdmi_jack_port_init()
1850 hdac_hdmi_fill_route(&route[i], pin->ports[j].jack_pin, in hdac_hdmi_jack_port_init()
1851 NULL, pin->ports[j].output_pin, NULL); in hdac_hdmi_jack_port_init()
1858 ret = snd_soc_dapm_new_controls(dapm, widgets, hdmi->num_ports); in hdac_hdmi_jack_port_init()
1862 ret = snd_soc_dapm_add_routes(dapm, route, hdmi->num_ports); in hdac_hdmi_jack_port_init()
1866 ret = snd_soc_dapm_new_widgets(dapm->card); in hdac_hdmi_jack_port_init()
1870 /* Add Jack Pin switch Kcontrol */ in hdac_hdmi_jack_port_init()
1871 ret = create_fill_jack_kcontrols(dapm->card, hdev); in hdac_hdmi_jack_port_init()
1876 /* default set the Jack Pin switch to OFF */ in hdac_hdmi_jack_port_init()
1877 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_jack_port_init()
1878 for (j = 0; j < pin->num_ports; j++) in hdac_hdmi_jack_port_init()
1879 snd_soc_dapm_disable_pin(pin->ports[j].dapm, in hdac_hdmi_jack_port_init()
1880 pin->ports[j].jack_pin); in hdac_hdmi_jack_port_init()
1890 struct snd_soc_component *component = dai->component; in hdac_hdmi_jack_init()
1891 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_jack_init() local
1892 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_jack_init()
1901 pcm = devm_kzalloc(&hdev->dev, sizeof(*pcm), GFP_KERNEL); in hdac_hdmi_jack_init()
1903 return -ENOMEM; in hdac_hdmi_jack_init()
1904 pcm->pcm_id = device; in hdac_hdmi_jack_init()
1905 pcm->cvt = hdmi->dai_map[dai->id].cvt; in hdac_hdmi_jack_init()
1906 pcm->jack_event = 0; in hdac_hdmi_jack_init()
1907 pcm->jack = jack; in hdac_hdmi_jack_init()
1908 mutex_init(&pcm->lock); in hdac_hdmi_jack_init()
1909 INIT_LIST_HEAD(&pcm->port_list); in hdac_hdmi_jack_init()
1910 snd_pcm = hdac_hdmi_get_pcm_from_id(dai->component->card, device); in hdac_hdmi_jack_init()
1912 err = snd_hdac_add_chmap_ctls(snd_pcm, device, &hdmi->chmap); in hdac_hdmi_jack_init()
1914 dev_err(&hdev->dev, in hdac_hdmi_jack_init()
1924 dev_err(&hdev->dev, in hdac_hdmi_jack_init()
1930 list_add_tail(&pcm->head, &hdmi->pcm_list); in hdac_hdmi_jack_init()
1937 struct hdac_hdmi_priv *hdmi, bool detect_pin_caps) in hdac_hdmi_present_sense_all_pins() argument
1942 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_present_sense_all_pins()
1945 if (hdac_hdmi_get_port_len(hdev, pin->nid) == 0) in hdac_hdmi_present_sense_all_pins()
1946 pin->mst_capable = false; in hdac_hdmi_present_sense_all_pins()
1948 pin->mst_capable = true; in hdac_hdmi_present_sense_all_pins()
1951 for (i = 0; i < pin->num_ports; i++) { in hdac_hdmi_present_sense_all_pins()
1952 if (!pin->mst_capable && i > 0) in hdac_hdmi_present_sense_all_pins()
1955 hdac_hdmi_present_sense(pin, &pin->ports[i]); in hdac_hdmi_present_sense_all_pins()
1962 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdmi_codec_probe() local
1963 struct hdac_device *hdev = hdmi->hdev; in hdmi_codec_probe()
1969 hdmi->component = component; in hdmi_codec_probe()
1975 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdmi_codec_probe()
1977 dev_err(&hdev->dev, "hdac link not found\n"); in hdmi_codec_probe()
1978 return -EIO; in hdmi_codec_probe()
1981 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdmi_codec_probe()
1988 ret = snd_hdac_acomp_register_notifier(hdev->bus, &aops); in hdmi_codec_probe()
1990 dev_err(&hdev->dev, "notifier register failed: err: %d\n", ret); in hdmi_codec_probe()
1994 hdac_hdmi_present_sense_all_pins(hdev, hdmi, true); in hdmi_codec_probe()
1996 hdmi->card = dapm->card->snd_card; in hdmi_codec_probe()
1999 * Setup a device_link between card device and HDMI codec device. in hdmi_codec_probe()
2000 * The card device is the consumer and the HDMI codec device is in hdmi_codec_probe()
2003 * on the HDMI audio codec registers. in hdmi_codec_probe()
2007 device_link_add(component->card->dev, &hdev->dev, DL_FLAG_RPM_ACTIVE | in hdmi_codec_probe()
2013 pm_runtime_enable(&hdev->dev); in hdmi_codec_probe()
2014 pm_runtime_put(&hdev->dev); in hdmi_codec_probe()
2015 pm_runtime_suspend(&hdev->dev); in hdmi_codec_probe()
2022 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdmi_codec_remove() local
2023 struct hdac_device *hdev = hdmi->hdev; in hdmi_codec_remove()
2026 ret = snd_hdac_acomp_register_notifier(hdev->bus, NULL); in hdmi_codec_remove()
2028 dev_err(&hdev->dev, "notifier unregister failed: err: %d\n", in hdmi_codec_remove()
2031 pm_runtime_disable(&hdev->dev); in hdmi_codec_remove()
2038 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdmi_codec_resume() local
2052 * works even if the HD-audio side is still dreaming peacefully. in hdmi_codec_resume()
2054 hdac_hdmi_present_sense_all_pins(hdev, hdmi, false); in hdmi_codec_resume()
2071 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_get_chmap() local
2072 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in hdac_hdmi_get_chmap()
2074 memcpy(chmap, pcm->chmap, ARRAY_SIZE(pcm->chmap)); in hdac_hdmi_get_chmap()
2080 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_set_chmap() local
2081 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in hdac_hdmi_set_chmap()
2087 if (list_empty(&pcm->port_list)) in hdac_hdmi_set_chmap()
2090 mutex_lock(&pcm->lock); in hdac_hdmi_set_chmap()
2091 pcm->chmap_set = true; in hdac_hdmi_set_chmap()
2092 memcpy(pcm->chmap, chmap, ARRAY_SIZE(pcm->chmap)); in hdac_hdmi_set_chmap()
2093 list_for_each_entry(port, &pcm->port_list, head) in hdac_hdmi_set_chmap()
2096 mutex_unlock(&pcm->lock); in hdac_hdmi_set_chmap()
2101 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in is_hdac_hdmi_pcm_attached() local
2102 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in is_hdac_hdmi_pcm_attached()
2107 if (list_empty(&pcm->port_list)) in is_hdac_hdmi_pcm_attached()
2115 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_get_spk_alloc() local
2116 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in hdac_hdmi_get_spk_alloc()
2122 if (list_empty(&pcm->port_list)) in hdac_hdmi_get_spk_alloc()
2125 port = list_first_entry(&pcm->port_list, struct hdac_hdmi_port, head); in hdac_hdmi_get_spk_alloc()
2127 if (!port || !port->eld.eld_valid) in hdac_hdmi_get_spk_alloc()
2130 return port->eld.info.spk_alloc; in hdac_hdmi_get_spk_alloc()
2148 struct hdac_driver *hdrv = drv_to_hdac_driver(hdev->dev.driver); in hdac_hdmi_dev_probe()
2152 hlink = snd_hdac_ext_bus_get_hlink_by_name(hdev->bus, dev_name(&hdev->dev)); in hdac_hdmi_dev_probe()
2154 dev_err(&hdev->dev, "hdac link not found\n"); in hdac_hdmi_dev_probe()
2155 return -EIO; in hdac_hdmi_dev_probe()
2158 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdac_hdmi_dev_probe()
2160 hdmi_priv = devm_kzalloc(&hdev->dev, sizeof(*hdmi_priv), GFP_KERNEL); in hdac_hdmi_dev_probe()
2162 return -ENOMEM; in hdac_hdmi_dev_probe()
2164 snd_hdac_register_chmap_ops(hdev, &hdmi_priv->chmap); in hdac_hdmi_dev_probe()
2165 hdmi_priv->chmap.ops.get_chmap = hdac_hdmi_get_chmap; in hdac_hdmi_dev_probe()
2166 hdmi_priv->chmap.ops.set_chmap = hdac_hdmi_set_chmap; in hdac_hdmi_dev_probe()
2167 hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; in hdac_hdmi_dev_probe()
2168 hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; in hdac_hdmi_dev_probe()
2169 hdmi_priv->hdev = hdev; in hdac_hdmi_dev_probe()
2172 return -ENODEV; in hdac_hdmi_dev_probe()
2174 if (hdac_id->driver_data) in hdac_hdmi_dev_probe()
2175 hdmi_priv->drv_data = in hdac_hdmi_dev_probe()
2176 (struct hdac_hdmi_drv_data *)hdac_id->driver_data; in hdac_hdmi_dev_probe()
2178 hdmi_priv->drv_data = &intel_drv_data; in hdac_hdmi_dev_probe()
2180 dev_set_drvdata(&hdev->dev, hdmi_priv); in hdac_hdmi_dev_probe()
2182 INIT_LIST_HEAD(&hdmi_priv->pin_list); in hdac_hdmi_dev_probe()
2183 INIT_LIST_HEAD(&hdmi_priv->cvt_list); in hdac_hdmi_dev_probe()
2184 INIT_LIST_HEAD(&hdmi_priv->pcm_list); in hdac_hdmi_dev_probe()
2185 mutex_init(&hdmi_priv->pin_mutex); in hdac_hdmi_dev_probe()
2191 snd_hdac_display_power(hdev->bus, hdev->addr, true); in hdac_hdmi_dev_probe()
2195 dev_err(&hdev->dev, in hdac_hdmi_dev_probe()
2202 ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, in hdac_hdmi_dev_probe()
2205 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hdmi_dev_probe()
2212 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in clear_dapm_works() local
2216 list_for_each_entry(pin, &hdmi->pin_list, head) in clear_dapm_works()
2217 for (i = 0; i < pin->num_ports; i++) in clear_dapm_works()
2218 cancel_work_sync(&pin->ports[i].dapm_work); in clear_dapm_works()
2224 snd_hdac_display_power(hdev->bus, hdev->addr, false); in hdac_hdmi_dev_remove()
2233 struct hdac_bus *bus = hdev->bus; in hdac_hdmi_runtime_suspend()
2249 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, in hdac_hdmi_runtime_suspend()
2255 return -EIO; in hdac_hdmi_runtime_suspend()
2261 snd_hdac_display_power(bus, hdev->addr, false); in hdac_hdmi_runtime_suspend()
2269 struct hdac_bus *bus = hdev->bus; in hdac_hdmi_runtime_resume()
2281 return -EIO; in hdac_hdmi_runtime_resume()
2287 snd_hdac_display_power(bus, hdev->addr, true); in hdac_hdmi_runtime_resume()
2293 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, in hdac_hdmi_runtime_resume()
2309 HDA_CODEC_EXT_ENTRY(0x80862809, 0x100000, "Skylake HDMI", 0),
2310 HDA_CODEC_EXT_ENTRY(0x8086280a, 0x100000, "Broxton HDMI", 0),
2311 HDA_CODEC_EXT_ENTRY(0x8086280b, 0x100000, "Kabylake HDMI", 0),
2312 HDA_CODEC_EXT_ENTRY(0x8086280c, 0x100000, "Cannonlake HDMI",
2314 HDA_CODEC_EXT_ENTRY(0x8086280d, 0x100000, "Geminilake HDMI",
2323 .name = "HDMI HDA Codec",
2345 MODULE_DESCRIPTION("HDMI HD codec");