hdcp_qseecom.c 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015-2022, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #define pr_fmt(fmt) "[hdcp-qseecom] %s: " fmt, __func__
  7. #include <linux/kernel.h>
  8. #include <linux/slab.h>
  9. #include <linux/module.h>
  10. #include <linux/fs.h>
  11. #include <linux/cdev.h>
  12. #include <linux/sched.h>
  13. #include <linux/list.h>
  14. #include <linux/mutex.h>
  15. #include <linux/io.h>
  16. #include <linux/types.h>
  17. #include <linux/device.h>
  18. #include <linux/sched.h>
  19. #include <linux/delay.h>
  20. #include <linux/completion.h>
  21. #include <linux/errno.h>
  22. #include <linux/kthread.h>
  23. #include <linux/hdcp_qseecom.h>
  24. #include "misc/qseecom_kernel.h"
  25. #define HDCP2P2_APP_NAME "hdcp2p2"
  26. #define HDCP1_APP_NAME "hdcp1"
  27. #define HDCP1OPS_APP_NAME "ops"
  28. #define HDCPSRM_APP_NAME "hdcpsrm"
  29. #define QSEECOM_SBUFF_SIZE 0x1000
  30. #define MAX_REC_ID_LIST_SIZE 160
  31. #define MAX_TX_MESSAGE_SIZE 129
  32. #define MAX_RX_MESSAGE_SIZE 534
  33. #define MAX_TOPOLOGY_ELEMS 32
  34. #define HDCP1_NOTIFY_TOPOLOGY 1
  35. #define HDCP1_AKSV_SIZE 8
  36. #define HDCP1_SET_KEY 202
  37. #define HDCP1_KEY_VERIFY 204
  38. #define HDCP1_SET_ENC 205
  39. #define BITS_8_IN_BYTES 1
  40. #define BITS_16_IN_BYTES 2
  41. #define BITS_24_IN_BYTES 3
  42. #define BITS_32_IN_BYTES 4
  43. #define BITS_40_IN_BYTES 5
  44. #define BITS_64_IN_BYTES 8
  45. #define BITS_128_IN_BYTES 16
  46. #define BITS_160_IN_BYTES 20
  47. #define BITS_256_IN_BYTES 32
  48. #define BITS_1024_IN_BYTES 128
  49. #define BITS_3072_IN_BYTES 384
  50. #define TXCAPS_SIZE 3
  51. #define RXCAPS_SIZE 3
  52. #define RXINFO_SIZE 2
  53. #define SEQ_NUM_V_SIZE 3
  54. #define RCVR_ID_SIZE BITS_40_IN_BYTES
  55. #define MAX_RCVR_IDS_ALLOWED_IN_LIST 31
  56. #define MAX_RCVR_ID_LIST_SIZE \
  57. (RCVR_ID_SIZE*MAX_RCVR_IDS_ALLOWED_IN_LIST)
  58. /*
  59. * minimum wait as per standard is 200 ms. keep it 300 ms
  60. * to be on safe side.
  61. */
  62. #define SLEEP_SET_HW_KEY_MS 300
  63. /* Wait 200ms after authentication */
  64. #define SLEEP_FORCE_ENCRYPTION_MS 200
  65. /* hdcp command status */
  66. #define HDCP_SUCCESS 0
  67. /* DP device type */
  68. #define DEVICE_TYPE_DP 0x8002
  69. const char *HdcpErrors[] = {
  70. "HDCP_SUCCESS",
  71. "HDCP_FAIL",
  72. "HDCP_BAD_PARAM",
  73. "HDCP_DEVICE_TYPE_UNSUPPORTED",
  74. "HDCP_INVALID_COMMAND",
  75. "HDCP_INVALID_COMMAND_HANDLE",
  76. "HDCP_ERROR_SIZE_IN",
  77. "HDCP_ERROR_SIZE_OUT",
  78. "HDCP_DATA_SIZE_INSUFFICIENT",
  79. "HDCP_UNSUPPORTED_RX_VERSION",
  80. "HDCP_WRONG_RX_CAPAB_MASK",
  81. "HDCP_WRONG_RX_RSVD",
  82. "HDCP_WRONG_RX_HDCP_CAPABLE",
  83. "HDCP_RSA_SIGNATURE_VERIFY_FAILED",
  84. "HDCP_VERIFY_H_PRIME_FAILED",
  85. "HDCP_LC_FAILED",
  86. "HDCP_MESSAGE_TIMEOUT",
  87. "HDCP_COUNTER_ROLL_OVER",
  88. "HDCP_WRONG_RXINFO_RSVD",
  89. "HDCP_RXINFO_MAX_DEVS",
  90. "HDCP_RXINFO_MAX_CASCADE",
  91. "HDCP_WRONG_INITIAL_SEQ_NUM_V",
  92. "HDCP_SEQ_NUM_V_ROLL_OVER",
  93. "HDCP_WRONG_SEQ_NUM_V",
  94. "HDCP_VERIFY_V_FAILED",
  95. "HDCP_RPT_METHOD_INVOKED",
  96. "HDCP_RPT_STRM_LEN_WRONG",
  97. "HDCP_VERIFY_STRM_M_FAILED",
  98. "HDCP_TRANSMITTER_NOT_FOUND",
  99. "HDCP_SESSION_NOT_FOUND",
  100. "HDCP_MAX_SESSION_EXCEEDED",
  101. "HDCP_MAX_CONNECTION_EXCEEDED",
  102. "HDCP_MAX_STREAMS_EXCEEDED",
  103. "HDCP_MAX_DEVICES",
  104. "HDCP_ALLOC_FAILED",
  105. "HDCP_CONNECTION_NOT_FOUND",
  106. "HDCP_HASH_FAILED",
  107. "HDCP_BN_FAILED",
  108. "HDCP_ENCRYPT_KM_FAILED",
  109. "HDCP_DECRYPT_KM_FAILED",
  110. "HDCP_HMAC_FAILED",
  111. "HDCP_GET_RANDOM_FAILED",
  112. "HDCP_INVALID_KEY_HEADER",
  113. "HDCP_INVALID_KEY_LC_HASH",
  114. "HDCP_INVALID_KEY_HASH",
  115. "HDCP_KEY_WRITE_FAILED",
  116. "HDCP_KEY_READ_FAILED",
  117. "HDCP_KEY_DECRYPT_FAILED",
  118. "HDCP_TEST_KEY_ON_SECURE_DEVICE",
  119. "HDCP_KEY_VERSION_UNSUPPORTED",
  120. "HDCP_RXID_NOT_FOUND",
  121. "HDCP_STORAGE_INIT_FAILED",
  122. "HDCP_STORAGE_FILE_OPEN_FAILED",
  123. "HDCP_STORAGE_FILE_READ_FAILED",
  124. "HDCP_STORAGE_FILE_WRITE_FAILED",
  125. "HDCP_STORAGE_ID_UNSUPPORTED",
  126. "HDCP_MUTUAL_EXCLUSIVE_DEVICE_PRESENT",
  127. "HDCP_INVALID_STATE",
  128. "HDCP_CONFIG_READ_FAILED",
  129. "HDCP_OPEN_TZ_SERVICE_FAILED",
  130. "HDCP_HW_CLOCK_OFF",
  131. "HDCP_SET_HW_KEY_FAILED",
  132. "HDCP_CLEAR_HW_KEY_FAILED",
  133. "HDCP_GET_CONTENT_LEVEL_FAILED",
  134. "HDCP_STREAMID_INUSE",
  135. "HDCP_STREAM_NOT_FOUND",
  136. "HDCP_FORCE_ENCRYPTION_FAILED",
  137. "HDCP_STREAMNUMBER_INUSE"
  138. };
  139. /* flags set by tz in response message */
  140. #define HDCP_TXMTR_SUBSTATE_INIT 0
  141. #define HDCP_TXMTR_SUBSTATE_WAITING_FOR_RECIEVERID_LIST 1
  142. #define HDCP_TXMTR_SUBSTATE_PROCESSED_RECIEVERID_LIST 2
  143. #define HDCP_TXMTR_SUBSTATE_WAITING_FOR_STREAM_READY_MESSAGE 3
  144. #define HDCP_TXMTR_SUBSTATE_REPEATER_AUTH_COMPLETE 4
  145. #define HDCP_DEVICE_ID 0x0008000
  146. #define HDCP_CREATE_DEVICE_ID(x) (HDCP_DEVICE_ID | (x))
  147. #define HDCP_TXMTR_HDMI HDCP_CREATE_DEVICE_ID(1)
  148. #define HDCP_TXMTR_SERVICE_ID 0x0001000
  149. #define SERVICE_CREATE_CMD(x) (HDCP_TXMTR_SERVICE_ID | x)
  150. #define HCDP_TXMTR_GET_MAJOR_VERSION(v) (((v) >> 16) & 0xFF)
  151. #define HCDP_TXMTR_GET_MINOR_VERSION(v) (((v) >> 8) & 0xFF)
  152. #define HCDP_TXMTR_GET_PATCH_VERSION(v) ((v) & 0xFF)
  153. #define HDCP_CLIENT_MAJOR_VERSION 2
  154. #define HDCP_CLIENT_MINOR_VERSION 1
  155. #define HDCP_CLIENT_PATCH_VERSION 0
  156. #define HDCP_CLIENT_MAKE_VERSION(maj, min, patch) \
  157. ((((maj) & 0xFF) << 16) | (((min) & 0xFF) << 8) | ((patch) & 0xFF))
  158. #define hdcp2_app_init_var(x) \
  159. struct hdcp_##x##_req *req_buf = NULL; \
  160. struct hdcp_##x##_rsp *rsp_buf = NULL; \
  161. if (!handle->qseecom_handle) { \
  162. pr_err("invalid qseecom_handle while processing %s\n", #x); \
  163. rc = -EINVAL; \
  164. goto error; \
  165. } \
  166. req_buf = (struct hdcp_##x##_req *) handle->qseecom_handle->sbuf; \
  167. rsp_buf = (struct hdcp_##x##_rsp *) (handle->qseecom_handle->sbuf + \
  168. QSEECOM_ALIGN(sizeof(struct hdcp_##x##_req))); \
  169. req_buf->commandid = hdcp_cmd_##x
  170. #define hdcp2_app_process_cmd(x) \
  171. ({ \
  172. int rc = qseecom_send_command(handle->qseecom_handle, \
  173. req_buf, QSEECOM_ALIGN(sizeof(struct hdcp_##x##_req)), \
  174. rsp_buf, QSEECOM_ALIGN(sizeof(struct hdcp_##x##_rsp))); \
  175. if ((rc < 0) || (rsp_buf->status != HDCP_SUCCESS)) { \
  176. pr_err("qseecom cmd %s failed with err = %d, status = %d:%s\n" \
  177. , #x, rc, rsp_buf->status, \
  178. hdcp_cmd_status_to_str(rsp_buf->status)); \
  179. rc = -EINVAL; \
  180. } \
  181. rc; \
  182. })
  183. enum {
  184. hdcp_cmd_tx_init = SERVICE_CREATE_CMD(1),
  185. hdcp_cmd_tx_init_v1 = SERVICE_CREATE_CMD(1),
  186. hdcp_cmd_tx_deinit = SERVICE_CREATE_CMD(2),
  187. hdcp_cmd_rcvd_msg = SERVICE_CREATE_CMD(3),
  188. hdcp_cmd_send_timeout = SERVICE_CREATE_CMD(4),
  189. hdcp_cmd_set_hw_key = SERVICE_CREATE_CMD(5),
  190. hdcp_cmd_query_stream_type = SERVICE_CREATE_CMD(6),
  191. hdcp_cmd_init_v1 = SERVICE_CREATE_CMD(11),
  192. hdcp_cmd_init = SERVICE_CREATE_CMD(11),
  193. hdcp_cmd_deinit = SERVICE_CREATE_CMD(12),
  194. hdcp_cmd_version = SERVICE_CREATE_CMD(14),
  195. hdcp_cmd_verify_key = SERVICE_CREATE_CMD(15),
  196. hdcp_cmd_session_init = SERVICE_CREATE_CMD(16),
  197. hdcp_cmd_session_deinit = SERVICE_CREATE_CMD(17),
  198. hdcp_cmd_start_auth = SERVICE_CREATE_CMD(18),
  199. hdcp_cmd_session_open_stream = SERVICE_CREATE_CMD(20),
  200. hdcp_cmd_session_close_stream = SERVICE_CREATE_CMD(21),
  201. hdcp_cmd_force_encryption = SERVICE_CREATE_CMD(22),
  202. };
  203. enum hdcp_state {
  204. HDCP_STATE_INIT = 0x00,
  205. HDCP_STATE_APP_LOADED = 0x01,
  206. HDCP_STATE_SESSION_INIT = 0x02,
  207. HDCP_STATE_TXMTR_INIT = 0x04,
  208. HDCP_STATE_AUTHENTICATED = 0x08,
  209. HDCP_STATE_ERROR = 0x10
  210. };
  211. enum hdcp_element {
  212. HDCP_TYPE_UNKNOWN,
  213. HDCP_TYPE_RECEIVER,
  214. HDCP_TYPE_REPEATER,
  215. };
  216. enum hdcp_version {
  217. HDCP_VERSION_UNKNOWN,
  218. HDCP_VERSION_2_2,
  219. HDCP_VERSION_1_4
  220. };
  221. struct receiver_info {
  222. unsigned char rcvrInfo[RCVR_ID_SIZE];
  223. enum hdcp_element elem_type;
  224. enum hdcp_version hdcp_version;
  225. };
  226. struct topology_info {
  227. unsigned int nNumRcvrs;
  228. struct receiver_info rcvinfo[MAX_TOPOLOGY_ELEMS];
  229. };
  230. struct __attribute__ ((__packed__)) hdcp1_key_set_req {
  231. uint32_t commandid;
  232. };
  233. struct __attribute__ ((__packed__)) hdcp1_key_set_rsp {
  234. uint32_t commandid;
  235. uint32_t ret;
  236. uint8_t ksv[HDCP1_AKSV_SIZE];
  237. };
  238. struct __attribute__ ((__packed__)) hdcp_version_req {
  239. uint32_t commandid;
  240. };
  241. struct __attribute__ ((__packed__)) hdcp_version_rsp {
  242. uint32_t status;
  243. uint32_t commandId;
  244. uint32_t appversion;
  245. };
  246. struct __attribute__ ((__packed__)) hdcp_verify_key_req {
  247. uint32_t commandid;
  248. };
  249. struct __attribute__ ((__packed__)) hdcp_verify_key_rsp {
  250. uint32_t status;
  251. uint32_t commandId;
  252. };
  253. struct __attribute__ ((__packed__)) hdcp1_key_verify_req {
  254. uint32_t commandid;
  255. uint32_t key_type;
  256. };
  257. struct __attribute__ ((__packed__)) hdcp1_key_verify_rsp {
  258. uint32_t commandId;
  259. uint32_t ret;
  260. };
  261. struct __attribute__ ((__packed__)) hdcp_init_v1_req {
  262. uint32_t commandid;
  263. };
  264. struct __attribute__ ((__packed__)) hdcp_init_v1_rsp {
  265. uint32_t status;
  266. uint32_t commandid;
  267. uint32_t ctxhandle;
  268. uint32_t timeout;
  269. uint32_t msglen;
  270. uint8_t message[MAX_TX_MESSAGE_SIZE];
  271. };
  272. struct __attribute__ ((__packed__)) hdcp_init_req {
  273. uint32_t commandid;
  274. uint32_t clientversion;
  275. };
  276. struct __attribute__ ((__packed__)) hdcp_init_rsp {
  277. uint32_t status;
  278. uint32_t commandid;
  279. uint32_t appversion;
  280. };
  281. struct __attribute__ ((__packed__)) hdcp_deinit_req {
  282. uint32_t commandid;
  283. };
  284. struct __attribute__ ((__packed__)) hdcp_deinit_rsp {
  285. uint32_t status;
  286. uint32_t commandid;
  287. };
  288. struct __attribute__ ((__packed__)) hdcp_session_init_req {
  289. uint32_t commandid;
  290. uint32_t deviceid;
  291. };
  292. struct __attribute__ ((__packed__)) hdcp_session_init_rsp {
  293. uint32_t status;
  294. uint32_t commandid;
  295. uint32_t sessionid;
  296. };
  297. struct __attribute__ ((__packed__)) hdcp_session_deinit_req {
  298. uint32_t commandid;
  299. uint32_t sessionid;
  300. };
  301. struct __attribute__ ((__packed__)) hdcp_session_deinit_rsp {
  302. uint32_t status;
  303. uint32_t commandid;
  304. };
  305. struct __attribute__ ((__packed__)) hdcp_tx_init_v1_req {
  306. uint32_t commandid;
  307. };
  308. struct __attribute__ ((__packed__)) hdcp_tx_init_v1_rsp {
  309. uint32_t status;
  310. uint32_t commandid;
  311. uint32_t ctxhandle;
  312. uint32_t timeout;
  313. uint32_t msglen;
  314. uint8_t message[MAX_TX_MESSAGE_SIZE];
  315. };
  316. struct __attribute__ ((__packed__)) hdcp_tx_init_req {
  317. uint32_t commandid;
  318. uint32_t sessionid;
  319. };
  320. struct __attribute__ ((__packed__)) hdcp_tx_init_rsp {
  321. uint32_t status;
  322. uint32_t commandid;
  323. uint32_t ctxhandle;
  324. };
  325. struct __attribute__ ((__packed__)) hdcp_tx_deinit_req {
  326. uint32_t commandid;
  327. uint32_t ctxhandle;
  328. };
  329. struct __attribute__ ((__packed__)) hdcp_tx_deinit_rsp {
  330. uint32_t status;
  331. uint32_t commandid;
  332. };
  333. struct __attribute__ ((__packed__)) hdcp_rcvd_msg_req {
  334. uint32_t commandid;
  335. uint32_t ctxhandle;
  336. uint32_t msglen;
  337. uint8_t msg[MAX_RX_MESSAGE_SIZE];
  338. };
  339. struct __attribute__ ((__packed__)) hdcp_rcvd_msg_rsp {
  340. uint32_t status;
  341. uint32_t commandid;
  342. uint32_t state;
  343. uint32_t timeout;
  344. uint32_t flag;
  345. uint32_t msglen;
  346. uint8_t msg[MAX_TX_MESSAGE_SIZE];
  347. };
  348. struct __attribute__ ((__packed__)) hdcp_set_hw_key_req {
  349. uint32_t commandid;
  350. uint32_t ctxhandle;
  351. };
  352. struct __attribute__ ((__packed__)) hdcp_set_hw_key_rsp {
  353. uint32_t status;
  354. uint32_t commandid;
  355. };
  356. struct __attribute__ ((__packed__)) hdcp_send_timeout_req {
  357. uint32_t commandid;
  358. uint32_t ctxhandle;
  359. };
  360. struct __attribute__ ((__packed__)) hdcp_send_timeout_rsp {
  361. uint32_t status;
  362. uint32_t commandid;
  363. uint32_t timeout;
  364. uint32_t msglen;
  365. uint8_t message[MAX_TX_MESSAGE_SIZE];
  366. };
  367. struct __attribute__ ((__packed__)) hdcp_query_stream_type_req {
  368. uint32_t commandid;
  369. uint32_t ctxhandle;
  370. };
  371. struct __attribute__ ((__packed__)) hdcp_query_stream_type_rsp {
  372. uint32_t status;
  373. uint32_t commandid;
  374. uint32_t timeout;
  375. uint32_t msglen;
  376. uint8_t msg[MAX_TX_MESSAGE_SIZE];
  377. };
  378. struct __attribute__ ((__packed__)) hdcp_set_stream_type_req {
  379. uint32_t commandid;
  380. uint32_t ctxhandle;
  381. uint8_t streamtype;
  382. };
  383. struct __attribute__ ((__packed__)) hdcp_set_stream_type_rsp {
  384. uint32_t status;
  385. uint32_t commandid;
  386. uint32_t timeout;
  387. uint32_t msglen;
  388. uint8_t message[MAX_TX_MESSAGE_SIZE];
  389. };
  390. struct __attribute__ ((__packed__)) hdcp_update_srm_req {
  391. uint32_t commandid;
  392. uint32_t ctxhandle;
  393. uint32_t srmoffset;
  394. uint32_t srmlength;
  395. };
  396. struct __attribute__ ((__packed__)) hdcp_update_srm_rsp {
  397. uint32_t status;
  398. uint32_t commandid;
  399. };
  400. struct __attribute__ ((__packed__)) hdcp_get_topology_req {
  401. uint32_t commandid;
  402. uint32_t ctxhandle;
  403. };
  404. struct __attribute__ ((__packed__)) hdcp_get_topology_rsp {
  405. uint32_t status;
  406. uint32_t commandid;
  407. struct topology_info topologyinfo;
  408. };
  409. struct __attribute__ ((__packed__)) rxvr_info_struct {
  410. uint8_t rcvrCert[522];
  411. uint8_t rrx[BITS_64_IN_BYTES];
  412. uint8_t rxcaps[RXCAPS_SIZE];
  413. bool repeater;
  414. };
  415. struct __attribute__ ((__packed__)) repeater_info_struct {
  416. uint8_t RxInfo[RXINFO_SIZE];
  417. uint8_t seq_num_V[SEQ_NUM_V_SIZE];
  418. bool seq_num_V_Rollover_flag;
  419. uint8_t ReceiverIDList[MAX_RCVR_ID_LIST_SIZE];
  420. uint32_t ReceiverIDListLen;
  421. };
  422. struct __attribute__ ((__packed__)) hdcp1_set_enc_req {
  423. uint32_t commandid;
  424. uint32_t enable;
  425. };
  426. struct __attribute__ ((__packed__)) hdcp1_set_enc_rsp {
  427. uint32_t commandid;
  428. uint32_t ret;
  429. };
  430. struct __attribute__ ((__packed__)) hdcp1_ops_notify_req {
  431. uint32_t commandid;
  432. uint32_t device_type;
  433. uint8_t recv_id_list[MAX_REC_ID_LIST_SIZE];
  434. int32_t recv_id_len;
  435. struct hdcp1_topology topology;
  436. bool is_authenticated;
  437. };
  438. struct __attribute__ ((__packed__)) hdcp1_ops_notify_rsp {
  439. uint32_t commandid;
  440. uint32_t ret;
  441. };
  442. struct __attribute__ ((__packed__)) hdcp_start_auth_req {
  443. uint32_t commandid;
  444. uint32_t ctxHandle;
  445. };
  446. struct __attribute__ ((__packed__)) hdcp_start_auth_rsp {
  447. uint32_t status;
  448. uint32_t commandid;
  449. uint32_t ctxhandle;
  450. uint32_t timeout;
  451. uint32_t msglen;
  452. uint8_t message[MAX_TX_MESSAGE_SIZE];
  453. };
  454. struct __attribute__((__packed__)) hdcp_session_open_stream_req {
  455. uint32_t commandid;
  456. uint32_t sessionid;
  457. uint32_t vcpayloadid;
  458. uint32_t stream_number;
  459. uint32_t streamMediaType;
  460. };
  461. struct __attribute__((__packed__)) hdcp_session_open_stream_rsp {
  462. uint32_t status;
  463. uint32_t commandid;
  464. uint32_t streamid;
  465. };
  466. struct __attribute__((__packed__)) hdcp_session_close_stream_req {
  467. uint32_t commandid;
  468. uint32_t sessionid;
  469. uint32_t streamid;
  470. };
  471. struct __attribute__((__packed__)) hdcp_session_close_stream_rsp {
  472. uint32_t status;
  473. uint32_t commandid;
  474. };
  475. struct __attribute__((__packed__)) hdcp_force_encryption_req {
  476. uint32_t commandid;
  477. uint32_t ctxhandle;
  478. uint32_t enable;
  479. };
  480. struct __attribute__ ((__packed__)) hdcp_force_encryption_rsp {
  481. uint32_t status;
  482. uint32_t commandid;
  483. };
  484. struct hdcp2_handle {
  485. struct hdcp2_app_data app_data;
  486. uint32_t tz_ctxhandle;
  487. bool feature_supported;
  488. enum hdcp_state hdcp_state;
  489. struct qseecom_handle *qseecom_handle;
  490. struct qseecom_handle *hdcpsrm_qseecom_handle;
  491. uint32_t session_id;
  492. bool legacy_app;
  493. uint32_t device_type;
  494. char *app_name;
  495. int (*app_init)(struct hdcp2_handle *handle);
  496. int (*tx_init)(struct hdcp2_handle *handle);
  497. };
  498. /*
  499. * struct hdcp1_handle - handle for HDCP 1.x client
  500. * @qseecom_handle - for sending commands to qseecom
  501. * @hdcpops_handle - for sending commands to ops TA
  502. * @feature_supported - set to true if the platform supports HDCP 1.x
  503. * @device_type - the interface type (HDMI or DisplayPort)
  504. */
  505. struct hdcp1_handle {
  506. struct qseecom_handle *qseecom_handle;
  507. struct qseecom_handle *hdcpops_handle;
  508. bool feature_supported;
  509. uint32_t device_type;
  510. enum hdcp_state hdcp_state;
  511. char *app_name;
  512. };
  513. #define HDCP_CMD_STATUS_TO_STR(x) #x
  514. static const char *hdcp_cmd_status_to_str(uint32_t err)
  515. {
  516. int len = ARRAY_SIZE(HdcpErrors);
  517. if (err >= 0 && err < len)
  518. return HdcpErrors[err];
  519. else
  520. return "";
  521. }
  522. static int hdcp_get_version(struct hdcp2_handle *handle)
  523. {
  524. int rc = 0;
  525. uint32_t app_major_version = 0;
  526. hdcp2_app_init_var(version);
  527. if (handle->hdcp_state & HDCP_STATE_APP_LOADED) {
  528. pr_err("library already loaded\n");
  529. goto error;
  530. }
  531. rc = hdcp2_app_process_cmd(version);
  532. if (rc)
  533. goto error;
  534. app_major_version = HCDP_TXMTR_GET_MAJOR_VERSION(rsp_buf->appversion);
  535. pr_debug("hdp2p2 app major version %d, app version %d\n",
  536. app_major_version, rsp_buf->appversion);
  537. if (app_major_version == 1)
  538. handle->legacy_app = true;
  539. error:
  540. return rc;
  541. }
  542. static int hdcp2_app_init_legacy(struct hdcp2_handle *handle)
  543. {
  544. int rc = 0;
  545. hdcp2_app_init_var(init_v1);
  546. if (!handle->legacy_app) {
  547. pr_err("wrong init function\n");
  548. rc = -EINVAL;
  549. goto error;
  550. }
  551. if (handle->hdcp_state & HDCP_STATE_APP_LOADED) {
  552. pr_err("library already loaded\n");
  553. goto error;
  554. }
  555. rc = hdcp2_app_process_cmd(init_v1);
  556. if (rc)
  557. goto error;
  558. pr_debug("success\n");
  559. error:
  560. return rc;
  561. }
  562. static int hdcp2_app_init(struct hdcp2_handle *handle)
  563. {
  564. int rc = 0;
  565. uint32_t app_minor_version = 0;
  566. hdcp2_app_init_var(init);
  567. if (handle->legacy_app) {
  568. pr_err("wrong init function\n");
  569. rc = -EINVAL;
  570. goto error;
  571. }
  572. if (handle->hdcp_state & HDCP_STATE_APP_LOADED) {
  573. pr_err("library already loaded\n");
  574. goto error;
  575. }
  576. req_buf->clientversion =
  577. HDCP_CLIENT_MAKE_VERSION(HDCP_CLIENT_MAJOR_VERSION,
  578. HDCP_CLIENT_MINOR_VERSION,
  579. HDCP_CLIENT_PATCH_VERSION);
  580. rc = hdcp2_app_process_cmd(init);
  581. if (rc)
  582. goto error;
  583. app_minor_version = HCDP_TXMTR_GET_MINOR_VERSION(rsp_buf->appversion);
  584. if (app_minor_version != HDCP_CLIENT_MINOR_VERSION) {
  585. pr_err
  586. ("client-app minor version mismatch app(%d), client(%d)\n",
  587. app_minor_version, HDCP_CLIENT_MINOR_VERSION);
  588. rc = -1;
  589. goto error;
  590. }
  591. pr_debug("success\n");
  592. pr_debug("client version major(%d), minor(%d), patch(%d)\n",
  593. HDCP_CLIENT_MAJOR_VERSION, HDCP_CLIENT_MINOR_VERSION,
  594. HDCP_CLIENT_PATCH_VERSION);
  595. pr_debug("app version major(%d), minor(%d), patch(%d)\n",
  596. HCDP_TXMTR_GET_MAJOR_VERSION(rsp_buf->appversion),
  597. HCDP_TXMTR_GET_MINOR_VERSION(rsp_buf->appversion),
  598. HCDP_TXMTR_GET_PATCH_VERSION(rsp_buf->appversion));
  599. error:
  600. return rc;
  601. }
  602. static int hdcp2_app_tx_init(struct hdcp2_handle *handle)
  603. {
  604. int rc = 0;
  605. hdcp2_app_init_var(tx_init);
  606. if (!(handle->hdcp_state & HDCP_STATE_SESSION_INIT)) {
  607. pr_err("session not initialized\n");
  608. rc = -EINVAL;
  609. goto error;
  610. }
  611. if (handle->hdcp_state & HDCP_STATE_TXMTR_INIT) {
  612. pr_err("txmtr already initialized\n");
  613. goto error;
  614. }
  615. req_buf->sessionid = handle->session_id;
  616. rc = hdcp2_app_process_cmd(tx_init);
  617. if (rc)
  618. goto error;
  619. handle->tz_ctxhandle = rsp_buf->ctxhandle;
  620. handle->hdcp_state |= HDCP_STATE_TXMTR_INIT;
  621. pr_debug("success\n");
  622. error:
  623. return rc;
  624. }
  625. static int hdcp2_app_tx_init_legacy(struct hdcp2_handle *handle)
  626. {
  627. int rc = 0;
  628. hdcp2_app_init_var(tx_init_v1);
  629. if (!(handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  630. pr_err("app not loaded\n");
  631. rc = -EINVAL;
  632. goto error;
  633. }
  634. if (handle->hdcp_state & HDCP_STATE_TXMTR_INIT) {
  635. pr_err("txmtr already initialized\n");
  636. goto error;
  637. }
  638. rc = hdcp2_app_process_cmd(tx_init_v1);
  639. if (rc)
  640. goto error;
  641. handle->app_data.response.data = rsp_buf->message;
  642. handle->app_data.response.length = rsp_buf->msglen;
  643. handle->app_data.timeout = rsp_buf->timeout;
  644. handle->tz_ctxhandle = rsp_buf->ctxhandle;
  645. handle->hdcp_state |= HDCP_STATE_TXMTR_INIT;
  646. pr_debug("success\n");
  647. error:
  648. return rc;
  649. }
  650. static int hdcp2_app_load(struct hdcp2_handle *handle)
  651. {
  652. int rc = 0;
  653. if (!handle) {
  654. pr_err("invalid input\n");
  655. rc = -EINVAL;
  656. goto error;
  657. }
  658. if (handle->hdcp_state & HDCP_STATE_APP_LOADED) {
  659. pr_err("%s app already loaded\n", handle->app_name);
  660. goto error;
  661. }
  662. rc = qseecom_start_app(&handle->qseecom_handle,
  663. handle->app_name, QSEECOM_SBUFF_SIZE);
  664. if (rc) {
  665. pr_err("qseecom_start_app failed for HDCP2P2 (%d)\n", rc);
  666. goto error;
  667. }
  668. rc = qseecom_start_app(&handle->hdcpsrm_qseecom_handle,
  669. HDCPSRM_APP_NAME, QSEECOM_SBUFF_SIZE);
  670. if (rc) {
  671. pr_err("qseecom_start_app failed for HDCPSRM (%d)\n", rc);
  672. goto hdcpsrm_error;
  673. }
  674. pr_debug("qseecom_start_app success\n");
  675. rc = hdcp_get_version(handle);
  676. if (rc) {
  677. pr_err("library get version failed\n");
  678. goto get_version_error;
  679. }
  680. if (handle->legacy_app) {
  681. handle->app_init = hdcp2_app_init_legacy;
  682. handle->tx_init = hdcp2_app_tx_init_legacy;
  683. } else {
  684. handle->app_init = hdcp2_app_init;
  685. handle->tx_init = hdcp2_app_tx_init;
  686. }
  687. rc = handle->app_init(handle);
  688. if (rc) {
  689. pr_err("app init failed\n");
  690. goto get_version_error;
  691. }
  692. handle->hdcp_state |= HDCP_STATE_APP_LOADED;
  693. return rc;
  694. get_version_error:
  695. qseecom_shutdown_app(&handle->hdcpsrm_qseecom_handle);
  696. hdcpsrm_error:
  697. qseecom_shutdown_app(&handle->qseecom_handle);
  698. error:
  699. return rc;
  700. }
  701. static int hdcp2_app_unload(struct hdcp2_handle *handle)
  702. {
  703. int rc = 0;
  704. hdcp2_app_init_var(deinit);
  705. hdcp2_app_process_cmd(deinit);
  706. /* deallocate the resources for qseecom HDCPSRM handle */
  707. rc = qseecom_shutdown_app(&handle->hdcpsrm_qseecom_handle);
  708. if (rc)
  709. pr_err("qseecom_shutdown_app failed for HDCPSRM (%d)\n", rc);
  710. /* deallocate the resources for qseecom HDCP2P2 handle */
  711. rc = qseecom_shutdown_app(&handle->qseecom_handle);
  712. if (rc) {
  713. pr_err("qseecom_shutdown_app failed for HDCP2P2 (%d)\n", rc);
  714. return rc;
  715. }
  716. handle->hdcp_state &= ~HDCP_STATE_APP_LOADED;
  717. pr_debug("%s app unloaded\n", handle->app_name);
  718. return rc;
  719. error:
  720. qseecom_shutdown_app(&handle->hdcpsrm_qseecom_handle);
  721. return rc;
  722. }
  723. static int hdcp2_verify_key(struct hdcp2_handle *handle)
  724. {
  725. int rc = 0;
  726. hdcp2_app_init_var(verify_key);
  727. if (!(handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  728. pr_err("%s app not loaded\n", handle->app_name);
  729. rc = -EINVAL;
  730. goto error;
  731. }
  732. rc = hdcp2_app_process_cmd(verify_key);
  733. pr_debug("verify_key = %d\n", rc);
  734. error:
  735. return rc;
  736. }
  737. bool hdcp2_feature_supported(void *data)
  738. {
  739. int rc = 0;
  740. bool supported = false;
  741. struct hdcp2_handle *handle = data;
  742. if (!handle) {
  743. pr_err("invalid input\n");
  744. rc = -EINVAL;
  745. goto error;
  746. }
  747. if (handle->feature_supported) {
  748. supported = true;
  749. goto error;
  750. }
  751. rc = hdcp2_app_load(handle);
  752. if (!rc) {
  753. if (!hdcp2_verify_key(handle)) {
  754. pr_debug("HDCP 2.2 supported\n");
  755. handle->feature_supported = true;
  756. supported = true;
  757. }
  758. hdcp2_app_unload(handle);
  759. }
  760. error:
  761. return supported;
  762. }
  763. EXPORT_SYMBOL(hdcp2_feature_supported);
  764. static int hdcp2_app_session_init(struct hdcp2_handle *handle)
  765. {
  766. int rc = 0;
  767. hdcp2_app_init_var(session_init);
  768. if (!handle->qseecom_handle || !handle->qseecom_handle->sbuf) {
  769. pr_err("invalid handle\n");
  770. rc = -EINVAL;
  771. goto error;
  772. }
  773. if (!(handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  774. pr_err("%s app not loaded\n", handle->app_name);
  775. rc = -EINVAL;
  776. goto error;
  777. }
  778. if (handle->hdcp_state & HDCP_STATE_SESSION_INIT) {
  779. pr_err("session already initialized\n");
  780. goto error;
  781. }
  782. req_buf->deviceid = handle->device_type;
  783. rc = hdcp2_app_process_cmd(session_init);
  784. if (rc)
  785. goto error;
  786. pr_debug("session id %d\n", rsp_buf->sessionid);
  787. handle->session_id = rsp_buf->sessionid;
  788. handle->hdcp_state |= HDCP_STATE_SESSION_INIT;
  789. pr_debug("success\n");
  790. error:
  791. return rc;
  792. }
  793. static int hdcp2_app_session_deinit(struct hdcp2_handle *handle)
  794. {
  795. int rc = 0;
  796. hdcp2_app_init_var(session_deinit);
  797. if (!(handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  798. pr_err("%s app not loaded\n", handle->app_name);
  799. rc = -EINVAL;
  800. goto error;
  801. }
  802. if (!(handle->hdcp_state & HDCP_STATE_SESSION_INIT)) {
  803. pr_err("session not initialized\n");
  804. rc = -EINVAL;
  805. goto error;
  806. }
  807. req_buf->sessionid = handle->session_id;
  808. rc = hdcp2_app_process_cmd(session_deinit);
  809. if (rc)
  810. goto error;
  811. handle->hdcp_state &= ~HDCP_STATE_SESSION_INIT;
  812. pr_debug("success\n");
  813. error:
  814. return rc;
  815. }
  816. static int hdcp2_app_tx_deinit(struct hdcp2_handle *handle)
  817. {
  818. int rc = 0;
  819. hdcp2_app_init_var(tx_deinit);
  820. if (!(handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  821. pr_err("%s app not loaded\n", handle->app_name);
  822. rc = -EINVAL;
  823. goto error;
  824. }
  825. if (!(handle->hdcp_state & HDCP_STATE_TXMTR_INIT)) {
  826. pr_err("txmtr not initialized\n");
  827. rc = -EINVAL;
  828. goto error;
  829. }
  830. req_buf->ctxhandle = handle->tz_ctxhandle;
  831. rc = hdcp2_app_process_cmd(tx_deinit);
  832. if (rc)
  833. goto error;
  834. handle->hdcp_state &= ~HDCP_STATE_TXMTR_INIT;
  835. pr_debug("success\n");
  836. error:
  837. return rc;
  838. }
  839. static int hdcp2_app_start_auth(struct hdcp2_handle *handle)
  840. {
  841. int rc = 0;
  842. hdcp2_app_init_var(start_auth);
  843. if (!(handle->hdcp_state & HDCP_STATE_SESSION_INIT)) {
  844. pr_err("session not initialized\n");
  845. rc = -EINVAL;
  846. goto error;
  847. }
  848. if (!(handle->hdcp_state & HDCP_STATE_TXMTR_INIT)) {
  849. pr_err("txmtr not initialized\n");
  850. rc = -EINVAL;
  851. goto error;
  852. }
  853. req_buf->ctxHandle = handle->tz_ctxhandle;
  854. rc = hdcp2_app_process_cmd(start_auth);
  855. if (rc)
  856. goto error;
  857. handle->app_data.response.data = rsp_buf->message;
  858. handle->app_data.response.length = rsp_buf->msglen;
  859. handle->app_data.timeout = rsp_buf->timeout;
  860. handle->app_data.repeater_flag = false;
  861. handle->tz_ctxhandle = rsp_buf->ctxhandle;
  862. pr_debug("success\n");
  863. error:
  864. return rc;
  865. }
  866. static int hdcp2_app_start(struct hdcp2_handle *handle)
  867. {
  868. int rc = 0;
  869. rc = hdcp2_app_load(handle);
  870. if (rc)
  871. goto error;
  872. if (!handle->legacy_app) {
  873. rc = hdcp2_app_session_init(handle);
  874. if (rc)
  875. goto error;
  876. }
  877. if (handle->tx_init == NULL) {
  878. pr_err("invalid txmtr init function pointer\n");
  879. rc = -EINVAL;
  880. goto error;
  881. }
  882. rc = handle->tx_init(handle);
  883. error:
  884. return rc;
  885. }
  886. static int hdcp2_app_stop(struct hdcp2_handle *handle)
  887. {
  888. int rc = 0;
  889. rc = hdcp2_app_tx_deinit(handle);
  890. if (rc)
  891. goto end;
  892. if (!handle->legacy_app) {
  893. rc = hdcp2_app_session_deinit(handle);
  894. if (rc)
  895. goto end;
  896. }
  897. rc = hdcp2_app_unload(handle);
  898. end:
  899. return rc;
  900. }
  901. static int hdcp2_app_process_msg(struct hdcp2_handle *handle)
  902. {
  903. int rc = 0;
  904. hdcp2_app_init_var(rcvd_msg);
  905. if (!handle->app_data.request.data) {
  906. pr_err("invalid request buffer\n");
  907. rc = -EINVAL;
  908. goto error;
  909. }
  910. req_buf->msglen = handle->app_data.request.length;
  911. req_buf->ctxhandle = handle->tz_ctxhandle;
  912. rc = hdcp2_app_process_cmd(rcvd_msg);
  913. if (rc)
  914. goto error;
  915. /* check if it's a repeater */
  916. if (rsp_buf->flag == HDCP_TXMTR_SUBSTATE_WAITING_FOR_RECIEVERID_LIST)
  917. handle->app_data.repeater_flag = true;
  918. handle->app_data.response.data = rsp_buf->msg;
  919. handle->app_data.response.length = rsp_buf->msglen;
  920. handle->app_data.timeout = rsp_buf->timeout;
  921. error:
  922. return rc;
  923. }
  924. static int hdcp2_app_timeout(struct hdcp2_handle *handle)
  925. {
  926. int rc = 0;
  927. hdcp2_app_init_var(send_timeout);
  928. rc = hdcp2_app_process_cmd(send_timeout);
  929. if (rc)
  930. goto error;
  931. handle->app_data.response.data = rsp_buf->message;
  932. handle->app_data.response.length = rsp_buf->msglen;
  933. handle->app_data.timeout = rsp_buf->timeout;
  934. error:
  935. return rc;
  936. }
  937. static int hdcp2_app_enable_encryption(struct hdcp2_handle *handle)
  938. {
  939. int rc = 0;
  940. hdcp2_app_init_var(set_hw_key);
  941. /*
  942. * wait at least 200ms before enabling encryption
  943. * as per hdcp2p2 specifications.
  944. */
  945. msleep(SLEEP_SET_HW_KEY_MS);
  946. req_buf->ctxhandle = handle->tz_ctxhandle;
  947. rc = hdcp2_app_process_cmd(set_hw_key);
  948. if (rc)
  949. goto error;
  950. handle->hdcp_state |= HDCP_STATE_AUTHENTICATED;
  951. pr_debug("success\n");
  952. return rc;
  953. error:
  954. return rc;
  955. }
  956. static int hdcp2_force_encryption_utility(struct hdcp2_handle *handle,
  957. uint32_t enable)
  958. {
  959. int rc = 0;
  960. hdcp2_app_init_var(force_encryption);
  961. if (handle->hdcp_state == HDCP_STATE_AUTHENTICATED)
  962. msleep(SLEEP_FORCE_ENCRYPTION_MS);
  963. req_buf->ctxhandle = handle->tz_ctxhandle;
  964. req_buf->enable = enable;
  965. rc = hdcp2_app_process_cmd(force_encryption);
  966. if (rc || (rsp_buf->commandid != hdcp_cmd_force_encryption))
  967. goto error;
  968. return 0;
  969. error:
  970. return rc;
  971. }
  972. int hdcp2_force_encryption(void *ctx, uint32_t enable)
  973. {
  974. int rc = 0;
  975. struct hdcp2_handle *handle = NULL;
  976. if (!ctx) {
  977. pr_err("invalid input\n");
  978. return -EINVAL;
  979. }
  980. handle = ctx;
  981. rc = hdcp2_force_encryption_utility(handle, enable);
  982. if (rc)
  983. goto error;
  984. pr_debug("success\n");
  985. return 0;
  986. error:
  987. pr_err("failed, rc=%d\n", rc);
  988. return rc;
  989. }
  990. EXPORT_SYMBOL(hdcp2_force_encryption);
  991. static int hdcp2_app_query_stream(struct hdcp2_handle *handle)
  992. {
  993. int rc = 0;
  994. hdcp2_app_init_var(query_stream_type);
  995. req_buf->ctxhandle = handle->tz_ctxhandle;
  996. rc = hdcp2_app_process_cmd(query_stream_type);
  997. if (rc)
  998. goto error;
  999. handle->app_data.response.data = rsp_buf->msg;
  1000. handle->app_data.response.length = rsp_buf->msglen;
  1001. handle->app_data.timeout = rsp_buf->timeout;
  1002. error:
  1003. return rc;
  1004. }
  1005. static unsigned char *hdcp2_get_recv_buf(struct hdcp2_handle *handle)
  1006. {
  1007. struct hdcp_rcvd_msg_req *req_buf;
  1008. req_buf = (struct hdcp_rcvd_msg_req *)(handle->qseecom_handle->sbuf);
  1009. return req_buf->msg;
  1010. }
  1011. int hdcp2_app_comm(void *ctx, enum hdcp2_app_cmd cmd,
  1012. struct hdcp2_app_data *app_data)
  1013. {
  1014. struct hdcp2_handle *handle = NULL;
  1015. int rc = 0;
  1016. if (!ctx || !app_data) {
  1017. pr_err("invalid input\n");
  1018. return -EINVAL;
  1019. }
  1020. handle = ctx;
  1021. handle->app_data.request.length = app_data->request.length;
  1022. pr_debug("command %s\n", hdcp2_app_cmd_str(cmd));
  1023. switch (cmd) {
  1024. case HDCP2_CMD_START:
  1025. rc = hdcp2_app_start(handle);
  1026. break;
  1027. case HDCP2_CMD_START_AUTH:
  1028. rc = hdcp2_app_start_auth(handle);
  1029. break;
  1030. case HDCP2_CMD_PROCESS_MSG:
  1031. rc = hdcp2_app_process_msg(handle);
  1032. break;
  1033. case HDCP2_CMD_TIMEOUT:
  1034. rc = hdcp2_app_timeout(handle);
  1035. break;
  1036. case HDCP2_CMD_EN_ENCRYPTION:
  1037. rc = hdcp2_app_enable_encryption(handle);
  1038. break;
  1039. case HDCP2_CMD_QUERY_STREAM:
  1040. rc = hdcp2_app_query_stream(handle);
  1041. break;
  1042. case HDCP2_CMD_STOP:
  1043. rc = hdcp2_app_stop(handle);
  1044. break;
  1045. default:
  1046. rc = -EINVAL;
  1047. break;
  1048. }
  1049. if (rc)
  1050. goto error;
  1051. handle->app_data.request.data = hdcp2_get_recv_buf(handle);
  1052. app_data->request.data = handle->app_data.request.data;
  1053. app_data->request.length = handle->app_data.request.length;
  1054. app_data->response.data = handle->app_data.response.data;
  1055. app_data->response.length = handle->app_data.response.length;
  1056. app_data->timeout = handle->app_data.timeout;
  1057. app_data->repeater_flag = handle->app_data.repeater_flag;
  1058. error:
  1059. return rc;
  1060. }
  1061. EXPORT_SYMBOL(hdcp2_app_comm);
  1062. static int hdcp2_open_stream_helper(struct hdcp2_handle *handle,
  1063. uint8_t vc_payload_id,
  1064. uint8_t stream_number,
  1065. uint32_t *stream_id)
  1066. {
  1067. int rc = 0;
  1068. hdcp2_app_init_var(session_open_stream);
  1069. if (!(handle->hdcp_state & HDCP_STATE_SESSION_INIT)) {
  1070. pr_err("session not initialized\n");
  1071. rc = -EINVAL;
  1072. goto error;
  1073. }
  1074. if (!(handle->hdcp_state & HDCP_STATE_TXMTR_INIT)) {
  1075. pr_err("txmtr not initialized\n");
  1076. rc = -EINVAL;
  1077. goto error;
  1078. }
  1079. req_buf->sessionid = handle->session_id;
  1080. req_buf->vcpayloadid = vc_payload_id;
  1081. req_buf->stream_number = stream_number;
  1082. req_buf->streamMediaType = 0;
  1083. rc = hdcp2_app_process_cmd(session_open_stream);
  1084. if (rc)
  1085. goto error;
  1086. *stream_id = rsp_buf->streamid;
  1087. pr_debug("success\n");
  1088. error:
  1089. return rc;
  1090. }
  1091. int hdcp2_open_stream(void *ctx, uint8_t vc_payload_id, uint8_t stream_number,
  1092. uint32_t *stream_id)
  1093. {
  1094. struct hdcp2_handle *handle = NULL;
  1095. if (!ctx) {
  1096. pr_err("invalid input\n");
  1097. return -EINVAL;
  1098. }
  1099. handle = ctx;
  1100. return hdcp2_open_stream_helper(handle, vc_payload_id, stream_number,
  1101. stream_id);
  1102. }
  1103. EXPORT_SYMBOL(hdcp2_open_stream);
  1104. static int hdcp2_close_stream_helper(struct hdcp2_handle *handle,
  1105. uint32_t stream_id)
  1106. {
  1107. int rc = 0;
  1108. hdcp2_app_init_var(session_close_stream);
  1109. if (!(handle->hdcp_state & HDCP_STATE_SESSION_INIT)) {
  1110. pr_err("session not initialized\n");
  1111. rc = -EINVAL;
  1112. goto error;
  1113. }
  1114. if (!(handle->hdcp_state & HDCP_STATE_TXMTR_INIT)) {
  1115. pr_err("txmtr not initialized\n");
  1116. rc = -EINVAL;
  1117. goto error;
  1118. }
  1119. req_buf->sessionid = handle->session_id;
  1120. req_buf->streamid = stream_id;
  1121. rc = hdcp2_app_process_cmd(session_close_stream);
  1122. if (rc)
  1123. goto error;
  1124. pr_debug("success\n");
  1125. error:
  1126. return rc;
  1127. }
  1128. int hdcp2_close_stream(void *ctx, uint32_t stream_id)
  1129. {
  1130. struct hdcp2_handle *handle = NULL;
  1131. if (!ctx) {
  1132. pr_err("invalid input\n");
  1133. return -EINVAL;
  1134. }
  1135. handle = ctx;
  1136. return hdcp2_close_stream_helper(handle, stream_id);
  1137. }
  1138. EXPORT_SYMBOL(hdcp2_close_stream);
  1139. void *hdcp2_init(u32 device_type)
  1140. {
  1141. struct hdcp2_handle *handle = NULL;
  1142. handle = kzalloc(sizeof(struct hdcp2_handle), GFP_KERNEL);
  1143. if (!handle)
  1144. goto error;
  1145. handle->device_type = device_type;
  1146. handle->app_name = HDCP2P2_APP_NAME;
  1147. error:
  1148. return handle;
  1149. }
  1150. EXPORT_SYMBOL(hdcp2_init);
  1151. void hdcp2_deinit(void *ctx)
  1152. {
  1153. kfree_sensitive(ctx);
  1154. }
  1155. EXPORT_SYMBOL(hdcp2_deinit);
  1156. void *hdcp1_init(void)
  1157. {
  1158. struct hdcp1_handle *handle =
  1159. kzalloc(sizeof(struct hdcp1_handle), GFP_KERNEL);
  1160. if (!handle)
  1161. goto error;
  1162. handle->app_name = HDCP1_APP_NAME;
  1163. error:
  1164. return handle;
  1165. }
  1166. EXPORT_SYMBOL(hdcp1_init);
  1167. void hdcp1_deinit(void *data)
  1168. {
  1169. kfree(data);
  1170. }
  1171. EXPORT_SYMBOL(hdcp1_deinit);
  1172. static int hdcp1_count_ones(u8 *array, u8 len)
  1173. {
  1174. int i, j, count = 0;
  1175. for (i = 0; i < len; i++)
  1176. for (j = 0; j < 8; j++)
  1177. count += (((array[i] >> j) & 0x1) ? 1 : 0);
  1178. return count;
  1179. }
  1180. static int hdcp1_validate_aksv(u32 aksv_msb, u32 aksv_lsb)
  1181. {
  1182. int const number_of_ones = 20;
  1183. u8 aksv[5];
  1184. pr_debug("AKSV=%02x%08x\n", aksv_msb, aksv_lsb);
  1185. aksv[0] = aksv_lsb & 0xFF;
  1186. aksv[1] = (aksv_lsb >> 8) & 0xFF;
  1187. aksv[2] = (aksv_lsb >> 16) & 0xFF;
  1188. aksv[3] = (aksv_lsb >> 24) & 0xFF;
  1189. aksv[4] = aksv_msb & 0xFF;
  1190. /* check there are 20 ones in AKSV */
  1191. if (hdcp1_count_ones(aksv, 5) != number_of_ones) {
  1192. pr_err("AKSV bit count failed\n");
  1193. return -EINVAL;
  1194. }
  1195. return 0;
  1196. }
  1197. static int hdcp1_set_key(struct hdcp1_handle *hdcp1_handle, u32 *aksv_msb,
  1198. u32 *aksv_lsb)
  1199. {
  1200. int rc = 0;
  1201. struct hdcp1_key_set_req *key_set_req;
  1202. struct hdcp1_key_set_rsp *key_set_rsp;
  1203. struct qseecom_handle *handle = NULL;
  1204. if (aksv_msb == NULL || aksv_lsb == NULL) {
  1205. pr_err("invalid aksv\n");
  1206. return -EINVAL;
  1207. }
  1208. if (!hdcp1_handle || !hdcp1_handle->qseecom_handle) {
  1209. pr_err("invalid HDCP 1.x handle\n");
  1210. return -EINVAL;
  1211. }
  1212. if (!(hdcp1_handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  1213. pr_err("%s app not loaded\n", hdcp1_handle->app_name);
  1214. return -EINVAL;
  1215. }
  1216. handle = hdcp1_handle->qseecom_handle;
  1217. /* set keys and request aksv */
  1218. key_set_req = (struct hdcp1_key_set_req *)handle->sbuf;
  1219. key_set_req->commandid = HDCP1_SET_KEY;
  1220. key_set_rsp = (struct hdcp1_key_set_rsp *)(handle->sbuf +
  1221. QSEECOM_ALIGN(sizeof(struct hdcp1_key_set_req)));
  1222. rc = qseecom_send_command(handle, key_set_req,
  1223. QSEECOM_ALIGN(sizeof
  1224. (struct hdcp1_key_set_req)),
  1225. key_set_rsp,
  1226. QSEECOM_ALIGN(sizeof
  1227. (struct hdcp1_key_set_rsp)));
  1228. if (rc < 0) {
  1229. pr_err("qseecom cmd failed err=%d\n", rc);
  1230. return -ENOKEY;
  1231. }
  1232. rc = key_set_rsp->ret;
  1233. if (rc) {
  1234. pr_err("set key cmd failed, rsp=%d\n", key_set_rsp->ret);
  1235. return -ENOKEY;
  1236. }
  1237. /* copy bytes into msb and lsb */
  1238. *aksv_msb = key_set_rsp->ksv[0] << 24 | key_set_rsp->ksv[1] << 16 |
  1239. key_set_rsp->ksv[2] << 8 | key_set_rsp->ksv[3];
  1240. *aksv_lsb = key_set_rsp->ksv[4] << 24 | key_set_rsp->ksv[5] << 16 |
  1241. key_set_rsp->ksv[6] << 8 | key_set_rsp->ksv[7];
  1242. rc = hdcp1_validate_aksv(*aksv_msb, *aksv_lsb);
  1243. if (rc) {
  1244. pr_err("aksv validation failed (%d)\n", rc);
  1245. return rc;
  1246. }
  1247. return 0;
  1248. }
  1249. static int hdcp1_app_load(struct hdcp1_handle *handle)
  1250. {
  1251. int rc = 0;
  1252. if (!handle) {
  1253. pr_err("invalid handle\n");
  1254. goto error;
  1255. }
  1256. rc = qseecom_start_app(&handle->qseecom_handle, handle->app_name,
  1257. QSEECOM_SBUFF_SIZE);
  1258. if (rc) {
  1259. pr_err("%s app load failed (%d)\n", handle->app_name, rc);
  1260. goto error;
  1261. }
  1262. rc = qseecom_start_app(&handle->hdcpops_handle, HDCP1OPS_APP_NAME,
  1263. QSEECOM_SBUFF_SIZE);
  1264. if (rc) {
  1265. pr_warn("%s app load failed (%d)\n", HDCP1OPS_APP_NAME, rc);
  1266. handle->hdcpops_handle = NULL;
  1267. }
  1268. handle->hdcp_state |= HDCP_STATE_APP_LOADED;
  1269. pr_debug("%s app loaded\n", handle->app_name);
  1270. error:
  1271. return rc;
  1272. }
  1273. static void hdcp1_app_unload(struct hdcp1_handle *handle)
  1274. {
  1275. int rc = 0;
  1276. if (!handle || !handle->qseecom_handle) {
  1277. pr_err("invalid handle\n");
  1278. return;
  1279. }
  1280. if (!(handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  1281. pr_warn("%s app not loaded\n", handle->app_name);
  1282. return;
  1283. }
  1284. if (handle->hdcpops_handle) {
  1285. /* deallocate the resources for HDCP 1.x ops handle */
  1286. rc = qseecom_shutdown_app(&handle->hdcpops_handle);
  1287. if (rc)
  1288. pr_warn("%s app unload failed (%d)\n", HDCP1OPS_APP_NAME, rc);
  1289. }
  1290. /* deallocate the resources for qseecom HDCP 1.x handle */
  1291. rc = qseecom_shutdown_app(&handle->qseecom_handle);
  1292. if (rc) {
  1293. pr_err("%s app unload failed (%d)\n", handle->app_name, rc);
  1294. return;
  1295. }
  1296. handle->hdcp_state &= ~HDCP_STATE_APP_LOADED;
  1297. pr_debug("%s app unloaded\n", handle->app_name);
  1298. }
  1299. static int hdcp1_verify_key(struct hdcp1_handle *hdcp1_handle)
  1300. {
  1301. int rc = 0;
  1302. struct hdcp1_key_verify_req *key_verify_req;
  1303. struct hdcp1_key_verify_rsp *key_verify_rsp;
  1304. struct qseecom_handle *handle = NULL;
  1305. if (!hdcp1_handle || !hdcp1_handle->qseecom_handle) {
  1306. pr_err("invalid HDCP 1.x handle\n");
  1307. return -EINVAL;
  1308. }
  1309. if (!(hdcp1_handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  1310. pr_err("%s app not loaded\n", hdcp1_handle->app_name);
  1311. return -EINVAL;
  1312. }
  1313. handle = hdcp1_handle->qseecom_handle;
  1314. key_verify_req = (struct hdcp1_key_verify_req *)handle->sbuf;
  1315. key_verify_req->commandid = HDCP1_KEY_VERIFY;
  1316. key_verify_rsp = (struct hdcp1_key_verify_rsp *)(handle->sbuf +
  1317. QSEECOM_ALIGN(sizeof(struct hdcp1_key_verify_req)));
  1318. rc = qseecom_send_command(handle, key_verify_req,
  1319. QSEECOM_ALIGN(sizeof
  1320. (struct hdcp1_key_verify_req)),
  1321. key_verify_rsp,
  1322. QSEECOM_ALIGN(sizeof
  1323. (struct hdcp1_key_set_rsp)));
  1324. if (rc < 0) {
  1325. pr_err("command HDCP1_KEY_VERIFY failed (%d)\n", rc);
  1326. return -EINVAL;
  1327. }
  1328. rc = key_verify_rsp->ret;
  1329. if (rc) {
  1330. pr_err("key_verify failed, rsp=%d\n", key_verify_rsp->ret);
  1331. return -EINVAL;
  1332. }
  1333. pr_debug("success\n");
  1334. return 0;
  1335. }
  1336. bool hdcp1_feature_supported(void *data)
  1337. {
  1338. bool supported = false;
  1339. struct hdcp1_handle *handle = data;
  1340. int rc = 0;
  1341. if (!handle) {
  1342. pr_err("invalid handle\n");
  1343. goto error;
  1344. }
  1345. if (handle->feature_supported) {
  1346. supported = true;
  1347. goto error;
  1348. }
  1349. rc = hdcp1_app_load(handle);
  1350. if (!rc && (handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  1351. if (!hdcp1_verify_key(handle)) {
  1352. pr_debug("HDCP 1.x supported\n");
  1353. handle->feature_supported = true;
  1354. supported = true;
  1355. }
  1356. hdcp1_app_unload(handle);
  1357. }
  1358. error:
  1359. return supported;
  1360. }
  1361. EXPORT_SYMBOL(hdcp1_feature_supported);
  1362. int hdcp1_set_enc(void *data, bool enable)
  1363. {
  1364. int rc = 0;
  1365. struct hdcp1_set_enc_req *set_enc_req;
  1366. struct hdcp1_set_enc_rsp *set_enc_rsp;
  1367. struct hdcp1_handle *hdcp1_handle = data;
  1368. struct qseecom_handle *handle = NULL;
  1369. if (!hdcp1_handle || !hdcp1_handle->qseecom_handle) {
  1370. pr_err("invalid HDCP 1.x handle\n");
  1371. return -EINVAL;
  1372. }
  1373. if (!hdcp1_handle->feature_supported) {
  1374. pr_err("HDCP 1.x not supported\n");
  1375. return -EINVAL;
  1376. }
  1377. if (!(hdcp1_handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  1378. pr_err("%s app not loaded\n", hdcp1_handle->app_name);
  1379. return -EINVAL;
  1380. }
  1381. handle = hdcp1_handle->qseecom_handle;
  1382. /* set keys and request aksv */
  1383. set_enc_req = (struct hdcp1_set_enc_req *)handle->sbuf;
  1384. set_enc_req->commandid = HDCP1_SET_ENC;
  1385. set_enc_req->enable = enable;
  1386. set_enc_rsp = (struct hdcp1_set_enc_rsp *)(handle->sbuf +
  1387. QSEECOM_ALIGN(sizeof(struct hdcp1_set_enc_req)));
  1388. rc = qseecom_send_command(handle, set_enc_req,
  1389. QSEECOM_ALIGN(sizeof
  1390. (struct hdcp1_set_enc_req)),
  1391. set_enc_rsp,
  1392. QSEECOM_ALIGN(sizeof
  1393. (struct hdcp1_set_enc_rsp)));
  1394. if (rc < 0) {
  1395. pr_err("qseecom cmd failed err=%d\n", rc);
  1396. return -EINVAL;
  1397. }
  1398. rc = set_enc_rsp->ret;
  1399. if (rc) {
  1400. pr_err("enc cmd failed, rsp=%d\n", set_enc_rsp->ret);
  1401. return -EINVAL;
  1402. }
  1403. pr_debug("success\n");
  1404. return 0;
  1405. }
  1406. EXPORT_SYMBOL(hdcp1_set_enc);
  1407. int hdcp1_ops_notify(void *data, void *topo, bool is_authenticated)
  1408. {
  1409. int rc = 0;
  1410. struct hdcp1_ops_notify_req *ops_notify_req;
  1411. struct hdcp1_ops_notify_rsp *ops_notify_rsp;
  1412. struct hdcp1_handle *hdcp1_handle = data;
  1413. struct qseecom_handle *handle = NULL;
  1414. struct hdcp1_topology *topology = NULL;
  1415. if (!hdcp1_handle || !hdcp1_handle->hdcpops_handle) {
  1416. pr_err("invalid HDCP 1.x ops handle\n");
  1417. return -EINVAL;
  1418. }
  1419. if (!hdcp1_handle->feature_supported) {
  1420. pr_err("HDCP 1.x not supported\n");
  1421. return -EINVAL;
  1422. }
  1423. if (!(hdcp1_handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  1424. pr_err("%s app not loaded\n", HDCP1OPS_APP_NAME);
  1425. return -EINVAL;
  1426. }
  1427. handle = hdcp1_handle->hdcpops_handle;
  1428. topology = (struct hdcp1_topology *)topo;
  1429. /* set keys and request aksv */
  1430. ops_notify_req = (struct hdcp1_ops_notify_req *)handle->sbuf;
  1431. ops_notify_req->commandid = HDCP1_NOTIFY_TOPOLOGY;
  1432. ops_notify_req->device_type = DEVICE_TYPE_DP;
  1433. ops_notify_req->is_authenticated = is_authenticated;
  1434. ops_notify_req->topology.depth = topology->depth;
  1435. ops_notify_req->topology.device_count = topology->device_count;
  1436. ops_notify_req->topology.max_devices_exceeded = topology->max_devices_exceeded;
  1437. ops_notify_req->topology.max_cascade_exceeded = topology->max_cascade_exceeded;
  1438. /*
  1439. * For hdcp1.4 below two nodes are not applicable but as
  1440. * TZ ops ta talks with other drivers with same structure
  1441. * and want to maintain same interface across hdcp versions,
  1442. * we are setting the values to 0.
  1443. */
  1444. ops_notify_req->topology.hdcp2LegacyDeviceDownstream = 0;
  1445. ops_notify_req->topology.hdcp1DeviceDownstream = 0;
  1446. memset(ops_notify_req->recv_id_list, 0, sizeof(uint8_t) * MAX_REC_ID_LIST_SIZE);
  1447. ops_notify_rsp = (struct hdcp1_ops_notify_rsp *)(handle->sbuf +
  1448. QSEECOM_ALIGN(sizeof(struct hdcp1_ops_notify_req)));
  1449. rc = qseecom_send_command(handle, ops_notify_req,
  1450. QSEECOM_ALIGN(sizeof(struct hdcp1_ops_notify_req)),
  1451. ops_notify_rsp,
  1452. QSEECOM_ALIGN(sizeof(struct hdcp1_ops_notify_rsp)));
  1453. rc = ops_notify_rsp->ret;
  1454. if (rc < 0) {
  1455. pr_warn("Ops notify cmd failed, rsp=%d\n", ops_notify_rsp->ret);
  1456. return -EINVAL;
  1457. }
  1458. pr_debug("ops notify success\n");
  1459. return 0;
  1460. }
  1461. EXPORT_SYMBOL(hdcp1_ops_notify);
  1462. int hdcp1_start(void *data, u32 *aksv_msb, u32 *aksv_lsb)
  1463. {
  1464. int rc = 0;
  1465. struct hdcp1_handle *hdcp1_handle = data;
  1466. if (!aksv_msb || !aksv_lsb) {
  1467. pr_err("invalid aksv output buffer\n");
  1468. rc = -EINVAL;
  1469. goto error;
  1470. }
  1471. if (!hdcp1_handle) {
  1472. pr_err("invalid handle\n");
  1473. rc = -EINVAL;
  1474. goto error;
  1475. }
  1476. if (!hdcp1_handle->feature_supported) {
  1477. pr_err("feature not supported\n");
  1478. rc = -EINVAL;
  1479. goto error;
  1480. }
  1481. if (hdcp1_handle->hdcp_state & HDCP_STATE_APP_LOADED) {
  1482. pr_debug("%s app already loaded\n", hdcp1_handle->app_name);
  1483. goto error;
  1484. }
  1485. rc = hdcp1_app_load(hdcp1_handle);
  1486. if (rc)
  1487. goto error;
  1488. rc = hdcp1_set_key(hdcp1_handle, aksv_msb, aksv_lsb);
  1489. if (rc)
  1490. goto key_error;
  1491. pr_debug("success\n");
  1492. return rc;
  1493. key_error:
  1494. hdcp1_app_unload(hdcp1_handle);
  1495. error:
  1496. return rc;
  1497. }
  1498. EXPORT_SYMBOL(hdcp1_start);
  1499. void hdcp1_stop(void *data)
  1500. {
  1501. struct hdcp1_handle *hdcp1_handle = data;
  1502. if (!hdcp1_handle || !hdcp1_handle->qseecom_handle || !hdcp1_handle->hdcpops_handle) {
  1503. pr_err("invalid handle\n");
  1504. return;
  1505. }
  1506. if (!(hdcp1_handle->hdcp_state & HDCP_STATE_APP_LOADED)) {
  1507. pr_debug("%s app not loaded\n", hdcp1_handle->app_name);
  1508. return;
  1509. }
  1510. hdcp1_app_unload(hdcp1_handle);
  1511. }
  1512. EXPORT_SYMBOL(hdcp1_stop);
  1513. static int __init hdcp_module_init(void){ return 0; }
  1514. static void __exit hdcp_module_exit(void){ return; }
  1515. MODULE_LICENSE("GPL v2");
  1516. MODULE_DESCRIPTION("HDCP driver");
  1517. module_init(hdcp_module_init);
  1518. module_exit(hdcp_module_exit);