linux/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h

/*
 * Copyright 2019 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors: AMD
 *
 */

#ifndef HDCP_H_
#define HDCP_H_

#include "mod_hdcp.h"
#include "hdcp_log.h"

#include <drm/display/drm_dp_helper.h>
#include <drm/display/drm_hdcp_helper.h>

enum mod_hdcp_trans_input_result {};

struct mod_hdcp_transition_input_hdcp1 {};

struct mod_hdcp_transition_input_hdcp2 {};

mod_hdcp_transition_input;

struct mod_hdcp_message_hdcp1 {};

struct mod_hdcp_message_hdcp2 {};

mod_hdcp_message;

struct mod_hdcp_auth_counters {};

/* contains values per connection */
struct mod_hdcp_connection {};

/* contains values per authentication cycle */
struct mod_hdcp_authentication {};

/* contains values per state change */
struct mod_hdcp_state {};

/* per event in a state */
struct mod_hdcp_event_context {};

struct mod_hdcp {};

enum mod_hdcp_initial_state_id {};

enum mod_hdcp_hdcp1_state_id {};

enum mod_hdcp_hdcp1_dp_state_id {};

enum mod_hdcp_hdcp2_state_id {};

enum mod_hdcp_hdcp2_dp_state_id {};

/* hdcp1 executions and transitions */
mod_hdcp_action;
uint8_t mod_hdcp_execute_and_set(
		mod_hdcp_action func, uint8_t *flag,
		enum mod_hdcp_status *status, struct mod_hdcp *hdcp, char *str);
enum mod_hdcp_status mod_hdcp_hdcp1_execution(struct mod_hdcp *hdcp,
	struct mod_hdcp_event_context *event_ctx,
	struct mod_hdcp_transition_input_hdcp1 *input);
enum mod_hdcp_status mod_hdcp_hdcp1_dp_execution(struct mod_hdcp *hdcp,
	struct mod_hdcp_event_context *event_ctx,
	struct mod_hdcp_transition_input_hdcp1 *input);
enum mod_hdcp_status mod_hdcp_hdcp1_transition(struct mod_hdcp *hdcp,
	struct mod_hdcp_event_context *event_ctx,
	struct mod_hdcp_transition_input_hdcp1 *input,
	struct mod_hdcp_output *output);
enum mod_hdcp_status mod_hdcp_hdcp1_dp_transition(struct mod_hdcp *hdcp,
	struct mod_hdcp_event_context *event_ctx,
	struct mod_hdcp_transition_input_hdcp1 *input,
	struct mod_hdcp_output *output);

/* hdcp2 executions and transitions */
enum mod_hdcp_status mod_hdcp_hdcp2_execution(struct mod_hdcp *hdcp,
	struct mod_hdcp_event_context *event_ctx,
	struct mod_hdcp_transition_input_hdcp2 *input);
enum mod_hdcp_status mod_hdcp_hdcp2_dp_execution(struct mod_hdcp *hdcp,
	struct mod_hdcp_event_context *event_ctx,
	struct mod_hdcp_transition_input_hdcp2 *input);
enum mod_hdcp_status mod_hdcp_hdcp2_transition(struct mod_hdcp *hdcp,
	struct mod_hdcp_event_context *event_ctx,
	struct mod_hdcp_transition_input_hdcp2 *input,
	struct mod_hdcp_output *output);
enum mod_hdcp_status mod_hdcp_hdcp2_dp_transition(struct mod_hdcp *hdcp,
	struct mod_hdcp_event_context *event_ctx,
	struct mod_hdcp_transition_input_hdcp2 *input,
	struct mod_hdcp_output *output);

/* log functions */
void mod_hdcp_dump_binary_message(uint8_t *msg, uint32_t msg_size,
		uint8_t *buf, uint32_t buf_size);
void mod_hdcp_log_ddc_trace(struct mod_hdcp *hdcp);
/* TODO: add adjustment log */

/* psp functions */
enum mod_hdcp_status mod_hdcp_add_display_to_topology(
		struct mod_hdcp *hdcp, struct mod_hdcp_display *display);
enum mod_hdcp_status mod_hdcp_remove_display_from_topology(
		struct mod_hdcp *hdcp, uint8_t index);
enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp1_validate_rx(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp1_enable_encryption(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp1_validate_ksvlist_vp(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(
	struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp1_link_maintenance(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_prepare_ake_init(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_validate_ake_cert(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_validate_h_prime(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_prepare_lc_init(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_validate_l_prime(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_prepare_eks(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(
		struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_prepare_stream_management(
		struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(
		struct mod_hdcp *hdcp);

/* ddc functions */
enum mod_hdcp_status mod_hdcp_read_bksv(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_bcaps(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_bstatus(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_r0p(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_ksvlist(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_vp(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_binfo(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_aksv(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_ainfo(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_an(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_hdcp2version(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_rxcaps(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_rxstatus(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_ake_cert(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_h_prime(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_pairing_info(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_l_prime(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_rx_id_list(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_read_stream_ready(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_ake_init(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_no_stored_km(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_stored_km(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_lc_init(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_eks(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_repeater_auth_ack(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_stream_manage(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_write_content_type(struct mod_hdcp *hdcp);
enum mod_hdcp_status mod_hdcp_clear_cp_irq_status(struct mod_hdcp *hdcp);

/* hdcp version helpers */
static inline uint8_t is_dp_hdcp(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_dp_mst_hdcp(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_hdmi_dvi_sl_hdcp(struct mod_hdcp *hdcp)
{}

/* hdcp state helpers */
static inline uint8_t current_state(struct mod_hdcp *hdcp)
{}

static inline void set_state_id(struct mod_hdcp *hdcp,
		struct mod_hdcp_output *output, uint8_t id)
{}

static inline uint8_t is_in_hdcp1_states(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_in_hdcp1_dp_states(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_in_hdcp2_states(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_in_hdcp2_dp_states(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_in_authenticated_states(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_hdcp1(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_hdcp2(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_in_cp_not_desired_state(struct mod_hdcp *hdcp)
{}

static inline uint8_t is_in_initialized_state(struct mod_hdcp *hdcp)
{}

/* transition operation helpers */
static inline void increment_stay_counter(struct mod_hdcp *hdcp)
{}

static inline void fail_and_restart_in_ms(uint16_t time,
		enum mod_hdcp_status *status,
		struct mod_hdcp_output *output)
{}

static inline void callback_in_ms(uint16_t time, struct mod_hdcp_output *output)
{}

static inline void set_watchdog_in_ms(struct mod_hdcp *hdcp, uint16_t time,
		struct mod_hdcp_output *output)
{}

static inline void set_auth_complete(struct mod_hdcp *hdcp,
		struct mod_hdcp_output *output)
{}

/* connection topology helpers */
static inline uint8_t is_display_active(struct mod_hdcp_display *display)
{}

static inline uint8_t is_display_encryption_enabled(struct mod_hdcp_display *display)
{}

static inline uint8_t get_active_display_count(struct mod_hdcp *hdcp)
{}

static inline struct mod_hdcp_display *get_first_active_display(
		struct mod_hdcp *hdcp)
{}

static inline struct mod_hdcp_display *get_active_display_at_index(
		struct mod_hdcp *hdcp, uint8_t index)
{}

static inline struct mod_hdcp_display *get_empty_display_container(
		struct mod_hdcp *hdcp)
{}

static inline void reset_retry_counts(struct mod_hdcp *hdcp)
{}

#endif /* HDCP_H_ */