Skip to content

Commit

Permalink
Revert "drm: msm: modify doze backlight sysfs"
Browse files Browse the repository at this point in the history
This reverts commit ae5d796.

Signed-off-by: UtsavBalar1231 <[email protected]>
  • Loading branch information
UtsavBalar1231 committed Aug 18, 2020
1 parent 8e78e6d commit 0cf9e0d
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 195 deletions.
64 changes: 11 additions & 53 deletions drivers/gpu/drm/drm_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ static ssize_t panel_info_show(struct device *device,
return written;
}

static ssize_t doze_brightness_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct drm_connector *connector = to_drm_connector(device);
struct drm_device *dev = connector->dev;

return snprintf(buf, PAGE_SIZE, "%d\n",
dev->doze_brightness);
}

void drm_bridge_disp_param_set(struct drm_bridge *bridge, int cmd);
static ssize_t disp_param_store(struct device *device,
struct device_attribute *attr,
Expand Down Expand Up @@ -291,57 +302,6 @@ static ssize_t disp_param_store(struct device *device,
return count;
}

int dsi_bridge_disp_set_doze_backlight(struct drm_connector *connector,
int doze_backlight);
ssize_t dsi_bridge_disp_get_doze_backlight(struct drm_connector *connector,
char *buf);
static ssize_t doze_brightness_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
int writen = 0;
struct drm_connector *connector = NULL;
struct drm_device *dev = NULL;

if (!device)
return writen;

connector = to_drm_connector(device);
if (!connector)
return writen;

dev = connector->dev;
if (!dev)
return writen;

return snprintf(buf, PAGE_SIZE, "%d\n",
dev->doze_brightness);
}

static ssize_t doze_backlight_store(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct drm_connector *connector = to_drm_connector(device);
int doze_backlight;
int ret;

ret = kstrtoint(buf, 0, &doze_backlight);
if (ret)
return ret;

ret = dsi_bridge_disp_set_doze_backlight(connector, doze_backlight);

return ret ? ret : count;
}

static ssize_t doze_backlight_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct drm_connector *connector = to_drm_connector(dev);
return dsi_bridge_disp_get_doze_backlight(connector, buf);
}

extern ssize_t mipi_reg_write(char *buf, size_t count);
extern ssize_t mipi_reg_read(char *buf);

Expand Down Expand Up @@ -498,7 +458,6 @@ static DEVICE_ATTR_RO(modes);
static DEVICE_ATTR_RO(panel_info);
static DEVICE_ATTR_WO(disp_param);
static DEVICE_ATTR_RO(doze_brightness);
static DEVICE_ATTR_RW(doze_backlight);
static DEVICE_ATTR_RW(mipi_reg);
static DEVICE_ATTR_RW(disp_count);
static DEVICE_ATTR_RW(dim_layer_enable);
Expand All @@ -514,7 +473,6 @@ static struct attribute *connector_dev_attrs[] = {
&dev_attr_panel_info.attr,
&dev_attr_disp_param.attr,
&dev_attr_doze_brightness.attr,
&dev_attr_doze_backlight.attr,
&dev_attr_mipi_reg.attr,
&dev_attr_disp_count.attr,
&dev_attr_dim_layer_enable.attr,
Expand Down
25 changes: 14 additions & 11 deletions drivers/gpu/drm/msm/dsi-staging/dsi_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,19 @@ int dsi_display_set_backlight(struct drm_connector *connector,
goto error;
}

rc = dsi_panel_set_backlight(panel, (u32)bl_temp);
if (rc)
pr_err("unable to set backlight\n");

if (drm_dev && (drm_dev->doze_state == MSM_DRM_BLANK_LP1 || drm_dev->doze_state == MSM_DRM_BLANK_LP2)) {
rc = dsi_panel_set_doze_backlight(display, (u32)bl_temp);
if (rc)
pr_err("unable to set doze backlight\n");
rc = dsi_panel_enable_doze_backlight(panel, (u32)bl_temp);
if (rc)
pr_err("unable to enable doze backlight\n");
} else {
drm_dev->doze_brightness = DOZE_BRIGHTNESS_INVALID;
rc = dsi_panel_set_backlight(panel, (u32)bl_temp);
if (rc)
pr_err("unable to set backlight\n");
}
rc = dsi_display_clk_ctrl(dsi_display->dsi_clk_handle,
DSI_CORE_CLK, DSI_CLK_OFF);
if (rc) {
Expand Down Expand Up @@ -1259,7 +1268,7 @@ int dsi_display_set_power(struct drm_connector *connector,
return -EINVAL;
} else {
dev = connector->dev;
event = dev->state;
event = dev->doze_state;
}

g_notify_data.data = &event;
Expand All @@ -1268,24 +1277,18 @@ int dsi_display_set_power(struct drm_connector *connector,
case SDE_MODE_DPMS_LP1:
msm_drm_notifier_call_chain(MSM_DRM_EARLY_EVENT_BLANK, &g_notify_data);
rc = dsi_panel_set_lp1(display->panel);
if (!rc)
dsi_panel_set_doze_backlight(display);
msm_drm_notifier_call_chain(MSM_DRM_EVENT_BLANK, &g_notify_data);
break;
case SDE_MODE_DPMS_LP2:
msm_drm_notifier_call_chain(MSM_DRM_EARLY_EVENT_BLANK, &g_notify_data);
rc = dsi_panel_set_lp2(display->panel);
if (!rc)
dsi_panel_set_doze_backlight(display);
msm_drm_notifier_call_chain(MSM_DRM_EVENT_BLANK, &g_notify_data);
break;
case SDE_MODE_DPMS_ON:
if (display->panel->power_mode == SDE_MODE_DPMS_LP1 ||
display->panel->power_mode == SDE_MODE_DPMS_LP2) {
msm_drm_notifier_call_chain(MSM_DRM_EARLY_EVENT_BLANK, &g_notify_data);
rc = dsi_panel_set_nolp(display->panel);
if (!rc)
dsi_panel_set_doze_backlight(display);
msm_drm_notifier_call_chain(MSM_DRM_EVENT_BLANK, &g_notify_data);
}
break;
Expand Down
9 changes: 1 addition & 8 deletions drivers/gpu/drm/msm/dsi-staging/dsi_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,7 @@ void dsi_display_enable_event(struct drm_connector *connector,
int dsi_display_set_backlight(struct drm_connector *connector,
void *display, u32 bl_lvl);

/**
* dsi_display_set_doze_backlight() - set doze backlight
* @display: Handle to display.
*/

int dsi_panel_set_doze_backlight(struct dsi_display *display);

ssize_t dsi_panel_get_doze_backlight(struct dsi_display *display, char *buf);
int dsi_panel_set_doze_backlight(struct dsi_display *display, u32 bl_lvl);

/**
* dsi_display_check_status() - check if panel is dead or alive
Expand Down
63 changes: 8 additions & 55 deletions drivers/gpu/drm/msm/dsi-staging/dsi_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ static void dsi_bridge_pre_enable(struct drm_bridge *bridge)
struct drm_device *dev = bridge->dev;
int event = 0;

if (dev->state == MSM_DRM_BLANK_POWERDOWN) {
dev->state = MSM_DRM_BLANK_UNBLANK;
if (dev->doze_state == MSM_DRM_BLANK_POWERDOWN) {
dev->doze_state = MSM_DRM_BLANK_UNBLANK;
pr_info("%s power on from power off\n", __func__);
}

event = dev->state;
event = dev->doze_state;

g_notify_data.data = &event;

Expand All @@ -223,7 +223,7 @@ static void dsi_bridge_pre_enable(struct drm_bridge *bridge)
cancel_delayed_work_sync(&prim_panel_work);
__pm_relax(&prim_panel_wakelock);
if (dev->fp_quickon &&
(dev->state == MSM_DRM_BLANK_LP1 || dev->state == MSM_DRM_BLANK_LP2)) {
(dev->doze_state == MSM_DRM_BLANK_LP1 || dev->doze_state == MSM_DRM_BLANK_LP2)) {
event = MSM_DRM_BLANK_POWERDOWN;
msm_drm_notifier_call_chain(MSM_DRM_EARLY_EVENT_BLANK, &g_notify_data);
msm_drm_notifier_call_chain(MSM_DRM_EVENT_BLANK, &g_notify_data);
Expand Down Expand Up @@ -364,53 +364,6 @@ static int dsi_bridge_get_panel_info(struct drm_bridge *bridge, char *buf)
return rc;
}

int dsi_panel_set_doze_backlight(struct dsi_display *display);

ssize_t dsi_panel_get_doze_backlight(struct dsi_display *display, char *buf);

int dsi_bridge_disp_set_doze_backlight(struct drm_connector *connector,
int doze_backlight)
{
struct dsi_display *display = NULL;
struct dsi_bridge *c_bridge = NULL;

if (!connector || !connector->encoder || !connector->encoder->bridge) {
pr_err("Invalid connector/encoder/bridge ptr\n");
return -EINVAL;
}

c_bridge = to_dsi_bridge(connector->encoder->bridge);
display = c_bridge->display;
if (!display || !display->panel || !display->drm_dev) {
pr_err("Invalid display/panel/drm_dev ptr\n");
return -EINVAL;
} else
display->drm_dev->doze_brightness = doze_backlight;

return dsi_panel_set_doze_backlight(display);
}

ssize_t dsi_bridge_disp_get_doze_backlight(struct drm_connector *connector,
char *buf)
{
struct dsi_display *display = NULL;
struct dsi_bridge *c_bridge = NULL;

if (!connector || !connector->encoder || !connector->encoder->bridge) {
pr_err("Invalid connector/encoder/bridge ptr\n");
return -EINVAL;
}

c_bridge = to_dsi_bridge(connector->encoder->bridge);
display = c_bridge->display;
if (!display || !display->panel) {
pr_err("Invalid display/panel ptr\n");
return -EINVAL;
}

return dsi_panel_get_doze_backlight(display, buf);
}

static void dsi_bridge_enable(struct drm_bridge *bridge)
{
int rc = 0;
Expand Down Expand Up @@ -468,12 +421,12 @@ static void dsi_bridge_post_disable(struct drm_bridge *bridge)
struct drm_device *dev = bridge->dev;
int event = 0;

if (dev->state == MSM_DRM_BLANK_UNBLANK) {
dev->state = MSM_DRM_BLANK_POWERDOWN;
if (dev->doze_state == MSM_DRM_BLANK_UNBLANK) {
dev->doze_state = MSM_DRM_BLANK_POWERDOWN;
pr_info("%s wrong doze state\n", __func__);
}

event = dev->state;
event = dev->doze_state;

g_notify_data.data = &event;

Expand All @@ -487,7 +440,7 @@ static void dsi_bridge_post_disable(struct drm_bridge *bridge)
return;
}

if (dev->state == MSM_DRM_BLANK_LP1 || dev->state == MSM_DRM_BLANK_LP2) {
if (dev->doze_state == MSM_DRM_BLANK_LP1 || dev->doze_state == MSM_DRM_BLANK_LP2) {
pr_err("%s doze state can't power off panel\n", __func__);
event = MSM_DRM_BLANK_POWERDOWN;
msm_drm_notifier_call_chain(MSM_DRM_EARLY_EVENT_BLANK, &g_notify_data);
Expand Down
Loading

0 comments on commit 0cf9e0d

Please sign in to comment.