Skip to content

Commit 2636a3f

Browse files
jigpuJiri Kosina
authored andcommitted
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: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 862cf55 commit 2636a3f

File tree

3 files changed

+131
-115
lines changed

3 files changed

+131
-115
lines changed

drivers/hid/wacom.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ extern const struct hid_device_id wacom_ids[];
135135

136136
void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
137137
void wacom_setup_device_quirks(struct wacom *wacom);
138-
int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
138+
int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
139+
struct wacom_wac *wacom_wac);
140+
int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
139141
struct wacom_wac *wacom_wac);
140142
int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
141143
struct wacom_wac *wacom_wac);

drivers/hid/wacom_sys.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,15 +1199,19 @@ static int wacom_register_inputs(struct wacom *wacom)
11991199
{
12001200
struct input_dev *input_dev, *pad_input_dev;
12011201
struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1202-
int error;
1202+
struct wacom_features *features = &wacom_wac->features;
1203+
int error = 0;
12031204

12041205
input_dev = wacom_wac->input;
12051206
pad_input_dev = wacom_wac->pad_input;
12061207

12071208
if (!input_dev || !pad_input_dev)
12081209
return -EINVAL;
12091210

1210-
error = wacom_setup_pentouch_input_capabilities(input_dev, wacom_wac);
1211+
if (features->device_type & WACOM_DEVICETYPE_PEN)
1212+
error = wacom_setup_pen_input_capabilities(input_dev, wacom_wac);
1213+
if (!error && features->device_type & WACOM_DEVICETYPE_TOUCH)
1214+
error = wacom_setup_touch_input_capabilities(input_dev, wacom_wac);
12111215
if (!error) {
12121216
error = input_register_device(input_dev);
12131217
if (error)

drivers/hid/wacom_wac.c

Lines changed: 122 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,62 +2237,34 @@ void wacom_setup_device_quirks(struct wacom *wacom)
22372237
}
22382238
}
22392239

2240-
static void wacom_abs_set_axis(struct input_dev *input_dev,
2241-
struct wacom_wac *wacom_wac)
2242-
{
2243-
struct wacom_features *features = &wacom_wac->features;
2244-
2245-
if (features->device_type & WACOM_DEVICETYPE_PEN) {
2246-
input_set_abs_params(input_dev, ABS_X, features->x_min,
2247-
features->x_max, features->x_fuzz, 0);
2248-
input_set_abs_params(input_dev, ABS_Y, features->y_min,
2249-
features->y_max, features->y_fuzz, 0);
2250-
input_set_abs_params(input_dev, ABS_PRESSURE, 0,
2251-
features->pressure_max, features->pressure_fuzz, 0);
2252-
2253-
/* penabled devices have fixed resolution for each model */
2254-
input_abs_set_res(input_dev, ABS_X, features->x_resolution);
2255-
input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
2256-
} else if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
2257-
if (features->touch_max == 1) {
2258-
input_set_abs_params(input_dev, ABS_X, 0,
2259-
features->x_max, features->x_fuzz, 0);
2260-
input_set_abs_params(input_dev, ABS_Y, 0,
2261-
features->y_max, features->y_fuzz, 0);
2262-
input_abs_set_res(input_dev, ABS_X,
2263-
features->x_resolution);
2264-
input_abs_set_res(input_dev, ABS_Y,
2265-
features->y_resolution);
2266-
}
2267-
2268-
if (features->touch_max > 1) {
2269-
input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
2270-
features->x_max, features->x_fuzz, 0);
2271-
input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
2272-
features->y_max, features->y_fuzz, 0);
2273-
input_abs_set_res(input_dev, ABS_MT_POSITION_X,
2274-
features->x_resolution);
2275-
input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
2276-
features->y_resolution);
2277-
}
2278-
}
2279-
}
2280-
2281-
int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
2240+
int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
22822241
struct wacom_wac *wacom_wac)
22832242
{
22842243
struct wacom_features *features = &wacom_wac->features;
22852244

22862245
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
22872246

2247+
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
2248+
return -ENODEV;
2249+
22882250
if (features->type == HID_GENERIC)
22892251
/* setup has already been done */
22902252
return 0;
22912253

22922254
__set_bit(BTN_TOUCH, input_dev->keybit);
22932255
__set_bit(ABS_MISC, input_dev->absbit);
22942256

2295-
wacom_abs_set_axis(input_dev, wacom_wac);
2257+
input_set_abs_params(input_dev, ABS_X, features->x_min,
2258+
features->x_max, features->x_fuzz, 0);
2259+
input_set_abs_params(input_dev, ABS_Y, features->y_min,
2260+
features->y_max, features->y_fuzz, 0);
2261+
input_set_abs_params(input_dev, ABS_PRESSURE, 0,
2262+
features->pressure_max, features->pressure_fuzz, 0);
2263+
2264+
/* penabled devices have fixed resolution for each model */
2265+
input_abs_set_res(input_dev, ABS_X, features->x_resolution);
2266+
input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
2267+
22962268

22972269
switch (features->type) {
22982270
case GRAPHIRE_BT:
@@ -2361,53 +2333,25 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
23612333
case INTUOSPS:
23622334
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
23632335

2364-
if (features->device_type & WACOM_DEVICETYPE_PEN) {
2365-
input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2366-
features->distance_max,
2367-
0, 0);
2368-
2369-
input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
2370-
input_abs_set_res(input_dev, ABS_Z, 287);
2336+
input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2337+
features->distance_max,
2338+
0, 0);
23712339

2372-
wacom_setup_intuos(wacom_wac);
2373-
} else if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
2374-
__clear_bit(ABS_MISC, input_dev->absbit);
2340+
input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
2341+
input_abs_set_res(input_dev, ABS_Z, 287);
23752342

