Input: psmouse - use boolean type
[linux-2.6.git] / drivers / input / mouse / synaptics.c
index 865fc69..b66ff1a 100644 (file)
@@ -60,7 +60,7 @@ static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode)
        return 0;
 }
 
-int synaptics_detect(struct psmouse *psmouse, int set_properties)
+int synaptics_detect(struct psmouse *psmouse, bool set_properties)
 {
        struct ps2dev *ps2dev = &psmouse->ps2dev;
        unsigned char param[4];
@@ -180,19 +180,39 @@ static int synaptics_identify(struct psmouse *psmouse)
        return -1;
 }
 
-static int synaptics_query_hardware(struct psmouse *psmouse)
+/*
+ * Read touchpad resolution
+ * Resolution is left zero if touchpad does not support the query
+ */
+static int synaptics_resolution(struct psmouse *psmouse)
 {
-       int retries = 0;
+       struct synaptics_data *priv = psmouse->private;
+       unsigned char res[3];
+
+       if (SYN_ID_MAJOR(priv->identity) < 4)
+               return 0;
+
+       if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, res))
+               return 0;
+
+       if ((res[0] != 0) && (res[1] & 0x80) && (res[2] != 0)) {
+               priv->x_res = res[0]; /* x resolution in units/mm */
+               priv->y_res = res[2]; /* y resolution in units/mm */
+       }
 
-       while ((retries++ < 3) && psmouse_reset(psmouse))
-               /* empty */;
+       return 0;
+}
 
+static int synaptics_query_hardware(struct psmouse *psmouse)
+{
        if (synaptics_identify(psmouse))
                return -1;
        if (synaptics_model_id(psmouse))
                return -1;
        if (synaptics_capability(psmouse))
                return -1;
+       if (synaptics_resolution(psmouse))
+               return -1;
 
        return 0;
 }
@@ -536,38 +556,41 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
 {
        int i;
 
-       set_bit(EV_ABS, dev->evbit);
+       __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_PRESSURE, 0, 255, 0, 0);
-       set_bit(ABS_TOOL_WIDTH, dev->absbit);
+       __set_bit(ABS_TOOL_WIDTH, dev->absbit);
 
-       set_bit(EV_KEY, dev->evbit);
-       set_bit(BTN_TOUCH, dev->keybit);
-       set_bit(BTN_TOOL_FINGER, dev->keybit);
-       set_bit(BTN_LEFT, dev->keybit);
-       set_bit(BTN_RIGHT, dev->keybit);
+       __set_bit(EV_KEY, dev->evbit);
+       __set_bit(BTN_TOUCH, dev->keybit);
+       __set_bit(BTN_TOOL_FINGER, dev->keybit);
+       __set_bit(BTN_LEFT, dev->keybit);
+       __set_bit(BTN_RIGHT, dev->keybit);
 
        if (SYN_CAP_MULTIFINGER(priv->capabilities)) {
-               set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
-               set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
+               __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
+               __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
        }
 
        if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities))
-               set_bit(BTN_MIDDLE, dev->keybit);
+               __set_bit(BTN_MIDDLE, dev->keybit);
 
        if (SYN_CAP_FOUR_BUTTON(priv->capabilities) ||
            SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) {
-               set_bit(BTN_FORWARD, dev->keybit);
-               set_bit(BTN_BACK, dev->keybit);
+               __set_bit(BTN_FORWARD, dev->keybit);
+               __set_bit(BTN_BACK, dev->keybit);
        }
 
        for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap); i++)
-               set_bit(BTN_0 + i, dev->keybit);
+               __set_bit(BTN_0 + i, dev->keybit);
+
+       __clear_bit(EV_REL, dev->evbit);
+       __clear_bit(REL_X, dev->relbit);
+       __clear_bit(REL_Y, dev->relbit);
 
-       clear_bit(EV_REL, dev->evbit);
-       clear_bit(REL_X, dev->relbit);
-       clear_bit(REL_Y, dev->relbit);
+       dev->absres[ABS_X] = priv->x_res;
+       dev->absres[ABS_Y] = priv->y_res;
 }
 
 static void synaptics_disconnect(struct psmouse *psmouse)
@@ -582,6 +605,8 @@ static int synaptics_reconnect(struct psmouse *psmouse)
        struct synaptics_data *priv = psmouse->private;
        struct synaptics_data old_priv = *priv;
 
+       psmouse_reset(psmouse);
+
        if (synaptics_detect(psmouse, 0))
                return -1;
 
@@ -640,6 +665,8 @@ int synaptics_init(struct psmouse *psmouse)
        if (!priv)
                return -1;
 
+       psmouse_reset(psmouse);
+
        if (synaptics_query_hardware(psmouse)) {
                printk(KERN_ERR "Unable to query Synaptics hardware.\n");
                goto init_fail;