dp_aux_bridge.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. /*
  15. * Copyright (c) 2016 Intel Corporation
  16. *
  17. * Permission to use, copy, modify, distribute, and sell this software and its
  18. * documentation for any purpose is hereby granted without fee, provided that
  19. * the above copyright notice appear in all copies and that both that copyright
  20. * notice and this permission notice appear in supporting documentation, and
  21. * that the name of the copyright holders not be used in advertising or
  22. * publicity pertaining to distribution of the software without specific,
  23. * written prior permission. The copyright holders make no representations
  24. * about the suitability of this software for any purpose. It is provided "as
  25. * is" without express or implied warranty.
  26. *
  27. * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  28. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  29. * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  30. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  31. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  32. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  33. * OF THIS SOFTWARE.
  34. */
  35. #ifndef _DP_AUX_BRIDGE_H_
  36. #define _DP_AUX_BRIDGE_H_
  37. #include <linux/types.h>
  38. #include <drm/drm_dp_helper.h>
  39. /**
  40. * enum dp_aux_bridge_flag - DP aux bridge capability flag
  41. * DP_AUX_BRIDGE_HPD: HPD will be generated by DP aux bridge
  42. * DP_AUX_BRIDGE_MST: MST simulator is used by DP aux bridge
  43. */
  44. enum dp_aux_bridge_flag {
  45. DP_AUX_BRIDGE_HPD = (1 << 0),
  46. DP_AUX_BRIDGE_MST = (1 << 1),
  47. };
  48. /**
  49. * struct dp_aux_bridge - DP aux bridge control structure
  50. * @of_node: device node pointer to the bridge
  51. * @dev_priv: pointer to the bridge driver's internal context
  52. * @flag: flag for capability
  53. * @mst_ctx: pointer to mst context when DP_AUX_BRIDGE_MST is set
  54. * @head: to keep track of all added bridges
  55. */
  56. struct dp_aux_bridge {
  57. #ifdef CONFIG_OF
  58. struct device_node *of_node;
  59. #endif
  60. void *dev_priv;
  61. u32 flag;
  62. void *mst_ctx;
  63. struct list_head head;
  64. /**
  65. * @register_hpd:
  66. *
  67. * This callback is invoked whenever bridge is registered
  68. * for HPD handling
  69. *
  70. * The attach callback is optional.
  71. *
  72. * Host will pass HPD callback handle to bridge, with
  73. * arguments @hpd_cb(void* dev, bool hpd, bool hpd_irq):
  74. *
  75. * @dev: private handle passed in register_hpd
  76. * @hpd: true if HPD is high, false if HPD is low
  77. * @hpd_irq: true if this is a HPD irq. @hpd will be
  78. * ignored when hpd_irq is true.
  79. *
  80. * RETURNS:
  81. *
  82. * Zero on success, error code on failure.
  83. */
  84. int (*register_hpd)(struct dp_aux_bridge *bridge,
  85. int (*hpd_cb)(void *, bool, bool), void *dev);
  86. /**
  87. * @transfer:
  88. *
  89. * This callback is invoked whenever dp_aux transfer
  90. * is called from host. Inside @transfer bridge can still
  91. * call @drm_aux->transfer to trigger the actual
  92. * DPCD/I2C transfer at host side.
  93. *
  94. * The attach callback is optional.
  95. *
  96. * RETURNS:
  97. *
  98. * Size of the bytes transferred, error code on failure.
  99. */
  100. ssize_t (*transfer)(struct dp_aux_bridge *bridge,
  101. struct drm_dp_aux *drm_aux,
  102. struct drm_dp_aux_msg *msg);
  103. };
  104. /**
  105. * dp_aux_add_bridge - Register DP aux bridge
  106. * @bridge: bridge pointer
  107. * return: 0 if successful
  108. */
  109. int dp_aux_add_bridge(struct dp_aux_bridge *bridge);
  110. #ifdef CONFIG_OF
  111. /**
  112. * of_dp_aux_find_bridge - Find registered DP aux bridge
  113. * @np: device node pointer to the bridge
  114. * return: DP aux bridge pointer, NULL if not found
  115. */
  116. struct dp_aux_bridge *of_dp_aux_find_bridge(struct device_node *np);
  117. #endif
  118. #endif /* _DP_AUX_BRIDGE_H_ */