18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2016 Intel Corporation 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, distribute, and sell this software and its 58c2ecf20Sopenharmony_ci * documentation for any purpose is hereby granted without fee, provided that 68c2ecf20Sopenharmony_ci * the above copyright notice appear in all copies and that both that copyright 78c2ecf20Sopenharmony_ci * notice and this permission notice appear in supporting documentation, and 88c2ecf20Sopenharmony_ci * that the name of the copyright holders not be used in advertising or 98c2ecf20Sopenharmony_ci * publicity pertaining to distribution of the software without specific, 108c2ecf20Sopenharmony_ci * written prior permission. The copyright holders make no representations 118c2ecf20Sopenharmony_ci * about the suitability of this software for any purpose. It is provided "as 128c2ecf20Sopenharmony_ci * is" without express or implied warranty. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 158c2ecf20Sopenharmony_ci * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 168c2ecf20Sopenharmony_ci * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 178c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 188c2ecf20Sopenharmony_ci * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 198c2ecf20Sopenharmony_ci * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 208c2ecf20Sopenharmony_ci * OF THIS SOFTWARE. 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#ifndef __DRM_MODE_CONFIG_H__ 248c2ecf20Sopenharmony_ci#define __DRM_MODE_CONFIG_H__ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include <linux/mutex.h> 278c2ecf20Sopenharmony_ci#include <linux/types.h> 288c2ecf20Sopenharmony_ci#include <linux/idr.h> 298c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 308c2ecf20Sopenharmony_ci#include <linux/llist.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#include <drm/drm_modeset_lock.h> 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct drm_file; 358c2ecf20Sopenharmony_cistruct drm_device; 368c2ecf20Sopenharmony_cistruct drm_atomic_state; 378c2ecf20Sopenharmony_cistruct drm_mode_fb_cmd2; 388c2ecf20Sopenharmony_cistruct drm_format_info; 398c2ecf20Sopenharmony_cistruct drm_display_mode; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/** 428c2ecf20Sopenharmony_ci * struct drm_mode_config_funcs - basic driver provided mode setting functions 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that 458c2ecf20Sopenharmony_ci * involve drivers. 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_cistruct drm_mode_config_funcs { 488c2ecf20Sopenharmony_ci /** 498c2ecf20Sopenharmony_ci * @fb_create: 508c2ecf20Sopenharmony_ci * 518c2ecf20Sopenharmony_ci * Create a new framebuffer object. The core does basic checks on the 528c2ecf20Sopenharmony_ci * requested metadata, but most of that is left to the driver. See 538c2ecf20Sopenharmony_ci * &struct drm_mode_fb_cmd2 for details. 548c2ecf20Sopenharmony_ci * 558c2ecf20Sopenharmony_ci * To validate the pixel format and modifier drivers can use 568c2ecf20Sopenharmony_ci * drm_any_plane_has_format() to make sure at least one plane supports 578c2ecf20Sopenharmony_ci * the requested values. Note that the driver must first determine the 588c2ecf20Sopenharmony_ci * actual modifier used if the request doesn't have it specified, 598c2ecf20Sopenharmony_ci * ie. when (@mode_cmd->flags & DRM_MODE_FB_MODIFIERS) == 0. 608c2ecf20Sopenharmony_ci * 618c2ecf20Sopenharmony_ci * If the parameters are deemed valid and the backing storage objects in 628c2ecf20Sopenharmony_ci * the underlying memory manager all exist, then the driver allocates 638c2ecf20Sopenharmony_ci * a new &drm_framebuffer structure, subclassed to contain 648c2ecf20Sopenharmony_ci * driver-specific information (like the internal native buffer object 658c2ecf20Sopenharmony_ci * references). It also needs to fill out all relevant metadata, which 668c2ecf20Sopenharmony_ci * should be done by calling drm_helper_mode_fill_fb_struct(). 678c2ecf20Sopenharmony_ci * 688c2ecf20Sopenharmony_ci * The initialization is finalized by calling drm_framebuffer_init(), 698c2ecf20Sopenharmony_ci * which registers the framebuffer and makes it accessible to other 708c2ecf20Sopenharmony_ci * threads. 718c2ecf20Sopenharmony_ci * 728c2ecf20Sopenharmony_ci * RETURNS: 738c2ecf20Sopenharmony_ci * 748c2ecf20Sopenharmony_ci * A new framebuffer with an initial reference count of 1 or a negative 758c2ecf20Sopenharmony_ci * error code encoded with ERR_PTR(). 768c2ecf20Sopenharmony_ci */ 778c2ecf20Sopenharmony_ci struct drm_framebuffer *(*fb_create)(struct drm_device *dev, 788c2ecf20Sopenharmony_ci struct drm_file *file_priv, 798c2ecf20Sopenharmony_ci const struct drm_mode_fb_cmd2 *mode_cmd); 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci /** 828c2ecf20Sopenharmony_ci * @get_format_info: 838c2ecf20Sopenharmony_ci * 848c2ecf20Sopenharmony_ci * Allows a driver to return custom format information for special 858c2ecf20Sopenharmony_ci * fb layouts (eg. ones with auxiliary compression control planes). 868c2ecf20Sopenharmony_ci * 878c2ecf20Sopenharmony_ci * RETURNS: 888c2ecf20Sopenharmony_ci * 898c2ecf20Sopenharmony_ci * The format information specific to the given fb metadata, or 908c2ecf20Sopenharmony_ci * NULL if none is found. 918c2ecf20Sopenharmony_ci */ 928c2ecf20Sopenharmony_ci const struct drm_format_info *(*get_format_info)(const struct drm_mode_fb_cmd2 *mode_cmd); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci /** 958c2ecf20Sopenharmony_ci * @output_poll_changed: 968c2ecf20Sopenharmony_ci * 978c2ecf20Sopenharmony_ci * Callback used by helpers to inform the driver of output configuration 988c2ecf20Sopenharmony_ci * changes. 998c2ecf20Sopenharmony_ci * 1008c2ecf20Sopenharmony_ci * Drivers implementing fbdev emulation with the helpers can call 1018c2ecf20Sopenharmony_ci * drm_fb_helper_hotplug_changed from this hook to inform the fbdev 1028c2ecf20Sopenharmony_ci * helper of output changes. 1038c2ecf20Sopenharmony_ci * 1048c2ecf20Sopenharmony_ci * FIXME: 1058c2ecf20Sopenharmony_ci * 1068c2ecf20Sopenharmony_ci * Except that there's no vtable for device-level helper callbacks 1078c2ecf20Sopenharmony_ci * there's no reason this is a core function. 1088c2ecf20Sopenharmony_ci */ 1098c2ecf20Sopenharmony_ci void (*output_poll_changed)(struct drm_device *dev); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci /** 1128c2ecf20Sopenharmony_ci * @mode_valid: 1138c2ecf20Sopenharmony_ci * 1148c2ecf20Sopenharmony_ci * Device specific validation of display modes. Can be used to reject 1158c2ecf20Sopenharmony_ci * modes that can never be supported. Only device wide constraints can 1168c2ecf20Sopenharmony_ci * be checked here. crtc/encoder/bridge/connector specific constraints 1178c2ecf20Sopenharmony_ci * should be checked in the .mode_valid() hook for each specific object. 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_ci enum drm_mode_status (*mode_valid)(struct drm_device *dev, 1208c2ecf20Sopenharmony_ci const struct drm_display_mode *mode); 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci /** 1238c2ecf20Sopenharmony_ci * @atomic_check: 1248c2ecf20Sopenharmony_ci * 1258c2ecf20Sopenharmony_ci * This is the only hook to validate an atomic modeset update. This 1268c2ecf20Sopenharmony_ci * function must reject any modeset and state changes which the hardware 1278c2ecf20Sopenharmony_ci * or driver doesn't support. This includes but is of course not limited 1288c2ecf20Sopenharmony_ci * to: 1298c2ecf20Sopenharmony_ci * 1308c2ecf20Sopenharmony_ci * - Checking that the modes, framebuffers, scaling and placement 1318c2ecf20Sopenharmony_ci * requirements and so on are within the limits of the hardware. 1328c2ecf20Sopenharmony_ci * 1338c2ecf20Sopenharmony_ci * - Checking that any hidden shared resources are not oversubscribed. 1348c2ecf20Sopenharmony_ci * This can be shared PLLs, shared lanes, overall memory bandwidth, 1358c2ecf20Sopenharmony_ci * display fifo space (where shared between planes or maybe even 1368c2ecf20Sopenharmony_ci * CRTCs). 1378c2ecf20Sopenharmony_ci * 1388c2ecf20Sopenharmony_ci * - Checking that virtualized resources exported to userspace are not 1398c2ecf20Sopenharmony_ci * oversubscribed. For various reasons it can make sense to expose 1408c2ecf20Sopenharmony_ci * more planes, crtcs or encoders than which are physically there. One 1418c2ecf20Sopenharmony_ci * example is dual-pipe operations (which generally should be hidden 1428c2ecf20Sopenharmony_ci * from userspace if when lockstepped in hardware, exposed otherwise), 1438c2ecf20Sopenharmony_ci * where a plane might need 1 hardware plane (if it's just on one 1448c2ecf20Sopenharmony_ci * pipe), 2 hardware planes (when it spans both pipes) or maybe even 1458c2ecf20Sopenharmony_ci * shared a hardware plane with a 2nd plane (if there's a compatible 1468c2ecf20Sopenharmony_ci * plane requested on the area handled by the other pipe). 1478c2ecf20Sopenharmony_ci * 1488c2ecf20Sopenharmony_ci * - Check that any transitional state is possible and that if 1498c2ecf20Sopenharmony_ci * requested, the update can indeed be done in the vblank period 1508c2ecf20Sopenharmony_ci * without temporarily disabling some functions. 1518c2ecf20Sopenharmony_ci * 1528c2ecf20Sopenharmony_ci * - Check any other constraints the driver or hardware might have. 1538c2ecf20Sopenharmony_ci * 1548c2ecf20Sopenharmony_ci * - This callback also needs to correctly fill out the &drm_crtc_state 1558c2ecf20Sopenharmony_ci * in this update to make sure that drm_atomic_crtc_needs_modeset() 1568c2ecf20Sopenharmony_ci * reflects the nature of the possible update and returns true if and 1578c2ecf20Sopenharmony_ci * only if the update cannot be applied without tearing within one 1588c2ecf20Sopenharmony_ci * vblank on that CRTC. The core uses that information to reject 1598c2ecf20Sopenharmony_ci * updates which require a full modeset (i.e. blanking the screen, or 1608c2ecf20Sopenharmony_ci * at least pausing updates for a substantial amount of time) if 1618c2ecf20Sopenharmony_ci * userspace has disallowed that in its request. 1628c2ecf20Sopenharmony_ci * 1638c2ecf20Sopenharmony_ci * - The driver also does not need to repeat basic input validation 1648c2ecf20Sopenharmony_ci * like done for the corresponding legacy entry points. The core does 1658c2ecf20Sopenharmony_ci * that before calling this hook. 1668c2ecf20Sopenharmony_ci * 1678c2ecf20Sopenharmony_ci * See the documentation of @atomic_commit for an exhaustive list of 1688c2ecf20Sopenharmony_ci * error conditions which don't have to be checked at the in this 1698c2ecf20Sopenharmony_ci * callback. 1708c2ecf20Sopenharmony_ci * 1718c2ecf20Sopenharmony_ci * See the documentation for &struct drm_atomic_state for how exactly 1728c2ecf20Sopenharmony_ci * an atomic modeset update is described. 1738c2ecf20Sopenharmony_ci * 1748c2ecf20Sopenharmony_ci * Drivers using the atomic helpers can implement this hook using 1758c2ecf20Sopenharmony_ci * drm_atomic_helper_check(), or one of the exported sub-functions of 1768c2ecf20Sopenharmony_ci * it. 1778c2ecf20Sopenharmony_ci * 1788c2ecf20Sopenharmony_ci * RETURNS: 1798c2ecf20Sopenharmony_ci * 1808c2ecf20Sopenharmony_ci * 0 on success or one of the below negative error codes: 1818c2ecf20Sopenharmony_ci * 1828c2ecf20Sopenharmony_ci * - -EINVAL, if any of the above constraints are violated. 1838c2ecf20Sopenharmony_ci * 1848c2ecf20Sopenharmony_ci * - -EDEADLK, when returned from an attempt to acquire an additional 1858c2ecf20Sopenharmony_ci * &drm_modeset_lock through drm_modeset_lock(). 1868c2ecf20Sopenharmony_ci * 1878c2ecf20Sopenharmony_ci * - -ENOMEM, if allocating additional state sub-structures failed due 1888c2ecf20Sopenharmony_ci * to lack of memory. 1898c2ecf20Sopenharmony_ci * 1908c2ecf20Sopenharmony_ci * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. 1918c2ecf20Sopenharmony_ci * This can either be due to a pending signal, or because the driver 1928c2ecf20Sopenharmony_ci * needs to completely bail out to recover from an exceptional 1938c2ecf20Sopenharmony_ci * situation like a GPU hang. From a userspace point all errors are 1948c2ecf20Sopenharmony_ci * treated equally. 1958c2ecf20Sopenharmony_ci */ 1968c2ecf20Sopenharmony_ci int (*atomic_check)(struct drm_device *dev, 1978c2ecf20Sopenharmony_ci struct drm_atomic_state *state); 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci /** 2008c2ecf20Sopenharmony_ci * @atomic_commit: 2018c2ecf20Sopenharmony_ci * 2028c2ecf20Sopenharmony_ci * This is the only hook to commit an atomic modeset update. The core 2038c2ecf20Sopenharmony_ci * guarantees that @atomic_check has been called successfully before 2048c2ecf20Sopenharmony_ci * calling this function, and that nothing has been changed in the 2058c2ecf20Sopenharmony_ci * interim. 2068c2ecf20Sopenharmony_ci * 2078c2ecf20Sopenharmony_ci * See the documentation for &struct drm_atomic_state for how exactly 2088c2ecf20Sopenharmony_ci * an atomic modeset update is described. 2098c2ecf20Sopenharmony_ci * 2108c2ecf20Sopenharmony_ci * Drivers using the atomic helpers can implement this hook using 2118c2ecf20Sopenharmony_ci * drm_atomic_helper_commit(), or one of the exported sub-functions of 2128c2ecf20Sopenharmony_ci * it. 2138c2ecf20Sopenharmony_ci * 2148c2ecf20Sopenharmony_ci * Nonblocking commits (as indicated with the nonblock parameter) must 2158c2ecf20Sopenharmony_ci * do any preparatory work which might result in an unsuccessful commit 2168c2ecf20Sopenharmony_ci * in the context of this callback. The only exceptions are hardware 2178c2ecf20Sopenharmony_ci * errors resulting in -EIO. But even in that case the driver must 2188c2ecf20Sopenharmony_ci * ensure that the display pipe is at least running, to avoid 2198c2ecf20Sopenharmony_ci * compositors crashing when pageflips don't work. Anything else, 2208c2ecf20Sopenharmony_ci * specifically committing the update to the hardware, should be done 2218c2ecf20Sopenharmony_ci * without blocking the caller. For updates which do not require a 2228c2ecf20Sopenharmony_ci * modeset this must be guaranteed. 2238c2ecf20Sopenharmony_ci * 2248c2ecf20Sopenharmony_ci * The driver must wait for any pending rendering to the new 2258c2ecf20Sopenharmony_ci * framebuffers to complete before executing the flip. It should also 2268c2ecf20Sopenharmony_ci * wait for any pending rendering from other drivers if the underlying 2278c2ecf20Sopenharmony_ci * buffer is a shared dma-buf. Nonblocking commits must not wait for 2288c2ecf20Sopenharmony_ci * rendering in the context of this callback. 2298c2ecf20Sopenharmony_ci * 2308c2ecf20Sopenharmony_ci * An application can request to be notified when the atomic commit has 2318c2ecf20Sopenharmony_ci * completed. These events are per-CRTC and can be distinguished by the 2328c2ecf20Sopenharmony_ci * CRTC index supplied in &drm_event to userspace. 2338c2ecf20Sopenharmony_ci * 2348c2ecf20Sopenharmony_ci * The drm core will supply a &struct drm_event in each CRTC's 2358c2ecf20Sopenharmony_ci * &drm_crtc_state.event. See the documentation for 2368c2ecf20Sopenharmony_ci * &drm_crtc_state.event for more details about the precise semantics of 2378c2ecf20Sopenharmony_ci * this event. 2388c2ecf20Sopenharmony_ci * 2398c2ecf20Sopenharmony_ci * NOTE: 2408c2ecf20Sopenharmony_ci * 2418c2ecf20Sopenharmony_ci * Drivers are not allowed to shut down any display pipe successfully 2428c2ecf20Sopenharmony_ci * enabled through an atomic commit on their own. Doing so can result in 2438c2ecf20Sopenharmony_ci * compositors crashing if a page flip is suddenly rejected because the 2448c2ecf20Sopenharmony_ci * pipe is off. 2458c2ecf20Sopenharmony_ci * 2468c2ecf20Sopenharmony_ci * RETURNS: 2478c2ecf20Sopenharmony_ci * 2488c2ecf20Sopenharmony_ci * 0 on success or one of the below negative error codes: 2498c2ecf20Sopenharmony_ci * 2508c2ecf20Sopenharmony_ci * - -EBUSY, if a nonblocking updated is requested and there is 2518c2ecf20Sopenharmony_ci * an earlier updated pending. Drivers are allowed to support a queue 2528c2ecf20Sopenharmony_ci * of outstanding updates, but currently no driver supports that. 2538c2ecf20Sopenharmony_ci * Note that drivers must wait for preceding updates to complete if a 2548c2ecf20Sopenharmony_ci * synchronous update is requested, they are not allowed to fail the 2558c2ecf20Sopenharmony_ci * commit in that case. 2568c2ecf20Sopenharmony_ci * 2578c2ecf20Sopenharmony_ci * - -ENOMEM, if the driver failed to allocate memory. Specifically 2588c2ecf20Sopenharmony_ci * this can happen when trying to pin framebuffers, which must only 2598c2ecf20Sopenharmony_ci * be done when committing the state. 2608c2ecf20Sopenharmony_ci * 2618c2ecf20Sopenharmony_ci * - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate 2628c2ecf20Sopenharmony_ci * that the driver has run out of vram, iommu space or similar GPU 2638c2ecf20Sopenharmony_ci * address space needed for framebuffer. 2648c2ecf20Sopenharmony_ci * 2658c2ecf20Sopenharmony_ci * - -EIO, if the hardware completely died. 2668c2ecf20Sopenharmony_ci * 2678c2ecf20Sopenharmony_ci * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. 2688c2ecf20Sopenharmony_ci * This can either be due to a pending signal, or because the driver 2698c2ecf20Sopenharmony_ci * needs to completely bail out to recover from an exceptional 2708c2ecf20Sopenharmony_ci * situation like a GPU hang. From a userspace point of view all errors are 2718c2ecf20Sopenharmony_ci * treated equally. 2728c2ecf20Sopenharmony_ci * 2738c2ecf20Sopenharmony_ci * This list is exhaustive. Specifically this hook is not allowed to 2748c2ecf20Sopenharmony_ci * return -EINVAL (any invalid requests should be caught in 2758c2ecf20Sopenharmony_ci * @atomic_check) or -EDEADLK (this function must not acquire 2768c2ecf20Sopenharmony_ci * additional modeset locks). 2778c2ecf20Sopenharmony_ci */ 2788c2ecf20Sopenharmony_ci int (*atomic_commit)(struct drm_device *dev, 2798c2ecf20Sopenharmony_ci struct drm_atomic_state *state, 2808c2ecf20Sopenharmony_ci bool nonblock); 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci /** 2838c2ecf20Sopenharmony_ci * @atomic_state_alloc: 2848c2ecf20Sopenharmony_ci * 2858c2ecf20Sopenharmony_ci * This optional hook can be used by drivers that want to subclass struct 2868c2ecf20Sopenharmony_ci * &drm_atomic_state to be able to track their own driver-private global 2878c2ecf20Sopenharmony_ci * state easily. If this hook is implemented, drivers must also 2888c2ecf20Sopenharmony_ci * implement @atomic_state_clear and @atomic_state_free. 2898c2ecf20Sopenharmony_ci * 2908c2ecf20Sopenharmony_ci * Subclassing of &drm_atomic_state is deprecated in favour of using 2918c2ecf20Sopenharmony_ci * &drm_private_state and &drm_private_obj. 2928c2ecf20Sopenharmony_ci * 2938c2ecf20Sopenharmony_ci * RETURNS: 2948c2ecf20Sopenharmony_ci * 2958c2ecf20Sopenharmony_ci * A new &drm_atomic_state on success or NULL on failure. 2968c2ecf20Sopenharmony_ci */ 2978c2ecf20Sopenharmony_ci struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev); 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci /** 3008c2ecf20Sopenharmony_ci * @atomic_state_clear: 3018c2ecf20Sopenharmony_ci * 3028c2ecf20Sopenharmony_ci * This hook must clear any driver private state duplicated into the 3038c2ecf20Sopenharmony_ci * passed-in &drm_atomic_state. This hook is called when the caller 3048c2ecf20Sopenharmony_ci * encountered a &drm_modeset_lock deadlock and needs to drop all 3058c2ecf20Sopenharmony_ci * already acquired locks as part of the deadlock avoidance dance 3068c2ecf20Sopenharmony_ci * implemented in drm_modeset_backoff(). 3078c2ecf20Sopenharmony_ci * 3088c2ecf20Sopenharmony_ci * Any duplicated state must be invalidated since a concurrent atomic 3098c2ecf20Sopenharmony_ci * update might change it, and the drm atomic interfaces always apply 3108c2ecf20Sopenharmony_ci * updates as relative changes to the current state. 3118c2ecf20Sopenharmony_ci * 3128c2ecf20Sopenharmony_ci * Drivers that implement this must call drm_atomic_state_default_clear() 3138c2ecf20Sopenharmony_ci * to clear common state. 3148c2ecf20Sopenharmony_ci * 3158c2ecf20Sopenharmony_ci * Subclassing of &drm_atomic_state is deprecated in favour of using 3168c2ecf20Sopenharmony_ci * &drm_private_state and &drm_private_obj. 3178c2ecf20Sopenharmony_ci */ 3188c2ecf20Sopenharmony_ci void (*atomic_state_clear)(struct drm_atomic_state *state); 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci /** 3218c2ecf20Sopenharmony_ci * @atomic_state_free: 3228c2ecf20Sopenharmony_ci * 3238c2ecf20Sopenharmony_ci * This hook needs driver private resources and the &drm_atomic_state 3248c2ecf20Sopenharmony_ci * itself. Note that the core first calls drm_atomic_state_clear() to 3258c2ecf20Sopenharmony_ci * avoid code duplicate between the clear and free hooks. 3268c2ecf20Sopenharmony_ci * 3278c2ecf20Sopenharmony_ci * Drivers that implement this must call 3288c2ecf20Sopenharmony_ci * drm_atomic_state_default_release() to release common resources. 3298c2ecf20Sopenharmony_ci * 3308c2ecf20Sopenharmony_ci * Subclassing of &drm_atomic_state is deprecated in favour of using 3318c2ecf20Sopenharmony_ci * &drm_private_state and &drm_private_obj. 3328c2ecf20Sopenharmony_ci */ 3338c2ecf20Sopenharmony_ci void (*atomic_state_free)(struct drm_atomic_state *state); 3348c2ecf20Sopenharmony_ci}; 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci/** 3378c2ecf20Sopenharmony_ci * struct drm_mode_config - Mode configuration control structure 3388c2ecf20Sopenharmony_ci * @min_width: minimum fb pixel width on this device 3398c2ecf20Sopenharmony_ci * @min_height: minimum fb pixel height on this device 3408c2ecf20Sopenharmony_ci * @max_width: maximum fb pixel width on this device 3418c2ecf20Sopenharmony_ci * @max_height: maximum fb pixel height on this device 3428c2ecf20Sopenharmony_ci * @funcs: core driver provided mode setting functions 3438c2ecf20Sopenharmony_ci * @fb_base: base address of the framebuffer 3448c2ecf20Sopenharmony_ci * @poll_enabled: track polling support for this device 3458c2ecf20Sopenharmony_ci * @poll_running: track polling status for this device 3468c2ecf20Sopenharmony_ci * @delayed_event: track delayed poll uevent deliver for this device 3478c2ecf20Sopenharmony_ci * @output_poll_work: delayed work for polling in process context 3488c2ecf20Sopenharmony_ci * @preferred_depth: preferred RBG pixel depth, used by fb helpers 3498c2ecf20Sopenharmony_ci * @prefer_shadow: hint to userspace to prefer shadow-fb rendering 3508c2ecf20Sopenharmony_ci * @cursor_width: hint to userspace for max cursor width 3518c2ecf20Sopenharmony_ci * @cursor_height: hint to userspace for max cursor height 3528c2ecf20Sopenharmony_ci * @helper_private: mid-layer private data 3538c2ecf20Sopenharmony_ci * 3548c2ecf20Sopenharmony_ci * Core mode resource tracking structure. All CRTC, encoders, and connectors 3558c2ecf20Sopenharmony_ci * enumerated by the driver are added here, as are global properties. Some 3568c2ecf20Sopenharmony_ci * global restrictions are also here, e.g. dimension restrictions. 3578c2ecf20Sopenharmony_ci */ 3588c2ecf20Sopenharmony_cistruct drm_mode_config { 3598c2ecf20Sopenharmony_ci /** 3608c2ecf20Sopenharmony_ci * @mutex: 3618c2ecf20Sopenharmony_ci * 3628c2ecf20Sopenharmony_ci * This is the big scary modeset BKL which protects everything that 3638c2ecf20Sopenharmony_ci * isn't protect otherwise. Scope is unclear and fuzzy, try to remove 3648c2ecf20Sopenharmony_ci * anything from under its protection and move it into more well-scoped 3658c2ecf20Sopenharmony_ci * locks. 3668c2ecf20Sopenharmony_ci * 3678c2ecf20Sopenharmony_ci * The one important thing this protects is the use of @acquire_ctx. 3688c2ecf20Sopenharmony_ci */ 3698c2ecf20Sopenharmony_ci struct mutex mutex; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci /** 3728c2ecf20Sopenharmony_ci * @connection_mutex: 3738c2ecf20Sopenharmony_ci * 3748c2ecf20Sopenharmony_ci * This protects connector state and the connector to encoder to CRTC 3758c2ecf20Sopenharmony_ci * routing chain. 3768c2ecf20Sopenharmony_ci * 3778c2ecf20Sopenharmony_ci * For atomic drivers specifically this protects &drm_connector.state. 3788c2ecf20Sopenharmony_ci */ 3798c2ecf20Sopenharmony_ci struct drm_modeset_lock connection_mutex; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci /** 3828c2ecf20Sopenharmony_ci * @acquire_ctx: 3838c2ecf20Sopenharmony_ci * 3848c2ecf20Sopenharmony_ci * Global implicit acquire context used by atomic drivers for legacy 3858c2ecf20Sopenharmony_ci * IOCTLs. Deprecated, since implicit locking contexts make it 3868c2ecf20Sopenharmony_ci * impossible to use driver-private &struct drm_modeset_lock. Users of 3878c2ecf20Sopenharmony_ci * this must hold @mutex. 3888c2ecf20Sopenharmony_ci */ 3898c2ecf20Sopenharmony_ci struct drm_modeset_acquire_ctx *acquire_ctx; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci /** 3928c2ecf20Sopenharmony_ci * @idr_mutex: 3938c2ecf20Sopenharmony_ci * 3948c2ecf20Sopenharmony_ci * Mutex for KMS ID allocation and management. Protects both @object_idr 3958c2ecf20Sopenharmony_ci * and @tile_idr. 3968c2ecf20Sopenharmony_ci */ 3978c2ecf20Sopenharmony_ci struct mutex idr_mutex; 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci /** 4008c2ecf20Sopenharmony_ci * @object_idr: 4018c2ecf20Sopenharmony_ci * 4028c2ecf20Sopenharmony_ci * Main KMS ID tracking object. Use this idr for all IDs, fb, crtc, 4038c2ecf20Sopenharmony_ci * connector, modes - just makes life easier to have only one. 4048c2ecf20Sopenharmony_ci */ 4058c2ecf20Sopenharmony_ci struct idr object_idr; 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ci /** 4088c2ecf20Sopenharmony_ci * @tile_idr: 4098c2ecf20Sopenharmony_ci * 4108c2ecf20Sopenharmony_ci * Use this idr for allocating new IDs for tiled sinks like use in some 4118c2ecf20Sopenharmony_ci * high-res DP MST screens. 4128c2ecf20Sopenharmony_ci */ 4138c2ecf20Sopenharmony_ci struct idr tile_idr; 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_ci /** @fb_lock: Mutex to protect fb the global @fb_list and @num_fb. */ 4168c2ecf20Sopenharmony_ci struct mutex fb_lock; 4178c2ecf20Sopenharmony_ci /** @num_fb: Number of entries on @fb_list. */ 4188c2ecf20Sopenharmony_ci int num_fb; 4198c2ecf20Sopenharmony_ci /** @fb_list: List of all &struct drm_framebuffer. */ 4208c2ecf20Sopenharmony_ci struct list_head fb_list; 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci /** 4238c2ecf20Sopenharmony_ci * @connector_list_lock: Protects @num_connector and 4248c2ecf20Sopenharmony_ci * @connector_list and @connector_free_list. 4258c2ecf20Sopenharmony_ci */ 4268c2ecf20Sopenharmony_ci spinlock_t connector_list_lock; 4278c2ecf20Sopenharmony_ci /** 4288c2ecf20Sopenharmony_ci * @num_connector: Number of connectors on this device. Protected by 4298c2ecf20Sopenharmony_ci * @connector_list_lock. 4308c2ecf20Sopenharmony_ci */ 4318c2ecf20Sopenharmony_ci int num_connector; 4328c2ecf20Sopenharmony_ci /** 4338c2ecf20Sopenharmony_ci * @connector_ida: ID allocator for connector indices. 4348c2ecf20Sopenharmony_ci */ 4358c2ecf20Sopenharmony_ci struct ida connector_ida; 4368c2ecf20Sopenharmony_ci /** 4378c2ecf20Sopenharmony_ci * @connector_list: 4388c2ecf20Sopenharmony_ci * 4398c2ecf20Sopenharmony_ci * List of connector objects linked with &drm_connector.head. Protected 4408c2ecf20Sopenharmony_ci * by @connector_list_lock. Only use drm_for_each_connector_iter() and 4418c2ecf20Sopenharmony_ci * &struct drm_connector_list_iter to walk this list. 4428c2ecf20Sopenharmony_ci */ 4438c2ecf20Sopenharmony_ci struct list_head connector_list; 4448c2ecf20Sopenharmony_ci /** 4458c2ecf20Sopenharmony_ci * @connector_free_list: 4468c2ecf20Sopenharmony_ci * 4478c2ecf20Sopenharmony_ci * List of connector objects linked with &drm_connector.free_head. 4488c2ecf20Sopenharmony_ci * Protected by @connector_list_lock. Used by 4498c2ecf20Sopenharmony_ci * drm_for_each_connector_iter() and 4508c2ecf20Sopenharmony_ci * &struct drm_connector_list_iter to savely free connectors using 4518c2ecf20Sopenharmony_ci * @connector_free_work. 4528c2ecf20Sopenharmony_ci */ 4538c2ecf20Sopenharmony_ci struct llist_head connector_free_list; 4548c2ecf20Sopenharmony_ci /** 4558c2ecf20Sopenharmony_ci * @connector_free_work: Work to clean up @connector_free_list. 4568c2ecf20Sopenharmony_ci */ 4578c2ecf20Sopenharmony_ci struct work_struct connector_free_work; 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci /** 4608c2ecf20Sopenharmony_ci * @num_encoder: 4618c2ecf20Sopenharmony_ci * 4628c2ecf20Sopenharmony_ci * Number of encoders on this device. This is invariant over the 4638c2ecf20Sopenharmony_ci * lifetime of a device and hence doesn't need any locks. 4648c2ecf20Sopenharmony_ci */ 4658c2ecf20Sopenharmony_ci int num_encoder; 4668c2ecf20Sopenharmony_ci /** 4678c2ecf20Sopenharmony_ci * @encoder_list: 4688c2ecf20Sopenharmony_ci * 4698c2ecf20Sopenharmony_ci * List of encoder objects linked with &drm_encoder.head. This is 4708c2ecf20Sopenharmony_ci * invariant over the lifetime of a device and hence doesn't need any 4718c2ecf20Sopenharmony_ci * locks. 4728c2ecf20Sopenharmony_ci */ 4738c2ecf20Sopenharmony_ci struct list_head encoder_list; 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci /** 4768c2ecf20Sopenharmony_ci * @num_total_plane: 4778c2ecf20Sopenharmony_ci * 4788c2ecf20Sopenharmony_ci * Number of universal (i.e. with primary/curso) planes on this device. 4798c2ecf20Sopenharmony_ci * This is invariant over the lifetime of a device and hence doesn't 4808c2ecf20Sopenharmony_ci * need any locks. 4818c2ecf20Sopenharmony_ci */ 4828c2ecf20Sopenharmony_ci int num_total_plane; 4838c2ecf20Sopenharmony_ci /** 4848c2ecf20Sopenharmony_ci * @plane_list: 4858c2ecf20Sopenharmony_ci * 4868c2ecf20Sopenharmony_ci * List of plane objects linked with &drm_plane.head. This is invariant 4878c2ecf20Sopenharmony_ci * over the lifetime of a device and hence doesn't need any locks. 4888c2ecf20Sopenharmony_ci */ 4898c2ecf20Sopenharmony_ci struct list_head plane_list; 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci /** 4928c2ecf20Sopenharmony_ci * @num_crtc: 4938c2ecf20Sopenharmony_ci * 4948c2ecf20Sopenharmony_ci * Number of CRTCs on this device linked with &drm_crtc.head. This is invariant over the lifetime 4958c2ecf20Sopenharmony_ci * of a device and hence doesn't need any locks. 4968c2ecf20Sopenharmony_ci */ 4978c2ecf20Sopenharmony_ci int num_crtc; 4988c2ecf20Sopenharmony_ci /** 4998c2ecf20Sopenharmony_ci * @crtc_list: 5008c2ecf20Sopenharmony_ci * 5018c2ecf20Sopenharmony_ci * List of CRTC objects linked with &drm_crtc.head. This is invariant 5028c2ecf20Sopenharmony_ci * over the lifetime of a device and hence doesn't need any locks. 5038c2ecf20Sopenharmony_ci */ 5048c2ecf20Sopenharmony_ci struct list_head crtc_list; 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci /** 5078c2ecf20Sopenharmony_ci * @property_list: 5088c2ecf20Sopenharmony_ci * 5098c2ecf20Sopenharmony_ci * List of property type objects linked with &drm_property.head. This is 5108c2ecf20Sopenharmony_ci * invariant over the lifetime of a device and hence doesn't need any 5118c2ecf20Sopenharmony_ci * locks. 5128c2ecf20Sopenharmony_ci */ 5138c2ecf20Sopenharmony_ci struct list_head property_list; 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci /** 5168c2ecf20Sopenharmony_ci * @privobj_list: 5178c2ecf20Sopenharmony_ci * 5188c2ecf20Sopenharmony_ci * List of private objects linked with &drm_private_obj.head. This is 5198c2ecf20Sopenharmony_ci * invariant over the lifetime of a device and hence doesn't need any 5208c2ecf20Sopenharmony_ci * locks. 5218c2ecf20Sopenharmony_ci */ 5228c2ecf20Sopenharmony_ci struct list_head privobj_list; 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ci int min_width, min_height; 5258c2ecf20Sopenharmony_ci int max_width, max_height; 5268c2ecf20Sopenharmony_ci const struct drm_mode_config_funcs *funcs; 5278c2ecf20Sopenharmony_ci resource_size_t fb_base; 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_ci /* output poll support */ 5308c2ecf20Sopenharmony_ci bool poll_enabled; 5318c2ecf20Sopenharmony_ci bool poll_running; 5328c2ecf20Sopenharmony_ci bool delayed_event; 5338c2ecf20Sopenharmony_ci struct delayed_work output_poll_work; 5348c2ecf20Sopenharmony_ci 5358c2ecf20Sopenharmony_ci /** 5368c2ecf20Sopenharmony_ci * @blob_lock: 5378c2ecf20Sopenharmony_ci * 5388c2ecf20Sopenharmony_ci * Mutex for blob property allocation and management, protects 5398c2ecf20Sopenharmony_ci * @property_blob_list and &drm_file.blobs. 5408c2ecf20Sopenharmony_ci */ 5418c2ecf20Sopenharmony_ci struct mutex blob_lock; 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci /** 5448c2ecf20Sopenharmony_ci * @property_blob_list: 5458c2ecf20Sopenharmony_ci * 5468c2ecf20Sopenharmony_ci * List of all the blob property objects linked with 5478c2ecf20Sopenharmony_ci * &drm_property_blob.head. Protected by @blob_lock. 5488c2ecf20Sopenharmony_ci */ 5498c2ecf20Sopenharmony_ci struct list_head property_blob_list; 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ci /* pointers to standard properties */ 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ci /** 5548c2ecf20Sopenharmony_ci * @edid_property: Default connector property to hold the EDID of the 5558c2ecf20Sopenharmony_ci * currently connected sink, if any. 5568c2ecf20Sopenharmony_ci */ 5578c2ecf20Sopenharmony_ci struct drm_property *edid_property; 5588c2ecf20Sopenharmony_ci /** 5598c2ecf20Sopenharmony_ci * @dpms_property: Default connector property to control the 5608c2ecf20Sopenharmony_ci * connector's DPMS state. 5618c2ecf20Sopenharmony_ci */ 5628c2ecf20Sopenharmony_ci struct drm_property *dpms_property; 5638c2ecf20Sopenharmony_ci /** 5648c2ecf20Sopenharmony_ci * @path_property: Default connector property to hold the DP MST path 5658c2ecf20Sopenharmony_ci * for the port. 5668c2ecf20Sopenharmony_ci */ 5678c2ecf20Sopenharmony_ci struct drm_property *path_property; 5688c2ecf20Sopenharmony_ci /** 5698c2ecf20Sopenharmony_ci * @tile_property: Default connector property to store the tile 5708c2ecf20Sopenharmony_ci * position of a tiled screen, for sinks which need to be driven with 5718c2ecf20Sopenharmony_ci * multiple CRTCs. 5728c2ecf20Sopenharmony_ci */ 5738c2ecf20Sopenharmony_ci struct drm_property *tile_property; 5748c2ecf20Sopenharmony_ci /** 5758c2ecf20Sopenharmony_ci * @link_status_property: Default connector property for link status 5768c2ecf20Sopenharmony_ci * of a connector 5778c2ecf20Sopenharmony_ci */ 5788c2ecf20Sopenharmony_ci struct drm_property *link_status_property; 5798c2ecf20Sopenharmony_ci /** 5808c2ecf20Sopenharmony_ci * @plane_type_property: Default plane property to differentiate 5818c2ecf20Sopenharmony_ci * CURSOR, PRIMARY and OVERLAY legacy uses of planes. 5828c2ecf20Sopenharmony_ci */ 5838c2ecf20Sopenharmony_ci struct drm_property *plane_type_property; 5848c2ecf20Sopenharmony_ci /** 5858c2ecf20Sopenharmony_ci * @prop_src_x: Default atomic plane property for the plane source 5868c2ecf20Sopenharmony_ci * position in the connected &drm_framebuffer. 5878c2ecf20Sopenharmony_ci */ 5888c2ecf20Sopenharmony_ci struct drm_property *prop_src_x; 5898c2ecf20Sopenharmony_ci /** 5908c2ecf20Sopenharmony_ci * @prop_src_y: Default atomic plane property for the plane source 5918c2ecf20Sopenharmony_ci * position in the connected &drm_framebuffer. 5928c2ecf20Sopenharmony_ci */ 5938c2ecf20Sopenharmony_ci struct drm_property *prop_src_y; 5948c2ecf20Sopenharmony_ci /** 5958c2ecf20Sopenharmony_ci * @prop_src_w: Default atomic plane property for the plane source 5968c2ecf20Sopenharmony_ci * position in the connected &drm_framebuffer. 5978c2ecf20Sopenharmony_ci */ 5988c2ecf20Sopenharmony_ci struct drm_property *prop_src_w; 5998c2ecf20Sopenharmony_ci /** 6008c2ecf20Sopenharmony_ci * @prop_src_h: Default atomic plane property for the plane source 6018c2ecf20Sopenharmony_ci * position in the connected &drm_framebuffer. 6028c2ecf20Sopenharmony_ci */ 6038c2ecf20Sopenharmony_ci struct drm_property *prop_src_h; 6048c2ecf20Sopenharmony_ci /** 6058c2ecf20Sopenharmony_ci * @prop_crtc_x: Default atomic plane property for the plane destination 6068c2ecf20Sopenharmony_ci * position in the &drm_crtc is being shown on. 6078c2ecf20Sopenharmony_ci */ 6088c2ecf20Sopenharmony_ci struct drm_property *prop_crtc_x; 6098c2ecf20Sopenharmony_ci /** 6108c2ecf20Sopenharmony_ci * @prop_crtc_y: Default atomic plane property for the plane destination 6118c2ecf20Sopenharmony_ci * position in the &drm_crtc is being shown on. 6128c2ecf20Sopenharmony_ci */ 6138c2ecf20Sopenharmony_ci struct drm_property *prop_crtc_y; 6148c2ecf20Sopenharmony_ci /** 6158c2ecf20Sopenharmony_ci * @prop_crtc_w: Default atomic plane property for the plane destination 6168c2ecf20Sopenharmony_ci * position in the &drm_crtc is being shown on. 6178c2ecf20Sopenharmony_ci */ 6188c2ecf20Sopenharmony_ci struct drm_property *prop_crtc_w; 6198c2ecf20Sopenharmony_ci /** 6208c2ecf20Sopenharmony_ci * @prop_crtc_h: Default atomic plane property for the plane destination 6218c2ecf20Sopenharmony_ci * position in the &drm_crtc is being shown on. 6228c2ecf20Sopenharmony_ci */ 6238c2ecf20Sopenharmony_ci struct drm_property *prop_crtc_h; 6248c2ecf20Sopenharmony_ci /** 6258c2ecf20Sopenharmony_ci * @prop_fb_id: Default atomic plane property to specify the 6268c2ecf20Sopenharmony_ci * &drm_framebuffer. 6278c2ecf20Sopenharmony_ci */ 6288c2ecf20Sopenharmony_ci struct drm_property *prop_fb_id; 6298c2ecf20Sopenharmony_ci /** 6308c2ecf20Sopenharmony_ci * @prop_in_fence_fd: Sync File fd representing the incoming fences 6318c2ecf20Sopenharmony_ci * for a Plane. 6328c2ecf20Sopenharmony_ci */ 6338c2ecf20Sopenharmony_ci struct drm_property *prop_in_fence_fd; 6348c2ecf20Sopenharmony_ci /** 6358c2ecf20Sopenharmony_ci * @prop_out_fence_ptr: Sync File fd pointer representing the 6368c2ecf20Sopenharmony_ci * outgoing fences for a CRTC. Userspace should provide a pointer to a 6378c2ecf20Sopenharmony_ci * value of type s32, and then cast that pointer to u64. 6388c2ecf20Sopenharmony_ci */ 6398c2ecf20Sopenharmony_ci struct drm_property *prop_out_fence_ptr; 6408c2ecf20Sopenharmony_ci /** 6418c2ecf20Sopenharmony_ci * @prop_crtc_id: Default atomic plane property to specify the 6428c2ecf20Sopenharmony_ci * &drm_crtc. 6438c2ecf20Sopenharmony_ci */ 6448c2ecf20Sopenharmony_ci struct drm_property *prop_crtc_id; 6458c2ecf20Sopenharmony_ci /** 6468c2ecf20Sopenharmony_ci * @prop_fb_damage_clips: Optional plane property to mark damaged 6478c2ecf20Sopenharmony_ci * regions on the plane in framebuffer coordinates of the framebuffer 6488c2ecf20Sopenharmony_ci * attached to the plane. 6498c2ecf20Sopenharmony_ci * 6508c2ecf20Sopenharmony_ci * The layout of blob data is simply an array of &drm_mode_rect. Unlike 6518c2ecf20Sopenharmony_ci * plane src coordinates, damage clips are not in 16.16 fixed point. 6528c2ecf20Sopenharmony_ci */ 6538c2ecf20Sopenharmony_ci struct drm_property *prop_fb_damage_clips; 6548c2ecf20Sopenharmony_ci /** 6558c2ecf20Sopenharmony_ci * @prop_active: Default atomic CRTC property to control the active 6568c2ecf20Sopenharmony_ci * state, which is the simplified implementation for DPMS in atomic 6578c2ecf20Sopenharmony_ci * drivers. 6588c2ecf20Sopenharmony_ci */ 6598c2ecf20Sopenharmony_ci struct drm_property *prop_active; 6608c2ecf20Sopenharmony_ci /** 6618c2ecf20Sopenharmony_ci * @prop_mode_id: Default atomic CRTC property to set the mode for a 6628c2ecf20Sopenharmony_ci * CRTC. A 0 mode implies that the CRTC is entirely disabled - all 6638c2ecf20Sopenharmony_ci * connectors must be of and active must be set to disabled, too. 6648c2ecf20Sopenharmony_ci */ 6658c2ecf20Sopenharmony_ci struct drm_property *prop_mode_id; 6668c2ecf20Sopenharmony_ci /** 6678c2ecf20Sopenharmony_ci * @prop_vrr_enabled: Default atomic CRTC property to indicate 6688c2ecf20Sopenharmony_ci * whether variable refresh rate should be enabled on the CRTC. 6698c2ecf20Sopenharmony_ci */ 6708c2ecf20Sopenharmony_ci struct drm_property *prop_vrr_enabled; 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ci /** 6738c2ecf20Sopenharmony_ci * @dvi_i_subconnector_property: Optional DVI-I property to 6748c2ecf20Sopenharmony_ci * differentiate between analog or digital mode. 6758c2ecf20Sopenharmony_ci */ 6768c2ecf20Sopenharmony_ci struct drm_property *dvi_i_subconnector_property; 6778c2ecf20Sopenharmony_ci /** 6788c2ecf20Sopenharmony_ci * @dvi_i_select_subconnector_property: Optional DVI-I property to 6798c2ecf20Sopenharmony_ci * select between analog or digital mode. 6808c2ecf20Sopenharmony_ci */ 6818c2ecf20Sopenharmony_ci struct drm_property *dvi_i_select_subconnector_property; 6828c2ecf20Sopenharmony_ci 6838c2ecf20Sopenharmony_ci /** 6848c2ecf20Sopenharmony_ci * @dp_subconnector_property: Optional DP property to differentiate 6858c2ecf20Sopenharmony_ci * between different DP downstream port types. 6868c2ecf20Sopenharmony_ci */ 6878c2ecf20Sopenharmony_ci struct drm_property *dp_subconnector_property; 6888c2ecf20Sopenharmony_ci 6898c2ecf20Sopenharmony_ci /** 6908c2ecf20Sopenharmony_ci * @tv_subconnector_property: Optional TV property to differentiate 6918c2ecf20Sopenharmony_ci * between different TV connector types. 6928c2ecf20Sopenharmony_ci */ 6938c2ecf20Sopenharmony_ci struct drm_property *tv_subconnector_property; 6948c2ecf20Sopenharmony_ci /** 6958c2ecf20Sopenharmony_ci * @tv_select_subconnector_property: Optional TV property to select 6968c2ecf20Sopenharmony_ci * between different TV connector types. 6978c2ecf20Sopenharmony_ci */ 6988c2ecf20Sopenharmony_ci struct drm_property *tv_select_subconnector_property; 6998c2ecf20Sopenharmony_ci /** 7008c2ecf20Sopenharmony_ci * @tv_mode_property: Optional TV property to select 7018c2ecf20Sopenharmony_ci * the output TV mode. 7028c2ecf20Sopenharmony_ci */ 7038c2ecf20Sopenharmony_ci struct drm_property *tv_mode_property; 7048c2ecf20Sopenharmony_ci /** 7058c2ecf20Sopenharmony_ci * @tv_left_margin_property: Optional TV property to set the left 7068c2ecf20Sopenharmony_ci * margin (expressed in pixels). 7078c2ecf20Sopenharmony_ci */ 7088c2ecf20Sopenharmony_ci struct drm_property *tv_left_margin_property; 7098c2ecf20Sopenharmony_ci /** 7108c2ecf20Sopenharmony_ci * @tv_right_margin_property: Optional TV property to set the right 7118c2ecf20Sopenharmony_ci * margin (expressed in pixels). 7128c2ecf20Sopenharmony_ci */ 7138c2ecf20Sopenharmony_ci struct drm_property *tv_right_margin_property; 7148c2ecf20Sopenharmony_ci /** 7158c2ecf20Sopenharmony_ci * @tv_top_margin_property: Optional TV property to set the right 7168c2ecf20Sopenharmony_ci * margin (expressed in pixels). 7178c2ecf20Sopenharmony_ci */ 7188c2ecf20Sopenharmony_ci struct drm_property *tv_top_margin_property; 7198c2ecf20Sopenharmony_ci /** 7208c2ecf20Sopenharmony_ci * @tv_bottom_margin_property: Optional TV property to set the right 7218c2ecf20Sopenharmony_ci * margin (expressed in pixels). 7228c2ecf20Sopenharmony_ci */ 7238c2ecf20Sopenharmony_ci struct drm_property *tv_bottom_margin_property; 7248c2ecf20Sopenharmony_ci /** 7258c2ecf20Sopenharmony_ci * @tv_brightness_property: Optional TV property to set the 7268c2ecf20Sopenharmony_ci * brightness. 7278c2ecf20Sopenharmony_ci */ 7288c2ecf20Sopenharmony_ci struct drm_property *tv_brightness_property; 7298c2ecf20Sopenharmony_ci /** 7308c2ecf20Sopenharmony_ci * @tv_contrast_property: Optional TV property to set the 7318c2ecf20Sopenharmony_ci * contrast. 7328c2ecf20Sopenharmony_ci */ 7338c2ecf20Sopenharmony_ci struct drm_property *tv_contrast_property; 7348c2ecf20Sopenharmony_ci /** 7358c2ecf20Sopenharmony_ci * @tv_flicker_reduction_property: Optional TV property to control the 7368c2ecf20Sopenharmony_ci * flicker reduction mode. 7378c2ecf20Sopenharmony_ci */ 7388c2ecf20Sopenharmony_ci struct drm_property *tv_flicker_reduction_property; 7398c2ecf20Sopenharmony_ci /** 7408c2ecf20Sopenharmony_ci * @tv_overscan_property: Optional TV property to control the overscan 7418c2ecf20Sopenharmony_ci * setting. 7428c2ecf20Sopenharmony_ci */ 7438c2ecf20Sopenharmony_ci struct drm_property *tv_overscan_property; 7448c2ecf20Sopenharmony_ci /** 7458c2ecf20Sopenharmony_ci * @tv_saturation_property: Optional TV property to set the 7468c2ecf20Sopenharmony_ci * saturation. 7478c2ecf20Sopenharmony_ci */ 7488c2ecf20Sopenharmony_ci struct drm_property *tv_saturation_property; 7498c2ecf20Sopenharmony_ci /** 7508c2ecf20Sopenharmony_ci * @tv_hue_property: Optional TV property to set the hue. 7518c2ecf20Sopenharmony_ci */ 7528c2ecf20Sopenharmony_ci struct drm_property *tv_hue_property; 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci /** 7558c2ecf20Sopenharmony_ci * @scaling_mode_property: Optional connector property to control the 7568c2ecf20Sopenharmony_ci * upscaling, mostly used for built-in panels. 7578c2ecf20Sopenharmony_ci */ 7588c2ecf20Sopenharmony_ci struct drm_property *scaling_mode_property; 7598c2ecf20Sopenharmony_ci /** 7608c2ecf20Sopenharmony_ci * @aspect_ratio_property: Optional connector property to control the 7618c2ecf20Sopenharmony_ci * HDMI infoframe aspect ratio setting. 7628c2ecf20Sopenharmony_ci */ 7638c2ecf20Sopenharmony_ci struct drm_property *aspect_ratio_property; 7648c2ecf20Sopenharmony_ci /** 7658c2ecf20Sopenharmony_ci * @content_type_property: Optional connector property to control the 7668c2ecf20Sopenharmony_ci * HDMI infoframe content type setting. 7678c2ecf20Sopenharmony_ci */ 7688c2ecf20Sopenharmony_ci struct drm_property *content_type_property; 7698c2ecf20Sopenharmony_ci /** 7708c2ecf20Sopenharmony_ci * @degamma_lut_property: Optional CRTC property to set the LUT used to 7718c2ecf20Sopenharmony_ci * convert the framebuffer's colors to linear gamma. 7728c2ecf20Sopenharmony_ci */ 7738c2ecf20Sopenharmony_ci struct drm_property *degamma_lut_property; 7748c2ecf20Sopenharmony_ci /** 7758c2ecf20Sopenharmony_ci * @degamma_lut_size_property: Optional CRTC property for the size of 7768c2ecf20Sopenharmony_ci * the degamma LUT as supported by the driver (read-only). 7778c2ecf20Sopenharmony_ci */ 7788c2ecf20Sopenharmony_ci struct drm_property *degamma_lut_size_property; 7798c2ecf20Sopenharmony_ci /** 7808c2ecf20Sopenharmony_ci * @ctm_property: Optional CRTC property to set the 7818c2ecf20Sopenharmony_ci * matrix used to convert colors after the lookup in the 7828c2ecf20Sopenharmony_ci * degamma LUT. 7838c2ecf20Sopenharmony_ci */ 7848c2ecf20Sopenharmony_ci struct drm_property *ctm_property; 7858c2ecf20Sopenharmony_ci /** 7868c2ecf20Sopenharmony_ci * @gamma_lut_property: Optional CRTC property to set the LUT used to 7878c2ecf20Sopenharmony_ci * convert the colors, after the CTM matrix, to the gamma space of the 7888c2ecf20Sopenharmony_ci * connected screen. 7898c2ecf20Sopenharmony_ci */ 7908c2ecf20Sopenharmony_ci struct drm_property *gamma_lut_property; 7918c2ecf20Sopenharmony_ci /** 7928c2ecf20Sopenharmony_ci * @gamma_lut_size_property: Optional CRTC property for the size of the 7938c2ecf20Sopenharmony_ci * gamma LUT as supported by the driver (read-only). 7948c2ecf20Sopenharmony_ci */ 7958c2ecf20Sopenharmony_ci struct drm_property *gamma_lut_size_property; 7968c2ecf20Sopenharmony_ci 7978c2ecf20Sopenharmony_ci /** 7988c2ecf20Sopenharmony_ci * @suggested_x_property: Optional connector property with a hint for 7998c2ecf20Sopenharmony_ci * the position of the output on the host's screen. 8008c2ecf20Sopenharmony_ci */ 8018c2ecf20Sopenharmony_ci struct drm_property *suggested_x_property; 8028c2ecf20Sopenharmony_ci /** 8038c2ecf20Sopenharmony_ci * @suggested_y_property: Optional connector property with a hint for 8048c2ecf20Sopenharmony_ci * the position of the output on the host's screen. 8058c2ecf20Sopenharmony_ci */ 8068c2ecf20Sopenharmony_ci struct drm_property *suggested_y_property; 8078c2ecf20Sopenharmony_ci 8088c2ecf20Sopenharmony_ci /** 8098c2ecf20Sopenharmony_ci * @non_desktop_property: Optional connector property with a hint 8108c2ecf20Sopenharmony_ci * that device isn't a standard display, and the console/desktop, 8118c2ecf20Sopenharmony_ci * should not be displayed on it. 8128c2ecf20Sopenharmony_ci */ 8138c2ecf20Sopenharmony_ci struct drm_property *non_desktop_property; 8148c2ecf20Sopenharmony_ci 8158c2ecf20Sopenharmony_ci /** 8168c2ecf20Sopenharmony_ci * @panel_orientation_property: Optional connector property indicating 8178c2ecf20Sopenharmony_ci * how the lcd-panel is mounted inside the casing (e.g. normal or 8188c2ecf20Sopenharmony_ci * upside-down). 8198c2ecf20Sopenharmony_ci */ 8208c2ecf20Sopenharmony_ci struct drm_property *panel_orientation_property; 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_ci /** 8238c2ecf20Sopenharmony_ci * @writeback_fb_id_property: Property for writeback connectors, storing 8248c2ecf20Sopenharmony_ci * the ID of the output framebuffer. 8258c2ecf20Sopenharmony_ci * See also: drm_writeback_connector_init() 8268c2ecf20Sopenharmony_ci */ 8278c2ecf20Sopenharmony_ci struct drm_property *writeback_fb_id_property; 8288c2ecf20Sopenharmony_ci 8298c2ecf20Sopenharmony_ci /** 8308c2ecf20Sopenharmony_ci * @writeback_pixel_formats_property: Property for writeback connectors, 8318c2ecf20Sopenharmony_ci * storing an array of the supported pixel formats for the writeback 8328c2ecf20Sopenharmony_ci * engine (read-only). 8338c2ecf20Sopenharmony_ci * See also: drm_writeback_connector_init() 8348c2ecf20Sopenharmony_ci */ 8358c2ecf20Sopenharmony_ci struct drm_property *writeback_pixel_formats_property; 8368c2ecf20Sopenharmony_ci /** 8378c2ecf20Sopenharmony_ci * @writeback_out_fence_ptr_property: Property for writeback connectors, 8388c2ecf20Sopenharmony_ci * fd pointer representing the outgoing fences for a writeback 8398c2ecf20Sopenharmony_ci * connector. Userspace should provide a pointer to a value of type s32, 8408c2ecf20Sopenharmony_ci * and then cast that pointer to u64. 8418c2ecf20Sopenharmony_ci * See also: drm_writeback_connector_init() 8428c2ecf20Sopenharmony_ci */ 8438c2ecf20Sopenharmony_ci struct drm_property *writeback_out_fence_ptr_property; 8448c2ecf20Sopenharmony_ci 8458c2ecf20Sopenharmony_ci /** 8468c2ecf20Sopenharmony_ci * @hdr_output_metadata_property: Connector property containing hdr 8478c2ecf20Sopenharmony_ci * metatada. This will be provided by userspace compositors based 8488c2ecf20Sopenharmony_ci * on HDR content 8498c2ecf20Sopenharmony_ci */ 8508c2ecf20Sopenharmony_ci struct drm_property *hdr_output_metadata_property; 8518c2ecf20Sopenharmony_ci 8528c2ecf20Sopenharmony_ci /** 8538c2ecf20Sopenharmony_ci * @content_protection_property: DRM ENUM property for content 8548c2ecf20Sopenharmony_ci * protection. See drm_connector_attach_content_protection_property(). 8558c2ecf20Sopenharmony_ci */ 8568c2ecf20Sopenharmony_ci struct drm_property *content_protection_property; 8578c2ecf20Sopenharmony_ci 8588c2ecf20Sopenharmony_ci /** 8598c2ecf20Sopenharmony_ci * @hdcp_content_type_property: DRM ENUM property for type of 8608c2ecf20Sopenharmony_ci * Protected Content. 8618c2ecf20Sopenharmony_ci */ 8628c2ecf20Sopenharmony_ci struct drm_property *hdcp_content_type_property; 8638c2ecf20Sopenharmony_ci 8648c2ecf20Sopenharmony_ci /* dumb ioctl parameters */ 8658c2ecf20Sopenharmony_ci uint32_t preferred_depth, prefer_shadow; 8668c2ecf20Sopenharmony_ci 8678c2ecf20Sopenharmony_ci /** 8688c2ecf20Sopenharmony_ci * @prefer_shadow_fbdev: 8698c2ecf20Sopenharmony_ci * 8708c2ecf20Sopenharmony_ci * Hint to framebuffer emulation to prefer shadow-fb rendering. 8718c2ecf20Sopenharmony_ci */ 8728c2ecf20Sopenharmony_ci bool prefer_shadow_fbdev; 8738c2ecf20Sopenharmony_ci 8748c2ecf20Sopenharmony_ci /** 8758c2ecf20Sopenharmony_ci * @fbdev_use_iomem: 8768c2ecf20Sopenharmony_ci * 8778c2ecf20Sopenharmony_ci * Set to true if framebuffer reside in iomem. 8788c2ecf20Sopenharmony_ci * When set to true memcpy_toio() is used when copying the framebuffer in 8798c2ecf20Sopenharmony_ci * drm_fb_helper.drm_fb_helper_dirty_blit_real(). 8808c2ecf20Sopenharmony_ci * 8818c2ecf20Sopenharmony_ci * FIXME: This should be replaced with a per-mapping is_iomem 8828c2ecf20Sopenharmony_ci * flag (like ttm does), and then used everywhere in fbdev code. 8838c2ecf20Sopenharmony_ci */ 8848c2ecf20Sopenharmony_ci bool fbdev_use_iomem; 8858c2ecf20Sopenharmony_ci 8868c2ecf20Sopenharmony_ci /** 8878c2ecf20Sopenharmony_ci * @quirk_addfb_prefer_xbgr_30bpp: 8888c2ecf20Sopenharmony_ci * 8898c2ecf20Sopenharmony_ci * Special hack for legacy ADDFB to keep nouveau userspace happy. Should 8908c2ecf20Sopenharmony_ci * only ever be set by the nouveau kernel driver. 8918c2ecf20Sopenharmony_ci */ 8928c2ecf20Sopenharmony_ci bool quirk_addfb_prefer_xbgr_30bpp; 8938c2ecf20Sopenharmony_ci 8948c2ecf20Sopenharmony_ci /** 8958c2ecf20Sopenharmony_ci * @quirk_addfb_prefer_host_byte_order: 8968c2ecf20Sopenharmony_ci * 8978c2ecf20Sopenharmony_ci * When set to true drm_mode_addfb() will pick host byte order 8988c2ecf20Sopenharmony_ci * pixel_format when calling drm_mode_addfb2(). This is how 8998c2ecf20Sopenharmony_ci * drm_mode_addfb() should have worked from day one. It 9008c2ecf20Sopenharmony_ci * didn't though, so we ended up with quirks in both kernel 9018c2ecf20Sopenharmony_ci * and userspace drivers to deal with the broken behavior. 9028c2ecf20Sopenharmony_ci * Simply fixing drm_mode_addfb() unconditionally would break 9038c2ecf20Sopenharmony_ci * these drivers, so add a quirk bit here to allow drivers 9048c2ecf20Sopenharmony_ci * opt-in. 9058c2ecf20Sopenharmony_ci */ 9068c2ecf20Sopenharmony_ci bool quirk_addfb_prefer_host_byte_order; 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_ci /** 9098c2ecf20Sopenharmony_ci * @async_page_flip: Does this device support async flips on the primary 9108c2ecf20Sopenharmony_ci * plane? 9118c2ecf20Sopenharmony_ci */ 9128c2ecf20Sopenharmony_ci bool async_page_flip; 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci /** 9158c2ecf20Sopenharmony_ci * @allow_fb_modifiers: 9168c2ecf20Sopenharmony_ci * 9178c2ecf20Sopenharmony_ci * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call. 9188c2ecf20Sopenharmony_ci */ 9198c2ecf20Sopenharmony_ci bool allow_fb_modifiers; 9208c2ecf20Sopenharmony_ci 9218c2ecf20Sopenharmony_ci /** 9228c2ecf20Sopenharmony_ci * @normalize_zpos: 9238c2ecf20Sopenharmony_ci * 9248c2ecf20Sopenharmony_ci * If true the drm core will call drm_atomic_normalize_zpos() as part of 9258c2ecf20Sopenharmony_ci * atomic mode checking from drm_atomic_helper_check() 9268c2ecf20Sopenharmony_ci */ 9278c2ecf20Sopenharmony_ci bool normalize_zpos; 9288c2ecf20Sopenharmony_ci 9298c2ecf20Sopenharmony_ci /** 9308c2ecf20Sopenharmony_ci * @modifiers_property: Plane property to list support modifier/format 9318c2ecf20Sopenharmony_ci * combination. 9328c2ecf20Sopenharmony_ci */ 9338c2ecf20Sopenharmony_ci struct drm_property *modifiers_property; 9348c2ecf20Sopenharmony_ci 9358c2ecf20Sopenharmony_ci /* cursor size */ 9368c2ecf20Sopenharmony_ci uint32_t cursor_width, cursor_height; 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci /** 9398c2ecf20Sopenharmony_ci * @suspend_state: 9408c2ecf20Sopenharmony_ci * 9418c2ecf20Sopenharmony_ci * Atomic state when suspended. 9428c2ecf20Sopenharmony_ci * Set by drm_mode_config_helper_suspend() and cleared by 9438c2ecf20Sopenharmony_ci * drm_mode_config_helper_resume(). 9448c2ecf20Sopenharmony_ci */ 9458c2ecf20Sopenharmony_ci struct drm_atomic_state *suspend_state; 9468c2ecf20Sopenharmony_ci 9478c2ecf20Sopenharmony_ci const struct drm_mode_config_helper_funcs *helper_private; 9488c2ecf20Sopenharmony_ci}; 9498c2ecf20Sopenharmony_ci 9508c2ecf20Sopenharmony_ciint __must_check drmm_mode_config_init(struct drm_device *dev); 9518c2ecf20Sopenharmony_ci 9528c2ecf20Sopenharmony_ci/** 9538c2ecf20Sopenharmony_ci * drm_mode_config_init - DRM mode_configuration structure initialization 9548c2ecf20Sopenharmony_ci * @dev: DRM device 9558c2ecf20Sopenharmony_ci * 9568c2ecf20Sopenharmony_ci * This is the unmanaged version of drmm_mode_config_init() for drivers which 9578c2ecf20Sopenharmony_ci * still explicitly call drm_mode_config_cleanup(). 9588c2ecf20Sopenharmony_ci * 9598c2ecf20Sopenharmony_ci * FIXME: This function is deprecated and drivers should be converted over to 9608c2ecf20Sopenharmony_ci * drmm_mode_config_init(). 9618c2ecf20Sopenharmony_ci */ 9628c2ecf20Sopenharmony_cistatic inline int drm_mode_config_init(struct drm_device *dev) 9638c2ecf20Sopenharmony_ci{ 9648c2ecf20Sopenharmony_ci return drmm_mode_config_init(dev); 9658c2ecf20Sopenharmony_ci} 9668c2ecf20Sopenharmony_ci 9678c2ecf20Sopenharmony_civoid drm_mode_config_reset(struct drm_device *dev); 9688c2ecf20Sopenharmony_civoid drm_mode_config_cleanup(struct drm_device *dev); 9698c2ecf20Sopenharmony_ci 9708c2ecf20Sopenharmony_ci#endif 971