Skip to contentSkip to conversation

Adding BTN_TOOL_TOUCH to input.h

RFC Henrik Rydberg 4 participants 20 messages Nov 25, 2010 – Dec 7, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

Reading through this thread, I think Dmitry's EVIOCGDEVTYPE is a great way to resolve this. We should expect some changes in userland to correctly interpret direct/indirect devices, and this seems a good way to go. The physical size of the surface would also be great to retrieve this way. The recent resolution addition is semantically odd, since we have only one physical surface, not one per axes.

In short, my suggestion is to build a struct for device properties, like this:

struct input_devinfo {
	__u32	type;			/* bitmask of possible dev types */
	__u32	capabilities;		/* bitmask of special device caps */
	__u32	phys_abs_width;		/* physical width of surface (mm) */
	__u32	phys_abs_height;	/* physical height of surface (mm) */
};

Adding more stuff here seems plausible. For instance, special devices like clickpads or integrated buttons would fit nicely in capabilities. The call would be very similar, like

	ioctl(fd, EVIOCGDEVINFO, &info);

What do you think?

Cheers,
Henrik

#1 lore raw
Quoted 2 lines · Henrik Rydberg
	__u32	phys_abs_width;		/* physical width of surface (mm) */
	__u32	phys_abs_height;	/* physical height of surface (mm) */

This is better and is already covered by input_absinfo. You could calculate it with (maximum - minimum) / resolution.

Sincerely,
Nick

#2 lore raw
Quoted 9 lines · Nikolai Kondrashov
Quoted 5 lines · Henrik Rydberg

       __u32   phys_abs_width;         /* physical width of surface (mm) */
       __u32   phys_abs_height;        /* physical height of surface (mm) */

This is better and is already covered by input_absinfo. You could calculate it with (maximum - minimum) / resolution.

On this topic. I'd like to start reporting resolution for a few wacom devices.

When I looked at input_absinfo.resolution, I see only synaptics.c is using it right now and it is defined using units/mm. Currently, this makes it up to xf86-input-synaptics were X is fed this value after converting to units/meter. Thats my intended usage as well.

I'm more used to values in inches (lpi) or at least something higher then mm. If I converted my lpi to mm for resolution I'd lose some accuracy.

We could solve that a few ways. Provide units in input_absinfo, convert to units/inch, units/cm or even units/meter, or define physical size in mm.

Any preferences?

Chris
--
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

maintainer
#3 lore raw
Quoted 14 lines · Chris Bagwell
Quoted 9 lines · Nikolai Kondrashov
Quoted 5 lines · Henrik Rydberg

       __u32   phys_abs_width;         /* physical width of surface (mm) */
       __u32   phys_abs_height;        /* physical height of surface (mm) */

This is better and is already covered by input_absinfo. You could calculate it with (maximum - minimum) / resolution.

On this topic. I'd like to start reporting resolution for a few wacom devices.

Quoted 8 lines

When I looked at input_absinfo.resolution, I see only synaptics.c is using it right now and it is defined using units/mm. Currently, this makes it up to xf86-input-synaptics were X is fed this value after converting to units/meter. Thats my intended usage as well.

I'm more used to values in inches (lpi) or at least something higher then mm. If I converted my lpi to mm for resolution I'd lose some accuracy.

Right, with devices that have low accuracy you'd be losing accuracy here too.

Quoted 4 lines

We could solve that a few ways. Provide units in input_absinfo, convert to units/inch, units/cm or even units/meter, or define physical size in mm.

How big is the error and how important is it if we go with option 4 (do nothing)?

Signature · 5 lines
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
#4 lore raw
In reply to Chris Bagwell
Quoted 2 lines · Chris Bagwell

When I looked at input_absinfo.resolution, I see only synaptics.c is using it right now and it is defined using units/mm.

I'm not sure if it matters a lot, but Jiri has accepted my resolution calculation patch to hid-input.c [1] which does it in *units/inch* for generic HID devices, which choose to provide correct information in their report descriptors.

Sincerely,
Nick

[1] http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blobdiff;f=drivers/hid/hid-input.c;h=8e733b6eae27587366c138187e59119b2b49ec35;hp=6c03dcc5760a277097bb17d866cc33aa17db484a;hb=4ea6e4ffb4acdaaf9ba7687dbd84ae36e26cef9e;hpb=b6dc79929fa18a97bbc08400db72405ad835622f

maintainer
#18 lore raw
In reply to Henrik Rydberg
Quoted 8 lines · Henrik Rydberg

Hi,

