drm/amd/display: call psp set/get interfaces
authorBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Thu, 12 Dec 2019 21:38:38 +0000 (16:38 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 6 Feb 2020 20:04:36 +0000 (15:04 -0500)
Call the cmd ids for set/get srm according to the sysfs call

v2: Use define for the magic number

Signed-off-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c

index fe043b18bb21cca532dd01a9de6fb2fcd9ba4e7d..c4fd148bf6e0f1ee39b0434a0656bf0ee1097788 100644 (file)
 #include <drm/drm_hdcp.h>
 #include "hdcp_psp.h"
 
+/*
+ * If the SRM version being loaded is less than or equal to the
+ * currently loaded SRM, psp will return 0xFFFF as the version
+ */
+#define PSP_SRM_VERSION_MAX 0xFFFF
 
 static bool
 lp_write_i2c(void *handle, uint32_t address, const uint8_t *data, uint32_t size)
@@ -71,11 +76,54 @@ lp_read_dpcd(void *handle, uint32_t address, uint8_t *data, uint32_t size)
 
 static uint8_t *psp_get_srm(struct psp_context *psp, uint32_t *srm_version, uint32_t *srm_size)
 {
-       return NULL;
+
+       struct ta_hdcp_shared_memory *hdcp_cmd;
+
+       if (!psp->hdcp_context.hdcp_initialized) {
+               DRM_WARN("Failed to get hdcp srm. HDCP TA is not initialized.");
+               return NULL;
+       }
+
+       hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;
+       memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
+
+       hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP_GET_SRM;
+       psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);
+
+       if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS)
+               return NULL;
+
+       *srm_version = hdcp_cmd->out_msg.hdcp_get_srm.srm_version;
+       *srm_size = hdcp_cmd->out_msg.hdcp_get_srm.srm_buf_size;
+
+
+       return hdcp_cmd->out_msg.hdcp_get_srm.srm_buf;
 }
 
 static int psp_set_srm(struct psp_context *psp, uint8_t *srm, uint32_t srm_size, uint32_t *srm_version)
 {
+
+       struct ta_hdcp_shared_memory *hdcp_cmd;
+
+       if (!psp->hdcp_context.hdcp_initialized) {
+               DRM_WARN("Failed to get hdcp srm. HDCP TA is not initialized.");
+               return -EINVAL;
+       }
+
+       hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf;
+       memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory));
+
+       memcpy(hdcp_cmd->in_msg.hdcp_set_srm.srm_buf, srm, srm_size);
+       hdcp_cmd->in_msg.hdcp_set_srm.srm_buf_size = srm_size;
+       hdcp_cmd->cmd_id = TA_HDCP_COMMAND__HDCP_SET_SRM;
+
+       psp_hdcp_invoke(psp, hdcp_cmd->cmd_id);
+
+       if (hdcp_cmd->hdcp_status != TA_HDCP_STATUS__SUCCESS || hdcp_cmd->out_msg.hdcp_set_srm.valid_signature != 1 ||
+           hdcp_cmd->out_msg.hdcp_set_srm.srm_version == PSP_SRM_VERSION_MAX)
+               return -EINVAL;
+
+       *srm_version = hdcp_cmd->out_msg.hdcp_set_srm.srm_version;
        return 0;
 }