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