File Index
Files and directories
Sign in
FILE

hdcp.h

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h C
  1/*
  2 * Copyright 2019 Advanced Micro Devices, Inc.
  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 HDCP_H_
 27#define HDCP_H_
 28
 29#include "mod_hdcp.h"
 30#include "hdcp_log.h"
 31
 32#include <drm/display/drm_dp_helper.h>
 33#include <drm/display/drm_hdcp_helper.h>
 34
 35enum mod_hdcp_trans_input_result {
 36	UNKNOWN = 0,
 37	PASS,
 38	FAIL
 39};
 40
 41struct mod_hdcp_transition_input_hdcp1 {
 42	uint8_t bksv_read;
 43	uint8_t bksv_validation;
 44	uint8_t create_session;
 45	uint8_t an_write;
 46	uint8_t aksv_write;
 47	uint8_t ainfo_write;
 48	uint8_t bcaps_read;
 49	uint8_t r0p_read;
 50	uint8_t rx_validation;
 51	uint8_t encryption;
 52	uint8_t link_maintenance;
 53	uint8_t ready_check;
 54	uint8_t bstatus_read;
 55	uint8_t max_cascade_check;
 56	uint8_t max_devs_check;
 57	uint8_t device_count_check;
 58	uint8_t ksvlist_read;
 59	uint8_t vp_read;
 60	uint8_t ksvlist_vp_validation;
 61
 62	uint8_t hdcp_capable_dp;
 63	uint8_t binfo_read_dp;
 64	uint8_t r0p_available_dp;
 65	uint8_t link_integrity_check;
 66	uint8_t reauth_request_check;
 67	uint8_t stream_encryption_dp;
 68};
 69
 70struct mod_hdcp_transition_input_hdcp2 {
 71	uint8_t hdcp2version_read;
 72	uint8_t hdcp2_capable_check;
 73	uint8_t create_session;
 74	uint8_t ake_init_prepare;
 75	uint8_t ake_init_write;
 76	uint8_t rxstatus_read;
 77	uint8_t ake_cert_available;
 78	uint8_t ake_cert_read;
 79	uint8_t ake_cert_validation;
 80	uint8_t stored_km_write;
 81	uint8_t no_stored_km_write;
 82	uint8_t h_prime_available;
 83	uint8_t h_prime_read;
 84	uint8_t pairing_available;
 85	uint8_t pairing_info_read;
 86	uint8_t h_prime_validation;
 87	uint8_t lc_init_prepare;
 88	uint8_t lc_init_write;
 89	uint8_t l_prime_available_poll;
 90	uint8_t l_prime_read;
 91	uint8_t l_prime_combo_read;
 92	uint8_t l_prime_validation;
 93	uint8_t eks_prepare;
 94	uint8_t eks_write;
 95	uint8_t enable_encryption;
 96	uint8_t reauth_request_check;
 97	uint8_t rx_id_list_read;
 98	uint8_t device_count_check;
 99	uint8_t rx_id_list_validation;
100	uint8_t repeater_auth_ack_write;
101	uint8_t prepare_stream_manage;
102	uint8_t stream_manage_write;
103	uint8_t stream_ready_available;
104	uint8_t stream_ready_read;
105	uint8_t stream_ready_validation;
106
107	uint8_t rx_caps_read_dp;
108	uint8_t content_stream_type_write;
109	uint8_t link_integrity_check_dp;
110	uint8_t stream_encryption_dp;
111};
112
113union mod_hdcp_transition_input {
114	struct mod_hdcp_transition_input_hdcp1 hdcp1;
115	struct mod_hdcp_transition_input_hdcp2 hdcp2;
116};
117
118struct mod_hdcp_message_hdcp1 {
119	uint8_t		an[8];
120	uint8_t		aksv[5];
121	uint8_t		ainfo;
122	uint8_t		bksv[5];
123	uint16_t	r0p;
124	uint8_t		bcaps;
125	uint16_t	bstatus;
126	uint8_t		ksvlist[635];
127	uint16_t	ksvlist_size;
128	uint8_t		vp[20];
129
130	uint16_t	binfo_dp;
131};
132
133struct mod_hdcp_message_hdcp2 {
134	uint8_t		hdcp2version_hdmi;
135	uint8_t		rxcaps_dp[3];
136	uint8_t		rxstatus[2];
137
138	uint8_t		ake_init[12];
139	uint8_t		ake_cert[534];
140	uint8_t		ake_no_stored_km[129];
141	uint8_t		ake_stored_km[33];
142	uint8_t		ake_h_prime[33];
143	uint8_t		ake_pairing_info[17];
144	uint8_t		lc_init[9];
145	uint8_t		lc_l_prime[33];
146	uint8_t		ske_eks[25];
147	uint8_t		rx_id_list[177]; // 22 + 5 * 31
148	uint16_t	rx_id_list_size;
149	uint8_t		repeater_auth_ack[17];
150	uint8_t		repeater_auth_stream_manage[68]; // 6 + 2 * 31
151	uint16_t	stream_manage_size;
152	uint8_t		repeater_auth_stream_ready[33];
153	uint8_t		rxstatus_dp;
154	uint8_t		content_stream_type_dp[2];
155};
156
157union mod_hdcp_message {
158	struct mod_hdcp_message_hdcp1 hdcp1;
159	struct mod_hdcp_message_hdcp2 hdcp2;
160};
161
162struct mod_hdcp_auth_counters {
163	uint8_t stream_management_retry_count;
164};
165
166/* contains values per connection */
167struct mod_hdcp_connection {
168	struct mod_hdcp_link link;
169	uint8_t is_repeater;
170	uint8_t is_km_stored;
171	uint8_t is_hdcp1_revoked;
172	uint8_t is_hdcp2_revoked;
173	struct mod_hdcp_trace trace;
174	uint8_t hdcp1_retry_count;
175	uint8_t hdcp2_retry_count;
176};
177
178/* contains values per authentication cycle */
179struct mod_hdcp_authentication {
180	uint32_t id;
181	union mod_hdcp_message msg;
182	union mod_hdcp_transition_input trans_input;
183	struct mod_hdcp_auth_counters count;
184};
185
186/* contains values per state change */
187struct mod_hdcp_state {
188	uint8_t id;
189	uint32_t stay_count;
190};
191
192/* per event in a state */
193struct mod_hdcp_event_context {
194	enum mod_hdcp_event event;
195	uint8_t rx_id_list_ready;
196	uint8_t unexpected_event;
197};
198
199struct mod_hdcp {
200	/* per link */
201	struct mod_hdcp_config config;
202	/* per connection */
203	struct mod_hdcp_connection connection;
204	/* per displays */
205	struct mod_hdcp_display displays[MAX_NUM_OF_DISPLAYS];
206	/* per authentication attempt */
207	struct mod_hdcp_authentication auth;
208	/* per state in an authentication */
209	struct mod_hdcp_state state;
210	/* reserved memory buffer */
211	uint8_t buf[2025];
212};
213
214enum mod_hdcp_initial_state_id {
215	HDCP_UNINITIALIZED = 0x0,
216	HDCP_INITIAL_STATE_START = HDCP_UNINITIALIZED,
217	HDCP_INITIALIZED,
218	HDCP_CP_NOT_DESIRED,
219	HDCP_INITIAL_STATE_END = HDCP_CP_NOT_DESIRED
220};
221
222enum mod_hdcp_hdcp1_state_id {
223	HDCP1_STATE_START = HDCP_INITIAL_STATE_END,
224	H1_A0_WAIT_FOR_ACTIVE_RX,
225	H1_A1_EXCHANGE_KSVS,
226	H1_A2_COMPUTATIONS_A3_VALIDATE_RX_A6_TEST_FOR_REPEATER,
227	H1_A45_AUTHENTICATED,
228	H1_A8_WAIT_FOR_READY,
229	H1_A9_READ_KSV_LIST,
230	HDCP1_STATE_END = H1_A9_READ_KSV_LIST
231};
232
233enum mod_hdcp_hdcp1_dp_state_id {
234	HDCP1_DP_STATE_START = HDCP1_STATE_END,
235	D1_A0_DETERMINE_RX_HDCP_CAPABLE,
236	D1_A1_EXCHANGE_KSVS,
237	D1_A23_WAIT_FOR_R0_PRIME,
238	D1_A2_COMPUTATIONS_A3_VALIDATE_RX_A5_TEST_FOR_REPEATER,
239	D1_A4_AUTHENTICATED,
240	D1_A6_WAIT_FOR_READY,
241	D1_A7_READ_KSV_LIST,
242	HDCP1_DP_STATE_END = D1_A7_READ_KSV_LIST,
243};
244
245enum mod_hdcp_hdcp2_state_id {
246	HDCP2_STATE_START = HDCP1_DP_STATE_END,
247	H2_A0_KNOWN_HDCP2_CAPABLE_RX,
248	H2_A1_SEND_AKE_INIT,
249	H2_A1_VALIDATE_AKE_CERT,
250	H2_A1_SEND_NO_STORED_KM,
251	H2_A1_READ_H_PRIME,
252	H2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME,
253	H2_A1_SEND_STORED_KM,
254	H2_A1_VALIDATE_H_PRIME,
255	H2_A2_LOCALITY_CHECK,
256	H2_A3_EXCHANGE_KS_AND_TEST_FOR_REPEATER,
257	H2_ENABLE_ENCRYPTION,
258	H2_A5_AUTHENTICATED,
259	H2_A6_WAIT_FOR_RX_ID_LIST,
260	H2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK,
261	H2_A9_SEND_STREAM_MANAGEMENT,
262	H2_A9_VALIDATE_STREAM_READY,
263	HDCP2_STATE_END = H2_A9_VALIDATE_STREAM_READY,
264};
265
266enum mod_hdcp_hdcp2_dp_state_id {
267	HDCP2_DP_STATE_START = HDCP2_STATE_END,
268	D2_A0_DETERMINE_RX_HDCP_CAPABLE,
269	D2_A1_SEND_AKE_INIT,
270	D2_A1_VALIDATE_AKE_CERT,
271	D2_A1_SEND_NO_STORED_KM,
272	D2_A1_READ_H_PRIME,
273	D2_A1_READ_PAIRING_INFO_AND_VALIDATE_H_PRIME,
274	D2_A1_SEND_STORED_KM,
275	D2_A1_VALIDATE_H_PRIME,
276	D2_A2_LOCALITY_CHECK,
277	D2_A34_EXCHANGE_KS_AND_TEST_FOR_REPEATER,
278	D2_SEND_CONTENT_STREAM_TYPE,
279	D2_ENABLE_ENCRYPTION,
280	D2_A5_AUTHENTICATED,
281	D2_A6_WAIT_FOR_RX_ID_LIST,
282	D2_A78_VERIFY_RX_ID_LIST_AND_SEND_ACK,
283	D2_A9_SEND_STREAM_MANAGEMENT,
284	D2_A9_VALIDATE_STREAM_READY,
285	HDCP2_DP_STATE_END = D2_A9_VALIDATE_STREAM_READY,
286	HDCP_STATE_END = HDCP2_DP_STATE_END,
287};
288
289/* hdcp1 executions and transitions */
290typedef enum mod_hdcp_status (*mod_hdcp_action)(struct mod_hdcp *hdcp);
291uint8_t mod_hdcp_execute_and_set(
292		mod_hdcp_action func, uint8_t *flag,
293		enum mod_hdcp_status *status, struct mod_hdcp *hdcp, char *str);
294enum mod_hdcp_status mod_hdcp_hdcp1_execution(struct mod_hdcp *hdcp,
295	struct mod_hdcp_event_context *event_ctx,
296	struct mod_hdcp_transition_input_hdcp1 *input);
297enum mod_hdcp_status mod_hdcp_hdcp1_dp_execution(struct mod_hdcp *hdcp,
298	struct mod_hdcp_event_context *event_ctx,
299	struct mod_hdcp_transition_input_hdcp1 *input);
300enum mod_hdcp_status mod_hdcp_hdcp1_transition(struct mod_hdcp *hdcp,
301	struct mod_hdcp_event_context *event_ctx,
302	struct mod_hdcp_transition_input_hdcp1 *input,
303	struct mod_hdcp_output *output);
304enum mod_hdcp_status mod_hdcp_hdcp1_dp_transition(struct mod_hdcp *hdcp,
305	struct mod_hdcp_event_context *event_ctx,
306	struct mod_hdcp_transition_input_hdcp1 *input,
307	struct mod_hdcp_output *output);
308
309/* hdcp2 executions and transitions */
310enum mod_hdcp_status mod_hdcp_hdcp2_execution(struct mod_hdcp *hdcp,
311	struct mod_hdcp_event_context *event_ctx,
312	struct mod_hdcp_transition_input_hdcp2 *input);
313enum mod_hdcp_status mod_hdcp_hdcp2_dp_execution(struct mod_hdcp *hdcp,
314	struct mod_hdcp_event_context *event_ctx,
315	struct mod_hdcp_transition_input_hdcp2 *input);
316enum mod_hdcp_status mod_hdcp_hdcp2_transition(struct mod_hdcp *hdcp,
317	struct mod_hdcp_event_context *event_ctx,
318	struct mod_hdcp_transition_input_hdcp2 *input,
319	struct mod_hdcp_output *output);
320enum mod_hdcp_status mod_hdcp_hdcp2_dp_transition(struct mod_hdcp *hdcp,
321	struct mod_hdcp_event_context *event_ctx,
322	struct mod_hdcp_transition_input_hdcp2 *input,
323	struct mod_hdcp_output *output);
324
325/* log functions */
326void mod_hdcp_dump_binary_message(uint8_t *msg, uint32_t msg_size,
327		uint8_t *buf, uint32_t buf_size);
328void mod_hdcp_log_ddc_trace(struct mod_hdcp *hdcp);
329/* TODO: add adjustment log */
330
331/* psp functions */
332enum mod_hdcp_status mod_hdcp_add_display_to_topology(
333		struct mod_hdcp *hdcp, struct mod_hdcp_display *display);
334enum mod_hdcp_status mod_hdcp_remove_display_from_topology(
335		struct mod_hdcp *hdcp, uint8_t index);
336enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp);
337enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp);
338enum mod_hdcp_status mod_hdcp_hdcp1_validate_rx(struct mod_hdcp *hdcp);
339enum mod_hdcp_status mod_hdcp_hdcp1_enable_encryption(struct mod_hdcp *hdcp);
340enum mod_hdcp_status mod_hdcp_hdcp1_validate_ksvlist_vp(struct mod_hdcp *hdcp);
341enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(
342	struct mod_hdcp *hdcp);
343enum mod_hdcp_status mod_hdcp_hdcp1_link_maintenance(struct mod_hdcp *hdcp);
344enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp);
345enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp);
346enum mod_hdcp_status mod_hdcp_hdcp2_prepare_ake_init(struct mod_hdcp *hdcp);
347enum mod_hdcp_status mod_hdcp_hdcp2_validate_ake_cert(struct mod_hdcp *hdcp);
348enum mod_hdcp_status mod_hdcp_hdcp2_validate_h_prime(struct mod_hdcp *hdcp);
349enum mod_hdcp_status mod_hdcp_hdcp2_prepare_lc_init(struct mod_hdcp *hdcp);
350enum mod_hdcp_status mod_hdcp_hdcp2_validate_l_prime(struct mod_hdcp *hdcp);
351enum mod_hdcp_status mod_hdcp_hdcp2_prepare_eks(struct mod_hdcp *hdcp);
352enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp);
353enum mod_hdcp_status mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp);
354enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(
355		struct mod_hdcp *hdcp);
356enum mod_hdcp_status mod_hdcp_hdcp2_prepare_stream_management(
357		struct mod_hdcp *hdcp);
358enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(
359		struct mod_hdcp *hdcp);
360
361/* ddc functions */
362enum mod_hdcp_status mod_hdcp_read_bksv(struct mod_hdcp *hdcp);
363enum mod_hdcp_status mod_hdcp_read_bcaps(struct mod_hdcp *hdcp);
364enum mod_hdcp_status mod_hdcp_read_bstatus(struct mod_hdcp *hdcp);
365enum mod_hdcp_status mod_hdcp_read_r0p(struct mod_hdcp *hdcp);
366enum mod_hdcp_status mod_hdcp_read_ksvlist(struct mod_hdcp *hdcp);
367enum mod_hdcp_status mod_hdcp_read_vp(struct mod_hdcp *hdcp);
368enum mod_hdcp_status mod_hdcp_read_binfo(struct mod_hdcp *hdcp);
369enum mod_hdcp_status mod_hdcp_write_aksv(struct mod_hdcp *hdcp);
370enum mod_hdcp_status mod_hdcp_write_ainfo(struct mod_hdcp *hdcp);
371enum mod_hdcp_status mod_hdcp_write_an(struct mod_hdcp *hdcp);
372enum mod_hdcp_status mod_hdcp_read_hdcp2version(struct mod_hdcp *hdcp);
373enum mod_hdcp_status mod_hdcp_read_rxcaps(struct mod_hdcp *hdcp);
374enum mod_hdcp_status mod_hdcp_read_rxstatus(struct mod_hdcp *hdcp);
375enum mod_hdcp_status mod_hdcp_read_ake_cert(struct mod_hdcp *hdcp);
376enum mod_hdcp_status mod_hdcp_read_h_prime(struct mod_hdcp *hdcp);
377enum mod_hdcp_status mod_hdcp_read_pairing_info(struct mod_hdcp *hdcp);
378enum mod_hdcp_status mod_hdcp_read_l_prime(struct mod_hdcp *hdcp);
379enum mod_hdcp_status mod_hdcp_read_rx_id_list(struct mod_hdcp *hdcp);
380enum mod_hdcp_status mod_hdcp_read_stream_ready(struct mod_hdcp *hdcp);
381enum mod_hdcp_status mod_hdcp_write_ake_init(struct mod_hdcp *hdcp);
382enum mod_hdcp_status mod_hdcp_write_no_stored_km(struct mod_hdcp *hdcp);
383enum mod_hdcp_status mod_hdcp_write_stored_km(struct mod_hdcp *hdcp);
384enum mod_hdcp_status mod_hdcp_write_lc_init(struct mod_hdcp *hdcp);
385enum mod_hdcp_status mod_hdcp_write_eks(struct mod_hdcp *hdcp);
386enum mod_hdcp_status mod_hdcp_write_repeater_auth_ack(struct mod_hdcp *hdcp);
387enum mod_hdcp_status mod_hdcp_write_stream_manage(struct mod_hdcp *hdcp);
388enum mod_hdcp_status mod_hdcp_write_content_type(struct mod_hdcp *hdcp);
389enum mod_hdcp_status mod_hdcp_clear_cp_irq_status(struct mod_hdcp *hdcp);
390enum mod_hdcp_status mod_hdcp_write_poll_read_lc_fw(struct mod_hdcp *hdcp);
391
392/* hdcp version helpers */
393static inline uint8_t is_dp_hdcp(struct mod_hdcp *hdcp)
394{
395	return (hdcp->connection.link.mode == MOD_HDCP_MODE_DP);
396}
397
398static inline uint8_t is_dp_mst_hdcp(struct mod_hdcp *hdcp)
399{
400	return (hdcp->connection.link.mode == MOD_HDCP_MODE_DP &&
401			hdcp->connection.link.dp.mst_enabled);
402}
403
404static inline uint8_t is_hdmi_dvi_sl_hdcp(struct mod_hdcp *hdcp)
405{
406	return (hdcp->connection.link.mode == MOD_HDCP_MODE_DEFAULT);
407}
408
409/* hdcp state helpers */
410static inline uint8_t current_state(struct mod_hdcp *hdcp)
411{
412	return hdcp->state.id;
413}
414
415static inline void set_state_id(struct mod_hdcp *hdcp,
416		struct mod_hdcp_output *output, uint8_t id)
417{
418	memset(&hdcp->state, 0, sizeof(hdcp->state));
419	hdcp->state.id = id;
420	/* callback timer should be reset per state */
421	output->callback_stop = 1;
422	output->watchdog_timer_stop = 1;
423	HDCP_NEXT_STATE_TRACE(hdcp, id, output);
424}
425
426static inline uint8_t is_in_hdcp1_states(struct mod_hdcp *hdcp)
427{
428	return (current_state(hdcp) > HDCP1_STATE_START &&
429			current_state(hdcp) <= HDCP1_STATE_END);
430}
431
432static inline uint8_t is_in_hdcp1_dp_states(struct mod_hdcp *hdcp)
433{
434	return (current_state(hdcp) > HDCP1_DP_STATE_START &&
435			current_state(hdcp) <= HDCP1_DP_STATE_END);
436}
437
438static inline uint8_t is_in_hdcp2_states(struct mod_hdcp *hdcp)
439{
440	return (current_state(hdcp) > HDCP2_STATE_START &&
441			current_state(hdcp) <= HDCP2_STATE_END);
442}
443
444static inline uint8_t is_in_hdcp2_dp_states(struct mod_hdcp *hdcp)
445{
446	return (current_state(hdcp) > HDCP2_DP_STATE_START &&
447			current_state(hdcp) <= HDCP2_DP_STATE_END);
448}
449
450static inline uint8_t is_in_authenticated_states(struct mod_hdcp *hdcp)
451{
452	return (current_state(hdcp) == D1_A4_AUTHENTICATED ||
453	current_state(hdcp) == H1_A45_AUTHENTICATED ||
454	current_state(hdcp) == D2_A5_AUTHENTICATED ||
455	current_state(hdcp) == H2_A5_AUTHENTICATED);
456}
457
458static inline uint8_t is_hdcp1(struct mod_hdcp *hdcp)
459{
460	return (is_in_hdcp1_states(hdcp) || is_in_hdcp1_dp_states(hdcp));
461}
462
463static inline uint8_t is_hdcp2(struct mod_hdcp *hdcp)
464{
465	return (is_in_hdcp2_states(hdcp) || is_in_hdcp2_dp_states(hdcp));
466}
467
468static inline uint8_t is_in_cp_not_desired_state(struct mod_hdcp *hdcp)
469{
470	return current_state(hdcp) == HDCP_CP_NOT_DESIRED;
471}
472
473static inline uint8_t is_in_initialized_state(struct mod_hdcp *hdcp)
474{
475	return current_state(hdcp) == HDCP_INITIALIZED;
476}
477
478/* transition operation helpers */
479static inline void increment_stay_counter(struct mod_hdcp *hdcp)
480{
481	hdcp->state.stay_count++;
482}
483
484static inline void fail_and_restart_in_ms(uint16_t time,
485		enum mod_hdcp_status *status,
486		struct mod_hdcp_output *output)
487{
488	output->callback_needed = 1;
489	output->callback_delay = time;
490	output->watchdog_timer_needed = 0;
491	output->watchdog_timer_delay = 0;
492	*status = MOD_HDCP_STATUS_RESET_NEEDED;
493}
494
495static inline void callback_in_ms(uint16_t time, struct mod_hdcp_output *output)
496{
497	output->callback_needed = 1;
498	output->callback_delay = time;
499}
500
501static inline void set_watchdog_in_ms(struct mod_hdcp *hdcp, uint16_t time,
502		struct mod_hdcp_output *output)
503{
504	output->watchdog_timer_needed = 1;
505	output->watchdog_timer_delay = time;
506}
507
508static inline void set_auth_complete(struct mod_hdcp *hdcp,
509		struct mod_hdcp_output *output)
510{
511	output->auth_complete = 1;
512	HDCP_AUTH_COMPLETE_TRACE(hdcp);
513}
514
515/* connection topology helpers */
516static inline uint8_t is_display_active(struct mod_hdcp_display *display)
517{
518	return display->state >= MOD_HDCP_DISPLAY_ACTIVE;
519}
520
521static inline uint8_t is_display_encryption_enabled(struct mod_hdcp_display *display)
522{
523	return display->state >= MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;
524}
525
526static inline uint8_t get_active_display_count(struct mod_hdcp *hdcp)
527{
528	uint8_t active_count = 0;
529	uint8_t i;
530
531	for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
532		if (is_display_active(&hdcp->displays[i]))
533			active_count++;
534	return active_count;
535}
536
537static inline struct mod_hdcp_display *get_first_active_display(
538		struct mod_hdcp *hdcp)
539{
540	uint8_t i;
541	struct mod_hdcp_display *display = NULL;
542
543	for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
544		if (is_display_active(&hdcp->displays[i])) {
545			display = &hdcp->displays[i];
546			break;
547		}
548	return display;
549}
550
551static inline struct mod_hdcp_display *get_active_display_at_index(
552		struct mod_hdcp *hdcp, uint8_t index)
553{
554	uint8_t i;
555	struct mod_hdcp_display *display = NULL;
556
557	for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
558		if (hdcp->displays[i].index == index &&
559				is_display_active(&hdcp->displays[i])) {
560			display = &hdcp->displays[i];
561			break;
562		}
563	return display;
564}
565
566static inline struct mod_hdcp_display *get_empty_display_container(
567		struct mod_hdcp *hdcp)
568{
569	uint8_t i;
570	struct mod_hdcp_display *display = NULL;
571
572	for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
573		if (!is_display_active(&hdcp->displays[i])) {
574			display = &hdcp->displays[i];
575			break;
576		}
577	return display;
578}
579
580static inline void reset_retry_counts(struct mod_hdcp *hdcp)
581{
582	hdcp->connection.hdcp1_retry_count = 0;
583	hdcp->connection.hdcp2_retry_count = 0;
584}
585
586#endif /* HDCP_H_ */
~/ Read-only file preview.