diff options
author | Jason Childs <oblivian@users.sourceforge.net> | 2010-02-18 01:38:31 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-02-19 04:25:16 -0500 |
commit | e33da8a5486aaadf5161118869e6cfb3d119beea (patch) | |
tree | ff5819b0f2e192557f6d9848698a65d988ee8983 /drivers/input/tablet/wacom_sys.c | |
parent | 4e45ad5e89128939c671e927f030cb3909fe1d69 (diff) |
Input: wacom - use per-device instance of wacom_features
Since we mangle data in wacom_features when dealing with certain devices let's
use a private (per-device) instance of wacom_features in wacom_wac. This way
same product ID can support more than one type of device, such as pen and touch,
and not interfere with each other.
Signed-off-by: Jason Childs <oblivian@users.sourceforge.net>
Signed-off-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/tablet/wacom_sys.c')
-rw-r--r-- | drivers/input/tablet/wacom_sys.c | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index be4b76f264a7..f22b88d03c6c 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
@@ -211,7 +211,8 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | |||
211 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | | 211 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_RUBBER) | |
212 | BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) | | 212 | BIT_MASK(BTN_TOOL_PEN) | BIT_MASK(BTN_STYLUS) | |
213 | BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); | 213 | BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_STYLUS2); |
214 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); | 214 | input_set_abs_params(input_dev, ABS_DISTANCE, |
215 | 0, wacom_wac->features.distance_max, 0, 0); | ||
215 | } | 216 | } |
216 | 217 | ||
217 | void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 218 | void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
@@ -261,7 +262,8 @@ void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | |||
261 | BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) | | 262 | BIT_MASK(BTN_TOOL_MOUSE) | BIT_MASK(BTN_TOOL_BRUSH) | |
262 | BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) | | 263 | BIT_MASK(BTN_TOOL_PENCIL) | BIT_MASK(BTN_TOOL_AIRBRUSH) | |
263 | BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2); | 264 | BIT_MASK(BTN_TOOL_LENS) | BIT_MASK(BTN_STYLUS2); |
264 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); | 265 | input_set_abs_params(input_dev, ABS_DISTANCE, |
266 | 0, wacom_wac->features.distance_max, 0, 0); | ||
265 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); | 267 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); |
266 | input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); | 268 | input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); |
267 | input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); | 269 | input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); |
@@ -282,17 +284,19 @@ void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | |||
282 | 284 | ||
283 | void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 285 | void input_dev_tpc(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
284 | { | 286 | { |
285 | if (wacom_wac->features->device_type == BTN_TOOL_DOUBLETAP || | 287 | struct wacom_features *features = &wacom_wac->features; |
286 | wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { | 288 | |
287 | input_set_abs_params(input_dev, ABS_RX, 0, wacom_wac->features->x_phy, 0, 0); | 289 | if (features->device_type == BTN_TOOL_DOUBLETAP || |
288 | input_set_abs_params(input_dev, ABS_RY, 0, wacom_wac->features->y_phy, 0, 0); | 290 | features->device_type == BTN_TOOL_TRIPLETAP) { |
289 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_DOUBLETAP); | 291 | input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0); |
292 | input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0); | ||
293 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
290 | } | 294 | } |
291 | } | 295 | } |
292 | 296 | ||
293 | void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac) | 297 | void input_dev_tpc2fg(struct input_dev *input_dev, struct wacom_wac *wacom_wac) |
294 | { | 298 | { |
295 | if (wacom_wac->features->device_type == BTN_TOOL_TRIPLETAP) { | 299 | if (wacom_wac->features.device_type == BTN_TOOL_TRIPLETAP) { |
296 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP); | 300 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOOL_TRIPLETAP); |
297 | input_dev->evbit[0] |= BIT_MASK(EV_MSC); | 301 | input_dev->evbit[0] |= BIT_MASK(EV_MSC); |
298 | input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); | 302 | input_dev->mscbit[0] |= BIT_MASK(MSC_SERIAL); |
@@ -530,26 +534,40 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
530 | struct usb_endpoint_descriptor *endpoint; | 534 | struct usb_endpoint_descriptor *endpoint; |
531 | struct wacom *wacom; | 535 | struct wacom *wacom; |
532 | struct wacom_wac *wacom_wac; | 536 | struct wacom_wac *wacom_wac; |
533 | struct wacom_features *features = (void *)id->driver_info; | 537 | struct wacom_features *features; |
534 | struct input_dev *input_dev; | 538 | struct input_dev *input_dev; |
535 | int error = -ENOMEM; | 539 | int error; |
536 | 540 | ||
537 | if (!features) | 541 | if (!id->driver_info) |
538 | return -EINVAL; | 542 | return -EINVAL; |
539 | 543 | ||
540 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); | 544 | wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); |
541 | wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); | 545 | wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL); |
542 | input_dev = input_allocate_device(); | 546 | input_dev = input_allocate_device(); |
543 | if (!wacom || !input_dev || !wacom_wac) | 547 | if (!wacom || !input_dev || !wacom_wac) { |
548 | error = -ENOMEM; | ||
549 | goto fail1; | ||
550 | } | ||
551 | |||
552 | wacom_wac->features = *((struct wacom_features *)id->driver_info); | ||
553 | features = &wacom_wac->features; | ||
554 | if (features->pktlen > WACOM_PKGLEN_MAX) { | ||
555 | error = -EINVAL; | ||
544 | goto fail1; | 556 | goto fail1; |
557 | } | ||
545 | 558 | ||
546 | wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX, GFP_KERNEL, &wacom->data_dma); | 559 | wacom_wac->data = usb_buffer_alloc(dev, WACOM_PKGLEN_MAX, |
547 | if (!wacom_wac->data) | 560 | GFP_KERNEL, &wacom->data_dma); |
561 | if (!wacom_wac->data) { | ||
562 | error = -ENOMEM; | ||
548 | goto fail1; | 563 | goto fail1; |
564 | } | ||
549 | 565 | ||
550 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); | 566 | wacom->irq = usb_alloc_urb(0, GFP_KERNEL); |
551 | if (!wacom->irq) | 567 | if (!wacom->irq) { |
568 | error = -ENOMEM; | ||
552 | goto fail2; | 569 | goto fail2; |
570 | } | ||
553 | 571 | ||
554 | wacom->usbdev = dev; | 572 | wacom->usbdev = dev; |
555 | wacom->dev = input_dev; | 573 | wacom->dev = input_dev; |
@@ -558,11 +576,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
558 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); | 576 | usb_make_path(dev, wacom->phys, sizeof(wacom->phys)); |
559 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); | 577 | strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); |
560 | 578 | ||
561 | wacom_wac->features = features; | ||
562 | BUG_ON(features->pktlen > WACOM_PKGLEN_MAX); | ||
563 | |||
564 | input_dev->name = wacom_wac->features->name; | ||
565 | wacom->wacom_wac = wacom_wac; | ||
566 | usb_to_input_id(dev, &input_dev->id); | 579 | usb_to_input_id(dev, &input_dev->id); |
567 | 580 | ||
568 | input_dev->dev.parent = &intf->dev; | 581 | input_dev->dev.parent = &intf->dev; |
@@ -579,6 +592,9 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
579 | if (error) | 592 | if (error) |
580 | goto fail2; | 593 | goto fail2; |
581 | 594 | ||
595 | input_dev->name = features->name; | ||
596 | wacom->wacom_wac = wacom_wac; | ||
597 | |||
582 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 598 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
583 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH); | 599 | input_dev->keybit[BIT_WORD(BTN_DIGI)] |= BIT_MASK(BTN_TOUCH); |
584 | 600 | ||
@@ -643,7 +659,7 @@ static int wacom_suspend(struct usb_interface *intf, pm_message_t message) | |||
643 | static int wacom_resume(struct usb_interface *intf) | 659 | static int wacom_resume(struct usb_interface *intf) |
644 | { | 660 | { |
645 | struct wacom *wacom = usb_get_intfdata(intf); | 661 | struct wacom *wacom = usb_get_intfdata(intf); |
646 | struct wacom_features *features = wacom->wacom_wac->features; | 662 | struct wacom_features *features = &wacom->wacom_wac->features; |
647 | int rv; | 663 | int rv; |
648 | 664 | ||
649 | mutex_lock(&wacom->lock); | 665 | mutex_lock(&wacom->lock); |