Skip to contentSkip to conversation

add module parameter to provide hardware-calibrated coordinate data for MicroTouch/3M touchscreens

PATCH Dan Streetman 3 participants 3 messages Nov 13, 2008 – Nov 14, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 8 lines · Greg KH
Quoted 5 lines · Dan Streetman

--- a/drivers/input/touchscreen/usbtouchscreen.c 2008-11-12
13:06:23.000000000 -0500
+++ b/drivers/input/touchscreen/usbtouchscreen.c 2008-11-12
13:07:44.000000000 -0500

Your patch is line-wrapped :(

Stupid gmail! :(
I'm trying now with thunderbird but I'm not sure if it has problems also or not. I'm attaching the patch as well just in case :(

Quoted 5 lines
Quoted 5 lines
(quoted diff) +0 -0
@@ -60,6 +60,10 @@ static int swap_xy;
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
 
Quoted 7 lines

Review static int swap_xy; · line 65

Quoted 3 lines
(quoted diff) +3 -0
+static int hwcalib_xy = 0;
+module_param(hwcalib_xy, bool, 0444);
+MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if available");

Should this variable be allowed to be changed at run time? That might be useful if the code is built into the system. If so, please change the permissions on the module_param() call.

I set it as read only because I had to override the min/max coordinate values in the mtouch_init() function if the hw-calibrated coordinates were being used, so if someone changed the value after a screen was already connected, it would start reporting hw-calibrated coordinates but the min/max values would still be the raw min/max...however, for people wanting to change the value and then hotplug their touchscreens (to reset the min/max values), it would be useful. Below is the patch with the permissions adjusted.

drivers/input/touchscreen/usbtouchscreen.c +17 -2
@@ -60,6 +60,10 @@ static int swap_xy;
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
 
+static int hwcalib_xy = 0;
+module_param(hwcalib_xy, bool, 0644);
+MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if available");
+
 /* device specifc data/functions */
 struct usbtouch_usb;
 struct usbtouch_device_info {
@@ -260,8 +264,13 @@ static int panjit_read_data(struct usbto
 
 static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
 {
-	dev->x = (pkt[8] << 8) | pkt[7];
-	dev->y = (pkt[10] << 8) | pkt[9];
+	if (hwcalib_xy) {
+		dev->x = (pkt[4] << 8) | pkt[3];
+		dev->y = (pkt[6] << 8) | pkt[5];
+	} else {
+		dev->x = (pkt[8] << 8) | pkt[7];
+		dev->y = (pkt[10] << 8) | pkt[9];
+	}
 	dev->touch = (pkt[2] & 0x40) ? 1 : 0;
 
 	return 1;
@@ -294,6 +303,12 @@ static int mtouch_init(struct usbtouch_u
 			return ret;
 	}
 
+	// Default min/max xy are the raw values, override if using hw-calib
+	if (hwcalib_xy) {
+		input_set_abs_params(usbtouch->input, ABS_X, 0, 0xffff, 0, 0);
+		input_set_abs_params(usbtouch->input, ABS_Y, 0xffff, 0, 0, 0);
+	}
+
 	return 0;
 }
 #endif
drivers/input/touchscreen/usbtouchscreen.c +17 -2
@@ -60,6 +60,10 @@ static int swap_xy;
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
 
+static int hwcalib_xy = 0;
+module_param(hwcalib_xy, bool, 0644);
+MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if available");
+
 /* device specifc data/functions */
 struct usbtouch_usb;
 struct usbtouch_device_info {
@@ -260,8 +264,13 @@ static int panjit_read_data(struct usbto
 
 static int mtouch_read_data(struct usbtouch_usb *dev, unsigned char *pkt)
 {
-	dev->x = (pkt[8] << 8) | pkt[7];
-	dev->y = (pkt[10] << 8) | pkt[9];
+	if (hwcalib_xy) {
+		dev->x = (pkt[4] << 8) | pkt[3];
+		dev->y = (pkt[6] << 8) | pkt[5];
+	} else {
+		dev->x = (pkt[8] << 8) | pkt[7];
+		dev->y = (pkt[10] << 8) | pkt[9];
+	}
 	dev->touch = (pkt[2] & 0x40) ? 1 : 0;
 
 	return 1;
@@ -294,6 +303,12 @@ static int mtouch_init(struct usbtouch_u
 			return ret;
 	}
 
+	// Default min/max xy are the raw values, override if using hw-calib
+	if (hwcalib_xy) {
+		input_set_abs_params(usbtouch->input, ABS_X, 0, 0xffff, 0, 0);
+		input_set_abs_params(usbtouch->input, ABS_Y, 0xffff, 0, 0, 0);
+	}
+
 	return 0;
 }
 #endif
#1 lore raw
Quoted 11 lines · Dan Streetman
Quoted 8 lines · Greg KH
Quoted 5 lines · Dan Streetman

--- a/drivers/input/touchscreen/usbtouchscreen.c 2008-11-12
13:06:23.000000000 -0500
+++ b/drivers/input/touchscreen/usbtouchscreen.c 2008-11-12
13:07:44.000000000 -0500

Your patch is line-wrapped :(

Quoted 3 lines

Stupid gmail! :(
I'm trying now with thunderbird but I'm not sure if it has problems also or not. I'm attaching the patch as well just in case :(

<snip>

Hello, all
Dan, may i get you small advice ? There is file in linux/Documentation/email-clients.txt that describes e-mail clients and what you should do to send patch inlined. May be it will be helpful to you :)
(Sorry for interruption)

Signature · 1 line
Best regards, Klimov Alexey
#2 lore raw
In reply to Dan Streetman
Quoted 11 lines · Dan Streetman
Quoted 8 lines · Greg KH
Quoted 5 lines · Dan Streetman

--- a/drivers/input/touchscreen/usbtouchscreen.c 2008-11-12
13:06:23.000000000 -0500
+++ b/drivers/input/touchscreen/usbtouchscreen.c 2008-11-12
13:07:44.000000000 -0500

Your patch is line-wrapped :(

Quoted 3 lines

Stupid gmail! :(
I'm trying now with thunderbird but I'm not sure if it has problems also or not. I'm attaching the patch as well just in case :(

Still linewrapped (the attached version isn't but then you have 2 copies of the same patch in one email, which our tools do not like...)

Quoted 13 lines
Quoted 7 lines

drivers/input/touchscreen/usbtouchscreen.c static int swap_xy; · line 65

Quoted 7 lines
drivers/input/touchscreen/usbtouchscreen.c +3 -0
@@ -60,6 +60,10 @@ static int swap_xy;
 module_param(swap_xy, bool, 0644);
 MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
 
+static int hwcalib_xy = 0;
+module_param(hwcalib_xy, bool, 0444);
+MODULE_PARM_DESC(hwcalib_xy, "If set hw-calibrated X/Y are used if 

available");

Quoted 4 lines

Should this variable be allowed to be changed at run time? That might be useful if the code is built into the system. If so, please change the permissions on the module_param() call.

Quoted 11 lines

I set it as read only because I had to override the min/max coordinate values in the mtouch_init() function
if the hw-calibrated coordinates were being used, so if someone changed the value after a screen
was already connected, it would start reporting hw-calibrated coordinates but the min/max values
would still be the raw min/max...however, for people wanting to change the value and then hotplug
their touchscreens (to reset the min/max values), it would be useful. Below is the patch with the
permissions adjusted.

This kind of implies that you want this setting on a per-device basis, right? Why not make it attached to the individual device instead of a system-wide option?

thanks,

greg k-h