dp_aux_bridge.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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/types.h>
  39. #include <drm/drm_dp_helper.h>
  40. /**
  41. * enum dp_aux_bridge_flag - DP aux bridge capability flag
  42. * DP_AUX_BRIDGE_HPD: HPD will be generated by DP aux bridge
  43. * DP_AUX_BRIDGE_MST: MST simulator is used by DP aux bridge
  44. */
  45. enum dp_aux_bridge_flag {
  46. DP_AUX_BRIDGE_HPD = (1 << 0),
  47. DP_AUX_BRIDGE_MST = (1 << 1),
  48. };
  49. /**
  50. * struct dp_aux_bridge - DP aux bridge control structure
  51. * @of_node: device node pointer to the bridge
  52. * @dev_priv: pointer to the bridge driver's internal context
  53. * @flag: flag for capability
  54. * @mst_ctx: pointer to mst context when DP_AUX_BRIDGE_MST is set
  55. * @head: to keep track of all added bridges
  56. */
  57. struct dp_aux_bridge {
  58. #if IS_ENABLED(CONFIG_OF)
  59. struct device_node *of_node;
  60. #endif /* CONFIG_OF */
  61. void *dev_priv;
  62. u32 flag;
  63. void *mst_ctx;
  64. struct list_head head;
  65. /**
  66. * @register_hpd:
  67. *
  68. * This callback is invoked whenever bridge is registered
  69. * for HPD handling
  70. *
  71. * The attach callback is optional.
  72. *
  73. * Host will pass HPD callback handle to bridge, with
  74. * arguments @hpd_cb(void* dev, bool hpd, bool hpd_irq):
  75. *
  76. * @dev: private handle passed in register_hpd
  77. * @hpd: true if HPD is high, false if HPD is low
  78. * @hpd_irq: true if this is a HPD irq. @hpd will be
  79. * ignored when hpd_irq is true.
  80. *
  81. * RETURNS:
  82. *
  83. * Zero on success, error code on failure.
  84. */
  85. int (*register_hpd)(struct dp_aux_bridge *bridge,
  86. int (*hpd_cb)(void *, bool, bool), void *dev);
  87. /**
  88. * @transfer:
  89. *
  90. * This callback is invoked whenever dp_aux transfer
  91. * is called from host. Inside @transfer bridge can still
  92. * call @drm_aux->transfer to trigger the actual
  93. * DPCD/I2C transfer at host side.
  94. *
  95. * The attach callback is optional.
  96. *
  97. * RETURNS:
  98. *
  99. * Size of the bytes transferred, error code on failure.
  100. */
  101. ssize_t (*transfer)(struct dp_aux_bridge *bridge,
  102. struct drm_dp_aux *drm_aux,
  103. struct drm_dp_aux_msg *msg);
  104. };
  105. /**
  106. * dp_aux_add_bridge - Register DP aux bridge
  107. * @bridge: bridge pointer
  108. * return: 0 if successful
  109. */
  110. int dp_aux_add_bridge(struct dp_aux_bridge *bridge);
  111. #if IS_ENABLED(CONFIG_OF)
  112. /**
  113. * of_dp_aux_find_bridge - Find registered DP aux bridge
  114. * @np: device node pointer to the bridge
  115. * return: DP aux bridge pointer, NULL if not found
  116. */
  117. struct dp_aux_bridge *of_dp_aux_find_bridge(struct device_node *np);
  118. #endif /* CONFIG_OF */
  119. #endif /* _DP_AUX_BRIDGE_H_ */