Commit | Line | Data |
---|---|---|
4c283fda | 1 | /* |
bf62221e | 2 | * Copyright 2018 Advanced Micro Devices, Inc. |
4c283fda BL |
3 | * |
4 | * Permission is hereby granted, free of charge, to any person obtaining a | |
5 | * copy of this software and associated documentation files (the "Software"), | |
6 | * to deal in the Software without restriction, including without limitation | |
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
8 | * and/or sell copies of the Software, and to permit persons to whom the | |
9 | * Software is furnished to do so, subject to the following conditions: | |
10 | * | |
11 | * The above copyright notice and this permission notice shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
20 | * OTHER DEALINGS IN THE SOFTWARE. | |
21 | * | |
22 | * Authors: AMD | |
23 | * | |
24 | */ | |
25 | ||
26 | #ifndef MOD_HDCP_H_ | |
27 | #define MOD_HDCP_H_ | |
28 | ||
29 | #include "os_types.h" | |
30 | #include "signal_types.h" | |
31 | ||
32 | /* Forward Declarations */ | |
33 | struct mod_hdcp; | |
34 | ||
35 | #define MAX_NUM_OF_DISPLAYS 6 | |
36 | #define MAX_NUM_OF_ATTEMPTS 4 | |
37 | #define MAX_NUM_OF_ERROR_TRACE 10 | |
38 | ||
39 | /* detailed return status */ | |
40 | enum mod_hdcp_status { | |
41 | MOD_HDCP_STATUS_SUCCESS = 0, | |
42 | MOD_HDCP_STATUS_FAILURE, | |
43 | MOD_HDCP_STATUS_RESET_NEEDED, | |
44 | MOD_HDCP_STATUS_DISPLAY_OUT_OF_BOUND, | |
45 | MOD_HDCP_STATUS_DISPLAY_NOT_FOUND, | |
46 | MOD_HDCP_STATUS_INVALID_STATE, | |
47 | MOD_HDCP_STATUS_NOT_IMPLEMENTED, | |
48 | MOD_HDCP_STATUS_INTERNAL_POLICY_FAILURE, | |
49 | MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE, | |
50 | MOD_HDCP_STATUS_CREATE_PSP_SERVICE_FAILURE, | |
51 | MOD_HDCP_STATUS_DESTROY_PSP_SERVICE_FAILURE, | |
52 | MOD_HDCP_STATUS_HDCP1_CREATE_SESSION_FAILURE, | |
53 | MOD_HDCP_STATUS_HDCP1_DESTROY_SESSION_FAILURE, | |
54 | MOD_HDCP_STATUS_HDCP1_VALIDATE_ENCRYPTION_FAILURE, | |
55 | MOD_HDCP_STATUS_HDCP1_NOT_HDCP_REPEATER, | |
56 | MOD_HDCP_STATUS_HDCP1_NOT_CAPABLE, | |
57 | MOD_HDCP_STATUS_HDCP1_R0_PRIME_PENDING, | |
58 | MOD_HDCP_STATUS_HDCP1_VALIDATE_RX_FAILURE, | |
3744ee2c | 59 | MOD_HDCP_STATUS_HDCP1_BKSV_REVOKED, |
4c283fda BL |
60 | MOD_HDCP_STATUS_HDCP1_KSV_LIST_NOT_READY, |
61 | MOD_HDCP_STATUS_HDCP1_VALIDATE_KSV_LIST_FAILURE, | |
3744ee2c | 62 | MOD_HDCP_STATUS_HDCP1_KSV_LIST_REVOKED, |
49c4a8b6 | 63 | MOD_HDCP_STATUS_HDCP1_ENABLE_ENCRYPTION_FAILURE, |
4c283fda BL |
64 | MOD_HDCP_STATUS_HDCP1_ENABLE_STREAM_ENCRYPTION_FAILURE, |
65 | MOD_HDCP_STATUS_HDCP1_MAX_CASCADE_EXCEEDED_FAILURE, | |
66 | MOD_HDCP_STATUS_HDCP1_MAX_DEVS_EXCEEDED_FAILURE, | |
67 | MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE, | |
68 | MOD_HDCP_STATUS_HDCP1_LINK_INTEGRITY_FAILURE, | |
69 | MOD_HDCP_STATUS_HDCP1_REAUTH_REQUEST_ISSUED, | |
70 | MOD_HDCP_STATUS_HDCP1_LINK_MAINTENANCE_FAILURE, | |
71 | MOD_HDCP_STATUS_HDCP1_INVALID_BKSV, | |
72 | MOD_HDCP_STATUS_DDC_FAILURE, /* TODO: specific errors */ | |
73 | MOD_HDCP_STATUS_INVALID_OPERATION, | |
74 | MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE, | |
75 | MOD_HDCP_STATUS_HDCP2_CREATE_SESSION_FAILURE, | |
76 | MOD_HDCP_STATUS_HDCP2_DESTROY_SESSION_FAILURE, | |
77 | MOD_HDCP_STATUS_HDCP2_PREP_AKE_INIT_FAILURE, | |
78 | MOD_HDCP_STATUS_HDCP2_AKE_CERT_PENDING, | |
79 | MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING, | |
80 | MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING, | |
81 | MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE, | |
51466b3f | 82 | MOD_HDCP_STATUS_HDCP2_AKE_CERT_REVOKED, |
4c283fda BL |
83 | MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE, |
84 | MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE, | |
85 | MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE, | |
86 | MOD_HDCP_STATUS_HDCP2_L_PRIME_PENDING, | |
87 | MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE, | |
88 | MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE, | |
89 | MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE, | |
90 | MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY, | |
91 | MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE, | |
51466b3f | 92 | MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED, |
49c4a8b6 | 93 | MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION_FAILURE, |
4c283fda BL |
94 | MOD_HDCP_STATUS_HDCP2_STREAM_READY_PENDING, |
95 | MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE, | |
96 | MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE, | |
97 | MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST, | |
98 | MOD_HDCP_STATUS_HDCP2_REAUTH_LINK_INTEGRITY_FAILURE, | |
99 | MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE, | |
bf62221e | 100 | MOD_HDCP_STATUS_UNSUPPORTED_PSP_VER_FAILURE, |
4c283fda BL |
101 | }; |
102 | ||
103 | struct mod_hdcp_displayport { | |
104 | uint8_t rev; | |
aac6d439 WL |
105 | uint8_t assr_enabled; |
106 | uint8_t mst_enabled; | |
580013b2 | 107 | uint8_t usb4_enabled; |
4c283fda BL |
108 | }; |
109 | ||
110 | struct mod_hdcp_hdmi { | |
111 | uint8_t reserved; | |
112 | }; | |
113 | enum mod_hdcp_operation_mode { | |
114 | MOD_HDCP_MODE_OFF, | |
115 | MOD_HDCP_MODE_DEFAULT, | |
b6a1a0e7 | 116 | MOD_HDCP_MODE_DP |
4c283fda BL |
117 | }; |
118 | ||
119 | enum mod_hdcp_display_state { | |
120 | MOD_HDCP_DISPLAY_INACTIVE = 0, | |
121 | MOD_HDCP_DISPLAY_ACTIVE, | |
4c283fda BL |
122 | MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED |
123 | }; | |
124 | ||
bf62221e NK |
125 | struct mod_hdcp_psp_caps { |
126 | uint8_t dtm_v3_supported; | |
bf62221e NK |
127 | }; |
128 | ||
4fe1fdcc WL |
129 | enum mod_hdcp_display_disable_option { |
130 | MOD_HDCP_DISPLAY_NOT_DISABLE = 0, | |
131 | MOD_HDCP_DISPLAY_DISABLE_AUTHENTICATION, | |
132 | MOD_HDCP_DISPLAY_DISABLE_ENCRYPTION, | |
133 | }; | |
134 | ||
4c283fda BL |
135 | struct mod_hdcp_ddc { |
136 | void *handle; | |
137 | struct { | |
138 | bool (*read_i2c)(void *handle, | |
139 | uint32_t address, | |
140 | uint8_t offset, | |
141 | uint8_t *data, | |
142 | uint32_t size); | |
143 | bool (*write_i2c)(void *handle, | |
144 | uint32_t address, | |
145 | const uint8_t *data, | |
146 | uint32_t size); | |
147 | bool (*read_dpcd)(void *handle, | |
148 | uint32_t address, | |
149 | uint8_t *data, | |
150 | uint32_t size); | |
151 | bool (*write_dpcd)(void *handle, | |
152 | uint32_t address, | |
153 | const uint8_t *data, | |
154 | uint32_t size); | |
155 | } funcs; | |
156 | }; | |
157 | ||
158 | struct mod_hdcp_psp { | |
159 | void *handle; | |
160 | void *funcs; | |
bf62221e | 161 | struct mod_hdcp_psp_caps caps; |
4c283fda BL |
162 | }; |
163 | ||
164 | struct mod_hdcp_display_adjustment { | |
4fe1fdcc WL |
165 | uint8_t disable : 2; |
166 | uint8_t reserved : 6; | |
4c283fda BL |
167 | }; |
168 | ||
169 | struct mod_hdcp_link_adjustment_hdcp1 { | |
170 | uint8_t disable : 1; | |
171 | uint8_t postpone_encryption : 1; | |
7bc3807f GS |
172 | uint8_t min_auth_retries_wa : 1; |
173 | uint8_t reserved : 5; | |
4c283fda BL |
174 | }; |
175 | ||
23eb4191 BL |
176 | enum mod_hdcp_force_hdcp_type { |
177 | MOD_HDCP_FORCE_TYPE_MAX = 0, | |
178 | MOD_HDCP_FORCE_TYPE_0, | |
179 | MOD_HDCP_FORCE_TYPE_1 | |
180 | }; | |
181 | ||
4c283fda BL |
182 | struct mod_hdcp_link_adjustment_hdcp2 { |
183 | uint8_t disable : 1; | |
23eb4191 | 184 | uint8_t force_type : 2; |
4c283fda BL |
185 | uint8_t force_no_stored_km : 1; |
186 | uint8_t increase_h_prime_timeout: 1; | |
23eb4191 | 187 | uint8_t reserved : 3; |
4c283fda BL |
188 | }; |
189 | ||
190 | struct mod_hdcp_link_adjustment { | |
191 | uint8_t auth_delay; | |
192 | struct mod_hdcp_link_adjustment_hdcp1 hdcp1; | |
193 | struct mod_hdcp_link_adjustment_hdcp2 hdcp2; | |
194 | }; | |
195 | ||
196 | struct mod_hdcp_error { | |
197 | enum mod_hdcp_status status; | |
198 | uint8_t state_id; | |
199 | }; | |
200 | ||
201 | struct mod_hdcp_trace { | |
202 | struct mod_hdcp_error errors[MAX_NUM_OF_ERROR_TRACE]; | |
203 | uint8_t error_count; | |
204 | }; | |
205 | ||
206 | enum mod_hdcp_encryption_status { | |
207 | MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF = 0, | |
208 | MOD_HDCP_ENCRYPTION_STATUS_HDCP1_ON, | |
209 | MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON, | |
45375a50 BL |
210 | MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON, |
211 | MOD_HDCP_ENCRYPTION_STATUS_HDCP2_ON | |
4c283fda BL |
212 | }; |
213 | ||
214 | /* per link events dm has to notify to hdcp module */ | |
215 | enum mod_hdcp_event { | |
216 | MOD_HDCP_EVENT_CALLBACK = 0, | |
217 | MOD_HDCP_EVENT_WATCHDOG_TIMEOUT, | |
218 | MOD_HDCP_EVENT_CPIRQ | |
219 | }; | |
220 | ||
221 | /* output flags from module requesting timer operations */ | |
222 | struct mod_hdcp_output { | |
223 | uint8_t callback_needed; | |
224 | uint8_t callback_stop; | |
225 | uint8_t watchdog_timer_needed; | |
226 | uint8_t watchdog_timer_stop; | |
227 | uint16_t callback_delay; | |
228 | uint16_t watchdog_timer_delay; | |
0a95fab3 | 229 | uint8_t auth_complete; |
4c283fda BL |
230 | }; |
231 | ||
232 | /* used to represent per display info */ | |
233 | struct mod_hdcp_display { | |
234 | enum mod_hdcp_display_state state; | |
235 | uint8_t index; | |
236 | uint8_t controller; | |
237 | uint8_t dig_fe; | |
bf62221e | 238 | uint8_t stream_enc_idx; |
4c283fda BL |
239 | union { |
240 | uint8_t vc_id; | |
241 | }; | |
242 | struct mod_hdcp_display_adjustment adjust; | |
243 | }; | |
244 | ||
245 | /* used to represent per link info */ | |
246 | /* in case a link has multiple displays, they share the same link info */ | |
247 | struct mod_hdcp_link { | |
248 | enum mod_hdcp_operation_mode mode; | |
249 | uint8_t dig_be; | |
250 | uint8_t ddc_line; | |
bf62221e NK |
251 | uint8_t link_enc_idx; |
252 | uint8_t phy_idx; | |
ffd89aa9 | 253 | uint8_t dio_output_id; |
bf62221e | 254 | uint8_t hdcp_supported_informational; |
4c283fda BL |
255 | union { |
256 | struct mod_hdcp_displayport dp; | |
257 | struct mod_hdcp_hdmi hdmi; | |
258 | }; | |
259 | struct mod_hdcp_link_adjustment adjust; | |
260 | }; | |
261 | ||
262 | /* a query structure for a display's hdcp information */ | |
263 | struct mod_hdcp_display_query { | |
264 | const struct mod_hdcp_display *display; | |
265 | const struct mod_hdcp_link *link; | |
266 | const struct mod_hdcp_trace *trace; | |
267 | enum mod_hdcp_encryption_status encryption_status; | |
268 | }; | |
269 | ||
270 | /* contains values per on external display configuration change */ | |
271 | struct mod_hdcp_config { | |
272 | struct mod_hdcp_psp psp; | |
273 | struct mod_hdcp_ddc ddc; | |
274 | uint8_t index; | |
275 | }; | |
276 | ||
4c283fda BL |
277 | /* dm allocates memory of mod_hdcp per dc_link on dm init based on memory size*/ |
278 | size_t mod_hdcp_get_memory_size(void); | |
279 | ||
280 | /* called per link on link creation */ | |
281 | enum mod_hdcp_status mod_hdcp_setup(struct mod_hdcp *hdcp, | |
282 | struct mod_hdcp_config *config); | |
283 | ||
284 | /* called per link on link destroy */ | |
285 | enum mod_hdcp_status mod_hdcp_teardown(struct mod_hdcp *hdcp); | |
286 | ||
40ef288f | 287 | /* called per display after stream is enabled */ |
4c283fda BL |
288 | enum mod_hdcp_status mod_hdcp_add_display(struct mod_hdcp *hdcp, |
289 | struct mod_hdcp_link *link, struct mod_hdcp_display *display, | |
290 | struct mod_hdcp_output *output); | |
291 | ||
40ef288f | 292 | /* called per display before stream is disabled */ |
4c283fda BL |
293 | enum mod_hdcp_status mod_hdcp_remove_display(struct mod_hdcp *hdcp, |
294 | uint8_t index, struct mod_hdcp_output *output); | |
295 | ||
40ef288f | 296 | /* called per display to apply new authentication adjustment */ |
4268d081 | 297 | enum mod_hdcp_status mod_hdcp_update_display(struct mod_hdcp *hdcp, |
40ef288f WL |
298 | uint8_t index, |
299 | struct mod_hdcp_link_adjustment *link_adjust, | |
300 | struct mod_hdcp_display_adjustment *display_adjust, | |
301 | struct mod_hdcp_output *output); | |
302 | ||
4c283fda BL |
303 | /* called to query hdcp information on a specific index */ |
304 | enum mod_hdcp_status mod_hdcp_query_display(struct mod_hdcp *hdcp, | |
305 | uint8_t index, struct mod_hdcp_display_query *query); | |
306 | ||
307 | /* called per link on connectivity change */ | |
308 | enum mod_hdcp_status mod_hdcp_reset_connection(struct mod_hdcp *hdcp, | |
309 | struct mod_hdcp_output *output); | |
310 | ||
311 | /* called per link on events (i.e. callback, watchdog, CP_IRQ) */ | |
312 | enum mod_hdcp_status mod_hdcp_process_event(struct mod_hdcp *hdcp, | |
313 | enum mod_hdcp_event event, struct mod_hdcp_output *output); | |
314 | ||
315 | /* called to convert enum mod_hdcp_status to c string */ | |
316 | char *mod_hdcp_status_to_str(int32_t status); | |
317 | ||
318 | /* called to convert state id to c string */ | |
319 | char *mod_hdcp_state_id_to_str(int32_t id); | |
320 | ||
321 | /* called to convert signal type to operation mode */ | |
322 | enum mod_hdcp_operation_mode mod_hdcp_signal_type_to_operation_mode( | |
323 | enum signal_type signal); | |
324 | #endif /* MOD_HDCP_H_ */ |