1 1.1 riastrad /* $NetBSD: drm_bridge.h,v 1.2 2021/12/18 23:45:45 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright (c) 2016 Intel Corporation 5 1.1 riastrad * 6 1.1 riastrad * Permission to use, copy, modify, distribute, and sell this software and its 7 1.1 riastrad * documentation for any purpose is hereby granted without fee, provided that 8 1.1 riastrad * the above copyright notice appear in all copies and that both that copyright 9 1.1 riastrad * notice and this permission notice appear in supporting documentation, and 10 1.1 riastrad * that the name of the copyright holders not be used in advertising or 11 1.1 riastrad * publicity pertaining to distribution of the software without specific, 12 1.1 riastrad * written prior permission. The copyright holders make no representations 13 1.1 riastrad * about the suitability of this software for any purpose. It is provided "as 14 1.1 riastrad * is" without express or implied warranty. 15 1.1 riastrad * 16 1.1 riastrad * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 17 1.1 riastrad * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 18 1.1 riastrad * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 19 1.1 riastrad * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 20 1.1 riastrad * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 21 1.1 riastrad * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 22 1.1 riastrad * OF THIS SOFTWARE. 23 1.1 riastrad */ 24 1.1 riastrad 25 1.1 riastrad #ifndef __DRM_BRIDGE_H__ 26 1.1 riastrad #define __DRM_BRIDGE_H__ 27 1.1 riastrad 28 1.1 riastrad #include <linux/list.h> 29 1.1 riastrad #include <linux/ctype.h> 30 1.1 riastrad #include <drm/drm_encoder.h> 31 1.1 riastrad #include <drm/drm_mode_object.h> 32 1.1 riastrad #include <drm/drm_modes.h> 33 1.1 riastrad 34 1.1 riastrad struct drm_bridge; 35 1.1 riastrad struct drm_bridge_timings; 36 1.1 riastrad struct drm_panel; 37 1.1 riastrad 38 1.1 riastrad /** 39 1.1 riastrad * struct drm_bridge_funcs - drm_bridge control functions 40 1.1 riastrad */ 41 1.1 riastrad struct drm_bridge_funcs { 42 1.1 riastrad /** 43 1.1 riastrad * @attach: 44 1.1 riastrad * 45 1.1 riastrad * This callback is invoked whenever our bridge is being attached to a 46 1.1 riastrad * &drm_encoder. 47 1.1 riastrad * 48 1.1 riastrad * The @attach callback is optional. 49 1.1 riastrad * 50 1.1 riastrad * RETURNS: 51 1.1 riastrad * 52 1.1 riastrad * Zero on success, error code on failure. 53 1.1 riastrad */ 54 1.1 riastrad int (*attach)(struct drm_bridge *bridge); 55 1.1 riastrad 56 1.1 riastrad /** 57 1.1 riastrad * @detach: 58 1.1 riastrad * 59 1.1 riastrad * This callback is invoked whenever our bridge is being detached from a 60 1.1 riastrad * &drm_encoder. 61 1.1 riastrad * 62 1.1 riastrad * The @detach callback is optional. 63 1.1 riastrad */ 64 1.1 riastrad void (*detach)(struct drm_bridge *bridge); 65 1.1 riastrad 66 1.1 riastrad /** 67 1.1 riastrad * @mode_valid: 68 1.1 riastrad * 69 1.1 riastrad * This callback is used to check if a specific mode is valid in this 70 1.1 riastrad * bridge. This should be implemented if the bridge has some sort of 71 1.1 riastrad * restriction in the modes it can display. For example, a given bridge 72 1.1 riastrad * may be responsible to set a clock value. If the clock can not 73 1.1 riastrad * produce all the values for the available modes then this callback 74 1.1 riastrad * can be used to restrict the number of modes to only the ones that 75 1.1 riastrad * can be displayed. 76 1.1 riastrad * 77 1.1 riastrad * This hook is used by the probe helpers to filter the mode list in 78 1.1 riastrad * drm_helper_probe_single_connector_modes(), and it is used by the 79 1.1 riastrad * atomic helpers to validate modes supplied by userspace in 80 1.1 riastrad * drm_atomic_helper_check_modeset(). 81 1.1 riastrad * 82 1.1 riastrad * The @mode_valid callback is optional. 83 1.1 riastrad * 84 1.1 riastrad * NOTE: 85 1.1 riastrad * 86 1.1 riastrad * Since this function is both called from the check phase of an atomic 87 1.1 riastrad * commit, and the mode validation in the probe paths it is not allowed 88 1.1 riastrad * to look at anything else but the passed-in mode, and validate it 89 1.1 riastrad * against configuration-invariant hardward constraints. Any further 90 1.1 riastrad * limits which depend upon the configuration can only be checked in 91 1.1 riastrad * @mode_fixup. 92 1.1 riastrad * 93 1.1 riastrad * RETURNS: 94 1.1 riastrad * 95 1.1 riastrad * drm_mode_status Enum 96 1.1 riastrad */ 97 1.1 riastrad enum drm_mode_status (*mode_valid)(struct drm_bridge *bridge, 98 1.1 riastrad const struct drm_display_mode *mode); 99 1.1 riastrad 100 1.1 riastrad /** 101 1.1 riastrad * @mode_fixup: 102 1.1 riastrad * 103 1.1 riastrad * This callback is used to validate and adjust a mode. The parameter 104 1.1 riastrad * mode is the display mode that should be fed to the next element in 105 1.1 riastrad * the display chain, either the final &drm_connector or the next 106 1.1 riastrad * &drm_bridge. The parameter adjusted_mode is the input mode the bridge 107 1.1 riastrad * requires. It can be modified by this callback and does not need to 108 1.1 riastrad * match mode. See also &drm_crtc_state.adjusted_mode for more details. 109 1.1 riastrad * 110 1.1 riastrad * This is the only hook that allows a bridge to reject a modeset. If 111 1.1 riastrad * this function passes all other callbacks must succeed for this 112 1.1 riastrad * configuration. 113 1.1 riastrad * 114 1.1 riastrad * The @mode_fixup callback is optional. 115 1.1 riastrad * 116 1.1 riastrad * NOTE: 117 1.1 riastrad * 118 1.1 riastrad * This function is called in the check phase of atomic modesets, which 119 1.1 riastrad * can be aborted for any reason (including on userspace's request to 120 1.1 riastrad * just check whether a configuration would be possible). Drivers MUST 121 1.1 riastrad * NOT touch any persistent state (hardware or software) or data 122 1.1 riastrad * structures except the passed in @state parameter. 123 1.1 riastrad * 124 1.1 riastrad * Also beware that userspace can request its own custom modes, neither 125 1.1 riastrad * core nor helpers filter modes to the list of probe modes reported by 126 1.1 riastrad * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure 127 1.1 riastrad * that modes are filtered consistently put any bridge constraints and 128 1.1 riastrad * limits checks into @mode_valid. 129 1.1 riastrad * 130 1.1 riastrad * RETURNS: 131 1.1 riastrad * 132 1.1 riastrad * True if an acceptable configuration is possible, false if the modeset 133 1.1 riastrad * operation should be rejected. 134 1.1 riastrad */ 135 1.1 riastrad bool (*mode_fixup)(struct drm_bridge *bridge, 136 1.1 riastrad const struct drm_display_mode *mode, 137 1.1 riastrad struct drm_display_mode *adjusted_mode); 138 1.1 riastrad /** 139 1.1 riastrad * @disable: 140 1.1 riastrad * 141 1.1 riastrad * This callback should disable the bridge. It is called right before 142 1.1 riastrad * the preceding element in the display pipe is disabled. If the 143 1.1 riastrad * preceding element is a bridge this means it's called before that 144 1.1 riastrad * bridge's @disable vfunc. If the preceding element is a &drm_encoder 145 1.1 riastrad * it's called right before the &drm_encoder_helper_funcs.disable, 146 1.1 riastrad * &drm_encoder_helper_funcs.prepare or &drm_encoder_helper_funcs.dpms 147 1.1 riastrad * hook. 148 1.1 riastrad * 149 1.1 riastrad * The bridge can assume that the display pipe (i.e. clocks and timing 150 1.1 riastrad * signals) feeding it is still running when this callback is called. 151 1.1 riastrad * 152 1.1 riastrad * The @disable callback is optional. 153 1.1 riastrad */ 154 1.1 riastrad void (*disable)(struct drm_bridge *bridge); 155 1.1 riastrad 156 1.1 riastrad /** 157 1.1 riastrad * @post_disable: 158 1.1 riastrad * 159 1.1 riastrad * This callback should disable the bridge. It is called right after the 160 1.1 riastrad * preceding element in the display pipe is disabled. If the preceding 161 1.1 riastrad * element is a bridge this means it's called after that bridge's 162 1.1 riastrad * @post_disable function. If the preceding element is a &drm_encoder 163 1.1 riastrad * it's called right after the encoder's 164 1.1 riastrad * &drm_encoder_helper_funcs.disable, &drm_encoder_helper_funcs.prepare 165 1.1 riastrad * or &drm_encoder_helper_funcs.dpms hook. 166 1.1 riastrad * 167 1.1 riastrad * The bridge must assume that the display pipe (i.e. clocks and timing 168 1.1 riastrad * singals) feeding it is no longer running when this callback is 169 1.1 riastrad * called. 170 1.1 riastrad * 171 1.1 riastrad * The @post_disable callback is optional. 172 1.1 riastrad */ 173 1.1 riastrad void (*post_disable)(struct drm_bridge *bridge); 174 1.1 riastrad 175 1.1 riastrad /** 176 1.1 riastrad * @mode_set: 177 1.1 riastrad * 178 1.1 riastrad * This callback should set the given mode on the bridge. It is called 179 1.1 riastrad * after the @mode_set callback for the preceding element in the display 180 1.1 riastrad * pipeline has been called already. If the bridge is the first element 181 1.1 riastrad * then this would be &drm_encoder_helper_funcs.mode_set. The display 182 1.1 riastrad * pipe (i.e. clocks and timing signals) is off when this function is 183 1.1 riastrad * called. 184 1.1 riastrad * 185 1.1 riastrad * The adjusted_mode parameter is the mode output by the CRTC for the 186 1.1 riastrad * first bridge in the chain. It can be different from the mode 187 1.1 riastrad * parameter that contains the desired mode for the connector at the end 188 1.1 riastrad * of the bridges chain, for instance when the first bridge in the chain 189 1.1 riastrad * performs scaling. The adjusted mode is mostly useful for the first 190 1.1 riastrad * bridge in the chain and is likely irrelevant for the other bridges. 191 1.1 riastrad * 192 1.1 riastrad * For atomic drivers the adjusted_mode is the mode stored in 193 1.1 riastrad * &drm_crtc_state.adjusted_mode. 194 1.1 riastrad * 195 1.1 riastrad * NOTE: 196 1.1 riastrad * 197 1.1 riastrad * If a need arises to store and access modes adjusted for other 198 1.1 riastrad * locations than the connection between the CRTC and the first bridge, 199 1.1 riastrad * the DRM framework will have to be extended with DRM bridge states. 200 1.1 riastrad */ 201 1.1 riastrad void (*mode_set)(struct drm_bridge *bridge, 202 1.1 riastrad const struct drm_display_mode *mode, 203 1.1 riastrad const struct drm_display_mode *adjusted_mode); 204 1.1 riastrad /** 205 1.1 riastrad * @pre_enable: 206 1.1 riastrad * 207 1.1 riastrad * This callback should enable the bridge. It is called right before 208 1.1 riastrad * the preceding element in the display pipe is enabled. If the 209 1.1 riastrad * preceding element is a bridge this means it's called before that 210 1.1 riastrad * bridge's @pre_enable function. If the preceding element is a 211 1.1 riastrad * &drm_encoder it's called right before the encoder's 212 1.1 riastrad * &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or 213 1.1 riastrad * &drm_encoder_helper_funcs.dpms hook. 214 1.1 riastrad * 215 1.1 riastrad * The display pipe (i.e. clocks and timing signals) feeding this bridge 216 1.1 riastrad * will not yet be running when this callback is called. The bridge must 217 1.1 riastrad * not enable the display link feeding the next bridge in the chain (if 218 1.1 riastrad * there is one) when this callback is called. 219 1.1 riastrad * 220 1.1 riastrad * The @pre_enable callback is optional. 221 1.1 riastrad */ 222 1.1 riastrad void (*pre_enable)(struct drm_bridge *bridge); 223 1.1 riastrad 224 1.1 riastrad /** 225 1.1 riastrad * @enable: 226 1.1 riastrad * 227 1.1 riastrad * This callback should enable the bridge. It is called right after 228 1.1 riastrad * the preceding element in the display pipe is enabled. If the 229 1.1 riastrad * preceding element is a bridge this means it's called after that 230 1.1 riastrad * bridge's @enable function. If the preceding element is a 231 1.1 riastrad * &drm_encoder it's called right after the encoder's 232 1.1 riastrad * &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or 233 1.1 riastrad * &drm_encoder_helper_funcs.dpms hook. 234 1.1 riastrad * 235 1.1 riastrad * The bridge can assume that the display pipe (i.e. clocks and timing 236 1.1 riastrad * signals) feeding it is running when this callback is called. This 237 1.1 riastrad * callback must enable the display link feeding the next bridge in the 238 1.1 riastrad * chain if there is one. 239 1.1 riastrad * 240 1.1 riastrad * The @enable callback is optional. 241 1.1 riastrad */ 242 1.1 riastrad void (*enable)(struct drm_bridge *bridge); 243 1.1 riastrad 244 1.1 riastrad /** 245 1.1 riastrad * @atomic_pre_enable: 246 1.1 riastrad * 247 1.1 riastrad * This callback should enable the bridge. It is called right before 248 1.1 riastrad * the preceding element in the display pipe is enabled. If the 249 1.1 riastrad * preceding element is a bridge this means it's called before that 250 1.1 riastrad * bridge's @atomic_pre_enable or @pre_enable function. If the preceding 251 1.1 riastrad * element is a &drm_encoder it's called right before the encoder's 252 1.1 riastrad * &drm_encoder_helper_funcs.atomic_enable hook. 253 1.1 riastrad * 254 1.1 riastrad * The display pipe (i.e. clocks and timing signals) feeding this bridge 255 1.1 riastrad * will not yet be running when this callback is called. The bridge must 256 1.1 riastrad * not enable the display link feeding the next bridge in the chain (if 257 1.1 riastrad * there is one) when this callback is called. 258 1.1 riastrad * 259 1.1 riastrad * Note that this function will only be invoked in the context of an 260 1.1 riastrad * atomic commit. It will not be invoked from 261 1.1 riastrad * &drm_bridge_chain_pre_enable. It would be prudent to also provide an 262 1.1 riastrad * implementation of @pre_enable if you are expecting driver calls into 263 1.1 riastrad * &drm_bridge_chain_pre_enable. 264 1.1 riastrad * 265 1.1 riastrad * The @atomic_pre_enable callback is optional. 266 1.1 riastrad */ 267 1.1 riastrad void (*atomic_pre_enable)(struct drm_bridge *bridge, 268 1.1 riastrad struct drm_atomic_state *old_state); 269 1.1 riastrad 270 1.1 riastrad /** 271 1.1 riastrad * @atomic_enable: 272 1.1 riastrad * 273 1.1 riastrad * This callback should enable the bridge. It is called right after 274 1.1 riastrad * the preceding element in the display pipe is enabled. If the 275 1.1 riastrad * preceding element is a bridge this means it's called after that 276 1.1 riastrad * bridge's @atomic_enable or @enable function. If the preceding element 277 1.1 riastrad * is a &drm_encoder it's called right after the encoder's 278 1.1 riastrad * &drm_encoder_helper_funcs.atomic_enable hook. 279 1.1 riastrad * 280 1.1 riastrad * The bridge can assume that the display pipe (i.e. clocks and timing 281 1.1 riastrad * signals) feeding it is running when this callback is called. This 282 1.1 riastrad * callback must enable the display link feeding the next bridge in the 283 1.1 riastrad * chain if there is one. 284 1.1 riastrad * 285 1.1 riastrad * Note that this function will only be invoked in the context of an 286 1.1 riastrad * atomic commit. It will not be invoked from &drm_bridge_chain_enable. 287 1.1 riastrad * It would be prudent to also provide an implementation of @enable if 288 1.1 riastrad * you are expecting driver calls into &drm_bridge_chain_enable. 289 1.1 riastrad * 290 1.1 riastrad * The @atomic_enable callback is optional. 291 1.1 riastrad */ 292 1.1 riastrad void (*atomic_enable)(struct drm_bridge *bridge, 293 1.1 riastrad struct drm_atomic_state *old_state); 294 1.1 riastrad /** 295 1.1 riastrad * @atomic_disable: 296 1.1 riastrad * 297 1.1 riastrad * This callback should disable the bridge. It is called right before 298 1.1 riastrad * the preceding element in the display pipe is disabled. If the 299 1.1 riastrad * preceding element is a bridge this means it's called before that 300 1.1 riastrad * bridge's @atomic_disable or @disable vfunc. If the preceding element 301 1.1 riastrad * is a &drm_encoder it's called right before the 302 1.1 riastrad * &drm_encoder_helper_funcs.atomic_disable hook. 303 1.1 riastrad * 304 1.1 riastrad * The bridge can assume that the display pipe (i.e. clocks and timing 305 1.1 riastrad * signals) feeding it is still running when this callback is called. 306 1.1 riastrad * 307 1.1 riastrad * Note that this function will only be invoked in the context of an 308 1.1 riastrad * atomic commit. It will not be invoked from 309 1.1 riastrad * &drm_bridge_chain_disable. It would be prudent to also provide an 310 1.1 riastrad * implementation of @disable if you are expecting driver calls into 311 1.1 riastrad * &drm_bridge_chain_disable. 312 1.1 riastrad * 313 1.1 riastrad * The @atomic_disable callback is optional. 314 1.1 riastrad */ 315 1.1 riastrad void (*atomic_disable)(struct drm_bridge *bridge, 316 1.1 riastrad struct drm_atomic_state *old_state); 317 1.1 riastrad 318 1.1 riastrad /** 319 1.1 riastrad * @atomic_post_disable: 320 1.1 riastrad * 321 1.1 riastrad * This callback should disable the bridge. It is called right after the 322 1.1 riastrad * preceding element in the display pipe is disabled. If the preceding 323 1.1 riastrad * element is a bridge this means it's called after that bridge's 324 1.1 riastrad * @atomic_post_disable or @post_disable function. If the preceding 325 1.1 riastrad * element is a &drm_encoder it's called right after the encoder's 326 1.1 riastrad * &drm_encoder_helper_funcs.atomic_disable hook. 327 1.1 riastrad * 328 1.1 riastrad * The bridge must assume that the display pipe (i.e. clocks and timing 329 1.1 riastrad * signals) feeding it is no longer running when this callback is 330 1.1 riastrad * called. 331 1.1 riastrad * 332 1.1 riastrad * Note that this function will only be invoked in the context of an 333 1.1 riastrad * atomic commit. It will not be invoked from 334 1.1 riastrad * &drm_bridge_chain_post_disable. 335 1.1 riastrad * It would be prudent to also provide an implementation of 336 1.1 riastrad * @post_disable if you are expecting driver calls into 337 1.1 riastrad * &drm_bridge_chain_post_disable. 338 1.1 riastrad * 339 1.1 riastrad * The @atomic_post_disable callback is optional. 340 1.1 riastrad */ 341 1.1 riastrad void (*atomic_post_disable)(struct drm_bridge *bridge, 342 1.1 riastrad struct drm_atomic_state *old_state); 343 1.1 riastrad }; 344 1.1 riastrad 345 1.1 riastrad /** 346 1.1 riastrad * struct drm_bridge_timings - timing information for the bridge 347 1.1 riastrad */ 348 1.1 riastrad struct drm_bridge_timings { 349 1.1 riastrad /** 350 1.1 riastrad * @input_bus_flags: 351 1.1 riastrad * 352 1.1 riastrad * Tells what additional settings for the pixel data on the bus 353 1.1 riastrad * this bridge requires (like pixel signal polarity). See also 354 1.1 riastrad * &drm_display_info->bus_flags. 355 1.1 riastrad */ 356 1.1 riastrad u32 input_bus_flags; 357 1.1 riastrad /** 358 1.1 riastrad * @setup_time_ps: 359 1.1 riastrad * 360 1.1 riastrad * Defines the time in picoseconds the input data lines must be 361 1.1 riastrad * stable before the clock edge. 362 1.1 riastrad */ 363 1.1 riastrad u32 setup_time_ps; 364 1.1 riastrad /** 365 1.1 riastrad * @hold_time_ps: 366 1.1 riastrad * 367 1.1 riastrad * Defines the time in picoseconds taken for the bridge to sample the 368 1.1 riastrad * input signal after the clock edge. 369 1.1 riastrad */ 370 1.1 riastrad u32 hold_time_ps; 371 1.1 riastrad /** 372 1.1 riastrad * @dual_link: 373 1.1 riastrad * 374 1.1 riastrad * True if the bus operates in dual-link mode. The exact meaning is 375 1.1 riastrad * dependent on the bus type. For LVDS buses, this indicates that even- 376 1.1 riastrad * and odd-numbered pixels are received on separate links. 377 1.1 riastrad */ 378 1.1 riastrad bool dual_link; 379 1.1 riastrad }; 380 1.1 riastrad 381 1.1 riastrad /** 382 1.1 riastrad * struct drm_bridge - central DRM bridge control structure 383 1.1 riastrad */ 384 1.1 riastrad struct drm_bridge { 385 1.1 riastrad /** @dev: DRM device this bridge belongs to */ 386 1.1 riastrad struct drm_device *dev; 387 1.1 riastrad /** @encoder: encoder to which this bridge is connected */ 388 1.1 riastrad struct drm_encoder *encoder; 389 1.1 riastrad /** @chain_node: used to form a bridge chain */ 390 1.1 riastrad struct list_head chain_node; 391 1.1 riastrad #ifdef CONFIG_OF 392 1.1 riastrad /** @of_node: device node pointer to the bridge */ 393 1.1 riastrad struct device_node *of_node; 394 1.1 riastrad #endif 395 1.1 riastrad /** @list: to keep track of all added bridges */ 396 1.1 riastrad struct list_head list; 397 1.1 riastrad /** 398 1.1 riastrad * @timings: 399 1.1 riastrad * 400 1.1 riastrad * the timing specification for the bridge, if any (may be NULL) 401 1.1 riastrad */ 402 1.1 riastrad const struct drm_bridge_timings *timings; 403 1.1 riastrad /** @funcs: control functions */ 404 1.1 riastrad const struct drm_bridge_funcs *funcs; 405 1.1 riastrad /** @driver_private: pointer to the bridge driver's internal context */ 406 1.1 riastrad void *driver_private; 407 1.1 riastrad }; 408 1.1 riastrad 409 1.1 riastrad void drm_bridge_add(struct drm_bridge *bridge); 410 1.1 riastrad void drm_bridge_remove(struct drm_bridge *bridge); 411 1.1 riastrad struct drm_bridge *of_drm_find_bridge(struct device_node *np); 412 1.1 riastrad int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, 413 1.1 riastrad struct drm_bridge *previous); 414 1.1 riastrad 415 1.1 riastrad /** 416 1.1 riastrad * drm_bridge_get_next_bridge() - Get the next bridge in the chain 417 1.1 riastrad * @bridge: bridge object 418 1.1 riastrad * 419 1.1 riastrad * RETURNS: 420 1.1 riastrad * the next bridge in the chain after @bridge, or NULL if @bridge is the last. 421 1.1 riastrad */ 422 1.1 riastrad static inline struct drm_bridge * 423 1.1 riastrad drm_bridge_get_next_bridge(struct drm_bridge *bridge) 424 1.1 riastrad { 425 1.1 riastrad if (list_is_last(&bridge->chain_node, &bridge->encoder->bridge_chain)) 426 1.1 riastrad return NULL; 427 1.1 riastrad 428 1.1 riastrad return list_next_entry(bridge, chain_node); 429 1.1 riastrad } 430 1.1 riastrad 431 1.1 riastrad /** 432 1.1 riastrad * drm_bridge_get_prev_bridge() - Get the previous bridge in the chain 433 1.1 riastrad * @bridge: bridge object 434 1.1 riastrad * 435 1.1 riastrad * RETURNS: 436 1.1 riastrad * the previous bridge in the chain, or NULL if @bridge is the first. 437 1.1 riastrad */ 438 1.1 riastrad static inline struct drm_bridge * 439 1.1 riastrad drm_bridge_get_prev_bridge(struct drm_bridge *bridge) 440 1.1 riastrad { 441 1.1 riastrad if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) 442 1.1 riastrad return NULL; 443 1.1 riastrad 444 1.1 riastrad return list_prev_entry(bridge, chain_node); 445 1.1 riastrad } 446 1.1 riastrad 447 1.1 riastrad /** 448 1.1 riastrad * drm_bridge_chain_get_first_bridge() - Get the first bridge in the chain 449 1.1 riastrad * @encoder: encoder object 450 1.1 riastrad * 451 1.1 riastrad * RETURNS: 452 1.1 riastrad * the first bridge in the chain, or NULL if @encoder has no bridge attached 453 1.1 riastrad * to it. 454 1.1 riastrad */ 455 1.1 riastrad static inline struct drm_bridge * 456 1.1 riastrad drm_bridge_chain_get_first_bridge(struct drm_encoder *encoder) 457 1.1 riastrad { 458 1.1 riastrad return list_first_entry_or_null(&encoder->bridge_chain, 459 1.1 riastrad struct drm_bridge, chain_node); 460 1.1 riastrad } 461 1.1 riastrad 462 1.1 riastrad /** 463 1.1 riastrad * drm_for_each_bridge_in_chain() - Iterate over all bridges present in a chain 464 1.1 riastrad * @encoder: the encoder to iterate bridges on 465 1.1 riastrad * @bridge: a bridge pointer updated to point to the current bridge at each 466 1.1 riastrad * iteration 467 1.1 riastrad * 468 1.1 riastrad * Iterate over all bridges present in the bridge chain attached to @encoder. 469 1.1 riastrad */ 470 1.1 riastrad #define drm_for_each_bridge_in_chain(encoder, bridge) \ 471 1.1 riastrad list_for_each_entry(bridge, &(encoder)->bridge_chain, chain_node) 472 1.1 riastrad 473 1.1 riastrad bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge, 474 1.1 riastrad const struct drm_display_mode *mode, 475 1.1 riastrad struct drm_display_mode *adjusted_mode); 476 1.1 riastrad enum drm_mode_status 477 1.1 riastrad drm_bridge_chain_mode_valid(struct drm_bridge *bridge, 478 1.1 riastrad const struct drm_display_mode *mode); 479 1.1 riastrad void drm_bridge_chain_disable(struct drm_bridge *bridge); 480 1.1 riastrad void drm_bridge_chain_post_disable(struct drm_bridge *bridge); 481 1.1 riastrad void drm_bridge_chain_mode_set(struct drm_bridge *bridge, 482 1.1 riastrad const struct drm_display_mode *mode, 483 1.1 riastrad const struct drm_display_mode *adjusted_mode); 484 1.1 riastrad void drm_bridge_chain_pre_enable(struct drm_bridge *bridge); 485 1.1 riastrad void drm_bridge_chain_enable(struct drm_bridge *bridge); 486 1.1 riastrad 487 1.1 riastrad void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge, 488 1.1 riastrad struct drm_atomic_state *state); 489 1.1 riastrad void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, 490 1.1 riastrad struct drm_atomic_state *state); 491 1.1 riastrad void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, 492 1.1 riastrad struct drm_atomic_state *state); 493 1.1 riastrad void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge, 494 1.1 riastrad struct drm_atomic_state *state); 495 1.1 riastrad 496 1.1 riastrad #ifdef CONFIG_DRM_PANEL_BRIDGE 497 1.1 riastrad struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel); 498 1.1 riastrad struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel, 499 1.1 riastrad u32 connector_type); 500 1.1 riastrad void drm_panel_bridge_remove(struct drm_bridge *bridge); 501 1.1 riastrad struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, 502 1.1 riastrad struct drm_panel *panel); 503 1.1 riastrad struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev, 504 1.1 riastrad struct drm_panel *panel, 505 1.1 riastrad u32 connector_type); 506 1.1 riastrad struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge); 507 1.1 riastrad #endif 508 1.1 riastrad 509 1.2 riastrad #ifdef __NetBSD__ 510 1.2 riastrad extern void drm_bridge_init_lock(void); 511 1.2 riastrad extern void drm_bridge_fini_lock(void); 512 1.2 riastrad #endif 513 1.2 riastrad 514 1.1 riastrad #endif 515