Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2006 Keith Packard |
| 3 | * Copyright © 2007-2008 Dave Airlie |
| 4 | * Copyright © 2007-2008 Intel Corporation |
| 5 | * Jesse Barnes <jesse.barnes@intel.com> |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 | * OTHER DEALINGS IN THE SOFTWARE. |
| 24 | */ |
| 25 | #ifndef __DRM_CRTC_H__ |
| 26 | #define __DRM_CRTC_H__ |
| 27 | |
| 28 | #include <linux/i2c.h> |
| 29 | #include <linux/spinlock.h> |
| 30 | #include <linux/types.h> |
| 31 | #include <linux/idr.h> |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 32 | #include <linux/fb.h> |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 33 | #include <linux/hdmi.h> |
Boris Brezillon | b5571e9 | 2014-07-22 12:09:10 +0200 | [diff] [blame] | 34 | #include <linux/media-bus-format.h> |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 35 | #include <uapi/drm/drm_mode.h> |
| 36 | #include <uapi/drm/drm_fourcc.h> |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 37 | #include <drm/drm_modeset_lock.h> |
Ville Syrjälä | d7da824 | 2016-07-26 19:06:57 +0300 | [diff] [blame] | 38 | #include <drm/drm_rect.h> |
Daniel Vetter | 949619f | 2016-08-29 10:27:51 +0200 | [diff] [blame] | 39 | #include <drm/drm_mode_object.h> |
Daniel Vetter | 7520a27 | 2016-08-15 16:07:02 +0200 | [diff] [blame] | 40 | #include <drm/drm_framebuffer.h> |
| 41 | #include <drm/drm_modes.h> |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 42 | #include <drm/drm_connector.h> |
Daniel Vetter | 321a95a | 2016-08-29 10:27:49 +0200 | [diff] [blame] | 43 | #include <drm/drm_encoder.h> |
Daniel Vetter | 59e71ee | 2016-08-29 10:27:55 +0200 | [diff] [blame] | 44 | #include <drm/drm_property.h> |
Daniel Vetter | 199e4e9 | 2016-08-31 18:09:05 +0200 | [diff] [blame] | 45 | #include <drm/drm_bridge.h> |
Daniel Vetter | cdc3d09 | 2016-08-31 18:09:06 +0200 | [diff] [blame^] | 46 | #include <drm/drm_edid.h> |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 47 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 48 | struct drm_device; |
| 49 | struct drm_mode_set; |
Thierry Reding | 595887e | 2012-11-21 15:00:47 +0100 | [diff] [blame] | 50 | struct drm_file; |
| 51 | struct drm_clip_rect; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 52 | struct device_node; |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 53 | struct fence; |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 54 | struct edid; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 55 | |
Rob Clark | ebc44cf | 2012-09-12 22:22:31 -0500 | [diff] [blame] | 56 | static inline int64_t U642I64(uint64_t val) |
| 57 | { |
| 58 | return (int64_t)*((int64_t *)&val); |
| 59 | } |
| 60 | static inline uint64_t I642U64(int64_t val) |
| 61 | { |
| 62 | return (uint64_t)*((uint64_t *)&val); |
| 63 | } |
| 64 | |
Robert Fekete | d9c3824 | 2015-11-02 16:14:08 +0100 | [diff] [blame] | 65 | /* |
| 66 | * Rotation property bits. DRM_ROTATE_<degrees> rotates the image by the |
| 67 | * specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and |
| 68 | * DRM_REFLECT_Y reflects the image along the specified axis prior to rotation |
| 69 | */ |
Joonas Lahtinen | 31ad61e | 2016-07-29 08:50:05 +0300 | [diff] [blame] | 70 | #define DRM_ROTATE_0 BIT(0) |
| 71 | #define DRM_ROTATE_90 BIT(1) |
| 72 | #define DRM_ROTATE_180 BIT(2) |
| 73 | #define DRM_ROTATE_270 BIT(3) |
| 74 | #define DRM_ROTATE_MASK (DRM_ROTATE_0 | DRM_ROTATE_90 | \ |
| 75 | DRM_ROTATE_180 | DRM_ROTATE_270) |
| 76 | #define DRM_REFLECT_X BIT(4) |
| 77 | #define DRM_REFLECT_Y BIT(5) |
| 78 | #define DRM_REFLECT_MASK (DRM_REFLECT_X | DRM_REFLECT_Y) |
Ville Syrjälä | 0659696 | 2014-07-08 10:31:51 +0530 | [diff] [blame] | 79 | |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 80 | /* data corresponds to displayid vend/prod/serial */ |
| 81 | struct drm_tile_group { |
| 82 | struct kref refcount; |
| 83 | struct drm_device *dev; |
| 84 | int id; |
| 85 | u8 group_data[8]; |
| 86 | }; |
| 87 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 88 | struct drm_crtc; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 89 | struct drm_encoder; |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 90 | struct drm_pending_vblank_event; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 91 | struct drm_plane; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 92 | struct drm_bridge; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 93 | struct drm_atomic_state; |
| 94 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 95 | struct drm_crtc_helper_funcs; |
| 96 | struct drm_encoder_helper_funcs; |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 97 | struct drm_plane_helper_funcs; |
| 98 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 99 | /** |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 100 | * struct drm_crtc_state - mutable CRTC state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 101 | * @crtc: backpointer to the CRTC |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 102 | * @enable: whether the CRTC should be enabled, gates all other state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 103 | * @active: whether the CRTC is actively displaying (used for DPMS) |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 104 | * @planes_changed: planes on this crtc are updated |
| 105 | * @mode_changed: crtc_state->mode or crtc_state->enable has been changed |
| 106 | * @active_changed: crtc_state->active has been toggled. |
| 107 | * @connectors_changed: connectors to this crtc have been updated |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 108 | * @zpos_changed: zpos values of planes on this crtc have been updated |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 109 | * @color_mgmt_changed: color management properties have changed (degamma or |
| 110 | * gamma LUT or CSC matrix) |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 111 | * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 112 | * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 113 | * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 114 | * @last_vblank_count: for helpers and drivers to capture the vblank of the |
| 115 | * update to ensure framebuffer cleanup isn't done too early |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 116 | * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 117 | * @mode: current mode timings |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 118 | * @mode_blob: &drm_property_blob for @mode |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 119 | * @degamma_lut: Lookup table for converting framebuffer pixel data |
| 120 | * before apply the conversion matrix |
| 121 | * @ctm: Transformation matrix |
| 122 | * @gamma_lut: Lookup table for converting pixel data after the |
| 123 | * conversion matrix |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 124 | * @event: optional pointer to a DRM event to signal upon completion of the |
| 125 | * state update |
| 126 | * @state: backpointer to global drm_atomic_state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 127 | * |
| 128 | * Note that the distinction between @enable and @active is rather subtile: |
| 129 | * Flipping @active while @enable is set without changing anything else may |
| 130 | * never return in a failure from the ->atomic_check callback. Userspace assumes |
| 131 | * that a DPMS On will always succeed. In other words: @enable controls resource |
| 132 | * assignment, @active controls the actual hardware state. |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 133 | */ |
| 134 | struct drm_crtc_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 135 | struct drm_crtc *crtc; |
| 136 | |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 137 | bool enable; |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 138 | bool active; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 139 | |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 140 | /* computed state bits used by helpers and drivers */ |
| 141 | bool planes_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 142 | bool mode_changed : 1; |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 143 | bool active_changed : 1; |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 144 | bool connectors_changed : 1; |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 145 | bool zpos_changed : 1; |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 146 | bool color_mgmt_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 147 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 148 | /* attached planes bitmask: |
| 149 | * WARNING: transitional helpers do not maintain plane_mask so |
| 150 | * drivers not converted over to atomic helpers should not rely |
| 151 | * on plane_mask being accurate! |
| 152 | */ |
| 153 | u32 plane_mask; |
| 154 | |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 155 | u32 connector_mask; |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 156 | u32 encoder_mask; |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 157 | |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 158 | /* last_vblank_count: for vblank waits before cleanup */ |
| 159 | u32 last_vblank_count; |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 160 | |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 161 | /* adjusted_mode: for use by helpers and drivers */ |
| 162 | struct drm_display_mode adjusted_mode; |
| 163 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 164 | struct drm_display_mode mode; |
| 165 | |
Daniel Stone | 99cf4a2 | 2015-05-25 19:11:51 +0100 | [diff] [blame] | 166 | /* blob property to expose current mode to atomic userspace */ |
| 167 | struct drm_property_blob *mode_blob; |
| 168 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 169 | /* blob property to expose color management to userspace */ |
| 170 | struct drm_property_blob *degamma_lut; |
| 171 | struct drm_property_blob *ctm; |
| 172 | struct drm_property_blob *gamma_lut; |
| 173 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 174 | struct drm_pending_vblank_event *event; |
| 175 | |
| 176 | struct drm_atomic_state *state; |
| 177 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 178 | |
| 179 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 180 | * struct drm_crtc_funcs - control CRTCs for a given device |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 181 | * |
| 182 | * The drm_crtc_funcs structure is the central CRTC management structure |
| 183 | * in the DRM. Each CRTC controls one or more connectors (note that the name |
| 184 | * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. |
| 185 | * connectors, not just CRTs). |
| 186 | * |
| 187 | * Each driver is responsible for filling out this structure at startup time, |
| 188 | * in addition to providing other modesetting features, like i2c and DDC |
| 189 | * bus accessors. |
| 190 | */ |
| 191 | struct drm_crtc_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 192 | /** |
| 193 | * @reset: |
| 194 | * |
| 195 | * Reset CRTC hardware and software state to off. This function isn't |
| 196 | * called by the core directly, only through drm_mode_config_reset(). |
| 197 | * It's not a helper hook only for historical reasons. |
| 198 | * |
| 199 | * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset |
| 200 | * atomic state using this hook. |
| 201 | */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 202 | void (*reset)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 203 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 204 | /** |
| 205 | * @cursor_set: |
| 206 | * |
| 207 | * Update the cursor image. The cursor position is relative to the CRTC |
| 208 | * and can be partially or fully outside of the visible area. |
| 209 | * |
| 210 | * Note that contrary to all other KMS functions the legacy cursor entry |
| 211 | * points don't take a framebuffer object, but instead take directly a |
| 212 | * raw buffer object id from the driver's buffer manager (which is |
| 213 | * either GEM or TTM for current drivers). |
| 214 | * |
| 215 | * This entry point is deprecated, drivers should instead implement |
| 216 | * universal plane support and register a proper cursor plane using |
| 217 | * drm_crtc_init_with_planes(). |
| 218 | * |
| 219 | * This callback is optional |
| 220 | * |
| 221 | * RETURNS: |
| 222 | * |
| 223 | * 0 on success or a negative error code on failure. |
| 224 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 225 | int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 226 | uint32_t handle, uint32_t width, uint32_t height); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 227 | |
| 228 | /** |
| 229 | * @cursor_set2: |
| 230 | * |
| 231 | * Update the cursor image, including hotspot information. The hotspot |
| 232 | * must not affect the cursor position in CRTC coordinates, but is only |
| 233 | * meant as a hint for virtualized display hardware to coordinate the |
| 234 | * guests and hosts cursor position. The cursor hotspot is relative to |
| 235 | * the cursor image. Otherwise this works exactly like @cursor_set. |
| 236 | * |
| 237 | * This entry point is deprecated, drivers should instead implement |
| 238 | * universal plane support and register a proper cursor plane using |
| 239 | * drm_crtc_init_with_planes(). |
| 240 | * |
| 241 | * This callback is optional. |
| 242 | * |
| 243 | * RETURNS: |
| 244 | * |
| 245 | * 0 on success or a negative error code on failure. |
| 246 | */ |
Dave Airlie | 4c813d4 | 2013-06-20 11:48:52 +1000 | [diff] [blame] | 247 | int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 248 | uint32_t handle, uint32_t width, uint32_t height, |
| 249 | int32_t hot_x, int32_t hot_y); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 250 | |
| 251 | /** |
| 252 | * @cursor_move: |
| 253 | * |
| 254 | * Update the cursor position. The cursor does not need to be visible |
| 255 | * when this hook is called. |
| 256 | * |
| 257 | * This entry point is deprecated, drivers should instead implement |
| 258 | * universal plane support and register a proper cursor plane using |
| 259 | * drm_crtc_init_with_planes(). |
| 260 | * |
| 261 | * This callback is optional. |
| 262 | * |
| 263 | * RETURNS: |
| 264 | * |
| 265 | * 0 on success or a negative error code on failure. |
| 266 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 267 | int (*cursor_move)(struct drm_crtc *crtc, int x, int y); |
| 268 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 269 | /** |
| 270 | * @gamma_set: |
| 271 | * |
| 272 | * Set gamma on the CRTC. |
| 273 | * |
| 274 | * This callback is optional. |
| 275 | * |
| 276 | * NOTE: |
| 277 | * |
| 278 | * Drivers that support gamma tables and also fbdev emulation through |
| 279 | * the provided helper library need to take care to fill out the gamma |
| 280 | * hooks for both. Currently there's a bit an unfortunate duplication |
| 281 | * going on, which should eventually be unified to just one set of |
| 282 | * hooks. |
| 283 | */ |
Maarten Lankhorst | 7ea7728 | 2016-06-07 12:49:30 +0200 | [diff] [blame] | 284 | int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, |
| 285 | uint32_t size); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 286 | |
| 287 | /** |
| 288 | * @destroy: |
| 289 | * |
| 290 | * Clean up plane resources. This is only called at driver unload time |
| 291 | * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged |
| 292 | * in DRM. |
| 293 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 294 | void (*destroy)(struct drm_crtc *crtc); |
| 295 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 296 | /** |
| 297 | * @set_config: |
| 298 | * |
| 299 | * This is the main legacy entry point to change the modeset state on a |
| 300 | * CRTC. All the details of the desired configuration are passed in a |
| 301 | * struct &drm_mode_set - see there for details. |
| 302 | * |
| 303 | * Drivers implementing atomic modeset should use |
| 304 | * drm_atomic_helper_set_config() to implement this hook. |
| 305 | * |
| 306 | * RETURNS: |
| 307 | * |
| 308 | * 0 on success or a negative error code on failure. |
| 309 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 310 | int (*set_config)(struct drm_mode_set *set); |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 311 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 312 | /** |
| 313 | * @page_flip: |
| 314 | * |
| 315 | * Legacy entry point to schedule a flip to the given framebuffer. |
| 316 | * |
| 317 | * Page flipping is a synchronization mechanism that replaces the frame |
| 318 | * buffer being scanned out by the CRTC with a new frame buffer during |
| 319 | * vertical blanking, avoiding tearing (except when requested otherwise |
| 320 | * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application |
| 321 | * requests a page flip the DRM core verifies that the new frame buffer |
| 322 | * is large enough to be scanned out by the CRTC in the currently |
| 323 | * configured mode and then calls the CRTC ->page_flip() operation with a |
| 324 | * pointer to the new frame buffer. |
| 325 | * |
| 326 | * The driver must wait for any pending rendering to the new framebuffer |
| 327 | * to complete before executing the flip. It should also wait for any |
| 328 | * pending rendering from other drivers if the underlying buffer is a |
| 329 | * shared dma-buf. |
| 330 | * |
| 331 | * An application can request to be notified when the page flip has |
| 332 | * completed. The drm core will supply a struct &drm_event in the event |
| 333 | * parameter in this case. This can be handled by the |
| 334 | * drm_crtc_send_vblank_event() function, which the driver should call on |
| 335 | * the provided event upon completion of the flip. Note that if |
| 336 | * the driver supports vblank signalling and timestamping the vblank |
| 337 | * counters and timestamps must agree with the ones returned from page |
| 338 | * flip events. With the current vblank helper infrastructure this can |
| 339 | * be achieved by holding a vblank reference while the page flip is |
| 340 | * pending, acquired through drm_crtc_vblank_get() and released with |
| 341 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank |
| 342 | * counter and timestamp tracking though, e.g. if they have accurate |
| 343 | * timestamp registers in hardware. |
| 344 | * |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 345 | * This callback is optional. |
| 346 | * |
| 347 | * NOTE: |
| 348 | * |
| 349 | * Very early versions of the KMS ABI mandated that the driver must |
| 350 | * block (but not reject) any rendering to the old framebuffer until the |
| 351 | * flip operation has completed and the old framebuffer is no longer |
| 352 | * visible. This requirement has been lifted, and userspace is instead |
| 353 | * expected to request delivery of an event and wait with recycling old |
| 354 | * buffers until such has been received. |
| 355 | * |
| 356 | * RETURNS: |
| 357 | * |
| 358 | * 0 on success or a negative error code on failure. Note that if a |
| 359 | * ->page_flip() operation is already pending the callback should return |
| 360 | * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode |
| 361 | * or just runtime disabled through DPMS respectively the new atomic |
Daniel Vetter | 4cba685 | 2015-12-08 09:49:20 +0100 | [diff] [blame] | 362 | * "ACTIVE" state) should result in an -EINVAL error code. Note that |
| 363 | * drm_atomic_helper_page_flip() checks this already for atomic drivers. |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 364 | */ |
| 365 | int (*page_flip)(struct drm_crtc *crtc, |
| 366 | struct drm_framebuffer *fb, |
Keith Packard | ed8d197 | 2013-07-22 18:49:58 -0700 | [diff] [blame] | 367 | struct drm_pending_vblank_event *event, |
| 368 | uint32_t flags); |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 369 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 370 | /** |
Michel Dänzer | c229bfb | 2016-08-08 16:23:03 +0900 | [diff] [blame] | 371 | * @page_flip_target: |
| 372 | * |
| 373 | * Same as @page_flip but with an additional parameter specifying the |
| 374 | * absolute target vertical blank period (as reported by |
| 375 | * drm_crtc_vblank_count()) when the flip should take effect. |
| 376 | * |
| 377 | * Note that the core code calls drm_crtc_vblank_get before this entry |
| 378 | * point, and will call drm_crtc_vblank_put if this entry point returns |
| 379 | * any non-0 error code. It's the driver's responsibility to call |
| 380 | * drm_crtc_vblank_put after this entry point returns 0, typically when |
| 381 | * the flip completes. |
| 382 | */ |
| 383 | int (*page_flip_target)(struct drm_crtc *crtc, |
| 384 | struct drm_framebuffer *fb, |
| 385 | struct drm_pending_vblank_event *event, |
| 386 | uint32_t flags, uint32_t target); |
| 387 | |
| 388 | /** |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 389 | * @set_property: |
| 390 | * |
| 391 | * This is the legacy entry point to update a property attached to the |
| 392 | * CRTC. |
| 393 | * |
| 394 | * Drivers implementing atomic modeset should use |
| 395 | * drm_atomic_helper_crtc_set_property() to implement this hook. |
| 396 | * |
| 397 | * This callback is optional if the driver does not support any legacy |
| 398 | * driver-private properties. |
| 399 | * |
| 400 | * RETURNS: |
| 401 | * |
| 402 | * 0 on success or a negative error code on failure. |
| 403 | */ |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 404 | int (*set_property)(struct drm_crtc *crtc, |
| 405 | struct drm_property *property, uint64_t val); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 406 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 407 | /** |
| 408 | * @atomic_duplicate_state: |
| 409 | * |
| 410 | * Duplicate the current atomic state for this CRTC and return it. |
| 411 | * The core and helpers gurantee that any atomic state duplicated with |
| 412 | * this hook and still owned by the caller (i.e. not transferred to the |
| 413 | * driver by calling ->atomic_commit() from struct |
| 414 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 415 | * @atomic_destroy_state hook in this structure. |
| 416 | * |
| 417 | * Atomic drivers which don't subclass struct &drm_crtc should use |
| 418 | * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the |
| 419 | * state structure to extend it with driver-private state should use |
| 420 | * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is |
| 421 | * duplicated in a consistent fashion across drivers. |
| 422 | * |
| 423 | * It is an error to call this hook before crtc->state has been |
| 424 | * initialized correctly. |
| 425 | * |
| 426 | * NOTE: |
| 427 | * |
| 428 | * If the duplicate state references refcounted resources this hook must |
| 429 | * acquire a reference for each of them. The driver must release these |
| 430 | * references again in @atomic_destroy_state. |
| 431 | * |
| 432 | * RETURNS: |
| 433 | * |
| 434 | * Duplicated atomic state or NULL when the allocation failed. |
| 435 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 436 | struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 437 | |
| 438 | /** |
| 439 | * @atomic_destroy_state: |
| 440 | * |
| 441 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 442 | * or unreference all resources it references |
| 443 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 444 | void (*atomic_destroy_state)(struct drm_crtc *crtc, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 445 | struct drm_crtc_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 446 | |
| 447 | /** |
| 448 | * @atomic_set_property: |
| 449 | * |
| 450 | * Decode a driver-private property value and store the decoded value |
| 451 | * into the passed-in state structure. Since the atomic core decodes all |
| 452 | * standardized properties (even for extensions beyond the core set of |
| 453 | * properties which might not be implemented by all drivers) this |
| 454 | * requires drivers to subclass the state structure. |
| 455 | * |
| 456 | * Such driver-private properties should really only be implemented for |
| 457 | * truly hardware/vendor specific state. Instead it is preferred to |
| 458 | * standardize atomic extension and decode the properties used to expose |
| 459 | * such an extension in the core. |
| 460 | * |
| 461 | * Do not call this function directly, use |
| 462 | * drm_atomic_crtc_set_property() instead. |
| 463 | * |
| 464 | * This callback is optional if the driver does not support any |
| 465 | * driver-private atomic properties. |
| 466 | * |
| 467 | * NOTE: |
| 468 | * |
| 469 | * This function is called in the state assembly phase of atomic |
| 470 | * modesets, which can be aborted for any reason (including on |
| 471 | * userspace's request to just check whether a configuration would be |
| 472 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 473 | * software) or data structures except the passed in @state parameter. |
| 474 | * |
| 475 | * Also since userspace controls in which order properties are set this |
| 476 | * function must not do any input validation (since the state update is |
| 477 | * incomplete and hence likely inconsistent). Instead any such input |
| 478 | * validation must be done in the various atomic_check callbacks. |
| 479 | * |
| 480 | * RETURNS: |
| 481 | * |
| 482 | * 0 if the property has been found, -EINVAL if the property isn't |
| 483 | * implemented by the driver (which should never happen, the core only |
| 484 | * asks for properties attached to this CRTC). No other validation is |
| 485 | * allowed by the driver. The core already checks that the property |
| 486 | * value is within the range (integer, valid enum value, ...) the driver |
| 487 | * set when registering the property. |
| 488 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 489 | int (*atomic_set_property)(struct drm_crtc *crtc, |
| 490 | struct drm_crtc_state *state, |
| 491 | struct drm_property *property, |
| 492 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 493 | /** |
| 494 | * @atomic_get_property: |
| 495 | * |
| 496 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 497 | * implement the GETCRTC IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 498 | * |
| 499 | * Do not call this function directly, use |
| 500 | * drm_atomic_crtc_get_property() instead. |
| 501 | * |
| 502 | * This callback is optional if the driver does not support any |
| 503 | * driver-private atomic properties. |
| 504 | * |
| 505 | * RETURNS: |
| 506 | * |
| 507 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 508 | * driver (which should never happen, the core only asks for |
| 509 | * properties attached to this CRTC). |
| 510 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 511 | int (*atomic_get_property)(struct drm_crtc *crtc, |
| 512 | const struct drm_crtc_state *state, |
| 513 | struct drm_property *property, |
| 514 | uint64_t *val); |
Benjamin Gaignard | 79190ea | 2016-06-21 16:37:09 +0200 | [diff] [blame] | 515 | |
| 516 | /** |
| 517 | * @late_register: |
| 518 | * |
| 519 | * This optional hook can be used to register additional userspace |
| 520 | * interfaces attached to the crtc like debugfs interfaces. |
| 521 | * It is called late in the driver load sequence from drm_dev_register(). |
| 522 | * Everything added from this callback should be unregistered in |
| 523 | * the early_unregister callback. |
| 524 | * |
| 525 | * Returns: |
| 526 | * |
| 527 | * 0 on success, or a negative error code on failure. |
| 528 | */ |
| 529 | int (*late_register)(struct drm_crtc *crtc); |
| 530 | |
| 531 | /** |
| 532 | * @early_unregister: |
| 533 | * |
| 534 | * This optional hook should be used to unregister the additional |
| 535 | * userspace interfaces attached to the crtc from |
| 536 | * late_unregister(). It is called from drm_dev_unregister(), |
| 537 | * early in the driver unload sequence to disable userspace access |
| 538 | * before data structures are torndown. |
| 539 | */ |
| 540 | void (*early_unregister)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 541 | }; |
| 542 | |
| 543 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 544 | * struct drm_crtc - central CRTC control structure |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 545 | * @dev: parent DRM device |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 546 | * @port: OF node used by drm_of_find_possible_crtcs() |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 547 | * @head: list management |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 548 | * @name: human readable name, can be overwritten by the driver |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 549 | * @mutex: per-CRTC locking |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 550 | * @base: base KMS object for ID tracking etc. |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 551 | * @primary: primary plane for this CRTC |
| 552 | * @cursor: cursor plane for this CRTC |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 553 | * @cursor_x: current x position of the cursor, used for universal cursor planes |
| 554 | * @cursor_y: current y position of the cursor, used for universal cursor planes |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 555 | * @enabled: is this CRTC enabled? |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 556 | * @mode: current mode timings |
| 557 | * @hwmode: mode timings as programmed to hw regs |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 558 | * @x: x position on screen |
| 559 | * @y: y position on screen |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 560 | * @funcs: CRTC control functions |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 561 | * @gamma_size: size of gamma ramp |
| 562 | * @gamma_store: gamma ramp values |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 563 | * @helper_private: mid-layer private data |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 564 | * @properties: property tracking for this CRTC |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 565 | * |
| 566 | * Each CRTC may have one or more connectors associated with it. This structure |
| 567 | * allows the CRTC to be controlled. |
| 568 | */ |
| 569 | struct drm_crtc { |
| 570 | struct drm_device *dev; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 571 | struct device_node *port; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 572 | struct list_head head; |
| 573 | |
Ville Syrjälä | fa3ab4c | 2015-12-08 18:41:53 +0200 | [diff] [blame] | 574 | char *name; |
| 575 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 576 | /** |
| 577 | * @mutex: |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 578 | * |
| 579 | * This provides a read lock for the overall crtc state (mode, dpms |
| 580 | * state, ...) and a write lock for everything which can be update |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 581 | * without a full modeset (fb, cursor data, crtc properties ...). Full |
| 582 | * modeset also need to grab dev->mode_config.connection_mutex. |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 583 | */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 584 | struct drm_modeset_lock mutex; |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 585 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 586 | struct drm_mode_object base; |
| 587 | |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 588 | /* primary and cursor planes for CRTC */ |
| 589 | struct drm_plane *primary; |
| 590 | struct drm_plane *cursor; |
| 591 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 592 | /** |
| 593 | * @index: Position inside the mode_config.list, can be used as an array |
| 594 | * index. It is invariant over the lifetime of the CRTC. |
| 595 | */ |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 596 | unsigned index; |
| 597 | |
Matt Roper | 161d0dc | 2014-06-10 08:28:10 -0700 | [diff] [blame] | 598 | /* position of cursor plane on crtc */ |
| 599 | int cursor_x; |
| 600 | int cursor_y; |
| 601 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 602 | bool enabled; |
| 603 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 604 | /* Requested mode from modesetting. */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 605 | struct drm_display_mode mode; |
| 606 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 607 | /* Programmed mode in hw, after adjustments for encoders, |
| 608 | * crtc, panel scaling etc. Needed for timestamping etc. |
| 609 | */ |
| 610 | struct drm_display_mode hwmode; |
| 611 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 612 | int x, y; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 613 | const struct drm_crtc_funcs *funcs; |
| 614 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 615 | /* Legacy FB CRTC gamma size for reporting to userspace */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 616 | uint32_t gamma_size; |
| 617 | uint16_t *gamma_store; |
| 618 | |
| 619 | /* if you are using the helper */ |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 620 | const struct drm_crtc_helper_funcs *helper_private; |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 621 | |
| 622 | struct drm_object_properties properties; |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 623 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 624 | /** |
| 625 | * @state: |
| 626 | * |
| 627 | * Current atomic state for this CRTC. |
| 628 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 629 | struct drm_crtc_state *state; |
| 630 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 631 | /** |
| 632 | * @commit_list: |
| 633 | * |
| 634 | * List of &drm_crtc_commit structures tracking pending commits. |
| 635 | * Protected by @commit_lock. This list doesn't hold its own full |
| 636 | * reference, but burrows it from the ongoing commit. Commit entries |
| 637 | * must be removed from this list once the commit is fully completed, |
| 638 | * but before it's correspoding &drm_atomic_state gets destroyed. |
| 639 | */ |
| 640 | struct list_head commit_list; |
| 641 | |
| 642 | /** |
| 643 | * @commit_lock: |
| 644 | * |
| 645 | * Spinlock to protect @commit_list. |
| 646 | */ |
| 647 | spinlock_t commit_lock; |
| 648 | |
| 649 | /** |
| 650 | * @acquire_ctx: |
| 651 | * |
| 652 | * Per-CRTC implicit acquire context used by atomic drivers for legacy |
| 653 | * IOCTLs, so that atomic drivers can get at the locking acquire |
| 654 | * context. |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 655 | */ |
| 656 | struct drm_modeset_acquire_ctx *acquire_ctx; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 657 | }; |
| 658 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 659 | /** |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 660 | * struct drm_plane_state - mutable plane state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 661 | * @plane: backpointer to the plane |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 662 | * @crtc: currently bound CRTC, NULL if disabled |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 663 | * @fb: currently bound framebuffer |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 664 | * @fence: optional fence to wait for before scanning out @fb |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 665 | * @crtc_x: left position of visible portion of plane on crtc |
| 666 | * @crtc_y: upper position of visible portion of plane on crtc |
| 667 | * @crtc_w: width of visible portion of plane on crtc |
| 668 | * @crtc_h: height of visible portion of plane on crtc |
| 669 | * @src_x: left position of visible portion of plane within |
| 670 | * plane (in 16.16) |
| 671 | * @src_y: upper position of visible portion of plane within |
| 672 | * plane (in 16.16) |
| 673 | * @src_w: width of visible portion of plane (in 16.16) |
| 674 | * @src_h: height of visible portion of plane (in 16.16) |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 675 | * @rotation: rotation of the plane |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 676 | * @zpos: priority of the given plane on crtc (optional) |
| 677 | * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1 |
| 678 | * where N is the number of active planes for given crtc |
Ville Syrjälä | d7da824 | 2016-07-26 19:06:57 +0300 | [diff] [blame] | 679 | * @src: clipped source coordinates of the plane (in 16.16) |
| 680 | * @dst: clipped destination coordinates of the plane |
| 681 | * @visible: visibility of the plane |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 682 | * @state: backpointer to global drm_atomic_state |
| 683 | */ |
| 684 | struct drm_plane_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 685 | struct drm_plane *plane; |
| 686 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 687 | struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */ |
| 688 | struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */ |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 689 | struct fence *fence; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 690 | |
| 691 | /* Signed dest location allows it to be partially off screen */ |
| 692 | int32_t crtc_x, crtc_y; |
| 693 | uint32_t crtc_w, crtc_h; |
| 694 | |
| 695 | /* Source values are 16.16 fixed point */ |
| 696 | uint32_t src_x, src_y; |
| 697 | uint32_t src_h, src_w; |
| 698 | |
Matt Roper | 1da3062 | 2015-01-21 16:35:40 -0800 | [diff] [blame] | 699 | /* Plane rotation */ |
| 700 | unsigned int rotation; |
| 701 | |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 702 | /* Plane zpos */ |
| 703 | unsigned int zpos; |
| 704 | unsigned int normalized_zpos; |
| 705 | |
Ville Syrjälä | d7da824 | 2016-07-26 19:06:57 +0300 | [diff] [blame] | 706 | /* Clipped coordinates */ |
| 707 | struct drm_rect src, dst; |
| 708 | |
| 709 | /* |
| 710 | * Is the plane actually visible? Can be false even |
| 711 | * if fb!=NULL and crtc!=NULL, due to clipping. |
| 712 | */ |
| 713 | bool visible; |
| 714 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 715 | struct drm_atomic_state *state; |
| 716 | }; |
| 717 | |
| 718 | |
| 719 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 720 | * struct drm_plane_funcs - driver plane control functions |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 721 | */ |
| 722 | struct drm_plane_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 723 | /** |
| 724 | * @update_plane: |
| 725 | * |
| 726 | * This is the legacy entry point to enable and configure the plane for |
| 727 | * the given CRTC and framebuffer. It is never called to disable the |
| 728 | * plane, i.e. the passed-in crtc and fb paramters are never NULL. |
| 729 | * |
| 730 | * The source rectangle in frame buffer memory coordinates is given by |
| 731 | * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point |
| 732 | * values). Devices that don't support subpixel plane coordinates can |
| 733 | * ignore the fractional part. |
| 734 | * |
| 735 | * The destination rectangle in CRTC coordinates is given by the |
| 736 | * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values). |
| 737 | * Devices scale the source rectangle to the destination rectangle. If |
| 738 | * scaling is not supported, and the source rectangle size doesn't match |
| 739 | * the destination rectangle size, the driver must return a |
| 740 | * -<errorname>EINVAL</errorname> error. |
| 741 | * |
| 742 | * Drivers implementing atomic modeset should use |
| 743 | * drm_atomic_helper_update_plane() to implement this hook. |
| 744 | * |
| 745 | * RETURNS: |
| 746 | * |
| 747 | * 0 on success or a negative error code on failure. |
| 748 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 749 | int (*update_plane)(struct drm_plane *plane, |
| 750 | struct drm_crtc *crtc, struct drm_framebuffer *fb, |
| 751 | int crtc_x, int crtc_y, |
| 752 | unsigned int crtc_w, unsigned int crtc_h, |
| 753 | uint32_t src_x, uint32_t src_y, |
| 754 | uint32_t src_w, uint32_t src_h); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 755 | |
| 756 | /** |
| 757 | * @disable_plane: |
| 758 | * |
| 759 | * This is the legacy entry point to disable the plane. The DRM core |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 760 | * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 761 | * with the frame buffer ID set to 0. Disabled planes must not be |
| 762 | * processed by the CRTC. |
| 763 | * |
| 764 | * Drivers implementing atomic modeset should use |
| 765 | * drm_atomic_helper_disable_plane() to implement this hook. |
| 766 | * |
| 767 | * RETURNS: |
| 768 | * |
| 769 | * 0 on success or a negative error code on failure. |
| 770 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 771 | int (*disable_plane)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 772 | |
| 773 | /** |
| 774 | * @destroy: |
| 775 | * |
| 776 | * Clean up plane resources. This is only called at driver unload time |
| 777 | * through drm_mode_config_cleanup() since a plane cannot be hotplugged |
| 778 | * in DRM. |
| 779 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 780 | void (*destroy)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 781 | |
| 782 | /** |
| 783 | * @reset: |
| 784 | * |
| 785 | * Reset plane hardware and software state to off. This function isn't |
| 786 | * called by the core directly, only through drm_mode_config_reset(). |
| 787 | * It's not a helper hook only for historical reasons. |
| 788 | * |
| 789 | * Atomic drivers can use drm_atomic_helper_plane_reset() to reset |
| 790 | * atomic state using this hook. |
| 791 | */ |
Daniel Vetter | 2a0d7cf | 2014-07-29 15:32:37 +0200 | [diff] [blame] | 792 | void (*reset)(struct drm_plane *plane); |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 793 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 794 | /** |
| 795 | * @set_property: |
| 796 | * |
| 797 | * This is the legacy entry point to update a property attached to the |
| 798 | * plane. |
| 799 | * |
| 800 | * Drivers implementing atomic modeset should use |
| 801 | * drm_atomic_helper_plane_set_property() to implement this hook. |
| 802 | * |
| 803 | * This callback is optional if the driver does not support any legacy |
| 804 | * driver-private properties. |
| 805 | * |
| 806 | * RETURNS: |
| 807 | * |
| 808 | * 0 on success or a negative error code on failure. |
| 809 | */ |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 810 | int (*set_property)(struct drm_plane *plane, |
| 811 | struct drm_property *property, uint64_t val); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 812 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 813 | /** |
| 814 | * @atomic_duplicate_state: |
| 815 | * |
| 816 | * Duplicate the current atomic state for this plane and return it. |
| 817 | * The core and helpers gurantee that any atomic state duplicated with |
| 818 | * this hook and still owned by the caller (i.e. not transferred to the |
| 819 | * driver by calling ->atomic_commit() from struct |
| 820 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 821 | * @atomic_destroy_state hook in this structure. |
| 822 | * |
| 823 | * Atomic drivers which don't subclass struct &drm_plane_state should use |
| 824 | * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the |
| 825 | * state structure to extend it with driver-private state should use |
| 826 | * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is |
| 827 | * duplicated in a consistent fashion across drivers. |
| 828 | * |
| 829 | * It is an error to call this hook before plane->state has been |
| 830 | * initialized correctly. |
| 831 | * |
| 832 | * NOTE: |
| 833 | * |
| 834 | * If the duplicate state references refcounted resources this hook must |
| 835 | * acquire a reference for each of them. The driver must release these |
| 836 | * references again in @atomic_destroy_state. |
| 837 | * |
| 838 | * RETURNS: |
| 839 | * |
| 840 | * Duplicated atomic state or NULL when the allocation failed. |
| 841 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 842 | struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 843 | |
| 844 | /** |
| 845 | * @atomic_destroy_state: |
| 846 | * |
| 847 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 848 | * or unreference all resources it references |
| 849 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 850 | void (*atomic_destroy_state)(struct drm_plane *plane, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 851 | struct drm_plane_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 852 | |
| 853 | /** |
| 854 | * @atomic_set_property: |
| 855 | * |
| 856 | * Decode a driver-private property value and store the decoded value |
| 857 | * into the passed-in state structure. Since the atomic core decodes all |
| 858 | * standardized properties (even for extensions beyond the core set of |
| 859 | * properties which might not be implemented by all drivers) this |
| 860 | * requires drivers to subclass the state structure. |
| 861 | * |
| 862 | * Such driver-private properties should really only be implemented for |
| 863 | * truly hardware/vendor specific state. Instead it is preferred to |
| 864 | * standardize atomic extension and decode the properties used to expose |
| 865 | * such an extension in the core. |
| 866 | * |
| 867 | * Do not call this function directly, use |
| 868 | * drm_atomic_plane_set_property() instead. |
| 869 | * |
| 870 | * This callback is optional if the driver does not support any |
| 871 | * driver-private atomic properties. |
| 872 | * |
| 873 | * NOTE: |
| 874 | * |
| 875 | * This function is called in the state assembly phase of atomic |
| 876 | * modesets, which can be aborted for any reason (including on |
| 877 | * userspace's request to just check whether a configuration would be |
| 878 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 879 | * software) or data structures except the passed in @state parameter. |
| 880 | * |
| 881 | * Also since userspace controls in which order properties are set this |
| 882 | * function must not do any input validation (since the state update is |
| 883 | * incomplete and hence likely inconsistent). Instead any such input |
| 884 | * validation must be done in the various atomic_check callbacks. |
| 885 | * |
| 886 | * RETURNS: |
| 887 | * |
| 888 | * 0 if the property has been found, -EINVAL if the property isn't |
| 889 | * implemented by the driver (which shouldn't ever happen, the core only |
| 890 | * asks for properties attached to this plane). No other validation is |
| 891 | * allowed by the driver. The core already checks that the property |
| 892 | * value is within the range (integer, valid enum value, ...) the driver |
| 893 | * set when registering the property. |
| 894 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 895 | int (*atomic_set_property)(struct drm_plane *plane, |
| 896 | struct drm_plane_state *state, |
| 897 | struct drm_property *property, |
| 898 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 899 | |
| 900 | /** |
| 901 | * @atomic_get_property: |
| 902 | * |
| 903 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 904 | * implement the GETPLANE IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 905 | * |
| 906 | * Do not call this function directly, use |
| 907 | * drm_atomic_plane_get_property() instead. |
| 908 | * |
| 909 | * This callback is optional if the driver does not support any |
| 910 | * driver-private atomic properties. |
| 911 | * |
| 912 | * RETURNS: |
| 913 | * |
| 914 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 915 | * driver (which should never happen, the core only asks for |
| 916 | * properties attached to this plane). |
| 917 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 918 | int (*atomic_get_property)(struct drm_plane *plane, |
| 919 | const struct drm_plane_state *state, |
| 920 | struct drm_property *property, |
| 921 | uint64_t *val); |
Benjamin Gaignard | 79190ea | 2016-06-21 16:37:09 +0200 | [diff] [blame] | 922 | /** |
| 923 | * @late_register: |
| 924 | * |
| 925 | * This optional hook can be used to register additional userspace |
| 926 | * interfaces attached to the plane like debugfs interfaces. |
| 927 | * It is called late in the driver load sequence from drm_dev_register(). |
| 928 | * Everything added from this callback should be unregistered in |
| 929 | * the early_unregister callback. |
| 930 | * |
| 931 | * Returns: |
| 932 | * |
| 933 | * 0 on success, or a negative error code on failure. |
| 934 | */ |
| 935 | int (*late_register)(struct drm_plane *plane); |
| 936 | |
| 937 | /** |
| 938 | * @early_unregister: |
| 939 | * |
| 940 | * This optional hook should be used to unregister the additional |
| 941 | * userspace interfaces attached to the plane from |
| 942 | * late_unregister(). It is called from drm_dev_unregister(), |
| 943 | * early in the driver unload sequence to disable userspace access |
| 944 | * before data structures are torndown. |
| 945 | */ |
| 946 | void (*early_unregister)(struct drm_plane *plane); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 947 | }; |
| 948 | |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 949 | enum drm_plane_type { |
| 950 | DRM_PLANE_TYPE_OVERLAY, |
| 951 | DRM_PLANE_TYPE_PRIMARY, |
| 952 | DRM_PLANE_TYPE_CURSOR, |
| 953 | }; |
| 954 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 955 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 956 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 957 | * struct drm_plane - central DRM plane control structure |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 958 | * @dev: DRM device this plane belongs to |
| 959 | * @head: for list management |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 960 | * @name: human readable name, can be overwritten by the driver |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 961 | * @base: base mode object |
| 962 | * @possible_crtcs: pipes this plane can be bound to |
| 963 | * @format_types: array of formats supported by this plane |
| 964 | * @format_count: number of formats supported |
Laurent Pinchart | 7eb5f30 | 2015-03-09 10:41:07 +0200 | [diff] [blame] | 965 | * @format_default: driver hasn't supplied supported formats for the plane |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 966 | * @crtc: currently bound CRTC |
| 967 | * @fb: currently bound fb |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 968 | * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by |
| 969 | * drm_mode_set_config_internal() to implement correct refcounting. |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 970 | * @funcs: helper functions |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 971 | * @properties: property tracking for this plane |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 972 | * @type: type of plane (overlay, primary, cursor) |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 973 | * @state: current atomic state for this plane |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 974 | * @zpos_property: zpos property for this plane |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 975 | * @helper_private: mid-layer private data |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 976 | */ |
| 977 | struct drm_plane { |
| 978 | struct drm_device *dev; |
| 979 | struct list_head head; |
| 980 | |
Ville Syrjälä | 9f4c97a | 2015-12-08 18:41:54 +0200 | [diff] [blame] | 981 | char *name; |
| 982 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 983 | /** |
| 984 | * @mutex: |
| 985 | * |
| 986 | * Protects modeset plane state, together with the mutex of &drm_crtc |
| 987 | * this plane is linked to (when active, getting actived or getting |
| 988 | * disabled). |
| 989 | */ |
Daniel Vetter | 4d02e2d | 2014-11-11 10:12:00 +0100 | [diff] [blame] | 990 | struct drm_modeset_lock mutex; |
| 991 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 992 | struct drm_mode_object base; |
| 993 | |
| 994 | uint32_t possible_crtcs; |
| 995 | uint32_t *format_types; |
Thierry Reding | 45e3743 | 2015-08-12 16:54:28 +0200 | [diff] [blame] | 996 | unsigned int format_count; |
Laurent Pinchart | 7eb5f30 | 2015-03-09 10:41:07 +0200 | [diff] [blame] | 997 | bool format_default; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 998 | |
| 999 | struct drm_crtc *crtc; |
| 1000 | struct drm_framebuffer *fb; |
| 1001 | |
Daniel Vetter | 3d30a59 | 2014-07-27 13:42:42 +0200 | [diff] [blame] | 1002 | struct drm_framebuffer *old_fb; |
| 1003 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1004 | const struct drm_plane_funcs *funcs; |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1005 | |
| 1006 | struct drm_object_properties properties; |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1007 | |
| 1008 | enum drm_plane_type type; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1009 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1010 | /** |
| 1011 | * @index: Position inside the mode_config.list, can be used as an array |
| 1012 | * index. It is invariant over the lifetime of the plane. |
| 1013 | */ |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 1014 | unsigned index; |
| 1015 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 1016 | const struct drm_plane_helper_funcs *helper_private; |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 1017 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1018 | struct drm_plane_state *state; |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 1019 | |
| 1020 | struct drm_property *zpos_property; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1021 | }; |
| 1022 | |
| 1023 | /** |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 1024 | * struct drm_crtc_commit - track modeset commits on a CRTC |
| 1025 | * |
| 1026 | * This structure is used to track pending modeset changes and atomic commit on |
| 1027 | * a per-CRTC basis. Since updating the list should never block this structure |
| 1028 | * is reference counted to allow waiters to safely wait on an event to complete, |
| 1029 | * without holding any locks. |
| 1030 | * |
| 1031 | * It has 3 different events in total to allow a fine-grained synchronization |
| 1032 | * between outstanding updates:: |
| 1033 | * |
| 1034 | * atomic commit thread hardware |
| 1035 | * |
| 1036 | * write new state into hardware ----> ... |
| 1037 | * signal hw_done |
| 1038 | * switch to new state on next |
| 1039 | * ... v/hblank |
| 1040 | * |
| 1041 | * wait for buffers to show up ... |
| 1042 | * |
| 1043 | * ... send completion irq |
| 1044 | * irq handler signals flip_done |
| 1045 | * cleanup old buffers |
| 1046 | * |
| 1047 | * signal cleanup_done |
| 1048 | * |
| 1049 | * wait for flip_done <---- |
| 1050 | * clean up atomic state |
| 1051 | * |
| 1052 | * The important bit to know is that cleanup_done is the terminal event, but the |
| 1053 | * ordering between flip_done and hw_done is entirely up to the specific driver |
| 1054 | * and modeset state change. |
| 1055 | * |
| 1056 | * For an implementation of how to use this look at |
| 1057 | * drm_atomic_helper_setup_commit() from the atomic helper library. |
| 1058 | */ |
| 1059 | struct drm_crtc_commit { |
| 1060 | /** |
| 1061 | * @crtc: |
| 1062 | * |
| 1063 | * DRM CRTC for this commit. |
| 1064 | */ |
| 1065 | struct drm_crtc *crtc; |
| 1066 | |
| 1067 | /** |
| 1068 | * @ref: |
| 1069 | * |
| 1070 | * Reference count for this structure. Needed to allow blocking on |
| 1071 | * completions without the risk of the completion disappearing |
| 1072 | * meanwhile. |
| 1073 | */ |
| 1074 | struct kref ref; |
| 1075 | |
| 1076 | /** |
| 1077 | * @flip_done: |
| 1078 | * |
| 1079 | * Will be signaled when the hardware has flipped to the new set of |
| 1080 | * buffers. Signals at the same time as when the drm event for this |
| 1081 | * commit is sent to userspace, or when an out-fence is singalled. Note |
| 1082 | * that for most hardware, in most cases this happens after @hw_done is |
| 1083 | * signalled. |
| 1084 | */ |
| 1085 | struct completion flip_done; |
| 1086 | |
| 1087 | /** |
| 1088 | * @hw_done: |
| 1089 | * |
| 1090 | * Will be signalled when all hw register changes for this commit have |
| 1091 | * been written out. Especially when disabling a pipe this can be much |
| 1092 | * later than than @flip_done, since that can signal already when the |
| 1093 | * screen goes black, whereas to fully shut down a pipe more register |
| 1094 | * I/O is required. |
| 1095 | * |
| 1096 | * Note that this does not need to include separately reference-counted |
| 1097 | * resources like backing storage buffer pinning, or runtime pm |
| 1098 | * management. |
| 1099 | */ |
| 1100 | struct completion hw_done; |
| 1101 | |
| 1102 | /** |
| 1103 | * @cleanup_done: |
| 1104 | * |
| 1105 | * Will be signalled after old buffers have been cleaned up by calling |
| 1106 | * drm_atomic_helper_cleanup_planes(). Since this can only happen after |
| 1107 | * a vblank wait completed it might be a bit later. This completion is |
| 1108 | * useful to throttle updates and avoid hardware updates getting ahead |
| 1109 | * of the buffer cleanup too much. |
| 1110 | */ |
| 1111 | struct completion cleanup_done; |
| 1112 | |
| 1113 | /** |
| 1114 | * @commit_entry: |
| 1115 | * |
| 1116 | * Entry on the per-CRTC commit_list. Protected by crtc->commit_lock. |
| 1117 | */ |
| 1118 | struct list_head commit_entry; |
| 1119 | |
| 1120 | /** |
| 1121 | * @event: |
| 1122 | * |
| 1123 | * &drm_pending_vblank_event pointer to clean up private events. |
| 1124 | */ |
| 1125 | struct drm_pending_vblank_event *event; |
| 1126 | }; |
| 1127 | |
Daniel Vetter | b8b5342 | 2016-06-02 00:06:33 +0200 | [diff] [blame] | 1128 | struct __drm_planes_state { |
| 1129 | struct drm_plane *ptr; |
| 1130 | struct drm_plane_state *state; |
| 1131 | }; |
| 1132 | |
Daniel Vetter | 5d943aa6 | 2016-06-02 00:06:34 +0200 | [diff] [blame] | 1133 | struct __drm_crtcs_state { |
| 1134 | struct drm_crtc *ptr; |
| 1135 | struct drm_crtc_state *state; |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 1136 | struct drm_crtc_commit *commit; |
Daniel Vetter | 5d943aa6 | 2016-06-02 00:06:34 +0200 | [diff] [blame] | 1137 | }; |
| 1138 | |
Daniel Vetter | 63e83c1 | 2016-06-02 00:06:32 +0200 | [diff] [blame] | 1139 | struct __drm_connnectors_state { |
| 1140 | struct drm_connector *ptr; |
| 1141 | struct drm_connector_state *state; |
| 1142 | }; |
| 1143 | |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1144 | /** |
Rob Clark | 08855fa | 2015-03-11 10:23:09 -0400 | [diff] [blame] | 1145 | * struct drm_atomic_state - the global state object for atomic updates |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1146 | * @dev: parent DRM device |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 1147 | * @allow_modeset: allow full modeset |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1148 | * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics |
Maarten Lankhorst | 40616a2 | 2016-03-03 10:17:39 +0100 | [diff] [blame] | 1149 | * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL. |
Daniel Vetter | b8b5342 | 2016-06-02 00:06:33 +0200 | [diff] [blame] | 1150 | * @planes: pointer to array of structures with per-plane data |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1151 | * @crtcs: pointer to array of CRTC pointers |
Daniel Vetter | f52b69f1 | 2014-11-19 18:38:08 +0100 | [diff] [blame] | 1152 | * @num_connector: size of the @connectors and @connector_states arrays |
Daniel Vetter | 63e83c1 | 2016-06-02 00:06:32 +0200 | [diff] [blame] | 1153 | * @connectors: pointer to array of structures with per-connector data |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1154 | * @acquire_ctx: acquire context for this atomic modeset state update |
| 1155 | */ |
| 1156 | struct drm_atomic_state { |
| 1157 | struct drm_device *dev; |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 1158 | bool allow_modeset : 1; |
Daniel Vetter | f02ad90 | 2015-01-22 16:36:23 +0100 | [diff] [blame] | 1159 | bool legacy_cursor_update : 1; |
Maarten Lankhorst | 40616a2 | 2016-03-03 10:17:39 +0100 | [diff] [blame] | 1160 | bool legacy_set_config : 1; |
Daniel Vetter | b8b5342 | 2016-06-02 00:06:33 +0200 | [diff] [blame] | 1161 | struct __drm_planes_state *planes; |
Daniel Vetter | 5d943aa6 | 2016-06-02 00:06:34 +0200 | [diff] [blame] | 1162 | struct __drm_crtcs_state *crtcs; |
Daniel Vetter | f52b69f1 | 2014-11-19 18:38:08 +0100 | [diff] [blame] | 1163 | int num_connector; |
Daniel Vetter | 63e83c1 | 2016-06-02 00:06:32 +0200 | [diff] [blame] | 1164 | struct __drm_connnectors_state *connectors; |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1165 | |
| 1166 | struct drm_modeset_acquire_ctx *acquire_ctx; |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 1167 | |
| 1168 | /** |
| 1169 | * @commit_work: |
| 1170 | * |
| 1171 | * Work item which can be used by the driver or helpers to execute the |
| 1172 | * commit without blocking. |
| 1173 | */ |
| 1174 | struct work_struct commit_work; |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1175 | }; |
| 1176 | |
| 1177 | |
| 1178 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1179 | * struct drm_mode_set - new values for a CRTC config change |
Jesse Barnes | ef27351 | 2011-11-07 12:03:19 -0800 | [diff] [blame] | 1180 | * @fb: framebuffer to use for new config |
| 1181 | * @crtc: CRTC whose configuration we're about to change |
| 1182 | * @mode: mode timings to use |
| 1183 | * @x: position of this CRTC relative to @fb |
| 1184 | * @y: position of this CRTC relative to @fb |
| 1185 | * @connectors: array of connectors to drive with this CRTC if possible |
| 1186 | * @num_connectors: size of @connectors array |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1187 | * |
| 1188 | * Represents a single crtc the connectors that it drives with what mode |
| 1189 | * and from which framebuffer it scans out from. |
| 1190 | * |
| 1191 | * This is used to set modes. |
| 1192 | */ |
| 1193 | struct drm_mode_set { |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1194 | struct drm_framebuffer *fb; |
| 1195 | struct drm_crtc *crtc; |
| 1196 | struct drm_display_mode *mode; |
| 1197 | |
| 1198 | uint32_t x; |
| 1199 | uint32_t y; |
| 1200 | |
| 1201 | struct drm_connector **connectors; |
| 1202 | size_t num_connectors; |
| 1203 | }; |
| 1204 | |
| 1205 | /** |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 1206 | * struct drm_mode_config_funcs - basic driver provided mode setting functions |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 1207 | * |
| 1208 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that |
| 1209 | * involve drivers. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1210 | */ |
| 1211 | struct drm_mode_config_funcs { |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1212 | /** |
| 1213 | * @fb_create: |
| 1214 | * |
| 1215 | * Create a new framebuffer object. The core does basic checks on the |
| 1216 | * requested metadata, but most of that is left to the driver. See |
| 1217 | * struct &drm_mode_fb_cmd2 for details. |
| 1218 | * |
Daniel Vetter | d55f532 | 2015-12-08 09:49:19 +0100 | [diff] [blame] | 1219 | * If the parameters are deemed valid and the backing storage objects in |
| 1220 | * the underlying memory manager all exist, then the driver allocates |
| 1221 | * a new &drm_framebuffer structure, subclassed to contain |
| 1222 | * driver-specific information (like the internal native buffer object |
| 1223 | * references). It also needs to fill out all relevant metadata, which |
| 1224 | * should be done by calling drm_helper_mode_fill_fb_struct(). |
| 1225 | * |
| 1226 | * The initialization is finalized by calling drm_framebuffer_init(), |
| 1227 | * which registers the framebuffer and makes it accessible to other |
| 1228 | * threads. |
| 1229 | * |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1230 | * RETURNS: |
| 1231 | * |
| 1232 | * A new framebuffer with an initial reference count of 1 or a negative |
| 1233 | * error code encoded with ERR_PTR(). |
| 1234 | */ |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 1235 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, |
| 1236 | struct drm_file *file_priv, |
Ville Syrjälä | 1eb8345 | 2015-11-11 19:11:29 +0200 | [diff] [blame] | 1237 | const struct drm_mode_fb_cmd2 *mode_cmd); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1238 | |
| 1239 | /** |
| 1240 | * @output_poll_changed: |
| 1241 | * |
| 1242 | * Callback used by helpers to inform the driver of output configuration |
| 1243 | * changes. |
| 1244 | * |
| 1245 | * Drivers implementing fbdev emulation with the helpers can call |
| 1246 | * drm_fb_helper_hotplug_changed from this hook to inform the fbdev |
| 1247 | * helper of output changes. |
| 1248 | * |
| 1249 | * FIXME: |
| 1250 | * |
| 1251 | * Except that there's no vtable for device-level helper callbacks |
| 1252 | * there's no reason this is a core function. |
| 1253 | */ |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1254 | void (*output_poll_changed)(struct drm_device *dev); |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1255 | |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1256 | /** |
| 1257 | * @atomic_check: |
| 1258 | * |
| 1259 | * This is the only hook to validate an atomic modeset update. This |
| 1260 | * function must reject any modeset and state changes which the hardware |
| 1261 | * or driver doesn't support. This includes but is of course not limited |
| 1262 | * to: |
| 1263 | * |
| 1264 | * - Checking that the modes, framebuffers, scaling and placement |
| 1265 | * requirements and so on are within the limits of the hardware. |
| 1266 | * |
| 1267 | * - Checking that any hidden shared resources are not oversubscribed. |
| 1268 | * This can be shared PLLs, shared lanes, overall memory bandwidth, |
| 1269 | * display fifo space (where shared between planes or maybe even |
| 1270 | * CRTCs). |
| 1271 | * |
| 1272 | * - Checking that virtualized resources exported to userspace are not |
| 1273 | * oversubscribed. For various reasons it can make sense to expose |
| 1274 | * more planes, crtcs or encoders than which are physically there. One |
| 1275 | * example is dual-pipe operations (which generally should be hidden |
| 1276 | * from userspace if when lockstepped in hardware, exposed otherwise), |
| 1277 | * where a plane might need 1 hardware plane (if it's just on one |
| 1278 | * pipe), 2 hardware planes (when it spans both pipes) or maybe even |
| 1279 | * shared a hardware plane with a 2nd plane (if there's a compatible |
| 1280 | * plane requested on the area handled by the other pipe). |
| 1281 | * |
| 1282 | * - Check that any transitional state is possible and that if |
| 1283 | * requested, the update can indeed be done in the vblank period |
| 1284 | * without temporarily disabling some functions. |
| 1285 | * |
| 1286 | * - Check any other constraints the driver or hardware might have. |
| 1287 | * |
| 1288 | * - This callback also needs to correctly fill out the &drm_crtc_state |
| 1289 | * in this update to make sure that drm_atomic_crtc_needs_modeset() |
| 1290 | * reflects the nature of the possible update and returns true if and |
| 1291 | * only if the update cannot be applied without tearing within one |
| 1292 | * vblank on that CRTC. The core uses that information to reject |
| 1293 | * updates which require a full modeset (i.e. blanking the screen, or |
| 1294 | * at least pausing updates for a substantial amount of time) if |
| 1295 | * userspace has disallowed that in its request. |
| 1296 | * |
| 1297 | * - The driver also does not need to repeat basic input validation |
| 1298 | * like done for the corresponding legacy entry points. The core does |
| 1299 | * that before calling this hook. |
| 1300 | * |
| 1301 | * See the documentation of @atomic_commit for an exhaustive list of |
| 1302 | * error conditions which don't have to be checked at the |
| 1303 | * ->atomic_check() stage? |
| 1304 | * |
| 1305 | * See the documentation for struct &drm_atomic_state for how exactly |
| 1306 | * an atomic modeset update is described. |
| 1307 | * |
| 1308 | * Drivers using the atomic helpers can implement this hook using |
| 1309 | * drm_atomic_helper_check(), or one of the exported sub-functions of |
| 1310 | * it. |
| 1311 | * |
| 1312 | * RETURNS: |
| 1313 | * |
| 1314 | * 0 on success or one of the below negative error codes: |
| 1315 | * |
| 1316 | * - -EINVAL, if any of the above constraints are violated. |
| 1317 | * |
| 1318 | * - -EDEADLK, when returned from an attempt to acquire an additional |
| 1319 | * &drm_modeset_lock through drm_modeset_lock(). |
| 1320 | * |
| 1321 | * - -ENOMEM, if allocating additional state sub-structures failed due |
| 1322 | * to lack of memory. |
| 1323 | * |
| 1324 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 1325 | * This can either be due to a pending signal, or because the driver |
| 1326 | * needs to completely bail out to recover from an exceptional |
| 1327 | * situation like a GPU hang. From a userspace point all errors are |
| 1328 | * treated equally. |
| 1329 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1330 | int (*atomic_check)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1331 | struct drm_atomic_state *state); |
| 1332 | |
| 1333 | /** |
| 1334 | * @atomic_commit: |
| 1335 | * |
| 1336 | * This is the only hook to commit an atomic modeset update. The core |
| 1337 | * guarantees that @atomic_check has been called successfully before |
| 1338 | * calling this function, and that nothing has been changed in the |
| 1339 | * interim. |
| 1340 | * |
| 1341 | * See the documentation for struct &drm_atomic_state for how exactly |
| 1342 | * an atomic modeset update is described. |
| 1343 | * |
| 1344 | * Drivers using the atomic helpers can implement this hook using |
| 1345 | * drm_atomic_helper_commit(), or one of the exported sub-functions of |
| 1346 | * it. |
| 1347 | * |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 1348 | * Nonblocking commits (as indicated with the nonblock parameter) must |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1349 | * do any preparatory work which might result in an unsuccessful commit |
| 1350 | * in the context of this callback. The only exceptions are hardware |
| 1351 | * errors resulting in -EIO. But even in that case the driver must |
| 1352 | * ensure that the display pipe is at least running, to avoid |
| 1353 | * compositors crashing when pageflips don't work. Anything else, |
| 1354 | * specifically committing the update to the hardware, should be done |
| 1355 | * without blocking the caller. For updates which do not require a |
| 1356 | * modeset this must be guaranteed. |
| 1357 | * |
| 1358 | * The driver must wait for any pending rendering to the new |
| 1359 | * framebuffers to complete before executing the flip. It should also |
| 1360 | * wait for any pending rendering from other drivers if the underlying |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 1361 | * buffer is a shared dma-buf. Nonblocking commits must not wait for |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1362 | * rendering in the context of this callback. |
| 1363 | * |
| 1364 | * An application can request to be notified when the atomic commit has |
| 1365 | * completed. These events are per-CRTC and can be distinguished by the |
| 1366 | * CRTC index supplied in &drm_event to userspace. |
| 1367 | * |
| 1368 | * The drm core will supply a struct &drm_event in the event |
| 1369 | * member of each CRTC's &drm_crtc_state structure. This can be handled by the |
| 1370 | * drm_crtc_send_vblank_event() function, which the driver should call on |
| 1371 | * the provided event upon completion of the atomic commit. Note that if |
| 1372 | * the driver supports vblank signalling and timestamping the vblank |
| 1373 | * counters and timestamps must agree with the ones returned from page |
| 1374 | * flip events. With the current vblank helper infrastructure this can |
| 1375 | * be achieved by holding a vblank reference while the page flip is |
| 1376 | * pending, acquired through drm_crtc_vblank_get() and released with |
| 1377 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank |
| 1378 | * counter and timestamp tracking though, e.g. if they have accurate |
| 1379 | * timestamp registers in hardware. |
| 1380 | * |
| 1381 | * NOTE: |
| 1382 | * |
| 1383 | * Drivers are not allowed to shut down any display pipe successfully |
| 1384 | * enabled through an atomic commit on their own. Doing so can result in |
| 1385 | * compositors crashing if a page flip is suddenly rejected because the |
| 1386 | * pipe is off. |
| 1387 | * |
| 1388 | * RETURNS: |
| 1389 | * |
| 1390 | * 0 on success or one of the below negative error codes: |
| 1391 | * |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 1392 | * - -EBUSY, if a nonblocking updated is requested and there is |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1393 | * an earlier updated pending. Drivers are allowed to support a queue |
| 1394 | * of outstanding updates, but currently no driver supports that. |
| 1395 | * Note that drivers must wait for preceding updates to complete if a |
| 1396 | * synchronous update is requested, they are not allowed to fail the |
| 1397 | * commit in that case. |
| 1398 | * |
| 1399 | * - -ENOMEM, if the driver failed to allocate memory. Specifically |
| 1400 | * this can happen when trying to pin framebuffers, which must only |
| 1401 | * be done when committing the state. |
| 1402 | * |
| 1403 | * - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate |
| 1404 | * that the driver has run out of vram, iommu space or similar GPU |
| 1405 | * address space needed for framebuffer. |
| 1406 | * |
| 1407 | * - -EIO, if the hardware completely died. |
| 1408 | * |
| 1409 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 1410 | * This can either be due to a pending signal, or because the driver |
| 1411 | * needs to completely bail out to recover from an exceptional |
| 1412 | * situation like a GPU hang. From a userspace point of view all errors are |
| 1413 | * treated equally. |
| 1414 | * |
| 1415 | * This list is exhaustive. Specifically this hook is not allowed to |
| 1416 | * return -EINVAL (any invalid requests should be caught in |
| 1417 | * @atomic_check) or -EDEADLK (this function must not acquire |
| 1418 | * additional modeset locks). |
| 1419 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1420 | int (*atomic_commit)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1421 | struct drm_atomic_state *state, |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 1422 | bool nonblock); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1423 | |
| 1424 | /** |
| 1425 | * @atomic_state_alloc: |
| 1426 | * |
| 1427 | * This optional hook can be used by drivers that want to subclass struct |
| 1428 | * &drm_atomic_state to be able to track their own driver-private global |
| 1429 | * state easily. If this hook is implemented, drivers must also |
| 1430 | * implement @atomic_state_clear and @atomic_state_free. |
| 1431 | * |
| 1432 | * RETURNS: |
| 1433 | * |
| 1434 | * A new &drm_atomic_state on success or NULL on failure. |
| 1435 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 1436 | struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1437 | |
| 1438 | /** |
| 1439 | * @atomic_state_clear: |
| 1440 | * |
| 1441 | * This hook must clear any driver private state duplicated into the |
| 1442 | * passed-in &drm_atomic_state. This hook is called when the caller |
| 1443 | * encountered a &drm_modeset_lock deadlock and needs to drop all |
| 1444 | * already acquired locks as part of the deadlock avoidance dance |
| 1445 | * implemented in drm_modeset_lock_backoff(). |
| 1446 | * |
| 1447 | * Any duplicated state must be invalidated since a concurrent atomic |
| 1448 | * update might change it, and the drm atomic interfaces always apply |
| 1449 | * updates as relative changes to the current state. |
| 1450 | * |
| 1451 | * Drivers that implement this must call drm_atomic_state_default_clear() |
| 1452 | * to clear common state. |
| 1453 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 1454 | void (*atomic_state_clear)(struct drm_atomic_state *state); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1455 | |
| 1456 | /** |
| 1457 | * @atomic_state_free: |
| 1458 | * |
| 1459 | * This hook needs driver private resources and the &drm_atomic_state |
| 1460 | * itself. Note that the core first calls drm_atomic_state_clear() to |
| 1461 | * avoid code duplicate between the clear and free hooks. |
| 1462 | * |
| 1463 | * Drivers that implement this must call drm_atomic_state_default_free() |
| 1464 | * to release common resources. |
| 1465 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 1466 | void (*atomic_state_free)(struct drm_atomic_state *state); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1467 | }; |
| 1468 | |
Jesse Barnes | c1aaca2 | 2011-11-07 12:03:21 -0800 | [diff] [blame] | 1469 | /** |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1470 | * struct drm_mode_config - Mode configuration control structure |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1471 | * @mutex: mutex protecting KMS related lists and structures |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1472 | * @connection_mutex: ww mutex protecting connector state and routing |
| 1473 | * @acquire_ctx: global implicit acquire context used by atomic drivers for |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1474 | * legacy IOCTLs |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1475 | * @fb_lock: mutex to protect fb state and lists |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1476 | * @num_fb: number of fbs available |
| 1477 | * @fb_list: list of framebuffers available |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1478 | * @num_encoder: number of encoders on this device |
| 1479 | * @encoder_list: list of encoder objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1480 | * @num_overlay_plane: number of overlay planes on this device |
| 1481 | * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device |
| 1482 | * @plane_list: list of plane objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1483 | * @num_crtc: number of CRTCs on this device |
| 1484 | * @crtc_list: list of CRTC objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1485 | * @property_list: list of property objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1486 | * @min_width: minimum pixel width on this device |
| 1487 | * @min_height: minimum pixel height on this device |
| 1488 | * @max_width: maximum pixel width on this device |
| 1489 | * @max_height: maximum pixel height on this device |
| 1490 | * @funcs: core driver provided mode setting functions |
| 1491 | * @fb_base: base address of the framebuffer |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1492 | * @poll_enabled: track polling support for this device |
| 1493 | * @poll_running: track polling status for this device |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1494 | * @delayed_event: track delayed poll uevent deliver for this device |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1495 | * @output_poll_work: delayed work for polling in process context |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1496 | * @property_blob_list: list of all the blob property objects |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 1497 | * @blob_lock: mutex for blob property allocation and management |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1498 | * @*_property: core property tracking |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1499 | * @preferred_depth: preferred RBG pixel depth, used by fb helpers |
| 1500 | * @prefer_shadow: hint to userspace to prefer shadow-fb rendering |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1501 | * @cursor_width: hint to userspace for max cursor width |
| 1502 | * @cursor_height: hint to userspace for max cursor height |
Daniel Vetter | 9f2a795 | 2016-06-08 14:19:02 +0200 | [diff] [blame] | 1503 | * @helper_private: mid-layer private data |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1504 | * |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1505 | * Core mode resource tracking structure. All CRTC, encoders, and connectors |
| 1506 | * enumerated by the driver are added here, as are global properties. Some |
| 1507 | * global restrictions are also here, e.g. dimension restrictions. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1508 | */ |
| 1509 | struct drm_mode_config { |
Jesse Barnes | ad2563c | 2009-01-19 17:21:45 +1000 | [diff] [blame] | 1510 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 1511 | struct drm_modeset_lock connection_mutex; /* protects connector->encoder and encoder->crtc links */ |
| 1512 | struct drm_modeset_acquire_ctx *acquire_ctx; /* for legacy _lock_all() / _unlock_all() */ |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1513 | |
| 1514 | /** |
| 1515 | * @idr_mutex: |
| 1516 | * |
| 1517 | * Mutex for KMS ID allocation and management. Protects both @crtc_idr |
| 1518 | * and @tile_idr. |
| 1519 | */ |
| 1520 | struct mutex idr_mutex; |
| 1521 | |
| 1522 | /** |
| 1523 | * @crtc_idr: |
| 1524 | * |
| 1525 | * Main KMS ID tracking object. Use this idr for all IDs, fb, crtc, |
| 1526 | * connector, modes - just makes life easier to have only one. |
| 1527 | */ |
| 1528 | struct idr crtc_idr; |
| 1529 | |
| 1530 | /** |
| 1531 | * @tile_idr: |
| 1532 | * |
| 1533 | * Use this idr for allocating new IDs for tiled sinks like use in some |
| 1534 | * high-res DP MST screens. |
| 1535 | */ |
| 1536 | struct idr tile_idr; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1537 | |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1538 | struct mutex fb_lock; /* proctects global and per-file fb lists */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1539 | int num_fb; |
| 1540 | struct list_head fb_list; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1541 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1542 | /** |
| 1543 | * @num_connector: Number of connectors on this device. |
| 1544 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1545 | int num_connector; |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1546 | /** |
| 1547 | * @connector_ida: ID allocator for connector indices. |
| 1548 | */ |
Maarten Lankhorst | 5fff80b | 2016-02-17 08:32:05 +0100 | [diff] [blame] | 1549 | struct ida connector_ida; |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1550 | /** |
| 1551 | * @connector_list: List of connector objects. |
| 1552 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1553 | struct list_head connector_list; |
| 1554 | int num_encoder; |
| 1555 | struct list_head encoder_list; |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1556 | |
| 1557 | /* |
| 1558 | * Track # of overlay planes separately from # of total planes. By |
| 1559 | * default we only advertise overlay planes to userspace; if userspace |
| 1560 | * sets the "universal plane" capability bit, we'll go ahead and |
| 1561 | * expose all planes. |
| 1562 | */ |
| 1563 | int num_overlay_plane; |
| 1564 | int num_total_plane; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1565 | struct list_head plane_list; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1566 | |
| 1567 | int num_crtc; |
| 1568 | struct list_head crtc_list; |
| 1569 | |
| 1570 | struct list_head property_list; |
| 1571 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1572 | int min_width, min_height; |
| 1573 | int max_width, max_height; |
Laurent Pinchart | e6ecefa | 2012-05-17 13:27:23 +0200 | [diff] [blame] | 1574 | const struct drm_mode_config_funcs *funcs; |
Benjamin Herrenschmidt | d883f7f | 2009-02-02 16:55:45 +1100 | [diff] [blame] | 1575 | resource_size_t fb_base; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1576 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1577 | /* output poll support */ |
| 1578 | bool poll_enabled; |
Daniel Vetter | 905bc9f | 2012-10-23 18:23:36 +0000 | [diff] [blame] | 1579 | bool poll_running; |
Daniel Vetter | 162b6a5 | 2015-01-21 08:45:21 +0100 | [diff] [blame] | 1580 | bool delayed_event; |
Tejun Heo | 991ea75 | 2010-07-20 22:09:02 +0200 | [diff] [blame] | 1581 | struct delayed_work output_poll_work; |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1582 | |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 1583 | struct mutex blob_lock; |
| 1584 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1585 | /* pointers to standard properties */ |
| 1586 | struct list_head property_blob_list; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1587 | /** |
| 1588 | * @edid_property: Default connector property to hold the EDID of the |
| 1589 | * currently connected sink, if any. |
| 1590 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1591 | struct drm_property *edid_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1592 | /** |
| 1593 | * @dpms_property: Default connector property to control the |
| 1594 | * connector's DPMS state. |
| 1595 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1596 | struct drm_property *dpms_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1597 | /** |
| 1598 | * @path_property: Default connector property to hold the DP MST path |
| 1599 | * for the port. |
| 1600 | */ |
Dave Airlie | 43aba7e | 2014-06-05 14:01:31 +1000 | [diff] [blame] | 1601 | struct drm_property *path_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1602 | /** |
| 1603 | * @tile_property: Default connector property to store the tile |
| 1604 | * position of a tiled screen, for sinks which need to be driven with |
| 1605 | * multiple CRTCs. |
| 1606 | */ |
Dave Airlie | 6f134d7 | 2014-10-20 16:30:50 +1000 | [diff] [blame] | 1607 | struct drm_property *tile_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1608 | /** |
| 1609 | * @plane_type_property: Default plane property to differentiate |
| 1610 | * CURSOR, PRIMARY and OVERLAY legacy uses of planes. |
| 1611 | */ |
Rob Clark | 9922ab5 | 2014-04-01 20:16:57 -0400 | [diff] [blame] | 1612 | struct drm_property *plane_type_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1613 | /** |
| 1614 | * @rotation_property: Optional property for planes or CRTCs to specifiy |
| 1615 | * rotation. |
| 1616 | */ |
Sonika Jindal | 2a297cc | 2014-08-05 11:26:54 +0530 | [diff] [blame] | 1617 | struct drm_property *rotation_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1618 | /** |
| 1619 | * @prop_src_x: Default atomic plane property for the plane source |
| 1620 | * position in the connected &drm_framebuffer. |
| 1621 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1622 | struct drm_property *prop_src_x; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1623 | /** |
| 1624 | * @prop_src_y: Default atomic plane property for the plane source |
| 1625 | * position in the connected &drm_framebuffer. |
| 1626 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1627 | struct drm_property *prop_src_y; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1628 | /** |
| 1629 | * @prop_src_w: Default atomic plane property for the plane source |
| 1630 | * position in the connected &drm_framebuffer. |
| 1631 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1632 | struct drm_property *prop_src_w; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1633 | /** |
| 1634 | * @prop_src_h: Default atomic plane property for the plane source |
| 1635 | * position in the connected &drm_framebuffer. |
| 1636 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1637 | struct drm_property *prop_src_h; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1638 | /** |
| 1639 | * @prop_crtc_x: Default atomic plane property for the plane destination |
| 1640 | * position in the &drm_crtc is is being shown on. |
| 1641 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1642 | struct drm_property *prop_crtc_x; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1643 | /** |
| 1644 | * @prop_crtc_y: Default atomic plane property for the plane destination |
| 1645 | * position in the &drm_crtc is is being shown on. |
| 1646 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1647 | struct drm_property *prop_crtc_y; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1648 | /** |
| 1649 | * @prop_crtc_w: Default atomic plane property for the plane destination |
| 1650 | * position in the &drm_crtc is is being shown on. |
| 1651 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1652 | struct drm_property *prop_crtc_w; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1653 | /** |
| 1654 | * @prop_crtc_h: Default atomic plane property for the plane destination |
| 1655 | * position in the &drm_crtc is is being shown on. |
| 1656 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1657 | struct drm_property *prop_crtc_h; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1658 | /** |
| 1659 | * @prop_fb_id: Default atomic plane property to specify the |
| 1660 | * &drm_framebuffer. |
| 1661 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1662 | struct drm_property *prop_fb_id; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1663 | /** |
| 1664 | * @prop_crtc_id: Default atomic plane property to specify the |
| 1665 | * &drm_crtc. |
| 1666 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1667 | struct drm_property *prop_crtc_id; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1668 | /** |
| 1669 | * @prop_active: Default atomic CRTC property to control the active |
| 1670 | * state, which is the simplified implementation for DPMS in atomic |
| 1671 | * drivers. |
| 1672 | */ |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 1673 | struct drm_property *prop_active; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1674 | /** |
| 1675 | * @prop_mode_id: Default atomic CRTC property to set the mode for a |
| 1676 | * CRTC. A 0 mode implies that the CRTC is entirely disabled - all |
| 1677 | * connectors must be of and active must be set to disabled, too. |
| 1678 | */ |
Daniel Stone | 955f3c3 | 2015-05-25 19:11:52 +0100 | [diff] [blame] | 1679 | struct drm_property *prop_mode_id; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1680 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1681 | /** |
| 1682 | * @dvi_i_subconnector_property: Optional DVI-I property to |
| 1683 | * differentiate between analog or digital mode. |
| 1684 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1685 | struct drm_property *dvi_i_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1686 | /** |
| 1687 | * @dvi_i_select_subconnector_property: Optional DVI-I property to |
| 1688 | * select between analog or digital mode. |
| 1689 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1690 | struct drm_property *dvi_i_select_subconnector_property; |
| 1691 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1692 | /** |
| 1693 | * @tv_subconnector_property: Optional TV property to differentiate |
| 1694 | * between different TV connector types. |
| 1695 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1696 | struct drm_property *tv_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1697 | /** |
| 1698 | * @tv_select_subconnector_property: Optional TV property to select |
| 1699 | * between different TV connector types. |
| 1700 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1701 | struct drm_property *tv_select_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1702 | /** |
| 1703 | * @tv_mode_property: Optional TV property to select |
| 1704 | * the output TV mode. |
| 1705 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1706 | struct drm_property *tv_mode_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1707 | /** |
| 1708 | * @tv_left_margin_property: Optional TV property to set the left |
| 1709 | * margin. |
| 1710 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1711 | struct drm_property *tv_left_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1712 | /** |
| 1713 | * @tv_right_margin_property: Optional TV property to set the right |
| 1714 | * margin. |
| 1715 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1716 | struct drm_property *tv_right_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1717 | /** |
| 1718 | * @tv_top_margin_property: Optional TV property to set the right |
| 1719 | * margin. |
| 1720 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1721 | struct drm_property *tv_top_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1722 | /** |
| 1723 | * @tv_bottom_margin_property: Optional TV property to set the right |
| 1724 | * margin. |
| 1725 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1726 | struct drm_property *tv_bottom_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1727 | /** |
| 1728 | * @tv_brightness_property: Optional TV property to set the |
| 1729 | * brightness. |
| 1730 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 1731 | struct drm_property *tv_brightness_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1732 | /** |
| 1733 | * @tv_contrast_property: Optional TV property to set the |
| 1734 | * contrast. |
| 1735 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 1736 | struct drm_property *tv_contrast_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1737 | /** |
| 1738 | * @tv_flicker_reduction_property: Optional TV property to control the |
| 1739 | * flicker reduction mode. |
| 1740 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 1741 | struct drm_property *tv_flicker_reduction_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1742 | /** |
| 1743 | * @tv_overscan_property: Optional TV property to control the overscan |
| 1744 | * setting. |
| 1745 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 1746 | struct drm_property *tv_overscan_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1747 | /** |
| 1748 | * @tv_saturation_property: Optional TV property to set the |
| 1749 | * saturation. |
| 1750 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 1751 | struct drm_property *tv_saturation_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1752 | /** |
| 1753 | * @tv_hue_property: Optional TV property to set the hue. |
| 1754 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 1755 | struct drm_property *tv_hue_property; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1756 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1757 | /** |
| 1758 | * @scaling_mode_property: Optional connector property to control the |
| 1759 | * upscaling, mostly used for built-in panels. |
| 1760 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1761 | struct drm_property *scaling_mode_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1762 | /** |
| 1763 | * @aspect_ratio_property: Optional connector property to control the |
| 1764 | * HDMI infoframe aspect ratio setting. |
| 1765 | */ |
Vandana Kannan | ff587e4 | 2014-06-11 10:46:48 +0530 | [diff] [blame] | 1766 | struct drm_property *aspect_ratio_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1767 | /** |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1768 | * @degamma_lut_property: Optional CRTC property to set the LUT used to |
| 1769 | * convert the framebuffer's colors to linear gamma. |
| 1770 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1771 | struct drm_property *degamma_lut_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1772 | /** |
| 1773 | * @degamma_lut_size_property: Optional CRTC property for the size of |
| 1774 | * the degamma LUT as supported by the driver (read-only). |
| 1775 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1776 | struct drm_property *degamma_lut_size_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1777 | /** |
| 1778 | * @ctm_property: Optional CRTC property to set the |
| 1779 | * matrix used to convert colors after the lookup in the |
| 1780 | * degamma LUT. |
| 1781 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1782 | struct drm_property *ctm_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1783 | /** |
| 1784 | * @gamma_lut_property: Optional CRTC property to set the LUT used to |
| 1785 | * convert the colors, after the CTM matrix, to the gamma space of the |
| 1786 | * connected screen. |
| 1787 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1788 | struct drm_property *gamma_lut_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1789 | /** |
| 1790 | * @gamma_lut_size_property: Optional CRTC property for the size of the |
| 1791 | * gamma LUT as supported by the driver (read-only). |
| 1792 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1793 | struct drm_property *gamma_lut_size_property; |
| 1794 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1795 | /** |
| 1796 | * @suggested_x_property: Optional connector property with a hint for |
| 1797 | * the position of the output on the host's screen. |
| 1798 | */ |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 1799 | struct drm_property *suggested_x_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1800 | /** |
| 1801 | * @suggested_y_property: Optional connector property with a hint for |
| 1802 | * the position of the output on the host's screen. |
| 1803 | */ |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 1804 | struct drm_property *suggested_y_property; |
| 1805 | |
Dave Airlie | 019d96c | 2011-09-29 16:20:42 +0100 | [diff] [blame] | 1806 | /* dumb ioctl parameters */ |
| 1807 | uint32_t preferred_depth, prefer_shadow; |
Keith Packard | 62f2104 | 2013-07-22 18:50:00 -0700 | [diff] [blame] | 1808 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1809 | /** |
| 1810 | * @async_page_flip: Does this device support async flips on the primary |
| 1811 | * plane? |
| 1812 | */ |
Keith Packard | 62f2104 | 2013-07-22 18:50:00 -0700 | [diff] [blame] | 1813 | bool async_page_flip; |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 1814 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1815 | /** |
| 1816 | * @allow_fb_modifiers: |
| 1817 | * |
| 1818 | * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call. |
| 1819 | */ |
Rob Clark | e3eb325 | 2015-02-05 14:41:52 +0000 | [diff] [blame] | 1820 | bool allow_fb_modifiers; |
| 1821 | |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 1822 | /* cursor size */ |
| 1823 | uint32_t cursor_width, cursor_height; |
Daniel Vetter | 9f2a795 | 2016-06-08 14:19:02 +0200 | [diff] [blame] | 1824 | |
| 1825 | struct drm_mode_config_helper_funcs *helper_private; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1826 | }; |
| 1827 | |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 1828 | /** |
| 1829 | * drm_for_each_plane_mask - iterate over planes specified by bitmask |
| 1830 | * @plane: the loop cursor |
| 1831 | * @dev: the DRM device |
| 1832 | * @plane_mask: bitmask of plane indices |
| 1833 | * |
| 1834 | * Iterate over all planes specified by bitmask. |
| 1835 | */ |
| 1836 | #define drm_for_each_plane_mask(plane, dev, plane_mask) \ |
| 1837 | list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \ |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 1838 | for_each_if ((plane_mask) & (1 << drm_plane_index(plane))) |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 1839 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1840 | #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1841 | #define obj_to_plane(x) container_of(x, struct drm_plane, base) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1842 | |
Ville Syrjälä | f988287 | 2015-12-09 16:19:31 +0200 | [diff] [blame] | 1843 | extern __printf(6, 7) |
| 1844 | int drm_crtc_init_with_planes(struct drm_device *dev, |
| 1845 | struct drm_crtc *crtc, |
| 1846 | struct drm_plane *primary, |
| 1847 | struct drm_plane *cursor, |
| 1848 | const struct drm_crtc_funcs *funcs, |
| 1849 | const char *name, ...); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1850 | extern void drm_crtc_cleanup(struct drm_crtc *crtc); |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 1851 | |
| 1852 | /** |
| 1853 | * drm_crtc_index - find the index of a registered CRTC |
| 1854 | * @crtc: CRTC to find index for |
| 1855 | * |
| 1856 | * Given a registered CRTC, return the index of that CRTC within a DRM |
| 1857 | * device's list of CRTCs. |
| 1858 | */ |
| 1859 | static inline unsigned int drm_crtc_index(struct drm_crtc *crtc) |
| 1860 | { |
| 1861 | return crtc->index; |
| 1862 | } |
Russell King | db5f7a6 | 2014-01-02 21:27:33 +0000 | [diff] [blame] | 1863 | |
| 1864 | /** |
| 1865 | * drm_crtc_mask - find the mask of a registered CRTC |
| 1866 | * @crtc: CRTC to find mask for |
| 1867 | * |
| 1868 | * Given a registered CRTC, return the mask bit of that CRTC for an |
| 1869 | * encoder's possible_crtcs field. |
| 1870 | */ |
| 1871 | static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc) |
| 1872 | { |
| 1873 | return 1 << drm_crtc_index(crtc); |
| 1874 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1875 | |
Ville Syrjälä | b0b3b79 | 2015-12-09 16:19:55 +0200 | [diff] [blame] | 1876 | extern __printf(8, 9) |
| 1877 | int drm_universal_plane_init(struct drm_device *dev, |
| 1878 | struct drm_plane *plane, |
| 1879 | unsigned long possible_crtcs, |
| 1880 | const struct drm_plane_funcs *funcs, |
| 1881 | const uint32_t *formats, |
| 1882 | unsigned int format_count, |
| 1883 | enum drm_plane_type type, |
| 1884 | const char *name, ...); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1885 | extern int drm_plane_init(struct drm_device *dev, |
| 1886 | struct drm_plane *plane, |
| 1887 | unsigned long possible_crtcs, |
| 1888 | const struct drm_plane_funcs *funcs, |
Thierry Reding | 45e3743 | 2015-08-12 16:54:28 +0200 | [diff] [blame] | 1889 | const uint32_t *formats, unsigned int format_count, |
Matt Roper | dc415ff | 2014-04-01 15:22:36 -0700 | [diff] [blame] | 1890 | bool is_primary); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1891 | extern void drm_plane_cleanup(struct drm_plane *plane); |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 1892 | |
| 1893 | /** |
| 1894 | * drm_plane_index - find the index of a registered plane |
| 1895 | * @plane: plane to find index for |
| 1896 | * |
| 1897 | * Given a registered plane, return the index of that plane within a DRM |
| 1898 | * device's list of planes. |
| 1899 | */ |
| 1900 | static inline unsigned int drm_plane_index(struct drm_plane *plane) |
| 1901 | { |
| 1902 | return plane->index; |
| 1903 | } |
Chandra Konduru | f81338a | 2015-04-09 17:36:21 -0700 | [diff] [blame] | 1904 | extern struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx); |
Ville Syrjälä | 9125e61 | 2013-06-03 16:10:40 +0300 | [diff] [blame] | 1905 | extern void drm_plane_force_disable(struct drm_plane *plane); |
Gustavo Padovan | ecb7e16 | 2014-12-01 15:40:09 -0800 | [diff] [blame] | 1906 | extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode, |
| 1907 | int *hdisplay, int *vdisplay); |
Lukas Wunner | 6a0d952 | 2016-06-08 18:47:27 +0200 | [diff] [blame] | 1908 | extern int drm_crtc_force_disable(struct drm_crtc *crtc); |
| 1909 | extern int drm_crtc_force_disable_all(struct drm_device *dev); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1910 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1911 | extern void drm_mode_config_init(struct drm_device *dev); |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 1912 | extern void drm_mode_config_reset(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1913 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1914 | |
Sascha Hauer | 4cae5b8 | 2012-02-01 11:38:23 +0100 | [diff] [blame] | 1915 | extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1916 | int gamma_size); |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 1917 | |
Daniel Vetter | 2d13b67 | 2012-12-11 13:47:23 +0100 | [diff] [blame] | 1918 | extern int drm_mode_set_config_internal(struct drm_mode_set *set); |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 1919 | |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 1920 | extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, |
| 1921 | char topology[8]); |
| 1922 | extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, |
| 1923 | char topology[8]); |
| 1924 | extern void drm_mode_put_tile_group(struct drm_device *dev, |
| 1925 | struct drm_tile_group *tg); |
Dave Airlie | ff72145b | 2011-02-07 12:16:14 +1000 | [diff] [blame] | 1926 | |
Thomas Wood | 3a5f87c | 2014-08-20 14:45:00 +0100 | [diff] [blame] | 1927 | extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane, |
| 1928 | struct drm_property *property, |
| 1929 | uint64_t value); |
Dave Airlie | 248dbc2 | 2011-11-29 20:02:54 +0000 | [diff] [blame] | 1930 | |
Ville Syrjälä | c1df5f3 | 2014-07-08 10:31:53 +0530 | [diff] [blame] | 1931 | extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, |
| 1932 | unsigned int supported_rotations); |
Ville Syrjälä | 3c9855f | 2014-07-08 10:31:56 +0530 | [diff] [blame] | 1933 | extern unsigned int drm_rotation_simplify(unsigned int rotation, |
| 1934 | unsigned int supported_rotations); |
Jyri Sarha | f8ed34a | 2016-06-07 15:09:14 +0300 | [diff] [blame] | 1935 | extern void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, |
| 1936 | uint degamma_lut_size, |
| 1937 | bool has_ctm, |
| 1938 | uint gamma_lut_size); |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 1939 | |
| 1940 | int drm_plane_create_zpos_property(struct drm_plane *plane, |
| 1941 | unsigned int zpos, |
| 1942 | unsigned int min, unsigned int max); |
| 1943 | |
| 1944 | int drm_plane_create_zpos_immutable_property(struct drm_plane *plane, |
| 1945 | unsigned int zpos); |
| 1946 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 1947 | /* Helpers */ |
Rob Clark | a2b34e2 | 2013-10-05 16:36:52 -0400 | [diff] [blame] | 1948 | static inline struct drm_plane *drm_plane_find(struct drm_device *dev, |
| 1949 | uint32_t id) |
| 1950 | { |
| 1951 | struct drm_mode_object *mo; |
| 1952 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE); |
| 1953 | return mo ? obj_to_plane(mo) : NULL; |
| 1954 | } |
| 1955 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 1956 | static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, |
| 1957 | uint32_t id) |
| 1958 | { |
| 1959 | struct drm_mode_object *mo; |
| 1960 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC); |
| 1961 | return mo ? obj_to_crtc(mo) : NULL; |
| 1962 | } |
| 1963 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1964 | /* |
| 1965 | * Extract a degamma/gamma LUT value provided by user and round it to the |
| 1966 | * precision supported by the hardware. |
| 1967 | */ |
| 1968 | static inline uint32_t drm_color_lut_extract(uint32_t user_input, |
| 1969 | uint32_t bit_precision) |
| 1970 | { |
Lionel Landwerlin | 644a805 | 2016-03-22 14:10:33 +0000 | [diff] [blame] | 1971 | uint32_t val = user_input; |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1972 | uint32_t max = 0xffff >> (16 - bit_precision); |
| 1973 | |
Lionel Landwerlin | 644a805 | 2016-03-22 14:10:33 +0000 | [diff] [blame] | 1974 | /* Round only if we're not using full precision. */ |
| 1975 | if (bit_precision < 16) { |
| 1976 | val += 1UL << (16 - bit_precision - 1); |
| 1977 | val >>= 16 - bit_precision; |
| 1978 | } |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1979 | |
| 1980 | return clamp_val(val, 0, max); |
| 1981 | } |
| 1982 | |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1983 | /* Plane list iterator for legacy (overlay only) planes. */ |
Daniel Vetter | 4ea50e9 | 2015-07-09 23:44:24 +0200 | [diff] [blame] | 1984 | #define drm_for_each_legacy_plane(plane, dev) \ |
| 1985 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \ |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 1986 | for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY) |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1987 | |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 1988 | #define drm_for_each_plane(plane, dev) \ |
| 1989 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) |
| 1990 | |
| 1991 | #define drm_for_each_crtc(crtc, dev) \ |
| 1992 | list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) |
| 1993 | |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 1994 | static inline void |
| 1995 | assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config) |
| 1996 | { |
Daniel Vetter | cff20ba | 2015-07-09 23:44:33 +0200 | [diff] [blame] | 1997 | /* |
| 1998 | * The connector hotadd/remove code currently grabs both locks when |
| 1999 | * updating lists. Hence readers need only hold either of them to be |
| 2000 | * safe and the check amounts to |
| 2001 | * |
| 2002 | * WARN_ON(not_holding(A) && not_holding(B)). |
| 2003 | */ |
| 2004 | WARN_ON(!mutex_is_locked(&mode_config->mutex) && |
| 2005 | !drm_modeset_is_locked(&mode_config->connection_mutex)); |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 2006 | } |
| 2007 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2008 | #endif /* __DRM_CRTC_H__ */ |