Lines Matching full:codec

40 #define is_haswell(codec)  ((codec)->core.vendor_id == 0x80862807)  argument
41 #define is_broadwell(codec) ((codec)->core.vendor_id == 0x80862808) argument
42 #define is_skylake(codec) ((codec)->core.vendor_id == 0x80862809) argument
43 #define is_broxton(codec) ((codec)->core.vendor_id == 0x8086280a) argument
44 #define is_kabylake(codec) ((codec)->core.vendor_id == 0x8086280b) argument
45 #define is_geminilake(codec) (((codec)->core.vendor_id == 0x8086280d) || \ argument
46 ((codec)->core.vendor_id == 0x80862800))
47 #define is_cannonlake(codec) ((codec)->core.vendor_id == 0x8086280c) argument
48 #define is_icelake(codec) ((codec)->core.vendor_id == 0x8086280f) argument
49 #define is_tigerlake(codec) ((codec)->core.vendor_id == 0x80862812) argument
50 #define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \ argument
51 || is_skylake(codec) || is_broxton(codec) \
52 || is_kabylake(codec) || is_geminilake(codec) \
53 || is_cannonlake(codec) || is_icelake(codec) \
54 || is_tigerlake(codec))
55 #define is_valleyview(codec) ((codec)->core.vendor_id == 0x80862882) argument
56 #define is_cherryview(codec) ((codec)->core.vendor_id == 0x80862883) argument
57 #define is_valleyview_plus(codec) (is_valleyview(codec) || is_cherryview(codec)) argument
82 struct hda_codec *codec; member
101 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
104 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
108 int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid, bool hbr);
110 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
113 void (*pin_cvt_fixup)(struct hda_codec *codec,
125 struct hda_codec *codec; member
184 static inline bool codec_has_acomp(struct hda_codec *codec) in codec_has_acomp() argument
186 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
190 #define codec_has_acomp(codec) false argument
238 static int pin_id_to_pin_index(struct hda_codec *codec, in pin_id_to_pin_index() argument
241 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
259 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid); in pin_id_to_pin_index()
263 static int hinfo_to_pcm_index(struct hda_codec *codec, in hinfo_to_pcm_index() argument
266 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
273 codec_warn(codec, "HDMI: hinfo %p not registered\n", hinfo); in hinfo_to_pcm_index()
277 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
280 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
291 codec_dbg(codec, "HDMI: hinfo %p not registered\n", hinfo); in hinfo_to_pin_index()
309 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
311 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
318 codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
326 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
352 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
353 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
396 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pcm_idx, in hdmi_create_eld_ctl() argument
400 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
403 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
412 err = snd_hda_ctl_add(codec, 0, kctl); in hdmi_create_eld_ctl()
421 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
426 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
434 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
441 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
444 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
447 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
450 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
452 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
456 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
457 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
469 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
501 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
505 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
506 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
520 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
543 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
546 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
547 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
554 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
557 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
558 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
562 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
568 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
569 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
572 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
574 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
579 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
586 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
591 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
593 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
594 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
596 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
601 codec_dbg(codec, in hdmi_clear_dip_buffers()
622 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
628 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
629 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
631 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
633 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
636 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
642 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
646 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
648 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
657 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
683 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n", in hdmi_pin_setup_infoframe()
693 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
695 codec_dbg(codec, in hdmi_pin_setup_infoframe()
699 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
700 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
702 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
706 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
710 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
722 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_setup_audio_infoframe()
723 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
729 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
735 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
746 spec->ops.pin_setup_infoframe(codec, pin_nid, ca, active_channels, in hdmi_setup_audio_infoframe()
758 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, in check_presence_and_report() argument
761 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
762 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id); in check_presence_and_report()
768 snd_hda_jack_report_sync(codec); in check_presence_and_report()
772 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
776 if (codec_has_acomp(codec)) in jack_callback()
780 check_presence_and_report(codec, jack->nid, 0); in jack_callback()
783 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_intrinsic_event() argument
795 jack = snd_hda_jack_tbl_get_from_tag(codec, tag); in hdmi_intrinsic_event()
800 codec_dbg(codec, in hdmi_intrinsic_event()
801 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_intrinsic_event()
802 codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
806 check_presence_and_report(codec, jack->nid, 0); in hdmi_intrinsic_event()
809 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
816 codec_info(codec, in hdmi_non_intrinsic_event()
817 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", in hdmi_non_intrinsic_event()
818 codec->addr, in hdmi_non_intrinsic_event()
832 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
837 if (codec_has_acomp(codec)) in hdmi_unsol_event()
840 if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) { in hdmi_unsol_event()
841 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
846 hdmi_intrinsic_event(codec, res); in hdmi_unsol_event()
848 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
851 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
859 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
860 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
862 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
863 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
866 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
868 codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
880 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
885 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
886 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
898 codec_dbg(codec, in hdmi_pin_hbr_setup()
905 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
914 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
917 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
921 err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format)); in hdmi_setup_stream()
924 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
928 if (is_haswell_plus(codec)) { in hdmi_setup_stream()
935 param = snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_setup_stream()
944 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_setup_stream()
948 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
957 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
960 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
1004 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1011 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1014 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1042 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1046 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1076 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1088 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
1089 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1090 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1093 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1099 * connection list are in the same order as in the codec. in intel_not_share_assigned_cvt()
1104 codec_dbg(codec, in intel_not_share_assigned_cvt()
1107 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1113 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1118 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
1122 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1131 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
1135 static void pin_cvt_fixup(struct hda_codec *codec, in pin_cvt_fixup() argument
1139 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1142 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1149 struct hda_codec *codec, in hdmi_pcm_open_no_pin() argument
1152 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1158 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open_no_pin()
1162 err = hdmi_choose_cvt(codec, -1, &cvt_idx); in hdmi_pcm_open_no_pin()
1170 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1197 struct hda_codec *codec, in hdmi_pcm_open() argument
1200 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1209 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open()
1214 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1225 err = hdmi_pcm_open_no_pin(hinfo, codec, substream); in hdmi_pcm_open()
1230 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in hdmi_pcm_open()
1243 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1244 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1249 pin_cvt_fixup(codec, per_pin, 0); in hdmi_pcm_open()
1251 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1268 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_open()
1290 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1292 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1296 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1297 codec_warn(codec, in hdmi_read_pin_conn()
1299 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1304 per_pin->num_mux_nids = snd_hda_get_connections(codec, pin_nid, in hdmi_read_pin_conn()
1376 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid);
1381 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin() local
1405 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1407 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1411 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1413 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1419 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in hdmi_pcm_setup_pin()
1426 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1438 static bool update_eld(struct hda_codec *codec, in update_eld() argument
1443 struct hdmi_spec *spec = codec->spec; in update_eld()
1466 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1493 pin_cvt_fixup(codec, per_pin, 0); in update_eld()
1494 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1498 snd_ctl_notify(codec->card, in update_eld()
1510 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs() local
1511 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1526 present = snd_hda_pin_sense(codec, pin_nid); in hdmi_present_sense_via_verbs()
1535 codec_dbg(codec, in hdmi_present_sense_via_verbs()
1536 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", in hdmi_present_sense_via_verbs()
1537 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1540 if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer, in hdmi_present_sense_via_verbs()
1544 if (snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in hdmi_present_sense_via_verbs()
1555 update_eld(codec, per_pin, eld); in hdmi_present_sense_via_verbs()
1559 jack = snd_hda_jack_tbl_get(codec, pin_nid); in hdmi_present_sense_via_verbs()
1569 static struct snd_jack *pin_idx_to_jack(struct hda_codec *codec, in pin_idx_to_jack() argument
1572 struct hdmi_spec *spec = codec->spec; in pin_idx_to_jack()
1590 jack_tbl = snd_hda_jack_tbl_get(codec, per_pin->pin_nid); in pin_idx_to_jack()
1598 static void sync_eld_via_acomp(struct hda_codec *codec, in sync_eld_via_acomp() argument
1601 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1609 size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1614 if (snd_hdmi_parse_eld(codec, &eld->info, in sync_eld_via_acomp()
1630 jack = pin_idx_to_jack(codec, per_pin); in sync_eld_via_acomp()
1631 changed = update_eld(codec, per_pin, eld); in sync_eld_via_acomp()
1633 jack = pin_idx_to_jack(codec, per_pin); in sync_eld_via_acomp()
1643 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1647 if (!codec_has_acomp(codec)) { in hdmi_present_sense()
1648 ret = snd_hda_power_up_pm(codec); in hdmi_present_sense()
1649 if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) { in hdmi_present_sense()
1650 snd_hda_power_down_pm(codec); in hdmi_present_sense()
1654 snd_hda_power_down_pm(codec); in hdmi_present_sense()
1656 sync_eld_via_acomp(codec, per_pin); in hdmi_present_sense()
1667 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld() local
1668 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1671 jack = snd_hda_jack_tbl_get(codec, per_pin->pin_nid); in hdmi_repoll_eld()
1680 snd_hda_jack_report_sync(per_pin->codec); in hdmi_repoll_eld()
1684 static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
1687 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1689 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1696 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1704 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1712 if (is_haswell_plus(codec)) { in hdmi_add_pin()
1724 } else if (spec->dyn_pcm_assign && codec->dp_mst) { in hdmi_add_pin()
1725 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; in hdmi_add_pin()
1760 snd_hda_set_dev_select(codec, pin_nid, i); in hdmi_add_pin()
1761 if (is_haswell_plus(codec)) in hdmi_add_pin()
1762 intel_haswell_fixup_connect_list(codec, pin_nid); in hdmi_add_pin()
1763 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1773 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1775 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1780 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1795 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
1809 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1814 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &nid); in hdmi_parse_codec()
1816 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
1824 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
1832 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
1835 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
1845 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
1850 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
1851 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
1858 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
1867 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
1873 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
1883 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
1889 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
1890 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
1910 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
1914 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
1915 snd_hdac_sync_audio_rate(&codec->core, pin_nid, per_pin->dev_id, in generic_hdmi_playback_pcm_prepare()
1918 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
1923 if (get_wcaps(codec, cvt_nid) & AC_WCAP_STRIPE) { in generic_hdmi_playback_pcm_prepare()
1924 stripe = snd_hdac_get_stream_stripe_ctl(&codec->bus->core, in generic_hdmi_playback_pcm_prepare()
1926 snd_hda_codec_write(codec, cvt_nid, 0, in generic_hdmi_playback_pcm_prepare()
1931 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
1934 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
1936 snd_hda_codec_write(codec, pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
1942 err = spec->ops.setup_stream(codec, cvt_nid, pin_nid, in generic_hdmi_playback_pcm_prepare()
1950 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
1953 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
1958 struct hda_codec *codec, in hdmi_pcm_close() argument
1961 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
1969 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
1972 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
1982 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
1984 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
1995 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
1997 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2025 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in hdmi_get_spk_alloc() local
2026 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2038 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in hdmi_get_chmap() local
2039 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2052 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in hdmi_set_chmap() local
2053 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2062 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2068 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in is_hdmi_pcm_attached() local
2069 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2075 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2077 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2090 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2118 static int add_hdmi_jack_kctl(struct hda_codec *codec, in add_hdmi_jack_kctl() argument
2126 err = snd_jack_new(codec->card, name, SND_JACK_AVOUT, &jack, in add_hdmi_jack_kctl()
2137 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2140 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2151 return add_hdmi_jack_kctl(codec, spec, pcm_idx, hdmi_str); in generic_hdmi_build_jack()
2159 phantom_jack = !is_jack_detectable(codec, per_pin->pin_nid); in generic_hdmi_build_jack()
2163 ret = snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str, in generic_hdmi_build_jack()
2167 jack = snd_hda_jack_tbl_get(codec, per_pin->pin_nid); in generic_hdmi_build_jack()
2177 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2179 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2190 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2198 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2204 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2211 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2216 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); in generic_hdmi_build_controls()
2243 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2245 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2251 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2259 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2261 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2265 spec->use_jack_detect = !codec->jackpoll_interval; in generic_hdmi_init()
2271 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2272 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2273 if (codec_has_acomp(codec)) in generic_hdmi_init()
2276 snd_hda_jack_detect_enable(codec, pin_nid); in generic_hdmi_init()
2278 snd_hda_jack_detect_enable_callback(codec, pin_nid, in generic_hdmi_init()
2297 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2299 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2304 codec->spec = NULL; in generic_spec_free()
2306 codec->dp_mst = false; in generic_spec_free()
2309 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2311 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2315 snd_hdac_acomp_exit(&codec->bus->core); in generic_hdmi_free()
2316 } else if (codec_has_acomp(codec)) { in generic_hdmi_free()
2317 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2318 codec->relaxed_resume = 0; in generic_hdmi_free()
2331 snd_device_free(codec->card, in generic_hdmi_free()
2337 generic_spec_free(codec); in generic_hdmi_free()
2341 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2343 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2346 codec->patch_ops.init(codec); in generic_hdmi_resume()
2347 regcache_sync(codec->core.regmap); in generic_hdmi_resume()
2375 /* allocate codec->spec and assign/initialize generic parser ops */
2376 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2384 spec->codec = codec; in alloc_generic_hdmi()
2389 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2396 codec->spec = spec; in alloc_generic_hdmi()
2399 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2405 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2409 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2413 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2415 generic_spec_free(codec); in patch_generic_hdmi()
2419 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2428 static void reprogram_jack_detect(struct hda_codec *codec, hda_nid_t nid, in reprogram_jack_detect() argument
2433 tbl = snd_hda_jack_tbl_get(codec, nid); in reprogram_jack_detect()
2439 snd_hda_codec_write_cache(codec, nid, 0, in reprogram_jack_detect()
2446 snd_hda_jack_detect_enable(codec, nid); in reprogram_jack_detect()
2460 spec->codec->relaxed_resume = use_acomp; in generic_acomp_notifier_set()
2464 reprogram_jack_detect(spec->codec, in generic_acomp_notifier_set()
2501 struct hda_codec *codec = audio_ptr; in generic_acomp_pin_eld_notify() local
2502 struct hdmi_spec *spec = codec->spec; in generic_acomp_pin_eld_notify()
2503 hda_nid_t pin_nid = spec->port2pin(codec, port); in generic_acomp_pin_eld_notify()
2507 if (get_wcaps_type(get_wcaps(codec, pin_nid)) != AC_WID_PIN) in generic_acomp_pin_eld_notify()
2512 if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0) in generic_acomp_pin_eld_notify()
2515 if (snd_hdac_is_in_pm(&codec->core)) in generic_acomp_pin_eld_notify()
2518 check_presence_and_report(codec, pin_nid, dev_id); in generic_acomp_pin_eld_notify()
2522 static void setup_drm_audio_ops(struct hda_codec *codec, in setup_drm_audio_ops() argument
2525 struct hdmi_spec *spec = codec->spec; in setup_drm_audio_ops()
2527 spec->drm_audio_ops.audio_ptr = codec; in setup_drm_audio_ops()
2540 static void generic_acomp_init(struct hda_codec *codec, in generic_acomp_init() argument
2544 struct hdmi_spec *spec = codec->spec; in generic_acomp_init()
2547 setup_drm_audio_ops(codec, ops); in generic_acomp_init()
2548 if (!snd_hdac_acomp_init(&codec->bus->core, &spec->drm_audio_ops, in generic_acomp_init()
2551 codec->bus->keep_power = 0; in generic_acomp_init()
2556 * Intel codec parsers and helpers
2559 static void intel_haswell_fixup_connect_list(struct hda_codec *codec, in intel_haswell_fixup_connect_list() argument
2562 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_connect_list()
2566 nconns = snd_hda_get_connections(codec, nid, conns, ARRAY_SIZE(conns)); in intel_haswell_fixup_connect_list()
2572 codec_dbg(codec, "hdmi: haswell: override pin connection 0x%x\n", nid); in intel_haswell_fixup_connect_list()
2573 snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids); in intel_haswell_fixup_connect_list()
2581 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2585 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2587 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2593 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2599 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2602 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2605 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2607 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2614 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2615 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2622 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2626 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2627 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2630 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2631 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2645 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2647 switch (codec->core.vendor_id) { in intel_base_nid()
2659 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
2660 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
2664 base_nid = intel_base_nid(codec); in intel_pin2port()
2680 codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid); in intel_pin2port()
2684 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
2686 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
2693 return port + intel_base_nid(codec) - 1; in intel_port2pin()
2703 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2707 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
2713 if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0) in intel_pin_eld_notify()
2716 if (snd_hdac_is_in_pm(&codec->core)) in intel_pin_eld_notify()
2719 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2720 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2729 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2731 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2735 setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
2736 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2739 codec->relaxed_resume = 1; in register_i915_notifier()
2743 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2746 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2747 return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); in i915_hsw_setup_stream()
2751 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2756 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2758 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2759 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2762 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2767 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
2772 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
2773 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
2775 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
2779 err = alloc_generic_hdmi(codec); in alloc_intel_hdmi()
2783 codec->patch_ops.unsol_event = NULL; in alloc_intel_hdmi()
2788 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
2792 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
2794 generic_spec_free(codec); in parse_intel_hdmi()
2798 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
2799 register_i915_notifier(codec); in parse_intel_hdmi()
2804 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
2810 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
2813 spec = codec->spec; in intel_hsw_common_init()
2814 codec->dp_mst = true; in intel_hsw_common_init()
2820 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
2821 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
2823 codec->display_power_control = 1; in intel_hsw_common_init()
2825 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
2826 codec->depop_delay = 0; in intel_hsw_common_init()
2827 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
2832 return parse_intel_hdmi(codec); in intel_hsw_common_init()
2835 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
2837 return intel_hsw_common_init(codec, 0x08, NULL, 0); in patch_i915_hsw_hdmi()
2840 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
2842 return intel_hsw_common_init(codec, 0x0b, NULL, 0); in patch_i915_glk_hdmi()
2845 static int patch_i915_icl_hdmi(struct hda_codec *codec) in patch_i915_icl_hdmi() argument
2853 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_icl_hdmi()
2856 static int patch_i915_tgl_hdmi(struct hda_codec *codec) in patch_i915_tgl_hdmi() argument
2864 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); in patch_i915_tgl_hdmi()
2869 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
2874 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
2877 spec = codec->spec; in patch_i915_byt_hdmi()
2879 /* For Valleyview/Cherryview, only the display codec is in the display in patch_i915_byt_hdmi()
2882 codec->display_power_control = 1; in patch_i915_byt_hdmi()
2884 codec->depop_delay = 0; in patch_i915_byt_hdmi()
2885 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
2889 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
2893 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
2897 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
2900 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
2907 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
2909 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
2916 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
2919 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
2934 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
2937 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
2938 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
2946 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
2948 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
2953 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
2958 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
2961 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
2963 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
2967 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
2970 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
2971 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
2973 snd_hda_jack_detect_enable(codec, pin); in simple_playback_init()
2977 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
2979 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
3038 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
3040 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
3044 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
3046 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
3071 struct hda_codec *codec, in simple_playback_pcm_open() argument
3074 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
3077 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
3100 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
3104 struct hda_codec *codec, in simple_playback_pcm_close() argument
3107 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
3108 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
3112 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
3117 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
3118 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
3141 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
3152 spec->codec = codec; in patch_simple_hdmi()
3153 codec->spec = spec; in patch_simple_hdmi()
3164 simple_playback_free(codec); in patch_simple_hdmi()
3171 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
3176 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
3201 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3204 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
3210 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
3213 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
3216 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
3220 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3223 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3229 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3231 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3235 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3243 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3247 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3249 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3256 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3257 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3264 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3268 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3273 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3274 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3279 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3294 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3296 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3302 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3308 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3315 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3317 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3322 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3329 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3331 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3350 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3353 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3358 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3359 /* override the PCM rates, etc, as the codec doesn't give full list */ in patch_nvhdmi_2ch()
3360 spec = codec->spec; in patch_nvhdmi_2ch()
3367 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3369 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3370 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3378 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3380 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3385 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3396 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3409 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3412 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3415 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3418 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3419 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3420 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3424 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3465 static int nvhdmi_port2pin(struct hda_codec *codec, int port) in nvhdmi_port2pin() argument
3477 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3482 err = patch_generic_hdmi(codec); in patch_nvhdmi()
3486 spec = codec->spec; in patch_nvhdmi()
3493 codec->link_down_at_suspend = 1; in patch_nvhdmi()
3495 generic_acomp_init(codec, &nvhdmi_audio_ops, nvhdmi_port2pin); in patch_nvhdmi()
3501 * The HDA codec on NVIDIA Tegra contains two scratch registers that are
3510 * The SCRATCH0 register is used to notify the HDMI codec of changes in audio
3512 * be raised in the HDMI codec. The remainder of the bits is arbitrary. This
3540 * the format is invalidated so that the HDMI codec can be disabled.
3542 static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) in tegra_hdmi_set_format() argument
3547 value = snd_hda_codec_read(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3552 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3555 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3560 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3574 * HDMI codec. The HDMI driver will use that as trigger to update its in tegra_hdmi_set_format()
3579 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3584 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3591 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3596 /* notify the HDMI codec of the format change */ in tegra_hdmi_pcm_prepare()
3597 tegra_hdmi_set_format(codec, format); in tegra_hdmi_pcm_prepare()
3603 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3606 /* invalidate the format in the HDMI codec */ in tegra_hdmi_pcm_cleanup()
3607 tegra_hdmi_set_format(codec, 0); in tegra_hdmi_pcm_cleanup()
3609 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3612 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3614 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3627 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
3633 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
3637 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
3643 * codec about format changes. in tegra_hdmi_build_pcms()
3652 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
3656 err = patch_generic_hdmi(codec); in patch_tegra_hdmi()
3660 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in patch_tegra_hdmi()
3669 #define is_amdhdmi_rev3_or_later(codec) \ argument
3670 ((codec)->core.vendor_id == 0x1002aa01 && \
3671 ((codec)->core.revision_id & 0xff00) >= 0x0300)
3672 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
3712 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
3716 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
3717 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
3720 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, hda_nid_t pin_nid, int ca, in atihdmi_pin_setup_infoframe() argument
3723 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
3794 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in atihdmi_pin_set_slot_channel() local
3801 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
3824 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
3830 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in atihdmi_pin_get_slot_channel() local
3839 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
3849 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
3912 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
3917 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
3924 codec_dbg(codec, in atihdmi_pin_hbr_setup()
3931 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
3941 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
3945 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
3951 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
3954 return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); in atihdmi_setup_stream()
3958 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
3960 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
3963 err = generic_hdmi_init(codec); in atihdmi_init()
3972 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
3975 if (has_amd_full_remap_support(codec)) in atihdmi_init()
3976 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
3992 static int atihdmi_port2pin(struct hda_codec *codec, int port) in atihdmi_port2pin() argument
4004 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
4010 err = patch_generic_hdmi(codec); in patch_atihdmi()
4015 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
4017 spec = codec->spec; in patch_atihdmi()
4027 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
4050 codec->link_down_at_suspend = 1; in patch_atihdmi()
4052 generic_acomp_init(codec, &atihdmi_audio_ops, atihdmi_port2pin); in patch_atihdmi()
4061 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
4063 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()
4182 MODULE_DESCRIPTION("HDMI HD-audio codec");
4183 MODULE_ALIAS("snd-hda-codec-intelhdmi");
4184 MODULE_ALIAS("snd-hda-codec-nvhdmi");
4185 MODULE_ALIAS("snd-hda-codec-atihdmi");