| 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_commit;
|
| 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_commit 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_commit *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_commit 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_commit *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_commit 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_commit is deprecated in favour of using
|
| 281 | * &drm_private_state and &drm_private_obj.
|
| 282 | *
|
| 283 | * RETURNS:
|
| 284 | *
|
| 285 | * A new &drm_atomic_commit on success or NULL on failure.
|
| 286 |
|
| 287 | struct drm_atomic_commit *(*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_commit. 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_commit_default_clear()
|
| 303 | * to clear common state.
|
| 304 | *
|
| 305 | * Subclassing of &drm_atomic_commit is deprecated in favour of using
|
| 306 | * &drm_private_state and &drm_private_obj.
|
| 307 |
|
| 308 | void (*atomic_state_clear)(struct drm_atomic_commit *state);
|
| 309 |
|
| 310 | |
| 311 | * @atomic_state_free:
|
| 312 | *
|
| 313 | * This hook needs driver private resources and the &drm_atomic_commit
|
| 314 | * itself. Note that the core first calls drm_atomic_commit_clear() to
|
| 315 | * avoid code duplicate between the clear and free hooks.
|
| 316 | *
|
| 317 | * Drivers that implement this must call
|
| 318 | * drm_atomic_commit_default_release() to release common resources.
|
| 319 | *
|
| 320 | * Subclassing of &drm_atomic_commit is deprecated in favour of using
|
| 321 | * &drm_private_state and &drm_private_obj.
|
| 322 |
|
| 323 | void (*atomic_state_free)(struct drm_atomic_commit *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 |
|
| 418 | struct mutex fb_lock;
|
| 419 |
|
| 420 | int num_fb;
|
| 421 |
|
| 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 |
|
| 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 |
|
| 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 | * @panel_type_property: Default connector property for panel type
|
| 605 |
|
| 606 | struct drm_property *panel_type_property;
|
| 607 | |
| 608 | * @link_status_property: Default connector property for link status
|
| 609 | * of a connector
|
| 610 |
|
| 611 | struct drm_property *link_status_property;
|
| 612 | |
| 613 | * @plane_type_property: Default plane property to differentiate
|
| 614 | * CURSOR, PRIMARY and OVERLAY legacy uses of planes.
|
| 615 |
|
| 616 | struct drm_property *plane_type_property;
|
| 617 | |
| 618 | * @prop_src_x: Default atomic plane property for the plane source
|
| 619 | * position in the connected &drm_framebuffer.
|
| 620 |
|
| 621 | struct drm_property *prop_src_x;
|
| 622 | |
| 623 | * @prop_src_y: Default atomic plane property for the plane source
|
| 624 | * position in the connected &drm_framebuffer.
|
| 625 |
|
| 626 | struct drm_property *prop_src_y;
|
| 627 | |
| 628 | * @prop_src_w: Default atomic plane property for the plane source
|
| 629 | * position in the connected &drm_framebuffer.
|
| 630 |
|
| 631 | struct drm_property *prop_src_w;
|
| 632 | |
| 633 | * @prop_src_h: Default atomic plane property for the plane source
|
| 634 | * position in the connected &drm_framebuffer.
|
| 635 |
|
| 636 | struct drm_property *prop_src_h;
|
| 637 | |
| 638 | * @prop_crtc_x: Default atomic plane property for the plane destination
|
| 639 | * position in the &drm_crtc is being shown on.
|
| 640 |
|
| 641 | struct drm_property *prop_crtc_x;
|
| 642 | |
| 643 | * @prop_crtc_y: Default atomic plane property for the plane destination
|
| 644 | * position in the &drm_crtc is being shown on.
|
| 645 |
|
| 646 | struct drm_property *prop_crtc_y;
|
| 647 | |
| 648 | * @prop_crtc_w: Default atomic plane property for the plane destination
|
| 649 | * position in the &drm_crtc is being shown on.
|
| 650 |
|
| 651 | struct drm_property *prop_crtc_w;
|
| 652 | |
| 653 | * @prop_crtc_h: Default atomic plane property for the plane destination
|
| 654 | * position in the &drm_crtc is being shown on.
|
| 655 |
|
| 656 | struct drm_property *prop_crtc_h;
|
| 657 | |
| 658 | * @prop_fb_id: Default atomic plane property to specify the
|
| 659 | * &drm_framebuffer.
|
| 660 |
|
| 661 | struct drm_property *prop_fb_id;
|
| 662 | |
| 663 | * @prop_in_fence_fd: Sync File fd representing the incoming fences
|
| 664 | * for a Plane.
|
| 665 |
|
| 666 | struct drm_property *prop_in_fence_fd;
|
| 667 | |
| 668 | * @prop_out_fence_ptr: Sync File fd pointer representing the
|
| 669 | * outgoing fences for a CRTC. Userspace should provide a pointer to a
|
| 670 | * value of type s32, and then cast that pointer to u64.
|
| 671 |
|
| 672 | struct drm_property *prop_out_fence_ptr;
|
| 673 | |
| 674 | * @prop_crtc_id: Default atomic plane property to specify the
|
| 675 | * &drm_crtc.
|
| 676 |
|
| 677 | struct drm_property *prop_crtc_id;
|
| 678 | |
| 679 | * @prop_fb_damage_clips: Optional plane property to mark damaged
|
| 680 | * regions on the plane in framebuffer coordinates of the framebuffer
|
| 681 | * attached to the plane.
|
| 682 | *
|
| 683 | * The layout of blob data is simply an array of &drm_mode_rect. Unlike
|
| 684 | * plane src coordinates, damage clips are not in 16.16 fixed point.
|
| 685 |
|
| 686 | struct drm_property *prop_fb_damage_clips;
|
| 687 | |
| 688 | * @prop_active: Default atomic CRTC property to control the active
|
| 689 | * state, which is the simplified implementation for DPMS in atomic
|
| 690 | * drivers.
|
| 691 |
|
| 692 | struct drm_property *prop_active;
|
| 693 | |
| 694 | * @prop_mode_id: Default atomic CRTC property to set the mode for a
|
| 695 | * CRTC. A 0 mode implies that the CRTC is entirely disabled - all
|
| 696 | * connectors must be of and active must be set to disabled, too.
|
| 697 |
|
| 698 | struct drm_property *prop_mode_id;
|
| 699 | |
| 700 | * @prop_vrr_enabled: Default atomic CRTC property to indicate
|
| 701 | * whether variable refresh rate should be enabled on the CRTC.
|
| 702 |
|
| 703 | struct drm_property *prop_vrr_enabled;
|
| 704 |
|
| 705 | |
| 706 | * @dvi_i_subconnector_property: Optional DVI-I property to
|
| 707 | * differentiate between analog or digital mode.
|
| 708 |
|
| 709 | struct drm_property *dvi_i_subconnector_property;
|
| 710 | |
| 711 | * @dvi_i_select_subconnector_property: Optional DVI-I property to
|
| 712 | * select between analog or digital mode.
|
| 713 |
|
| 714 | struct drm_property *dvi_i_select_subconnector_property;
|
| 715 |
|
| 716 | |
| 717 | * @dp_subconnector_property: Optional DP property to differentiate
|
| 718 | * between different DP downstream port types.
|
| 719 |
|
| 720 | struct drm_property *dp_subconnector_property;
|
| 721 |
|
| 722 | |
| 723 | * @tv_subconnector_property: Optional TV property to differentiate
|
| 724 | * between different TV connector types.
|
| 725 |
|
| 726 | struct drm_property *tv_subconnector_property;
|
| 727 | |
| 728 | * @tv_select_subconnector_property: Optional TV property to select
|
| 729 | * between different TV connector types.
|
| 730 |
|
| 731 | struct drm_property *tv_select_subconnector_property;
|
| 732 |
|
| 733 | |
| 734 | * @legacy_tv_mode_property: Optional TV property to select
|
| 735 | * the output TV mode.
|
| 736 | *
|
| 737 | * Superseded by @tv_mode_property
|
| 738 |
|
| 739 | struct drm_property *legacy_tv_mode_property;
|
| 740 |
|
| 741 | |
| 742 | * @tv_mode_property: Optional TV property to select the TV
|
| 743 | * standard output on the connector.
|
| 744 |
|
| 745 | struct drm_property *tv_mode_property;
|
| 746 |
|
| 747 | |
| 748 | * @tv_left_margin_property: Optional TV property to set the left
|
| 749 | * margin (expressed in pixels).
|
| 750 |
|
| 751 | struct drm_property *tv_left_margin_property;
|
| 752 | |
| 753 | * @tv_right_margin_property: Optional TV property to set the right
|
| 754 | * margin (expressed in pixels).
|
| 755 |
|
| 756 | struct drm_property *tv_right_margin_property;
|
| 757 | |
| 758 | * @tv_top_margin_property: Optional TV property to set the right
|
| 759 | * margin (expressed in pixels).
|
| 760 |
|
| 761 | struct drm_property *tv_top_margin_property;
|
| 762 | |
| 763 | * @tv_bottom_margin_property: Optional TV property to set the right
|
| 764 | * margin (expressed in pixels).
|
| 765 |
|
| 766 | struct drm_property *tv_bottom_margin_property;
|
| 767 | |
| 768 | * @tv_brightness_property: Optional TV property to set the
|
| 769 | * brightness.
|
| 770 |
|
| 771 | struct drm_property *tv_brightness_property;
|
| 772 | |
| 773 | * @tv_contrast_property: Optional TV property to set the
|
| 774 | * contrast.
|
| 775 |
|
| 776 | struct drm_property *tv_contrast_property;
|
| 777 | |
| 778 | * @tv_flicker_reduction_property: Optional TV property to control the
|
| 779 | * flicker reduction mode.
|
| 780 |
|
| 781 | struct drm_property *tv_flicker_reduction_property;
|
| 782 | |
| 783 | * @tv_overscan_property: Optional TV property to control the overscan
|
| 784 | * setting.
|
| 785 |
|
| 786 | struct drm_property *tv_overscan_property;
|
| 787 | |
| 788 | * @tv_saturation_property: Optional TV property to set the
|
| 789 | * saturation.
|
| 790 |
|
| 791 | struct drm_property *tv_saturation_property;
|
| 792 | |
| 793 | * @tv_hue_property: Optional TV property to set the hue.
|
| 794 |
|
| 795 | struct drm_property *tv_hue_property;
|
| 796 |
|
| 797 | |
| 798 | * @scaling_mode_property: Optional connector property to control the
|
| 799 | * upscaling, mostly used for built-in panels.
|
| 800 |
|
| 801 | struct drm_property *scaling_mode_property;
|
| 802 | |
| 803 | * @aspect_ratio_property: Optional connector property to control the
|
| 804 | * HDMI infoframe aspect ratio setting.
|
| 805 |
|
| 806 | struct drm_property *aspect_ratio_property;
|
| 807 | |
| 808 | * @content_type_property: Optional connector property to control the
|
| 809 | * HDMI infoframe content type setting.
|
| 810 |
|
| 811 | struct drm_property *content_type_property;
|
| 812 | |
| 813 | * @degamma_lut_property: Optional CRTC property to set the LUT used to
|
| 814 | * convert the framebuffer's colors to linear gamma.
|
| 815 |
|
| 816 | struct drm_property *degamma_lut_property;
|
| 817 | |
| 818 | * @degamma_lut_size_property: Optional CRTC property for the size of
|
| 819 | * the degamma LUT as supported by the driver (read-only).
|
| 820 |
|
| 821 | struct drm_property *degamma_lut_size_property;
|
| 822 | |
| 823 | * @ctm_property: Optional CRTC property to set the
|
| 824 | * matrix used to convert colors after the lookup in the
|
| 825 | * degamma LUT.
|
| 826 |
|
| 827 | struct drm_property *ctm_property;
|
| 828 | |
| 829 | * @gamma_lut_property: Optional CRTC property to set the LUT used to
|
| 830 | * convert the colors, after the CTM matrix, to the gamma space of the
|
| 831 | * connected screen.
|
| 832 |
|
| 833 | struct drm_property *gamma_lut_property;
|
| 834 | |
| 835 | * @gamma_lut_size_property: Optional CRTC property for the size of the
|
| 836 | * gamma LUT as supported by the driver (read-only).
|
| 837 |
|
| 838 | struct drm_property *gamma_lut_size_property;
|
| 839 | |
| 840 | * @background_color_property: Optional CRTC property to set the
|
| 841 | * background color.
|
| 842 |
|
| 843 | struct drm_property *background_color_property;
|
| 844 |
|
| 845 | |
| 846 | * @suggested_x_property: Optional connector property with a hint for
|
| 847 | * the position of the output on the host's screen.
|
| 848 |
|
| 849 | struct drm_property *suggested_x_property;
|
| 850 | |
| 851 | * @suggested_y_property: Optional connector property with a hint for
|
| 852 | * the position of the output on the host's screen.
|
| 853 |
|
| 854 | struct drm_property *suggested_y_property;
|
| 855 |
|
| 856 | |
| 857 | * @non_desktop_property: Optional connector property with a hint
|
| 858 | * that device isn't a standard display, and the console/desktop,
|
| 859 | * should not be displayed on it.
|
| 860 |
|
| 861 | struct drm_property *non_desktop_property;
|
| 862 |
|
| 863 | |
| 864 | * @panel_orientation_property: Optional connector property indicating
|
| 865 | * how the lcd-panel is mounted inside the casing (e.g. normal or
|
| 866 | * upside-down).
|
| 867 |
|
| 868 | struct drm_property *panel_orientation_property;
|
| 869 |
|
| 870 | |
| 871 | * @writeback_fb_id_property: Property for writeback connectors, storing
|
| 872 | * the ID of the output framebuffer.
|
| 873 | * See also: drm_writeback_connector_init()
|
| 874 |
|
| 875 | struct drm_property *writeback_fb_id_property;
|
| 876 |
|
| 877 | |
| 878 | * @writeback_pixel_formats_property: Property for writeback connectors,
|
| 879 | * storing an array of the supported pixel formats for the writeback
|
| 880 | * engine (read-only).
|
| 881 | * See also: drm_writeback_connector_init()
|
| 882 |
|
| 883 | struct drm_property *writeback_pixel_formats_property;
|
| 884 | |
| 885 | * @writeback_out_fence_ptr_property: Property for writeback connectors,
|
| 886 | * fd pointer representing the outgoing fences for a writeback
|
| 887 | * connector. Userspace should provide a pointer to a value of type s32,
|
| 888 | * and then cast that pointer to u64.
|
| 889 | * See also: drm_writeback_connector_init()
|
| 890 |
|
| 891 | struct drm_property *writeback_out_fence_ptr_property;
|
| 892 |
|
| 893 | |
| 894 | * @hdr_output_metadata_property: Connector property containing hdr
|
| 895 | * metatada. This will be provided by userspace compositors based
|
| 896 | * on HDR content
|
| 897 |
|
| 898 | struct drm_property *hdr_output_metadata_property;
|
| 899 |
|
| 900 | |
| 901 | * @content_protection_property: DRM ENUM property for content
|
| 902 | * protection. See drm_connector_attach_content_protection_property().
|
| 903 |
|
| 904 | struct drm_property *content_protection_property;
|
| 905 |
|
| 906 | |
| 907 | * @hdcp_content_type_property: DRM ENUM property for type of
|
| 908 | * Protected Content.
|
| 909 |
|
| 910 | struct drm_property *hdcp_content_type_property;
|
| 911 |
|
| 912 |
|
| 913 | uint32_t preferred_depth, prefer_shadow;
|
| 914 |
|
| 915 | |
| 916 | * @quirk_addfb_prefer_xbgr_30bpp:
|
| 917 | *
|
| 918 | * Special hack for legacy ADDFB to keep nouveau userspace happy. Should
|
| 919 | * only ever be set by the nouveau kernel driver.
|
| 920 |
|
| 921 | bool quirk_addfb_prefer_xbgr_30bpp;
|
| 922 |
|
| 923 | |
| 924 | * @quirk_addfb_prefer_host_byte_order:
|
| 925 | *
|
| 926 | * When set to true drm_mode_addfb() will pick host byte order
|
| 927 | * pixel_format when calling drm_mode_addfb2(). This is how
|
| 928 | * drm_mode_addfb() should have worked from day one. It
|
| 929 | * didn't though, so we ended up with quirks in both kernel
|
| 930 | * and userspace drivers to deal with the broken behavior.
|
| 931 | * Simply fixing drm_mode_addfb() unconditionally would break
|
| 932 | * these drivers, so add a quirk bit here to allow drivers
|
| 933 | * opt-in.
|
| 934 |
|
| 935 | bool quirk_addfb_prefer_host_byte_order;
|
| 936 |
|
| 937 | |
| 938 | * @async_page_flip: Does this device support async flips on the primary
|
| 939 | * plane?
|
| 940 |
|
| 941 | bool async_page_flip;
|
| 942 |
|
| 943 | |
| 944 | * @fb_modifiers_not_supported:
|
| 945 | *
|
| 946 | * When this flag is set, the DRM device will not expose modifier
|
| 947 | * support to userspace. This is only used by legacy drivers that infer
|
| 948 | * the buffer layout through heuristics without using modifiers. New
|
| 949 | * drivers shall not set fhis flag.
|
| 950 |
|
| 951 | bool fb_modifiers_not_supported;
|
| 952 |
|
| 953 | |
| 954 | * @normalize_zpos:
|
| 955 | *
|
| 956 | * If true the drm core will call drm_atomic_normalize_zpos() as part of
|
| 957 | * atomic mode checking from drm_atomic_helper_check()
|
| 958 |
|
| 959 | bool normalize_zpos;
|
| 960 |
|
| 961 | |
| 962 | * @modifiers_property: Plane property to list support modifier/format
|
| 963 | * combination.
|
| 964 |
|
| 965 | struct drm_property *modifiers_property;
|
| 966 |
|
| 967 | |
| 968 | * @async_modifiers_property: Plane property to list support modifier/format
|
| 969 | * combination for asynchronous flips.
|
| 970 |
|
| 971 | struct drm_property *async_modifiers_property;
|
| 972 |
|
| 973 | |
| 974 | * @size_hints_property: Plane SIZE_HINTS property.
|
| 975 |
|
| 976 | struct drm_property *size_hints_property;
|
| 977 |
|
| 978 |
|
| 979 | uint32_t cursor_width, cursor_height;
|
| 980 |
|
| 981 | |
| 982 | * @suspend_state:
|
| 983 | *
|
| 984 | * Atomic state when suspended.
|
| 985 | * Set by drm_mode_config_helper_suspend() and cleared by
|
| 986 | * drm_mode_config_helper_resume().
|
| 987 |
|
| 988 | struct drm_atomic_commit *suspend_state;
|
| 989 |
|
| 990 | const struct drm_mode_config_helper_funcs *helper_private;
|
| 991 | };
|
| 992 |
|
| 993 | int __must_check drmm_mode_config_init(struct drm_device *dev);
|
| 994 |
|
| 995 | |
| 996 | * drm_mode_config_init - DRM mode_configuration structure initialization
|
| 997 | * @dev: DRM device
|
| 998 | *
|
| 999 | * This is the unmanaged version of drmm_mode_config_init() for drivers which
|
| 1000 | * still explicitly call drm_mode_config_cleanup().
|
| 1001 | *
|
| 1002 | * FIXME: This function is deprecated and drivers should be converted over to
|
| 1003 | * drmm_mode_config_init().
|
| 1004 |
|
| 1005 | static inline int drm_mode_config_init(struct drm_device *dev)
|
| 1006 | {
|
| 1007 | return drmm_mode_config_init(dev);
|
| 1008 | }
|
| 1009 |
|
| 1010 | int drm_mode_config_create_initial_state(struct drm_device *dev);
|
| 1011 | void drm_mode_config_reset(struct drm_device *dev);
|
| 1012 | void drm_mode_config_cleanup(struct drm_device *dev);
|
| 1013 |
|
| 1014 | #endif
|