input : wacom_w8001 - report resolution to userland
Subsystems (2)
PATCH v3 1/1 input : wacom_w8001 - report resolution to userland
Serial devices send both pen and touch data through the same logical port. Since we scaled touch to pen maximum, we use pen resolution for touch as well here.
This is under the assumption that pen and touch share the same physical surface. In the case when a small physical dimensional difference occurs between pen and touch, we assume the tolerance for touch point precision is higher than pen and the difference is within touch point tolerance.
A per-MT tool based resolution mechanism should be introduced if the above assumption does not hold true for the pen and touch devices any more. A good candidate to resolve this issue without introducing design change could be to report touch resolution through ABS_MT_POSITION_X/Y.
This version corrected an oversimplified if statement in v2.
--- drivers/input/touchscreen/wacom_w8001.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-)
drivers/input/touchscreen/wacom_w8001.c +15 -5
@@ -51,6 +51,10 @@ MODULE_LICENSE("GPL");#define W8001_PKTLEN_TPCCTL 11/* control packet */ #define W8001_PKTLEN_TOUCH2FG 13 +/* resolution in points/mm */ +#define W8001_PEN_RESOLUTION 100 +#define W8001_TOUCH_RESOLUTION 10 +struct w8001_coord {u8 rdy;u8 tsw;
@@ -198,7 +202,7 @@ static void parse_touchquery(u8 *data, struct w8001_touch_query *query) query->y =1024 ;if (query->panel_res) query->x = query->y = (1 << query->panel_res); - query->panel_res =10 ; + query->panel_res =W8001_TOUCH_RESOLUTION ; } }
@@ -394,6 +398,8 @@ static int w8001_setup(struct w8001 *w8001)input_set_abs_params (dev,ABS_X ,0 , coord.x,0 ,0 );input_set_abs_params (dev,ABS_Y ,0 , coord.y,0 ,0 ); +input_abs_set_res (dev,ABS_X ,W8001_PEN_RESOLUTION ); +input_abs_set_res (dev,ABS_Y ,W8001_PEN_RESOLUTION );input_set_abs_params (dev,ABS_PRESSURE ,0 , coord.pen_pressure,0 ,0 );if (coord.tilt_x && coord.tilt_y) {input_set_abs_params (dev,ABS_TILT_X ,0 , coord.tilt_x,0 ,0 );
@@ -418,15 +424,19 @@ static int w8001_setup(struct w8001 *w8001) w8001->max_touch_x = touch.x; w8001->max_touch_y = touch.y; -/* scale to pen maximum */ +/* pen supported */ if (w8001->max_pen_x && w8001->max_pen_y) { +/* scale to pen maximum */ touch.x = w8001->max_pen_x; touch.y = w8001->max_pen_y; + }else {/* touch only */ +/* set axes with touch data */ +input_set_abs_params (dev,ABS_X ,0 , touch.x,0 ,0 ); +input_set_abs_params (dev,ABS_Y ,0 , touch.y,0 ,0 ); +input_abs_set_res (dev,ABS_X , touch.panel_res); +input_abs_set_res (dev,ABS_Y , touch.panel_res); } -input_set_abs_params (dev,ABS_X ,0 , touch.x,0 ,0 ); -input_set_abs_params (dev,ABS_Y ,0 , touch.y,0 ,0 ); -switch (touch.sensor_id) {case 0 :case 2 :
Signature · 1 line
1.7.3.5
Hi Ping,
Quoted 9 lines · Ping Cheng
Serial devices send both pen and touch data through the same logical port. Since we scaled touch to pen maximum, we use pen resolution for touch as well here.
This is under the assumption that pen and touch share the same physical surface. In the case when a small physical dimensional difference occurs between pen and touch, we assume the tolerance for touch point precision is higher than pen and the difference is within touch point tolerance.
Quoted 4 lines
A per-MT tool based resolution mechanism should be introduced if the above assumption does not hold true for the pen and touch devices any more. A good candidate to resolve this issue without introducing design change could be to report touch resolution through ABS_MT_POSITION_X/Y.
This still sounds a bit like mixing apples and oranges. If this case would ever happen, and I doubt it since the whole idea is to use different tools on the same surface, then splitting into separate devices would be appropriate.
Quoted 43 lines
This version corrected an oversimplified if statement in v2.
Signed-off-by Ping Cheng <[email protected]>---
drivers/input/touchscreen/wacom_w8001.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-)drivers/input/touchscreen/wacom_w8001.c +7
-1@@ -51,6 +51,10 @@ MODULE_LICENSE("GPL");#define W8001_PKTLEN_TPCCTL 11/* control packet */ #define W8001_PKTLEN_TOUCH2FG 13 +/* resolution in points/mm */ +#define W8001_PEN_RESOLUTION 100 +#define W8001_TOUCH_RESOLUTION 10 +struct w8001_coord {u8 rdy;u8 tsw;@@ -198,7 +202,7 @@ static void parse_touchquery(u8 *data, struct w8001_touch_query *query) query->y =1024 ;if (query->panel_res) query->x = query->y = (1 << query->panel_res); - query->panel_res =10 ; + query->panel_res =W8001_TOUCH_RESOLUTION ; } }@@ -394,6 +398,8 @@ static int w8001_setup(struct w8001 *w8001)input_set_abs_params (dev,ABS_X ,0 , coord.x,0 ,0 );input_set_abs_params (dev,ABS_Y ,0 , coord.y,0 ,0 ); +input_abs_set_res (dev,ABS_X ,W8001_PEN_RESOLUTION ); +input_abs_set_res (dev,ABS_Y ,W8001_PEN_RESOLUTION );input_set_abs_params (dev,ABS_PRESSURE ,0 , coord.pen_pressure,0 ,0 );if (coord.tilt_x && coord.tilt_y) {input_set_abs_params (dev,ABS_TILT_X ,0 , coord.tilt_x,0 ,0 );
drivers/input/touchscreen/wacom_w8001.c static int w8001_setup(struct w8001 *w8001) · line 425
Quoted 2 lines
drivers/input/touchscreen/wacom_w8001.c +0
-0@@ -418,15 +424,19 @@ static int w8001_setup(struct w8001 *w8001) w8001->max_touch_x = touch.x; w8001->max_touch_y = touch.y;
So max_touch is set here
drivers/input/touchscreen/wacom_w8001.c static int w8001_setup(struct w8001 *w8001) · line 431
Quoted 7 lines
drivers/input/touchscreen/wacom_w8001.c +2
-1-/* scale to pen maximum */ +/* pen supported */ if (w8001->max_pen_x && w8001->max_pen_y) { +/* scale to pen maximum */ touch.x = w8001->max_pen_x; touch.y = w8001->max_pen_y;
And possibly redefined here
Quoted 4 lines
drivers/input/touchscreen/wacom_w8001.c +4
-0+ }else {/* touch only */ +/* set axes with touch data */ +input_set_abs_params (dev,ABS_X ,0 , touch.x,0 ,0 ); +input_set_abs_params (dev,ABS_Y ,0 , touch.y,0 ,0 );
drivers/input/touchscreen/wacom_w8001.c static int w8001_setup(struct w8001 *w8001) · line 442
Quoted 10 lines
drivers/input/touchscreen/wacom_w8001.c +2
-3+input_abs_set_res (dev,ABS_X , touch.panel_res); +input_abs_set_res (dev,ABS_Y , touch.panel_res); } -input_set_abs_params (dev,ABS_X ,0 , touch.x,0 ,0 ); -input_set_abs_params (dev,ABS_Y ,0 , touch.y,0 ,0 ); -switch (touch.sensor_id) {case 0 :case 2 :
And then just used to set MT later on, which will lead to ABS_MT_POSITION_X values different from ABS_X. This is just getting messier. In fact, the whole setup function is messy, with unclear handling of error paths. Any chance one could simplify the logic involved here? It should be possible to use a single code path for input_set_abs_params() and input_abs_set_res(), for instance.
Thanks,
Henrik
Dmitry Torokhov
maintainerQuoted 88 lines · Henrik Rydberg
Hi Ping,
Quoted 9 lines · Ping Cheng
Serial devices send both pen and touch data through the same logical port. Since we scaled touch to pen maximum, we use pen resolution for touch as well here.
This is under the assumption that pen and touch share the same physical surface. In the case when a small physical dimensional difference occurs between pen and touch, we assume the tolerance for touch point precision is higher than pen and the difference is within touch point tolerance.
Quoted 4 lines
A per-MT tool based resolution mechanism should be introduced if the above assumption does not hold true for the pen and touch devices any more. A good candidate to resolve this issue without introducing design change could be to report touch resolution through ABS_MT_POSITION_X/Y.
This still sounds a bit like mixing apples and oranges. If this case would ever happen, and I doubt it since the whole idea is to use different tools on the same surface, then splitting into separate devices would be appropriate.
Quoted 43 lines
This version corrected an oversimplified if statement in v2.
Signed-off-by Ping Cheng <[email protected]>---
drivers/input/touchscreen/wacom_w8001.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-)drivers/input/touchscreen/wacom_w8001.c +7
-1@@ -51,6 +51,10 @@ MODULE_LICENSE("GPL");#define W8001_PKTLEN_TPCCTL 11/* control packet */ #define W8001_PKTLEN_TOUCH2FG 13 +/* resolution in points/mm */ +#define W8001_PEN_RESOLUTION 100 +#define W8001_TOUCH_RESOLUTION 10 +struct w8001_coord {u8 rdy;u8 tsw;@@ -198,7 +202,7 @@ static void parse_touchquery(u8 *data, struct w8001_touch_query *query) query->y =1024 ;if (query->panel_res) query->x = query->y = (1 << query->panel_res); - query->panel_res =10 ; + query->panel_res =W8001_TOUCH_RESOLUTION ; } }@@ -394,6 +398,8 @@ static int w8001_setup(struct w8001 *w8001)input_set_abs_params (dev,ABS_X ,0 , coord.x,0 ,0 );input_set_abs_params (dev,ABS_Y ,0 , coord.y,0 ,0 ); +input_abs_set_res (dev,ABS_X ,W8001_PEN_RESOLUTION ); +input_abs_set_res (dev,ABS_Y ,W8001_PEN_RESOLUTION );input_set_abs_params (dev,ABS_PRESSURE ,0 , coord.pen_pressure,0 ,0 );if (coord.tilt_x && coord.tilt_y) {input_set_abs_params (dev,ABS_TILT_X ,0 , coord.tilt_x,0 ,0 );drivers/input/touchscreen/wacom_w8001.c static int w8001_setup(struct w8001 *w8001) · line 425
Quoted 2 lines
drivers/input/touchscreen/wacom_w8001.c +0
-0@@ -418,15 +424,19 @@ static int w8001_setup(struct w8001 *w8001) w8001->max_touch_x = touch.x; w8001->max_touch_y = touch.y;So
max_touchis set heredrivers/input/touchscreen/wacom_w8001.c static int w8001_setup(struct w8001 *w8001) · line 430
Quoted 7 lines
drivers/input/touchscreen/wacom_w8001.c +2
-1-/* scale to pen maximum */ +/* pen supported */ if (w8001->max_pen_x && w8001->max_pen_y) { +/* scale to pen maximum */ touch.x = w8001->max_pen_x; touch.y = w8001->max_pen_y;And possibly redefined here
Quoted 8 lines
drivers/input/touchscreen/wacom_w8001.c +6
-0+ }else {/* touch only */ +/* set axes with touch data */ +input_set_abs_params (dev,ABS_X ,0 , touch.x,0 ,0 ); +input_set_abs_params (dev,ABS_Y ,0 , touch.y,0 ,0 ); +input_abs_set_res (dev,ABS_X , touch.panel_res); +input_abs_set_res (dev,ABS_Y , touch.panel_res); }
Quoted 14 lines
drivers/input/touchscreen/wacom_w8001.c static int w8001_setup(struct w8001 *w8001) · line 441
Quoted 6 lines
drivers/input/touchscreen/wacom_w8001.c +0
-3-input_set_abs_params (dev,ABS_X ,0 , touch.x,0 ,0 ); -input_set_abs_params (dev,ABS_Y ,0 , touch.y,0 ,0 ); -switch (touch.sensor_id) {case 0 :case 2 :And then just used to set MT later on, which will lead to
ABS_MT_POSITION_Xvalues different fromABS_X. This is just getting messier. In fact, the whole setup function is messy, with unclear handling of error paths. Any chance one could simplify the logic involved here? It should be possible to use a single code path forinput_set_abs_params()andinput_abs_set_res(), for instance.
I have the following for the resolution reporting:
Input: wacom_w8001 - report resolution to userland
From: Ping Cheng <[email protected]>
Serial devices send both pen and touch data through the same logical port. Since we scaled touch to pen maximum, we use pen resolution for touch as well here.
This is under the assumption that pen and touch share the same physical surface. In the case when a small physical dimensional difference occurs between pen and touch, we assume the tolerance for touch point precision is higher than pen and the difference is within touch point tolerance.
A per-MT tool based resolution mechanism should be introduced if the above assumption does not hold true for the pen and touch devices any more.
---
drivers/input/touchscreen/wacom_w8001.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)
drivers/input/touchscreen/wacom_w8001.c +11 -2
@@ -51,6 +51,10 @@ MODULE_LICENSE("GPL");#define W8001_PKTLEN_TPCCTL 11/* control packet */ #define W8001_PKTLEN_TOUCH2FG 13 +/* resolution in points/mm */ +#define W8001_PEN_RESOLUTION 100 +#define W8001_TOUCH_RESOLUTION 10 +struct w8001_coord {u8 rdy;u8 tsw;
@@ -198,7 +202,7 @@ static void parse_touchquery(u8 *data, struct w8001_touch_query *query) query->y =1024 ;if (query->panel_res) query->x = query->y = (1 << query->panel_res); - query->panel_res =10 ; + query->panel_res =W8001_TOUCH_RESOLUTION ; } }
@@ -394,6 +398,8 @@ static int w8001_setup(struct w8001 *w8001)input_set_abs_params (dev,ABS_X ,0 , coord.x,0 ,0 );input_set_abs_params (dev,ABS_Y ,0 , coord.y,0 ,0 ); +input_abs_set_res (dev,ABS_X ,W8001_PEN_RESOLUTION ); +input_abs_set_res (dev,ABS_Y ,W8001_PEN_RESOLUTION );input_set_abs_params (dev,ABS_PRESSURE ,0 , coord.pen_pressure,0 ,0 );if (coord.tilt_x && coord.tilt_y) {input_set_abs_params (dev,ABS_TILT_X ,0 , coord.tilt_x,0 ,0 );
@@ -418,14 +424,17 @@ static int w8001_setup(struct w8001 *w8001) w8001->max_touch_x = touch.x; w8001->max_touch_y = touch.y; -/* scale to pen maximum */ if (w8001->max_pen_x && w8001->max_pen_y) { +/* if pen is supported scale to pen maximum */ touch.x = w8001->max_pen_x; touch.y = w8001->max_pen_y; + touch.panel_res =W8001_PEN_RESOLUTION ; }input_set_abs_params (dev,ABS_X ,0 , touch.x,0 ,0 );input_set_abs_params (dev,ABS_Y ,0 , touch.y,0 ,0 ); +input_abs_set_res (dev,ABS_X , touch.panel_res); +input_abs_set_res (dev,ABS_Y , touch.panel_res);switch (touch.sensor_id) {case 0 :
Signature · 1 line
Dmitry
Quoted 104 lines · Dmitry Torokhov
Quoted 95 lines · Henrik Rydberg
Hi Ping,
Quoted 9 lines · Ping Cheng
Serial devices send both pen and touch data through the same logical port. Since we scaled touch to pen maximum, we use pen resolution for touch as well here.
This is under the assumption that pen and touch share the same physical surface. In the case when a small physical dimensional difference occurs between pen and touch, we assume the tolerance for touch point precision is higher than pen and the difference is within touch point tolerance.
Quoted 4 lines
A per-MT tool based resolution mechanism should be introduced if the above assumption does not hold true for the pen and touch devices any more. A good candidate to resolve this issue without introducing design change could be to report touch resolution through ABS_MT_POSITION_X/Y.
This still sounds a bit like mixing apples and oranges. If this case would ever happen, and I doubt it since the whole idea is to use different tools on the same surface, then splitting into separate devices would be appropriate.
Quoted 43 lines
This version corrected an oversimplified if statement in v2.
Signed-off-by Ping Cheng <[email protected]>---
drivers/input/touchscreen/wacom_w8001.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)drivers/input/touchscreen/wacom_w8001.c +7
-1@@ -51,6 +51,10 @@ MODULE_LICENSE("GPL"); #define W8001_PKTLEN_TPCCTL 11 /* control packet */ #define W8001_PKTLEN_TOUCH2FG 13 +/* resolution in points/mm */ +#define W8001_PEN_RESOLUTION 100 +#define W8001_TOUCH_RESOLUTION 10 + struct w8001_coord { u8 rdy; u8 tsw;@@ -198,7 +202,7 @@ static void parse_touchquery(u8 *data, struct w8001_touch_query *query) query->y = 1024; if (query->panel_res) query->x = query->y = (1 << query->panel_res); - query->panel_res = 10; + query->panel_res = W8001_TOUCH_RESOLUTION; } }@@ -394,6 +398,8 @@ static int w8001_setup(struct w8001 *w8001) input_set_abs_params(dev, ABS_X, 0, coord.x, 0, 0); input_set_abs_params(dev, ABS_Y, 0, coord.y, 0, 0); + input_abs_set_res(dev, ABS_X, W8001_PEN_RESOLUTION); + input_abs_set_res(dev, ABS_Y, W8001_PEN_RESOLUTION); input_set_abs_params(dev, ABS_PRESSURE, 0, coord.pen_pressure, 0, 0); if (coord.tilt_x && coord.tilt_y) { input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0);drivers/input/touchscreen/wacom_w8001.c static int w8001_setup(struct w8001 *w8001) · line 425
Quoted 2 lines
drivers/input/touchscreen/wacom_w8001.c +0
-0@@ -418,15 +424,19 @@ static int w8001_setup(struct w8001 *w8001) w8001->max_touch_x = touch.x; w8001->max_touch_y = touch.y;So
max_touchis set heredrivers/input/touchscreen/wacom_w8001.c static int w8001_setup(struct w8001 *w8001) · line 430
Quoted 7 lines
drivers/input/touchscreen/wacom_w8001.c +2
-1- /* scale to pen maximum */ + /* pen supported */ if (w8001->max_pen_x && w8001->max_pen_y) { + /* scale to pen maximum */ touch.x = w8001->max_pen_x; touch.y = w8001->max_pen_y;And possibly redefined here
Quoted 12 lines
drivers/input/touchscreen/wacom_w8001.c +6
-3+ } else { /* touch only */ + /* set axes with touch data */ + input_set_abs_params(dev, ABS_X, 0, touch.x, 0, 0); + input_set_abs_params(dev, ABS_Y, 0, touch.y, 0, 0); + input_abs_set_res(dev, ABS_X, touch.panel_res); + input_abs_set_res(dev, ABS_Y, touch.panel_res); } - input_set_abs_params(dev, ABS_X, 0, touch.x, 0, 0); - input_set_abs_params(dev, ABS_Y, 0, touch.y, 0, 0); - switch (touch.sensor_id) {Quoted 2 lines
case 0:
case 2:Quoted 7 lines
And then just used to set MT later on, which will lead to
ABS_MT_POSITION_Xvalues different fromABS_X. This is just getting messier. In fact, the whole setup function is messy, with unclear handling of error paths. Any chance one could simplify the logic involved here? It should be possible to use a single code path forinput_set_abs_params()andinput_abs_set_res(), for instance.
Quoted 1 line
I have the following for the resolution reporting:
It works for me. Although the end result is the same as the v3 since params and res have already been set in pen response blok if pen is supported, it is more straight forward in logical to anyone who tries to understand the code.
Thank you, Dmitry.
Ping
Quoted 76 lines
Input:
wacom_w8001- report resolution to userlandFrom: Ping Cheng <[email protected]>
Serial devices send both pen and touch data through the same logical port. Since we scaled touch to pen maximum, we use pen resolution for touch as well here.
This is under the assumption that pen and touch share the same physical surface. In the case when a small physical dimensional difference occurs between pen and touch, we assume the tolerance for touch point precision is higher than pen and the difference is within touch point tolerance.
A per-MT tool based resolution mechanism should be introduced if the above assumption does not hold true for the pen and touch devices any more.
Signed-off-by Ping Cheng <[email protected]>Signed-off-by Dmitry Torokhov <[email protected]>---
drivers/input/touchscreen/wacom_w8001.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)drivers/input/touchscreen/wacom_w8001.c +11
-2@@ -51,6 +51,10 @@ MODULE_LICENSE("GPL"); #define W8001_PKTLEN_TPCCTL 11 /* control packet */ #define W8001_PKTLEN_TOUCH2FG 13 +/* resolution in points/mm */ +#define W8001_PEN_RESOLUTION 100 +#define W8001_TOUCH_RESOLUTION 10 + struct w8001_coord { u8 rdy; u8 tsw;@@ -198,7 +202,7 @@ static void parse_touchquery(u8 *data, struct w8001_touch_query *query) query->y = 1024; if (query->panel_res) query->x = query->y = (1 << query->panel_res); - query->panel_res = 10; + query->panel_res = W8001_TOUCH_RESOLUTION; } }@@ -394,6 +398,8 @@ static int w8001_setup(struct w8001 *w8001) input_set_abs_params(dev, ABS_X, 0, coord.x, 0, 0); input_set_abs_params(dev, ABS_Y, 0, coord.y, 0, 0); + input_abs_set_res(dev, ABS_X, W8001_PEN_RESOLUTION); + input_abs_set_res(dev, ABS_Y, W8001_PEN_RESOLUTION); input_set_abs_params(dev, ABS_PRESSURE, 0, coord.pen_pressure, 0, 0); if (coord.tilt_x && coord.tilt_y) { input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0);@@ -418,14 +424,17 @@ static int w8001_setup(struct w8001 *w8001) w8001->max_touch_x = touch.x; w8001->max_touch_y = touch.y; - /* scale to pen maximum */ if (w8001->max_pen_x && w8001->max_pen_y) { + /* if pen is supported scale to pen maximum */ touch.x = w8001->max_pen_x; touch.y = w8001->max_pen_y; + touch.panel_res = W8001_PEN_RESOLUTION; } input_set_abs_params(dev, ABS_X, 0, touch.x, 0, 0); input_set_abs_params(dev, ABS_Y, 0, touch.y, 0, 0); + input_abs_set_res(dev, ABS_X, touch.panel_res); + input_abs_set_res(dev, ABS_Y, touch.panel_res); switch (touch.sensor_id) {
Quoted 4 lines
case 0:
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Henrik Rydberg
Reviewed-byQuoted 9 lines
Quoted 1 line
I have the following for the resolution reporting:
It works for me. Although the end result is the same as the v3 since params and res have already been set in pen response blok if pen is supported, it is more straight forward in logical to anyone who tries to understand the code.
Thank you, Dmitry.
Yep, looks good - thanks!
Henrik