Commit b45f9a3e authored by Isabel Zhang's avatar Isabel Zhang Committed by Alex Deucher

drm/amd/display: Remove redundant hdcp display state

[Why]
Due to previous code changes displays which are in active state
immediately transition to the active and added state. This makes the two
states redundant and unnecessary.

[How]
Instead of updating the device state to active and added after
successful addition, change state to inactive if addition failed. Also,
change references to active and added state to just added state.
Signed-off-by: default avatarIsabel Zhang <isabel.zhang@amd.com>
Reviewed-by: default avatarWenjing Liu <Wenjing.Liu@amd.com>
Acked-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent ef65c702
...@@ -328,7 +328,8 @@ enum mod_hdcp_status mod_hdcp_add_display(struct mod_hdcp *hdcp, ...@@ -328,7 +328,8 @@ enum mod_hdcp_status mod_hdcp_add_display(struct mod_hdcp *hdcp,
/* add display to connection */ /* add display to connection */
hdcp->connection.link = *link; hdcp->connection.link = *link;
*display_container = *display; *display_container = *display;
status = mod_hdcp_add_display_to_topology(hdcp, display->index); status = mod_hdcp_add_display_to_topology(hdcp, display_container);
if (status != MOD_HDCP_STATUS_SUCCESS) if (status != MOD_HDCP_STATUS_SUCCESS)
goto out; goto out;
...@@ -374,7 +375,7 @@ enum mod_hdcp_status mod_hdcp_remove_display(struct mod_hdcp *hdcp, ...@@ -374,7 +375,7 @@ enum mod_hdcp_status mod_hdcp_remove_display(struct mod_hdcp *hdcp,
status = mod_hdcp_remove_display_from_topology(hdcp, index); status = mod_hdcp_remove_display_from_topology(hdcp, index);
if (status != MOD_HDCP_STATUS_SUCCESS) if (status != MOD_HDCP_STATUS_SUCCESS)
goto out; goto out;
display->state = MOD_HDCP_DISPLAY_INACTIVE; memset(display, 0, sizeof(struct mod_hdcp_display));
/* request authentication when connection is not reset */ /* request authentication when connection is not reset */
if (current_state(hdcp) != HDCP_UNINITIALIZED) if (current_state(hdcp) != HDCP_UNINITIALIZED)
......
...@@ -328,7 +328,7 @@ void mod_hdcp_dump_binary_message(uint8_t *msg, uint32_t msg_size, ...@@ -328,7 +328,7 @@ void mod_hdcp_dump_binary_message(uint8_t *msg, uint32_t msg_size,
/* psp functions */ /* psp functions */
enum mod_hdcp_status mod_hdcp_add_display_to_topology( enum mod_hdcp_status mod_hdcp_add_display_to_topology(
struct mod_hdcp *hdcp, uint8_t index); struct mod_hdcp *hdcp, struct mod_hdcp_display *display);
enum mod_hdcp_status mod_hdcp_remove_display_from_topology( enum mod_hdcp_status mod_hdcp_remove_display_from_topology(
struct mod_hdcp *hdcp, uint8_t index); 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_create_session(struct mod_hdcp *hdcp);
...@@ -503,11 +503,6 @@ static inline uint8_t is_display_active(struct mod_hdcp_display *display) ...@@ -503,11 +503,6 @@ static inline uint8_t is_display_active(struct mod_hdcp_display *display)
return display->state >= MOD_HDCP_DISPLAY_ACTIVE; return display->state >= MOD_HDCP_DISPLAY_ACTIVE;
} }
static inline uint8_t is_display_added(struct mod_hdcp_display *display)
{
return display->state >= MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;
}
static inline uint8_t is_display_encryption_enabled(struct mod_hdcp_display *display) static inline uint8_t is_display_encryption_enabled(struct mod_hdcp_display *display)
{ {
return display->state >= MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED; return display->state >= MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;
...@@ -515,34 +510,23 @@ static inline uint8_t is_display_encryption_enabled(struct mod_hdcp_display *dis ...@@ -515,34 +510,23 @@ static inline uint8_t is_display_encryption_enabled(struct mod_hdcp_display *dis
static inline uint8_t get_active_display_count(struct mod_hdcp *hdcp) static inline uint8_t get_active_display_count(struct mod_hdcp *hdcp)
{ {
uint8_t added_count = 0; uint8_t active_count = 0;
uint8_t i; uint8_t i;
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
if (is_display_active(&hdcp->displays[i])) if (is_display_active(&hdcp->displays[i]))
added_count++; active_count++;
return added_count; return active_count;
}
static inline uint8_t get_added_display_count(struct mod_hdcp *hdcp)
{
uint8_t added_count = 0;
uint8_t i;
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
if (is_display_added(&hdcp->displays[i]))
added_count++;
return added_count;
} }
static inline struct mod_hdcp_display *get_first_added_display( static inline struct mod_hdcp_display *get_first_active_display(
struct mod_hdcp *hdcp) struct mod_hdcp *hdcp)
{ {
uint8_t i; uint8_t i;
struct mod_hdcp_display *display = NULL; struct mod_hdcp_display *display = NULL;
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
if (is_display_added(&hdcp->displays[i])) { if (is_display_active(&hdcp->displays[i])) {
display = &hdcp->displays[i]; display = &hdcp->displays[i];
break; break;
} }
......
...@@ -129,7 +129,7 @@ static inline uint8_t get_device_count(struct mod_hdcp *hdcp) ...@@ -129,7 +129,7 @@ static inline uint8_t get_device_count(struct mod_hdcp *hdcp)
static inline enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp) static inline enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp)
{ {
/* device count must be greater than or equal to tracked hdcp displays */ /* device count must be greater than or equal to tracked hdcp displays */
return (get_device_count(hdcp) < get_added_display_count(hdcp)) ? return (get_device_count(hdcp) < get_active_display_count(hdcp)) ?
MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE : MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE :
MOD_HDCP_STATUS_SUCCESS; MOD_HDCP_STATUS_SUCCESS;
} }
......
...@@ -208,7 +208,7 @@ static inline uint8_t get_device_count(struct mod_hdcp *hdcp) ...@@ -208,7 +208,7 @@ static inline uint8_t get_device_count(struct mod_hdcp *hdcp)
static enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp) static enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp)
{ {
/* device count must be greater than or equal to tracked hdcp displays */ /* device count must be greater than or equal to tracked hdcp displays */
return (get_device_count(hdcp) < get_added_display_count(hdcp)) ? return (get_device_count(hdcp) < get_active_display_count(hdcp)) ?
MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE : MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE :
MOD_HDCP_STATUS_SUCCESS; MOD_HDCP_STATUS_SUCCESS;
} }
......
...@@ -54,7 +54,7 @@ enum mod_hdcp_status mod_hdcp_remove_display_from_topology( ...@@ -54,7 +54,7 @@ enum mod_hdcp_status mod_hdcp_remove_display_from_topology(
dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf;
if (!display || !is_display_added(display)) if (!display || !is_display_active(display))
return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND; return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND;
memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory)); memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory));
...@@ -76,22 +76,18 @@ enum mod_hdcp_status mod_hdcp_remove_display_from_topology( ...@@ -76,22 +76,18 @@ enum mod_hdcp_status mod_hdcp_remove_display_from_topology(
} }
enum mod_hdcp_status mod_hdcp_add_display_to_topology( enum mod_hdcp_status mod_hdcp_add_display_to_topology(
struct mod_hdcp *hdcp, uint8_t index) struct mod_hdcp *hdcp, struct mod_hdcp_display *display)
{ {
struct psp_context *psp = hdcp->config.psp.handle; struct psp_context *psp = hdcp->config.psp.handle;
struct ta_dtm_shared_memory *dtm_cmd; struct ta_dtm_shared_memory *dtm_cmd;
struct mod_hdcp_display *display =
get_active_display_at_index(hdcp, index);
struct mod_hdcp_link *link = &hdcp->connection.link; struct mod_hdcp_link *link = &hdcp->connection.link;
if (!psp->dtm_context.dtm_initialized) { if (!psp->dtm_context.dtm_initialized) {
DRM_ERROR("Failed to add display topology, DTM TA is not initialized."); DRM_ERROR("Failed to add display topology, DTM TA is not initialized.");
display->state = MOD_HDCP_DISPLAY_INACTIVE;
return MOD_HDCP_STATUS_FAILURE; return MOD_HDCP_STATUS_FAILURE;
} }
if (!display || is_display_added(display))
return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE;
dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf;
memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory)); memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory));
...@@ -113,10 +109,11 @@ enum mod_hdcp_status mod_hdcp_add_display_to_topology( ...@@ -113,10 +109,11 @@ enum mod_hdcp_status mod_hdcp_add_display_to_topology(
psp_dtm_invoke(psp, dtm_cmd->cmd_id); psp_dtm_invoke(psp, dtm_cmd->cmd_id);
if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) {
display->state = MOD_HDCP_DISPLAY_INACTIVE;
return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE; return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE;
}
display->state = MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;
HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, display->index); HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, display->index);
return MOD_HDCP_STATUS_SUCCESS; return MOD_HDCP_STATUS_SUCCESS;
...@@ -126,7 +123,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp) ...@@ -126,7 +123,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp)
{ {
struct psp_context *psp = hdcp->config.psp.handle; struct psp_context *psp = hdcp->config.psp.handle;
struct mod_hdcp_display *display = get_first_added_display(hdcp); struct mod_hdcp_display *display = get_first_active_display(hdcp);
struct ta_hdcp_shared_memory *hdcp_cmd; struct ta_hdcp_shared_memory *hdcp_cmd;
if (!psp->hdcp_context.hdcp_initialized) { if (!psp->hdcp_context.hdcp_initialized) {
...@@ -179,7 +176,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp) ...@@ -179,7 +176,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp)
if (is_display_encryption_enabled( if (is_display_encryption_enabled(
&hdcp->displays[i])) { &hdcp->displays[i])) {
hdcp->displays[i].state = hdcp->displays[i].state =
MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED; MOD_HDCP_DISPLAY_ACTIVE;
HDCP_HDCP1_DISABLED_TRACE(hdcp, HDCP_HDCP1_DISABLED_TRACE(hdcp,
hdcp->displays[i].index); hdcp->displays[i].index);
} }
...@@ -231,7 +228,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_encryption(struct mod_hdcp *hdcp) ...@@ -231,7 +228,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_encryption(struct mod_hdcp *hdcp)
{ {
struct psp_context *psp = hdcp->config.psp.handle; struct psp_context *psp = hdcp->config.psp.handle;
struct ta_hdcp_shared_memory *hdcp_cmd; struct ta_hdcp_shared_memory *hdcp_cmd;
struct mod_hdcp_display *display = get_first_added_display(hdcp); struct mod_hdcp_display *display = get_first_active_display(hdcp);
hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;
memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
...@@ -301,8 +298,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(struct mod_hdcp ...@@ -301,8 +298,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(struct mod_hdcp
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED || if (hdcp->displays[i].adjust.disable)
hdcp->displays[i].adjust.disable)
continue; continue;
memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
...@@ -364,7 +360,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp) ...@@ -364,7 +360,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp)
{ {
struct psp_context *psp = hdcp->config.psp.handle; struct psp_context *psp = hdcp->config.psp.handle;
struct ta_hdcp_shared_memory *hdcp_cmd; struct ta_hdcp_shared_memory *hdcp_cmd;
struct mod_hdcp_display *display = get_first_added_display(hdcp); struct mod_hdcp_display *display = get_first_active_display(hdcp);
if (!psp->hdcp_context.hdcp_initialized) { if (!psp->hdcp_context.hdcp_initialized) {
DRM_ERROR("Failed to create hdcp session, HDCP TA is not initialized"); DRM_ERROR("Failed to create hdcp session, HDCP TA is not initialized");
...@@ -423,7 +419,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp) ...@@ -423,7 +419,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp)
if (is_display_encryption_enabled( if (is_display_encryption_enabled(
&hdcp->displays[i])) { &hdcp->displays[i])) {
hdcp->displays[i].state = hdcp->displays[i].state =
MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED; MOD_HDCP_DISPLAY_ACTIVE;
HDCP_HDCP2_DISABLED_TRACE(hdcp, HDCP_HDCP2_DISABLED_TRACE(hdcp,
hdcp->displays[i].index); hdcp->displays[i].index);
} }
...@@ -662,7 +658,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp) ...@@ -662,7 +658,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp)
{ {
struct psp_context *psp = hdcp->config.psp.handle; struct psp_context *psp = hdcp->config.psp.handle;
struct ta_hdcp_shared_memory *hdcp_cmd; struct ta_hdcp_shared_memory *hdcp_cmd;
struct mod_hdcp_display *display = get_first_added_display(hdcp); struct mod_hdcp_display *display = get_first_active_display(hdcp);
hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;
memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
...@@ -747,8 +743,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp ...@@ -747,8 +743,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED || if (hdcp->displays[i].adjust.disable)
hdcp->displays[i].adjust.disable)
continue; continue;
hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.display_handle = hdcp->displays[i].index; hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.display_handle = hdcp->displays[i].index;
hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.session_handle = hdcp->auth.id; hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.session_handle = hdcp->auth.id;
......
...@@ -117,7 +117,6 @@ enum mod_hdcp_operation_mode { ...@@ -117,7 +117,6 @@ enum mod_hdcp_operation_mode {
enum mod_hdcp_display_state { enum mod_hdcp_display_state {
MOD_HDCP_DISPLAY_INACTIVE = 0, MOD_HDCP_DISPLAY_INACTIVE = 0,
MOD_HDCP_DISPLAY_ACTIVE, MOD_HDCP_DISPLAY_ACTIVE,
MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED,
MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment