2 * Copyright 2019 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
30 #include "signal_types.h"
32 /* Forward Declarations */
35 #define MAX_NUM_OF_DISPLAYS 6
36 #define MAX_NUM_OF_ATTEMPTS 4
37 #define MAX_NUM_OF_ERROR_TRACE 10
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
,
59 MOD_HDCP_STATUS_HDCP1_KSV_LIST_NOT_READY
,
60 MOD_HDCP_STATUS_HDCP1_VALIDATE_KSV_LIST_FAILURE
,
61 MOD_HDCP_STATUS_HDCP1_ENABLE_ENCRYPTION
,
62 MOD_HDCP_STATUS_HDCP1_ENABLE_STREAM_ENCRYPTION_FAILURE
,
63 MOD_HDCP_STATUS_HDCP1_MAX_CASCADE_EXCEEDED_FAILURE
,
64 MOD_HDCP_STATUS_HDCP1_MAX_DEVS_EXCEEDED_FAILURE
,
65 MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE
,
66 MOD_HDCP_STATUS_HDCP1_LINK_INTEGRITY_FAILURE
,
67 MOD_HDCP_STATUS_HDCP1_REAUTH_REQUEST_ISSUED
,
68 MOD_HDCP_STATUS_HDCP1_LINK_MAINTENANCE_FAILURE
,
69 MOD_HDCP_STATUS_HDCP1_INVALID_BKSV
,
70 MOD_HDCP_STATUS_DDC_FAILURE
, /* TODO: specific errors */
71 MOD_HDCP_STATUS_INVALID_OPERATION
,
72 MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE
,
73 MOD_HDCP_STATUS_HDCP2_CREATE_SESSION_FAILURE
,
74 MOD_HDCP_STATUS_HDCP2_DESTROY_SESSION_FAILURE
,
75 MOD_HDCP_STATUS_HDCP2_PREP_AKE_INIT_FAILURE
,
76 MOD_HDCP_STATUS_HDCP2_AKE_CERT_PENDING
,
77 MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING
,
78 MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING
,
79 MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE
,
80 MOD_HDCP_STATUS_HDCP2_AKE_CERT_REVOKED
,
81 MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE
,
82 MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE
,
83 MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE
,
84 MOD_HDCP_STATUS_HDCP2_L_PRIME_PENDING
,
85 MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE
,
86 MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE
,
87 MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE
,
88 MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY
,
89 MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE
,
90 MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED
,
91 MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION
,
92 MOD_HDCP_STATUS_HDCP2_STREAM_READY_PENDING
,
93 MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE
,
94 MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE
,
95 MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST
,
96 MOD_HDCP_STATUS_HDCP2_REAUTH_LINK_INTEGRITY_FAILURE
,
97 MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE
,
100 struct mod_hdcp_displayport
{
102 uint8_t assr_supported
;
105 struct mod_hdcp_hdmi
{
108 enum mod_hdcp_operation_mode
{
110 MOD_HDCP_MODE_DEFAULT
,
115 enum mod_hdcp_display_state
{
116 MOD_HDCP_DISPLAY_INACTIVE
= 0,
117 MOD_HDCP_DISPLAY_ACTIVE
,
118 MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED
,
119 MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED
122 struct mod_hdcp_ddc
{
125 bool (*read_i2c
)(void *handle
,
130 bool (*write_i2c
)(void *handle
,
134 bool (*read_dpcd
)(void *handle
,
138 bool (*write_dpcd
)(void *handle
,
145 struct mod_hdcp_psp
{
150 struct mod_hdcp_display_adjustment
{
152 uint8_t reserved
: 7;
155 struct mod_hdcp_link_adjustment_hdcp1
{
157 uint8_t postpone_encryption
: 1;
158 uint8_t reserved
: 6;
161 enum mod_hdcp_force_hdcp_type
{
162 MOD_HDCP_FORCE_TYPE_MAX
= 0,
163 MOD_HDCP_FORCE_TYPE_0
,
164 MOD_HDCP_FORCE_TYPE_1
167 struct mod_hdcp_link_adjustment_hdcp2
{
169 uint8_t force_type
: 2;
170 uint8_t force_no_stored_km
: 1;
171 uint8_t increase_h_prime_timeout
: 1;
172 uint8_t reserved
: 3;
175 struct mod_hdcp_link_adjustment
{
177 struct mod_hdcp_link_adjustment_hdcp1 hdcp1
;
178 struct mod_hdcp_link_adjustment_hdcp2 hdcp2
;
181 struct mod_hdcp_error
{
182 enum mod_hdcp_status status
;
186 struct mod_hdcp_trace
{
187 struct mod_hdcp_error errors
[MAX_NUM_OF_ERROR_TRACE
];
191 enum mod_hdcp_encryption_status
{
192 MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF
= 0,
193 MOD_HDCP_ENCRYPTION_STATUS_HDCP1_ON
,
194 MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON
,
195 MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON
,
196 MOD_HDCP_ENCRYPTION_STATUS_HDCP2_ON
199 /* per link events dm has to notify to hdcp module */
200 enum mod_hdcp_event
{
201 MOD_HDCP_EVENT_CALLBACK
= 0,
202 MOD_HDCP_EVENT_WATCHDOG_TIMEOUT
,
206 /* output flags from module requesting timer operations */
207 struct mod_hdcp_output
{
208 uint8_t callback_needed
;
209 uint8_t callback_stop
;
210 uint8_t watchdog_timer_needed
;
211 uint8_t watchdog_timer_stop
;
212 uint16_t callback_delay
;
213 uint16_t watchdog_timer_delay
;
216 /* used to represent per display info */
217 struct mod_hdcp_display
{
218 enum mod_hdcp_display_state state
;
225 struct mod_hdcp_display_adjustment adjust
;
228 /* used to represent per link info */
229 /* in case a link has multiple displays, they share the same link info */
230 struct mod_hdcp_link
{
231 enum mod_hdcp_operation_mode mode
;
235 struct mod_hdcp_displayport dp
;
236 struct mod_hdcp_hdmi hdmi
;
238 struct mod_hdcp_link_adjustment adjust
;
241 /* a query structure for a display's hdcp information */
242 struct mod_hdcp_display_query
{
243 const struct mod_hdcp_display
*display
;
244 const struct mod_hdcp_link
*link
;
245 const struct mod_hdcp_trace
*trace
;
246 enum mod_hdcp_encryption_status encryption_status
;
249 /* contains values per on external display configuration change */
250 struct mod_hdcp_config
{
251 struct mod_hdcp_psp psp
;
252 struct mod_hdcp_ddc ddc
;
258 /* dm allocates memory of mod_hdcp per dc_link on dm init based on memory size*/
259 size_t mod_hdcp_get_memory_size(void);
261 /* called per link on link creation */
262 enum mod_hdcp_status
mod_hdcp_setup(struct mod_hdcp
*hdcp
,
263 struct mod_hdcp_config
*config
);
265 /* called per link on link destroy */
266 enum mod_hdcp_status
mod_hdcp_teardown(struct mod_hdcp
*hdcp
);
268 /* called per display on cp_desired set to true */
269 enum mod_hdcp_status
mod_hdcp_add_display(struct mod_hdcp
*hdcp
,
270 struct mod_hdcp_link
*link
, struct mod_hdcp_display
*display
,
271 struct mod_hdcp_output
*output
);
273 /* called per display on cp_desired set to false */
274 enum mod_hdcp_status
mod_hdcp_remove_display(struct mod_hdcp
*hdcp
,
275 uint8_t index
, struct mod_hdcp_output
*output
);
277 /* called to query hdcp information on a specific index */
278 enum mod_hdcp_status
mod_hdcp_query_display(struct mod_hdcp
*hdcp
,
279 uint8_t index
, struct mod_hdcp_display_query
*query
);
281 /* called per link on connectivity change */
282 enum mod_hdcp_status
mod_hdcp_reset_connection(struct mod_hdcp
*hdcp
,
283 struct mod_hdcp_output
*output
);
285 /* called per link on events (i.e. callback, watchdog, CP_IRQ) */
286 enum mod_hdcp_status
mod_hdcp_process_event(struct mod_hdcp
*hdcp
,
287 enum mod_hdcp_event event
, struct mod_hdcp_output
*output
);
289 /* called to convert enum mod_hdcp_status to c string */
290 char *mod_hdcp_status_to_str(int32_t status
);
292 /* called to convert state id to c string */
293 char *mod_hdcp_state_id_to_str(int32_t id
);
295 /* called to convert signal type to operation mode */
296 enum mod_hdcp_operation_mode
mod_hdcp_signal_type_to_operation_mode(
297 enum signal_type signal
);
298 #endif /* MOD_HDCP_H_ */