提交 ec20a022 编写于 作者: T Tero Saarni 提交者: Dmitry Torokhov

Input: synaptics - add support for reporting x/y resolution

Synaptics uses anisotropic coordinate system.  On some wide touchpads
vertical resolution can be twice as high as horizontal which causes
unequal sensitivity on x/y directions.  Add support for reading the
resolution with EVIOCGABS ioctl.
Signed-off-by: NTero Saarni <tero.saarni@gmail.com>
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
上级 d7ed5d88
...@@ -626,8 +626,11 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, ...@@ -626,8 +626,11 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
abs.maximum = dev->absmax[t]; abs.maximum = dev->absmax[t];
abs.fuzz = dev->absfuzz[t]; abs.fuzz = dev->absfuzz[t];
abs.flat = dev->absflat[t]; abs.flat = dev->absflat[t];
abs.resolution = dev->absres[t];
if (copy_to_user(p, &abs, sizeof(struct input_absinfo))) if (copy_to_user(p, &abs, min_t(size_t,
_IOC_SIZE(cmd),
sizeof(struct input_absinfo))))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -654,8 +657,9 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, ...@@ -654,8 +657,9 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
t = _IOC_NR(cmd) & ABS_MAX; t = _IOC_NR(cmd) & ABS_MAX;
if (copy_from_user(&abs, p, if (copy_from_user(&abs, p, min_t(size_t,
sizeof(struct input_absinfo))) _IOC_SIZE(cmd),
sizeof(struct input_absinfo))))
return -EFAULT; return -EFAULT;
/* /*
...@@ -670,6 +674,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, ...@@ -670,6 +674,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
dev->absmax[t] = abs.maximum; dev->absmax[t] = abs.maximum;
dev->absfuzz[t] = abs.fuzz; dev->absfuzz[t] = abs.fuzz;
dev->absflat[t] = abs.flat; dev->absflat[t] = abs.flat;
dev->absres[t] = _IOC_SIZE(cmd) < sizeof(struct input_absinfo) ?
0 : abs.resolution;
spin_unlock_irq(&dev->event_lock); spin_unlock_irq(&dev->event_lock);
......
...@@ -180,6 +180,29 @@ static int synaptics_identify(struct psmouse *psmouse) ...@@ -180,6 +180,29 @@ static int synaptics_identify(struct psmouse *psmouse)
return -1; return -1;
} }
/*
* Read touchpad resolution
* Resolution is left zero if touchpad does not support the query
*/
static int synaptics_resolution(struct psmouse *psmouse)
{
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 */
}
return 0;
}
static int synaptics_query_hardware(struct psmouse *psmouse) static int synaptics_query_hardware(struct psmouse *psmouse)
{ {
if (synaptics_identify(psmouse)) if (synaptics_identify(psmouse))
...@@ -188,6 +211,8 @@ static int synaptics_query_hardware(struct psmouse *psmouse) ...@@ -188,6 +211,8 @@ static int synaptics_query_hardware(struct psmouse *psmouse)
return -1; return -1;
if (synaptics_capability(psmouse)) if (synaptics_capability(psmouse))
return -1; return -1;
if (synaptics_resolution(psmouse))
return -1;
return 0; return 0;
} }
...@@ -563,6 +588,9 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) ...@@ -563,6 +588,9 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
clear_bit(EV_REL, dev->evbit); clear_bit(EV_REL, dev->evbit);
clear_bit(REL_X, dev->relbit); clear_bit(REL_X, dev->relbit);
clear_bit(REL_Y, 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) static void synaptics_disconnect(struct psmouse *psmouse)
......
...@@ -97,6 +97,8 @@ struct synaptics_data { ...@@ -97,6 +97,8 @@ struct synaptics_data {
unsigned long int capabilities; /* Capabilities */ unsigned long int capabilities; /* Capabilities */
unsigned long int ext_cap; /* Extended Capabilities */ unsigned long int ext_cap; /* Extended Capabilities */
unsigned long int identity; /* Identification */ unsigned long int identity; /* Identification */
int x_res; /* X resolution in units/mm */
int y_res; /* Y resolution in units/mm */
unsigned char pkt_type; /* packet type - old, new, etc */ unsigned char pkt_type; /* packet type - old, new, etc */
unsigned char mode; /* current mode byte */ unsigned char mode; /* current mode byte */
......
...@@ -53,6 +53,7 @@ struct input_absinfo { ...@@ -53,6 +53,7 @@ struct input_absinfo {
__s32 maximum; __s32 maximum;
__s32 fuzz; __s32 fuzz;
__s32 flat; __s32 flat;
__s32 resolution;
}; };
#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ #define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */
...@@ -1109,6 +1110,7 @@ struct input_dev { ...@@ -1109,6 +1110,7 @@ struct input_dev {
int absmin[ABS_MAX + 1]; int absmin[ABS_MAX + 1];
int absfuzz[ABS_MAX + 1]; int absfuzz[ABS_MAX + 1];
int absflat[ABS_MAX + 1]; int absflat[ABS_MAX + 1];
int absres[ABS_MAX + 1];
int (*open)(struct input_dev *dev); int (*open)(struct input_dev *dev);
void (*close)(struct input_dev *dev); void (*close)(struct input_dev *dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册