Skip to content
2 changes: 2 additions & 0 deletions arch/arm64/configs/cm_oneplus2_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ CONFIG_SUSPEND=y
CONFIG_SUSPEND_FREEZER=y
CONFIG_HAS_WAKELOCK=y
CONFIG_WAKELOCK=y
CONFIG_POWERSUSPEND=y
# CONFIG_POWERSUSPEND_DEBUG is not set
CONFIG_PM_SLEEP=y
CONFIG_PM_SLEEP_SMP=y
CONFIG_PM_AUTOSLEEP=y
Expand Down
2 changes: 0 additions & 2 deletions drivers/input/misc/fpc1020.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,5 @@ typedef enum {
FPC1020_CHIP_1155X = 7
} fpc1020_chip_t;

extern unsigned int nav_switch;

#endif

3 changes: 3 additions & 0 deletions drivers/input/misc/fpc1020_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
/* -------------------------------------------------------------------- */
extern const bool target_little_endian;

extern unsigned int nav_switch;
extern unsigned int enable_keys;

#define FPC1020_DEV_NAME "fpc1020"
#define FPC1020_TOUCH_PAD_DEV_NAME "fpc1020tp"

Expand Down
16 changes: 5 additions & 11 deletions drivers/input/misc/fpc1020_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ static int fb_notifier_callback(struct notifier_block *self, unsigned long event
#endif

unsigned int nav_switch = 1;
unsigned int enable_keys = 1;

/* -------------------------------------------------------------------- */
/* External interface */
Expand Down Expand Up @@ -575,7 +576,6 @@ static ssize_t fpc1020_home_switch_store(struct device *dev, struct device_attri

//tmp = strsep((char **) &buf, "\n");
char *after;
unsigned long nav_switch = 0;

mutex_lock(&mLock);

Expand All @@ -584,7 +584,7 @@ static ssize_t fpc1020_home_switch_store(struct device *dev, struct device_attri

fpc1020 = dev_get_drvdata(dev);

dev_err(&fpc1020->spi->dev, "nav_switch change to %ld\n", nav_switch);
dev_err(&fpc1020->spi->dev, "nav_switch change to %d\n", nav_switch);

write_nav_switch(fpc1020);

Expand All @@ -597,7 +597,7 @@ static ssize_t fpc1020_home_switch_show(struct device *dev, struct device_attrib
fpc1020_data_t *fpc1020;
fpc1020 = dev_get_drvdata(dev);

return sprintf(buf, "%d", fpc1020->nav.enabled);
return sprintf(buf, "%d\n", fpc1020->nav.enabled);
}
//*/
static struct device_attribute fpc1020_state_attr =
Expand Down Expand Up @@ -938,8 +938,6 @@ static int /*__devexit*/ fpc1020_remove(struct spi_device *spi)
}

#if defined(CONFIG_FB)
static int enable_keys = 1;

static int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data)
{
struct fb_event *evdata = data;
Expand All @@ -954,17 +952,13 @@ static int fb_notifier_callback(struct notifier_block *self, unsigned long event
if( *blank == FB_BLANK_UNBLANK && (event == FB_EARLY_EVENT_BLANK )) {
dev_err(&fpc1020->spi->dev, "%s change to home key\n", __func__);
fpc1020->to_power = false;
if (enable_keys) nav_switch = 1;
enable_keys = 1;
} else if( *blank == FB_BLANK_POWERDOWN && (event == FB_EVENT_BLANK )) {
dev_err(&fpc1020->spi->dev, "%s change to power key\n", __func__);
fpc1020->to_power = true;
if (!nav_switch) enable_keys = 0;
nav_switch = 0;
enable_keys = 0;
}
}

if (enable_keys) write_nav_switch(fpc1020);
if (!fpc1020->to_power) enable_keys = 1;
return 0;
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions drivers/input/misc/fpc1020_nav.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ static int fpc1020_wait_finger_present_lpm(fpc1020_data_t *fpc1020)
input_report_key(fpc1020->input_dev,
FPC1020_KEY_FINGER_PRESS, 1);
input_sync(fpc1020->input_dev);
}else{
}else if (enable_keys) {
wake_lock_timeout(&fpc1020_wake_lock,5*HZ);
input_report_key(fpc1020->input_dev,
KEY_HOME, 1);
Expand Down Expand Up @@ -962,7 +962,7 @@ static int fpc1020_wait_finger_present_lpm(fpc1020_data_t *fpc1020)
input_report_key(fpc1020->input_dev,
FPC1020_KEY_FINGER_PRESS, 0);
input_sync(fpc1020->input_dev);
}else{
}else if (enable_keys) {
input_report_key(fpc1020->input_dev,
KEY_HOME, 0);
input_sync(fpc1020->input_dev);
Expand Down
4 changes: 2 additions & 2 deletions drivers/input/touchscreen/synaptics_driver_s1302.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#include <linux/input/mt.h>

#include "synaptics_s1302_redremote.h"
#include "../misc/fpc1020.h"
#include "../misc/fpc1020_common.h"
#include <linux/boot_mode.h>
#include <linux/project_info.h>
/*------------------------------------------------Global Define--------------------------------------------*/
Expand Down Expand Up @@ -672,7 +672,7 @@ static void int_key(struct synaptics_ts_data *ts )
int ret;
int button_key;

if (!nav_switch)
if (!nav_switch || !enable_keys)
return;

ret = synaptics_rmi4_i2c_write_byte(ts->client, 0xff, 0x02 );
Expand Down
12 changes: 12 additions & 0 deletions drivers/video/msm/mdss/mdss_dsi_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include "mdss_dsi.h"
#include "mdss_mdp.h"

#ifdef CONFIG_POWERSUSPEND
#include <linux/powersuspend.h>
#endif

#define DT_CMD_HDR 6
#define MIN_REFRESH_RATE 30

Expand Down Expand Up @@ -953,6 +957,10 @@ static int mdss_dsi_panel_on(struct mdss_panel_data *pdata)
return -EINVAL;
}

#ifdef CONFIG_POWERSUSPEND
set_power_suspend_state_panel_hook(POWER_SUSPEND_INACTIVE);
#endif

pinfo = &pdata->panel_info;
ctrl = container_of(pdata, struct mdss_dsi_ctrl_pdata,
panel_data);
Expand Down Expand Up @@ -1080,6 +1088,10 @@ static int mdss_dsi_panel_off(struct mdss_panel_data *pdata)
// printk("%s: after sleep Reg 0A 0x%02x\n", __func__, rx_buf[0]);
// mdss_debug_enable_clock(0);

#ifdef CONFIG_POWERSUSPEND
set_power_suspend_state_panel_hook(POWER_SUSPEND_ACTIVE);
#endif

end:
pinfo->blank_state = MDSS_PANEL_BLANK_BLANK;
pr_debug("%s:-\n", __func__);
Expand Down
42 changes: 42 additions & 0 deletions include/linux/powersuspend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* include/linux/powersuspend.h
*
* Copyright (C) 2007-2008 Google, Inc.
* Copyright (C) 2013 Paul Reioux
*
* Modified by Jean-Pierre Rasquin <[email protected]>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/

#ifndef _LINUX_POWERSUSPEND_H
#define _LINUX_POWERSUSPEND_H

#include <linux/list.h>

#define POWER_SUSPEND_INACTIVE 0
#define POWER_SUSPEND_ACTIVE 1

#define POWER_SUSPEND_USERSPACE 1 // Use fauxclock as trigger
#define POWER_SUSPEND_PANEL 2 // Use display panel state as hook

struct power_suspend {
struct list_head link;
void (*suspend)(struct power_suspend *h);
void (*resume)(struct power_suspend *h);
};

void register_power_suspend(struct power_suspend *handler);
void unregister_power_suspend(struct power_suspend *handler);

void set_power_suspend_state_panel_hook(int new_state);

#endif

13 changes: 13 additions & 0 deletions kernel/power/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ config WAKELOCK
bool
default y

config POWERSUSPEND
bool "Power suspend"
default y
---help---
Call early suspend handlers when the user requested sleep state
changes.

config POWERSUSPEND_DEBUG
bool "Powersuspend driver debugging code"
depends on POWERSUSPEND
help
Output debugging info in dmesg [POWERSUSPEND] (Yank555.lu)

config HIBERNATE_CALLBACKS
bool

Expand Down
1 change: 1 addition & 0 deletions kernel/power/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ obj-$(CONFIG_SUSPEND) += suspend.o
obj-$(CONFIG_PM_TEST_SUSPEND) += suspend_test.o
obj-$(CONFIG_HIBERNATION) += hibernate.o snapshot.o swap.o user.o \
block_io.o
obj-$(CONFIG_POWERSUSPEND) += powersuspend.o
obj-$(CONFIG_PM_AUTOSLEEP) += autosleep.o
obj-$(CONFIG_PM_WAKELOCKS) += wakelock.o
obj-$(CONFIG_SUSPEND_TIME) += suspend_time.o
Expand Down
Loading