Commit 5d0a4fe2 authored by Peter Hutterer's avatar Peter Hutterer Committed by Dmitry Torokhov

Input: wacom_w8001 - split pen and touch initialization up

This is preparation work for splitting it up for two event nodes.
Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
Acked-by: default avatarBenjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent e1717354
...@@ -380,12 +380,10 @@ static void w8001_close(struct input_dev *dev) ...@@ -380,12 +380,10 @@ static void w8001_close(struct input_dev *dev)
w8001_command(w8001, W8001_CMD_STOP, false); w8001_command(w8001, W8001_CMD_STOP, false);
} }
static int w8001_setup(struct w8001 *w8001) static int w8001_detect(struct w8001 *w8001)
{ {
struct input_dev *dev = w8001->dev; struct input_dev *dev = w8001->dev;
struct w8001_coord coord; int error;
struct w8001_touch_query touch;
int error, err_pen, err_touch;
error = w8001_command(w8001, W8001_CMD_STOP, false); error = w8001_command(w8001, W8001_CMD_STOP, false);
if (error) if (error)
...@@ -399,9 +397,20 @@ static int w8001_setup(struct w8001 *w8001) ...@@ -399,9 +397,20 @@ static int w8001_setup(struct w8001 *w8001)
__set_bit(INPUT_PROP_DIRECT, dev->propbit); __set_bit(INPUT_PROP_DIRECT, dev->propbit);
return 0;
}
static int w8001_setup_pen(struct w8001 *w8001)
{
struct input_dev *dev = w8001->dev;
struct w8001_coord coord;
int error;
/* penabled? */ /* penabled? */
err_pen = w8001_command(w8001, W8001_CMD_QUERY, true); error = w8001_command(w8001, W8001_CMD_QUERY, true);
if (!err_pen) { if (error)
return error;
__set_bit(BTN_TOUCH, dev->keybit); __set_bit(BTN_TOUCH, dev->keybit);
__set_bit(BTN_TOOL_PEN, dev->keybit); __set_bit(BTN_TOOL_PEN, dev->keybit);
__set_bit(BTN_TOOL_RUBBER, dev->keybit); __set_bit(BTN_TOOL_RUBBER, dev->keybit);
...@@ -421,17 +430,30 @@ static int w8001_setup(struct w8001 *w8001) ...@@ -421,17 +430,30 @@ static int w8001_setup(struct w8001 *w8001)
input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0); input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0);
input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0); input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0);
} }
w8001->id = 0x90; w8001->id = 0x90;
strlcat(w8001->name, " Penabled", sizeof(w8001->name)); strlcat(w8001->name, " Penabled", sizeof(w8001->name));
}
/* Touch enabled? */ return 0;
err_touch = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true); }
if (!err_touch && !w8001->response[1]) static int w8001_setup_touch(struct w8001 *w8001)
err_touch = -ENXIO; {
struct input_dev *dev = w8001->dev;
struct w8001_touch_query touch;
int error;
/* Touch enabled? */
error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true);
if (error)
return error;
/*
* Some non-touch devices may reply to the touch query. But their
* second byte is empty, which indicates touch is not supported.
*/
if (!w8001->response[1])
return -ENXIO;
if (!err_touch) {
__set_bit(BTN_TOUCH, dev->keybit); __set_bit(BTN_TOUCH, dev->keybit);
__set_bit(BTN_TOOL_FINGER, dev->keybit); __set_bit(BTN_TOOL_FINGER, dev->keybit);
...@@ -486,11 +508,10 @@ static int w8001_setup(struct w8001 *w8001) ...@@ -486,11 +508,10 @@ static int w8001_setup(struct w8001 *w8001)
w8001->id = 0xE2; w8001->id = 0xE2;
break; break;
} }
}
strlcat(w8001->name, " Touchscreen", sizeof(w8001->name)); strlcat(w8001->name, " Touchscreen", sizeof(w8001->name));
return !err_pen || !err_touch ? 0 : -ENXIO; return 0;
} }
/* /*
...@@ -519,7 +540,7 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv) ...@@ -519,7 +540,7 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv)
{ {
struct w8001 *w8001; struct w8001 *w8001;
struct input_dev *input_dev; struct input_dev *input_dev;
int err; int err, err_pen, err_touch;
w8001 = kzalloc(sizeof(struct w8001), GFP_KERNEL); w8001 = kzalloc(sizeof(struct w8001), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = input_allocate_device();
...@@ -538,10 +559,17 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv) ...@@ -538,10 +559,17 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv)
if (err) if (err)
goto fail2; goto fail2;
err = w8001_setup(w8001); err = w8001_detect(w8001);
if (err) if (err)
goto fail3; goto fail3;
err_pen = w8001_setup_pen(w8001);
err_touch = w8001_setup_touch(w8001);
if (err_pen && err_touch) {
err = -ENXIO;
goto fail3;
}
input_dev->name = w8001->name; input_dev->name = w8001->name;
input_dev->phys = w8001->phys; input_dev->phys = w8001->phys;
input_dev->id.product = w8001->id; input_dev->id.product = w8001->id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment