blob: 20f5cba11f96d1183cc8f3345c01df7876bd650f [file] [log] [blame]
Tatenda Chipeperekwa65935362017-06-07 13:44:11 -07001/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __HDCP_QSEECOM_H
14#define __HDCP_QSEECOM_H
15#include <linux/types.h>
16
17#define HDCP_MAX_MESSAGE_PARTS 4
18
19/**
20 * enum hdcp_lib_wakeup_cmd - commands for interacting with HDCP driver
21 * @HDCP_LIB_WKUP_CMD_INVALID: initialization value
22 * @HDCP_LIB_WKUP_CMD_START: start authentication
23 * @HDCP_LIB_WKUP_CMD_STOP: stop authentication
24 * @HDCP_LIB_WKUP_CMD_MSG_SEND_SUCCESS: sending message to sink succeeded
25 * @HDCP_LIB_WKUP_CMD_MSG_SEND_FAILED: sending message to sink failed
26 * @HDCP_LIB_WKUP_CMD_MSG_RECV_SUCCESS: receiving message from sink succeeded
27 * @HDCP_LIB_WKUP_CMD_MSG_RECV_FAILED: receiving message from sink failed
28 * @HDCP_LIB_WKUP_CMD_MSG_RECV_TIMEOUT: receiving message from sink timed out
29 * @HDCP_LIB_WKUP_CMD_QUERY_STREAM_TYPE: start content stream processing
30 * @HDCP_LIB_WKUP_CMD_LINK_FAILED: link failure notification
31 */
32enum hdcp_lib_wakeup_cmd {
33 HDCP_LIB_WKUP_CMD_INVALID,
34 HDCP_LIB_WKUP_CMD_START,
35 HDCP_LIB_WKUP_CMD_STOP,
36 HDCP_LIB_WKUP_CMD_MSG_SEND_SUCCESS,
37 HDCP_LIB_WKUP_CMD_MSG_SEND_FAILED,
38 HDCP_LIB_WKUP_CMD_MSG_RECV_SUCCESS,
39 HDCP_LIB_WKUP_CMD_MSG_RECV_FAILED,
40 HDCP_LIB_WKUP_CMD_MSG_RECV_TIMEOUT,
41 HDCP_LIB_WKUP_CMD_QUERY_STREAM_TYPE,
42 HDCP_LIB_WKUP_CMD_LINK_FAILED,
43};
44
45/**
46 * enum hdcp_wakeup_cmd - commands for interacting with display transport layer
47 * @HDCP_WKUP_CMD_INVALID: initialization value
48 * @HDCP_WKUP_CMD_SEND_MESSAGE: send message to sink
49 * @HDCP_WKUP_CMD_RECV_MESSAGE: receive message from sink
50 * @HDCP_WKUP_CMD_STATUS_SUCCESS: successfully communicated with TrustZone
51 * @HDCP_WKUP_CMD_STATUS_FAILED: failed to communicate with TrustZone
52 * @HDCP_WKUP_CMD_LINK_POLL: poll the HDCP link
53 * @HDCP_WKUP_CMD_AUTHENTICATE: start authentication
54 */
55enum hdcp_wakeup_cmd {
56 HDCP_WKUP_CMD_INVALID,
57 HDCP_WKUP_CMD_SEND_MESSAGE,
58 HDCP_WKUP_CMD_RECV_MESSAGE,
59 HDCP_WKUP_CMD_STATUS_SUCCESS,
60 HDCP_WKUP_CMD_STATUS_FAILED,
61 HDCP_WKUP_CMD_LINK_POLL,
62 HDCP_WKUP_CMD_AUTHENTICATE
63};
64
65/**
66 * struct hdcp_lib_wakeup_data - command and data send to HDCP driver
67 * @cmd: command type
68 * @context: void pointer to the HDCP driver instance
69 * @recvd_msg_buf: message received from the sink
70 * @recvd_msg_len: length of message received from the sink
71 * @timeout: time out value for timed transactions
72 */
73struct hdcp_lib_wakeup_data {
74 enum hdcp_lib_wakeup_cmd cmd;
75 void *context;
76 char *recvd_msg_buf;
77 uint32_t recvd_msg_len;
78 uint32_t timeout;
79};
80
81/**
82 * struct hdcp_msg_part - a single part of an HDCP 2.2 message
83 * @name: user readable message name
84 * @offset: message part offset
85 * @length message part length
86 */
87struct hdcp_msg_part {
88 char *name;
89 uint32_t offset;
90 uint32_t length;
91};
92
93/**
94 * struct hdcp_msg_data - a full HDCP 2.2 message containing one or more parts
95 * @num_messages: total number of parts in a full message
96 * @messages: array containing num_messages parts
97 * @rx_status: value of rx_status register
98 */
99struct hdcp_msg_data {
100 uint32_t num_messages;
101 struct hdcp_msg_part messages[HDCP_MAX_MESSAGE_PARTS];
102 uint8_t rx_status;
103};
104
105/**
106 * struct hdcp_wakeup_data - command and data sent to display transport layer
107 * @cmd: command type
108 * @context: void pointer to the display transport layer
109 * @send_msg_buf: buffer containing message to be sent to sink
110 * @send_msg_len: length of the message to be sent to sink
111 * @timeout: timeout value for timed transactions
112 * @abort_mask: mask used to determine whether HDCP link is valid
113 * @message_data: a pointer to the message description
114 */
115struct hdcp_wakeup_data {
116 enum hdcp_wakeup_cmd cmd;
117 void *context;
118 char *send_msg_buf;
119 uint32_t send_msg_len;
120 uint32_t timeout;
121 uint8_t abort_mask;
122 const struct hdcp_msg_data *message_data;
123};
124
125static inline char *hdcp_cmd_to_str(uint32_t cmd)
126{
127 switch (cmd) {
128 case HDCP_WKUP_CMD_SEND_MESSAGE:
129 return "HDCP_WKUP_CMD_SEND_MESSAGE";
130 case HDCP_WKUP_CMD_RECV_MESSAGE:
131 return "HDCP_WKUP_CMD_RECV_MESSAGE";
132 case HDCP_WKUP_CMD_STATUS_SUCCESS:
133 return "HDCP_WKUP_CMD_STATUS_SUCCESS";
134 case HDCP_WKUP_CMD_STATUS_FAILED:
135 return "HDCP_WKUP_CMD_STATUS_FAIL";
136 case HDCP_WKUP_CMD_LINK_POLL:
137 return "HDCP_WKUP_CMD_LINK_POLL";
138 case HDCP_WKUP_CMD_AUTHENTICATE:
139 return "HDCP_WKUP_CMD_AUTHENTICATE";
140 default:
141 return "???";
142 }
143}
144
145static inline char *hdcp_lib_cmd_to_str(uint32_t cmd)
146{
147 switch (cmd) {
148 case HDCP_LIB_WKUP_CMD_START:
149 return "HDCP_LIB_WKUP_CMD_START";
150 case HDCP_LIB_WKUP_CMD_STOP:
151 return "HDCP_LIB_WKUP_CMD_STOP";
152 case HDCP_LIB_WKUP_CMD_MSG_SEND_SUCCESS:
153 return "HDCP_LIB_WKUP_CMD_MSG_SEND_SUCCESS";
154 case HDCP_LIB_WKUP_CMD_MSG_SEND_FAILED:
155 return "HDCP_LIB_WKUP_CMD_MSG_SEND_FAILED";
156 case HDCP_LIB_WKUP_CMD_MSG_RECV_SUCCESS:
157 return "HDCP_LIB_WKUP_CMD_MSG_RECV_SUCCESS";
158 case HDCP_LIB_WKUP_CMD_MSG_RECV_FAILED:
159 return "HDCP_LIB_WKUP_CMD_MSG_RECV_FAILED";
160 case HDCP_LIB_WKUP_CMD_MSG_RECV_TIMEOUT:
161 return "HDCP_LIB_WKUP_CMD_MSG_RECV_TIMEOUT";
162 case HDCP_LIB_WKUP_CMD_QUERY_STREAM_TYPE:
163 return "HDCP_LIB_WKUP_CMD_QUERY_STREAM_TYPE";
164 case HDCP_LIB_WKUP_CMD_LINK_FAILED:
165 return "HDCP_LIB_WKUP_CMD_LINK_FAILED";
166 default:
167 return "???";
168 }
169}
170
171/**
172 * struct hdcp_txmtr_ops - interface to HDCP Driver
173 * @wakeup: wake the HDCP driver with a new command
174 * @feature_supported: checks for HDCP support on the target device
175 */
176struct hdcp_txmtr_ops {
177 int (*wakeup)(struct hdcp_lib_wakeup_data *data);
178 bool (*feature_supported)(void *phdcpcontext);
179};
180
181/**
182 * struct hdcp_client_ops - call back functions to display transport layer
183 * @wakeup: wake up display transport layer with a new command
184 * @notify_lvl_change notify of encryption level changes
185 */
186struct hdcp_client_ops {
187 int (*wakeup)(struct hdcp_wakeup_data *data);
188 void (*notify_lvl_change)(void *client_ctx, int min_lvl);
189};
190
191/**
192 * enum hdcp_device_type - display interface types
193 * @HDCP_TXMTR_HDMI: HDMI interface
194 * @HDCP_TXMTR_DP: DisplayPort interface
195 */
196enum hdcp_device_type {
197 HDCP_TXMTR_HDMI = 0x8001,
198 HDCP_TXMTR_DP = 0x8002
199};
200
201/**
202 * struct hdcp_register_data - data used in HDCP driver clients' registration
203 * @client_ops: call back functions from the client
204 * @txmtr_ops: HDCP driver interface
205 * @device_type: display interface type of the client
206 * @client_ctx: void pointer to client data object
207 * @hdcp_ctx: void pointer to HDCP driver reference for client use
208 */
209struct hdcp_register_data {
210 struct hdcp_client_ops *client_ops;
211 struct hdcp_txmtr_ops *txmtr_ops;
212 enum hdcp_device_type device_type;
213 void *client_ctx;
214 void **hdcp_ctx;
215};
216
217int hdcp_library_register(struct hdcp_register_data *data);
218void hdcp_library_deregister(void *phdcpcontext);
219bool hdcp1_check_if_supported_load_app(void);
220int hdcp1_set_keys(uint32_t *aksv_msb, uint32_t *aksv_lsb);
221int hdcp1_set_enc(bool enable);
222void hdcp1_cache_repeater_topology(void *hdcp1_cached_tp);
223void hdcp1_notify_topology(void);
224#endif /* __HDCP_QSEECOM_H */