143968d7bSDaniel Vetter /*
243968d7bSDaniel Vetter * Copyright (c) 2016 Intel Corporation
343968d7bSDaniel Vetter *
443968d7bSDaniel Vetter * Permission to use, copy, modify, distribute, and sell this software and its
543968d7bSDaniel Vetter * documentation for any purpose is hereby granted without fee, provided that
643968d7bSDaniel Vetter * the above copyright notice appear in all copies and that both that copyright
743968d7bSDaniel Vetter * notice and this permission notice appear in supporting documentation, and
843968d7bSDaniel Vetter * that the name of the copyright holders not be used in advertising or
943968d7bSDaniel Vetter * publicity pertaining to distribution of the software without specific,
1043968d7bSDaniel Vetter * written prior permission. The copyright holders make no representations
1143968d7bSDaniel Vetter * about the suitability of this software for any purpose. It is provided "as
1243968d7bSDaniel Vetter * is" without express or implied warranty.
1343968d7bSDaniel Vetter *
1443968d7bSDaniel Vetter * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1543968d7bSDaniel Vetter * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1643968d7bSDaniel Vetter * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1743968d7bSDaniel Vetter * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1843968d7bSDaniel Vetter * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
1943968d7bSDaniel Vetter * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
2043968d7bSDaniel Vetter * OF THIS SOFTWARE.
2143968d7bSDaniel Vetter */
2243968d7bSDaniel Vetter
2343968d7bSDaniel Vetter #ifndef __DRM_PLANE_H__
2443968d7bSDaniel Vetter #define __DRM_PLANE_H__
2543968d7bSDaniel Vetter
2643968d7bSDaniel Vetter #include <linux/list.h>
2743968d7bSDaniel Vetter #include <linux/ctype.h>
28bf9fb17cSJocelyn Falempe #include <linux/kmsg_dump.h>
2943968d7bSDaniel Vetter #include <drm/drm_mode_object.h>
3080f690e9SJyri Sarha #include <drm/drm_color_mgmt.h>
31b88ac005SDaniel Vetter #include <drm/drm_rect.h>
32b88ac005SDaniel Vetter #include <drm/drm_modeset_lock.h>
33d78aa650SDaniel Vetter #include <drm/drm_util.h>
3443968d7bSDaniel Vetter
3543968d7bSDaniel Vetter struct drm_crtc;
369677547dSVille Syrjälä struct drm_plane_size_hint;
37fceffb32SRob Clark struct drm_printer;
3834a2ab5eSDaniel Vetter struct drm_modeset_acquire_ctx;
3943968d7bSDaniel Vetter
405c759edaSPankaj Bharadiya enum drm_scaling_filter {
415c759edaSPankaj Bharadiya DRM_SCALING_FILTER_DEFAULT,
425c759edaSPankaj Bharadiya DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
435c759edaSPankaj Bharadiya };
445c759edaSPankaj Bharadiya
4543968d7bSDaniel Vetter /**
4643968d7bSDaniel Vetter * struct drm_plane_state - mutable plane state
472e784a91SDaniel Vetter *
484087d2fbSAlyssa Rosenzweig * Please note that the destination coordinates @crtc_x, @crtc_y, @crtc_h and
492e784a91SDaniel Vetter * @crtc_w and the source coordinates @src_x, @src_y, @src_h and @src_w are the
502e784a91SDaniel Vetter * raw coordinates provided by userspace. Drivers should use
512e784a91SDaniel Vetter * drm_atomic_helper_check_plane_state() and only use the derived rectangles in
522e784a91SDaniel Vetter * @src and @dst to program the hardware.
5343968d7bSDaniel Vetter */
5443968d7bSDaniel Vetter struct drm_plane_state {
552e784a91SDaniel Vetter /** @plane: backpointer to the plane */
5643968d7bSDaniel Vetter struct drm_plane *plane;
5743968d7bSDaniel Vetter
583835b46eSGustavo Padovan /**
593835b46eSGustavo Padovan * @crtc:
603835b46eSGustavo Padovan *
61dd9d7c18SSui Jingfeng * Currently bound CRTC, NULL if disabled. Do not write this directly,
623835b46eSGustavo Padovan * use drm_atomic_set_crtc_for_plane()
633835b46eSGustavo Padovan */
643835b46eSGustavo Padovan struct drm_crtc *crtc;
6543968d7bSDaniel Vetter
663835b46eSGustavo Padovan /**
673835b46eSGustavo Padovan * @fb:
683835b46eSGustavo Padovan *
693835b46eSGustavo Padovan * Currently bound framebuffer. Do not write this directly, use
703835b46eSGustavo Padovan * drm_atomic_set_fb_for_plane()
713835b46eSGustavo Padovan */
723835b46eSGustavo Padovan struct drm_framebuffer *fb;
733835b46eSGustavo Padovan
743835b46eSGustavo Padovan /**
753835b46eSGustavo Padovan * @fence:
763835b46eSGustavo Padovan *
7730d23f22SDaniel Vetter * Optional fence to wait for before scanning out @fb. The core atomic
7830d23f22SDaniel Vetter * code will set this when userspace is using explicit fencing. Do not
791ea28bc5SChristian König * write this field directly for a driver's implicit fence.
8030d23f22SDaniel Vetter *
8130d23f22SDaniel Vetter * Drivers should store any implicit fence in this from their
8200b5497dSThomas Zimmermann * &drm_plane_helper_funcs.prepare_fb callback. See
8300b5497dSThomas Zimmermann * drm_gem_plane_helper_prepare_fb() for a suitable helper.
843835b46eSGustavo Padovan */
8543968d7bSDaniel Vetter struct dma_fence *fence;
8643968d7bSDaniel Vetter
873835b46eSGustavo Padovan /**
883835b46eSGustavo Padovan * @crtc_x:
893835b46eSGustavo Padovan *
903835b46eSGustavo Padovan * Left position of visible portion of plane on crtc, signed dest
913835b46eSGustavo Padovan * location allows it to be partially off screen.
923835b46eSGustavo Padovan */
933835b46eSGustavo Padovan
943835b46eSGustavo Padovan int32_t crtc_x;
953835b46eSGustavo Padovan /**
963835b46eSGustavo Padovan * @crtc_y:
973835b46eSGustavo Padovan *
983835b46eSGustavo Padovan * Upper position of visible portion of plane on crtc, signed dest
993835b46eSGustavo Padovan * location allows it to be partially off screen.
1003835b46eSGustavo Padovan */
1013835b46eSGustavo Padovan int32_t crtc_y;
1023835b46eSGustavo Padovan
1032e784a91SDaniel Vetter /** @crtc_w: width of visible portion of plane on crtc */
1042e784a91SDaniel Vetter /** @crtc_h: height of visible portion of plane on crtc */
10543968d7bSDaniel Vetter uint32_t crtc_w, crtc_h;
10643968d7bSDaniel Vetter
1072e784a91SDaniel Vetter /**
1082e784a91SDaniel Vetter * @src_x: left position of visible portion of plane within plane (in
1092e784a91SDaniel Vetter * 16.16 fixed point).
1102e784a91SDaniel Vetter */
1112e784a91SDaniel Vetter uint32_t src_x;
1122e784a91SDaniel Vetter /**
1132e784a91SDaniel Vetter * @src_y: upper position of visible portion of plane within plane (in
1142e784a91SDaniel Vetter * 16.16 fixed point).
1152e784a91SDaniel Vetter */
1162e784a91SDaniel Vetter uint32_t src_y;
1172e784a91SDaniel Vetter /** @src_w: width of visible portion of plane (in 16.16) */
1182e784a91SDaniel Vetter /** @src_h: height of visible portion of plane (in 16.16) */
11943968d7bSDaniel Vetter uint32_t src_h, src_w;
12043968d7bSDaniel Vetter
1218f7179a1SZack Rusin /** @hotspot_x: x offset to mouse cursor hotspot */
1228f7179a1SZack Rusin /** @hotspot_y: y offset to mouse cursor hotspot */
1238f7179a1SZack Rusin int32_t hotspot_x, hotspot_y;
1248f7179a1SZack Rusin
1252e784a91SDaniel Vetter /**
1262e784a91SDaniel Vetter * @alpha:
1272e784a91SDaniel Vetter * Opacity of the plane with 0 as completely transparent and 0xffff as
1282e784a91SDaniel Vetter * completely opaque. See drm_plane_create_alpha_property() for more
1292e784a91SDaniel Vetter * details.
1302e784a91SDaniel Vetter */
131ae0e2826SMaxime Ripard u16 alpha;
132b972ceceSSean Paul
133b972ceceSSean Paul /**
134b972ceceSSean Paul * @pixel_blend_mode:
135b972ceceSSean Paul * The alpha blending equation selection, describing how the pixels from
136b972ceceSSean Paul * the current plane are composited with the background. Value can be
137b972ceceSSean Paul * one of DRM_MODE_BLEND_*
138b972ceceSSean Paul */
139a5ec8332SLowry Li uint16_t pixel_blend_mode;
140ae0e2826SMaxime Ripard
1412e784a91SDaniel Vetter /**
1422e784a91SDaniel Vetter * @rotation:
1432e784a91SDaniel Vetter * Rotation of the plane. See drm_plane_create_rotation_property() for
1442e784a91SDaniel Vetter * more details.
1452e784a91SDaniel Vetter */
14643968d7bSDaniel Vetter unsigned int rotation;
14743968d7bSDaniel Vetter
1482e784a91SDaniel Vetter /**
1492e784a91SDaniel Vetter * @zpos:
1502e784a91SDaniel Vetter * Priority of the given plane on crtc (optional).
1512e784a91SDaniel Vetter *
1528f6ea27bSSimon Ser * User-space may set mutable zpos properties so that multiple active
1538f6ea27bSSimon Ser * planes on the same CRTC have identical zpos values. This is a
1548f6ea27bSSimon Ser * user-space bug, but drivers can solve the conflict by comparing the
1558f6ea27bSSimon Ser * plane object IDs; the plane with a higher ID is stacked on top of a
1568f6ea27bSSimon Ser * plane with a lower ID.
1572e784a91SDaniel Vetter *
1582e784a91SDaniel Vetter * See drm_plane_create_zpos_property() and
1592e784a91SDaniel Vetter * drm_plane_create_zpos_immutable_property() for more details.
1602e784a91SDaniel Vetter */
16143968d7bSDaniel Vetter unsigned int zpos;
1622e784a91SDaniel Vetter
1632e784a91SDaniel Vetter /**
1642e784a91SDaniel Vetter * @normalized_zpos:
1652e784a91SDaniel Vetter * Normalized value of zpos: unique, range from 0 to N-1 where N is the
1662e784a91SDaniel Vetter * number of active planes for given crtc. Note that the driver must set
1672e784a91SDaniel Vetter * &drm_mode_config.normalize_zpos or call drm_atomic_normalize_zpos() to
1682e784a91SDaniel Vetter * update this before it can be trusted.
1692e784a91SDaniel Vetter */
17043968d7bSDaniel Vetter unsigned int normalized_zpos;
17143968d7bSDaniel Vetter
17280f690e9SJyri Sarha /**
17380f690e9SJyri Sarha * @color_encoding:
17480f690e9SJyri Sarha *
17580f690e9SJyri Sarha * Color encoding for non RGB formats
17680f690e9SJyri Sarha */
17780f690e9SJyri Sarha enum drm_color_encoding color_encoding;
17880f690e9SJyri Sarha
17980f690e9SJyri Sarha /**
18080f690e9SJyri Sarha * @color_range:
18180f690e9SJyri Sarha *
18280f690e9SJyri Sarha * Color range for non RGB formats
18380f690e9SJyri Sarha */
18480f690e9SJyri Sarha enum drm_color_range color_range;
18580f690e9SJyri Sarha
186d3b21767SLukasz Spintzyk /**
187d3b21767SLukasz Spintzyk * @fb_damage_clips:
188d3b21767SLukasz Spintzyk *
189d3b21767SLukasz Spintzyk * Blob representing damage (area in plane framebuffer that changed
190d3b21767SLukasz Spintzyk * since last plane update) as an array of &drm_mode_rect in framebuffer
191d3b21767SLukasz Spintzyk * coodinates of the attached framebuffer. Note that unlike plane src,
192d3b21767SLukasz Spintzyk * damage clips are not in 16.16 fixed point.
1936f11f374SDaniel Vetter *
1946f11f374SDaniel Vetter * See drm_plane_get_damage_clips() and
1956f11f374SDaniel Vetter * drm_plane_get_damage_clips_count() for accessing these.
196d3b21767SLukasz Spintzyk */
197d3b21767SLukasz Spintzyk struct drm_property_blob *fb_damage_clips;
198d3b21767SLukasz Spintzyk
199fec74874SMaarten Lankhorst /**
20035ed38d5SJavier Martinez Canillas * @ignore_damage_clips:
20135ed38d5SJavier Martinez Canillas *
20235ed38d5SJavier Martinez Canillas * Set by drivers to indicate the drm_atomic_helper_damage_iter_init()
20335ed38d5SJavier Martinez Canillas * helper that the @fb_damage_clips blob property should be ignored.
20435ed38d5SJavier Martinez Canillas *
20535ed38d5SJavier Martinez Canillas * See :ref:`damage_tracking_properties` for more information.
20635ed38d5SJavier Martinez Canillas */
20735ed38d5SJavier Martinez Canillas bool ignore_damage_clips;
20835ed38d5SJavier Martinez Canillas
20935ed38d5SJavier Martinez Canillas /**
210fec74874SMaarten Lankhorst * @src:
211fec74874SMaarten Lankhorst *
212fec74874SMaarten Lankhorst * source coordinates of the plane (in 16.16).
213fec74874SMaarten Lankhorst *
214fec74874SMaarten Lankhorst * When using drm_atomic_helper_check_plane_state(),
215fec74874SMaarten Lankhorst * the coordinates are clipped, but the driver may choose
216fec74874SMaarten Lankhorst * to use unclipped coordinates instead when the hardware
217fec74874SMaarten Lankhorst * performs the clipping automatically.
218fec74874SMaarten Lankhorst */
219fec74874SMaarten Lankhorst /**
220fec74874SMaarten Lankhorst * @dst:
221fec74874SMaarten Lankhorst *
222fec74874SMaarten Lankhorst * clipped destination coordinates of the plane.
223fec74874SMaarten Lankhorst *
224fec74874SMaarten Lankhorst * When using drm_atomic_helper_check_plane_state(),
225fec74874SMaarten Lankhorst * the coordinates are clipped, but the driver may choose
226fec74874SMaarten Lankhorst * to use unclipped coordinates instead when the hardware
227fec74874SMaarten Lankhorst * performs the clipping automatically.
228fec74874SMaarten Lankhorst */
22943968d7bSDaniel Vetter struct drm_rect src, dst;
23043968d7bSDaniel Vetter
2313835b46eSGustavo Padovan /**
2323835b46eSGustavo Padovan * @visible:
2333835b46eSGustavo Padovan *
2343835b46eSGustavo Padovan * Visibility of the plane. This can be false even if fb!=NULL and
2353835b46eSGustavo Padovan * crtc!=NULL, due to clipping.
23643968d7bSDaniel Vetter */
23743968d7bSDaniel Vetter bool visible;
23843968d7bSDaniel Vetter
23921a01abbSMaarten Lankhorst /**
2405c759edaSPankaj Bharadiya * @scaling_filter:
2415c759edaSPankaj Bharadiya *
2425c759edaSPankaj Bharadiya * Scaling filter to be applied
2435c759edaSPankaj Bharadiya */
2445c759edaSPankaj Bharadiya enum drm_scaling_filter scaling_filter;
2455c759edaSPankaj Bharadiya
2465c759edaSPankaj Bharadiya /**
247669c9215SMaarten Lankhorst * @commit: Tracks the pending commit to prevent use-after-free conditions,
248669c9215SMaarten Lankhorst * and for async plane updates.
24921a01abbSMaarten Lankhorst *
250669c9215SMaarten Lankhorst * May be NULL.
25121a01abbSMaarten Lankhorst */
25221a01abbSMaarten Lankhorst struct drm_crtc_commit *commit;
25321a01abbSMaarten Lankhorst
2542e784a91SDaniel Vetter /** @state: backpointer to global drm_atomic_state */
25543968d7bSDaniel Vetter struct drm_atomic_state *state;
25624013b93SMelissa Wen
25724013b93SMelissa Wen /**
25824013b93SMelissa Wen * @color_mgmt_changed: Color management properties have changed. Used
25924013b93SMelissa Wen * by the atomic helpers and drivers to steer the atomic commit control
26024013b93SMelissa Wen * flow.
26124013b93SMelissa Wen */
26224013b93SMelissa Wen bool color_mgmt_changed : 1;
26343968d7bSDaniel Vetter };
26443968d7bSDaniel Vetter
2651638d30cSRob Clark static inline struct drm_rect
drm_plane_state_src(const struct drm_plane_state * state)2661638d30cSRob Clark drm_plane_state_src(const struct drm_plane_state *state)
2671638d30cSRob Clark {
2681638d30cSRob Clark struct drm_rect src = {
2691638d30cSRob Clark .x1 = state->src_x,
2701638d30cSRob Clark .y1 = state->src_y,
2711638d30cSRob Clark .x2 = state->src_x + state->src_w,
2721638d30cSRob Clark .y2 = state->src_y + state->src_h,
2731638d30cSRob Clark };
2741638d30cSRob Clark return src;
2751638d30cSRob Clark }
2761638d30cSRob Clark
2771638d30cSRob Clark static inline struct drm_rect
drm_plane_state_dest(const struct drm_plane_state * state)2781638d30cSRob Clark drm_plane_state_dest(const struct drm_plane_state *state)
2791638d30cSRob Clark {
2801638d30cSRob Clark struct drm_rect dest = {
2811638d30cSRob Clark .x1 = state->crtc_x,
2821638d30cSRob Clark .y1 = state->crtc_y,
2831638d30cSRob Clark .x2 = state->crtc_x + state->crtc_w,
2841638d30cSRob Clark .y2 = state->crtc_y + state->crtc_h,
2851638d30cSRob Clark };
2861638d30cSRob Clark return dest;
2871638d30cSRob Clark }
2881638d30cSRob Clark
28943968d7bSDaniel Vetter /**
29043968d7bSDaniel Vetter * struct drm_plane_funcs - driver plane control functions
29143968d7bSDaniel Vetter */
29243968d7bSDaniel Vetter struct drm_plane_funcs {
29343968d7bSDaniel Vetter /**
29443968d7bSDaniel Vetter * @update_plane:
29543968d7bSDaniel Vetter *
29643968d7bSDaniel Vetter * This is the legacy entry point to enable and configure the plane for
29743968d7bSDaniel Vetter * the given CRTC and framebuffer. It is never called to disable the
29843968d7bSDaniel Vetter * plane, i.e. the passed-in crtc and fb paramters are never NULL.
29943968d7bSDaniel Vetter *
30043968d7bSDaniel Vetter * The source rectangle in frame buffer memory coordinates is given by
30143968d7bSDaniel Vetter * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point
30243968d7bSDaniel Vetter * values). Devices that don't support subpixel plane coordinates can
30343968d7bSDaniel Vetter * ignore the fractional part.
30443968d7bSDaniel Vetter *
30543968d7bSDaniel Vetter * The destination rectangle in CRTC coordinates is given by the
30643968d7bSDaniel Vetter * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values).
30743968d7bSDaniel Vetter * Devices scale the source rectangle to the destination rectangle. If
30843968d7bSDaniel Vetter * scaling is not supported, and the source rectangle size doesn't match
30943968d7bSDaniel Vetter * the destination rectangle size, the driver must return a
31043968d7bSDaniel Vetter * -<errorname>EINVAL</errorname> error.
31143968d7bSDaniel Vetter *
31243968d7bSDaniel Vetter * Drivers implementing atomic modeset should use
31343968d7bSDaniel Vetter * drm_atomic_helper_update_plane() to implement this hook.
31443968d7bSDaniel Vetter *
31543968d7bSDaniel Vetter * RETURNS:
31643968d7bSDaniel Vetter *
31743968d7bSDaniel Vetter * 0 on success or a negative error code on failure.
31843968d7bSDaniel Vetter */
31943968d7bSDaniel Vetter int (*update_plane)(struct drm_plane *plane,
32043968d7bSDaniel Vetter struct drm_crtc *crtc, struct drm_framebuffer *fb,
32143968d7bSDaniel Vetter int crtc_x, int crtc_y,
32243968d7bSDaniel Vetter unsigned int crtc_w, unsigned int crtc_h,
32343968d7bSDaniel Vetter uint32_t src_x, uint32_t src_y,
32434a2ab5eSDaniel Vetter uint32_t src_w, uint32_t src_h,
32534a2ab5eSDaniel Vetter struct drm_modeset_acquire_ctx *ctx);
32643968d7bSDaniel Vetter
32743968d7bSDaniel Vetter /**
32843968d7bSDaniel Vetter * @disable_plane:
32943968d7bSDaniel Vetter *
33043968d7bSDaniel Vetter * This is the legacy entry point to disable the plane. The DRM core
33143968d7bSDaniel Vetter * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call
33243968d7bSDaniel Vetter * with the frame buffer ID set to 0. Disabled planes must not be
33343968d7bSDaniel Vetter * processed by the CRTC.
33443968d7bSDaniel Vetter *
33543968d7bSDaniel Vetter * Drivers implementing atomic modeset should use
33643968d7bSDaniel Vetter * drm_atomic_helper_disable_plane() to implement this hook.
33743968d7bSDaniel Vetter *
33843968d7bSDaniel Vetter * RETURNS:
33943968d7bSDaniel Vetter *
34043968d7bSDaniel Vetter * 0 on success or a negative error code on failure.
34143968d7bSDaniel Vetter */
34219315294SDaniel Vetter int (*disable_plane)(struct drm_plane *plane,
34319315294SDaniel Vetter struct drm_modeset_acquire_ctx *ctx);
34443968d7bSDaniel Vetter
34543968d7bSDaniel Vetter /**
34643968d7bSDaniel Vetter * @destroy:
34743968d7bSDaniel Vetter *
34843968d7bSDaniel Vetter * Clean up plane resources. This is only called at driver unload time
34943968d7bSDaniel Vetter * through drm_mode_config_cleanup() since a plane cannot be hotplugged
35043968d7bSDaniel Vetter * in DRM.
35143968d7bSDaniel Vetter */
35243968d7bSDaniel Vetter void (*destroy)(struct drm_plane *plane);
35343968d7bSDaniel Vetter
35443968d7bSDaniel Vetter /**
35543968d7bSDaniel Vetter * @reset:
35643968d7bSDaniel Vetter *
35743968d7bSDaniel Vetter * Reset plane hardware and software state to off. This function isn't
35843968d7bSDaniel Vetter * called by the core directly, only through drm_mode_config_reset().
35943968d7bSDaniel Vetter * It's not a helper hook only for historical reasons.
36043968d7bSDaniel Vetter *
36143968d7bSDaniel Vetter * Atomic drivers can use drm_atomic_helper_plane_reset() to reset
36243968d7bSDaniel Vetter * atomic state using this hook.
36343968d7bSDaniel Vetter */
36443968d7bSDaniel Vetter void (*reset)(struct drm_plane *plane);
36543968d7bSDaniel Vetter
36643968d7bSDaniel Vetter /**
36743968d7bSDaniel Vetter * @set_property:
36843968d7bSDaniel Vetter *
36943968d7bSDaniel Vetter * This is the legacy entry point to update a property attached to the
37043968d7bSDaniel Vetter * plane.
37143968d7bSDaniel Vetter *
37243968d7bSDaniel Vetter * This callback is optional if the driver does not support any legacy
373144a7999SDaniel Vetter * driver-private properties. For atomic drivers it is not used because
374144a7999SDaniel Vetter * property handling is done entirely in the DRM core.
37543968d7bSDaniel Vetter *
37643968d7bSDaniel Vetter * RETURNS:
37743968d7bSDaniel Vetter *
37843968d7bSDaniel Vetter * 0 on success or a negative error code on failure.
37943968d7bSDaniel Vetter */
38043968d7bSDaniel Vetter int (*set_property)(struct drm_plane *plane,
38143968d7bSDaniel Vetter struct drm_property *property, uint64_t val);
38243968d7bSDaniel Vetter
38343968d7bSDaniel Vetter /**
38443968d7bSDaniel Vetter * @atomic_duplicate_state:
38543968d7bSDaniel Vetter *
38643968d7bSDaniel Vetter * Duplicate the current atomic state for this plane and return it.
387d574528aSDaniel Vetter * The core and helpers guarantee that any atomic state duplicated with
38843968d7bSDaniel Vetter * this hook and still owned by the caller (i.e. not transferred to the
389d574528aSDaniel Vetter * driver by calling &drm_mode_config_funcs.atomic_commit) will be
390d574528aSDaniel Vetter * cleaned up by calling the @atomic_destroy_state hook in this
391d574528aSDaniel Vetter * structure.
39243968d7bSDaniel Vetter *
393ba1f665fSHaneen Mohammed * This callback is mandatory for atomic drivers.
394ba1f665fSHaneen Mohammed *
395ea0dd85aSDaniel Vetter * Atomic drivers which don't subclass &struct drm_plane_state should use
39643968d7bSDaniel Vetter * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the
39743968d7bSDaniel Vetter * state structure to extend it with driver-private state should use
39843968d7bSDaniel Vetter * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is
39943968d7bSDaniel Vetter * duplicated in a consistent fashion across drivers.
40043968d7bSDaniel Vetter *
401d574528aSDaniel Vetter * It is an error to call this hook before &drm_plane.state has been
40243968d7bSDaniel Vetter * initialized correctly.
40343968d7bSDaniel Vetter *
40443968d7bSDaniel Vetter * NOTE:
40543968d7bSDaniel Vetter *
40643968d7bSDaniel Vetter * If the duplicate state references refcounted resources this hook must
40743968d7bSDaniel Vetter * acquire a reference for each of them. The driver must release these
40843968d7bSDaniel Vetter * references again in @atomic_destroy_state.
40943968d7bSDaniel Vetter *
41043968d7bSDaniel Vetter * RETURNS:
41143968d7bSDaniel Vetter *
41243968d7bSDaniel Vetter * Duplicated atomic state or NULL when the allocation failed.
41343968d7bSDaniel Vetter */
41443968d7bSDaniel Vetter struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane);
41543968d7bSDaniel Vetter
41643968d7bSDaniel Vetter /**
41743968d7bSDaniel Vetter * @atomic_destroy_state:
41843968d7bSDaniel Vetter *
41943968d7bSDaniel Vetter * Destroy a state duplicated with @atomic_duplicate_state and release
42043968d7bSDaniel Vetter * or unreference all resources it references
421ba1f665fSHaneen Mohammed *
422ba1f665fSHaneen Mohammed * This callback is mandatory for atomic drivers.
42343968d7bSDaniel Vetter */
42443968d7bSDaniel Vetter void (*atomic_destroy_state)(struct drm_plane *plane,
42543968d7bSDaniel Vetter struct drm_plane_state *state);
42643968d7bSDaniel Vetter
42743968d7bSDaniel Vetter /**
42843968d7bSDaniel Vetter * @atomic_set_property:
42943968d7bSDaniel Vetter *
43043968d7bSDaniel Vetter * Decode a driver-private property value and store the decoded value
43143968d7bSDaniel Vetter * into the passed-in state structure. Since the atomic core decodes all
43243968d7bSDaniel Vetter * standardized properties (even for extensions beyond the core set of
43343968d7bSDaniel Vetter * properties which might not be implemented by all drivers) this
43443968d7bSDaniel Vetter * requires drivers to subclass the state structure.
43543968d7bSDaniel Vetter *
43643968d7bSDaniel Vetter * Such driver-private properties should really only be implemented for
43743968d7bSDaniel Vetter * truly hardware/vendor specific state. Instead it is preferred to
43843968d7bSDaniel Vetter * standardize atomic extension and decode the properties used to expose
43943968d7bSDaniel Vetter * such an extension in the core.
44043968d7bSDaniel Vetter *
44143968d7bSDaniel Vetter * Do not call this function directly, use
44243968d7bSDaniel Vetter * drm_atomic_plane_set_property() instead.
44343968d7bSDaniel Vetter *
44443968d7bSDaniel Vetter * This callback is optional if the driver does not support any
44543968d7bSDaniel Vetter * driver-private atomic properties.
44643968d7bSDaniel Vetter *
44743968d7bSDaniel Vetter * NOTE:
44843968d7bSDaniel Vetter *
44943968d7bSDaniel Vetter * This function is called in the state assembly phase of atomic
45043968d7bSDaniel Vetter * modesets, which can be aborted for any reason (including on
45143968d7bSDaniel Vetter * userspace's request to just check whether a configuration would be
45243968d7bSDaniel Vetter * possible). Drivers MUST NOT touch any persistent state (hardware or
45343968d7bSDaniel Vetter * software) or data structures except the passed in @state parameter.
45443968d7bSDaniel Vetter *
45543968d7bSDaniel Vetter * Also since userspace controls in which order properties are set this
45643968d7bSDaniel Vetter * function must not do any input validation (since the state update is
45743968d7bSDaniel Vetter * incomplete and hence likely inconsistent). Instead any such input
45843968d7bSDaniel Vetter * validation must be done in the various atomic_check callbacks.
45943968d7bSDaniel Vetter *
46043968d7bSDaniel Vetter * RETURNS:
46143968d7bSDaniel Vetter *
46243968d7bSDaniel Vetter * 0 if the property has been found, -EINVAL if the property isn't
46343968d7bSDaniel Vetter * implemented by the driver (which shouldn't ever happen, the core only
46443968d7bSDaniel Vetter * asks for properties attached to this plane). No other validation is
46543968d7bSDaniel Vetter * allowed by the driver. The core already checks that the property
46643968d7bSDaniel Vetter * value is within the range (integer, valid enum value, ...) the driver
46743968d7bSDaniel Vetter * set when registering the property.
46843968d7bSDaniel Vetter */
46943968d7bSDaniel Vetter int (*atomic_set_property)(struct drm_plane *plane,
47043968d7bSDaniel Vetter struct drm_plane_state *state,
47143968d7bSDaniel Vetter struct drm_property *property,
47243968d7bSDaniel Vetter uint64_t val);
47343968d7bSDaniel Vetter
47443968d7bSDaniel Vetter /**
47543968d7bSDaniel Vetter * @atomic_get_property:
47643968d7bSDaniel Vetter *
47743968d7bSDaniel Vetter * Reads out the decoded driver-private property. This is used to
47843968d7bSDaniel Vetter * implement the GETPLANE IOCTL.
47943968d7bSDaniel Vetter *
48043968d7bSDaniel Vetter * Do not call this function directly, use
48143968d7bSDaniel Vetter * drm_atomic_plane_get_property() instead.
48243968d7bSDaniel Vetter *
48343968d7bSDaniel Vetter * This callback is optional if the driver does not support any
48443968d7bSDaniel Vetter * driver-private atomic properties.
48543968d7bSDaniel Vetter *
48643968d7bSDaniel Vetter * RETURNS:
48743968d7bSDaniel Vetter *
48843968d7bSDaniel Vetter * 0 on success, -EINVAL if the property isn't implemented by the
48943968d7bSDaniel Vetter * driver (which should never happen, the core only asks for
49043968d7bSDaniel Vetter * properties attached to this plane).
49143968d7bSDaniel Vetter */
49243968d7bSDaniel Vetter int (*atomic_get_property)(struct drm_plane *plane,
49343968d7bSDaniel Vetter const struct drm_plane_state *state,
49443968d7bSDaniel Vetter struct drm_property *property,
49543968d7bSDaniel Vetter uint64_t *val);
49643968d7bSDaniel Vetter /**
49743968d7bSDaniel Vetter * @late_register:
49843968d7bSDaniel Vetter *
49943968d7bSDaniel Vetter * This optional hook can be used to register additional userspace
50043968d7bSDaniel Vetter * interfaces attached to the plane like debugfs interfaces.
50143968d7bSDaniel Vetter * It is called late in the driver load sequence from drm_dev_register().
50243968d7bSDaniel Vetter * Everything added from this callback should be unregistered in
50343968d7bSDaniel Vetter * the early_unregister callback.
50443968d7bSDaniel Vetter *
50543968d7bSDaniel Vetter * Returns:
50643968d7bSDaniel Vetter *
50743968d7bSDaniel Vetter * 0 on success, or a negative error code on failure.
50843968d7bSDaniel Vetter */
50943968d7bSDaniel Vetter int (*late_register)(struct drm_plane *plane);
51043968d7bSDaniel Vetter
51143968d7bSDaniel Vetter /**
51243968d7bSDaniel Vetter * @early_unregister:
51343968d7bSDaniel Vetter *
51443968d7bSDaniel Vetter * This optional hook should be used to unregister the additional
51543968d7bSDaniel Vetter * userspace interfaces attached to the plane from
516559bdaf7SDaniel Vetter * @late_register. It is called from drm_dev_unregister(),
51743968d7bSDaniel Vetter * early in the driver unload sequence to disable userspace access
51843968d7bSDaniel Vetter * before data structures are torndown.
51943968d7bSDaniel Vetter */
52043968d7bSDaniel Vetter void (*early_unregister)(struct drm_plane *plane);
521fceffb32SRob Clark
522fceffb32SRob Clark /**
523fceffb32SRob Clark * @atomic_print_state:
524fceffb32SRob Clark *
525ea0dd85aSDaniel Vetter * If driver subclasses &struct drm_plane_state, it should implement
526fceffb32SRob Clark * this optional hook for printing additional driver specific state.
527fceffb32SRob Clark *
528fceffb32SRob Clark * Do not call this directly, use drm_atomic_plane_print_state()
529fceffb32SRob Clark * instead.
530fceffb32SRob Clark */
531fceffb32SRob Clark void (*atomic_print_state)(struct drm_printer *p,
532fceffb32SRob Clark const struct drm_plane_state *state);
533e6fc3b68SBen Widawsky
534e6fc3b68SBen Widawsky /**
535e6fc3b68SBen Widawsky * @format_mod_supported:
536e6fc3b68SBen Widawsky *
537e6fc3b68SBen Widawsky * This optional hook is used for the DRM to determine if the given
538e6fc3b68SBen Widawsky * format/modifier combination is valid for the plane. This allows the
539e6fc3b68SBen Widawsky * DRM to generate the correct format bitmask (which formats apply to
54091d85313SJosé Expósito * which modifier), and to validate modifiers at atomic_check time.
5418fb756dfSEric Anholt *
5428fb756dfSEric Anholt * If not present, then any modifier in the plane's modifier
5438fb756dfSEric Anholt * list is allowed with any of the plane's formats.
544e6fc3b68SBen Widawsky *
545e6fc3b68SBen Widawsky * Returns:
546e6fc3b68SBen Widawsky *
547e6fc3b68SBen Widawsky * True if the given modifier is valid for that format on the plane.
548e6fc3b68SBen Widawsky * False otherwise.
549e6fc3b68SBen Widawsky */
550e6fc3b68SBen Widawsky bool (*format_mod_supported)(struct drm_plane *plane, uint32_t format,
551e6fc3b68SBen Widawsky uint64_t modifier);
55243968d7bSDaniel Vetter };
55343968d7bSDaniel Vetter
554532b3671SDaniel Vetter /**
555532b3671SDaniel Vetter * enum drm_plane_type - uapi plane type enumeration
556532b3671SDaniel Vetter *
557532b3671SDaniel Vetter * For historical reasons not all planes are made the same. This enumeration is
558532b3671SDaniel Vetter * used to tell the different types of planes apart to implement the different
559532b3671SDaniel Vetter * uapi semantics for them. For userspace which is universal plane aware and
560532b3671SDaniel Vetter * which is using that atomic IOCTL there's no difference between these planes
561532b3671SDaniel Vetter * (beyong what the driver and hardware can support of course).
562532b3671SDaniel Vetter *
563532b3671SDaniel Vetter * For compatibility with legacy userspace, only overlay planes are made
564532b3671SDaniel Vetter * available to userspace by default. Userspace clients may set the
5657e5d1e12SSimon Ser * &DRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate that they
566532b3671SDaniel Vetter * wish to receive a universal plane list containing all plane types. See also
567532b3671SDaniel Vetter * drm_for_each_legacy_plane().
568226714dcSDaniel Vetter *
5697e5d1e12SSimon Ser * In addition to setting each plane's type, drivers need to setup the
5707e5d1e12SSimon Ser * &drm_crtc.primary and optionally &drm_crtc.cursor pointers for legacy
5717e5d1e12SSimon Ser * IOCTLs. See drm_crtc_init_with_planes().
5727e5d1e12SSimon Ser *
573226714dcSDaniel Vetter * WARNING: The values of this enum is UABI since they're exposed in the "type"
574226714dcSDaniel Vetter * property.
575532b3671SDaniel Vetter */
57643968d7bSDaniel Vetter enum drm_plane_type {
577532b3671SDaniel Vetter /**
578226714dcSDaniel Vetter * @DRM_PLANE_TYPE_OVERLAY:
579226714dcSDaniel Vetter *
580226714dcSDaniel Vetter * Overlay planes represent all non-primary, non-cursor planes. Some
581226714dcSDaniel Vetter * drivers refer to these types of planes as "sprites" internally.
582226714dcSDaniel Vetter */
583226714dcSDaniel Vetter DRM_PLANE_TYPE_OVERLAY,
584226714dcSDaniel Vetter
585226714dcSDaniel Vetter /**
586532b3671SDaniel Vetter * @DRM_PLANE_TYPE_PRIMARY:
587532b3671SDaniel Vetter *
5887e5d1e12SSimon Ser * A primary plane attached to a CRTC is the most likely to be able to
5897e5d1e12SSimon Ser * light up the CRTC when no scaling/cropping is used and the plane
5907e5d1e12SSimon Ser * covers the whole CRTC.
591532b3671SDaniel Vetter */
59243968d7bSDaniel Vetter DRM_PLANE_TYPE_PRIMARY,
593532b3671SDaniel Vetter
594532b3671SDaniel Vetter /**
595532b3671SDaniel Vetter * @DRM_PLANE_TYPE_CURSOR:
596532b3671SDaniel Vetter *
5977e5d1e12SSimon Ser * A cursor plane attached to a CRTC is more likely to be able to be
5987e5d1e12SSimon Ser * enabled when no scaling/cropping is used and the framebuffer has the
5997e5d1e12SSimon Ser * size indicated by &drm_mode_config.cursor_width and
6007e5d1e12SSimon Ser * &drm_mode_config.cursor_height. Additionally, if the driver doesn't
6017e5d1e12SSimon Ser * support modifiers, the framebuffer should have a linear layout.
602532b3671SDaniel Vetter */
60343968d7bSDaniel Vetter DRM_PLANE_TYPE_CURSOR,
60443968d7bSDaniel Vetter };
60543968d7bSDaniel Vetter
60643968d7bSDaniel Vetter
60743968d7bSDaniel Vetter /**
60843968d7bSDaniel Vetter * struct drm_plane - central DRM plane control structure
609268bc24eSDaniel Vetter *
610268bc24eSDaniel Vetter * Planes represent the scanout hardware of a display block. They receive their
611268bc24eSDaniel Vetter * input data from a &drm_framebuffer and feed it to a &drm_crtc. Planes control
612268bc24eSDaniel Vetter * the color conversion, see `Plane Composition Properties`_ for more details,
613268bc24eSDaniel Vetter * and are also involved in the color conversion of input pixels, see `Color
614268bc24eSDaniel Vetter * Management Properties`_ for details on that.
61543968d7bSDaniel Vetter */
61643968d7bSDaniel Vetter struct drm_plane {
617268bc24eSDaniel Vetter /** @dev: DRM device this plane belongs to */
61843968d7bSDaniel Vetter struct drm_device *dev;
619268bc24eSDaniel Vetter
620268bc24eSDaniel Vetter /**
621268bc24eSDaniel Vetter * @head:
622268bc24eSDaniel Vetter *
623268bc24eSDaniel Vetter * List of all planes on @dev, linked from &drm_mode_config.plane_list.
624268bc24eSDaniel Vetter * Invariant over the lifetime of @dev and therefore does not need
625268bc24eSDaniel Vetter * locking.
626268bc24eSDaniel Vetter */
62743968d7bSDaniel Vetter struct list_head head;
62843968d7bSDaniel Vetter
629268bc24eSDaniel Vetter /** @name: human readable name, can be overwritten by the driver */
63043968d7bSDaniel Vetter char *name;
63143968d7bSDaniel Vetter
63243968d7bSDaniel Vetter /**
63343968d7bSDaniel Vetter * @mutex:
63443968d7bSDaniel Vetter *
635d574528aSDaniel Vetter * Protects modeset plane state, together with the &drm_crtc.mutex of
636d574528aSDaniel Vetter * CRTC this plane is linked to (when active, getting activated or
637d574528aSDaniel Vetter * getting disabled).
638c9e42b72SDaniel Vetter *
639c9e42b72SDaniel Vetter * For atomic drivers specifically this protects @state.
64043968d7bSDaniel Vetter */
64143968d7bSDaniel Vetter struct drm_modeset_lock mutex;
64243968d7bSDaniel Vetter
643268bc24eSDaniel Vetter /** @base: base mode object */
64443968d7bSDaniel Vetter struct drm_mode_object base;
64543968d7bSDaniel Vetter
646268bc24eSDaniel Vetter /**
647268bc24eSDaniel Vetter * @possible_crtcs: pipes this plane can be bound to constructed from
648268bc24eSDaniel Vetter * drm_crtc_mask()
649268bc24eSDaniel Vetter */
65043968d7bSDaniel Vetter uint32_t possible_crtcs;
651268bc24eSDaniel Vetter /** @format_types: array of formats supported by this plane */
65243968d7bSDaniel Vetter uint32_t *format_types;
653268bc24eSDaniel Vetter /** @format_count: Size of the array pointed at by @format_types. */
65443968d7bSDaniel Vetter unsigned int format_count;
655268bc24eSDaniel Vetter /**
656268bc24eSDaniel Vetter * @format_default: driver hasn't supplied supported formats for the
6577221941cSThomas Zimmermann * plane. Used by the non-atomic driver compatibility wrapper only.
658268bc24eSDaniel Vetter */
65943968d7bSDaniel Vetter bool format_default;
66043968d7bSDaniel Vetter
661268bc24eSDaniel Vetter /** @modifiers: array of modifiers supported by this plane */
662e6fc3b68SBen Widawsky uint64_t *modifiers;
663268bc24eSDaniel Vetter /** @modifier_count: Size of the array pointed at by @modifier_count. */
664e6fc3b68SBen Widawsky unsigned int modifier_count;
665e6fc3b68SBen Widawsky
6662e2b96efSDaniel Vetter /**
667268bc24eSDaniel Vetter * @crtc:
668268bc24eSDaniel Vetter *
669268bc24eSDaniel Vetter * Currently bound CRTC, only meaningful for non-atomic drivers. For
670268bc24eSDaniel Vetter * atomic drivers this is forced to be NULL, atomic drivers should
671268bc24eSDaniel Vetter * instead check &drm_plane_state.crtc.
6722e2b96efSDaniel Vetter */
67343968d7bSDaniel Vetter struct drm_crtc *crtc;
6742e2b96efSDaniel Vetter
6752e2b96efSDaniel Vetter /**
676268bc24eSDaniel Vetter * @fb:
677268bc24eSDaniel Vetter *
678268bc24eSDaniel Vetter * Currently bound framebuffer, only meaningful for non-atomic drivers.
679268bc24eSDaniel Vetter * For atomic drivers this is forced to be NULL, atomic drivers should
680268bc24eSDaniel Vetter * instead check &drm_plane_state.fb.
6812e2b96efSDaniel Vetter */
68243968d7bSDaniel Vetter struct drm_framebuffer *fb;
68343968d7bSDaniel Vetter
684268bc24eSDaniel Vetter /**
685268bc24eSDaniel Vetter * @old_fb:
686268bc24eSDaniel Vetter *
687268bc24eSDaniel Vetter * Temporary tracking of the old fb while a modeset is ongoing. Only
688268bc24eSDaniel Vetter * used by non-atomic drivers, forced to be NULL for atomic drivers.
689268bc24eSDaniel Vetter */
69043968d7bSDaniel Vetter struct drm_framebuffer *old_fb;
69143968d7bSDaniel Vetter
692268bc24eSDaniel Vetter /** @funcs: plane control functions */
69343968d7bSDaniel Vetter const struct drm_plane_funcs *funcs;
69443968d7bSDaniel Vetter
695268bc24eSDaniel Vetter /** @properties: property tracking for this plane */
69643968d7bSDaniel Vetter struct drm_object_properties properties;
69743968d7bSDaniel Vetter
698268bc24eSDaniel Vetter /** @type: Type of plane, see &enum drm_plane_type for details. */
69943968d7bSDaniel Vetter enum drm_plane_type type;
70043968d7bSDaniel Vetter
70143968d7bSDaniel Vetter /**
70243968d7bSDaniel Vetter * @index: Position inside the mode_config.list, can be used as an array
70343968d7bSDaniel Vetter * index. It is invariant over the lifetime of the plane.
70443968d7bSDaniel Vetter */
70543968d7bSDaniel Vetter unsigned index;
70643968d7bSDaniel Vetter
707268bc24eSDaniel Vetter /** @helper_private: mid-layer private data */
70843968d7bSDaniel Vetter const struct drm_plane_helper_funcs *helper_private;
70943968d7bSDaniel Vetter
710c9e42b72SDaniel Vetter /**
711c9e42b72SDaniel Vetter * @state:
712c9e42b72SDaniel Vetter *
713c9e42b72SDaniel Vetter * Current atomic state for this plane.
714c9e42b72SDaniel Vetter *
715c9e42b72SDaniel Vetter * This is protected by @mutex. Note that nonblocking atomic commits
716c9e42b72SDaniel Vetter * access the current plane state without taking locks. Either by going
717c9e42b72SDaniel Vetter * through the &struct drm_atomic_state pointers, see
71877ac3b00SMaarten Lankhorst * for_each_oldnew_plane_in_state(), for_each_old_plane_in_state() and
71977ac3b00SMaarten Lankhorst * for_each_new_plane_in_state(). Or through careful ordering of atomic
72077ac3b00SMaarten Lankhorst * commit operations as implemented in the atomic helpers, see
72177ac3b00SMaarten Lankhorst * &struct drm_crtc_commit.
722c9e42b72SDaniel Vetter */
72343968d7bSDaniel Vetter struct drm_plane_state *state;
72443968d7bSDaniel Vetter
725268bc24eSDaniel Vetter /**
726268bc24eSDaniel Vetter * @alpha_property:
727268bc24eSDaniel Vetter * Optional alpha property for this plane. See
728268bc24eSDaniel Vetter * drm_plane_create_alpha_property().
729268bc24eSDaniel Vetter */
730ae0e2826SMaxime Ripard struct drm_property *alpha_property;
731268bc24eSDaniel Vetter /**
732268bc24eSDaniel Vetter * @zpos_property:
733268bc24eSDaniel Vetter * Optional zpos property for this plane. See
734268bc24eSDaniel Vetter * drm_plane_create_zpos_property().
735268bc24eSDaniel Vetter */
73643968d7bSDaniel Vetter struct drm_property *zpos_property;
737268bc24eSDaniel Vetter /**
738268bc24eSDaniel Vetter * @rotation_property:
739268bc24eSDaniel Vetter * Optional rotation property for this plane. See
740268bc24eSDaniel Vetter * drm_plane_create_rotation_property().
741268bc24eSDaniel Vetter */
742d138dd3cSVille Syrjälä struct drm_property *rotation_property;
743a5ec8332SLowry Li /**
744a5ec8332SLowry Li * @blend_mode_property:
745a5ec8332SLowry Li * Optional "pixel blend mode" enum property for this plane.
746a5ec8332SLowry Li * Blend mode property represents the alpha blending equation selection,
747a5ec8332SLowry Li * describing how the pixels from the current plane are composited with
748a5ec8332SLowry Li * the background.
749a5ec8332SLowry Li */
750a5ec8332SLowry Li struct drm_property *blend_mode_property;
75180f690e9SJyri Sarha
75280f690e9SJyri Sarha /**
75380f690e9SJyri Sarha * @color_encoding_property:
75480f690e9SJyri Sarha *
75580f690e9SJyri Sarha * Optional "COLOR_ENCODING" enum property for specifying
75680f690e9SJyri Sarha * color encoding for non RGB formats.
75780f690e9SJyri Sarha * See drm_plane_create_color_properties().
75880f690e9SJyri Sarha */
75980f690e9SJyri Sarha struct drm_property *color_encoding_property;
76080f690e9SJyri Sarha /**
76180f690e9SJyri Sarha * @color_range_property:
76280f690e9SJyri Sarha *
76380f690e9SJyri Sarha * Optional "COLOR_RANGE" enum property for specifying
76480f690e9SJyri Sarha * color range for non RGB formats.
76580f690e9SJyri Sarha * See drm_plane_create_color_properties().
76680f690e9SJyri Sarha */
76780f690e9SJyri Sarha struct drm_property *color_range_property;
7685c759edaSPankaj Bharadiya
7695c759edaSPankaj Bharadiya /**
7705c759edaSPankaj Bharadiya * @scaling_filter_property: property to apply a particular filter while
7715c759edaSPankaj Bharadiya * scaling.
7725c759edaSPankaj Bharadiya */
7735c759edaSPankaj Bharadiya struct drm_property *scaling_filter_property;
7748f7179a1SZack Rusin
7758f7179a1SZack Rusin /**
7768f7179a1SZack Rusin * @hotspot_x_property: property to set mouse hotspot x offset.
7778f7179a1SZack Rusin */
7788f7179a1SZack Rusin struct drm_property *hotspot_x_property;
7798f7179a1SZack Rusin
7808f7179a1SZack Rusin /**
7818f7179a1SZack Rusin * @hotspot_y_property: property to set mouse hotspot y offset.
7828f7179a1SZack Rusin */
7838f7179a1SZack Rusin struct drm_property *hotspot_y_property;
784bf9fb17cSJocelyn Falempe
785bf9fb17cSJocelyn Falempe /**
786bf9fb17cSJocelyn Falempe * @kmsg_panic: Used to register a panic notifier for this plane
787bf9fb17cSJocelyn Falempe */
788bf9fb17cSJocelyn Falempe struct kmsg_dumper kmsg_panic;
78943968d7bSDaniel Vetter };
79043968d7bSDaniel Vetter
79143968d7bSDaniel Vetter #define obj_to_plane(x) container_of(x, struct drm_plane, base)
79243968d7bSDaniel Vetter
793e6fc3b68SBen Widawsky __printf(9, 10)
79443968d7bSDaniel Vetter int drm_universal_plane_init(struct drm_device *dev,
79543968d7bSDaniel Vetter struct drm_plane *plane,
7965cd57a46STomi Valkeinen uint32_t possible_crtcs,
79743968d7bSDaniel Vetter const struct drm_plane_funcs *funcs,
79843968d7bSDaniel Vetter const uint32_t *formats,
79943968d7bSDaniel Vetter unsigned int format_count,
800e6fc3b68SBen Widawsky const uint64_t *format_modifiers,
80143968d7bSDaniel Vetter enum drm_plane_type type,
80243968d7bSDaniel Vetter const char *name, ...);
80391faa047SDaniel Vetter void drm_plane_cleanup(struct drm_plane *plane);
80443968d7bSDaniel Vetter
8050a1b813fSPhilipp Zabel __printf(10, 11)
8060a1b813fSPhilipp Zabel void *__drmm_universal_plane_alloc(struct drm_device *dev,
8070a1b813fSPhilipp Zabel size_t size, size_t offset,
8080a1b813fSPhilipp Zabel uint32_t possible_crtcs,
8090a1b813fSPhilipp Zabel const struct drm_plane_funcs *funcs,
8100a1b813fSPhilipp Zabel const uint32_t *formats,
8110a1b813fSPhilipp Zabel unsigned int format_count,
8120a1b813fSPhilipp Zabel const uint64_t *format_modifiers,
8130a1b813fSPhilipp Zabel enum drm_plane_type plane_type,
8140a1b813fSPhilipp Zabel const char *name, ...);
8150a1b813fSPhilipp Zabel
8160a1b813fSPhilipp Zabel /**
8170a1b813fSPhilipp Zabel * drmm_universal_plane_alloc - Allocate and initialize an universal plane object
8180a1b813fSPhilipp Zabel * @dev: DRM device
8190a1b813fSPhilipp Zabel * @type: the type of the struct which contains struct &drm_plane
8200a1b813fSPhilipp Zabel * @member: the name of the &drm_plane within @type
8210a1b813fSPhilipp Zabel * @possible_crtcs: bitmask of possible CRTCs
8220a1b813fSPhilipp Zabel * @funcs: callbacks for the new plane
8230a1b813fSPhilipp Zabel * @formats: array of supported formats (DRM_FORMAT\_\*)
8240a1b813fSPhilipp Zabel * @format_count: number of elements in @formats
8250a1b813fSPhilipp Zabel * @format_modifiers: array of struct drm_format modifiers terminated by
8260a1b813fSPhilipp Zabel * DRM_FORMAT_MOD_INVALID
8270a1b813fSPhilipp Zabel * @plane_type: type of plane (overlay, primary, cursor)
8280a1b813fSPhilipp Zabel * @name: printf style format string for the plane name, or NULL for default name
8290a1b813fSPhilipp Zabel *
8300a1b813fSPhilipp Zabel * Allocates and initializes a plane object of type @type. Cleanup is
8310a1b813fSPhilipp Zabel * automatically handled through registering drm_plane_cleanup() with
8320a1b813fSPhilipp Zabel * drmm_add_action().
8330a1b813fSPhilipp Zabel *
8340a1b813fSPhilipp Zabel * The @drm_plane_funcs.destroy hook must be NULL.
8350a1b813fSPhilipp Zabel *
8368be57683STomohito Esaki * Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set
8378be57683STomohito Esaki * @format_modifiers to NULL. The plane will advertise the linear modifier.
8388be57683STomohito Esaki *
8390a1b813fSPhilipp Zabel * Returns:
8400a1b813fSPhilipp Zabel * Pointer to new plane, or ERR_PTR on failure.
8410a1b813fSPhilipp Zabel */
8420a1b813fSPhilipp Zabel #define drmm_universal_plane_alloc(dev, type, member, possible_crtcs, funcs, formats, \
8430a1b813fSPhilipp Zabel format_count, format_modifiers, plane_type, name, ...) \
8440a1b813fSPhilipp Zabel ((type *)__drmm_universal_plane_alloc(dev, sizeof(type), \
8450a1b813fSPhilipp Zabel offsetof(type, member), \
8460a1b813fSPhilipp Zabel possible_crtcs, funcs, formats, \
8470a1b813fSPhilipp Zabel format_count, format_modifiers, \
8480a1b813fSPhilipp Zabel plane_type, name, ##__VA_ARGS__))
8490a1b813fSPhilipp Zabel
850e71def05SThomas Zimmermann __printf(10, 11)
851e71def05SThomas Zimmermann void *__drm_universal_plane_alloc(struct drm_device *dev,
852e71def05SThomas Zimmermann size_t size, size_t offset,
853e71def05SThomas Zimmermann uint32_t possible_crtcs,
854e71def05SThomas Zimmermann const struct drm_plane_funcs *funcs,
855e71def05SThomas Zimmermann const uint32_t *formats,
856e71def05SThomas Zimmermann unsigned int format_count,
857e71def05SThomas Zimmermann const uint64_t *format_modifiers,
858e71def05SThomas Zimmermann enum drm_plane_type plane_type,
859e71def05SThomas Zimmermann const char *name, ...);
860e71def05SThomas Zimmermann
861e71def05SThomas Zimmermann /**
862e71def05SThomas Zimmermann * drm_universal_plane_alloc() - Allocate and initialize an universal plane object
863e71def05SThomas Zimmermann * @dev: DRM device
864e71def05SThomas Zimmermann * @type: the type of the struct which contains struct &drm_plane
865e71def05SThomas Zimmermann * @member: the name of the &drm_plane within @type
866e71def05SThomas Zimmermann * @possible_crtcs: bitmask of possible CRTCs
867e71def05SThomas Zimmermann * @funcs: callbacks for the new plane
868e71def05SThomas Zimmermann * @formats: array of supported formats (DRM_FORMAT\_\*)
869e71def05SThomas Zimmermann * @format_count: number of elements in @formats
870e71def05SThomas Zimmermann * @format_modifiers: array of struct drm_format modifiers terminated by
871e71def05SThomas Zimmermann * DRM_FORMAT_MOD_INVALID
872e71def05SThomas Zimmermann * @plane_type: type of plane (overlay, primary, cursor)
873e71def05SThomas Zimmermann * @name: printf style format string for the plane name, or NULL for default name
874e71def05SThomas Zimmermann *
875e71def05SThomas Zimmermann * Allocates and initializes a plane object of type @type. The caller
876e71def05SThomas Zimmermann * is responsible for releasing the allocated memory with kfree().
877e71def05SThomas Zimmermann *
878e71def05SThomas Zimmermann * Drivers are encouraged to use drmm_universal_plane_alloc() instead.
879e71def05SThomas Zimmermann *
880e71def05SThomas Zimmermann * Drivers that only support the DRM_FORMAT_MOD_LINEAR modifier support may set
881e71def05SThomas Zimmermann * @format_modifiers to NULL. The plane will advertise the linear modifier.
882e71def05SThomas Zimmermann *
883e71def05SThomas Zimmermann * Returns:
884e71def05SThomas Zimmermann * Pointer to new plane, or ERR_PTR on failure.
885e71def05SThomas Zimmermann */
886e71def05SThomas Zimmermann #define drm_universal_plane_alloc(dev, type, member, possible_crtcs, funcs, formats, \
887e71def05SThomas Zimmermann format_count, format_modifiers, plane_type, name, ...) \
888e71def05SThomas Zimmermann ((type *)__drm_universal_plane_alloc(dev, sizeof(type), \
889e71def05SThomas Zimmermann offsetof(type, member), \
890e71def05SThomas Zimmermann possible_crtcs, funcs, formats, \
891e71def05SThomas Zimmermann format_count, format_modifiers, \
892e71def05SThomas Zimmermann plane_type, name, ##__VA_ARGS__))
893e71def05SThomas Zimmermann
89443968d7bSDaniel Vetter /**
89543968d7bSDaniel Vetter * drm_plane_index - find the index of a registered plane
89643968d7bSDaniel Vetter * @plane: plane to find index for
89743968d7bSDaniel Vetter *
89843968d7bSDaniel Vetter * Given a registered plane, return the index of that plane within a DRM
89943968d7bSDaniel Vetter * device's list of planes.
90043968d7bSDaniel Vetter */
drm_plane_index(const struct drm_plane * plane)90162f77ad0SVille Syrjälä static inline unsigned int drm_plane_index(const struct drm_plane *plane)
90243968d7bSDaniel Vetter {
90343968d7bSDaniel Vetter return plane->index;
90443968d7bSDaniel Vetter }
90562f77ad0SVille Syrjälä
90662f77ad0SVille Syrjälä /**
90762f77ad0SVille Syrjälä * drm_plane_mask - find the mask of a registered plane
90862f77ad0SVille Syrjälä * @plane: plane to find mask for
90962f77ad0SVille Syrjälä */
drm_plane_mask(const struct drm_plane * plane)91062f77ad0SVille Syrjälä static inline u32 drm_plane_mask(const struct drm_plane *plane)
91162f77ad0SVille Syrjälä {
91262f77ad0SVille Syrjälä return 1 << drm_plane_index(plane);
91362f77ad0SVille Syrjälä }
91462f77ad0SVille Syrjälä
91591faa047SDaniel Vetter struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx);
91691faa047SDaniel Vetter void drm_plane_force_disable(struct drm_plane *plane);
91743968d7bSDaniel Vetter
91843968d7bSDaniel Vetter int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
91943968d7bSDaniel Vetter struct drm_property *property,
92043968d7bSDaniel Vetter uint64_t value);
92143968d7bSDaniel Vetter
92243968d7bSDaniel Vetter /**
92343968d7bSDaniel Vetter * drm_plane_find - find a &drm_plane
92443968d7bSDaniel Vetter * @dev: DRM device
925e7e62c7eSDave Airlie * @file_priv: drm file to check for lease against.
92643968d7bSDaniel Vetter * @id: plane id
92743968d7bSDaniel Vetter *
92843968d7bSDaniel Vetter * Returns the plane with @id, NULL if it doesn't exist. Simple wrapper around
92943968d7bSDaniel Vetter * drm_mode_object_find().
93043968d7bSDaniel Vetter */
drm_plane_find(struct drm_device * dev,struct drm_file * file_priv,uint32_t id)93143968d7bSDaniel Vetter static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
932418da172SKeith Packard struct drm_file *file_priv,
93343968d7bSDaniel Vetter uint32_t id)
93443968d7bSDaniel Vetter {
93543968d7bSDaniel Vetter struct drm_mode_object *mo;
936418da172SKeith Packard mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_PLANE);
93743968d7bSDaniel Vetter return mo ? obj_to_plane(mo) : NULL;
93843968d7bSDaniel Vetter }
93943968d7bSDaniel Vetter
94043968d7bSDaniel Vetter /**
94143968d7bSDaniel Vetter * drm_for_each_plane_mask - iterate over planes specified by bitmask
94243968d7bSDaniel Vetter * @plane: the loop cursor
94343968d7bSDaniel Vetter * @dev: the DRM device
94443968d7bSDaniel Vetter * @plane_mask: bitmask of plane indices
94543968d7bSDaniel Vetter *
94643968d7bSDaniel Vetter * Iterate over all planes specified by bitmask.
94743968d7bSDaniel Vetter */
94843968d7bSDaniel Vetter #define drm_for_each_plane_mask(plane, dev, plane_mask) \
94943968d7bSDaniel Vetter list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
95062f77ad0SVille Syrjälä for_each_if ((plane_mask) & drm_plane_mask(plane))
95143968d7bSDaniel Vetter
952532b3671SDaniel Vetter /**
953532b3671SDaniel Vetter * drm_for_each_legacy_plane - iterate over all planes for legacy userspace
954532b3671SDaniel Vetter * @plane: the loop cursor
955532b3671SDaniel Vetter * @dev: the DRM device
956532b3671SDaniel Vetter *
957532b3671SDaniel Vetter * Iterate over all legacy planes of @dev, excluding primary and cursor planes.
958532b3671SDaniel Vetter * This is useful for implementing userspace apis when userspace is not
959d574528aSDaniel Vetter * universal plane aware. See also &enum drm_plane_type.
960532b3671SDaniel Vetter */
96143968d7bSDaniel Vetter #define drm_for_each_legacy_plane(plane, dev) \
96243968d7bSDaniel Vetter list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
96343968d7bSDaniel Vetter for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY)
96443968d7bSDaniel Vetter
965532b3671SDaniel Vetter /**
966532b3671SDaniel Vetter * drm_for_each_plane - iterate over all planes
967532b3671SDaniel Vetter * @plane: the loop cursor
968532b3671SDaniel Vetter * @dev: the DRM device
969532b3671SDaniel Vetter *
970532b3671SDaniel Vetter * Iterate over all planes of @dev, include primary and cursor planes.
971532b3671SDaniel Vetter */
97243968d7bSDaniel Vetter #define drm_for_each_plane(plane, dev) \
97343968d7bSDaniel Vetter list_for_each_entry(plane, &(dev)->mode_config.plane_list, head)
97443968d7bSDaniel Vetter
975*1c5f18d8SVille Syrjälä bool drm_plane_has_format(struct drm_plane *plane,
976*1c5f18d8SVille Syrjälä u32 format, u64 modifier);
977e7afb623SVille Syrjälä bool drm_any_plane_has_format(struct drm_device *dev,
978e7afb623SVille Syrjälä u32 format, u64 modifier);
979ba6cd766SDaniel Vetter
980ba6cd766SDaniel Vetter void drm_plane_enable_fb_damage_clips(struct drm_plane *plane);
981c7fcbf25SDaniel Vetter unsigned int
982c7fcbf25SDaniel Vetter drm_plane_get_damage_clips_count(const struct drm_plane_state *state);
983c7fcbf25SDaniel Vetter struct drm_mode_rect *
984c7fcbf25SDaniel Vetter drm_plane_get_damage_clips(const struct drm_plane_state *state);
98543968d7bSDaniel Vetter
9865c759edaSPankaj Bharadiya int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
9875c759edaSPankaj Bharadiya unsigned int supported_filters);
9889677547dSVille Syrjälä int drm_plane_add_size_hints_property(struct drm_plane *plane,
9899677547dSVille Syrjälä const struct drm_plane_size_hint *hints,
9909677547dSVille Syrjälä int num_hints);
9915c759edaSPankaj Bharadiya
99243968d7bSDaniel Vetter #endif
993