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