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
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>
36 struct drm_modeset_acquire_ctx;
38 enum drm_scaling_filter {
39 DRM_SCALING_FILTER_DEFAULT,
40 DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
44 * struct drm_plane_state - mutable plane state
46 * Please not that the destination coordinates @crtc_x, @crtc_y, @crtc_h and
47 * @crtc_w and the source coordinates @src_x, @src_y, @src_h and @src_w are the
48 * raw coordinates provided by userspace. Drivers should use
49 * drm_atomic_helper_check_plane_state() and only use the derived rectangles in
50 * @src and @dst to program the hardware.
52 struct drm_plane_state {
53 /** @plane: backpointer to the plane */
54 struct drm_plane *plane;
59 * Currently bound CRTC, NULL if disabled. Do not this write directly,
60 * use drm_atomic_set_crtc_for_plane()
62 struct drm_crtc *crtc;
67 * Currently bound framebuffer. Do not write this directly, use
68 * drm_atomic_set_fb_for_plane()
70 struct drm_framebuffer *fb;
75 * Optional fence to wait for before scanning out @fb. The core atomic
76 * code will set this when userspace is using explicit fencing. Do not
77 * write this field directly for a driver's implicit fence, use
78 * drm_atomic_set_fence_for_plane() to ensure that an explicit fence is
81 * Drivers should store any implicit fence in this from their
82 * &drm_plane_helper_funcs.prepare_fb callback. See drm_gem_fb_prepare_fb()
83 * and drm_gem_fb_simple_display_pipe_prepare_fb() for suitable helpers.
85 struct dma_fence *fence;
90 * Left position of visible portion of plane on crtc, signed dest
91 * location allows it to be partially off screen.
98 * Upper position of visible portion of plane on crtc, signed dest
99 * location allows it to be partially off screen.
103 /** @crtc_w: width of visible portion of plane on crtc */
104 /** @crtc_h: height of visible portion of plane on crtc */
105 uint32_t crtc_w, crtc_h;
108 * @src_x: left position of visible portion of plane within plane (in
109 * 16.16 fixed point).
113 * @src_y: upper position of visible portion of plane within plane (in
114 * 16.16 fixed point).
117 /** @src_w: width of visible portion of plane (in 16.16) */
118 /** @src_h: height of visible portion of plane (in 16.16) */
119 uint32_t src_h, src_w;
123 * Opacity of the plane with 0 as completely transparent and 0xffff as
124 * completely opaque. See drm_plane_create_alpha_property() for more
131 * The alpha blending equation selection, describing how the pixels from
132 * the current plane are composited with the background. Value can be
133 * one of DRM_MODE_BLEND_*
135 uint16_t pixel_blend_mode;
139 * Rotation of the plane. See drm_plane_create_rotation_property() for
142 unsigned int rotation;
146 * Priority of the given plane on crtc (optional).
148 * User-space may set mutable zpos properties so that multiple active
149 * planes on the same CRTC have identical zpos values. This is a
150 * user-space bug, but drivers can solve the conflict by comparing the
151 * plane object IDs; the plane with a higher ID is stacked on top of a
152 * plane with a lower ID.
154 * See drm_plane_create_zpos_property() and
155 * drm_plane_create_zpos_immutable_property() for more details.
161 * Normalized value of zpos: unique, range from 0 to N-1 where N is the
162 * number of active planes for given crtc. Note that the driver must set
163 * &drm_mode_config.normalize_zpos or call drm_atomic_normalize_zpos() to
164 * update this before it can be trusted.
166 unsigned int normalized_zpos;
171 * Color encoding for non RGB formats
173 enum drm_color_encoding color_encoding;
178 * Color range for non RGB formats
180 enum drm_color_range color_range;
185 * Blob representing damage (area in plane framebuffer that changed
186 * since last plane update) as an array of &drm_mode_rect in framebuffer
187 * coodinates of the attached framebuffer. Note that unlike plane src,
188 * damage clips are not in 16.16 fixed point.
190 struct drm_property_blob *fb_damage_clips;
195 * source coordinates of the plane (in 16.16).
197 * When using drm_atomic_helper_check_plane_state(),
198 * the coordinates are clipped, but the driver may choose
199 * to use unclipped coordinates instead when the hardware
200 * performs the clipping automatically.
205 * clipped destination coordinates of the plane.
207 * When using drm_atomic_helper_check_plane_state(),
208 * the coordinates are clipped, but the driver may choose
209 * to use unclipped coordinates instead when the hardware
210 * performs the clipping automatically.
212 struct drm_rect src, dst;
217 * Visibility of the plane. This can be false even if fb!=NULL and
218 * crtc!=NULL, due to clipping.
225 * Scaling filter to be applied
227 enum drm_scaling_filter scaling_filter;
230 * @commit: Tracks the pending commit to prevent use-after-free conditions,
231 * and for async plane updates.
235 struct drm_crtc_commit *commit;
237 /** @state: backpointer to global drm_atomic_state */
238 struct drm_atomic_state *state;
241 static inline struct drm_rect
242 drm_plane_state_src(const struct drm_plane_state *state)
244 struct drm_rect src = {
247 .x2 = state->src_x + state->src_w,
248 .y2 = state->src_y + state->src_h,
253 static inline struct drm_rect
254 drm_plane_state_dest(const struct drm_plane_state *state)
256 struct drm_rect dest = {
259 .x2 = state->crtc_x + state->crtc_w,
260 .y2 = state->crtc_y + state->crtc_h,
266 * struct drm_plane_funcs - driver plane control functions
268 struct drm_plane_funcs {
272 * This is the legacy entry point to enable and configure the plane for
273 * the given CRTC and framebuffer. It is never called to disable the
274 * plane, i.e. the passed-in crtc and fb paramters are never NULL.
276 * The source rectangle in frame buffer memory coordinates is given by
277 * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point
278 * values). Devices that don't support subpixel plane coordinates can
279 * ignore the fractional part.
281 * The destination rectangle in CRTC coordinates is given by the
282 * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values).
283 * Devices scale the source rectangle to the destination rectangle. If
284 * scaling is not supported, and the source rectangle size doesn't match
285 * the destination rectangle size, the driver must return a
286 * -<errorname>EINVAL</errorname> error.
288 * Drivers implementing atomic modeset should use
289 * drm_atomic_helper_update_plane() to implement this hook.
293 * 0 on success or a negative error code on failure.
295 int (*update_plane)(struct drm_plane *plane,
296 struct drm_crtc *crtc, struct drm_framebuffer *fb,
297 int crtc_x, int crtc_y,
298 unsigned int crtc_w, unsigned int crtc_h,
299 uint32_t src_x, uint32_t src_y,
300 uint32_t src_w, uint32_t src_h,
301 struct drm_modeset_acquire_ctx *ctx);
306 * This is the legacy entry point to disable the plane. The DRM core
307 * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call
308 * with the frame buffer ID set to 0. Disabled planes must not be
309 * processed by the CRTC.
311 * Drivers implementing atomic modeset should use
312 * drm_atomic_helper_disable_plane() to implement this hook.
316 * 0 on success or a negative error code on failure.
318 int (*disable_plane)(struct drm_plane *plane,
319 struct drm_modeset_acquire_ctx *ctx);
324 * Clean up plane resources. This is only called at driver unload time
325 * through drm_mode_config_cleanup() since a plane cannot be hotplugged
328 void (*destroy)(struct drm_plane *plane);
333 * Reset plane hardware and software state to off. This function isn't
334 * called by the core directly, only through drm_mode_config_reset().
335 * It's not a helper hook only for historical reasons.
337 * Atomic drivers can use drm_atomic_helper_plane_reset() to reset
338 * atomic state using this hook.
340 void (*reset)(struct drm_plane *plane);
345 * This is the legacy entry point to update a property attached to the
348 * This callback is optional if the driver does not support any legacy
349 * driver-private properties. For atomic drivers it is not used because
350 * property handling is done entirely in the DRM core.
354 * 0 on success or a negative error code on failure.
356 int (*set_property)(struct drm_plane *plane,
357 struct drm_property *property, uint64_t val);
360 * @atomic_duplicate_state:
362 * Duplicate the current atomic state for this plane and return it.
363 * The core and helpers guarantee that any atomic state duplicated with
364 * this hook and still owned by the caller (i.e. not transferred to the
365 * driver by calling &drm_mode_config_funcs.atomic_commit) will be
366 * cleaned up by calling the @atomic_destroy_state hook in this
369 * This callback is mandatory for atomic drivers.
371 * Atomic drivers which don't subclass &struct drm_plane_state should use
372 * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the
373 * state structure to extend it with driver-private state should use
374 * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is
375 * duplicated in a consistent fashion across drivers.
377 * It is an error to call this hook before &drm_plane.state has been
378 * initialized correctly.
382 * If the duplicate state references refcounted resources this hook must
383 * acquire a reference for each of them. The driver must release these
384 * references again in @atomic_destroy_state.
388 * Duplicated atomic state or NULL when the allocation failed.
390 struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane);
393 * @atomic_destroy_state:
395 * Destroy a state duplicated with @atomic_duplicate_state and release
396 * or unreference all resources it references
398 * This callback is mandatory for atomic drivers.
400 void (*atomic_destroy_state)(struct drm_plane *plane,
401 struct drm_plane_state *state);
404 * @atomic_set_property:
406 * Decode a driver-private property value and store the decoded value
407 * into the passed-in state structure. Since the atomic core decodes all
408 * standardized properties (even for extensions beyond the core set of
409 * properties which might not be implemented by all drivers) this
410 * requires drivers to subclass the state structure.
412 * Such driver-private properties should really only be implemented for
413 * truly hardware/vendor specific state. Instead it is preferred to
414 * standardize atomic extension and decode the properties used to expose
415 * such an extension in the core.
417 * Do not call this function directly, use
418 * drm_atomic_plane_set_property() instead.
420 * This callback is optional if the driver does not support any
421 * driver-private atomic properties.
425 * This function is called in the state assembly phase of atomic
426 * modesets, which can be aborted for any reason (including on
427 * userspace's request to just check whether a configuration would be
428 * possible). Drivers MUST NOT touch any persistent state (hardware or
429 * software) or data structures except the passed in @state parameter.
431 * Also since userspace controls in which order properties are set this
432 * function must not do any input validation (since the state update is
433 * incomplete and hence likely inconsistent). Instead any such input
434 * validation must be done in the various atomic_check callbacks.
438 * 0 if the property has been found, -EINVAL if the property isn't
439 * implemented by the driver (which shouldn't ever happen, the core only
440 * asks for properties attached to this plane). No other validation is
441 * allowed by the driver. The core already checks that the property
442 * value is within the range (integer, valid enum value, ...) the driver
443 * set when registering the property.
445 int (*atomic_set_property)(struct drm_plane *plane,
446 struct drm_plane_state *state,
447 struct drm_property *property,
451 * @atomic_get_property:
453 * Reads out the decoded driver-private property. This is used to
454 * implement the GETPLANE IOCTL.
456 * Do not call this function directly, use
457 * drm_atomic_plane_get_property() instead.
459 * This callback is optional if the driver does not support any
460 * driver-private atomic properties.
464 * 0 on success, -EINVAL if the property isn't implemented by the
465 * driver (which should never happen, the core only asks for
466 * properties attached to this plane).
468 int (*atomic_get_property)(struct drm_plane *plane,
469 const struct drm_plane_state *state,
470 struct drm_property *property,
475 * This optional hook can be used to register additional userspace
476 * interfaces attached to the plane like debugfs interfaces.
477 * It is called late in the driver load sequence from drm_dev_register().
478 * Everything added from this callback should be unregistered in
479 * the early_unregister callback.
483 * 0 on success, or a negative error code on failure.
485 int (*late_register)(struct drm_plane *plane);
490 * This optional hook should be used to unregister the additional
491 * userspace interfaces attached to the plane from
492 * @late_register. It is called from drm_dev_unregister(),
493 * early in the driver unload sequence to disable userspace access
494 * before data structures are torndown.
496 void (*early_unregister)(struct drm_plane *plane);
499 * @atomic_print_state:
501 * If driver subclasses &struct drm_plane_state, it should implement
502 * this optional hook for printing additional driver specific state.
504 * Do not call this directly, use drm_atomic_plane_print_state()
507 void (*atomic_print_state)(struct drm_printer *p,
508 const struct drm_plane_state *state);
511 * @format_mod_supported:
513 * This optional hook is used for the DRM to determine if the given
514 * format/modifier combination is valid for the plane. This allows the
515 * DRM to generate the correct format bitmask (which formats apply to
516 * which modifier), and to valdiate modifiers at atomic_check time.
518 * If not present, then any modifier in the plane's modifier
519 * list is allowed with any of the plane's formats.
523 * True if the given modifier is valid for that format on the plane.
526 bool (*format_mod_supported)(struct drm_plane *plane, uint32_t format,
531 * enum drm_plane_type - uapi plane type enumeration
533 * For historical reasons not all planes are made the same. This enumeration is
534 * used to tell the different types of planes apart to implement the different
535 * uapi semantics for them. For userspace which is universal plane aware and
536 * which is using that atomic IOCTL there's no difference between these planes
537 * (beyong what the driver and hardware can support of course).
539 * For compatibility with legacy userspace, only overlay planes are made
540 * available to userspace by default. Userspace clients may set the
541 * DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that they
542 * wish to receive a universal plane list containing all plane types. See also
543 * drm_for_each_legacy_plane().
545 * WARNING: The values of this enum is UABI since they're exposed in the "type"
548 enum drm_plane_type {
550 * @DRM_PLANE_TYPE_OVERLAY:
552 * Overlay planes represent all non-primary, non-cursor planes. Some
553 * drivers refer to these types of planes as "sprites" internally.
555 DRM_PLANE_TYPE_OVERLAY,
558 * @DRM_PLANE_TYPE_PRIMARY:
560 * Primary planes represent a "main" plane for a CRTC. Primary planes
561 * are the planes operated upon by CRTC modesetting and flipping
562 * operations described in the &drm_crtc_funcs.page_flip and
563 * &drm_crtc_funcs.set_config hooks.
565 DRM_PLANE_TYPE_PRIMARY,
568 * @DRM_PLANE_TYPE_CURSOR:
570 * Cursor planes represent a "cursor" plane for a CRTC. Cursor planes
571 * are the planes operated upon by the DRM_IOCTL_MODE_CURSOR and
572 * DRM_IOCTL_MODE_CURSOR2 IOCTLs.
574 DRM_PLANE_TYPE_CURSOR,
579 * struct drm_plane - central DRM plane control structure
581 * Planes represent the scanout hardware of a display block. They receive their
582 * input data from a &drm_framebuffer and feed it to a &drm_crtc. Planes control
583 * the color conversion, see `Plane Composition Properties`_ for more details,
584 * and are also involved in the color conversion of input pixels, see `Color
585 * Management Properties`_ for details on that.
588 /** @dev: DRM device this plane belongs to */
589 struct drm_device *dev;
594 * List of all planes on @dev, linked from &drm_mode_config.plane_list.
595 * Invariant over the lifetime of @dev and therefore does not need
598 struct list_head head;
600 /** @name: human readable name, can be overwritten by the driver */
606 * Protects modeset plane state, together with the &drm_crtc.mutex of
607 * CRTC this plane is linked to (when active, getting activated or
610 * For atomic drivers specifically this protects @state.
612 struct drm_modeset_lock mutex;
614 /** @base: base mode object */
615 struct drm_mode_object base;
618 * @possible_crtcs: pipes this plane can be bound to constructed from
621 uint32_t possible_crtcs;
622 /** @format_types: array of formats supported by this plane */
623 uint32_t *format_types;
624 /** @format_count: Size of the array pointed at by @format_types. */
625 unsigned int format_count;
627 * @format_default: driver hasn't supplied supported formats for the
628 * plane. Used by the drm_plane_init compatibility wrapper only.
632 /** @modifiers: array of modifiers supported by this plane */
634 /** @modifier_count: Size of the array pointed at by @modifier_count. */
635 unsigned int modifier_count;
640 * Currently bound CRTC, only meaningful for non-atomic drivers. For
641 * atomic drivers this is forced to be NULL, atomic drivers should
642 * instead check &drm_plane_state.crtc.
644 struct drm_crtc *crtc;
649 * Currently bound framebuffer, only meaningful for non-atomic drivers.
650 * For atomic drivers this is forced to be NULL, atomic drivers should
651 * instead check &drm_plane_state.fb.
653 struct drm_framebuffer *fb;
658 * Temporary tracking of the old fb while a modeset is ongoing. Only
659 * used by non-atomic drivers, forced to be NULL for atomic drivers.
661 struct drm_framebuffer *old_fb;
663 /** @funcs: plane control functions */
664 const struct drm_plane_funcs *funcs;
666 /** @properties: property tracking for this plane */
667 struct drm_object_properties properties;
669 /** @type: Type of plane, see &enum drm_plane_type for details. */
670 enum drm_plane_type type;
673 * @index: Position inside the mode_config.list, can be used as an array
674 * index. It is invariant over the lifetime of the plane.
678 /** @helper_private: mid-layer private data */
679 const struct drm_plane_helper_funcs *helper_private;
684 * Current atomic state for this plane.
686 * This is protected by @mutex. Note that nonblocking atomic commits
687 * access the current plane state without taking locks. Either by going
688 * through the &struct drm_atomic_state pointers, see
689 * for_each_oldnew_plane_in_state(), for_each_old_plane_in_state() and
690 * for_each_new_plane_in_state(). Or through careful ordering of atomic
691 * commit operations as implemented in the atomic helpers, see
692 * &struct drm_crtc_commit.
694 struct drm_plane_state *state;
698 * Optional alpha property for this plane. See
699 * drm_plane_create_alpha_property().
701 struct drm_property *alpha_property;
704 * Optional zpos property for this plane. See
705 * drm_plane_create_zpos_property().
707 struct drm_property *zpos_property;
709 * @rotation_property:
710 * Optional rotation property for this plane. See
711 * drm_plane_create_rotation_property().
713 struct drm_property *rotation_property;
715 * @blend_mode_property:
716 * Optional "pixel blend mode" enum property for this plane.
717 * Blend mode property represents the alpha blending equation selection,
718 * describing how the pixels from the current plane are composited with
721 struct drm_property *blend_mode_property;
724 * @color_encoding_property:
726 * Optional "COLOR_ENCODING" enum property for specifying
727 * color encoding for non RGB formats.
728 * See drm_plane_create_color_properties().
730 struct drm_property *color_encoding_property;
732 * @color_range_property:
734 * Optional "COLOR_RANGE" enum property for specifying
735 * color range for non RGB formats.
736 * See drm_plane_create_color_properties().
738 struct drm_property *color_range_property;
741 * @scaling_filter_property: property to apply a particular filter while
744 struct drm_property *scaling_filter_property;
747 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
750 int drm_universal_plane_init(struct drm_device *dev,
751 struct drm_plane *plane,
752 uint32_t possible_crtcs,
753 const struct drm_plane_funcs *funcs,
754 const uint32_t *formats,
755 unsigned int format_count,
756 const uint64_t *format_modifiers,
757 enum drm_plane_type type,
758 const char *name, ...);
759 int drm_plane_init(struct drm_device *dev,
760 struct drm_plane *plane,
761 uint32_t possible_crtcs,
762 const struct drm_plane_funcs *funcs,
763 const uint32_t *formats, unsigned int format_count,
765 void drm_plane_cleanup(struct drm_plane *plane);
768 void *__drmm_universal_plane_alloc(struct drm_device *dev,
769 size_t size, size_t offset,
770 uint32_t possible_crtcs,
771 const struct drm_plane_funcs *funcs,
772 const uint32_t *formats,
773 unsigned int format_count,
774 const uint64_t *format_modifiers,
775 enum drm_plane_type plane_type,
776 const char *name, ...);
779 * drmm_universal_plane_alloc - Allocate and initialize an universal plane object
781 * @type: the type of the struct which contains struct &drm_plane
782 * @member: the name of the &drm_plane within @type
783 * @possible_crtcs: bitmask of possible CRTCs
784 * @funcs: callbacks for the new plane
785 * @formats: array of supported formats (DRM_FORMAT\_\*)
786 * @format_count: number of elements in @formats
787 * @format_modifiers: array of struct drm_format modifiers terminated by
788 * DRM_FORMAT_MOD_INVALID
789 * @plane_type: type of plane (overlay, primary, cursor)
790 * @name: printf style format string for the plane name, or NULL for default name
792 * Allocates and initializes a plane object of type @type. Cleanup is
793 * automatically handled through registering drm_plane_cleanup() with
796 * The @drm_plane_funcs.destroy hook must be NULL.
799 * Pointer to new plane, or ERR_PTR on failure.
801 #define drmm_universal_plane_alloc(dev, type, member, possible_crtcs, funcs, formats, \
802 format_count, format_modifiers, plane_type, name, ...) \
803 ((type *)__drmm_universal_plane_alloc(dev, sizeof(type), \
804 offsetof(type, member), \
805 possible_crtcs, funcs, formats, \
806 format_count, format_modifiers, \
807 plane_type, name, ##__VA_ARGS__))
810 * drm_plane_index - find the index of a registered plane
811 * @plane: plane to find index for
813 * Given a registered plane, return the index of that plane within a DRM
814 * device's list of planes.
816 static inline unsigned int drm_plane_index(const struct drm_plane *plane)
822 * drm_plane_mask - find the mask of a registered plane
823 * @plane: plane to find mask for
825 static inline u32 drm_plane_mask(const struct drm_plane *plane)
827 return 1 << drm_plane_index(plane);
830 struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
831 void drm_plane_force_disable(struct drm_plane *plane);
833 int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
834 struct drm_property *property,
838 * drm_plane_find - find a &drm_plane
840 * @file_priv: drm file to check for lease against.
843 * Returns the plane with @id, NULL if it doesn't exist. Simple wrapper around
844 * drm_mode_object_find().
846 static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
847 struct drm_file *file_priv,
850 struct drm_mode_object *mo;
851 mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_PLANE);
852 return mo ? obj_to_plane(mo) : NULL;
856 * drm_for_each_plane_mask - iterate over planes specified by bitmask
857 * @plane: the loop cursor
858 * @dev: the DRM device
859 * @plane_mask: bitmask of plane indices
861 * Iterate over all planes specified by bitmask.
863 #define drm_for_each_plane_mask(plane, dev, plane_mask) \
864 list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
865 for_each_if ((plane_mask) & drm_plane_mask(plane))
868 * drm_for_each_legacy_plane - iterate over all planes for legacy userspace
869 * @plane: the loop cursor
870 * @dev: the DRM device
872 * Iterate over all legacy planes of @dev, excluding primary and cursor planes.
873 * This is useful for implementing userspace apis when userspace is not
874 * universal plane aware. See also &enum drm_plane_type.
876 #define drm_for_each_legacy_plane(plane, dev) \
877 list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
878 for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY)
881 * drm_for_each_plane - iterate over all planes
882 * @plane: the loop cursor
883 * @dev: the DRM device
885 * Iterate over all planes of @dev, include primary and cursor planes.
887 #define drm_for_each_plane(plane, dev) \
888 list_for_each_entry(plane, &(dev)->mode_config.plane_list, head)
890 bool drm_any_plane_has_format(struct drm_device *dev,
891 u32 format, u64 modifier);
893 * drm_plane_get_damage_clips_count - Returns damage clips count.
894 * @state: Plane state.
896 * Simple helper to get the number of &drm_mode_rect clips set by user-space
897 * during plane update.
899 * Return: Number of clips in plane fb_damage_clips blob property.
901 static inline unsigned int
902 drm_plane_get_damage_clips_count(const struct drm_plane_state *state)
904 return (state && state->fb_damage_clips) ?
905 state->fb_damage_clips->length/sizeof(struct drm_mode_rect) : 0;
909 * drm_plane_get_damage_clips - Returns damage clips.
910 * @state: Plane state.
912 * Note that this function returns uapi type &drm_mode_rect. Drivers might
913 * instead be interested in internal &drm_rect which can be obtained by calling
914 * drm_helper_get_plane_damage_clips().
916 * Return: Damage clips in plane fb_damage_clips blob property.
918 static inline struct drm_mode_rect *
919 drm_plane_get_damage_clips(const struct drm_plane_state *state)
921 return (struct drm_mode_rect *)((state && state->fb_damage_clips) ?
922 state->fb_damage_clips->data : NULL);
925 int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
926 unsigned int supported_filters);