2376-
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
2377-
0, features->x_max, 0, 0);
2378-
input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
2379-
0, features->y_max, 0, 0);
2380-
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
2381-
}
2343+
wacom_setup_intuos(wacom_wac);
23822344
break;
23832345

23842346
case WACOM_24HDT:
2385-
if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
2386-
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
2387-
input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
2388-
input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
2389-
input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2390-
}
2391-
/* fall through */
2392-
23932347
case WACOM_27QHDT:
23942348
case MTSCREEN:
23952349
case MTTPC:
23962350
case MTTPC_B:
23972351
case TABLETPC2FG:
2398-
if (features->device_type & WACOM_DEVICETYPE_TOUCH && features->touch_max > 1)
2399-
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
2400-
/* fall through */
2401-
24022352
case TABLETPC:
24032353
case TABLETPCE:
24042354
__clear_bit(ABS_MISC, input_dev->absbit);
2405-
2406-
__set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2407-
2408-
if (!(features->device_type & WACOM_DEVICETYPE_PEN))
2409-
break; /* no need to process stylus stuff */
2410-
24112355
/* fall through */
24122356

24132357
case DTUS:
@@ -2435,48 +2379,114 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
24352379
break;
24362380

24372381
case INTUOSHT:
2438-
if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
2439-
input_dev->evbit[0] |= BIT_MASK(EV_SW);
2440-
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
2441-
}
2442-
/* fall through */
2443-
24442382
case BAMBOO_PT:
24452383
__clear_bit(ABS_MISC, input_dev->absbit);
24462384

2447-
if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
2448-
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
2449-
input_set_abs_params(input_dev,
2450-
ABS_MT_TOUCH_MAJOR,
2451-
0, features->x_max, 0, 0);
2452-
input_set_abs_params(input_dev,
2453-
ABS_MT_TOUCH_MINOR,
2454-
0, features->y_max, 0, 0);
2455-
}
2456-
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
2457-
}
2458-
if (features->device_type & WACOM_DEVICETYPE_PAD) {
2459-
/* buttons/keys only interface */
2460-
__clear_bit(ABS_X, input_dev->absbit);
2461-
__clear_bit(ABS_Y, input_dev->absbit);
2462-
__clear_bit(BTN_TOUCH, input_dev->keybit);
2385+
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2386+
__set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2387+
__set_bit(BTN_TOOL_PEN, input_dev->keybit);
2388+
__set_bit(BTN_STYLUS, input_dev->keybit);
2389+
__set_bit(BTN_STYLUS2, input_dev->keybit);
2390+
input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2391+
features->distance_max,
2392+
0, 0);
2393+
break;
2394+
case BAMBOO_PAD:
2395+
__clear_bit(ABS_MISC, input_dev->absbit);
2396+
break;
2397+
}
2398+
return 0;
2399+
}
24632400

