aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2016-07-13 12:06:14 -0400
committerJiri Kosina <jkosina@suse.cz>2016-08-05 07:39:21 -0400
commit6a06281e2bfb6f59aa3290c459981471b4940a39 (patch)
tree98163dcd6116018bbb2d58f837751331ad3e085e /drivers/hid
parent5a0fe8abd169be4f2e1f73ad851419d502b5a832 (diff)
HID: wacom: leds: handle Cintiq 24HD leds buttons
The 24HD has 1 button per LED (first three buttons of each group). We need a special treatment for them as it's not a uniq button that switches between the LEDs. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Acked-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/wacom_wac.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index a9693d5d2e93..0914667585ce 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -2763,18 +2763,47 @@ static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
2763 __set_bit(BTN_BASE + (i-16), input_dev->keybit); 2763 __set_bit(BTN_BASE + (i-16), input_dev->keybit);
2764} 2764}
2765 2765
2766static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
2767{
2768 struct wacom_led *led;
2769 int i;
2770 bool updated = false;
2771
2772 /*
2773 * 24HD has LED group 1 to the left and LED group 0 to the right.
2774 * So group 0 matches the second half of the buttons and thus the mask
2775 * needs to be shifted.
2776 */
2777 if (group == 0)
2778 mask >>= 8;
2779
2780 for (i = 0; i < 3; i++) {
2781 led = wacom_led_find(wacom, group, i);
2782 if (!led) {
2783 hid_err(wacom->hdev, "can't find LED %d in group %d\n",
2784 i, group);
2785 continue;
2786 }
2787 if (!updated && mask & BIT(i)) {
2788 led->held = true;
2789 led_trigger_event(&led->trigger, LED_FULL);
2790 } else {
2791 led->held = false;
2792 }
2793 }
2794}
2795
2766static bool wacom_is_led_toggled(struct wacom *wacom, int button_count, 2796static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
2767 int mask, int group) 2797 int mask, int group)
2768{ 2798{
2769 int button_per_group; 2799 int button_per_group;
2770 2800
2771 /* 2801 /*
2772 * 24HD and 21UX2 have LED group 1 to the left and LED group 0 2802 * 21UX2 has LED group 1 to the left and LED group 0
2773 * to the right. We need to reverse the group to match this 2803 * to the right. We need to reverse the group to match this
2774 * historical behavior. 2804 * historical behavior.
2775 */ 2805 */
2776 if (wacom->wacom_wac.features.type == WACOM_24HD || 2806 if (wacom->wacom_wac.features.type == WACOM_21UX2)
2777 wacom->wacom_wac.features.type == WACOM_21UX2)
2778 group = 1 - group; 2807 group = 1 - group;
2779 2808
2780 button_per_group = button_count/wacom->led.count; 2809 button_per_group = button_count/wacom->led.count;
@@ -2789,6 +2818,9 @@ static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
2789 int cur; 2818 int cur;
2790 bool pressed; 2819 bool pressed;
2791 2820
2821 if (wacom->wacom_wac.features.type == WACOM_24HD)
2822 return wacom_24hd_update_leds(wacom, mask, group);
2823
2792 pressed = wacom_is_led_toggled(wacom, button_count, mask, group); 2824 pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
2793 cur = wacom->led.groups[group].select; 2825 cur = wacom->led.groups[group].select;
2794 2826