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