18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (C) 2014 Red Hat 38c2ecf20Sopenharmony_ci * Copyright (C) 2014 Intel Corp. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 68c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 78c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 88c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 98c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 108c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 138c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 168c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 178c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 188c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 198c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 208c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 218c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * Authors: 248c2ecf20Sopenharmony_ci * Rob Clark <robdclark@gmail.com> 258c2ecf20Sopenharmony_ci * Daniel Vetter <daniel.vetter@ffwll.ch> 268c2ecf20Sopenharmony_ci */ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#ifndef DRM_ATOMIC_H_ 298c2ecf20Sopenharmony_ci#define DRM_ATOMIC_H_ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#include <drm/drm_crtc.h> 328c2ecf20Sopenharmony_ci#include <drm/drm_util.h> 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/** 358c2ecf20Sopenharmony_ci * struct drm_crtc_commit - track modeset commits on a CRTC 368c2ecf20Sopenharmony_ci * 378c2ecf20Sopenharmony_ci * This structure is used to track pending modeset changes and atomic commit on 388c2ecf20Sopenharmony_ci * a per-CRTC basis. Since updating the list should never block, this structure 398c2ecf20Sopenharmony_ci * is reference counted to allow waiters to safely wait on an event to complete, 408c2ecf20Sopenharmony_ci * without holding any locks. 418c2ecf20Sopenharmony_ci * 428c2ecf20Sopenharmony_ci * It has 3 different events in total to allow a fine-grained synchronization 438c2ecf20Sopenharmony_ci * between outstanding updates:: 448c2ecf20Sopenharmony_ci * 458c2ecf20Sopenharmony_ci * atomic commit thread hardware 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * write new state into hardware ----> ... 488c2ecf20Sopenharmony_ci * signal hw_done 498c2ecf20Sopenharmony_ci * switch to new state on next 508c2ecf20Sopenharmony_ci * ... v/hblank 518c2ecf20Sopenharmony_ci * 528c2ecf20Sopenharmony_ci * wait for buffers to show up ... 538c2ecf20Sopenharmony_ci * 548c2ecf20Sopenharmony_ci * ... send completion irq 558c2ecf20Sopenharmony_ci * irq handler signals flip_done 568c2ecf20Sopenharmony_ci * cleanup old buffers 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci * signal cleanup_done 598c2ecf20Sopenharmony_ci * 608c2ecf20Sopenharmony_ci * wait for flip_done <---- 618c2ecf20Sopenharmony_ci * clean up atomic state 628c2ecf20Sopenharmony_ci * 638c2ecf20Sopenharmony_ci * The important bit to know is that &cleanup_done is the terminal event, but the 648c2ecf20Sopenharmony_ci * ordering between &flip_done and &hw_done is entirely up to the specific driver 658c2ecf20Sopenharmony_ci * and modeset state change. 668c2ecf20Sopenharmony_ci * 678c2ecf20Sopenharmony_ci * For an implementation of how to use this look at 688c2ecf20Sopenharmony_ci * drm_atomic_helper_setup_commit() from the atomic helper library. 698c2ecf20Sopenharmony_ci */ 708c2ecf20Sopenharmony_cistruct drm_crtc_commit { 718c2ecf20Sopenharmony_ci /** 728c2ecf20Sopenharmony_ci * @crtc: 738c2ecf20Sopenharmony_ci * 748c2ecf20Sopenharmony_ci * DRM CRTC for this commit. 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_ci struct drm_crtc *crtc; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci /** 798c2ecf20Sopenharmony_ci * @ref: 808c2ecf20Sopenharmony_ci * 818c2ecf20Sopenharmony_ci * Reference count for this structure. Needed to allow blocking on 828c2ecf20Sopenharmony_ci * completions without the risk of the completion disappearing 838c2ecf20Sopenharmony_ci * meanwhile. 848c2ecf20Sopenharmony_ci */ 858c2ecf20Sopenharmony_ci struct kref ref; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci /** 888c2ecf20Sopenharmony_ci * @flip_done: 898c2ecf20Sopenharmony_ci * 908c2ecf20Sopenharmony_ci * Will be signaled when the hardware has flipped to the new set of 918c2ecf20Sopenharmony_ci * buffers. Signals at the same time as when the drm event for this 928c2ecf20Sopenharmony_ci * commit is sent to userspace, or when an out-fence is singalled. Note 938c2ecf20Sopenharmony_ci * that for most hardware, in most cases this happens after @hw_done is 948c2ecf20Sopenharmony_ci * signalled. 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * Completion of this stage is signalled implicitly by calling 978c2ecf20Sopenharmony_ci * drm_crtc_send_vblank_event() on &drm_crtc_state.event. 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_ci struct completion flip_done; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci /** 1028c2ecf20Sopenharmony_ci * @hw_done: 1038c2ecf20Sopenharmony_ci * 1048c2ecf20Sopenharmony_ci * Will be signalled when all hw register changes for this commit have 1058c2ecf20Sopenharmony_ci * been written out. Especially when disabling a pipe this can be much 1068c2ecf20Sopenharmony_ci * later than @flip_done, since that can signal already when the 1078c2ecf20Sopenharmony_ci * screen goes black, whereas to fully shut down a pipe more register 1088c2ecf20Sopenharmony_ci * I/O is required. 1098c2ecf20Sopenharmony_ci * 1108c2ecf20Sopenharmony_ci * Note that this does not need to include separately reference-counted 1118c2ecf20Sopenharmony_ci * resources like backing storage buffer pinning, or runtime pm 1128c2ecf20Sopenharmony_ci * management. 1138c2ecf20Sopenharmony_ci * 1148c2ecf20Sopenharmony_ci * Drivers should call drm_atomic_helper_commit_hw_done() to signal 1158c2ecf20Sopenharmony_ci * completion of this stage. 1168c2ecf20Sopenharmony_ci */ 1178c2ecf20Sopenharmony_ci struct completion hw_done; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci /** 1208c2ecf20Sopenharmony_ci * @cleanup_done: 1218c2ecf20Sopenharmony_ci * 1228c2ecf20Sopenharmony_ci * Will be signalled after old buffers have been cleaned up by calling 1238c2ecf20Sopenharmony_ci * drm_atomic_helper_cleanup_planes(). Since this can only happen after 1248c2ecf20Sopenharmony_ci * a vblank wait completed it might be a bit later. This completion is 1258c2ecf20Sopenharmony_ci * useful to throttle updates and avoid hardware updates getting ahead 1268c2ecf20Sopenharmony_ci * of the buffer cleanup too much. 1278c2ecf20Sopenharmony_ci * 1288c2ecf20Sopenharmony_ci * Drivers should call drm_atomic_helper_commit_cleanup_done() to signal 1298c2ecf20Sopenharmony_ci * completion of this stage. 1308c2ecf20Sopenharmony_ci */ 1318c2ecf20Sopenharmony_ci struct completion cleanup_done; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci /** 1348c2ecf20Sopenharmony_ci * @commit_entry: 1358c2ecf20Sopenharmony_ci * 1368c2ecf20Sopenharmony_ci * Entry on the per-CRTC &drm_crtc.commit_list. Protected by 1378c2ecf20Sopenharmony_ci * $drm_crtc.commit_lock. 1388c2ecf20Sopenharmony_ci */ 1398c2ecf20Sopenharmony_ci struct list_head commit_entry; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci /** 1428c2ecf20Sopenharmony_ci * @event: 1438c2ecf20Sopenharmony_ci * 1448c2ecf20Sopenharmony_ci * &drm_pending_vblank_event pointer to clean up private events. 1458c2ecf20Sopenharmony_ci */ 1468c2ecf20Sopenharmony_ci struct drm_pending_vblank_event *event; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci /** 1498c2ecf20Sopenharmony_ci * @abort_completion: 1508c2ecf20Sopenharmony_ci * 1518c2ecf20Sopenharmony_ci * A flag that's set after drm_atomic_helper_setup_commit() takes a 1528c2ecf20Sopenharmony_ci * second reference for the completion of $drm_crtc_state.event. It's 1538c2ecf20Sopenharmony_ci * used by the free code to remove the second reference if commit fails. 1548c2ecf20Sopenharmony_ci */ 1558c2ecf20Sopenharmony_ci bool abort_completion; 1568c2ecf20Sopenharmony_ci}; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_cistruct __drm_planes_state { 1598c2ecf20Sopenharmony_ci struct drm_plane *ptr; 1608c2ecf20Sopenharmony_ci struct drm_plane_state *state, *old_state, *new_state; 1618c2ecf20Sopenharmony_ci}; 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_cistruct __drm_crtcs_state { 1648c2ecf20Sopenharmony_ci struct drm_crtc *ptr; 1658c2ecf20Sopenharmony_ci struct drm_crtc_state *state, *old_state, *new_state; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci /** 1688c2ecf20Sopenharmony_ci * @commit: 1698c2ecf20Sopenharmony_ci * 1708c2ecf20Sopenharmony_ci * A reference to the CRTC commit object that is kept for use by 1718c2ecf20Sopenharmony_ci * drm_atomic_helper_wait_for_flip_done() after 1728c2ecf20Sopenharmony_ci * drm_atomic_helper_commit_hw_done() is called. This ensures that a 1738c2ecf20Sopenharmony_ci * concurrent commit won't free a commit object that is still in use. 1748c2ecf20Sopenharmony_ci */ 1758c2ecf20Sopenharmony_ci struct drm_crtc_commit *commit; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci s32 __user *out_fence_ptr; 1788c2ecf20Sopenharmony_ci u64 last_vblank_count; 1798c2ecf20Sopenharmony_ci}; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistruct __drm_connnectors_state { 1828c2ecf20Sopenharmony_ci struct drm_connector *ptr; 1838c2ecf20Sopenharmony_ci struct drm_connector_state *state, *old_state, *new_state; 1848c2ecf20Sopenharmony_ci /** 1858c2ecf20Sopenharmony_ci * @out_fence_ptr: 1868c2ecf20Sopenharmony_ci * 1878c2ecf20Sopenharmony_ci * User-provided pointer which the kernel uses to return a sync_file 1888c2ecf20Sopenharmony_ci * file descriptor. Used by writeback connectors to signal completion of 1898c2ecf20Sopenharmony_ci * the writeback. 1908c2ecf20Sopenharmony_ci */ 1918c2ecf20Sopenharmony_ci s32 __user *out_fence_ptr; 1928c2ecf20Sopenharmony_ci}; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_cistruct drm_private_obj; 1958c2ecf20Sopenharmony_cistruct drm_private_state; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci/** 1988c2ecf20Sopenharmony_ci * struct drm_private_state_funcs - atomic state functions for private objects 1998c2ecf20Sopenharmony_ci * 2008c2ecf20Sopenharmony_ci * These hooks are used by atomic helpers to create, swap and destroy states of 2018c2ecf20Sopenharmony_ci * private objects. The structure itself is used as a vtable to identify the 2028c2ecf20Sopenharmony_ci * associated private object type. Each private object type that needs to be 2038c2ecf20Sopenharmony_ci * added to the atomic states is expected to have an implementation of these 2048c2ecf20Sopenharmony_ci * hooks and pass a pointer to its drm_private_state_funcs struct to 2058c2ecf20Sopenharmony_ci * drm_atomic_get_private_obj_state(). 2068c2ecf20Sopenharmony_ci */ 2078c2ecf20Sopenharmony_cistruct drm_private_state_funcs { 2088c2ecf20Sopenharmony_ci /** 2098c2ecf20Sopenharmony_ci * @atomic_duplicate_state: 2108c2ecf20Sopenharmony_ci * 2118c2ecf20Sopenharmony_ci * Duplicate the current state of the private object and return it. It 2128c2ecf20Sopenharmony_ci * is an error to call this before obj->state has been initialized. 2138c2ecf20Sopenharmony_ci * 2148c2ecf20Sopenharmony_ci * RETURNS: 2158c2ecf20Sopenharmony_ci * 2168c2ecf20Sopenharmony_ci * Duplicated atomic state or NULL when obj->state is not 2178c2ecf20Sopenharmony_ci * initialized or allocation failed. 2188c2ecf20Sopenharmony_ci */ 2198c2ecf20Sopenharmony_ci struct drm_private_state *(*atomic_duplicate_state)(struct drm_private_obj *obj); 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci /** 2228c2ecf20Sopenharmony_ci * @atomic_destroy_state: 2238c2ecf20Sopenharmony_ci * 2248c2ecf20Sopenharmony_ci * Frees the private object state created with @atomic_duplicate_state. 2258c2ecf20Sopenharmony_ci */ 2268c2ecf20Sopenharmony_ci void (*atomic_destroy_state)(struct drm_private_obj *obj, 2278c2ecf20Sopenharmony_ci struct drm_private_state *state); 2288c2ecf20Sopenharmony_ci}; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci/** 2318c2ecf20Sopenharmony_ci * struct drm_private_obj - base struct for driver private atomic object 2328c2ecf20Sopenharmony_ci * 2338c2ecf20Sopenharmony_ci * A driver private object is initialized by calling 2348c2ecf20Sopenharmony_ci * drm_atomic_private_obj_init() and cleaned up by calling 2358c2ecf20Sopenharmony_ci * drm_atomic_private_obj_fini(). 2368c2ecf20Sopenharmony_ci * 2378c2ecf20Sopenharmony_ci * Currently only tracks the state update functions and the opaque driver 2388c2ecf20Sopenharmony_ci * private state itself, but in the future might also track which 2398c2ecf20Sopenharmony_ci * &drm_modeset_lock is required to duplicate and update this object's state. 2408c2ecf20Sopenharmony_ci * 2418c2ecf20Sopenharmony_ci * All private objects must be initialized before the DRM device they are 2428c2ecf20Sopenharmony_ci * attached to is registered to the DRM subsystem (call to drm_dev_register()) 2438c2ecf20Sopenharmony_ci * and should stay around until this DRM device is unregistered (call to 2448c2ecf20Sopenharmony_ci * drm_dev_unregister()). In other words, private objects lifetime is tied 2458c2ecf20Sopenharmony_ci * to the DRM device lifetime. This implies that: 2468c2ecf20Sopenharmony_ci * 2478c2ecf20Sopenharmony_ci * 1/ all calls to drm_atomic_private_obj_init() must be done before calling 2488c2ecf20Sopenharmony_ci * drm_dev_register() 2498c2ecf20Sopenharmony_ci * 2/ all calls to drm_atomic_private_obj_fini() must be done after calling 2508c2ecf20Sopenharmony_ci * drm_dev_unregister() 2518c2ecf20Sopenharmony_ci */ 2528c2ecf20Sopenharmony_cistruct drm_private_obj { 2538c2ecf20Sopenharmony_ci /** 2548c2ecf20Sopenharmony_ci * @head: List entry used to attach a private object to a &drm_device 2558c2ecf20Sopenharmony_ci * (queued to &drm_mode_config.privobj_list). 2568c2ecf20Sopenharmony_ci */ 2578c2ecf20Sopenharmony_ci struct list_head head; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci /** 2608c2ecf20Sopenharmony_ci * @lock: Modeset lock to protect the state object. 2618c2ecf20Sopenharmony_ci */ 2628c2ecf20Sopenharmony_ci struct drm_modeset_lock lock; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci /** 2658c2ecf20Sopenharmony_ci * @state: Current atomic state for this driver private object. 2668c2ecf20Sopenharmony_ci */ 2678c2ecf20Sopenharmony_ci struct drm_private_state *state; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci /** 2708c2ecf20Sopenharmony_ci * @funcs: 2718c2ecf20Sopenharmony_ci * 2728c2ecf20Sopenharmony_ci * Functions to manipulate the state of this driver private object, see 2738c2ecf20Sopenharmony_ci * &drm_private_state_funcs. 2748c2ecf20Sopenharmony_ci */ 2758c2ecf20Sopenharmony_ci const struct drm_private_state_funcs *funcs; 2768c2ecf20Sopenharmony_ci}; 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci/** 2798c2ecf20Sopenharmony_ci * drm_for_each_privobj() - private object iterator 2808c2ecf20Sopenharmony_ci * 2818c2ecf20Sopenharmony_ci * @privobj: pointer to the current private object. Updated after each 2828c2ecf20Sopenharmony_ci * iteration 2838c2ecf20Sopenharmony_ci * @dev: the DRM device we want get private objects from 2848c2ecf20Sopenharmony_ci * 2858c2ecf20Sopenharmony_ci * Allows one to iterate over all private objects attached to @dev 2868c2ecf20Sopenharmony_ci */ 2878c2ecf20Sopenharmony_ci#define drm_for_each_privobj(privobj, dev) \ 2888c2ecf20Sopenharmony_ci list_for_each_entry(privobj, &(dev)->mode_config.privobj_list, head) 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci/** 2918c2ecf20Sopenharmony_ci * struct drm_private_state - base struct for driver private object state 2928c2ecf20Sopenharmony_ci * @state: backpointer to global drm_atomic_state 2938c2ecf20Sopenharmony_ci * 2948c2ecf20Sopenharmony_ci * Currently only contains a backpointer to the overall atomic update, but in 2958c2ecf20Sopenharmony_ci * the future also might hold synchronization information similar to e.g. 2968c2ecf20Sopenharmony_ci * &drm_crtc.commit. 2978c2ecf20Sopenharmony_ci */ 2988c2ecf20Sopenharmony_cistruct drm_private_state { 2998c2ecf20Sopenharmony_ci struct drm_atomic_state *state; 3008c2ecf20Sopenharmony_ci}; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_cistruct __drm_private_objs_state { 3038c2ecf20Sopenharmony_ci struct drm_private_obj *ptr; 3048c2ecf20Sopenharmony_ci struct drm_private_state *state, *old_state, *new_state; 3058c2ecf20Sopenharmony_ci}; 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci/** 3088c2ecf20Sopenharmony_ci * struct drm_atomic_state - the global state object for atomic updates 3098c2ecf20Sopenharmony_ci * @ref: count of all references to this state (will not be freed until zero) 3108c2ecf20Sopenharmony_ci * @dev: parent DRM device 3118c2ecf20Sopenharmony_ci * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics 3128c2ecf20Sopenharmony_ci * @async_update: hint for asynchronous plane update 3138c2ecf20Sopenharmony_ci * @planes: pointer to array of structures with per-plane data 3148c2ecf20Sopenharmony_ci * @crtcs: pointer to array of CRTC pointers 3158c2ecf20Sopenharmony_ci * @num_connector: size of the @connectors and @connector_states arrays 3168c2ecf20Sopenharmony_ci * @connectors: pointer to array of structures with per-connector data 3178c2ecf20Sopenharmony_ci * @num_private_objs: size of the @private_objs array 3188c2ecf20Sopenharmony_ci * @private_objs: pointer to array of private object pointers 3198c2ecf20Sopenharmony_ci * @acquire_ctx: acquire context for this atomic modeset state update 3208c2ecf20Sopenharmony_ci * 3218c2ecf20Sopenharmony_ci * States are added to an atomic update by calling drm_atomic_get_crtc_state(), 3228c2ecf20Sopenharmony_ci * drm_atomic_get_plane_state(), drm_atomic_get_connector_state(), or for 3238c2ecf20Sopenharmony_ci * private state structures, drm_atomic_get_private_obj_state(). 3248c2ecf20Sopenharmony_ci */ 3258c2ecf20Sopenharmony_cistruct drm_atomic_state { 3268c2ecf20Sopenharmony_ci struct kref ref; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci struct drm_device *dev; 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci /** 3318c2ecf20Sopenharmony_ci * @allow_modeset: 3328c2ecf20Sopenharmony_ci * 3338c2ecf20Sopenharmony_ci * Allow full modeset. This is used by the ATOMIC IOCTL handler to 3348c2ecf20Sopenharmony_ci * implement the DRM_MODE_ATOMIC_ALLOW_MODESET flag. Drivers should 3358c2ecf20Sopenharmony_ci * never consult this flag, instead looking at the output of 3368c2ecf20Sopenharmony_ci * drm_atomic_crtc_needs_modeset(). 3378c2ecf20Sopenharmony_ci */ 3388c2ecf20Sopenharmony_ci bool allow_modeset : 1; 3398c2ecf20Sopenharmony_ci bool legacy_cursor_update : 1; 3408c2ecf20Sopenharmony_ci bool async_update : 1; 3418c2ecf20Sopenharmony_ci /** 3428c2ecf20Sopenharmony_ci * @duplicated: 3438c2ecf20Sopenharmony_ci * 3448c2ecf20Sopenharmony_ci * Indicates whether or not this atomic state was duplicated using 3458c2ecf20Sopenharmony_ci * drm_atomic_helper_duplicate_state(). Drivers and atomic helpers 3468c2ecf20Sopenharmony_ci * should use this to fixup normal inconsistencies in duplicated 3478c2ecf20Sopenharmony_ci * states. 3488c2ecf20Sopenharmony_ci */ 3498c2ecf20Sopenharmony_ci bool duplicated : 1; 3508c2ecf20Sopenharmony_ci struct __drm_planes_state *planes; 3518c2ecf20Sopenharmony_ci struct __drm_crtcs_state *crtcs; 3528c2ecf20Sopenharmony_ci int num_connector; 3538c2ecf20Sopenharmony_ci struct __drm_connnectors_state *connectors; 3548c2ecf20Sopenharmony_ci int num_private_objs; 3558c2ecf20Sopenharmony_ci struct __drm_private_objs_state *private_objs; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci struct drm_modeset_acquire_ctx *acquire_ctx; 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci /** 3608c2ecf20Sopenharmony_ci * @fake_commit: 3618c2ecf20Sopenharmony_ci * 3628c2ecf20Sopenharmony_ci * Used for signaling unbound planes/connectors. 3638c2ecf20Sopenharmony_ci * When a connector or plane is not bound to any CRTC, it's still important 3648c2ecf20Sopenharmony_ci * to preserve linearity to prevent the atomic states from being freed to early. 3658c2ecf20Sopenharmony_ci * 3668c2ecf20Sopenharmony_ci * This commit (if set) is not bound to any CRTC, but will be completed when 3678c2ecf20Sopenharmony_ci * drm_atomic_helper_commit_hw_done() is called. 3688c2ecf20Sopenharmony_ci */ 3698c2ecf20Sopenharmony_ci struct drm_crtc_commit *fake_commit; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_ci /** 3728c2ecf20Sopenharmony_ci * @commit_work: 3738c2ecf20Sopenharmony_ci * 3748c2ecf20Sopenharmony_ci * Work item which can be used by the driver or helpers to execute the 3758c2ecf20Sopenharmony_ci * commit without blocking. 3768c2ecf20Sopenharmony_ci */ 3778c2ecf20Sopenharmony_ci struct work_struct commit_work; 3788c2ecf20Sopenharmony_ci}; 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_civoid __drm_crtc_commit_free(struct kref *kref); 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci/** 3838c2ecf20Sopenharmony_ci * drm_crtc_commit_get - acquire a reference to the CRTC commit 3848c2ecf20Sopenharmony_ci * @commit: CRTC commit 3858c2ecf20Sopenharmony_ci * 3868c2ecf20Sopenharmony_ci * Increases the reference of @commit. 3878c2ecf20Sopenharmony_ci * 3888c2ecf20Sopenharmony_ci * Returns: 3898c2ecf20Sopenharmony_ci * The pointer to @commit, with reference increased. 3908c2ecf20Sopenharmony_ci */ 3918c2ecf20Sopenharmony_cistatic inline struct drm_crtc_commit *drm_crtc_commit_get(struct drm_crtc_commit *commit) 3928c2ecf20Sopenharmony_ci{ 3938c2ecf20Sopenharmony_ci kref_get(&commit->ref); 3948c2ecf20Sopenharmony_ci return commit; 3958c2ecf20Sopenharmony_ci} 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci/** 3988c2ecf20Sopenharmony_ci * drm_crtc_commit_put - release a reference to the CRTC commmit 3998c2ecf20Sopenharmony_ci * @commit: CRTC commit 4008c2ecf20Sopenharmony_ci * 4018c2ecf20Sopenharmony_ci * This releases a reference to @commit which is freed after removing the 4028c2ecf20Sopenharmony_ci * final reference. No locking required and callable from any context. 4038c2ecf20Sopenharmony_ci */ 4048c2ecf20Sopenharmony_cistatic inline void drm_crtc_commit_put(struct drm_crtc_commit *commit) 4058c2ecf20Sopenharmony_ci{ 4068c2ecf20Sopenharmony_ci kref_put(&commit->ref, __drm_crtc_commit_free); 4078c2ecf20Sopenharmony_ci} 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_cistruct drm_atomic_state * __must_check 4108c2ecf20Sopenharmony_cidrm_atomic_state_alloc(struct drm_device *dev); 4118c2ecf20Sopenharmony_civoid drm_atomic_state_clear(struct drm_atomic_state *state); 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci/** 4148c2ecf20Sopenharmony_ci * drm_atomic_state_get - acquire a reference to the atomic state 4158c2ecf20Sopenharmony_ci * @state: The atomic state 4168c2ecf20Sopenharmony_ci * 4178c2ecf20Sopenharmony_ci * Returns a new reference to the @state 4188c2ecf20Sopenharmony_ci */ 4198c2ecf20Sopenharmony_cistatic inline struct drm_atomic_state * 4208c2ecf20Sopenharmony_cidrm_atomic_state_get(struct drm_atomic_state *state) 4218c2ecf20Sopenharmony_ci{ 4228c2ecf20Sopenharmony_ci kref_get(&state->ref); 4238c2ecf20Sopenharmony_ci return state; 4248c2ecf20Sopenharmony_ci} 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_civoid __drm_atomic_state_free(struct kref *ref); 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci/** 4298c2ecf20Sopenharmony_ci * drm_atomic_state_put - release a reference to the atomic state 4308c2ecf20Sopenharmony_ci * @state: The atomic state 4318c2ecf20Sopenharmony_ci * 4328c2ecf20Sopenharmony_ci * This releases a reference to @state which is freed after removing the 4338c2ecf20Sopenharmony_ci * final reference. No locking required and callable from any context. 4348c2ecf20Sopenharmony_ci */ 4358c2ecf20Sopenharmony_cistatic inline void drm_atomic_state_put(struct drm_atomic_state *state) 4368c2ecf20Sopenharmony_ci{ 4378c2ecf20Sopenharmony_ci kref_put(&state->ref, __drm_atomic_state_free); 4388c2ecf20Sopenharmony_ci} 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ciint __must_check 4418c2ecf20Sopenharmony_cidrm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state); 4428c2ecf20Sopenharmony_civoid drm_atomic_state_default_clear(struct drm_atomic_state *state); 4438c2ecf20Sopenharmony_civoid drm_atomic_state_default_release(struct drm_atomic_state *state); 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_cistruct drm_crtc_state * __must_check 4468c2ecf20Sopenharmony_cidrm_atomic_get_crtc_state(struct drm_atomic_state *state, 4478c2ecf20Sopenharmony_ci struct drm_crtc *crtc); 4488c2ecf20Sopenharmony_cistruct drm_plane_state * __must_check 4498c2ecf20Sopenharmony_cidrm_atomic_get_plane_state(struct drm_atomic_state *state, 4508c2ecf20Sopenharmony_ci struct drm_plane *plane); 4518c2ecf20Sopenharmony_cistruct drm_connector_state * __must_check 4528c2ecf20Sopenharmony_cidrm_atomic_get_connector_state(struct drm_atomic_state *state, 4538c2ecf20Sopenharmony_ci struct drm_connector *connector); 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_civoid drm_atomic_private_obj_init(struct drm_device *dev, 4568c2ecf20Sopenharmony_ci struct drm_private_obj *obj, 4578c2ecf20Sopenharmony_ci struct drm_private_state *state, 4588c2ecf20Sopenharmony_ci const struct drm_private_state_funcs *funcs); 4598c2ecf20Sopenharmony_civoid drm_atomic_private_obj_fini(struct drm_private_obj *obj); 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_cistruct drm_private_state * __must_check 4628c2ecf20Sopenharmony_cidrm_atomic_get_private_obj_state(struct drm_atomic_state *state, 4638c2ecf20Sopenharmony_ci struct drm_private_obj *obj); 4648c2ecf20Sopenharmony_cistruct drm_private_state * 4658c2ecf20Sopenharmony_cidrm_atomic_get_old_private_obj_state(struct drm_atomic_state *state, 4668c2ecf20Sopenharmony_ci struct drm_private_obj *obj); 4678c2ecf20Sopenharmony_cistruct drm_private_state * 4688c2ecf20Sopenharmony_cidrm_atomic_get_new_private_obj_state(struct drm_atomic_state *state, 4698c2ecf20Sopenharmony_ci struct drm_private_obj *obj); 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_cistruct drm_connector * 4728c2ecf20Sopenharmony_cidrm_atomic_get_old_connector_for_encoder(struct drm_atomic_state *state, 4738c2ecf20Sopenharmony_ci struct drm_encoder *encoder); 4748c2ecf20Sopenharmony_cistruct drm_connector * 4758c2ecf20Sopenharmony_cidrm_atomic_get_new_connector_for_encoder(struct drm_atomic_state *state, 4768c2ecf20Sopenharmony_ci struct drm_encoder *encoder); 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_ci/** 4798c2ecf20Sopenharmony_ci * drm_atomic_get_existing_crtc_state - get CRTC state, if it exists 4808c2ecf20Sopenharmony_ci * @state: global atomic state object 4818c2ecf20Sopenharmony_ci * @crtc: CRTC to grab 4828c2ecf20Sopenharmony_ci * 4838c2ecf20Sopenharmony_ci * This function returns the CRTC state for the given CRTC, or NULL 4848c2ecf20Sopenharmony_ci * if the CRTC is not part of the global atomic state. 4858c2ecf20Sopenharmony_ci * 4868c2ecf20Sopenharmony_ci * This function is deprecated, @drm_atomic_get_old_crtc_state or 4878c2ecf20Sopenharmony_ci * @drm_atomic_get_new_crtc_state should be used instead. 4888c2ecf20Sopenharmony_ci */ 4898c2ecf20Sopenharmony_cistatic inline struct drm_crtc_state * 4908c2ecf20Sopenharmony_cidrm_atomic_get_existing_crtc_state(struct drm_atomic_state *state, 4918c2ecf20Sopenharmony_ci struct drm_crtc *crtc) 4928c2ecf20Sopenharmony_ci{ 4938c2ecf20Sopenharmony_ci return state->crtcs[drm_crtc_index(crtc)].state; 4948c2ecf20Sopenharmony_ci} 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci/** 4978c2ecf20Sopenharmony_ci * drm_atomic_get_old_crtc_state - get old CRTC state, if it exists 4988c2ecf20Sopenharmony_ci * @state: global atomic state object 4998c2ecf20Sopenharmony_ci * @crtc: CRTC to grab 5008c2ecf20Sopenharmony_ci * 5018c2ecf20Sopenharmony_ci * This function returns the old CRTC state for the given CRTC, or 5028c2ecf20Sopenharmony_ci * NULL if the CRTC is not part of the global atomic state. 5038c2ecf20Sopenharmony_ci */ 5048c2ecf20Sopenharmony_cistatic inline struct drm_crtc_state * 5058c2ecf20Sopenharmony_cidrm_atomic_get_old_crtc_state(struct drm_atomic_state *state, 5068c2ecf20Sopenharmony_ci struct drm_crtc *crtc) 5078c2ecf20Sopenharmony_ci{ 5088c2ecf20Sopenharmony_ci return state->crtcs[drm_crtc_index(crtc)].old_state; 5098c2ecf20Sopenharmony_ci} 5108c2ecf20Sopenharmony_ci/** 5118c2ecf20Sopenharmony_ci * drm_atomic_get_new_crtc_state - get new CRTC state, if it exists 5128c2ecf20Sopenharmony_ci * @state: global atomic state object 5138c2ecf20Sopenharmony_ci * @crtc: CRTC to grab 5148c2ecf20Sopenharmony_ci * 5158c2ecf20Sopenharmony_ci * This function returns the new CRTC state for the given CRTC, or 5168c2ecf20Sopenharmony_ci * NULL if the CRTC is not part of the global atomic state. 5178c2ecf20Sopenharmony_ci */ 5188c2ecf20Sopenharmony_cistatic inline struct drm_crtc_state * 5198c2ecf20Sopenharmony_cidrm_atomic_get_new_crtc_state(struct drm_atomic_state *state, 5208c2ecf20Sopenharmony_ci struct drm_crtc *crtc) 5218c2ecf20Sopenharmony_ci{ 5228c2ecf20Sopenharmony_ci return state->crtcs[drm_crtc_index(crtc)].new_state; 5238c2ecf20Sopenharmony_ci} 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci/** 5268c2ecf20Sopenharmony_ci * drm_atomic_get_existing_plane_state - get plane state, if it exists 5278c2ecf20Sopenharmony_ci * @state: global atomic state object 5288c2ecf20Sopenharmony_ci * @plane: plane to grab 5298c2ecf20Sopenharmony_ci * 5308c2ecf20Sopenharmony_ci * This function returns the plane state for the given plane, or NULL 5318c2ecf20Sopenharmony_ci * if the plane is not part of the global atomic state. 5328c2ecf20Sopenharmony_ci * 5338c2ecf20Sopenharmony_ci * This function is deprecated, @drm_atomic_get_old_plane_state or 5348c2ecf20Sopenharmony_ci * @drm_atomic_get_new_plane_state should be used instead. 5358c2ecf20Sopenharmony_ci */ 5368c2ecf20Sopenharmony_cistatic inline struct drm_plane_state * 5378c2ecf20Sopenharmony_cidrm_atomic_get_existing_plane_state(struct drm_atomic_state *state, 5388c2ecf20Sopenharmony_ci struct drm_plane *plane) 5398c2ecf20Sopenharmony_ci{ 5408c2ecf20Sopenharmony_ci return state->planes[drm_plane_index(plane)].state; 5418c2ecf20Sopenharmony_ci} 5428c2ecf20Sopenharmony_ci 5438c2ecf20Sopenharmony_ci/** 5448c2ecf20Sopenharmony_ci * drm_atomic_get_old_plane_state - get plane state, if it exists 5458c2ecf20Sopenharmony_ci * @state: global atomic state object 5468c2ecf20Sopenharmony_ci * @plane: plane to grab 5478c2ecf20Sopenharmony_ci * 5488c2ecf20Sopenharmony_ci * This function returns the old plane state for the given plane, or 5498c2ecf20Sopenharmony_ci * NULL if the plane is not part of the global atomic state. 5508c2ecf20Sopenharmony_ci */ 5518c2ecf20Sopenharmony_cistatic inline struct drm_plane_state * 5528c2ecf20Sopenharmony_cidrm_atomic_get_old_plane_state(struct drm_atomic_state *state, 5538c2ecf20Sopenharmony_ci struct drm_plane *plane) 5548c2ecf20Sopenharmony_ci{ 5558c2ecf20Sopenharmony_ci return state->planes[drm_plane_index(plane)].old_state; 5568c2ecf20Sopenharmony_ci} 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci/** 5598c2ecf20Sopenharmony_ci * drm_atomic_get_new_plane_state - get plane state, if it exists 5608c2ecf20Sopenharmony_ci * @state: global atomic state object 5618c2ecf20Sopenharmony_ci * @plane: plane to grab 5628c2ecf20Sopenharmony_ci * 5638c2ecf20Sopenharmony_ci * This function returns the new plane state for the given plane, or 5648c2ecf20Sopenharmony_ci * NULL if the plane is not part of the global atomic state. 5658c2ecf20Sopenharmony_ci */ 5668c2ecf20Sopenharmony_cistatic inline struct drm_plane_state * 5678c2ecf20Sopenharmony_cidrm_atomic_get_new_plane_state(struct drm_atomic_state *state, 5688c2ecf20Sopenharmony_ci struct drm_plane *plane) 5698c2ecf20Sopenharmony_ci{ 5708c2ecf20Sopenharmony_ci return state->planes[drm_plane_index(plane)].new_state; 5718c2ecf20Sopenharmony_ci} 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci/** 5748c2ecf20Sopenharmony_ci * drm_atomic_get_existing_connector_state - get connector state, if it exists 5758c2ecf20Sopenharmony_ci * @state: global atomic state object 5768c2ecf20Sopenharmony_ci * @connector: connector to grab 5778c2ecf20Sopenharmony_ci * 5788c2ecf20Sopenharmony_ci * This function returns the connector state for the given connector, 5798c2ecf20Sopenharmony_ci * or NULL if the connector is not part of the global atomic state. 5808c2ecf20Sopenharmony_ci * 5818c2ecf20Sopenharmony_ci * This function is deprecated, @drm_atomic_get_old_connector_state or 5828c2ecf20Sopenharmony_ci * @drm_atomic_get_new_connector_state should be used instead. 5838c2ecf20Sopenharmony_ci */ 5848c2ecf20Sopenharmony_cistatic inline struct drm_connector_state * 5858c2ecf20Sopenharmony_cidrm_atomic_get_existing_connector_state(struct drm_atomic_state *state, 5868c2ecf20Sopenharmony_ci struct drm_connector *connector) 5878c2ecf20Sopenharmony_ci{ 5888c2ecf20Sopenharmony_ci int index = drm_connector_index(connector); 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci if (index >= state->num_connector) 5918c2ecf20Sopenharmony_ci return NULL; 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci return state->connectors[index].state; 5948c2ecf20Sopenharmony_ci} 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci/** 5978c2ecf20Sopenharmony_ci * drm_atomic_get_old_connector_state - get connector state, if it exists 5988c2ecf20Sopenharmony_ci * @state: global atomic state object 5998c2ecf20Sopenharmony_ci * @connector: connector to grab 6008c2ecf20Sopenharmony_ci * 6018c2ecf20Sopenharmony_ci * This function returns the old connector state for the given connector, 6028c2ecf20Sopenharmony_ci * or NULL if the connector is not part of the global atomic state. 6038c2ecf20Sopenharmony_ci */ 6048c2ecf20Sopenharmony_cistatic inline struct drm_connector_state * 6058c2ecf20Sopenharmony_cidrm_atomic_get_old_connector_state(struct drm_atomic_state *state, 6068c2ecf20Sopenharmony_ci struct drm_connector *connector) 6078c2ecf20Sopenharmony_ci{ 6088c2ecf20Sopenharmony_ci int index = drm_connector_index(connector); 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_ci if (index >= state->num_connector) 6118c2ecf20Sopenharmony_ci return NULL; 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_ci return state->connectors[index].old_state; 6148c2ecf20Sopenharmony_ci} 6158c2ecf20Sopenharmony_ci 6168c2ecf20Sopenharmony_ci/** 6178c2ecf20Sopenharmony_ci * drm_atomic_get_new_connector_state - get connector state, if it exists 6188c2ecf20Sopenharmony_ci * @state: global atomic state object 6198c2ecf20Sopenharmony_ci * @connector: connector to grab 6208c2ecf20Sopenharmony_ci * 6218c2ecf20Sopenharmony_ci * This function returns the new connector state for the given connector, 6228c2ecf20Sopenharmony_ci * or NULL if the connector is not part of the global atomic state. 6238c2ecf20Sopenharmony_ci */ 6248c2ecf20Sopenharmony_cistatic inline struct drm_connector_state * 6258c2ecf20Sopenharmony_cidrm_atomic_get_new_connector_state(struct drm_atomic_state *state, 6268c2ecf20Sopenharmony_ci struct drm_connector *connector) 6278c2ecf20Sopenharmony_ci{ 6288c2ecf20Sopenharmony_ci int index = drm_connector_index(connector); 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci if (index >= state->num_connector) 6318c2ecf20Sopenharmony_ci return NULL; 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci return state->connectors[index].new_state; 6348c2ecf20Sopenharmony_ci} 6358c2ecf20Sopenharmony_ci 6368c2ecf20Sopenharmony_ci/** 6378c2ecf20Sopenharmony_ci * __drm_atomic_get_current_plane_state - get current plane state 6388c2ecf20Sopenharmony_ci * @state: global atomic state object 6398c2ecf20Sopenharmony_ci * @plane: plane to grab 6408c2ecf20Sopenharmony_ci * 6418c2ecf20Sopenharmony_ci * This function returns the plane state for the given plane, either from 6428c2ecf20Sopenharmony_ci * @state, or if the plane isn't part of the atomic state update, from @plane. 6438c2ecf20Sopenharmony_ci * This is useful in atomic check callbacks, when drivers need to peek at, but 6448c2ecf20Sopenharmony_ci * not change, state of other planes, since it avoids threading an error code 6458c2ecf20Sopenharmony_ci * back up the call chain. 6468c2ecf20Sopenharmony_ci * 6478c2ecf20Sopenharmony_ci * WARNING: 6488c2ecf20Sopenharmony_ci * 6498c2ecf20Sopenharmony_ci * Note that this function is in general unsafe since it doesn't check for the 6508c2ecf20Sopenharmony_ci * required locking for access state structures. Drivers must ensure that it is 6518c2ecf20Sopenharmony_ci * safe to access the returned state structure through other means. One common 6528c2ecf20Sopenharmony_ci * example is when planes are fixed to a single CRTC, and the driver knows that 6538c2ecf20Sopenharmony_ci * the CRTC lock is held already. In that case holding the CRTC lock gives a 6548c2ecf20Sopenharmony_ci * read-lock on all planes connected to that CRTC. But if planes can be 6558c2ecf20Sopenharmony_ci * reassigned things get more tricky. In that case it's better to use 6568c2ecf20Sopenharmony_ci * drm_atomic_get_plane_state and wire up full error handling. 6578c2ecf20Sopenharmony_ci * 6588c2ecf20Sopenharmony_ci * Returns: 6598c2ecf20Sopenharmony_ci * 6608c2ecf20Sopenharmony_ci * Read-only pointer to the current plane state. 6618c2ecf20Sopenharmony_ci */ 6628c2ecf20Sopenharmony_cistatic inline const struct drm_plane_state * 6638c2ecf20Sopenharmony_ci__drm_atomic_get_current_plane_state(struct drm_atomic_state *state, 6648c2ecf20Sopenharmony_ci struct drm_plane *plane) 6658c2ecf20Sopenharmony_ci{ 6668c2ecf20Sopenharmony_ci if (state->planes[drm_plane_index(plane)].state) 6678c2ecf20Sopenharmony_ci return state->planes[drm_plane_index(plane)].state; 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_ci return plane->state; 6708c2ecf20Sopenharmony_ci} 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ciint __must_check 6738c2ecf20Sopenharmony_cidrm_atomic_add_encoder_bridges(struct drm_atomic_state *state, 6748c2ecf20Sopenharmony_ci struct drm_encoder *encoder); 6758c2ecf20Sopenharmony_ciint __must_check 6768c2ecf20Sopenharmony_cidrm_atomic_add_affected_connectors(struct drm_atomic_state *state, 6778c2ecf20Sopenharmony_ci struct drm_crtc *crtc); 6788c2ecf20Sopenharmony_ciint __must_check 6798c2ecf20Sopenharmony_cidrm_atomic_add_affected_planes(struct drm_atomic_state *state, 6808c2ecf20Sopenharmony_ci struct drm_crtc *crtc); 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ciint __must_check drm_atomic_check_only(struct drm_atomic_state *state); 6838c2ecf20Sopenharmony_ciint __must_check drm_atomic_commit(struct drm_atomic_state *state); 6848c2ecf20Sopenharmony_ciint __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state); 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_civoid drm_state_dump(struct drm_device *dev, struct drm_printer *p); 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_ci/** 6898c2ecf20Sopenharmony_ci * for_each_oldnew_connector_in_state - iterate over all connectors in an atomic update 6908c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 6918c2ecf20Sopenharmony_ci * @connector: &struct drm_connector iteration cursor 6928c2ecf20Sopenharmony_ci * @old_connector_state: &struct drm_connector_state iteration cursor for the 6938c2ecf20Sopenharmony_ci * old state 6948c2ecf20Sopenharmony_ci * @new_connector_state: &struct drm_connector_state iteration cursor for the 6958c2ecf20Sopenharmony_ci * new state 6968c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 6978c2ecf20Sopenharmony_ci * 6988c2ecf20Sopenharmony_ci * This iterates over all connectors in an atomic update, tracking both old and 6998c2ecf20Sopenharmony_ci * new state. This is useful in places where the state delta needs to be 7008c2ecf20Sopenharmony_ci * considered, for example in atomic check functions. 7018c2ecf20Sopenharmony_ci */ 7028c2ecf20Sopenharmony_ci#define for_each_oldnew_connector_in_state(__state, connector, old_connector_state, new_connector_state, __i) \ 7038c2ecf20Sopenharmony_ci for ((__i) = 0; \ 7048c2ecf20Sopenharmony_ci (__i) < (__state)->num_connector; \ 7058c2ecf20Sopenharmony_ci (__i)++) \ 7068c2ecf20Sopenharmony_ci for_each_if ((__state)->connectors[__i].ptr && \ 7078c2ecf20Sopenharmony_ci ((connector) = (__state)->connectors[__i].ptr, \ 7088c2ecf20Sopenharmony_ci (void)(connector) /* Only to avoid unused-but-set-variable warning */, \ 7098c2ecf20Sopenharmony_ci (old_connector_state) = (__state)->connectors[__i].old_state, \ 7108c2ecf20Sopenharmony_ci (new_connector_state) = (__state)->connectors[__i].new_state, 1)) 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci/** 7138c2ecf20Sopenharmony_ci * for_each_old_connector_in_state - iterate over all connectors in an atomic update 7148c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 7158c2ecf20Sopenharmony_ci * @connector: &struct drm_connector iteration cursor 7168c2ecf20Sopenharmony_ci * @old_connector_state: &struct drm_connector_state iteration cursor for the 7178c2ecf20Sopenharmony_ci * old state 7188c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 7198c2ecf20Sopenharmony_ci * 7208c2ecf20Sopenharmony_ci * This iterates over all connectors in an atomic update, tracking only the old 7218c2ecf20Sopenharmony_ci * state. This is useful in disable functions, where we need the old state the 7228c2ecf20Sopenharmony_ci * hardware is still in. 7238c2ecf20Sopenharmony_ci */ 7248c2ecf20Sopenharmony_ci#define for_each_old_connector_in_state(__state, connector, old_connector_state, __i) \ 7258c2ecf20Sopenharmony_ci for ((__i) = 0; \ 7268c2ecf20Sopenharmony_ci (__i) < (__state)->num_connector; \ 7278c2ecf20Sopenharmony_ci (__i)++) \ 7288c2ecf20Sopenharmony_ci for_each_if ((__state)->connectors[__i].ptr && \ 7298c2ecf20Sopenharmony_ci ((connector) = (__state)->connectors[__i].ptr, \ 7308c2ecf20Sopenharmony_ci (void)(connector) /* Only to avoid unused-but-set-variable warning */, \ 7318c2ecf20Sopenharmony_ci (old_connector_state) = (__state)->connectors[__i].old_state, 1)) 7328c2ecf20Sopenharmony_ci 7338c2ecf20Sopenharmony_ci/** 7348c2ecf20Sopenharmony_ci * for_each_new_connector_in_state - iterate over all connectors in an atomic update 7358c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 7368c2ecf20Sopenharmony_ci * @connector: &struct drm_connector iteration cursor 7378c2ecf20Sopenharmony_ci * @new_connector_state: &struct drm_connector_state iteration cursor for the 7388c2ecf20Sopenharmony_ci * new state 7398c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 7408c2ecf20Sopenharmony_ci * 7418c2ecf20Sopenharmony_ci * This iterates over all connectors in an atomic update, tracking only the new 7428c2ecf20Sopenharmony_ci * state. This is useful in enable functions, where we need the new state the 7438c2ecf20Sopenharmony_ci * hardware should be in when the atomic commit operation has completed. 7448c2ecf20Sopenharmony_ci */ 7458c2ecf20Sopenharmony_ci#define for_each_new_connector_in_state(__state, connector, new_connector_state, __i) \ 7468c2ecf20Sopenharmony_ci for ((__i) = 0; \ 7478c2ecf20Sopenharmony_ci (__i) < (__state)->num_connector; \ 7488c2ecf20Sopenharmony_ci (__i)++) \ 7498c2ecf20Sopenharmony_ci for_each_if ((__state)->connectors[__i].ptr && \ 7508c2ecf20Sopenharmony_ci ((connector) = (__state)->connectors[__i].ptr, \ 7518c2ecf20Sopenharmony_ci (void)(connector) /* Only to avoid unused-but-set-variable warning */, \ 7528c2ecf20Sopenharmony_ci (new_connector_state) = (__state)->connectors[__i].new_state, \ 7538c2ecf20Sopenharmony_ci (void)(new_connector_state) /* Only to avoid unused-but-set-variable warning */, 1)) 7548c2ecf20Sopenharmony_ci 7558c2ecf20Sopenharmony_ci/** 7568c2ecf20Sopenharmony_ci * for_each_oldnew_crtc_in_state - iterate over all CRTCs in an atomic update 7578c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 7588c2ecf20Sopenharmony_ci * @crtc: &struct drm_crtc iteration cursor 7598c2ecf20Sopenharmony_ci * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state 7608c2ecf20Sopenharmony_ci * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state 7618c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 7628c2ecf20Sopenharmony_ci * 7638c2ecf20Sopenharmony_ci * This iterates over all CRTCs in an atomic update, tracking both old and 7648c2ecf20Sopenharmony_ci * new state. This is useful in places where the state delta needs to be 7658c2ecf20Sopenharmony_ci * considered, for example in atomic check functions. 7668c2ecf20Sopenharmony_ci */ 7678c2ecf20Sopenharmony_ci#define for_each_oldnew_crtc_in_state(__state, crtc, old_crtc_state, new_crtc_state, __i) \ 7688c2ecf20Sopenharmony_ci for ((__i) = 0; \ 7698c2ecf20Sopenharmony_ci (__i) < (__state)->dev->mode_config.num_crtc; \ 7708c2ecf20Sopenharmony_ci (__i)++) \ 7718c2ecf20Sopenharmony_ci for_each_if ((__state)->crtcs[__i].ptr && \ 7728c2ecf20Sopenharmony_ci ((crtc) = (__state)->crtcs[__i].ptr, \ 7738c2ecf20Sopenharmony_ci (void)(crtc) /* Only to avoid unused-but-set-variable warning */, \ 7748c2ecf20Sopenharmony_ci (old_crtc_state) = (__state)->crtcs[__i].old_state, \ 7758c2ecf20Sopenharmony_ci (void)(old_crtc_state) /* Only to avoid unused-but-set-variable warning */, \ 7768c2ecf20Sopenharmony_ci (new_crtc_state) = (__state)->crtcs[__i].new_state, 1)) 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci/** 7798c2ecf20Sopenharmony_ci * for_each_old_crtc_in_state - iterate over all CRTCs in an atomic update 7808c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 7818c2ecf20Sopenharmony_ci * @crtc: &struct drm_crtc iteration cursor 7828c2ecf20Sopenharmony_ci * @old_crtc_state: &struct drm_crtc_state iteration cursor for the old state 7838c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 7848c2ecf20Sopenharmony_ci * 7858c2ecf20Sopenharmony_ci * This iterates over all CRTCs in an atomic update, tracking only the old 7868c2ecf20Sopenharmony_ci * state. This is useful in disable functions, where we need the old state the 7878c2ecf20Sopenharmony_ci * hardware is still in. 7888c2ecf20Sopenharmony_ci */ 7898c2ecf20Sopenharmony_ci#define for_each_old_crtc_in_state(__state, crtc, old_crtc_state, __i) \ 7908c2ecf20Sopenharmony_ci for ((__i) = 0; \ 7918c2ecf20Sopenharmony_ci (__i) < (__state)->dev->mode_config.num_crtc; \ 7928c2ecf20Sopenharmony_ci (__i)++) \ 7938c2ecf20Sopenharmony_ci for_each_if ((__state)->crtcs[__i].ptr && \ 7948c2ecf20Sopenharmony_ci ((crtc) = (__state)->crtcs[__i].ptr, \ 7958c2ecf20Sopenharmony_ci (old_crtc_state) = (__state)->crtcs[__i].old_state, 1)) 7968c2ecf20Sopenharmony_ci 7978c2ecf20Sopenharmony_ci/** 7988c2ecf20Sopenharmony_ci * for_each_new_crtc_in_state - iterate over all CRTCs in an atomic update 7998c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 8008c2ecf20Sopenharmony_ci * @crtc: &struct drm_crtc iteration cursor 8018c2ecf20Sopenharmony_ci * @new_crtc_state: &struct drm_crtc_state iteration cursor for the new state 8028c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 8038c2ecf20Sopenharmony_ci * 8048c2ecf20Sopenharmony_ci * This iterates over all CRTCs in an atomic update, tracking only the new 8058c2ecf20Sopenharmony_ci * state. This is useful in enable functions, where we need the new state the 8068c2ecf20Sopenharmony_ci * hardware should be in when the atomic commit operation has completed. 8078c2ecf20Sopenharmony_ci */ 8088c2ecf20Sopenharmony_ci#define for_each_new_crtc_in_state(__state, crtc, new_crtc_state, __i) \ 8098c2ecf20Sopenharmony_ci for ((__i) = 0; \ 8108c2ecf20Sopenharmony_ci (__i) < (__state)->dev->mode_config.num_crtc; \ 8118c2ecf20Sopenharmony_ci (__i)++) \ 8128c2ecf20Sopenharmony_ci for_each_if ((__state)->crtcs[__i].ptr && \ 8138c2ecf20Sopenharmony_ci ((crtc) = (__state)->crtcs[__i].ptr, \ 8148c2ecf20Sopenharmony_ci (void)(crtc) /* Only to avoid unused-but-set-variable warning */, \ 8158c2ecf20Sopenharmony_ci (new_crtc_state) = (__state)->crtcs[__i].new_state, \ 8168c2ecf20Sopenharmony_ci (void)(new_crtc_state) /* Only to avoid unused-but-set-variable warning */, 1)) 8178c2ecf20Sopenharmony_ci 8188c2ecf20Sopenharmony_ci/** 8198c2ecf20Sopenharmony_ci * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update 8208c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 8218c2ecf20Sopenharmony_ci * @plane: &struct drm_plane iteration cursor 8228c2ecf20Sopenharmony_ci * @old_plane_state: &struct drm_plane_state iteration cursor for the old state 8238c2ecf20Sopenharmony_ci * @new_plane_state: &struct drm_plane_state iteration cursor for the new state 8248c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 8258c2ecf20Sopenharmony_ci * 8268c2ecf20Sopenharmony_ci * This iterates over all planes in an atomic update, tracking both old and 8278c2ecf20Sopenharmony_ci * new state. This is useful in places where the state delta needs to be 8288c2ecf20Sopenharmony_ci * considered, for example in atomic check functions. 8298c2ecf20Sopenharmony_ci */ 8308c2ecf20Sopenharmony_ci#define for_each_oldnew_plane_in_state(__state, plane, old_plane_state, new_plane_state, __i) \ 8318c2ecf20Sopenharmony_ci for ((__i) = 0; \ 8328c2ecf20Sopenharmony_ci (__i) < (__state)->dev->mode_config.num_total_plane; \ 8338c2ecf20Sopenharmony_ci (__i)++) \ 8348c2ecf20Sopenharmony_ci for_each_if ((__state)->planes[__i].ptr && \ 8358c2ecf20Sopenharmony_ci ((plane) = (__state)->planes[__i].ptr, \ 8368c2ecf20Sopenharmony_ci (void)(plane) /* Only to avoid unused-but-set-variable warning */, \ 8378c2ecf20Sopenharmony_ci (old_plane_state) = (__state)->planes[__i].old_state,\ 8388c2ecf20Sopenharmony_ci (new_plane_state) = (__state)->planes[__i].new_state, 1)) 8398c2ecf20Sopenharmony_ci 8408c2ecf20Sopenharmony_ci/** 8418c2ecf20Sopenharmony_ci * for_each_oldnew_plane_in_state_reverse - iterate over all planes in an atomic 8428c2ecf20Sopenharmony_ci * update in reverse order 8438c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 8448c2ecf20Sopenharmony_ci * @plane: &struct drm_plane iteration cursor 8458c2ecf20Sopenharmony_ci * @old_plane_state: &struct drm_plane_state iteration cursor for the old state 8468c2ecf20Sopenharmony_ci * @new_plane_state: &struct drm_plane_state iteration cursor for the new state 8478c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 8488c2ecf20Sopenharmony_ci * 8498c2ecf20Sopenharmony_ci * This iterates over all planes in an atomic update in reverse order, 8508c2ecf20Sopenharmony_ci * tracking both old and new state. This is useful in places where the 8518c2ecf20Sopenharmony_ci * state delta needs to be considered, for example in atomic check functions. 8528c2ecf20Sopenharmony_ci */ 8538c2ecf20Sopenharmony_ci#define for_each_oldnew_plane_in_state_reverse(__state, plane, old_plane_state, new_plane_state, __i) \ 8548c2ecf20Sopenharmony_ci for ((__i) = ((__state)->dev->mode_config.num_total_plane - 1); \ 8558c2ecf20Sopenharmony_ci (__i) >= 0; \ 8568c2ecf20Sopenharmony_ci (__i)--) \ 8578c2ecf20Sopenharmony_ci for_each_if ((__state)->planes[__i].ptr && \ 8588c2ecf20Sopenharmony_ci ((plane) = (__state)->planes[__i].ptr, \ 8598c2ecf20Sopenharmony_ci (old_plane_state) = (__state)->planes[__i].old_state,\ 8608c2ecf20Sopenharmony_ci (new_plane_state) = (__state)->planes[__i].new_state, 1)) 8618c2ecf20Sopenharmony_ci 8628c2ecf20Sopenharmony_ci/** 8638c2ecf20Sopenharmony_ci * for_each_old_plane_in_state - iterate over all planes in an atomic update 8648c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 8658c2ecf20Sopenharmony_ci * @plane: &struct drm_plane iteration cursor 8668c2ecf20Sopenharmony_ci * @old_plane_state: &struct drm_plane_state iteration cursor for the old state 8678c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 8688c2ecf20Sopenharmony_ci * 8698c2ecf20Sopenharmony_ci * This iterates over all planes in an atomic update, tracking only the old 8708c2ecf20Sopenharmony_ci * state. This is useful in disable functions, where we need the old state the 8718c2ecf20Sopenharmony_ci * hardware is still in. 8728c2ecf20Sopenharmony_ci */ 8738c2ecf20Sopenharmony_ci#define for_each_old_plane_in_state(__state, plane, old_plane_state, __i) \ 8748c2ecf20Sopenharmony_ci for ((__i) = 0; \ 8758c2ecf20Sopenharmony_ci (__i) < (__state)->dev->mode_config.num_total_plane; \ 8768c2ecf20Sopenharmony_ci (__i)++) \ 8778c2ecf20Sopenharmony_ci for_each_if ((__state)->planes[__i].ptr && \ 8788c2ecf20Sopenharmony_ci ((plane) = (__state)->planes[__i].ptr, \ 8798c2ecf20Sopenharmony_ci (old_plane_state) = (__state)->planes[__i].old_state, 1)) 8808c2ecf20Sopenharmony_ci/** 8818c2ecf20Sopenharmony_ci * for_each_new_plane_in_state - iterate over all planes in an atomic update 8828c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 8838c2ecf20Sopenharmony_ci * @plane: &struct drm_plane iteration cursor 8848c2ecf20Sopenharmony_ci * @new_plane_state: &struct drm_plane_state iteration cursor for the new state 8858c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 8868c2ecf20Sopenharmony_ci * 8878c2ecf20Sopenharmony_ci * This iterates over all planes in an atomic update, tracking only the new 8888c2ecf20Sopenharmony_ci * state. This is useful in enable functions, where we need the new state the 8898c2ecf20Sopenharmony_ci * hardware should be in when the atomic commit operation has completed. 8908c2ecf20Sopenharmony_ci */ 8918c2ecf20Sopenharmony_ci#define for_each_new_plane_in_state(__state, plane, new_plane_state, __i) \ 8928c2ecf20Sopenharmony_ci for ((__i) = 0; \ 8938c2ecf20Sopenharmony_ci (__i) < (__state)->dev->mode_config.num_total_plane; \ 8948c2ecf20Sopenharmony_ci (__i)++) \ 8958c2ecf20Sopenharmony_ci for_each_if ((__state)->planes[__i].ptr && \ 8968c2ecf20Sopenharmony_ci ((plane) = (__state)->planes[__i].ptr, \ 8978c2ecf20Sopenharmony_ci (void)(plane) /* Only to avoid unused-but-set-variable warning */, \ 8988c2ecf20Sopenharmony_ci (new_plane_state) = (__state)->planes[__i].new_state, \ 8998c2ecf20Sopenharmony_ci (void)(new_plane_state) /* Only to avoid unused-but-set-variable warning */, 1)) 9008c2ecf20Sopenharmony_ci 9018c2ecf20Sopenharmony_ci/** 9028c2ecf20Sopenharmony_ci * for_each_oldnew_private_obj_in_state - iterate over all private objects in an atomic update 9038c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 9048c2ecf20Sopenharmony_ci * @obj: &struct drm_private_obj iteration cursor 9058c2ecf20Sopenharmony_ci * @old_obj_state: &struct drm_private_state iteration cursor for the old state 9068c2ecf20Sopenharmony_ci * @new_obj_state: &struct drm_private_state iteration cursor for the new state 9078c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 9088c2ecf20Sopenharmony_ci * 9098c2ecf20Sopenharmony_ci * This iterates over all private objects in an atomic update, tracking both 9108c2ecf20Sopenharmony_ci * old and new state. This is useful in places where the state delta needs 9118c2ecf20Sopenharmony_ci * to be considered, for example in atomic check functions. 9128c2ecf20Sopenharmony_ci */ 9138c2ecf20Sopenharmony_ci#define for_each_oldnew_private_obj_in_state(__state, obj, old_obj_state, new_obj_state, __i) \ 9148c2ecf20Sopenharmony_ci for ((__i) = 0; \ 9158c2ecf20Sopenharmony_ci (__i) < (__state)->num_private_objs && \ 9168c2ecf20Sopenharmony_ci ((obj) = (__state)->private_objs[__i].ptr, \ 9178c2ecf20Sopenharmony_ci (old_obj_state) = (__state)->private_objs[__i].old_state, \ 9188c2ecf20Sopenharmony_ci (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \ 9198c2ecf20Sopenharmony_ci (__i)++) 9208c2ecf20Sopenharmony_ci 9218c2ecf20Sopenharmony_ci/** 9228c2ecf20Sopenharmony_ci * for_each_old_private_obj_in_state - iterate over all private objects in an atomic update 9238c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 9248c2ecf20Sopenharmony_ci * @obj: &struct drm_private_obj iteration cursor 9258c2ecf20Sopenharmony_ci * @old_obj_state: &struct drm_private_state iteration cursor for the old state 9268c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 9278c2ecf20Sopenharmony_ci * 9288c2ecf20Sopenharmony_ci * This iterates over all private objects in an atomic update, tracking only 9298c2ecf20Sopenharmony_ci * the old state. This is useful in disable functions, where we need the old 9308c2ecf20Sopenharmony_ci * state the hardware is still in. 9318c2ecf20Sopenharmony_ci */ 9328c2ecf20Sopenharmony_ci#define for_each_old_private_obj_in_state(__state, obj, old_obj_state, __i) \ 9338c2ecf20Sopenharmony_ci for ((__i) = 0; \ 9348c2ecf20Sopenharmony_ci (__i) < (__state)->num_private_objs && \ 9358c2ecf20Sopenharmony_ci ((obj) = (__state)->private_objs[__i].ptr, \ 9368c2ecf20Sopenharmony_ci (old_obj_state) = (__state)->private_objs[__i].old_state, 1); \ 9378c2ecf20Sopenharmony_ci (__i)++) 9388c2ecf20Sopenharmony_ci 9398c2ecf20Sopenharmony_ci/** 9408c2ecf20Sopenharmony_ci * for_each_new_private_obj_in_state - iterate over all private objects in an atomic update 9418c2ecf20Sopenharmony_ci * @__state: &struct drm_atomic_state pointer 9428c2ecf20Sopenharmony_ci * @obj: &struct drm_private_obj iteration cursor 9438c2ecf20Sopenharmony_ci * @new_obj_state: &struct drm_private_state iteration cursor for the new state 9448c2ecf20Sopenharmony_ci * @__i: int iteration cursor, for macro-internal use 9458c2ecf20Sopenharmony_ci * 9468c2ecf20Sopenharmony_ci * This iterates over all private objects in an atomic update, tracking only 9478c2ecf20Sopenharmony_ci * the new state. This is useful in enable functions, where we need the new state the 9488c2ecf20Sopenharmony_ci * hardware should be in when the atomic commit operation has completed. 9498c2ecf20Sopenharmony_ci */ 9508c2ecf20Sopenharmony_ci#define for_each_new_private_obj_in_state(__state, obj, new_obj_state, __i) \ 9518c2ecf20Sopenharmony_ci for ((__i) = 0; \ 9528c2ecf20Sopenharmony_ci (__i) < (__state)->num_private_objs && \ 9538c2ecf20Sopenharmony_ci ((obj) = (__state)->private_objs[__i].ptr, \ 9548c2ecf20Sopenharmony_ci (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \ 9558c2ecf20Sopenharmony_ci (__i)++) 9568c2ecf20Sopenharmony_ci 9578c2ecf20Sopenharmony_ci/** 9588c2ecf20Sopenharmony_ci * drm_atomic_crtc_needs_modeset - compute combined modeset need 9598c2ecf20Sopenharmony_ci * @state: &drm_crtc_state for the CRTC 9608c2ecf20Sopenharmony_ci * 9618c2ecf20Sopenharmony_ci * To give drivers flexibility &struct drm_crtc_state has 3 booleans to track 9628c2ecf20Sopenharmony_ci * whether the state CRTC changed enough to need a full modeset cycle: 9638c2ecf20Sopenharmony_ci * mode_changed, active_changed and connectors_changed. This helper simply 9648c2ecf20Sopenharmony_ci * combines these three to compute the overall need for a modeset for @state. 9658c2ecf20Sopenharmony_ci * 9668c2ecf20Sopenharmony_ci * The atomic helper code sets these booleans, but drivers can and should 9678c2ecf20Sopenharmony_ci * change them appropriately to accurately represent whether a modeset is 9688c2ecf20Sopenharmony_ci * really needed. In general, drivers should avoid full modesets whenever 9698c2ecf20Sopenharmony_ci * possible. 9708c2ecf20Sopenharmony_ci * 9718c2ecf20Sopenharmony_ci * For example if the CRTC mode has changed, and the hardware is able to enact 9728c2ecf20Sopenharmony_ci * the requested mode change without going through a full modeset, the driver 9738c2ecf20Sopenharmony_ci * should clear mode_changed in its &drm_mode_config_funcs.atomic_check 9748c2ecf20Sopenharmony_ci * implementation. 9758c2ecf20Sopenharmony_ci */ 9768c2ecf20Sopenharmony_cistatic inline bool 9778c2ecf20Sopenharmony_cidrm_atomic_crtc_needs_modeset(const struct drm_crtc_state *state) 9788c2ecf20Sopenharmony_ci{ 9798c2ecf20Sopenharmony_ci return state->mode_changed || state->active_changed || 9808c2ecf20Sopenharmony_ci state->connectors_changed; 9818c2ecf20Sopenharmony_ci} 9828c2ecf20Sopenharmony_ci 9838c2ecf20Sopenharmony_ci/** 9848c2ecf20Sopenharmony_ci * drm_atomic_crtc_effectively_active - compute whether CRTC is actually active 9858c2ecf20Sopenharmony_ci * @state: &drm_crtc_state for the CRTC 9868c2ecf20Sopenharmony_ci * 9878c2ecf20Sopenharmony_ci * When in self refresh mode, the crtc_state->active value will be false, since 9888c2ecf20Sopenharmony_ci * the CRTC is off. However in some cases we're interested in whether the CRTC 9898c2ecf20Sopenharmony_ci * is active, or effectively active (ie: it's connected to an active display). 9908c2ecf20Sopenharmony_ci * In these cases, use this function instead of just checking active. 9918c2ecf20Sopenharmony_ci */ 9928c2ecf20Sopenharmony_cistatic inline bool 9938c2ecf20Sopenharmony_cidrm_atomic_crtc_effectively_active(const struct drm_crtc_state *state) 9948c2ecf20Sopenharmony_ci{ 9958c2ecf20Sopenharmony_ci return state->active || state->self_refresh_active; 9968c2ecf20Sopenharmony_ci} 9978c2ecf20Sopenharmony_ci 9988c2ecf20Sopenharmony_ci/** 9998c2ecf20Sopenharmony_ci * struct drm_bus_cfg - bus configuration 10008c2ecf20Sopenharmony_ci * 10018c2ecf20Sopenharmony_ci * This structure stores the configuration of a physical bus between two 10028c2ecf20Sopenharmony_ci * components in an output pipeline, usually between two bridges, an encoder 10038c2ecf20Sopenharmony_ci * and a bridge, or a bridge and a connector. 10048c2ecf20Sopenharmony_ci * 10058c2ecf20Sopenharmony_ci * The bus configuration is stored in &drm_bridge_state separately for the 10068c2ecf20Sopenharmony_ci * input and output buses, as seen from the point of view of each bridge. The 10078c2ecf20Sopenharmony_ci * bus configuration of a bridge output is usually identical to the 10088c2ecf20Sopenharmony_ci * configuration of the next bridge's input, but may differ if the signals are 10098c2ecf20Sopenharmony_ci * modified between the two bridges, for instance by an inverter on the board. 10108c2ecf20Sopenharmony_ci * The input and output configurations of a bridge may differ if the bridge 10118c2ecf20Sopenharmony_ci * modifies the signals internally, for instance by performing format 10128c2ecf20Sopenharmony_ci * conversion, or modifying signals polarities. 10138c2ecf20Sopenharmony_ci */ 10148c2ecf20Sopenharmony_cistruct drm_bus_cfg { 10158c2ecf20Sopenharmony_ci /** 10168c2ecf20Sopenharmony_ci * @format: format used on this bus (one of the MEDIA_BUS_FMT_* format) 10178c2ecf20Sopenharmony_ci * 10188c2ecf20Sopenharmony_ci * This field should not be directly modified by drivers 10198c2ecf20Sopenharmony_ci * (drm_atomic_bridge_chain_select_bus_fmts() takes care of the bus 10208c2ecf20Sopenharmony_ci * format negotiation). 10218c2ecf20Sopenharmony_ci */ 10228c2ecf20Sopenharmony_ci u32 format; 10238c2ecf20Sopenharmony_ci 10248c2ecf20Sopenharmony_ci /** 10258c2ecf20Sopenharmony_ci * @flags: DRM_BUS_* flags used on this bus 10268c2ecf20Sopenharmony_ci */ 10278c2ecf20Sopenharmony_ci u32 flags; 10288c2ecf20Sopenharmony_ci}; 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci/** 10318c2ecf20Sopenharmony_ci * struct drm_bridge_state - Atomic bridge state object 10328c2ecf20Sopenharmony_ci */ 10338c2ecf20Sopenharmony_cistruct drm_bridge_state { 10348c2ecf20Sopenharmony_ci /** 10358c2ecf20Sopenharmony_ci * @base: inherit from &drm_private_state 10368c2ecf20Sopenharmony_ci */ 10378c2ecf20Sopenharmony_ci struct drm_private_state base; 10388c2ecf20Sopenharmony_ci 10398c2ecf20Sopenharmony_ci /** 10408c2ecf20Sopenharmony_ci * @bridge: the bridge this state refers to 10418c2ecf20Sopenharmony_ci */ 10428c2ecf20Sopenharmony_ci struct drm_bridge *bridge; 10438c2ecf20Sopenharmony_ci 10448c2ecf20Sopenharmony_ci /** 10458c2ecf20Sopenharmony_ci * @input_bus_cfg: input bus configuration 10468c2ecf20Sopenharmony_ci */ 10478c2ecf20Sopenharmony_ci struct drm_bus_cfg input_bus_cfg; 10488c2ecf20Sopenharmony_ci 10498c2ecf20Sopenharmony_ci /** 10508c2ecf20Sopenharmony_ci * @output_bus_cfg: input bus configuration 10518c2ecf20Sopenharmony_ci */ 10528c2ecf20Sopenharmony_ci struct drm_bus_cfg output_bus_cfg; 10538c2ecf20Sopenharmony_ci}; 10548c2ecf20Sopenharmony_ci 10558c2ecf20Sopenharmony_cistatic inline struct drm_bridge_state * 10568c2ecf20Sopenharmony_cidrm_priv_to_bridge_state(struct drm_private_state *priv) 10578c2ecf20Sopenharmony_ci{ 10588c2ecf20Sopenharmony_ci return container_of(priv, struct drm_bridge_state, base); 10598c2ecf20Sopenharmony_ci} 10608c2ecf20Sopenharmony_ci 10618c2ecf20Sopenharmony_cistruct drm_bridge_state * 10628c2ecf20Sopenharmony_cidrm_atomic_get_bridge_state(struct drm_atomic_state *state, 10638c2ecf20Sopenharmony_ci struct drm_bridge *bridge); 10648c2ecf20Sopenharmony_cistruct drm_bridge_state * 10658c2ecf20Sopenharmony_cidrm_atomic_get_old_bridge_state(struct drm_atomic_state *state, 10668c2ecf20Sopenharmony_ci struct drm_bridge *bridge); 10678c2ecf20Sopenharmony_cistruct drm_bridge_state * 10688c2ecf20Sopenharmony_cidrm_atomic_get_new_bridge_state(struct drm_atomic_state *state, 10698c2ecf20Sopenharmony_ci struct drm_bridge *bridge); 10708c2ecf20Sopenharmony_ci 10718c2ecf20Sopenharmony_ci#endif /* DRM_ATOMIC_H_ */ 1072