Skip to content

Commit 58edb07

Browse files
Isabel Zhangalexdeucher
authored andcommitted
drm/amd/display: Revert change to HDCP display states
[Why] Change is causing a regression where the OPC app no longer functions properly. [How] Revert the changelist causing the issue. Signed-off-by: Isabel Zhang <[email protected]> Reviewed-by: Yongqiang Sun <[email protected]> Acked-by: Rodrigo Siqueira <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 9941b81 commit 58edb07

File tree

6 files changed

+49
-28
lines changed

6 files changed

+49
-28
lines changed

drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,7 @@ enum mod_hdcp_status mod_hdcp_add_display(struct mod_hdcp *hdcp,
328328
/* add display to connection */
329329
hdcp->connection.link = *link;
330330
*display_container = *display;
331-
status = mod_hdcp_add_display_to_topology(hdcp, display_container);
332-
331+
status = mod_hdcp_add_display_to_topology(hdcp, display->index);
333332
if (status != MOD_HDCP_STATUS_SUCCESS)
334333
goto out;
335334

@@ -375,7 +374,7 @@ enum mod_hdcp_status mod_hdcp_remove_display(struct mod_hdcp *hdcp,
375374
status = mod_hdcp_remove_display_from_topology(hdcp, index);
376375
if (status != MOD_HDCP_STATUS_SUCCESS)
377376
goto out;
378-
memset(display, 0, sizeof(struct mod_hdcp_display));
377+
display->state = MOD_HDCP_DISPLAY_INACTIVE;
379378

380379
/* request authentication when connection is not reset */
381380
if (current_state(hdcp) != HDCP_UNINITIALIZED)

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void mod_hdcp_dump_binary_message(uint8_t *msg, uint32_t msg_size,
328328

329329
/* psp functions */
330330
enum mod_hdcp_status mod_hdcp_add_display_to_topology(
331-
struct mod_hdcp *hdcp, struct mod_hdcp_display *display);
331+
struct mod_hdcp *hdcp, uint8_t index);
332332
enum mod_hdcp_status mod_hdcp_remove_display_from_topology(
333333
struct mod_hdcp *hdcp, uint8_t index);
334334
enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp);
@@ -503,30 +503,46 @@ static inline uint8_t is_display_active(struct mod_hdcp_display *display)
503503
return display->state >= MOD_HDCP_DISPLAY_ACTIVE;
504504
}
505505

506+
static inline uint8_t is_display_added(struct mod_hdcp_display *display)
507+
{
508+
return display->state >= MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;
509+
}
510+
506511
static inline uint8_t is_display_encryption_enabled(struct mod_hdcp_display *display)
507512
{
508513
return display->state >= MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED;
509514
}
510515

511516
static inline uint8_t get_active_display_count(struct mod_hdcp *hdcp)
512517
{
513-
uint8_t active_count = 0;
518+
uint8_t added_count = 0;
514519
uint8_t i;
515520

516521
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
517522
if (is_display_active(&hdcp->displays[i]))
518-
active_count++;
519-
return active_count;
523+
added_count++;
524+
return added_count;
525+
}
526+
527+
static inline uint8_t get_added_display_count(struct mod_hdcp *hdcp)
528+
{
529+
uint8_t added_count = 0;
530+
uint8_t i;
531+
532+
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
533+
if (is_display_added(&hdcp->displays[i]))
534+
added_count++;
535+
return added_count;
520536
}
521537

522-
static inline struct mod_hdcp_display *get_first_active_display(
538+
static inline struct mod_hdcp_display *get_first_added_display(
523539
struct mod_hdcp *hdcp)
524540
{
525541
uint8_t i;
526542
struct mod_hdcp_display *display = NULL;
527543

528544
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++)
529-
if (is_display_active(&hdcp->displays[i])) {
545+
if (is_display_added(&hdcp->displays[i])) {
530546
display = &hdcp->displays[i];
531547
break;
532548
}

drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static inline uint8_t get_device_count(struct mod_hdcp *hdcp)
129129
static inline enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp)
130130
{
131131
/* device count must be greater than or equal to tracked hdcp displays */
132-
return (get_device_count(hdcp) < get_active_display_count(hdcp)) ?
132+
return (get_device_count(hdcp) < get_added_display_count(hdcp)) ?
133133
MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE :
134134
MOD_HDCP_STATUS_SUCCESS;
135135
}

drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static inline uint8_t get_device_count(struct mod_hdcp *hdcp)
208208
static enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp)
209209
{
210210
/* device count must be greater than or equal to tracked hdcp displays */
211-
return (get_device_count(hdcp) < get_active_display_count(hdcp)) ?
211+
return (get_device_count(hdcp) < get_added_display_count(hdcp)) ?
212212
MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE :
213213
MOD_HDCP_STATUS_SUCCESS;
214214
}

drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ enum mod_hdcp_status mod_hdcp_remove_display_from_topology(
5454

5555
dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf;
5656

57-
if (!display || !is_display_active(display))
57+
if (!display || !is_display_added(display))
5858
return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND;
5959

6060
memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory));
@@ -73,21 +73,25 @@ enum mod_hdcp_status mod_hdcp_remove_display_from_topology(
7373
HDCP_TOP_REMOVE_DISPLAY_TRACE(hdcp, display->index);
7474

7575
return MOD_HDCP_STATUS_SUCCESS;
76-
}
77-
78-
enum mod_hdcp_status mod_hdcp_add_display_to_topology(
79-
struct mod_hdcp *hdcp, struct mod_hdcp_display *display)
76+
77+
}
78+
enum mod_hdcp_status mod_hdcp_add_display_to_topology(struct mod_hdcp *hdcp,
79+
uint8_t index)
8080
{
8181
struct psp_context *psp = hdcp->config.psp.handle;
8282
struct ta_dtm_shared_memory *dtm_cmd;
83+
struct mod_hdcp_display *display =
84+
get_active_display_at_index(hdcp, index);
8385
struct mod_hdcp_link *link = &hdcp->connection.link;
8486

8587
if (!psp->dtm_context.dtm_initialized) {
8688
DRM_ERROR("Failed to add display topology, DTM TA is not initialized.");
87-
display->state = MOD_HDCP_DISPLAY_INACTIVE;
8889
return MOD_HDCP_STATUS_FAILURE;
8990
}
9091

92+
if (!display || is_display_added(display))
93+
return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE;
94+
9195
dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf;
9296

9397
memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory));
@@ -109,11 +113,10 @@ enum mod_hdcp_status mod_hdcp_add_display_to_topology(
109113

110114
psp_dtm_invoke(psp, dtm_cmd->cmd_id);
111115

112-
if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) {
113-
display->state = MOD_HDCP_DISPLAY_INACTIVE;
116+
if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS)
114117
return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE;
115-
}
116118

119+
display->state = MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;
117120
HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, display->index);
118121

119122
return MOD_HDCP_STATUS_SUCCESS;
@@ -123,7 +126,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp)
123126
{
124127

125128
struct psp_context *psp = hdcp->config.psp.handle;
126-
struct mod_hdcp_display *display = get_first_active_display(hdcp);
129+
struct mod_hdcp_display *display = get_first_added_display(hdcp);
127130
struct ta_hdcp_shared_memory *hdcp_cmd;
128131

129132
if (!psp->hdcp_context.hdcp_initialized) {
@@ -176,7 +179,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_destroy_session(struct mod_hdcp *hdcp)
176179
if (is_display_encryption_enabled(
177180
&hdcp->displays[i])) {
178181
hdcp->displays[i].state =
179-
MOD_HDCP_DISPLAY_ACTIVE;
182+
MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;
180183
HDCP_HDCP1_DISABLED_TRACE(hdcp,
181184
hdcp->displays[i].index);
182185
}
@@ -228,7 +231,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_encryption(struct mod_hdcp *hdcp)
228231
{
229232
struct psp_context *psp = hdcp->config.psp.handle;
230233
struct ta_hdcp_shared_memory *hdcp_cmd;
231-
struct mod_hdcp_display *display = get_first_active_display(hdcp);
234+
struct mod_hdcp_display *display = get_first_added_display(hdcp);
232235

233236
hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;
234237
memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
@@ -298,7 +301,8 @@ enum mod_hdcp_status mod_hdcp_hdcp1_enable_dp_stream_encryption(struct mod_hdcp
298301

299302
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
300303

301-
if (hdcp->displays[i].adjust.disable)
304+
if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED ||
305+
hdcp->displays[i].adjust.disable)
302306
continue;
303307

304308
memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
@@ -360,7 +364,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp)
360364
{
361365
struct psp_context *psp = hdcp->config.psp.handle;
362366
struct ta_hdcp_shared_memory *hdcp_cmd;
363-
struct mod_hdcp_display *display = get_first_active_display(hdcp);
367+
struct mod_hdcp_display *display = get_first_added_display(hdcp);
364368

365369
if (!psp->hdcp_context.hdcp_initialized) {
366370
DRM_ERROR("Failed to create hdcp session, HDCP TA is not initialized");
@@ -419,7 +423,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp)
419423
if (is_display_encryption_enabled(
420424
&hdcp->displays[i])) {
421425
hdcp->displays[i].state =
422-
MOD_HDCP_DISPLAY_ACTIVE;
426+
MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED;
423427
HDCP_HDCP2_DISABLED_TRACE(hdcp,
424428
hdcp->displays[i].index);
425429
}
@@ -658,7 +662,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp)
658662
{
659663
struct psp_context *psp = hdcp->config.psp.handle;
660664
struct ta_hdcp_shared_memory *hdcp_cmd;
661-
struct mod_hdcp_display *display = get_first_active_display(hdcp);
665+
struct mod_hdcp_display *display = get_first_added_display(hdcp);
662666

663667
hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;
664668
memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
@@ -743,7 +747,8 @@ enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(struct mod_hdcp
743747

744748

745749
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
746-
if (hdcp->displays[i].adjust.disable)
750+
if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED ||
751+
hdcp->displays[i].adjust.disable)
747752
continue;
748753
hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.display_handle = hdcp->displays[i].index;
749754
hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.session_handle = hdcp->auth.id;

drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ enum mod_hdcp_operation_mode {
117117
enum mod_hdcp_display_state {
118118
MOD_HDCP_DISPLAY_INACTIVE = 0,
119119
MOD_HDCP_DISPLAY_ACTIVE,
120+
MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED,
120121
MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED
121122
};
122123

0 commit comments

Comments
 (0)