Lines Matching full:codec
73 struct hda_codec *codec; member
92 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
95 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
100 int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid,
103 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
107 void (*pin_cvt_fixup)(struct hda_codec *codec,
119 struct hda_codec *codec; member
180 static inline bool codec_has_acomp(struct hda_codec *codec) in codec_has_acomp() argument
182 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
186 #define codec_has_acomp(codec) false argument
234 static int pin_id_to_pin_index(struct hda_codec *codec, in pin_id_to_pin_index() argument
237 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
255 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid); in pin_id_to_pin_index()
259 static int hinfo_to_pcm_index(struct hda_codec *codec, in hinfo_to_pcm_index() argument
262 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
269 codec_warn(codec, "HDMI: hinfo %p not tied to a PCM\n", hinfo); in hinfo_to_pcm_index()
273 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
276 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
287 codec_dbg(codec, "HDMI: hinfo %p (pcm %d) not registered\n", hinfo, in hinfo_to_pin_index()
288 hinfo_to_pcm_index(codec, hinfo)); in hinfo_to_pin_index()
306 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
308 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
315 codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
322 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
323 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
349 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
350 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
394 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pcm_idx, in hdmi_create_eld_ctl() argument
398 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
401 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
410 err = snd_hda_ctl_add(codec, 0, kctl); in hdmi_create_eld_ctl()
419 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
424 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
432 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
439 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
442 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
445 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
448 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
450 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
454 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
455 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
467 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
499 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
503 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
504 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
518 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
541 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
544 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
545 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
552 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
555 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
556 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
560 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
566 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
567 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
570 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
572 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
577 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
584 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
589 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
591 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
592 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
594 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
599 codec_dbg(codec, in hdmi_clear_dip_buffers()
620 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
626 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
627 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
629 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
631 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
634 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
640 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
644 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
646 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
655 static int hdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in hdmi_pin_get_eld() argument
658 snd_hda_set_dev_select(codec, nid, dev_id); in hdmi_pin_get_eld()
660 return snd_hdmi_get_eld(codec, nid, buf, eld_size); in hdmi_pin_get_eld()
663 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
689 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n", in hdmi_pin_setup_infoframe()
694 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_setup_infoframe()
701 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
703 codec_dbg(codec, in hdmi_pin_setup_infoframe()
707 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
708 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
710 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
714 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
718 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
730 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_setup_audio_infoframe()
733 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_setup_audio_infoframe()
734 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
740 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
746 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
757 spec->ops.pin_setup_infoframe(codec, pin_nid, dev_id, in hdmi_setup_audio_infoframe()
769 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, in check_presence_and_report() argument
772 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
773 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id); in check_presence_and_report()
782 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
786 if (codec_has_acomp(codec)) in jack_callback()
789 check_presence_and_report(codec, jack->nid, jack->dev_id); in jack_callback()
792 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res, in hdmi_intrinsic_event() argument
797 codec_dbg(codec, in hdmi_intrinsic_event()
798 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_intrinsic_event()
799 codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
802 check_presence_and_report(codec, jack->nid, jack->dev_id); in hdmi_intrinsic_event()
805 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
812 codec_info(codec, in hdmi_non_intrinsic_event()
813 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", in hdmi_non_intrinsic_event()
814 codec->addr, in hdmi_non_intrinsic_event()
830 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
836 if (codec_has_acomp(codec)) in hdmi_unsol_event()
839 if (codec->dp_mst) { in hdmi_unsol_event()
843 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, dev_entry); in hdmi_unsol_event()
845 jack = snd_hda_jack_tbl_get_from_tag(codec, tag, 0); in hdmi_unsol_event()
849 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
854 hdmi_intrinsic_event(codec, res, jack); in hdmi_unsol_event()
856 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
859 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
867 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
868 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
870 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
871 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
874 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
876 codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
888 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
893 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
894 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_pin_hbr_setup()
895 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
907 codec_dbg(codec, in hdmi_pin_hbr_setup()
914 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
923 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
927 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
931 err = spec->ops.pin_hbr_setup(codec, pin_nid, dev_id, in hdmi_setup_stream()
935 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
946 param = snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_setup_stream()
955 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_setup_stream()
959 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
968 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
971 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
1015 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1022 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1025 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1053 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1057 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1087 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1099 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
1100 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1101 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1104 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1110 * connection list are in the same order as in the codec. in intel_not_share_assigned_cvt()
1115 codec_dbg(codec, in intel_not_share_assigned_cvt()
1118 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1124 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1129 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
1133 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1142 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
1146 static void pin_cvt_fixup(struct hda_codec *codec, in pin_cvt_fixup() argument
1150 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1153 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1160 struct hda_codec *codec, in hdmi_pcm_open_no_pin() argument
1163 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1169 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open_no_pin()
1173 err = hdmi_choose_cvt(codec, -1, &cvt_idx); in hdmi_pcm_open_no_pin()
1181 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1208 struct hda_codec *codec, in hdmi_pcm_open() argument
1211 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1220 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open()
1225 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1236 err = hdmi_pcm_open_no_pin(hinfo, codec, substream); in hdmi_pcm_open()
1241 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in hdmi_pcm_open()
1255 if (get_wcaps(codec, per_cvt->cvt_nid) & AC_WCAP_STRIPE) in hdmi_pcm_open()
1258 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1259 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1264 pin_cvt_fixup(codec, per_pin, 0); in hdmi_pcm_open()
1266 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1283 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_open()
1305 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1307 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1313 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1314 codec_warn(codec, in hdmi_read_pin_conn()
1316 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1320 snd_hda_set_dev_select(codec, pin_nid, dev_id); in hdmi_read_pin_conn()
1327 conns = snd_hda_get_raw_connections(codec, pin_nid, in hdmi_read_pin_conn()
1422 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid);
1427 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin() local
1451 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1453 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1457 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1459 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1465 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in hdmi_pcm_setup_pin()
1472 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1481 static struct snd_jack *pin_idx_to_pcm_jack(struct hda_codec *codec, in pin_idx_to_pcm_jack() argument
1484 struct hdmi_spec *spec = codec->spec; in pin_idx_to_pcm_jack()
1496 static void update_eld(struct hda_codec *codec, in update_eld() argument
1502 struct hdmi_spec *spec = codec->spec; in update_eld()
1510 snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in update_eld()
1533 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1550 pcm_jack = pin_idx_to_pcm_jack(codec, per_pin); in update_eld()
1553 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1580 pin_cvt_fixup(codec, per_pin, 0); in update_eld()
1581 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1585 snd_ctl_notify(codec->card, in update_eld()
1600 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs() local
1601 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1616 ret = snd_hda_power_up_pm(codec); in hdmi_present_sense_via_verbs()
1617 if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) in hdmi_present_sense_via_verbs()
1620 present = snd_hda_jack_pin_sense(codec, pin_nid, dev_id); in hdmi_present_sense_via_verbs()
1629 codec_dbg(codec, in hdmi_present_sense_via_verbs()
1630 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_present_sense_via_verbs()
1631 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1634 if (spec->ops.pin_get_eld(codec, pin_nid, dev_id, in hdmi_present_sense_via_verbs()
1639 update_eld(codec, per_pin, eld, repoll); in hdmi_present_sense_via_verbs()
1642 snd_hda_power_down_pm(codec); in hdmi_present_sense_via_verbs()
1645 static void silent_stream_enable(struct hda_codec *codec, in silent_stream_enable() argument
1650 codec_dbg(codec, "hdmi: enabling silent stream for NID %d\n", in silent_stream_enable()
1658 oldval = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in silent_stream_enable()
1661 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in silent_stream_enable()
1664 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in silent_stream_enable()
1670 static void sync_eld_via_acomp(struct hda_codec *codec, in sync_eld_via_acomp() argument
1673 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1680 eld->eld_size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1684 update_eld(codec, per_pin, eld, 0); in sync_eld_via_acomp()
1697 pm_ret = snd_hda_power_up_pm(codec); in sync_eld_via_acomp()
1699 codec_err(codec, in sync_eld_via_acomp()
1700 "Monitor plugged-in, Failed to power up codec ret=[%d]\n", in sync_eld_via_acomp()
1702 silent_stream_enable(codec, per_pin); in sync_eld_via_acomp()
1704 pm_ret = snd_hda_power_down_pm(codec); in sync_eld_via_acomp()
1706 codec_err(codec, in sync_eld_via_acomp()
1707 "Monitor plugged-out, Failed to power down codec ret=[%d]\n", in sync_eld_via_acomp()
1715 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1717 if (!codec_has_acomp(codec)) in hdmi_present_sense()
1720 sync_eld_via_acomp(codec, per_pin); in hdmi_present_sense()
1727 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld() local
1728 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1731 jack = snd_hda_jack_tbl_get_mst(codec, per_pin->pin_nid, in hdmi_repoll_eld()
1744 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1746 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1753 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1761 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1782 } else if (spec->dyn_pcm_assign && codec->dp_mst) { in hdmi_add_pin()
1783 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; in hdmi_add_pin()
1818 snd_hda_set_dev_select(codec, pin_nid, i); in hdmi_add_pin()
1819 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1829 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1831 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1836 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1851 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
1871 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1873 struct hdmi_spec *spec = codec->spec; in hdmi_parse_codec()
1879 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &start_nid); in hdmi_parse_codec()
1881 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
1885 q = snd_pci_quirk_lookup(codec->bus->pci, force_connect_list); in hdmi_parse_codec()
1897 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
1903 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
1910 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
1916 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
1924 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
1929 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
1930 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
1935 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
1939 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
1948 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
1954 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
1963 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
1969 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
1970 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
1989 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
1993 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
1994 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
1997 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
2002 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) { in generic_hdmi_playback_pcm_prepare()
2003 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
2005 snd_hda_codec_write(codec, cvt_nid, 0, in generic_hdmi_playback_pcm_prepare()
2010 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
2013 snd_hda_set_dev_select(codec, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2015 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2017 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
2023 err = spec->ops.setup_stream(codec, cvt_nid, per_pin->pin_nid, in generic_hdmi_playback_pcm_prepare()
2031 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
2034 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
2039 struct hda_codec *codec, in hdmi_pcm_close() argument
2042 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
2051 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
2056 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
2068 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
2070 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
2081 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_close()
2083 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2085 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2114 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_spk_alloc() local
2115 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2127 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_get_chmap() local
2128 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2141 struct hda_codec *codec = hdac_to_hda_codec(hdac); in hdmi_set_chmap() local
2142 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2151 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2157 struct hda_codec *codec = hdac_to_hda_codec(hdac); in is_hdmi_pcm_attached() local
2158 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2164 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2166 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2177 if (codec->mst_no_extra_pcms) in generic_hdmi_build_pcms()
2182 codec_dbg(codec, "hdmi: pcm_num set to %d\n", pcm_num); in generic_hdmi_build_pcms()
2188 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2216 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2219 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2228 !is_jack_detectable(codec, per_pin->pin_nid)) in generic_hdmi_build_jack()
2232 err = snd_jack_new(codec->card, hdmi_str, SND_JACK_AVOUT, &jack, in generic_hdmi_build_jack()
2243 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2245 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2256 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2264 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2270 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2277 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2282 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); in generic_hdmi_build_controls()
2311 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2313 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2319 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2327 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2329 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2338 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2339 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2340 if (codec_has_acomp(codec)) in generic_hdmi_init()
2342 snd_hda_jack_detect_enable_callback_mst(codec, pin_nid, dev_id, in generic_hdmi_init()
2361 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2363 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2368 codec->spec = NULL; in generic_spec_free()
2370 codec->dp_mst = false; in generic_spec_free()
2373 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2375 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2379 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2380 } else if (codec_has_acomp(codec)) { in generic_hdmi_free()
2381 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2383 codec->relaxed_resume = 0; in generic_hdmi_free()
2395 snd_device_free(codec->card, in generic_hdmi_free()
2401 generic_spec_free(codec); in generic_hdmi_free()
2405 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2407 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2410 codec->patch_ops.init(codec); in generic_hdmi_resume()
2411 snd_hda_regmap_sync(codec); in generic_hdmi_resume()
2439 /* allocate codec->spec and assign/initialize generic parser ops */
2440 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2448 spec->codec = codec; in alloc_generic_hdmi()
2453 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2460 codec->spec = spec; in alloc_generic_hdmi()
2463 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2469 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2473 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2477 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2479 generic_spec_free(codec); in patch_generic_hdmi()
2483 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2492 static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid, in reprogram_jack_detect() argument
2497 tbl = snd_hda_jack_tbl_get_mst(codec, nid, dev_id); in reprogram_jack_detect()
2503 snd_hda_codec_write_cache(codec, nid, 0, in reprogram_jack_detect()
2518 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2519 spec->codec->bus->keep_power = 0; in generic_acomp_notifier_set()
2522 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2559 struct hda_codec *codec = audio_ptr; in generic_acomp_pin_eld_notify() local
2560 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2561 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2565 if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN) in generic_acomp_pin_eld_notify()
2570 if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0) in generic_acomp_pin_eld_notify()
2573 if (snd_hdac_is_in_pm(&codec->core)) in generic_acomp_pin_eld_notify()
2576 check_presence_and_report(codec, pin_nid, dev_id); in generic_acomp_pin_eld_notify()
2580 static void setup_drm_audio_ops(struct hda_codec *codec, in setup_drm_audio_ops() argument
2583 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2585 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2598 static void generic_acomp_init(struct hda_codec *codec, in generic_acomp_init() argument
2602 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2605 codec_info(codec, "audio component disabled by module option\n"); in generic_acomp_init()
2610 setup_drm_audio_ops(codec, ops); in generic_acomp_init()
2611 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2618 * Intel codec parsers and helpers
2626 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2630 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2632 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2638 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2644 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2647 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2650 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2652 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2659 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2660 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2667 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2671 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2672 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2675 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2676 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2690 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2692 switch (codec->core.vendor_id) { in intel_base_nid()
2704 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
2705 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2709 base_nid = intel_base_nid(codec); in intel_pin2port()
2724 codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid); in intel_pin2port()
2728 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
2730 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2736 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2746 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2750 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
2756 if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0) in intel_pin_eld_notify()
2759 if (snd_hdac_is_in_pm(&codec->core)) in intel_pin_eld_notify()
2762 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2763 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2772 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2774 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2778 setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
2779 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2782 codec->relaxed_resume = 1; in register_i915_notifier()
2786 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2790 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2791 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in i915_hsw_setup_stream()
2796 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2801 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
2802 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2804 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2805 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2808 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2813 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
2818 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
2819 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
2821 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
2825 err = alloc_generic_hdmi(codec); in alloc_intel_hdmi()
2829 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
2834 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
2839 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
2843 generic_spec_free(codec); in parse_intel_hdmi()
2847 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
2848 register_i915_notifier(codec); in parse_intel_hdmi()
2853 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
2859 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
2862 spec = codec->spec; in intel_hsw_common_init()
2863 codec->dp_mst = true; in intel_hsw_common_init()
2870 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
2871 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
2873 codec->display_power_control = 1; in intel_hsw_common_init()
2875 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
2876 codec->depop_delay = 0; in intel_hsw_common_init()
2877 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
2889 return parse_intel_hdmi(codec); in intel_hsw_common_init()
2892 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
2894 return intel_hsw_common_init(codec, 0x08, NULL, 0); in patch_i915_hsw_hdmi()
2897 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
2899 return intel_hsw_common_init(codec, 0x0b, NULL, 0); in patch_i915_glk_hdmi()
2902 static int patch_i915_icl_hdmi(struct hda_codec *codec) in patch_i915_icl_hdmi() argument
2910 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_icl_hdmi()
2913 static int patch_i915_tgl_hdmi(struct hda_codec *codec) in patch_i915_tgl_hdmi() argument
2921 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_tgl_hdmi()
2925 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
2930 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
2933 spec = codec->spec; in patch_i915_byt_hdmi()
2935 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
2938 codec->display_power_control = 1; in patch_i915_byt_hdmi()
2940 codec->depop_delay = 0; in patch_i915_byt_hdmi()
2941 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
2945 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
2949 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
2953 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
2956 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
2963 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
2965 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
2972 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
2975 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
2990 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
2993 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
2994 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
3002 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
3004 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
3009 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
3014 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
3017 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
3019 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
3023 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
3026 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
3027 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
3029 snd_hda_jack_detect_enable(codec, pin, per_pin->dev_id); in simple_playback_init()
3033 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
3035 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3094 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
3096 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
3100 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
3102 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
3127 struct hda_codec *codec, in simple_playback_pcm_open() argument
3130 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3133 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3156 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3160 struct hda_codec *codec, in simple_playback_pcm_close() argument
3163 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3164 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3168 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
3173 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3174 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3197 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
3208 spec->codec = codec; in patch_simple_hdmi()
3209 codec->spec = spec; in patch_simple_hdmi()
3220 simple_playback_free(codec); in patch_simple_hdmi()
3227 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3232 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
3257 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3260 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3266 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
3269 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3272 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
3276 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3279 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3285 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3287 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3291 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3299 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3303 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3305 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3312 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3313 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3320 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3324 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3329 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3330 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3335 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3350 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3352 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3358 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3364 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3371 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3373 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3378 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3385 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3387 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3406 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3409 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3414 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3415 /* override the PCM rates, etc, as the codec doesn't give full list */ in patch_nvhdmi_2ch()
3416 spec = codec->spec; in patch_nvhdmi_2ch()
3423 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3425 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3426 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3434 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3436 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3441 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3452 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3465 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3468 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3471 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3474 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3475 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3476 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3480 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3521 static int nvhdmi_port2pin(struct hda_codec *codec, int port) in nvhdmi_port2pin() argument
3533 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3538 err = alloc_generic_hdmi(codec); in patch_nvhdmi()
3541 codec->dp_mst = true; in patch_nvhdmi()
3543 spec = codec->spec; in patch_nvhdmi()
3546 err = hdmi_parse_codec(codec); in patch_nvhdmi()
3548 generic_spec_free(codec); in patch_nvhdmi()
3552 generic_hdmi_init_per_pins(codec); in patch_nvhdmi()
3560 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3562 generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin); in patch_nvhdmi()
3567 static int patch_nvhdmi_legacy(struct hda_codec *codec) in patch_nvhdmi_legacy() argument
3572 err = patch_generic_hdmi(codec); in patch_nvhdmi_legacy()
3576 spec = codec->spec; in patch_nvhdmi_legacy()
3583 codec->link_down_at_suspend = 1; in patch_nvhdmi_legacy()
3589 * The HDA codec on NVIDIA Tegra contains two scratch registers that are
3598 * The SCRATCH0 register is used to notify the HDMI codec of changes in audio
3600 * be raised in the HDMI codec. The remainder of the bits is arbitrary. This
3628 * the format is invalidated so that the HDMI codec can be disabled.
3630 static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) in tegra_hdmi_set_format() argument
3635 value = snd_hda_codec_read(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3640 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3643 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3648 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3662 * HDMI codec. The HDMI driver will use that as trigger to update its in tegra_hdmi_set_format()
3667 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3672 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3679 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3684 /* notify the HDMI codec of the format change */ in tegra_hdmi_pcm_prepare()
3685 tegra_hdmi_set_format(codec, format); in tegra_hdmi_pcm_prepare()
3691 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3694 /* invalidate the format in the HDMI codec */ in tegra_hdmi_pcm_cleanup()
3695 tegra_hdmi_set_format(codec, 0); in tegra_hdmi_pcm_cleanup()
3697 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3700 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3702 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3715 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
3721 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
3725 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
3731 * codec about format changes. in tegra_hdmi_build_pcms()
3740 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
3745 err = patch_generic_hdmi(codec); in patch_tegra_hdmi()
3749 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in patch_tegra_hdmi()
3750 spec = codec->spec; in patch_tegra_hdmi()
3762 #define is_amdhdmi_rev3_or_later(codec) \ argument
3763 ((codec)->core.vendor_id == 0x1002aa01 && \
3764 ((codec)->core.revision_id & 0xff00) >= 0x0300)
3765 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
3805 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
3810 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
3811 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
3814 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, in atihdmi_pin_setup_infoframe() argument
3819 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
3890 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_set_slot_channel() local
3897 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
3920 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
3926 struct hda_codec *codec = hdac_to_hda_codec(hdac); in atihdmi_pin_get_slot_channel() local
3935 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
3945 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
4008 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
4015 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
4022 codec_dbg(codec, in atihdmi_pin_hbr_setup()
4029 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
4039 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
4043 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
4049 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
4052 return hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in atihdmi_setup_stream()
4057 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
4059 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
4062 err = generic_hdmi_init(codec); in atihdmi_init()
4071 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
4074 if (has_amd_full_remap_support(codec)) in atihdmi_init()
4075 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
4079 codec->auto_runtime_pm = 1; in atihdmi_init()
4092 static int atihdmi_port2pin(struct hda_codec *codec, int port) in atihdmi_port2pin() argument
4104 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
4110 err = patch_generic_hdmi(codec); in patch_atihdmi()
4115 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4117 spec = codec->spec; in patch_atihdmi()
4127 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
4150 codec->link_down_at_suspend = 1; in patch_atihdmi()
4152 generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin); in patch_atihdmi()
4161 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
4163 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()
4292 MODULE_DESCRIPTION("HDMI HD-audio codec");
4293 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4294 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4295 MODULE_ALIAS("snd-hda-codec-atihdmi");