hdcp_qseecom.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __HDCP_QSEECOM_H__
  6. #define __HDCP_QSEECOM_H__
  7. #include <linux/hdcp_qseecom.h>
  8. #include <linux/kernel.h>
  9. #include <linux/slab.h>
  10. #include <linux/types.h>
  11. #include "hdcp_main.h"
  12. /*
  13. * @max_hdcp_key_verify_retries - Max number of retries by default set to 0 which
  14. * is equivalent to 0MS. Actual value will be the one
  15. * from the dtsi file.
  16. */
  17. struct hdcp1_qsee_handle {
  18. struct qseecom_handle *qseecom_handle;
  19. struct qseecom_handle *hdcpops_handle;
  20. bool feature_supported;
  21. uint32_t device_type;
  22. enum hdcp_state hdcp_state;
  23. char *app_name;
  24. uint32_t max_hdcp_key_verify_retries;
  25. };
  26. /*
  27. * If Qseecomd starts late and hdcp key
  28. * verification has already started, qseecomd_down
  29. * flag will be set to true. It will be set to false
  30. * once the Qseecomd is up. Initial assumption is
  31. * that the Qseecomd will start in time.
  32. */
  33. static bool qseecomd_down;
  34. /*
  35. * @max_hdcp_key_verify_retries - Max number of retries by default set to 0 which
  36. * is equivalent to 0MS. Actual value will be the one
  37. * from the dtsi file.
  38. */
  39. struct hdcp2_qsee_handle {
  40. struct hdcp2_app_data app_data;
  41. uint32_t tz_ctxhandle;
  42. bool feature_supported;
  43. enum hdcp_state hdcp_state;
  44. struct qseecom_handle *qseecom_handle;
  45. struct qseecom_handle *hdcpsrm_qseecom_handle;
  46. uint32_t session_id;
  47. bool legacy_app;
  48. uint32_t device_type;
  49. char *app_name;
  50. unsigned char *req_buf;
  51. unsigned char *res_buf;
  52. int (*app_init)(struct hdcp2_qsee_handle *handle);
  53. int (*tx_init)(struct hdcp2_qsee_handle *handle);
  54. uint32_t max_hdcp_key_verify_retries;
  55. };
  56. struct hdcp1_key_set_req {
  57. uint32_t commandid;
  58. } __packed;
  59. struct hdcp1_key_set_rsp {
  60. uint32_t commandid;
  61. uint32_t ret;
  62. uint8_t ksv[HDCP1_AKSV_SIZE];
  63. } __packed;
  64. struct hdcp1_ops_notify_req {
  65. uint32_t commandid;
  66. uint32_t device_type;
  67. uint8_t recv_id_list[MAX_REC_ID_LIST_SIZE];
  68. int32_t recv_id_len;
  69. struct hdcp1_topology topology;
  70. bool is_authenticated;
  71. } __packed;
  72. struct hdcp1_ops_notify_rsp {
  73. uint32_t commandid;
  74. uint32_t ret;
  75. } __packed;
  76. struct hdcp1_set_enc_req {
  77. uint32_t commandid;
  78. uint32_t enable;
  79. } __packed;
  80. struct hdcp1_set_enc_rsp {
  81. uint32_t commandid;
  82. uint32_t ret;
  83. } __packed;
  84. struct hdcp1_key_verify_req {
  85. uint32_t commandid;
  86. uint32_t key_type;
  87. } __packed;
  88. struct hdcp1_key_verify_rsp {
  89. uint32_t commandId;
  90. uint32_t ret;
  91. } __packed;
  92. struct hdcp_init_v1_req {
  93. uint32_t commandid;
  94. } __packed;
  95. struct hdcp_init_v1_rsp {
  96. uint32_t status;
  97. uint32_t commandid;
  98. uint32_t ctxhandle;
  99. uint32_t timeout;
  100. uint32_t msglen;
  101. uint8_t message[MAX_TX_MESSAGE_SIZE];
  102. } __packed;
  103. struct hdcp_init_req {
  104. uint32_t commandid;
  105. uint32_t clientversion;
  106. } __packed;
  107. struct hdcp_init_rsp {
  108. uint32_t status;
  109. uint32_t commandid;
  110. uint32_t appversion;
  111. } __packed;
  112. struct hdcp_session_init_req {
  113. uint32_t commandid;
  114. uint32_t deviceid;
  115. } __packed;
  116. struct hdcp_session_init_rsp {
  117. uint32_t status;
  118. uint32_t commandid;
  119. uint32_t sessionid;
  120. } __packed;
  121. struct hdcp_tx_init_v1_req {
  122. uint32_t commandid;
  123. } __packed;
  124. struct hdcp_tx_init_v1_rsp {
  125. uint32_t status;
  126. uint32_t commandid;
  127. uint32_t ctxhandle;
  128. uint32_t timeout;
  129. uint32_t msglen;
  130. uint8_t message[MAX_TX_MESSAGE_SIZE];
  131. } __packed;
  132. struct hdcp_tx_init_req {
  133. uint32_t commandid;
  134. uint32_t sessionid;
  135. } __packed;
  136. struct hdcp_tx_init_rsp {
  137. uint32_t status;
  138. uint32_t commandid;
  139. uint32_t ctxhandle;
  140. } __packed;
  141. struct hdcp_version_req {
  142. uint32_t commandid;
  143. } __packed;
  144. struct hdcp_version_rsp {
  145. uint32_t status;
  146. uint32_t commandId;
  147. uint32_t appversion;
  148. } __packed;
  149. struct hdcp_session_open_stream_req {
  150. uint32_t commandid;
  151. uint32_t sessionid;
  152. uint32_t vcpayloadid;
  153. uint32_t stream_number;
  154. uint32_t streamMediaType;
  155. } __packed;
  156. struct hdcp_session_open_stream_rsp {
  157. uint32_t status;
  158. uint32_t commandid;
  159. uint32_t streamid;
  160. } __packed;
  161. struct hdcp_session_close_stream_req {
  162. uint32_t commandid;
  163. uint32_t sessionid;
  164. uint32_t streamid;
  165. } __packed;
  166. struct hdcp_session_close_stream_rsp {
  167. uint32_t status;
  168. uint32_t commandid;
  169. } __packed;
  170. struct hdcp_force_encryption_req {
  171. uint32_t commandid;
  172. uint32_t ctxhandle;
  173. uint32_t enable;
  174. } __packed;
  175. struct hdcp_force_encryption_rsp {
  176. uint32_t status;
  177. uint32_t commandid;
  178. } __packed;
  179. struct hdcp_tx_deinit_req {
  180. uint32_t commandid;
  181. uint32_t ctxhandle;
  182. } __packed;
  183. struct hdcp_tx_deinit_rsp {
  184. uint32_t status;
  185. uint32_t commandid;
  186. } __packed;
  187. struct hdcp_session_deinit_req {
  188. uint32_t commandid;
  189. uint32_t sessionid;
  190. } __packed;
  191. struct hdcp_session_deinit_rsp {
  192. uint32_t status;
  193. uint32_t commandid;
  194. } __packed;
  195. struct hdcp_deinit_req {
  196. uint32_t commandid;
  197. } __packed;
  198. struct hdcp_deinit_rsp {
  199. uint32_t status;
  200. uint32_t commandid;
  201. } __packed;
  202. struct hdcp_query_stream_type_req {
  203. uint32_t commandid;
  204. uint32_t ctxhandle;
  205. } __packed;
  206. struct hdcp_query_stream_type_rsp {
  207. uint32_t status;
  208. uint32_t commandid;
  209. uint32_t timeout;
  210. uint32_t msglen;
  211. uint8_t msg[MAX_TX_MESSAGE_SIZE];
  212. } __packed;
  213. struct hdcp_set_hw_key_req {
  214. uint32_t commandid;
  215. uint32_t ctxhandle;
  216. } __packed;
  217. struct hdcp_set_hw_key_rsp {
  218. uint32_t status;
  219. uint32_t commandid;
  220. } __packed;
  221. struct hdcp_send_timeout_req {
  222. uint32_t commandid;
  223. uint32_t ctxhandle;
  224. } __packed;
  225. struct hdcp_send_timeout_rsp {
  226. uint32_t status;
  227. uint32_t commandid;
  228. uint32_t timeout;
  229. uint32_t msglen;
  230. uint8_t message[MAX_TX_MESSAGE_SIZE];
  231. } __packed;
  232. struct hdcp_start_auth_req {
  233. uint32_t commandid;
  234. uint32_t ctxHandle;
  235. } __packed;
  236. struct hdcp_start_auth_rsp {
  237. uint32_t status;
  238. uint32_t commandid;
  239. uint32_t ctxhandle;
  240. uint32_t timeout;
  241. uint32_t msglen;
  242. uint8_t message[MAX_TX_MESSAGE_SIZE];
  243. } __packed;
  244. struct hdcp_rcvd_msg_req {
  245. uint32_t commandid;
  246. uint32_t ctxhandle;
  247. uint32_t msglen;
  248. uint8_t msg[MAX_RX_MESSAGE_SIZE];
  249. } __packed;
  250. struct hdcp_rcvd_msg_rsp {
  251. uint32_t status;
  252. uint32_t commandid;
  253. uint32_t state;
  254. uint32_t timeout;
  255. uint32_t flag;
  256. uint32_t msglen;
  257. uint8_t msg[MAX_TX_MESSAGE_SIZE];
  258. } __packed;
  259. struct hdcp_verify_key_req {
  260. uint32_t commandid;
  261. } __packed;
  262. struct hdcp_verify_key_rsp {
  263. uint32_t status;
  264. uint32_t commandId;
  265. } __packed;
  266. #define HDCP1_SET_KEY 202
  267. #define HDCP1_KEY_VERIFY 204
  268. #define HDCP1_SET_ENC 205
  269. /* DP device type */
  270. #define DEVICE_TYPE_DP 0x8002
  271. void *hdcp1_init_qseecom(void);
  272. bool hdcp1_feature_supported_qseecom(void *data);
  273. int hdcp1_set_enc_qseecom(void *data, bool enable);
  274. int hdcp1_ops_notify_qseecom(void *data, void *topo, bool is_authenticated);
  275. int hdcp1_start_qseecom(void *data, u32 *aksv_msb, u32 *aksv_lsb);
  276. void hdcp1_stop_qseecom(void *data);
  277. void *hdcp2_init_qseecom(u32 device_type);
  278. void hdcp2_deinit_qseecom(void *ctx);
  279. int hdcp2_app_start_qseecom(void *ctx, uint32_t req_len);
  280. int hdcp2_app_start_auth_qseecom(void *ctx, uint32_t req_len);
  281. int hdcp2_app_process_msg_qseecom(void *ctx, uint32_t req_len);
  282. int hdcp2_app_timeout_qseecom(void *ctx, uint32_t req_len);
  283. int hdcp2_app_enable_encryption_qseecom(void *ctx, uint32_t req_len);
  284. int hdcp2_app_query_stream_qseecom(void *ctx, uint32_t req_len);
  285. int hdcp2_app_stop_qseecom(void *ctx);
  286. bool hdcp2_feature_supported_qseecom(void *ctx);
  287. int hdcp2_force_encryption_qseecom(void *ctx, uint32_t enable);
  288. int hdcp2_open_stream_qseecom(void *ctx, uint8_t vc_payload_id,
  289. uint8_t stream_number, uint32_t *stream_id);
  290. int hdcp2_close_stream_qseecom(void *ctx, uint32_t stream_id);
  291. int hdcp2_update_app_data_qseecom(void *ctx, struct hdcp2_app_data *app_data);
  292. #endif /* __HDCP_QSEECOM_H__ */