Skip to content

Commit

Permalink
os/driver/input/ist415: Change to power off when touch disabling
Browse files Browse the repository at this point in the history
Change to tunr off ist415 power when touch is disabled from apps
for reduce power consumption.

Signed-off-by: eunwoo.nam <[email protected]>
  • Loading branch information
ewoodev authored and sunghan-chang committed Feb 26, 2025
1 parent 8422547 commit b2942f8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
44 changes: 37 additions & 7 deletions os/drivers/input/ist415.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,11 @@ static int ist415_suspend_device(struct touchscreen_s *upper)
ASSERT(get_errno() == EINTR);
}

if (dev->forcedoff) {
sem_post(&dev->sem);
return EPERM;
}

dev->suspend = true;

if (dev->knockknock) {
Expand Down Expand Up @@ -571,6 +576,11 @@ static int ist415_resume_device(struct touchscreen_s *upper)
ASSERT(get_errno() == EINTR);
}

if (dev->forcedoff) {
sem_post(&dev->sem);
return ESHUTDOWN;
}

dev->suspend = false;

if (dev->knockknock) {
Expand All @@ -596,10 +606,18 @@ static void ist415_disable_touch(struct touchscreen_s *upper)
{
struct ist415_dev_s *dev = upper->priv;
ist415vdbg("%s\n", __func__);
ist415_suspend_device(upper);
if (dev->knockknock) {
ist415_disable(upper->priv);

while (sem_wait(&dev->sem) != OK) {
ASSERT(get_errno() == EINTR);
}

dev->forcedoff = true;
ist415_disable(dev);
ist415_power_off(dev);

ist415_forced_release(dev);

sem_post(&dev->sem);
}

/****************************************************************************
Expand All @@ -610,10 +628,18 @@ static void ist415_enable_touch(struct touchscreen_s *upper)
{
struct ist415_dev_s *dev = upper->priv;
ist415vdbg("%s\n", __func__);
ist415_resume_device(upper);
if (dev->knockknock) {
ist415_enable(upper->priv);

while (sem_wait(&dev->sem) != OK) {
ASSERT(get_errno() == EINTR);
}

dev->forcedoff = false;
dev->suspend = false;
ist415_reset(dev, false);
ist415_enable(dev);
ist415_start(dev);

sem_post(&dev->sem);
}

/****************************************************************************
Expand Down Expand Up @@ -669,7 +695,10 @@ static void ist415_lockup_work(struct ist415_dev_s *dev)
ist415_disable(dev);
ist415_forced_release(dev);
ist415_reset(dev, false);
if (dev->suspend) {

if (dev->forcedoff) {
ist415_power_off(dev);
} else if (dev->suspend) {
if (dev->knockknock) {
if (dev->sys_mode == SYS_MODE_LPM) {
ist415_power_mode(dev, dev->sys_mode);
Expand Down Expand Up @@ -1150,6 +1179,7 @@ int ist415_initialize(const char *path, struct i2c_dev_s *i2c, struct ist415_con
dev->enable = false;
dev->pre_enable = false;
dev->suspend = false;
dev->forcedoff = false;
dev->log = IST415_LOG_LEVEL_ERRO;

dev->sys_mode = SYS_MODE_TOUCH;
Expand Down
1 change: 1 addition & 0 deletions os/drivers/input/ist415.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ struct ist415_dev_s {

uint8_t sys_mode; /* System Mode (NPM or LPM) */
uint16_t touch_type; /* Touch Type */
bool forcedoff;
bool knockknock;

bool touched[TOUCH_MAX_POINTS];
Expand Down

0 comments on commit b2942f8

Please sign in to comment.