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