Commit 2636a3f2 authored by Jason Gerecke's avatar Jason Gerecke Committed by Jiri Kosina

HID: wacom: Split apart 'wacom_setup_pentouch_input_capabilites'

This splits the 'wacom_setup_pentouch_input_capabilites' function into
pieces dedicated to doing setup for just the pen interface and just
the touch interface. This makes it easier to focus on the relevant
piece when making changes.

This patch introduces no functional changes.
Signed-off-by: default avatarJason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 862cf553
...@@ -135,7 +135,9 @@ extern const struct hid_device_id wacom_ids[]; ...@@ -135,7 +135,9 @@ extern const struct hid_device_id wacom_ids[];
void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
void wacom_setup_device_quirks(struct wacom *wacom); void wacom_setup_device_quirks(struct wacom *wacom);
int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac);
int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac); struct wacom_wac *wacom_wac);
int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac); struct wacom_wac *wacom_wac);
......
...@@ -1199,7 +1199,8 @@ static int wacom_register_inputs(struct wacom *wacom) ...@@ -1199,7 +1199,8 @@ static int wacom_register_inputs(struct wacom *wacom)
{ {
struct input_dev *input_dev, *pad_input_dev; struct input_dev *input_dev, *pad_input_dev;
struct wacom_wac *wacom_wac = &(wacom->wacom_wac); struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
int error; struct wacom_features *features = &wacom_wac->features;
int error = 0;
input_dev = wacom_wac->input; input_dev = wacom_wac->input;
pad_input_dev = wacom_wac->pad_input; pad_input_dev = wacom_wac->pad_input;
...@@ -1207,7 +1208,10 @@ static int wacom_register_inputs(struct wacom *wacom) ...@@ -1207,7 +1208,10 @@ static int wacom_register_inputs(struct wacom *wacom)
if (!input_dev || !pad_input_dev) if (!input_dev || !pad_input_dev)
return -EINVAL; return -EINVAL;
error = wacom_setup_pentouch_input_capabilities(input_dev, wacom_wac); if (features->device_type & WACOM_DEVICETYPE_PEN)
error = wacom_setup_pen_input_capabilities(input_dev, wacom_wac);
if (!error && features->device_type & WACOM_DEVICETYPE_TOUCH)
error = wacom_setup_touch_input_capabilities(input_dev, wacom_wac);
if (!error) { if (!error) {
error = input_register_device(input_dev); error = input_register_device(input_dev);
if (error) if (error)
......
...@@ -2237,12 +2237,23 @@ void wacom_setup_device_quirks(struct wacom *wacom) ...@@ -2237,12 +2237,23 @@ void wacom_setup_device_quirks(struct wacom *wacom)
} }
} }
static void wacom_abs_set_axis(struct input_dev *input_dev, int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac) struct wacom_wac *wacom_wac)
{ {
struct wacom_features *features = &wacom_wac->features; struct wacom_features *features = &wacom_wac->features;
if (features->device_type & WACOM_DEVICETYPE_PEN) { input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
return -ENODEV;
if (features->type == HID_GENERIC)
/* setup has already been done */
return 0;
__set_bit(BTN_TOUCH, input_dev->keybit);
__set_bit(ABS_MISC, input_dev->absbit);
input_set_abs_params(input_dev, ABS_X, features->x_min, input_set_abs_params(input_dev, ABS_X, features->x_min,
features->x_max, features->x_fuzz, 0); features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_Y, features->y_min, input_set_abs_params(input_dev, ABS_Y, features->y_min,
...@@ -2253,46 +2264,7 @@ static void wacom_abs_set_axis(struct input_dev *input_dev, ...@@ -2253,46 +2264,7 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,
/* penabled devices have fixed resolution for each model */ /* penabled devices have fixed resolution for each model */
input_abs_set_res(input_dev, ABS_X, features->x_resolution); input_abs_set_res(input_dev, ABS_X, features->x_resolution);
input_abs_set_res(input_dev, ABS_Y, features->y_resolution); input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
} else if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
if (features->touch_max == 1) {
input_set_abs_params(input_dev, ABS_X, 0,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_Y, 0,
features->y_max, features->y_fuzz, 0);
input_abs_set_res(input_dev, ABS_X,
features->x_resolution);
input_abs_set_res(input_dev, ABS_Y,
features->y_resolution);
}
if (features->touch_max > 1) {
input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
features->y_max, features->y_fuzz, 0);
input_abs_set_res(input_dev, ABS_MT_POSITION_X,
features->x_resolution);
input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
features->y_resolution);
}
}
}
int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac)
{
struct wacom_features *features = &wacom_wac->features;
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
if (features->type == HID_GENERIC)
/* setup has already been done */
return 0;
__set_bit(BTN_TOUCH, input_dev->keybit);
__set_bit(ABS_MISC, input_dev->absbit);
wacom_abs_set_axis(input_dev, wacom_wac);
switch (features->type) { switch (features->type) {
case GRAPHIRE_BT: case GRAPHIRE_BT:
...@@ -2361,7 +2333,6 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, ...@@ -2361,7 +2333,6 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
case INTUOSPS: case INTUOSPS:
__set_bit(INPUT_PROP_POINTER, input_dev->propbit); __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
if (features->device_type & WACOM_DEVICETYPE_PEN) {
input_set_abs_params(input_dev, ABS_DISTANCE, 0, input_set_abs_params(input_dev, ABS_DISTANCE, 0,
features->distance_max, features->distance_max,
0, 0); 0, 0);
...@@ -2370,44 +2341,17 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, ...@@ -2370,44 +2341,17 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
input_abs_set_res(input_dev, ABS_Z, 287); input_abs_set_res(input_dev, ABS_Z, 287);
wacom_setup_intuos(wacom_wac); wacom_setup_intuos(wacom_wac);
} else if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
__clear_bit(ABS_MISC, input_dev->absbit);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
0, features->y_max, 0, 0);
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
}
break; break;
case WACOM_24HDT: case WACOM_24HDT:
if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
}
/* fall through */
case WACOM_27QHDT: case WACOM_27QHDT:
case MTSCREEN: case MTSCREEN:
case MTTPC: case MTTPC:
case MTTPC_B: case MTTPC_B:
case TABLETPC2FG: case TABLETPC2FG:
if (features->device_type & WACOM_DEVICETYPE_TOUCH && features->touch_max > 1)
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
/* fall through */
case TABLETPC: case TABLETPC:
case TABLETPCE: case TABLETPCE:
__clear_bit(ABS_MISC, input_dev->absbit); __clear_bit(ABS_MISC, input_dev->absbit);
__set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
break; /* no need to process stylus stuff */
/* fall through */ /* fall through */
case DTUS: case DTUS:
...@@ -2435,16 +2379,102 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, ...@@ -2435,16 +2379,102 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
break; break;
case INTUOSHT: case INTUOSHT:
if (features->device_type & WACOM_DEVICETYPE_TOUCH) { case BAMBOO_PT:
__clear_bit(ABS_MISC, input_dev->absbit);
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
__set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
__set_bit(BTN_TOOL_PEN, input_dev->keybit);
__set_bit(BTN_STYLUS, input_dev->keybit);
__set_bit(BTN_STYLUS2, input_dev->keybit);
input_set_abs_params(input_dev, ABS_DISTANCE, 0,
features->distance_max,
0, 0);
break;
case BAMBOO_PAD:
__clear_bit(ABS_MISC, input_dev->absbit);
break;
}
return 0;
}
int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
struct wacom_wac *wacom_wac)
{
struct wacom_features *features = &wacom_wac->features;
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
return -ENODEV;
if (features->type == HID_GENERIC)
/* setup has already been done */
return 0;
__set_bit(BTN_TOUCH, input_dev->keybit);
if (features->touch_max == 1) {
input_set_abs_params(input_dev, ABS_X, 0,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_Y, 0,
features->y_max, features->y_fuzz, 0);
input_abs_set_res(input_dev, ABS_X,
features->x_resolution);
input_abs_set_res(input_dev, ABS_Y,
features->y_resolution);
}
else if (features->touch_max > 1) {
input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
features->x_max, features->x_fuzz, 0);
input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
features->y_max, features->y_fuzz, 0);
input_abs_set_res(input_dev, ABS_MT_POSITION_X,
features->x_resolution);
input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
features->y_resolution);
}
switch (features->type) {
case INTUOS5:
case INTUOS5L:
case INTUOSPM:
case INTUOSPL:
case INTUOS5S:
case INTUOSPS:
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
break;
case WACOM_24HDT:
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
/* fall through */
case WACOM_27QHDT:
case MTSCREEN:
case MTTPC:
case MTTPC_B:
case TABLETPC2FG:
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
/*fall through */
case TABLETPC:
case TABLETPCE:
__set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
break;
case INTUOSHT:
input_dev->evbit[0] |= BIT_MASK(EV_SW); input_dev->evbit[0] |= BIT_MASK(EV_SW);
__set_bit(SW_MUTE_DEVICE, input_dev->swbit); __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
}
/* fall through */ /* fall through */
case BAMBOO_PT: case BAMBOO_PT:
__clear_bit(ABS_MISC, input_dev->absbit);
if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
input_set_abs_params(input_dev, input_set_abs_params(input_dev,
ABS_MT_TOUCH_MAJOR, ABS_MT_TOUCH_MAJOR,
...@@ -2454,29 +2484,9 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, ...@@ -2454,29 +2484,9 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
0, features->y_max, 0, 0); 0, features->y_max, 0, 0);
} }
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
}
if (features->device_type & WACOM_DEVICETYPE_PAD) {
/* buttons/keys only interface */
__clear_bit(ABS_X, input_dev->absbit);
__clear_bit(ABS_Y, input_dev->absbit);
__clear_bit(BTN_TOUCH, input_dev->keybit);
/* PAD is setup by wacom_setup_pad_input_capabilities later */
return 1;
}
if (features->device_type & WACOM_DEVICETYPE_PEN) {
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
__set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
__set_bit(BTN_TOOL_PEN, input_dev->keybit);
__set_bit(BTN_STYLUS, input_dev->keybit);
__set_bit(BTN_STYLUS2, input_dev->keybit);
input_set_abs_params(input_dev, ABS_DISTANCE, 0,
features->distance_max,
0, 0);
}
break; break;
case BAMBOO_PAD: case BAMBOO_PAD:
__clear_bit(ABS_MISC, input_dev->absbit);
input_mt_init_slots(input_dev, features->touch_max, input_mt_init_slots(input_dev, features->touch_max,
INPUT_MT_POINTER); INPUT_MT_POINTER);
__set_bit(BTN_LEFT, input_dev->keybit); __set_bit(BTN_LEFT, input_dev->keybit);
......
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