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_crtc: 505 * 506 * Number of CRTCs on this device linked with &drm_crtc.head. This is invariant over the lifetime 507 * of a device and hence doesn't need any locks. 508 */ 509 int num_crtc; 510 /** 511 * @crtc_list: 512 * 513 * List of CRTC objects linked with &drm_crtc.head. This is invariant 514 * over the lifetime of a device and hence doesn't need any locks. 515 */ 516 struct list_head crtc_list; 517 518 /** 519 * @property_list: 520 * 521 * List of property type objects linked with &drm_property.head. This is 522 * invariant over the lifetime of a device and hence doesn't need any 523 * locks. 524 */ 525 struct list_head property_list; 526 527 /** 528 * @privobj_list: 529 * 530 * List of private objects linked with &drm_private_obj.head. This is 531 * invariant over the lifetime of a device and hence doesn't need any 532 * locks. 533 */ 534 struct list_head privobj_list; 535 536 unsigned int min_width, min_height; 537 unsigned int max_width, max_height; 538 const struct drm_mode_config_funcs *funcs; 539 540 /* output poll support */ 541 bool poll_enabled; 542 bool poll_running; 543 bool delayed_event; 544 struct delayed_work output_poll_work; 545 546 /** 547 * @blob_lock: 548 * 549 * Mutex for blob property allocation and management, protects 550 * @property_blob_list and &drm_file.blobs. 551 */ 552 struct mutex blob_lock; 553 554 /** 555 * @property_blob_list: 556 * 557 * List of all the blob property objects linked with 558 * &drm_property_blob.head. Protected by @blob_lock. 559 */ 560 struct list_head property_blob_list; 561 562 /* pointers to standard properties */ 563 564 /** 565 * @edid_property: Default connector property to hold the EDID of the 566 * currently connected sink, if any. 567 */ 568 struct drm_property *edid_property; 569 /** 570 * @dpms_property: Default connector property to control the 571 * connector's DPMS state. 572 */ 573 struct drm_property *dpms_property; 574 /** 575 * @path_property: Default connector property to hold the DP MST path 576 * for the port. 577 */ 578 struct drm_property *path_property; 579 /** 580 * @tile_property: Default connector property to store the tile 581 * position of a tiled screen, for sinks which need to be driven with 582 * multiple CRTCs. 583 */ 584 struct drm_property *tile_property; 585 /** 586 * @link_status_property: Default connector property for link status 587 * of a connector 588 */ 589 struct drm_property *link_status_property; 590 /** 591 * @plane_type_property: Default plane property to differentiate 592 * CURSOR, PRIMARY and OVERLAY legacy uses of planes. 593 */ 594 struct drm_property *plane_type_property; 595 /** 596 * @prop_src_x: Default atomic plane property for the plane source 597 * position in the connected &drm_framebuffer. 598 */ 599 struct drm_property *prop_src_x; 600 /** 601 * @prop_src_y: Default atomic plane property for the plane source 602 * position in the connected &drm_framebuffer. 603 */ 604 struct drm_property *prop_src_y; 605 /** 606 * @prop_src_w: Default atomic plane property for the plane source 607 * position in the connected &drm_framebuffer. 608 */ 609 struct drm_property *prop_src_w; 610 /** 611 * @prop_src_h: Default atomic plane property for the plane source 612 * position in the connected &drm_framebuffer. 613 */ 614 struct drm_property *prop_src_h; 615 /** 616 * @prop_crtc_x: Default atomic plane property for the plane destination 617 * position in the &drm_crtc is being shown on. 618 */ 619 struct drm_property *prop_crtc_x; 620 /** 621 * @prop_crtc_y: Default atomic plane property for the plane destination 622 * position in the &drm_crtc is being shown on. 623 */ 624 struct drm_property *prop_crtc_y; 625 /** 626 * @prop_crtc_w: Default atomic plane property for the plane destination 627 * position in the &drm_crtc is being shown on. 628 */ 629 struct drm_property *prop_crtc_w; 630 /** 631 * @prop_crtc_h: Default atomic plane property for the plane destination 632 * position in the &drm_crtc is being shown on. 633 */ 634 struct drm_property *prop_crtc_h; 635 /** 636 * @prop_fb_id: Default atomic plane property to specify the 637 * &drm_framebuffer. 638 */ 639 struct drm_property *prop_fb_id; 640 /** 641 * @prop_in_fence_fd: Sync File fd representing the incoming fences 642 * for a Plane. 643 */ 644 struct drm_property *prop_in_fence_fd; 645 /** 646 * @prop_out_fence_ptr: Sync File fd pointer representing the 647 * outgoing fences for a CRTC. Userspace should provide a pointer to a 648 * value of type s32, and then cast that pointer to u64. 649 */ 650 struct drm_property *prop_out_fence_ptr; 651 /** 652 * @prop_crtc_id: Default atomic plane property to specify the 653 * &drm_crtc. 654 */ 655 struct drm_property *prop_crtc_id; 656 /** 657 * @prop_fb_damage_clips: Optional plane property to mark damaged 658 * regions on the plane in framebuffer coordinates of the framebuffer 659 * attached to the plane. 660 * 661 * The layout of blob data is simply an array of &drm_mode_rect. Unlike 662 * plane src coordinates, damage clips are not in 16.16 fixed point. 663 */ 664 struct drm_property *prop_fb_damage_clips; 665 /** 666 * @prop_active: Default atomic CRTC property to control the active 667 * state, which is the simplified implementation for DPMS in atomic 668 * drivers. 669 */ 670 struct drm_property *prop_active; 671 /** 672 * @prop_mode_id: Default atomic CRTC property to set the mode for a 673 * CRTC. A 0 mode implies that the CRTC is entirely disabled - all 674 * connectors must be of and active must be set to disabled, too. 675 */ 676 struct drm_property *prop_mode_id; 677 /** 678 * @prop_vrr_enabled: Default atomic CRTC property to indicate 679 * whether variable refresh rate should be enabled on the CRTC. 680 */ 681 struct drm_property *prop_vrr_enabled; 682 683 /** 684 * @dvi_i_subconnector_property: Optional DVI-I property to 685 * differentiate between analog or digital mode. 686 */ 687 struct drm_property *dvi_i_subconnector_property; 688 /** 689 * @dvi_i_select_subconnector_property: Optional DVI-I property to 690 * select between analog or digital mode. 691 */ 692 struct drm_property *dvi_i_select_subconnector_property; 693 694 /** 695 * @dp_subconnector_property: Optional DP property to differentiate 696 * between different DP downstream port types. 697 */ 698 struct drm_property *dp_subconnector_property; 699 700 /** 701 * @tv_subconnector_property: Optional TV property to differentiate 702 * between different TV connector types. 703 */ 704 struct drm_property *tv_subconnector_property; 705 /** 706 * @tv_select_subconnector_property: Optional TV property to select 707 * between different TV connector types. 708 */ 709 struct drm_property *tv_select_subconnector_property; 710 711 /** 712 * @legacy_tv_mode_property: Optional TV property to select 713 * the output TV mode. 714 * 715 * Superseded by @tv_mode_property 716 */ 717 struct drm_property *legacy_tv_mode_property; 718 719 /** 720 * @tv_mode_property: Optional TV property to select the TV 721 * standard output on the connector. 722 */ 723 struct drm_property *tv_mode_property; 724 725 /** 726 * @tv_left_margin_property: Optional TV property to set the left 727 * margin (expressed in pixels). 728 */ 729 struct drm_property *tv_left_margin_property; 730 /** 731 * @tv_right_margin_property: Optional TV property to set the right 732 * margin (expressed in pixels). 733 */ 734 struct drm_property *tv_right_margin_property; 735 /** 736 * @tv_top_margin_property: Optional TV property to set the right 737 * margin (expressed in pixels). 738 */ 739 struct drm_property *tv_top_margin_property; 740 /** 741 * @tv_bottom_margin_property: Optional TV property to set the right 742 * margin (expressed in pixels). 743 */ 744 struct drm_property *tv_bottom_margin_property; 745 /** 746 * @tv_brightness_property: Optional TV property to set the 747 * brightness. 748 */ 749 struct drm_property *tv_brightness_property; 750 /** 751 * @tv_contrast_property: Optional TV property to set the 752 * contrast. 753 */ 754 struct drm_property *tv_contrast_property; 755 /** 756 * @tv_flicker_reduction_property: Optional TV property to control the 757 * flicker reduction mode. 758 */ 759 struct drm_property *tv_flicker_reduction_property; 760 /** 761 * @tv_overscan_property: Optional TV property to control the overscan 762 * setting. 763 */ 764 struct drm_property *tv_overscan_property; 765 /** 766 * @tv_saturation_property: Optional TV property to set the 767 * saturation. 768 */ 769 struct drm_property *tv_saturation_property; 770 /** 771 * @tv_hue_property: Optional TV property to set the hue. 772 */ 773 struct drm_property *tv_hue_property; 774 775 /** 776 * @scaling_mode_property: Optional connector property to control the 777 * upscaling, mostly used for built-in panels. 778 */ 779 struct drm_property *scaling_mode_property; 780 /** 781 * @aspect_ratio_property: Optional connector property to control the 782 * HDMI infoframe aspect ratio setting. 783 */ 784 struct drm_property *aspect_ratio_property; 785 /** 786 * @content_type_property: Optional connector property to control the 787 * HDMI infoframe content type setting. 788 */ 789 struct drm_property *content_type_property; 790 /** 791 * @degamma_lut_property: Optional CRTC property to set the LUT used to 792 * convert the framebuffer's colors to linear gamma. 793 */ 794 struct drm_property *degamma_lut_property; 795 /** 796 * @degamma_lut_size_property: Optional CRTC property for the size of 797 * the degamma LUT as supported by the driver (read-only). 798 */ 799 struct drm_property *degamma_lut_size_property; 800 /** 801 * @ctm_property: Optional CRTC property to set the 802 * matrix used to convert colors after the lookup in the 803 * degamma LUT. 804 */ 805 struct drm_property *ctm_property; 806 /** 807 * @gamma_lut_property: Optional CRTC property to set the LUT used to 808 * convert the colors, after the CTM matrix, to the gamma space of the 809 * connected screen. 810 */ 811 struct drm_property *gamma_lut_property; 812 /** 813 * @gamma_lut_size_property: Optional CRTC property for the size of the 814 * gamma LUT as supported by the driver (read-only). 815 */ 816 struct drm_property *gamma_lut_size_property; 817 818 /** 819 * @suggested_x_property: Optional connector property with a hint for 820 * the position of the output on the host's screen. 821 */ 822 struct drm_property *suggested_x_property; 823 /** 824 * @suggested_y_property: Optional connector property with a hint for 825 * the position of the output on the host's screen. 826 */ 827 struct drm_property *suggested_y_property; 828 829 /** 830 * @non_desktop_property: Optional connector property with a hint 831 * that device isn't a standard display, and the console/desktop, 832 * should not be displayed on it. 833 */ 834 struct drm_property *non_desktop_property; 835 836 /** 837 * @panel_orientation_property: Optional connector property indicating 838 * how the lcd-panel is mounted inside the casing (e.g. normal or 839 * upside-down). 840 */ 841 struct drm_property *panel_orientation_property; 842 843 /** 844 * @writeback_fb_id_property: Property for writeback connectors, storing 845 * the ID of the output framebuffer. 846 * See also: drm_writeback_connector_init() 847 */ 848 struct drm_property *writeback_fb_id_property; 849 850 /** 851 * @writeback_pixel_formats_property: Property for writeback connectors, 852 * storing an array of the supported pixel formats for the writeback 853 * engine (read-only). 854 * See also: drm_writeback_connector_init() 855 */ 856 struct drm_property *writeback_pixel_formats_property; 857 /** 858 * @writeback_out_fence_ptr_property: Property for writeback connectors, 859 * fd pointer representing the outgoing fences for a writeback 860 * connector. Userspace should provide a pointer to a value of type s32, 861 * and then cast that pointer to u64. 862 * See also: drm_writeback_connector_init() 863 */ 864 struct drm_property *writeback_out_fence_ptr_property; 865 866 /** 867 * @hdr_output_metadata_property: Connector property containing hdr 868 * metatada. This will be provided by userspace compositors based 869 * on HDR content 870 */ 871 struct drm_property *hdr_output_metadata_property; 872 873 /** 874 * @content_protection_property: DRM ENUM property for content 875 * protection. See drm_connector_attach_content_protection_property(). 876 */ 877 struct drm_property *content_protection_property; 878 879 /** 880 * @hdcp_content_type_property: DRM ENUM property for type of 881 * Protected Content. 882 */ 883 struct drm_property *hdcp_content_type_property; 884 885 /* dumb ioctl parameters */ 886 uint32_t preferred_depth, prefer_shadow; 887 888 /** 889 * @quirk_addfb_prefer_xbgr_30bpp: 890 * 891 * Special hack for legacy ADDFB to keep nouveau userspace happy. Should 892 * only ever be set by the nouveau kernel driver. 893 */ 894 bool quirk_addfb_prefer_xbgr_30bpp; 895 896 /** 897 * @quirk_addfb_prefer_host_byte_order: 898 * 899 * When set to true drm_mode_addfb() will pick host byte order 900 * pixel_format when calling drm_mode_addfb2(). This is how 901 * drm_mode_addfb() should have worked from day one. It 902 * didn't though, so we ended up with quirks in both kernel 903 * and userspace drivers to deal with the broken behavior. 904 * Simply fixing drm_mode_addfb() unconditionally would break 905 * these drivers, so add a quirk bit here to allow drivers 906 * opt-in. 907 */ 908 bool quirk_addfb_prefer_host_byte_order; 909 910 /** 911 * @async_page_flip: Does this device support async flips on the primary 912 * plane? 913 */ 914 bool async_page_flip; 915 916 /** 917 * @fb_modifiers_not_supported: 918 * 919 * When this flag is set, the DRM device will not expose modifier 920 * support to userspace. This is only used by legacy drivers that infer 921 * the buffer layout through heuristics without using modifiers. New 922 * drivers shall not set fhis flag. 923 */ 924 bool fb_modifiers_not_supported; 925 926 /** 927 * @normalize_zpos: 928 * 929 * If true the drm core will call drm_atomic_normalize_zpos() as part of 930 * atomic mode checking from drm_atomic_helper_check() 931 */ 932 bool normalize_zpos; 933 934 /** 935 * @modifiers_property: Plane property to list support modifier/format 936 * combination. 937 */ 938 struct drm_property *modifiers_property; 939 940 /** 941 * @async_modifiers_property: Plane property to list support modifier/format 942 * combination for asynchronous flips. 943 */ 944 struct drm_property *async_modifiers_property; 945 946 /** 947 * @size_hints_property: Plane SIZE_HINTS property. 948 */ 949 struct drm_property *size_hints_property; 950 951 /* cursor size */ 952 uint32_t cursor_width, cursor_height; 953 954 /** 955 * @suspend_state: 956 * 957 * Atomic state when suspended. 958 * Set by drm_mode_config_helper_suspend() and cleared by 959 * drm_mode_config_helper_resume(). 960 */ 961 struct drm_atomic_state *suspend_state; 962 963 const struct drm_mode_config_helper_funcs *helper_private; 964 }; 965 966 int __must_check drmm_mode_config_init(struct drm_device *dev); 967 968 /** 969 * drm_mode_config_init - DRM mode_configuration structure initialization 970 * @dev: DRM device 971 * 972 * This is the unmanaged version of drmm_mode_config_init() for drivers which 973 * still explicitly call drm_mode_config_cleanup(). 974 * 975 * FIXME: This function is deprecated and drivers should be converted over to 976 * drmm_mode_config_init(). 977 */ 978 static inline int drm_mode_config_init(struct drm_device *dev) 979 { 980 return drmm_mode_config_init(dev); 981 } 982 983 void drm_mode_config_reset(struct drm_device *dev); 984 void drm_mode_config_cleanup(struct drm_device *dev); 985 986 #endif 987