Advertisement
Guest User

Tero

a guest
Feb 2nd, 2009
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
  2. index d349c4a..ecb7f74 100644
  3. --- a/drivers/input/mouse/synaptics.c
  4. +++ b/drivers/input/mouse/synaptics.c
  5. @@ -40,6 +40,21 @@
  6. #define YMIN_NOMINAL 1408
  7. #define YMAX_NOMINAL 4448
  8.  
  9. +/*
  10. + * The resolution of the sensor is defined by units per millimeter value
  11. + * reported by the touchpad (see chapters 2.4.3 and 3.5.1). Both axis
  12. + * have individual resolution. To get similar feel of responsiveness,
  13. + * the readouts are normalized.
  14. + */
  15. +#define XCENTER ((XMAX_NOMINAL + XMIN_NOMINAL) / 2)
  16. +#define YCENTER ((YMAX_NOMINAL + YMIN_NOMINAL) / 2)
  17. +
  18. +#define NORMALIZED_X(x) \
  19. + (priv->x_scale ? (x - XCENTER) * 100 / priv->x_scale + XCENTER : x)
  20. +
  21. +#define NORMALIZED_Y(y) \
  22. + (priv->y_scale ? (y - YCENTER) * 100 / priv->y_scale + YCENTER : y)
  23. +
  24.  
  25. /*****************************************************************************
  26. * Stuff we need even when we do not want native Synaptics support
  27. @@ -180,6 +195,31 @@ static int synaptics_identify(struct psmouse *psmouse)
  28. return -1;
  29. }
  30.  
  31. +static int synaptics_resolution(struct psmouse *psmouse)
  32. +{
  33. + struct synaptics_data *priv = psmouse->private;
  34. + unsigned char res[3];
  35. + int xupmm;
  36. + int yupmm;
  37. +
  38. + if (SYN_ID_MAJOR(priv->identity) < 4)
  39. + return 0;
  40. +
  41. + if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, res))
  42. + return 0;
  43. +
  44. + if (res[1] == 0x80) {
  45. + xupmm = res[0];
  46. + yupmm = res[2];
  47. + if (xupmm > yupmm)
  48. + priv->x_scale = (xupmm * 100) / yupmm;
  49. + if (yupmm > xupmm)
  50. + priv->y_scale = (yupmm * 100) / xupmm;
  51. + }
  52. +
  53. + return 0;
  54. +}
  55. +
  56. static int synaptics_query_hardware(struct psmouse *psmouse)
  57. {
  58. int retries = 0;
  59. @@ -193,6 +233,8 @@ static int synaptics_query_hardware(struct psmouse *psmouse)
  60. return -1;
  61. if (synaptics_capability(psmouse))
  62. return -1;
  63. + if (synaptics_resolution(psmouse))
  64. + return -1;
  65.  
  66. return 0;
  67. }
  68. @@ -438,8 +480,8 @@ static void synaptics_process_packet(struct psmouse *psmouse)
  69. if (hw.z < 25) input_report_key(dev, BTN_TOUCH, 0);
  70.  
  71. if (hw.z > 0) {
  72. - input_report_abs(dev, ABS_X, hw.x);
  73. - input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y);
  74. + input_report_abs(dev, ABS_X, NORMALIZED_X(hw.x));
  75. + input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - NORMALIZED_Y(hw.y));
  76. }
  77. input_report_abs(dev, ABS_PRESSURE, hw.z);
  78.  
  79. @@ -535,8 +577,8 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
  80. int i;
  81.  
  82. set_bit(EV_ABS, dev->evbit);
  83. - input_set_abs_params(dev, ABS_X, XMIN_NOMINAL, XMAX_NOMINAL, 0, 0);
  84. - input_set_abs_params(dev, ABS_Y, YMIN_NOMINAL, YMAX_NOMINAL, 0, 0);
  85. + input_set_abs_params(dev, ABS_X, NORMALIZED_X(XMIN_NOMINAL), NORMALIZED_X(XMAX_NOMINAL), 0, 0);
  86. + input_set_abs_params(dev, ABS_Y, NORMALIZED_Y(YMIN_NOMINAL), NORMALIZED_Y(YMAX_NOMINAL), 0, 0);
  87. input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
  88. set_bit(ABS_TOOL_WIDTH, dev->absbit);
  89.  
  90. diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
  91. index 02aa4cf..0836d60 100644
  92. --- a/drivers/input/mouse/synaptics.h
  93. +++ b/drivers/input/mouse/synaptics.h
  94. @@ -101,6 +101,8 @@ struct synaptics_data {
  95. unsigned char pkt_type; /* packet type - old, new, etc */
  96. unsigned char mode; /* current mode byte */
  97. int scroll;
  98. + int x_scale;
  99. + int y_scale;
  100. };
  101.  
  102. int synaptics_detect(struct psmouse *psmouse, int set_properties);
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement