xref: /openbmc/linux/include/drm/drm_mode_config.h (revision 1a931707ad4a46e79d4ecfee56d8f6e8cc8d4f28)
128575f16SDaniel Vetter /*
228575f16SDaniel Vetter  * Copyright (c) 2016 Intel Corporation
328575f16SDaniel Vetter  *
428575f16SDaniel Vetter  * Permission to use, copy, modify, distribute, and sell this software and its
528575f16SDaniel Vetter  * documentation for any purpose is hereby granted without fee, provided that
628575f16SDaniel Vetter  * the above copyright notice appear in all copies and that both that copyright
728575f16SDaniel Vetter  * notice and this permission notice appear in supporting documentation, and
828575f16SDaniel Vetter  * that the name of the copyright holders not be used in advertising or
928575f16SDaniel Vetter  * publicity pertaining to distribution of the software without specific,
1028575f16SDaniel Vetter  * written prior permission.  The copyright holders make no representations
1128575f16SDaniel Vetter  * about the suitability of this software for any purpose.  It is provided "as
1228575f16SDaniel Vetter  * is" without express or implied warranty.
1328575f16SDaniel Vetter  *
1428575f16SDaniel Vetter  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1528575f16SDaniel Vetter  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
1628575f16SDaniel Vetter  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1728575f16SDaniel Vetter  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
1828575f16SDaniel Vetter  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
1928575f16SDaniel Vetter  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
2028575f16SDaniel Vetter  * OF THIS SOFTWARE.
2128575f16SDaniel Vetter  */
2228575f16SDaniel Vetter 
2328575f16SDaniel Vetter #ifndef __DRM_MODE_CONFIG_H__
2428575f16SDaniel Vetter #define __DRM_MODE_CONFIG_H__
2528575f16SDaniel Vetter 
2628575f16SDaniel Vetter #include <linux/mutex.h>
2728575f16SDaniel Vetter #include <linux/types.h>
2828575f16SDaniel Vetter #include <linux/idr.h>
2928575f16SDaniel Vetter #include <linux/workqueue.h>
30ea497bb9SDaniel Vetter #include <linux/llist.h>
3128575f16SDaniel Vetter 
3228575f16SDaniel Vetter #include <drm/drm_modeset_lock.h>
3328575f16SDaniel Vetter 
3428575f16SDaniel Vetter struct drm_file;
3528575f16SDaniel Vetter struct drm_device;
3628575f16SDaniel Vetter struct drm_atomic_state;
3728575f16SDaniel Vetter struct drm_mode_fb_cmd2;
386a0f9ebfSVille Syrjälä struct drm_format_info;
3975a655e0SVille Syrjälä struct drm_display_mode;
4028575f16SDaniel Vetter 
4128575f16SDaniel Vetter /**
4228575f16SDaniel Vetter  * struct drm_mode_config_funcs - basic driver provided mode setting functions
4328575f16SDaniel Vetter  *
4428575f16SDaniel Vetter  * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
4528575f16SDaniel Vetter  * involve drivers.
4628575f16SDaniel Vetter  */
4728575f16SDaniel Vetter struct drm_mode_config_funcs {
4828575f16SDaniel Vetter 	/**
4928575f16SDaniel Vetter 	 * @fb_create:
5028575f16SDaniel Vetter 	 *
5128575f16SDaniel Vetter 	 * Create a new framebuffer object. The core does basic checks on the
5228575f16SDaniel Vetter 	 * requested metadata, but most of that is left to the driver. See
53ea0dd85aSDaniel Vetter 	 * &struct drm_mode_fb_cmd2 for details.
5428575f16SDaniel Vetter 	 *
55e7afb623SVille Syrjälä 	 * To validate the pixel format and modifier drivers can use
56e7afb623SVille Syrjälä 	 * drm_any_plane_has_format() to make sure at least one plane supports
57e7afb623SVille Syrjälä 	 * the requested values. Note that the driver must first determine the
58e7afb623SVille Syrjälä 	 * actual modifier used if the request doesn't have it specified,
59e7afb623SVille Syrjälä 	 * ie. when (@mode_cmd->flags & DRM_MODE_FB_MODIFIERS) == 0.
60e7afb623SVille Syrjälä 	 *
619e9f605fSDaniel Vetter 	 * IMPORTANT: These implied modifiers for legacy userspace must be
629e9f605fSDaniel Vetter 	 * stored in struct &drm_framebuffer, including all relevant metadata
639e9f605fSDaniel Vetter 	 * like &drm_framebuffer.pitches and &drm_framebuffer.offsets if the
649e9f605fSDaniel Vetter 	 * modifier enables additional planes beyond the fourcc pixel format
659e9f605fSDaniel Vetter 	 * code. This is required by the GETFB2 ioctl.
669e9f605fSDaniel Vetter 	 *
6728575f16SDaniel Vetter 	 * If the parameters are deemed valid and the backing storage objects in
6828575f16SDaniel Vetter 	 * the underlying memory manager all exist, then the driver allocates
6928575f16SDaniel Vetter 	 * a new &drm_framebuffer structure, subclassed to contain
7028575f16SDaniel Vetter 	 * driver-specific information (like the internal native buffer object
7128575f16SDaniel Vetter 	 * references). It also needs to fill out all relevant metadata, which
7228575f16SDaniel Vetter 	 * should be done by calling drm_helper_mode_fill_fb_struct().
7328575f16SDaniel Vetter 	 *
7428575f16SDaniel Vetter 	 * The initialization is finalized by calling drm_framebuffer_init(),
7528575f16SDaniel Vetter 	 * which registers the framebuffer and makes it accessible to other
7628575f16SDaniel Vetter 	 * threads.
7728575f16SDaniel Vetter 	 *
7828575f16SDaniel Vetter 	 * RETURNS:
7928575f16SDaniel Vetter 	 *
8028575f16SDaniel Vetter 	 * A new framebuffer with an initial reference count of 1 or a negative
8128575f16SDaniel Vetter 	 * error code encoded with ERR_PTR().
8228575f16SDaniel Vetter 	 */
8328575f16SDaniel Vetter 	struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
8428575f16SDaniel Vetter 					     struct drm_file *file_priv,
8528575f16SDaniel Vetter 					     const struct drm_mode_fb_cmd2 *mode_cmd);
8628575f16SDaniel Vetter 
8728575f16SDaniel Vetter 	/**
886a0f9ebfSVille Syrjälä 	 * @get_format_info:
896a0f9ebfSVille Syrjälä 	 *
906a0f9ebfSVille Syrjälä 	 * Allows a driver to return custom format information for special
916a0f9ebfSVille Syrjälä 	 * fb layouts (eg. ones with auxiliary compression control planes).
926a0f9ebfSVille Syrjälä 	 *
936a0f9ebfSVille Syrjälä 	 * RETURNS:
946a0f9ebfSVille Syrjälä 	 *
956a0f9ebfSVille Syrjälä 	 * The format information specific to the given fb metadata, or
966a0f9ebfSVille Syrjälä 	 * NULL if none is found.
976a0f9ebfSVille Syrjälä 	 */
986a0f9ebfSVille Syrjälä 	const struct drm_format_info *(*get_format_info)(const struct drm_mode_fb_cmd2 *mode_cmd);
996a0f9ebfSVille Syrjälä 
1006a0f9ebfSVille Syrjälä 	/**
10128575f16SDaniel Vetter 	 * @output_poll_changed:
10228575f16SDaniel Vetter 	 *
10328575f16SDaniel Vetter 	 * Callback used by helpers to inform the driver of output configuration
10428575f16SDaniel Vetter 	 * changes.
10528575f16SDaniel Vetter 	 *
106a9fc4315Szhangzhijie 	 * Drivers implementing fbdev emulation use drm_kms_helper_hotplug_event()
107a9fc4315Szhangzhijie 	 * to call this hook to inform the fbdev helper of output changes.
10828575f16SDaniel Vetter 	 *
109a9fc4315Szhangzhijie 	 * This hook is deprecated, drivers should instead use
110a9fc4315Szhangzhijie 	 * drm_fbdev_generic_setup() which takes care of any necessary
111a9fc4315Szhangzhijie 	 * hotplug event forwarding already without further involvement by
112a9fc4315Szhangzhijie 	 * the driver.
11328575f16SDaniel Vetter 	 */
11428575f16SDaniel Vetter 	void (*output_poll_changed)(struct drm_device *dev);
11528575f16SDaniel Vetter 
11628575f16SDaniel Vetter 	/**
11775a655e0SVille Syrjälä 	 * @mode_valid:
11875a655e0SVille Syrjälä 	 *
11975a655e0SVille Syrjälä 	 * Device specific validation of display modes. Can be used to reject
12075a655e0SVille Syrjälä 	 * modes that can never be supported. Only device wide constraints can
12175a655e0SVille Syrjälä 	 * be checked here. crtc/encoder/bridge/connector specific constraints
12275a655e0SVille Syrjälä 	 * should be checked in the .mode_valid() hook for each specific object.
12375a655e0SVille Syrjälä 	 */
12475a655e0SVille Syrjälä 	enum drm_mode_status (*mode_valid)(struct drm_device *dev,
12575a655e0SVille Syrjälä 					   const struct drm_display_mode *mode);
12675a655e0SVille Syrjälä 
12775a655e0SVille Syrjälä 	/**
12828575f16SDaniel Vetter 	 * @atomic_check:
12928575f16SDaniel Vetter 	 *
13028575f16SDaniel Vetter 	 * This is the only hook to validate an atomic modeset update. This
13128575f16SDaniel Vetter 	 * function must reject any modeset and state changes which the hardware
13228575f16SDaniel Vetter 	 * or driver doesn't support. This includes but is of course not limited
13328575f16SDaniel Vetter 	 * to:
13428575f16SDaniel Vetter 	 *
13528575f16SDaniel Vetter 	 *  - Checking that the modes, framebuffers, scaling and placement
13628575f16SDaniel Vetter 	 *    requirements and so on are within the limits of the hardware.
13728575f16SDaniel Vetter 	 *
13828575f16SDaniel Vetter 	 *  - Checking that any hidden shared resources are not oversubscribed.
13928575f16SDaniel Vetter 	 *    This can be shared PLLs, shared lanes, overall memory bandwidth,
14028575f16SDaniel Vetter 	 *    display fifo space (where shared between planes or maybe even
14128575f16SDaniel Vetter 	 *    CRTCs).
14228575f16SDaniel Vetter 	 *
14328575f16SDaniel Vetter 	 *  - Checking that virtualized resources exported to userspace are not
14428575f16SDaniel Vetter 	 *    oversubscribed. For various reasons it can make sense to expose
14528575f16SDaniel Vetter 	 *    more planes, crtcs or encoders than which are physically there. One
14628575f16SDaniel Vetter 	 *    example is dual-pipe operations (which generally should be hidden
14728575f16SDaniel Vetter 	 *    from userspace if when lockstepped in hardware, exposed otherwise),
14828575f16SDaniel Vetter 	 *    where a plane might need 1 hardware plane (if it's just on one
14928575f16SDaniel Vetter 	 *    pipe), 2 hardware planes (when it spans both pipes) or maybe even
15028575f16SDaniel Vetter 	 *    shared a hardware plane with a 2nd plane (if there's a compatible
15128575f16SDaniel Vetter 	 *    plane requested on the area handled by the other pipe).
15228575f16SDaniel Vetter 	 *
15328575f16SDaniel Vetter 	 *  - Check that any transitional state is possible and that if
15428575f16SDaniel Vetter 	 *    requested, the update can indeed be done in the vblank period
15528575f16SDaniel Vetter 	 *    without temporarily disabling some functions.
15628575f16SDaniel Vetter 	 *
15728575f16SDaniel Vetter 	 *  - Check any other constraints the driver or hardware might have.
15828575f16SDaniel Vetter 	 *
15928575f16SDaniel Vetter 	 *  - This callback also needs to correctly fill out the &drm_crtc_state
16028575f16SDaniel Vetter 	 *    in this update to make sure that drm_atomic_crtc_needs_modeset()
16128575f16SDaniel Vetter 	 *    reflects the nature of the possible update and returns true if and
16228575f16SDaniel Vetter 	 *    only if the update cannot be applied without tearing within one
16328575f16SDaniel Vetter 	 *    vblank on that CRTC. The core uses that information to reject
16428575f16SDaniel Vetter 	 *    updates which require a full modeset (i.e. blanking the screen, or
16528575f16SDaniel Vetter 	 *    at least pausing updates for a substantial amount of time) if
16628575f16SDaniel Vetter 	 *    userspace has disallowed that in its request.
16728575f16SDaniel Vetter 	 *
16828575f16SDaniel Vetter 	 *  - The driver also does not need to repeat basic input validation
16928575f16SDaniel Vetter 	 *    like done for the corresponding legacy entry points. The core does
17028575f16SDaniel Vetter 	 *    that before calling this hook.
17128575f16SDaniel Vetter 	 *
17228575f16SDaniel Vetter 	 * See the documentation of @atomic_commit for an exhaustive list of
173d574528aSDaniel Vetter 	 * error conditions which don't have to be checked at the in this
174d574528aSDaniel Vetter 	 * callback.
17528575f16SDaniel Vetter 	 *
176ea0dd85aSDaniel Vetter 	 * See the documentation for &struct drm_atomic_state for how exactly
17728575f16SDaniel Vetter 	 * an atomic modeset update is described.
17828575f16SDaniel Vetter 	 *
17928575f16SDaniel Vetter 	 * Drivers using the atomic helpers can implement this hook using
18028575f16SDaniel Vetter 	 * drm_atomic_helper_check(), or one of the exported sub-functions of
18128575f16SDaniel Vetter 	 * it.
18228575f16SDaniel Vetter 	 *
18328575f16SDaniel Vetter 	 * RETURNS:
18428575f16SDaniel Vetter 	 *
18528575f16SDaniel Vetter 	 * 0 on success or one of the below negative error codes:
18628575f16SDaniel Vetter 	 *
18728575f16SDaniel Vetter 	 *  - -EINVAL, if any of the above constraints are violated.
18828575f16SDaniel Vetter 	 *
18928575f16SDaniel Vetter 	 *  - -EDEADLK, when returned from an attempt to acquire an additional
19028575f16SDaniel Vetter 	 *    &drm_modeset_lock through drm_modeset_lock().
19128575f16SDaniel Vetter 	 *
19228575f16SDaniel Vetter 	 *  - -ENOMEM, if allocating additional state sub-structures failed due
19328575f16SDaniel Vetter 	 *    to lack of memory.
19428575f16SDaniel Vetter 	 *
19528575f16SDaniel Vetter 	 *  - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted.
19628575f16SDaniel Vetter 	 *    This can either be due to a pending signal, or because the driver
19728575f16SDaniel Vetter 	 *    needs to completely bail out to recover from an exceptional
19828575f16SDaniel Vetter 	 *    situation like a GPU hang. From a userspace point all errors are
19928575f16SDaniel Vetter 	 *    treated equally.
20028575f16SDaniel Vetter 	 */
20128575f16SDaniel Vetter 	int (*atomic_check)(struct drm_device *dev,
20228575f16SDaniel Vetter 			    struct drm_atomic_state *state);
20328575f16SDaniel Vetter 
20428575f16SDaniel Vetter 	/**
20528575f16SDaniel Vetter 	 * @atomic_commit:
20628575f16SDaniel Vetter 	 *
20728575f16SDaniel Vetter 	 * This is the only hook to commit an atomic modeset update. The core
20828575f16SDaniel Vetter 	 * guarantees that @atomic_check has been called successfully before
20928575f16SDaniel Vetter 	 * calling this function, and that nothing has been changed in the
21028575f16SDaniel Vetter 	 * interim.
21128575f16SDaniel Vetter 	 *
212ea0dd85aSDaniel Vetter 	 * See the documentation for &struct drm_atomic_state for how exactly
21328575f16SDaniel Vetter 	 * an atomic modeset update is described.
21428575f16SDaniel Vetter 	 *
21528575f16SDaniel Vetter 	 * Drivers using the atomic helpers can implement this hook using
21628575f16SDaniel Vetter 	 * drm_atomic_helper_commit(), or one of the exported sub-functions of
21728575f16SDaniel Vetter 	 * it.
21828575f16SDaniel Vetter 	 *
21928575f16SDaniel Vetter 	 * Nonblocking commits (as indicated with the nonblock parameter) must
22028575f16SDaniel Vetter 	 * do any preparatory work which might result in an unsuccessful commit
22128575f16SDaniel Vetter 	 * in the context of this callback. The only exceptions are hardware
22228575f16SDaniel Vetter 	 * errors resulting in -EIO. But even in that case the driver must
22328575f16SDaniel Vetter 	 * ensure that the display pipe is at least running, to avoid
22428575f16SDaniel Vetter 	 * compositors crashing when pageflips don't work. Anything else,
22528575f16SDaniel Vetter 	 * specifically committing the update to the hardware, should be done
22628575f16SDaniel Vetter 	 * without blocking the caller. For updates which do not require a
22728575f16SDaniel Vetter 	 * modeset this must be guaranteed.
22828575f16SDaniel Vetter 	 *
22928575f16SDaniel Vetter 	 * The driver must wait for any pending rendering to the new
23028575f16SDaniel Vetter 	 * framebuffers to complete before executing the flip. It should also
23128575f16SDaniel Vetter 	 * wait for any pending rendering from other drivers if the underlying
23228575f16SDaniel Vetter 	 * buffer is a shared dma-buf. Nonblocking commits must not wait for
23328575f16SDaniel Vetter 	 * rendering in the context of this callback.
23428575f16SDaniel Vetter 	 *
23528575f16SDaniel Vetter 	 * An application can request to be notified when the atomic commit has
23628575f16SDaniel Vetter 	 * completed. These events are per-CRTC and can be distinguished by the
23728575f16SDaniel Vetter 	 * CRTC index supplied in &drm_event to userspace.
23828575f16SDaniel Vetter 	 *
239d574528aSDaniel Vetter 	 * The drm core will supply a &struct drm_event in each CRTC's
240d574528aSDaniel Vetter 	 * &drm_crtc_state.event. See the documentation for
241d574528aSDaniel Vetter 	 * &drm_crtc_state.event for more details about the precise semantics of
242d574528aSDaniel Vetter 	 * this event.
24328575f16SDaniel Vetter 	 *
24428575f16SDaniel Vetter 	 * NOTE:
24528575f16SDaniel Vetter 	 *
24628575f16SDaniel Vetter 	 * Drivers are not allowed to shut down any display pipe successfully
24728575f16SDaniel Vetter 	 * enabled through an atomic commit on their own. Doing so can result in
24828575f16SDaniel Vetter 	 * compositors crashing if a page flip is suddenly rejected because the
24928575f16SDaniel Vetter 	 * pipe is off.
25028575f16SDaniel Vetter 	 *
25128575f16SDaniel Vetter 	 * RETURNS:
25228575f16SDaniel Vetter 	 *
25328575f16SDaniel Vetter 	 * 0 on success or one of the below negative error codes:
25428575f16SDaniel Vetter 	 *
25528575f16SDaniel Vetter 	 *  - -EBUSY, if a nonblocking updated is requested and there is
25628575f16SDaniel Vetter 	 *    an earlier updated pending. Drivers are allowed to support a queue
25728575f16SDaniel Vetter 	 *    of outstanding updates, but currently no driver supports that.
25828575f16SDaniel Vetter 	 *    Note that drivers must wait for preceding updates to complete if a
25928575f16SDaniel Vetter 	 *    synchronous update is requested, they are not allowed to fail the
26028575f16SDaniel Vetter 	 *    commit in that case.
26128575f16SDaniel Vetter 	 *
26228575f16SDaniel Vetter 	 *  - -ENOMEM, if the driver failed to allocate memory. Specifically
26328575f16SDaniel Vetter 	 *    this can happen when trying to pin framebuffers, which must only
26428575f16SDaniel Vetter 	 *    be done when committing the state.
26528575f16SDaniel Vetter 	 *
26628575f16SDaniel Vetter 	 *  - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate
26728575f16SDaniel Vetter 	 *    that the driver has run out of vram, iommu space or similar GPU
26828575f16SDaniel Vetter 	 *    address space needed for framebuffer.
26928575f16SDaniel Vetter 	 *
27028575f16SDaniel Vetter 	 *  - -EIO, if the hardware completely died.
27128575f16SDaniel Vetter 	 *
27228575f16SDaniel Vetter 	 *  - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted.
27328575f16SDaniel Vetter 	 *    This can either be due to a pending signal, or because the driver
27428575f16SDaniel Vetter 	 *    needs to completely bail out to recover from an exceptional
27528575f16SDaniel Vetter 	 *    situation like a GPU hang. From a userspace point of view all errors are
27628575f16SDaniel Vetter 	 *    treated equally.
27728575f16SDaniel Vetter 	 *
27828575f16SDaniel Vetter 	 * This list is exhaustive. Specifically this hook is not allowed to
27928575f16SDaniel Vetter 	 * return -EINVAL (any invalid requests should be caught in
28028575f16SDaniel Vetter 	 * @atomic_check) or -EDEADLK (this function must not acquire
28128575f16SDaniel Vetter 	 * additional modeset locks).
28228575f16SDaniel Vetter 	 */
28328575f16SDaniel Vetter 	int (*atomic_commit)(struct drm_device *dev,
28428575f16SDaniel Vetter 			     struct drm_atomic_state *state,
28528575f16SDaniel Vetter 			     bool nonblock);
28628575f16SDaniel Vetter 
28728575f16SDaniel Vetter 	/**
28828575f16SDaniel Vetter 	 * @atomic_state_alloc:
28928575f16SDaniel Vetter 	 *
29028575f16SDaniel Vetter 	 * This optional hook can be used by drivers that want to subclass struct
29128575f16SDaniel Vetter 	 * &drm_atomic_state to be able to track their own driver-private global
29228575f16SDaniel Vetter 	 * state easily. If this hook is implemented, drivers must also
29328575f16SDaniel Vetter 	 * implement @atomic_state_clear and @atomic_state_free.
29428575f16SDaniel Vetter 	 *
295da6c0596SDaniel Vetter 	 * Subclassing of &drm_atomic_state is deprecated in favour of using
296da6c0596SDaniel Vetter 	 * &drm_private_state and &drm_private_obj.
297da6c0596SDaniel Vetter 	 *
29828575f16SDaniel Vetter 	 * RETURNS:
29928575f16SDaniel Vetter 	 *
30028575f16SDaniel Vetter 	 * A new &drm_atomic_state on success or NULL on failure.
30128575f16SDaniel Vetter 	 */
30228575f16SDaniel Vetter 	struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev);
30328575f16SDaniel Vetter 
30428575f16SDaniel Vetter 	/**
30528575f16SDaniel Vetter 	 * @atomic_state_clear:
30628575f16SDaniel Vetter 	 *
30728575f16SDaniel Vetter 	 * This hook must clear any driver private state duplicated into the
30828575f16SDaniel Vetter 	 * passed-in &drm_atomic_state. This hook is called when the caller
30928575f16SDaniel Vetter 	 * encountered a &drm_modeset_lock deadlock and needs to drop all
31028575f16SDaniel Vetter 	 * already acquired locks as part of the deadlock avoidance dance
3117adbd209SArchit Taneja 	 * implemented in drm_modeset_backoff().
31228575f16SDaniel Vetter 	 *
31328575f16SDaniel Vetter 	 * Any duplicated state must be invalidated since a concurrent atomic
31428575f16SDaniel Vetter 	 * update might change it, and the drm atomic interfaces always apply
31528575f16SDaniel Vetter 	 * updates as relative changes to the current state.
31628575f16SDaniel Vetter 	 *
31728575f16SDaniel Vetter 	 * Drivers that implement this must call drm_atomic_state_default_clear()
31828575f16SDaniel Vetter 	 * to clear common state.
319da6c0596SDaniel Vetter 	 *
320da6c0596SDaniel Vetter 	 * Subclassing of &drm_atomic_state is deprecated in favour of using
321da6c0596SDaniel Vetter 	 * &drm_private_state and &drm_private_obj.
32228575f16SDaniel Vetter 	 */
32328575f16SDaniel Vetter 	void (*atomic_state_clear)(struct drm_atomic_state *state);
32428575f16SDaniel Vetter 
32528575f16SDaniel Vetter 	/**
32628575f16SDaniel Vetter 	 * @atomic_state_free:
32728575f16SDaniel Vetter 	 *
32828575f16SDaniel Vetter 	 * This hook needs driver private resources and the &drm_atomic_state
32928575f16SDaniel Vetter 	 * itself. Note that the core first calls drm_atomic_state_clear() to
33028575f16SDaniel Vetter 	 * avoid code duplicate between the clear and free hooks.
33128575f16SDaniel Vetter 	 *
3327adbd209SArchit Taneja 	 * Drivers that implement this must call
3337adbd209SArchit Taneja 	 * drm_atomic_state_default_release() to release common resources.
334da6c0596SDaniel Vetter 	 *
335da6c0596SDaniel Vetter 	 * Subclassing of &drm_atomic_state is deprecated in favour of using
336da6c0596SDaniel Vetter 	 * &drm_private_state and &drm_private_obj.
33728575f16SDaniel Vetter 	 */
33828575f16SDaniel Vetter 	void (*atomic_state_free)(struct drm_atomic_state *state);
33928575f16SDaniel Vetter };
34028575f16SDaniel Vetter 
34128575f16SDaniel Vetter /**
34228575f16SDaniel Vetter  * struct drm_mode_config - Mode configuration control structure
3438d4f4b82SVille Syrjälä  * @min_width: minimum fb pixel width on this device
3448d4f4b82SVille Syrjälä  * @min_height: minimum fb pixel height on this device
3458d4f4b82SVille Syrjälä  * @max_width: maximum fb pixel width on this device
3468d4f4b82SVille Syrjälä  * @max_height: maximum fb pixel height on this device
34728575f16SDaniel Vetter  * @funcs: core driver provided mode setting functions
34828575f16SDaniel Vetter  * @poll_enabled: track polling support for this device
34928575f16SDaniel Vetter  * @poll_running: track polling status for this device
35028575f16SDaniel Vetter  * @delayed_event: track delayed poll uevent deliver for this device
35128575f16SDaniel Vetter  * @output_poll_work: delayed work for polling in process context
35228575f16SDaniel Vetter  * @preferred_depth: preferred RBG pixel depth, used by fb helpers
35328575f16SDaniel Vetter  * @prefer_shadow: hint to userspace to prefer shadow-fb rendering
35428575f16SDaniel Vetter  * @cursor_width: hint to userspace for max cursor width
35528575f16SDaniel Vetter  * @cursor_height: hint to userspace for max cursor height
35628575f16SDaniel Vetter  * @helper_private: mid-layer private data
35728575f16SDaniel Vetter  *
35828575f16SDaniel Vetter  * Core mode resource tracking structure.  All CRTC, encoders, and connectors
35928575f16SDaniel Vetter  * enumerated by the driver are added here, as are global properties.  Some
36028575f16SDaniel Vetter  * global restrictions are also here, e.g. dimension restrictions.
36184e9dfd5SThomas Zimmermann  *
36284e9dfd5SThomas Zimmermann  * Framebuffer sizes refer to the virtual screen that can be displayed by
36384e9dfd5SThomas Zimmermann  * the CRTC. This can be different from the physical resolution programmed.
36484e9dfd5SThomas Zimmermann  * The minimum width and height, stored in @min_width and @min_height,
36584e9dfd5SThomas Zimmermann  * describe the smallest size of the framebuffer. It correlates to the
36684e9dfd5SThomas Zimmermann  * minimum programmable resolution.
36784e9dfd5SThomas Zimmermann  * The maximum width, stored in @max_width, is typically limited by the
36884e9dfd5SThomas Zimmermann  * maximum pitch between two adjacent scanlines. The maximum height, stored
36984e9dfd5SThomas Zimmermann  * in @max_height, is usually only limited by the amount of addressable video
37084e9dfd5SThomas Zimmermann  * memory. For hardware that has no real maximum, drivers should pick a
37184e9dfd5SThomas Zimmermann  * reasonable default.
37284e9dfd5SThomas Zimmermann  *
37384e9dfd5SThomas Zimmermann  * See also @DRM_SHADOW_PLANE_MAX_WIDTH and @DRM_SHADOW_PLANE_MAX_HEIGHT.
37428575f16SDaniel Vetter  */
37528575f16SDaniel Vetter struct drm_mode_config {
376c9e42b72SDaniel Vetter 	/**
377c9e42b72SDaniel Vetter 	 * @mutex:
378c9e42b72SDaniel Vetter 	 *
379c9e42b72SDaniel Vetter 	 * This is the big scary modeset BKL which protects everything that
380c9e42b72SDaniel Vetter 	 * isn't protect otherwise. Scope is unclear and fuzzy, try to remove
3811e55a53aSMatt Roper 	 * anything from under its protection and move it into more well-scoped
382c9e42b72SDaniel Vetter 	 * locks.
383c9e42b72SDaniel Vetter 	 *
384c9e42b72SDaniel Vetter 	 * The one important thing this protects is the use of @acquire_ctx.
385c9e42b72SDaniel Vetter 	 */
386c9e42b72SDaniel Vetter 	struct mutex mutex;
387c9e42b72SDaniel Vetter 
388c9e42b72SDaniel Vetter 	/**
389c9e42b72SDaniel Vetter 	 * @connection_mutex:
390c9e42b72SDaniel Vetter 	 *
391c9e42b72SDaniel Vetter 	 * This protects connector state and the connector to encoder to CRTC
392c9e42b72SDaniel Vetter 	 * routing chain.
393c9e42b72SDaniel Vetter 	 *
394c9e42b72SDaniel Vetter 	 * For atomic drivers specifically this protects &drm_connector.state.
395c9e42b72SDaniel Vetter 	 */
396c9e42b72SDaniel Vetter 	struct drm_modeset_lock connection_mutex;
397c9e42b72SDaniel Vetter 
398c9e42b72SDaniel Vetter 	/**
399c9e42b72SDaniel Vetter 	 * @acquire_ctx:
400c9e42b72SDaniel Vetter 	 *
401c9e42b72SDaniel Vetter 	 * Global implicit acquire context used by atomic drivers for legacy
402c9e42b72SDaniel Vetter 	 * IOCTLs. Deprecated, since implicit locking contexts make it
403c9e42b72SDaniel Vetter 	 * impossible to use driver-private &struct drm_modeset_lock. Users of
404c9e42b72SDaniel Vetter 	 * this must hold @mutex.
405c9e42b72SDaniel Vetter 	 */
406c9e42b72SDaniel Vetter 	struct drm_modeset_acquire_ctx *acquire_ctx;
40728575f16SDaniel Vetter 
40828575f16SDaniel Vetter 	/**
40928575f16SDaniel Vetter 	 * @idr_mutex:
41028575f16SDaniel Vetter 	 *
411b5f06893SShayenne da Luz Moura 	 * Mutex for KMS ID allocation and management. Protects both @object_idr
41228575f16SDaniel Vetter 	 * and @tile_idr.
41328575f16SDaniel Vetter 	 */
41428575f16SDaniel Vetter 	struct mutex idr_mutex;
41528575f16SDaniel Vetter 
41628575f16SDaniel Vetter 	/**
417b5f06893SShayenne da Luz Moura 	 * @object_idr:
41828575f16SDaniel Vetter 	 *
41928575f16SDaniel Vetter 	 * Main KMS ID tracking object. Use this idr for all IDs, fb, crtc,
42028575f16SDaniel Vetter 	 * connector, modes - just makes life easier to have only one.
42128575f16SDaniel Vetter 	 */
422b5f06893SShayenne da Luz Moura 	struct idr object_idr;
42328575f16SDaniel Vetter 
42428575f16SDaniel Vetter 	/**
42528575f16SDaniel Vetter 	 * @tile_idr:
42628575f16SDaniel Vetter 	 *
42728575f16SDaniel Vetter 	 * Use this idr for allocating new IDs for tiled sinks like use in some
42828575f16SDaniel Vetter 	 * high-res DP MST screens.
42928575f16SDaniel Vetter 	 */
43028575f16SDaniel Vetter 	struct idr tile_idr;
43128575f16SDaniel Vetter 
432c9e42b72SDaniel Vetter 	/** @fb_lock: Mutex to protect fb the global @fb_list and @num_fb. */
433c9e42b72SDaniel Vetter 	struct mutex fb_lock;
434c9e42b72SDaniel Vetter 	/** @num_fb: Number of entries on @fb_list. */
43528575f16SDaniel Vetter 	int num_fb;
436c9e42b72SDaniel Vetter 	/** @fb_list: List of all &struct drm_framebuffer. */
43728575f16SDaniel Vetter 	struct list_head fb_list;
43828575f16SDaniel Vetter 
43928575f16SDaniel Vetter 	/**
440613051daSDaniel Vetter 	 * @connector_list_lock: Protects @num_connector and
441ea497bb9SDaniel Vetter 	 * @connector_list and @connector_free_list.
442613051daSDaniel Vetter 	 */
443613051daSDaniel Vetter 	spinlock_t connector_list_lock;
444613051daSDaniel Vetter 	/**
445613051daSDaniel Vetter 	 * @num_connector: Number of connectors on this device. Protected by
446613051daSDaniel Vetter 	 * @connector_list_lock.
44728575f16SDaniel Vetter 	 */
44828575f16SDaniel Vetter 	int num_connector;
44928575f16SDaniel Vetter 	/**
45028575f16SDaniel Vetter 	 * @connector_ida: ID allocator for connector indices.
45128575f16SDaniel Vetter 	 */
45228575f16SDaniel Vetter 	struct ida connector_ida;
45328575f16SDaniel Vetter 	/**
454c9e42b72SDaniel Vetter 	 * @connector_list:
455c9e42b72SDaniel Vetter 	 *
456c9e42b72SDaniel Vetter 	 * List of connector objects linked with &drm_connector.head. Protected
457c9e42b72SDaniel Vetter 	 * by @connector_list_lock. Only use drm_for_each_connector_iter() and
458ea0dd85aSDaniel Vetter 	 * &struct drm_connector_list_iter to walk this list.
45928575f16SDaniel Vetter 	 */
46028575f16SDaniel Vetter 	struct list_head connector_list;
461c9e42b72SDaniel Vetter 	/**
462ea497bb9SDaniel Vetter 	 * @connector_free_list:
463ea497bb9SDaniel Vetter 	 *
464ea497bb9SDaniel Vetter 	 * List of connector objects linked with &drm_connector.free_head.
465ea497bb9SDaniel Vetter 	 * Protected by @connector_list_lock. Used by
466ea497bb9SDaniel Vetter 	 * drm_for_each_connector_iter() and
467ea497bb9SDaniel Vetter 	 * &struct drm_connector_list_iter to savely free connectors using
468ea497bb9SDaniel Vetter 	 * @connector_free_work.
469ea497bb9SDaniel Vetter 	 */
470ea497bb9SDaniel Vetter 	struct llist_head connector_free_list;
471ea497bb9SDaniel Vetter 	/**
472ea497bb9SDaniel Vetter 	 * @connector_free_work: Work to clean up @connector_free_list.
473ea497bb9SDaniel Vetter 	 */
474ea497bb9SDaniel Vetter 	struct work_struct connector_free_work;
475ea497bb9SDaniel Vetter 
476ea497bb9SDaniel Vetter 	/**
477c9e42b72SDaniel Vetter 	 * @num_encoder:
478c9e42b72SDaniel Vetter 	 *
479c9e42b72SDaniel Vetter 	 * Number of encoders on this device. This is invariant over the
480c9e42b72SDaniel Vetter 	 * lifetime of a device and hence doesn't need any locks.
481c9e42b72SDaniel Vetter 	 */
48228575f16SDaniel Vetter 	int num_encoder;
483c9e42b72SDaniel Vetter 	/**
484c9e42b72SDaniel Vetter 	 * @encoder_list:
485c9e42b72SDaniel Vetter 	 *
486c9e42b72SDaniel Vetter 	 * List of encoder objects linked with &drm_encoder.head. This is
487c9e42b72SDaniel Vetter 	 * invariant over the lifetime of a device and hence doesn't need any
488c9e42b72SDaniel Vetter 	 * locks.
489c9e42b72SDaniel Vetter 	 */
49028575f16SDaniel Vetter 	struct list_head encoder_list;
49128575f16SDaniel Vetter 
492c9e42b72SDaniel Vetter 	/**
493c9e42b72SDaniel Vetter 	 * @num_total_plane:
494c9e42b72SDaniel Vetter 	 *
495c9e42b72SDaniel Vetter 	 * Number of universal (i.e. with primary/curso) planes on this device.
496c9e42b72SDaniel Vetter 	 * This is invariant over the lifetime of a device and hence doesn't
497c9e42b72SDaniel Vetter 	 * need any locks.
498c9e42b72SDaniel Vetter 	 */
49928575f16SDaniel Vetter 	int num_total_plane;
500c9e42b72SDaniel Vetter 	/**
501c9e42b72SDaniel Vetter 	 * @plane_list:
502c9e42b72SDaniel Vetter 	 *
503c9e42b72SDaniel Vetter 	 * List of plane objects linked with &drm_plane.head. This is invariant
504c9e42b72SDaniel Vetter 	 * over the lifetime of a device and hence doesn't need any locks.
505c9e42b72SDaniel Vetter 	 */
50628575f16SDaniel Vetter 	struct list_head plane_list;
50728575f16SDaniel Vetter 
508c9e42b72SDaniel Vetter 	/**
509c9e42b72SDaniel Vetter 	 * @num_crtc:
510c9e42b72SDaniel Vetter 	 *
511c9e42b72SDaniel Vetter 	 * Number of CRTCs on this device linked with &drm_crtc.head. This is invariant over the lifetime
512c9e42b72SDaniel Vetter 	 * of a device and hence doesn't need any locks.
513c9e42b72SDaniel Vetter 	 */
51428575f16SDaniel Vetter 	int num_crtc;
515c9e42b72SDaniel Vetter 	/**
516c9e42b72SDaniel Vetter 	 * @crtc_list:
517c9e42b72SDaniel Vetter 	 *
518c9e42b72SDaniel Vetter 	 * List of CRTC objects linked with &drm_crtc.head. This is invariant
519c9e42b72SDaniel Vetter 	 * over the lifetime of a device and hence doesn't need any locks.
520c9e42b72SDaniel Vetter 	 */
52128575f16SDaniel Vetter 	struct list_head crtc_list;
52228575f16SDaniel Vetter 
523c9e42b72SDaniel Vetter 	/**
524c9e42b72SDaniel Vetter 	 * @property_list:
525c9e42b72SDaniel Vetter 	 *
526c9e42b72SDaniel Vetter 	 * List of property type objects linked with &drm_property.head. This is
527c9e42b72SDaniel Vetter 	 * invariant over the lifetime of a device and hence doesn't need any
528c9e42b72SDaniel Vetter 	 * locks.
529c9e42b72SDaniel Vetter 	 */
53028575f16SDaniel Vetter 	struct list_head property_list;
53128575f16SDaniel Vetter 
532b962a120SRob Clark 	/**
533b962a120SRob Clark 	 * @privobj_list:
534b962a120SRob Clark 	 *
535b962a120SRob Clark 	 * List of private objects linked with &drm_private_obj.head. This is
536b962a120SRob Clark 	 * invariant over the lifetime of a device and hence doesn't need any
537b962a120SRob Clark 	 * locks.
538b962a120SRob Clark 	 */
539b962a120SRob Clark 	struct list_head privobj_list;
540b962a120SRob Clark 
54128575f16SDaniel Vetter 	int min_width, min_height;
54228575f16SDaniel Vetter 	int max_width, max_height;
54328575f16SDaniel Vetter 	const struct drm_mode_config_funcs *funcs;
54428575f16SDaniel Vetter 
54528575f16SDaniel Vetter 	/* output poll support */
54628575f16SDaniel Vetter 	bool poll_enabled;
54728575f16SDaniel Vetter 	bool poll_running;
54828575f16SDaniel Vetter 	bool delayed_event;
54928575f16SDaniel Vetter 	struct delayed_work output_poll_work;
55028575f16SDaniel Vetter 
551c9e42b72SDaniel Vetter 	/**
552c9e42b72SDaniel Vetter 	 * @blob_lock:
553c9e42b72SDaniel Vetter 	 *
554c9e42b72SDaniel Vetter 	 * Mutex for blob property allocation and management, protects
555c9e42b72SDaniel Vetter 	 * @property_blob_list and &drm_file.blobs.
556c9e42b72SDaniel Vetter 	 */
55728575f16SDaniel Vetter 	struct mutex blob_lock;
55828575f16SDaniel Vetter 
559c9e42b72SDaniel Vetter 	/**
560c9e42b72SDaniel Vetter 	 * @property_blob_list:
561c9e42b72SDaniel Vetter 	 *
562c9e42b72SDaniel Vetter 	 * List of all the blob property objects linked with
563c9e42b72SDaniel Vetter 	 * &drm_property_blob.head. Protected by @blob_lock.
564c9e42b72SDaniel Vetter 	 */
56528575f16SDaniel Vetter 	struct list_head property_blob_list;
566c9e42b72SDaniel Vetter 
567c9e42b72SDaniel Vetter 	/* pointers to standard properties */
568c9e42b72SDaniel Vetter 
56928575f16SDaniel Vetter 	/**
57028575f16SDaniel Vetter 	 * @edid_property: Default connector property to hold the EDID of the
57128575f16SDaniel Vetter 	 * currently connected sink, if any.
57228575f16SDaniel Vetter 	 */
57328575f16SDaniel Vetter 	struct drm_property *edid_property;
57428575f16SDaniel Vetter 	/**
57528575f16SDaniel Vetter 	 * @dpms_property: Default connector property to control the
57628575f16SDaniel Vetter 	 * connector's DPMS state.
57728575f16SDaniel Vetter 	 */
57828575f16SDaniel Vetter 	struct drm_property *dpms_property;
57928575f16SDaniel Vetter 	/**
58028575f16SDaniel Vetter 	 * @path_property: Default connector property to hold the DP MST path
58128575f16SDaniel Vetter 	 * for the port.
58228575f16SDaniel Vetter 	 */
58328575f16SDaniel Vetter 	struct drm_property *path_property;
58428575f16SDaniel Vetter 	/**
58528575f16SDaniel Vetter 	 * @tile_property: Default connector property to store the tile
58628575f16SDaniel Vetter 	 * position of a tiled screen, for sinks which need to be driven with
58728575f16SDaniel Vetter 	 * multiple CRTCs.
58828575f16SDaniel Vetter 	 */
58928575f16SDaniel Vetter 	struct drm_property *tile_property;
59028575f16SDaniel Vetter 	/**
59140ee6fbeSManasi Navare 	 * @link_status_property: Default connector property for link status
59240ee6fbeSManasi Navare 	 * of a connector
59340ee6fbeSManasi Navare 	 */
59440ee6fbeSManasi Navare 	struct drm_property *link_status_property;
59540ee6fbeSManasi Navare 	/**
59628575f16SDaniel Vetter 	 * @plane_type_property: Default plane property to differentiate
59728575f16SDaniel Vetter 	 * CURSOR, PRIMARY and OVERLAY legacy uses of planes.
59828575f16SDaniel Vetter 	 */
59928575f16SDaniel Vetter 	struct drm_property *plane_type_property;
60028575f16SDaniel Vetter 	/**
60128575f16SDaniel Vetter 	 * @prop_src_x: Default atomic plane property for the plane source
60228575f16SDaniel Vetter 	 * position in the connected &drm_framebuffer.
60328575f16SDaniel Vetter 	 */
60428575f16SDaniel Vetter 	struct drm_property *prop_src_x;
60528575f16SDaniel Vetter 	/**
60628575f16SDaniel Vetter 	 * @prop_src_y: Default atomic plane property for the plane source
60728575f16SDaniel Vetter 	 * position in the connected &drm_framebuffer.
60828575f16SDaniel Vetter 	 */
60928575f16SDaniel Vetter 	struct drm_property *prop_src_y;
61028575f16SDaniel Vetter 	/**
61128575f16SDaniel Vetter 	 * @prop_src_w: Default atomic plane property for the plane source
61228575f16SDaniel Vetter 	 * position in the connected &drm_framebuffer.
61328575f16SDaniel Vetter 	 */
61428575f16SDaniel Vetter 	struct drm_property *prop_src_w;
61528575f16SDaniel Vetter 	/**
61628575f16SDaniel Vetter 	 * @prop_src_h: Default atomic plane property for the plane source
61728575f16SDaniel Vetter 	 * position in the connected &drm_framebuffer.
61828575f16SDaniel Vetter 	 */
61928575f16SDaniel Vetter 	struct drm_property *prop_src_h;
62028575f16SDaniel Vetter 	/**
62128575f16SDaniel Vetter 	 * @prop_crtc_x: Default atomic plane property for the plane destination
622b9f3cfa2SRandy Dunlap 	 * position in the &drm_crtc is being shown on.
62328575f16SDaniel Vetter 	 */
62428575f16SDaniel Vetter 	struct drm_property *prop_crtc_x;
62528575f16SDaniel Vetter 	/**
62628575f16SDaniel Vetter 	 * @prop_crtc_y: Default atomic plane property for the plane destination
627b9f3cfa2SRandy Dunlap 	 * position in the &drm_crtc is being shown on.
62828575f16SDaniel Vetter 	 */
62928575f16SDaniel Vetter 	struct drm_property *prop_crtc_y;
63028575f16SDaniel Vetter 	/**
63128575f16SDaniel Vetter 	 * @prop_crtc_w: Default atomic plane property for the plane destination
632b9f3cfa2SRandy Dunlap 	 * position in the &drm_crtc is being shown on.
63328575f16SDaniel Vetter 	 */
63428575f16SDaniel Vetter 	struct drm_property *prop_crtc_w;
63528575f16SDaniel Vetter 	/**
63628575f16SDaniel Vetter 	 * @prop_crtc_h: Default atomic plane property for the plane destination
637b9f3cfa2SRandy Dunlap 	 * position in the &drm_crtc is being shown on.
63828575f16SDaniel Vetter 	 */
63928575f16SDaniel Vetter 	struct drm_property *prop_crtc_h;
64028575f16SDaniel Vetter 	/**
64128575f16SDaniel Vetter 	 * @prop_fb_id: Default atomic plane property to specify the
64228575f16SDaniel Vetter 	 * &drm_framebuffer.
64328575f16SDaniel Vetter 	 */
64428575f16SDaniel Vetter 	struct drm_property *prop_fb_id;
64528575f16SDaniel Vetter 	/**
64696260142SGustavo Padovan 	 * @prop_in_fence_fd: Sync File fd representing the incoming fences
64796260142SGustavo Padovan 	 * for a Plane.
64896260142SGustavo Padovan 	 */
64996260142SGustavo Padovan 	struct drm_property *prop_in_fence_fd;
65096260142SGustavo Padovan 	/**
651beaf5af4SGustavo Padovan 	 * @prop_out_fence_ptr: Sync File fd pointer representing the
652beaf5af4SGustavo Padovan 	 * outgoing fences for a CRTC. Userspace should provide a pointer to a
6537e9081c5SGustavo Padovan 	 * value of type s32, and then cast that pointer to u64.
654beaf5af4SGustavo Padovan 	 */
655beaf5af4SGustavo Padovan 	struct drm_property *prop_out_fence_ptr;
656beaf5af4SGustavo Padovan 	/**
65728575f16SDaniel Vetter 	 * @prop_crtc_id: Default atomic plane property to specify the
65828575f16SDaniel Vetter 	 * &drm_crtc.
65928575f16SDaniel Vetter 	 */
66028575f16SDaniel Vetter 	struct drm_property *prop_crtc_id;
66128575f16SDaniel Vetter 	/**
662d3b21767SLukasz Spintzyk 	 * @prop_fb_damage_clips: Optional plane property to mark damaged
663d3b21767SLukasz Spintzyk 	 * regions on the plane in framebuffer coordinates of the framebuffer
664d3b21767SLukasz Spintzyk 	 * attached to the plane.
665d3b21767SLukasz Spintzyk 	 *
666d3b21767SLukasz Spintzyk 	 * The layout of blob data is simply an array of &drm_mode_rect. Unlike
667d3b21767SLukasz Spintzyk 	 * plane src coordinates, damage clips are not in 16.16 fixed point.
668d3b21767SLukasz Spintzyk 	 */
669d3b21767SLukasz Spintzyk 	struct drm_property *prop_fb_damage_clips;
670d3b21767SLukasz Spintzyk 	/**
67128575f16SDaniel Vetter 	 * @prop_active: Default atomic CRTC property to control the active
67228575f16SDaniel Vetter 	 * state, which is the simplified implementation for DPMS in atomic
67328575f16SDaniel Vetter 	 * drivers.
67428575f16SDaniel Vetter 	 */
67528575f16SDaniel Vetter 	struct drm_property *prop_active;
67628575f16SDaniel Vetter 	/**
67728575f16SDaniel Vetter 	 * @prop_mode_id: Default atomic CRTC property to set the mode for a
67828575f16SDaniel Vetter 	 * CRTC. A 0 mode implies that the CRTC is entirely disabled - all
67928575f16SDaniel Vetter 	 * connectors must be of and active must be set to disabled, too.
68028575f16SDaniel Vetter 	 */
68128575f16SDaniel Vetter 	struct drm_property *prop_mode_id;
6821398958cSNicholas Kazlauskas 	/**
6831398958cSNicholas Kazlauskas 	 * @prop_vrr_enabled: Default atomic CRTC property to indicate
6841398958cSNicholas Kazlauskas 	 * whether variable refresh rate should be enabled on the CRTC.
6851398958cSNicholas Kazlauskas 	 */
6861398958cSNicholas Kazlauskas 	struct drm_property *prop_vrr_enabled;
68728575f16SDaniel Vetter 
68828575f16SDaniel Vetter 	/**
68928575f16SDaniel Vetter 	 * @dvi_i_subconnector_property: Optional DVI-I property to
69028575f16SDaniel Vetter 	 * differentiate between analog or digital mode.
69128575f16SDaniel Vetter 	 */
69228575f16SDaniel Vetter 	struct drm_property *dvi_i_subconnector_property;
69328575f16SDaniel Vetter 	/**
69428575f16SDaniel Vetter 	 * @dvi_i_select_subconnector_property: Optional DVI-I property to
69528575f16SDaniel Vetter 	 * select between analog or digital mode.
69628575f16SDaniel Vetter 	 */
69728575f16SDaniel Vetter 	struct drm_property *dvi_i_select_subconnector_property;
69828575f16SDaniel Vetter 
69928575f16SDaniel Vetter 	/**
700e5b92773SOleg Vasilev 	 * @dp_subconnector_property: Optional DP property to differentiate
701e5b92773SOleg Vasilev 	 * between different DP downstream port types.
702e5b92773SOleg Vasilev 	 */
703e5b92773SOleg Vasilev 	struct drm_property *dp_subconnector_property;
704e5b92773SOleg Vasilev 
705e5b92773SOleg Vasilev 	/**
70628575f16SDaniel Vetter 	 * @tv_subconnector_property: Optional TV property to differentiate
70728575f16SDaniel Vetter 	 * between different TV connector types.
70828575f16SDaniel Vetter 	 */
70928575f16SDaniel Vetter 	struct drm_property *tv_subconnector_property;
71028575f16SDaniel Vetter 	/**
71128575f16SDaniel Vetter 	 * @tv_select_subconnector_property: Optional TV property to select
71228575f16SDaniel Vetter 	 * between different TV connector types.
71328575f16SDaniel Vetter 	 */
71428575f16SDaniel Vetter 	struct drm_property *tv_select_subconnector_property;
71528575f16SDaniel Vetter 
71628575f16SDaniel Vetter 	/**
71728575f16SDaniel Vetter 	 * @legacy_tv_mode_property: Optional TV property to select
71828575f16SDaniel Vetter 	 * the output TV mode.
71928575f16SDaniel Vetter 	 *
72028575f16SDaniel Vetter 	 * Superseded by @tv_mode_property
72128575f16SDaniel Vetter 	 */
72256406e15SBoris Brezillon 	struct drm_property *legacy_tv_mode_property;
72328575f16SDaniel Vetter 
72428575f16SDaniel Vetter 	/**
72528575f16SDaniel Vetter 	 * @tv_mode_property: Optional TV property to select the TV
72628575f16SDaniel Vetter 	 * standard output on the connector.
72756406e15SBoris Brezillon 	 */
72828575f16SDaniel Vetter 	struct drm_property *tv_mode_property;
72928575f16SDaniel Vetter 
73028575f16SDaniel Vetter 	/**
73128575f16SDaniel Vetter 	 * @tv_left_margin_property: Optional TV property to set the left
73256406e15SBoris Brezillon 	 * margin (expressed in pixels).
73328575f16SDaniel Vetter 	 */
73428575f16SDaniel Vetter 	struct drm_property *tv_left_margin_property;
73528575f16SDaniel Vetter 	/**
73628575f16SDaniel Vetter 	 * @tv_right_margin_property: Optional TV property to set the right
73756406e15SBoris Brezillon 	 * margin (expressed in pixels).
73828575f16SDaniel Vetter 	 */
73928575f16SDaniel Vetter 	struct drm_property *tv_right_margin_property;
74028575f16SDaniel Vetter 	/**
74128575f16SDaniel Vetter 	 * @tv_top_margin_property: Optional TV property to set the right
74228575f16SDaniel Vetter 	 * margin (expressed in pixels).
74328575f16SDaniel Vetter 	 */
74428575f16SDaniel Vetter 	struct drm_property *tv_top_margin_property;
74528575f16SDaniel Vetter 	/**
74628575f16SDaniel Vetter 	 * @tv_bottom_margin_property: Optional TV property to set the right
74728575f16SDaniel Vetter 	 * margin (expressed in pixels).
74828575f16SDaniel Vetter 	 */
74928575f16SDaniel Vetter 	struct drm_property *tv_bottom_margin_property;
75028575f16SDaniel Vetter 	/**
75128575f16SDaniel Vetter 	 * @tv_brightness_property: Optional TV property to set the
75228575f16SDaniel Vetter 	 * brightness.
75328575f16SDaniel Vetter 	 */
75428575f16SDaniel Vetter 	struct drm_property *tv_brightness_property;
75528575f16SDaniel Vetter 	/**
75628575f16SDaniel Vetter 	 * @tv_contrast_property: Optional TV property to set the
75728575f16SDaniel Vetter 	 * contrast.
75828575f16SDaniel Vetter 	 */
75928575f16SDaniel Vetter 	struct drm_property *tv_contrast_property;
76028575f16SDaniel Vetter 	/**
76128575f16SDaniel Vetter 	 * @tv_flicker_reduction_property: Optional TV property to control the
76228575f16SDaniel Vetter 	 * flicker reduction mode.
76328575f16SDaniel Vetter 	 */
76428575f16SDaniel Vetter 	struct drm_property *tv_flicker_reduction_property;
76528575f16SDaniel Vetter 	/**
76628575f16SDaniel Vetter 	 * @tv_overscan_property: Optional TV property to control the overscan
76728575f16SDaniel Vetter 	 * setting.
76828575f16SDaniel Vetter 	 */
76928575f16SDaniel Vetter 	struct drm_property *tv_overscan_property;
77028575f16SDaniel Vetter 	/**
77128575f16SDaniel Vetter 	 * @tv_saturation_property: Optional TV property to set the
77228575f16SDaniel Vetter 	 * saturation.
77328575f16SDaniel Vetter 	 */
77428575f16SDaniel Vetter 	struct drm_property *tv_saturation_property;
77528575f16SDaniel Vetter 	/**
77628575f16SDaniel Vetter 	 * @tv_hue_property: Optional TV property to set the hue.
77728575f16SDaniel Vetter 	 */
77828575f16SDaniel Vetter 	struct drm_property *tv_hue_property;
77928575f16SDaniel Vetter 
78028575f16SDaniel Vetter 	/**
78150525c33SStanislav Lisovskiy 	 * @scaling_mode_property: Optional connector property to control the
78250525c33SStanislav Lisovskiy 	 * upscaling, mostly used for built-in panels.
78350525c33SStanislav Lisovskiy 	 */
78450525c33SStanislav Lisovskiy 	struct drm_property *scaling_mode_property;
78550525c33SStanislav Lisovskiy 	/**
78628575f16SDaniel Vetter 	 * @aspect_ratio_property: Optional connector property to control the
78728575f16SDaniel Vetter 	 * HDMI infoframe aspect ratio setting.
78828575f16SDaniel Vetter 	 */
78928575f16SDaniel Vetter 	struct drm_property *aspect_ratio_property;
79028575f16SDaniel Vetter 	/**
79128575f16SDaniel Vetter 	 * @content_type_property: Optional connector property to control the
79228575f16SDaniel Vetter 	 * HDMI infoframe content type setting.
79328575f16SDaniel Vetter 	 */
79428575f16SDaniel Vetter 	struct drm_property *content_type_property;
79528575f16SDaniel Vetter 	/**
79628575f16SDaniel Vetter 	 * @degamma_lut_property: Optional CRTC property to set the LUT used to
79728575f16SDaniel Vetter 	 * convert the framebuffer's colors to linear gamma.
79828575f16SDaniel Vetter 	 */
79928575f16SDaniel Vetter 	struct drm_property *degamma_lut_property;
80028575f16SDaniel Vetter 	/**
80128575f16SDaniel Vetter 	 * @degamma_lut_size_property: Optional CRTC property for the size of
80228575f16SDaniel Vetter 	 * the degamma LUT as supported by the driver (read-only).
80328575f16SDaniel Vetter 	 */
80428575f16SDaniel Vetter 	struct drm_property *degamma_lut_size_property;
80528575f16SDaniel Vetter 	/**
80628575f16SDaniel Vetter 	 * @ctm_property: Optional CRTC property to set the
80728575f16SDaniel Vetter 	 * matrix used to convert colors after the lookup in the
80828575f16SDaniel Vetter 	 * degamma LUT.
80928575f16SDaniel Vetter 	 */
81028575f16SDaniel Vetter 	struct drm_property *ctm_property;
81128575f16SDaniel Vetter 	/**
81228575f16SDaniel Vetter 	 * @gamma_lut_property: Optional CRTC property to set the LUT used to
81328575f16SDaniel Vetter 	 * convert the colors, after the CTM matrix, to the gamma space of the
81428575f16SDaniel Vetter 	 * connected screen.
81528575f16SDaniel Vetter 	 */
81628575f16SDaniel Vetter 	struct drm_property *gamma_lut_property;
81728575f16SDaniel Vetter 	/**
81828575f16SDaniel Vetter 	 * @gamma_lut_size_property: Optional CRTC property for the size of the
81928575f16SDaniel Vetter 	 * gamma LUT as supported by the driver (read-only).
82028575f16SDaniel Vetter 	 */
82128575f16SDaniel Vetter 	struct drm_property *gamma_lut_size_property;
82228575f16SDaniel Vetter 
82328575f16SDaniel Vetter 	/**
82466660d4cSDave Airlie 	 * @suggested_x_property: Optional connector property with a hint for
82566660d4cSDave Airlie 	 * the position of the output on the host's screen.
82666660d4cSDave Airlie 	 */
82766660d4cSDave Airlie 	struct drm_property *suggested_x_property;
82866660d4cSDave Airlie 	/**
82966660d4cSDave Airlie 	 * @suggested_y_property: Optional connector property with a hint for
83066660d4cSDave Airlie 	 * the position of the output on the host's screen.
8318d70f395SHans de Goede 	 */
8328d70f395SHans de Goede 	struct drm_property *suggested_y_property;
8338d70f395SHans de Goede 
8348d70f395SHans de Goede 	/**
8358d70f395SHans de Goede 	 * @non_desktop_property: Optional connector property with a hint
8368d70f395SHans de Goede 	 * that device isn't a standard display, and the console/desktop,
8378d70f395SHans de Goede 	 * should not be displayed on it.
838935774cdSBrian Starkey 	 */
839935774cdSBrian Starkey 	struct drm_property *non_desktop_property;
840935774cdSBrian Starkey 
841935774cdSBrian Starkey 	/**
842935774cdSBrian Starkey 	 * @panel_orientation_property: Optional connector property indicating
843935774cdSBrian Starkey 	 * how the lcd-panel is mounted inside the casing (e.g. normal or
844935774cdSBrian Starkey 	 * upside-down).
845935774cdSBrian Starkey 	 */
846935774cdSBrian Starkey 	struct drm_property *panel_orientation_property;
847935774cdSBrian Starkey 
848935774cdSBrian Starkey 	/**
849935774cdSBrian Starkey 	 * @writeback_fb_id_property: Property for writeback connectors, storing
850935774cdSBrian Starkey 	 * the ID of the output framebuffer.
851935774cdSBrian Starkey 	 * See also: drm_writeback_connector_init()
852b13cc8ddSBrian Starkey 	 */
853b13cc8ddSBrian Starkey 	struct drm_property *writeback_fb_id_property;
854b13cc8ddSBrian Starkey 
855b13cc8ddSBrian Starkey 	/**
856b13cc8ddSBrian Starkey 	 * @writeback_pixel_formats_property: Property for writeback connectors,
857b13cc8ddSBrian Starkey 	 * storing an array of the supported pixel formats for the writeback
858b13cc8ddSBrian Starkey 	 * engine (read-only).
859b13cc8ddSBrian Starkey 	 * See also: drm_writeback_connector_init()
860935774cdSBrian Starkey 	 */
861fbb5d035SUma Shankar 	struct drm_property *writeback_pixel_formats_property;
862a09db883SUma Shankar 	/**
863a09db883SUma Shankar 	 * @writeback_out_fence_ptr_property: Property for writeback connectors,
864fbb5d035SUma Shankar 	 * fd pointer representing the outgoing fences for a writeback
865fbb5d035SUma Shankar 	 * connector. Userspace should provide a pointer to a value of type s32,
866fbb5d035SUma Shankar 	 * and then cast that pointer to u64.
867fbb5d035SUma Shankar 	 * See also: drm_writeback_connector_init()
86814ee642cSDave Airlie 	 */
869585b000dSRamalingam C 	struct drm_property *writeback_out_fence_ptr_property;
870585b000dSRamalingam C 
871585b000dSRamalingam C 	/**
872585b000dSRamalingam C 	 * @hdr_output_metadata_property: Connector property containing hdr
873585b000dSRamalingam C 	 * metatada. This will be provided by userspace compositors based
8747672dbbaSRamalingam C 	 * on HDR content
8757672dbbaSRamalingam C 	 */
8767672dbbaSRamalingam C 	struct drm_property *hdr_output_metadata_property;
8777672dbbaSRamalingam C 
8787672dbbaSRamalingam C 	/**
8797672dbbaSRamalingam C 	 * @content_protection_property: DRM ENUM property for content
88028575f16SDaniel Vetter 	 * protection. See drm_connector_attach_content_protection_property().
88128575f16SDaniel Vetter 	 */
8826217f0ecSDaniel Vetter 	struct drm_property *content_protection_property;
8836217f0ecSDaniel Vetter 
884f458579eSThomas Zimmermann 	/**
885f458579eSThomas Zimmermann 	 * @hdcp_content_type_property: DRM ENUM property for type of
886f458579eSThomas Zimmermann 	 * Protected Content.
887f458579eSThomas Zimmermann 	 */
888f458579eSThomas Zimmermann 	struct drm_property *hdcp_content_type_property;
889f458579eSThomas Zimmermann 
890f458579eSThomas Zimmermann 	/* dumb ioctl parameters */
8916217f0ecSDaniel Vetter 	uint32_t preferred_depth, prefer_shadow;
8926217f0ecSDaniel Vetter 
8936217f0ecSDaniel Vetter 	/**
8946217f0ecSDaniel Vetter 	 * @quirk_addfb_prefer_xbgr_30bpp:
8956217f0ecSDaniel Vetter 	 *
8960e94043eSGerd Hoffmann 	 * Special hack for legacy ADDFB to keep nouveau userspace happy. Should
89728575f16SDaniel Vetter 	 * only ever be set by the nouveau kernel driver.
89828575f16SDaniel Vetter 	 */
8996960e6daSGerd Hoffmann 	bool quirk_addfb_prefer_xbgr_30bpp;
9006960e6daSGerd Hoffmann 
9016960e6daSGerd Hoffmann 	/**
9026960e6daSGerd Hoffmann 	 * @quirk_addfb_prefer_host_byte_order:
9036960e6daSGerd Hoffmann 	 *
9046960e6daSGerd Hoffmann 	 * When set to true drm_mode_addfb() will pick host byte order
9056960e6daSGerd Hoffmann 	 * pixel_format when calling drm_mode_addfb2().  This is how
9066960e6daSGerd Hoffmann 	 * drm_mode_addfb() should have worked from day one.  It
9076960e6daSGerd Hoffmann 	 * didn't though, so we ended up with quirks in both kernel
9086960e6daSGerd Hoffmann 	 * and userspace drivers to deal with the broken behavior.
9096960e6daSGerd Hoffmann 	 * Simply fixing drm_mode_addfb() unconditionally would break
9106960e6daSGerd Hoffmann 	 * these drivers, so add a quirk bit here to allow drivers
9116960e6daSGerd Hoffmann 	 * opt-in.
9126960e6daSGerd Hoffmann 	 */
91328575f16SDaniel Vetter 	bool quirk_addfb_prefer_host_byte_order;
91428575f16SDaniel Vetter 
91528575f16SDaniel Vetter 	/**
91628575f16SDaniel Vetter 	 * @async_page_flip: Does this device support async flips on the primary
91728575f16SDaniel Vetter 	 * plane?
91828575f16SDaniel Vetter 	 */
919*2af10429STomohito Esaki 	bool async_page_flip;
920*2af10429STomohito Esaki 
921*2af10429STomohito Esaki 	/**
922*2af10429STomohito Esaki 	 * @fb_modifiers_not_supported:
923*2af10429STomohito Esaki 	 *
924*2af10429STomohito Esaki 	 * When this flag is set, the DRM device will not expose modifier
925*2af10429STomohito Esaki 	 * support to userspace. This is only used by legacy drivers that infer
926*2af10429STomohito Esaki 	 * the buffer layout through heuristics without using modifiers. New
927*2af10429STomohito Esaki 	 * drivers shall not set fhis flag.
928*2af10429STomohito Esaki 	 */
92949efffc7SPeter Ujfalusi 	bool fb_modifiers_not_supported;
93049efffc7SPeter Ujfalusi 
93149efffc7SPeter Ujfalusi 	/**
93249efffc7SPeter Ujfalusi 	 * @normalize_zpos:
93349efffc7SPeter Ujfalusi 	 *
93449efffc7SPeter Ujfalusi 	 * If true the drm core will call drm_atomic_normalize_zpos() as part of
93549efffc7SPeter Ujfalusi 	 * atomic mode checking from drm_atomic_helper_check()
93649efffc7SPeter Ujfalusi 	 */
937dadcc5e0SVille Syrjälä 	bool normalize_zpos;
938db1689aaSBen Widawsky 
939db1689aaSBen Widawsky 	/**
940db1689aaSBen Widawsky 	 * @modifiers_property: Plane property to list support modifier/format
941db1689aaSBen Widawsky 	 * combination.
94228575f16SDaniel Vetter 	 */
94328575f16SDaniel Vetter 	struct drm_property *modifiers_property;
94428575f16SDaniel Vetter 
945ca038cfbSNoralf Trønnes 	/* cursor size */
946ca038cfbSNoralf Trønnes 	uint32_t cursor_width, cursor_height;
947ca038cfbSNoralf Trønnes 
948ca038cfbSNoralf Trønnes 	/**
949ca038cfbSNoralf Trønnes 	 * @suspend_state:
950ca038cfbSNoralf Trønnes 	 *
951ca038cfbSNoralf Trønnes 	 * Atomic state when suspended.
952ca038cfbSNoralf Trønnes 	 * Set by drm_mode_config_helper_suspend() and cleared by
953ca038cfbSNoralf Trønnes 	 * drm_mode_config_helper_resume().
954a4b10cceSLaurent Pinchart 	 */
95528575f16SDaniel Vetter 	struct drm_atomic_state *suspend_state;
95628575f16SDaniel Vetter 
957c3b790eaSDaniel Vetter 	const struct drm_mode_config_helper_funcs *helper_private;
958c3b790eaSDaniel Vetter };
959c3b790eaSDaniel Vetter 
960c3b790eaSDaniel Vetter int __must_check drmm_mode_config_init(struct drm_device *dev);
961c3b790eaSDaniel Vetter 
962c3b790eaSDaniel Vetter /**
963c3b790eaSDaniel Vetter  * drm_mode_config_init - DRM mode_configuration structure initialization
964c3b790eaSDaniel Vetter  * @dev: DRM device
965c3b790eaSDaniel Vetter  *
966c3b790eaSDaniel Vetter  * This is the unmanaged version of drmm_mode_config_init() for drivers which
967c3b790eaSDaniel Vetter  * still explicitly call drm_mode_config_cleanup().
968c3b790eaSDaniel Vetter  *
969c3b790eaSDaniel Vetter  * FIXME: This function is deprecated and drivers should be converted over to
970c3b790eaSDaniel Vetter  * drmm_mode_config_init().
971c3b790eaSDaniel Vetter  */
drm_mode_config_init(struct drm_device * dev)972c3b790eaSDaniel Vetter static inline int drm_mode_config_init(struct drm_device *dev)
973c3b790eaSDaniel Vetter {
97428575f16SDaniel Vetter 	return drmm_mode_config_init(dev);
97528575f16SDaniel Vetter }
97628575f16SDaniel Vetter 
97728575f16SDaniel Vetter void drm_mode_config_reset(struct drm_device *dev);
978 void drm_mode_config_cleanup(struct drm_device *dev);
979 
980 #endif
981