diff options
author | Ping Cheng <pinglinux@gmail.com> | 2011-10-05 02:51:14 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-10-05 03:26:21 -0400 |
commit | 09e7d9410764f96f83ebf4a435028ac5e6240af6 (patch) | |
tree | d13102a4df693056017abd632376f026c5220618 /drivers | |
parent | 77e82516a69ad7dd10ada425930ba35e933abcfb (diff) |
Input: wacom - add LED support for Cintiq 21ux2
Cintiq 21ux2 has two sets of four LEDs on right and left side of
the tablet, respectively.
Reviewed-by: Eduard Hasenleithner <eduard@hasenleithner.at>
Tested-by: Eduard Hasenleithner <eduard@hasenleithner.at>
Signed-off-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/tablet/wacom.h | 10 | ||||
-rw-r--r-- | drivers/input/tablet/wacom_sys.c | 98 |
2 files changed, 78 insertions, 30 deletions
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h index 561f1072343b..0783864a7dc2 100644 --- a/drivers/input/tablet/wacom.h +++ b/drivers/input/tablet/wacom.h | |||
@@ -11,7 +11,7 @@ | |||
11 | * Copyright (c) 2000 Daniel Egger <egger@suse.de> | 11 | * Copyright (c) 2000 Daniel Egger <egger@suse.de> |
12 | * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com> | 12 | * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com> |
13 | * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be> | 13 | * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be> |
14 | * Copyright (c) 2002-2009 Ping Cheng <pingc@wacom.com> | 14 | * Copyright (c) 2002-2011 Ping Cheng <pingc@wacom.com> |
15 | * | 15 | * |
16 | * ChangeLog: | 16 | * ChangeLog: |
17 | * v0.1 (vp) - Initial release | 17 | * v0.1 (vp) - Initial release |
@@ -93,7 +93,7 @@ | |||
93 | /* | 93 | /* |
94 | * Version Information | 94 | * Version Information |
95 | */ | 95 | */ |
96 | #define DRIVER_VERSION "v1.52" | 96 | #define DRIVER_VERSION "v1.53" |
97 | #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" | 97 | #define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" |
98 | #define DRIVER_DESC "USB Wacom tablet driver" | 98 | #define DRIVER_DESC "USB Wacom tablet driver" |
99 | #define DRIVER_LICENSE "GPL" | 99 | #define DRIVER_LICENSE "GPL" |
@@ -115,9 +115,9 @@ struct wacom { | |||
115 | bool open; | 115 | bool open; |
116 | char phys[32]; | 116 | char phys[32]; |
117 | struct wacom_led { | 117 | struct wacom_led { |
118 | u8 select; /* status led selector (0..3) */ | 118 | u8 select[2]; /* status led selector (0..3) */ |
119 | u8 llv; /* status led brightness no button (1..127) */ | 119 | u8 llv; /* status led brightness no button (1..127) */ |
120 | u8 hlv; /* status led brightness button pressed (1..127) */ | 120 | u8 hlv; /* status led brightness button pressed (1..127) */ |
121 | u8 img_lum; /* OLED matrix display brightness */ | 121 | u8 img_lum; /* OLED matrix display brightness */ |
122 | } led; | 122 | } led; |
123 | }; | 123 | }; |
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 4f5e62a1621d..abe5920e2cdb 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
@@ -493,14 +493,19 @@ static void wacom_remove_shared_data(struct wacom_wac *wacom) | |||
493 | static int wacom_led_control(struct wacom *wacom) | 493 | static int wacom_led_control(struct wacom *wacom) |
494 | { | 494 | { |
495 | unsigned char *buf; | 495 | unsigned char *buf; |
496 | int retval; | 496 | int retval, led = 0; |
497 | 497 | ||
498 | buf = kzalloc(9, GFP_KERNEL); | 498 | buf = kzalloc(9, GFP_KERNEL); |
499 | if (!buf) | 499 | if (!buf) |
500 | return -ENOMEM; | 500 | return -ENOMEM; |
501 | 501 | ||
502 | if (wacom->wacom_wac.features.type == WACOM_21UX2) | ||
503 | led = (wacom->led.select[1] << 4) | 0x40; | ||
504 | |||
505 | led |= wacom->led.select[0] | 0x4; | ||
506 | |||
502 | buf[0] = WAC_CMD_LED_CONTROL; | 507 | buf[0] = WAC_CMD_LED_CONTROL; |
503 | buf[1] = wacom->led.select >= 0 ? wacom->led.select | 4 : 0; | 508 | buf[1] = led; |
504 | buf[2] = wacom->led.llv; | 509 | buf[2] = wacom->led.llv; |
505 | buf[3] = wacom->led.hlv; | 510 | buf[3] = wacom->led.hlv; |
506 | buf[4] = wacom->led.img_lum; | 511 | buf[4] = wacom->led.img_lum; |
@@ -552,8 +557,7 @@ out: | |||
552 | return retval; | 557 | return retval; |
553 | } | 558 | } |
554 | 559 | ||
555 | static ssize_t wacom_led_select_store(struct device *dev, | 560 | static ssize_t wacom_led_select_store(struct device *dev, int set_id, |
556 | struct device_attribute *attr, | ||
557 | const char *buf, size_t count) | 561 | const char *buf, size_t count) |
558 | { | 562 | { |
559 | struct wacom *wacom = dev_get_drvdata(dev); | 563 | struct wacom *wacom = dev_get_drvdata(dev); |
@@ -566,7 +570,7 @@ static ssize_t wacom_led_select_store(struct device *dev, | |||
566 | 570 | ||
567 | mutex_lock(&wacom->lock); | 571 | mutex_lock(&wacom->lock); |
568 | 572 | ||
569 | wacom->led.select = id; | 573 | wacom->led.select[set_id] = id & 0x3; |
570 | err = wacom_led_control(wacom); | 574 | err = wacom_led_control(wacom); |
571 | 575 | ||
572 | mutex_unlock(&wacom->lock); | 576 | mutex_unlock(&wacom->lock); |
@@ -574,7 +578,17 @@ static ssize_t wacom_led_select_store(struct device *dev, | |||
574 | return err < 0 ? err : count; | 578 | return err < 0 ? err : count; |
575 | } | 579 | } |
576 | 580 | ||
577 | static DEVICE_ATTR(status_led_select, S_IWUSR, NULL, wacom_led_select_store); | 581 | #define DEVICE_LED_SELECT_ATTR(SET_ID) \ |
582 | static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \ | ||
583 | struct device_attribute *attr, const char *buf, size_t count) \ | ||
584 | { \ | ||
585 | return wacom_led_select_store(dev, SET_ID, buf, count); \ | ||
586 | } \ | ||
587 | static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR, NULL, \ | ||
588 | wacom_led##SET_ID##_select_store) | ||
589 | |||
590 | DEVICE_LED_SELECT_ATTR(0); | ||
591 | DEVICE_LED_SELECT_ATTR(1); | ||
578 | 592 | ||
579 | static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, | 593 | static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, |
580 | const char *buf, size_t count) | 594 | const char *buf, size_t count) |
@@ -648,10 +662,21 @@ DEVICE_BTNIMG_ATTR(5); | |||
648 | DEVICE_BTNIMG_ATTR(6); | 662 | DEVICE_BTNIMG_ATTR(6); |
649 | DEVICE_BTNIMG_ATTR(7); | 663 | DEVICE_BTNIMG_ATTR(7); |
650 | 664 | ||
651 | static struct attribute *wacom_led_attrs[] = { | 665 | static struct attribute *cintiq_led_attrs[] = { |
666 | &dev_attr_status_led0_select.attr, | ||
667 | &dev_attr_status_led1_select.attr, | ||
668 | NULL | ||
669 | }; | ||
670 | |||
671 | static struct attribute_group cintiq_led_attr_group = { | ||
672 | .name = "wacom_led", | ||
673 | .attrs = cintiq_led_attrs, | ||
674 | }; | ||
675 | |||
676 | static struct attribute *intuos4_led_attrs[] = { | ||
652 | &dev_attr_status0_luminance.attr, | 677 | &dev_attr_status0_luminance.attr, |
653 | &dev_attr_status1_luminance.attr, | 678 | &dev_attr_status1_luminance.attr, |
654 | &dev_attr_status_led_select.attr, | 679 | &dev_attr_status_led0_select.attr, |
655 | &dev_attr_buttons_luminance.attr, | 680 | &dev_attr_buttons_luminance.attr, |
656 | &dev_attr_button0_rawimg.attr, | 681 | &dev_attr_button0_rawimg.attr, |
657 | &dev_attr_button1_rawimg.attr, | 682 | &dev_attr_button1_rawimg.attr, |
@@ -664,43 +689,66 @@ static struct attribute *wacom_led_attrs[] = { | |||
664 | NULL | 689 | NULL |
665 | }; | 690 | }; |
666 | 691 | ||
667 | static struct attribute_group wacom_led_attr_group = { | 692 | static struct attribute_group intuos4_led_attr_group = { |
668 | .name = "wacom_led", | 693 | .name = "wacom_led", |
669 | .attrs = wacom_led_attrs, | 694 | .attrs = intuos4_led_attrs, |
670 | }; | 695 | }; |
671 | 696 | ||
672 | static int wacom_initialize_leds(struct wacom *wacom) | 697 | static int wacom_initialize_leds(struct wacom *wacom) |
673 | { | 698 | { |
674 | int error; | 699 | int error; |
675 | 700 | ||
676 | if (wacom->wacom_wac.features.type >= INTUOS4 && | 701 | /* Initialize default values */ |
677 | wacom->wacom_wac.features.type <= INTUOS4L) { | 702 | switch (wacom->wacom_wac.features.type) { |
678 | 703 | case INTUOS4: | |
679 | /* Initialize default values */ | 704 | case INTUOS4L: |
680 | wacom->led.select = 0; | 705 | wacom->led.select[0] = 0; |
706 | wacom->led.select[1] = 0; | ||
681 | wacom->led.llv = 10; | 707 | wacom->led.llv = 10; |
682 | wacom->led.hlv = 20; | 708 | wacom->led.hlv = 20; |
683 | wacom->led.img_lum = 10; | 709 | wacom->led.img_lum = 10; |
684 | wacom_led_control(wacom); | 710 | error = sysfs_create_group(&wacom->intf->dev.kobj, |
711 | &intuos4_led_attr_group); | ||
712 | break; | ||
713 | |||
714 | case WACOM_21UX2: | ||
715 | wacom->led.select[0] = 0; | ||
716 | wacom->led.select[1] = 0; | ||
717 | wacom->led.llv = 0; | ||
718 | wacom->led.hlv = 0; | ||
719 | wacom->led.img_lum = 0; | ||
685 | 720 | ||
686 | error = sysfs_create_group(&wacom->intf->dev.kobj, | 721 | error = sysfs_create_group(&wacom->intf->dev.kobj, |
687 | &wacom_led_attr_group); | 722 | &cintiq_led_attr_group); |
688 | if (error) { | 723 | break; |
689 | dev_err(&wacom->intf->dev, | 724 | |
690 | "cannot create sysfs group err: %d\n", error); | 725 | default: |
691 | return error; | 726 | return 0; |
692 | } | 727 | } |
728 | |||
729 | if (error) { | ||
730 | dev_err(&wacom->intf->dev, | ||
731 | "cannot create sysfs group err: %d\n", error); | ||
732 | return error; | ||
693 | } | 733 | } |
734 | wacom_led_control(wacom); | ||
694 | 735 | ||
695 | return 0; | 736 | return 0; |
696 | } | 737 | } |
697 | 738 | ||
698 | static void wacom_destroy_leds(struct wacom *wacom) | 739 | static void wacom_destroy_leds(struct wacom *wacom) |
699 | { | 740 | { |
700 | if (wacom->wacom_wac.features.type >= INTUOS4 && | 741 | switch (wacom->wacom_wac.features.type) { |
701 | wacom->wacom_wac.features.type <= INTUOS4L) { | 742 | case INTUOS4: |
743 | case INTUOS4L: | ||
702 | sysfs_remove_group(&wacom->intf->dev.kobj, | 744 | sysfs_remove_group(&wacom->intf->dev.kobj, |
703 | &wacom_led_attr_group); | 745 | &intuos4_led_attr_group); |
746 | break; | ||
747 | |||
748 | case WACOM_21UX2: | ||
749 | sysfs_remove_group(&wacom->intf->dev.kobj, | ||
750 | &cintiq_led_attr_group); | ||
751 | break; | ||
704 | } | 752 | } |
705 | } | 753 | } |
706 | 754 | ||