Reading through this thread, I think Dmitry's EVIOCGDEVTYPE is a great way to resolve this. We should expect some changes in userland to correctly interpret direct/indirect devices, and this seems a good way to go. The physical size of the surface would also be great to retrieve this way. The recent resolution addition is semantically odd, since we have only one physical surface, not one per axes.

1 for each of 2 major axes, at least. We might need resolution for pressure/distance as well, although it certainly won't be unit/mm ;)

Quoted 10 lines

In short, my suggestion is to build a struct for device properties, like this:

struct input_devinfo {
	__u32	type;			/* bitmask of possible dev types */
	__u32	capabilities;		/* bitmask of special device caps */
	__u32	phys_abs_width;		/* physical width of surface (mm) */
	__u32	phys_abs_height;	/* physical height of surface (mm) */
};
Quoted 6 lines

Adding more stuff here seems plausible. For instance, special devices like clickpads or integrated buttons would fit nicely in capabilities. The call would be very similar, like

	ioctl(fd, EVIOCGDEVINFO, &info);

Yep, should work, although the dimensions could be retrieved from absinfo.

Signature · 1 line
Dmitry
maintainer
#5 lore raw
In reply to Nikolai Kondrashov
Quoted 8 lines · Nikolai Kondrashov
Quoted 2 lines · Chris Bagwell

When I looked at input_absinfo.resolution, I see only synaptics.c is using it right now and it is defined using units/mm.

I'm not sure if it matters a lot, but Jiri has accepted my resolution calculation patch to hid-input.c [1] which does it in *units/inch* for generic HID devices, which choose to provide correct information in their report descriptors.

OUCH. We need to fix this _now_. We can not allow reporting resolutions in random units. Since we started with unit/mm we have to keep it and if it gives issues we can think about adding other units later on, but for everyone.

Signature · 1 line
Dmitry
#6 lore raw
Quoted 4 lines · Dmitry Torokhov

OUCH. We need to fix this _now_. We can not allow reporting resolutions in random units. Since we started with unit/mm we have to keep it and if it gives issues we can think about adding other units later on, but for everyone.

I understand your concerns, but this will make this feature useless for the 8 tablet models I was aiming it at. Most of them have 2000 LPI resolution.

The thing is, I suspect, there is basicly very little to none real devices correctly specifying their resolution in the report descriptors. Plus almost no one uses the resolution field in input_absinfo currently and especially for generic processing (as opposed to working with a specific device). Even more, I have failed to find any noticeable amount of device drivers filling it in, but it could be my fault of course.

So, I think, now is the best time to standardize on this and do real changes.

Sincerely,
Nick

#8 lore raw
In reply to a message not in the archive
Quoted 1 line · Dmitry Torokhov

2000LPI == about 79 l/mm. How is it not useable?

TBH, I didn't make any real calculations.
The introduced error isn't very high, indeed. The vertical size of 4x3 inch tablet becomes 75 mm instead of 76 mm. So maybe it's alright.

Quoted 4 lines

In mainline synaptics is the only one that does this. We do not know how many drivers in vendor trees fill and use this data nor we do not know about userspace. The fact that we were not able to locate them does not mean they do not exist. The units/mm are part of input ABI now.

Well, I can't argue with you here.
I didn't think about 3rd party drivers, TBH.

Quoted 2 lines

Right, standarize on existing UOM (which are per/mm) and then implement other UOM if theya re really needed.

Will this fix qualify for inclusion into 2.6.37?
Also, what do you think about units per radians for rotational axis?

Thanks :)

Sincerely,
Nick

#19 lore raw
In reply to Dmitry Torokhov
Quoted 10 lines · Dmitry Torokhov
Quoted 8 lines · Henrik Rydberg

Hi,

Reading through this thread, I think Dmitry's EVIOCGDEVTYPE is a great way to resolve this. We should expect some changes in userland to correctly interpret direct/indirect devices, and this seems a good way to go. The physical size of the surface would also be great to retrieve this way. The recent resolution addition is semantically odd, since we have only one physical surface, not one per axes.

Quoted 2 lines

1 for each of 2 major axes, at least. We might need resolution for pressure/distance as well, although it certainly won't be unit/mm ;)

Alright, neither abstraction is perfect, but I agree the resolution has its virtues. :-)

Quoted 14 lines
Quoted 14 lines

In short, my suggestion is to build a struct for device properties, like this:

struct input_devinfo {
	__u32	type;			/* bitmask of possible dev types */
	__u32	capabilities;		/* bitmask of special device caps */
	__u32	phys_abs_width;		/* physical width of surface (mm) */
	__u32	phys_abs_height;	/* physical height of surface (mm) */
};

