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