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