Lines Matching full:codec

77 	struct hda_codec *codec;  member
97 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
100 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
105 int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid,
108 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
112 void (*pin_cvt_fixup)(struct hda_codec *codec,
124 struct hda_codec *codec; member
186 static inline bool codec_has_acomp(struct hda_codec *codec) in codec_has_acomp() argument
188 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
192 #define codec_has_acomp(codec) false argument
240 static int pin_id_to_pin_index(struct hda_codec *codec, in pin_id_to_pin_index() argument
243 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
261 codec_warn(codec, "HDMI: pin NID 0x%x not registered\n", pin_nid); in pin_id_to_pin_index()
265 static int hinfo_to_pcm_index(struct hda_codec *codec, in hinfo_to_pcm_index() argument
268 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
275 codec_warn(codec, "HDMI: hinfo %p not tied to a PCM\n", hinfo); in hinfo_to_pcm_index()
279 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
282 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
293 codec_dbg(codec, "HDMI: hinfo %p (pcm %d) not registered\n", hinfo, in hinfo_to_pin_index()
294 hinfo_to_pcm_index(codec, hinfo)); in hinfo_to_pin_index()
312 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
314 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
321 codec_warn(codec, "HDMI: cvt NID 0x%x not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
329 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
355 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
356 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
400 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pcm_idx, in hdmi_create_eld_ctl() argument
404 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
407 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
416 err = snd_hda_ctl_add(codec, 0, kctl); in hdmi_create_eld_ctl()
425 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
430 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
438 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
445 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
448 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
451 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
454 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
456 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
460 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
461 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
473 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
505 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
509 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
510 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
524 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
547 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
550 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
551 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
558 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
561 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
562 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
566 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
572 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
573 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
576 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
578 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
583 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
590 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
595 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
597 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
598 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
600 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
605 codec_dbg(codec, in hdmi_clear_dip_buffers()
626 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
632 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
633 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
635 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
637 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
640 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
646 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
647 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
652 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
661 static int hdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in hdmi_pin_get_eld() argument
664 snd_hda_set_dev_select(codec, nid, dev_id); in hdmi_pin_get_eld()
666 return snd_hdmi_get_eld(codec, nid, buf, eld_size); in hdmi_pin_get_eld()
669 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
695 codec_dbg(codec, "HDMI: unknown connection type at pin NID 0x%x\n", pin_nid); in hdmi_pin_setup_infoframe()
699 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_setup_infoframe()
706 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
708 codec_dbg(codec, "%s: pin NID=0x%x channels=%d ca=0x%02x\n", in hdmi_pin_setup_infoframe()
710 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
711 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
713 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
717 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
721 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
733 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_setup_audio_infoframe()
736 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_setup_audio_infoframe()
737 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
743 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
749 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
760 spec->ops.pin_setup_infoframe(codec, pin_nid, dev_id, in hdmi_setup_audio_infoframe()
772 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, in check_presence_and_report() argument
775 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
776 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id); in check_presence_and_report()
785 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
789 if (codec_has_acomp(codec)) in jack_callback()
792 check_presence_and_report(codec, jack->nid, jack->dev_id); in jack_callback()
795 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res, in hdmi_intrinsic_event() argument
800 codec_dbg(codec, in hdmi_intrinsic_event()
801 "HDMI hot plug event: Codec=%d NID=0x%x Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_intrinsic_event()
802 codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
805 check_presence_and_report(codec, jack->nid, jack->dev_id); in hdmi_intrinsic_event()
808 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
815 codec_info(codec, in hdmi_non_intrinsic_event()
816 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", in hdmi_non_intrinsic_event()
817 codec->addr, in hdmi_non_intrinsic_event()
833 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
839 if (codec_has_acomp(codec)) in hdmi_unsol_event()
842 if (codec->dp_mst) { in hdmi_unsol_event()
846 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry); in hdmi_unsol_event()
848 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, 0); in hdmi_unsol_event()
852 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
857 hdmi_intrinsic_event(codec, res, jack); in hdmi_unsol_event()
859 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
862 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
870 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
871 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
873 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
874 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
877 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
879 codec_dbg(codec, "Haswell HDMI audio: Power for NID 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
891 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
896 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
897 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_hbr_setup()
898 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
910 codec_dbg(codec, in hdmi_pin_hbr_setup()
917 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
926 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
930 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
934 err = spec->ops.pin_hbr_setup(codec, pin_nid, dev_id, in hdmi_setup_stream()
938 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
949 param = snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_setup_stream()
958 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_setup_stream()
962 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
971 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
974 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
986 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in hdmi_choose_cvt()
1025 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1032 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1035 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1063 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1067 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1097 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1109 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
1110 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1111 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1114 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1120 * connection list are in the same order as in the codec. in intel_not_share_assigned_cvt()
1125 codec_dbg(codec, in intel_not_share_assigned_cvt()
1128 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1134 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1139 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
1143 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1152 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
1156 static void pin_cvt_fixup(struct hda_codec *codec, in pin_cvt_fixup() argument
1160 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1163 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1170 struct hda_codec *codec, in hdmi_pcm_open_no_pin() argument
1173 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1179 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open_no_pin()
1183 err = hdmi_choose_cvt(codec, -1, &cvt_idx); in hdmi_pcm_open_no_pin()
1191 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1218 struct hda_codec *codec, in hdmi_pcm_open() argument
1221 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1230 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open()
1235 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1246 err = hdmi_pcm_open_no_pin(hinfo, codec, substream); in hdmi_pcm_open()
1251 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in hdmi_pcm_open()
1265 if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE) in hdmi_pcm_open()
1268 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1269 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1274 pin_cvt_fixup(codec, per_pin, 0); in hdmi_pcm_open()
1276 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1293 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_open()
1315 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1317 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1323 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1324 codec_warn(codec, in hdmi_read_pin_conn()
1326 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1330 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_read_pin_conn()
1337 conns = snd_hda_get_raw_connections(codec, pin_nid, in hdmi_read_pin_conn()
1439 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid);
1444 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin() local
1468 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1470 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1474 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1476 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1482 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in hdmi_pcm_setup_pin()
1489 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1498 static struct snd_jack *pin_idx_to_pcm_jack(struct hda_codec *codec, in pin_idx_to_pcm_jack() argument
1501 struct hdmi_spec *spec = codec->spec; in pin_idx_to_pcm_jack()
1513 static void update_eld(struct hda_codec *codec, in update_eld() argument
1519 struct hdmi_spec *spec = codec->spec; in update_eld()
1527 snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in update_eld()
1550 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1567 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1570 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1597 pin_cvt_fixup(codec, per_pin, 0); in update_eld()
1598 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1602 snd_ctl_notify(codec->card, in update_eld()
1617 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs() local
1618 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1633 ret = snd_hda_power_up_pm(codec); in hdmi_present_sense_via_verbs()
1634 if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) in hdmi_present_sense_via_verbs()
1637 present = snd_hda_jack_pin_sense(codec, pin_nid, dev_id); in hdmi_present_sense_via_verbs()
1646 codec_dbg(codec, in hdmi_present_sense_via_verbs()
1647 "HDMI status: Codec=%d NID=0x%x Presence_Detect=%d ELD_Valid=%d\n", in hdmi_present_sense_via_verbs()
1648 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1651 if (spec->ops.pin_get_eld(codec, pin_nid, dev_id, in hdmi_present_sense_via_verbs()
1656 update_eld(codec, per_pin, eld, repoll); in hdmi_present_sense_via_verbs()
1659 snd_hda_power_down_pm(codec); in hdmi_present_sense_via_verbs()
1668 static void silent_stream_enable(struct hda_codec *codec, in silent_stream_enable() argument
1671 struct hdmi_spec *spec = codec->spec; in silent_stream_enable()
1679 codec_dbg(codec, "hdmi: PCM already open, no silent stream\n"); in silent_stream_enable()
1683 pin_idx = pin_id_to_pin_index(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1684 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in silent_stream_enable()
1686 codec_err(codec, "hdmi: no free converter to enable silent mode\n"); in silent_stream_enable()
1695 codec_dbg(codec, "hdmi: enabling silent stream pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_enable()
1698 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in silent_stream_enable()
1699 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in silent_stream_enable()
1704 pin_cvt_fixup(codec, per_pin, 0); in silent_stream_enable()
1706 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in silent_stream_enable()
1712 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, in silent_stream_enable()
1715 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format); in silent_stream_enable()
1718 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in silent_stream_enable()
1724 static void silent_stream_disable(struct hda_codec *codec, in silent_stream_disable() argument
1727 struct hdmi_spec *spec = codec->spec; in silent_stream_disable()
1735 codec_dbg(codec, "HDMI: disable silent stream on pin-NID=0x%x cvt-NID=0x%x\n", in silent_stream_disable()
1738 cvt_idx = cvt_nid_to_cvt_index(codec, per_pin->cvt_nid); in silent_stream_disable()
1752 static void sync_eld_via_acomp(struct hda_codec *codec, in sync_eld_via_acomp() argument
1755 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1762 eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1766 update_eld(codec, per_pin, eld, 0); in sync_eld_via_acomp()
1779 pm_ret = snd_hda_power_up_pm(codec); in sync_eld_via_acomp()
1781 codec_err(codec, in sync_eld_via_acomp()
1782 "Monitor plugged-in, Failed to power up codec ret=[%d]\n", in sync_eld_via_acomp()
1784 silent_stream_enable(codec, per_pin); in sync_eld_via_acomp()
1786 silent_stream_disable(codec, per_pin); in sync_eld_via_acomp()
1787 pm_ret = snd_hda_power_down_pm(codec); in sync_eld_via_acomp()
1789 codec_err(codec, in sync_eld_via_acomp()
1790 "Monitor plugged-out, Failed to power down codec ret=[%d]\n", in sync_eld_via_acomp()
1798 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1800 if (!codec_has_acomp(codec)) in hdmi_present_sense()
1803 sync_eld_via_acomp(codec, per_pin); in hdmi_present_sense()
1810 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld() local
1811 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1814 jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid, in hdmi_repoll_eld()
1827 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1829 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1836 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1844 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1861 } else if (spec->dyn_pcm_assign && codec->dp_mst) { in hdmi_add_pin()
1862 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; in hdmi_add_pin()
1897 snd_hda_set_dev_select(codec, pin_nid, i); in hdmi_add_pin()
1898 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1908 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1910 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1915 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1930 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
1952 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1954 struct hdmi_spec *spec = codec->spec; in hdmi_parse_codec()
1960 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); in hdmi_parse_codec()
1962 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
1969 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); in hdmi_parse_codec()
1981 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
1987 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
1994 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
2000 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
2008 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
2013 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2014 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
2019 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2023 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
2032 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
2038 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
2047 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
2053 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2054 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
2073 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
2077 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
2078 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2081 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2086 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) { in generic_hdmi_playback_pcm_prepare()
2087 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
2089 snd_hda_codec_write(codec, cvt_nid, 0, in generic_hdmi_playback_pcm_prepare()
2094 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
2097 snd_hda_set_dev_select(codec, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2099 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2101 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2107 err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2115 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
2118 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
2123 struct hda_codec *codec, in hdmi_pcm_close() argument
2126 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
2135 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
2140 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
2151 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
2153 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
2164 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_close()
2166 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2168 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2197 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_spk_alloc() local
2198 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2210 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_chmap() local
2211 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2224 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_set_chmap() local
2225 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2234 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2240 struct hda_codec *codec = hdac_to_hda_codec(hdac); in is_hdmi_pcm_attached() local
2241 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2247 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2249 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2260 if (codec->mst_no_extra_pcms) in generic_hdmi_build_pcms()
2265 codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); in generic_hdmi_build_pcms()
2271 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2299 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2302 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2311 !is_jack_detectable(codec, per_pin->pin_nid)) in generic_hdmi_build_jack()
2315 err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack, in generic_hdmi_build_jack()
2326 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2328 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2339 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2347 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2353 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2360 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2365 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); in generic_hdmi_build_controls()
2394 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2396 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2402 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2410 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2412 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2421 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2422 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2423 if (codec_has_acomp(codec)) in generic_hdmi_init()
2425 snd_hda_jack_detect_enable_callback_mst(codec, pin_nid, dev_id, in generic_hdmi_init()
2444 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2446 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2451 codec->spec = NULL; in generic_spec_free()
2453 codec->dp_mst = false; in generic_spec_free()
2456 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2458 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2462 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2463 } else if (codec_has_acomp(codec)) { in generic_hdmi_free()
2464 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2466 codec->relaxed_resume = 0; in generic_hdmi_free()
2478 snd_device_free(codec->card, in generic_hdmi_free()
2484 generic_spec_free(codec); in generic_hdmi_free()
2488 static int generic_hdmi_suspend(struct hda_codec *codec) in generic_hdmi_suspend() argument
2490 struct hdmi_spec *spec = codec->spec; in generic_hdmi_suspend()
2500 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2502 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2505 codec->patch_ops.init(codec); in generic_hdmi_resume()
2506 snd_hda_regmap_sync(codec); in generic_hdmi_resume()
2535 /* allocate codec->spec and assign/initialize generic parser ops */
2536 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2544 spec->codec = codec; in alloc_generic_hdmi()
2549 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2556 codec->spec = spec; in alloc_generic_hdmi()
2559 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2565 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2569 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2573 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2575 generic_spec_free(codec); in patch_generic_hdmi()
2579 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2588 static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid, in reprogram_jack_detect() argument
2593 tbl = snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in reprogram_jack_detect()
2599 snd_hda_codec_write_cache(codec, nid, 0, in reprogram_jack_detect()
2614 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2615 spec->codec->bus->keep_power = 0; in generic_acomp_notifier_set()
2618 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2655 struct hda_codec *codec = audio_ptr; in generic_acomp_pin_eld_notify() local
2656 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2657 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2661 if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN) in generic_acomp_pin_eld_notify()
2666 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in generic_acomp_pin_eld_notify()
2669 if (snd_hdac_is_in_pm(&codec->core)) in generic_acomp_pin_eld_notify()
2672 check_presence_and_report(codec, pin_nid, dev_id); in generic_acomp_pin_eld_notify()
2676 static void setup_drm_audio_ops(struct hda_codec *codec, in setup_drm_audio_ops() argument
2679 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2681 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2694 static void generic_acomp_init(struct hda_codec *codec, in generic_acomp_init() argument
2698 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2701 codec_info(codec, "audio component disabled by module option\n"); in generic_acomp_init()
2706 setup_drm_audio_ops(codec, ops); in generic_acomp_init()
2707 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2714 * Intel codec parsers and helpers
2722 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2726 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2728 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2734 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2740 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2743 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2746 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2748 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2755 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2756 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2763 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2767 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2768 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2771 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2772 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2786 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2788 switch (codec->core.vendor_id) { in intel_base_nid()
2800 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
2801 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2805 base_nid = intel_base_nid(codec); in intel_pin2port()
2820 codec_info(codec, "Can't find the HDMI/DP port for pin NID 0x%x\n", pin_nid); in intel_pin2port()
2824 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
2826 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2832 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2842 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2846 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
2852 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in intel_pin_eld_notify()
2855 if (snd_hdac_is_in_pm(&codec->core)) in intel_pin_eld_notify()
2858 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2859 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2868 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2870 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2874 setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
2875 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2878 codec->relaxed_resume = 1; in register_i915_notifier()
2882 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2886 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2887 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in i915_hsw_setup_stream()
2892 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2897 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
2898 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2900 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2901 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2904 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2909 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
2914 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
2915 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
2917 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
2921 err = alloc_generic_hdmi(codec); in alloc_intel_hdmi()
2925 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
2930 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
2935 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
2939 generic_spec_free(codec); in parse_intel_hdmi()
2943 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
2944 register_i915_notifier(codec); in parse_intel_hdmi()
2949 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
2955 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
2958 spec = codec->spec; in intel_hsw_common_init()
2959 codec->dp_mst = true; in intel_hsw_common_init()
2967 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
2968 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
2970 codec->display_power_control = 1; in intel_hsw_common_init()
2972 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
2973 codec->depop_delay = 0; in intel_hsw_common_init()
2974 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
2986 return parse_intel_hdmi(codec); in intel_hsw_common_init()
2989 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
2991 return intel_hsw_common_init(codec, 0x08, NULL, 0, 3); in patch_i915_hsw_hdmi()
2994 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
2996 return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3); in patch_i915_glk_hdmi()
2999 static int patch_i915_icl_hdmi(struct hda_codec *codec) in patch_i915_icl_hdmi() argument
3007 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3); in patch_i915_icl_hdmi()
3010 static int patch_i915_tgl_hdmi(struct hda_codec *codec) in patch_i915_tgl_hdmi() argument
3019 ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4); in patch_i915_tgl_hdmi()
3021 struct hdmi_spec *spec = codec->spec; in patch_i915_tgl_hdmi()
3030 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
3035 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
3038 spec = codec->spec; in patch_i915_byt_hdmi()
3040 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
3043 codec->display_power_control = 1; in patch_i915_byt_hdmi()
3045 codec->depop_delay = 0; in patch_i915_byt_hdmi()
3046 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
3050 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
3054 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
3058 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3061 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
3068 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
3070 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
3077 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
3080 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
3095 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
3098 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
3099 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
3107 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
3109 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
3114 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
3119 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
3122 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
3124 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
3128 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
3131 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
3132 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
3134 snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id); in simple_playback_init()
3138 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
3140 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3199 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
3201 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
3205 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
3207 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
3232 struct hda_codec *codec, in simple_playback_pcm_open() argument
3235 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3238 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3261 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3265 struct hda_codec *codec, in simple_playback_pcm_close() argument
3268 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3269 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3273 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
3278 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3279 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3302 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
3313 spec->codec = codec; in patch_simple_hdmi()
3314 codec->spec = spec; in patch_simple_hdmi()
3325 simple_playback_free(codec); in patch_simple_hdmi()
3332 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3337 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
3362 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3365 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3371 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
3374 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3377 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
3381 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3384 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3390 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3392 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3396 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3404 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3408 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3410 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3417 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3418 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3425 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3429 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3434 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3435 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3440 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3455 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3457 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3463 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3469 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3476 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3478 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3483 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3490 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3492 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3511 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3514 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3519 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3520 /* override the PCM rates, etc, as the codec doesn't give full list */ in patch_nvhdmi_2ch()
3521 spec = codec->spec; in patch_nvhdmi_2ch()
3528 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3530 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3531 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3539 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3541 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3546 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3557 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3570 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3573 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3576 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3579 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3580 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3581 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3585 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3626 static int nvhdmi_port2pin(struct hda_codec *codec, int port) in nvhdmi_port2pin() argument
3638 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3643 err = alloc_generic_hdmi(codec); in patch_nvhdmi()
3646 codec->dp_mst = true; in patch_nvhdmi()
3648 spec = codec->spec; in patch_nvhdmi()
3651 err = hdmi_parse_codec(codec); in patch_nvhdmi()
3653 generic_spec_free(codec); in patch_nvhdmi()
3657 generic_hdmi_init_per_pins(codec); in patch_nvhdmi()
3665 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3667 generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin); in patch_nvhdmi()
3672 static int patch_nvhdmi_legacy(struct hda_codec *codec) in patch_nvhdmi_legacy() argument
3677 err = patch_generic_hdmi(codec); in patch_nvhdmi_legacy()
3681 spec = codec->spec; in patch_nvhdmi_legacy()
3688 codec->link_down_at_suspend = 1; in patch_nvhdmi_legacy()
3694 * The HDA codec on NVIDIA Tegra contains two scratch registers that are
3703 * The SCRATCH0 register is used to notify the HDMI codec of changes in audio
3705 * be raised in the HDMI codec. The remainder of the bits is arbitrary. This
3733 * the format is invalidated so that the HDMI codec can be disabled.
3735 static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) in tegra_hdmi_set_format() argument
3740 value = snd_hda_codec_read(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3745 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3748 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3753 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3767 * HDMI codec. The HDMI driver will use that as trigger to update its in tegra_hdmi_set_format()
3772 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3777 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3784 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3789 /* notify the HDMI codec of the format change */ in tegra_hdmi_pcm_prepare()
3790 tegra_hdmi_set_format(codec, format); in tegra_hdmi_pcm_prepare()
3796 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3799 /* invalidate the format in the HDMI codec */ in tegra_hdmi_pcm_cleanup()
3800 tegra_hdmi_set_format(codec, 0); in tegra_hdmi_pcm_cleanup()
3802 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3805 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3807 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3820 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
3826 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
3830 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
3836 * codec about format changes. in tegra_hdmi_build_pcms()
3845 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
3850 err = patch_generic_hdmi(codec); in patch_tegra_hdmi()
3854 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in patch_tegra_hdmi()
3855 spec = codec->spec; in patch_tegra_hdmi()
3867 #define is_amdhdmi_rev3_or_later(codec) \ argument
3868 ((codec)->core.vendor_id == 0x1002aa01 && \
3869 ((codec)->core.revision_id & 0xff00) >= 0x0300)
3870 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
3910 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
3915 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
3916 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
3919 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, in atihdmi_pin_setup_infoframe() argument
3924 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
3995 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_set_slot_channel() local
4002 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
4025 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
4031 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_get_slot_channel() local
4040 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
4050 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
4113 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
4120 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
4127 codec_dbg(codec, in atihdmi_pin_hbr_setup()
4134 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
4144 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
4148 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
4154 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
4157 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in atihdmi_setup_stream()
4162 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
4164 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
4167 err = generic_hdmi_init(codec); in atihdmi_init()
4176 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
4179 if (has_amd_full_remap_support(codec)) in atihdmi_init()
4180 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
4184 codec->auto_runtime_pm = 1; in atihdmi_init()
4197 static int atihdmi_port2pin(struct hda_codec *codec, int port) in atihdmi_port2pin() argument
4209 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
4215 err = patch_generic_hdmi(codec); in patch_atihdmi()
4220 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4222 spec = codec->spec; in patch_atihdmi()
4232 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
4255 codec->link_down_at_suspend = 1; in patch_atihdmi()
4257 generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin); in patch_atihdmi()
4266 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
4268 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()
4398 MODULE_DESCRIPTION("HDMI HD-audio codec");
4399 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4400 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4401 MODULE_ALIAS("snd-hda-codec-atihdmi");