Lines Matching +full:self +full:- +full:refresh
1 // SPDX-License-Identifier: MIT
27 * framework to implement panel self refresh (SR) support. Drivers are
31 * &drm_connector_state.self_refresh_aware to true at runtime if it is SR-aware
32 * (meaning it knows how to initiate self refresh on the panel).
38 * that tells you to disable/enable SR on the panel instead of power-cycling it.
72 struct drm_crtc *crtc = sr_data->crtc; in drm_self_refresh_helper_entry_work()
73 struct drm_device *dev = crtc->dev; in drm_self_refresh_helper_entry_work()
85 ret = -ENOMEM; in drm_self_refresh_helper_entry_work()
90 state->acquire_ctx = &ctx; in drm_self_refresh_helper_entry_work()
98 if (!crtc_state->enable) in drm_self_refresh_helper_entry_work()
106 if (!conn_state->self_refresh_aware) in drm_self_refresh_helper_entry_work()
110 crtc_state->active = false; in drm_self_refresh_helper_entry_work()
111 crtc_state->self_refresh_active = true; in drm_self_refresh_helper_entry_work()
118 if (ret == -EDEADLK) { in drm_self_refresh_helper_entry_work()
133 * drm_self_refresh_helper_update_avg_times - Updates a crtc's SR time averages
140 * update the average entry/exit self refresh times on self refresh transitions.
142 * entering self refresh mode after activity.
155 struct drm_self_refresh_data *sr_data = crtc->self_refresh_data; in drm_self_refresh_helper_update_avg_times()
158 if (old_crtc_state->self_refresh_active == in drm_self_refresh_helper_update_avg_times()
163 time = &sr_data->entry_avg_ms; in drm_self_refresh_helper_update_avg_times()
165 time = &sr_data->exit_avg_ms; in drm_self_refresh_helper_update_avg_times()
167 mutex_lock(&sr_data->avg_mutex); in drm_self_refresh_helper_update_avg_times()
169 mutex_unlock(&sr_data->avg_mutex); in drm_self_refresh_helper_update_avg_times()
175 * drm_self_refresh_helper_alter_state - Alters the atomic state for SR exit
179 * incompatible with self refresh exit and changes them. This is a bit
181 * another. However in order to keep self refresh entirely hidden from
184 * At the end, we queue up the self refresh entry work so we can enter PSR after
193 if (state->async_update || !state->allow_modeset) { in drm_self_refresh_helper_alter_state()
195 if (crtc_state->self_refresh_active) { in drm_self_refresh_helper_alter_state()
196 state->async_update = false; in drm_self_refresh_helper_alter_state()
197 state->allow_modeset = true; in drm_self_refresh_helper_alter_state()
208 if (crtc_state->self_refresh_active) in drm_self_refresh_helper_alter_state()
211 sr_data = crtc->self_refresh_data; in drm_self_refresh_helper_alter_state()
215 mutex_lock(&sr_data->avg_mutex); in drm_self_refresh_helper_alter_state()
216 delay = (ewma_psr_time_read(&sr_data->entry_avg_ms) + in drm_self_refresh_helper_alter_state()
217 ewma_psr_time_read(&sr_data->exit_avg_ms)) * 2; in drm_self_refresh_helper_alter_state()
218 mutex_unlock(&sr_data->avg_mutex); in drm_self_refresh_helper_alter_state()
220 mod_delayed_work(system_wq, &sr_data->entry_work, in drm_self_refresh_helper_alter_state()
227 * drm_self_refresh_helper_init - Initializes self refresh helpers for a crtc
228 * @crtc: the crtc which supports self refresh supported displays
230 * Returns zero if successful or -errno on failure
234 struct drm_self_refresh_data *sr_data = crtc->self_refresh_data; in drm_self_refresh_helper_init()
238 return -EINVAL; in drm_self_refresh_helper_init()
242 return -ENOMEM; in drm_self_refresh_helper_init()
244 INIT_DELAYED_WORK(&sr_data->entry_work, in drm_self_refresh_helper_init()
246 sr_data->crtc = crtc; in drm_self_refresh_helper_init()
247 mutex_init(&sr_data->avg_mutex); in drm_self_refresh_helper_init()
248 ewma_psr_time_init(&sr_data->entry_avg_ms); in drm_self_refresh_helper_init()
249 ewma_psr_time_init(&sr_data->exit_avg_ms); in drm_self_refresh_helper_init()
252 * Seed the averages so they're non-zero (and sufficiently large in drm_self_refresh_helper_init()
256 ewma_psr_time_add(&sr_data->entry_avg_ms, SELF_REFRESH_AVG_SEED_MS); in drm_self_refresh_helper_init()
257 ewma_psr_time_add(&sr_data->exit_avg_ms, SELF_REFRESH_AVG_SEED_MS); in drm_self_refresh_helper_init()
259 crtc->self_refresh_data = sr_data; in drm_self_refresh_helper_init()
265 * drm_self_refresh_helper_cleanup - Cleans up self refresh helpers for a crtc
270 struct drm_self_refresh_data *sr_data = crtc->self_refresh_data; in drm_self_refresh_helper_cleanup()
276 crtc->self_refresh_data = NULL; in drm_self_refresh_helper_cleanup()
278 cancel_delayed_work_sync(&sr_data->entry_work); in drm_self_refresh_helper_cleanup()