-
Notifications
You must be signed in to change notification settings - Fork 579
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/drivers/input/: Add callback functionality to notify touch interrupt to application for touch driver ist415, touch HAL layer #6539
Conversation
apps/examples/lcd_test/example_lcd.c
Outdated
int ret = ioctl(touch_fd, TSIOC_SETAPPNOTIFY, &touch_set_callback); | ||
if (ret != OK) { | ||
printf("ERROR: Touch callback register from application to touch driver failed\n"); | ||
return; |
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.
close(touch_fd) before return
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.
Fixed
882d68b
to
07a1610
Compare
|
||
#elif CONFIG_TOUCH_CALLBACK | ||
|
||
touch_set_callback.touch_points = (struct touch_sample_s *)malloc(sizeof(struct touch_sample_s)); |
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.
Should free it when task end or operation below failed
07a1610
to
7813c5f
Compare
@@ -85,7 +85,9 @@ | |||
#define TSIOC_GETFREQUENCY _TSIOC(0x0004) /* arg: Pointer to uint32_t frequency value */ | |||
#define TSIOC_DISABLE _TSIOC(0x0005) /* Disable touch interrupt */ | |||
#define TSIOC_ENABLE _TSIOC(0x0006) /* Enable touch interrupt */ | |||
|
|||
#ifdef CONFIG_TOUCH_CALLBACK | |||
#define TSIOC_SETAPPNOTIFY _TSIOC(0x0008) /* arg: Pointer to struct touch_set_callback_s */ |
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.
address will be 0x0007
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.
fixed
apps/examples/lcd_test/example_lcd.c
Outdated
@@ -446,8 +510,15 @@ int lcd_test_main(int argc, char *argv[]) | |||
} | |||
test_fps(); | |||
close(fd); | |||
errout: |
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 will not always errout case
this line could execute in OK case also.
change the name errout
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.
fixed
apps/examples/lcd_test/example_lcd.c
Outdated
free(touch_set_callback.touch_points); | ||
return; | ||
} | ||
|
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.
remove all extra lines in # ifdefines
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.
fixed
apps/examples/lcd_test/example_lcd.c
Outdated
@@ -370,6 +374,9 @@ static void test_fps(void) | |||
} | |||
|
|||
#ifdef CONFIG_TOUCH | |||
|
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.
remove the extra line
apps/examples/lcd_test/example_lcd.c
Outdated
@@ -370,6 +374,9 @@ static void test_fps(void) | |||
} | |||
|
|||
#ifdef CONFIG_TOUCH | |||
|
|||
#ifdef CONFIG_TOUCH_POLL | |||
|
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.
remove the extra line
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.
fixed
apps/examples/lcd_test/example_lcd.c
Outdated
@@ -85,6 +85,10 @@ static int yres; | |||
#define EXAMPLE_LCD_FPS_TEST 5000 | |||
#endif | |||
|
|||
#if defined(CONFIG_TOUCH) && defined(CONFIG_TOUCH_CALLBACK) |
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.
You can keep defined(CONFIG_TOUCH_CALLBACK)
only. Because it can be enabled only when the CONFIG_TOUCH is enabled.
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.
fixed
apps/examples/lcd_test/example_lcd.c
Outdated
@@ -408,6 +415,37 @@ static void touch_test(void) | |||
} | |||
close(fd); | |||
} | |||
|
|||
#elif CONFIG_TOUCH_CALLBACK |
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.
This should be #elif defined(CONFIG_...)
. This is wrong usage of the config.
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.
fixed
apps/examples/lcd_test/example_lcd.c
Outdated
touch_set_callback.touch_points = (struct touch_sample_s *)malloc(sizeof(struct touch_sample_s)); | ||
if (!touch_set_callback.touch_points) { | ||
printf("Error: Touch point buffer memory allocation failed\n"); | ||
return; |
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.
This function return type is int, not void. So you should return -1 or something else.
Same as other returns in the function.
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.
fixed
os/drivers/input/Kconfig
Outdated
prompt "choose TOUCH DEVICE app notification type" | ||
default TOUCH_POLL | ||
---help--- | ||
Polling based notification to application |
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.
This help sentence is for TOUCH_POLL
, not for the choice.
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.
fixed
os/drivers/input/ist415.c
Outdated
@@ -135,6 +147,12 @@ static int ist415_get_touch_data(struct ist415_dev_s *dev, FAR void *buf) | |||
} | |||
touchvdbg("touch_point %d\n", touch_point + 1); | |||
|
|||
#ifdef CONFIG_TOUCH_CALLBACK |
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.
line 156 is not in this conditional. Do we need to add this conditional here only?
This new code looks not releated with callback config.
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.
In case of TOUCH_POLL we have handle buffer NULL condition inside function touch read()
but in case of TOUCH_CALLBACK this function is getting directly called from here (
TizenRT/os/drivers/input/ist415.c
Line 272 in 54895ab
int ret = ist415_get_touch_data(priv, upper->app_touch_point_buffer); |
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.
- The touch_read does not check whether the buffer is null or not.
- What you linked is https://github.com/Samsung/TizenRT/blob/e5d7ef9b8629882448210d8615255e70fc591db4/os/drivers/input/ist415.c#L259C13-L259C27. This is for callback, not poll case.
Could you check it again?
And even it is really checking like that, I suggest to do the same thing at the same location.
For the same purpose, if we do different location for each, it's not good to maintain.
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.
This is the platform code, it should be easy-maintain and common.
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.
@anjana348 I left the same comment on @namanjain7 's PR. Let's concern this point for all.
Same purpose, same location regardless of the config difference as possible.
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 has been fixed.
Now buffer NULL condition is getting checked at same location for both the cases.
static void get_touch_data(struct ist415_dev_s *priv) | ||
{ | ||
FAR struct touchscreen_s *upper = priv->upper; | ||
|
||
struct touch_sample_s touch_points; | ||
|
||
if (!upper->app_touch_point_buffer) { | ||
touchdbg("ERROR: application buffer touch data is NULL\n"); | ||
if (upper->is_touch_detected) { | ||
upper->is_touch_detected(-EINVAL); | ||
return; | ||
} | ||
} | ||
int ret = ist415_get_touch_data(priv, upper->app_touch_point_buffer); | ||
|
||
if (upper->is_touch_detected) { | ||
upper->is_touch_detected(ret); | ||
} | ||
} |
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.
Sorry I don't know how to give the data to app. Could you explain working flow?
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.
We are registering callback function is_touch_detected and buffer to driver using IOCTL call TSIOC_SETAPPNOTIFY
When there is an touch interrupt a new thread will be created which will execute function get_touch_data() and this function will call function ist415_get_touch_data() by passing buffer as a parameter(this buffer was register to driver using IOCTL call).
Function ist415_get_touch_data() copy data related to touch inside the passed buffer and after completion of this function the callback function will be called from here
Now callback fuction use the buffer(which was passed to driver) to acces the touch data.
@@ -85,7 +85,9 @@ | |||
#define TSIOC_GETFREQUENCY _TSIOC(0x0004) /* arg: Pointer to uint32_t frequency value */ | |||
#define TSIOC_DISABLE _TSIOC(0x0005) /* Disable touch interrupt */ | |||
#define TSIOC_ENABLE _TSIOC(0x0006) /* Enable touch interrupt */ | |||
|
|||
#ifdef CONFIG_TOUCH_CALLBACK |
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.
Let's add this without conditional.
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.
I didn't understood the query.
Could you please elaborate it more
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.
Let's remove #ifdef CONFIG_TOUCH_CALLBACK
and #endif
.
Just add new definition without #ifdef.
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.
fixed
e5d7ef9
to
9dacc47
Compare
…pt to application for touch driver ist415, touch HAL layer Register a callback function with touch input driver using TSIOC_SETAPPNOTIFY IOCTL Call. This function will be automatically called whenever a touch event(Press ,Hold/Move, Release) is detected. When a touch event occurs , the registered callback function is triggered by the touch interrupt handler function. The driver provides details such as touch coordinate and type directly to this callback. Whenever there is a touch interrupt a new task is created to get the touch data and it eventually call the callback function.
…ctionality Touch hold/move event Total touch points 3 TOUCH COORDINATES id: 0, x : 313 y : 162 touch type: 2 Touch hold/move event TOUCH COORDINATES id: 1, x : 398 y : 282 touch type: 2 Touch hold/move event TOUCH COORDINATES id: 2, x : 561 y : 321 touch type: 2 Touch hold/move event Total touch points 3 TOUCH COORDINATES id: 0, x : 313 y : 162 touch type: 2 Touch hold/move event
9dacc47
to
e528e6c
Compare
Touch Driver provides a mechanism to notify application whenever a touch event occur.
Register a callback function with touch input driver using TSIOC_SETAPPNOTIFY IOCTL Call. THis function will be automatically called whenever a touch event(Press ,Hold/Move, Release) is detected.
When a touch event occurs , the registered callback function is triggered by the touch interrupt handler function. The driver provides details such as touch coordinate and type directly to this callback. Whenever there is a touch interrupt a new task is created to get the touch data and it eventually call the callback function.