/*1* Copyright (c) 2016 Intel Corporation2*3* Permission to use, copy, modify, distribute, and sell this software and its4* documentation for any purpose is hereby granted without fee, provided that5* the above copyright notice appear in all copies and that both that copyright6* notice and this permission notice appear in supporting documentation, and7* that the name of the copyright holders not be used in advertising or8* publicity pertaining to distribution of the software without specific,9* written prior permission. The copyright holders make no representations10* about the suitability of this software for any purpose. It is provided "as11* is" without express or implied warranty.12*13* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,14* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO15* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR16* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,17* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER18* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE19* OF THIS SOFTWARE.20*/2122#ifndef __DRM_BRIDGE_H__23#define __DRM_BRIDGE_H__2425#include <linux/cleanup.h>26#include <linux/ctype.h>27#include <linux/list.h>28#include <linux/mutex.h>2930#include <drm/drm_atomic.h>31#include <drm/drm_encoder.h>32#include <drm/drm_mode_object.h>33#include <drm/drm_modes.h>3435struct cec_msg;36struct device_node;3738struct drm_bridge;39struct drm_bridge_timings;40struct drm_connector;41struct drm_display_info;42struct drm_minor;43struct drm_panel;44struct edid;45struct hdmi_codec_daifmt;46struct hdmi_codec_params;47struct i2c_adapter;4849/**50* enum drm_bridge_attach_flags - Flags for &drm_bridge_funcs.attach51*/52enum drm_bridge_attach_flags {53/**54* @DRM_BRIDGE_ATTACH_NO_CONNECTOR: When this flag is set the bridge55* shall not create a drm_connector.56*/57DRM_BRIDGE_ATTACH_NO_CONNECTOR = BIT(0),58};5960/**61* struct drm_bridge_funcs - drm_bridge control functions62*/63struct drm_bridge_funcs {64/**65* @attach:66*67* This callback is invoked whenever our bridge is being attached to a68* &drm_encoder. The flags argument tunes the behaviour of the attach69* operation (see DRM_BRIDGE_ATTACH_*).70*71* The @attach callback is optional.72*73* RETURNS:74*75* Zero on success, error code on failure.76*/77int (*attach)(struct drm_bridge *bridge, struct drm_encoder *encoder,78enum drm_bridge_attach_flags flags);7980/**81* @destroy:82*83* This callback is invoked when the bridge is about to be84* deallocated.85*86* The @destroy callback is optional.87*/88void (*destroy)(struct drm_bridge *bridge);8990/**91* @detach:92*93* This callback is invoked whenever our bridge is being detached from a94* &drm_encoder.95*96* The @detach callback is optional.97*/98void (*detach)(struct drm_bridge *bridge);99100/**101* @mode_valid:102*103* This callback is used to check if a specific mode is valid in this104* bridge. This should be implemented if the bridge has some sort of105* restriction in the modes it can display. For example, a given bridge106* may be responsible to set a clock value. If the clock can not107* produce all the values for the available modes then this callback108* can be used to restrict the number of modes to only the ones that109* can be displayed.110*111* This hook is used by the probe helpers to filter the mode list in112* drm_helper_probe_single_connector_modes(), and it is used by the113* atomic helpers to validate modes supplied by userspace in114* drm_atomic_helper_check_modeset().115*116* The @mode_valid callback is optional.117*118* NOTE:119*120* Since this function is both called from the check phase of an atomic121* commit, and the mode validation in the probe paths it is not allowed122* to look at anything else but the passed-in mode, and validate it123* against configuration-invariant hardware constraints. Any further124* limits which depend upon the configuration can only be checked in125* @mode_fixup.126*127* RETURNS:128*129* drm_mode_status Enum130*/131enum drm_mode_status (*mode_valid)(struct drm_bridge *bridge,132const struct drm_display_info *info,133const struct drm_display_mode *mode);134135/**136* @mode_fixup:137*138* This callback is used to validate and adjust a mode. The parameter139* mode is the display mode that should be fed to the next element in140* the display chain, either the final &drm_connector or the next141* &drm_bridge. The parameter adjusted_mode is the input mode the bridge142* requires. It can be modified by this callback and does not need to143* match mode. See also &drm_crtc_state.adjusted_mode for more details.144*145* This is the only hook that allows a bridge to reject a modeset. If146* this function passes all other callbacks must succeed for this147* configuration.148*149* The mode_fixup callback is optional. &drm_bridge_funcs.mode_fixup()150* is not called when &drm_bridge_funcs.atomic_check() is implemented,151* so only one of them should be provided.152*153* NOTE:154*155* This function is called in the check phase of atomic modesets, which156* can be aborted for any reason (including on userspace's request to157* just check whether a configuration would be possible). Drivers MUST158* NOT touch any persistent state (hardware or software) or data159* structures except the passed in @state parameter.160*161* Also beware that userspace can request its own custom modes, neither162* core nor helpers filter modes to the list of probe modes reported by163* the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure164* that modes are filtered consistently put any bridge constraints and165* limits checks into @mode_valid.166*167* RETURNS:168*169* True if an acceptable configuration is possible, false if the modeset170* operation should be rejected.171*/172bool (*mode_fixup)(struct drm_bridge *bridge,173const struct drm_display_mode *mode,174struct drm_display_mode *adjusted_mode);175/**176* @disable:177*178* The @disable callback should disable the bridge.179*180* The bridge can assume that the display pipe (i.e. clocks and timing181* signals) feeding it is still running when this callback is called.182*183*184* If the preceding element is a &drm_bridge, then this is called before185* that bridge is disabled via one of:186*187* - &drm_bridge_funcs.disable188* - &drm_bridge_funcs.atomic_disable189*190* If the preceding element of the bridge is a display controller, then191* this callback is called before the encoder is disabled via one of:192*193* - &drm_encoder_helper_funcs.atomic_disable194* - &drm_encoder_helper_funcs.prepare195* - &drm_encoder_helper_funcs.disable196* - &drm_encoder_helper_funcs.dpms197*198* and the CRTC is disabled via one of:199*200* - &drm_crtc_helper_funcs.prepare201* - &drm_crtc_helper_funcs.atomic_disable202* - &drm_crtc_helper_funcs.disable203* - &drm_crtc_helper_funcs.dpms.204*205* The @disable callback is optional.206*207* NOTE:208*209* This is deprecated, do not use!210* New drivers shall use &drm_bridge_funcs.atomic_disable.211*/212void (*disable)(struct drm_bridge *bridge);213214/**215* @post_disable:216*217* The bridge must assume that the display pipe (i.e. clocks and timing218* signals) feeding this bridge is no longer running when the219* @post_disable is called.220*221* This callback should perform all the actions required by the hardware222* after it has stopped receiving signals from the preceding element.223*224* If the preceding element is a &drm_bridge, then this is called after225* that bridge is post-disabled (unless marked otherwise by the226* @pre_enable_prev_first flag) via one of:227*228* - &drm_bridge_funcs.post_disable229* - &drm_bridge_funcs.atomic_post_disable230*231* If the preceding element of the bridge is a display controller, then232* this callback is called after the encoder is disabled via one of:233*234* - &drm_encoder_helper_funcs.atomic_disable235* - &drm_encoder_helper_funcs.prepare236* - &drm_encoder_helper_funcs.disable237* - &drm_encoder_helper_funcs.dpms238*239* and the CRTC is disabled via one of:240*241* - &drm_crtc_helper_funcs.prepare242* - &drm_crtc_helper_funcs.atomic_disable243* - &drm_crtc_helper_funcs.disable244* - &drm_crtc_helper_funcs.dpms245*246* The @post_disable callback is optional.247*248* NOTE:249*250* This is deprecated, do not use!251* New drivers shall use &drm_bridge_funcs.atomic_post_disable.252*/253void (*post_disable)(struct drm_bridge *bridge);254255/**256* @mode_set:257*258* This callback should set the given mode on the bridge. It is called259* after the @mode_set callback for the preceding element in the display260* pipeline has been called already. If the bridge is the first element261* then this would be &drm_encoder_helper_funcs.mode_set. The display262* pipe (i.e. clocks and timing signals) is off when this function is263* called.264*265* The adjusted_mode parameter is the mode output by the CRTC for the266* first bridge in the chain. It can be different from the mode267* parameter that contains the desired mode for the connector at the end268* of the bridges chain, for instance when the first bridge in the chain269* performs scaling. The adjusted mode is mostly useful for the first270* bridge in the chain and is likely irrelevant for the other bridges.271*272* For atomic drivers the adjusted_mode is the mode stored in273* &drm_crtc_state.adjusted_mode.274*275* NOTE:276*277* This is deprecated, do not use!278* New drivers shall set their mode in the279* &drm_bridge_funcs.atomic_enable operation.280*/281void (*mode_set)(struct drm_bridge *bridge,282const struct drm_display_mode *mode,283const struct drm_display_mode *adjusted_mode);284/**285* @pre_enable:286*287* The display pipe (i.e. clocks and timing signals) feeding this bridge288* will not yet be running when the @pre_enable is called.289*290* This callback should perform all the necessary actions to prepare the291* bridge to accept signals from the preceding element.292*293* If the preceding element is a &drm_bridge, then this is called before294* that bridge is pre-enabled (unless marked otherwise by295* @pre_enable_prev_first flag) via one of:296*297* - &drm_bridge_funcs.pre_enable298* - &drm_bridge_funcs.atomic_pre_enable299*300* If the preceding element of the bridge is a display controller, then301* this callback is called before the CRTC is enabled via one of:302*303* - &drm_crtc_helper_funcs.atomic_enable304* - &drm_crtc_helper_funcs.commit305*306* and the encoder is enabled via one of:307*308* - &drm_encoder_helper_funcs.atomic_enable309* - &drm_encoder_helper_funcs.enable310* - &drm_encoder_helper_funcs.commit311*312* The @pre_enable callback is optional.313*314* NOTE:315*316* This is deprecated, do not use!317* New drivers shall use &drm_bridge_funcs.atomic_pre_enable.318*/319void (*pre_enable)(struct drm_bridge *bridge);320321/**322* @enable:323*324* The @enable callback should enable the bridge.325*326* The bridge can assume that the display pipe (i.e. clocks and timing327* signals) feeding it is running when this callback is called. This328* callback must enable the display link feeding the next bridge in the329* chain if there is one.330*331* If the preceding element is a &drm_bridge, then this is called after332* that bridge is enabled via one of:333*334* - &drm_bridge_funcs.enable335* - &drm_bridge_funcs.atomic_enable336*337* If the preceding element of the bridge is a display controller, then338* this callback is called after the CRTC is enabled via one of:339*340* - &drm_crtc_helper_funcs.atomic_enable341* - &drm_crtc_helper_funcs.commit342*343* and the encoder is enabled via one of:344*345* - &drm_encoder_helper_funcs.atomic_enable346* - &drm_encoder_helper_funcs.enable347* - drm_encoder_helper_funcs.commit348*349* The @enable callback is optional.350*351* NOTE:352*353* This is deprecated, do not use!354* New drivers shall use &drm_bridge_funcs.atomic_enable.355*/356void (*enable)(struct drm_bridge *bridge);357358/**359* @atomic_pre_enable:360*361* The display pipe (i.e. clocks and timing signals) feeding this bridge362* will not yet be running when the @atomic_pre_enable is called.363*364* This callback should perform all the necessary actions to prepare the365* bridge to accept signals from the preceding element.366*367* If the preceding element is a &drm_bridge, then this is called before368* that bridge is pre-enabled (unless marked otherwise by369* @pre_enable_prev_first flag) via one of:370*371* - &drm_bridge_funcs.pre_enable372* - &drm_bridge_funcs.atomic_pre_enable373*374* If the preceding element of the bridge is a display controller, then375* this callback is called before the CRTC is enabled via one of:376*377* - &drm_crtc_helper_funcs.atomic_enable378* - &drm_crtc_helper_funcs.commit379*380* and the encoder is enabled via one of:381*382* - &drm_encoder_helper_funcs.atomic_enable383* - &drm_encoder_helper_funcs.enable384* - &drm_encoder_helper_funcs.commit385*386* The @atomic_pre_enable callback is optional.387*/388void (*atomic_pre_enable)(struct drm_bridge *bridge,389struct drm_atomic_state *state);390391/**392* @atomic_enable:393*394* The @atomic_enable callback should enable the bridge.395*396* The bridge can assume that the display pipe (i.e. clocks and timing397* signals) feeding it is running when this callback is called. This398* callback must enable the display link feeding the next bridge in the399* chain if there is one.400*401* If the preceding element is a &drm_bridge, then this is called after402* that bridge is enabled via one of:403*404* - &drm_bridge_funcs.enable405* - &drm_bridge_funcs.atomic_enable406*407* If the preceding element of the bridge is a display controller, then408* this callback is called after the CRTC is enabled via one of:409*410* - &drm_crtc_helper_funcs.atomic_enable411* - &drm_crtc_helper_funcs.commit412*413* and the encoder is enabled via one of:414*415* - &drm_encoder_helper_funcs.atomic_enable416* - &drm_encoder_helper_funcs.enable417* - drm_encoder_helper_funcs.commit418*419* The @atomic_enable callback is optional.420*/421void (*atomic_enable)(struct drm_bridge *bridge,422struct drm_atomic_state *state);423/**424* @atomic_disable:425*426* The @atomic_disable callback should disable the bridge.427*428* The bridge can assume that the display pipe (i.e. clocks and timing429* signals) feeding it is still running when this callback is called.430*431* If the preceding element is a &drm_bridge, then this is called before432* that bridge is disabled via one of:433*434* - &drm_bridge_funcs.disable435* - &drm_bridge_funcs.atomic_disable436*437* If the preceding element of the bridge is a display controller, then438* this callback is called before the encoder is disabled via one of:439*440* - &drm_encoder_helper_funcs.atomic_disable441* - &drm_encoder_helper_funcs.prepare442* - &drm_encoder_helper_funcs.disable443* - &drm_encoder_helper_funcs.dpms444*445* and the CRTC is disabled via one of:446*447* - &drm_crtc_helper_funcs.prepare448* - &drm_crtc_helper_funcs.atomic_disable449* - &drm_crtc_helper_funcs.disable450* - &drm_crtc_helper_funcs.dpms.451*452* The @atomic_disable callback is optional.453*/454void (*atomic_disable)(struct drm_bridge *bridge,455struct drm_atomic_state *state);456457/**458* @atomic_post_disable:459*460* The bridge must assume that the display pipe (i.e. clocks and timing461* signals) feeding this bridge is no longer running when the462* @atomic_post_disable is called.463*464* This callback should perform all the actions required by the hardware465* after it has stopped receiving signals from the preceding element.466*467* If the preceding element is a &drm_bridge, then this is called after468* that bridge is post-disabled (unless marked otherwise by the469* @pre_enable_prev_first flag) via one of:470*471* - &drm_bridge_funcs.post_disable472* - &drm_bridge_funcs.atomic_post_disable473*474* If the preceding element of the bridge is a display controller, then475* this callback is called after the encoder is disabled via one of:476*477* - &drm_encoder_helper_funcs.atomic_disable478* - &drm_encoder_helper_funcs.prepare479* - &drm_encoder_helper_funcs.disable480* - &drm_encoder_helper_funcs.dpms481*482* and the CRTC is disabled via one of:483*484* - &drm_crtc_helper_funcs.prepare485* - &drm_crtc_helper_funcs.atomic_disable486* - &drm_crtc_helper_funcs.disable487* - &drm_crtc_helper_funcs.dpms488*489* The @atomic_post_disable callback is optional.490*/491void (*atomic_post_disable)(struct drm_bridge *bridge,492struct drm_atomic_state *state);493494/**495* @atomic_duplicate_state:496*497* Duplicate the current bridge state object (which is guaranteed to be498* non-NULL).499*500* The atomic_duplicate_state hook is mandatory if the bridge501* implements any of the atomic hooks, and should be left unassigned502* otherwise. For bridges that don't subclass &drm_bridge_state, the503* drm_atomic_helper_bridge_duplicate_state() helper function shall be504* used to implement this hook.505*506* RETURNS:507* A valid drm_bridge_state object or NULL if the allocation fails.508*/509struct drm_bridge_state *(*atomic_duplicate_state)(struct drm_bridge *bridge);510511/**512* @atomic_destroy_state:513*514* Destroy a bridge state object previously allocated by515* &drm_bridge_funcs.atomic_duplicate_state().516*517* The atomic_destroy_state hook is mandatory if the bridge implements518* any of the atomic hooks, and should be left unassigned otherwise.519* For bridges that don't subclass &drm_bridge_state, the520* drm_atomic_helper_bridge_destroy_state() helper function shall be521* used to implement this hook.522*/523void (*atomic_destroy_state)(struct drm_bridge *bridge,524struct drm_bridge_state *state);525526/**527* @atomic_get_output_bus_fmts:528*529* Return the supported bus formats on the output end of a bridge.530* The returned array must be allocated with kmalloc() and will be531* freed by the caller. If the allocation fails, NULL should be532* returned. num_output_fmts must be set to the returned array size.533* Formats listed in the returned array should be listed in decreasing534* preference order (the core will try all formats until it finds one535* that works).536*537* This method is only called on the last element of the bridge chain538* as part of the bus format negotiation process that happens in539* &drm_atomic_bridge_chain_select_bus_fmts().540* This method is optional. When not implemented, the core will541* fall back to &drm_connector.display_info.bus_formats[0] if542* &drm_connector.display_info.num_bus_formats > 0,543* or to MEDIA_BUS_FMT_FIXED otherwise.544*/545u32 *(*atomic_get_output_bus_fmts)(struct drm_bridge *bridge,546struct drm_bridge_state *bridge_state,547struct drm_crtc_state *crtc_state,548struct drm_connector_state *conn_state,549unsigned int *num_output_fmts);550551/**552* @atomic_get_input_bus_fmts:553*554* Return the supported bus formats on the input end of a bridge for555* a specific output bus format.556*557* The returned array must be allocated with kmalloc() and will be558* freed by the caller. If the allocation fails, NULL should be559* returned. num_input_fmts must be set to the returned array size.560* Formats listed in the returned array should be listed in decreasing561* preference order (the core will try all formats until it finds one562* that works). When the format is not supported NULL should be563* returned and num_input_fmts should be set to 0.564*565* This method is called on all elements of the bridge chain as part of566* the bus format negotiation process that happens in567* drm_atomic_bridge_chain_select_bus_fmts().568* This method is optional. When not implemented, the core will bypass569* bus format negotiation on this element of the bridge without570* failing, and the previous element in the chain will be passed571* MEDIA_BUS_FMT_FIXED as its output bus format.572*573* Bridge drivers that need to support being linked to bridges that are574* not supporting bus format negotiation should handle the575* output_fmt == MEDIA_BUS_FMT_FIXED case appropriately, by selecting a576* sensible default value or extracting this information from somewhere577* else (FW property, &drm_display_mode, &drm_display_info, ...)578*579* Note: Even if input format selection on the first bridge has no580* impact on the negotiation process (bus format negotiation stops once581* we reach the first element of the chain), drivers are expected to582* return accurate input formats as the input format may be used to583* configure the CRTC output appropriately.584*/585u32 *(*atomic_get_input_bus_fmts)(struct drm_bridge *bridge,586struct drm_bridge_state *bridge_state,587struct drm_crtc_state *crtc_state,588struct drm_connector_state *conn_state,589u32 output_fmt,590unsigned int *num_input_fmts);591592/**593* @atomic_check:594*595* This method is responsible for checking bridge state correctness.596* It can also check the state of the surrounding components in chain597* to make sure the whole pipeline can work properly.598*599* &drm_bridge_funcs.atomic_check() hooks are called in reverse600* order (from the last to the first bridge).601*602* This method is optional. &drm_bridge_funcs.mode_fixup() is not603* called when &drm_bridge_funcs.atomic_check() is implemented, so only604* one of them should be provided.605*606* If drivers need to tweak &drm_bridge_state.input_bus_cfg.flags or607* &drm_bridge_state.output_bus_cfg.flags it should happen in608* this function. By default the &drm_bridge_state.output_bus_cfg.flags609* field is set to the next bridge610* &drm_bridge_state.input_bus_cfg.flags value or611* &drm_connector.display_info.bus_flags if the bridge is the last612* element in the chain.613*614* RETURNS:615* zero if the check passed, a negative error code otherwise.616*/617int (*atomic_check)(struct drm_bridge *bridge,618struct drm_bridge_state *bridge_state,619struct drm_crtc_state *crtc_state,620struct drm_connector_state *conn_state);621622/**623* @atomic_reset:624*625* Reset the bridge to a predefined state (or retrieve its current626* state) and return a &drm_bridge_state object matching this state.627* This function is called at attach time.628*629* The atomic_reset hook is mandatory if the bridge implements any of630* the atomic hooks, and should be left unassigned otherwise. For631* bridges that don't subclass &drm_bridge_state, the632* drm_atomic_helper_bridge_reset() helper function shall be used to633* implement this hook.634*635* Note that the atomic_reset() semantics is not exactly matching the636* reset() semantics found on other components (connector, plane, ...).637*638* 1. The reset operation happens when the bridge is attached, not when639* drm_mode_config_reset() is called640* 2. It's meant to be used exclusively on bridges that have been641* converted to the ATOMIC API642*643* RETURNS:644* A valid drm_bridge_state object in case of success, an ERR_PTR()645* giving the reason of the failure otherwise.646*/647struct drm_bridge_state *(*atomic_reset)(struct drm_bridge *bridge);648649/**650* @detect:651*652* Check if anything is attached to the bridge output.653*654* This callback is optional, if not implemented the bridge will be655* considered as always having a component attached to its output.656* Bridges that implement this callback shall set the657* DRM_BRIDGE_OP_DETECT flag in their &drm_bridge->ops.658*659* RETURNS:660*661* drm_connector_status indicating the bridge output status.662*/663enum drm_connector_status (*detect)(struct drm_bridge *bridge,664struct drm_connector *connector);665666/**667* @get_modes:668*669* Fill all modes currently valid for the sink into the &drm_connector670* with drm_mode_probed_add().671*672* The @get_modes callback is mostly intended to support non-probeable673* displays such as many fixed panels. Bridges that support reading674* EDID shall leave @get_modes unimplemented and implement the675* &drm_bridge_funcs->edid_read callback instead.676*677* This callback is optional. Bridges that implement it shall set the678* DRM_BRIDGE_OP_MODES flag in their &drm_bridge->ops.679*680* The connector parameter shall be used for the sole purpose of681* filling modes, and shall not be stored internally by bridge drivers682* for future usage.683*684* RETURNS:685*686* The number of modes added by calling drm_mode_probed_add().687*/688int (*get_modes)(struct drm_bridge *bridge,689struct drm_connector *connector);690691/**692* @edid_read:693*694* Read the EDID data of the connected display.695*696* The @edid_read callback is the preferred way of reporting mode697* information for a display connected to the bridge output. Bridges698* that support reading EDID shall implement this callback and leave699* the @get_modes callback unimplemented.700*701* The caller of this operation shall first verify the output702* connection status and refrain from reading EDID from a disconnected703* output.704*705* This callback is optional. Bridges that implement it shall set the706* DRM_BRIDGE_OP_EDID flag in their &drm_bridge->ops.707*708* The connector parameter shall be used for the sole purpose of EDID709* retrieval, and shall not be stored internally by bridge drivers for710* future usage.711*712* RETURNS:713*714* An edid structure newly allocated with drm_edid_alloc() or returned715* from drm_edid_read() family of functions on success, or NULL716* otherwise. The caller is responsible for freeing the returned edid717* structure with drm_edid_free().718*/719const struct drm_edid *(*edid_read)(struct drm_bridge *bridge,720struct drm_connector *connector);721722/**723* @hpd_notify:724*725* Notify the bridge of hot plug detection.726*727* This callback is optional, it may be implemented by bridges that728* need to be notified of display connection or disconnection for729* internal reasons. One use case is to reset the internal state of CEC730* controllers for HDMI bridges.731*/732void (*hpd_notify)(struct drm_bridge *bridge,733enum drm_connector_status status);734735/**736* @hpd_enable:737*738* Enable hot plug detection. From now on the bridge shall call739* drm_bridge_hpd_notify() each time a change is detected in the output740* connection status, until hot plug detection gets disabled with741* @hpd_disable.742*743* This callback is optional and shall only be implemented by bridges744* that support hot-plug notification without polling. Bridges that745* implement it shall also implement the @hpd_disable callback and set746* the DRM_BRIDGE_OP_HPD flag in their &drm_bridge->ops.747*/748void (*hpd_enable)(struct drm_bridge *bridge);749750/**751* @hpd_disable:752*753* Disable hot plug detection. Once this function returns the bridge754* shall not call drm_bridge_hpd_notify() when a change in the output755* connection status occurs.756*757* This callback is optional and shall only be implemented by bridges758* that support hot-plug notification without polling. Bridges that759* implement it shall also implement the @hpd_enable callback and set760* the DRM_BRIDGE_OP_HPD flag in their &drm_bridge->ops.761*/762void (*hpd_disable)(struct drm_bridge *bridge);763764/**765* @hdmi_tmds_char_rate_valid:766*767* Check whether a particular TMDS character rate is supported by the768* driver.769*770* This callback is optional and should only be implemented by the771* bridges that take part in the HDMI connector implementation. Bridges772* that implement it shall set the DRM_BRIDGE_OP_HDMI flag in their773* &drm_bridge->ops.774*775* Returns:776*777* Either &drm_mode_status.MODE_OK or one of the failure reasons778* in &enum drm_mode_status.779*/780enum drm_mode_status781(*hdmi_tmds_char_rate_valid)(const struct drm_bridge *bridge,782const struct drm_display_mode *mode,783unsigned long long tmds_rate);784785/**786* @hdmi_clear_infoframe:787*788* This callback clears the infoframes in the hardware during commit.789* It will be called multiple times, once for every disabled infoframe790* type.791*792* This callback is optional but it must be implemented by bridges that793* set the DRM_BRIDGE_OP_HDMI flag in their &drm_bridge->ops.794*/795int (*hdmi_clear_infoframe)(struct drm_bridge *bridge,796enum hdmi_infoframe_type type);797/**798* @hdmi_write_infoframe:799*800* Program the infoframe into the hardware. It will be called multiple801* times, once for every updated infoframe type.802*803* This callback is optional but it must be implemented by bridges that804* set the DRM_BRIDGE_OP_HDMI flag in their &drm_bridge->ops.805*/806int (*hdmi_write_infoframe)(struct drm_bridge *bridge,807enum hdmi_infoframe_type type,808const u8 *buffer, size_t len);809810/**811* @hdmi_audio_startup:812*813* Called when ASoC starts an audio stream setup.814*815* This callback is optional, it can be implemented by bridges that816* set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.817*818* Returns:819* 0 on success, a negative error code otherwise820*/821int (*hdmi_audio_startup)(struct drm_bridge *bridge,822struct drm_connector *connector);823824/**825* @hdmi_audio_prepare:826* Configures HDMI-encoder for audio stream. Can be called multiple827* times for each setup.828*829* This callback is optional but it must be implemented by bridges that830* set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.831*832* Returns:833* 0 on success, a negative error code otherwise834*/835int (*hdmi_audio_prepare)(struct drm_bridge *bridge,836struct drm_connector *connector,837struct hdmi_codec_daifmt *fmt,838struct hdmi_codec_params *hparms);839840/**841* @hdmi_audio_shutdown:842*843* Shut down the audio stream.844*845* This callback is optional but it must be implemented by bridges that846* set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.847*848* Returns:849* 0 on success, a negative error code otherwise850*/851void (*hdmi_audio_shutdown)(struct drm_bridge *bridge,852struct drm_connector *connector);853854/**855* @hdmi_audio_mute_stream:856*857* Mute/unmute HDMI audio stream.858*859* This callback is optional, it can be implemented by bridges that860* set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops.861*862* Returns:863* 0 on success, a negative error code otherwise864*/865int (*hdmi_audio_mute_stream)(struct drm_bridge *bridge,866struct drm_connector *connector,867bool enable, int direction);868869/**870* @hdmi_cec_init:871*872* Initialize CEC part of the bridge.873*874* This callback is optional, it can be implemented by bridges that875* set the @DRM_BRIDGE_OP_HDMI_CEC_ADAPTER flag in their876* &drm_bridge->ops.877*878* Returns:879* 0 on success, a negative error code otherwise880*/881int (*hdmi_cec_init)(struct drm_bridge *bridge,882struct drm_connector *connector);883884/**885* @hdmi_cec_enable:886*887* Enable or disable the CEC adapter inside the bridge.888*889* This callback is optional, it can be implemented by bridges that890* set the @DRM_BRIDGE_OP_HDMI_CEC_ADAPTER flag in their891* &drm_bridge->ops.892*893* Returns:894* 0 on success, a negative error code otherwise895*/896int (*hdmi_cec_enable)(struct drm_bridge *bridge, bool enable);897898/**899* @hdmi_cec_log_addr:900*901* Set the logical address of the CEC adapter inside the bridge.902*903* This callback is optional, it can be implemented by bridges that904* set the @DRM_BRIDGE_OP_HDMI_CEC_ADAPTER flag in their905* &drm_bridge->ops.906*907* Returns:908* 0 on success, a negative error code otherwise909*/910int (*hdmi_cec_log_addr)(struct drm_bridge *bridge, u8 logical_addr);911912/**913* @hdmi_cec_transmit:914*915* Transmit the message using the CEC adapter inside the bridge.916*917* This callback is optional, it can be implemented by bridges that918* set the @DRM_BRIDGE_OP_HDMI_CEC_ADAPTER flag in their919* &drm_bridge->ops.920*921* Returns:922* 0 on success, a negative error code otherwise923*/924int (*hdmi_cec_transmit)(struct drm_bridge *bridge, u8 attempts,925u32 signal_free_time, struct cec_msg *msg);926927/**928* @dp_audio_startup:929*930* Called when ASoC starts a DisplayPort audio stream setup.931*932* This callback is optional, it can be implemented by bridges that933* set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops.934*935* Returns:936* 0 on success, a negative error code otherwise937*/938int (*dp_audio_startup)(struct drm_bridge *bridge,939struct drm_connector *connector);940941/**942* @dp_audio_prepare:943* Configures DisplayPort audio stream. Can be called multiple944* times for each setup.945*946* This callback is optional but it must be implemented by bridges that947* set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops.948*949* Returns:950* 0 on success, a negative error code otherwise951*/952int (*dp_audio_prepare)(struct drm_bridge *bridge,953struct drm_connector *connector,954struct hdmi_codec_daifmt *fmt,955struct hdmi_codec_params *hparms);956957/**958* @dp_audio_shutdown:959*960* Shut down the DisplayPort audio stream.961*962* This callback is optional but it must be implemented by bridges that963* set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops.964*965* Returns:966* 0 on success, a negative error code otherwise967*/968void (*dp_audio_shutdown)(struct drm_bridge *bridge,969struct drm_connector *connector);970971/**972* @dp_audio_mute_stream:973*974* Mute/unmute DisplayPort audio stream.975*976* This callback is optional, it can be implemented by bridges that977* set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops.978*979* Returns:980* 0 on success, a negative error code otherwise981*/982int (*dp_audio_mute_stream)(struct drm_bridge *bridge,983struct drm_connector *connector,984bool enable, int direction);985986/**987* @debugfs_init:988*989* Allows bridges to create bridge-specific debugfs files.990*/991void (*debugfs_init)(struct drm_bridge *bridge, struct dentry *root);992};993994/**995* struct drm_bridge_timings - timing information for the bridge996*/997struct drm_bridge_timings {998/**999* @input_bus_flags:1000*1001* Tells what additional settings for the pixel data on the bus1002* this bridge requires (like pixel signal polarity). See also1003* &drm_display_info->bus_flags.1004*/1005u32 input_bus_flags;1006/**1007* @setup_time_ps:1008*1009* Defines the time in picoseconds the input data lines must be1010* stable before the clock edge.1011*/1012u32 setup_time_ps;1013/**1014* @hold_time_ps:1015*1016* Defines the time in picoseconds taken for the bridge to sample the1017* input signal after the clock edge.1018*/1019u32 hold_time_ps;1020/**1021* @dual_link:1022*1023* True if the bus operates in dual-link mode. The exact meaning is1024* dependent on the bus type. For LVDS buses, this indicates that even-1025* and odd-numbered pixels are received on separate links.1026*/1027bool dual_link;1028};10291030/**1031* enum drm_bridge_ops - Bitmask of operations supported by the bridge1032*/1033enum drm_bridge_ops {1034/**1035* @DRM_BRIDGE_OP_DETECT: The bridge can detect displays connected to1036* its output. Bridges that set this flag shall implement the1037* &drm_bridge_funcs->detect callback.1038*/1039DRM_BRIDGE_OP_DETECT = BIT(0),1040/**1041* @DRM_BRIDGE_OP_EDID: The bridge can retrieve the EDID of the display1042* connected to its output. Bridges that set this flag shall implement1043* the &drm_bridge_funcs->edid_read callback.1044*/1045DRM_BRIDGE_OP_EDID = BIT(1),1046/**1047* @DRM_BRIDGE_OP_HPD: The bridge can detect hot-plug and hot-unplug1048* without requiring polling. Bridges that set this flag shall1049* implement the &drm_bridge_funcs->hpd_enable and1050* &drm_bridge_funcs->hpd_disable callbacks if they support enabling1051* and disabling hot-plug detection dynamically.1052*/1053DRM_BRIDGE_OP_HPD = BIT(2),1054/**1055* @DRM_BRIDGE_OP_MODES: The bridge can retrieve the modes supported1056* by the display at its output. This does not include reading EDID1057* which is separately covered by @DRM_BRIDGE_OP_EDID. Bridges that set1058* this flag shall implement the &drm_bridge_funcs->get_modes callback.1059*/1060DRM_BRIDGE_OP_MODES = BIT(3),1061/**1062* @DRM_BRIDGE_OP_HDMI: The bridge provides HDMI connector operations,1063* including infoframes support. Bridges that set this flag must1064* implement the &drm_bridge_funcs->write_infoframe callback.1065*1066* Note: currently there can be at most one bridge in a chain that sets1067* this bit. This is to simplify corresponding glue code in connector1068* drivers.1069*/1070DRM_BRIDGE_OP_HDMI = BIT(4),1071/**1072* @DRM_BRIDGE_OP_HDMI_AUDIO: The bridge provides HDMI audio operations.1073* Bridges that set this flag must implement the1074* &drm_bridge_funcs->hdmi_audio_prepare and1075* &drm_bridge_funcs->hdmi_audio_shutdown callbacks.1076*1077* Note: currently there can be at most one bridge in a chain that sets1078* this bit. This is to simplify corresponding glue code in connector1079* drivers. Also it is not possible to have a bridge in the chain that1080* sets @DRM_BRIDGE_OP_DP_AUDIO if there is a bridge that sets this1081* flag.1082*/1083DRM_BRIDGE_OP_HDMI_AUDIO = BIT(5),1084/**1085* @DRM_BRIDGE_OP_DP_AUDIO: The bridge provides DisplayPort audio operations.1086* Bridges that set this flag must implement the1087* &drm_bridge_funcs->dp_audio_prepare and1088* &drm_bridge_funcs->dp_audio_shutdown callbacks.1089*1090* Note: currently there can be at most one bridge in a chain that sets1091* this bit. This is to simplify corresponding glue code in connector1092* drivers. Also it is not possible to have a bridge in the chain that1093* sets @DRM_BRIDGE_OP_HDMI_AUDIO if there is a bridge that sets this1094* flag.1095*/1096DRM_BRIDGE_OP_DP_AUDIO = BIT(6),1097/**1098* @DRM_BRIDGE_OP_HDMI_CEC_NOTIFIER: The bridge requires CEC notifier1099* to be present.1100*/1101DRM_BRIDGE_OP_HDMI_CEC_NOTIFIER = BIT(7),1102/**1103* @DRM_BRIDGE_OP_HDMI_CEC_ADAPTER: The bridge requires CEC adapter1104* to be present.1105*/1106DRM_BRIDGE_OP_HDMI_CEC_ADAPTER = BIT(8),1107};11081109/**1110* struct drm_bridge - central DRM bridge control structure1111*/1112struct drm_bridge {1113/** @base: inherit from &drm_private_object */1114struct drm_private_obj base;1115/** @dev: DRM device this bridge belongs to */1116struct drm_device *dev;1117/** @encoder: encoder to which this bridge is connected */1118struct drm_encoder *encoder;1119/** @chain_node: used to form a bridge chain */1120struct list_head chain_node;1121/** @of_node: device node pointer to the bridge */1122struct device_node *of_node;1123/** @list: to keep track of all added bridges */1124struct list_head list;1125/**1126* @timings:1127*1128* the timing specification for the bridge, if any (may be NULL)1129*/1130const struct drm_bridge_timings *timings;1131/** @funcs: control functions */1132const struct drm_bridge_funcs *funcs;11331134/**1135* @container: Pointer to the private driver struct embedding this1136* @struct drm_bridge.1137*/1138void *container;11391140/**1141* @refcount: reference count of users referencing this bridge.1142*/1143struct kref refcount;11441145/** @driver_private: pointer to the bridge driver's internal context */1146void *driver_private;1147/** @ops: bitmask of operations supported by the bridge */1148enum drm_bridge_ops ops;1149/**1150* @type: Type of the connection at the bridge output1151* (DRM_MODE_CONNECTOR_*). For bridges at the end of this chain this1152* identifies the type of connected display.1153*/1154int type;1155/**1156* @interlace_allowed: Indicate that the bridge can handle interlaced1157* modes.1158*/1159bool interlace_allowed;1160/**1161* @ycbcr_420_allowed: Indicate that the bridge can handle YCbCr 4201162* output.1163*/1164bool ycbcr_420_allowed;1165/**1166* @pre_enable_prev_first: The bridge requires that the prev1167* bridge @pre_enable function is called before its @pre_enable,1168* and conversely for post_disable. This is most frequently a1169* requirement for DSI devices which need the host to be initialised1170* before the peripheral.1171*/1172bool pre_enable_prev_first;1173/**1174* @support_hdcp: Indicate that the bridge supports HDCP.1175*/1176bool support_hdcp;1177/**1178* @ddc: Associated I2C adapter for DDC access, if any.1179*/1180struct i2c_adapter *ddc;11811182/**1183* @vendor: Vendor of the product to be used for the SPD InfoFrame1184* generation. This is required if @DRM_BRIDGE_OP_HDMI is set.1185*/1186const char *vendor;11871188/**1189* @product: Name of the product to be used for the SPD InfoFrame1190* generation. This is required if @DRM_BRIDGE_OP_HDMI is set.1191*/1192const char *product;11931194/**1195* @supported_formats: Bitmask of @hdmi_colorspace listing supported1196* output formats. This is only relevant if @DRM_BRIDGE_OP_HDMI is set.1197*/1198unsigned int supported_formats;11991200/**1201* @max_bpc: Maximum bits per char the HDMI bridge supports. Allowed1202* values are 8, 10 and 12. This is only relevant if1203* @DRM_BRIDGE_OP_HDMI is set.1204*/1205unsigned int max_bpc;12061207/**1208* @hdmi_cec_dev: device to be used as a containing device for CEC1209* functions.1210*/1211struct device *hdmi_cec_dev;12121213/**1214* @hdmi_audio_dev: device to be used as a parent for the HDMI Codec if1215* either of @DRM_BRIDGE_OP_HDMI_AUDIO or @DRM_BRIDGE_OP_DP_AUDIO is set.1216*/1217struct device *hdmi_audio_dev;12181219/**1220* @hdmi_audio_max_i2s_playback_channels: maximum number of playback1221* I2S channels for the @DRM_BRIDGE_OP_HDMI_AUDIO or1222* @DRM_BRIDGE_OP_DP_AUDIO.1223*/1224int hdmi_audio_max_i2s_playback_channels;12251226/**1227* @hdmi_audio_i2s_formats: supported I2S formats, optional. The1228* default is to allow all formats supported by the corresponding I2S1229* bus driver. This is only used for bridges setting1230* @DRM_BRIDGE_OP_HDMI_AUDIO or @DRM_BRIDGE_OP_DP_AUDIO.1231*/1232u64 hdmi_audio_i2s_formats;12331234/**1235* @hdmi_audio_spdif_playback: set if this bridge has S/PDIF playback1236* port for @DRM_BRIDGE_OP_HDMI_AUDIO or @DRM_BRIDGE_OP_DP_AUDIO.1237*/1238unsigned int hdmi_audio_spdif_playback : 1;12391240/**1241* @hdmi_audio_dai_port: sound DAI port for either of1242* @DRM_BRIDGE_OP_HDMI_AUDIO and @DRM_BRIDGE_OP_DP_AUDIO, -1 if it is1243* not used.1244*/1245int hdmi_audio_dai_port;12461247/**1248* @hdmi_cec_adapter_name: the name of the adapter to register1249*/1250const char *hdmi_cec_adapter_name;12511252/**1253* @hdmi_cec_available_las: number of logical addresses, CEC_MAX_LOG_ADDRS if unset1254*/1255u8 hdmi_cec_available_las;12561257/** private: */1258/**1259* @hpd_mutex: Protects the @hpd_cb and @hpd_data fields.1260*/1261struct mutex hpd_mutex;1262/**1263* @hpd_cb: Hot plug detection callback, registered with1264* drm_bridge_hpd_enable().1265*/1266void (*hpd_cb)(void *data, enum drm_connector_status status);1267/**1268* @hpd_data: Private data passed to the Hot plug detection callback1269* @hpd_cb.1270*/1271void *hpd_data;1272};12731274static inline struct drm_bridge *1275drm_priv_to_bridge(struct drm_private_obj *priv)1276{1277return container_of(priv, struct drm_bridge, base);1278}12791280struct drm_bridge *drm_bridge_get(struct drm_bridge *bridge);1281void drm_bridge_put(struct drm_bridge *bridge);12821283/* Cleanup action for use with __free() */1284DEFINE_FREE(drm_bridge_put, struct drm_bridge *, if (_T) drm_bridge_put(_T))12851286void *__devm_drm_bridge_alloc(struct device *dev, size_t size, size_t offset,1287const struct drm_bridge_funcs *funcs);12881289/**1290* devm_drm_bridge_alloc - Allocate and initialize a bridge1291* @dev: struct device of the bridge device1292* @type: the type of the struct which contains struct &drm_bridge1293* @member: the name of the &drm_bridge within @type1294* @funcs: callbacks for this bridge1295*1296* The reference count of the returned bridge is initialized to 1. This1297* reference will be automatically dropped via devm (by calling1298* drm_bridge_put()) when @dev is removed.1299*1300* Returns:1301* Pointer to new bridge, or ERR_PTR on failure.1302*/1303#define devm_drm_bridge_alloc(dev, type, member, funcs) \1304((type *)__devm_drm_bridge_alloc(dev, sizeof(type), \1305offsetof(type, member), funcs))13061307void drm_bridge_add(struct drm_bridge *bridge);1308int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge);1309void drm_bridge_remove(struct drm_bridge *bridge);1310int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,1311struct drm_bridge *previous,1312enum drm_bridge_attach_flags flags);13131314#ifdef CONFIG_OF1315struct drm_bridge *of_drm_find_bridge(struct device_node *np);1316#else1317static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np)1318{1319return NULL;1320}1321#endif13221323static inline bool drm_bridge_is_last(struct drm_bridge *bridge)1324{1325return list_is_last(&bridge->chain_node, &bridge->encoder->bridge_chain);1326}13271328/**1329* drm_bridge_get_current_state() - Get the current bridge state1330* @bridge: bridge object1331*1332* This function must be called with the modeset lock held.1333*1334* RETURNS:1335*1336* The current bridge state, or NULL if there is none.1337*/1338static inline struct drm_bridge_state *1339drm_bridge_get_current_state(struct drm_bridge *bridge)1340{1341if (!bridge)1342return NULL;13431344/*1345* Only atomic bridges will have bridge->base initialized by1346* drm_atomic_private_obj_init(), so we need to make sure we're1347* working with one before we try to use the lock.1348*/1349if (!bridge->funcs || !bridge->funcs->atomic_reset)1350return NULL;13511352drm_modeset_lock_assert_held(&bridge->base.lock);13531354if (!bridge->base.state)1355return NULL;13561357return drm_priv_to_bridge_state(bridge->base.state);1358}13591360/**1361* drm_bridge_get_next_bridge() - Get the next bridge in the chain1362* @bridge: bridge object1363*1364* RETURNS:1365* the next bridge in the chain after @bridge, or NULL if @bridge is the last.1366*/1367static inline struct drm_bridge *1368drm_bridge_get_next_bridge(struct drm_bridge *bridge)1369{1370if (list_is_last(&bridge->chain_node, &bridge->encoder->bridge_chain))1371return NULL;13721373return list_next_entry(bridge, chain_node);1374}13751376/**1377* drm_bridge_get_prev_bridge() - Get the previous bridge in the chain1378* @bridge: bridge object1379*1380* The caller is responsible of having a reference to @bridge via1381* drm_bridge_get() or equivalent. This function leaves the refcount of1382* @bridge unmodified.1383*1384* The refcount of the returned bridge is incremented. Use drm_bridge_put()1385* when done with it.1386*1387* RETURNS:1388* the previous bridge in the chain, or NULL if @bridge is the first.1389*/1390static inline struct drm_bridge *1391drm_bridge_get_prev_bridge(struct drm_bridge *bridge)1392{1393if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain))1394return NULL;13951396return drm_bridge_get(list_prev_entry(bridge, chain_node));1397}13981399/**1400* drm_bridge_chain_get_first_bridge() - Get the first bridge in the chain1401* @encoder: encoder object1402*1403* The refcount of the returned bridge is incremented. Use drm_bridge_put()1404* when done with it.1405*1406* RETURNS:1407* the first bridge in the chain, or NULL if @encoder has no bridge attached1408* to it.1409*/1410static inline struct drm_bridge *1411drm_bridge_chain_get_first_bridge(struct drm_encoder *encoder)1412{1413return drm_bridge_get(list_first_entry_or_null(&encoder->bridge_chain,1414struct drm_bridge, chain_node));1415}14161417/**1418* drm_bridge_chain_get_last_bridge() - Get the last bridge in the chain1419* @encoder: encoder object1420*1421* The refcount of the returned bridge is incremented. Use drm_bridge_put()1422* when done with it.1423*1424* RETURNS:1425* the last bridge in the chain, or NULL if @encoder has no bridge attached1426* to it.1427*/1428static inline struct drm_bridge *1429drm_bridge_chain_get_last_bridge(struct drm_encoder *encoder)1430{1431return drm_bridge_get(list_last_entry_or_null(&encoder->bridge_chain,1432struct drm_bridge, chain_node));1433}14341435/**1436* drm_for_each_bridge_in_chain() - Iterate over all bridges present in a chain1437* @encoder: the encoder to iterate bridges on1438* @bridge: a bridge pointer updated to point to the current bridge at each1439* iteration1440*1441* Iterate over all bridges present in the bridge chain attached to @encoder.1442*/1443#define drm_for_each_bridge_in_chain(encoder, bridge) \1444list_for_each_entry(bridge, &(encoder)->bridge_chain, chain_node)14451446enum drm_mode_status1447drm_bridge_chain_mode_valid(struct drm_bridge *bridge,1448const struct drm_display_info *info,1449const struct drm_display_mode *mode);1450void drm_bridge_chain_mode_set(struct drm_bridge *bridge,1451const struct drm_display_mode *mode,1452const struct drm_display_mode *adjusted_mode);14531454int drm_atomic_bridge_chain_check(struct drm_bridge *bridge,1455struct drm_crtc_state *crtc_state,1456struct drm_connector_state *conn_state);1457void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge,1458struct drm_atomic_state *state);1459void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,1460struct drm_atomic_state *state);1461void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,1462struct drm_atomic_state *state);1463void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge,1464struct drm_atomic_state *state);14651466u32 *1467drm_atomic_helper_bridge_propagate_bus_fmt(struct drm_bridge *bridge,1468struct drm_bridge_state *bridge_state,1469struct drm_crtc_state *crtc_state,1470struct drm_connector_state *conn_state,1471u32 output_fmt,1472unsigned int *num_input_fmts);14731474enum drm_connector_status1475drm_bridge_detect(struct drm_bridge *bridge, struct drm_connector *connector);1476int drm_bridge_get_modes(struct drm_bridge *bridge,1477struct drm_connector *connector);1478const struct drm_edid *drm_bridge_edid_read(struct drm_bridge *bridge,1479struct drm_connector *connector);1480void drm_bridge_hpd_enable(struct drm_bridge *bridge,1481void (*cb)(void *data,1482enum drm_connector_status status),1483void *data);1484void drm_bridge_hpd_disable(struct drm_bridge *bridge);1485void drm_bridge_hpd_notify(struct drm_bridge *bridge,1486enum drm_connector_status status);14871488#ifdef CONFIG_DRM_PANEL_BRIDGE1489bool drm_bridge_is_panel(const struct drm_bridge *bridge);1490struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel);1491struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel,1492u32 connector_type);1493void drm_panel_bridge_remove(struct drm_bridge *bridge);1494int drm_panel_bridge_set_orientation(struct drm_connector *connector,1495struct drm_bridge *bridge);1496struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev,1497struct drm_panel *panel);1498struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev,1499struct drm_panel *panel,1500u32 connector_type);1501struct drm_bridge *drmm_panel_bridge_add(struct drm_device *drm,1502struct drm_panel *panel);1503struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge);1504#else1505static inline bool drm_bridge_is_panel(const struct drm_bridge *bridge)1506{1507return false;1508}15091510static inline int drm_panel_bridge_set_orientation(struct drm_connector *connector,1511struct drm_bridge *bridge)1512{1513return -EINVAL;1514}1515#endif15161517#if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL_BRIDGE)1518struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node *node,1519u32 port, u32 endpoint);1520struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, struct device_node *node,1521u32 port, u32 endpoint);1522#else1523static inline struct drm_bridge *devm_drm_of_get_bridge(struct device *dev,1524struct device_node *node,1525u32 port,1526u32 endpoint)1527{1528return ERR_PTR(-ENODEV);1529}15301531static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm,1532struct device_node *node,1533u32 port,1534u32 endpoint)1535{1536return ERR_PTR(-ENODEV);1537}1538#endif15391540void devm_drm_put_bridge(struct device *dev, struct drm_bridge *bridge);15411542void drm_bridge_debugfs_params(struct dentry *root);1543void drm_bridge_debugfs_encoder_params(struct dentry *root, struct drm_encoder *encoder);15441545#endif154615471548