Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0e2306a authored by Aravind Venkateswaran's avatar Aravind Venkateswaran Committed by Gerrit - the friendly Code Review server
Browse files

msm: mdss: fix fb device pm suspend and resume handlers



Under normal circumstances, the framebuffer device should have been
blanked or configured to a low power mode prior to the pm suspend
callback getting executed. In cases when this sequence is not followed,
blank the framebuffer as part of pm suspend handler to ensure that all
display resources are freed. Similarly, if the framebuffer was
explicitly blanked during suspend, then unblank it when resuming. This
also eliminates the need for the existing sysfs node to indicate
always-on display mode.

Change-Id: I1613f5eba420c9587af2ecb04bc5cb115b7a1095
Signed-off-by: default avatarAravind Venkateswaran <aravindh@codeaurora.org>
parent db3712f7
Loading
Loading
Loading
Loading
+19 −54
Original line number Diff line number Diff line
@@ -596,38 +596,6 @@ static ssize_t mdss_fb_get_src_split_info(struct device *dev,
	return ret;
}

static ssize_t mdss_fb_set_doze_mode(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t count)
{
	struct fb_info *fbi = dev_get_drvdata(dev);
	struct msm_fb_data_type *mfd = fbi->par;
	int rc = 0;
	int doze_mode = 0;

	rc = kstrtoint(buf, 10, &doze_mode);
	if (rc) {
		pr_err("kstrtoint failed. rc=%d\n", rc);
		return rc;
	}

	pr_debug("Always-on mode %s\n", doze_mode ? "enabled" : "disabled");
	if (mfd->panel_info->type !=  MIPI_CMD_PANEL)
		pr_err("Always on mode only supported for cmd mode panel\n");
	else
		mfd->doze_mode = doze_mode;

	return count;
}

static ssize_t mdss_fb_get_doze_mode(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	struct fb_info *fbi = dev_get_drvdata(dev);
	struct msm_fb_data_type *mfd = fbi->par;

	return scnprintf(buf, PAGE_SIZE, "%d\n", mfd->doze_mode);
}

static DEVICE_ATTR(msm_fb_type, S_IRUGO, mdss_fb_get_type, NULL);
static DEVICE_ATTR(msm_fb_split, S_IRUGO | S_IWUSR, mdss_fb_show_split,
					mdss_fb_store_split);
@@ -640,8 +608,6 @@ static DEVICE_ATTR(msm_fb_src_split_info, S_IRUGO, mdss_fb_get_src_split_info,
	NULL);
static DEVICE_ATTR(msm_fb_thermal_level, S_IRUGO | S_IWUSR,
	mdss_fb_get_thermal_level, mdss_fb_set_thermal_level);
static DEVICE_ATTR(always_on, S_IRUGO | S_IWUSR | S_IWGRP,
	mdss_fb_get_doze_mode, mdss_fb_set_doze_mode);

static struct attribute *mdss_fb_attrs[] = {
	&dev_attr_msm_fb_type.attr,
@@ -652,7 +618,6 @@ static struct attribute *mdss_fb_attrs[] = {
	&dev_attr_msm_fb_panel_info.attr,
	&dev_attr_msm_fb_src_split_info.attr,
	&dev_attr_msm_fb_thermal_level.attr,
	&dev_attr_always_on.attr,
	NULL,
};

@@ -884,18 +849,18 @@ static int mdss_fb_suspend_sub(struct msm_fb_data_type *mfd)

	if (mfd->op_enable) {
		/*
		 * Ideally, display should have been blanked by now.
		 * If not, then blank the display based on whether always-on
		 * feature is enabled or not
		 * Ideally, display should have either been blanked by now, or
		 * should have transitioned to a low power state. If not, then
		 * as a fall back option, blank the display.
		 */
		int unblank_flag = mfd->doze_mode ? FB_BLANK_VSYNC_SUSPEND :
			FB_BLANK_POWERDOWN;
		ret = mdss_fb_blank_sub(unblank_flag, mfd->fbi,
		if (mdss_fb_is_power_on_interactive(mfd)) {
			ret = mdss_fb_blank_sub(FB_BLANK_POWERDOWN, mfd->fbi,
					mfd->suspend.op_enable);
			if (ret) {
			pr_warn("can't turn off display!\n");
				pr_err("can't turn off display!\n");
				return ret;
			}
		}
		mfd->op_enable = false;
		fb_set_suspend(mfd->fbi, FBINFO_STATE_SUSPENDED);
	}
@@ -924,9 +889,16 @@ static int mdss_fb_resume_sub(struct msm_fb_data_type *mfd)
	/* resume state var recover */
	mfd->op_enable = mfd->suspend.op_enable;

	/*
	 * If the fb was explicitly blanked during suspend, then unblank it
	 * during resume.
	 */
	if (mdss_panel_is_power_on(mfd->suspend.panel_power_state)) {
		ret = mdss_fb_blank_sub(FB_BLANK_UNBLANK, mfd->fbi,
					mfd->op_enable);
		int unblank_flag = mdss_panel_is_power_on_interactive(
			mfd->suspend.panel_power_state) ? FB_BLANK_UNBLANK :
			FB_BLANK_VSYNC_SUSPEND;

		ret = mdss_fb_blank_sub(unblank_flag, mfd->fbi, mfd->op_enable);
		if (ret)
			pr_warn("can't turn on display!\n");
		else
@@ -1061,13 +1033,6 @@ void mdss_fb_set_backlight(struct msm_fb_data_type *mfd, u32 bkl_lvl)
	int ret = -EINVAL;
	bool bl_notify_needed = false;

	/* todo: temporary workaround to support doze mode */
	if ((bkl_lvl == 0) && (mfd->doze_mode)) {
		pr_debug("keeping backlight on with always-on displays\n");
		mfd->unset_bl_level = 0;
		return;
	}

	if (((mdss_fb_is_power_off(mfd) && mfd->dcm_state != DCM_ENTER)
		|| !mfd->bl_updated) && !IS_CALIB_MODE_BL(mfd) &&
		mfd->panel_info->cont_splash_enabled) {
+0 −1
Original line number Diff line number Diff line
@@ -273,7 +273,6 @@ struct msm_fb_data_type {

	u32 wait_for_kickoff;
	u32 thermal_level;
	int doze_mode;
};

static inline void mdss_fb_update_notify_update(struct msm_fb_data_type *mfd)