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