-
Notifications
You must be signed in to change notification settings - Fork 594
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
Add ist415 semaphore and recording mode. #6626
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,6 +336,10 @@ static int ist415_process_event(struct ist415_dev_s *dev) | |
|
||
kmm_free(touch_event); | ||
|
||
if (dev->rec_mode) { | ||
ist415_recording(dev); | ||
} | ||
|
||
return OK; | ||
} | ||
|
||
|
@@ -406,6 +410,8 @@ static int ist415_cmd(struct touchscreen_s *upper, int argc, char **argv) | |
ret = ist415_set_dbg(dev, argc, argv); | ||
} else if (strncmp(argv[1], "selftest", 9) == 0) { | ||
ist415_selftest(dev); | ||
} else if (strncmp(argv[1], "rec", 4) == 0) { | ||
ret = ist415_rec_mode(dev, argc, argv); | ||
} else { | ||
ret = -EINVAL; | ||
} | ||
|
@@ -490,6 +496,10 @@ static void ist415_stop_device(struct ist415_dev_s *dev) | |
{ | ||
ist415vdbg("%s\n", __func__); | ||
|
||
while (sem_wait(&dev->sem) != OK) { | ||
ASSERT(get_errno() == EINTR); | ||
} | ||
|
||
dev->suspend = true; | ||
|
||
if (dev->knockknock) { | ||
|
@@ -503,6 +513,10 @@ static void ist415_stop_device(struct ist415_dev_s *dev) | |
ist415_disable(dev); | ||
ist415_power_off(dev); | ||
} | ||
|
||
ist415_forced_release(dev); | ||
|
||
sem_post(&dev->sem); | ||
} | ||
|
||
/**************************************************************************** | ||
|
@@ -513,6 +527,10 @@ static void ist415_start_device(struct ist415_dev_s *dev) | |
{ | ||
ist415vdbg("%s\n", __func__); | ||
|
||
while (sem_wait(&dev->sem) != OK) { | ||
ASSERT(get_errno() == EINTR); | ||
} | ||
|
||
dev->suspend = false; | ||
|
||
if (dev->knockknock) { | ||
|
@@ -525,6 +543,8 @@ static void ist415_start_device(struct ist415_dev_s *dev) | |
ist415_enable(dev); | ||
ist415_start(dev); | ||
} | ||
|
||
sem_post(&dev->sem); | ||
} | ||
|
||
/**************************************************************************** | ||
|
@@ -553,10 +573,10 @@ static void ist415_enable_touch(struct touchscreen_s *upper) | |
* Name: ist415_lockup_work | ||
****************************************************************************/ | ||
|
||
static void ist415_lookup_work(struct ist415_dev_s *dev) | ||
static void ist415_lockup_work(struct ist415_dev_s *dev) | ||
{ | ||
u32 touch_status = 0; | ||
u32 scan_count = 0; | ||
uint32_t touch_status = 0; | ||
uint32_t scan_count = 0; | ||
int ret = 0; | ||
|
||
if (dev->irq_working == false) { | ||
|
@@ -595,6 +615,10 @@ static void ist415_lookup_work(struct ist415_dev_s *dev) | |
dev->alive_retry++; | ||
ist415dbg("Retry touch status(%d)\n", dev->alive_retry); | ||
if (dev->alive_retry == IST415_MAX_ALIVE_CNT) { | ||
while (sem_wait(&dev->sem) != OK) { | ||
ASSERT(get_errno() == EINTR); | ||
} | ||
|
||
ist415_disable(dev); | ||
ist415_forced_release(dev); | ||
ist415_reset(dev, false); | ||
|
@@ -615,8 +639,11 @@ static void ist415_lookup_work(struct ist415_dev_s *dev) | |
ist415_start(dev); | ||
ist415_enable(dev); | ||
} | ||
|
||
dev->alive_retry = 0; | ||
dev->scan_count = 0; | ||
|
||
sem_post(&dev->sem); | ||
} else { | ||
(void)wd_start(dev->wdog, MSEC2TICK(IST415_LOOKUP_RETRY_MS), (wdentry_t)ist415_timer_handler, 1, (uint32_t)dev); | ||
} | ||
|
@@ -630,7 +657,7 @@ static void ist415_timer_handler(int argc, uint32_t arg1) | |
{ | ||
struct ist415_dev_s *dev = (struct ist415_dev_s *)arg1; | ||
|
||
work_queue(HPWORK, &dev->work, (worker_t)ist415_lookup_work, dev, 0); | ||
work_queue(HPWORK, &dev->work, (worker_t)ist415_lockup_work, dev, 0); | ||
} | ||
|
||
/**************************************************************************** | ||
|
@@ -672,7 +699,7 @@ static int ist415_event_thread(int argc, char **argv) | |
if (ist415_process_event(dev) != OK) { | ||
ist415dbg("Fail to process event\n"); | ||
} | ||
|
||
dev->irq_working = false; | ||
dev->lower->ops->irq_enable(dev->lower); | ||
} | ||
|
@@ -1076,7 +1103,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->log = IST415_LOG_LEVEL_ERRO; | ||
dev->log = IST415_LOG_LEVEL_INFO; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't set the log level to default info because this may cause performance degradation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I didn't check. |
||
|
||
dev->sys_mode = SYS_MODE_TOUCH; | ||
dev->touch_type = (1 << TOUCH_TYPE_NORMAL) | (1 << TOUCH_TYPE_WET) | (1 << TOUCH_TYPE_PALMLARGE); | ||
|
@@ -1105,6 +1132,9 @@ int ist415_initialize(const char *path, struct i2c_dev_s *i2c, struct ist415_con | |
|
||
ist415_disable(dev); | ||
|
||
// Semaphore reset scenario | ||
sem_init(&dev->sem, 0, 1); | ||
|
||
dev->lower->handler = touch_interrupt; | ||
sem_init(&dev->wait_irq, 0, 0); | ||
itoa((int)dev, parm_buf, 16); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It call ASSERT, not retry, is it right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it's checking errno == EINTR. sem_wait fail case must be EINTR only. If not system is corrupted