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