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