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/ctype.h> 27 #include <linux/list.h> 28 #include <linux/mutex.h> 29 30 #include <drm/drm_atomic.h> 31 #include <drm/drm_encoder.h> 32 #include <drm/drm_mode_object.h> 33 #include <drm/drm_modes.h> 34 35 struct cec_msg; 36 struct device_node; 37 38 struct drm_bridge; 39 struct drm_bridge_timings; 40 struct drm_connector; 41 struct drm_display_info; 42 struct drm_minor; 43 struct drm_panel; 44 struct edid; 45 struct hdmi_codec_daifmt; 46 struct hdmi_codec_params; 47 struct i2c_adapter; 48 49 /** 50 * enum drm_bridge_attach_flags - Flags for &drm_bridge_funcs.attach 51 */ 52 enum drm_bridge_attach_flags { 53 /** 54 * @DRM_BRIDGE_ATTACH_NO_CONNECTOR: When this flag is set the bridge 55 * shall not create a drm_connector. 56 */ 57 DRM_BRIDGE_ATTACH_NO_CONNECTOR = BIT(0), 58 }; 59 60 /** 61 * struct drm_bridge_funcs - drm_bridge control functions 62 */ 63 struct drm_bridge_funcs { 64 /** 65 * @attach: 66 * 67 * This callback is invoked whenever our bridge is being attached to a 68 * &drm_encoder. The flags argument tunes the behaviour of the attach 69 * 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 */ 77 int (*attach)(struct drm_bridge *bridge, struct drm_encoder *encoder, 78 enum drm_bridge_attach_flags flags); 79 80 /** 81 * @detach: 82 * 83 * This callback is invoked whenever our bridge is being detached from a 84 * &drm_encoder. 85 * 86 * The @detach callback is optional. 87 */ 88 void (*detach)(struct drm_bridge *bridge); 89 90 /** 91 * @mode_valid: 92 * 93 * This callback is used to check if a specific mode is valid in this 94 * bridge. This should be implemented if the bridge has some sort of 95 * restriction in the modes it can display. For example, a given bridge 96 * may be responsible to set a clock value. If the clock can not 97 * produce all the values for the available modes then this callback 98 * can be used to restrict the number of modes to only the ones that 99 * can be displayed. 100 * 101 * This hook is used by the probe helpers to filter the mode list in 102 * drm_helper_probe_single_connector_modes(), and it is used by the 103 * atomic helpers to validate modes supplied by userspace in 104 * drm_atomic_helper_check_modeset(). 105 * 106 * The @mode_valid callback is optional. 107 * 108 * NOTE: 109 * 110 * Since this function is both called from the check phase of an atomic 111 * commit, and the mode validation in the probe paths it is not allowed 112 * to look at anything else but the passed-in mode, and validate it 113 * against configuration-invariant hardware constraints. Any further 114 * limits which depend upon the configuration can only be checked in 115 * @mode_fixup. 116 * 117 * RETURNS: 118 * 119 * drm_mode_status Enum 120 */ 121 enum drm_mode_status (*mode_valid)(struct drm_bridge *bridge, 122 const struct drm_display_info *info, 123 const struct drm_display_mode *mode); 124 125 /** 126 * @mode_fixup: 127 * 128 * This callback is used to validate and adjust a mode. The parameter 129 * mode is the display mode that should be fed to the next element in 130 * the display chain, either the final &drm_connector or the next 131 * &drm_bridge. The parameter adjusted_mode is the input mode the bridge 132 * requires. It can be modified by this callback and does not need to 133 * match mode. See also &drm_crtc_state.adjusted_mode for more details. 134 * 135 * This is the only hook that allows a bridge to reject a modeset. If 136 * this function passes all other callbacks must succeed for this 137 * configuration. 138 * 139 * The mode_fixup callback is optional. &drm_bridge_funcs.mode_fixup() 140 * is not called when &drm_bridge_funcs.atomic_check() is implemented, 141 * so only one of them should be provided. 142 * 143 * NOTE: 144 * 145 * This function is called in the check phase of atomic modesets, which 146 * can be aborted for any reason (including on userspace's request to 147 * just check whether a configuration would be possible). Drivers MUST 148 * NOT touch any persistent state (hardware or software) or data 149 * structures except the passed in @state parameter. 150 * 151 * Also beware that userspace can request its own custom modes, neither 152 * core nor helpers filter modes to the list of probe modes reported by 153 * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure 154 * that modes are filtered consistently put any bridge constraints and 155 * limits checks into @mode_valid. 156 * 157 * RETURNS: 158 * 159 * True if an acceptable configuration is possible, false if the modeset 160 * operation should be rejected. 161 */ 162 bool (*mode_fixup)(struct drm_bridge *bridge, 163 const struct drm_display_mode *mode, 164 struct drm_display_mode *adjusted_mode); 165 /** 166 * @disable: 167 * 168 * This callback should disable the bridge. It is called right before 169 * the preceding element in the display pipe is disabled. If the 170 * preceding element is a bridge this means it's called before that 171 * bridge's @disable vfunc. If the preceding element is a &drm_encoder 172 * it's called right before the &drm_encoder_helper_funcs.disable, 173 * &drm_encoder_helper_funcs.prepare or &drm_encoder_helper_funcs.dpms 174 * hook. 175 * 176 * The bridge can assume that the display pipe (i.e. clocks and timing 177 * signals) feeding it is still running when this callback is called. 178 * 179 * The @disable callback is optional. 180 * 181 * NOTE: 182 * 183 * This is deprecated, do not use! 184 * New drivers shall use &drm_bridge_funcs.atomic_disable. 185 */ 186 void (*disable)(struct drm_bridge *bridge); 187 188 /** 189 * @post_disable: 190 * 191 * This callback should disable the bridge. It is called right after the 192 * preceding element in the display pipe is disabled. If the preceding 193 * element is a bridge this means it's called after that bridge's 194 * @post_disable function. If the preceding element is a &drm_encoder 195 * it's called right after the encoder's 196 * &drm_encoder_helper_funcs.disable, &drm_encoder_helper_funcs.prepare 197 * or &drm_encoder_helper_funcs.dpms hook. 198 * 199 * The bridge must assume that the display pipe (i.e. clocks and timing 200 * signals) feeding it is no longer running when this callback is 201 * called. 202 * 203 * The @post_disable callback is optional. 204 * 205 * NOTE: 206 * 207 * This is deprecated, do not use! 208 * New drivers shall use &drm_bridge_funcs.atomic_post_disable. 209 */ 210 void (*post_disable)(struct drm_bridge *bridge); 211 212 /** 213 * @mode_set: 214 * 215 * This callback should set the given mode on the bridge. It is called 216 * after the @mode_set callback for the preceding element in the display 217 * pipeline has been called already. If the bridge is the first element 218 * then this would be &drm_encoder_helper_funcs.mode_set. The display 219 * pipe (i.e. clocks and timing signals) is off when this function is 220 * called. 221 * 222 * The adjusted_mode parameter is the mode output by the CRTC for the 223 * first bridge in the chain. It can be different from the mode 224 * parameter that contains the desired mode for the connector at the end 225 * of the bridges chain, for instance when the first bridge in the chain 226 * performs scaling. The adjusted mode is mostly useful for the first 227 * bridge in the chain and is likely irrelevant for the other bridges. 228 * 229 * For atomic drivers the adjusted_mode is the mode stored in 230 * &drm_crtc_state.adjusted_mode. 231 * 232 * NOTE: 233 * 234 * This is deprecated, do not use! 235 * New drivers shall set their mode in the 236 * &drm_bridge_funcs.atomic_enable operation. 237 */ 238 void (*mode_set)(struct drm_bridge *bridge, 239 const struct drm_display_mode *mode, 240 const struct drm_display_mode *adjusted_mode); 241 /** 242 * @pre_enable: 243 * 244 * This callback should enable the bridge. It is called right before 245 * the preceding element in the display pipe is enabled. If the 246 * preceding element is a bridge this means it's called before that 247 * bridge's @pre_enable function. If the preceding element is a 248 * &drm_encoder it's called right before the encoder's 249 * &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or 250 * &drm_encoder_helper_funcs.dpms 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 * The @pre_enable callback is optional. 258 * 259 * NOTE: 260 * 261 * This is deprecated, do not use! 262 * New drivers shall use &drm_bridge_funcs.atomic_pre_enable. 263 */ 264 void (*pre_enable)(struct drm_bridge *bridge); 265 266 /** 267 * @enable: 268 * 269 * This callback should enable the bridge. It is called right after 270 * the preceding element in the display pipe is enabled. If the 271 * preceding element is a bridge this means it's called after that 272 * bridge's @enable function. If the preceding element is a 273 * &drm_encoder it's called right after the encoder's 274 * &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or 275 * &drm_encoder_helper_funcs.dpms hook. 276 * 277 * The bridge can assume that the display pipe (i.e. clocks and timing 278 * signals) feeding it is running when this callback is called. This 279 * callback must enable the display link feeding the next bridge in the 280 * chain if there is one. 281 * 282 * The @enable callback is optional. 283 * 284 * NOTE: 285 * 286 * This is deprecated, do not use! 287 * New drivers shall use &drm_bridge_funcs.atomic_enable. 288 */ 289 void (*enable)(struct drm_bridge *bridge); 290 291 /** 292 * @atomic_pre_enable: 293 * 294 * This callback should enable the bridge. It is called right before 295 * the preceding element in the display pipe is enabled. If the 296 * preceding element is a bridge this means it's called before that 297 * bridge's @atomic_pre_enable or @pre_enable function. If the preceding 298 * element is a &drm_encoder it's called right before the encoder's 299 * &drm_encoder_helper_funcs.atomic_enable hook. 300 * 301 * The display pipe (i.e. clocks and timing signals) feeding this bridge 302 * will not yet be running when this callback is called. The bridge must 303 * not enable the display link feeding the next bridge in the chain (if 304 * there is one) when this callback is called. 305 * 306 * The @atomic_pre_enable callback is optional. 307 */ 308 void (*atomic_pre_enable)(struct drm_bridge *bridge, 309 struct drm_atomic_state *state); 310 311 /** 312 * @atomic_enable: 313 * 314 * This callback should enable the bridge. It is called right after 315 * the preceding element in the display pipe is enabled. If the 316 * preceding element is a bridge this means it's called after that 317 * bridge's @atomic_enable or @enable function. If the preceding element 318 * is a &drm_encoder it's called right after the encoder's 319 * &drm_encoder_helper_funcs.atomic_enable hook. 320 * 321 * The bridge can assume that the display pipe (i.e. clocks and timing 322 * signals) feeding it is running when this callback is called. This 323 * callback must enable the display link feeding the next bridge in the 324 * chain if there is one. 325 * 326 * The @atomic_enable callback is optional. 327 */ 328 void (*atomic_enable)(struct drm_bridge *bridge, 329 struct drm_atomic_state *state); 330 /** 331 * @atomic_disable: 332 * 333 * This callback should disable the bridge. It is called right before 334 * the preceding element in the display pipe is disabled. If the 335 * preceding element is a bridge this means it's called before that 336 * bridge's @atomic_disable or @disable vfunc. If the preceding element 337 * is a &drm_encoder it's called right before the 338 * &drm_encoder_helper_funcs.atomic_disable hook. 339 * 340 * The bridge can assume that the display pipe (i.e. clocks and timing 341 * signals) feeding it is still running when this callback is called. 342 * 343 * The @atomic_disable callback is optional. 344 */ 345 void (*atomic_disable)(struct drm_bridge *bridge, 346 struct drm_atomic_state *state); 347 348 /** 349 * @atomic_post_disable: 350 * 351 * This callback should disable the bridge. It is called right after the 352 * preceding element in the display pipe is disabled. If the preceding 353 * element is a bridge this means it's called after that bridge's 354 * @atomic_post_disable or @post_disable function. If the preceding 355 * element is a &drm_encoder it's called right after the encoder's 356 * &drm_encoder_helper_funcs.atomic_disable hook. 357 * 358 * The bridge must assume that the display pipe (i.e. clocks and timing 359 * signals) feeding it is no longer running when this callback is 360 * called. 361 * 362 * The @atomic_post_disable callback is optional. 363 */ 364 void (*atomic_post_disable)(struct drm_bridge *bridge, 365 struct drm_atomic_state *state); 366 367 /** 368 * @atomic_duplicate_state: 369 * 370 * Duplicate the current bridge state object (which is guaranteed to be 371 * non-NULL). 372 * 373 * The atomic_duplicate_state hook is mandatory if the bridge 374 * implements any of the atomic hooks, and should be left unassigned 375 * otherwise. For bridges that don't subclass &drm_bridge_state, the 376 * drm_atomic_helper_bridge_duplicate_state() helper function shall be 377 * used to implement this hook. 378 * 379 * RETURNS: 380 * A valid drm_bridge_state object or NULL if the allocation fails. 381 */ 382 struct drm_bridge_state *(*atomic_duplicate_state)(struct drm_bridge *bridge); 383 384 /** 385 * @atomic_destroy_state: 386 * 387 * Destroy a bridge state object previously allocated by 388 * &drm_bridge_funcs.atomic_duplicate_state(). 389 * 390 * The atomic_destroy_state hook is mandatory if the bridge implements 391 * any of the atomic hooks, and should be left unassigned otherwise. 392 * For bridges that don't subclass &drm_bridge_state, the 393 * drm_atomic_helper_bridge_destroy_state() helper function shall be 394 * used to implement this hook. 395 */ 396 void (*atomic_destroy_state)(struct drm_bridge *bridge, 397 struct drm_bridge_state *state); 398 399 /** 400 * @atomic_get_output_bus_fmts: 401 * 402 * Return the supported bus formats on the output end of a bridge. 403 * The returned array must be allocated with kmalloc() and will be 404 * freed by the caller. If the allocation fails, NULL should be 405 * returned. num_output_fmts must be set to the returned array size. 406 * Formats listed in the returned array should be listed in decreasing 407 * preference order (the core will try all formats until it finds one 408 * that works). 409 * 410 * This method is only called on the last element of the bridge chain 411 * as part of the bus format negotiation process that happens in 412 * &drm_atomic_bridge_chain_select_bus_fmts(). 413 * This method is optional. When not implemented, the core will 414 * fall back to &drm_connector.display_info.bus_formats[0] if 415 * &drm_connector.display_info.num_bus_formats > 0, 416 * or to MEDIA_BUS_FMT_FIXED otherwise. 417 */ 418 u32 *(*atomic_get_output_bus_fmts)(struct drm_bridge *bridge, 419 struct drm_bridge_state *bridge_state, 420 struct drm_crtc_state *crtc_state, 421 struct drm_connector_state *conn_state, 422 unsigned int *num_output_fmts); 423 424 /** 425 * @atomic_get_input_bus_fmts: 426 * 427 * Return the supported bus formats on the input end of a bridge for 428 * a specific output bus format. 429 * 430 * The returned array must be allocated with kmalloc() and will be 431 * freed by the caller. If the allocation fails, NULL should be 432 * returned. num_input_fmts must be set to the returned array size. 433 * Formats listed in the returned array should be listed in decreasing 434 * preference order (the core will try all formats until it finds one 435 * that works). When the format is not supported NULL should be 436 * returned and num_input_fmts should be set to 0. 437 * 438 * This method is called on all elements of the bridge chain as part of 439 * the bus format negotiation process that happens in 440 * drm_atomic_bridge_chain_select_bus_fmts(). 441 * This method is optional. When not implemented, the core will bypass 442 * bus format negotiation on this element of the bridge without 443 * failing, and the previous element in the chain will be passed 444 * MEDIA_BUS_FMT_FIXED as its output bus format. 445 * 446 * Bridge drivers that need to support being linked to bridges that are 447 * not supporting bus format negotiation should handle the 448 * output_fmt == MEDIA_BUS_FMT_FIXED case appropriately, by selecting a 449 * sensible default value or extracting this information from somewhere 450 * else (FW property, &drm_display_mode, &drm_display_info, ...) 451 * 452 * Note: Even if input format selection on the first bridge has no 453 * impact on the negotiation process (bus format negotiation stops once 454 * we reach the first element of the chain), drivers are expected to 455 * return accurate input formats as the input format may be used to 456 * configure the CRTC output appropriately. 457 */ 458 u32 *(*atomic_get_input_bus_fmts)(struct drm_bridge *bridge, 459 struct drm_bridge_state *bridge_state, 460 struct drm_crtc_state *crtc_state, 461 struct drm_connector_state *conn_state, 462 u32 output_fmt, 463 unsigned int *num_input_fmts); 464 465 /** 466 * @atomic_check: 467 * 468 * This method is responsible for checking bridge state correctness. 469 * It can also check the state of the surrounding components in chain 470 * to make sure the whole pipeline can work properly. 471 * 472 * &drm_bridge_funcs.atomic_check() hooks are called in reverse 473 * order (from the last to the first bridge). 474 * 475 * This method is optional. &drm_bridge_funcs.mode_fixup() is not 476 * called when &drm_bridge_funcs.atomic_check() is implemented, so only 477 * one of them should be provided. 478 * 479 * If drivers need to tweak &drm_bridge_state.input_bus_cfg.flags or 480 * &drm_bridge_state.output_bus_cfg.flags it should happen in 481 * this function. By default the &drm_bridge_state.output_bus_cfg.flags 482 * field is set to the next bridge 483 * &drm_bridge_state.input_bus_cfg.flags value or 484 * &drm_connector.display_info.bus_flags if the bridge is the last 485 * element in the chain. 486 * 487 * RETURNS: 488 * zero if the check passed, a negative error code otherwise. 489 */ 490 int (*atomic_check)(struct drm_bridge *bridge, 491 struct drm_bridge_state *bridge_state, 492 struct drm_crtc_state *crtc_state, 493 struct drm_connector_state *conn_state); 494 495 /** 496 * @atomic_reset: 497 * 498 * Reset the bridge to a predefined state (or retrieve its current 499 * state) and return a &drm_bridge_state object matching this state. 500 * This function is called at attach time. 501 * 502 * The atomic_reset hook is mandatory if the bridge implements any of 503 * the atomic hooks, and should be left unassigned otherwise. For 504 * bridges that don't subclass &drm_bridge_state, the 505 * drm_atomic_helper_bridge_reset() helper function shall be used to 506 * implement this hook. 507 * 508 * Note that the atomic_reset() semantics is not exactly matching the 509 * reset() semantics found on other components (connector, plane, ...). 510 * 511 * 1. The reset operation happens when the bridge is attached, not when 512 * drm_mode_config_reset() is called 513 * 2. It's meant to be used exclusively on bridges that have been 514 * converted to the ATOMIC API 515 * 516 * RETURNS: 517 * A valid drm_bridge_state object in case of success, an ERR_PTR() 518 * giving the reason of the failure otherwise. 519 */ 520 struct drm_bridge_state *(*atomic_reset)(struct drm_bridge *bridge); 521 522 /** 523 * @detect: 524 * 525 * Check if anything is attached to the bridge output. 526 * 527 * This callback is optional, if not implemented the bridge will be 528 * considered as always having a component attached to its output. 529 * Bridges that implement this callback shall set the 530 * DRM_BRIDGE_OP_DETECT flag in their &drm_bridge->ops. 531 * 532 * RETURNS: 533 * 534 * drm_connector_status indicating the bridge output status. 535 */ 536 enum drm_connector_status (*detect)(struct drm_bridge *bridge); 537 538 /** 539 * @get_modes: 540 * 541 * Fill all modes currently valid for the sink into the &drm_connector 542 * with drm_mode_probed_add(). 543 * 544 * The @get_modes callback is mostly intended to support non-probeable 545 * displays such as many fixed panels. Bridges that support reading 546 * EDID shall leave @get_modes unimplemented and implement the 547 * &drm_bridge_funcs->edid_read callback instead. 548 * 549 * This callback is optional. Bridges that implement it shall set the 550 * DRM_BRIDGE_OP_MODES flag in their &drm_bridge->ops. 551 * 552 * The connector parameter shall be used for the sole purpose of 553 * filling modes, and shall not be stored internally by bridge drivers 554 * for future usage. 555 * 556 * RETURNS: 557 * 558 * The number of modes added by calling drm_mode_probed_add(). 559 */ 560 int (*get_modes)(struct drm_bridge *bridge, 561 struct drm_connector *connector); 562 563 /** 564 * @edid_read: 565 * 566 * Read the EDID data of the connected display. 567 * 568 * The @edid_read callback is the preferred way of reporting mode 569 * information for a display connected to the bridge output. Bridges 570 * that support reading EDID shall implement this callback and leave 571 * the @get_modes callback unimplemented. 572 * 573 * The caller of this operation shall first verify the output 574 * connection status and refrain from reading EDID from a disconnected 575 * output. 576 * 577 * This callback is optional. Bridges that implement it shall set the 578 * DRM_BRIDGE_OP_EDID flag in their &drm_bridge->ops. 579 * 580 * The connector parameter shall be used for the sole purpose of EDID 581 * retrieval, and shall not be stored internally by bridge drivers for 582 * future usage. 583 * 584 * RETURNS: 585 * 586 * An edid structure newly allocated with drm_edid_alloc() or returned 587 * from drm_edid_read() family of functions on success, or NULL 588 * otherwise. The caller is responsible for freeing the returned edid 589 * structure with drm_edid_free(). 590 */ 591 const struct drm_edid *(*edid_read)(struct drm_bridge *bridge, 592 struct drm_connector *connector); 593 594 /** 595 * @hpd_notify: 596 * 597 * Notify the bridge of hot plug detection. 598 * 599 * This callback is optional, it may be implemented by bridges that 600 * need to be notified of display connection or disconnection for 601 * internal reasons. One use case is to reset the internal state of CEC 602 * controllers for HDMI bridges. 603 */ 604 void (*hpd_notify)(struct drm_bridge *bridge, 605 enum drm_connector_status status); 606 607 /** 608 * @hpd_enable: 609 * 610 * Enable hot plug detection. From now on the bridge shall call 611 * drm_bridge_hpd_notify() each time a change is detected in the output 612 * connection status, until hot plug detection gets disabled with 613 * @hpd_disable. 614 * 615 * This callback is optional and shall only be implemented by bridges 616 * that support hot-plug notification without polling. Bridges that 617 * implement it shall also implement the @hpd_disable callback and set 618 * the DRM_BRIDGE_OP_HPD flag in their &drm_bridge->ops. 619 */ 620 void (*hpd_enable)(struct drm_bridge *bridge); 621 622 /** 623 * @hpd_disable: 624 * 625 * Disable hot plug detection. Once this function returns the bridge 626 * shall not call drm_bridge_hpd_notify() when a change in the output 627 * connection status occurs. 628 * 629 * This callback is optional and shall only be implemented by bridges 630 * that support hot-plug notification without polling. Bridges that 631 * implement it shall also implement the @hpd_enable callback and set 632 * the DRM_BRIDGE_OP_HPD flag in their &drm_bridge->ops. 633 */ 634 void (*hpd_disable)(struct drm_bridge *bridge); 635 636 /** 637 * @hdmi_tmds_char_rate_valid: 638 * 639 * Check whether a particular TMDS character rate is supported by the 640 * driver. 641 * 642 * This callback is optional and should only be implemented by the 643 * bridges that take part in the HDMI connector implementation. Bridges 644 * that implement it shall set the DRM_BRIDGE_OP_HDMI flag in their 645 * &drm_bridge->ops. 646 * 647 * Returns: 648 * 649 * Either &drm_mode_status.MODE_OK or one of the failure reasons 650 * in &enum drm_mode_status. 651 */ 652 enum drm_mode_status 653 (*hdmi_tmds_char_rate_valid)(const struct drm_bridge *bridge, 654 const struct drm_display_mode *mode, 655 unsigned long long tmds_rate); 656 657 /** 658 * @hdmi_clear_infoframe: 659 * 660 * This callback clears the infoframes in the hardware during commit. 661 * It will be called multiple times, once for every disabled infoframe 662 * type. 663 * 664 * This callback is optional but it must be implemented by bridges that 665 * set the DRM_BRIDGE_OP_HDMI flag in their &drm_bridge->ops. 666 */ 667 int (*hdmi_clear_infoframe)(struct drm_bridge *bridge, 668 enum hdmi_infoframe_type type); 669 /** 670 * @hdmi_write_infoframe: 671 * 672 * Program the infoframe into the hardware. It will be called multiple 673 * times, once for every updated infoframe type. 674 * 675 * This callback is optional but it must be implemented by bridges that 676 * set the DRM_BRIDGE_OP_HDMI flag in their &drm_bridge->ops. 677 */ 678 int (*hdmi_write_infoframe)(struct drm_bridge *bridge, 679 enum hdmi_infoframe_type type, 680 const u8 *buffer, size_t len); 681 682 /** 683 * @hdmi_audio_startup: 684 * 685 * Called when ASoC starts an audio stream setup. 686 * 687 * This callback is optional, it can be implemented by bridges that 688 * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops. 689 * 690 * Returns: 691 * 0 on success, a negative error code otherwise 692 */ 693 int (*hdmi_audio_startup)(struct drm_connector *connector, 694 struct drm_bridge *bridge); 695 696 /** 697 * @hdmi_audio_prepare: 698 * Configures HDMI-encoder for audio stream. Can be called multiple 699 * times for each setup. 700 * 701 * This callback is optional but it must be implemented by bridges that 702 * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops. 703 * 704 * Returns: 705 * 0 on success, a negative error code otherwise 706 */ 707 int (*hdmi_audio_prepare)(struct drm_connector *connector, 708 struct drm_bridge *bridge, 709 struct hdmi_codec_daifmt *fmt, 710 struct hdmi_codec_params *hparms); 711 712 /** 713 * @hdmi_audio_shutdown: 714 * 715 * Shut down the audio stream. 716 * 717 * This callback is optional but it must be implemented by bridges that 718 * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops. 719 * 720 * Returns: 721 * 0 on success, a negative error code otherwise 722 */ 723 void (*hdmi_audio_shutdown)(struct drm_connector *connector, 724 struct drm_bridge *bridge); 725 726 /** 727 * @hdmi_audio_mute_stream: 728 * 729 * Mute/unmute HDMI audio stream. 730 * 731 * This callback is optional, it can be implemented by bridges that 732 * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops. 733 * 734 * Returns: 735 * 0 on success, a negative error code otherwise 736 */ 737 int (*hdmi_audio_mute_stream)(struct drm_connector *connector, 738 struct drm_bridge *bridge, 739 bool enable, int direction); 740 741 int (*hdmi_cec_init)(struct drm_connector *connector, 742 struct drm_bridge *bridge); 743 744 int (*hdmi_cec_enable)(struct drm_bridge *bridge, bool enable); 745 746 int (*hdmi_cec_log_addr)(struct drm_bridge *bridge, u8 logical_addr); 747 748 int (*hdmi_cec_transmit)(struct drm_bridge *bridge, u8 attempts, 749 u32 signal_free_time, struct cec_msg *msg); 750 751 /** 752 * @dp_audio_startup: 753 * 754 * Called when ASoC starts a DisplayPort audio stream setup. 755 * 756 * This callback is optional, it can be implemented by bridges that 757 * set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops. 758 * 759 * Returns: 760 * 0 on success, a negative error code otherwise 761 */ 762 int (*dp_audio_startup)(struct drm_connector *connector, 763 struct drm_bridge *bridge); 764 765 /** 766 * @dp_audio_prepare: 767 * Configures DisplayPort audio stream. Can be called multiple 768 * times for each setup. 769 * 770 * This callback is optional but it must be implemented by bridges that 771 * set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops. 772 * 773 * Returns: 774 * 0 on success, a negative error code otherwise 775 */ 776 int (*dp_audio_prepare)(struct drm_connector *connector, 777 struct drm_bridge *bridge, 778 struct hdmi_codec_daifmt *fmt, 779 struct hdmi_codec_params *hparms); 780 781 /** 782 * @dp_audio_shutdown: 783 * 784 * Shut down the DisplayPort audio stream. 785 * 786 * This callback is optional but it must be implemented by bridges that 787 * set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops. 788 * 789 * Returns: 790 * 0 on success, a negative error code otherwise 791 */ 792 void (*dp_audio_shutdown)(struct drm_connector *connector, 793 struct drm_bridge *bridge); 794 795 /** 796 * @dp_audio_mute_stream: 797 * 798 * Mute/unmute DisplayPort audio stream. 799 * 800 * This callback is optional, it can be implemented by bridges that 801 * set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops. 802 * 803 * Returns: 804 * 0 on success, a negative error code otherwise 805 */ 806 int (*dp_audio_mute_stream)(struct drm_connector *connector, 807 struct drm_bridge *bridge, 808 bool enable, int direction); 809 810 /** 811 * @debugfs_init: 812 * 813 * Allows bridges to create bridge-specific debugfs files. 814 */ 815 void (*debugfs_init)(struct drm_bridge *bridge, struct dentry *root); 816 }; 817 818 /** 819 * struct drm_bridge_timings - timing information for the bridge 820 */ 821 struct drm_bridge_timings { 822 /** 823 * @input_bus_flags: 824 * 825 * Tells what additional settings for the pixel data on the bus 826 * this bridge requires (like pixel signal polarity). See also 827 * &drm_display_info->bus_flags. 828 */ 829 u32 input_bus_flags; 830 /** 831 * @setup_time_ps: 832 * 833 * Defines the time in picoseconds the input data lines must be 834 * stable before the clock edge. 835 */ 836 u32 setup_time_ps; 837 /** 838 * @hold_time_ps: 839 * 840 * Defines the time in picoseconds taken for the bridge to sample the 841 * input signal after the clock edge. 842 */ 843 u32 hold_time_ps; 844 /** 845 * @dual_link: 846 * 847 * True if the bus operates in dual-link mode. The exact meaning is 848 * dependent on the bus type. For LVDS buses, this indicates that even- 849 * and odd-numbered pixels are received on separate links. 850 */ 851 bool dual_link; 852 }; 853 854 /** 855 * enum drm_bridge_ops - Bitmask of operations supported by the bridge 856 */ 857 enum drm_bridge_ops { 858 /** 859 * @DRM_BRIDGE_OP_DETECT: The bridge can detect displays connected to 860 * its output. Bridges that set this flag shall implement the 861 * &drm_bridge_funcs->detect callback. 862 */ 863 DRM_BRIDGE_OP_DETECT = BIT(0), 864 /** 865 * @DRM_BRIDGE_OP_EDID: The bridge can retrieve the EDID of the display 866 * connected to its output. Bridges that set this flag shall implement 867 * the &drm_bridge_funcs->edid_read callback. 868 */ 869 DRM_BRIDGE_OP_EDID = BIT(1), 870 /** 871 * @DRM_BRIDGE_OP_HPD: The bridge can detect hot-plug and hot-unplug 872 * without requiring polling. Bridges that set this flag shall 873 * implement the &drm_bridge_funcs->hpd_enable and 874 * &drm_bridge_funcs->hpd_disable callbacks if they support enabling 875 * and disabling hot-plug detection dynamically. 876 */ 877 DRM_BRIDGE_OP_HPD = BIT(2), 878 /** 879 * @DRM_BRIDGE_OP_MODES: The bridge can retrieve the modes supported 880 * by the display at its output. This does not include reading EDID 881 * which is separately covered by @DRM_BRIDGE_OP_EDID. Bridges that set 882 * this flag shall implement the &drm_bridge_funcs->get_modes callback. 883 */ 884 DRM_BRIDGE_OP_MODES = BIT(3), 885 /** 886 * @DRM_BRIDGE_OP_HDMI: The bridge provides HDMI connector operations, 887 * including infoframes support. Bridges that set this flag must 888 * implement the &drm_bridge_funcs->write_infoframe callback. 889 * 890 * Note: currently there can be at most one bridge in a chain that sets 891 * this bit. This is to simplify corresponding glue code in connector 892 * drivers. 893 */ 894 DRM_BRIDGE_OP_HDMI = BIT(4), 895 /** 896 * @DRM_BRIDGE_OP_HDMI_AUDIO: The bridge provides HDMI audio operations. 897 * Bridges that set this flag must implement the 898 * &drm_bridge_funcs->hdmi_audio_prepare and 899 * &drm_bridge_funcs->hdmi_audio_shutdown callbacks. 900 * 901 * Note: currently there can be at most one bridge in a chain that sets 902 * this bit. This is to simplify corresponding glue code in connector 903 * drivers. Also it is not possible to have a bridge in the chain that 904 * sets @DRM_BRIDGE_OP_DP_AUDIO if there is a bridge that sets this 905 * flag. 906 */ 907 DRM_BRIDGE_OP_HDMI_AUDIO = BIT(5), 908 /** 909 * @DRM_BRIDGE_OP_DP_AUDIO: The bridge provides DisplayPort audio operations. 910 * Bridges that set this flag must implement the 911 * &drm_bridge_funcs->dp_audio_prepare and 912 * &drm_bridge_funcs->dp_audio_shutdown callbacks. 913 * 914 * Note: currently there can be at most one bridge in a chain that sets 915 * this bit. This is to simplify corresponding glue code in connector 916 * drivers. Also it is not possible to have a bridge in the chain that 917 * sets @DRM_BRIDGE_OP_HDMI_AUDIO if there is a bridge that sets this 918 * flag. 919 */ 920 DRM_BRIDGE_OP_DP_AUDIO = BIT(6), 921 /** 922 * @DRM_BRIDGE_OP_HDMI_CEC_NOTIFIER: The bridge requires CEC notifier 923 * to be present. 924 */ 925 DRM_BRIDGE_OP_HDMI_CEC_NOTIFIER = BIT(7), 926 /** 927 * @DRM_BRIDGE_OP_HDMI_CEC_ADAPTER: The bridge requires CEC notifier 928 * to be present. 929 */ 930 DRM_BRIDGE_OP_HDMI_CEC_ADAPTER = BIT(8), 931 }; 932 933 /** 934 * struct drm_bridge - central DRM bridge control structure 935 */ 936 struct drm_bridge { 937 /** @base: inherit from &drm_private_object */ 938 struct drm_private_obj base; 939 /** @dev: DRM device this bridge belongs to */ 940 struct drm_device *dev; 941 /** @encoder: encoder to which this bridge is connected */ 942 struct drm_encoder *encoder; 943 /** @chain_node: used to form a bridge chain */ 944 struct list_head chain_node; 945 /** @of_node: device node pointer to the bridge */ 946 struct device_node *of_node; 947 /** @list: to keep track of all added bridges */ 948 struct list_head list; 949 /** 950 * @timings: 951 * 952 * the timing specification for the bridge, if any (may be NULL) 953 */ 954 const struct drm_bridge_timings *timings; 955 /** @funcs: control functions */ 956 const struct drm_bridge_funcs *funcs; 957 958 /** 959 * @container: Pointer to the private driver struct embedding this 960 * @struct drm_bridge. 961 */ 962 void *container; 963 964 /** 965 * @refcount: reference count of users referencing this bridge. 966 */ 967 struct kref refcount; 968 969 /** @driver_private: pointer to the bridge driver's internal context */ 970 void *driver_private; 971 /** @ops: bitmask of operations supported by the bridge */ 972 enum drm_bridge_ops ops; 973 /** 974 * @type: Type of the connection at the bridge output 975 * (DRM_MODE_CONNECTOR_*). For bridges at the end of this chain this 976 * identifies the type of connected display. 977 */ 978 int type; 979 /** 980 * @interlace_allowed: Indicate that the bridge can handle interlaced 981 * modes. 982 */ 983 bool interlace_allowed; 984 /** 985 * @ycbcr_420_allowed: Indicate that the bridge can handle YCbCr 420 986 * output. 987 */ 988 bool ycbcr_420_allowed; 989 /** 990 * @pre_enable_prev_first: The bridge requires that the prev 991 * bridge @pre_enable function is called before its @pre_enable, 992 * and conversely for post_disable. This is most frequently a 993 * requirement for DSI devices which need the host to be initialised 994 * before the peripheral. 995 */ 996 bool pre_enable_prev_first; 997 /** 998 * @ddc: Associated I2C adapter for DDC access, if any. 999 */ 1000 struct i2c_adapter *ddc; 1001 1002 /** 1003 * @vendor: Vendor of the product to be used for the SPD InfoFrame 1004 * generation. This is required if @DRM_BRIDGE_OP_HDMI is set. 1005 */ 1006 const char *vendor; 1007 1008 /** 1009 * @product: Name of the product to be used for the SPD InfoFrame 1010 * generation. This is required if @DRM_BRIDGE_OP_HDMI is set. 1011 */ 1012 const char *product; 1013 1014 /** 1015 * @supported_formats: Bitmask of @hdmi_colorspace listing supported 1016 * output formats. This is only relevant if @DRM_BRIDGE_OP_HDMI is set. 1017 */ 1018 unsigned int supported_formats; 1019 1020 /** 1021 * @max_bpc: Maximum bits per char the HDMI bridge supports. Allowed 1022 * values are 8, 10 and 12. This is only relevant if 1023 * @DRM_BRIDGE_OP_HDMI is set. 1024 */ 1025 unsigned int max_bpc; 1026 1027 /** 1028 * @hdmi_cec_dev: device to be used as a containing device for CEC 1029 * functions. 1030 */ 1031 struct device *hdmi_cec_dev; 1032 1033 /** 1034 * @hdmi_audio_dev: device to be used as a parent for the HDMI Codec if 1035 * either of @DRM_BRIDGE_OP_HDMI_AUDIO or @DRM_BRIDGE_OP_DP_AUDIO is set. 1036 */ 1037 struct device *hdmi_audio_dev; 1038 1039 /** 1040 * @hdmi_audio_max_i2s_playback_channels: maximum number of playback 1041 * I2S channels for the @DRM_BRIDGE_OP_HDMI_AUDIO or 1042 * @DRM_BRIDGE_OP_DP_AUDIO. 1043 */ 1044 int hdmi_audio_max_i2s_playback_channels; 1045 1046 /** 1047 * @hdmi_audio_i2s_formats: supported I2S formats, optional. The 1048 * default is to allow all formats supported by the corresponding I2S 1049 * bus driver. This is only used for bridges setting 1050 * @DRM_BRIDGE_OP_HDMI_AUDIO or @DRM_BRIDGE_OP_DP_AUDIO. 1051 */ 1052 u64 hdmi_audio_i2s_formats; 1053 1054 /** 1055 * @hdmi_audio_spdif_playback: set if this bridge has S/PDIF playback 1056 * port for @DRM_BRIDGE_OP_HDMI_AUDIO or @DRM_BRIDGE_OP_DP_AUDIO. 1057 */ 1058 unsigned int hdmi_audio_spdif_playback : 1; 1059 1060 /** 1061 * @hdmi_audio_dai_port: sound DAI port for either of 1062 * @DRM_BRIDGE_OP_HDMI_AUDIO and @DRM_BRIDGE_OP_DP_AUDIO, -1 if it is 1063 * not used. 1064 */ 1065 int hdmi_audio_dai_port; 1066 1067 /** 1068 * @hdmi_cec_adapter_name: the name of the adapter to register 1069 */ 1070 const char *hdmi_cec_adapter_name; 1071 1072 /** 1073 * @hdmi_cec_available_las: number of logical addresses, CEC_MAX_LOG_ADDRS if unset 1074 */ 1075 u8 hdmi_cec_available_las; 1076 1077 /** private: */ 1078 /** 1079 * @hpd_mutex: Protects the @hpd_cb and @hpd_data fields. 1080 */ 1081 struct mutex hpd_mutex; 1082 /** 1083 * @hpd_cb: Hot plug detection callback, registered with 1084 * drm_bridge_hpd_enable(). 1085 */ 1086 void (*hpd_cb)(void *data, enum drm_connector_status status); 1087 /** 1088 * @hpd_data: Private data passed to the Hot plug detection callback 1089 * @hpd_cb. 1090 */ 1091 void *hpd_data; 1092 }; 1093 1094 static inline struct drm_bridge * 1095 drm_priv_to_bridge(struct drm_private_obj *priv) 1096 { 1097 return container_of(priv, struct drm_bridge, base); 1098 } 1099 1100 struct drm_bridge *drm_bridge_get(struct drm_bridge *bridge); 1101 void drm_bridge_put(struct drm_bridge *bridge); 1102 1103 void *__devm_drm_bridge_alloc(struct device *dev, size_t size, size_t offset, 1104 const struct drm_bridge_funcs *funcs); 1105 1106 /** 1107 * devm_drm_bridge_alloc - Allocate and initialize a bridge 1108 * @dev: struct device of the bridge device 1109 * @type: the type of the struct which contains struct &drm_bridge 1110 * @member: the name of the &drm_bridge within @type 1111 * @funcs: callbacks for this bridge 1112 * 1113 * The reference count of the returned bridge is initialized to 1. This 1114 * reference will be automatically dropped via devm (by calling 1115 * drm_bridge_put()) when @dev is removed. 1116 * 1117 * Returns: 1118 * Pointer to new bridge, or ERR_PTR on failure. 1119 */ 1120 #define devm_drm_bridge_alloc(dev, type, member, funcs) \ 1121 ((type *)__devm_drm_bridge_alloc(dev, sizeof(type), \ 1122 offsetof(type, member), funcs)) 1123 1124 void drm_bridge_add(struct drm_bridge *bridge); 1125 int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge); 1126 void drm_bridge_remove(struct drm_bridge *bridge); 1127 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, 1128 struct drm_bridge *previous, 1129 enum drm_bridge_attach_flags flags); 1130 1131 #ifdef CONFIG_OF 1132 struct drm_bridge *of_drm_find_bridge(struct device_node *np); 1133 #else 1134 static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np) 1135 { 1136 return NULL; 1137 } 1138 #endif 1139 1140 /** 1141 * drm_bridge_get_current_state() - Get the current bridge state 1142 * @bridge: bridge object 1143 * 1144 * This function must be called with the modeset lock held. 1145 * 1146 * RETURNS: 1147 * 1148 * The current bridge state, or NULL if there is none. 1149 */ 1150 static inline struct drm_bridge_state * 1151 drm_bridge_get_current_state(struct drm_bridge *bridge) 1152 { 1153 if (!bridge) 1154 return NULL; 1155 1156 /* 1157 * Only atomic bridges will have bridge->base initialized by 1158 * drm_atomic_private_obj_init(), so we need to make sure we're 1159 * working with one before we try to use the lock. 1160 */ 1161 if (!bridge->funcs || !bridge->funcs->atomic_reset) 1162 return NULL; 1163 1164 drm_modeset_lock_assert_held(&bridge->base.lock); 1165 1166 if (!bridge->base.state) 1167 return NULL; 1168 1169 return drm_priv_to_bridge_state(bridge->base.state); 1170 } 1171 1172 /** 1173 * drm_bridge_get_next_bridge() - Get the next bridge in the chain 1174 * @bridge: bridge object 1175 * 1176 * RETURNS: 1177 * the next bridge in the chain after @bridge, or NULL if @bridge is the last. 1178 */ 1179 static inline struct drm_bridge * 1180 drm_bridge_get_next_bridge(struct drm_bridge *bridge) 1181 { 1182 if (list_is_last(&bridge->chain_node, &bridge->encoder->bridge_chain)) 1183 return NULL; 1184 1185 return list_next_entry(bridge, chain_node); 1186 } 1187 1188 /** 1189 * drm_bridge_get_prev_bridge() - Get the previous bridge in the chain 1190 * @bridge: bridge object 1191 * 1192 * RETURNS: 1193 * the previous bridge in the chain, or NULL if @bridge is the first. 1194 */ 1195 static inline struct drm_bridge * 1196 drm_bridge_get_prev_bridge(struct drm_bridge *bridge) 1197 { 1198 if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) 1199 return NULL; 1200 1201 return list_prev_entry(bridge, chain_node); 1202 } 1203 1204 /** 1205 * drm_bridge_chain_get_first_bridge() - Get the first bridge in the chain 1206 * @encoder: encoder object 1207 * 1208 * RETURNS: 1209 * the first bridge in the chain, or NULL if @encoder has no bridge attached 1210 * to it. 1211 */ 1212 static inline struct drm_bridge * 1213 drm_bridge_chain_get_first_bridge(struct drm_encoder *encoder) 1214 { 1215 return list_first_entry_or_null(&encoder->bridge_chain, 1216 struct drm_bridge, chain_node); 1217 } 1218 1219 /** 1220 * drm_for_each_bridge_in_chain() - Iterate over all bridges present in a chain 1221 * @encoder: the encoder to iterate bridges on 1222 * @bridge: a bridge pointer updated to point to the current bridge at each 1223 * iteration 1224 * 1225 * Iterate over all bridges present in the bridge chain attached to @encoder. 1226 */ 1227 #define drm_for_each_bridge_in_chain(encoder, bridge) \ 1228 list_for_each_entry(bridge, &(encoder)->bridge_chain, chain_node) 1229 1230 enum drm_mode_status 1231 drm_bridge_chain_mode_valid(struct drm_bridge *bridge, 1232 const struct drm_display_info *info, 1233 const struct drm_display_mode *mode); 1234 void drm_bridge_chain_mode_set(struct drm_bridge *bridge, 1235 const struct drm_display_mode *mode, 1236 const struct drm_display_mode *adjusted_mode); 1237 1238 int drm_atomic_bridge_chain_check(struct drm_bridge *bridge, 1239 struct drm_crtc_state *crtc_state, 1240 struct drm_connector_state *conn_state); 1241 void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge, 1242 struct drm_atomic_state *state); 1243 void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, 1244 struct drm_atomic_state *state); 1245 void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, 1246 struct drm_atomic_state *state); 1247 void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge, 1248 struct drm_atomic_state *state); 1249 1250 u32 * 1251 drm_atomic_helper_bridge_propagate_bus_fmt(struct drm_bridge *bridge, 1252 struct drm_bridge_state *bridge_state, 1253 struct drm_crtc_state *crtc_state, 1254 struct drm_connector_state *conn_state, 1255 u32 output_fmt, 1256 unsigned int *num_input_fmts); 1257 1258 enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge); 1259 int drm_bridge_get_modes(struct drm_bridge *bridge, 1260 struct drm_connector *connector); 1261 const struct drm_edid *drm_bridge_edid_read(struct drm_bridge *bridge, 1262 struct drm_connector *connector); 1263 void drm_bridge_hpd_enable(struct drm_bridge *bridge, 1264 void (*cb)(void *data, 1265 enum drm_connector_status status), 1266 void *data); 1267 void drm_bridge_hpd_disable(struct drm_bridge *bridge); 1268 void drm_bridge_hpd_notify(struct drm_bridge *bridge, 1269 enum drm_connector_status status); 1270 1271 #ifdef CONFIG_DRM_PANEL_BRIDGE 1272 bool drm_bridge_is_panel(const struct drm_bridge *bridge); 1273 struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel); 1274 struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel, 1275 u32 connector_type); 1276 void drm_panel_bridge_remove(struct drm_bridge *bridge); 1277 int drm_panel_bridge_set_orientation(struct drm_connector *connector, 1278 struct drm_bridge *bridge); 1279 struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, 1280 struct drm_panel *panel); 1281 struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev, 1282 struct drm_panel *panel, 1283 u32 connector_type); 1284 struct drm_bridge *drmm_panel_bridge_add(struct drm_device *drm, 1285 struct drm_panel *panel); 1286 struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge); 1287 #else 1288 static inline bool drm_bridge_is_panel(const struct drm_bridge *bridge) 1289 { 1290 return false; 1291 } 1292 1293 static inline int drm_panel_bridge_set_orientation(struct drm_connector *connector, 1294 struct drm_bridge *bridge) 1295 { 1296 return -EINVAL; 1297 } 1298 #endif 1299 1300 #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL_BRIDGE) 1301 struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node *node, 1302 u32 port, u32 endpoint); 1303 struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, struct device_node *node, 1304 u32 port, u32 endpoint); 1305 #else 1306 static inline struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, 1307 struct device_node *node, 1308 u32 port, 1309 u32 endpoint) 1310 { 1311 return ERR_PTR(-ENODEV); 1312 } 1313 1314 static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, 1315 struct device_node *node, 1316 u32 port, 1317 u32 endpoint) 1318 { 1319 return ERR_PTR(-ENODEV); 1320 } 1321 #endif 1322 1323 void devm_drm_put_bridge(struct device *dev, struct drm_bridge *bridge); 1324 1325 void drm_bridge_debugfs_params(struct dentry *root); 1326 void drm_bridge_debugfs_encoder_params(struct dentry *root, struct drm_encoder *encoder); 1327 1328 #endif 1329