Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
- index d349c4a..ecb7f74 100644
- --- a/drivers/input/mouse/synaptics.c
- +++ b/drivers/input/mouse/synaptics.c
- @@ -40,6 +40,21 @@
- #define YMIN_NOMINAL 1408
- #define YMAX_NOMINAL 4448
- +/*
- + * The resolution of the sensor is defined by units per millimeter value
- + * reported by the touchpad (see chapters 2.4.3 and 3.5.1). Both axis
- + * have individual resolution. To get similar feel of responsiveness,
- + * the readouts are normalized.
- + */
- +#define XCENTER ((XMAX_NOMINAL + XMIN_NOMINAL) / 2)
- +#define YCENTER ((YMAX_NOMINAL + YMIN_NOMINAL) / 2)
- +
- +#define NORMALIZED_X(x) \
- + (priv->x_scale ? (x - XCENTER) * 100 / priv->x_scale + XCENTER : x)
- +
- +#define NORMALIZED_Y(y) \
- + (priv->y_scale ? (y - YCENTER) * 100 / priv->y_scale + YCENTER : y)
- +
- /*****************************************************************************
- * Stuff we need even when we do not want native Synaptics support
- @@ -180,6 +195,31 @@ static int synaptics_identify(struct psmouse *psmouse)
- return -1;
- }
- +static int synaptics_resolution(struct psmouse *psmouse)
- +{
- + struct synaptics_data *priv = psmouse->private;
- + unsigned char res[3];
- + int xupmm;
- + int yupmm;
- +
- + if (SYN_ID_MAJOR(priv->identity) < 4)
- + return 0;
- +
- + if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, res))
- + return 0;
- +
- + if (res[1] == 0x80) {
- + xupmm = res[0];
- + yupmm = res[2];
- + if (xupmm > yupmm)
- + priv->x_scale = (xupmm * 100) / yupmm;
- + if (yupmm > xupmm)
- + priv->y_scale = (yupmm * 100) / xupmm;
- + }
- +
- + return 0;
- +}
- +
- static int synaptics_query_hardware(struct psmouse *psmouse)
- {
- int retries = 0;
- @@ -193,6 +233,8 @@ static int synaptics_query_hardware(struct psmouse *psmouse)
- return -1;
- if (synaptics_capability(psmouse))
- return -1;
- + if (synaptics_resolution(psmouse))
- + return -1;
- return 0;
- }
- @@ -438,8 +480,8 @@ static void synaptics_process_packet(struct psmouse *psmouse)
- if (hw.z < 25) input_report_key(dev, BTN_TOUCH, 0);
- if (hw.z > 0) {
- - input_report_abs(dev, ABS_X, hw.x);
- - input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - hw.y);
- + input_report_abs(dev, ABS_X, NORMALIZED_X(hw.x));
- + input_report_abs(dev, ABS_Y, YMAX_NOMINAL + YMIN_NOMINAL - NORMALIZED_Y(hw.y));
- }
- input_report_abs(dev, ABS_PRESSURE, hw.z);
- @@ -535,8 +577,8 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
- int i;
- set_bit(EV_ABS, dev->evbit);
- - input_set_abs_params(dev, ABS_X, XMIN_NOMINAL, XMAX_NOMINAL, 0, 0);
- - input_set_abs_params(dev, ABS_Y, YMIN_NOMINAL, YMAX_NOMINAL, 0, 0);
- + input_set_abs_params(dev, ABS_X, NORMALIZED_X(XMIN_NOMINAL), NORMALIZED_X(XMAX_NOMINAL), 0, 0);
- + input_set_abs_params(dev, ABS_Y, NORMALIZED_Y(YMIN_NOMINAL), NORMALIZED_Y(YMAX_NOMINAL), 0, 0);
- input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
- set_bit(ABS_TOOL_WIDTH, dev->absbit);
- diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
- index 02aa4cf..0836d60 100644
- --- a/drivers/input/mouse/synaptics.h
- +++ b/drivers/input/mouse/synaptics.h
- @@ -101,6 +101,8 @@ struct synaptics_data {
- unsigned char pkt_type; /* packet type - old, new, etc */
- unsigned char mode; /* current mode byte */
- int scroll;
- + int x_scale;
- + int y_scale;
- };
- int synaptics_detect(struct psmouse *psmouse, int set_properties);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement