kernel/0066-fix-Delete-HDCP1.4-authentication-key.patch

499 lines
7.4 KiB
Diff
Raw Permalink Normal View History

2025-01-03 03:30:57 +00:00
From 6dcf142df7b7761fb851b43aba876dabc96a8630 Mon Sep 17 00:00:00 2001
2024-12-15 18:29:23 +00:00
From: denglei <denglei@eswincomputing.com>
Date: Mon, 8 Jul 2024 19:56:12 +0800
2024-12-27 22:35:16 +00:00
Subject: [PATCH 066/222] fix:Delete HDCP1.4 authentication key.
2024-12-15 18:29:23 +00:00
Changelogs:
Delete HDCP1.4 authentication key.
Signed-off-by: denglei <denglei@eswincomputing.com>
---
drivers/gpu/drm/eswin/dw_hdmi_hdcp.c | 396 +++------------------------
1 file changed, 32 insertions(+), 364 deletions(-)
diff --git a/drivers/gpu/drm/eswin/dw_hdmi_hdcp.c b/drivers/gpu/drm/eswin/dw_hdmi_hdcp.c
index b69b1be14e0d..a6bb3a8b939d 100644
--- a/drivers/gpu/drm/eswin/dw_hdmi_hdcp.c
+++ b/drivers/gpu/drm/eswin/dw_hdmi_hdcp.c
@@ -22,7 +22,6 @@
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/spinlock.h>
-//#include <linux/soc/eswin/eswin_vendor_storage.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/module.h>
@@ -43,332 +42,6 @@
#define DPK_WR_OK_TIMEOUT_US 30000
#define HDMI_HDCP1X_ID 5
-/* HDCP DCP KEY & SEED */
-const u8 hdcp_const_data[320] = {
- /* 0 1 2 3 4 5 6 */
- 0x00,
- 0x00,
- 0xf0,
- 0xff,
- 0xff,
- 0x00,
- 0x00,
- 0x00, //KSV
- 0x91,
- 0x71,
- 0x7,
- 0x42,
- 0x86,
- 0xC1,
- 0xD1,
- 0x89,
- 0x0E,
- 0x2D,
- 0xFF,
- 0x92,
- 0x95,
- 0x28,
- 0xF4,
- 0x7D,
- 0x7B,
- 0x1F,
- 0x2A,
- 0xD9,
- 0xBB,
- 0xE4,
- 0xFD,
- 0x10,
- 0x18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
- 0x96,
- 0x27,
- 0xe7,
- 0xd9,
- 0x7b,
- 0xc5,
- 0x27,
- 0x20, //seed 0x2020
- 0x20,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
- 0x00,
-};
-
/* HDCP Registers */
#define HDMI_A_KSVMEMCTRL 0x5016
#define HDMI_HDCPREG_ANCONF 0x7805
@@ -466,15 +139,11 @@ static void hdcp_modb(struct dw_hdcp *hdcp, u8 data, u8 mask, unsigned int reg)
static int hdcp_load_keys_cb(struct dw_hdcp *hdcp)
{
- u32 size;
u8 hdcp_vendor_data[320];
- int i;
-#if 0
- int j;
- struct file *fp;
- loff_t pos = 0;
- ssize_t nread;
-#endif
+ struct file *fp;
+ loff_t pos = 0;
+ ssize_t nread;
+
hdcp->keys = kmalloc(HDCP_KEY_SIZE, GFP_KERNEL);
if (!hdcp->keys)
return -ENOMEM;
@@ -484,27 +153,11 @@ static int hdcp_load_keys_cb(struct dw_hdcp *hdcp)
kfree(hdcp->keys);
return -ENOMEM;
}
-#if 1
- // size = eswin_vendor_read(HDMI_HDCP1X_ID, hdcp_vendor_data, 314);
-
- for (i = 0; i < sizeof(hdcp_vendor_data); i++)
- hdcp_vendor_data[i] = hdcp_const_data[i];
- size = 320;
- if (size < (HDCP_KEY_SIZE + HDCP_KEY_SEED_SIZE)) {
- dev_dbg(hdcp->dev, "HDCP: read size %d\n", size);
- memset(hdcp->keys, 0, HDCP_KEY_SIZE);
- memset(hdcp->seeds, 0, HDCP_KEY_SEED_SIZE);
- } else {
- memcpy(hdcp->keys, hdcp_vendor_data, HDCP_KEY_SIZE);
- memcpy(hdcp->seeds, hdcp_vendor_data + HDCP_KEY_SIZE,
- HDCP_KEY_SEED_SIZE);
- }
-#else
fp = filp_open(HDCP_KEY_PATH, O_RDONLY, 0644);
if (IS_ERR(fp)) {
- printk("Error, Tx_A2_TestDPK_encrypted.txt doesn't exist.\n");
- return 0;
+ printk("Error, Tx_A2_TestDPK_encrypted doesn't exist.\n");
+ goto err;
}
nread = kernel_read(fp, hdcp_vendor_data, sizeof(hdcp_vendor_data),
@@ -513,7 +166,8 @@ static int hdcp_load_keys_cb(struct dw_hdcp *hdcp)
if (nread != sizeof(hdcp_vendor_data)) {
printk("Error, failed to read %ld bytes to non volatile memory area,ret %ld\n",
sizeof(hdcp_vendor_data), nread);
- return -EIO;
+ filp_close(fp, NULL);
+ goto err;
}
memcpy(hdcp->keys, hdcp_vendor_data, HDCP_KEY_SIZE);
@@ -521,9 +175,13 @@ static int hdcp_load_keys_cb(struct dw_hdcp *hdcp)
HDCP_KEY_SEED_SIZE);
filp_close(fp, NULL);
-#endif
-
return 0;
+err:
+ kfree(hdcp->keys);
+ kfree(hdcp->seeds);
+ hdcp->keys = NULL;
+ hdcp->seeds = NULL;
+ return -EIO;
}
static int dw_hdmi_hdcp_load_key(struct dw_hdcp *hdcp)
@@ -599,6 +257,7 @@ static int dw_hdmi_hdcp1x_start(struct dw_hdcp *hdcp)
int i;
int val;
u8 An[8];
+ int ret;
if (!hdcp->enable)
return -EPERM;
@@ -607,11 +266,6 @@ static int dw_hdmi_hdcp1x_start(struct dw_hdcp *hdcp)
hdcp->status == DW_HDCP_AUTH_SUCCESS)
return 0;
- /* disable the pixel clock*/
- dev_dbg(hdcp->dev, "start hdcp with disable hdmi pixel clock\n");
- hdcp_modb(hdcp, HDMI_MC_CLKDIS_PIXELCLK_DISABLE,
- HDMI_MC_CLKDIS_PIXELCLK_MASK, HDMI_MC_CLKDIS);
-
/* Update An */
get_random_bytes(&An, sizeof(An));
for (i = 0; i < 8; i++)
@@ -619,8 +273,18 @@ static int dw_hdmi_hdcp1x_start(struct dw_hdcp *hdcp)
hdcp->write(hdmi, 0x01, HDMI_HDCPREG_ANCONF);
- if (!(hdcp->read(hdmi, HDMI_HDCPREG_RMSTS) & 0x3f))
- dw_hdmi_hdcp_load_key(hdcp);
+ if (!(hdcp->read(hdmi, HDMI_HDCPREG_RMSTS) & 0x3f)) {
+ ret = dw_hdmi_hdcp_load_key(hdcp);
+ if (ret) {
+ dev_err(hdcp->dev, "load hdcp key failed, ret=%d\n", ret);
+ return ret;
+ }
+ }
+
+ /* disable the pixel clock*/
+ dev_dbg(hdcp->dev, "start hdcp with disable hdmi pixel clock\n");
+ hdcp_modb(hdcp, HDMI_MC_CLKDIS_PIXELCLK_DISABLE,
+ HDMI_MC_CLKDIS_PIXELCLK_MASK, HDMI_MC_CLKDIS);
if (hdcp->hdcp2) {
for (i = 0; i < 100; i++) {
@@ -879,6 +543,7 @@ static ssize_t hdcp_enable_write(struct device *device,
{
bool enable;
struct dw_hdcp *hdcp = g_hdcp;
+ int ret;
if (!hdcp)
return -EINVAL;
@@ -895,7 +560,10 @@ static ssize_t hdcp_enable_write(struct device *device,
if (hdcp->read(hdcp->hdmi, HDMI_PHY_STAT0) &
HDMI_PHY_HPD) {
- dw_hdmi_hdcp1x_start(hdcp);
+ ret = dw_hdmi_hdcp1x_start(hdcp);
+ if (ret) {
+ hdcp->enable = 0;
+ }
}
} else {
if (hdcp->status != DW_HDCP_DISABLED) {
--
2.47.0