Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Jason Gerecke and committed by
Jiri Kosina
2636a3f2 862cf553

+132 -116
+3 -1
drivers/hid/wacom.h
··· 135 135 136 136 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); 137 137 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, 139 141 struct wacom_wac *wacom_wac); 140 142 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, 141 143 struct wacom_wac *wacom_wac);
+6 -2
drivers/hid/wacom_sys.c
··· 1199 1199 { 1200 1200 struct input_dev *input_dev, *pad_input_dev; 1201 1201 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1202 - int error; 1202 + struct wacom_features *features = &wacom_wac->features; 1203 + int error = 0; 1203 1204 1204 1205 input_dev = wacom_wac->input; 1205 1206 pad_input_dev = wacom_wac->pad_input; ··· 1208 1207 if (!input_dev || !pad_input_dev) 1209 1208 return -EINVAL; 1210 1209 1211 - error = wacom_setup_pentouch_input_capabilities(input_dev, wacom_wac); 1210 + if (features->device_type & WACOM_DEVICETYPE_PEN) 1211 + error = wacom_setup_pen_input_capabilities(input_dev, wacom_wac); 1212 + if (!error && features->device_type & WACOM_DEVICETYPE_TOUCH) 1213 + error = wacom_setup_touch_input_capabilities(input_dev, wacom_wac); 1212 1214 if (!error) { 1213 1215 error = input_register_device(input_dev); 1214 1216 if (error)
+123 -113
drivers/hid/wacom_wac.c
··· 2237 2237 } 2238 2238 } 2239 2239 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, 2282 2241 struct wacom_wac *wacom_wac) 2283 2242 { 2284 2243 struct wacom_features *features = &wacom_wac->features; 2285 2244 2286 2245 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 2246 + 2247 + if (!(features->device_type & WACOM_DEVICETYPE_PEN)) 2248 + return -ENODEV; 2287 2249 2288 2250 if (features->type == HID_GENERIC) 2289 2251 /* setup has already been done */ ··· 2254 2292 __set_bit(BTN_TOUCH, input_dev->keybit); 2255 2293 __set_bit(ABS_MISC, input_dev->absbit); 2256 2294 2257 - wacom_abs_set_axis(input_dev, wacom_wac); 2295 + input_set_abs_params(input_dev, ABS_X, features->x_min, 2296 + features->x_max, features->x_fuzz, 0); 2297 + input_set_abs_params(input_dev, ABS_Y, features->y_min, 2298 + features->y_max, features->y_fuzz, 0); 2299 + input_set_abs_params(input_dev, ABS_PRESSURE, 0, 2300 + features->pressure_max, features->pressure_fuzz, 0); 2301 + 2302 + /* penabled devices have fixed resolution for each model */ 2303 + input_abs_set_res(input_dev, ABS_X, features->x_resolution); 2304 + input_abs_set_res(input_dev, ABS_Y, features->y_resolution); 2305 + 2258 2306 2259 2307 switch (features->type) { 2260 2308 case GRAPHIRE_BT: ··· 2333 2361 case INTUOSPS: 2334 2362 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 2335 2363 2336 - if (features->device_type & WACOM_DEVICETYPE_PEN) { 2337 - input_set_abs_params(input_dev, ABS_DISTANCE, 0, 2338 - features->distance_max, 2339 - 0, 0); 2364 + input_set_abs_params(input_dev, ABS_DISTANCE, 0, 2365 + features->distance_max, 2366 + 0, 0); 2340 2367 2341 - input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2342 - input_abs_set_res(input_dev, ABS_Z, 287); 2368 + input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2369 + input_abs_set_res(input_dev, ABS_Z, 287); 2343 2370 2344 - wacom_setup_intuos(wacom_wac); 2345 - } else if (features->device_type & WACOM_DEVICETYPE_TOUCH) { 2346 - __clear_bit(ABS_MISC, input_dev->absbit); 2347 - 2348 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 2349 - 0, features->x_max, 0, 0); 2350 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 2351 - 0, features->y_max, 0, 0); 2352 - input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); 2353 - } 2371 + wacom_setup_intuos(wacom_wac); 2354 2372 break; 2355 2373 2356 2374 case WACOM_24HDT: 2357 - if (features->device_type & WACOM_DEVICETYPE_TOUCH) { 2358 - input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); 2359 - input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0); 2360 - input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0); 2361 - input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); 2362 - } 2363 - /* fall through */ 2364 - 2365 2375 case WACOM_27QHDT: 2366 2376 case MTSCREEN: 2367 2377 case MTTPC: 2368 2378 case MTTPC_B: 2369 2379 case TABLETPC2FG: 2370 - if (features->device_type & WACOM_DEVICETYPE_TOUCH && features->touch_max > 1) 2371 - input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT); 2372 - /* fall through */ 2373 - 2374 2380 case TABLETPC: 2375 2381 case TABLETPCE: 2376 2382 __clear_bit(ABS_MISC, input_dev->absbit); 2377 - 2378 - __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 2379 - 2380 - if (!(features->device_type & WACOM_DEVICETYPE_PEN)) 2381 - break; /* no need to process stylus stuff */ 2382 - 2383 2383 /* fall through */ 2384 2384 2385 2385 case DTUS: ··· 2379 2435 break; 2380 2436 2381 2437 case INTUOSHT: 2382 - if (features->device_type & WACOM_DEVICETYPE_TOUCH) { 2383 - input_dev->evbit[0] |= BIT_MASK(EV_SW); 2384 - __set_bit(SW_MUTE_DEVICE, input_dev->swbit); 2385 - } 2386 - /* fall through */ 2387 - 2388 2438 case BAMBOO_PT: 2389 2439 __clear_bit(ABS_MISC, input_dev->absbit); 2390 2440 2391 - if (features->device_type & WACOM_DEVICETYPE_TOUCH) { 2392 - if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 2393 - input_set_abs_params(input_dev, 2394 - ABS_MT_TOUCH_MAJOR, 2395 - 0, features->x_max, 0, 0); 2396 - input_set_abs_params(input_dev, 2397 - ABS_MT_TOUCH_MINOR, 2398 - 0, features->y_max, 0, 0); 2399 - } 2400 - input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); 2401 - } 2402 - if (features->device_type & WACOM_DEVICETYPE_PAD) { 2403 - /* buttons/keys only interface */ 2404 - __clear_bit(ABS_X, input_dev->absbit); 2405 - __clear_bit(ABS_Y, input_dev->absbit); 2406 - __clear_bit(BTN_TOUCH, input_dev->keybit); 2407 - 2408 - /* PAD is setup by wacom_setup_pad_input_capabilities later */ 2409 - return 1; 2410 - } 2411 - if (features->device_type & WACOM_DEVICETYPE_PEN) { 2412 - __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 2413 - __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 2414 - __set_bit(BTN_TOOL_PEN, input_dev->keybit); 2415 - __set_bit(BTN_STYLUS, input_dev->keybit); 2416 - __set_bit(BTN_STYLUS2, input_dev->keybit); 2417 - input_set_abs_params(input_dev, ABS_DISTANCE, 0, 2418 - features->distance_max, 2419 - 0, 0); 2420 - } 2441 + __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 2442 + __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 2443 + __set_bit(BTN_TOOL_PEN, input_dev->keybit); 2444 + __set_bit(BTN_STYLUS, input_dev->keybit); 2445 + __set_bit(BTN_STYLUS2, input_dev->keybit); 2446 + input_set_abs_params(input_dev, ABS_DISTANCE, 0, 2447 + features->distance_max, 2448 + 0, 0); 2421 2449 break; 2422 2450 case BAMBOO_PAD: 2423 2451 __clear_bit(ABS_MISC, input_dev->absbit); 2452 + break; 2453 + } 2454 + return 0; 2455 + } 2456 + 2457 + int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, 2458 + struct wacom_wac *wacom_wac) 2459 + { 2460 + struct wacom_features *features = &wacom_wac->features; 2461 + 2462 + input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 2463 + 2464 + if (!(features->device_type & WACOM_DEVICETYPE_TOUCH)) 2465 + return -ENODEV; 2466 + 2467 + if (features->type == HID_GENERIC) 2468 + /* setup has already been done */ 2469 + return 0; 2470 + 2471 + __set_bit(BTN_TOUCH, input_dev->keybit); 2472 + 2473 + if (features->touch_max == 1) { 2474 + input_set_abs_params(input_dev, ABS_X, 0, 2475 + features->x_max, features->x_fuzz, 0); 2476 + input_set_abs_params(input_dev, ABS_Y, 0, 2477 + features->y_max, features->y_fuzz, 0); 2478 + input_abs_set_res(input_dev, ABS_X, 2479 + features->x_resolution); 2480 + input_abs_set_res(input_dev, ABS_Y, 2481 + features->y_resolution); 2482 + } 2483 + else if (features->touch_max > 1) { 2484 + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, 2485 + features->x_max, features->x_fuzz, 0); 2486 + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 2487 + features->y_max, features->y_fuzz, 0); 2488 + input_abs_set_res(input_dev, ABS_MT_POSITION_X, 2489 + features->x_resolution); 2490 + input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 2491 + features->y_resolution); 2492 + } 2493 + 2494 + switch (features->type) { 2495 + case INTUOS5: 2496 + case INTUOS5L: 2497 + case INTUOSPM: 2498 + case INTUOSPL: 2499 + case INTUOS5S: 2500 + case INTUOSPS: 2501 + __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 2502 + 2503 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); 2504 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0); 2505 + input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); 2506 + break; 2507 + 2508 + case WACOM_24HDT: 2509 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); 2510 + input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0); 2511 + input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0); 2512 + input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); 2513 + /* fall through */ 2514 + 2515 + case WACOM_27QHDT: 2516 + case MTSCREEN: 2517 + case MTTPC: 2518 + case MTTPC_B: 2519 + case TABLETPC2FG: 2520 + input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT); 2521 + /*fall through */ 2522 + 2523 + case TABLETPC: 2524 + case TABLETPCE: 2525 + __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 2526 + break; 2527 + 2528 + case INTUOSHT: 2529 + input_dev->evbit[0] |= BIT_MASK(EV_SW); 2530 + __set_bit(SW_MUTE_DEVICE, input_dev->swbit); 2531 + /* fall through */ 2532 + 2533 + case BAMBOO_PT: 2534 + if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 2535 + input_set_abs_params(input_dev, 2536 + ABS_MT_TOUCH_MAJOR, 2537 + 0, features->x_max, 0, 0); 2538 + input_set_abs_params(input_dev, 2539 + ABS_MT_TOUCH_MINOR, 2540 + 0, features->y_max, 0, 0); 2541 + } 2542 + input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); 2543 + break; 2544 + 2545 + case BAMBOO_PAD: 2424 2546 input_mt_init_slots(input_dev, features->touch_max, 2425 2547 INPUT_MT_POINTER); 2426 2548 __set_bit(BTN_LEFT, input_dev->keybit);