Adding more stuff here seems plausible. For instance, special devices like clickpads or integrated buttons would fit nicely in capabilities. The call would be very similar, like

Quoted 6 lines
Quoted 2 lines
	ioctl(fd, EVIOCGDEVINFO, &info);

Yep, should work, although the dimensions could be retrieved from absinfo.

I'll see if I can fit that (minus physical dimensions) into the upcoming patch sets.

Cheers,
Henrik

#9 lore raw
In reply to Nikolai Kondrashov
Quoted 7 lines · Nikolai Kondrashov
Quoted 2 lines · Dmitry Torokhov

2000LPI == about 79 l/mm. How is it not useable?

TBH, I didn't make any real calculations.
The introduced error isn't very high, indeed. The vertical size of 4x3 inch tablet becomes 75 mm instead of 76 mm. So maybe it's alright.

The wacom's I'm inteterested in have lots of different resolutions (0.5k to 5k) and different sizes. I've only calculated a few to see error but seems no more then a few mm in the ones I chose as well.

It works for me... that is to use units/mm for now and if that ever shows to be an issue we can move to new units in future.

Thanks all for feedback,
Chris

#20 lore raw
In reply to Henrik Rydberg
Quoted 21 lines · Henrik Rydberg
Quoted 19 lines · Dmitry Torokhov
Quoted 16 lines · Henrik Rydberg

In short, my suggestion is to build a struct for device properties, like this:

struct input_devinfo {
     __u32   type;                   /* bitmask of possible dev types */ __u32   capabilities;           /* bitmask of special device caps */ __u32   phys_abs_width;         /* physical width of surface (mm) */ __u32   phys_abs_height;        /* physical height of surface (mm) */ };

Adding more stuff here seems plausible. For instance, special devices like clickpads or integrated buttons would fit nicely in capabilities. The call would be very similar, like

     ioctl(fd, EVIOCGDEVINFO, &info);

Quoted 7 lines
Quoted 3 lines

Yep, should work, although the dimensions could be retrieved from absinfo.

I'll see if I can fit that (minus physical dimensions) into the upcoming patch sets.

Thanks, Henrik. That will help move things along for up coming wacom changes needed.

Chris
--
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

maintainer
#10 lore raw
In reply to Nikolai Kondrashov
Quoted 10 lines · Nikolai Kondrashov
Quoted 1 line · Dmitry Torokhov

2000LPI == about 79 l/mm. How is it not useable?

TBH, I didn't make any real calculations.
The introduced error isn't very high, indeed. The vertical size of 4x3 inch tablet becomes 75 mm instead of 76 mm. So maybe it's alright.

Quoted 4 lines

In mainline synaptics is the only one that does this. We do not know how many drivers in vendor trees fill and use this data nor we do not know about userspace. The fact that we were not able to locate them does not mean they do not exist. The units/mm are part of input ABI now.

Quoted 6 lines

Well, I can't argue with you here.
I didn't think about 3rd party drivers, TBH.

Quoted 2 lines

Right, standarize on existing UOM (which are per/mm) and then implement other UOM if theya re really needed.

Will this fix qualify for inclusion into 2.6.37?

Yes, I believe it does.

Quoted 1 line

Also, what do you think about units per radians for rotational axis?

Works for me.

Signature · 1 line
Dmitry
maintainer
#11 lore raw
Quoted 11 lines · Dmitry Torokhov
Quoted 10 lines · Nikolai Kondrashov
Quoted 1 line · Dmitry Torokhov

2000LPI == about 79 l/mm. How is it not useable?

TBH, I didn't make any real calculations.
The introduced error isn't very high, indeed. The vertical size of 4x3 inch tablet becomes 75 mm instead of 76 mm. So maybe it's alright.

Quoted 4 lines

In mainline synaptics is the only one that does this. We do not know how many drivers in vendor trees fill and use this data nor we do not know about userspace. The fact that we were not able to locate them does not mean they do not exist. The units/mm are part of input ABI now.

Quoted 9 lines
Quoted 6 lines

Well, I can't argue with you here.
I didn't think about 3rd party drivers, TBH.

Quoted 2 lines

Right, standarize on existing UOM (which are per/mm) and then implement other UOM if theya re really needed.

Will this fix qualify for inclusion into 2.6.37?

Yes, I believe it does.

Does the following work by any chance?

Thanks.

Signature · 15 lines
Dmitry


HID: length resolution should be reported units/mm

From: Dmitry Torokhov <[email protected]>

Input ABI requires reporting resolution on main axes in units per
millimeter, not units per inch, so we need to convert accordingly.

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/hid/hid-input.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
drivers/hid/hid-input.c +11 -8
index c9c90de..5cde845 100644
@@ -203,8 +203,8 @@ static int hidinput_setkeycode(struct input_dev *dev,
  *
  * as seen in the HID specification v1.11 6.2.2.7 Global Items.
  *
- * Only exponent 1 length units are processed. Centimeters are converted to
- * inches. Degrees are converted to radians.
+ * Only exponent 1 length units are processed. Centimeters and inches are
+ * converted to millimeters. Degrees are converted to radians.
  */
 static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
 {
@@ -225,13 +225,16 @@ static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
 	 */
 	if (code == ABS_X || code == ABS_Y || code == ABS_Z) {
 		if (field->unit == 0x11) {		/* If centimeters */
-			/* Convert to inches */
-			prev = logical_extents;
-			logical_extents *= 254;
-			if (logical_extents < prev)
+			/* Convert to millimeters */
+			unit_exponent += 1;
+		} else if (field->unit == 0x13) {	/* If inches */
+			/* Convert to millimeters */
+			prev = physical_extents;
+			physical_extents *= 254;
+			if (physical_extents < prev)
 				return 0;
-			unit_exponent += 2;
-		} else if (field->unit != 0x13) {	/* If not inches */
+			unit_exponent -= 1;
+		} else {
 			return 0;
 		}
 	} else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) {
maintainer
#15 lore raw
In reply to Dmitry Torokhov
Quoted 11 lines · Dmitry Torokhov
Quoted 10 lines · Nikolai Kondrashov
Quoted 1 line · Dmitry Torokhov

2000LPI == about 79 l/mm. How is it not useable?

TBH, I didn't make any real calculations.
The introduced error isn't very high, indeed. The vertical size of 4x3 inch tablet becomes 75 mm instead of 76 mm. So maybe it's alright.

Quoted 4 lines

In mainline synaptics is the only one that does this. We do not know how many drivers in vendor trees fill and use this data nor we do not know about userspace. The fact that we were not able to locate them does not mean they do not exist. The units/mm are part of input ABI now.

Quoted 11 lines
Quoted 6 lines

Well, I can't argue with you here.
I didn't think about 3rd party drivers, TBH.

Quoted 2 lines

Right, standarize on existing UOM (which are per/mm) and then implement other UOM if theya re really needed.

Will this fix qualify for inclusion into 2.6.37?

Yes, I believe it does.

Quoted 1 line

Also, what do you think about units per radians for rotational axis?

How about the following?

Signature · 14 lines
Dmitry


Input: document struct input_absinfo

Add documentation for struct input_absinfo that is used in EVIOCGABS
and EVIOCSABS ioctl and specify units of measure used for reporting
resolution for an axis.

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 include/linux/input.h |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
include/linux/input.h +20 -1
index a50046f..a8af21d 100644
@@ -47,6 +47,25 @@ struct input_id {
 	__u16 version;
 };
 
+/**
+ * struct input_absinfo - used by EVIOCGABS/EVIOCSABS ioctls
+ * @value: latest reported value for the axis.
+ * @minimum: specifies minimum value for the axis.
+ * @maximum: specifies maximum value for the axis.
+ * @fuzz: specifies fuzz value that is used to filter noise from
+ *	the event stream.
+ * @flat: values that are within this value will be discarded by
+ *	joydev interface and reported as 0 instead.
+ * @resolution: specifies resolution for the values reported for
+ *	the axis.
+ *
+ * Note that input core does not clamp reported values to the
+ * [minimum, maximum] limits, such task is left to userspace.
+ *
+ * Resolution for main axes (ABS_X, ABS_Y, ABS_Z) is reported in
+ * units per millimeter (units/mm), resolution for rotational axes
+ * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian.
+ */
 struct input_absinfo {
 	__s32 value;
 	__s32 minimum;
@@ -1134,7 +1153,7 @@ struct input_mt_slot {
  *	of tracked contacts
  * @mtsize: number of MT slots the device uses
  * @slot: MT slot currently being transmitted
- * @absinfo: array of &struct absinfo elements holding information
+ * @absinfo: array of &struct input_absinfo elements holding information
  *	about absolute axes (current value, min, max, flat, fuzz,
  *	resolution)
  * @key: reflects current state of device's keys/buttons
#14 lore raw
Quoted 1 line · Dmitry Torokhov

Jiri, will you pick it up for 2.6.37?

Just to finish the thread:
I see this patch applied in both Jiri's and Linus' trees now.

Thanks everyone :)

Sincerely,
Nick