// SPDX-License-Identifier: MIT /* * Copyright © 2021 Intel Corporation */ #include "i915_drv.h" #include "i915_reg.h" #include "intel_atomic.h" #include "intel_de.h" #include "intel_display_types.h" #include "intel_drrs.h" #include "intel_frontbuffer.h" #include "intel_panel.h" /** * DOC: Display Refresh Rate Switching (DRRS) * * Display Refresh Rate Switching (DRRS) is a power conservation feature * which enables swtching between low and high refresh rates, * dynamically, based on the usage scenario. This feature is applicable * for internal panels. * * Indication that the panel supports DRRS is given by the panel EDID, which * would list multiple refresh rates for one resolution. * * DRRS is of 2 types - static and seamless. * Static DRRS involves changing refresh rate (RR) by doing a full modeset * (may appear as a blink on screen) and is used in dock-undock scenario. * Seamless DRRS involves changing RR without any visual effect to the user * and can be used during normal system usage. This is done by programming * certain registers. * * Support for static/seamless DRRS may be indicated in the VBT based on * inputs from the panel spec. * * DRRS saves power by switching to low RR based on usage scenarios. * * The implementation is based on frontbuffer tracking implementation. When * there is a disturbance on the screen triggered by user activity or a periodic * system activity, DRRS is disabled (RR is changed to high RR). When there is * no movement on screen, after a timeout of 1 second, a switch to low RR is * made. * * For integration with frontbuffer tracking code, intel_drrs_invalidate() * and intel_drrs_flush() are called. * * DRRS can be further extended to support other internal panels and also * the scenario of video playback wherein RR is set based on the rate * requested by userspace. */ const char *intel_drrs_type_str(enum drrs_type drrs_type) { … } bool intel_cpu_transcoder_has_drrs(struct drm_i915_private *i915, enum transcoder cpu_transcoder) { … } static void intel_drrs_set_refresh_rate_pipeconf(struct intel_crtc *crtc, enum drrs_refresh_rate refresh_rate) { … } static void intel_drrs_set_refresh_rate_m_n(struct intel_crtc *crtc, enum drrs_refresh_rate refresh_rate) { … } bool intel_drrs_is_active(struct intel_crtc *crtc) { … } static void intel_drrs_set_state(struct intel_crtc *crtc, enum drrs_refresh_rate refresh_rate) { … } static void intel_drrs_schedule_work(struct intel_crtc *crtc) { … } static unsigned int intel_drrs_frontbuffer_bits(const struct intel_crtc_state *crtc_state) { … } /** * intel_drrs_activate - activate DRRS * @crtc_state: the crtc state * * Activates DRRS on the crtc. */ void intel_drrs_activate(const struct intel_crtc_state *crtc_state) { … } /** * intel_drrs_deactivate - deactivate DRRS * @old_crtc_state: the old crtc state * * Deactivates DRRS on the crtc. */ void intel_drrs_deactivate(const struct intel_crtc_state *old_crtc_state) { … } static void intel_drrs_downclock_work(struct work_struct *work) { … } static void intel_drrs_frontbuffer_update(struct drm_i915_private *dev_priv, unsigned int all_frontbuffer_bits, bool invalidate) { … } /** * intel_drrs_invalidate - Disable Idleness DRRS * @dev_priv: i915 device * @frontbuffer_bits: frontbuffer plane tracking bits * * This function gets called everytime rendering on the given planes start. * Hence DRRS needs to be Upclocked, i.e. (LOW_RR -> HIGH_RR). * * Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bits. */ void intel_drrs_invalidate(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits) { … } /** * intel_drrs_flush - Restart Idleness DRRS * @dev_priv: i915 device * @frontbuffer_bits: frontbuffer plane tracking bits * * This function gets called every time rendering on the given planes has * completed or flip on a crtc is completed. So DRRS should be upclocked * (LOW_RR -> HIGH_RR). And also Idleness detection should be started again, * if no other planes are dirty. * * Dirty frontbuffers relevant to DRRS are tracked in busy_frontbuffer_bits. */ void intel_drrs_flush(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits) { … } /** * intel_drrs_crtc_init - Init DRRS for CRTC * @crtc: crtc * * This function is called only once at driver load to initialize basic * DRRS stuff. * */ void intel_drrs_crtc_init(struct intel_crtc *crtc) { … } static int intel_drrs_debugfs_status_show(struct seq_file *m, void *unused) { … } DEFINE_SHOW_ATTRIBUTE(…); static int intel_drrs_debugfs_ctl_set(void *data, u64 val) { … } DEFINE_DEBUGFS_ATTRIBUTE(…); void intel_drrs_crtc_debugfs_add(struct intel_crtc *crtc) { … } static int intel_drrs_debugfs_type_show(struct seq_file *m, void *unused) { … } DEFINE_SHOW_ATTRIBUTE(…); void intel_drrs_connector_debugfs_add(struct intel_connector *connector) { … }