dp_mst_sim_helper.h 4.6 KB

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