dp_mst_sim_helper.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Copyright (c) 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) 2014 Red Hat.
  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_MST_SIM_HELPER_H_
  37. #define _DP_MST_SIM_HELPER_H_
  38. #include <linux/types.h>
  39. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0))
  40. #include <drm/display/drm_dp_helper.h>
  41. #else
  42. #include <drm/drm_dp_helper.h>
  43. #endif
  44. /**
  45. * struct dp_mst_sim_port - MST port configuration
  46. * @input: if this port is an input port.
  47. * @mcs: message capability status - DP 1.2 spec.
  48. * @ddps: DisplayPort Device Plug Status - DP 1.2
  49. * @pdt: Peer Device Type
  50. * @ldps: Legacy Device Plug Status
  51. * @dpcd_rev: DPCD revision of device on this port
  52. * @peer_guid: Peer GUID on this port
  53. * @num_sdp_streams: Number of simultaneous streams
  54. * @num_sdp_stream_sinks: Number of stream sinks
  55. * @full_pbn: Full bandwidth for this port.
  56. * @avail_pbn: Available bandwidth for this port.
  57. * @edid: EDID data on this port.
  58. * @edid_size: size of EDID data on this port.
  59. */
  60. struct dp_mst_sim_port {
  61. bool input;
  62. bool mcs;
  63. bool ddps;
  64. u8 pdt;
  65. bool ldps;
  66. u8 dpcd_rev;
  67. u8 peer_guid[16];
  68. u8 num_sdp_streams;
  69. u8 num_sdp_stream_sinks;
  70. u16 full_pbn;
  71. u16 avail_pbn;
  72. const u8 *edid;
  73. u32 edid_size;
  74. };
  75. /**
  76. * struct dp_mst_sim_cfg - MST simulator configuration
  77. * @host_dev: host device pointer used in callback functions
  78. * @guid: GUID of the top MST branch.
  79. */
  80. struct dp_mst_sim_cfg {
  81. void *host_dev;
  82. u8 guid[16];
  83. /**
  84. * @host_hpd_irq:
  85. *
  86. * This callback is invoked whenever simulator need to
  87. * notify host that there is a HPD_IRQ.
  88. * @host_dev: host_dev pointer
  89. */
  90. void (*host_hpd_irq)(void *host_dev);
  91. /**
  92. * @host_req:
  93. *
  94. * This callback is invoked whenever simulator's reply is ready
  95. * to response downstream request. Host can use this function
  96. * to replace the reply generated by simulator.
  97. * @host_dev: host_dev pointer
  98. * @in: pointer of downstream request buffer to simulator
  99. * @in_size: size of downstream request buffer to simulator
  100. * @out: pointer of downstream reply from simulator
  101. * @out_size: pointer of size of downstream reply from simulator
  102. *
  103. * This callback is optional.
  104. */
  105. void (*host_req)(void *host_dev, const u8 *in, int in_size,
  106. u8 *out, int *out_size);
  107. };
  108. /**
  109. * dp_mst_sim_create - Create simulator context
  110. * @cfg: see dp_mst_sim_cfg
  111. * @mst_sim_context: simulator context returned
  112. * return: 0 if successful
  113. */
  114. int dp_mst_sim_create(const struct dp_mst_sim_cfg *cfg,
  115. void **mst_sim_context);
  116. /**
  117. * dp_mst_sim_destroy - Destroy simulator context
  118. * @mst_sim_context: simulator context
  119. * return: 0 if successful
  120. */
  121. int dp_mst_sim_destroy(void *mst_sim_context);
  122. /**
  123. * dp_mst_sim_transfer - Send aux message to simulator context
  124. * @mst_sim_context: simulator context
  125. * @msg: aux message
  126. * return: 0 if successful
  127. */
  128. int dp_mst_sim_transfer(void *mst_sim_context, struct drm_dp_aux_msg *msg);
  129. /**
  130. * dp_mst_sim_update - Update port configuration
  131. * @mst_sim_context: simulator context
  132. * @port_num: number of ports
  133. * @ports: ports configuration
  134. * return: 0 if successful
  135. */
  136. int dp_mst_sim_update(void *mst_sim_context, u32 port_num,
  137. struct dp_mst_sim_port *ports);
  138. #endif /* _DP_MST_SIM_HELPER_H_ */