xref: /OK3568_Linux_fs/kernel/include/drm/drm_mode_config.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (c) 2016 Intel Corporation
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Permission to use, copy, modify, distribute, and sell this software and its
5*4882a593Smuzhiyun  * documentation for any purpose is hereby granted without fee, provided that
6*4882a593Smuzhiyun  * the above copyright notice appear in all copies and that both that copyright
7*4882a593Smuzhiyun  * notice and this permission notice appear in supporting documentation, and
8*4882a593Smuzhiyun  * that the name of the copyright holders not be used in advertising or
9*4882a593Smuzhiyun  * publicity pertaining to distribution of the software without specific,
10*4882a593Smuzhiyun  * written prior permission.  The copyright holders make no representations
11*4882a593Smuzhiyun  * about the suitability of this software for any purpose.  It is provided "as
12*4882a593Smuzhiyun  * is" without express or implied warranty.
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15*4882a593Smuzhiyun  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16*4882a593Smuzhiyun  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17*4882a593Smuzhiyun  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18*4882a593Smuzhiyun  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19*4882a593Smuzhiyun  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20*4882a593Smuzhiyun  * OF THIS SOFTWARE.
21*4882a593Smuzhiyun  */
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #ifndef __DRM_MODE_CONFIG_H__
24*4882a593Smuzhiyun #define __DRM_MODE_CONFIG_H__
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun #include <linux/mutex.h>
27*4882a593Smuzhiyun #include <linux/types.h>
28*4882a593Smuzhiyun #include <linux/idr.h>
29*4882a593Smuzhiyun #include <linux/workqueue.h>
30*4882a593Smuzhiyun #include <linux/llist.h>
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #include <drm/drm_modeset_lock.h>
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun struct drm_file;
35*4882a593Smuzhiyun struct drm_device;
36*4882a593Smuzhiyun struct drm_atomic_state;
37*4882a593Smuzhiyun struct drm_mode_fb_cmd2;
38*4882a593Smuzhiyun struct drm_format_info;
39*4882a593Smuzhiyun struct drm_display_mode;
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun /**
42*4882a593Smuzhiyun  * struct drm_mode_config_funcs - basic driver provided mode setting functions
43*4882a593Smuzhiyun  *
44*4882a593Smuzhiyun  * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
45*4882a593Smuzhiyun  * involve drivers.
46*4882a593Smuzhiyun  */
47*4882a593Smuzhiyun struct drm_mode_config_funcs {
48*4882a593Smuzhiyun 	/**
49*4882a593Smuzhiyun 	 * @fb_create:
50*4882a593Smuzhiyun 	 *
51*4882a593Smuzhiyun 	 * Create a new framebuffer object. The core does basic checks on the
52*4882a593Smuzhiyun 	 * requested metadata, but most of that is left to the driver. See
53*4882a593Smuzhiyun 	 * &struct drm_mode_fb_cmd2 for details.
54*4882a593Smuzhiyun 	 *
55*4882a593Smuzhiyun 	 * To validate the pixel format and modifier drivers can use
56*4882a593Smuzhiyun 	 * drm_any_plane_has_format() to make sure at least one plane supports
57*4882a593Smuzhiyun 	 * the requested values. Note that the driver must first determine the
58*4882a593Smuzhiyun 	 * actual modifier used if the request doesn't have it specified,
59*4882a593Smuzhiyun 	 * ie. when (@mode_cmd->flags & DRM_MODE_FB_MODIFIERS) == 0.
60*4882a593Smuzhiyun 	 *
61*4882a593Smuzhiyun 	 * If the parameters are deemed valid and the backing storage objects in
62*4882a593Smuzhiyun 	 * the underlying memory manager all exist, then the driver allocates
63*4882a593Smuzhiyun 	 * a new &drm_framebuffer structure, subclassed to contain
64*4882a593Smuzhiyun 	 * driver-specific information (like the internal native buffer object
65*4882a593Smuzhiyun 	 * references). It also needs to fill out all relevant metadata, which
66*4882a593Smuzhiyun 	 * should be done by calling drm_helper_mode_fill_fb_struct().
67*4882a593Smuzhiyun 	 *
68*4882a593Smuzhiyun 	 * The initialization is finalized by calling drm_framebuffer_init(),
69*4882a593Smuzhiyun 	 * which registers the framebuffer and makes it accessible to other
70*4882a593Smuzhiyun 	 * threads.
71*4882a593Smuzhiyun 	 *
72*4882a593Smuzhiyun 	 * RETURNS:
73*4882a593Smuzhiyun 	 *
74*4882a593Smuzhiyun 	 * A new framebuffer with an initial reference count of 1 or a negative
75*4882a593Smuzhiyun 	 * error code encoded with ERR_PTR().
76*4882a593Smuzhiyun 	 */
77*4882a593Smuzhiyun 	struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
78*4882a593Smuzhiyun 					     struct drm_file *file_priv,
79*4882a593Smuzhiyun 					     const struct drm_mode_fb_cmd2 *mode_cmd);
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun 	/**
82*4882a593Smuzhiyun 	 * @get_format_info:
83*4882a593Smuzhiyun 	 *
84*4882a593Smuzhiyun 	 * Allows a driver to return custom format information for special
85*4882a593Smuzhiyun 	 * fb layouts (eg. ones with auxiliary compression control planes).
86*4882a593Smuzhiyun 	 *
87*4882a593Smuzhiyun 	 * RETURNS:
88*4882a593Smuzhiyun 	 *
89*4882a593Smuzhiyun 	 * The format information specific to the given fb metadata, or
90*4882a593Smuzhiyun 	 * NULL if none is found.
91*4882a593Smuzhiyun 	 */
92*4882a593Smuzhiyun 	const struct drm_format_info *(*get_format_info)(const struct drm_mode_fb_cmd2 *mode_cmd);
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun 	/**
95*4882a593Smuzhiyun 	 * @output_poll_changed:
96*4882a593Smuzhiyun 	 *
97*4882a593Smuzhiyun 	 * Callback used by helpers to inform the driver of output configuration
98*4882a593Smuzhiyun 	 * changes.
99*4882a593Smuzhiyun 	 *
100*4882a593Smuzhiyun 	 * Drivers implementing fbdev emulation with the helpers can call
101*4882a593Smuzhiyun 	 * drm_fb_helper_hotplug_changed from this hook to inform the fbdev
102*4882a593Smuzhiyun 	 * helper of output changes.
103*4882a593Smuzhiyun 	 *
104*4882a593Smuzhiyun 	 * FIXME:
105*4882a593Smuzhiyun 	 *
106*4882a593Smuzhiyun 	 * Except that there's no vtable for device-level helper callbacks
107*4882a593Smuzhiyun 	 * there's no reason this is a core function.
108*4882a593Smuzhiyun 	 */
109*4882a593Smuzhiyun 	void (*output_poll_changed)(struct drm_device *dev);
110*4882a593Smuzhiyun 
111*4882a593Smuzhiyun 	/**
112*4882a593Smuzhiyun 	 * @mode_valid:
113*4882a593Smuzhiyun 	 *
114*4882a593Smuzhiyun 	 * Device specific validation of display modes. Can be used to reject
115*4882a593Smuzhiyun 	 * modes that can never be supported. Only device wide constraints can
116*4882a593Smuzhiyun 	 * be checked here. crtc/encoder/bridge/connector specific constraints
117*4882a593Smuzhiyun 	 * should be checked in the .mode_valid() hook for each specific object.
118*4882a593Smuzhiyun 	 */
119*4882a593Smuzhiyun 	enum drm_mode_status (*mode_valid)(struct drm_device *dev,
120*4882a593Smuzhiyun 					   const struct drm_display_mode *mode);
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun 	/**
123*4882a593Smuzhiyun 	 * @atomic_check:
124*4882a593Smuzhiyun 	 *
125*4882a593Smuzhiyun 	 * This is the only hook to validate an atomic modeset update. This
126*4882a593Smuzhiyun 	 * function must reject any modeset and state changes which the hardware
127*4882a593Smuzhiyun 	 * or driver doesn't support. This includes but is of course not limited
128*4882a593Smuzhiyun 	 * to:
129*4882a593Smuzhiyun 	 *
130*4882a593Smuzhiyun 	 *  - Checking that the modes, framebuffers, scaling and placement
131*4882a593Smuzhiyun 	 *    requirements and so on are within the limits of the hardware.
132*4882a593Smuzhiyun 	 *
133*4882a593Smuzhiyun 	 *  - Checking that any hidden shared resources are not oversubscribed.
134*4882a593Smuzhiyun 	 *    This can be shared PLLs, shared lanes, overall memory bandwidth,
135*4882a593Smuzhiyun 	 *    display fifo space (where shared between planes or maybe even
136*4882a593Smuzhiyun 	 *    CRTCs).
137*4882a593Smuzhiyun 	 *
138*4882a593Smuzhiyun 	 *  - Checking that virtualized resources exported to userspace are not
139*4882a593Smuzhiyun 	 *    oversubscribed. For various reasons it can make sense to expose
140*4882a593Smuzhiyun 	 *    more planes, crtcs or encoders than which are physically there. One
141*4882a593Smuzhiyun 	 *    example is dual-pipe operations (which generally should be hidden
142*4882a593Smuzhiyun 	 *    from userspace if when lockstepped in hardware, exposed otherwise),
143*4882a593Smuzhiyun 	 *    where a plane might need 1 hardware plane (if it's just on one
144*4882a593Smuzhiyun 	 *    pipe), 2 hardware planes (when it spans both pipes) or maybe even
145*4882a593Smuzhiyun 	 *    shared a hardware plane with a 2nd plane (if there's a compatible
146*4882a593Smuzhiyun 	 *    plane requested on the area handled by the other pipe).
147*4882a593Smuzhiyun 	 *
148*4882a593Smuzhiyun 	 *  - Check that any transitional state is possible and that if
149*4882a593Smuzhiyun 	 *    requested, the update can indeed be done in the vblank period
150*4882a593Smuzhiyun 	 *    without temporarily disabling some functions.
151*4882a593Smuzhiyun 	 *
152*4882a593Smuzhiyun 	 *  - Check any other constraints the driver or hardware might have.
153*4882a593Smuzhiyun 	 *
154*4882a593Smuzhiyun 	 *  - This callback also needs to correctly fill out the &drm_crtc_state
155*4882a593Smuzhiyun 	 *    in this update to make sure that drm_atomic_crtc_needs_modeset()
156*4882a593Smuzhiyun 	 *    reflects the nature of the possible update and returns true if and
157*4882a593Smuzhiyun 	 *    only if the update cannot be applied without tearing within one
158*4882a593Smuzhiyun 	 *    vblank on that CRTC. The core uses that information to reject
159*4882a593Smuzhiyun 	 *    updates which require a full modeset (i.e. blanking the screen, or
160*4882a593Smuzhiyun 	 *    at least pausing updates for a substantial amount of time) if
161*4882a593Smuzhiyun 	 *    userspace has disallowed that in its request.
162*4882a593Smuzhiyun 	 *
163*4882a593Smuzhiyun 	 *  - The driver also does not need to repeat basic input validation
164*4882a593Smuzhiyun 	 *    like done for the corresponding legacy entry points. The core does
165*4882a593Smuzhiyun 	 *    that before calling this hook.
166*4882a593Smuzhiyun 	 *
167*4882a593Smuzhiyun 	 * See the documentation of @atomic_commit for an exhaustive list of
168*4882a593Smuzhiyun 	 * error conditions which don't have to be checked at the in this
169*4882a593Smuzhiyun 	 * callback.
170*4882a593Smuzhiyun 	 *
171*4882a593Smuzhiyun 	 * See the documentation for &struct drm_atomic_state for how exactly
172*4882a593Smuzhiyun 	 * an atomic modeset update is described.
173*4882a593Smuzhiyun 	 *
174*4882a593Smuzhiyun 	 * Drivers using the atomic helpers can implement this hook using
175*4882a593Smuzhiyun 	 * drm_atomic_helper_check(), or one of the exported sub-functions of
176*4882a593Smuzhiyun 	 * it.
177*4882a593Smuzhiyun 	 *
178*4882a593Smuzhiyun 	 * RETURNS:
179*4882a593Smuzhiyun 	 *
180*4882a593Smuzhiyun 	 * 0 on success or one of the below negative error codes:
181*4882a593Smuzhiyun 	 *
182*4882a593Smuzhiyun 	 *  - -EINVAL, if any of the above constraints are violated.
183*4882a593Smuzhiyun 	 *
184*4882a593Smuzhiyun 	 *  - -EDEADLK, when returned from an attempt to acquire an additional
185*4882a593Smuzhiyun 	 *    &drm_modeset_lock through drm_modeset_lock().
186*4882a593Smuzhiyun 	 *
187*4882a593Smuzhiyun 	 *  - -ENOMEM, if allocating additional state sub-structures failed due
188*4882a593Smuzhiyun 	 *    to lack of memory.
189*4882a593Smuzhiyun 	 *
190*4882a593Smuzhiyun 	 *  - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted.
191*4882a593Smuzhiyun 	 *    This can either be due to a pending signal, or because the driver
192*4882a593Smuzhiyun 	 *    needs to completely bail out to recover from an exceptional
193*4882a593Smuzhiyun 	 *    situation like a GPU hang. From a userspace point all errors are
194*4882a593Smuzhiyun 	 *    treated equally.
195*4882a593Smuzhiyun 	 */
196*4882a593Smuzhiyun 	int (*atomic_check)(struct drm_device *dev,
197*4882a593Smuzhiyun 			    struct drm_atomic_state *state);
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun 	/**
200*4882a593Smuzhiyun 	 * @atomic_commit:
201*4882a593Smuzhiyun 	 *
202*4882a593Smuzhiyun 	 * This is the only hook to commit an atomic modeset update. The core
203*4882a593Smuzhiyun 	 * guarantees that @atomic_check has been called successfully before
204*4882a593Smuzhiyun 	 * calling this function, and that nothing has been changed in the
205*4882a593Smuzhiyun 	 * interim.
206*4882a593Smuzhiyun 	 *
207*4882a593Smuzhiyun 	 * See the documentation for &struct drm_atomic_state for how exactly
208*4882a593Smuzhiyun 	 * an atomic modeset update is described.
209*4882a593Smuzhiyun 	 *
210*4882a593Smuzhiyun 	 * Drivers using the atomic helpers can implement this hook using
211*4882a593Smuzhiyun 	 * drm_atomic_helper_commit(), or one of the exported sub-functions of
212*4882a593Smuzhiyun 	 * it.
213*4882a593Smuzhiyun 	 *
214*4882a593Smuzhiyun 	 * Nonblocking commits (as indicated with the nonblock parameter) must
215*4882a593Smuzhiyun 	 * do any preparatory work which might result in an unsuccessful commit
216*4882a593Smuzhiyun 	 * in the context of this callback. The only exceptions are hardware
217*4882a593Smuzhiyun 	 * errors resulting in -EIO. But even in that case the driver must
218*4882a593Smuzhiyun 	 * ensure that the display pipe is at least running, to avoid
219*4882a593Smuzhiyun 	 * compositors crashing when pageflips don't work. Anything else,
220*4882a593Smuzhiyun 	 * specifically committing the update to the hardware, should be done
221*4882a593Smuzhiyun 	 * without blocking the caller. For updates which do not require a
222*4882a593Smuzhiyun 	 * modeset this must be guaranteed.
223*4882a593Smuzhiyun 	 *
224*4882a593Smuzhiyun 	 * The driver must wait for any pending rendering to the new
225*4882a593Smuzhiyun 	 * framebuffers to complete before executing the flip. It should also
226*4882a593Smuzhiyun 	 * wait for any pending rendering from other drivers if the underlying
227*4882a593Smuzhiyun 	 * buffer is a shared dma-buf. Nonblocking commits must not wait for
228*4882a593Smuzhiyun 	 * rendering in the context of this callback.
229*4882a593Smuzhiyun 	 *
230*4882a593Smuzhiyun 	 * An application can request to be notified when the atomic commit has
231*4882a593Smuzhiyun 	 * completed. These events are per-CRTC and can be distinguished by the
232*4882a593Smuzhiyun 	 * CRTC index supplied in &drm_event to userspace.
233*4882a593Smuzhiyun 	 *
234*4882a593Smuzhiyun 	 * The drm core will supply a &struct drm_event in each CRTC's
235*4882a593Smuzhiyun 	 * &drm_crtc_state.event. See the documentation for
236*4882a593Smuzhiyun 	 * &drm_crtc_state.event for more details about the precise semantics of
237*4882a593Smuzhiyun 	 * this event.
238*4882a593Smuzhiyun 	 *
239*4882a593Smuzhiyun 	 * NOTE:
240*4882a593Smuzhiyun 	 *
241*4882a593Smuzhiyun 	 * Drivers are not allowed to shut down any display pipe successfully
242*4882a593Smuzhiyun 	 * enabled through an atomic commit on their own. Doing so can result in
243*4882a593Smuzhiyun 	 * compositors crashing if a page flip is suddenly rejected because the
244*4882a593Smuzhiyun 	 * pipe is off.
245*4882a593Smuzhiyun 	 *
246*4882a593Smuzhiyun 	 * RETURNS:
247*4882a593Smuzhiyun 	 *
248*4882a593Smuzhiyun 	 * 0 on success or one of the below negative error codes:
249*4882a593Smuzhiyun 	 *
250*4882a593Smuzhiyun 	 *  - -EBUSY, if a nonblocking updated is requested and there is
251*4882a593Smuzhiyun 	 *    an earlier updated pending. Drivers are allowed to support a queue
252*4882a593Smuzhiyun 	 *    of outstanding updates, but currently no driver supports that.
253*4882a593Smuzhiyun 	 *    Note that drivers must wait for preceding updates to complete if a
254*4882a593Smuzhiyun 	 *    synchronous update is requested, they are not allowed to fail the
255*4882a593Smuzhiyun 	 *    commit in that case.
256*4882a593Smuzhiyun 	 *
257*4882a593Smuzhiyun 	 *  - -ENOMEM, if the driver failed to allocate memory. Specifically
258*4882a593Smuzhiyun 	 *    this can happen when trying to pin framebuffers, which must only
259*4882a593Smuzhiyun 	 *    be done when committing the state.
260*4882a593Smuzhiyun 	 *
261*4882a593Smuzhiyun 	 *  - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate
262*4882a593Smuzhiyun 	 *    that the driver has run out of vram, iommu space or similar GPU
263*4882a593Smuzhiyun 	 *    address space needed for framebuffer.
264*4882a593Smuzhiyun 	 *
265*4882a593Smuzhiyun 	 *  - -EIO, if the hardware completely died.
266*4882a593Smuzhiyun 	 *
267*4882a593Smuzhiyun 	 *  - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted.
268*4882a593Smuzhiyun 	 *    This can either be due to a pending signal, or because the driver
269*4882a593Smuzhiyun 	 *    needs to completely bail out to recover from an exceptional
270*4882a593Smuzhiyun 	 *    situation like a GPU hang. From a userspace point of view all errors are
271*4882a593Smuzhiyun 	 *    treated equally.
272*4882a593Smuzhiyun 	 *
273*4882a593Smuzhiyun 	 * This list is exhaustive. Specifically this hook is not allowed to
274*4882a593Smuzhiyun 	 * return -EINVAL (any invalid requests should be caught in
275*4882a593Smuzhiyun 	 * @atomic_check) or -EDEADLK (this function must not acquire
276*4882a593Smuzhiyun 	 * additional modeset locks).
277*4882a593Smuzhiyun 	 */
278*4882a593Smuzhiyun 	int (*atomic_commit)(struct drm_device *dev,
279*4882a593Smuzhiyun 			     struct drm_atomic_state *state,
280*4882a593Smuzhiyun 			     bool nonblock);
281*4882a593Smuzhiyun 
282*4882a593Smuzhiyun 	/**
283*4882a593Smuzhiyun 	 * @atomic_state_alloc:
284*4882a593Smuzhiyun 	 *
285*4882a593Smuzhiyun 	 * This optional hook can be used by drivers that want to subclass struct
286*4882a593Smuzhiyun 	 * &drm_atomic_state to be able to track their own driver-private global
287*4882a593Smuzhiyun 	 * state easily. If this hook is implemented, drivers must also
288*4882a593Smuzhiyun 	 * implement @atomic_state_clear and @atomic_state_free.
289*4882a593Smuzhiyun 	 *
290*4882a593Smuzhiyun 	 * Subclassing of &drm_atomic_state is deprecated in favour of using
291*4882a593Smuzhiyun 	 * &drm_private_state and &drm_private_obj.
292*4882a593Smuzhiyun 	 *
293*4882a593Smuzhiyun 	 * RETURNS:
294*4882a593Smuzhiyun 	 *
295*4882a593Smuzhiyun 	 * A new &drm_atomic_state on success or NULL on failure.
296*4882a593Smuzhiyun 	 */
297*4882a593Smuzhiyun 	struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev);
298*4882a593Smuzhiyun 
299*4882a593Smuzhiyun 	/**
300*4882a593Smuzhiyun 	 * @atomic_state_clear:
301*4882a593Smuzhiyun 	 *
302*4882a593Smuzhiyun 	 * This hook must clear any driver private state duplicated into the
303*4882a593Smuzhiyun 	 * passed-in &drm_atomic_state. This hook is called when the caller
304*4882a593Smuzhiyun 	 * encountered a &drm_modeset_lock deadlock and needs to drop all
305*4882a593Smuzhiyun 	 * already acquired locks as part of the deadlock avoidance dance
306*4882a593Smuzhiyun 	 * implemented in drm_modeset_backoff().
307*4882a593Smuzhiyun 	 *
308*4882a593Smuzhiyun 	 * Any duplicated state must be invalidated since a concurrent atomic
309*4882a593Smuzhiyun 	 * update might change it, and the drm atomic interfaces always apply
310*4882a593Smuzhiyun 	 * updates as relative changes to the current state.
311*4882a593Smuzhiyun 	 *
312*4882a593Smuzhiyun 	 * Drivers that implement this must call drm_atomic_state_default_clear()
313*4882a593Smuzhiyun 	 * to clear common state.
314*4882a593Smuzhiyun 	 *
315*4882a593Smuzhiyun 	 * Subclassing of &drm_atomic_state is deprecated in favour of using
316*4882a593Smuzhiyun 	 * &drm_private_state and &drm_private_obj.
317*4882a593Smuzhiyun 	 */
318*4882a593Smuzhiyun 	void (*atomic_state_clear)(struct drm_atomic_state *state);
319*4882a593Smuzhiyun 
320*4882a593Smuzhiyun 	/**
321*4882a593Smuzhiyun 	 * @atomic_state_free:
322*4882a593Smuzhiyun 	 *
323*4882a593Smuzhiyun 	 * This hook needs driver private resources and the &drm_atomic_state
324*4882a593Smuzhiyun 	 * itself. Note that the core first calls drm_atomic_state_clear() to
325*4882a593Smuzhiyun 	 * avoid code duplicate between the clear and free hooks.
326*4882a593Smuzhiyun 	 *
327*4882a593Smuzhiyun 	 * Drivers that implement this must call
328*4882a593Smuzhiyun 	 * drm_atomic_state_default_release() to release common resources.
329*4882a593Smuzhiyun 	 *
330*4882a593Smuzhiyun 	 * Subclassing of &drm_atomic_state is deprecated in favour of using
331*4882a593Smuzhiyun 	 * &drm_private_state and &drm_private_obj.
332*4882a593Smuzhiyun 	 */
333*4882a593Smuzhiyun 	void (*atomic_state_free)(struct drm_atomic_state *state);
334*4882a593Smuzhiyun };
335*4882a593Smuzhiyun 
336*4882a593Smuzhiyun /**
337*4882a593Smuzhiyun  * struct drm_mode_config - Mode configuration control structure
338*4882a593Smuzhiyun  * @min_width: minimum fb pixel width on this device
339*4882a593Smuzhiyun  * @min_height: minimum fb pixel height on this device
340*4882a593Smuzhiyun  * @max_width: maximum fb pixel width on this device
341*4882a593Smuzhiyun  * @max_height: maximum fb pixel height on this device
342*4882a593Smuzhiyun  * @funcs: core driver provided mode setting functions
343*4882a593Smuzhiyun  * @fb_base: base address of the framebuffer
344*4882a593Smuzhiyun  * @poll_enabled: track polling support for this device
345*4882a593Smuzhiyun  * @poll_running: track polling status for this device
346*4882a593Smuzhiyun  * @delayed_event: track delayed poll uevent deliver for this device
347*4882a593Smuzhiyun  * @output_poll_work: delayed work for polling in process context
348*4882a593Smuzhiyun  * @preferred_depth: preferred RBG pixel depth, used by fb helpers
349*4882a593Smuzhiyun  * @prefer_shadow: hint to userspace to prefer shadow-fb rendering
350*4882a593Smuzhiyun  * @cursor_width: hint to userspace for max cursor width
351*4882a593Smuzhiyun  * @cursor_height: hint to userspace for max cursor height
352*4882a593Smuzhiyun  * @helper_private: mid-layer private data
353*4882a593Smuzhiyun  *
354*4882a593Smuzhiyun  * Core mode resource tracking structure.  All CRTC, encoders, and connectors
355*4882a593Smuzhiyun  * enumerated by the driver are added here, as are global properties.  Some
356*4882a593Smuzhiyun  * global restrictions are also here, e.g. dimension restrictions.
357*4882a593Smuzhiyun  */
358*4882a593Smuzhiyun struct drm_mode_config {
359*4882a593Smuzhiyun 	/**
360*4882a593Smuzhiyun 	 * @mutex:
361*4882a593Smuzhiyun 	 *
362*4882a593Smuzhiyun 	 * This is the big scary modeset BKL which protects everything that
363*4882a593Smuzhiyun 	 * isn't protect otherwise. Scope is unclear and fuzzy, try to remove
364*4882a593Smuzhiyun 	 * anything from under its protection and move it into more well-scoped
365*4882a593Smuzhiyun 	 * locks.
366*4882a593Smuzhiyun 	 *
367*4882a593Smuzhiyun 	 * The one important thing this protects is the use of @acquire_ctx.
368*4882a593Smuzhiyun 	 */
369*4882a593Smuzhiyun 	struct mutex mutex;
370*4882a593Smuzhiyun 
371*4882a593Smuzhiyun 	/**
372*4882a593Smuzhiyun 	 * @connection_mutex:
373*4882a593Smuzhiyun 	 *
374*4882a593Smuzhiyun 	 * This protects connector state and the connector to encoder to CRTC
375*4882a593Smuzhiyun 	 * routing chain.
376*4882a593Smuzhiyun 	 *
377*4882a593Smuzhiyun 	 * For atomic drivers specifically this protects &drm_connector.state.
378*4882a593Smuzhiyun 	 */
379*4882a593Smuzhiyun 	struct drm_modeset_lock connection_mutex;
380*4882a593Smuzhiyun 
381*4882a593Smuzhiyun 	/**
382*4882a593Smuzhiyun 	 * @acquire_ctx:
383*4882a593Smuzhiyun 	 *
384*4882a593Smuzhiyun 	 * Global implicit acquire context used by atomic drivers for legacy
385*4882a593Smuzhiyun 	 * IOCTLs. Deprecated, since implicit locking contexts make it
386*4882a593Smuzhiyun 	 * impossible to use driver-private &struct drm_modeset_lock. Users of
387*4882a593Smuzhiyun 	 * this must hold @mutex.
388*4882a593Smuzhiyun 	 */
389*4882a593Smuzhiyun 	struct drm_modeset_acquire_ctx *acquire_ctx;
390*4882a593Smuzhiyun 
391*4882a593Smuzhiyun 	/**
392*4882a593Smuzhiyun 	 * @idr_mutex:
393*4882a593Smuzhiyun 	 *
394*4882a593Smuzhiyun 	 * Mutex for KMS ID allocation and management. Protects both @object_idr
395*4882a593Smuzhiyun 	 * and @tile_idr.
396*4882a593Smuzhiyun 	 */
397*4882a593Smuzhiyun 	struct mutex idr_mutex;
398*4882a593Smuzhiyun 
399*4882a593Smuzhiyun 	/**
400*4882a593Smuzhiyun 	 * @object_idr:
401*4882a593Smuzhiyun 	 *
402*4882a593Smuzhiyun 	 * Main KMS ID tracking object. Use this idr for all IDs, fb, crtc,
403*4882a593Smuzhiyun 	 * connector, modes - just makes life easier to have only one.
404*4882a593Smuzhiyun 	 */
405*4882a593Smuzhiyun 	struct idr object_idr;
406*4882a593Smuzhiyun 
407*4882a593Smuzhiyun 	/**
408*4882a593Smuzhiyun 	 * @tile_idr:
409*4882a593Smuzhiyun 	 *
410*4882a593Smuzhiyun 	 * Use this idr for allocating new IDs for tiled sinks like use in some
411*4882a593Smuzhiyun 	 * high-res DP MST screens.
412*4882a593Smuzhiyun 	 */
413*4882a593Smuzhiyun 	struct idr tile_idr;
414*4882a593Smuzhiyun 
415*4882a593Smuzhiyun 	/** @fb_lock: Mutex to protect fb the global @fb_list and @num_fb. */
416*4882a593Smuzhiyun 	struct mutex fb_lock;
417*4882a593Smuzhiyun 	/** @num_fb: Number of entries on @fb_list. */
418*4882a593Smuzhiyun 	int num_fb;
419*4882a593Smuzhiyun 	/** @fb_list: List of all &struct drm_framebuffer. */
420*4882a593Smuzhiyun 	struct list_head fb_list;
421*4882a593Smuzhiyun 
422*4882a593Smuzhiyun 	/**
423*4882a593Smuzhiyun 	 * @connector_list_lock: Protects @num_connector and
424*4882a593Smuzhiyun 	 * @connector_list and @connector_free_list.
425*4882a593Smuzhiyun 	 */
426*4882a593Smuzhiyun 	spinlock_t connector_list_lock;
427*4882a593Smuzhiyun 	/**
428*4882a593Smuzhiyun 	 * @num_connector: Number of connectors on this device. Protected by
429*4882a593Smuzhiyun 	 * @connector_list_lock.
430*4882a593Smuzhiyun 	 */
431*4882a593Smuzhiyun 	int num_connector;
432*4882a593Smuzhiyun 	/**
433*4882a593Smuzhiyun 	 * @connector_ida: ID allocator for connector indices.
434*4882a593Smuzhiyun 	 */
435*4882a593Smuzhiyun 	struct ida connector_ida;
436*4882a593Smuzhiyun 	/**
437*4882a593Smuzhiyun 	 * @connector_list:
438*4882a593Smuzhiyun 	 *
439*4882a593Smuzhiyun 	 * List of connector objects linked with &drm_connector.head. Protected
440*4882a593Smuzhiyun 	 * by @connector_list_lock. Only use drm_for_each_connector_iter() and
441*4882a593Smuzhiyun 	 * &struct drm_connector_list_iter to walk this list.
442*4882a593Smuzhiyun 	 */
443*4882a593Smuzhiyun 	struct list_head connector_list;
444*4882a593Smuzhiyun 	/**
445*4882a593Smuzhiyun 	 * @connector_free_list:
446*4882a593Smuzhiyun 	 *
447*4882a593Smuzhiyun 	 * List of connector objects linked with &drm_connector.free_head.
448*4882a593Smuzhiyun 	 * Protected by @connector_list_lock. Used by
449*4882a593Smuzhiyun 	 * drm_for_each_connector_iter() and
450*4882a593Smuzhiyun 	 * &struct drm_connector_list_iter to savely free connectors using
451*4882a593Smuzhiyun 	 * @connector_free_work.
452*4882a593Smuzhiyun 	 */
453*4882a593Smuzhiyun 	struct llist_head connector_free_list;
454*4882a593Smuzhiyun 	/**
455*4882a593Smuzhiyun 	 * @connector_free_work: Work to clean up @connector_free_list.
456*4882a593Smuzhiyun 	 */
457*4882a593Smuzhiyun 	struct work_struct connector_free_work;
458*4882a593Smuzhiyun 
459*4882a593Smuzhiyun 	/**
460*4882a593Smuzhiyun 	 * @num_encoder:
461*4882a593Smuzhiyun 	 *
462*4882a593Smuzhiyun 	 * Number of encoders on this device. This is invariant over the
463*4882a593Smuzhiyun 	 * lifetime of a device and hence doesn't need any locks.
464*4882a593Smuzhiyun 	 */
465*4882a593Smuzhiyun 	int num_encoder;
466*4882a593Smuzhiyun 	/**
467*4882a593Smuzhiyun 	 * @encoder_list:
468*4882a593Smuzhiyun 	 *
469*4882a593Smuzhiyun 	 * List of encoder objects linked with &drm_encoder.head. This is
470*4882a593Smuzhiyun 	 * invariant over the lifetime of a device and hence doesn't need any
471*4882a593Smuzhiyun 	 * locks.
472*4882a593Smuzhiyun 	 */
473*4882a593Smuzhiyun 	struct list_head encoder_list;
474*4882a593Smuzhiyun 
475*4882a593Smuzhiyun 	/**
476*4882a593Smuzhiyun 	 * @num_total_plane:
477*4882a593Smuzhiyun 	 *
478*4882a593Smuzhiyun 	 * Number of universal (i.e. with primary/curso) planes on this device.
479*4882a593Smuzhiyun 	 * This is invariant over the lifetime of a device and hence doesn't
480*4882a593Smuzhiyun 	 * need any locks.
481*4882a593Smuzhiyun 	 */
482*4882a593Smuzhiyun 	int num_total_plane;
483*4882a593Smuzhiyun 	/**
484*4882a593Smuzhiyun 	 * @plane_list:
485*4882a593Smuzhiyun 	 *
486*4882a593Smuzhiyun 	 * List of plane objects linked with &drm_plane.head. This is invariant
487*4882a593Smuzhiyun 	 * over the lifetime of a device and hence doesn't need any locks.
488*4882a593Smuzhiyun 	 */
489*4882a593Smuzhiyun 	struct list_head plane_list;
490*4882a593Smuzhiyun 
491*4882a593Smuzhiyun 	/**
492*4882a593Smuzhiyun 	 * @num_crtc:
493*4882a593Smuzhiyun 	 *
494*4882a593Smuzhiyun 	 * Number of CRTCs on this device linked with &drm_crtc.head. This is invariant over the lifetime
495*4882a593Smuzhiyun 	 * of a device and hence doesn't need any locks.
496*4882a593Smuzhiyun 	 */
497*4882a593Smuzhiyun 	int num_crtc;
498*4882a593Smuzhiyun 	/**
499*4882a593Smuzhiyun 	 * @crtc_list:
500*4882a593Smuzhiyun 	 *
501*4882a593Smuzhiyun 	 * List of CRTC objects linked with &drm_crtc.head. This is invariant
502*4882a593Smuzhiyun 	 * over the lifetime of a device and hence doesn't need any locks.
503*4882a593Smuzhiyun 	 */
504*4882a593Smuzhiyun 	struct list_head crtc_list;
505*4882a593Smuzhiyun 
506*4882a593Smuzhiyun 	/**
507*4882a593Smuzhiyun 	 * @property_list:
508*4882a593Smuzhiyun 	 *
509*4882a593Smuzhiyun 	 * List of property type objects linked with &drm_property.head. This is
510*4882a593Smuzhiyun 	 * invariant over the lifetime of a device and hence doesn't need any
511*4882a593Smuzhiyun 	 * locks.
512*4882a593Smuzhiyun 	 */
513*4882a593Smuzhiyun 	struct list_head property_list;
514*4882a593Smuzhiyun 
515*4882a593Smuzhiyun 	/**
516*4882a593Smuzhiyun 	 * @privobj_list:
517*4882a593Smuzhiyun 	 *
518*4882a593Smuzhiyun 	 * List of private objects linked with &drm_private_obj.head. This is
519*4882a593Smuzhiyun 	 * invariant over the lifetime of a device and hence doesn't need any
520*4882a593Smuzhiyun 	 * locks.
521*4882a593Smuzhiyun 	 */
522*4882a593Smuzhiyun 	struct list_head privobj_list;
523*4882a593Smuzhiyun 
524*4882a593Smuzhiyun 	int min_width, min_height;
525*4882a593Smuzhiyun 	int max_width, max_height;
526*4882a593Smuzhiyun 	const struct drm_mode_config_funcs *funcs;
527*4882a593Smuzhiyun 	resource_size_t fb_base;
528*4882a593Smuzhiyun 
529*4882a593Smuzhiyun 	/* output poll support */
530*4882a593Smuzhiyun 	bool poll_enabled;
531*4882a593Smuzhiyun 	bool poll_running;
532*4882a593Smuzhiyun 	bool delayed_event;
533*4882a593Smuzhiyun 	struct delayed_work output_poll_work;
534*4882a593Smuzhiyun 
535*4882a593Smuzhiyun 	/**
536*4882a593Smuzhiyun 	 * @blob_lock:
537*4882a593Smuzhiyun 	 *
538*4882a593Smuzhiyun 	 * Mutex for blob property allocation and management, protects
539*4882a593Smuzhiyun 	 * @property_blob_list and &drm_file.blobs.
540*4882a593Smuzhiyun 	 */
541*4882a593Smuzhiyun 	struct mutex blob_lock;
542*4882a593Smuzhiyun 
543*4882a593Smuzhiyun 	/**
544*4882a593Smuzhiyun 	 * @property_blob_list:
545*4882a593Smuzhiyun 	 *
546*4882a593Smuzhiyun 	 * List of all the blob property objects linked with
547*4882a593Smuzhiyun 	 * &drm_property_blob.head. Protected by @blob_lock.
548*4882a593Smuzhiyun 	 */
549*4882a593Smuzhiyun 	struct list_head property_blob_list;
550*4882a593Smuzhiyun 
551*4882a593Smuzhiyun 	/* pointers to standard properties */
552*4882a593Smuzhiyun 
553*4882a593Smuzhiyun 	/**
554*4882a593Smuzhiyun 	 * @edid_property: Default connector property to hold the EDID of the
555*4882a593Smuzhiyun 	 * currently connected sink, if any.
556*4882a593Smuzhiyun 	 */
557*4882a593Smuzhiyun 	struct drm_property *edid_property;
558*4882a593Smuzhiyun 	/**
559*4882a593Smuzhiyun 	 * @dpms_property: Default connector property to control the
560*4882a593Smuzhiyun 	 * connector's DPMS state.
561*4882a593Smuzhiyun 	 */
562*4882a593Smuzhiyun 	struct drm_property *dpms_property;
563*4882a593Smuzhiyun 	/**
564*4882a593Smuzhiyun 	 * @path_property: Default connector property to hold the DP MST path
565*4882a593Smuzhiyun 	 * for the port.
566*4882a593Smuzhiyun 	 */
567*4882a593Smuzhiyun 	struct drm_property *path_property;
568*4882a593Smuzhiyun 	/**
569*4882a593Smuzhiyun 	 * @tile_property: Default connector property to store the tile
570*4882a593Smuzhiyun 	 * position of a tiled screen, for sinks which need to be driven with
571*4882a593Smuzhiyun 	 * multiple CRTCs.
572*4882a593Smuzhiyun 	 */
573*4882a593Smuzhiyun 	struct drm_property *tile_property;
574*4882a593Smuzhiyun 	/**
575*4882a593Smuzhiyun 	 * @link_status_property: Default connector property for link status
576*4882a593Smuzhiyun 	 * of a connector
577*4882a593Smuzhiyun 	 */
578*4882a593Smuzhiyun 	struct drm_property *link_status_property;
579*4882a593Smuzhiyun 	/**
580*4882a593Smuzhiyun 	 * @plane_type_property: Default plane property to differentiate
581*4882a593Smuzhiyun 	 * CURSOR, PRIMARY and OVERLAY legacy uses of planes.
582*4882a593Smuzhiyun 	 */
583*4882a593Smuzhiyun 	struct drm_property *plane_type_property;
584*4882a593Smuzhiyun 	/**
585*4882a593Smuzhiyun 	 * @prop_src_x: Default atomic plane property for the plane source
586*4882a593Smuzhiyun 	 * position in the connected &drm_framebuffer.
587*4882a593Smuzhiyun 	 */
588*4882a593Smuzhiyun 	struct drm_property *prop_src_x;
589*4882a593Smuzhiyun 	/**
590*4882a593Smuzhiyun 	 * @prop_src_y: Default atomic plane property for the plane source
591*4882a593Smuzhiyun 	 * position in the connected &drm_framebuffer.
592*4882a593Smuzhiyun 	 */
593*4882a593Smuzhiyun 	struct drm_property *prop_src_y;
594*4882a593Smuzhiyun 	/**
595*4882a593Smuzhiyun 	 * @prop_src_w: Default atomic plane property for the plane source
596*4882a593Smuzhiyun 	 * position in the connected &drm_framebuffer.
597*4882a593Smuzhiyun 	 */
598*4882a593Smuzhiyun 	struct drm_property *prop_src_w;
599*4882a593Smuzhiyun 	/**
600*4882a593Smuzhiyun 	 * @prop_src_h: Default atomic plane property for the plane source
601*4882a593Smuzhiyun 	 * position in the connected &drm_framebuffer.
602*4882a593Smuzhiyun 	 */
603*4882a593Smuzhiyun 	struct drm_property *prop_src_h;
604*4882a593Smuzhiyun 	/**
605*4882a593Smuzhiyun 	 * @prop_crtc_x: Default atomic plane property for the plane destination
606*4882a593Smuzhiyun 	 * position in the &drm_crtc is being shown on.
607*4882a593Smuzhiyun 	 */
608*4882a593Smuzhiyun 	struct drm_property *prop_crtc_x;
609*4882a593Smuzhiyun 	/**
610*4882a593Smuzhiyun 	 * @prop_crtc_y: Default atomic plane property for the plane destination
611*4882a593Smuzhiyun 	 * position in the &drm_crtc is being shown on.
612*4882a593Smuzhiyun 	 */
613*4882a593Smuzhiyun 	struct drm_property *prop_crtc_y;
614*4882a593Smuzhiyun 	/**
615*4882a593Smuzhiyun 	 * @prop_crtc_w: Default atomic plane property for the plane destination
616*4882a593Smuzhiyun 	 * position in the &drm_crtc is being shown on.
617*4882a593Smuzhiyun 	 */
618*4882a593Smuzhiyun 	struct drm_property *prop_crtc_w;
619*4882a593Smuzhiyun 	/**
620*4882a593Smuzhiyun 	 * @prop_crtc_h: Default atomic plane property for the plane destination
621*4882a593Smuzhiyun 	 * position in the &drm_crtc is being shown on.
622*4882a593Smuzhiyun 	 */
623*4882a593Smuzhiyun 	struct drm_property *prop_crtc_h;
624*4882a593Smuzhiyun 	/**
625*4882a593Smuzhiyun 	 * @prop_fb_id: Default atomic plane property to specify the
626*4882a593Smuzhiyun 	 * &drm_framebuffer.
627*4882a593Smuzhiyun 	 */
628*4882a593Smuzhiyun 	struct drm_property *prop_fb_id;
629*4882a593Smuzhiyun 	/**
630*4882a593Smuzhiyun 	 * @prop_in_fence_fd: Sync File fd representing the incoming fences
631*4882a593Smuzhiyun 	 * for a Plane.
632*4882a593Smuzhiyun 	 */
633*4882a593Smuzhiyun 	struct drm_property *prop_in_fence_fd;
634*4882a593Smuzhiyun 	/**
635*4882a593Smuzhiyun 	 * @prop_out_fence_ptr: Sync File fd pointer representing the
636*4882a593Smuzhiyun 	 * outgoing fences for a CRTC. Userspace should provide a pointer to a
637*4882a593Smuzhiyun 	 * value of type s32, and then cast that pointer to u64.
638*4882a593Smuzhiyun 	 */
639*4882a593Smuzhiyun 	struct drm_property *prop_out_fence_ptr;
640*4882a593Smuzhiyun 	/**
641*4882a593Smuzhiyun 	 * @prop_crtc_id: Default atomic plane property to specify the
642*4882a593Smuzhiyun 	 * &drm_crtc.
643*4882a593Smuzhiyun 	 */
644*4882a593Smuzhiyun 	struct drm_property *prop_crtc_id;
645*4882a593Smuzhiyun 	/**
646*4882a593Smuzhiyun 	 * @prop_fb_damage_clips: Optional plane property to mark damaged
647*4882a593Smuzhiyun 	 * regions on the plane in framebuffer coordinates of the framebuffer
648*4882a593Smuzhiyun 	 * attached to the plane.
649*4882a593Smuzhiyun 	 *
650*4882a593Smuzhiyun 	 * The layout of blob data is simply an array of &drm_mode_rect. Unlike
651*4882a593Smuzhiyun 	 * plane src coordinates, damage clips are not in 16.16 fixed point.
652*4882a593Smuzhiyun 	 */
653*4882a593Smuzhiyun 	struct drm_property *prop_fb_damage_clips;
654*4882a593Smuzhiyun 	/**
655*4882a593Smuzhiyun 	 * @prop_active: Default atomic CRTC property to control the active
656*4882a593Smuzhiyun 	 * state, which is the simplified implementation for DPMS in atomic
657*4882a593Smuzhiyun 	 * drivers.
658*4882a593Smuzhiyun 	 */
659*4882a593Smuzhiyun 	struct drm_property *prop_active;
660*4882a593Smuzhiyun 	/**
661*4882a593Smuzhiyun 	 * @prop_mode_id: Default atomic CRTC property to set the mode for a
662*4882a593Smuzhiyun 	 * CRTC. A 0 mode implies that the CRTC is entirely disabled - all
663*4882a593Smuzhiyun 	 * connectors must be of and active must be set to disabled, too.
664*4882a593Smuzhiyun 	 */
665*4882a593Smuzhiyun 	struct drm_property *prop_mode_id;
666*4882a593Smuzhiyun 	/**
667*4882a593Smuzhiyun 	 * @prop_vrr_enabled: Default atomic CRTC property to indicate
668*4882a593Smuzhiyun 	 * whether variable refresh rate should be enabled on the CRTC.
669*4882a593Smuzhiyun 	 */
670*4882a593Smuzhiyun 	struct drm_property *prop_vrr_enabled;
671*4882a593Smuzhiyun 
672*4882a593Smuzhiyun 	/**
673*4882a593Smuzhiyun 	 * @dvi_i_subconnector_property: Optional DVI-I property to
674*4882a593Smuzhiyun 	 * differentiate between analog or digital mode.
675*4882a593Smuzhiyun 	 */
676*4882a593Smuzhiyun 	struct drm_property *dvi_i_subconnector_property;
677*4882a593Smuzhiyun 	/**
678*4882a593Smuzhiyun 	 * @dvi_i_select_subconnector_property: Optional DVI-I property to
679*4882a593Smuzhiyun 	 * select between analog or digital mode.
680*4882a593Smuzhiyun 	 */
681*4882a593Smuzhiyun 	struct drm_property *dvi_i_select_subconnector_property;
682*4882a593Smuzhiyun 
683*4882a593Smuzhiyun 	/**
684*4882a593Smuzhiyun 	 * @dp_subconnector_property: Optional DP property to differentiate
685*4882a593Smuzhiyun 	 * between different DP downstream port types.
686*4882a593Smuzhiyun 	 */
687*4882a593Smuzhiyun 	struct drm_property *dp_subconnector_property;
688*4882a593Smuzhiyun 
689*4882a593Smuzhiyun 	/**
690*4882a593Smuzhiyun 	 * @tv_subconnector_property: Optional TV property to differentiate
691*4882a593Smuzhiyun 	 * between different TV connector types.
692*4882a593Smuzhiyun 	 */
693*4882a593Smuzhiyun 	struct drm_property *tv_subconnector_property;
694*4882a593Smuzhiyun 	/**
695*4882a593Smuzhiyun 	 * @tv_select_subconnector_property: Optional TV property to select
696*4882a593Smuzhiyun 	 * between different TV connector types.
697*4882a593Smuzhiyun 	 */
698*4882a593Smuzhiyun 	struct drm_property *tv_select_subconnector_property;
699*4882a593Smuzhiyun 	/**
700*4882a593Smuzhiyun 	 * @tv_mode_property: Optional TV property to select
701*4882a593Smuzhiyun 	 * the output TV mode.
702*4882a593Smuzhiyun 	 */
703*4882a593Smuzhiyun 	struct drm_property *tv_mode_property;
704*4882a593Smuzhiyun 	/**
705*4882a593Smuzhiyun 	 * @tv_left_margin_property: Optional TV property to set the left
706*4882a593Smuzhiyun 	 * margin (expressed in pixels).
707*4882a593Smuzhiyun 	 */
708*4882a593Smuzhiyun 	struct drm_property *tv_left_margin_property;
709*4882a593Smuzhiyun 	/**
710*4882a593Smuzhiyun 	 * @tv_right_margin_property: Optional TV property to set the right
711*4882a593Smuzhiyun 	 * margin (expressed in pixels).
712*4882a593Smuzhiyun 	 */
713*4882a593Smuzhiyun 	struct drm_property *tv_right_margin_property;
714*4882a593Smuzhiyun 	/**
715*4882a593Smuzhiyun 	 * @tv_top_margin_property: Optional TV property to set the right
716*4882a593Smuzhiyun 	 * margin (expressed in pixels).
717*4882a593Smuzhiyun 	 */
718*4882a593Smuzhiyun 	struct drm_property *tv_top_margin_property;
719*4882a593Smuzhiyun 	/**
720*4882a593Smuzhiyun 	 * @tv_bottom_margin_property: Optional TV property to set the right
721*4882a593Smuzhiyun 	 * margin (expressed in pixels).
722*4882a593Smuzhiyun 	 */
723*4882a593Smuzhiyun 	struct drm_property *tv_bottom_margin_property;
724*4882a593Smuzhiyun 	/**
725*4882a593Smuzhiyun 	 * @tv_brightness_property: Optional TV property to set the
726*4882a593Smuzhiyun 	 * brightness.
727*4882a593Smuzhiyun 	 */
728*4882a593Smuzhiyun 	struct drm_property *tv_brightness_property;
729*4882a593Smuzhiyun 	/**
730*4882a593Smuzhiyun 	 * @tv_contrast_property: Optional TV property to set the
731*4882a593Smuzhiyun 	 * contrast.
732*4882a593Smuzhiyun 	 */
733*4882a593Smuzhiyun 	struct drm_property *tv_contrast_property;
734*4882a593Smuzhiyun 	/**
735*4882a593Smuzhiyun 	 * @tv_flicker_reduction_property: Optional TV property to control the
736*4882a593Smuzhiyun 	 * flicker reduction mode.
737*4882a593Smuzhiyun 	 */
738*4882a593Smuzhiyun 	struct drm_property *tv_flicker_reduction_property;
739*4882a593Smuzhiyun 	/**
740*4882a593Smuzhiyun 	 * @tv_overscan_property: Optional TV property to control the overscan
741*4882a593Smuzhiyun 	 * setting.
742*4882a593Smuzhiyun 	 */
743*4882a593Smuzhiyun 	struct drm_property *tv_overscan_property;
744*4882a593Smuzhiyun 	/**
745*4882a593Smuzhiyun 	 * @tv_saturation_property: Optional TV property to set the
746*4882a593Smuzhiyun 	 * saturation.
747*4882a593Smuzhiyun 	 */
748*4882a593Smuzhiyun 	struct drm_property *tv_saturation_property;
749*4882a593Smuzhiyun 	/**
750*4882a593Smuzhiyun 	 * @tv_hue_property: Optional TV property to set the hue.
751*4882a593Smuzhiyun 	 */
752*4882a593Smuzhiyun 	struct drm_property *tv_hue_property;
753*4882a593Smuzhiyun 
754*4882a593Smuzhiyun 	/**
755*4882a593Smuzhiyun 	 * @scaling_mode_property: Optional connector property to control the
756*4882a593Smuzhiyun 	 * upscaling, mostly used for built-in panels.
757*4882a593Smuzhiyun 	 */
758*4882a593Smuzhiyun 	struct drm_property *scaling_mode_property;
759*4882a593Smuzhiyun 	/**
760*4882a593Smuzhiyun 	 * @aspect_ratio_property: Optional connector property to control the
761*4882a593Smuzhiyun 	 * HDMI infoframe aspect ratio setting.
762*4882a593Smuzhiyun 	 */
763*4882a593Smuzhiyun 	struct drm_property *aspect_ratio_property;
764*4882a593Smuzhiyun 	/**
765*4882a593Smuzhiyun 	 * @content_type_property: Optional connector property to control the
766*4882a593Smuzhiyun 	 * HDMI infoframe content type setting.
767*4882a593Smuzhiyun 	 */
768*4882a593Smuzhiyun 	struct drm_property *content_type_property;
769*4882a593Smuzhiyun 	/**
770*4882a593Smuzhiyun 	 * @degamma_lut_property: Optional CRTC property to set the LUT used to
771*4882a593Smuzhiyun 	 * convert the framebuffer's colors to linear gamma.
772*4882a593Smuzhiyun 	 */
773*4882a593Smuzhiyun 	struct drm_property *degamma_lut_property;
774*4882a593Smuzhiyun 	/**
775*4882a593Smuzhiyun 	 * @degamma_lut_size_property: Optional CRTC property for the size of
776*4882a593Smuzhiyun 	 * the degamma LUT as supported by the driver (read-only).
777*4882a593Smuzhiyun 	 */
778*4882a593Smuzhiyun 	struct drm_property *degamma_lut_size_property;
779*4882a593Smuzhiyun 	/**
780*4882a593Smuzhiyun 	 * @ctm_property: Optional CRTC property to set the
781*4882a593Smuzhiyun 	 * matrix used to convert colors after the lookup in the
782*4882a593Smuzhiyun 	 * degamma LUT.
783*4882a593Smuzhiyun 	 */
784*4882a593Smuzhiyun 	struct drm_property *ctm_property;
785*4882a593Smuzhiyun 	/**
786*4882a593Smuzhiyun 	 * @gamma_lut_property: Optional CRTC property to set the LUT used to
787*4882a593Smuzhiyun 	 * convert the colors, after the CTM matrix, to the gamma space of the
788*4882a593Smuzhiyun 	 * connected screen.
789*4882a593Smuzhiyun 	 */
790*4882a593Smuzhiyun 	struct drm_property *gamma_lut_property;
791*4882a593Smuzhiyun 	/**
792*4882a593Smuzhiyun 	 * @gamma_lut_size_property: Optional CRTC property for the size of the
793*4882a593Smuzhiyun 	 * gamma LUT as supported by the driver (read-only).
794*4882a593Smuzhiyun 	 */
795*4882a593Smuzhiyun 	struct drm_property *gamma_lut_size_property;
796*4882a593Smuzhiyun 
797*4882a593Smuzhiyun 	/**
798*4882a593Smuzhiyun 	 * @suggested_x_property: Optional connector property with a hint for
799*4882a593Smuzhiyun 	 * the position of the output on the host's screen.
800*4882a593Smuzhiyun 	 */
801*4882a593Smuzhiyun 	struct drm_property *suggested_x_property;
802*4882a593Smuzhiyun 	/**
803*4882a593Smuzhiyun 	 * @suggested_y_property: Optional connector property with a hint for
804*4882a593Smuzhiyun 	 * the position of the output on the host's screen.
805*4882a593Smuzhiyun 	 */
806*4882a593Smuzhiyun 	struct drm_property *suggested_y_property;
807*4882a593Smuzhiyun 
808*4882a593Smuzhiyun 	/**
809*4882a593Smuzhiyun 	 * @non_desktop_property: Optional connector property with a hint
810*4882a593Smuzhiyun 	 * that device isn't a standard display, and the console/desktop,
811*4882a593Smuzhiyun 	 * should not be displayed on it.
812*4882a593Smuzhiyun 	 */
813*4882a593Smuzhiyun 	struct drm_property *non_desktop_property;
814*4882a593Smuzhiyun 
815*4882a593Smuzhiyun 	/**
816*4882a593Smuzhiyun 	 * @panel_orientation_property: Optional connector property indicating
817*4882a593Smuzhiyun 	 * how the lcd-panel is mounted inside the casing (e.g. normal or
818*4882a593Smuzhiyun 	 * upside-down).
819*4882a593Smuzhiyun 	 */
820*4882a593Smuzhiyun 	struct drm_property *panel_orientation_property;
821*4882a593Smuzhiyun 
822*4882a593Smuzhiyun 	/**
823*4882a593Smuzhiyun 	 * @writeback_fb_id_property: Property for writeback connectors, storing
824*4882a593Smuzhiyun 	 * the ID of the output framebuffer.
825*4882a593Smuzhiyun 	 * See also: drm_writeback_connector_init()
826*4882a593Smuzhiyun 	 */
827*4882a593Smuzhiyun 	struct drm_property *writeback_fb_id_property;
828*4882a593Smuzhiyun 
829*4882a593Smuzhiyun 	/**
830*4882a593Smuzhiyun 	 * @writeback_pixel_formats_property: Property for writeback connectors,
831*4882a593Smuzhiyun 	 * storing an array of the supported pixel formats for the writeback
832*4882a593Smuzhiyun 	 * engine (read-only).
833*4882a593Smuzhiyun 	 * See also: drm_writeback_connector_init()
834*4882a593Smuzhiyun 	 */
835*4882a593Smuzhiyun 	struct drm_property *writeback_pixel_formats_property;
836*4882a593Smuzhiyun 	/**
837*4882a593Smuzhiyun 	 * @writeback_out_fence_ptr_property: Property for writeback connectors,
838*4882a593Smuzhiyun 	 * fd pointer representing the outgoing fences for a writeback
839*4882a593Smuzhiyun 	 * connector. Userspace should provide a pointer to a value of type s32,
840*4882a593Smuzhiyun 	 * and then cast that pointer to u64.
841*4882a593Smuzhiyun 	 * See also: drm_writeback_connector_init()
842*4882a593Smuzhiyun 	 */
843*4882a593Smuzhiyun 	struct drm_property *writeback_out_fence_ptr_property;
844*4882a593Smuzhiyun 
845*4882a593Smuzhiyun 	/**
846*4882a593Smuzhiyun 	 * @hdr_output_metadata_property: Connector property containing hdr
847*4882a593Smuzhiyun 	 * metatada. This will be provided by userspace compositors based
848*4882a593Smuzhiyun 	 * on HDR content
849*4882a593Smuzhiyun 	 */
850*4882a593Smuzhiyun 	struct drm_property *hdr_output_metadata_property;
851*4882a593Smuzhiyun 
852*4882a593Smuzhiyun 	/**
853*4882a593Smuzhiyun 	 * @content_protection_property: DRM ENUM property for content
854*4882a593Smuzhiyun 	 * protection. See drm_connector_attach_content_protection_property().
855*4882a593Smuzhiyun 	 */
856*4882a593Smuzhiyun 	struct drm_property *content_protection_property;
857*4882a593Smuzhiyun 
858*4882a593Smuzhiyun 	/**
859*4882a593Smuzhiyun 	 * @hdcp_content_type_property: DRM ENUM property for type of
860*4882a593Smuzhiyun 	 * Protected Content.
861*4882a593Smuzhiyun 	 */
862*4882a593Smuzhiyun 	struct drm_property *hdcp_content_type_property;
863*4882a593Smuzhiyun 
864*4882a593Smuzhiyun 	/* dumb ioctl parameters */
865*4882a593Smuzhiyun 	uint32_t preferred_depth, prefer_shadow;
866*4882a593Smuzhiyun 
867*4882a593Smuzhiyun 	/**
868*4882a593Smuzhiyun 	 * @prefer_shadow_fbdev:
869*4882a593Smuzhiyun 	 *
870*4882a593Smuzhiyun 	 * Hint to framebuffer emulation to prefer shadow-fb rendering.
871*4882a593Smuzhiyun 	 */
872*4882a593Smuzhiyun 	bool prefer_shadow_fbdev;
873*4882a593Smuzhiyun 
874*4882a593Smuzhiyun 	/**
875*4882a593Smuzhiyun 	 * @fbdev_use_iomem:
876*4882a593Smuzhiyun 	 *
877*4882a593Smuzhiyun 	 * Set to true if framebuffer reside in iomem.
878*4882a593Smuzhiyun 	 * When set to true memcpy_toio() is used when copying the framebuffer in
879*4882a593Smuzhiyun 	 * drm_fb_helper.drm_fb_helper_dirty_blit_real().
880*4882a593Smuzhiyun 	 *
881*4882a593Smuzhiyun 	 * FIXME: This should be replaced with a per-mapping is_iomem
882*4882a593Smuzhiyun 	 * flag (like ttm does), and then used everywhere in fbdev code.
883*4882a593Smuzhiyun 	 */
884*4882a593Smuzhiyun 	bool fbdev_use_iomem;
885*4882a593Smuzhiyun 
886*4882a593Smuzhiyun 	/**
887*4882a593Smuzhiyun 	 * @quirk_addfb_prefer_xbgr_30bpp:
888*4882a593Smuzhiyun 	 *
889*4882a593Smuzhiyun 	 * Special hack for legacy ADDFB to keep nouveau userspace happy. Should
890*4882a593Smuzhiyun 	 * only ever be set by the nouveau kernel driver.
891*4882a593Smuzhiyun 	 */
892*4882a593Smuzhiyun 	bool quirk_addfb_prefer_xbgr_30bpp;
893*4882a593Smuzhiyun 
894*4882a593Smuzhiyun 	/**
895*4882a593Smuzhiyun 	 * @quirk_addfb_prefer_host_byte_order:
896*4882a593Smuzhiyun 	 *
897*4882a593Smuzhiyun 	 * When set to true drm_mode_addfb() will pick host byte order
898*4882a593Smuzhiyun 	 * pixel_format when calling drm_mode_addfb2().  This is how
899*4882a593Smuzhiyun 	 * drm_mode_addfb() should have worked from day one.  It
900*4882a593Smuzhiyun 	 * didn't though, so we ended up with quirks in both kernel
901*4882a593Smuzhiyun 	 * and userspace drivers to deal with the broken behavior.
902*4882a593Smuzhiyun 	 * Simply fixing drm_mode_addfb() unconditionally would break
903*4882a593Smuzhiyun 	 * these drivers, so add a quirk bit here to allow drivers
904*4882a593Smuzhiyun 	 * opt-in.
905*4882a593Smuzhiyun 	 */
906*4882a593Smuzhiyun 	bool quirk_addfb_prefer_host_byte_order;
907*4882a593Smuzhiyun 
908*4882a593Smuzhiyun 	/**
909*4882a593Smuzhiyun 	 * @async_page_flip: Does this device support async flips on the primary
910*4882a593Smuzhiyun 	 * plane?
911*4882a593Smuzhiyun 	 */
912*4882a593Smuzhiyun 	bool async_page_flip;
913*4882a593Smuzhiyun 
914*4882a593Smuzhiyun 	/**
915*4882a593Smuzhiyun 	 * @allow_fb_modifiers:
916*4882a593Smuzhiyun 	 *
917*4882a593Smuzhiyun 	 * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
918*4882a593Smuzhiyun 	 */
919*4882a593Smuzhiyun 	bool allow_fb_modifiers;
920*4882a593Smuzhiyun 
921*4882a593Smuzhiyun 	/**
922*4882a593Smuzhiyun 	 * @normalize_zpos:
923*4882a593Smuzhiyun 	 *
924*4882a593Smuzhiyun 	 * If true the drm core will call drm_atomic_normalize_zpos() as part of
925*4882a593Smuzhiyun 	 * atomic mode checking from drm_atomic_helper_check()
926*4882a593Smuzhiyun 	 */
927*4882a593Smuzhiyun 	bool normalize_zpos;
928*4882a593Smuzhiyun 
929*4882a593Smuzhiyun 	/**
930*4882a593Smuzhiyun 	 * @modifiers_property: Plane property to list support modifier/format
931*4882a593Smuzhiyun 	 * combination.
932*4882a593Smuzhiyun 	 */
933*4882a593Smuzhiyun 	struct drm_property *modifiers_property;
934*4882a593Smuzhiyun 
935*4882a593Smuzhiyun 	/* cursor size */
936*4882a593Smuzhiyun 	uint32_t cursor_width, cursor_height;
937*4882a593Smuzhiyun 
938*4882a593Smuzhiyun 	/**
939*4882a593Smuzhiyun 	 * @suspend_state:
940*4882a593Smuzhiyun 	 *
941*4882a593Smuzhiyun 	 * Atomic state when suspended.
942*4882a593Smuzhiyun 	 * Set by drm_mode_config_helper_suspend() and cleared by
943*4882a593Smuzhiyun 	 * drm_mode_config_helper_resume().
944*4882a593Smuzhiyun 	 */
945*4882a593Smuzhiyun 	struct drm_atomic_state *suspend_state;
946*4882a593Smuzhiyun 
947*4882a593Smuzhiyun 	const struct drm_mode_config_helper_funcs *helper_private;
948*4882a593Smuzhiyun };
949*4882a593Smuzhiyun 
950*4882a593Smuzhiyun int __must_check drmm_mode_config_init(struct drm_device *dev);
951*4882a593Smuzhiyun 
952*4882a593Smuzhiyun /**
953*4882a593Smuzhiyun  * drm_mode_config_init - DRM mode_configuration structure initialization
954*4882a593Smuzhiyun  * @dev: DRM device
955*4882a593Smuzhiyun  *
956*4882a593Smuzhiyun  * This is the unmanaged version of drmm_mode_config_init() for drivers which
957*4882a593Smuzhiyun  * still explicitly call drm_mode_config_cleanup().
958*4882a593Smuzhiyun  *
959*4882a593Smuzhiyun  * FIXME: This function is deprecated and drivers should be converted over to
960*4882a593Smuzhiyun  * drmm_mode_config_init().
961*4882a593Smuzhiyun  */
drm_mode_config_init(struct drm_device * dev)962*4882a593Smuzhiyun static inline int drm_mode_config_init(struct drm_device *dev)
963*4882a593Smuzhiyun {
964*4882a593Smuzhiyun 	return drmm_mode_config_init(dev);
965*4882a593Smuzhiyun }
966*4882a593Smuzhiyun 
967*4882a593Smuzhiyun void drm_mode_config_reset(struct drm_device *dev);
968*4882a593Smuzhiyun void drm_mode_config_cleanup(struct drm_device *dev);
969*4882a593Smuzhiyun 
970*4882a593Smuzhiyun #endif
971