2464-
/* PAD is setup by wacom_setup_pad_input_capabilities later */
2465-
return 1;
2466-
}
2467-
if (features->device_type & WACOM_DEVICETYPE_PEN) {
2468-
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2469-
__set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
2470-
__set_bit(BTN_TOOL_PEN, input_dev->keybit);
2471-
__set_bit(BTN_STYLUS, input_dev->keybit);
2472-
__set_bit(BTN_STYLUS2, input_dev->keybit);
2473-
input_set_abs_params(input_dev, ABS_DISTANCE, 0,
2474-
features->distance_max,
2475-
0, 0);
2401+
int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
2402+
struct wacom_wac *wacom_wac)
2403+
{
2404+
struct wacom_features *features = &wacom_wac->features;
2405+
2406+
input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
2407+
2408+
if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
2409+
return -ENODEV;
2410+
2411+
if (features->type == HID_GENERIC)
2412+
/* setup has already been done */
2413+
return 0;
2414+
2415+
__set_bit(BTN_TOUCH, input_dev->keybit);
2416+
2417+
if (features->touch_max == 1) {
2418+
input_set_abs_params(input_dev, ABS_X, 0,
2419+
features->x_max, features->x_fuzz, 0);
2420+
input_set_abs_params(input_dev, ABS_Y, 0,
2421+
features->y_max, features->y_fuzz, 0);
2422+
input_abs_set_res(input_dev, ABS_X,
2423+
features->x_resolution);
2424+
input_abs_set_res(input_dev, ABS_Y,
2425+
features->y_resolution);
2426+
}
2427+
else if (features->touch_max > 1) {
2428+
input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
2429+
features->x_max, features->x_fuzz, 0);
2430+
input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
2431+
features->y_max, features->y_fuzz, 0);
2432+
input_abs_set_res(input_dev, ABS_MT_POSITION_X,
2433+
features->x_resolution);
2434+
input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
2435+
features->y_resolution);
2436+
}
2437+
2438+
switch (features->type) {
2439+
case INTUOS5:
2440+
case INTUOS5L:
2441+
case INTUOSPM:
2442+
case INTUOSPL:
2443+
case INTUOS5S:
2444+
case INTUOSPS:
2445+
__set_bit(INPUT_PROP_POINTER, input_dev->propbit);
2446+
2447+
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
2448+
input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
2449+
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
2450+
break;
2451+
2452+
case WACOM_24HDT:
2453+
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
2454+
input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
2455+
input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
2456+
input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
2457+
/* fall through */
2458+
2459+
case WACOM_27QHDT:
2460+
case MTSCREEN:
2461+
case MTTPC:
2462+
case MTTPC_B:
2463+
case TABLETPC2FG:
2464+
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
2465+
/*fall through */
2466+
2467+
case TABLETPC:
2468+
case TABLETPCE:
2469+
__set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
2470+
break;
2471+
2472+
case INTUOSHT:
2473+
input_dev->evbit[0] |= BIT_MASK(EV_SW);
2474+
__set_bit(SW_MUTE_DEVICE, input_dev->swbit);
2475+
/* fall through */
2476+
2477+
case BAMBOO_PT:
2478+
if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
2479+
input_set_abs_params(input_dev,
2480+
ABS_MT_TOUCH_MAJOR,
2481+
0, features->x_max, 0, 0);
2482+
input_set_abs_params(input_dev,
2483+
ABS_MT_TOUCH_MINOR,
2484+
0, features->y_max, 0, 0);
24762485
}
2486+
input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
24772487
break;
2488+
24782489
case BAMBOO_PAD:
2479-
__clear_bit(ABS_MISC, input_dev->absbit);
24802490
input_mt_init_slots(input_dev, features->touch_max,
24812491
INPUT_MT_POINTER);
24822492
__set_bit(BTN_LEFT, input_dev->keybit);

0 commit comments

Comments
 (0)