mei_hdcp.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright © 2019 Intel Corporation
  4. *
  5. * Authors:
  6. * Ramalingam C <[email protected]>
  7. */
  8. #ifndef __MEI_HDCP_H__
  9. #define __MEI_HDCP_H__
  10. #include <drm/display/drm_hdcp.h>
  11. /* me_hdcp_status: Enumeration of all HDCP Status Codes */
  12. enum me_hdcp_status {
  13. ME_HDCP_STATUS_SUCCESS = 0x0000,
  14. /* WiDi Generic Status Codes */
  15. ME_HDCP_STATUS_INTERNAL_ERROR = 0x1000,
  16. ME_HDCP_STATUS_UNKNOWN_ERROR = 0x1001,
  17. ME_HDCP_STATUS_INCORRECT_API_VERSION = 0x1002,
  18. ME_HDCP_STATUS_INVALID_FUNCTION = 0x1003,
  19. ME_HDCP_STATUS_INVALID_BUFFER_LENGTH = 0x1004,
  20. ME_HDCP_STATUS_INVALID_PARAMS = 0x1005,
  21. ME_HDCP_STATUS_AUTHENTICATION_FAILED = 0x1006,
  22. /* WiDi Status Codes */
  23. ME_HDCP_INVALID_SESSION_STATE = 0x6000,
  24. ME_HDCP_SRM_FRAGMENT_UNEXPECTED = 0x6001,
  25. ME_HDCP_SRM_INVALID_LENGTH = 0x6002,
  26. ME_HDCP_SRM_FRAGMENT_OFFSET_INVALID = 0x6003,
  27. ME_HDCP_SRM_VERIFICATION_FAILED = 0x6004,
  28. ME_HDCP_SRM_VERSION_TOO_OLD = 0x6005,
  29. ME_HDCP_RX_CERT_VERIFICATION_FAILED = 0x6006,
  30. ME_HDCP_RX_REVOKED = 0x6007,
  31. ME_HDCP_H_VERIFICATION_FAILED = 0x6008,
  32. ME_HDCP_REPEATER_CHECK_UNEXPECTED = 0x6009,
  33. ME_HDCP_TOPOLOGY_MAX_EXCEEDED = 0x600A,
  34. ME_HDCP_V_VERIFICATION_FAILED = 0x600B,
  35. ME_HDCP_L_VERIFICATION_FAILED = 0x600C,
  36. ME_HDCP_STREAM_KEY_ALLOC_FAILED = 0x600D,
  37. ME_HDCP_BASE_KEY_RESET_FAILED = 0x600E,
  38. ME_HDCP_NONCE_GENERATION_FAILED = 0x600F,
  39. ME_HDCP_STATUS_INVALID_E_KEY_STATE = 0x6010,
  40. ME_HDCP_STATUS_INVALID_CS_ICV = 0x6011,
  41. ME_HDCP_STATUS_INVALID_KB_KEY_STATE = 0x6012,
  42. ME_HDCP_STATUS_INVALID_PAVP_MODE_ICV = 0x6013,
  43. ME_HDCP_STATUS_INVALID_PAVP_MODE = 0x6014,
  44. ME_HDCP_STATUS_LC_MAX_ATTEMPTS = 0x6015,
  45. /* New status for HDCP 2.1 */
  46. ME_HDCP_STATUS_MISMATCH_IN_M = 0x6016,
  47. /* New status code for HDCP 2.2 Rx */
  48. ME_HDCP_STATUS_RX_PROV_NOT_ALLOWED = 0x6017,
  49. ME_HDCP_STATUS_RX_PROV_WRONG_SUBJECT = 0x6018,
  50. ME_HDCP_RX_NEEDS_PROVISIONING = 0x6019,
  51. ME_HDCP_BKSV_ICV_AUTH_FAILED = 0x6020,
  52. ME_HDCP_STATUS_INVALID_STREAM_ID = 0x6021,
  53. ME_HDCP_STATUS_CHAIN_NOT_INITIALIZED = 0x6022,
  54. ME_HDCP_FAIL_NOT_EXPECTED = 0x6023,
  55. ME_HDCP_FAIL_HDCP_OFF = 0x6024,
  56. ME_HDCP_FAIL_INVALID_PAVP_MEMORY_MODE = 0x6025,
  57. ME_HDCP_FAIL_AES_ECB_FAILURE = 0x6026,
  58. ME_HDCP_FEATURE_NOT_SUPPORTED = 0x6027,
  59. ME_HDCP_DMA_READ_ERROR = 0x6028,
  60. ME_HDCP_DMA_WRITE_ERROR = 0x6029,
  61. ME_HDCP_FAIL_INVALID_PACKET_SIZE = 0x6030,
  62. ME_HDCP_H264_PARSING_ERROR = 0x6031,
  63. ME_HDCP_HDCP2_ERRATA_VIDEO_VIOLATION = 0x6032,
  64. ME_HDCP_HDCP2_ERRATA_AUDIO_VIOLATION = 0x6033,
  65. ME_HDCP_TX_ACTIVE_ERROR = 0x6034,
  66. ME_HDCP_MODE_CHANGE_ERROR = 0x6035,
  67. ME_HDCP_STREAM_TYPE_ERROR = 0x6036,
  68. ME_HDCP_STREAM_MANAGE_NOT_POSSIBLE = 0x6037,
  69. ME_HDCP_STATUS_PORT_INVALID_COMMAND = 0x6038,
  70. ME_HDCP_STATUS_UNSUPPORTED_PROTOCOL = 0x6039,
  71. ME_HDCP_STATUS_INVALID_PORT_INDEX = 0x603a,
  72. ME_HDCP_STATUS_TX_AUTH_NEEDED = 0x603b,
  73. ME_HDCP_STATUS_NOT_INTEGRATED_PORT = 0x603c,
  74. ME_HDCP_STATUS_SESSION_MAX_REACHED = 0x603d,
  75. /* hdcp capable bit is not set in rx_caps(error is unique to DP) */
  76. ME_HDCP_STATUS_NOT_HDCP_CAPABLE = 0x6041,
  77. ME_HDCP_STATUS_INVALID_STREAM_COUNT = 0x6042,
  78. };
  79. #define HDCP_API_VERSION 0x00010000
  80. #define HDCP_M_LEN 16
  81. #define HDCP_KH_LEN 16
  82. /* Payload Buffer size(Excluding Header) for CMDs and corresponding response */
  83. /* Wired_Tx_AKE */
  84. #define WIRED_CMD_BUF_LEN_INITIATE_HDCP2_SESSION_IN (4 + 1)
  85. #define WIRED_CMD_BUF_LEN_INITIATE_HDCP2_SESSION_OUT (4 + 8 + 3)
  86. #define WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_IN (4 + 522 + 8 + 3)
  87. #define WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_MIN_OUT (4 + 1 + 3 + 16 + 16)
  88. #define WIRED_CMD_BUF_LEN_VERIFY_RECEIVER_CERT_MAX_OUT (4 + 1 + 3 + 128)
  89. #define WIRED_CMD_BUF_LEN_AKE_SEND_HPRIME_IN (4 + 32)
  90. #define WIRED_CMD_BUF_LEN_AKE_SEND_HPRIME_OUT (4)
  91. #define WIRED_CMD_BUF_LEN_SEND_PAIRING_INFO_IN (4 + 16)
  92. #define WIRED_CMD_BUF_LEN_SEND_PAIRING_INFO_OUT (4)
  93. #define WIRED_CMD_BUF_LEN_CLOSE_SESSION_IN (4)
  94. #define WIRED_CMD_BUF_LEN_CLOSE_SESSION_OUT (4)
  95. /* Wired_Tx_LC */
  96. #define WIRED_CMD_BUF_LEN_INIT_LOCALITY_CHECK_IN (4)
  97. #define WIRED_CMD_BUF_LEN_INIT_LOCALITY_CHECK_OUT (4 + 8)
  98. #define WIRED_CMD_BUF_LEN_VALIDATE_LOCALITY_IN (4 + 32)
  99. #define WIRED_CMD_BUF_LEN_VALIDATE_LOCALITY_OUT (4)
  100. /* Wired_Tx_SKE */
  101. #define WIRED_CMD_BUF_LEN_GET_SESSION_KEY_IN (4)
  102. #define WIRED_CMD_BUF_LEN_GET_SESSION_KEY_OUT (4 + 16 + 8)
  103. /* Wired_Tx_SKE */
  104. #define WIRED_CMD_BUF_LEN_ENABLE_AUTH_IN (4 + 1)
  105. #define WIRED_CMD_BUF_LEN_ENABLE_AUTH_OUT (4)
  106. /* Wired_Tx_Repeater */
  107. #define WIRED_CMD_BUF_LEN_VERIFY_REPEATER_IN (4 + 2 + 3 + 16 + 155)
  108. #define WIRED_CMD_BUF_LEN_VERIFY_REPEATER_OUT (4 + 1 + 16)
  109. #define WIRED_CMD_BUF_LEN_REPEATER_AUTH_STREAM_REQ_MIN_IN (4 + 3 + \
  110. 32 + 2 + 2)
  111. #define WIRED_CMD_BUF_LEN_REPEATER_AUTH_STREAM_REQ_OUT (4)
  112. /* hdcp_command_id: Enumeration of all WIRED HDCP Command IDs */
  113. enum hdcp_command_id {
  114. _WIDI_COMMAND_BASE = 0x00030000,
  115. WIDI_INITIATE_HDCP2_SESSION = _WIDI_COMMAND_BASE,
  116. HDCP_GET_SRM_STATUS,
  117. HDCP_SEND_SRM_FRAGMENT,
  118. /* The wired HDCP Tx commands */
  119. _WIRED_COMMAND_BASE = 0x00031000,
  120. WIRED_INITIATE_HDCP2_SESSION = _WIRED_COMMAND_BASE,
  121. WIRED_VERIFY_RECEIVER_CERT,
  122. WIRED_AKE_SEND_HPRIME,
  123. WIRED_AKE_SEND_PAIRING_INFO,
  124. WIRED_INIT_LOCALITY_CHECK,
  125. WIRED_VALIDATE_LOCALITY,
  126. WIRED_GET_SESSION_KEY,
  127. WIRED_ENABLE_AUTH,
  128. WIRED_VERIFY_REPEATER,
  129. WIRED_REPEATER_AUTH_STREAM_REQ,
  130. WIRED_CLOSE_SESSION,
  131. _WIRED_COMMANDS_COUNT,
  132. };
  133. union encrypted_buff {
  134. u8 e_kpub_km[HDCP_2_2_E_KPUB_KM_LEN];
  135. u8 e_kh_km_m[HDCP_2_2_E_KH_KM_M_LEN];
  136. struct {
  137. u8 e_kh_km[HDCP_KH_LEN];
  138. u8 m[HDCP_M_LEN];
  139. } __packed;
  140. };
  141. /* HDCP HECI message header. All header values are little endian. */
  142. struct hdcp_cmd_header {
  143. u32 api_version;
  144. u32 command_id;
  145. enum me_hdcp_status status;
  146. /* Length of the HECI message (excluding the header) */
  147. u32 buffer_len;
  148. } __packed;
  149. /* Empty command request or response. No data follows the header. */
  150. struct hdcp_cmd_no_data {
  151. struct hdcp_cmd_header header;
  152. } __packed;
  153. /* Uniquely identifies the hdcp port being addressed for a given command. */
  154. struct hdcp_port_id {
  155. u8 integrated_port_type;
  156. /* physical_port is used until Gen11.5. Must be zero for Gen11.5+ */
  157. u8 physical_port;
  158. /* attached_transcoder is for Gen11.5+. Set to zero for <Gen11.5 */
  159. u8 attached_transcoder;
  160. u8 reserved;
  161. } __packed;
  162. /*
  163. * Data structures for integrated wired HDCP2 Tx in
  164. * support of the AKE protocol
  165. */
  166. /* HECI struct for integrated wired HDCP Tx session initiation. */
  167. struct wired_cmd_initiate_hdcp2_session_in {
  168. struct hdcp_cmd_header header;
  169. struct hdcp_port_id port;
  170. u8 protocol; /* for HDMI vs DP */
  171. } __packed;
  172. struct wired_cmd_initiate_hdcp2_session_out {
  173. struct hdcp_cmd_header header;
  174. struct hdcp_port_id port;
  175. u8 r_tx[HDCP_2_2_RTX_LEN];
  176. struct hdcp2_tx_caps tx_caps;
  177. } __packed;
  178. /* HECI struct for ending an integrated wired HDCP Tx session. */
  179. struct wired_cmd_close_session_in {
  180. struct hdcp_cmd_header header;
  181. struct hdcp_port_id port;
  182. } __packed;
  183. struct wired_cmd_close_session_out {
  184. struct hdcp_cmd_header header;
  185. struct hdcp_port_id port;
  186. } __packed;
  187. /* HECI struct for integrated wired HDCP Tx Rx Cert verification. */
  188. struct wired_cmd_verify_receiver_cert_in {
  189. struct hdcp_cmd_header header;
  190. struct hdcp_port_id port;
  191. struct hdcp2_cert_rx cert_rx;
  192. u8 r_rx[HDCP_2_2_RRX_LEN];
  193. u8 rx_caps[HDCP_2_2_RXCAPS_LEN];
  194. } __packed;
  195. struct wired_cmd_verify_receiver_cert_out {
  196. struct hdcp_cmd_header header;
  197. struct hdcp_port_id port;
  198. u8 km_stored;
  199. u8 reserved[3];
  200. union encrypted_buff ekm_buff;
  201. } __packed;
  202. /* HECI struct for verification of Rx's Hprime in a HDCP Tx session */
  203. struct wired_cmd_ake_send_hprime_in {
  204. struct hdcp_cmd_header header;
  205. struct hdcp_port_id port;
  206. u8 h_prime[HDCP_2_2_H_PRIME_LEN];
  207. } __packed;
  208. struct wired_cmd_ake_send_hprime_out {
  209. struct hdcp_cmd_header header;
  210. struct hdcp_port_id port;
  211. } __packed;
  212. /*
  213. * HECI struct for sending in AKE pairing data generated by the Rx in an
  214. * integrated wired HDCP Tx session.
  215. */
  216. struct wired_cmd_ake_send_pairing_info_in {
  217. struct hdcp_cmd_header header;
  218. struct hdcp_port_id port;
  219. u8 e_kh_km[HDCP_2_2_E_KH_KM_LEN];
  220. } __packed;
  221. struct wired_cmd_ake_send_pairing_info_out {
  222. struct hdcp_cmd_header header;
  223. struct hdcp_port_id port;
  224. } __packed;
  225. /* Data structures for integrated wired HDCP2 Tx in support of the LC protocol*/
  226. /*
  227. * HECI struct for initiating locality check with an
  228. * integrated wired HDCP Tx session.
  229. */
  230. struct wired_cmd_init_locality_check_in {
  231. struct hdcp_cmd_header header;
  232. struct hdcp_port_id port;
  233. } __packed;
  234. struct wired_cmd_init_locality_check_out {
  235. struct hdcp_cmd_header header;
  236. struct hdcp_port_id port;
  237. u8 r_n[HDCP_2_2_RN_LEN];
  238. } __packed;
  239. /*
  240. * HECI struct for validating an Rx's LPrime value in an
  241. * integrated wired HDCP Tx session.
  242. */
  243. struct wired_cmd_validate_locality_in {
  244. struct hdcp_cmd_header header;
  245. struct hdcp_port_id port;
  246. u8 l_prime[HDCP_2_2_L_PRIME_LEN];
  247. } __packed;
  248. struct wired_cmd_validate_locality_out {
  249. struct hdcp_cmd_header header;
  250. struct hdcp_port_id port;
  251. } __packed;
  252. /*
  253. * Data structures for integrated wired HDCP2 Tx in support of the
  254. * SKE protocol
  255. */
  256. /* HECI struct for creating session key */
  257. struct wired_cmd_get_session_key_in {
  258. struct hdcp_cmd_header header;
  259. struct hdcp_port_id port;
  260. } __packed;
  261. struct wired_cmd_get_session_key_out {
  262. struct hdcp_cmd_header header;
  263. struct hdcp_port_id port;
  264. u8 e_dkey_ks[HDCP_2_2_E_DKEY_KS_LEN];
  265. u8 r_iv[HDCP_2_2_RIV_LEN];
  266. } __packed;
  267. /* HECI struct for the Tx enable authentication command */
  268. struct wired_cmd_enable_auth_in {
  269. struct hdcp_cmd_header header;
  270. struct hdcp_port_id port;
  271. u8 stream_type;
  272. } __packed;
  273. struct wired_cmd_enable_auth_out {
  274. struct hdcp_cmd_header header;
  275. struct hdcp_port_id port;
  276. } __packed;
  277. /*
  278. * Data structures for integrated wired HDCP2 Tx in support of
  279. * the repeater protocols
  280. */
  281. /*
  282. * HECI struct for verifying the downstream repeater's HDCP topology in an
  283. * integrated wired HDCP Tx session.
  284. */
  285. struct wired_cmd_verify_repeater_in {
  286. struct hdcp_cmd_header header;
  287. struct hdcp_port_id port;
  288. u8 rx_info[HDCP_2_2_RXINFO_LEN];
  289. u8 seq_num_v[HDCP_2_2_SEQ_NUM_LEN];
  290. u8 v_prime[HDCP_2_2_V_PRIME_HALF_LEN];
  291. u8 receiver_ids[HDCP_2_2_RECEIVER_IDS_MAX_LEN];
  292. } __packed;
  293. struct wired_cmd_verify_repeater_out {
  294. struct hdcp_cmd_header header;
  295. struct hdcp_port_id port;
  296. u8 content_type_supported;
  297. u8 v[HDCP_2_2_V_PRIME_HALF_LEN];
  298. } __packed;
  299. /*
  300. * HECI struct in support of stream management in an
  301. * integrated wired HDCP Tx session.
  302. */
  303. struct wired_cmd_repeater_auth_stream_req_in {
  304. struct hdcp_cmd_header header;
  305. struct hdcp_port_id port;
  306. u8 seq_num_m[HDCP_2_2_SEQ_NUM_LEN];
  307. u8 m_prime[HDCP_2_2_MPRIME_LEN];
  308. __be16 k;
  309. struct hdcp2_streamid_type streams[];
  310. } __packed;
  311. struct wired_cmd_repeater_auth_stream_req_out {
  312. struct hdcp_cmd_header header;
  313. struct hdcp_port_id port;
  314. } __packed;
  315. #endif /* __MEI_HDCP_H__ */