On Thu, 24 Feb 2005, Vojtech Pavlik wrote:

>> would a module parameter that selects raw or hw-calibrated be better?
>
>That'd be a conflict-less solution, indeed.

ok, here's a patch to add a boolean parameter "raw_coordinates".  It 
defaults to true, so behavior won't change by default.

One note, in your bk tree you'd already changed the Y reporting to (MAX_YC
- GET_YC), i.e. to flip Y.  However, with 2 different possible maxes (raw
and hw-calib), it was easier to just reverse the min/max Y's, since the
max depends on the module param.  It should work the same.

Look ok?



--- input/drivers/usb/input/mtouchusb.c 2005-02-23 15:54:37.000000000 -0500
+++ input-changed/drivers/usb/input/mtouchusb.c 2005-02-28 18:33:19.000000000 
-0500
@@ -34,6 +34,9 @@
  *    Eliminated vendor/product module params
  *    Performed multiple successfull tests with an EXII-5010UC
  *
+ *  1.5 02/27/2005 [EMAIL PROTECTED]
+ *    Added module parameter to select raw or hw-calibrated coordinate 
reporting
+ *
  *****************************************************************************/
 
 #include <linux/config.h>
@@ -52,11 +55,13 @@
 #include <linux/usb.h>
 
 #define MTOUCHUSB_MIN_XC                0x0
-#define MTOUCHUSB_MAX_XC                0x4000
+#define MTOUCHUSB_MAX_RAW_XC            0x4000
+#define MTOUCHUSB_MAX_CALIB_XC          0xffff
 #define MTOUCHUSB_XC_FUZZ               0x0
 #define MTOUCHUSB_XC_FLAT               0x0
 #define MTOUCHUSB_MIN_YC                0x0
-#define MTOUCHUSB_MAX_YC                0x4000
+#define MTOUCHUSB_MAX_RAW_YC            0x4000
+#define MTOUCHUSB_MAX_CALIB_YC          0xffff
 #define MTOUCHUSB_YC_FUZZ               0x0
 #define MTOUCHUSB_YC_FLAT               0x0
 
@@ -65,15 +70,28 @@
 #define MTOUCHUSB_REPORT_DATA_SIZE      11
 #define MTOUCHUSB_REQ_CTRLLR_ID         10
 
-#define MTOUCHUSB_GET_XC(data)          (data[8]<<8 | data[7])
-#define MTOUCHUSB_GET_YC(data)          (data[10]<<8 | data[9])
+#define MTOUCHUSB_GET_RAW_XC(data)      (data[8]<<8 | data[7])
+#define MTOUCHUSB_GET_CALIB_XC(data)    (data[4]<<8 | data[3])
+#define MTOUCHUSB_GET_RAW_YC(data)      (data[10]<<8 | data[9])
+#define MTOUCHUSB_GET_CALIB_YC(data)    (data[6]<<8 | data[5])
+#define MTOUCHUSB_GET_XC(data)          (raw_coordinates ? \
+                                         MTOUCHUSB_GET_RAW_XC(data) : \
+                                         MTOUCHUSB_GET_CALIB_XC(data))
+#define MTOUCHUSB_GET_YC(data)          (raw_coordinates ? \
+                                         MTOUCHUSB_GET_RAW_YC(data) : \
+                                         MTOUCHUSB_GET_CALIB_YC(data))
 #define MTOUCHUSB_GET_TOUCHED(data)     ((data[2] & 0x40) ? 1:0)
 
-#define DRIVER_VERSION "v1.4"
+#define DRIVER_VERSION "v1.5"
 #define DRIVER_AUTHOR "Todd E. Johnson, [EMAIL PROTECTED]"
 #define DRIVER_DESC "3M USB Touchscreen Driver"
 #define DRIVER_LICENSE "GPL"
 
+static int raw_coordinates = 1;
+
+module_param(raw_coordinates, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(raw_coordinates, "report raw coordinate values (y, default) 
or hardware-calibrated coordinate values (n)");
+
 struct mtouch_usb {
         unsigned char *data;
         dma_addr_t data_dma;
@@ -123,7 +141,7 @@
         input_report_abs(&mtouch->input, ABS_X,
                          MTOUCHUSB_GET_XC(mtouch->data));
         input_report_abs(&mtouch->input, ABS_Y,
-                         MTOUCHUSB_MAX_YC - MTOUCHUSB_GET_YC(mtouch->data));
+                         MTOUCHUSB_GET_YC(mtouch->data));
         input_sync(&mtouch->input);
 
 exit:
@@ -234,11 +252,13 @@
 
         /* Used to Scale Compensated Data and Flip Y */
         mtouch->input.absmin[ABS_X] =  MTOUCHUSB_MIN_XC;
-        mtouch->input.absmax[ABS_X] =  MTOUCHUSB_MAX_XC;
+        mtouch->input.absmax[ABS_X] =  raw_coordinates ? \
+                                       MTOUCHUSB_MAX_RAW_XC : 
MTOUCHUSB_MAX_CALIB_XC;
         mtouch->input.absfuzz[ABS_X] = MTOUCHUSB_XC_FUZZ;
         mtouch->input.absflat[ABS_X] = MTOUCHUSB_XC_FLAT;
-        mtouch->input.absmin[ABS_Y] =  MTOUCHUSB_MIN_YC;
-        mtouch->input.absmax[ABS_Y] =  MTOUCHUSB_MAX_YC;
+        mtouch->input.absmin[ABS_Y] =  raw_coordinates ? \
+                                       MTOUCHUSB_MAX_RAW_YC : 
MTOUCHUSB_MAX_CALIB_YC;
+        mtouch->input.absmax[ABS_Y] =  MTOUCHUSB_MIN_YC;
         mtouch->input.absfuzz[ABS_Y] = MTOUCHUSB_YC_FUZZ;
         mtouch->input.absflat[ABS_Y] = MTOUCHUSB_YC_FLAT;
 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to