Lines Matching full:codec

3  * Intel HDMI codec support
36 static void intel_haswell_enable_all_pins(struct hda_codec *codec, in intel_haswell_enable_all_pins() argument
40 struct hdmi_spec *spec = codec->spec; in intel_haswell_enable_all_pins()
42 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
48 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_enable_all_pins()
54 snd_hda_codec_update_widgets(codec); in intel_haswell_enable_all_pins()
57 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec) in intel_haswell_fixup_enable_dp12() argument
60 struct hdmi_spec *spec = codec->spec; in intel_haswell_fixup_enable_dp12()
62 vendor_param = snd_hda_codec_read(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
69 snd_hdac_regmap_add_vendor_verb(&codec->core, INTEL_SET_VENDOR_VERB); in intel_haswell_fixup_enable_dp12()
70 snd_hda_codec_write_cache(codec, spec->vendor_nid, 0, in intel_haswell_fixup_enable_dp12()
77 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg, in haswell_set_power_state() argument
80 /* check codec->spec: it can be called before the probe gets called */ in haswell_set_power_state()
81 if (codec->spec) { in haswell_set_power_state()
83 intel_haswell_enable_all_pins(codec, false); in haswell_set_power_state()
84 intel_haswell_fixup_enable_dp12(codec); in haswell_set_power_state()
88 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state); in haswell_set_power_state()
89 snd_hda_codec_set_power_to_all(codec, fg, power_state); in haswell_set_power_state()
103 static int intel_base_nid(struct hda_codec *codec) in intel_base_nid() argument
105 switch (codec->core.vendor_id) { in intel_base_nid()
117 struct hda_codec *codec = audio_ptr; in intel_pin2port() local
118 struct hdmi_spec *spec = codec->spec; in intel_pin2port()
122 base_nid = intel_base_nid(codec); in intel_pin2port()
137 codec_info(codec, "Can't find the HDMI/DP port for pin NID 0x%x\n", pin_nid); in intel_pin2port()
141 static int intel_port2pin(struct hda_codec *codec, int port) in intel_port2pin() argument
143 struct hdmi_spec *spec = codec->spec; in intel_port2pin()
149 return port + intel_base_nid(codec) - 1; in intel_port2pin()
159 struct hda_codec *codec = audio_ptr; in intel_pin_eld_notify() local
163 pin_nid = intel_port2pin(codec, port); in intel_pin_eld_notify()
169 if (codec->core.dev.power.power_state.event == PM_EVENT_SUSPEND) in intel_pin_eld_notify()
172 snd_hdac_i915_set_bclk(&codec->bus->core); in intel_pin_eld_notify()
173 snd_hda_hdmi_check_presence_and_report(codec, pin_nid, dev_id); in intel_pin_eld_notify()
182 static void register_i915_notifier(struct hda_codec *codec) in register_i915_notifier() argument
184 struct hdmi_spec *spec = codec->spec; in register_i915_notifier()
188 snd_hda_hdmi_setup_drm_audio_ops(codec, &intel_audio_ops); in register_i915_notifier()
189 snd_hdac_acomp_register_notifier(&codec->bus->core, in register_i915_notifier()
192 codec->relaxed_resume = 1; in register_i915_notifier()
200 static void silent_stream_enable_i915(struct hda_codec *codec, in silent_stream_enable_i915() argument
205 snd_hdac_sync_audio_rate(&codec->core, per_pin->pin_nid, in silent_stream_enable_i915()
211 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, in silent_stream_enable_i915()
214 snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, 0, format); in silent_stream_enable_i915()
217 snd_hda_hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm); in silent_stream_enable_i915()
220 static void silent_stream_set_kae(struct hda_codec *codec, in silent_stream_set_kae() argument
226 codec_dbg(codec, "HDMI: KAE %d cvt-NID=0x%x\n", enable, per_pin->cvt_nid); in silent_stream_set_kae()
228 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, AC_VERB_GET_DIGI_CONVERT_1, 0); in silent_stream_set_kae()
236 snd_hda_codec_write(codec, per_pin->cvt_nid, 0, AC_VERB_SET_DIGI_CONVERT_3, param); in silent_stream_set_kae()
239 static void i915_set_silent_stream(struct hda_codec *codec, in i915_set_silent_stream() argument
243 struct hdmi_spec *spec = codec->spec; in i915_set_silent_stream()
248 silent_stream_enable_i915(codec, per_pin); in i915_set_silent_stream()
249 silent_stream_set_kae(codec, per_pin, true); in i915_set_silent_stream()
251 silent_stream_set_kae(codec, per_pin, false); in i915_set_silent_stream()
256 silent_stream_enable_i915(codec, per_pin); in i915_set_silent_stream()
257 snd_hda_power_up_pm(codec); in i915_set_silent_stream()
260 snd_hda_power_down_pm(codec); in i915_set_silent_stream()
268 static void haswell_verify_D0(struct hda_codec *codec, in haswell_verify_D0() argument
277 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0)) in haswell_verify_D0()
278 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0); in haswell_verify_D0()
280 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) { in haswell_verify_D0()
281 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE, in haswell_verify_D0()
284 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); in haswell_verify_D0()
286 codec_dbg(codec, "Haswell HDMI audio: Power for NID 0x%x is now D%d\n", nid, pwr); in haswell_verify_D0()
291 static void intel_verify_pin_cvt_connect(struct hda_codec *codec, in intel_verify_pin_cvt_connect() argument
298 curr = snd_hda_codec_read(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
301 snd_hda_codec_write_cache(codec, pin_nid, 0, in intel_verify_pin_cvt_connect()
329 static void intel_not_share_assigned_cvt(struct hda_codec *codec, in intel_not_share_assigned_cvt() argument
333 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt()
363 dev_num = snd_hda_get_num_devices(codec, per_pin->pin_nid) + 1; in intel_not_share_assigned_cvt()
375 dev_id_saved = snd_hda_get_dev_select(codec, nid); in intel_not_share_assigned_cvt()
376 snd_hda_set_dev_select(codec, nid, per_pin->dev_id); in intel_not_share_assigned_cvt()
377 curr = snd_hda_codec_read(codec, nid, 0, in intel_not_share_assigned_cvt()
380 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
386 * connection list are in the same order as in the codec. in intel_not_share_assigned_cvt()
391 codec_dbg(codec, in intel_not_share_assigned_cvt()
394 snd_hda_codec_write_cache(codec, nid, 0, in intel_not_share_assigned_cvt()
400 snd_hda_set_dev_select(codec, nid, dev_id_saved); in intel_not_share_assigned_cvt()
405 static void intel_not_share_assigned_cvt_nid(struct hda_codec *codec, in intel_not_share_assigned_cvt_nid() argument
409 struct hdmi_spec *spec = codec->spec; in intel_not_share_assigned_cvt_nid()
418 intel_not_share_assigned_cvt(codec, pin_nid, dev_id, mux_idx); in intel_not_share_assigned_cvt_nid()
422 static int i915_hsw_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid, in i915_hsw_setup_stream() argument
426 struct hdmi_spec *spec = codec->spec; in i915_hsw_setup_stream()
427 int pin_idx = pin_id_to_pin_index(codec, pin_nid, dev_id); in i915_hsw_setup_stream()
436 haswell_verify_D0(codec, cvt_nid, pin_nid); in i915_hsw_setup_stream()
439 silent_stream_set_kae(codec, per_pin, false); in i915_hsw_setup_stream()
440 /* wait for pending transfers in codec to clear */ in i915_hsw_setup_stream()
444 res = snd_hda_hdmi_setup_stream(codec, cvt_nid, pin_nid, dev_id, in i915_hsw_setup_stream()
449 silent_stream_set_kae(codec, per_pin, true); in i915_hsw_setup_stream()
456 static void i915_pin_cvt_fixup(struct hda_codec *codec, in i915_pin_cvt_fixup() argument
461 haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid); in i915_pin_cvt_fixup()
462 snd_hda_set_dev_select(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
464 intel_verify_pin_cvt_connect(codec, per_pin); in i915_pin_cvt_fixup()
465 intel_not_share_assigned_cvt(codec, per_pin->pin_nid, in i915_pin_cvt_fixup()
468 intel_not_share_assigned_cvt_nid(codec, 0, 0, cvt_nid); in i915_pin_cvt_fixup()
472 static int i915_hdmi_suspend(struct hda_codec *codec) in i915_hdmi_suspend() argument
474 struct hdmi_spec *spec = codec->spec; in i915_hdmi_suspend()
478 res = snd_hda_hdmi_generic_suspend(codec); in i915_hdmi_suspend()
493 * stream-id should remain programmed when codec goes in i915_hdmi_suspend()
496 codec->no_stream_clean_at_suspend = 1; in i915_hdmi_suspend()
502 codec->forced_resume = 1; in i915_hdmi_suspend()
504 codec_dbg(codec, "HDMI: KAE active at suspend\n"); in i915_hdmi_suspend()
506 codec->no_stream_clean_at_suspend = 0; in i915_hdmi_suspend()
507 codec->forced_resume = 0; in i915_hdmi_suspend()
513 static int i915_hdmi_resume(struct hda_codec *codec) in i915_hdmi_resume() argument
515 struct hdmi_spec *spec = codec->spec; in i915_hdmi_resume()
518 res = snd_hda_hdmi_generic_resume(codec); in i915_hdmi_resume()
523 if (!codec->no_stream_clean_at_suspend) in i915_hdmi_resume()
531 * the codec setting may have been lost. Re-enable in i915_hdmi_resume()
537 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, in i915_hdmi_resume()
540 codec_dbg(codec, "HDMI: KAE: restore stream id\n"); in i915_hdmi_resume()
541 silent_stream_enable_i915(codec, per_pin); in i915_hdmi_resume()
544 param = snd_hda_codec_read(codec, per_pin->cvt_nid, 0, in i915_hdmi_resume()
547 codec_dbg(codec, "HDMI: KAE: restore DIG3_KAE\n"); in i915_hdmi_resume()
548 silent_stream_set_kae(codec, per_pin, true); in i915_hdmi_resume()
557 static int alloc_intel_hdmi(struct hda_codec *codec) in alloc_intel_hdmi() argument
560 if (!codec->bus->core.audio_component) { in alloc_intel_hdmi()
561 codec_info(codec, "No i915 binding for Intel HDMI/DP codec\n"); in alloc_intel_hdmi()
563 codec->probe_id = HDA_CODEC_ID_SKIP_PROBE; in alloc_intel_hdmi()
567 return snd_hda_hdmi_generic_alloc(codec); in alloc_intel_hdmi()
571 static int parse_intel_hdmi(struct hda_codec *codec) in parse_intel_hdmi() argument
576 err = snd_hda_hdmi_parse_codec(codec); in parse_intel_hdmi()
582 snd_hda_hdmi_generic_init_per_pins(codec); in parse_intel_hdmi()
583 register_i915_notifier(codec); in parse_intel_hdmi()
588 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, in intel_hsw_common_init() argument
594 spec = codec->spec; in intel_hsw_common_init()
595 codec->dp_mst = true; in intel_hsw_common_init()
602 intel_haswell_enable_all_pins(codec, true); in intel_hsw_common_init()
603 intel_haswell_fixup_enable_dp12(codec); in intel_hsw_common_init()
605 codec->display_power_control = 1; in intel_hsw_common_init()
607 codec->depop_delay = 0; in intel_hsw_common_init()
608 codec->auto_runtime_pm = 1; in intel_hsw_common_init()
621 return parse_intel_hdmi(codec); in intel_hsw_common_init()
624 static int probe_i915_hsw_hdmi(struct hda_codec *codec) in probe_i915_hsw_hdmi() argument
626 return intel_hsw_common_init(codec, 0x08, NULL, 0, 3, in probe_i915_hsw_hdmi()
630 static int probe_i915_glk_hdmi(struct hda_codec *codec) in probe_i915_glk_hdmi() argument
637 return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3, false); in probe_i915_glk_hdmi()
640 static int probe_i915_icl_hdmi(struct hda_codec *codec) in probe_i915_icl_hdmi() argument
648 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3, in probe_i915_icl_hdmi()
652 static int probe_i915_tgl_hdmi(struct hda_codec *codec) in probe_i915_tgl_hdmi() argument
660 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4, in probe_i915_tgl_hdmi()
664 static int probe_i915_adlp_hdmi(struct hda_codec *codec) in probe_i915_adlp_hdmi() argument
669 res = probe_i915_tgl_hdmi(codec); in probe_i915_adlp_hdmi()
671 spec = codec->spec; in probe_i915_adlp_hdmi()
681 static int probe_i915_byt_hdmi(struct hda_codec *codec) in probe_i915_byt_hdmi() argument
685 spec = codec->spec; in probe_i915_byt_hdmi()
687 /* For Valleyview/Cherryview, only the display codec is in the display in probe_i915_byt_hdmi()
690 codec->display_power_control = 1; in probe_i915_byt_hdmi()
692 codec->depop_delay = 0; in probe_i915_byt_hdmi()
693 codec->auto_runtime_pm = 1; in probe_i915_byt_hdmi()
697 return parse_intel_hdmi(codec); in probe_i915_byt_hdmi()
701 static int probe_i915_cpt_hdmi(struct hda_codec *codec) in probe_i915_cpt_hdmi() argument
703 return parse_intel_hdmi(codec); in probe_i915_cpt_hdmi()
709 static int intelhdmi_probe(struct hda_codec *codec, const struct hda_device_id *id) in intelhdmi_probe() argument
713 err = alloc_intel_hdmi(codec); in intelhdmi_probe()
719 err = probe_i915_hsw_hdmi(codec); in intelhdmi_probe()
722 err = probe_i915_glk_hdmi(codec); in intelhdmi_probe()
725 err = probe_i915_icl_hdmi(codec); in intelhdmi_probe()
728 err = probe_i915_tgl_hdmi(codec); in intelhdmi_probe()
731 err = probe_i915_adlp_hdmi(codec); in intelhdmi_probe()
734 err = probe_i915_byt_hdmi(codec); in intelhdmi_probe()
737 err = probe_i915_cpt_hdmi(codec); in intelhdmi_probe()
745 snd_hda_hdmi_generic_spec_free(codec); in intelhdmi_probe()
803 MODULE_DESCRIPTION("Intel HDMI HD-audio codec");