Path: blob/master/drivers/gpu/drm/drm_atomic_state_helper.c
48869 views
/*1* Copyright (C) 2018 Intel Corp.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*21* Authors:22* Rob Clark <[email protected]>23* Daniel Vetter <[email protected]>24*/2526#include <drm/drm_atomic.h>27#include <drm/drm_atomic_state_helper.h>28#include <drm/drm_blend.h>29#include <drm/drm_bridge.h>30#include <drm/drm_connector.h>31#include <drm/drm_crtc.h>32#include <drm/drm_device.h>33#include <drm/drm_framebuffer.h>34#include <drm/drm_plane.h>35#include <drm/drm_print.h>36#include <drm/drm_vblank.h>37#include <drm/drm_writeback.h>3839#include <linux/export.h>40#include <linux/slab.h>41#include <linux/dma-fence.h>4243/**44* DOC: atomic state reset and initialization45*46* Both the drm core and the atomic helpers assume that there is always the full47* and correct atomic software state for all connectors, CRTCs and planes48* available. Which is a bit a problem on driver load and also after system49* suspend. One way to solve this is to have a hardware state read-out50* infrastructure which reconstructs the full software state (e.g. the i91551* driver).52*53* The simpler solution is to just reset the software state to everything off,54* which is easiest to do by calling drm_mode_config_reset(). To facilitate this55* the atomic helpers provide default reset implementations for all hooks.56*57* On the upside the precise state tracking of atomic simplifies system suspend58* and resume a lot. For drivers using drm_mode_config_reset() a complete recipe59* is implemented in drm_atomic_helper_suspend() and drm_atomic_helper_resume().60* For other drivers the building blocks are split out, see the documentation61* for these functions.62*/6364/**65* __drm_atomic_helper_crtc_state_reset - reset the CRTC state66* @crtc_state: atomic CRTC state, must not be NULL67* @crtc: CRTC object, must not be NULL68*69* Initializes the newly allocated @crtc_state with default70* values. This is useful for drivers that subclass the CRTC state.71*/72void73__drm_atomic_helper_crtc_state_reset(struct drm_crtc_state *crtc_state,74struct drm_crtc *crtc)75{76crtc_state->crtc = crtc;77}78EXPORT_SYMBOL(__drm_atomic_helper_crtc_state_reset);7980/**81* __drm_atomic_helper_crtc_reset - reset state on CRTC82* @crtc: drm CRTC83* @crtc_state: CRTC state to assign84*85* Initializes the newly allocated @crtc_state and assigns it to86* the &drm_crtc->state pointer of @crtc, usually required when87* initializing the drivers or when called from the &drm_crtc_funcs.reset88* hook.89*90* This is useful for drivers that subclass the CRTC state.91*/92void93__drm_atomic_helper_crtc_reset(struct drm_crtc *crtc,94struct drm_crtc_state *crtc_state)95{96if (crtc_state)97__drm_atomic_helper_crtc_state_reset(crtc_state, crtc);9899if (drm_dev_has_vblank(crtc->dev))100drm_crtc_vblank_reset(crtc);101102crtc->state = crtc_state;103}104EXPORT_SYMBOL(__drm_atomic_helper_crtc_reset);105106/**107* drm_atomic_helper_crtc_reset - default &drm_crtc_funcs.reset hook for CRTCs108* @crtc: drm CRTC109*110* Resets the atomic state for @crtc by freeing the state pointer (which might111* be NULL, e.g. at driver load time) and allocating a new empty state object.112*/113void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc)114{115struct drm_crtc_state *crtc_state =116kzalloc(sizeof(*crtc->state), GFP_KERNEL);117118if (crtc->state)119crtc->funcs->atomic_destroy_state(crtc, crtc->state);120121__drm_atomic_helper_crtc_reset(crtc, crtc_state);122}123EXPORT_SYMBOL(drm_atomic_helper_crtc_reset);124125/**126* __drm_atomic_helper_crtc_duplicate_state - copy atomic CRTC state127* @crtc: CRTC object128* @state: atomic CRTC state129*130* Copies atomic state from a CRTC's current state and resets inferred values.131* This is useful for drivers that subclass the CRTC state.132*/133void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,134struct drm_crtc_state *state)135{136memcpy(state, crtc->state, sizeof(*state));137138if (state->mode_blob)139drm_property_blob_get(state->mode_blob);140if (state->degamma_lut)141drm_property_blob_get(state->degamma_lut);142if (state->ctm)143drm_property_blob_get(state->ctm);144if (state->gamma_lut)145drm_property_blob_get(state->gamma_lut);146state->mode_changed = false;147state->active_changed = false;148state->planes_changed = false;149state->connectors_changed = false;150state->color_mgmt_changed = false;151state->zpos_changed = false;152state->commit = NULL;153state->event = NULL;154state->async_flip = false;155156/* Self refresh should be canceled when a new update is available */157state->active = drm_atomic_crtc_effectively_active(state);158state->self_refresh_active = false;159}160EXPORT_SYMBOL(__drm_atomic_helper_crtc_duplicate_state);161162/**163* drm_atomic_helper_crtc_duplicate_state - default state duplicate hook164* @crtc: drm CRTC165*166* Default CRTC state duplicate hook for drivers which don't have their own167* subclassed CRTC state structure.168*/169struct drm_crtc_state *170drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc)171{172struct drm_crtc_state *state;173174if (WARN_ON(!crtc->state))175return NULL;176177state = kmalloc(sizeof(*state), GFP_KERNEL);178if (state)179__drm_atomic_helper_crtc_duplicate_state(crtc, state);180181return state;182}183EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);184185/**186* __drm_atomic_helper_crtc_destroy_state - release CRTC state187* @state: CRTC state object to release188*189* Releases all resources stored in the CRTC state without actually freeing190* the memory of the CRTC state. This is useful for drivers that subclass the191* CRTC state.192*/193void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state)194{195if (state->commit) {196/*197* In the event that a non-blocking commit returns198* -ERESTARTSYS before the commit_tail work is queued, we will199* have an extra reference to the commit object. Release it, if200* the event has not been consumed by the worker.201*202* state->event may be freed, so we can't directly look at203* state->event->base.completion.204*/205if (state->event && state->commit->abort_completion)206drm_crtc_commit_put(state->commit);207208kfree(state->commit->event);209state->commit->event = NULL;210211drm_crtc_commit_put(state->commit);212}213214drm_property_blob_put(state->mode_blob);215drm_property_blob_put(state->degamma_lut);216drm_property_blob_put(state->ctm);217drm_property_blob_put(state->gamma_lut);218}219EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);220221/**222* drm_atomic_helper_crtc_destroy_state - default state destroy hook223* @crtc: drm CRTC224* @state: CRTC state object to release225*226* Default CRTC state destroy hook for drivers which don't have their own227* subclassed CRTC state structure.228*/229void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc,230struct drm_crtc_state *state)231{232__drm_atomic_helper_crtc_destroy_state(state);233kfree(state);234}235EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state);236237/**238* __drm_atomic_helper_plane_state_reset - resets plane state to default values239* @plane_state: atomic plane state, must not be NULL240* @plane: plane object, must not be NULL241*242* Initializes the newly allocated @plane_state with default243* values. This is useful for drivers that subclass the CRTC state.244*/245void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,246struct drm_plane *plane)247{248u64 val;249250plane_state->plane = plane;251plane_state->rotation = DRM_MODE_ROTATE_0;252253plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;254plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;255256if (plane->color_encoding_property) {257if (!drm_object_property_get_default_value(&plane->base,258plane->color_encoding_property,259&val))260plane_state->color_encoding = val;261}262263if (plane->color_range_property) {264if (!drm_object_property_get_default_value(&plane->base,265plane->color_range_property,266&val))267plane_state->color_range = val;268}269270if (plane->color_pipeline_property) {271/* default is always NULL, i.e., bypass */272plane_state->color_pipeline = NULL;273}274275if (plane->zpos_property) {276if (!drm_object_property_get_default_value(&plane->base,277plane->zpos_property,278&val)) {279plane_state->zpos = val;280plane_state->normalized_zpos = val;281}282}283284if (plane->hotspot_x_property) {285if (!drm_object_property_get_default_value(&plane->base,286plane->hotspot_x_property,287&val))288plane_state->hotspot_x = val;289}290291if (plane->hotspot_y_property) {292if (!drm_object_property_get_default_value(&plane->base,293plane->hotspot_y_property,294&val))295plane_state->hotspot_y = val;296}297}298EXPORT_SYMBOL(__drm_atomic_helper_plane_state_reset);299300/**301* __drm_atomic_helper_plane_reset - reset state on plane302* @plane: drm plane303* @plane_state: plane state to assign304*305* Initializes the newly allocated @plane_state and assigns it to306* the &drm_crtc->state pointer of @plane, usually required when307* initializing the drivers or when called from the &drm_plane_funcs.reset308* hook.309*310* This is useful for drivers that subclass the plane state.311*/312void __drm_atomic_helper_plane_reset(struct drm_plane *plane,313struct drm_plane_state *plane_state)314{315if (plane_state)316__drm_atomic_helper_plane_state_reset(plane_state, plane);317318plane->state = plane_state;319}320EXPORT_SYMBOL(__drm_atomic_helper_plane_reset);321322/**323* drm_atomic_helper_plane_reset - default &drm_plane_funcs.reset hook for planes324* @plane: drm plane325*326* Resets the atomic state for @plane by freeing the state pointer (which might327* be NULL, e.g. at driver load time) and allocating a new empty state object.328*/329void drm_atomic_helper_plane_reset(struct drm_plane *plane)330{331if (plane->state)332__drm_atomic_helper_plane_destroy_state(plane->state);333334kfree(plane->state);335plane->state = kzalloc(sizeof(*plane->state), GFP_KERNEL);336if (plane->state)337__drm_atomic_helper_plane_reset(plane, plane->state);338}339EXPORT_SYMBOL(drm_atomic_helper_plane_reset);340341/**342* __drm_atomic_helper_plane_duplicate_state - copy atomic plane state343* @plane: plane object344* @state: atomic plane state345*346* Copies atomic state from a plane's current state. This is useful for347* drivers that subclass the plane state.348*/349void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,350struct drm_plane_state *state)351{352memcpy(state, plane->state, sizeof(*state));353354if (state->fb)355drm_framebuffer_get(state->fb);356357state->fence = NULL;358state->commit = NULL;359state->fb_damage_clips = NULL;360state->color_mgmt_changed = false;361}362EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);363364/**365* drm_atomic_helper_plane_duplicate_state - default state duplicate hook366* @plane: drm plane367*368* Default plane state duplicate hook for drivers which don't have their own369* subclassed plane state structure.370*/371struct drm_plane_state *372drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane)373{374struct drm_plane_state *state;375376if (WARN_ON(!plane->state))377return NULL;378379state = kmalloc(sizeof(*state), GFP_KERNEL);380if (state)381__drm_atomic_helper_plane_duplicate_state(plane, state);382383return state;384}385EXPORT_SYMBOL(drm_atomic_helper_plane_duplicate_state);386387/**388* __drm_atomic_helper_plane_destroy_state - release plane state389* @state: plane state object to release390*391* Releases all resources stored in the plane state without actually freeing392* the memory of the plane state. This is useful for drivers that subclass the393* plane state.394*/395void __drm_atomic_helper_plane_destroy_state(struct drm_plane_state *state)396{397if (state->fb)398drm_framebuffer_put(state->fb);399400if (state->fence)401dma_fence_put(state->fence);402403if (state->commit)404drm_crtc_commit_put(state->commit);405406drm_property_blob_put(state->fb_damage_clips);407}408EXPORT_SYMBOL(__drm_atomic_helper_plane_destroy_state);409410/**411* drm_atomic_helper_plane_destroy_state - default state destroy hook412* @plane: drm plane413* @state: plane state object to release414*415* Default plane state destroy hook for drivers which don't have their own416* subclassed plane state structure.417*/418void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane,419struct drm_plane_state *state)420{421__drm_atomic_helper_plane_destroy_state(state);422kfree(state);423}424EXPORT_SYMBOL(drm_atomic_helper_plane_destroy_state);425426/**427* __drm_atomic_helper_connector_state_reset - reset the connector state428* @conn_state: atomic connector state, must not be NULL429* @connector: connectotr object, must not be NULL430*431* Initializes the newly allocated @conn_state with default432* values. This is useful for drivers that subclass the connector state.433*/434void435__drm_atomic_helper_connector_state_reset(struct drm_connector_state *conn_state,436struct drm_connector *connector)437{438conn_state->connector = connector;439}440EXPORT_SYMBOL(__drm_atomic_helper_connector_state_reset);441442/**443* __drm_atomic_helper_connector_reset - reset state on connector444* @connector: drm connector445* @conn_state: connector state to assign446*447* Initializes the newly allocated @conn_state and assigns it to448* the &drm_connector->state pointer of @connector, usually required when449* initializing the drivers or when called from the &drm_connector_funcs.reset450* hook.451*452* This is useful for drivers that subclass the connector state.453*/454void455__drm_atomic_helper_connector_reset(struct drm_connector *connector,456struct drm_connector_state *conn_state)457{458if (conn_state)459__drm_atomic_helper_connector_state_reset(conn_state, connector);460461connector->state = conn_state;462}463EXPORT_SYMBOL(__drm_atomic_helper_connector_reset);464465/**466* drm_atomic_helper_connector_reset - default &drm_connector_funcs.reset hook for connectors467* @connector: drm connector468*469* Resets the atomic state for @connector by freeing the state pointer (which470* might be NULL, e.g. at driver load time) and allocating a new empty state471* object.472*/473void drm_atomic_helper_connector_reset(struct drm_connector *connector)474{475struct drm_connector_state *conn_state =476kzalloc(sizeof(*conn_state), GFP_KERNEL);477478if (connector->state)479__drm_atomic_helper_connector_destroy_state(connector->state);480481kfree(connector->state);482__drm_atomic_helper_connector_reset(connector, conn_state);483}484EXPORT_SYMBOL(drm_atomic_helper_connector_reset);485486/**487* drm_atomic_helper_connector_tv_margins_reset - Resets TV connector properties488* @connector: DRM connector489*490* Resets the TV-related properties attached to a connector.491*/492void drm_atomic_helper_connector_tv_margins_reset(struct drm_connector *connector)493{494struct drm_cmdline_mode *cmdline = &connector->cmdline_mode;495struct drm_connector_state *state = connector->state;496497state->tv.margins.left = cmdline->tv_margins.left;498state->tv.margins.right = cmdline->tv_margins.right;499state->tv.margins.top = cmdline->tv_margins.top;500state->tv.margins.bottom = cmdline->tv_margins.bottom;501}502EXPORT_SYMBOL(drm_atomic_helper_connector_tv_margins_reset);503504/**505* drm_atomic_helper_connector_tv_reset - Resets Analog TV connector properties506* @connector: DRM connector507*508* Resets the analog TV properties attached to a connector509*/510void drm_atomic_helper_connector_tv_reset(struct drm_connector *connector)511{512struct drm_device *dev = connector->dev;513struct drm_cmdline_mode *cmdline = &connector->cmdline_mode;514struct drm_connector_state *state = connector->state;515struct drm_property *prop;516uint64_t val;517518prop = dev->mode_config.tv_mode_property;519if (prop)520if (!drm_object_property_get_default_value(&connector->base,521prop, &val))522state->tv.mode = val;523524if (cmdline->tv_mode_specified)525state->tv.mode = cmdline->tv_mode;526527prop = dev->mode_config.tv_select_subconnector_property;528if (prop)529if (!drm_object_property_get_default_value(&connector->base,530prop, &val))531state->tv.select_subconnector = val;532533prop = dev->mode_config.tv_subconnector_property;534if (prop)535if (!drm_object_property_get_default_value(&connector->base,536prop, &val))537state->tv.subconnector = val;538539prop = dev->mode_config.tv_brightness_property;540if (prop)541if (!drm_object_property_get_default_value(&connector->base,542prop, &val))543state->tv.brightness = val;544545prop = dev->mode_config.tv_contrast_property;546if (prop)547if (!drm_object_property_get_default_value(&connector->base,548prop, &val))549state->tv.contrast = val;550551prop = dev->mode_config.tv_flicker_reduction_property;552if (prop)553if (!drm_object_property_get_default_value(&connector->base,554prop, &val))555state->tv.flicker_reduction = val;556557prop = dev->mode_config.tv_overscan_property;558if (prop)559if (!drm_object_property_get_default_value(&connector->base,560prop, &val))561state->tv.overscan = val;562563prop = dev->mode_config.tv_saturation_property;564if (prop)565if (!drm_object_property_get_default_value(&connector->base,566prop, &val))567state->tv.saturation = val;568569prop = dev->mode_config.tv_hue_property;570if (prop)571if (!drm_object_property_get_default_value(&connector->base,572prop, &val))573state->tv.hue = val;574575drm_atomic_helper_connector_tv_margins_reset(connector);576}577EXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset);578579/**580* drm_atomic_helper_connector_tv_check - Validate an analog TV connector state581* @connector: DRM Connector582* @state: the DRM State object583*584* Checks the state object to see if the requested state is valid for an585* analog TV connector.586*587* Return:588* %0 for success, a negative error code on error.589*/590int drm_atomic_helper_connector_tv_check(struct drm_connector *connector,591struct drm_atomic_state *state)592{593struct drm_connector_state *old_conn_state =594drm_atomic_get_old_connector_state(state, connector);595struct drm_connector_state *new_conn_state =596drm_atomic_get_new_connector_state(state, connector);597struct drm_crtc_state *crtc_state;598struct drm_crtc *crtc;599600crtc = new_conn_state->crtc;601if (!crtc)602return 0;603604crtc_state = drm_atomic_get_new_crtc_state(state, crtc);605if (!crtc_state)606return -EINVAL;607608if (old_conn_state->tv.mode != new_conn_state->tv.mode)609crtc_state->mode_changed = true;610611if (old_conn_state->tv.margins.left != new_conn_state->tv.margins.left ||612old_conn_state->tv.margins.right != new_conn_state->tv.margins.right ||613old_conn_state->tv.margins.top != new_conn_state->tv.margins.top ||614old_conn_state->tv.margins.bottom != new_conn_state->tv.margins.bottom ||615old_conn_state->tv.mode != new_conn_state->tv.mode ||616old_conn_state->tv.brightness != new_conn_state->tv.brightness ||617old_conn_state->tv.contrast != new_conn_state->tv.contrast ||618old_conn_state->tv.flicker_reduction != new_conn_state->tv.flicker_reduction ||619old_conn_state->tv.overscan != new_conn_state->tv.overscan ||620old_conn_state->tv.saturation != new_conn_state->tv.saturation ||621old_conn_state->tv.hue != new_conn_state->tv.hue)622crtc_state->connectors_changed = true;623624return 0;625}626EXPORT_SYMBOL(drm_atomic_helper_connector_tv_check);627628/**629* __drm_atomic_helper_connector_duplicate_state - copy atomic connector state630* @connector: connector object631* @state: atomic connector state632*633* Copies atomic state from a connector's current state. This is useful for634* drivers that subclass the connector state.635*/636void637__drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,638struct drm_connector_state *state)639{640memcpy(state, connector->state, sizeof(*state));641if (state->crtc)642drm_connector_get(connector);643state->commit = NULL;644645if (state->hdr_output_metadata)646drm_property_blob_get(state->hdr_output_metadata);647648/* Don't copy over a writeback job, they are used only once */649state->writeback_job = NULL;650}651EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state);652653/**654* drm_atomic_helper_connector_duplicate_state - default state duplicate hook655* @connector: drm connector656*657* Default connector state duplicate hook for drivers which don't have their own658* subclassed connector state structure.659*/660struct drm_connector_state *661drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector)662{663struct drm_connector_state *state;664665if (WARN_ON(!connector->state))666return NULL;667668state = kmalloc(sizeof(*state), GFP_KERNEL);669if (state)670__drm_atomic_helper_connector_duplicate_state(connector, state);671672return state;673}674EXPORT_SYMBOL(drm_atomic_helper_connector_duplicate_state);675676/**677* __drm_atomic_helper_connector_destroy_state - release connector state678* @state: connector state object to release679*680* Releases all resources stored in the connector state without actually681* freeing the memory of the connector state. This is useful for drivers that682* subclass the connector state.683*/684void685__drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state)686{687if (state->crtc)688drm_connector_put(state->connector);689690if (state->commit)691drm_crtc_commit_put(state->commit);692693if (state->writeback_job)694drm_writeback_cleanup_job(state->writeback_job);695696drm_property_blob_put(state->hdr_output_metadata);697}698EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state);699700/**701* drm_atomic_helper_connector_destroy_state - default state destroy hook702* @connector: drm connector703* @state: connector state object to release704*705* Default connector state destroy hook for drivers which don't have their own706* subclassed connector state structure.707*/708void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,709struct drm_connector_state *state)710{711__drm_atomic_helper_connector_destroy_state(state);712kfree(state);713}714EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);715716/**717* __drm_atomic_helper_private_obj_duplicate_state - copy atomic private state718* @obj: CRTC object719* @state: new private object state720*721* Copies atomic state from a private objects's current state and resets inferred values.722* This is useful for drivers that subclass the private state.723*/724void __drm_atomic_helper_private_obj_duplicate_state(struct drm_private_obj *obj,725struct drm_private_state *state)726{727memcpy(state, obj->state, sizeof(*state));728}729EXPORT_SYMBOL(__drm_atomic_helper_private_obj_duplicate_state);730731/**732* __drm_atomic_helper_bridge_duplicate_state() - Copy atomic bridge state733* @bridge: bridge object734* @state: atomic bridge state735*736* Copies atomic state from a bridge's current state and resets inferred values.737* This is useful for drivers that subclass the bridge state.738*/739void __drm_atomic_helper_bridge_duplicate_state(struct drm_bridge *bridge,740struct drm_bridge_state *state)741{742__drm_atomic_helper_private_obj_duplicate_state(&bridge->base,743&state->base);744state->bridge = bridge;745}746EXPORT_SYMBOL(__drm_atomic_helper_bridge_duplicate_state);747748/**749* drm_atomic_helper_bridge_duplicate_state() - Duplicate a bridge state object750* @bridge: bridge object751*752* Allocates a new bridge state and initializes it with the current bridge753* state values. This helper is meant to be used as a bridge754* &drm_bridge_funcs.atomic_duplicate_state hook for bridges that don't755* subclass the bridge state.756*/757struct drm_bridge_state *758drm_atomic_helper_bridge_duplicate_state(struct drm_bridge *bridge)759{760struct drm_bridge_state *new;761762if (WARN_ON(!bridge->base.state))763return NULL;764765new = kzalloc(sizeof(*new), GFP_KERNEL);766if (new)767__drm_atomic_helper_bridge_duplicate_state(bridge, new);768769return new;770}771EXPORT_SYMBOL(drm_atomic_helper_bridge_duplicate_state);772773/**774* drm_atomic_helper_bridge_destroy_state() - Destroy a bridge state object775* @bridge: the bridge this state refers to776* @state: bridge state to destroy777*778* Destroys a bridge state previously created by779* &drm_atomic_helper_bridge_reset() or780* &drm_atomic_helper_bridge_duplicate_state(). This helper is meant to be781* used as a bridge &drm_bridge_funcs.atomic_destroy_state hook for bridges782* that don't subclass the bridge state.783*/784void drm_atomic_helper_bridge_destroy_state(struct drm_bridge *bridge,785struct drm_bridge_state *state)786{787kfree(state);788}789EXPORT_SYMBOL(drm_atomic_helper_bridge_destroy_state);790791/**792* __drm_atomic_helper_bridge_reset() - Initialize a bridge state to its793* default794* @bridge: the bridge this state refers to795* @state: bridge state to initialize796*797* Initializes the bridge state to default values. This is meant to be called798* by the bridge &drm_bridge_funcs.atomic_reset hook for bridges that subclass799* the bridge state.800*/801void __drm_atomic_helper_bridge_reset(struct drm_bridge *bridge,802struct drm_bridge_state *state)803{804memset(state, 0, sizeof(*state));805state->bridge = bridge;806}807EXPORT_SYMBOL(__drm_atomic_helper_bridge_reset);808809/**810* drm_atomic_helper_bridge_reset() - Allocate and initialize a bridge state811* to its default812* @bridge: the bridge this state refers to813*814* Allocates the bridge state and initializes it to default values. This helper815* is meant to be used as a bridge &drm_bridge_funcs.atomic_reset hook for816* bridges that don't subclass the bridge state.817*/818struct drm_bridge_state *819drm_atomic_helper_bridge_reset(struct drm_bridge *bridge)820{821struct drm_bridge_state *bridge_state;822823bridge_state = kzalloc(sizeof(*bridge_state), GFP_KERNEL);824if (!bridge_state)825return ERR_PTR(-ENOMEM);826827__drm_atomic_helper_bridge_reset(bridge, bridge_state);828return bridge_state;829}830EXPORT_SYMBOL(drm_atomic_helper_bridge_reset);831832833