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