Lines Matching full:codec
78 struct hda_codec *codec; member
98 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
101 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
106 int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid,
109 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
113 void (*pin_cvt_fixup)(struct hda_codec *codec,
131 struct hda_codec *codec; member
170 /* hdmi interrupt trigger control flag for Nvidia codec */
195 static inline bool codec_has_acomp(struct hda_codec *codec) in codec_has_acomp() argument
197 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
201 #define codec_has_acomp(codec) false argument
249 static int pin_id_to_pin_index(struct hda_codec *codec, in pin_id_to_pin_index() argument
252 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
270 codec_warn(codec, "HDMI: pin NID 0x%x not registered\n", pin_nid); in pin_id_to_pin_index()
274 static int hinfo_to_pcm_index(struct hda_codec *codec, in hinfo_to_pcm_index() argument
277 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
284 codec_warn(codec, "HDMI: hinfo %p not tied to a PCM\n", hinfo); in hinfo_to_pcm_index()
288 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
291 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
302 codec_dbg(codec, "HDMI: hinfo %p (pcm %d) not registered\n", hinfo, in hinfo_to_pin_index()
303 hinfo_to_pcm_index(codec, hinfo)); in hinfo_to_pin_index()
321 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
323 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
330 codec_warn(codec, "HDMI: cvt NID 0x%x not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
337 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
338 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
364 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
365 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
409 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pcm_idx, in hdmi_create_eld_ctl() argument
413 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
416 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
425 err = snd_hda_ctl_add(codec, 0, kctl); in hdmi_create_eld_ctl()
434 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
439 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
447 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
454 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
457 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
460 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
463 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
465 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
469 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
470 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
482 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
515 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
519 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
520 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
534 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
557 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
560 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
561 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
568 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
571 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
572 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
576 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
582 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
583 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
586 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
588 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
593 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
600 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
605 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
607 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
608 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
610 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
615 codec_dbg(codec, in hdmi_clear_dip_buffers()
636 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
642 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
643 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
645 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
647 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
650 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
656 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
657 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
662 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
671 static int hdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in hdmi_pin_get_eld() argument
674 snd_hda_set_dev_select(codec, nid, dev_id); in hdmi_pin_get_eld()
676 return snd_hdmi_get_eld(codec, nid, buf, eld_size); in hdmi_pin_get_eld()
679 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
684 struct hdmi_spec *spec = codec->spec; in hdmi_pin_setup_infoframe()
714 codec_dbg(codec, "HDMI: unknown connection type at pin NID 0x%x\n", pin_nid); in hdmi_pin_setup_infoframe()
718 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_setup_infoframe()
725 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
727 codec_dbg(codec, "%s: pin NID=0x%x channels=%d ca=0x%02x\n", in hdmi_pin_setup_infoframe()
729 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
730 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
732 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
736 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
740 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
752 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_setup_audio_infoframe()
755 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_setup_audio_infoframe()
756 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
762 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
768 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
779 spec->ops.pin_setup_infoframe(codec, pin_nid, dev_id, in hdmi_setup_audio_infoframe()
791 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, in check_presence_and_report() argument
794 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
795 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id); in check_presence_and_report()
804 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
808 if (codec_has_acomp(codec)) in jack_callback()
811 check_presence_and_report(codec, jack->nid, jack->dev_id); in jack_callback()
814 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res, in hdmi_intrinsic_event() argument
819 codec_dbg(codec, in hdmi_intrinsic_event()
820 "HDMI hot plug event: Codec=%d NID=0x%x Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_intrinsic_event()
821 codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
824 check_presence_and_report(codec, jack->nid, jack->dev_id); in hdmi_intrinsic_event()
827 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
834 codec_info(codec, in hdmi_non_intrinsic_event()
835 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", in hdmi_non_intrinsic_event()
836 codec->addr, in hdmi_non_intrinsic_event()
852 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
858 if (codec_has_acomp(codec)) in hdmi_unsol_event()
861 if (codec->dp_mst) { in hdmi_unsol_event()
865 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry); in hdmi_unsol_event()
867 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, 0); in hdmi_unsol_event()
871 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
876 hdmi_intrinsic_event(codec, res, jack); in hdmi_unsol_event()
878 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
881 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
889 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
890 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
892 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
893 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
896 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
898 codec_dbg(codec, "Haswell HDMI audio: Power for NID 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
910 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
915 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
916 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_hbr_setup()
917 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
929 codec_dbg(codec, in hdmi_pin_hbr_setup()
936 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
945 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
949 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
953 err = spec->ops.pin_hbr_setup(codec, pin_nid, dev_id, in hdmi_setup_stream()
957 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
968 param = snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_setup_stream()
977 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_setup_stream()
981 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
990 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
994 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
1006 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in hdmi_choose_cvt()
1048 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1055 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1058 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1086 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1090 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1120 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1132 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
1133 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1134 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1137 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1143 * connection list are in the same order as in the codec. in intel_not_share_assigned_cvt()
1148 codec_dbg(codec, in intel_not_share_assigned_cvt()
1151 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1157 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1162 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
1166 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1175 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
1179 static void pin_cvt_fixup(struct hda_codec *codec, in pin_cvt_fixup() argument
1183 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1186 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1191 struct hda_codec *codec, in hdmi_pcm_open_no_pin() argument
1194 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1200 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open_no_pin()
1204 err = hdmi_choose_cvt(codec, -1, &cvt_idx, false); in hdmi_pcm_open_no_pin()
1212 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1239 struct hda_codec *codec, in hdmi_pcm_open() argument
1242 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1251 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open()
1256 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1261 err = hdmi_pcm_open_no_pin(hinfo, codec, substream); in hdmi_pcm_open()
1265 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx, false); in hdmi_pcm_open()
1279 if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE) in hdmi_pcm_open()
1282 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1283 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1288 pin_cvt_fixup(codec, per_pin, 0); in hdmi_pcm_open()
1290 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1307 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_open()
1329 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1331 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1337 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1338 codec_warn(codec, in hdmi_read_pin_conn()
1340 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1344 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_read_pin_conn()
1351 conns = snd_hda_get_raw_connections(codec, pin_nid, in hdmi_read_pin_conn()
1416 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid);
1421 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin() local
1444 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1446 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1450 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1452 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1458 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in hdmi_pcm_setup_pin()
1465 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1474 static struct snd_jack *pin_idx_to_pcm_jack(struct hda_codec *codec, in pin_idx_to_pcm_jack() argument
1477 struct hdmi_spec *spec = codec->spec; in pin_idx_to_pcm_jack()
1489 static void update_eld(struct hda_codec *codec, in update_eld() argument
1495 struct hdmi_spec *spec = codec->spec; in update_eld()
1503 snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in update_eld()
1526 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1541 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1544 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1571 pin_cvt_fixup(codec, per_pin, 0); in update_eld()
1572 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1576 snd_ctl_notify(codec->card, in update_eld()
1591 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs() local
1592 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1594 struct device *dev = hda_codec_dev(codec); in hdmi_present_sense_via_verbs()
1613 ret = snd_hda_power_up_pm(codec); in hdmi_present_sense_via_verbs()
1617 present = snd_hda_jack_pin_sense(codec, pin_nid, dev_id); in hdmi_present_sense_via_verbs()
1626 codec_dbg(codec, in hdmi_present_sense_via_verbs()
1627 "HDMI status: Codec=%d NID=0x%x Presence_Detect=%d ELD_Valid=%d\n", in hdmi_present_sense_via_verbs()
1628 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1631 if (spec->ops.pin_get_eld(codec, pin_nid, dev_id, in hdmi_present_sense_via_verbs()
1636 update_eld(codec, per_pin, eld, repoll); in hdmi_present_sense_via_verbs()
1639 snd_hda_power_down_pm(codec); in hdmi_present_sense_via_verbs()
1648 static void silent_stream_enable_i915(struct hda_codec *codec, in silent_stream_enable_i915() argument
1653 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in silent_stream_enable_i915()
1659 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, in silent_stream_enable_i915()
1662 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format); in silent_stream_enable_i915()
1665 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in silent_stream_enable_i915()
1668 static void silent_stream_set_kae(struct hda_codec *codec, in silent_stream_set_kae() argument
1674 codec_dbg(codec, "HDMI: KAE %d cvt-NID=0x%x\n", enable, per_pin->cvt_nid); in silent_stream_set_kae()
1676 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, AC_VERB_GET_DIGI_CONVERT_1, 0); in silent_stream_set_kae()
1684 snd_hda_codec_write(codec, per_pin->cvt_nid, 0, AC_VERB_SET_DIGI_CONVERT_3, param); in silent_stream_set_kae()
1687 static void silent_stream_enable(struct hda_codec *codec, in silent_stream_enable() argument
1690 struct hdmi_spec *spec = codec->spec; in silent_stream_enable()
1700 err = snd_hda_power_up_pm(codec); in silent_stream_enable()
1702 codec_err(codec, in silent_stream_enable()
1703 "Failed to power up codec for silent stream enable ret=[%d]\n", err); in silent_stream_enable()
1704 snd_hda_power_down_pm(codec); in silent_stream_enable()
1711 codec_dbg(codec, "hdmi: PCM already open, no silent stream\n"); in silent_stream_enable()
1716 pin_idx = pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1717 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx, true); in silent_stream_enable()
1719 codec_err(codec, "hdmi: no free converter to enable silent mode\n"); in silent_stream_enable()
1728 codec_dbg(codec, "hdmi: enabling silent stream pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_enable()
1731 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1732 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in silent_stream_enable()
1737 pin_cvt_fixup(codec, per_pin, 0); in silent_stream_enable()
1741 silent_stream_set_kae(codec, per_pin, true); in silent_stream_enable()
1744 silent_stream_enable_i915(codec, per_pin); in silent_stream_enable()
1755 snd_hda_power_down_pm(codec); in silent_stream_enable()
1758 static void silent_stream_disable(struct hda_codec *codec, in silent_stream_disable() argument
1761 struct hdmi_spec *spec = codec->spec; in silent_stream_disable()
1765 err = snd_hda_power_up_pm(codec); in silent_stream_disable()
1767 codec_err(codec, in silent_stream_disable()
1768 "Failed to power up codec for silent stream disable ret=[%d]\n", in silent_stream_disable()
1770 snd_hda_power_down_pm(codec); in silent_stream_disable()
1778 codec_dbg(codec, "HDMI: disable silent stream on pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_disable()
1781 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in silent_stream_disable()
1789 snd_hda_power_down_pm(codec); in silent_stream_disable()
1791 silent_stream_set_kae(codec, per_pin, false); in silent_stream_disable()
1800 snd_hda_power_down_pm(codec); in silent_stream_disable()
1804 static void sync_eld_via_acomp(struct hda_codec *codec, in sync_eld_via_acomp() argument
1807 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1814 eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1818 update_eld(codec, per_pin, eld, 0); in sync_eld_via_acomp()
1824 silent_stream_enable(codec, per_pin); in sync_eld_via_acomp()
1826 silent_stream_disable(codec, per_pin); in sync_eld_via_acomp()
1832 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1834 if (!codec_has_acomp(codec)) in hdmi_present_sense()
1837 sync_eld_via_acomp(codec, per_pin); in hdmi_present_sense()
1844 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld() local
1845 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1848 jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid, in hdmi_repoll_eld()
1861 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1863 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1870 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1878 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1895 } else if (codec->dp_mst) { in hdmi_add_pin()
1896 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; in hdmi_add_pin()
1926 snd_hda_set_dev_select(codec, pin_nid, i); in hdmi_add_pin()
1927 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1930 if (!is_jack_detectable(codec, pin_nid)) in hdmi_add_pin()
1931 codec_warn(codec, "HDMI: pin NID 0x%x - jack not detectable\n", pin_nid); in hdmi_add_pin()
1939 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1941 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1946 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1961 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
1983 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1985 struct hdmi_spec *spec = codec->spec; in hdmi_parse_codec()
1991 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); in hdmi_parse_codec()
1993 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
2000 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); in hdmi_parse_codec()
2012 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2018 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
2025 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2031 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
2039 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
2044 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2045 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
2050 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2054 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2063 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
2069 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
2078 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
2083 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2084 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
2103 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
2107 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
2108 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2111 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2116 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) { in generic_hdmi_playback_pcm_prepare()
2117 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
2119 snd_hda_codec_write(codec, cvt_nid, 0, in generic_hdmi_playback_pcm_prepare()
2124 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
2127 snd_hda_set_dev_select(codec, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2129 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2131 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2137 err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2145 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
2148 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
2153 struct hda_codec *codec, in hdmi_pcm_close() argument
2156 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
2165 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
2170 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
2181 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
2183 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
2194 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_close()
2196 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2198 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2227 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_spk_alloc() local
2228 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2240 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_chmap() local
2241 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2254 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_set_chmap() local
2255 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2264 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2270 struct hda_codec *codec = hdac_to_hda_codec(hdac); in is_hdmi_pcm_attached() local
2271 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2277 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2279 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2282 /* limit the PCM devices to the codec converters */ in generic_hdmi_build_pcms()
2284 codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); in generic_hdmi_build_pcms()
2290 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2318 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2321 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2329 err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack, in generic_hdmi_build_jack()
2340 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2342 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2353 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2360 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2365 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2370 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); in generic_hdmi_build_controls()
2399 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2401 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2407 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2415 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2417 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2426 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2427 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2428 if (codec_has_acomp(codec)) in generic_hdmi_init()
2430 snd_hda_jack_detect_enable_callback_mst(codec, pin_nid, dev_id, in generic_hdmi_init()
2449 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2451 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2456 codec->spec = NULL; in generic_spec_free()
2458 codec->dp_mst = false; in generic_spec_free()
2461 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2463 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2467 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2468 } else if (codec_has_acomp(codec)) { in generic_hdmi_free()
2469 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2471 codec->relaxed_resume = 0; in generic_hdmi_free()
2482 snd_device_free(codec->card, spec->pcm_rec[pcm_idx].jack); in generic_hdmi_free()
2485 generic_spec_free(codec); in generic_hdmi_free()
2489 static int generic_hdmi_suspend(struct hda_codec *codec) in generic_hdmi_suspend() argument
2491 struct hdmi_spec *spec = codec->spec; in generic_hdmi_suspend()
2501 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2503 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2506 codec->patch_ops.init(codec); in generic_hdmi_resume()
2507 snd_hda_regmap_sync(codec); in generic_hdmi_resume()
2536 /* allocate codec->spec and assign/initialize generic parser ops */
2537 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2545 spec->codec = codec; in alloc_generic_hdmi()
2550 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2557 codec->spec = spec; in alloc_generic_hdmi()
2560 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2566 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2570 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2574 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2576 generic_spec_free(codec); in patch_generic_hdmi()
2580 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2589 static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid, in reprogram_jack_detect() argument
2594 tbl = snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in reprogram_jack_detect()
2600 snd_hda_codec_write_cache(codec, nid, 0, in reprogram_jack_detect()
2615 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2616 spec->codec->bus->keep_power = 0; in generic_acomp_notifier_set()
2619 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2656 struct hda_codec *codec = audio_ptr; in generic_acomp_pin_eld_notify() local
2657 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2658 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2662 if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN) in generic_acomp_pin_eld_notify()
2667 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in generic_acomp_pin_eld_notify()
2670 check_presence_and_report(codec, pin_nid, dev_id); in generic_acomp_pin_eld_notify()
2674 static void setup_drm_audio_ops(struct hda_codec *codec, in setup_drm_audio_ops() argument
2677 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2679 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2692 static void generic_acomp_init(struct hda_codec *codec, in generic_acomp_init() argument
2696 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2699 codec_info(codec, "audio component disabled by module option\n"); in generic_acomp_init()
2704 setup_drm_audio_ops(codec, ops); in generic_acomp_init()
2705 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2712 * Intel codec parsers and helpers
2720 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2724 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2726 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2732 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2738 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2741 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2744 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2746 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2753 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2754 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2761 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2765 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2766 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2769 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2770 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2784 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2786 switch (codec->core.vendor_id) { in intel_base_nid()
2798 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
2799 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2803 base_nid = intel_base_nid(codec); in intel_pin2port()
2818 codec_info(codec, "Can't find the HDMI/DP port for pin NID 0x%x\n", pin_nid); in intel_pin2port()
2822 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
2824 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2830 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2840 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2844 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
2850 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in intel_pin_eld_notify()
2853 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2854 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2863 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2865 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2869 setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
2870 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2873 codec->relaxed_resume = 1; in register_i915_notifier()
2877 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2881 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2882 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in i915_hsw_setup_stream()
2887 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2892 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
2893 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2895 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2896 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2899 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2904 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
2909 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
2910 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
2912 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
2916 err = alloc_generic_hdmi(codec); in alloc_intel_hdmi()
2920 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
2925 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
2930 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
2934 generic_spec_free(codec); in parse_intel_hdmi()
2938 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
2939 register_i915_notifier(codec); in parse_intel_hdmi()
2944 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
2951 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
2954 spec = codec->spec; in intel_hsw_common_init()
2955 codec->dp_mst = true; in intel_hsw_common_init()
2962 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
2963 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
2965 codec->display_power_control = 1; in intel_hsw_common_init()
2967 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
2968 codec->depop_delay = 0; in intel_hsw_common_init()
2969 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
2981 return parse_intel_hdmi(codec); in intel_hsw_common_init()
2984 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
2986 return intel_hsw_common_init(codec, 0x08, NULL, 0, 3, in patch_i915_hsw_hdmi()
2990 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
2997 return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3, false); in patch_i915_glk_hdmi()
3000 static int patch_i915_icl_hdmi(struct hda_codec *codec) in patch_i915_icl_hdmi() argument
3008 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3, in patch_i915_icl_hdmi()
3012 static int patch_i915_tgl_hdmi(struct hda_codec *codec) in patch_i915_tgl_hdmi() argument
3020 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4, in patch_i915_tgl_hdmi()
3024 static int patch_i915_adlp_hdmi(struct hda_codec *codec) in patch_i915_adlp_hdmi() argument
3029 res = patch_i915_tgl_hdmi(codec); in patch_i915_adlp_hdmi()
3031 spec = codec->spec; in patch_i915_adlp_hdmi()
3041 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
3046 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
3049 spec = codec->spec; in patch_i915_byt_hdmi()
3051 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
3054 codec->display_power_control = 1; in patch_i915_byt_hdmi()
3056 codec->depop_delay = 0; in patch_i915_byt_hdmi()
3057 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
3061 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
3065 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
3069 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3072 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3079 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
3081 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
3088 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
3091 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
3106 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
3109 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
3110 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
3118 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
3120 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
3125 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
3130 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
3133 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
3135 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
3139 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
3142 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
3143 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
3145 snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id); in simple_playback_init()
3149 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
3151 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3210 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
3212 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
3216 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
3218 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
3243 struct hda_codec *codec, in simple_playback_pcm_open() argument
3246 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3249 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3272 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3276 struct hda_codec *codec, in simple_playback_pcm_close() argument
3279 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3280 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3284 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
3289 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3290 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3313 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
3324 spec->codec = codec; in patch_simple_hdmi()
3325 codec->spec = spec; in patch_simple_hdmi()
3336 simple_playback_free(codec); in patch_simple_hdmi()
3343 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3348 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
3373 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3376 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3382 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
3385 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3388 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
3392 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3395 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3401 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3403 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3407 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3415 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3419 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3421 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3428 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3429 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3436 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3440 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3445 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3446 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3451 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3466 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3468 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3474 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3480 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3487 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3489 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3494 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3501 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3503 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3522 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3525 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3530 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3531 /* override the PCM rates, etc, as the codec doesn't give full list */ in patch_nvhdmi_2ch()
3532 spec = codec->spec; in patch_nvhdmi_2ch()
3540 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3542 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3543 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3551 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3553 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3558 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3569 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3582 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3585 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3588 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3591 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3592 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3593 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3597 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3638 static int nvhdmi_port2pin(struct hda_codec *codec, int port) in nvhdmi_port2pin() argument
3650 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3655 err = alloc_generic_hdmi(codec); in patch_nvhdmi()
3658 codec->dp_mst = true; in patch_nvhdmi()
3660 spec = codec->spec; in patch_nvhdmi()
3662 err = hdmi_parse_codec(codec); in patch_nvhdmi()
3664 generic_spec_free(codec); in patch_nvhdmi()
3668 generic_hdmi_init_per_pins(codec); in patch_nvhdmi()
3677 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3679 generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin); in patch_nvhdmi()
3684 static int patch_nvhdmi_legacy(struct hda_codec *codec) in patch_nvhdmi_legacy() argument
3689 err = patch_generic_hdmi(codec); in patch_nvhdmi_legacy()
3693 spec = codec->spec; in patch_nvhdmi_legacy()
3701 codec->link_down_at_suspend = 1; in patch_nvhdmi_legacy()
3707 * The HDA codec on NVIDIA Tegra contains two scratch registers that are
3716 * The SCRATCH0 register is used to notify the HDMI codec of changes in audio
3718 * be raised in the HDMI codec. The remainder of the bits is arbitrary. This
3749 * the format is invalidated so that the HDMI codec can be disabled.
3751 static void tegra_hdmi_set_format(struct hda_codec *codec, in tegra_hdmi_set_format() argument
3757 struct hdmi_spec *spec = codec->spec; in tegra_hdmi_set_format()
3760 * Tegra HDA codec design from TEGRA234 chip onwards support DP MST. in tegra_hdmi_set_format()
3763 * scratch register read/write for DP MST supported Tegra HDA codec. in tegra_hdmi_set_format()
3765 if (codec->dp_mst) in tegra_hdmi_set_format()
3769 value = snd_hda_codec_read(codec, nid, 0, in tegra_hdmi_set_format()
3774 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3777 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3782 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3796 * For Tegra HDA Codec design from TEGRA234 onwards, the in tegra_hdmi_set_format()
3801 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3803 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3808 * in the HDMI codec. The HDMI driver will use that as trigger in tegra_hdmi_set_format()
3813 snd_hda_codec_write(codec, nid, 0, in tegra_hdmi_set_format()
3819 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3826 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3831 /* notify the HDMI codec of the format change */ in tegra_hdmi_pcm_prepare()
3832 tegra_hdmi_set_format(codec, hinfo->nid, format); in tegra_hdmi_pcm_prepare()
3838 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3841 /* invalidate the format in the HDMI codec */ in tegra_hdmi_pcm_cleanup()
3842 tegra_hdmi_set_format(codec, hinfo->nid, 0); in tegra_hdmi_pcm_cleanup()
3844 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3847 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3849 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3862 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
3868 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
3872 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
3878 * codec about format changes. in tegra_hdmi_build_pcms()
3887 static int tegra_hdmi_init(struct hda_codec *codec) in tegra_hdmi_init() argument
3889 struct hdmi_spec *spec = codec->spec; in tegra_hdmi_init()
3892 err = hdmi_parse_codec(codec); in tegra_hdmi_init()
3894 generic_spec_free(codec); in tegra_hdmi_init()
3899 snd_hda_codec_write(codec, spec->cvt_nids[i], 0, in tegra_hdmi_init()
3903 generic_hdmi_init_per_pins(codec); in tegra_hdmi_init()
3905 codec->depop_delay = 10; in tegra_hdmi_init()
3906 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in tegra_hdmi_init()
3919 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
3923 err = alloc_generic_hdmi(codec); in patch_tegra_hdmi()
3927 return tegra_hdmi_init(codec); in patch_tegra_hdmi()
3930 static int patch_tegra234_hdmi(struct hda_codec *codec) in patch_tegra234_hdmi() argument
3935 err = alloc_generic_hdmi(codec); in patch_tegra234_hdmi()
3939 codec->dp_mst = true; in patch_tegra234_hdmi()
3940 spec = codec->spec; in patch_tegra234_hdmi()
3944 return tegra_hdmi_init(codec); in patch_tegra234_hdmi()
3951 #define is_amdhdmi_rev3_or_later(codec) \ argument
3952 ((codec)->core.vendor_id == 0x1002aa01 && \
3953 ((codec)->core.revision_id & 0xff00) >= 0x0300)
3954 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
3994 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
3999 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
4000 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
4003 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, in atihdmi_pin_setup_infoframe() argument
4008 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
4079 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_set_slot_channel() local
4086 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
4109 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
4115 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_get_slot_channel() local
4124 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
4134 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
4197 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
4204 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
4211 codec_dbg(codec, in atihdmi_pin_hbr_setup()
4218 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
4228 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
4232 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
4238 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
4241 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in atihdmi_setup_stream()
4246 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
4248 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
4251 err = generic_hdmi_init(codec); in atihdmi_init()
4260 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
4263 if (has_amd_full_remap_support(codec)) in atihdmi_init()
4264 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
4268 codec->auto_runtime_pm = 1; in atihdmi_init()
4281 static int atihdmi_port2pin(struct hda_codec *codec, int port) in atihdmi_port2pin() argument
4293 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
4299 err = patch_generic_hdmi(codec); in patch_atihdmi()
4304 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4306 spec = codec->spec; in patch_atihdmi()
4316 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
4339 codec->link_down_at_suspend = 1; in patch_atihdmi()
4341 generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin); in patch_atihdmi()
4350 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
4352 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()
4487 MODULE_DESCRIPTION("HDMI HD-audio codec");
4488 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4489 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4490 MODULE_ALIAS("snd-hda-codec-atihdmi");