summaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2019-06-12 10:50:19 -0400
committerSean Paul <seanpaul@chromium.org>2019-06-13 14:31:10 -0400
commit1452c25b0e60278820f3d2155c65f1bfcce5ee79 (patch)
tree1f070c0600b87f5a608f4373d38b8aaa73d02d15 /include/drm
parent6f3b62781bbd2670756a4847113d410a827a2593 (diff)
drm: Add helpers to kick off self refresh mode in drivers
This patch adds a new drm helper library to help drivers implement self refresh. Drivers choosing to use it will register crtcs and will receive callbacks when it's time to enter or exit self refresh mode. In its current form, it has a timer which will trigger after a driver-specified amount of inactivity. When the timer triggers, the helpers will submit a new atomic commit to shut the refreshing pipe off. On the next atomic commit, the drm core will revert the self refresh state and bring everything back up to be actively driven. From the driver's perspective, this works like a regular disable/enable cycle. The driver need only check the 'self_refresh_active' state in crtc_state. It should initiate self refresh mode on the panel and enter an off or low-power state. Changes in v2: - s/psr/self_refresh/ (Daniel) - integrated the psr exit into the commit that wakes it up (Jose/Daniel) - made the psr state per-crtc (Jose/Daniel) Changes in v3: - Remove the self_refresh_(active|changed) from connector state (Daniel) - Simplify loop in drm_self_refresh_helper_alter_state (Daniel) - Improve self_refresh_aware comment (Daniel) - s/self_refresh_state/self_refresh_data/ (Daniel) Changes in v4: - Move docbook location below panel (Daniel) - Improve docbook with references and more detailed explanation (Daniel) - Instead of register/unregister, use init/cleanup (Daniel) Changes in v5: - Resolved conflict in drm_atomic_helper.c #include block - Resolved conflict in rst with HDCP helper docs Changes in v6: - Fix include ordering, clean up forward declarations (Sam) Link to v1: https://patchwork.freedesktop.org/patch/msgid/20190228210939.83386-2-sean@poorly.run Link to v2: https://patchwork.freedesktop.org/patch/msgid/20190326204509.96515-1-sean@poorly.run Link to v3: https://patchwork.freedesktop.org/patch/msgid/20190502194956.218441-6-sean@poorly.run Link to v4: https://patchwork.freedesktop.org/patch/msgid/20190508160920.144739-6-sean@poorly.run Link to v5: https://patchwork.freedesktop.org/patch/msgid/20190611160844.257498-6-sean@poorly.run Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Jose Souza <jose.souza@intel.com> Cc: Zain Wang <wzz@rock-chips.com> Cc: Tomasz Figa <tfiga@chromium.org> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Sam Ravnborg <sam@ravnborg.org> Tested-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Sean Paul <seanpaul@chromium.org> Link: https://patchwork.freedesktop.org/patch/msgid/20190612145026.191846-1-sean@poorly.run
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/drm_atomic.h15
-rw-r--r--include/drm/drm_connector.h14
-rw-r--r--include/drm/drm_crtc.h19
-rw-r--r--include/drm/drm_self_refresh_helper.h20
4 files changed, 68 insertions, 0 deletions
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index f12215647801..927e1205d7aa 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -957,4 +957,19 @@ drm_atomic_crtc_needs_modeset(const struct drm_crtc_state *state)
957 state->connectors_changed; 957 state->connectors_changed;
958} 958}
959 959
960/**
961 * drm_atomic_crtc_effectively_active - compute whether crtc is actually active
962 * @state: &drm_crtc_state for the CRTC
963 *
964 * When in self refresh mode, the crtc_state->active value will be false, since
965 * the crtc is off. However in some cases we're interested in whether the crtc
966 * is active, or effectively active (ie: it's connected to an active display).
967 * In these cases, use this function instead of just checking active.
968 */
969static inline bool
970drm_atomic_crtc_effectively_active(const struct drm_crtc_state *state)
971{
972 return state->active || state->self_refresh_active;
973}
974
960#endif /* DRM_ATOMIC_H_ */ 975#endif /* DRM_ATOMIC_H_ */
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 071143bc0ebd..c6f8486d8b8f 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -549,6 +549,20 @@ struct drm_connector_state {
549 struct drm_tv_connector_state tv; 549 struct drm_tv_connector_state tv;
550 550
551 /** 551 /**
552 * @self_refresh_aware:
553 *
554 * This tracks whether a connector is aware of the self refresh state.
555 * It should be set to true for those connector implementations which
556 * understand the self refresh state. This is needed since the crtc
557 * registers the self refresh helpers and it doesn't know if the
558 * connectors downstream have implemented self refresh entry/exit.
559 *
560 * Drivers should set this to true in atomic_check if they know how to
561 * handle self_refresh requests.
562 */
563 bool self_refresh_aware;
564
565 /**
552 * @picture_aspect_ratio: Connector property to control the 566 * @picture_aspect_ratio: Connector property to control the
553 * HDMI infoframe aspect ratio setting. 567 * HDMI infoframe aspect ratio setting.
554 * 568 *
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index dc42b9e35333..128d8b210621 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -54,6 +54,7 @@ struct drm_mode_set;
54struct drm_file; 54struct drm_file;
55struct drm_clip_rect; 55struct drm_clip_rect;
56struct drm_printer; 56struct drm_printer;
57struct drm_self_refresh_data;
57struct device_node; 58struct device_node;
58struct dma_fence; 59struct dma_fence;
59struct edid; 60struct edid;
@@ -301,6 +302,17 @@ struct drm_crtc_state {
301 bool vrr_enabled; 302 bool vrr_enabled;
302 303
303 /** 304 /**
305 * @self_refresh_active:
306 *
307 * Used by the self refresh helpers to denote when a self refresh
308 * transition is occurring. This will be set on enable/disable callbacks
309 * when self refresh is being enabled or disabled. In some cases, it may
310 * not be desirable to fully shut off the crtc during self refresh.
311 * CRTC's can inspect this flag and determine the best course of action.
312 */
313 bool self_refresh_active;
314
315 /**
304 * @event: 316 * @event:
305 * 317 *
306 * Optional pointer to a DRM event to signal upon completion of the 318 * Optional pointer to a DRM event to signal upon completion of the
@@ -1088,6 +1100,13 @@ struct drm_crtc {
1088 * The name of the CRTC's fence timeline. 1100 * The name of the CRTC's fence timeline.
1089 */ 1101 */
1090 char timeline_name[32]; 1102 char timeline_name[32];
1103
1104 /**
1105 * @self_refresh_data: Holds the state for the self refresh helpers
1106 *
1107 * Initialized via drm_self_refresh_helper_register().
1108 */
1109 struct drm_self_refresh_data *self_refresh_data;
1091}; 1110};
1092 1111
1093/** 1112/**
diff --git a/include/drm/drm_self_refresh_helper.h b/include/drm/drm_self_refresh_helper.h
new file mode 100644
index 000000000000..397a583ccca7
--- /dev/null
+++ b/include/drm/drm_self_refresh_helper.h
@@ -0,0 +1,20 @@
1// SPDX-License-Identifier: MIT
2/*
3 * Copyright (C) 2019 Google, Inc.
4 *
5 * Authors:
6 * Sean Paul <seanpaul@chromium.org>
7 */
8#ifndef DRM_SELF_REFRESH_HELPER_H_
9#define DRM_SELF_REFRESH_HELPER_H_
10
11struct drm_atomic_state;
12struct drm_crtc;
13
14void drm_self_refresh_helper_alter_state(struct drm_atomic_state *state);
15
16int drm_self_refresh_helper_init(struct drm_crtc *crtc,
17 unsigned int entry_delay_ms);
18
19void drm_self_refresh_helper_cleanup(struct drm_crtc *crtc);
20#endif