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