18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (C) 2018 Intel Corp. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * Authors: 238c2ecf20Sopenharmony_ci * Rob Clark <robdclark@gmail.com> 248c2ecf20Sopenharmony_ci * Daniel Vetter <daniel.vetter@ffwll.ch> 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#include <drm/drm_atomic.h> 288c2ecf20Sopenharmony_ci#include <drm/drm_atomic_state_helper.h> 298c2ecf20Sopenharmony_ci#include <drm/drm_bridge.h> 308c2ecf20Sopenharmony_ci#include <drm/drm_connector.h> 318c2ecf20Sopenharmony_ci#include <drm/drm_crtc.h> 328c2ecf20Sopenharmony_ci#include <drm/drm_device.h> 338c2ecf20Sopenharmony_ci#include <drm/drm_plane.h> 348c2ecf20Sopenharmony_ci#include <drm/drm_print.h> 358c2ecf20Sopenharmony_ci#include <drm/drm_vblank.h> 368c2ecf20Sopenharmony_ci#include <drm/drm_writeback.h> 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#include <linux/slab.h> 398c2ecf20Sopenharmony_ci#include <linux/dma-fence.h> 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/** 428c2ecf20Sopenharmony_ci * DOC: atomic state reset and initialization 438c2ecf20Sopenharmony_ci * 448c2ecf20Sopenharmony_ci * Both the drm core and the atomic helpers assume that there is always the full 458c2ecf20Sopenharmony_ci * and correct atomic software state for all connectors, CRTCs and planes 468c2ecf20Sopenharmony_ci * available. Which is a bit a problem on driver load and also after system 478c2ecf20Sopenharmony_ci * suspend. One way to solve this is to have a hardware state read-out 488c2ecf20Sopenharmony_ci * infrastructure which reconstructs the full software state (e.g. the i915 498c2ecf20Sopenharmony_ci * driver). 508c2ecf20Sopenharmony_ci * 518c2ecf20Sopenharmony_ci * The simpler solution is to just reset the software state to everything off, 528c2ecf20Sopenharmony_ci * which is easiest to do by calling drm_mode_config_reset(). To facilitate this 538c2ecf20Sopenharmony_ci * the atomic helpers provide default reset implementations for all hooks. 548c2ecf20Sopenharmony_ci * 558c2ecf20Sopenharmony_ci * On the upside the precise state tracking of atomic simplifies system suspend 568c2ecf20Sopenharmony_ci * and resume a lot. For drivers using drm_mode_config_reset() a complete recipe 578c2ecf20Sopenharmony_ci * is implemented in drm_atomic_helper_suspend() and drm_atomic_helper_resume(). 588c2ecf20Sopenharmony_ci * For other drivers the building blocks are split out, see the documentation 598c2ecf20Sopenharmony_ci * for these functions. 608c2ecf20Sopenharmony_ci */ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/** 638c2ecf20Sopenharmony_ci * __drm_atomic_helper_crtc_state_reset - reset the CRTC state 648c2ecf20Sopenharmony_ci * @crtc_state: atomic CRTC state, must not be NULL 658c2ecf20Sopenharmony_ci * @crtc: CRTC object, must not be NULL 668c2ecf20Sopenharmony_ci * 678c2ecf20Sopenharmony_ci * Initializes the newly allocated @crtc_state with default 688c2ecf20Sopenharmony_ci * values. This is useful for drivers that subclass the CRTC state. 698c2ecf20Sopenharmony_ci */ 708c2ecf20Sopenharmony_civoid 718c2ecf20Sopenharmony_ci__drm_atomic_helper_crtc_state_reset(struct drm_crtc_state *crtc_state, 728c2ecf20Sopenharmony_ci struct drm_crtc *crtc) 738c2ecf20Sopenharmony_ci{ 748c2ecf20Sopenharmony_ci crtc_state->crtc = crtc; 758c2ecf20Sopenharmony_ci} 768c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_crtc_state_reset); 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/** 798c2ecf20Sopenharmony_ci * __drm_atomic_helper_crtc_reset - reset state on CRTC 808c2ecf20Sopenharmony_ci * @crtc: drm CRTC 818c2ecf20Sopenharmony_ci * @crtc_state: CRTC state to assign 828c2ecf20Sopenharmony_ci * 838c2ecf20Sopenharmony_ci * Initializes the newly allocated @crtc_state and assigns it to 848c2ecf20Sopenharmony_ci * the &drm_crtc->state pointer of @crtc, usually required when 858c2ecf20Sopenharmony_ci * initializing the drivers or when called from the &drm_crtc_funcs.reset 868c2ecf20Sopenharmony_ci * hook. 878c2ecf20Sopenharmony_ci * 888c2ecf20Sopenharmony_ci * This is useful for drivers that subclass the CRTC state. 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_civoid 918c2ecf20Sopenharmony_ci__drm_atomic_helper_crtc_reset(struct drm_crtc *crtc, 928c2ecf20Sopenharmony_ci struct drm_crtc_state *crtc_state) 938c2ecf20Sopenharmony_ci{ 948c2ecf20Sopenharmony_ci if (crtc_state) 958c2ecf20Sopenharmony_ci __drm_atomic_helper_crtc_state_reset(crtc_state, crtc); 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci if (drm_dev_has_vblank(crtc->dev)) 988c2ecf20Sopenharmony_ci drm_crtc_vblank_reset(crtc); 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci crtc->state = crtc_state; 1018c2ecf20Sopenharmony_ci} 1028c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_crtc_reset); 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/** 1058c2ecf20Sopenharmony_ci * drm_atomic_helper_crtc_reset - default &drm_crtc_funcs.reset hook for CRTCs 1068c2ecf20Sopenharmony_ci * @crtc: drm CRTC 1078c2ecf20Sopenharmony_ci * 1088c2ecf20Sopenharmony_ci * Resets the atomic state for @crtc by freeing the state pointer (which might 1098c2ecf20Sopenharmony_ci * be NULL, e.g. at driver load time) and allocating a new empty state object. 1108c2ecf20Sopenharmony_ci */ 1118c2ecf20Sopenharmony_civoid drm_atomic_helper_crtc_reset(struct drm_crtc *crtc) 1128c2ecf20Sopenharmony_ci{ 1138c2ecf20Sopenharmony_ci struct drm_crtc_state *crtc_state = 1148c2ecf20Sopenharmony_ci kzalloc(sizeof(*crtc->state), GFP_KERNEL); 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci if (crtc->state) 1178c2ecf20Sopenharmony_ci crtc->funcs->atomic_destroy_state(crtc, crtc->state); 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci __drm_atomic_helper_crtc_reset(crtc, crtc_state); 1208c2ecf20Sopenharmony_ci} 1218c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_crtc_reset); 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci/** 1248c2ecf20Sopenharmony_ci * __drm_atomic_helper_crtc_duplicate_state - copy atomic CRTC state 1258c2ecf20Sopenharmony_ci * @crtc: CRTC object 1268c2ecf20Sopenharmony_ci * @state: atomic CRTC state 1278c2ecf20Sopenharmony_ci * 1288c2ecf20Sopenharmony_ci * Copies atomic state from a CRTC's current state and resets inferred values. 1298c2ecf20Sopenharmony_ci * This is useful for drivers that subclass the CRTC state. 1308c2ecf20Sopenharmony_ci */ 1318c2ecf20Sopenharmony_civoid __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc, 1328c2ecf20Sopenharmony_ci struct drm_crtc_state *state) 1338c2ecf20Sopenharmony_ci{ 1348c2ecf20Sopenharmony_ci memcpy(state, crtc->state, sizeof(*state)); 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci if (state->mode_blob) 1378c2ecf20Sopenharmony_ci drm_property_blob_get(state->mode_blob); 1388c2ecf20Sopenharmony_ci if (state->degamma_lut) 1398c2ecf20Sopenharmony_ci drm_property_blob_get(state->degamma_lut); 1408c2ecf20Sopenharmony_ci if (state->ctm) 1418c2ecf20Sopenharmony_ci drm_property_blob_get(state->ctm); 1428c2ecf20Sopenharmony_ci if (state->gamma_lut) 1438c2ecf20Sopenharmony_ci drm_property_blob_get(state->gamma_lut); 1448c2ecf20Sopenharmony_ci state->mode_changed = false; 1458c2ecf20Sopenharmony_ci state->active_changed = false; 1468c2ecf20Sopenharmony_ci state->planes_changed = false; 1478c2ecf20Sopenharmony_ci state->connectors_changed = false; 1488c2ecf20Sopenharmony_ci state->color_mgmt_changed = false; 1498c2ecf20Sopenharmony_ci state->zpos_changed = false; 1508c2ecf20Sopenharmony_ci state->commit = NULL; 1518c2ecf20Sopenharmony_ci state->event = NULL; 1528c2ecf20Sopenharmony_ci state->async_flip = false; 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci /* Self refresh should be canceled when a new update is available */ 1558c2ecf20Sopenharmony_ci state->active = drm_atomic_crtc_effectively_active(state); 1568c2ecf20Sopenharmony_ci state->self_refresh_active = false; 1578c2ecf20Sopenharmony_ci} 1588c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_crtc_duplicate_state); 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci/** 1618c2ecf20Sopenharmony_ci * drm_atomic_helper_crtc_duplicate_state - default state duplicate hook 1628c2ecf20Sopenharmony_ci * @crtc: drm CRTC 1638c2ecf20Sopenharmony_ci * 1648c2ecf20Sopenharmony_ci * Default CRTC state duplicate hook for drivers which don't have their own 1658c2ecf20Sopenharmony_ci * subclassed CRTC state structure. 1668c2ecf20Sopenharmony_ci */ 1678c2ecf20Sopenharmony_cistruct drm_crtc_state * 1688c2ecf20Sopenharmony_cidrm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc) 1698c2ecf20Sopenharmony_ci{ 1708c2ecf20Sopenharmony_ci struct drm_crtc_state *state; 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci if (WARN_ON(!crtc->state)) 1738c2ecf20Sopenharmony_ci return NULL; 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci state = kmalloc(sizeof(*state), GFP_KERNEL); 1768c2ecf20Sopenharmony_ci if (state) 1778c2ecf20Sopenharmony_ci __drm_atomic_helper_crtc_duplicate_state(crtc, state); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci return state; 1808c2ecf20Sopenharmony_ci} 1818c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state); 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci/** 1848c2ecf20Sopenharmony_ci * __drm_atomic_helper_crtc_destroy_state - release CRTC state 1858c2ecf20Sopenharmony_ci * @state: CRTC state object to release 1868c2ecf20Sopenharmony_ci * 1878c2ecf20Sopenharmony_ci * Releases all resources stored in the CRTC state without actually freeing 1888c2ecf20Sopenharmony_ci * the memory of the CRTC state. This is useful for drivers that subclass the 1898c2ecf20Sopenharmony_ci * CRTC state. 1908c2ecf20Sopenharmony_ci */ 1918c2ecf20Sopenharmony_civoid __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state) 1928c2ecf20Sopenharmony_ci{ 1938c2ecf20Sopenharmony_ci if (state->commit) { 1948c2ecf20Sopenharmony_ci /* 1958c2ecf20Sopenharmony_ci * In the event that a non-blocking commit returns 1968c2ecf20Sopenharmony_ci * -ERESTARTSYS before the commit_tail work is queued, we will 1978c2ecf20Sopenharmony_ci * have an extra reference to the commit object. Release it, if 1988c2ecf20Sopenharmony_ci * the event has not been consumed by the worker. 1998c2ecf20Sopenharmony_ci * 2008c2ecf20Sopenharmony_ci * state->event may be freed, so we can't directly look at 2018c2ecf20Sopenharmony_ci * state->event->base.completion. 2028c2ecf20Sopenharmony_ci */ 2038c2ecf20Sopenharmony_ci if (state->event && state->commit->abort_completion) 2048c2ecf20Sopenharmony_ci drm_crtc_commit_put(state->commit); 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci kfree(state->commit->event); 2078c2ecf20Sopenharmony_ci state->commit->event = NULL; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci drm_crtc_commit_put(state->commit); 2108c2ecf20Sopenharmony_ci } 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci drm_property_blob_put(state->mode_blob); 2138c2ecf20Sopenharmony_ci drm_property_blob_put(state->degamma_lut); 2148c2ecf20Sopenharmony_ci drm_property_blob_put(state->ctm); 2158c2ecf20Sopenharmony_ci drm_property_blob_put(state->gamma_lut); 2168c2ecf20Sopenharmony_ci} 2178c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state); 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci/** 2208c2ecf20Sopenharmony_ci * drm_atomic_helper_crtc_destroy_state - default state destroy hook 2218c2ecf20Sopenharmony_ci * @crtc: drm CRTC 2228c2ecf20Sopenharmony_ci * @state: CRTC state object to release 2238c2ecf20Sopenharmony_ci * 2248c2ecf20Sopenharmony_ci * Default CRTC state destroy hook for drivers which don't have their own 2258c2ecf20Sopenharmony_ci * subclassed CRTC state structure. 2268c2ecf20Sopenharmony_ci */ 2278c2ecf20Sopenharmony_civoid drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc, 2288c2ecf20Sopenharmony_ci struct drm_crtc_state *state) 2298c2ecf20Sopenharmony_ci{ 2308c2ecf20Sopenharmony_ci __drm_atomic_helper_crtc_destroy_state(state); 2318c2ecf20Sopenharmony_ci kfree(state); 2328c2ecf20Sopenharmony_ci} 2338c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state); 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci/** 2368c2ecf20Sopenharmony_ci * __drm_atomic_helper_plane_state_reset - resets plane state to default values 2378c2ecf20Sopenharmony_ci * @plane_state: atomic plane state, must not be NULL 2388c2ecf20Sopenharmony_ci * @plane: plane object, must not be NULL 2398c2ecf20Sopenharmony_ci * 2408c2ecf20Sopenharmony_ci * Initializes the newly allocated @plane_state with default 2418c2ecf20Sopenharmony_ci * values. This is useful for drivers that subclass the CRTC state. 2428c2ecf20Sopenharmony_ci */ 2438c2ecf20Sopenharmony_civoid __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state, 2448c2ecf20Sopenharmony_ci struct drm_plane *plane) 2458c2ecf20Sopenharmony_ci{ 2468c2ecf20Sopenharmony_ci plane_state->plane = plane; 2478c2ecf20Sopenharmony_ci plane_state->rotation = DRM_MODE_ROTATE_0; 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE; 2508c2ecf20Sopenharmony_ci plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; 2518c2ecf20Sopenharmony_ci} 2528c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_plane_state_reset); 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci/** 2558c2ecf20Sopenharmony_ci * __drm_atomic_helper_plane_reset - reset state on plane 2568c2ecf20Sopenharmony_ci * @plane: drm plane 2578c2ecf20Sopenharmony_ci * @plane_state: plane state to assign 2588c2ecf20Sopenharmony_ci * 2598c2ecf20Sopenharmony_ci * Initializes the newly allocated @plane_state and assigns it to 2608c2ecf20Sopenharmony_ci * the &drm_crtc->state pointer of @plane, usually required when 2618c2ecf20Sopenharmony_ci * initializing the drivers or when called from the &drm_plane_funcs.reset 2628c2ecf20Sopenharmony_ci * hook. 2638c2ecf20Sopenharmony_ci * 2648c2ecf20Sopenharmony_ci * This is useful for drivers that subclass the plane state. 2658c2ecf20Sopenharmony_ci */ 2668c2ecf20Sopenharmony_civoid __drm_atomic_helper_plane_reset(struct drm_plane *plane, 2678c2ecf20Sopenharmony_ci struct drm_plane_state *plane_state) 2688c2ecf20Sopenharmony_ci{ 2698c2ecf20Sopenharmony_ci if (plane_state) 2708c2ecf20Sopenharmony_ci __drm_atomic_helper_plane_state_reset(plane_state, plane); 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci plane->state = plane_state; 2738c2ecf20Sopenharmony_ci} 2748c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_plane_reset); 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci/** 2778c2ecf20Sopenharmony_ci * drm_atomic_helper_plane_reset - default &drm_plane_funcs.reset hook for planes 2788c2ecf20Sopenharmony_ci * @plane: drm plane 2798c2ecf20Sopenharmony_ci * 2808c2ecf20Sopenharmony_ci * Resets the atomic state for @plane by freeing the state pointer (which might 2818c2ecf20Sopenharmony_ci * be NULL, e.g. at driver load time) and allocating a new empty state object. 2828c2ecf20Sopenharmony_ci */ 2838c2ecf20Sopenharmony_civoid drm_atomic_helper_plane_reset(struct drm_plane *plane) 2848c2ecf20Sopenharmony_ci{ 2858c2ecf20Sopenharmony_ci if (plane->state) 2868c2ecf20Sopenharmony_ci __drm_atomic_helper_plane_destroy_state(plane->state); 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci kfree(plane->state); 2898c2ecf20Sopenharmony_ci plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL); 2908c2ecf20Sopenharmony_ci if (plane->state) 2918c2ecf20Sopenharmony_ci __drm_atomic_helper_plane_reset(plane, plane->state); 2928c2ecf20Sopenharmony_ci} 2938c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_plane_reset); 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci/** 2968c2ecf20Sopenharmony_ci * __drm_atomic_helper_plane_duplicate_state - copy atomic plane state 2978c2ecf20Sopenharmony_ci * @plane: plane object 2988c2ecf20Sopenharmony_ci * @state: atomic plane state 2998c2ecf20Sopenharmony_ci * 3008c2ecf20Sopenharmony_ci * Copies atomic state from a plane's current state. This is useful for 3018c2ecf20Sopenharmony_ci * drivers that subclass the plane state. 3028c2ecf20Sopenharmony_ci */ 3038c2ecf20Sopenharmony_civoid __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane, 3048c2ecf20Sopenharmony_ci struct drm_plane_state *state) 3058c2ecf20Sopenharmony_ci{ 3068c2ecf20Sopenharmony_ci memcpy(state, plane->state, sizeof(*state)); 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci if (state->fb) 3098c2ecf20Sopenharmony_ci drm_framebuffer_get(state->fb); 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci state->fence = NULL; 3128c2ecf20Sopenharmony_ci state->commit = NULL; 3138c2ecf20Sopenharmony_ci state->fb_damage_clips = NULL; 3148c2ecf20Sopenharmony_ci} 3158c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state); 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci/** 3188c2ecf20Sopenharmony_ci * drm_atomic_helper_plane_duplicate_state - default state duplicate hook 3198c2ecf20Sopenharmony_ci * @plane: drm plane 3208c2ecf20Sopenharmony_ci * 3218c2ecf20Sopenharmony_ci * Default plane state duplicate hook for drivers which don't have their own 3228c2ecf20Sopenharmony_ci * subclassed plane state structure. 3238c2ecf20Sopenharmony_ci */ 3248c2ecf20Sopenharmony_cistruct drm_plane_state * 3258c2ecf20Sopenharmony_cidrm_atomic_helper_plane_duplicate_state(struct drm_plane *plane) 3268c2ecf20Sopenharmony_ci{ 3278c2ecf20Sopenharmony_ci struct drm_plane_state *state; 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci if (WARN_ON(!plane->state)) 3308c2ecf20Sopenharmony_ci return NULL; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci state = kmalloc(sizeof(*state), GFP_KERNEL); 3338c2ecf20Sopenharmony_ci if (state) 3348c2ecf20Sopenharmony_ci __drm_atomic_helper_plane_duplicate_state(plane, state); 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci return state; 3378c2ecf20Sopenharmony_ci} 3388c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_plane_duplicate_state); 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci/** 3418c2ecf20Sopenharmony_ci * __drm_atomic_helper_plane_destroy_state - release plane state 3428c2ecf20Sopenharmony_ci * @state: plane state object to release 3438c2ecf20Sopenharmony_ci * 3448c2ecf20Sopenharmony_ci * Releases all resources stored in the plane state without actually freeing 3458c2ecf20Sopenharmony_ci * the memory of the plane state. This is useful for drivers that subclass the 3468c2ecf20Sopenharmony_ci * plane state. 3478c2ecf20Sopenharmony_ci */ 3488c2ecf20Sopenharmony_civoid __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state) 3498c2ecf20Sopenharmony_ci{ 3508c2ecf20Sopenharmony_ci if (state->fb) 3518c2ecf20Sopenharmony_ci drm_framebuffer_put(state->fb); 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci if (state->fence) 3548c2ecf20Sopenharmony_ci dma_fence_put(state->fence); 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_ci if (state->commit) 3578c2ecf20Sopenharmony_ci drm_crtc_commit_put(state->commit); 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci drm_property_blob_put(state->fb_damage_clips); 3608c2ecf20Sopenharmony_ci} 3618c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state); 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci/** 3648c2ecf20Sopenharmony_ci * drm_atomic_helper_plane_destroy_state - default state destroy hook 3658c2ecf20Sopenharmony_ci * @plane: drm plane 3668c2ecf20Sopenharmony_ci * @state: plane state object to release 3678c2ecf20Sopenharmony_ci * 3688c2ecf20Sopenharmony_ci * Default plane state destroy hook for drivers which don't have their own 3698c2ecf20Sopenharmony_ci * subclassed plane state structure. 3708c2ecf20Sopenharmony_ci */ 3718c2ecf20Sopenharmony_civoid drm_atomic_helper_plane_destroy_state(struct drm_plane *plane, 3728c2ecf20Sopenharmony_ci struct drm_plane_state *state) 3738c2ecf20Sopenharmony_ci{ 3748c2ecf20Sopenharmony_ci __drm_atomic_helper_plane_destroy_state(state); 3758c2ecf20Sopenharmony_ci kfree(state); 3768c2ecf20Sopenharmony_ci} 3778c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state); 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci/** 3808c2ecf20Sopenharmony_ci * __drm_atomic_helper_connector_state_reset - reset the connector state 3818c2ecf20Sopenharmony_ci * @conn_state: atomic connector state, must not be NULL 3828c2ecf20Sopenharmony_ci * @connector: connectotr object, must not be NULL 3838c2ecf20Sopenharmony_ci * 3848c2ecf20Sopenharmony_ci * Initializes the newly allocated @conn_state with default 3858c2ecf20Sopenharmony_ci * values. This is useful for drivers that subclass the connector state. 3868c2ecf20Sopenharmony_ci */ 3878c2ecf20Sopenharmony_civoid 3888c2ecf20Sopenharmony_ci__drm_atomic_helper_connector_state_reset(struct drm_connector_state *conn_state, 3898c2ecf20Sopenharmony_ci struct drm_connector *connector) 3908c2ecf20Sopenharmony_ci{ 3918c2ecf20Sopenharmony_ci conn_state->connector = connector; 3928c2ecf20Sopenharmony_ci} 3938c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_connector_state_reset); 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ci/** 3968c2ecf20Sopenharmony_ci * __drm_atomic_helper_connector_reset - reset state on connector 3978c2ecf20Sopenharmony_ci * @connector: drm connector 3988c2ecf20Sopenharmony_ci * @conn_state: connector state to assign 3998c2ecf20Sopenharmony_ci * 4008c2ecf20Sopenharmony_ci * Initializes the newly allocated @conn_state and assigns it to 4018c2ecf20Sopenharmony_ci * the &drm_connector->state pointer of @connector, usually required when 4028c2ecf20Sopenharmony_ci * initializing the drivers or when called from the &drm_connector_funcs.reset 4038c2ecf20Sopenharmony_ci * hook. 4048c2ecf20Sopenharmony_ci * 4058c2ecf20Sopenharmony_ci * This is useful for drivers that subclass the connector state. 4068c2ecf20Sopenharmony_ci */ 4078c2ecf20Sopenharmony_civoid 4088c2ecf20Sopenharmony_ci__drm_atomic_helper_connector_reset(struct drm_connector *connector, 4098c2ecf20Sopenharmony_ci struct drm_connector_state *conn_state) 4108c2ecf20Sopenharmony_ci{ 4118c2ecf20Sopenharmony_ci if (conn_state) 4128c2ecf20Sopenharmony_ci __drm_atomic_helper_connector_state_reset(conn_state, connector); 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci connector->state = conn_state; 4158c2ecf20Sopenharmony_ci} 4168c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_connector_reset); 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci/** 4198c2ecf20Sopenharmony_ci * drm_atomic_helper_connector_reset - default &drm_connector_funcs.reset hook for connectors 4208c2ecf20Sopenharmony_ci * @connector: drm connector 4218c2ecf20Sopenharmony_ci * 4228c2ecf20Sopenharmony_ci * Resets the atomic state for @connector by freeing the state pointer (which 4238c2ecf20Sopenharmony_ci * might be NULL, e.g. at driver load time) and allocating a new empty state 4248c2ecf20Sopenharmony_ci * object. 4258c2ecf20Sopenharmony_ci */ 4268c2ecf20Sopenharmony_civoid drm_atomic_helper_connector_reset(struct drm_connector *connector) 4278c2ecf20Sopenharmony_ci{ 4288c2ecf20Sopenharmony_ci struct drm_connector_state *conn_state = 4298c2ecf20Sopenharmony_ci kzalloc(sizeof(*conn_state), GFP_KERNEL); 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci if (connector->state) 4328c2ecf20Sopenharmony_ci __drm_atomic_helper_connector_destroy_state(connector->state); 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci kfree(connector->state); 4358c2ecf20Sopenharmony_ci __drm_atomic_helper_connector_reset(connector, conn_state); 4368c2ecf20Sopenharmony_ci} 4378c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_connector_reset); 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci/** 4408c2ecf20Sopenharmony_ci * drm_atomic_helper_connector_tv_reset - Resets TV connector properties 4418c2ecf20Sopenharmony_ci * @connector: DRM connector 4428c2ecf20Sopenharmony_ci * 4438c2ecf20Sopenharmony_ci * Resets the TV-related properties attached to a connector. 4448c2ecf20Sopenharmony_ci */ 4458c2ecf20Sopenharmony_civoid drm_atomic_helper_connector_tv_reset(struct drm_connector *connector) 4468c2ecf20Sopenharmony_ci{ 4478c2ecf20Sopenharmony_ci struct drm_cmdline_mode *cmdline = &connector->cmdline_mode; 4488c2ecf20Sopenharmony_ci struct drm_connector_state *state = connector->state; 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ci state->tv.margins.left = cmdline->tv_margins.left; 4518c2ecf20Sopenharmony_ci state->tv.margins.right = cmdline->tv_margins.right; 4528c2ecf20Sopenharmony_ci state->tv.margins.top = cmdline->tv_margins.top; 4538c2ecf20Sopenharmony_ci state->tv.margins.bottom = cmdline->tv_margins.bottom; 4548c2ecf20Sopenharmony_ci} 4558c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset); 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci/** 4588c2ecf20Sopenharmony_ci * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state 4598c2ecf20Sopenharmony_ci * @connector: connector object 4608c2ecf20Sopenharmony_ci * @state: atomic connector state 4618c2ecf20Sopenharmony_ci * 4628c2ecf20Sopenharmony_ci * Copies atomic state from a connector's current state. This is useful for 4638c2ecf20Sopenharmony_ci * drivers that subclass the connector state. 4648c2ecf20Sopenharmony_ci */ 4658c2ecf20Sopenharmony_civoid 4668c2ecf20Sopenharmony_ci__drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector, 4678c2ecf20Sopenharmony_ci struct drm_connector_state *state) 4688c2ecf20Sopenharmony_ci{ 4698c2ecf20Sopenharmony_ci memcpy(state, connector->state, sizeof(*state)); 4708c2ecf20Sopenharmony_ci if (state->crtc) 4718c2ecf20Sopenharmony_ci drm_connector_get(connector); 4728c2ecf20Sopenharmony_ci state->commit = NULL; 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci if (state->hdr_output_metadata) 4758c2ecf20Sopenharmony_ci drm_property_blob_get(state->hdr_output_metadata); 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci /* Don't copy over a writeback job, they are used only once */ 4788c2ecf20Sopenharmony_ci state->writeback_job = NULL; 4798c2ecf20Sopenharmony_ci} 4808c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state); 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci/** 4838c2ecf20Sopenharmony_ci * drm_atomic_helper_connector_duplicate_state - default state duplicate hook 4848c2ecf20Sopenharmony_ci * @connector: drm connector 4858c2ecf20Sopenharmony_ci * 4868c2ecf20Sopenharmony_ci * Default connector state duplicate hook for drivers which don't have their own 4878c2ecf20Sopenharmony_ci * subclassed connector state structure. 4888c2ecf20Sopenharmony_ci */ 4898c2ecf20Sopenharmony_cistruct drm_connector_state * 4908c2ecf20Sopenharmony_cidrm_atomic_helper_connector_duplicate_state(struct drm_connector *connector) 4918c2ecf20Sopenharmony_ci{ 4928c2ecf20Sopenharmony_ci struct drm_connector_state *state; 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci if (WARN_ON(!connector->state)) 4958c2ecf20Sopenharmony_ci return NULL; 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci state = kmalloc(sizeof(*state), GFP_KERNEL); 4988c2ecf20Sopenharmony_ci if (state) 4998c2ecf20Sopenharmony_ci __drm_atomic_helper_connector_duplicate_state(connector, state); 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci return state; 5028c2ecf20Sopenharmony_ci} 5038c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_connector_duplicate_state); 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_ci/** 5068c2ecf20Sopenharmony_ci * __drm_atomic_helper_connector_destroy_state - release connector state 5078c2ecf20Sopenharmony_ci * @state: connector state object to release 5088c2ecf20Sopenharmony_ci * 5098c2ecf20Sopenharmony_ci * Releases all resources stored in the connector state without actually 5108c2ecf20Sopenharmony_ci * freeing the memory of the connector state. This is useful for drivers that 5118c2ecf20Sopenharmony_ci * subclass the connector state. 5128c2ecf20Sopenharmony_ci */ 5138c2ecf20Sopenharmony_civoid 5148c2ecf20Sopenharmony_ci__drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state) 5158c2ecf20Sopenharmony_ci{ 5168c2ecf20Sopenharmony_ci if (state->crtc) 5178c2ecf20Sopenharmony_ci drm_connector_put(state->connector); 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_ci if (state->commit) 5208c2ecf20Sopenharmony_ci drm_crtc_commit_put(state->commit); 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_ci if (state->writeback_job) 5238c2ecf20Sopenharmony_ci drm_writeback_cleanup_job(state->writeback_job); 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci drm_property_blob_put(state->hdr_output_metadata); 5268c2ecf20Sopenharmony_ci} 5278c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state); 5288c2ecf20Sopenharmony_ci 5298c2ecf20Sopenharmony_ci/** 5308c2ecf20Sopenharmony_ci * drm_atomic_helper_connector_destroy_state - default state destroy hook 5318c2ecf20Sopenharmony_ci * @connector: drm connector 5328c2ecf20Sopenharmony_ci * @state: connector state object to release 5338c2ecf20Sopenharmony_ci * 5348c2ecf20Sopenharmony_ci * Default connector state destroy hook for drivers which don't have their own 5358c2ecf20Sopenharmony_ci * subclassed connector state structure. 5368c2ecf20Sopenharmony_ci */ 5378c2ecf20Sopenharmony_civoid drm_atomic_helper_connector_destroy_state(struct drm_connector *connector, 5388c2ecf20Sopenharmony_ci struct drm_connector_state *state) 5398c2ecf20Sopenharmony_ci{ 5408c2ecf20Sopenharmony_ci __drm_atomic_helper_connector_destroy_state(state); 5418c2ecf20Sopenharmony_ci kfree(state); 5428c2ecf20Sopenharmony_ci} 5438c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state); 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci/** 5468c2ecf20Sopenharmony_ci * __drm_atomic_helper_private_duplicate_state - copy atomic private state 5478c2ecf20Sopenharmony_ci * @obj: CRTC object 5488c2ecf20Sopenharmony_ci * @state: new private object state 5498c2ecf20Sopenharmony_ci * 5508c2ecf20Sopenharmony_ci * Copies atomic state from a private objects's current state and resets inferred values. 5518c2ecf20Sopenharmony_ci * This is useful for drivers that subclass the private state. 5528c2ecf20Sopenharmony_ci */ 5538c2ecf20Sopenharmony_civoid __drm_atomic_helper_private_obj_duplicate_state(struct drm_private_obj *obj, 5548c2ecf20Sopenharmony_ci struct drm_private_state *state) 5558c2ecf20Sopenharmony_ci{ 5568c2ecf20Sopenharmony_ci memcpy(state, obj->state, sizeof(*state)); 5578c2ecf20Sopenharmony_ci} 5588c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_private_obj_duplicate_state); 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci/** 5618c2ecf20Sopenharmony_ci * __drm_atomic_helper_bridge_duplicate_state() - Copy atomic bridge state 5628c2ecf20Sopenharmony_ci * @bridge: bridge object 5638c2ecf20Sopenharmony_ci * @state: atomic bridge state 5648c2ecf20Sopenharmony_ci * 5658c2ecf20Sopenharmony_ci * Copies atomic state from a bridge's current state and resets inferred values. 5668c2ecf20Sopenharmony_ci * This is useful for drivers that subclass the bridge state. 5678c2ecf20Sopenharmony_ci */ 5688c2ecf20Sopenharmony_civoid __drm_atomic_helper_bridge_duplicate_state(struct drm_bridge *bridge, 5698c2ecf20Sopenharmony_ci struct drm_bridge_state *state) 5708c2ecf20Sopenharmony_ci{ 5718c2ecf20Sopenharmony_ci __drm_atomic_helper_private_obj_duplicate_state(&bridge->base, 5728c2ecf20Sopenharmony_ci &state->base); 5738c2ecf20Sopenharmony_ci state->bridge = bridge; 5748c2ecf20Sopenharmony_ci} 5758c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_bridge_duplicate_state); 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci/** 5788c2ecf20Sopenharmony_ci * drm_atomic_helper_bridge_duplicate_state() - Duplicate a bridge state object 5798c2ecf20Sopenharmony_ci * @bridge: bridge object 5808c2ecf20Sopenharmony_ci * 5818c2ecf20Sopenharmony_ci * Allocates a new bridge state and initializes it with the current bridge 5828c2ecf20Sopenharmony_ci * state values. This helper is meant to be used as a bridge 5838c2ecf20Sopenharmony_ci * &drm_bridge_funcs.atomic_duplicate_state hook for bridges that don't 5848c2ecf20Sopenharmony_ci * subclass the bridge state. 5858c2ecf20Sopenharmony_ci */ 5868c2ecf20Sopenharmony_cistruct drm_bridge_state * 5878c2ecf20Sopenharmony_cidrm_atomic_helper_bridge_duplicate_state(struct drm_bridge *bridge) 5888c2ecf20Sopenharmony_ci{ 5898c2ecf20Sopenharmony_ci struct drm_bridge_state *new; 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci if (WARN_ON(!bridge->base.state)) 5928c2ecf20Sopenharmony_ci return NULL; 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci new = kzalloc(sizeof(*new), GFP_KERNEL); 5958c2ecf20Sopenharmony_ci if (new) 5968c2ecf20Sopenharmony_ci __drm_atomic_helper_bridge_duplicate_state(bridge, new); 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_ci return new; 5998c2ecf20Sopenharmony_ci} 6008c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_bridge_duplicate_state); 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci/** 6038c2ecf20Sopenharmony_ci * drm_atomic_helper_bridge_destroy_state() - Destroy a bridge state object 6048c2ecf20Sopenharmony_ci * @bridge: the bridge this state refers to 6058c2ecf20Sopenharmony_ci * @state: bridge state to destroy 6068c2ecf20Sopenharmony_ci * 6078c2ecf20Sopenharmony_ci * Destroys a bridge state previously created by 6088c2ecf20Sopenharmony_ci * &drm_atomic_helper_bridge_reset() or 6098c2ecf20Sopenharmony_ci * &drm_atomic_helper_bridge_duplicate_state(). This helper is meant to be 6108c2ecf20Sopenharmony_ci * used as a bridge &drm_bridge_funcs.atomic_destroy_state hook for bridges 6118c2ecf20Sopenharmony_ci * that don't subclass the bridge state. 6128c2ecf20Sopenharmony_ci */ 6138c2ecf20Sopenharmony_civoid drm_atomic_helper_bridge_destroy_state(struct drm_bridge *bridge, 6148c2ecf20Sopenharmony_ci struct drm_bridge_state *state) 6158c2ecf20Sopenharmony_ci{ 6168c2ecf20Sopenharmony_ci kfree(state); 6178c2ecf20Sopenharmony_ci} 6188c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_bridge_destroy_state); 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ci/** 6218c2ecf20Sopenharmony_ci * __drm_atomic_helper_bridge_reset() - Initialize a bridge state to its 6228c2ecf20Sopenharmony_ci * default 6238c2ecf20Sopenharmony_ci * @bridge: the bridge this state refers to 6248c2ecf20Sopenharmony_ci * @state: bridge state to initialize 6258c2ecf20Sopenharmony_ci * 6268c2ecf20Sopenharmony_ci * Initializes the bridge state to default values. This is meant to be called 6278c2ecf20Sopenharmony_ci * by the bridge &drm_bridge_funcs.atomic_reset hook for bridges that subclass 6288c2ecf20Sopenharmony_ci * the bridge state. 6298c2ecf20Sopenharmony_ci */ 6308c2ecf20Sopenharmony_civoid __drm_atomic_helper_bridge_reset(struct drm_bridge *bridge, 6318c2ecf20Sopenharmony_ci struct drm_bridge_state *state) 6328c2ecf20Sopenharmony_ci{ 6338c2ecf20Sopenharmony_ci memset(state, 0, sizeof(*state)); 6348c2ecf20Sopenharmony_ci state->bridge = bridge; 6358c2ecf20Sopenharmony_ci} 6368c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__drm_atomic_helper_bridge_reset); 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci/** 6398c2ecf20Sopenharmony_ci * drm_atomic_helper_bridge_reset() - Allocate and initialize a bridge state 6408c2ecf20Sopenharmony_ci * to its default 6418c2ecf20Sopenharmony_ci * @bridge: the bridge this state refers to 6428c2ecf20Sopenharmony_ci * 6438c2ecf20Sopenharmony_ci * Allocates the bridge state and initializes it to default values. This helper 6448c2ecf20Sopenharmony_ci * is meant to be used as a bridge &drm_bridge_funcs.atomic_reset hook for 6458c2ecf20Sopenharmony_ci * bridges that don't subclass the bridge state. 6468c2ecf20Sopenharmony_ci */ 6478c2ecf20Sopenharmony_cistruct drm_bridge_state * 6488c2ecf20Sopenharmony_cidrm_atomic_helper_bridge_reset(struct drm_bridge *bridge) 6498c2ecf20Sopenharmony_ci{ 6508c2ecf20Sopenharmony_ci struct drm_bridge_state *bridge_state; 6518c2ecf20Sopenharmony_ci 6528c2ecf20Sopenharmony_ci bridge_state = kzalloc(sizeof(*bridge_state), GFP_KERNEL); 6538c2ecf20Sopenharmony_ci if (!bridge_state) 6548c2ecf20Sopenharmony_ci return ERR_PTR(-ENOMEM); 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci __drm_atomic_helper_bridge_reset(bridge, bridge_state); 6578c2ecf20Sopenharmony_ci return bridge_state; 6588c2ecf20Sopenharmony_ci} 6598c2ecf20Sopenharmony_ciEXPORT_SYMBOL(drm_atomic_helper_bridge_reset); 660