Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Intel Corporation |
| 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and its |
| 5 | * documentation for any purpose is hereby granted without fee, provided that |
| 6 | * the above copyright notice appear in all copies and that both that copyright |
| 7 | * notice and this permission notice appear in supporting documentation, and |
| 8 | * that the name of the copyright holders not be used in advertising or |
| 9 | * publicity pertaining to distribution of the software without specific, |
| 10 | * written prior permission. The copyright holders make no representations |
| 11 | * about the suitability of this software for any purpose. It is provided "as |
| 12 | * is" without express or implied warranty. |
| 13 | * |
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
| 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
| 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
| 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
| 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
| 20 | * OF THIS SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | #ifndef __DRM_PLANE_H__ |
| 24 | #define __DRM_PLANE_H__ |
| 25 | |
| 26 | #include <linux/list.h> |
| 27 | #include <linux/ctype.h> |
| 28 | #include <drm/drm_mode_object.h> |
Jyri Sarha | 80f690e | 2018-02-19 22:28:23 +0200 | [diff] [blame] | 29 | #include <drm/drm_color_mgmt.h> |
Daniel Vetter | b88ac00 | 2018-09-05 15:57:07 +0200 | [diff] [blame] | 30 | #include <drm/drm_rect.h> |
| 31 | #include <drm/drm_modeset_lock.h> |
Daniel Vetter | d78aa65 | 2018-09-05 15:57:05 +0200 | [diff] [blame] | 32 | #include <drm/drm_util.h> |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 33 | |
| 34 | struct drm_crtc; |
Rob Clark | fceffb32 | 2016-11-05 11:08:09 -0400 | [diff] [blame] | 35 | struct drm_printer; |
Daniel Vetter | 34a2ab5 | 2017-03-22 22:50:41 +0100 | [diff] [blame] | 36 | struct drm_modeset_acquire_ctx; |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 37 | |
Pankaj Bharadiya | 5c759ed | 2020-10-20 21:44:23 +0530 | [diff] [blame] | 38 | enum drm_scaling_filter { |
| 39 | DRM_SCALING_FILTER_DEFAULT, |
| 40 | DRM_SCALING_FILTER_NEAREST_NEIGHBOR, |
| 41 | }; |
| 42 | |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 43 | /** |
| 44 | * struct drm_plane_state - mutable plane state |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 45 | * |
Alyssa Rosenzweig | 4087d2f | 2021-08-29 12:04:01 -0400 | [diff] [blame] | 46 | * Please note that the destination coordinates @crtc_x, @crtc_y, @crtc_h and |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 47 | * @crtc_w and the source coordinates @src_x, @src_y, @src_h and @src_w are the |
| 48 | * raw coordinates provided by userspace. Drivers should use |
| 49 | * drm_atomic_helper_check_plane_state() and only use the derived rectangles in |
| 50 | * @src and @dst to program the hardware. |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 51 | */ |
| 52 | struct drm_plane_state { |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 53 | /** @plane: backpointer to the plane */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 54 | struct drm_plane *plane; |
| 55 | |
Gustavo Padovan | 3835b46 | 2016-11-07 19:03:33 +0900 | [diff] [blame] | 56 | /** |
| 57 | * @crtc: |
| 58 | * |
| 59 | * Currently bound CRTC, NULL if disabled. Do not this write directly, |
| 60 | * use drm_atomic_set_crtc_for_plane() |
| 61 | */ |
| 62 | struct drm_crtc *crtc; |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 63 | |
Gustavo Padovan | 3835b46 | 2016-11-07 19:03:33 +0900 | [diff] [blame] | 64 | /** |
| 65 | * @fb: |
| 66 | * |
| 67 | * Currently bound framebuffer. Do not write this directly, use |
| 68 | * drm_atomic_set_fb_for_plane() |
| 69 | */ |
| 70 | struct drm_framebuffer *fb; |
| 71 | |
| 72 | /** |
| 73 | * @fence: |
| 74 | * |
Daniel Vetter | 30d23f2 | 2018-04-05 17:44:46 +0200 | [diff] [blame] | 75 | * Optional fence to wait for before scanning out @fb. The core atomic |
| 76 | * code will set this when userspace is using explicit fencing. Do not |
Daniel Vetter | 1b94f47 | 2019-06-03 16:28:48 +0200 | [diff] [blame] | 77 | * write this field directly for a driver's implicit fence, use |
Daniel Vetter | 30d23f2 | 2018-04-05 17:44:46 +0200 | [diff] [blame] | 78 | * drm_atomic_set_fence_for_plane() to ensure that an explicit fence is |
| 79 | * preserved. |
| 80 | * |
| 81 | * Drivers should store any implicit fence in this from their |
Thomas Zimmermann | 820c170 | 2021-02-22 15:17:56 +0100 | [diff] [blame] | 82 | * &drm_plane_helper_funcs.prepare_fb callback. See drm_gem_plane_helper_prepare_fb() |
| 83 | * and drm_gem_simple_display_pipe_prepare_fb() for suitable helpers. |
Gustavo Padovan | 3835b46 | 2016-11-07 19:03:33 +0900 | [diff] [blame] | 84 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 85 | struct dma_fence *fence; |
| 86 | |
Gustavo Padovan | 3835b46 | 2016-11-07 19:03:33 +0900 | [diff] [blame] | 87 | /** |
| 88 | * @crtc_x: |
| 89 | * |
| 90 | * Left position of visible portion of plane on crtc, signed dest |
| 91 | * location allows it to be partially off screen. |
| 92 | */ |
| 93 | |
| 94 | int32_t crtc_x; |
| 95 | /** |
| 96 | * @crtc_y: |
| 97 | * |
| 98 | * Upper position of visible portion of plane on crtc, signed dest |
| 99 | * location allows it to be partially off screen. |
| 100 | */ |
| 101 | int32_t crtc_y; |
| 102 | |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 103 | /** @crtc_w: width of visible portion of plane on crtc */ |
| 104 | /** @crtc_h: height of visible portion of plane on crtc */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 105 | uint32_t crtc_w, crtc_h; |
| 106 | |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 107 | /** |
| 108 | * @src_x: left position of visible portion of plane within plane (in |
| 109 | * 16.16 fixed point). |
| 110 | */ |
| 111 | uint32_t src_x; |
| 112 | /** |
| 113 | * @src_y: upper position of visible portion of plane within plane (in |
| 114 | * 16.16 fixed point). |
| 115 | */ |
| 116 | uint32_t src_y; |
| 117 | /** @src_w: width of visible portion of plane (in 16.16) */ |
| 118 | /** @src_h: height of visible portion of plane (in 16.16) */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 119 | uint32_t src_h, src_w; |
| 120 | |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 121 | /** |
| 122 | * @alpha: |
| 123 | * Opacity of the plane with 0 as completely transparent and 0xffff as |
| 124 | * completely opaque. See drm_plane_create_alpha_property() for more |
| 125 | * details. |
| 126 | */ |
Maxime Ripard | ae0e282 | 2018-04-11 09:39:25 +0200 | [diff] [blame] | 127 | u16 alpha; |
Sean Paul | b972cec | 2018-08-31 11:09:25 -0400 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * @pixel_blend_mode: |
| 131 | * The alpha blending equation selection, describing how the pixels from |
| 132 | * the current plane are composited with the background. Value can be |
| 133 | * one of DRM_MODE_BLEND_* |
| 134 | */ |
Lowry Li | a5ec833 | 2018-08-23 16:30:19 +0800 | [diff] [blame] | 135 | uint16_t pixel_blend_mode; |
Maxime Ripard | ae0e282 | 2018-04-11 09:39:25 +0200 | [diff] [blame] | 136 | |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 137 | /** |
| 138 | * @rotation: |
| 139 | * Rotation of the plane. See drm_plane_create_rotation_property() for |
| 140 | * more details. |
| 141 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 142 | unsigned int rotation; |
| 143 | |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 144 | /** |
| 145 | * @zpos: |
| 146 | * Priority of the given plane on crtc (optional). |
| 147 | * |
Simon Ser | 8f6ea27 | 2019-10-09 15:10:49 +0000 | [diff] [blame] | 148 | * User-space may set mutable zpos properties so that multiple active |
| 149 | * planes on the same CRTC have identical zpos values. This is a |
| 150 | * user-space bug, but drivers can solve the conflict by comparing the |
| 151 | * plane object IDs; the plane with a higher ID is stacked on top of a |
| 152 | * plane with a lower ID. |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 153 | * |
| 154 | * See drm_plane_create_zpos_property() and |
| 155 | * drm_plane_create_zpos_immutable_property() for more details. |
| 156 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 157 | unsigned int zpos; |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 158 | |
| 159 | /** |
| 160 | * @normalized_zpos: |
| 161 | * Normalized value of zpos: unique, range from 0 to N-1 where N is the |
| 162 | * number of active planes for given crtc. Note that the driver must set |
| 163 | * &drm_mode_config.normalize_zpos or call drm_atomic_normalize_zpos() to |
| 164 | * update this before it can be trusted. |
| 165 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 166 | unsigned int normalized_zpos; |
| 167 | |
Jyri Sarha | 80f690e | 2018-02-19 22:28:23 +0200 | [diff] [blame] | 168 | /** |
| 169 | * @color_encoding: |
| 170 | * |
| 171 | * Color encoding for non RGB formats |
| 172 | */ |
| 173 | enum drm_color_encoding color_encoding; |
| 174 | |
| 175 | /** |
| 176 | * @color_range: |
| 177 | * |
| 178 | * Color range for non RGB formats |
| 179 | */ |
| 180 | enum drm_color_range color_range; |
| 181 | |
Lukasz Spintzyk | d3b2176 | 2018-05-23 19:04:08 -0700 | [diff] [blame] | 182 | /** |
| 183 | * @fb_damage_clips: |
| 184 | * |
| 185 | * Blob representing damage (area in plane framebuffer that changed |
| 186 | * since last plane update) as an array of &drm_mode_rect in framebuffer |
| 187 | * coodinates of the attached framebuffer. Note that unlike plane src, |
| 188 | * damage clips are not in 16.16 fixed point. |
Daniel Vetter | 6f11f374 | 2021-07-23 10:34:55 +0200 | [diff] [blame] | 189 | * |
| 190 | * See drm_plane_get_damage_clips() and |
| 191 | * drm_plane_get_damage_clips_count() for accessing these. |
Lukasz Spintzyk | d3b2176 | 2018-05-23 19:04:08 -0700 | [diff] [blame] | 192 | */ |
| 193 | struct drm_property_blob *fb_damage_clips; |
| 194 | |
Maarten Lankhorst | fec7487 | 2019-10-10 13:19:13 +0200 | [diff] [blame] | 195 | /** |
| 196 | * @src: |
| 197 | * |
| 198 | * source coordinates of the plane (in 16.16). |
| 199 | * |
| 200 | * When using drm_atomic_helper_check_plane_state(), |
| 201 | * the coordinates are clipped, but the driver may choose |
| 202 | * to use unclipped coordinates instead when the hardware |
| 203 | * performs the clipping automatically. |
| 204 | */ |
| 205 | /** |
| 206 | * @dst: |
| 207 | * |
| 208 | * clipped destination coordinates of the plane. |
| 209 | * |
| 210 | * When using drm_atomic_helper_check_plane_state(), |
| 211 | * the coordinates are clipped, but the driver may choose |
| 212 | * to use unclipped coordinates instead when the hardware |
| 213 | * performs the clipping automatically. |
| 214 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 215 | struct drm_rect src, dst; |
| 216 | |
Gustavo Padovan | 3835b46 | 2016-11-07 19:03:33 +0900 | [diff] [blame] | 217 | /** |
| 218 | * @visible: |
| 219 | * |
| 220 | * Visibility of the plane. This can be false even if fb!=NULL and |
| 221 | * crtc!=NULL, due to clipping. |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 222 | */ |
| 223 | bool visible; |
| 224 | |
Maarten Lankhorst | 21a01ab | 2017-09-04 12:48:37 +0200 | [diff] [blame] | 225 | /** |
Pankaj Bharadiya | 5c759ed | 2020-10-20 21:44:23 +0530 | [diff] [blame] | 226 | * @scaling_filter: |
| 227 | * |
| 228 | * Scaling filter to be applied |
| 229 | */ |
| 230 | enum drm_scaling_filter scaling_filter; |
| 231 | |
| 232 | /** |
Maarten Lankhorst | 669c921 | 2017-09-04 12:48:38 +0200 | [diff] [blame] | 233 | * @commit: Tracks the pending commit to prevent use-after-free conditions, |
| 234 | * and for async plane updates. |
Maarten Lankhorst | 21a01ab | 2017-09-04 12:48:37 +0200 | [diff] [blame] | 235 | * |
Maarten Lankhorst | 669c921 | 2017-09-04 12:48:38 +0200 | [diff] [blame] | 236 | * May be NULL. |
Maarten Lankhorst | 21a01ab | 2017-09-04 12:48:37 +0200 | [diff] [blame] | 237 | */ |
| 238 | struct drm_crtc_commit *commit; |
| 239 | |
Daniel Vetter | 2e784a9 | 2018-07-09 10:40:09 +0200 | [diff] [blame] | 240 | /** @state: backpointer to global drm_atomic_state */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 241 | struct drm_atomic_state *state; |
| 242 | }; |
| 243 | |
Rob Clark | 1638d30 | 2016-11-05 11:08:08 -0400 | [diff] [blame] | 244 | static inline struct drm_rect |
| 245 | drm_plane_state_src(const struct drm_plane_state *state) |
| 246 | { |
| 247 | struct drm_rect src = { |
| 248 | .x1 = state->src_x, |
| 249 | .y1 = state->src_y, |
| 250 | .x2 = state->src_x + state->src_w, |
| 251 | .y2 = state->src_y + state->src_h, |
| 252 | }; |
| 253 | return src; |
| 254 | } |
| 255 | |
| 256 | static inline struct drm_rect |
| 257 | drm_plane_state_dest(const struct drm_plane_state *state) |
| 258 | { |
| 259 | struct drm_rect dest = { |
| 260 | .x1 = state->crtc_x, |
| 261 | .y1 = state->crtc_y, |
| 262 | .x2 = state->crtc_x + state->crtc_w, |
| 263 | .y2 = state->crtc_y + state->crtc_h, |
| 264 | }; |
| 265 | return dest; |
| 266 | } |
| 267 | |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 268 | /** |
| 269 | * struct drm_plane_funcs - driver plane control functions |
| 270 | */ |
| 271 | struct drm_plane_funcs { |
| 272 | /** |
| 273 | * @update_plane: |
| 274 | * |
| 275 | * This is the legacy entry point to enable and configure the plane for |
| 276 | * the given CRTC and framebuffer. It is never called to disable the |
| 277 | * plane, i.e. the passed-in crtc and fb paramters are never NULL. |
| 278 | * |
| 279 | * The source rectangle in frame buffer memory coordinates is given by |
| 280 | * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point |
| 281 | * values). Devices that don't support subpixel plane coordinates can |
| 282 | * ignore the fractional part. |
| 283 | * |
| 284 | * The destination rectangle in CRTC coordinates is given by the |
| 285 | * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values). |
| 286 | * Devices scale the source rectangle to the destination rectangle. If |
| 287 | * scaling is not supported, and the source rectangle size doesn't match |
| 288 | * the destination rectangle size, the driver must return a |
| 289 | * -<errorname>EINVAL</errorname> error. |
| 290 | * |
| 291 | * Drivers implementing atomic modeset should use |
| 292 | * drm_atomic_helper_update_plane() to implement this hook. |
| 293 | * |
| 294 | * RETURNS: |
| 295 | * |
| 296 | * 0 on success or a negative error code on failure. |
| 297 | */ |
| 298 | int (*update_plane)(struct drm_plane *plane, |
| 299 | struct drm_crtc *crtc, struct drm_framebuffer *fb, |
| 300 | int crtc_x, int crtc_y, |
| 301 | unsigned int crtc_w, unsigned int crtc_h, |
| 302 | uint32_t src_x, uint32_t src_y, |
Daniel Vetter | 34a2ab5 | 2017-03-22 22:50:41 +0100 | [diff] [blame] | 303 | uint32_t src_w, uint32_t src_h, |
| 304 | struct drm_modeset_acquire_ctx *ctx); |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 305 | |
| 306 | /** |
| 307 | * @disable_plane: |
| 308 | * |
| 309 | * This is the legacy entry point to disable the plane. The DRM core |
| 310 | * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call |
| 311 | * with the frame buffer ID set to 0. Disabled planes must not be |
| 312 | * processed by the CRTC. |
| 313 | * |
| 314 | * Drivers implementing atomic modeset should use |
| 315 | * drm_atomic_helper_disable_plane() to implement this hook. |
| 316 | * |
| 317 | * RETURNS: |
| 318 | * |
| 319 | * 0 on success or a negative error code on failure. |
| 320 | */ |
Daniel Vetter | 1931529 | 2017-03-22 22:50:43 +0100 | [diff] [blame] | 321 | int (*disable_plane)(struct drm_plane *plane, |
| 322 | struct drm_modeset_acquire_ctx *ctx); |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 323 | |
| 324 | /** |
| 325 | * @destroy: |
| 326 | * |
| 327 | * Clean up plane resources. This is only called at driver unload time |
| 328 | * through drm_mode_config_cleanup() since a plane cannot be hotplugged |
| 329 | * in DRM. |
| 330 | */ |
| 331 | void (*destroy)(struct drm_plane *plane); |
| 332 | |
| 333 | /** |
| 334 | * @reset: |
| 335 | * |
| 336 | * Reset plane hardware and software state to off. This function isn't |
| 337 | * called by the core directly, only through drm_mode_config_reset(). |
| 338 | * It's not a helper hook only for historical reasons. |
| 339 | * |
| 340 | * Atomic drivers can use drm_atomic_helper_plane_reset() to reset |
| 341 | * atomic state using this hook. |
| 342 | */ |
| 343 | void (*reset)(struct drm_plane *plane); |
| 344 | |
| 345 | /** |
| 346 | * @set_property: |
| 347 | * |
| 348 | * This is the legacy entry point to update a property attached to the |
| 349 | * plane. |
| 350 | * |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 351 | * This callback is optional if the driver does not support any legacy |
Daniel Vetter | 144a799 | 2017-07-25 14:02:04 +0200 | [diff] [blame] | 352 | * driver-private properties. For atomic drivers it is not used because |
| 353 | * property handling is done entirely in the DRM core. |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 354 | * |
| 355 | * RETURNS: |
| 356 | * |
| 357 | * 0 on success or a negative error code on failure. |
| 358 | */ |
| 359 | int (*set_property)(struct drm_plane *plane, |
| 360 | struct drm_property *property, uint64_t val); |
| 361 | |
| 362 | /** |
| 363 | * @atomic_duplicate_state: |
| 364 | * |
| 365 | * Duplicate the current atomic state for this plane and return it. |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 366 | * The core and helpers guarantee that any atomic state duplicated with |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 367 | * this hook and still owned by the caller (i.e. not transferred to the |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 368 | * driver by calling &drm_mode_config_funcs.atomic_commit) will be |
| 369 | * cleaned up by calling the @atomic_destroy_state hook in this |
| 370 | * structure. |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 371 | * |
Haneen Mohammed | ba1f665 | 2018-05-25 04:25:55 +0300 | [diff] [blame] | 372 | * This callback is mandatory for atomic drivers. |
| 373 | * |
Daniel Vetter | ea0dd85 | 2016-12-29 21:48:26 +0100 | [diff] [blame] | 374 | * Atomic drivers which don't subclass &struct drm_plane_state should use |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 375 | * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the |
| 376 | * state structure to extend it with driver-private state should use |
| 377 | * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is |
| 378 | * duplicated in a consistent fashion across drivers. |
| 379 | * |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 380 | * It is an error to call this hook before &drm_plane.state has been |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 381 | * initialized correctly. |
| 382 | * |
| 383 | * NOTE: |
| 384 | * |
| 385 | * If the duplicate state references refcounted resources this hook must |
| 386 | * acquire a reference for each of them. The driver must release these |
| 387 | * references again in @atomic_destroy_state. |
| 388 | * |
| 389 | * RETURNS: |
| 390 | * |
| 391 | * Duplicated atomic state or NULL when the allocation failed. |
| 392 | */ |
| 393 | struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane); |
| 394 | |
| 395 | /** |
| 396 | * @atomic_destroy_state: |
| 397 | * |
| 398 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 399 | * or unreference all resources it references |
Haneen Mohammed | ba1f665 | 2018-05-25 04:25:55 +0300 | [diff] [blame] | 400 | * |
| 401 | * This callback is mandatory for atomic drivers. |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 402 | */ |
| 403 | void (*atomic_destroy_state)(struct drm_plane *plane, |
| 404 | struct drm_plane_state *state); |
| 405 | |
| 406 | /** |
| 407 | * @atomic_set_property: |
| 408 | * |
| 409 | * Decode a driver-private property value and store the decoded value |
| 410 | * into the passed-in state structure. Since the atomic core decodes all |
| 411 | * standardized properties (even for extensions beyond the core set of |
| 412 | * properties which might not be implemented by all drivers) this |
| 413 | * requires drivers to subclass the state structure. |
| 414 | * |
| 415 | * Such driver-private properties should really only be implemented for |
| 416 | * truly hardware/vendor specific state. Instead it is preferred to |
| 417 | * standardize atomic extension and decode the properties used to expose |
| 418 | * such an extension in the core. |
| 419 | * |
| 420 | * Do not call this function directly, use |
| 421 | * drm_atomic_plane_set_property() instead. |
| 422 | * |
| 423 | * This callback is optional if the driver does not support any |
| 424 | * driver-private atomic properties. |
| 425 | * |
| 426 | * NOTE: |
| 427 | * |
| 428 | * This function is called in the state assembly phase of atomic |
| 429 | * modesets, which can be aborted for any reason (including on |
| 430 | * userspace's request to just check whether a configuration would be |
| 431 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 432 | * software) or data structures except the passed in @state parameter. |
| 433 | * |
| 434 | * Also since userspace controls in which order properties are set this |
| 435 | * function must not do any input validation (since the state update is |
| 436 | * incomplete and hence likely inconsistent). Instead any such input |
| 437 | * validation must be done in the various atomic_check callbacks. |
| 438 | * |
| 439 | * RETURNS: |
| 440 | * |
| 441 | * 0 if the property has been found, -EINVAL if the property isn't |
| 442 | * implemented by the driver (which shouldn't ever happen, the core only |
| 443 | * asks for properties attached to this plane). No other validation is |
| 444 | * allowed by the driver. The core already checks that the property |
| 445 | * value is within the range (integer, valid enum value, ...) the driver |
| 446 | * set when registering the property. |
| 447 | */ |
| 448 | int (*atomic_set_property)(struct drm_plane *plane, |
| 449 | struct drm_plane_state *state, |
| 450 | struct drm_property *property, |
| 451 | uint64_t val); |
| 452 | |
| 453 | /** |
| 454 | * @atomic_get_property: |
| 455 | * |
| 456 | * Reads out the decoded driver-private property. This is used to |
| 457 | * implement the GETPLANE IOCTL. |
| 458 | * |
| 459 | * Do not call this function directly, use |
| 460 | * drm_atomic_plane_get_property() instead. |
| 461 | * |
| 462 | * This callback is optional if the driver does not support any |
| 463 | * driver-private atomic properties. |
| 464 | * |
| 465 | * RETURNS: |
| 466 | * |
| 467 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 468 | * driver (which should never happen, the core only asks for |
| 469 | * properties attached to this plane). |
| 470 | */ |
| 471 | int (*atomic_get_property)(struct drm_plane *plane, |
| 472 | const struct drm_plane_state *state, |
| 473 | struct drm_property *property, |
| 474 | uint64_t *val); |
| 475 | /** |
| 476 | * @late_register: |
| 477 | * |
| 478 | * This optional hook can be used to register additional userspace |
| 479 | * interfaces attached to the plane like debugfs interfaces. |
| 480 | * It is called late in the driver load sequence from drm_dev_register(). |
| 481 | * Everything added from this callback should be unregistered in |
| 482 | * the early_unregister callback. |
| 483 | * |
| 484 | * Returns: |
| 485 | * |
| 486 | * 0 on success, or a negative error code on failure. |
| 487 | */ |
| 488 | int (*late_register)(struct drm_plane *plane); |
| 489 | |
| 490 | /** |
| 491 | * @early_unregister: |
| 492 | * |
| 493 | * This optional hook should be used to unregister the additional |
| 494 | * userspace interfaces attached to the plane from |
Daniel Vetter | 559bdaf | 2017-01-25 07:26:55 +0100 | [diff] [blame] | 495 | * @late_register. It is called from drm_dev_unregister(), |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 496 | * early in the driver unload sequence to disable userspace access |
| 497 | * before data structures are torndown. |
| 498 | */ |
| 499 | void (*early_unregister)(struct drm_plane *plane); |
Rob Clark | fceffb32 | 2016-11-05 11:08:09 -0400 | [diff] [blame] | 500 | |
| 501 | /** |
| 502 | * @atomic_print_state: |
| 503 | * |
Daniel Vetter | ea0dd85 | 2016-12-29 21:48:26 +0100 | [diff] [blame] | 504 | * If driver subclasses &struct drm_plane_state, it should implement |
Rob Clark | fceffb32 | 2016-11-05 11:08:09 -0400 | [diff] [blame] | 505 | * this optional hook for printing additional driver specific state. |
| 506 | * |
| 507 | * Do not call this directly, use drm_atomic_plane_print_state() |
| 508 | * instead. |
| 509 | */ |
| 510 | void (*atomic_print_state)(struct drm_printer *p, |
| 511 | const struct drm_plane_state *state); |
Ben Widawsky | e6fc3b6 | 2017-07-23 20:46:38 -0700 | [diff] [blame] | 512 | |
| 513 | /** |
| 514 | * @format_mod_supported: |
| 515 | * |
| 516 | * This optional hook is used for the DRM to determine if the given |
| 517 | * format/modifier combination is valid for the plane. This allows the |
| 518 | * DRM to generate the correct format bitmask (which formats apply to |
Eric Anholt | 8fb756d | 2018-03-16 15:04:33 -0700 | [diff] [blame] | 519 | * which modifier), and to valdiate modifiers at atomic_check time. |
| 520 | * |
| 521 | * If not present, then any modifier in the plane's modifier |
| 522 | * list is allowed with any of the plane's formats. |
Ben Widawsky | e6fc3b6 | 2017-07-23 20:46:38 -0700 | [diff] [blame] | 523 | * |
| 524 | * Returns: |
| 525 | * |
| 526 | * True if the given modifier is valid for that format on the plane. |
| 527 | * False otherwise. |
| 528 | */ |
| 529 | bool (*format_mod_supported)(struct drm_plane *plane, uint32_t format, |
| 530 | uint64_t modifier); |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 531 | }; |
| 532 | |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 533 | /** |
| 534 | * enum drm_plane_type - uapi plane type enumeration |
| 535 | * |
| 536 | * For historical reasons not all planes are made the same. This enumeration is |
| 537 | * used to tell the different types of planes apart to implement the different |
| 538 | * uapi semantics for them. For userspace which is universal plane aware and |
| 539 | * which is using that atomic IOCTL there's no difference between these planes |
| 540 | * (beyong what the driver and hardware can support of course). |
| 541 | * |
| 542 | * For compatibility with legacy userspace, only overlay planes are made |
| 543 | * available to userspace by default. Userspace clients may set the |
Simon Ser | 7e5d1e1 | 2021-01-15 12:06:25 +0100 | [diff] [blame] | 544 | * &DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that they |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 545 | * wish to receive a universal plane list containing all plane types. See also |
| 546 | * drm_for_each_legacy_plane(). |
Daniel Vetter | 226714d | 2016-09-23 08:35:25 +0200 | [diff] [blame] | 547 | * |
Simon Ser | 7e5d1e1 | 2021-01-15 12:06:25 +0100 | [diff] [blame] | 548 | * In addition to setting each plane's type, drivers need to setup the |
| 549 | * &drm_crtc.primary and optionally &drm_crtc.cursor pointers for legacy |
| 550 | * IOCTLs. See drm_crtc_init_with_planes(). |
| 551 | * |
Daniel Vetter | 226714d | 2016-09-23 08:35:25 +0200 | [diff] [blame] | 552 | * WARNING: The values of this enum is UABI since they're exposed in the "type" |
| 553 | * property. |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 554 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 555 | enum drm_plane_type { |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 556 | /** |
Daniel Vetter | 226714d | 2016-09-23 08:35:25 +0200 | [diff] [blame] | 557 | * @DRM_PLANE_TYPE_OVERLAY: |
| 558 | * |
| 559 | * Overlay planes represent all non-primary, non-cursor planes. Some |
| 560 | * drivers refer to these types of planes as "sprites" internally. |
| 561 | */ |
| 562 | DRM_PLANE_TYPE_OVERLAY, |
| 563 | |
| 564 | /** |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 565 | * @DRM_PLANE_TYPE_PRIMARY: |
| 566 | * |
Simon Ser | 7e5d1e1 | 2021-01-15 12:06:25 +0100 | [diff] [blame] | 567 | * A primary plane attached to a CRTC is the most likely to be able to |
| 568 | * light up the CRTC when no scaling/cropping is used and the plane |
| 569 | * covers the whole CRTC. |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 570 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 571 | DRM_PLANE_TYPE_PRIMARY, |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 572 | |
| 573 | /** |
| 574 | * @DRM_PLANE_TYPE_CURSOR: |
| 575 | * |
Simon Ser | 7e5d1e1 | 2021-01-15 12:06:25 +0100 | [diff] [blame] | 576 | * A cursor plane attached to a CRTC is more likely to be able to be |
| 577 | * enabled when no scaling/cropping is used and the framebuffer has the |
| 578 | * size indicated by &drm_mode_config.cursor_width and |
| 579 | * &drm_mode_config.cursor_height. Additionally, if the driver doesn't |
| 580 | * support modifiers, the framebuffer should have a linear layout. |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 581 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 582 | DRM_PLANE_TYPE_CURSOR, |
| 583 | }; |
| 584 | |
| 585 | |
| 586 | /** |
| 587 | * struct drm_plane - central DRM plane control structure |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 588 | * |
| 589 | * Planes represent the scanout hardware of a display block. They receive their |
| 590 | * input data from a &drm_framebuffer and feed it to a &drm_crtc. Planes control |
| 591 | * the color conversion, see `Plane Composition Properties`_ for more details, |
| 592 | * and are also involved in the color conversion of input pixels, see `Color |
| 593 | * Management Properties`_ for details on that. |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 594 | */ |
| 595 | struct drm_plane { |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 596 | /** @dev: DRM device this plane belongs to */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 597 | struct drm_device *dev; |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 598 | |
| 599 | /** |
| 600 | * @head: |
| 601 | * |
| 602 | * List of all planes on @dev, linked from &drm_mode_config.plane_list. |
| 603 | * Invariant over the lifetime of @dev and therefore does not need |
| 604 | * locking. |
| 605 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 606 | struct list_head head; |
| 607 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 608 | /** @name: human readable name, can be overwritten by the driver */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 609 | char *name; |
| 610 | |
| 611 | /** |
| 612 | * @mutex: |
| 613 | * |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 614 | * Protects modeset plane state, together with the &drm_crtc.mutex of |
| 615 | * CRTC this plane is linked to (when active, getting activated or |
| 616 | * getting disabled). |
Daniel Vetter | c9e42b7 | 2017-03-28 17:53:48 +0200 | [diff] [blame] | 617 | * |
| 618 | * For atomic drivers specifically this protects @state. |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 619 | */ |
| 620 | struct drm_modeset_lock mutex; |
| 621 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 622 | /** @base: base mode object */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 623 | struct drm_mode_object base; |
| 624 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 625 | /** |
| 626 | * @possible_crtcs: pipes this plane can be bound to constructed from |
| 627 | * drm_crtc_mask() |
| 628 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 629 | uint32_t possible_crtcs; |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 630 | /** @format_types: array of formats supported by this plane */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 631 | uint32_t *format_types; |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 632 | /** @format_count: Size of the array pointed at by @format_types. */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 633 | unsigned int format_count; |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 634 | /** |
| 635 | * @format_default: driver hasn't supplied supported formats for the |
| 636 | * plane. Used by the drm_plane_init compatibility wrapper only. |
| 637 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 638 | bool format_default; |
| 639 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 640 | /** @modifiers: array of modifiers supported by this plane */ |
Ben Widawsky | e6fc3b6 | 2017-07-23 20:46:38 -0700 | [diff] [blame] | 641 | uint64_t *modifiers; |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 642 | /** @modifier_count: Size of the array pointed at by @modifier_count. */ |
Ben Widawsky | e6fc3b6 | 2017-07-23 20:46:38 -0700 | [diff] [blame] | 643 | unsigned int modifier_count; |
| 644 | |
Daniel Vetter | 2e2b96e | 2017-11-08 21:30:07 +0100 | [diff] [blame] | 645 | /** |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 646 | * @crtc: |
| 647 | * |
| 648 | * Currently bound CRTC, only meaningful for non-atomic drivers. For |
| 649 | * atomic drivers this is forced to be NULL, atomic drivers should |
| 650 | * instead check &drm_plane_state.crtc. |
Daniel Vetter | 2e2b96e | 2017-11-08 21:30:07 +0100 | [diff] [blame] | 651 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 652 | struct drm_crtc *crtc; |
Daniel Vetter | 2e2b96e | 2017-11-08 21:30:07 +0100 | [diff] [blame] | 653 | |
| 654 | /** |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 655 | * @fb: |
| 656 | * |
| 657 | * Currently bound framebuffer, only meaningful for non-atomic drivers. |
| 658 | * For atomic drivers this is forced to be NULL, atomic drivers should |
| 659 | * instead check &drm_plane_state.fb. |
Daniel Vetter | 2e2b96e | 2017-11-08 21:30:07 +0100 | [diff] [blame] | 660 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 661 | struct drm_framebuffer *fb; |
| 662 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 663 | /** |
| 664 | * @old_fb: |
| 665 | * |
| 666 | * Temporary tracking of the old fb while a modeset is ongoing. Only |
| 667 | * used by non-atomic drivers, forced to be NULL for atomic drivers. |
| 668 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 669 | struct drm_framebuffer *old_fb; |
| 670 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 671 | /** @funcs: plane control functions */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 672 | const struct drm_plane_funcs *funcs; |
| 673 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 674 | /** @properties: property tracking for this plane */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 675 | struct drm_object_properties properties; |
| 676 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 677 | /** @type: Type of plane, see &enum drm_plane_type for details. */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 678 | enum drm_plane_type type; |
| 679 | |
| 680 | /** |
| 681 | * @index: Position inside the mode_config.list, can be used as an array |
| 682 | * index. It is invariant over the lifetime of the plane. |
| 683 | */ |
| 684 | unsigned index; |
| 685 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 686 | /** @helper_private: mid-layer private data */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 687 | const struct drm_plane_helper_funcs *helper_private; |
| 688 | |
Daniel Vetter | c9e42b7 | 2017-03-28 17:53:48 +0200 | [diff] [blame] | 689 | /** |
| 690 | * @state: |
| 691 | * |
| 692 | * Current atomic state for this plane. |
| 693 | * |
| 694 | * This is protected by @mutex. Note that nonblocking atomic commits |
| 695 | * access the current plane state without taking locks. Either by going |
| 696 | * through the &struct drm_atomic_state pointers, see |
Maarten Lankhorst | 77ac3b0 | 2017-07-19 16:39:20 +0200 | [diff] [blame] | 697 | * for_each_oldnew_plane_in_state(), for_each_old_plane_in_state() and |
| 698 | * for_each_new_plane_in_state(). Or through careful ordering of atomic |
| 699 | * commit operations as implemented in the atomic helpers, see |
| 700 | * &struct drm_crtc_commit. |
Daniel Vetter | c9e42b7 | 2017-03-28 17:53:48 +0200 | [diff] [blame] | 701 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 702 | struct drm_plane_state *state; |
| 703 | |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 704 | /** |
| 705 | * @alpha_property: |
| 706 | * Optional alpha property for this plane. See |
| 707 | * drm_plane_create_alpha_property(). |
| 708 | */ |
Maxime Ripard | ae0e282 | 2018-04-11 09:39:25 +0200 | [diff] [blame] | 709 | struct drm_property *alpha_property; |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 710 | /** |
| 711 | * @zpos_property: |
| 712 | * Optional zpos property for this plane. See |
| 713 | * drm_plane_create_zpos_property(). |
| 714 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 715 | struct drm_property *zpos_property; |
Daniel Vetter | 268bc24 | 2018-07-09 10:40:10 +0200 | [diff] [blame] | 716 | /** |
| 717 | * @rotation_property: |
| 718 | * Optional rotation property for this plane. See |
| 719 | * drm_plane_create_rotation_property(). |
| 720 | */ |
Ville Syrjälä | d138dd3 | 2016-09-26 19:30:48 +0300 | [diff] [blame] | 721 | struct drm_property *rotation_property; |
Lowry Li | a5ec833 | 2018-08-23 16:30:19 +0800 | [diff] [blame] | 722 | /** |
| 723 | * @blend_mode_property: |
| 724 | * Optional "pixel blend mode" enum property for this plane. |
| 725 | * Blend mode property represents the alpha blending equation selection, |
| 726 | * describing how the pixels from the current plane are composited with |
| 727 | * the background. |
| 728 | */ |
| 729 | struct drm_property *blend_mode_property; |
Jyri Sarha | 80f690e | 2018-02-19 22:28:23 +0200 | [diff] [blame] | 730 | |
| 731 | /** |
| 732 | * @color_encoding_property: |
| 733 | * |
| 734 | * Optional "COLOR_ENCODING" enum property for specifying |
| 735 | * color encoding for non RGB formats. |
| 736 | * See drm_plane_create_color_properties(). |
| 737 | */ |
| 738 | struct drm_property *color_encoding_property; |
| 739 | /** |
| 740 | * @color_range_property: |
| 741 | * |
| 742 | * Optional "COLOR_RANGE" enum property for specifying |
| 743 | * color range for non RGB formats. |
| 744 | * See drm_plane_create_color_properties(). |
| 745 | */ |
| 746 | struct drm_property *color_range_property; |
Pankaj Bharadiya | 5c759ed | 2020-10-20 21:44:23 +0530 | [diff] [blame] | 747 | |
| 748 | /** |
| 749 | * @scaling_filter_property: property to apply a particular filter while |
| 750 | * scaling. |
| 751 | */ |
| 752 | struct drm_property *scaling_filter_property; |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 753 | }; |
| 754 | |
| 755 | #define obj_to_plane(x) container_of(x, struct drm_plane, base) |
| 756 | |
Ben Widawsky | e6fc3b6 | 2017-07-23 20:46:38 -0700 | [diff] [blame] | 757 | __printf(9, 10) |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 758 | int drm_universal_plane_init(struct drm_device *dev, |
| 759 | struct drm_plane *plane, |
Tomi Valkeinen | 5cd57a4 | 2016-12-02 15:45:35 +0200 | [diff] [blame] | 760 | uint32_t possible_crtcs, |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 761 | const struct drm_plane_funcs *funcs, |
| 762 | const uint32_t *formats, |
| 763 | unsigned int format_count, |
Ben Widawsky | e6fc3b6 | 2017-07-23 20:46:38 -0700 | [diff] [blame] | 764 | const uint64_t *format_modifiers, |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 765 | enum drm_plane_type type, |
| 766 | const char *name, ...); |
Daniel Vetter | 91faa04 | 2017-03-22 09:36:02 +0100 | [diff] [blame] | 767 | int drm_plane_init(struct drm_device *dev, |
| 768 | struct drm_plane *plane, |
| 769 | uint32_t possible_crtcs, |
| 770 | const struct drm_plane_funcs *funcs, |
| 771 | const uint32_t *formats, unsigned int format_count, |
| 772 | bool is_primary); |
| 773 | void drm_plane_cleanup(struct drm_plane *plane); |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 774 | |
Philipp Zabel | 0a1b813 | 2020-12-10 16:38:30 +0100 | [diff] [blame] | 775 | __printf(10, 11) |
| 776 | void *__drmm_universal_plane_alloc(struct drm_device *dev, |
| 777 | size_t size, size_t offset, |
| 778 | uint32_t possible_crtcs, |
| 779 | const struct drm_plane_funcs *funcs, |
| 780 | const uint32_t *formats, |
| 781 | unsigned int format_count, |
| 782 | const uint64_t *format_modifiers, |
| 783 | enum drm_plane_type plane_type, |
| 784 | const char *name, ...); |
| 785 | |
| 786 | /** |
| 787 | * drmm_universal_plane_alloc - Allocate and initialize an universal plane object |
| 788 | * @dev: DRM device |
| 789 | * @type: the type of the struct which contains struct &drm_plane |
| 790 | * @member: the name of the &drm_plane within @type |
| 791 | * @possible_crtcs: bitmask of possible CRTCs |
| 792 | * @funcs: callbacks for the new plane |
| 793 | * @formats: array of supported formats (DRM_FORMAT\_\*) |
| 794 | * @format_count: number of elements in @formats |
| 795 | * @format_modifiers: array of struct drm_format modifiers terminated by |
| 796 | * DRM_FORMAT_MOD_INVALID |
| 797 | * @plane_type: type of plane (overlay, primary, cursor) |
| 798 | * @name: printf style format string for the plane name, or NULL for default name |
| 799 | * |
| 800 | * Allocates and initializes a plane object of type @type. Cleanup is |
| 801 | * automatically handled through registering drm_plane_cleanup() with |
| 802 | * drmm_add_action(). |
| 803 | * |
| 804 | * The @drm_plane_funcs.destroy hook must be NULL. |
| 805 | * |
| 806 | * Returns: |
| 807 | * Pointer to new plane, or ERR_PTR on failure. |
| 808 | */ |
| 809 | #define drmm_universal_plane_alloc(dev, type, member, possible_crtcs, funcs, formats, \ |
| 810 | format_count, format_modifiers, plane_type, name, ...) \ |
| 811 | ((type *)__drmm_universal_plane_alloc(dev, sizeof(type), \ |
| 812 | offsetof(type, member), \ |
| 813 | possible_crtcs, funcs, formats, \ |
| 814 | format_count, format_modifiers, \ |
| 815 | plane_type, name, ##__VA_ARGS__)) |
| 816 | |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 817 | /** |
| 818 | * drm_plane_index - find the index of a registered plane |
| 819 | * @plane: plane to find index for |
| 820 | * |
| 821 | * Given a registered plane, return the index of that plane within a DRM |
| 822 | * device's list of planes. |
| 823 | */ |
Ville Syrjälä | 62f77ad | 2018-06-26 22:47:07 +0300 | [diff] [blame] | 824 | static inline unsigned int drm_plane_index(const struct drm_plane *plane) |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 825 | { |
| 826 | return plane->index; |
| 827 | } |
Ville Syrjälä | 62f77ad | 2018-06-26 22:47:07 +0300 | [diff] [blame] | 828 | |
| 829 | /** |
| 830 | * drm_plane_mask - find the mask of a registered plane |
| 831 | * @plane: plane to find mask for |
| 832 | */ |
| 833 | static inline u32 drm_plane_mask(const struct drm_plane *plane) |
| 834 | { |
| 835 | return 1 << drm_plane_index(plane); |
| 836 | } |
| 837 | |
Daniel Vetter | 91faa04 | 2017-03-22 09:36:02 +0100 | [diff] [blame] | 838 | struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx); |
| 839 | void drm_plane_force_disable(struct drm_plane *plane); |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 840 | |
| 841 | int drm_mode_plane_set_obj_prop(struct drm_plane *plane, |
| 842 | struct drm_property *property, |
| 843 | uint64_t value); |
| 844 | |
| 845 | /** |
| 846 | * drm_plane_find - find a &drm_plane |
| 847 | * @dev: DRM device |
Dave Airlie | e7e62c7 | 2017-11-09 09:35:04 +1000 | [diff] [blame] | 848 | * @file_priv: drm file to check for lease against. |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 849 | * @id: plane id |
| 850 | * |
| 851 | * Returns the plane with @id, NULL if it doesn't exist. Simple wrapper around |
| 852 | * drm_mode_object_find(). |
| 853 | */ |
| 854 | static inline struct drm_plane *drm_plane_find(struct drm_device *dev, |
Keith Packard | 418da17 | 2017-03-14 23:25:07 -0700 | [diff] [blame] | 855 | struct drm_file *file_priv, |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 856 | uint32_t id) |
| 857 | { |
| 858 | struct drm_mode_object *mo; |
Keith Packard | 418da17 | 2017-03-14 23:25:07 -0700 | [diff] [blame] | 859 | mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_PLANE); |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 860 | return mo ? obj_to_plane(mo) : NULL; |
| 861 | } |
| 862 | |
| 863 | /** |
| 864 | * drm_for_each_plane_mask - iterate over planes specified by bitmask |
| 865 | * @plane: the loop cursor |
| 866 | * @dev: the DRM device |
| 867 | * @plane_mask: bitmask of plane indices |
| 868 | * |
| 869 | * Iterate over all planes specified by bitmask. |
| 870 | */ |
| 871 | #define drm_for_each_plane_mask(plane, dev, plane_mask) \ |
| 872 | list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \ |
Ville Syrjälä | 62f77ad | 2018-06-26 22:47:07 +0300 | [diff] [blame] | 873 | for_each_if ((plane_mask) & drm_plane_mask(plane)) |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 874 | |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 875 | /** |
| 876 | * drm_for_each_legacy_plane - iterate over all planes for legacy userspace |
| 877 | * @plane: the loop cursor |
| 878 | * @dev: the DRM device |
| 879 | * |
| 880 | * Iterate over all legacy planes of @dev, excluding primary and cursor planes. |
| 881 | * This is useful for implementing userspace apis when userspace is not |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 882 | * universal plane aware. See also &enum drm_plane_type. |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 883 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 884 | #define drm_for_each_legacy_plane(plane, dev) \ |
| 885 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \ |
| 886 | for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY) |
| 887 | |
Daniel Vetter | 532b367 | 2016-09-21 10:59:25 +0200 | [diff] [blame] | 888 | /** |
| 889 | * drm_for_each_plane - iterate over all planes |
| 890 | * @plane: the loop cursor |
| 891 | * @dev: the DRM device |
| 892 | * |
| 893 | * Iterate over all planes of @dev, include primary and cursor planes. |
| 894 | */ |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 895 | #define drm_for_each_plane(plane, dev) \ |
| 896 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) |
| 897 | |
Ville Syrjälä | e7afb62 | 2018-10-29 20:34:52 +0200 | [diff] [blame] | 898 | bool drm_any_plane_has_format(struct drm_device *dev, |
| 899 | u32 format, u64 modifier); |
Daniel Vetter | ba6cd76 | 2021-07-23 10:34:57 +0200 | [diff] [blame] | 900 | |
| 901 | void drm_plane_enable_fb_damage_clips(struct drm_plane *plane); |
Daniel Vetter | c7fcbf2 | 2021-07-23 10:34:56 +0200 | [diff] [blame] | 902 | unsigned int |
| 903 | drm_plane_get_damage_clips_count(const struct drm_plane_state *state); |
Daniel Vetter | c7fcbf2 | 2021-07-23 10:34:56 +0200 | [diff] [blame] | 904 | struct drm_mode_rect * |
| 905 | drm_plane_get_damage_clips(const struct drm_plane_state *state); |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 906 | |
Pankaj Bharadiya | 5c759ed | 2020-10-20 21:44:23 +0530 | [diff] [blame] | 907 | int drm_plane_create_scaling_filter_property(struct drm_plane *plane, |
| 908 | unsigned int supported_filters); |
| 909 | |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 910 | #endif |