split dev_queue
[cor.git] / include / drm / drm_plane.h
blob3f396d94afe407abd1bb0690bcb06fc7ebeffa3a
1 /*
2 * Copyright (c) 2016 Intel Corporation
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.
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.
23 #ifndef __DRM_PLANE_H__
24 #define __DRM_PLANE_H__
26 #include <linux/list.h>
27 #include <linux/ctype.h>
28 #include <drm/drm_mode_object.h>
29 #include <drm/drm_color_mgmt.h>
30 #include <drm/drm_rect.h>
31 #include <drm/drm_modeset_lock.h>
32 #include <drm/drm_util.h>
34 struct drm_crtc;
35 struct drm_printer;
36 struct drm_modeset_acquire_ctx;
38 /**
39 * struct drm_plane_state - mutable plane state
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.
47 struct drm_plane_state {
48 /** @plane: backpointer to the plane */
49 struct drm_plane *plane;
51 /**
52 * @crtc:
54 * Currently bound CRTC, NULL if disabled. Do not this write directly,
55 * use drm_atomic_set_crtc_for_plane()
57 struct drm_crtc *crtc;
59 /**
60 * @fb:
62 * Currently bound framebuffer. Do not write this directly, use
63 * drm_atomic_set_fb_for_plane()
65 struct drm_framebuffer *fb;
67 /**
68 * @fence:
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
72 * write this field directly for a driver's implicit fence, use
73 * drm_atomic_set_fence_for_plane() to ensure that an explicit fence is
74 * preserved.
76 * Drivers should store any implicit fence in this from their
77 * &drm_plane_helper_funcs.prepare_fb callback. See drm_gem_fb_prepare_fb()
78 * and drm_gem_fb_simple_display_pipe_prepare_fb() for suitable helpers.
80 struct dma_fence *fence;
82 /**
83 * @crtc_x:
85 * Left position of visible portion of plane on crtc, signed dest
86 * location allows it to be partially off screen.
89 int32_t crtc_x;
90 /**
91 * @crtc_y:
93 * Upper position of visible portion of plane on crtc, signed dest
94 * location allows it to be partially off screen.
96 int32_t crtc_y;
98 /** @crtc_w: width of visible portion of plane on crtc */
99 /** @crtc_h: height of visible portion of plane on crtc */
100 uint32_t crtc_w, crtc_h;
103 * @src_x: left position of visible portion of plane within plane (in
104 * 16.16 fixed point).
106 uint32_t src_x;
108 * @src_y: upper position of visible portion of plane within plane (in
109 * 16.16 fixed point).
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) */
114 uint32_t src_h, src_w;
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.
122 u16 alpha;
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_*
130 uint16_t pixel_blend_mode;
133 * @rotation:
134 * Rotation of the plane. See drm_plane_create_rotation_property() for
135 * more details.
137 unsigned int rotation;
140 * @zpos:
141 * Priority of the given plane on crtc (optional).
143 * User-space may set mutable zpos properties so that multiple active
144 * planes on the same CRTC have identical zpos values. This is a
145 * user-space bug, but drivers can solve the conflict by comparing the
146 * plane object IDs; the plane with a higher ID is stacked on top of a
147 * plane with a lower ID.
149 * See drm_plane_create_zpos_property() and
150 * drm_plane_create_zpos_immutable_property() for more details.
152 unsigned int zpos;
155 * @normalized_zpos:
156 * Normalized value of zpos: unique, range from 0 to N-1 where N is the
157 * number of active planes for given crtc. Note that the driver must set
158 * &drm_mode_config.normalize_zpos or call drm_atomic_normalize_zpos() to
159 * update this before it can be trusted.
161 unsigned int normalized_zpos;
164 * @color_encoding:
166 * Color encoding for non RGB formats
168 enum drm_color_encoding color_encoding;
171 * @color_range:
173 * Color range for non RGB formats
175 enum drm_color_range color_range;
178 * @fb_damage_clips:
180 * Blob representing damage (area in plane framebuffer that changed
181 * since last plane update) as an array of &drm_mode_rect in framebuffer
182 * coodinates of the attached framebuffer. Note that unlike plane src,
183 * damage clips are not in 16.16 fixed point.
185 struct drm_property_blob *fb_damage_clips;
188 * @src:
190 * source coordinates of the plane (in 16.16).
192 * When using drm_atomic_helper_check_plane_state(),
193 * the coordinates are clipped, but the driver may choose
194 * to use unclipped coordinates instead when the hardware
195 * performs the clipping automatically.
198 * @dst:
200 * clipped destination coordinates of the plane.
202 * When using drm_atomic_helper_check_plane_state(),
203 * the coordinates are clipped, but the driver may choose
204 * to use unclipped coordinates instead when the hardware
205 * performs the clipping automatically.
207 struct drm_rect src, dst;
210 * @visible:
212 * Visibility of the plane. This can be false even if fb!=NULL and
213 * crtc!=NULL, due to clipping.
215 bool visible;
218 * @commit: Tracks the pending commit to prevent use-after-free conditions,
219 * and for async plane updates.
221 * May be NULL.
223 struct drm_crtc_commit *commit;
225 /** @state: backpointer to global drm_atomic_state */
226 struct drm_atomic_state *state;
229 static inline struct drm_rect
230 drm_plane_state_src(const struct drm_plane_state *state)
232 struct drm_rect src = {
233 .x1 = state->src_x,
234 .y1 = state->src_y,
235 .x2 = state->src_x + state->src_w,
236 .y2 = state->src_y + state->src_h,
238 return src;
241 static inline struct drm_rect
242 drm_plane_state_dest(const struct drm_plane_state *state)
244 struct drm_rect dest = {
245 .x1 = state->crtc_x,
246 .y1 = state->crtc_y,
247 .x2 = state->crtc_x + state->crtc_w,
248 .y2 = state->crtc_y + state->crtc_h,
250 return dest;
254 * struct drm_plane_funcs - driver plane control functions
256 struct drm_plane_funcs {
258 * @update_plane:
260 * This is the legacy entry point to enable and configure the plane for
261 * the given CRTC and framebuffer. It is never called to disable the
262 * plane, i.e. the passed-in crtc and fb paramters are never NULL.
264 * The source rectangle in frame buffer memory coordinates is given by
265 * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point
266 * values). Devices that don't support subpixel plane coordinates can
267 * ignore the fractional part.
269 * The destination rectangle in CRTC coordinates is given by the
270 * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values).
271 * Devices scale the source rectangle to the destination rectangle. If
272 * scaling is not supported, and the source rectangle size doesn't match
273 * the destination rectangle size, the driver must return a
274 * -<errorname>EINVAL</errorname> error.
276 * Drivers implementing atomic modeset should use
277 * drm_atomic_helper_update_plane() to implement this hook.
279 * RETURNS:
281 * 0 on success or a negative error code on failure.
283 int (*update_plane)(struct drm_plane *plane,
284 struct drm_crtc *crtc, struct drm_framebuffer *fb,
285 int crtc_x, int crtc_y,
286 unsigned int crtc_w, unsigned int crtc_h,
287 uint32_t src_x, uint32_t src_y,
288 uint32_t src_w, uint32_t src_h,
289 struct drm_modeset_acquire_ctx *ctx);
292 * @disable_plane:
294 * This is the legacy entry point to disable the plane. The DRM core
295 * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call
296 * with the frame buffer ID set to 0. Disabled planes must not be
297 * processed by the CRTC.
299 * Drivers implementing atomic modeset should use
300 * drm_atomic_helper_disable_plane() to implement this hook.
302 * RETURNS:
304 * 0 on success or a negative error code on failure.
306 int (*disable_plane)(struct drm_plane *plane,
307 struct drm_modeset_acquire_ctx *ctx);
310 * @destroy:
312 * Clean up plane resources. This is only called at driver unload time
313 * through drm_mode_config_cleanup() since a plane cannot be hotplugged
314 * in DRM.
316 void (*destroy)(struct drm_plane *plane);
319 * @reset:
321 * Reset plane hardware and software state to off. This function isn't
322 * called by the core directly, only through drm_mode_config_reset().
323 * It's not a helper hook only for historical reasons.
325 * Atomic drivers can use drm_atomic_helper_plane_reset() to reset
326 * atomic state using this hook.
328 void (*reset)(struct drm_plane *plane);
331 * @set_property:
333 * This is the legacy entry point to update a property attached to the
334 * plane.
336 * This callback is optional if the driver does not support any legacy
337 * driver-private properties. For atomic drivers it is not used because
338 * property handling is done entirely in the DRM core.
340 * RETURNS:
342 * 0 on success or a negative error code on failure.
344 int (*set_property)(struct drm_plane *plane,
345 struct drm_property *property, uint64_t val);
348 * @atomic_duplicate_state:
350 * Duplicate the current atomic state for this plane and return it.
351 * The core and helpers guarantee that any atomic state duplicated with
352 * this hook and still owned by the caller (i.e. not transferred to the
353 * driver by calling &drm_mode_config_funcs.atomic_commit) will be
354 * cleaned up by calling the @atomic_destroy_state hook in this
355 * structure.
357 * This callback is mandatory for atomic drivers.
359 * Atomic drivers which don't subclass &struct drm_plane_state should use
360 * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the
361 * state structure to extend it with driver-private state should use
362 * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is
363 * duplicated in a consistent fashion across drivers.
365 * It is an error to call this hook before &drm_plane.state has been
366 * initialized correctly.
368 * NOTE:
370 * If the duplicate state references refcounted resources this hook must
371 * acquire a reference for each of them. The driver must release these
372 * references again in @atomic_destroy_state.
374 * RETURNS:
376 * Duplicated atomic state or NULL when the allocation failed.
378 struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane);
381 * @atomic_destroy_state:
383 * Destroy a state duplicated with @atomic_duplicate_state and release
384 * or unreference all resources it references
386 * This callback is mandatory for atomic drivers.
388 void (*atomic_destroy_state)(struct drm_plane *plane,
389 struct drm_plane_state *state);
392 * @atomic_set_property:
394 * Decode a driver-private property value and store the decoded value
395 * into the passed-in state structure. Since the atomic core decodes all
396 * standardized properties (even for extensions beyond the core set of
397 * properties which might not be implemented by all drivers) this
398 * requires drivers to subclass the state structure.
400 * Such driver-private properties should really only be implemented for
401 * truly hardware/vendor specific state. Instead it is preferred to
402 * standardize atomic extension and decode the properties used to expose
403 * such an extension in the core.
405 * Do not call this function directly, use
406 * drm_atomic_plane_set_property() instead.
408 * This callback is optional if the driver does not support any
409 * driver-private atomic properties.
411 * NOTE:
413 * This function is called in the state assembly phase of atomic
414 * modesets, which can be aborted for any reason (including on
415 * userspace's request to just check whether a configuration would be
416 * possible). Drivers MUST NOT touch any persistent state (hardware or
417 * software) or data structures except the passed in @state parameter.
419 * Also since userspace controls in which order properties are set this
420 * function must not do any input validation (since the state update is
421 * incomplete and hence likely inconsistent). Instead any such input
422 * validation must be done in the various atomic_check callbacks.
424 * RETURNS:
426 * 0 if the property has been found, -EINVAL if the property isn't
427 * implemented by the driver (which shouldn't ever happen, the core only
428 * asks for properties attached to this plane). No other validation is
429 * allowed by the driver. The core already checks that the property
430 * value is within the range (integer, valid enum value, ...) the driver
431 * set when registering the property.
433 int (*atomic_set_property)(struct drm_plane *plane,
434 struct drm_plane_state *state,
435 struct drm_property *property,
436 uint64_t val);
439 * @atomic_get_property:
441 * Reads out the decoded driver-private property. This is used to
442 * implement the GETPLANE IOCTL.
444 * Do not call this function directly, use
445 * drm_atomic_plane_get_property() instead.
447 * This callback is optional if the driver does not support any
448 * driver-private atomic properties.
450 * RETURNS:
452 * 0 on success, -EINVAL if the property isn't implemented by the
453 * driver (which should never happen, the core only asks for
454 * properties attached to this plane).
456 int (*atomic_get_property)(struct drm_plane *plane,
457 const struct drm_plane_state *state,
458 struct drm_property *property,
459 uint64_t *val);
461 * @late_register:
463 * This optional hook can be used to register additional userspace
464 * interfaces attached to the plane like debugfs interfaces.
465 * It is called late in the driver load sequence from drm_dev_register().
466 * Everything added from this callback should be unregistered in
467 * the early_unregister callback.
469 * Returns:
471 * 0 on success, or a negative error code on failure.
473 int (*late_register)(struct drm_plane *plane);
476 * @early_unregister:
478 * This optional hook should be used to unregister the additional
479 * userspace interfaces attached to the plane from
480 * @late_register. It is called from drm_dev_unregister(),
481 * early in the driver unload sequence to disable userspace access
482 * before data structures are torndown.
484 void (*early_unregister)(struct drm_plane *plane);
487 * @atomic_print_state:
489 * If driver subclasses &struct drm_plane_state, it should implement
490 * this optional hook for printing additional driver specific state.
492 * Do not call this directly, use drm_atomic_plane_print_state()
493 * instead.
495 void (*atomic_print_state)(struct drm_printer *p,
496 const struct drm_plane_state *state);
499 * @format_mod_supported:
501 * This optional hook is used for the DRM to determine if the given
502 * format/modifier combination is valid for the plane. This allows the
503 * DRM to generate the correct format bitmask (which formats apply to
504 * which modifier), and to valdiate modifiers at atomic_check time.
506 * If not present, then any modifier in the plane's modifier
507 * list is allowed with any of the plane's formats.
509 * Returns:
511 * True if the given modifier is valid for that format on the plane.
512 * False otherwise.
514 bool (*format_mod_supported)(struct drm_plane *plane, uint32_t format,
515 uint64_t modifier);
519 * enum drm_plane_type - uapi plane type enumeration
521 * For historical reasons not all planes are made the same. This enumeration is
522 * used to tell the different types of planes apart to implement the different
523 * uapi semantics for them. For userspace which is universal plane aware and
524 * which is using that atomic IOCTL there's no difference between these planes
525 * (beyong what the driver and hardware can support of course).
527 * For compatibility with legacy userspace, only overlay planes are made
528 * available to userspace by default. Userspace clients may set the
529 * DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that they
530 * wish to receive a universal plane list containing all plane types. See also
531 * drm_for_each_legacy_plane().
533 * WARNING: The values of this enum is UABI since they're exposed in the "type"
534 * property.
536 enum drm_plane_type {
538 * @DRM_PLANE_TYPE_OVERLAY:
540 * Overlay planes represent all non-primary, non-cursor planes. Some
541 * drivers refer to these types of planes as "sprites" internally.
543 DRM_PLANE_TYPE_OVERLAY,
546 * @DRM_PLANE_TYPE_PRIMARY:
548 * Primary planes represent a "main" plane for a CRTC. Primary planes
549 * are the planes operated upon by CRTC modesetting and flipping
550 * operations described in the &drm_crtc_funcs.page_flip and
551 * &drm_crtc_funcs.set_config hooks.
553 DRM_PLANE_TYPE_PRIMARY,
556 * @DRM_PLANE_TYPE_CURSOR:
558 * Cursor planes represent a "cursor" plane for a CRTC. Cursor planes
559 * are the planes operated upon by the DRM_IOCTL_MODE_CURSOR and
560 * DRM_IOCTL_MODE_CURSOR2 IOCTLs.
562 DRM_PLANE_TYPE_CURSOR,
567 * struct drm_plane - central DRM plane control structure
569 * Planes represent the scanout hardware of a display block. They receive their
570 * input data from a &drm_framebuffer and feed it to a &drm_crtc. Planes control
571 * the color conversion, see `Plane Composition Properties`_ for more details,
572 * and are also involved in the color conversion of input pixels, see `Color
573 * Management Properties`_ for details on that.
575 struct drm_plane {
576 /** @dev: DRM device this plane belongs to */
577 struct drm_device *dev;
580 * @head:
582 * List of all planes on @dev, linked from &drm_mode_config.plane_list.
583 * Invariant over the lifetime of @dev and therefore does not need
584 * locking.
586 struct list_head head;
588 /** @name: human readable name, can be overwritten by the driver */
589 char *name;
592 * @mutex:
594 * Protects modeset plane state, together with the &drm_crtc.mutex of
595 * CRTC this plane is linked to (when active, getting activated or
596 * getting disabled).
598 * For atomic drivers specifically this protects @state.
600 struct drm_modeset_lock mutex;
602 /** @base: base mode object */
603 struct drm_mode_object base;
606 * @possible_crtcs: pipes this plane can be bound to constructed from
607 * drm_crtc_mask()
609 uint32_t possible_crtcs;
610 /** @format_types: array of formats supported by this plane */
611 uint32_t *format_types;
612 /** @format_count: Size of the array pointed at by @format_types. */
613 unsigned int format_count;
615 * @format_default: driver hasn't supplied supported formats for the
616 * plane. Used by the drm_plane_init compatibility wrapper only.
618 bool format_default;
620 /** @modifiers: array of modifiers supported by this plane */
621 uint64_t *modifiers;
622 /** @modifier_count: Size of the array pointed at by @modifier_count. */
623 unsigned int modifier_count;
626 * @crtc:
628 * Currently bound CRTC, only meaningful for non-atomic drivers. For
629 * atomic drivers this is forced to be NULL, atomic drivers should
630 * instead check &drm_plane_state.crtc.
632 struct drm_crtc *crtc;
635 * @fb:
637 * Currently bound framebuffer, only meaningful for non-atomic drivers.
638 * For atomic drivers this is forced to be NULL, atomic drivers should
639 * instead check &drm_plane_state.fb.
641 struct drm_framebuffer *fb;
644 * @old_fb:
646 * Temporary tracking of the old fb while a modeset is ongoing. Only
647 * used by non-atomic drivers, forced to be NULL for atomic drivers.
649 struct drm_framebuffer *old_fb;
651 /** @funcs: plane control functions */
652 const struct drm_plane_funcs *funcs;
654 /** @properties: property tracking for this plane */
655 struct drm_object_properties properties;
657 /** @type: Type of plane, see &enum drm_plane_type for details. */
658 enum drm_plane_type type;
661 * @index: Position inside the mode_config.list, can be used as an array
662 * index. It is invariant over the lifetime of the plane.
664 unsigned index;
666 /** @helper_private: mid-layer private data */
667 const struct drm_plane_helper_funcs *helper_private;
670 * @state:
672 * Current atomic state for this plane.
674 * This is protected by @mutex. Note that nonblocking atomic commits
675 * access the current plane state without taking locks. Either by going
676 * through the &struct drm_atomic_state pointers, see
677 * for_each_oldnew_plane_in_state(), for_each_old_plane_in_state() and
678 * for_each_new_plane_in_state(). Or through careful ordering of atomic
679 * commit operations as implemented in the atomic helpers, see
680 * &struct drm_crtc_commit.
682 struct drm_plane_state *state;
685 * @alpha_property:
686 * Optional alpha property for this plane. See
687 * drm_plane_create_alpha_property().
689 struct drm_property *alpha_property;
691 * @zpos_property:
692 * Optional zpos property for this plane. See
693 * drm_plane_create_zpos_property().
695 struct drm_property *zpos_property;
697 * @rotation_property:
698 * Optional rotation property for this plane. See
699 * drm_plane_create_rotation_property().
701 struct drm_property *rotation_property;
703 * @blend_mode_property:
704 * Optional "pixel blend mode" enum property for this plane.
705 * Blend mode property represents the alpha blending equation selection,
706 * describing how the pixels from the current plane are composited with
707 * the background.
709 struct drm_property *blend_mode_property;
712 * @color_encoding_property:
714 * Optional "COLOR_ENCODING" enum property for specifying
715 * color encoding for non RGB formats.
716 * See drm_plane_create_color_properties().
718 struct drm_property *color_encoding_property;
720 * @color_range_property:
722 * Optional "COLOR_RANGE" enum property for specifying
723 * color range for non RGB formats.
724 * See drm_plane_create_color_properties().
726 struct drm_property *color_range_property;
729 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
731 __printf(9, 10)
732 int drm_universal_plane_init(struct drm_device *dev,
733 struct drm_plane *plane,
734 uint32_t possible_crtcs,
735 const struct drm_plane_funcs *funcs,
736 const uint32_t *formats,
737 unsigned int format_count,
738 const uint64_t *format_modifiers,
739 enum drm_plane_type type,
740 const char *name, ...);
741 int drm_plane_init(struct drm_device *dev,
742 struct drm_plane *plane,
743 uint32_t possible_crtcs,
744 const struct drm_plane_funcs *funcs,
745 const uint32_t *formats, unsigned int format_count,
746 bool is_primary);
747 void drm_plane_cleanup(struct drm_plane *plane);
750 * drm_plane_index - find the index of a registered plane
751 * @plane: plane to find index for
753 * Given a registered plane, return the index of that plane within a DRM
754 * device's list of planes.
756 static inline unsigned int drm_plane_index(const struct drm_plane *plane)
758 return plane->index;
762 * drm_plane_mask - find the mask of a registered plane
763 * @plane: plane to find mask for
765 static inline u32 drm_plane_mask(const struct drm_plane *plane)
767 return 1 << drm_plane_index(plane);
770 struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
771 void drm_plane_force_disable(struct drm_plane *plane);
773 int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
774 struct drm_property *property,
775 uint64_t value);
778 * drm_plane_find - find a &drm_plane
779 * @dev: DRM device
780 * @file_priv: drm file to check for lease against.
781 * @id: plane id
783 * Returns the plane with @id, NULL if it doesn't exist. Simple wrapper around
784 * drm_mode_object_find().
786 static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
787 struct drm_file *file_priv,
788 uint32_t id)
790 struct drm_mode_object *mo;
791 mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_PLANE);
792 return mo ? obj_to_plane(mo) : NULL;
796 * drm_for_each_plane_mask - iterate over planes specified by bitmask
797 * @plane: the loop cursor
798 * @dev: the DRM device
799 * @plane_mask: bitmask of plane indices
801 * Iterate over all planes specified by bitmask.
803 #define drm_for_each_plane_mask(plane, dev, plane_mask) \
804 list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
805 for_each_if ((plane_mask) & drm_plane_mask(plane))
808 * drm_for_each_legacy_plane - iterate over all planes for legacy userspace
809 * @plane: the loop cursor
810 * @dev: the DRM device
812 * Iterate over all legacy planes of @dev, excluding primary and cursor planes.
813 * This is useful for implementing userspace apis when userspace is not
814 * universal plane aware. See also &enum drm_plane_type.
816 #define drm_for_each_legacy_plane(plane, dev) \
817 list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
818 for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY)
821 * drm_for_each_plane - iterate over all planes
822 * @plane: the loop cursor
823 * @dev: the DRM device
825 * Iterate over all planes of @dev, include primary and cursor planes.
827 #define drm_for_each_plane(plane, dev) \
828 list_for_each_entry(plane, &(dev)->mode_config.plane_list, head)
830 bool drm_any_plane_has_format(struct drm_device *dev,
831 u32 format, u64 modifier);
833 * drm_plane_get_damage_clips_count - Returns damage clips count.
834 * @state: Plane state.
836 * Simple helper to get the number of &drm_mode_rect clips set by user-space
837 * during plane update.
839 * Return: Number of clips in plane fb_damage_clips blob property.
841 static inline unsigned int
842 drm_plane_get_damage_clips_count(const struct drm_plane_state *state)
844 return (state && state->fb_damage_clips) ?
845 state->fb_damage_clips->length/sizeof(struct drm_mode_rect) : 0;
849 * drm_plane_get_damage_clips - Returns damage clips.
850 * @state: Plane state.
852 * Note that this function returns uapi type &drm_mode_rect. Drivers might
853 * instead be interested in internal &drm_rect which can be obtained by calling
854 * drm_helper_get_plane_damage_clips().
856 * Return: Damage clips in plane fb_damage_clips blob property.
858 static inline struct drm_mode_rect *
859 drm_plane_get_damage_clips(const struct drm_plane_state *state)
861 return (struct drm_mode_rect *)((state && state->fb_damage_clips) ?
862 state->fb_damage_clips->data : NULL);
865 #endif