Lines Matching refs:codec
52 #define is_haswell(codec) ((codec)->core.vendor_id == 0x80862807) argument
53 #define is_broadwell(codec) ((codec)->core.vendor_id == 0x80862808) argument
54 #define is_skylake(codec) ((codec)->core.vendor_id == 0x80862809) argument
55 #define is_broxton(codec) ((codec)->core.vendor_id == 0x8086280a) argument
56 #define is_kabylake(codec) ((codec)->core.vendor_id == 0x8086280b) argument
57 #define is_geminilake(codec) (((codec)->core.vendor_id == 0x8086280d) || \ argument
58 ((codec)->core.vendor_id == 0x80862800))
59 #define is_cannonlake(codec) ((codec)->core.vendor_id == 0x8086280c) argument
60 #define is_haswell_plus(codec) (is_haswell(codec) || is_broadwell(codec) \ argument
61 || is_skylake(codec) || is_broxton(codec) \
62 || is_kabylake(codec)) || is_geminilake(codec) \
63 || is_cannonlake(codec)
64 #define is_valleyview(codec) ((codec)->core.vendor_id == 0x80862882) argument
65 #define is_cherryview(codec) ((codec)->core.vendor_id == 0x80862883) argument
66 #define is_valleyview_plus(codec) (is_valleyview(codec) || is_cherryview(codec)) argument
91 struct hda_codec *codec; member
110 int (*pin_get_eld)(struct hda_codec *codec, hda_nid_t pin_nid,
113 void (*pin_setup_infoframe)(struct hda_codec *codec, hda_nid_t pin_nid,
117 int (*pin_hbr_setup)(struct hda_codec *codec, hda_nid_t pin_nid, bool hbr);
119 int (*setup_stream)(struct hda_codec *codec, hda_nid_t cvt_nid,
122 void (*pin_cvt_fixup)(struct hda_codec *codec,
187 static inline bool codec_has_acomp(struct hda_codec *codec) in codec_has_acomp() argument
189 struct hdmi_spec *spec = codec->spec; in codec_has_acomp()
193 #define codec_has_acomp(codec) false argument
241 static int pin_id_to_pin_index(struct hda_codec *codec, in pin_id_to_pin_index() argument
244 struct hdmi_spec *spec = codec->spec; in pin_id_to_pin_index()
262 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid); in pin_id_to_pin_index()
266 static int hinfo_to_pcm_index(struct hda_codec *codec, in hinfo_to_pcm_index() argument
269 struct hdmi_spec *spec = codec->spec; in hinfo_to_pcm_index()
276 codec_warn(codec, "HDMI: hinfo %p not registered\n", hinfo); in hinfo_to_pcm_index()
280 static int hinfo_to_pin_index(struct hda_codec *codec, in hinfo_to_pin_index() argument
283 struct hdmi_spec *spec = codec->spec; in hinfo_to_pin_index()
294 codec_dbg(codec, "HDMI: hinfo %p not registered\n", hinfo); in hinfo_to_pin_index()
312 static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid) in cvt_nid_to_cvt_index() argument
314 struct hdmi_spec *spec = codec->spec; in cvt_nid_to_cvt_index()
321 codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid); in cvt_nid_to_cvt_index()
328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_info() local
329 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_info()
355 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in hdmi_eld_ctl_get() local
356 struct hdmi_spec *spec = codec->spec; in hdmi_eld_ctl_get()
399 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pcm_idx, in hdmi_create_eld_ctl() argument
403 struct hdmi_spec *spec = codec->spec; in hdmi_create_eld_ctl()
406 kctl = snd_ctl_new1(&eld_bytes_ctl, codec); in hdmi_create_eld_ctl()
415 err = snd_hda_ctl_add(codec, 0, kctl); in hdmi_create_eld_ctl()
424 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_get_dip_index() argument
429 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_get_dip_index()
437 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_set_dip_index() argument
444 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); in hdmi_set_dip_index()
447 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_write_dip_byte() argument
450 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); in hdmi_write_dip_byte()
453 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_init_pin() argument
455 struct hdmi_spec *spec = codec->spec; in hdmi_init_pin()
459 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_init_pin()
460 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
472 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_init_pin()
504 struct hda_codec *codec = per_pin->codec; in eld_proc_new() local
508 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index); in eld_proc_new()
509 err = snd_card_proc_new(codec->card, name, &entry); in eld_proc_new()
523 if (!per_pin->codec->bus->shutdown) { in eld_proc_free()
546 static void hdmi_start_infoframe_trans(struct hda_codec *codec, in hdmi_start_infoframe_trans() argument
549 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_start_infoframe_trans()
550 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_start_infoframe_trans()
557 static void hdmi_stop_infoframe_trans(struct hda_codec *codec, in hdmi_stop_infoframe_trans() argument
560 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_stop_infoframe_trans()
561 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, in hdmi_stop_infoframe_trans()
565 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_debug_dip_size() argument
571 size = snd_hdmi_get_eld_size(codec, pin_nid); in hdmi_debug_dip_size()
572 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size); in hdmi_debug_dip_size()
575 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_debug_dip_size()
577 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size); in hdmi_debug_dip_size()
582 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_clear_dip_buffers() argument
589 size = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_clear_dip_buffers()
594 hdmi_set_dip_index(codec, pin_nid, i, 0x0); in hdmi_clear_dip_buffers()
596 hdmi_write_dip_byte(codec, pin_nid, 0x0); in hdmi_clear_dip_buffers()
597 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); in hdmi_clear_dip_buffers()
599 codec_dbg(codec, "dip index %d: %d != %d\n", in hdmi_clear_dip_buffers()
604 codec_dbg(codec, in hdmi_clear_dip_buffers()
625 static void hdmi_fill_audio_infoframe(struct hda_codec *codec, in hdmi_fill_audio_infoframe() argument
631 hdmi_debug_dip_size(codec, pin_nid); in hdmi_fill_audio_infoframe()
632 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ in hdmi_fill_audio_infoframe()
634 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_fill_audio_infoframe()
636 hdmi_write_dip_byte(codec, pin_nid, dip[i]); in hdmi_fill_audio_infoframe()
639 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_infoframe_uptodate() argument
645 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) in hdmi_infoframe_uptodate()
649 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); in hdmi_infoframe_uptodate()
651 val = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_infoframe_uptodate()
660 static void hdmi_pin_setup_infoframe(struct hda_codec *codec, in hdmi_pin_setup_infoframe() argument
686 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n", in hdmi_pin_setup_infoframe()
696 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, in hdmi_pin_setup_infoframe()
698 codec_dbg(codec, in hdmi_pin_setup_infoframe()
702 hdmi_stop_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
703 hdmi_fill_audio_infoframe(codec, pin_nid, in hdmi_pin_setup_infoframe()
705 hdmi_start_infoframe_trans(codec, pin_nid); in hdmi_pin_setup_infoframe()
709 static void hdmi_setup_audio_infoframe(struct hda_codec *codec, in hdmi_setup_audio_infoframe() argument
713 struct hdmi_spec *spec = codec->spec; in hdmi_setup_audio_infoframe()
725 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) in hdmi_setup_audio_infoframe()
726 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_setup_audio_infoframe()
732 ca = snd_hdac_channel_allocation(&codec->core, in hdmi_setup_audio_infoframe()
738 chmap->ops.set_channel_count(&codec->core, per_pin->cvt_nid, in hdmi_setup_audio_infoframe()
749 spec->ops.pin_setup_infoframe(codec, pin_nid, ca, active_channels, in hdmi_setup_audio_infoframe()
761 static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid, in check_presence_and_report() argument
764 struct hdmi_spec *spec = codec->spec; in check_presence_and_report()
765 int pin_idx = pin_id_to_pin_index(codec, nid, dev_id); in check_presence_and_report()
771 snd_hda_jack_report_sync(codec); in check_presence_and_report()
775 static void jack_callback(struct hda_codec *codec, in jack_callback() argument
779 check_presence_and_report(codec, jack->nid, 0); in jack_callback()
782 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_intrinsic_event() argument
794 jack = snd_hda_jack_tbl_get_from_tag(codec, tag); in hdmi_intrinsic_event()
799 codec_dbg(codec, in hdmi_intrinsic_event()
801 codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA), in hdmi_intrinsic_event()
805 check_presence_and_report(codec, jack->nid, 0); in hdmi_intrinsic_event()
808 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) in hdmi_non_intrinsic_event() argument
815 codec_info(codec, in hdmi_non_intrinsic_event()
817 codec->addr, in hdmi_non_intrinsic_event()
831 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) in hdmi_unsol_event() argument
836 if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) { in hdmi_unsol_event()
837 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag); in hdmi_unsol_event()
842 hdmi_intrinsic_event(codec, res); in hdmi_unsol_event()
844 hdmi_non_intrinsic_event(codec, res); in hdmi_unsol_event()
847 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
855 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
856 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
858 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
859 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
862 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
864 codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
876 static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in hdmi_pin_hbr_setup() argument
881 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) { in hdmi_pin_hbr_setup()
882 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
894 codec_dbg(codec, in hdmi_pin_hbr_setup()
901 snd_hda_codec_write(codec, pin_nid, 0, in hdmi_pin_hbr_setup()
910 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in hdmi_setup_stream() argument
913 struct hdmi_spec *spec = codec->spec; in hdmi_setup_stream()
917 err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format)); in hdmi_setup_stream()
920 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n"); in hdmi_setup_stream()
924 if (is_haswell_plus(codec)) { in hdmi_setup_stream()
931 param = snd_hda_codec_read(codec, cvt_nid, 0, in hdmi_setup_stream()
940 snd_hda_codec_write(codec, cvt_nid, 0, in hdmi_setup_stream()
944 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format); in hdmi_setup_stream()
953 static int hdmi_choose_cvt(struct hda_codec *codec, in hdmi_choose_cvt() argument
956 struct hdmi_spec *spec = codec->spec; in hdmi_choose_cvt()
1000 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
1007 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1010 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
1038 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
1042 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
1072 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
1084 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
1085 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
1086 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
1089 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1100 codec_dbg(codec, in intel_not_share_assigned_cvt()
1103 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
1109 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
1114 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
1118 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
1127 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
1131 static void pin_cvt_fixup(struct hda_codec *codec, in pin_cvt_fixup() argument
1135 struct hdmi_spec *spec = codec->spec; in pin_cvt_fixup()
1138 spec->ops.pin_cvt_fixup(codec, per_pin, cvt_nid); in pin_cvt_fixup()
1145 struct hda_codec *codec, in hdmi_pcm_open_no_pin() argument
1148 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open_no_pin()
1154 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open_no_pin()
1158 err = hdmi_choose_cvt(codec, -1, &cvt_idx); in hdmi_pcm_open_no_pin()
1166 pin_cvt_fixup(codec, NULL, per_cvt->cvt_nid); in hdmi_pcm_open_no_pin()
1193 struct hda_codec *codec, in hdmi_pcm_open() argument
1196 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_open()
1205 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_open()
1210 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_open()
1221 err = hdmi_pcm_open_no_pin(hinfo, codec, substream); in hdmi_pcm_open()
1226 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx); in hdmi_pcm_open()
1239 snd_hda_set_dev_select(codec, per_pin->pin_nid, per_pin->dev_id); in hdmi_pcm_open()
1240 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_open()
1245 pin_cvt_fixup(codec, per_pin, 0); in hdmi_pcm_open()
1247 snd_hda_spdif_ctls_assign(codec, pcm_idx, per_cvt->cvt_nid); in hdmi_pcm_open()
1264 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_open()
1286 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx) in hdmi_read_pin_conn() argument
1288 struct hdmi_spec *spec = codec->spec; in hdmi_read_pin_conn()
1292 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { in hdmi_read_pin_conn()
1293 codec_warn(codec, in hdmi_read_pin_conn()
1295 pin_nid, get_wcaps(codec, pin_nid)); in hdmi_read_pin_conn()
1300 per_pin->num_mux_nids = snd_hda_get_connections(codec, pin_nid, in hdmi_read_pin_conn()
1372 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid);
1377 struct hda_codec *codec = per_pin->codec; in hdmi_pcm_setup_pin() local
1401 snd_hda_set_dev_select(codec, per_pin->pin_nid, in hdmi_pcm_setup_pin()
1403 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0, in hdmi_pcm_setup_pin()
1407 snd_hda_spdif_ctls_assign(codec, per_pin->pcm_idx, hinfo->nid); in hdmi_pcm_setup_pin()
1409 non_pcm = check_non_pcm_per_cvt(codec, hinfo->nid); in hdmi_pcm_setup_pin()
1415 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in hdmi_pcm_setup_pin()
1422 snd_hda_spdif_ctls_unassign(per_pin->codec, per_pin->pcm_idx); in hdmi_pcm_reset_pin()
1434 static void update_eld(struct hda_codec *codec, in update_eld() argument
1439 struct hdmi_spec *spec = codec->spec; in update_eld()
1462 snd_hdmi_show_eld(codec, &eld->info); in update_eld()
1485 pin_cvt_fixup(codec, per_pin, 0); in update_eld()
1486 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in update_eld()
1490 snd_ctl_notify(codec->card, in update_eld()
1501 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense_via_verbs() local
1502 struct hdmi_spec *spec = codec->spec; in hdmi_present_sense_via_verbs()
1517 present = snd_hda_pin_sense(codec, pin_nid); in hdmi_present_sense_via_verbs()
1526 codec_dbg(codec, in hdmi_present_sense_via_verbs()
1528 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); in hdmi_present_sense_via_verbs()
1531 if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer, in hdmi_present_sense_via_verbs()
1535 if (snd_hdmi_parse_eld(codec, &eld->info, eld->eld_buffer, in hdmi_present_sense_via_verbs()
1546 update_eld(codec, per_pin, eld); in hdmi_present_sense_via_verbs()
1550 jack = snd_hda_jack_tbl_get(codec, pin_nid); in hdmi_present_sense_via_verbs()
1558 static struct snd_jack *pin_idx_to_jack(struct hda_codec *codec, in pin_idx_to_jack() argument
1561 struct hdmi_spec *spec = codec->spec; in pin_idx_to_jack()
1579 jack_tbl = snd_hda_jack_tbl_get(codec, per_pin->pin_nid); in pin_idx_to_jack()
1587 static void sync_eld_via_acomp(struct hda_codec *codec, in sync_eld_via_acomp() argument
1590 struct hdmi_spec *spec = codec->spec; in sync_eld_via_acomp()
1597 size = snd_hdac_acomp_get_eld(&codec->core, per_pin->pin_nid, in sync_eld_via_acomp()
1602 if (snd_hdmi_parse_eld(codec, &eld->info, in sync_eld_via_acomp()
1618 jack = pin_idx_to_jack(codec, per_pin); in sync_eld_via_acomp()
1619 update_eld(codec, per_pin, eld); in sync_eld_via_acomp()
1621 jack = pin_idx_to_jack(codec, per_pin); in sync_eld_via_acomp()
1632 struct hda_codec *codec = per_pin->codec; in hdmi_present_sense() local
1636 if (!codec_has_acomp(codec)) { in hdmi_present_sense()
1637 ret = snd_hda_power_up_pm(codec); in hdmi_present_sense()
1638 if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) { in hdmi_present_sense()
1639 snd_hda_power_down_pm(codec); in hdmi_present_sense()
1644 if (codec_has_acomp(codec)) { in hdmi_present_sense()
1645 sync_eld_via_acomp(codec, per_pin); in hdmi_present_sense()
1651 if (!codec_has_acomp(codec)) in hdmi_present_sense()
1652 snd_hda_power_down_pm(codec); in hdmi_present_sense()
1661 struct hda_codec *codec = per_pin->codec; in hdmi_repoll_eld() local
1662 struct hdmi_spec *spec = codec->spec; in hdmi_repoll_eld()
1669 snd_hda_jack_report_sync(per_pin->codec); in hdmi_repoll_eld()
1673 static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
1676 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) in hdmi_add_pin() argument
1678 struct hdmi_spec *spec = codec->spec; in hdmi_add_pin()
1685 caps = snd_hda_query_pin_caps(codec, pin_nid); in hdmi_add_pin()
1693 config = snd_hda_codec_get_pincfg(codec, pin_nid); in hdmi_add_pin()
1701 if (is_haswell_plus(codec)) { in hdmi_add_pin()
1713 } else if (spec->dyn_pcm_assign && codec->dp_mst) { in hdmi_add_pin()
1714 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; in hdmi_add_pin()
1749 snd_hda_set_dev_select(codec, pin_nid, i); in hdmi_add_pin()
1750 if (is_haswell_plus(codec)) in hdmi_add_pin()
1751 intel_haswell_fixup_connect_list(codec, pin_nid); in hdmi_add_pin()
1752 err = hdmi_read_pin_conn(codec, pin_idx); in hdmi_add_pin()
1762 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in hdmi_add_cvt() argument
1764 struct hdmi_spec *spec = codec->spec; in hdmi_add_cvt()
1769 chans = get_wcaps(codec, cvt_nid); in hdmi_add_cvt()
1784 err = snd_hda_query_supported_pcm(codec, cvt_nid, in hdmi_add_cvt()
1798 static int hdmi_parse_codec(struct hda_codec *codec) in hdmi_parse_codec() argument
1803 nodes = snd_hda_get_sub_nodes(codec, codec->core.afg, &nid); in hdmi_parse_codec()
1805 codec_warn(codec, "HDMI: failed to get afg sub nodes\n"); in hdmi_parse_codec()
1813 caps = get_wcaps(codec, nid); in hdmi_parse_codec()
1821 hdmi_add_cvt(codec, nid); in hdmi_parse_codec()
1824 hdmi_add_pin(codec, nid); in hdmi_parse_codec()
1834 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) in check_non_pcm_per_cvt() argument
1839 mutex_lock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
1840 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid); in check_non_pcm_per_cvt()
1847 mutex_unlock(&codec->spdif_mutex); in check_non_pcm_per_cvt()
1856 struct hda_codec *codec, in generic_hdmi_playback_pcm_prepare() argument
1862 struct hdmi_spec *spec = codec->spec; in generic_hdmi_playback_pcm_prepare()
1872 pin_idx = hinfo_to_pin_index(codec, hinfo); in generic_hdmi_playback_pcm_prepare()
1878 pin_cvt_fixup(codec, NULL, cvt_nid); in generic_hdmi_playback_pcm_prepare()
1879 snd_hda_codec_setup_stream(codec, cvt_nid, in generic_hdmi_playback_pcm_prepare()
1899 pin_cvt_fixup(codec, per_pin, 0); in generic_hdmi_playback_pcm_prepare()
1903 if (codec_has_acomp(codec)) in generic_hdmi_playback_pcm_prepare()
1904 snd_hdac_sync_audio_rate(&codec->core, pin_nid, per_pin->dev_id, in generic_hdmi_playback_pcm_prepare()
1907 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); in generic_hdmi_playback_pcm_prepare()
1912 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm); in generic_hdmi_playback_pcm_prepare()
1915 pinctl = snd_hda_codec_read(codec, pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
1917 snd_hda_codec_write(codec, pin_nid, 0, in generic_hdmi_playback_pcm_prepare()
1923 err = spec->ops.setup_stream(codec, cvt_nid, pin_nid, in generic_hdmi_playback_pcm_prepare()
1931 struct hda_codec *codec, in generic_hdmi_playback_pcm_cleanup() argument
1934 snd_hda_codec_cleanup_stream(codec, hinfo->nid); in generic_hdmi_playback_pcm_cleanup()
1939 struct hda_codec *codec, in hdmi_pcm_close() argument
1942 struct hdmi_spec *spec = codec->spec; in hdmi_pcm_close()
1950 pcm_idx = hinfo_to_pcm_index(codec, hinfo); in hdmi_pcm_close()
1953 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid); in hdmi_pcm_close()
1963 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in hdmi_pcm_close()
1965 pin_idx = hinfo_to_pin_index(codec, hinfo); in hdmi_pcm_close()
1976 pinctl = snd_hda_codec_read(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
1978 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in hdmi_pcm_close()
2006 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in hdmi_get_spk_alloc() local
2007 struct hdmi_spec *spec = codec->spec; in hdmi_get_spk_alloc()
2019 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in hdmi_get_chmap() local
2020 struct hdmi_spec *spec = codec->spec; in hdmi_get_chmap()
2033 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in hdmi_set_chmap() local
2034 struct hdmi_spec *spec = codec->spec; in hdmi_set_chmap()
2043 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in hdmi_set_chmap()
2049 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in is_hdmi_pcm_attached() local
2050 struct hdmi_spec *spec = codec->spec; in is_hdmi_pcm_attached()
2056 static int generic_hdmi_build_pcms(struct hda_codec *codec) in generic_hdmi_build_pcms() argument
2058 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_pcms()
2071 info = snd_hda_codec_pcm_new(codec, "HDMI %d", idx); in generic_hdmi_build_pcms()
2099 static int add_hdmi_jack_kctl(struct hda_codec *codec, in add_hdmi_jack_kctl() argument
2107 err = snd_jack_new(codec->card, name, SND_JACK_AVOUT, &jack, in add_hdmi_jack_kctl()
2118 static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) in generic_hdmi_build_jack() argument
2121 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_jack()
2132 return add_hdmi_jack_kctl(codec, spec, pcm_idx, hdmi_str); in generic_hdmi_build_jack()
2140 phantom_jack = !is_jack_detectable(codec, per_pin->pin_nid); in generic_hdmi_build_jack()
2144 ret = snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str, in generic_hdmi_build_jack()
2148 jack = snd_hda_jack_tbl_get(codec, per_pin->pin_nid); in generic_hdmi_build_jack()
2158 static int generic_hdmi_build_controls(struct hda_codec *codec) in generic_hdmi_build_controls() argument
2160 struct hdmi_spec *spec = codec->spec; in generic_hdmi_build_controls()
2171 err = generic_hdmi_build_jack(codec, pcm_idx); in generic_hdmi_build_controls()
2179 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2185 err = snd_hda_create_dig_out_ctls(codec, in generic_hdmi_build_controls()
2192 snd_hda_spdif_ctls_unassign(codec, pcm_idx); in generic_hdmi_build_controls()
2197 err = hdmi_create_eld_ctl(codec, pcm_idx, dev); in generic_hdmi_build_controls()
2224 static int generic_hdmi_init_per_pins(struct hda_codec *codec) in generic_hdmi_init_per_pins() argument
2226 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init_per_pins()
2232 per_pin->codec = codec; in generic_hdmi_init_per_pins()
2240 static int generic_hdmi_init(struct hda_codec *codec) in generic_hdmi_init() argument
2242 struct hdmi_spec *spec = codec->spec; in generic_hdmi_init()
2250 snd_hda_set_dev_select(codec, pin_nid, dev_id); in generic_hdmi_init()
2251 hdmi_init_pin(codec, pin_nid); in generic_hdmi_init()
2252 if (!codec_has_acomp(codec)) in generic_hdmi_init()
2253 snd_hda_jack_detect_enable_callback(codec, pin_nid, in generic_hdmi_init()
2254 codec->jackpoll_interval > 0 ? in generic_hdmi_init()
2272 static void generic_spec_free(struct hda_codec *codec) in generic_spec_free() argument
2274 struct hdmi_spec *spec = codec->spec; in generic_spec_free()
2279 codec->spec = NULL; in generic_spec_free()
2281 codec->dp_mst = false; in generic_spec_free()
2284 static void generic_hdmi_free(struct hda_codec *codec) in generic_hdmi_free() argument
2286 struct hdmi_spec *spec = codec->spec; in generic_hdmi_free()
2289 if (codec_has_acomp(codec)) in generic_hdmi_free()
2290 snd_hdac_acomp_register_notifier(&codec->bus->core, NULL); in generic_hdmi_free()
2302 snd_device_free(codec->card, in generic_hdmi_free()
2308 generic_spec_free(codec); in generic_hdmi_free()
2312 static int generic_hdmi_resume(struct hda_codec *codec) in generic_hdmi_resume() argument
2314 struct hdmi_spec *spec = codec->spec; in generic_hdmi_resume()
2317 codec->patch_ops.init(codec); in generic_hdmi_resume()
2318 regcache_sync(codec->core.regmap); in generic_hdmi_resume()
2347 static int alloc_generic_hdmi(struct hda_codec *codec) in alloc_generic_hdmi() argument
2358 snd_hdac_register_chmap_ops(&codec->core, &spec->chmap); in alloc_generic_hdmi()
2365 codec->spec = spec; in alloc_generic_hdmi()
2368 codec->patch_ops = generic_hdmi_patch_ops; in alloc_generic_hdmi()
2374 static int patch_generic_hdmi(struct hda_codec *codec) in patch_generic_hdmi() argument
2378 err = alloc_generic_hdmi(codec); in patch_generic_hdmi()
2382 err = hdmi_parse_codec(codec); in patch_generic_hdmi()
2384 generic_spec_free(codec); in patch_generic_hdmi()
2388 generic_hdmi_init_per_pins(codec); in patch_generic_hdmi()
2396 static void intel_haswell_fixup_connect_list(struct hda_codec *codec, in intel_haswell_fixup_connect_list() argument
2399 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_connect_list()
2403 nconns = snd_hda_get_connections(codec, nid, conns, ARRAY_SIZE(conns)); in intel_haswell_fixup_connect_list()
2409 codec_dbg(codec, "hdmi: haswell: override pin connection 0x%x\n", nid); in intel_haswell_fixup_connect_list()
2410 snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids); in intel_haswell_fixup_connect_list()
2420 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
2424 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
2426 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2432 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
2438 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
2441 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
2444 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
2446 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2453 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
2454 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
2461 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
2465 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
2466 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
2469 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
2470 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
2484 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
2486 switch (codec->core.vendor_id) { in intel_base_nid()
2507 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
2515 pin_nid = port + intel_base_nid(codec) - 1; /* intel port is 1-based */ in intel_pin_eld_notify()
2520 if (snd_power_get_state(codec->card) != SNDRV_CTL_POWER_D0) in intel_pin_eld_notify()
2523 if (snd_hdac_is_in_pm(&codec->core)) in intel_pin_eld_notify()
2526 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
2527 check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
2531 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
2533 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
2536 spec->drm_audio_ops.audio_ptr = codec; in register_i915_notifier()
2544 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
2549 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
2552 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
2553 return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); in i915_hsw_setup_stream()
2557 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
2562 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2564 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
2565 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
2568 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
2573 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
2576 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
2577 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
2579 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
2583 return alloc_generic_hdmi(codec); in alloc_intel_hdmi()
2587 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
2591 err = hdmi_parse_codec(codec); in parse_intel_hdmi()
2593 generic_spec_free(codec); in parse_intel_hdmi()
2597 generic_hdmi_init_per_pins(codec); in parse_intel_hdmi()
2598 register_i915_notifier(codec); in parse_intel_hdmi()
2603 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid) in intel_hsw_common_init() argument
2608 err = alloc_intel_hdmi(codec); in intel_hsw_common_init()
2611 spec = codec->spec; in intel_hsw_common_init()
2612 codec->dp_mst = true; in intel_hsw_common_init()
2616 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
2617 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
2622 if (!is_haswell(codec) && !is_broadwell(codec)) in intel_hsw_common_init()
2623 codec->core.link_power_control = 1; in intel_hsw_common_init()
2625 codec->patch_ops.set_power_state = haswell_set_power_state; in intel_hsw_common_init()
2626 codec->depop_delay = 0; in intel_hsw_common_init()
2627 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
2632 return parse_intel_hdmi(codec); in intel_hsw_common_init()
2635 static int patch_i915_hsw_hdmi(struct hda_codec *codec) in patch_i915_hsw_hdmi() argument
2637 return intel_hsw_common_init(codec, INTEL_VENDOR_NID); in patch_i915_hsw_hdmi()
2640 static int patch_i915_glk_hdmi(struct hda_codec *codec) in patch_i915_glk_hdmi() argument
2642 return intel_hsw_common_init(codec, INTEL_GLK_VENDOR_NID); in patch_i915_glk_hdmi()
2646 static int patch_i915_byt_hdmi(struct hda_codec *codec) in patch_i915_byt_hdmi() argument
2651 err = alloc_intel_hdmi(codec); in patch_i915_byt_hdmi()
2654 spec = codec->spec; in patch_i915_byt_hdmi()
2659 codec->core.link_power_control = 1; in patch_i915_byt_hdmi()
2661 codec->depop_delay = 0; in patch_i915_byt_hdmi()
2662 codec->auto_runtime_pm = 1; in patch_i915_byt_hdmi()
2666 return parse_intel_hdmi(codec); in patch_i915_byt_hdmi()
2670 static int patch_i915_cpt_hdmi(struct hda_codec *codec) in patch_i915_cpt_hdmi() argument
2674 err = alloc_intel_hdmi(codec); in patch_i915_cpt_hdmi()
2677 return parse_intel_hdmi(codec); in patch_i915_cpt_hdmi()
2684 static int simple_playback_build_pcms(struct hda_codec *codec) in simple_playback_build_pcms() argument
2686 struct hdmi_spec *spec = codec->spec; in simple_playback_build_pcms()
2693 chans = get_wcaps(codec, per_cvt->cvt_nid); in simple_playback_build_pcms()
2696 info = snd_hda_codec_pcm_new(codec, "HDMI 0"); in simple_playback_build_pcms()
2711 static void simple_hdmi_unsol_event(struct hda_codec *codec, in simple_hdmi_unsol_event() argument
2714 snd_hda_jack_set_dirty_all(codec); in simple_hdmi_unsol_event()
2715 snd_hda_jack_report_sync(codec); in simple_hdmi_unsol_event()
2723 static int simple_playback_build_controls(struct hda_codec *codec) in simple_playback_build_controls() argument
2725 struct hdmi_spec *spec = codec->spec; in simple_playback_build_controls()
2730 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid, in simple_playback_build_controls()
2735 return simple_hdmi_build_jack(codec, 0); in simple_playback_build_controls()
2738 static int simple_playback_init(struct hda_codec *codec) in simple_playback_init() argument
2740 struct hdmi_spec *spec = codec->spec; in simple_playback_init()
2744 snd_hda_codec_write(codec, pin, 0, in simple_playback_init()
2747 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP) in simple_playback_init()
2748 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE, in simple_playback_init()
2750 snd_hda_jack_detect_enable(codec, pin); in simple_playback_init()
2754 static void simple_playback_free(struct hda_codec *codec) in simple_playback_free() argument
2756 struct hdmi_spec *spec = codec->spec; in simple_playback_free()
2815 static int nvhdmi_7x_init_2ch(struct hda_codec *codec) in nvhdmi_7x_init_2ch() argument
2817 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch); in nvhdmi_7x_init_2ch()
2821 static int nvhdmi_7x_init_8ch(struct hda_codec *codec) in nvhdmi_7x_init_8ch() argument
2823 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch); in nvhdmi_7x_init_8ch()
2848 struct hda_codec *codec, in simple_playback_pcm_open() argument
2851 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_open()
2854 switch (codec->preset->vendor_id) { in simple_playback_pcm_open()
2877 return snd_hda_multi_out_dig_open(codec, &spec->multiout); in simple_playback_pcm_open()
2881 struct hda_codec *codec, in simple_playback_pcm_close() argument
2884 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_close()
2885 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in simple_playback_pcm_close()
2889 struct hda_codec *codec, in simple_playback_pcm_prepare() argument
2894 struct hdmi_spec *spec = codec->spec; in simple_playback_pcm_prepare()
2895 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, in simple_playback_pcm_prepare()
2918 static int patch_simple_hdmi(struct hda_codec *codec, in patch_simple_hdmi() argument
2929 codec->spec = spec; in patch_simple_hdmi()
2940 simple_playback_free(codec); in patch_simple_hdmi()
2947 codec->patch_ops = simple_hdmi_patch_ops; in patch_simple_hdmi()
2952 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec, in nvhdmi_8ch_7x_set_info_frame_parameters() argument
2977 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
2980 snd_hda_codec_write(codec, 0x1, 0, in nvhdmi_8ch_7x_set_info_frame_parameters()
2986 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_close() argument
2989 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_close()
2992 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, in nvhdmi_8ch_7x_pcm_close()
2996 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
2999 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, in nvhdmi_8ch_7x_pcm_close()
3005 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in nvhdmi_8ch_7x_pcm_close()
3007 return snd_hda_multi_out_dig_close(codec, &spec->multiout); in nvhdmi_8ch_7x_pcm_close()
3011 struct hda_codec *codec, in nvhdmi_8ch_7x_pcm_prepare() argument
3019 struct hdmi_spec *spec = codec->spec; in nvhdmi_8ch_7x_pcm_prepare()
3023 mutex_lock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3025 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid); in nvhdmi_8ch_7x_pcm_prepare()
3032 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) in nvhdmi_8ch_7x_pcm_prepare()
3033 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3040 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3044 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, in nvhdmi_8ch_7x_pcm_prepare()
3049 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) { in nvhdmi_8ch_7x_pcm_prepare()
3050 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3055 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3070 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3072 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3078 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3084 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3091 if (codec->spdif_status_reset && in nvhdmi_8ch_7x_pcm_prepare()
3093 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3098 snd_hda_codec_write(codec, in nvhdmi_8ch_7x_pcm_prepare()
3105 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs); in nvhdmi_8ch_7x_pcm_prepare()
3107 mutex_unlock(&codec->spdif_mutex); in nvhdmi_8ch_7x_pcm_prepare()
3126 static int patch_nvhdmi_2ch(struct hda_codec *codec) in patch_nvhdmi_2ch() argument
3129 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x, in patch_nvhdmi_2ch()
3134 codec->patch_ops.init = nvhdmi_7x_init_2ch; in patch_nvhdmi_2ch()
3136 spec = codec->spec; in patch_nvhdmi_2ch()
3143 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec) in nvhdmi_7x_8ch_build_pcms() argument
3145 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_pcms()
3146 int err = simple_playback_build_pcms(codec); in nvhdmi_7x_8ch_build_pcms()
3154 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec) in nvhdmi_7x_8ch_build_controls() argument
3156 struct hdmi_spec *spec = codec->spec; in nvhdmi_7x_8ch_build_controls()
3161 err = simple_playback_build_controls(codec); in nvhdmi_7x_8ch_build_controls()
3172 switch (codec->preset->vendor_id) { in nvhdmi_7x_8ch_build_controls()
3185 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) in patch_nvhdmi_8ch_7x() argument
3188 int err = patch_nvhdmi_2ch(codec); in patch_nvhdmi_8ch_7x()
3191 spec = codec->spec; in patch_nvhdmi_8ch_7x()
3194 codec->patch_ops.init = nvhdmi_7x_init_8ch; in patch_nvhdmi_8ch_7x()
3195 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms; in patch_nvhdmi_8ch_7x()
3196 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls; in patch_nvhdmi_8ch_7x()
3200 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8); in patch_nvhdmi_8ch_7x()
3233 static int patch_nvhdmi(struct hda_codec *codec) in patch_nvhdmi() argument
3238 err = patch_generic_hdmi(codec); in patch_nvhdmi()
3242 spec = codec->spec; in patch_nvhdmi()
3294 static void tegra_hdmi_set_format(struct hda_codec *codec, unsigned int format) in tegra_hdmi_set_format() argument
3299 value = snd_hda_codec_read(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3304 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3307 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3312 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3331 snd_hda_codec_write(codec, NVIDIA_AFG_NID, 0, in tegra_hdmi_set_format()
3336 struct hda_codec *codec, in tegra_hdmi_pcm_prepare() argument
3343 err = generic_hdmi_playback_pcm_prepare(hinfo, codec, stream_tag, in tegra_hdmi_pcm_prepare()
3349 tegra_hdmi_set_format(codec, format); in tegra_hdmi_pcm_prepare()
3355 struct hda_codec *codec, in tegra_hdmi_pcm_cleanup() argument
3359 tegra_hdmi_set_format(codec, 0); in tegra_hdmi_pcm_cleanup()
3361 return generic_hdmi_playback_pcm_cleanup(hinfo, codec, substream); in tegra_hdmi_pcm_cleanup()
3364 static struct hda_pcm *hda_find_pcm_by_type(struct hda_codec *codec, int type) in hda_find_pcm_by_type() argument
3366 struct hdmi_spec *spec = codec->spec; in hda_find_pcm_by_type()
3379 static int tegra_hdmi_build_pcms(struct hda_codec *codec) in tegra_hdmi_build_pcms() argument
3385 err = generic_hdmi_build_pcms(codec); in tegra_hdmi_build_pcms()
3389 pcm = hda_find_pcm_by_type(codec, HDA_PCM_TYPE_HDMI); in tegra_hdmi_build_pcms()
3404 static int patch_tegra_hdmi(struct hda_codec *codec) in patch_tegra_hdmi() argument
3408 err = patch_generic_hdmi(codec); in patch_tegra_hdmi()
3412 codec->patch_ops.build_pcms = tegra_hdmi_build_pcms; in patch_tegra_hdmi()
3421 #define is_amdhdmi_rev3_or_later(codec) \ argument
3422 ((codec)->core.vendor_id == 0x1002aa01 && \
3423 ((codec)->core.revision_id & 0xff00) >= 0x0300)
3424 #define has_amd_full_remap_support(codec) is_amdhdmi_rev3_or_later(codec) argument
3464 static int atihdmi_pin_get_eld(struct hda_codec *codec, hda_nid_t nid, in atihdmi_pin_get_eld() argument
3468 return snd_hdmi_get_eld_ati(codec, nid, buf, eld_size, in atihdmi_pin_get_eld()
3469 is_amdhdmi_rev3_or_later(codec)); in atihdmi_pin_get_eld()
3472 static void atihdmi_pin_setup_infoframe(struct hda_codec *codec, hda_nid_t pin_nid, int ca, in atihdmi_pin_setup_infoframe() argument
3475 snd_hda_codec_write(codec, pin_nid, 0, ATI_VERB_SET_CHANNEL_ALLOCATION, ca); in atihdmi_pin_setup_infoframe()
3546 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in atihdmi_pin_set_slot_channel() local
3553 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_set_slot_channel()
3576 return snd_hda_codec_write(codec, pin_nid, 0, verb, ati_channel_setup); in atihdmi_pin_set_slot_channel()
3582 struct hda_codec *codec = container_of(hdac, struct hda_codec, core); in atihdmi_pin_get_slot_channel() local
3591 if (!has_amd_full_remap_support(codec)) { in atihdmi_pin_get_slot_channel()
3601 ati_channel_setup = snd_hda_codec_read(codec, pin_nid, 0, verb, 0); in atihdmi_pin_get_slot_channel()
3664 static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid, in atihdmi_pin_hbr_setup() argument
3669 hbr_ctl = snd_hda_codec_read(codec, pin_nid, 0, ATI_VERB_GET_HBR_CONTROL, 0); in atihdmi_pin_hbr_setup()
3676 codec_dbg(codec, in atihdmi_pin_hbr_setup()
3683 snd_hda_codec_write(codec, pin_nid, 0, in atihdmi_pin_hbr_setup()
3693 static int atihdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in atihdmi_setup_stream() argument
3697 if (is_amdhdmi_rev3_or_later(codec)) { in atihdmi_setup_stream()
3703 snd_hda_codec_write(codec, cvt_nid, 0, ATI_VERB_SET_RAMP_RATE, ramp_rate); in atihdmi_setup_stream()
3706 return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format); in atihdmi_setup_stream()
3710 static int atihdmi_init(struct hda_codec *codec) in atihdmi_init() argument
3712 struct hdmi_spec *spec = codec->spec; in atihdmi_init()
3715 err = generic_hdmi_init(codec); in atihdmi_init()
3724 snd_hda_codec_write(codec, per_pin->pin_nid, 0, ATI_VERB_SET_DOWNMIX_INFO, 0); in atihdmi_init()
3727 if (has_amd_full_remap_support(codec)) in atihdmi_init()
3728 snd_hda_codec_write(codec, per_pin->pin_nid, 0, in atihdmi_init()
3736 static int patch_atihdmi(struct hda_codec *codec) in patch_atihdmi() argument
3742 err = patch_generic_hdmi(codec); in patch_atihdmi()
3747 codec->patch_ops.init = atihdmi_init; in patch_atihdmi()
3749 spec = codec->spec; in patch_atihdmi()
3759 if (!has_amd_full_remap_support(codec)) { in patch_atihdmi()
3782 codec->link_down_at_suspend = 1; in patch_atihdmi()
3791 static int patch_via_hdmi(struct hda_codec *codec) in patch_via_hdmi() argument
3793 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID); in patch_via_hdmi()