Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/driver/input/ist415: Change to power off when touch disabling #6697

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions os/drivers/input/ist415.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,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 @@ -568,6 +573,11 @@ static int ist415_resume_device(struct touchscreen_s *upper)
ASSERT(get_errno() == EINTR);
}

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

dev->suspend = false;

if (dev->knockknock) {
Expand All @@ -593,10 +603,16 @@ 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);

sem_post(&dev->sem);
}

/****************************************************************************
Expand All @@ -607,10 +623,17 @@ 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;
ist415_reset(dev, false);
ist415_enable(dev);
ist415_start(dev);

sem_post(&dev->sem);
}

/****************************************************************************
Expand Down Expand Up @@ -666,7 +689,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 @@ -1147,6 +1173,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