Merge "msm: mdss: Allow resource update during secure UI"
diff --git a/drivers/video/fbdev/msm/mdp3.h b/drivers/video/fbdev/msm/mdp3.h
index 3ab4652..e7294cb 100644
--- a/drivers/video/fbdev/msm/mdp3.h
+++ b/drivers/video/fbdev/msm/mdp3.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, 2016-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 2016-2020, The Linux Foundation. All rights reserved.
* Copyright (C) 2007 Google Incorporated
*
* This program is free software; you can redistribute it and/or modify
@@ -211,6 +211,8 @@
struct mutex reg_bus_lock;
int bklt_level;
int bklt_update;
+ bool secure_update_bl;
+ bool secure_reg_on;
bool twm_en;
u32 max_bw;
diff --git a/drivers/video/fbdev/msm/mdp3_ctrl.c b/drivers/video/fbdev/msm/mdp3_ctrl.c
index 09841d7..34869b8 100644
--- a/drivers/video/fbdev/msm/mdp3_ctrl.c
+++ b/drivers/video/fbdev/msm/mdp3_ctrl.c
@@ -948,6 +948,7 @@
mutex_lock(&mdp3_session->lock);
MDSS_XLOG(XLOG_FUNC_ENTRY, __LINE__, mfd->panel_power_state);
+ mdp3_res->secure_update_bl = false;
panel = mdp3_session->panel;
/* make sure DSI host is initialized properly */
if (panel) {
@@ -1865,6 +1866,24 @@
return ret;
}
break;
+ case metadata_op_secure_bl_set:
+ if (mdss_panel_is_power_off(mfd->panel_power_state) &&
+ mfd->panel.type == SPI_PANEL) {
+ mfd->allow_secure_bl_update =
+ metadata_ptr->data.sec_bl_update_en;
+ mdp3_res->secure_update_bl =
+ mfd->allow_secure_bl_update;
+ }
+ pr_debug("Secure backlight = %d,panel power state = %d\n",
+ mfd->allow_secure_bl_update, mfd->panel_power_state);
+ break;
+ case metadata_op_secure_reg:
+ if (mfd->panel.type == SPI_PANEL) {
+ mdp3_res->secure_reg_on = metadata_ptr->data.sec_reg_on;
+ pr_debug("Secure regulator_on flag is %d\n",
+ mdp3_res->secure_reg_on);
+ }
+ break;
default:
pr_warn("Unsupported request to MDP SET META IOCTL.\n");
ret = -EINVAL;
@@ -2813,7 +2832,8 @@
req = &mdp3_session->req_overlay;
if (!mdp3_session->status && cmd != MSMFB_METADATA_GET &&
- cmd != MSMFB_HISTOGRAM_STOP && cmd != MSMFB_HISTOGRAM) {
+ cmd != MSMFB_METADATA_SET && cmd != MSMFB_HISTOGRAM_STOP &&
+ cmd != MSMFB_HISTOGRAM) {
pr_err("mdp3_ctrl_ioctl_handler, display off!\n");
return -EPERM;
}
diff --git a/drivers/video/fbdev/msm/mdss_compat_utils.h b/drivers/video/fbdev/msm/mdss_compat_utils.h
index 819106b..10c5011 100644
--- a/drivers/video/fbdev/msm/mdss_compat_utils.h
+++ b/drivers/video/fbdev/msm/mdss_compat_utils.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016, 2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2016, 2018,2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -88,6 +88,8 @@
uint32_t video_info_code;
struct mdss_hw_caps caps;
uint8_t secure_en;
+ bool sec_bl_update_en;
+ bool sec_reg_on;
} data;
};
diff --git a/drivers/video/fbdev/msm/mdss_fb.c b/drivers/video/fbdev/msm/mdss_fb.c
index 3a5dd02..f9c9c6d 100644
--- a/drivers/video/fbdev/msm/mdss_fb.c
+++ b/drivers/video/fbdev/msm/mdss_fb.c
@@ -2,7 +2,7 @@
* Core MDSS framebuffer driver.
*
* Copyright (C) 2007 Google Incorporated
- * Copyright (c) 2008-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2008-2020, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -1716,13 +1716,14 @@
bool twm_en = false;
if ((((mdss_fb_is_power_off(mfd) && mfd->dcm_state != DCM_ENTER)
- || !mfd->allow_bl_update) && !IS_CALIB_MODE_BL(mfd)) ||
+ || !mfd->allow_bl_update) && !IS_CALIB_MODE_BL(mfd) &&
+ !mfd->allow_secure_bl_update) ||
mfd->panel_info->cont_splash_enabled) {
mfd->unset_bl_level = bkl_lvl;
return;
} else if (mdss_fb_is_power_on(mfd) && mfd->panel_info->panel_dead) {
mfd->unset_bl_level = mfd->bl_level;
- } else {
+ } else if (!mfd->allow_secure_bl_update) {
mfd->unset_bl_level = U32_MAX;
}
@@ -1734,6 +1735,9 @@
&ad_bl_notify_needed);
if (!IS_CALIB_MODE_BL(mfd))
mdss_fb_scale_bl(mfd, &temp);
+
+ if (!temp && !mfd->allow_secure_bl_update && mfd->bl_level)
+ mfd->unset_bl_level = mfd->bl_level;
/*
* Even though backlight has been scaled, want to show that
* backlight has been set to bkl_lvl to those that read from
@@ -1914,7 +1918,8 @@
mfd->allow_bl_update = true;
mdss_fb_set_backlight(mfd, 0);
mfd->allow_bl_update = false;
- mfd->unset_bl_level = current_bl;
+ if (current_bl)
+ mfd->unset_bl_level = current_bl;
mutex_unlock(&mfd->bl_lock);
}
mfd->panel_power_state = req_power_state;
@@ -1960,6 +1965,8 @@
return 0;
}
+ mfd->allow_secure_bl_update = false;
+
if (mfd->mdp.on_fnc) {
struct mdss_panel_info *panel_info = mfd->panel_info;
struct fb_var_screeninfo *var = &mfd->fbi->var;
diff --git a/drivers/video/fbdev/msm/mdss_fb.h b/drivers/video/fbdev/msm/mdss_fb.h
index 38cf5f7..4b39f9e 100644
--- a/drivers/video/fbdev/msm/mdss_fb.h
+++ b/drivers/video/fbdev/msm/mdss_fb.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2008-2018,2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -322,6 +322,7 @@
struct mutex bl_lock;
struct mutex mdss_sysfs_lock;
bool ipc_resume;
+ bool allow_secure_bl_update;
struct platform_device *pdev;
diff --git a/drivers/video/fbdev/msm/mdss_spi_panel.c b/drivers/video/fbdev/msm/mdss_spi_panel.c
index 86a1c1c..e95dcd5 100644
--- a/drivers/video/fbdev/msm/mdss_spi_panel.c
+++ b/drivers/video/fbdev/msm/mdss_spi_panel.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018,2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -163,12 +163,14 @@
ctrl_pdata = container_of(pdata, struct spi_panel_data,
panel_data);
- ret = msm_mdss_enable_vreg(
- ctrl_pdata->panel_power_data.vreg_config,
- ctrl_pdata->panel_power_data.num_vreg, 1);
- if (ret) {
- pr_err("%s: failed to enable vregs for %s\n",
- __func__, "PANEL_PM");
+ if (!mdp3_res->secure_reg_on) {
+ ret = msm_mdss_enable_vreg(
+ ctrl_pdata->panel_power_data.vreg_config,
+ ctrl_pdata->panel_power_data.num_vreg, 1);
+ if (ret) {
+ pr_err("%s: failed to enable vregs for %s\n",
+ __func__, "PANEL_PM");
+ }
}
/*
@@ -213,12 +215,14 @@
if (mdss_spi_panel_pinctrl_set_state(ctrl_pdata, false))
pr_warn("reset disable: pinctrl not enabled\n");
- ret = msm_mdss_enable_vreg(
- ctrl_pdata->panel_power_data.vreg_config,
- ctrl_pdata->panel_power_data.num_vreg, 0);
- if (ret)
- pr_err("%s: failed to disable vregs for %s\n",
- __func__, "PANEL_PM");
+ if (!mdp3_res->secure_reg_on) {
+ ret = msm_mdss_enable_vreg(
+ ctrl_pdata->panel_power_data.vreg_config,
+ ctrl_pdata->panel_power_data.num_vreg, 0);
+ if (ret)
+ pr_err("%s: failed to disable vregs for %s\n",
+ __func__, "PANEL_PM");
+ }
end:
return ret;
@@ -1167,7 +1171,8 @@
static void mdss_spi_panel_bl_ctrl(struct mdss_panel_data *pdata,
u32 bl_level)
{
- if (bl_level) {
+ /* Allow panel backlight update if secure UI is enabled */
+ if (bl_level && !mdp3_res->secure_update_bl) {
mdp3_res->bklt_level = bl_level;
mdp3_res->bklt_update = true;
} else {
diff --git a/include/uapi/linux/msm_mdp.h b/include/uapi/linux/msm_mdp.h
index 8a0e4cf..9102741 100644
--- a/include/uapi/linux/msm_mdp.h
+++ b/include/uapi/linux/msm_mdp.h
@@ -7,6 +7,7 @@
#include <linux/types.h>
#endif
#include <linux/fb.h>
+#include <stdbool.h>
#define MSMFB_IOCTL_MAGIC 'm'
#define MSMFB_GRP_DISP _IOW(MSMFB_IOCTL_MAGIC, 1, unsigned int)
@@ -1275,6 +1276,8 @@
metadata_op_get_caps,
metadata_op_crc,
metadata_op_get_ion_fd,
+ metadata_op_secure_bl_set,
+ metadata_op_secure_reg,
metadata_op_max
};
@@ -1309,6 +1312,8 @@
struct mdss_hw_caps caps;
uint8_t secure_en;
int fbmem_ionfd;
+ bool sec_bl_update_en;
+ bool sec_reg_on;
} data;
};