sde_hdcp_2x.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2020, 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. * @transaction_timeout: maximum duration to read/write message from/to sink
  111. */
  112. struct sde_hdcp_2x_msg_data {
  113. uint32_t num_messages;
  114. struct sde_hdcp_2x_msg_part messages[HDCP_MAX_MESSAGE_PARTS];
  115. uint8_t rx_status;
  116. uint32_t transaction_timeout;
  117. };
  118. /**
  119. * struct hdcp_transport_wakeup_data - data sent to display transport layer
  120. * @cmd: command type
  121. * @context: void pointer to the display transport layer
  122. * @send_msg_buf: buffer containing message to be sent to sink
  123. * @send_msg_len: length of the message to be sent to sink
  124. * @timeout: timeout value for timed transactions
  125. * @abort_mask: mask used to determine whether HDCP link is valid
  126. * @message_data: a pointer to the message description
  127. * @transaction_delay: amount of time to delay before performing transaction
  128. * @transaction_timeout: maximum duration to read/write message from/to sink
  129. */
  130. struct hdcp_transport_wakeup_data {
  131. enum hdcp_transport_wakeup_cmd cmd;
  132. void *context;
  133. unsigned char *buf;
  134. u32 buf_len;
  135. u32 transaction_delay;
  136. u32 transaction_timeout;
  137. u8 abort_mask;
  138. const struct sde_hdcp_2x_msg_data *message_data;
  139. };
  140. static inline const char *sde_hdcp_2x_cmd_to_str(
  141. enum sde_hdcp_2x_wakeup_cmd cmd)
  142. {
  143. switch (cmd) {
  144. case HDCP_2X_CMD_START:
  145. return TO_STR(HDCP_2X_CMD_START);
  146. case HDCP_2X_CMD_STOP:
  147. return TO_STR(HDCP_2X_CMD_STOP);
  148. case HDCP_2X_CMD_MSG_SEND_SUCCESS:
  149. return TO_STR(HDCP_2X_CMD_MSG_SEND_SUCCESS);
  150. case HDCP_2X_CMD_MSG_SEND_FAILED:
  151. return TO_STR(HDCP_2X_CMD_MSG_SEND_FAILED);
  152. case HDCP_2X_CMD_MSG_SEND_TIMEOUT:
  153. return TO_STR(HDCP_2X_CMD_MSG_SEND_TIMEOUT);
  154. case HDCP_2X_CMD_MSG_RECV_SUCCESS:
  155. return TO_STR(HDCP_2X_CMD_MSG_RECV_SUCCESS);
  156. case HDCP_2X_CMD_MSG_RECV_FAILED:
  157. return TO_STR(HDCP_2X_CMD_MSG_RECV_FAILED);
  158. case HDCP_2X_CMD_MSG_RECV_TIMEOUT:
  159. return TO_STR(HDCP_2X_CMD_MSG_RECV_TIMEOUT);
  160. case HDCP_2X_CMD_QUERY_STREAM_TYPE:
  161. return TO_STR(HDCP_2X_CMD_QUERY_STREAM_TYPE);
  162. case HDCP_2X_CMD_OPEN_STREAMS:
  163. return TO_STR(HDCP_2X_CMD_OPEN_STREAMS);
  164. case HDCP_2X_CMD_CLOSE_STREAMS:
  165. return TO_STR(HDCP_2X_CMD_CLOSE_STREAMS);
  166. default:
  167. return "UNKNOWN";
  168. }
  169. }
  170. static inline const char *hdcp_transport_cmd_to_str(
  171. enum hdcp_transport_wakeup_cmd cmd)
  172. {
  173. switch (cmd) {
  174. case HDCP_TRANSPORT_CMD_SEND_MESSAGE:
  175. return TO_STR(HDCP_TRANSPORT_CMD_SEND_MESSAGE);
  176. case HDCP_TRANSPORT_CMD_RECV_MESSAGE:
  177. return TO_STR(HDCP_TRANSPORT_CMD_RECV_MESSAGE);
  178. case HDCP_TRANSPORT_CMD_STATUS_SUCCESS:
  179. return TO_STR(HDCP_TRANSPORT_CMD_STATUS_SUCCESS);
  180. case HDCP_TRANSPORT_CMD_STATUS_FAILED:
  181. return TO_STR(HDCP_TRANSPORT_CMD_STATUS_FAILED);
  182. case HDCP_TRANSPORT_CMD_LINK_POLL:
  183. return TO_STR(HDCP_TRANSPORT_CMD_LINK_POLL);
  184. case HDCP_TRANSPORT_CMD_AUTHENTICATE:
  185. return TO_STR(HDCP_TRANSPORT_CMD_AUTHENTICATE);
  186. default:
  187. return "UNKNOWN";
  188. }
  189. }
  190. struct sde_hdcp_2x_ops {
  191. int (*wakeup)(struct sde_hdcp_2x_wakeup_data *data);
  192. bool (*feature_supported)(void *data);
  193. void (*force_encryption)(void *data, bool enable);
  194. };
  195. struct hdcp_transport_ops {
  196. int (*wakeup)(struct hdcp_transport_wakeup_data *data);
  197. };
  198. struct sde_hdcp_2x_register_data {
  199. struct hdcp_transport_ops *client_ops;
  200. struct sde_hdcp_2x_ops *ops;
  201. void *client_data;
  202. void **hdcp_data;
  203. };
  204. /* functions for the HDCP 2.2 state machine module */
  205. int sde_hdcp_2x_register(struct sde_hdcp_2x_register_data *data);
  206. void sde_hdcp_2x_deregister(void *data);
  207. #endif