drm/amd/display: determine rx id list bytes to read based on device count
authorWenjing Liu <Wenjing.Liu@amd.com>
Tue, 25 Feb 2020 21:37:32 +0000 (16:37 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 9 Mar 2020 17:49:40 +0000 (13:49 -0400)
[why]
Some RX doesn't like us to read rx id list upto max rx id list size.  As
discussed, we decided to read rx id list based on device count.

[how]
According to HDCP specs the actual size of rx id list is calculated as
rx id list size = 2+3+16+5*device_count.  We will read 16 bytes at a
time until it reached or exceeded rx id list size.

Signed-off-by: Wenjing Liu <Wenjing.Liu@amd.com>
Reviewed-by: Ashley Thomas <Ashley.Thomas2@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c

index ff9d54812e62934053a4d0738e00948b5bdfa19e..816759d10cbc20aedd7aacb18e4657b512735180 100644 (file)
@@ -65,6 +65,7 @@ enum mod_hdcp_ddc_message_id {
        MOD_HDCP_MESSAGE_ID_READ_LC_SEND_L_PRIME,
        MOD_HDCP_MESSAGE_ID_WRITE_SKE_SEND_EKS,
        MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST,
+       MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST_PART2,
        MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_SEND_ACK,
        MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_STREAM_MANAGE,
        MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_STREAM_READY,
@@ -101,6 +102,7 @@ static const uint8_t hdcp_i2c_offsets[] = {
        [MOD_HDCP_MESSAGE_ID_READ_LC_SEND_L_PRIME] = 0x80,
        [MOD_HDCP_MESSAGE_ID_WRITE_SKE_SEND_EKS] = 0x60,
        [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST] = 0x80,
+       [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST_PART2] = 0x80,
        [MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_SEND_ACK] = 0x60,
        [MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_STREAM_MANAGE] = 0x60,
        [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_STREAM_READY] = 0x80,
@@ -135,6 +137,7 @@ static const uint32_t hdcp_dpcd_addrs[] = {
        [MOD_HDCP_MESSAGE_ID_READ_LC_SEND_L_PRIME] = 0x692f8,
        [MOD_HDCP_MESSAGE_ID_WRITE_SKE_SEND_EKS] = 0x69318,
        [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST] = 0x69330,
+       [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST_PART2] = 0x69340,
        [MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_SEND_ACK] = 0x693e0,
        [MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_STREAM_MANAGE] = 0x693f0,
        [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_STREAM_READY] = 0x69473,
@@ -474,14 +477,27 @@ 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 status;
+       enum mod_hdcp_status status = MOD_HDCP_STATUS_SUCCESS;
 
        if (is_dp_hdcp(hdcp)) {
+               uint32_t device_count = 0;
+               uint32_t rx_id_list_size = 0;
+               uint32_t bytes_read = 0;
+
                hdcp->auth.msg.hdcp2.rx_id_list[0] = 12;
                status = read(hdcp, MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST,
-                               hdcp->auth.msg.hdcp2.rx_id_list+1,
-                               sizeof(hdcp->auth.msg.hdcp2.rx_id_list)-1);
-
+                                               hdcp->auth.msg.hdcp2.rx_id_list+1,
+                                               HDCP_MAX_AUX_TRANSACTION_SIZE);
+               if (status == MOD_HDCP_STATUS_SUCCESS) {
+                       bytes_read = HDCP_MAX_AUX_TRANSACTION_SIZE;
+                       device_count = HDCP_2_2_DEV_COUNT_LO(hdcp->auth.msg.hdcp2.rx_id_list[2]) +
+                                       (HDCP_2_2_DEV_COUNT_HI(hdcp->auth.msg.hdcp2.rx_id_list[1]) << 4);
+                       rx_id_list_size = MIN((21 + 5 * device_count),
+                                       (sizeof(hdcp->auth.msg.hdcp2.rx_id_list) - 1));
+                       status = read(hdcp, MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST_PART2,
+                                       hdcp->auth.msg.hdcp2.rx_id_list + 1 + bytes_read,
+                                       (rx_id_list_size - 1) / HDCP_MAX_AUX_TRANSACTION_SIZE * HDCP_MAX_AUX_TRANSACTION_SIZE);
+               }
        } else {
                status = read(hdcp, MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST,
                                hdcp->auth.msg.hdcp2.rx_id_list,