sde_hdcp_2x.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __SDE_HDCP_2X_H__
  6. #define __SDE_HDCP_2X_H__
  7. #include "sde_hdcp.h"
  8. #define TO_STR(x) #x
  9. #define HDCP_MAX_MESSAGE_PARTS 4
  10. /**
  11. * enum sde_hdcp_2x_wakeup_cmd - commands for interacting with HDCP driver
  12. * @HDCP_2X_CMD_INVALID: initialization value
  13. * @HDCP_2X_CMD_START: start HDCP driver
  14. * @HDCP_2X_CMD_START_AUTH: start authentication
  15. * @HDCP_2X_CMD_STOP: stop HDCP driver
  16. * @HDCP_2X_CMD_MSG_SEND_SUCCESS: sending message to sink succeeded
  17. * @HDCP_2X_CMD_MSG_SEND_FAILED: sending message to sink failed
  18. * @HDCP_2X_CMD_MSG_SEND_TIMEOUT: sending message to sink timed out
  19. * @HDCP_2X_CMD_MSG_RECV_SUCCESS: receiving message from sink succeeded
  20. * @HDCP_2X_CMD_MSG_RECV_FAILED: receiving message from sink failed
  21. * @HDCP_2X_CMD_MSG_RECV_TIMEOUT: receiving message from sink timed out
  22. * @HDCP_2X_CMD_QUERY_STREAM_TYPE: start content stream processing
  23. * @HDCP_2X_CMD_LINK_FAILED: link failure notification
  24. * @HDCP_2X_CMD_MIN_ENC_LEVEL: trigger minimum encryption level change
  25. * @HDCP_2X_CMD_OPEN_STREAMS: open a virtual channel
  26. * @HDCP_2X_CMD_CLOSE_STREAMS: close a virtual channel
  27. */
  28. enum sde_hdcp_2x_wakeup_cmd {
  29. HDCP_2X_CMD_INVALID,
  30. HDCP_2X_CMD_ENABLE,
  31. HDCP_2X_CMD_DISABLE,
  32. HDCP_2X_CMD_START,
  33. HDCP_2X_CMD_START_AUTH,
  34. HDCP_2X_CMD_STOP,
  35. HDCP_2X_CMD_MSG_SEND_SUCCESS,
  36. HDCP_2X_CMD_MSG_SEND_FAILED,
  37. HDCP_2X_CMD_MSG_SEND_TIMEOUT,
  38. HDCP_2X_CMD_MSG_RECV_SUCCESS,
  39. HDCP_2X_CMD_MSG_RECV_FAILED,
  40. HDCP_2X_CMD_MSG_RECV_TIMEOUT,
  41. HDCP_2X_CMD_QUERY_STREAM_TYPE,
  42. HDCP_2X_CMD_LINK_FAILED,
  43. HDCP_2X_CMD_MIN_ENC_LEVEL,
  44. HDCP_2X_CMD_OPEN_STREAMS,
  45. HDCP_2X_CMD_CLOSE_STREAMS,
  46. };
  47. /**
  48. * enum hdcp_transport_wakeup_cmd - commands to instruct display transport layer
  49. * @HDCP_TRANSPORT_CMD_INVALID: initialization value
  50. * @HDCP_TRANSPORT_CMD_SEND_MESSAGE: send message to sink
  51. * @HDCP_TRANSPORT_CMD_RECV_MESSAGE: receive message from sink
  52. * @HDCP_TRANSPORT_CMD_STATUS_SUCCESS: successfully communicated with TrustZone
  53. * @HDCP_TRANSPORT_CMD_STATUS_FAILED: failed to communicate with TrustZone
  54. * @HDCP_TRANSPORT_CMD_LINK_POLL: poll the HDCP link
  55. * @HDCP_TRANSPORT_CMD_LINK_CHECK: check link status in response to cp_irq
  56. * @HDCP_TRANSPORT_CMD_AUTHENTICATE: start authentication
  57. */
  58. enum hdcp_transport_wakeup_cmd {
  59. HDCP_TRANSPORT_CMD_INVALID,
  60. HDCP_TRANSPORT_CMD_SEND_MESSAGE,
  61. HDCP_TRANSPORT_CMD_RECV_MESSAGE,
  62. HDCP_TRANSPORT_CMD_STATUS_SUCCESS,
  63. HDCP_TRANSPORT_CMD_STATUS_FAILED,
  64. HDCP_TRANSPORT_CMD_LINK_POLL,
  65. HDCP_TRANSPORT_CMD_LINK_CHECK,
  66. HDCP_TRANSPORT_CMD_AUTHENTICATE,
  67. };
  68. enum sde_hdcp_2x_device_type {
  69. HDCP_TXMTR_HDMI = 0x8001,
  70. HDCP_TXMTR_DP = 0x8002,
  71. HDCP_TXMTR_DP_MST = 0x8003
  72. };
  73. /**
  74. * struct sde_hdcp_2x_lib_wakeup_data - command and data send to HDCP driver
  75. * @cmd: command type
  76. * @device_type type of device in use by the HDCP driver
  77. * @context: void pointer to the HDCP driver instance
  78. * @buf: message received from the sink
  79. * @buf_len: length of message received from the sink
  80. * @timeout: time out value for timed transactions
  81. * @streams: list indicating which streams need adjustment
  82. * @num_streams: number of entries in streams
  83. */
  84. struct sde_hdcp_2x_wakeup_data {
  85. enum sde_hdcp_2x_wakeup_cmd cmd;
  86. enum sde_hdcp_2x_device_type device_type;
  87. void *context;
  88. uint32_t total_message_length;
  89. uint32_t timeout;
  90. u8 min_enc_level;
  91. struct stream_info *streams;
  92. u8 num_streams;
  93. };
  94. /**
  95. * struct sde_hdcp_2x_msg_part - a single part of an HDCP 2.2 message
  96. * @name: user readable message name
  97. * @offset: message part offset
  98. * @length message part length
  99. */
  100. struct sde_hdcp_2x_msg_part {
  101. char *name;
  102. uint32_t offset;
  103. uint32_t length;
  104. };
  105. /**
  106. * struct sde_hdcp_2x_msg_data - HDCP 2.2 message containing one or more parts
  107. * @num_messages: total number of parts in a full message
  108. * @messages: array containing num_messages parts
  109. * @rx_status: value of rx_status register
  110. */
  111. struct sde_hdcp_2x_msg_data {
  112. uint32_t num_messages;
  113. struct sde_hdcp_2x_msg_part messages[HDCP_MAX_MESSAGE_PARTS];
  114. uint8_t rx_status;
  115. };
  116. /**
  117. * struct hdcp_transport_wakeup_data - data sent to display transport layer
  118. * @cmd: command type
  119. * @context: void pointer to the display transport layer
  120. * @send_msg_buf: buffer containing message to be sent to sink
  121. * @send_msg_len: length of the message to be sent to sink
  122. * @timeout: timeout value for timed transactions
  123. * @abort_mask: mask used to determine whether HDCP link is valid
  124. * @message_data: a pointer to the message description
  125. */
  126. struct hdcp_transport_wakeup_data {
  127. enum hdcp_transport_wakeup_cmd cmd;
  128. void *context;
  129. unsigned char *buf;
  130. u32 buf_len;
  131. u32 timeout;
  132. u8 abort_mask;
  133. const struct sde_hdcp_2x_msg_data *message_data;
  134. };
  135. static inline const char *sde_hdcp_2x_cmd_to_str(
  136. enum sde_hdcp_2x_wakeup_cmd cmd)
  137. {
  138. switch (cmd) {
  139. case HDCP_2X_CMD_START:
  140. return TO_STR(HDCP_2X_CMD_START);
  141. case HDCP_2X_CMD_STOP:
  142. return TO_STR(HDCP_2X_CMD_STOP);
  143. case HDCP_2X_CMD_MSG_SEND_SUCCESS:
  144. return TO_STR(HDCP_2X_CMD_MSG_SEND_SUCCESS);
  145. case HDCP_2X_CMD_MSG_SEND_FAILED:
  146. return TO_STR(HDCP_2X_CMD_MSG_SEND_FAILED);
  147. case HDCP_2X_CMD_MSG_SEND_TIMEOUT:
  148. return TO_STR(HDCP_2X_CMD_MSG_SEND_TIMEOUT);
  149. case HDCP_2X_CMD_MSG_RECV_SUCCESS:
  150. return TO_STR(HDCP_2X_CMD_MSG_RECV_SUCCESS);
  151. case HDCP_2X_CMD_MSG_RECV_FAILED:
  152. return TO_STR(HDCP_2X_CMD_MSG_RECV_FAILED);
  153. case HDCP_2X_CMD_MSG_RECV_TIMEOUT:
  154. return TO_STR(HDCP_2X_CMD_MSG_RECV_TIMEOUT);
  155. case HDCP_2X_CMD_QUERY_STREAM_TYPE:
  156. return TO_STR(HDCP_2X_CMD_QUERY_STREAM_TYPE);
  157. case HDCP_2X_CMD_OPEN_STREAMS:
  158. return TO_STR(HDCP_2X_CMD_OPEN_STREAMS);
  159. case HDCP_2X_CMD_CLOSE_STREAMS:
  160. return TO_STR(HDCP_2X_CMD_CLOSE_STREAMS);
  161. default:
  162. return "UNKNOWN";
  163. }
  164. }
  165. static inline const char *hdcp_transport_cmd_to_str(
  166. enum hdcp_transport_wakeup_cmd cmd)
  167. {
  168. switch (cmd) {
  169. case HDCP_TRANSPORT_CMD_SEND_MESSAGE:
  170. return TO_STR(HDCP_TRANSPORT_CMD_SEND_MESSAGE);
  171. case HDCP_TRANSPORT_CMD_RECV_MESSAGE:
  172. return TO_STR(HDCP_TRANSPORT_CMD_RECV_MESSAGE);
  173. case HDCP_TRANSPORT_CMD_STATUS_SUCCESS:
  174. return TO_STR(HDCP_TRANSPORT_CMD_STATUS_SUCCESS);
  175. case HDCP_TRANSPORT_CMD_STATUS_FAILED:
  176. return TO_STR(HDCP_TRANSPORT_CMD_STATUS_FAILED);
  177. case HDCP_TRANSPORT_CMD_LINK_POLL:
  178. return TO_STR(HDCP_TRANSPORT_CMD_LINK_POLL);
  179. case HDCP_TRANSPORT_CMD_AUTHENTICATE:
  180. return TO_STR(HDCP_TRANSPORT_CMD_AUTHENTICATE);
  181. default:
  182. return "UNKNOWN";
  183. }
  184. }
  185. struct sde_hdcp_2x_ops {
  186. int (*wakeup)(struct sde_hdcp_2x_wakeup_data *data);
  187. bool (*feature_supported)(void *data);
  188. void (*force_encryption)(void *data, bool enable);
  189. };
  190. struct hdcp_transport_ops {
  191. int (*wakeup)(struct hdcp_transport_wakeup_data *data);
  192. };
  193. struct sde_hdcp_2x_register_data {
  194. struct hdcp_transport_ops *client_ops;
  195. struct sde_hdcp_2x_ops *ops;
  196. void *client_data;
  197. void **hdcp_data;
  198. };
  199. /* functions for the HDCP 2.2 state machine module */
  200. int sde_hdcp_2x_register(struct sde_hdcp_2x_register_data *data);
  201. void sde_hdcp_2x_deregister(void *data);
  202. #endif