Lines Matching refs:codec

48 #define is_haswell(codec)  ((codec)->core.vendor_id == 0x80862807)  argument
49 #define is_broadwell(codec) ((codec)->core.vendor_id == 0x80862808) argument
50 #define is_skylake(codec) ((codec)->core.vendor_id == 0x80862809) argument
51 #define is_broxton(codec) ((codec)->core.vendor_id == 0x8086280a) argument
52 #define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \ argument
53 || is_skylake(codec) || is_broxton(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
79 struct hda_codec *codec; member
99 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
103 int (*pin_get_slot_channel)(struct hda_codec *codec, hda_nid_t pin_nid,
105 int (*pin_set_slot_channel)(struct hda_codec *codec, hda_nid_t pin_nid,
108 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
112 int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid, bool hbr);
114 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
360 static int pin_nid_to_pin_index(struct hda_codec *codec, hda_nid_t pin_nid) in pin_nid_to_pin_index() argument
362 struct hdmi_spec *spec = codec->spec; in pin_nid_to_pin_index()
369 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid); in pin_nid_to_pin_index()
373 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
376 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
383 codec_warn(codec, "HDMI: hinfo %p not registered\n", hinfo); in hinfo_to_pin_index()
387 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
389 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
396 codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
404 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
425 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
426 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
461 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pin_idx, in hdmi_create_eld_ctl() argument
465 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
468 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
474 err = snd_hda_ctl_add(codec, get_pin(spec, pin_idx)->pin_nid, kctl); in hdmi_create_eld_ctl()
483 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
488 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
496 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
503 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
506 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
509 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
512 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
514 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
518 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
519 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
531 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
535 static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_get_channel_count() argument
537 return 1 + snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_get_channel_count()
541 static void hdmi_set_channel_count(struct hda_codec *codec, in hdmi_set_channel_count() argument
544 if (chs != hdmi_get_channel_count(codec, cvt_nid)) in hdmi_set_channel_count()
545 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_set_channel_count()
577 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
581 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
582 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
596 if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) { in eld_proc_free()
597 snd_device_free(per_pin->codec->card, per_pin->proc_entry); in eld_proc_free()
655 static int hdmi_channel_allocation(struct hda_codec *codec, in hdmi_channel_allocation() argument
702 codec_dbg(codec, "HDMI: select CA 0x%x for %d-channel allocation: %s\n", in hdmi_channel_allocation()
708 static void hdmi_debug_channel_mapping(struct hda_codec *codec, in hdmi_debug_channel_mapping() argument
712 struct hdmi_spec *spec = codec->spec; in hdmi_debug_channel_mapping()
717 channel = spec->ops.pin_get_slot_channel(codec, pin_nid, i); in hdmi_debug_channel_mapping()
718 codec_dbg(codec, "HDMI: ASP channel %d => slot %d\n", in hdmi_debug_channel_mapping()
724 static void hdmi_std_setup_channel_mapping(struct hda_codec *codec, in hdmi_std_setup_channel_mapping() argument
729 struct hdmi_spec *spec = codec->spec; in hdmi_std_setup_channel_mapping()
765 err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, channel); in hdmi_std_setup_channel_mapping()
767 codec_dbg(codec, "HDMI: channel mapping failed\n"); in hdmi_std_setup_channel_mapping()
869 static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec, in hdmi_manual_setup_channel_mapping() argument
874 struct hdmi_spec *spec = codec->spec; in hdmi_manual_setup_channel_mapping()
892 err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, in hdmi_manual_setup_channel_mapping()
913 static void hdmi_setup_channel_mapping(struct hda_codec *codec, in hdmi_setup_channel_mapping() argument
919 hdmi_manual_setup_channel_mapping(codec, pin_nid, in hdmi_setup_channel_mapping()
922 hdmi_std_setup_channel_mapping(codec, pin_nid, non_pcm, ca); in hdmi_setup_channel_mapping()
926 hdmi_debug_channel_mapping(codec, pin_nid); in hdmi_setup_channel_mapping()
929 static int hdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_set_slot_channel() argument
932 return snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_set_slot_channel()
937 static int hdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_get_slot_channel() argument
940 return (snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_get_slot_channel()
952 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
955 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
956 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
963 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
966 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
967 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
971 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
977 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
978 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
981 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
983 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
988 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
995 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
1000 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
1002 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
1003 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
1005 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
1010 codec_dbg(codec, in hdmi_clear_dip_buffers()
1031 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
1037 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
1038 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
1040 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
1042 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
1045 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
1051 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
1055 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
1057 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
1066 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
1092 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n", in hdmi_pin_setup_infoframe()
1102 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
1104 codec_dbg(codec, in hdmi_pin_setup_infoframe()
1108 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
1109 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
1111 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
1115 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
1119 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
1129 if (is_haswell_plus(codec)) in hdmi_setup_audio_infoframe()
1130 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
1139 ca = hdmi_channel_allocation(codec, eld, channels); in hdmi_setup_audio_infoframe()
1146 hdmi_set_channel_count(codec, per_pin->cvt_nid, active_channels); in hdmi_setup_audio_infoframe()
1152 hdmi_setup_channel_mapping(codec, pin_nid, non_pcm, ca, in hdmi_setup_audio_infoframe()
1156 spec->ops.pin_setup_infoframe(codec, pin_nid, ca, active_channels, in hdmi_setup_audio_infoframe()
1168 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid) in check_presence_and_report() argument
1170 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
1171 int pin_idx = pin_nid_to_pin_index(codec, nid); in check_presence_and_report()
1176 snd_hda_jack_report_sync(codec); in check_presence_and_report()
1179 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
1182 check_presence_and_report(codec, jack->nid); in jack_callback()
1185 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_intrinsic_event() argument
1191 jack = snd_hda_jack_tbl_get_from_tag(codec, tag); in hdmi_intrinsic_event()
1196 codec_dbg(codec, in hdmi_intrinsic_event()
1198 codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
1201 check_presence_and_report(codec, jack->nid); in hdmi_intrinsic_event()
1204 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
1211 codec_info(codec, in hdmi_non_intrinsic_event()
1213 codec->addr, in hdmi_non_intrinsic_event()
1227 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
1232 if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) { in hdmi_unsol_event()
1233 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
1238 hdmi_intrinsic_event(codec, res); in hdmi_unsol_event()
1240 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
1243 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
1251 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
1252 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
1254 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
1255 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
1258 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
1260 codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
1272 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
1277 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
1278 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
1290 codec_dbg(codec, in hdmi_pin_hbr_setup()
1297 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
1306 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
1309 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
1312 if (is_haswell_plus(codec)) in hdmi_setup_stream()
1313 haswell_verify_D0(codec, cvt_nid, pin_nid); in hdmi_setup_stream()
1315 err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format)); in hdmi_setup_stream()
1318 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
1322 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
1326 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
1329 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
1368 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1375 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1378 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1392 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1395 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1401 for_each_hda_codec_node(nid, codec) { in intel_not_share_assigned_cvt()
1402 unsigned int wid_caps = get_wcaps(codec, nid); in intel_not_share_assigned_cvt()
1411 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1422 codec_dbg(codec, in intel_not_share_assigned_cvt()
1425 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1438 struct hda_codec *codec, in hdmi_pcm_open() argument
1441 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1450 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1456 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx, &mux_idx); in hdmi_pcm_open()
1466 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1471 if (is_haswell_plus(codec) || is_valleyview_plus(codec)) in hdmi_pcm_open()
1472 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, mux_idx); in hdmi_pcm_open()
1474 snd_hda_spdif_ctls_assign(codec, pin_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1490 snd_hda_spdif_ctls_unassign(codec, pin_idx); in hdmi_pcm_open()
1509 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1511 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1515 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1516 codec_warn(codec, in hdmi_read_pin_conn()
1518 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1522 per_pin->num_mux_nids = snd_hda_get_connections(codec, pin_nid, in hdmi_read_pin_conn()
1532 static void update_eld(struct hda_codec *codec, in update_eld() argument
1541 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1564 if (is_haswell_plus(codec) || is_valleyview_plus(codec)) { in update_eld()
1565 intel_verify_pin_cvt_connect(codec, per_pin); in update_eld()
1566 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in update_eld()
1570 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1574 snd_ctl_notify(codec->card, in update_eld()
1583 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1584 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense()
1599 snd_hda_power_up_pm(codec); in hdmi_present_sense()
1600 present = snd_hda_pin_sense(codec, pin_nid); in hdmi_present_sense()
1611 codec_dbg(codec, in hdmi_present_sense()
1613 codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid); in hdmi_present_sense()
1616 if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer, in hdmi_present_sense()
1621 if (snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in hdmi_present_sense()
1630 update_eld(codec, per_pin, eld); in hdmi_present_sense()
1634 jack = snd_hda_jack_tbl_get(codec, pin_nid); in hdmi_present_sense()
1639 snd_hda_power_down_pm(codec); in hdmi_present_sense()
1652 snd_hda_jack_report_sync(per_pin->codec); in hdmi_repoll_eld()
1655 static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
1658 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1660 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1666 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1670 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1674 if (is_haswell_plus(codec)) in hdmi_add_pin()
1675 intel_haswell_fixup_connect_list(codec, pin_nid); in hdmi_add_pin()
1685 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1694 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1696 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1701 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1716 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
1730 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1735 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &nid); in hdmi_parse_codec()
1737 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
1745 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
1753 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
1756 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
1766 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
1771 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
1772 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
1774 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
1784 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
1790 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
1791 int pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
1797 if (is_haswell_plus(codec) || is_valleyview_plus(codec)) { in generic_hdmi_playback_pcm_prepare()
1806 intel_verify_pin_cvt_connect(codec, per_pin); in generic_hdmi_playback_pcm_prepare()
1807 intel_not_share_assigned_cvt(codec, pin_nid, per_pin->mux_idx); in generic_hdmi_playback_pcm_prepare()
1810 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
1815 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
1819 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
1821 snd_hda_codec_write(codec, pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
1826 return spec->ops.setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); in generic_hdmi_playback_pcm_prepare()
1830 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
1833 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
1838 struct hda_codec *codec, in hdmi_pcm_close() argument
1841 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
1848 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
1857 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
1863 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
1865 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
1870 snd_hda_spdif_ctls_unassign(codec, pin_idx); in hdmi_pcm_close()
1898 struct hda_codec *codec = info->private_data; in hdmi_chmap_ctl_info() local
1899 struct hdmi_spec *spec = codec->spec; in hdmi_chmap_ctl_info()
1939 struct hda_codec *codec = info->private_data; in hdmi_chmap_ctl_tlv() local
1940 struct hdmi_spec *spec = codec->spec; in hdmi_chmap_ctl_tlv()
1988 struct hda_codec *codec = info->private_data; in hdmi_chmap_ctl_get() local
1989 struct hdmi_spec *spec = codec->spec; in hdmi_chmap_ctl_get()
2003 struct hda_codec *codec = info->private_data; in hdmi_chmap_ctl_put() local
2004 struct hdmi_spec *spec = codec->spec; in hdmi_chmap_ctl_put()
2043 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_chmap_ctl_put()
2049 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2051 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2060 info = snd_hda_codec_pcm_new(codec, "HDMI %d", pin_idx); in generic_hdmi_build_pcms()
2076 static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx) in generic_hdmi_build_jack() argument
2079 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2085 if (!is_jack_detectable(codec, per_pin->pin_nid)) in generic_hdmi_build_jack()
2089 return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str, 0); in generic_hdmi_build_jack()
2092 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2094 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2101 err = generic_hdmi_build_jack(codec, pin_idx); in generic_hdmi_build_controls()
2105 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2111 snd_hda_spdif_ctls_unassign(codec, pin_idx); in generic_hdmi_build_controls()
2114 err = hdmi_create_eld_ctl(codec, pin_idx, in generic_hdmi_build_controls()
2139 chmap->private_data = codec; in generic_hdmi_build_controls()
2152 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2154 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2160 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2168 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2170 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2177 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2178 snd_hda_jack_detect_enable_callback(codec, pin_nid, in generic_hdmi_init()
2179 codec->jackpoll_interval > 0 ? jack_callback : NULL); in generic_hdmi_init()
2196 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2198 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2213 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2215 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2218 codec->patch_ops.init(codec); in generic_hdmi_resume()
2219 regcache_sync(codec->core.regmap); in generic_hdmi_resume()
2252 static void intel_haswell_fixup_connect_list(struct hda_codec *codec, in intel_haswell_fixup_connect_list() argument
2255 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_connect_list()
2259 nconns = snd_hda_get_connections(codec, nid, conns, ARRAY_SIZE(conns)); in intel_haswell_fixup_connect_list()
2265 codec_dbg(codec, "hdmi: haswell: override pin connection 0x%x\n", nid); in intel_haswell_fixup_connect_list()
2266 snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids); in intel_haswell_fixup_connect_list()
2275 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2280 vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0, in intel_haswell_enable_all_pins()
2286 vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0, in intel_haswell_enable_all_pins()
2292 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2295 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2299 vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0, in intel_haswell_fixup_enable_dp12()
2306 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2307 snd_hda_codec_write_cache(codec, INTEL_VENDOR_NID, 0, in intel_haswell_fixup_enable_dp12()
2314 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2318 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2319 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2322 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2323 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2326 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2335 codec->spec = spec; in patch_generic_hdmi()
2338 if (is_haswell_plus(codec)) { in patch_generic_hdmi()
2339 intel_haswell_enable_all_pins(codec, true); in patch_generic_hdmi()
2340 intel_haswell_fixup_enable_dp12(codec); in patch_generic_hdmi()
2343 if (is_haswell_plus(codec) || is_valleyview_plus(codec)) in patch_generic_hdmi()
2344 codec->depop_delay = 0; in patch_generic_hdmi()
2346 if (hdmi_parse_codec(codec) < 0) { in patch_generic_hdmi()
2347 codec->spec = NULL; in patch_generic_hdmi()
2351 codec->patch_ops = generic_hdmi_patch_ops; in patch_generic_hdmi()
2352 if (is_haswell_plus(codec)) { in patch_generic_hdmi()
2353 codec->patch_ops.set_power_state = haswell_set_power_state; in patch_generic_hdmi()
2354 codec->dp_mst = true; in patch_generic_hdmi()
2357 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2368 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
2370 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
2377 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
2380 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
2395 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
2398 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
2399 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
2407 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
2409 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
2414 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
2419 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
2422 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
2424 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
2428 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
2431 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
2432 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
2434 snd_hda_jack_detect_enable(codec, pin); in simple_playback_init()
2438 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
2440 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
2499 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
2501 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
2505 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
2507 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
2532 struct hda_codec *codec, in simple_playback_pcm_open() argument
2535 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
2538 switch (codec->preset->id) { in simple_playback_pcm_open()
2561 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
2565 struct hda_codec *codec, in simple_playback_pcm_close() argument
2568 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
2569 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
2573 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
2578 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
2579 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
2602 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
2613 codec->spec = spec; in patch_simple_hdmi()
2624 simple_playback_free(codec); in patch_simple_hdmi()
2631 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
2636 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
2661 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
2664 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
2670 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
2673 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
2676 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
2680 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
2683 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
2689 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
2691 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
2695 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
2703 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
2707 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
2709 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
2716 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
2717 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
2724 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
2728 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
2733 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
2734 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
2739 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
2754 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
2756 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
2762 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
2768 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
2775 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
2777 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
2782 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
2789 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
2791 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
2810 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
2813 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
2818 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
2820 spec = codec->spec; in patch_nvhdmi_2ch()
2827 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
2829 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
2830 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
2838 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
2840 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
2845 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
2856 switch (codec->preset->id) { in nvhdmi_7x_8ch_build_controls()
2869 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
2872 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
2875 spec = codec->spec; in patch_nvhdmi_8ch_7x()
2878 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
2879 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
2880 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
2884 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
2911 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
2916 err = patch_generic_hdmi(codec); in patch_nvhdmi()
2920 spec = codec->spec; in patch_nvhdmi()
2934 #define is_amdhdmi_rev3_or_later(codec) \ argument
2935 ((codec)->core.vendor_id == 0x1002aa01 && \
2936 ((codec)->core.revision_id & 0xff00) >= 0x0300)
2937 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
2977 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
2981 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
2982 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
2985 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, hda_nid_t pin_nid, int ca, in atihdmi_pin_setup_infoframe() argument
2988 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
3055 static int atihdmi_pin_set_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_set_slot_channel() argument
3064 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
3087 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
3090 static int atihdmi_pin_get_slot_channel(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_get_slot_channel() argument
3101 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
3111 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
3171 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
3176 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
3183 codec_dbg(codec, in atihdmi_pin_hbr_setup()
3190 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
3200 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
3204 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
3210 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
3213 return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); in atihdmi_setup_stream()
3217 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
3219 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
3222 err = generic_hdmi_init(codec); in atihdmi_init()
3231 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
3234 if (has_amd_full_remap_support(codec)) in atihdmi_init()
3235 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
3243 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
3249 err = patch_generic_hdmi(codec); in patch_atihdmi()
3254 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
3256 spec = codec->spec; in patch_atihdmi()
3265 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
3291 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
3293 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()