Lines Matching +full:hdmi +full:- +full:dp1

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()
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()
443 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_set_tdm_slot() local
444 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_set_tdm_slot()
448 dev_dbg(&hdev->dev, "%s: strm_tag: %d\n", __func__, tx_mask); in hdac_hdmi_set_tdm_slot()
450 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_set_tdm_slot()
452 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); in hdac_hdmi_set_tdm_slot()
455 pcm->stream_tag = (tx_mask << 4); in hdac_hdmi_set_tdm_slot()
463 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_set_hw_params() local
468 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_set_hw_params()
472 dai->driver->playback.sig_bits, 0); in hdac_hdmi_set_hw_params()
474 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); in hdac_hdmi_set_hw_params()
476 return -EIO; in hdac_hdmi_set_hw_params()
478 pcm->format = format; in hdac_hdmi_set_hw_params()
479 pcm->channels = params_channels(hparams); in hdac_hdmi_set_hw_params()
488 if (!(get_wcaps(hdev, pin->nid) & AC_WCAP_CONN_LIST)) { in hdac_hdmi_query_port_connlist()
489 dev_warn(&hdev->dev, in hdac_hdmi_query_port_connlist()
490 "HDMI: pin %d wcaps %#x does not support connection list\n", in hdac_hdmi_query_port_connlist()
491 pin->nid, get_wcaps(hdev, pin->nid)); in hdac_hdmi_query_port_connlist()
492 return -EINVAL; in hdac_hdmi_query_port_connlist()
496 return -EIO; in hdac_hdmi_query_port_connlist()
498 port->num_mux_nids = snd_hdac_get_connections(hdev, pin->nid, in hdac_hdmi_query_port_connlist()
499 port->mux_nids, HDA_MAX_CONNECTIONS); in hdac_hdmi_query_port_connlist()
500 if (port->num_mux_nids == 0) in hdac_hdmi_query_port_connlist()
501 dev_warn(&hdev->dev, in hdac_hdmi_query_port_connlist()
503 pin->nid, port->id); in hdac_hdmi_query_port_connlist()
505 dev_dbg(&hdev->dev, "num_mux_nids %d for pin:port %d:%d\n", in hdac_hdmi_query_port_connlist()
506 port->num_mux_nids, pin->nid, port->id); in hdac_hdmi_query_port_connlist()
508 return port->num_mux_nids; in hdac_hdmi_query_port_connlist()
522 struct hdac_hdmi_priv *hdmi, in hdac_hdmi_get_port_from_cvt() argument
529 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_get_port_from_cvt()
530 if (pcm->cvt == cvt) { in hdac_hdmi_get_port_from_cvt()
531 if (list_empty(&pcm->port_list)) in hdac_hdmi_get_port_from_cvt()
534 list_for_each_entry(port, &pcm->port_list, head) { in hdac_hdmi_get_port_from_cvt()
535 mutex_lock(&pcm->lock); in hdac_hdmi_get_port_from_cvt()
537 port->pin, port); in hdac_hdmi_get_port_from_cvt()
538 mutex_unlock(&pcm->lock); in hdac_hdmi_get_port_from_cvt()
542 for (i = 0; i < port->num_mux_nids; i++) { in hdac_hdmi_get_port_from_cvt()
543 if (port->mux_nids[i] == cvt->nid && in hdac_hdmi_get_port_from_cvt()
544 port->eld.monitor_present && in hdac_hdmi_get_port_from_cvt()
545 port->eld.eld_valid) in hdac_hdmi_get_port_from_cvt()
561 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_verify_connect_sel_all_pins() local
566 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_verify_connect_sel_all_pins()
567 port = hdac_hdmi_get_port_from_cvt(hdev, hdmi, cvt); in hdac_hdmi_verify_connect_sel_all_pins()
568 if (port && port->pin) { in hdac_hdmi_verify_connect_sel_all_pins()
569 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_verify_connect_sel_all_pins()
571 dev_dbg(&hdev->dev, "%s: %s set connect %d -> %d\n", in hdac_hdmi_verify_connect_sel_all_pins()
572 __func__, cvt->name, port->pin->nid, cvt_idx); in hdac_hdmi_verify_connect_sel_all_pins()
586 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_pcm_open() local
587 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_pcm_open()
593 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_pcm_open()
595 cvt = dai_map->cvt; in hdac_hdmi_pcm_open()
596 port = hdac_hdmi_get_port_from_cvt(hdev, hdmi, cvt); in hdac_hdmi_pcm_open()
604 if ((!port->eld.monitor_present) || in hdac_hdmi_pcm_open()
605 (!port->eld.eld_valid)) { in hdac_hdmi_pcm_open()
607 dev_warn(&hdev->dev, in hdac_hdmi_pcm_open()
609 port->eld.monitor_present, port->eld.eld_valid, in hdac_hdmi_pcm_open()
610 port->pin->nid, port->id); in hdac_hdmi_pcm_open()
615 dai_map->port = port; in hdac_hdmi_pcm_open()
617 ret = hdac_hdmi_eld_limit_formats(substream->runtime, in hdac_hdmi_pcm_open()
618 port->eld.eld_buffer); in hdac_hdmi_pcm_open()
622 return snd_pcm_hw_constraint_eld(substream->runtime, in hdac_hdmi_pcm_open()
623 port->eld.eld_buffer); in hdac_hdmi_pcm_open()
629 struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); in hdac_hdmi_pcm_close() local
633 dai_map = &hdmi->dai_map[dai->id]; in hdac_hdmi_pcm_close()
635 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); in hdac_hdmi_pcm_close()
638 mutex_lock(&pcm->lock); in hdac_hdmi_pcm_close()
639 pcm->chmap_set = false; in hdac_hdmi_pcm_close()
640 memset(pcm->chmap, 0, sizeof(pcm->chmap)); in hdac_hdmi_pcm_close()
641 pcm->channels = 0; in hdac_hdmi_pcm_close()
642 mutex_unlock(&pcm->lock); in hdac_hdmi_pcm_close()
645 if (dai_map->port) in hdac_hdmi_pcm_close()
646 dai_map->port = NULL; in hdac_hdmi_pcm_close()
653 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_query_cvt_params() local
656 chans = get_wcaps(hdev, cvt->nid); in hdac_hdmi_query_cvt_params()
659 cvt->params.channels_min = 2; in hdac_hdmi_query_cvt_params()
661 cvt->params.channels_max = chans; in hdac_hdmi_query_cvt_params()
662 if (chans > hdmi->chmap.channels_max) in hdac_hdmi_query_cvt_params()
663 hdmi->chmap.channels_max = chans; in hdac_hdmi_query_cvt_params()
665 err = snd_hdac_query_supported_pcm(hdev, cvt->nid, in hdac_hdmi_query_cvt_params()
666 &cvt->params.rates, in hdac_hdmi_query_cvt_params()
667 &cvt->params.formats, in hdac_hdmi_query_cvt_params()
668 &cvt->params.maxbps); in hdac_hdmi_query_cvt_params()
670 dev_err(&hdev->dev, in hdac_hdmi_query_cvt_params()
672 cvt->nid, err); in hdac_hdmi_query_cvt_params()
684 w->id = id; in hdac_hdmi_fill_widget_info()
685 w->name = devm_kstrdup(dev, wname, GFP_KERNEL); in hdac_hdmi_fill_widget_info()
686 if (!w->name) in hdac_hdmi_fill_widget_info()
687 return -ENOMEM; in hdac_hdmi_fill_widget_info()
689 w->sname = stream; in hdac_hdmi_fill_widget_info()
690 w->reg = SND_SOC_NOPM; in hdac_hdmi_fill_widget_info()
691 w->shift = 0; in hdac_hdmi_fill_widget_info()
692 w->kcontrol_news = wc; in hdac_hdmi_fill_widget_info()
693 w->num_kcontrols = numkc; in hdac_hdmi_fill_widget_info()
694 w->priv = priv; in hdac_hdmi_fill_widget_info()
695 w->event = event; in hdac_hdmi_fill_widget_info()
696 w->event_flags = event_flags; in hdac_hdmi_fill_widget_info()
706 route->sink = sink; in hdac_hdmi_fill_route()
707 route->source = src; in hdac_hdmi_fill_route()
708 route->control = control; in hdac_hdmi_fill_route()
709 route->connected = handler; in hdac_hdmi_fill_route()
715 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_get_pcm() local
719 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_get_pcm()
720 if (list_empty(&pcm->port_list)) in hdac_hdmi_get_pcm()
723 list_for_each_entry(p, &pcm->port_list, head) { in hdac_hdmi_get_pcm()
724 if (p->id == port->id && port->pin == p->pin) in hdac_hdmi_get_pcm()
765 struct hdac_hdmi_port *port = w->priv; in hdac_hdmi_pin_output_widget_event()
766 struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); in hdac_hdmi_pin_output_widget_event()
769 dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", in hdac_hdmi_pin_output_widget_event()
770 __func__, w->name, event); in hdac_hdmi_pin_output_widget_event()
774 return -EIO; in hdac_hdmi_pin_output_widget_event()
778 return -EIO; in hdac_hdmi_pin_output_widget_event()
782 hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D0); in hdac_hdmi_pin_output_widget_event()
785 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_pin_output_widget_event()
788 hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_UNMUTE); in hdac_hdmi_pin_output_widget_event()
793 hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_MUTE); in hdac_hdmi_pin_output_widget_event()
796 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_pin_output_widget_event()
799 hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D3); in hdac_hdmi_pin_output_widget_event()
810 struct hdac_hdmi_cvt *cvt = w->priv; in hdac_hdmi_cvt_output_widget_event()
811 struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); in hdac_hdmi_cvt_output_widget_event()
812 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_cvt_output_widget_event() local
815 dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", in hdac_hdmi_cvt_output_widget_event()
816 __func__, w->name, event); in hdac_hdmi_cvt_output_widget_event()
818 pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, cvt); in hdac_hdmi_cvt_output_widget_event()
820 return -EIO; in hdac_hdmi_cvt_output_widget_event()
824 hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D0); in hdac_hdmi_cvt_output_widget_event()
827 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
831 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
834 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
835 AC_VERB_SET_CHANNEL_STREAMID, pcm->stream_tag); in hdac_hdmi_cvt_output_widget_event()
836 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
837 AC_VERB_SET_STREAM_FORMAT, pcm->format); in hdac_hdmi_cvt_output_widget_event()
849 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
851 snd_hdac_codec_write(hdev, cvt->nid, 0, in hdac_hdmi_cvt_output_widget_event()
854 hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D3); in hdac_hdmi_cvt_output_widget_event()
865 struct hdac_hdmi_port *port = w->priv; in hdac_hdmi_pin_mux_widget_event()
866 struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); in hdac_hdmi_pin_mux_widget_event()
869 dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", in hdac_hdmi_pin_mux_widget_event()
870 __func__, w->name, event); in hdac_hdmi_pin_mux_widget_event()
873 kc = w->kcontrols[0]; in hdac_hdmi_pin_mux_widget_event()
879 return -EIO; in hdac_hdmi_pin_mux_widget_event()
882 snd_hdac_codec_write(hdev, port->pin->nid, 0, in hdac_hdmi_pin_mux_widget_event()
883 AC_VERB_SET_CONNECT_SEL, (mux_idx - 1)); in hdac_hdmi_pin_mux_widget_event()
897 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in hdac_hdmi_set_pin_port_mux()
899 struct snd_soc_dapm_context *dapm = w->dapm; in hdac_hdmi_set_pin_port_mux()
900 struct hdac_hdmi_port *port = w->priv; in hdac_hdmi_set_pin_port_mux()
901 struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); in hdac_hdmi_set_pin_port_mux()
902 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_set_pin_port_mux() local
904 const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0]]; in hdac_hdmi_set_pin_port_mux()
911 return -EINVAL; in hdac_hdmi_set_pin_port_mux()
913 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_set_pin_port_mux()
914 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_set_pin_port_mux()
915 if (list_empty(&pcm->port_list)) in hdac_hdmi_set_pin_port_mux()
918 list_for_each_entry_safe(p, p_next, &pcm->port_list, head) { in hdac_hdmi_set_pin_port_mux()
919 if (p == port && p->id == port->id && in hdac_hdmi_set_pin_port_mux()
920 p->pin == port->pin) { in hdac_hdmi_set_pin_port_mux()
922 list_del(&p->head); in hdac_hdmi_set_pin_port_mux()
931 list_for_each_entry(pcm, &hdmi->pcm_list, head) { in hdac_hdmi_set_pin_port_mux()
932 if (!strcmp(cvt_name, pcm->cvt->name)) { in hdac_hdmi_set_pin_port_mux()
933 list_add_tail(&port->head, &pcm->port_list); in hdac_hdmi_set_pin_port_mux()
934 if (port->eld.monitor_present && port->eld.eld_valid) { in hdac_hdmi_set_pin_port_mux()
936 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_set_pin_port_mux()
941 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_set_pin_port_mux()
960 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_create_pin_port_muxs() local
961 struct hdac_hdmi_pin *pin = port->pin; in hdac_hdmi_create_pin_port_muxs()
970 int num_items = hdmi->num_cvt + 1; in hdac_hdmi_create_pin_port_muxs()
972 kc = devm_kzalloc(&hdev->dev, sizeof(*kc), GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
974 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
976 se = devm_kzalloc(&hdev->dev, sizeof(*se), GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
978 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
981 pin->nid, port->id); in hdac_hdmi_create_pin_port_muxs()
982 kc->name = devm_kstrdup(&hdev->dev, kc_name, GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
983 if (!kc->name) in hdac_hdmi_create_pin_port_muxs()
984 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
986 kc->private_value = (long)se; in hdac_hdmi_create_pin_port_muxs()
987 kc->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in hdac_hdmi_create_pin_port_muxs()
988 kc->access = 0; in hdac_hdmi_create_pin_port_muxs()
989 kc->info = snd_soc_info_enum_double; in hdac_hdmi_create_pin_port_muxs()
990 kc->put = hdac_hdmi_set_pin_port_mux; in hdac_hdmi_create_pin_port_muxs()
991 kc->get = snd_soc_dapm_get_enum_double; in hdac_hdmi_create_pin_port_muxs()
993 se->reg = SND_SOC_NOPM; in hdac_hdmi_create_pin_port_muxs()
996 se->items = num_items; in hdac_hdmi_create_pin_port_muxs()
997 se->mask = roundup_pow_of_two(se->items) - 1; in hdac_hdmi_create_pin_port_muxs()
1000 items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
1002 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
1004 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_create_pin_port_muxs()
1006 sprintf(mux_items, "cvt %d", cvt->nid); in hdac_hdmi_create_pin_port_muxs()
1007 items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); in hdac_hdmi_create_pin_port_muxs()
1009 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
1012 se->texts = devm_kmemdup(&hdev->dev, items, in hdac_hdmi_create_pin_port_muxs()
1014 if (!se->texts) in hdac_hdmi_create_pin_port_muxs()
1015 return -ENOMEM; in hdac_hdmi_create_pin_port_muxs()
1017 return hdac_hdmi_fill_widget_info(&hdev->dev, widget, in hdac_hdmi_create_pin_port_muxs()
1023 /* Add cvt <- input <- mux route map */
1028 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_add_pinmux_cvt_route() local
1031 int mux_index = hdmi->num_cvt + hdmi->num_ports; in hdac_hdmi_add_pinmux_cvt_route()
1034 for (i = 0; i < hdmi->num_ports; i++) { in hdac_hdmi_add_pinmux_cvt_route()
1036 se = (struct soc_enum *)kc->private_value; in hdac_hdmi_add_pinmux_cvt_route()
1037 for (j = 0; j < hdmi->num_cvt; j++) { in hdac_hdmi_add_pinmux_cvt_route()
1040 se->texts[j + 1], in hdac_hdmi_add_pinmux_cvt_route()
1053 * Pin-port widgets for num ports for Pins enumerated
1054 * Pin-port mux widgets to represent connenction list of pin widget
1060 * pin-port mux -> pin (based on num_ports)
1061 * cvt -> "Input sel control" -> pin-port_mux
1070 struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); in create_fill_widget_route_map()
1071 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in create_fill_widget_route_map() local
1072 struct snd_soc_dai_driver *dai_drv = hdmi->dai_drv; in create_fill_widget_route_map()
1078 if (list_empty(&hdmi->cvt_list) || list_empty(&hdmi->pin_list)) in create_fill_widget_route_map()
1079 return -EINVAL; in create_fill_widget_route_map()
1081 widgets = devm_kzalloc(dapm->dev, (sizeof(*widgets) * in create_fill_widget_route_map()
1082 ((2 * hdmi->num_ports) + hdmi->num_cvt)), in create_fill_widget_route_map()
1086 return -ENOMEM; in create_fill_widget_route_map()
1089 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in create_fill_widget_route_map()
1090 sprintf(widget_name, "Converter %d", cvt->nid); in create_fill_widget_route_map()
1091 ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], in create_fill_widget_route_map()
1101 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_widget_route_map()
1102 for (j = 0; j < pin->num_ports; j++) { in create_fill_widget_route_map()
1103 sprintf(widget_name, "hif%d-%d Output", in create_fill_widget_route_map()
1104 pin->nid, pin->ports[j].id); in create_fill_widget_route_map()
1105 ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], in create_fill_widget_route_map()
1106 snd_soc_dapm_output, &pin->ports[j], in create_fill_widget_route_map()
1113 pin->ports[j].output_pin = widgets[i].name; in create_fill_widget_route_map()
1119 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_widget_route_map()
1120 for (j = 0; j < pin->num_ports; j++) { in create_fill_widget_route_map()
1121 sprintf(widget_name, "Pin%d-Port%d Mux", in create_fill_widget_route_map()
1122 pin->nid, pin->ports[j].id); in create_fill_widget_route_map()
1124 &pin->ports[j], &widgets[i], in create_fill_widget_route_map()
1131 num_routes += hdmi->num_cvt; in create_fill_widget_route_map()
1138 route = devm_kzalloc(dapm->dev, (sizeof(*route) * num_routes), in create_fill_widget_route_map()
1141 return -ENOMEM; in create_fill_widget_route_map()
1144 /* Add pin <- NULL <- mux route map */ in create_fill_widget_route_map()
1145 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_widget_route_map()
1146 for (j = 0; j < pin->num_ports; j++) { in create_fill_widget_route_map()
1147 int sink_index = i + hdmi->num_cvt; in create_fill_widget_route_map()
1148 int src_index = sink_index + pin->num_ports * in create_fill_widget_route_map()
1149 hdmi->num_pin; in create_fill_widget_route_map()
1161 ((2 * hdmi->num_ports) + hdmi->num_cvt)); in create_fill_widget_route_map()
1164 snd_soc_dapm_new_widgets(dapm->card); in create_fill_widget_route_map()
1172 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_init_dai_map() local
1177 if (list_empty(&hdmi->cvt_list)) in hdac_hdmi_init_dai_map()
1178 return -EINVAL; in hdac_hdmi_init_dai_map()
1180 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_init_dai_map()
1181 dai_map = &hdmi->dai_map[dai_id]; in hdac_hdmi_init_dai_map()
1182 dai_map->dai_id = dai_id; in hdac_hdmi_init_dai_map()
1183 dai_map->cvt = cvt; in hdac_hdmi_init_dai_map()
1188 dev_warn(&hdev->dev, in hdac_hdmi_init_dai_map()
1199 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_add_cvt() local
1203 cvt = devm_kzalloc(&hdev->dev, sizeof(*cvt), GFP_KERNEL); in hdac_hdmi_add_cvt()
1205 return -ENOMEM; in hdac_hdmi_add_cvt()
1207 cvt->nid = nid; in hdac_hdmi_add_cvt()
1208 sprintf(name, "cvt %d", cvt->nid); in hdac_hdmi_add_cvt()
1209 cvt->name = devm_kstrdup(&hdev->dev, name, GFP_KERNEL); in hdac_hdmi_add_cvt()
1210 if (!cvt->name) in hdac_hdmi_add_cvt()
1211 return -ENOMEM; in hdac_hdmi_add_cvt()
1213 list_add_tail(&cvt->head, &hdmi->cvt_list); in hdac_hdmi_add_cvt()
1214 hdmi->num_cvt++; in hdac_hdmi_add_cvt()
1224 ver = (port->eld.eld_buffer[DRM_ELD_VER] & DRM_ELD_VER_MASK) in hdac_hdmi_parse_eld()
1228 dev_err(&hdev->dev, "HDMI: Unknown ELD version %d\n", ver); in hdac_hdmi_parse_eld()
1229 return -EINVAL; in hdac_hdmi_parse_eld()
1232 mnl = (port->eld.eld_buffer[DRM_ELD_CEA_EDID_VER_MNL] & in hdac_hdmi_parse_eld()
1236 dev_err(&hdev->dev, "HDMI: MNL Invalid %d\n", mnl); in hdac_hdmi_parse_eld()
1237 return -EINVAL; in hdac_hdmi_parse_eld()
1240 port->eld.info.spk_alloc = port->eld.eld_buffer[DRM_ELD_SPEAKER]; in hdac_hdmi_parse_eld()
1248 struct hdac_device *hdev = pin->hdev; in hdac_hdmi_present_sense()
1249 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_present_sense() local
1252 int port_id = -1; in hdac_hdmi_present_sense()
1255 if (!hdmi) in hdac_hdmi_present_sense()
1260 * to be -1. in hdac_hdmi_present_sense()
1262 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_present_sense()
1263 port->eld.monitor_present = false; in hdac_hdmi_present_sense()
1265 if (pin->mst_capable) in hdac_hdmi_present_sense()
1266 port_id = port->id; in hdac_hdmi_present_sense()
1268 size = snd_hdac_acomp_get_eld(hdev, pin->nid, port_id, in hdac_hdmi_present_sense()
1269 &port->eld.monitor_present, in hdac_hdmi_present_sense()
1270 port->eld.eld_buffer, in hdac_hdmi_present_sense()
1276 size = -EINVAL; in hdac_hdmi_present_sense()
1279 eld_valid = port->eld.eld_valid; in hdac_hdmi_present_sense()
1282 port->eld.eld_valid = true; in hdac_hdmi_present_sense()
1283 port->eld.eld_size = size; in hdac_hdmi_present_sense()
1285 port->eld.eld_valid = false; in hdac_hdmi_present_sense()
1286 port->eld.eld_size = 0; in hdac_hdmi_present_sense()
1289 eld_changed = (eld_valid != port->eld.eld_valid); in hdac_hdmi_present_sense()
1293 if (!port->eld.monitor_present || !port->eld.eld_valid) { in hdac_hdmi_present_sense()
1295 dev_err(&hdev->dev, "%s: disconnect for pin:port %d:%d\n", in hdac_hdmi_present_sense()
1296 __func__, pin->nid, port->id); in hdac_hdmi_present_sense()
1305 schedule_work(&port->dapm_work); in hdac_hdmi_present_sense()
1308 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_present_sense()
1312 if (port->eld.monitor_present && port->eld.eld_valid) { in hdac_hdmi_present_sense()
1315 schedule_work(&port->dapm_work); in hdac_hdmi_present_sense()
1319 port->eld.eld_buffer, port->eld.eld_size, false); in hdac_hdmi_present_sense()
1322 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_present_sense()
1325 snd_ctl_notify(hdmi->card, in hdac_hdmi_present_sense()
1328 &pcm->eld_ctl->id); in hdac_hdmi_present_sense()
1344 ports = devm_kcalloc(&hdev->dev, max_ports, sizeof(*ports), GFP_KERNEL); in hdac_hdmi_add_ports()
1346 return -ENOMEM; in hdac_hdmi_add_ports()
1353 pin->ports = ports; in hdac_hdmi_add_ports()
1354 pin->num_ports = max_ports; in hdac_hdmi_add_ports()
1360 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_add_pin() local
1364 pin = devm_kzalloc(&hdev->dev, sizeof(*pin), GFP_KERNEL); in hdac_hdmi_add_pin()
1366 return -ENOMEM; in hdac_hdmi_add_pin()
1368 pin->nid = nid; in hdac_hdmi_add_pin()
1369 pin->mst_capable = false; in hdac_hdmi_add_pin()
1370 pin->hdev = hdev; in hdac_hdmi_add_pin()
1375 list_add_tail(&pin->head, &hdmi->pin_list); in hdac_hdmi_add_pin()
1376 hdmi->num_pin++; in hdac_hdmi_add_pin()
1377 hdmi->num_ports += pin->num_ports; in hdac_hdmi_add_pin()
1392 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_skl_enable_all_pins() local
1393 unsigned int vendor_nid = hdmi->drv_data->vendor_nid; in hdac_hdmi_skl_enable_all_pins()
1397 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS) in hdac_hdmi_skl_enable_all_pins()
1403 if (vendor_param == -1) in hdac_hdmi_skl_enable_all_pins()
1410 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_skl_enable_dp12() local
1411 unsigned int vendor_nid = hdmi->drv_data->vendor_nid; in hdac_hdmi_skl_enable_dp12()
1415 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12) in hdac_hdmi_skl_enable_dp12()
1418 /* enable DP1.2 mode */ in hdac_hdmi_skl_enable_dp12()
1422 if (vendor_param == -1) in hdac_hdmi_skl_enable_dp12()
1431 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_eld_ctl_info() local
1436 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; in hdac_hdmi_eld_ctl_info()
1437 uinfo->count = 0; in hdac_hdmi_eld_ctl_info()
1439 pcm = get_hdmi_pcm_from_id(hdmi, kcontrol->id.device); in hdac_hdmi_eld_ctl_info()
1441 dev_dbg(component->dev, "%s: no pcm, device %d\n", __func__, in hdac_hdmi_eld_ctl_info()
1442 kcontrol->id.device); in hdac_hdmi_eld_ctl_info()
1446 if (list_empty(&pcm->port_list)) { in hdac_hdmi_eld_ctl_info()
1447 dev_dbg(component->dev, "%s: empty port list, device %d\n", in hdac_hdmi_eld_ctl_info()
1448 __func__, kcontrol->id.device); in hdac_hdmi_eld_ctl_info()
1452 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_info()
1454 list_for_each_entry(port, &pcm->port_list, head) { in hdac_hdmi_eld_ctl_info()
1455 eld = &port->eld; in hdac_hdmi_eld_ctl_info()
1457 if (eld->eld_valid) { in hdac_hdmi_eld_ctl_info()
1458 uinfo->count = eld->eld_size; in hdac_hdmi_eld_ctl_info()
1463 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_info()
1472 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_eld_ctl_get() local
1477 memset(ucontrol->value.bytes.data, 0, sizeof(ucontrol->value.bytes.data)); in hdac_hdmi_eld_ctl_get()
1479 pcm = get_hdmi_pcm_from_id(hdmi, kcontrol->id.device); in hdac_hdmi_eld_ctl_get()
1481 dev_dbg(component->dev, "%s: no pcm, device %d\n", __func__, in hdac_hdmi_eld_ctl_get()
1482 kcontrol->id.device); in hdac_hdmi_eld_ctl_get()
1486 if (list_empty(&pcm->port_list)) { in hdac_hdmi_eld_ctl_get()
1487 dev_dbg(component->dev, "%s: empty port list, device %d\n", in hdac_hdmi_eld_ctl_get()
1488 __func__, kcontrol->id.device); in hdac_hdmi_eld_ctl_get()
1492 mutex_lock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_get()
1494 list_for_each_entry(port, &pcm->port_list, head) { in hdac_hdmi_eld_ctl_get()
1495 eld = &port->eld; in hdac_hdmi_eld_ctl_get()
1497 if (!eld->eld_valid) in hdac_hdmi_eld_ctl_get()
1500 if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) || in hdac_hdmi_eld_ctl_get()
1501 eld->eld_size > ELD_MAX_SIZE) { in hdac_hdmi_eld_ctl_get()
1502 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_get()
1504 dev_err(component->dev, "%s: buffer too small, device %d eld_size %d\n", in hdac_hdmi_eld_ctl_get()
1505 __func__, kcontrol->id.device, eld->eld_size); in hdac_hdmi_eld_ctl_get()
1507 return -EINVAL; in hdac_hdmi_eld_ctl_get()
1510 memcpy(ucontrol->value.bytes.data, eld->eld_buffer, in hdac_hdmi_eld_ctl_get()
1511 eld->eld_size); in hdac_hdmi_eld_ctl_get()
1515 mutex_unlock(&hdmi->pin_mutex); in hdac_hdmi_eld_ctl_get()
1530 .device = pcm->pcm_id, in hdac_hdmi_create_eld_ctl()
1536 return -ENOMEM; in hdac_hdmi_create_eld_ctl()
1538 pcm->eld_ctl = kctl; in hdac_hdmi_create_eld_ctl()
1540 return snd_ctl_add(component->card->snd_card, kctl); in hdac_hdmi_create_eld_ctl()
1556 struct hdac_hdmi_priv *hdmi, int num_dais) in hdac_hdmi_create_dais() argument
1567 hdmi_dais = devm_kzalloc(&hdev->dev, in hdac_hdmi_create_dais()
1571 return -ENOMEM; in hdac_hdmi_create_dais()
1573 list_for_each_entry(cvt, &hdmi->cvt_list, head) { in hdac_hdmi_create_dais()
1574 ret = snd_hdac_query_supported_pcm(hdev, cvt->nid, in hdac_hdmi_create_dais()
1583 return -EINVAL; in hdac_hdmi_create_dais()
1585 sprintf(dai_name, "intel-hdmi-hifi%d", i+1); in hdac_hdmi_create_dais()
1586 hdmi_dais[i].name = devm_kstrdup(&hdev->dev, in hdac_hdmi_create_dais()
1590 return -ENOMEM; in hdac_hdmi_create_dais()
1594 devm_kstrdup(&hdev->dev, name, GFP_KERNEL); in hdac_hdmi_create_dais()
1596 return -ENOMEM; in hdac_hdmi_create_dais()
1614 hdmi->dai_drv = hdmi_dais; in hdac_hdmi_create_dais()
1628 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_parse_and_map_nid() local
1634 num_nodes = snd_hdac_get_sub_nodes(hdev, hdev->afg, &nid); in hdac_hdmi_parse_and_map_nid()
1636 dev_warn(&hdev->dev, "HDMI: failed to get afg sub nodes\n"); in hdac_hdmi_parse_and_map_nid()
1637 return -EINVAL; in hdac_hdmi_parse_and_map_nid()
1666 if (!hdmi->num_pin || !hdmi->num_cvt) { in hdac_hdmi_parse_and_map_nid()
1667 ret = -EIO; in hdac_hdmi_parse_and_map_nid()
1668 dev_err(&hdev->dev, "Bad pin/cvt setup in %s\n", __func__); in hdac_hdmi_parse_and_map_nid()
1672 ret = hdac_hdmi_create_dais(hdev, dais, hdmi, hdmi->num_cvt); in hdac_hdmi_parse_and_map_nid()
1674 dev_err(&hdev->dev, "Failed to create dais with err: %d\n", in hdac_hdmi_parse_and_map_nid()
1679 *num_dais = hdmi->num_cvt; in hdac_hdmi_parse_and_map_nid()
1682 dev_err(&hdev->dev, "Failed to init DAI map with err: %d\n", in hdac_hdmi_parse_and_map_nid()
1689 return pin - 4; /* map NID 0x05 -> port #1 */ in hdac_hdmi_pin2port()
1695 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_eld_notify_cb() local
1698 struct snd_soc_component *component = hdmi->component; in hdac_hdmi_eld_notify_cb()
1704 dev_dbg(&hdev->dev, "%s: for pin:%d port=%d\n", __func__, in hdac_hdmi_eld_notify_cb()
1713 if (snd_power_get_state(component->card->snd_card) != in hdac_hdmi_eld_notify_cb()
1717 if (atomic_read(&hdev->in_pm)) in hdac_hdmi_eld_notify_cb()
1720 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_eld_notify_cb()
1721 if (pin->nid != pin_nid) in hdac_hdmi_eld_notify_cb()
1724 /* In case of non MST pin, pipe is -1 */ in hdac_hdmi_eld_notify_cb()
1725 if (pipe == -1) { in hdac_hdmi_eld_notify_cb()
1726 pin->mst_capable = false; in hdac_hdmi_eld_notify_cb()
1728 hport = &pin->ports[0]; in hdac_hdmi_eld_notify_cb()
1730 for (i = 0; i < pin->num_ports; i++) { in hdac_hdmi_eld_notify_cb()
1731 pin->mst_capable = true; in hdac_hdmi_eld_notify_cb()
1732 if (pin->ports[i].id == pipe) { in hdac_hdmi_eld_notify_cb()
1733 hport = &pin->ports[i]; in hdac_hdmi_eld_notify_cb()
1756 if (rtd->pcm && (rtd->pcm->device == device)) in hdac_hdmi_get_pcm_from_id()
1757 return rtd->pcm; in hdac_hdmi_get_pcm_from_id()
1772 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in create_fill_jack_kcontrols() local
1773 struct snd_soc_component *component = hdmi->component; in create_fill_jack_kcontrols()
1775 kc = devm_kcalloc(component->dev, hdmi->num_ports, in create_fill_jack_kcontrols()
1779 return -ENOMEM; in create_fill_jack_kcontrols()
1781 list_for_each_entry(pin, &hdmi->pin_list, head) { in create_fill_jack_kcontrols()
1782 for (j = 0; j < pin->num_ports; j++) { in create_fill_jack_kcontrols()
1783 snprintf(xname, sizeof(xname), "hif%d-%d Jack", in create_fill_jack_kcontrols()
1784 pin->nid, pin->ports[j].id); in create_fill_jack_kcontrols()
1785 name = devm_kstrdup(component->dev, xname, GFP_KERNEL); in create_fill_jack_kcontrols()
1787 return -ENOMEM; in create_fill_jack_kcontrols()
1789 kc[i].name = devm_kstrdup(component->dev, kc_name, in create_fill_jack_kcontrols()
1792 return -ENOMEM; in create_fill_jack_kcontrols()
1810 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_jack_port_init() local
1811 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_jack_port_init()
1818 widgets = devm_kcalloc(dapm->dev, hdmi->num_ports, in hdac_hdmi_jack_port_init()
1822 return -ENOMEM; in hdac_hdmi_jack_port_init()
1824 route = devm_kcalloc(dapm->dev, hdmi->num_ports, in hdac_hdmi_jack_port_init()
1827 return -ENOMEM; in hdac_hdmi_jack_port_init()
1830 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_jack_port_init()
1831 for (j = 0; j < pin->num_ports; j++) { in hdac_hdmi_jack_port_init()
1832 snprintf(w_name, sizeof(w_name), "hif%d-%d Jack", in hdac_hdmi_jack_port_init()
1833 pin->nid, pin->ports[j].id); in hdac_hdmi_jack_port_init()
1835 ret = hdac_hdmi_fill_widget_info(dapm->dev, &widgets[i], in hdac_hdmi_jack_port_init()
1841 pin->ports[j].jack_pin = widgets[i].name; in hdac_hdmi_jack_port_init()
1842 pin->ports[j].dapm = dapm; in hdac_hdmi_jack_port_init()
1845 hdac_hdmi_fill_route(&route[i], pin->ports[j].jack_pin, in hdac_hdmi_jack_port_init()
1846 NULL, pin->ports[j].output_pin, NULL); in hdac_hdmi_jack_port_init()
1853 ret = snd_soc_dapm_new_controls(dapm, widgets, hdmi->num_ports); in hdac_hdmi_jack_port_init()
1857 ret = snd_soc_dapm_add_routes(dapm, route, hdmi->num_ports); in hdac_hdmi_jack_port_init()
1861 ret = snd_soc_dapm_new_widgets(dapm->card); in hdac_hdmi_jack_port_init()
1866 ret = create_fill_jack_kcontrols(dapm->card, hdev); in hdac_hdmi_jack_port_init()
1872 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_jack_port_init()
1873 for (j = 0; j < pin->num_ports; j++) in hdac_hdmi_jack_port_init()
1874 snd_soc_dapm_disable_pin(pin->ports[j].dapm, in hdac_hdmi_jack_port_init()
1875 pin->ports[j].jack_pin); in hdac_hdmi_jack_port_init()
1885 struct snd_soc_component *component = dai->component; in hdac_hdmi_jack_init()
1886 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdac_hdmi_jack_init() local
1887 struct hdac_device *hdev = hdmi->hdev; in hdac_hdmi_jack_init()
1896 pcm = devm_kzalloc(&hdev->dev, sizeof(*pcm), GFP_KERNEL); in hdac_hdmi_jack_init()
1898 return -ENOMEM; in hdac_hdmi_jack_init()
1899 pcm->pcm_id = device; in hdac_hdmi_jack_init()
1900 pcm->cvt = hdmi->dai_map[dai->id].cvt; in hdac_hdmi_jack_init()
1901 pcm->jack_event = 0; in hdac_hdmi_jack_init()
1902 pcm->jack = jack; in hdac_hdmi_jack_init()
1903 mutex_init(&pcm->lock); in hdac_hdmi_jack_init()
1904 INIT_LIST_HEAD(&pcm->port_list); in hdac_hdmi_jack_init()
1905 snd_pcm = hdac_hdmi_get_pcm_from_id(dai->component->card, device); in hdac_hdmi_jack_init()
1907 err = snd_hdac_add_chmap_ctls(snd_pcm, device, &hdmi->chmap); in hdac_hdmi_jack_init()
1909 dev_err(&hdev->dev, in hdac_hdmi_jack_init()
1919 dev_err(&hdev->dev, in hdac_hdmi_jack_init()
1925 list_add_tail(&pcm->head, &hdmi->pcm_list); in hdac_hdmi_jack_init()
1932 struct hdac_hdmi_priv *hdmi, bool detect_pin_caps) in hdac_hdmi_present_sense_all_pins() argument
1937 list_for_each_entry(pin, &hdmi->pin_list, head) { in hdac_hdmi_present_sense_all_pins()
1940 if (hdac_hdmi_get_port_len(hdev, pin->nid) == 0) in hdac_hdmi_present_sense_all_pins()
1941 pin->mst_capable = false; in hdac_hdmi_present_sense_all_pins()
1943 pin->mst_capable = true; in hdac_hdmi_present_sense_all_pins()
1946 for (i = 0; i < pin->num_ports; i++) { in hdac_hdmi_present_sense_all_pins()
1947 if (!pin->mst_capable && i > 0) in hdac_hdmi_present_sense_all_pins()
1950 hdac_hdmi_present_sense(pin, &pin->ports[i]); in hdac_hdmi_present_sense_all_pins()
1957 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdmi_codec_probe() local
1958 struct hdac_device *hdev = hdmi->hdev; in hdmi_codec_probe()
1964 hdmi->component = component; in hdmi_codec_probe()
1970 hlink = snd_hdac_ext_bus_get_link(hdev->bus, dev_name(&hdev->dev)); in hdmi_codec_probe()
1972 dev_err(&hdev->dev, "hdac link not found\n"); in hdmi_codec_probe()
1973 return -EIO; in hdmi_codec_probe()
1976 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdmi_codec_probe()
1983 ret = snd_hdac_acomp_register_notifier(hdev->bus, &aops); in hdmi_codec_probe()
1985 dev_err(&hdev->dev, "notifier register failed: err: %d\n", ret); in hdmi_codec_probe()
1989 hdac_hdmi_present_sense_all_pins(hdev, hdmi, true); in hdmi_codec_probe()
1991 hdmi->card = dapm->card->snd_card; in hdmi_codec_probe()
1994 * Setup a device_link between card device and HDMI codec device. in hdmi_codec_probe()
1995 * The card device is the consumer and the HDMI codec device is in hdmi_codec_probe()
1998 * on the HDMI audio codec registers. in hdmi_codec_probe()
2002 device_link_add(component->card->dev, &hdev->dev, DL_FLAG_RPM_ACTIVE | in hdmi_codec_probe()
2008 pm_runtime_enable(&hdev->dev); in hdmi_codec_probe()
2009 pm_runtime_put(&hdev->dev); in hdmi_codec_probe()
2010 pm_runtime_suspend(&hdev->dev); in hdmi_codec_probe()
2017 struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); in hdmi_codec_remove() local
2018 struct hdac_device *hdev = hdmi->hdev; in hdmi_codec_remove()
2021 ret = snd_hdac_acomp_register_notifier(hdev->bus, NULL); in hdmi_codec_remove()
2023 dev_err(&hdev->dev, "notifier unregister failed: err: %d\n", in hdmi_codec_remove()
2026 pm_runtime_disable(&hdev->dev); in hdmi_codec_remove()
2033 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdmi_codec_resume() local
2047 * works even if the HD-audio side is still dreaming peacefully. in hdmi_codec_resume()
2049 hdac_hdmi_present_sense_all_pins(hdev, hdmi, false); in hdmi_codec_resume()
2066 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_get_chmap() local
2067 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in hdac_hdmi_get_chmap()
2069 memcpy(chmap, pcm->chmap, ARRAY_SIZE(pcm->chmap)); in hdac_hdmi_get_chmap()
2075 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_set_chmap() local
2076 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in hdac_hdmi_set_chmap()
2082 if (list_empty(&pcm->port_list)) in hdac_hdmi_set_chmap()
2085 mutex_lock(&pcm->lock); in hdac_hdmi_set_chmap()
2086 pcm->chmap_set = true; in hdac_hdmi_set_chmap()
2087 memcpy(pcm->chmap, chmap, ARRAY_SIZE(pcm->chmap)); in hdac_hdmi_set_chmap()
2088 list_for_each_entry(port, &pcm->port_list, head) in hdac_hdmi_set_chmap()
2091 mutex_unlock(&pcm->lock); in hdac_hdmi_set_chmap()
2096 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in is_hdac_hdmi_pcm_attached() local
2097 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in is_hdac_hdmi_pcm_attached()
2102 if (list_empty(&pcm->port_list)) in is_hdac_hdmi_pcm_attached()
2110 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in hdac_hdmi_get_spk_alloc() local
2111 struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); in hdac_hdmi_get_spk_alloc()
2117 if (list_empty(&pcm->port_list)) in hdac_hdmi_get_spk_alloc()
2120 port = list_first_entry(&pcm->port_list, struct hdac_hdmi_port, head); in hdac_hdmi_get_spk_alloc()
2122 if (!port || !port->eld.eld_valid) in hdac_hdmi_get_spk_alloc()
2125 return port->eld.info.spk_alloc; in hdac_hdmi_get_spk_alloc()
2143 struct hdac_driver *hdrv = drv_to_hdac_driver(hdev->dev.driver); in hdac_hdmi_dev_probe()
2147 hlink = snd_hdac_ext_bus_get_link(hdev->bus, dev_name(&hdev->dev)); in hdac_hdmi_dev_probe()
2149 dev_err(&hdev->dev, "hdac link not found\n"); in hdac_hdmi_dev_probe()
2150 return -EIO; in hdac_hdmi_dev_probe()
2153 snd_hdac_ext_bus_link_get(hdev->bus, hlink); in hdac_hdmi_dev_probe()
2155 hdmi_priv = devm_kzalloc(&hdev->dev, sizeof(*hdmi_priv), GFP_KERNEL); in hdac_hdmi_dev_probe()
2157 return -ENOMEM; in hdac_hdmi_dev_probe()
2159 snd_hdac_register_chmap_ops(hdev, &hdmi_priv->chmap); in hdac_hdmi_dev_probe()
2160 hdmi_priv->chmap.ops.get_chmap = hdac_hdmi_get_chmap; in hdac_hdmi_dev_probe()
2161 hdmi_priv->chmap.ops.set_chmap = hdac_hdmi_set_chmap; in hdac_hdmi_dev_probe()
2162 hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; in hdac_hdmi_dev_probe()
2163 hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; in hdac_hdmi_dev_probe()
2164 hdmi_priv->hdev = hdev; in hdac_hdmi_dev_probe()
2167 return -ENODEV; in hdac_hdmi_dev_probe()
2169 if (hdac_id->driver_data) in hdac_hdmi_dev_probe()
2170 hdmi_priv->drv_data = in hdac_hdmi_dev_probe()
2171 (struct hdac_hdmi_drv_data *)hdac_id->driver_data; in hdac_hdmi_dev_probe()
2173 hdmi_priv->drv_data = &intel_drv_data; in hdac_hdmi_dev_probe()
2175 dev_set_drvdata(&hdev->dev, hdmi_priv); in hdac_hdmi_dev_probe()
2177 INIT_LIST_HEAD(&hdmi_priv->pin_list); in hdac_hdmi_dev_probe()
2178 INIT_LIST_HEAD(&hdmi_priv->cvt_list); in hdac_hdmi_dev_probe()
2179 INIT_LIST_HEAD(&hdmi_priv->pcm_list); in hdac_hdmi_dev_probe()
2180 mutex_init(&hdmi_priv->pin_mutex); in hdac_hdmi_dev_probe()
2186 snd_hdac_display_power(hdev->bus, hdev->addr, true); in hdac_hdmi_dev_probe()
2190 dev_err(&hdev->dev, in hdac_hdmi_dev_probe()
2197 ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, in hdac_hdmi_dev_probe()
2200 snd_hdac_ext_bus_link_put(hdev->bus, hlink); in hdac_hdmi_dev_probe()
2207 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); in clear_dapm_works() local
2211 list_for_each_entry(pin, &hdmi->pin_list, head) in clear_dapm_works()
2212 for (i = 0; i < pin->num_ports; i++) in clear_dapm_works()
2213 cancel_work_sync(&pin->ports[i].dapm_work); in clear_dapm_works()
2219 snd_hdac_display_power(hdev->bus, hdev->addr, false); in hdac_hdmi_dev_remove()
2228 struct hdac_bus *bus = hdev->bus; in hdac_hdmi_runtime_suspend()
2244 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, in hdac_hdmi_runtime_suspend()
2250 return -EIO; in hdac_hdmi_runtime_suspend()
2256 snd_hdac_display_power(bus, hdev->addr, false); in hdac_hdmi_runtime_suspend()
2264 struct hdac_bus *bus = hdev->bus; in hdac_hdmi_runtime_resume()
2276 return -EIO; in hdac_hdmi_runtime_resume()
2282 snd_hdac_display_power(bus, hdev->addr, true); in hdac_hdmi_runtime_resume()
2288 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, in hdac_hdmi_runtime_resume()
2304 HDA_CODEC_EXT_ENTRY(0x80862809, 0x100000, "Skylake HDMI", 0),
2305 HDA_CODEC_EXT_ENTRY(0x8086280a, 0x100000, "Broxton HDMI", 0),
2306 HDA_CODEC_EXT_ENTRY(0x8086280b, 0x100000, "Kabylake HDMI", 0),
2307 HDA_CODEC_EXT_ENTRY(0x8086280c, 0x100000, "Cannonlake HDMI",
2309 HDA_CODEC_EXT_ENTRY(0x8086280d, 0x100000, "Geminilake HDMI",
2318 .name = "HDMI HDA Codec",
2340 MODULE_DESCRIPTION("HDMI HD codec");