dp_aux_bridge.h 4.3 KB

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