blob: 2adab8fbf8dbad876a4c5e957834d5e63f1c182b [file] [log] [blame]
Ziyuan Xu48890e22016-10-27 19:07:35 +08001/*
Antonio Nino Diaz3c817f42018-03-21 10:49:27 +00002 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
Ziyuan Xu48890e22016-10-27 19:07:35 +08003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz4b32e622018-08-16 16:52:57 +01007#include <cdefs.h>
Ziyuan Xu4060cfd2017-02-10 11:54:52 +08008#include <cdn_dp.h>
Antonio Nino Diaz3c817f42018-03-21 10:49:27 +00009#include <smccc.h>
Ziyuan Xu48890e22016-10-27 19:07:35 +080010#include <stdlib.h>
Ziyuan Xu4060cfd2017-02-10 11:54:52 +080011#include <string.h>
Ziyuan Xu48890e22016-10-27 19:07:35 +080012
13__asm__(
14 ".pushsection .text.hdcp_handler, \"ax\", %progbits\n"
15 ".global hdcp_handler\n"
16 ".balign 4\n"
17 "hdcp_handler:\n"
18 ".incbin \"" __XSTRING(HDCPFW) "\"\n"
19 ".type hdcp_handler, %function\n"
20 ".size hdcp_handler, .- hdcp_handler\n"
21 ".popsection\n"
22);
23
Ziyuan Xu4060cfd2017-02-10 11:54:52 +080024static uint64_t *hdcp_key_pdata;
25static struct cdn_dp_hdcp_key_1x key;
26
27int hdcp_handler(struct cdn_dp_hdcp_key_1x *key);
28
29uint64_t dp_hdcp_ctrl(uint64_t type)
30{
31 switch (type) {
32 case HDCP_KEY_DATA_START_TRANSFER:
33 memset(&key, 0x00, sizeof(key));
34 hdcp_key_pdata = (uint64_t *)&key;
35 return 0;
36 case HDCP_KEY_DATA_START_DECRYPT:
37 if (hdcp_key_pdata == (uint64_t *)(&key + 1))
38 return hdcp_handler(&key);
39 else
40 return PSCI_E_INVALID_PARAMS;
41 default:
42 return SMC_UNK;
43 }
44}
45
46uint64_t dp_hdcp_store_key(uint64_t x1,
47 uint64_t x2,
48 uint64_t x3,
49 uint64_t x4,
50 uint64_t x5,
51 uint64_t x6)
52{
53 if (hdcp_key_pdata < (uint64_t *)&key ||
54 hdcp_key_pdata + 6 > (uint64_t *)(&key + 1))
55 return PSCI_E_INVALID_PARAMS;
56
57 hdcp_key_pdata[0] = x1;
58 hdcp_key_pdata[1] = x2;
59 hdcp_key_pdata[2] = x3;
60 hdcp_key_pdata[3] = x4;
61 hdcp_key_pdata[4] = x5;
62 hdcp_key_pdata[5] = x6;
63 hdcp_key_pdata += 6;
64
65 return 0;
66}