Lines Matching full:codec

78 	struct hda_codec *codec;  member
99 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
102 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
107 int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid,
110 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
114 void (*pin_cvt_fixup)(struct hda_codec *codec,
132 struct hda_codec *codec; member
172 /* hdmi interrupt trigger control flag for Nvidia codec */
197 static inline bool codec_has_acomp(struct hda_codec *codec) in codec_has_acomp() argument
199 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
203 #define codec_has_acomp(codec) false argument
251 static int pin_id_to_pin_index(struct hda_codec *codec, in pin_id_to_pin_index() argument
254 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
272 codec_warn(codec, "HDMI: pin NID 0x%x not registered\n", pin_nid); in pin_id_to_pin_index()
276 static int hinfo_to_pcm_index(struct hda_codec *codec, in hinfo_to_pcm_index() argument
279 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
286 codec_warn(codec, "HDMI: hinfo %p not tied to a PCM\n", hinfo); in hinfo_to_pcm_index()
290 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
293 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
304 codec_dbg(codec, "HDMI: hinfo %p (pcm %d) not registered\n", hinfo, in hinfo_to_pin_index()
305 hinfo_to_pcm_index(codec, hinfo)); in hinfo_to_pin_index()
323 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
325 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
332 codec_warn(codec, "HDMI: cvt NID 0x%x not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
339 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
340 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
366 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
367 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
411 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pcm_idx, in hdmi_create_eld_ctl() argument
415 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
418 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
427 err = snd_hda_ctl_add(codec, 0, kctl); in hdmi_create_eld_ctl()
436 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
441 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
449 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
456 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
459 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
462 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
465 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
467 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
471 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
472 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
484 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
517 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
521 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
522 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
536 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
559 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
562 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
563 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
570 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
573 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
574 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
578 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
584 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
585 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
588 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
590 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
595 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
602 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
607 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
609 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
610 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
612 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
617 codec_dbg(codec, in hdmi_clear_dip_buffers()
638 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
644 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
645 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
647 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
649 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
652 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
658 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
659 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
664 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
673 static int hdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in hdmi_pin_get_eld() argument
676 snd_hda_set_dev_select(codec, nid, dev_id); in hdmi_pin_get_eld()
678 return snd_hdmi_get_eld(codec, nid, buf, eld_size); in hdmi_pin_get_eld()
681 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
686 struct hdmi_spec *spec = codec->spec; in hdmi_pin_setup_infoframe()
716 codec_dbg(codec, "HDMI: unknown connection type at pin NID 0x%x\n", pin_nid); in hdmi_pin_setup_infoframe()
720 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_setup_infoframe()
727 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
729 codec_dbg(codec, "%s: pin NID=0x%x channels=%d ca=0x%02x\n", in hdmi_pin_setup_infoframe()
731 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
732 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
734 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
738 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
742 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
754 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_setup_audio_infoframe()
757 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_setup_audio_infoframe()
758 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
764 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
770 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
781 spec->ops.pin_setup_infoframe(codec, pin_nid, dev_id, in hdmi_setup_audio_infoframe()
793 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, in check_presence_and_report() argument
796 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
797 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id); in check_presence_and_report()
806 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
810 if (codec_has_acomp(codec)) in jack_callback()
813 check_presence_and_report(codec, jack->nid, jack->dev_id); in jack_callback()
816 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res, in hdmi_intrinsic_event() argument
821 codec_dbg(codec, in hdmi_intrinsic_event()
822 "HDMI hot plug event: Codec=%d NID=0x%x Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_intrinsic_event()
823 codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
826 check_presence_and_report(codec, jack->nid, jack->dev_id); in hdmi_intrinsic_event()
829 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
836 codec_info(codec, in hdmi_non_intrinsic_event()
837 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", in hdmi_non_intrinsic_event()
838 codec->addr, in hdmi_non_intrinsic_event()
854 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
860 if (codec_has_acomp(codec)) in hdmi_unsol_event()
863 if (codec->dp_mst) { in hdmi_unsol_event()
867 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry); in hdmi_unsol_event()
869 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, 0); in hdmi_unsol_event()
873 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
878 hdmi_intrinsic_event(codec, res, jack); in hdmi_unsol_event()
880 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
883 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
891 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
892 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
894 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
895 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
898 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
900 codec_dbg(codec, "Haswell HDMI audio: Power for NID 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
912 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
917 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
918 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_hbr_setup()
919 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
931 codec_dbg(codec, in hdmi_pin_hbr_setup()
938 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
947 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
951 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
955 err = spec->ops.pin_hbr_setup(codec, pin_nid, dev_id, in hdmi_setup_stream()
959 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
970 param = snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_setup_stream()
979 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_setup_stream()
983 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
992 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
996 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
1008 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in hdmi_choose_cvt()
1050 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1057 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1060 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1088 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1092 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1122 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1134 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
1135 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1136 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1139 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1145 * connection list are in the same order as in the codec. in intel_not_share_assigned_cvt()
1150 codec_dbg(codec, in intel_not_share_assigned_cvt()
1153 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1159 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1164 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
1168 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1177 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
1181 static void pin_cvt_fixup(struct hda_codec *codec, in pin_cvt_fixup() argument
1185 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1188 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1193 struct hda_codec *codec, in hdmi_pcm_open_no_pin() argument
1196 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1202 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open_no_pin()
1206 err = hdmi_choose_cvt(codec, -1, &cvt_idx, false); in hdmi_pcm_open_no_pin()
1214 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1241 struct hda_codec *codec, in hdmi_pcm_open() argument
1244 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1253 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open()
1258 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1263 err = hdmi_pcm_open_no_pin(hinfo, codec, substream); in hdmi_pcm_open()
1267 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx, false); in hdmi_pcm_open()
1281 if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE) in hdmi_pcm_open()
1284 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1285 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1290 pin_cvt_fixup(codec, per_pin, 0); in hdmi_pcm_open()
1292 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1309 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_open()
1331 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1333 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1339 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1340 codec_warn(codec, in hdmi_read_pin_conn()
1342 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1346 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_read_pin_conn()
1353 conns = snd_hda_get_raw_connections(codec, pin_nid, in hdmi_read_pin_conn()
1427 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid);
1432 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin() local
1455 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1457 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1461 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1463 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1469 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in hdmi_pcm_setup_pin()
1476 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1485 static struct snd_jack *pin_idx_to_pcm_jack(struct hda_codec *codec, in pin_idx_to_pcm_jack() argument
1488 struct hdmi_spec *spec = codec->spec; in pin_idx_to_pcm_jack()
1500 static void update_eld(struct hda_codec *codec, in update_eld() argument
1506 struct hdmi_spec *spec = codec->spec; in update_eld()
1514 snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in update_eld()
1537 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1555 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1558 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1585 pin_cvt_fixup(codec, per_pin, 0); in update_eld()
1586 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1590 snd_ctl_notify(codec->card, in update_eld()
1605 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs() local
1606 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1608 struct device *dev = hda_codec_dev(codec); in hdmi_present_sense_via_verbs()
1627 ret = snd_hda_power_up_pm(codec); in hdmi_present_sense_via_verbs()
1631 present = snd_hda_jack_pin_sense(codec, pin_nid, dev_id); in hdmi_present_sense_via_verbs()
1640 codec_dbg(codec, in hdmi_present_sense_via_verbs()
1641 "HDMI status: Codec=%d NID=0x%x Presence_Detect=%d ELD_Valid=%d\n", in hdmi_present_sense_via_verbs()
1642 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1645 if (spec->ops.pin_get_eld(codec, pin_nid, dev_id, in hdmi_present_sense_via_verbs()
1650 update_eld(codec, per_pin, eld, repoll); in hdmi_present_sense_via_verbs()
1653 snd_hda_power_down_pm(codec); in hdmi_present_sense_via_verbs()
1661 static void silent_stream_enable_i915(struct hda_codec *codec, in silent_stream_enable_i915() argument
1666 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in silent_stream_enable_i915()
1672 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, in silent_stream_enable_i915()
1675 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format); in silent_stream_enable_i915()
1678 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in silent_stream_enable_i915()
1681 static void silent_stream_set_kae(struct hda_codec *codec, in silent_stream_set_kae() argument
1687 codec_dbg(codec, "HDMI: KAE %d cvt-NID=0x%x\n", enable, per_pin->cvt_nid); in silent_stream_set_kae()
1689 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, AC_VERB_GET_DIGI_CONVERT_1, 0); in silent_stream_set_kae()
1697 snd_hda_codec_write(codec, per_pin->cvt_nid, 0, AC_VERB_SET_DIGI_CONVERT_3, param); in silent_stream_set_kae()
1700 static void silent_stream_enable(struct hda_codec *codec, in silent_stream_enable() argument
1703 struct hdmi_spec *spec = codec->spec; in silent_stream_enable()
1713 err = snd_hda_power_up_pm(codec); in silent_stream_enable()
1715 codec_err(codec, in silent_stream_enable()
1716 "Failed to power up codec for silent stream enable ret=[%d]\n", err); in silent_stream_enable()
1717 snd_hda_power_down_pm(codec); in silent_stream_enable()
1724 codec_dbg(codec, "hdmi: PCM already open, no silent stream\n"); in silent_stream_enable()
1729 pin_idx = pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1730 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx, true); in silent_stream_enable()
1732 codec_err(codec, "hdmi: no free converter to enable silent mode\n"); in silent_stream_enable()
1741 codec_dbg(codec, "hdmi: enabling silent stream pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_enable()
1744 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1745 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in silent_stream_enable()
1750 pin_cvt_fixup(codec, per_pin, 0); in silent_stream_enable()
1754 silent_stream_enable_i915(codec, per_pin); in silent_stream_enable()
1755 silent_stream_set_kae(codec, per_pin, true); in silent_stream_enable()
1758 silent_stream_enable_i915(codec, per_pin); in silent_stream_enable()
1769 snd_hda_power_down_pm(codec); in silent_stream_enable()
1772 static void silent_stream_disable(struct hda_codec *codec, in silent_stream_disable() argument
1775 struct hdmi_spec *spec = codec->spec; in silent_stream_disable()
1779 err = snd_hda_power_up_pm(codec); in silent_stream_disable()
1781 codec_err(codec, in silent_stream_disable()
1782 "Failed to power up codec for silent stream disable ret=[%d]\n", in silent_stream_disable()
1784 snd_hda_power_down_pm(codec); in silent_stream_disable()
1792 codec_dbg(codec, "HDMI: disable silent stream on pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_disable()
1795 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in silent_stream_disable()
1803 snd_hda_power_down_pm(codec); in silent_stream_disable()
1805 silent_stream_set_kae(codec, per_pin, false); in silent_stream_disable()
1814 snd_hda_power_down_pm(codec); in silent_stream_disable()
1818 static void sync_eld_via_acomp(struct hda_codec *codec, in sync_eld_via_acomp() argument
1821 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1828 eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1832 update_eld(codec, per_pin, eld, 0); in sync_eld_via_acomp()
1838 silent_stream_enable(codec, per_pin); in sync_eld_via_acomp()
1840 silent_stream_disable(codec, per_pin); in sync_eld_via_acomp()
1846 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1848 if (!codec_has_acomp(codec)) in hdmi_present_sense()
1851 sync_eld_via_acomp(codec, per_pin); in hdmi_present_sense()
1858 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld() local
1859 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1862 jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid, in hdmi_repoll_eld()
1875 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1877 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1884 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1892 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1909 } else if (codec->dp_mst) { in hdmi_add_pin()
1910 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; in hdmi_add_pin()
1941 snd_hda_set_dev_select(codec, pin_nid, i); in hdmi_add_pin()
1942 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1945 if (!is_jack_detectable(codec, pin_nid)) in hdmi_add_pin()
1946 codec_warn(codec, "HDMI: pin NID 0x%x - jack not detectable\n", pin_nid); in hdmi_add_pin()
1954 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1956 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1961 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1976 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
2006 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
2008 struct hdmi_spec *spec = codec->spec; in hdmi_parse_codec()
2014 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); in hdmi_parse_codec()
2016 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
2023 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); in hdmi_parse_codec()
2035 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2041 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
2048 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2054 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
2062 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
2067 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2068 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
2073 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2077 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2086 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
2092 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
2101 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
2106 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2107 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
2122 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
2126 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
2127 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2130 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2135 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) { in generic_hdmi_playback_pcm_prepare()
2136 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
2138 snd_hda_codec_write(codec, cvt_nid, 0, in generic_hdmi_playback_pcm_prepare()
2143 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
2146 snd_hda_set_dev_select(codec, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2148 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2150 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2156 err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2164 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
2167 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
2172 struct hda_codec *codec, in hdmi_pcm_close() argument
2175 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
2184 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
2189 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
2200 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
2202 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
2213 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_close()
2215 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2217 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2246 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_spk_alloc() local
2247 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2259 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_chmap() local
2260 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2273 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_set_chmap() local
2274 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2283 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2289 struct hda_codec *codec = hdac_to_hda_codec(hdac); in is_hdmi_pcm_attached() local
2290 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2296 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2298 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2301 /* limit the PCM devices to the codec converters or available PINs */ in generic_hdmi_build_pcms()
2303 codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); in generic_hdmi_build_pcms()
2310 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2343 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2346 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2354 err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack, in generic_hdmi_build_jack()
2365 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2367 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2378 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2385 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2390 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2395 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); in generic_hdmi_build_controls()
2429 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2431 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2437 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2445 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2447 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2456 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2457 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2458 if (codec_has_acomp(codec)) in generic_hdmi_init()
2460 snd_hda_jack_detect_enable_callback_mst(codec, pin_nid, dev_id, in generic_hdmi_init()
2479 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2481 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2486 codec->spec = NULL; in generic_spec_free()
2488 codec->dp_mst = false; in generic_spec_free()
2491 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2493 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2497 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2498 } else if (codec_has_acomp(codec)) { in generic_hdmi_free()
2499 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2501 codec->relaxed_resume = 0; in generic_hdmi_free()
2512 snd_device_free(codec->card, spec->pcm_rec[pcm_idx].jack); in generic_hdmi_free()
2515 generic_spec_free(codec); in generic_hdmi_free()
2518 static int generic_hdmi_suspend(struct hda_codec *codec) in generic_hdmi_suspend() argument
2520 struct hdmi_spec *spec = codec->spec; in generic_hdmi_suspend()
2530 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2532 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2535 codec->patch_ops.init(codec); in generic_hdmi_resume()
2536 snd_hda_regmap_sync(codec); in generic_hdmi_resume()
2562 /* allocate codec->spec and assign/initialize generic parser ops */
2563 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2571 spec->codec = codec; in alloc_generic_hdmi()
2576 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2583 codec->spec = spec; in alloc_generic_hdmi()
2586 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2592 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2596 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2600 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2602 generic_spec_free(codec); in patch_generic_hdmi()
2606 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2615 static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid, in reprogram_jack_detect() argument
2620 tbl = snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in reprogram_jack_detect()
2626 snd_hda_codec_write_cache(codec, nid, 0, in reprogram_jack_detect()
2641 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2642 spec->codec->bus->keep_power = 0; in generic_acomp_notifier_set()
2645 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2682 struct hda_codec *codec = audio_ptr; in generic_acomp_pin_eld_notify() local
2683 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2684 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2688 if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN) in generic_acomp_pin_eld_notify()
2693 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in generic_acomp_pin_eld_notify()
2696 check_presence_and_report(codec, pin_nid, dev_id); in generic_acomp_pin_eld_notify()
2700 static void setup_drm_audio_ops(struct hda_codec *codec, in setup_drm_audio_ops() argument
2703 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2705 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2718 static void generic_acomp_init(struct hda_codec *codec, in generic_acomp_init() argument
2722 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2725 codec_info(codec, "audio component disabled by module option\n"); in generic_acomp_init()
2730 setup_drm_audio_ops(codec, ops); in generic_acomp_init()
2731 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2738 * Intel codec parsers and helpers
2746 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2750 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2752 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2758 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2764 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2767 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2770 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2772 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2779 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2780 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2787 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2791 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2792 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2795 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2796 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2810 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2812 switch (codec->core.vendor_id) { in intel_base_nid()
2824 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
2825 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2829 base_nid = intel_base_nid(codec); in intel_pin2port()
2844 codec_info(codec, "Can't find the HDMI/DP port for pin NID 0x%x\n", pin_nid); in intel_pin2port()
2848 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
2850 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2856 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2866 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2870 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
2876 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in intel_pin_eld_notify()
2879 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2880 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2889 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2891 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2895 setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
2896 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2899 codec->relaxed_resume = 1; in register_i915_notifier()
2903 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2907 struct hdmi_spec *spec = codec->spec; in i915_hsw_setup_stream()
2908 int pin_idx = pin_id_to_pin_index(codec, pin_nid, dev_id); in i915_hsw_setup_stream()
2917 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2920 silent_stream_set_kae(codec, per_pin, false); in i915_hsw_setup_stream()
2921 /* wait for pending transfers in codec to clear */ in i915_hsw_setup_stream()
2925 res = hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in i915_hsw_setup_stream()
2930 silent_stream_set_kae(codec, per_pin, true); in i915_hsw_setup_stream()
2937 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2942 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
2943 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2945 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2946 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2949 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2953 static int i915_adlp_hdmi_suspend(struct hda_codec *codec) in i915_adlp_hdmi_suspend() argument
2955 struct hdmi_spec *spec = codec->spec; in i915_adlp_hdmi_suspend()
2959 res = generic_hdmi_suspend(codec); in i915_adlp_hdmi_suspend()
2972 * stream-id should remain programmed when codec goes in i915_adlp_hdmi_suspend()
2975 codec->no_stream_clean_at_suspend = 1; in i915_adlp_hdmi_suspend()
2981 codec->forced_resume = 1; in i915_adlp_hdmi_suspend()
2983 codec_dbg(codec, "HDMI: KAE active at suspend\n"); in i915_adlp_hdmi_suspend()
2985 codec->no_stream_clean_at_suspend = 0; in i915_adlp_hdmi_suspend()
2986 codec->forced_resume = 0; in i915_adlp_hdmi_suspend()
2992 static int i915_adlp_hdmi_resume(struct hda_codec *codec) in i915_adlp_hdmi_resume() argument
2994 struct hdmi_spec *spec = codec->spec; in i915_adlp_hdmi_resume()
2997 res = generic_hdmi_resume(codec); in i915_adlp_hdmi_resume()
3000 if (!codec->no_stream_clean_at_suspend) in i915_adlp_hdmi_resume()
3008 * the codec setting may have been lost. Re-enable in i915_adlp_hdmi_resume()
3014 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, in i915_adlp_hdmi_resume()
3017 codec_dbg(codec, "HDMI: KAE: restore stream id\n"); in i915_adlp_hdmi_resume()
3018 silent_stream_enable_i915(codec, per_pin); in i915_adlp_hdmi_resume()
3021 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, in i915_adlp_hdmi_resume()
3024 codec_dbg(codec, "HDMI: KAE: restore DIG3_KAE\n"); in i915_adlp_hdmi_resume()
3025 silent_stream_set_kae(codec, per_pin, true); in i915_adlp_hdmi_resume()
3034 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
3039 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
3040 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
3042 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
3046 err = alloc_generic_hdmi(codec); in alloc_intel_hdmi()
3050 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
3055 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
3060 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
3064 generic_spec_free(codec); in parse_intel_hdmi()
3068 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
3069 register_i915_notifier(codec); in parse_intel_hdmi()
3074 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
3081 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
3084 spec = codec->spec; in intel_hsw_common_init()
3085 codec->dp_mst = true; in intel_hsw_common_init()
3092 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
3093 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
3095 codec->display_power_control = 1; in intel_hsw_common_init()
3097 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
3098 codec->depop_delay = 0; in intel_hsw_common_init()
3099 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
3111 return parse_intel_hdmi(codec); in intel_hsw_common_init()
3114 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
3116 return intel_hsw_common_init(codec, 0x08, NULL, 0, 3, in patch_i915_hsw_hdmi()
3120 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
3127 return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3, false); in patch_i915_glk_hdmi()
3130 static int patch_i915_icl_hdmi(struct hda_codec *codec) in patch_i915_icl_hdmi() argument
3138 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3, in patch_i915_icl_hdmi()
3142 static int patch_i915_tgl_hdmi(struct hda_codec *codec) in patch_i915_tgl_hdmi() argument
3150 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4, in patch_i915_tgl_hdmi()
3154 static int patch_i915_adlp_hdmi(struct hda_codec *codec) in patch_i915_adlp_hdmi() argument
3159 res = patch_i915_tgl_hdmi(codec); in patch_i915_adlp_hdmi()
3161 spec = codec->spec; in patch_i915_adlp_hdmi()
3166 codec->patch_ops.resume = i915_adlp_hdmi_resume; in patch_i915_adlp_hdmi()
3167 codec->patch_ops.suspend = i915_adlp_hdmi_suspend; in patch_i915_adlp_hdmi()
3175 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
3180 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
3183 spec = codec->spec; in patch_i915_byt_hdmi()
3185 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
3188 codec->display_power_control = 1; in patch_i915_byt_hdmi()
3190 codec->depop_delay = 0; in patch_i915_byt_hdmi()
3191 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
3195 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
3199 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
3203 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3206 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3213 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
3215 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
3222 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
3225 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
3240 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
3243 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
3244 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
3252 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
3254 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
3259 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
3264 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
3267 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
3269 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
3273 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
3276 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
3277 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
3279 snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id); in simple_playback_init()
3283 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
3285 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3344 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
3346 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
3350 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
3352 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
3377 struct hda_codec *codec, in simple_playback_pcm_open() argument
3380 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3383 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3406 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3410 struct hda_codec *codec, in simple_playback_pcm_close() argument
3413 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3414 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3418 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
3423 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3424 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3447 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
3458 spec->codec = codec; in patch_simple_hdmi()
3459 codec->spec = spec; in patch_simple_hdmi()
3470 simple_playback_free(codec); in patch_simple_hdmi()
3477 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3482 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
3507 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3510 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3516 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
3519 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3522 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
3526 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3529 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3535 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3537 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3541 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3549 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3553 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3555 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3562 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3563 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3570 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3574 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3579 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3580 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3585 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3600 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3602 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3608 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3614 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3621 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3623 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3628 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3635 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3637 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3656 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3659 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3664 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3665 /* override the PCM rates, etc, as the codec doesn't give full list */ in patch_nvhdmi_2ch()
3666 spec = codec->spec; in patch_nvhdmi_2ch()
3674 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3676 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3677 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3685 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3687 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3692 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3703 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3716 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3719 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3722 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3725 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3726 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3727 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3731 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3772 static int nvhdmi_port2pin(struct hda_codec *codec, int port) in nvhdmi_port2pin() argument
3784 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3789 err = alloc_generic_hdmi(codec); in patch_nvhdmi()
3792 codec->dp_mst = true; in patch_nvhdmi()
3794 spec = codec->spec; in patch_nvhdmi()
3796 err = hdmi_parse_codec(codec); in patch_nvhdmi()
3798 generic_spec_free(codec); in patch_nvhdmi()
3802 generic_hdmi_init_per_pins(codec); in patch_nvhdmi()
3811 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3813 generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin); in patch_nvhdmi()
3818 static int patch_nvhdmi_legacy(struct hda_codec *codec) in patch_nvhdmi_legacy() argument
3823 err = patch_generic_hdmi(codec); in patch_nvhdmi_legacy()
3827 spec = codec->spec; in patch_nvhdmi_legacy()
3835 codec->link_down_at_suspend = 1; in patch_nvhdmi_legacy()
3841 * The HDA codec on NVIDIA Tegra contains two scratch registers that are
3850 * The SCRATCH0 register is used to notify the HDMI codec of changes in audio
3852 * be raised in the HDMI codec. The remainder of the bits is arbitrary. This
3883 * the format is invalidated so that the HDMI codec can be disabled.
3885 static void tegra_hdmi_set_format(struct hda_codec *codec, in tegra_hdmi_set_format() argument
3891 struct hdmi_spec *spec = codec->spec; in tegra_hdmi_set_format()
3894 * Tegra HDA codec design from TEGRA234 chip onwards support DP MST. in tegra_hdmi_set_format()
3897 * scratch register read/write for DP MST supported Tegra HDA codec. in tegra_hdmi_set_format()
3899 if (codec->dp_mst) in tegra_hdmi_set_format()
3903 value = snd_hda_codec_read(codec, nid, 0, in tegra_hdmi_set_format()
3908 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3911 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3916 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3930 * For Tegra HDA Codec design from TEGRA234 onwards, the in tegra_hdmi_set_format()
3935 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3937 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3942 * in the HDMI codec. The HDMI driver will use that as trigger in tegra_hdmi_set_format()
3947 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3953 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3960 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3965 /* notify the HDMI codec of the format change */ in tegra_hdmi_pcm_prepare()
3966 tegra_hdmi_set_format(codec, hinfo->nid, format); in tegra_hdmi_pcm_prepare()
3972 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3975 /* invalidate the format in the HDMI codec */ in tegra_hdmi_pcm_cleanup()
3976 tegra_hdmi_set_format(codec, hinfo->nid, 0); in tegra_hdmi_pcm_cleanup()
3978 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3981 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3983 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3996 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
4002 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
4006 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
4012 * codec about format changes. in tegra_hdmi_build_pcms()
4021 static int tegra_hdmi_init(struct hda_codec *codec) in tegra_hdmi_init() argument
4023 struct hdmi_spec *spec = codec->spec; in tegra_hdmi_init()
4026 err = hdmi_parse_codec(codec); in tegra_hdmi_init()
4028 generic_spec_free(codec); in tegra_hdmi_init()
4033 snd_hda_codec_write(codec, spec->cvt_nids[i], 0, in tegra_hdmi_init()
4037 generic_hdmi_init_per_pins(codec); in tegra_hdmi_init()
4039 codec->depop_delay = 10; in tegra_hdmi_init()
4040 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in tegra_hdmi_init()
4053 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
4057 err = alloc_generic_hdmi(codec); in patch_tegra_hdmi()
4061 return tegra_hdmi_init(codec); in patch_tegra_hdmi()
4064 static int patch_tegra234_hdmi(struct hda_codec *codec) in patch_tegra234_hdmi() argument
4069 err = alloc_generic_hdmi(codec); in patch_tegra234_hdmi()
4073 codec->dp_mst = true; in patch_tegra234_hdmi()
4074 spec = codec->spec; in patch_tegra234_hdmi()
4078 return tegra_hdmi_init(codec); in patch_tegra234_hdmi()
4085 #define is_amdhdmi_rev3_or_later(codec) \ argument
4086 ((codec)->core.vendor_id == 0x1002aa01 && \
4087 ((codec)->core.revision_id & 0xff00) >= 0x0300)
4088 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
4128 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
4133 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
4134 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
4137 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, in atihdmi_pin_setup_infoframe() argument
4142 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
4213 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_set_slot_channel() local
4220 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
4243 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
4249 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_get_slot_channel() local
4258 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
4268 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
4331 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
4338 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
4345 codec_dbg(codec, in atihdmi_pin_hbr_setup()
4352 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
4362 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
4366 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
4372 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
4375 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in atihdmi_setup_stream()
4380 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
4382 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
4385 err = generic_hdmi_init(codec); in atihdmi_init()
4394 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
4397 if (has_amd_full_remap_support(codec)) in atihdmi_init()
4398 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
4402 codec->auto_runtime_pm = 1; in atihdmi_init()
4415 static int atihdmi_port2pin(struct hda_codec *codec, int port) in atihdmi_port2pin() argument
4427 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
4433 err = patch_generic_hdmi(codec); in patch_atihdmi()
4438 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4440 spec = codec->spec; in patch_atihdmi()
4452 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
4475 codec->link_down_at_suspend = 1; in patch_atihdmi()
4477 generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin); in patch_atihdmi()
4486 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
4488 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()
4491 static int patch_gf_hdmi(struct hda_codec *codec) in patch_gf_hdmi() argument
4495 err = patch_generic_hdmi(codec); in patch_gf_hdmi()
4500 * Glenfly GPUs have two codecs, stream switches from one codec to in patch_gf_hdmi()
4503 codec->no_sticky_stream = 1; in patch_gf_hdmi()
4654 MODULE_DESCRIPTION("HDMI HD-audio codec");
4655 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4656 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4657 MODULE_ALIAS("snd-hda-codec-atihdmi");