summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhung Cheng <ahcheng@nvidia.com>2021-11-26 06:17:13 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2022-01-07 09:10:37 -0500
commitaead036da110062df01a7a4f92592e95f3970a18 (patch)
tree48b1dc71283fbbfb60abd8435bd2e66617d443a5
parent14b4a6ed4d7b0aa1f3fb340be01a47241401d4c2 (diff)
tegra: hdcp: update policy init value
Update hdcp policy init value based on availability of HDCP TA for L4T Bug 3167119 Change-Id: I81e4f02b20214fb23c94756804448fa0ae80246b Signed-off-by: Ahung Cheng <ahcheng@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2632879 Reviewed-by: Ilhan Gurel <igurel@nvidia.com> Reviewed-by: Bibek Basu <bbasu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
-rw-r--r--drivers/video/tegra/dc/hdcp/dphdcp.c22
-rw-r--r--drivers/video/tegra/dc/hdcp/dphdcp.h3
-rw-r--r--drivers/video/tegra/dc/hdcp/hdmihdcp.c137
-rw-r--r--drivers/video/tegra/dc/hdcp/hdmihdcp.h3
4 files changed, 92 insertions, 73 deletions
diff --git a/drivers/video/tegra/dc/hdcp/dphdcp.c b/drivers/video/tegra/dc/hdcp/dphdcp.c
index 260a20018..b81e6b162 100644
--- a/drivers/video/tegra/dc/hdcp/dphdcp.c
+++ b/drivers/video/tegra/dc/hdcp/dphdcp.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * dphdcp.c: dp hdcp driver. 2 * dphdcp.c: dp hdcp driver.
3 * 3 *
4 * Copyright (c) 2015-2020, NVIDIA CORPORATION, All rights reserved. 4 * Copyright (c) 2015-2021, NVIDIA CORPORATION, All rights reserved.
5 * 5 *
6 * This software is licensed under the terms of the GNU General Public 6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and 7 * License version 2, as published by the Free Software Foundation, and
@@ -2196,7 +2196,27 @@ static int dphdcp_dev_open(struct inode *inode, struct file *filp)
2196 struct miscdevice *miscdev = filp->private_data; 2196 struct miscdevice *miscdev = filp->private_data;
2197 struct tegra_dphdcp *dphdcp = 2197 struct tegra_dphdcp *dphdcp =
2198 container_of(miscdev, struct tegra_dphdcp, miscdev); 2198 container_of(miscdev, struct tegra_dphdcp, miscdev);
2199#ifndef CONFIG_ANDROID
2200 int err = 0;
2201#endif
2199 filp->private_data = dphdcp; 2202 filp->private_data = dphdcp;
2203
2204/* enable policy only if HDCP TA is ready */
2205#ifndef CONFIG_ANDROID
2206 if (!dphdcp->policy_initialized) {
2207 dphdcp->policy_initialized = true;
2208
2209 err = te_open_trusted_session(HDCP_PORT_NAME, &dphdcp->ta_ctx);
2210 if (!err)
2211 tegra_dphdcp_set_policy(dphdcp,
2212 TEGRA_DC_HDCP_POLICY_ALWAYS_ON);
2213
2214 if (dphdcp->ta_ctx) {
2215 te_close_trusted_session(dphdcp->ta_ctx);
2216 dphdcp->ta_ctx = NULL;
2217 }
2218 }
2219#endif
2200 return 0; 2220 return 0;
2201} 2221}
2202 2222
diff --git a/drivers/video/tegra/dc/hdcp/dphdcp.h b/drivers/video/tegra/dc/hdcp/dphdcp.h
index 21ad10d3e..0293cfb73 100644
--- a/drivers/video/tegra/dc/hdcp/dphdcp.h
+++ b/drivers/video/tegra/dc/hdcp/dphdcp.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * dphdcp.h: dp hdcp driver. 2 * dphdcp.h: dp hdcp driver.
3 * 3 *
4 * Copyright (c) 2015-2019, NVIDIA CORPORATION, All rights reserved. 4 * Copyright (c) 2015-2021, NVIDIA CORPORATION, All rights reserved.
5 * 5 *
6 * This software is licensed under the terms of the GNU General Public 6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and 7 * License version 2, as published by the Free Software Foundation, and
@@ -75,6 +75,7 @@ struct tegra_dphdcp {
75 u8 hpd; 75 u8 hpd;
76 u8 repeater; 76 u8 repeater;
77 void *ta_ctx; 77 void *ta_ctx;
78 bool policy_initialized;
78}; 79};
79 80
80#ifdef CONFIG_DPHDCP 81#ifdef CONFIG_DPHDCP
diff --git a/drivers/video/tegra/dc/hdcp/hdmihdcp.c b/drivers/video/tegra/dc/hdcp/hdmihdcp.c
index 89dd5ef5a..97398e8bc 100644
--- a/drivers/video/tegra/dc/hdcp/hdmihdcp.c
+++ b/drivers/video/tegra/dc/hdcp/hdmihdcp.c
@@ -847,7 +847,6 @@ static int get_srm_signature(struct hdcp_context_t *hdcp_context,
847#else 847#else
848 err = te_launch_trusted_oper(pkt, PKT_SIZE, HDCP_CMD_GEN_CMAC, ta_ctx); 848 err = te_launch_trusted_oper(pkt, PKT_SIZE, HDCP_CMD_GEN_CMAC, ta_ctx);
849#endif 849#endif
850
851 if (err) 850 if (err)
852 nvhdcp_err("te launch operation failed with error %d\n", err); 851 nvhdcp_err("te launch operation failed with error %d\n", err);
853 return err; 852 return err;
@@ -1037,6 +1036,51 @@ static int get_repeater_info(struct tegra_nvhdcp *nvhdcp)
1037 return 0; 1036 return 0;
1038} 1037}
1039 1038
1039static int nvhdcp_te_open(struct tegra_nvhdcp *nvhdcp)
1040{
1041 int err = 0;
1042
1043#ifdef CONFIG_TRUSTED_LITTLE_KERNEL
1044 /* differentiate between TLK and trusty */
1045 if (te_is_secos_dev_enabled()) {
1046 err = te_open_trusted_session_tlk(hdcp_uuid, sizeof(hdcp_uuid),
1047 &session_id);
1048 } else {
1049 nvhdcp->ta_ctx = NULL;
1050 /* Open a trusted sesion with HDCP TA */
1051 err = te_open_trusted_session(HDCP_PORT_NAME, &nvhdcp->ta_ctx);
1052 }
1053#else
1054 nvhdcp->ta_ctx = NULL;
1055 /* Open a trusted sesion with HDCP TA */
1056 err = te_open_trusted_session(HDCP_PORT_NAME, &nvhdcp->ta_ctx);
1057#endif
1058 return err;
1059}
1060
1061static void nvhdcp_te_close(struct tegra_nvhdcp *nvhdcp)
1062{
1063#ifdef CONFIG_TRUSTED_LITTLE_KERNEL
1064 if (te_is_secos_dev_enabled()) {
1065 if (session_id) {
1066 te_close_trusted_session_tlk(session_id, hdcp_uuid,
1067 sizeof(hdcp_uuid));
1068 session_id = 0;
1069 }
1070 } else {
1071 if (nvhdcp->ta_ctx) {
1072 te_close_trusted_session(nvhdcp->ta_ctx);
1073 nvhdcp->ta_ctx = NULL;
1074 }
1075 }
1076#else
1077 if (nvhdcp->ta_ctx) {
1078 te_close_trusted_session(nvhdcp->ta_ctx);
1079 nvhdcp->ta_ctx = NULL;
1080 }
1081#endif
1082}
1083
1040static int nvhdcp_ake_init_send(struct tegra_nvhdcp *nvhdcp, u8 *buf) 1084static int nvhdcp_ake_init_send(struct tegra_nvhdcp *nvhdcp, u8 *buf)
1041{ 1085{
1042 int e; 1086 int e;
@@ -1286,22 +1330,7 @@ static int tsec_hdcp_authentication(struct tegra_nvhdcp *nvhdcp,
1286 if (err) 1330 if (err)
1287 goto exit; 1331 goto exit;
1288 1332
1289#ifdef CONFIG_TRUSTED_LITTLE_KERNEL 1333 err = nvhdcp_te_open(nvhdcp);
1290 /* differentiate between TLK and trusty */
1291 if (te_is_secos_dev_enabled()) {
1292 err = te_open_trusted_session_tlk(hdcp_uuid, sizeof(hdcp_uuid),
1293 &session_id);
1294 } else {
1295 nvhdcp->ta_ctx = NULL;
1296 /* Open a trusted sesion with HDCP TA */
1297 err = te_open_trusted_session(HDCP_PORT_NAME, &nvhdcp->ta_ctx);
1298 }
1299#else
1300 nvhdcp->ta_ctx = NULL;
1301 /* Open a trusted sesion with HDCP TA */
1302 err = te_open_trusted_session(HDCP_PORT_NAME, &nvhdcp->ta_ctx);
1303#endif
1304
1305 if (err) { 1334 if (err) {
1306 nvhdcp_err("Error opening trusted session\n"); 1335 nvhdcp_err("Error opening trusted session\n");
1307 goto exit; 1336 goto exit;
@@ -1476,27 +1505,7 @@ exit:
1476 if (err) 1505 if (err)
1477 nvhdcp_err("HDCP authentication failed with err %d\n", err); 1506 nvhdcp_err("HDCP authentication failed with err %d\n", err);
1478 kfree(pkt); 1507 kfree(pkt);
1479 1508 nvhdcp_te_close(nvhdcp);
1480#ifdef CONFIG_TRUSTED_LITTLE_KERNEL
1481 if (te_is_secos_dev_enabled()) {
1482 if (session_id) {
1483 te_close_trusted_session_tlk(session_id, hdcp_uuid,
1484 sizeof(hdcp_uuid));
1485 session_id = 0;
1486 }
1487 } else {
1488 if (nvhdcp->ta_ctx) {
1489 te_close_trusted_session(nvhdcp->ta_ctx);
1490 nvhdcp->ta_ctx = NULL;
1491 }
1492 }
1493#else
1494 if (nvhdcp->ta_ctx) {
1495 te_close_trusted_session(nvhdcp->ta_ctx);
1496 nvhdcp->ta_ctx = NULL;
1497 }
1498#endif
1499
1500 return err; 1509 return err;
1501} 1510}
1502 1511
@@ -1594,11 +1603,7 @@ static void nvhdcp1_downstream_worker(struct work_struct *work)
1594 nvhdcp_vdbg("read Bcaps = 0x%02x\n", b_caps); 1603 nvhdcp_vdbg("read Bcaps = 0x%02x\n", b_caps);
1595 1604
1596 nvhdcp->ta_ctx = NULL; 1605 nvhdcp->ta_ctx = NULL;
1597 e = te_open_trusted_session(HDCP_PORT_NAME, &nvhdcp->ta_ctx); 1606 e = nvhdcp_te_open(nvhdcp);
1598 if (e) {
1599 nvhdcp_err("Error opening trusted session\n");
1600 goto failure;
1601 }
1602 1607
1603 if (tegra_dc_is_nvdisplay()) { 1608 if (tegra_dc_is_nvdisplay()) {
1604 /* if session successfully opened, launch operations 1609 /* if session successfully opened, launch operations
@@ -1929,19 +1934,13 @@ lost_hdmi:
1929err: 1934err:
1930 mutex_unlock(&nvhdcp->lock); 1935 mutex_unlock(&nvhdcp->lock);
1931 kfree(pkt); 1936 kfree(pkt);
1932 if (nvhdcp->ta_ctx) { 1937 nvhdcp_te_close(nvhdcp);
1933 te_close_trusted_session(nvhdcp->ta_ctx);
1934 nvhdcp->ta_ctx = NULL;
1935 }
1936 tegra_dc_io_end(dc); 1938 tegra_dc_io_end(dc);
1937 return; 1939 return;
1938disable: 1940disable:
1939 nvhdcp->state = STATE_OFF; 1941 nvhdcp->state = STATE_OFF;
1940 kfree(pkt); 1942 kfree(pkt);
1941 if (nvhdcp->ta_ctx) { 1943 nvhdcp_te_close(nvhdcp);
1942 te_close_trusted_session(nvhdcp->ta_ctx);
1943 nvhdcp->ta_ctx = NULL;
1944 }
1945 nvhdcp_set_plugged(nvhdcp, false); 1944 nvhdcp_set_plugged(nvhdcp, false);
1946 mutex_unlock(&nvhdcp->lock); 1945 mutex_unlock(&nvhdcp->lock);
1947 tegra_dc_io_end(dc); 1946 tegra_dc_io_end(dc);
@@ -1986,21 +1985,7 @@ static int link_integrity_check(struct tegra_nvhdcp *nvhdcp,
1986 msecs_to_jiffies(10)); 1985 msecs_to_jiffies(10));
1987 goto exit; 1986 goto exit;
1988 } 1987 }
1989#ifdef CONFIG_TRUSTED_LITTLE_KERNEL 1988 err = nvhdcp_te_open(nvhdcp);
1990 /* differentiate between TLK and trusty */
1991 if (te_is_secos_dev_enabled()) {
1992 err = te_open_trusted_session_tlk(hdcp_uuid, sizeof(hdcp_uuid),
1993 &session_id);
1994 } else {
1995 nvhdcp->ta_ctx = NULL;
1996 /* Open a trusted sesion with HDCP TA */
1997 err = te_open_trusted_session(HDCP_PORT_NAME, &nvhdcp->ta_ctx);
1998 }
1999#else
2000 nvhdcp->ta_ctx = NULL;
2001 /* Open a trusted sesion with HDCP TA */
2002 err = te_open_trusted_session(HDCP_PORT_NAME, &nvhdcp->ta_ctx);
2003#endif
2004 if (err) { 1989 if (err) {
2005 nvhdcp_err("Error opening trusted session\n"); 1990 nvhdcp_err("Error opening trusted session\n");
2006 goto exit; 1991 goto exit;
@@ -2026,10 +2011,7 @@ static int link_integrity_check(struct tegra_nvhdcp *nvhdcp,
2026 err = (rx_status & HDCP_RX_STATUS_MSG_REAUTH_REQ); 2011 err = (rx_status & HDCP_RX_STATUS_MSG_REAUTH_REQ);
2027exit: 2012exit:
2028 kfree(pkt); 2013 kfree(pkt);
2029 if (nvhdcp->ta_ctx) { 2014 nvhdcp_te_close(nvhdcp);
2030 te_close_trusted_session(nvhdcp->ta_ctx);
2031 nvhdcp->ta_ctx = NULL;
2032 }
2033 return err; 2015 return err;
2034} 2016}
2035 2017
@@ -2423,7 +2405,22 @@ static int nvhdcp_dev_open(struct inode *inode, struct file *filp)
2423 struct miscdevice *miscdev = filp->private_data; 2405 struct miscdevice *miscdev = filp->private_data;
2424 struct tegra_nvhdcp *nvhdcp = 2406 struct tegra_nvhdcp *nvhdcp =
2425 container_of(miscdev, struct tegra_nvhdcp, miscdev); 2407 container_of(miscdev, struct tegra_nvhdcp, miscdev);
2408#ifndef CONFIG_ANDROID
2409 int err = 0;
2410#endif
2426 filp->private_data = nvhdcp; 2411 filp->private_data = nvhdcp;
2412
2413/* enable policy only if HDCP TA is ready */
2414#ifndef CONFIG_ANDROID
2415 if (!nvhdcp->policy_initialized) {
2416 nvhdcp->policy_initialized = true;
2417 err = nvhdcp_te_open(nvhdcp);
2418 if (!err)
2419 tegra_nvhdcp_set_policy(nvhdcp,
2420 TEGRA_DC_HDCP_POLICY_ALWAYS_ON);
2421 nvhdcp_te_close(nvhdcp);
2422 }
2423#endif
2427 return 0; 2424 return 0;
2428} 2425}
2429 2426
diff --git a/drivers/video/tegra/dc/hdcp/hdmihdcp.h b/drivers/video/tegra/dc/hdcp/hdmihdcp.h
index e8320afea..01d85a7cc 100644
--- a/drivers/video/tegra/dc/hdcp/hdmihdcp.h
+++ b/drivers/video/tegra/dc/hdcp/hdmihdcp.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * hdmihdcp.h: hdmi hdcp interface. 2 * hdmihdcp.h: hdmi hdcp interface.
3 * 3 *
4 * Copyright (c) 2015-2019, NVIDIA CORPORATION, All rights reserved. 4 * Copyright (c) 2015-2021, NVIDIA CORPORATION, All rights reserved.
5 * 5 *
6 * This software is licensed under the terms of the GNU General Public 6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and 7 * License version 2, as published by the Free Software Foundation, and
@@ -78,6 +78,7 @@ struct tegra_nvhdcp {
78 struct workqueue_struct *fallback_wq; 78 struct workqueue_struct *fallback_wq;
79 struct delayed_work fallback_work; 79 struct delayed_work fallback_work;
80 void *ta_ctx; 80 void *ta_ctx;
81 bool policy_initialized;
81}; 82};
82 83
83#ifdef CONFIG_HDCP 84#ifdef CONFIG_HDCP