aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet/wacom_sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/tablet/wacom_sys.c')
-rw-r--r--drivers/input/tablet/wacom_sys.c98
1 files changed, 73 insertions, 25 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 4f5e62a1621..abe5920e2cd 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)
493static int wacom_led_control(struct wacom *wacom) 493static 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
555static ssize_t wacom_led_select_store(struct device *dev, 560static 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
577static DEVICE_ATTR(status_led_select, S_IWUSR, NULL, wacom_led_select_store); 581#define DEVICE_LED_SELECT_ATTR(SET_ID) \
582static 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} \
587static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR, NULL, \
588 wacom_led##SET_ID##_select_store)
589
590DEVICE_LED_SELECT_ATTR(0);
591DEVICE_LED_SELECT_ATTR(1);
578 592
579static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, 593static 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);
648DEVICE_BTNIMG_ATTR(6); 662DEVICE_BTNIMG_ATTR(6);
649DEVICE_BTNIMG_ATTR(7); 663DEVICE_BTNIMG_ATTR(7);
650 664
651static struct attribute *wacom_led_attrs[] = { 665static struct attribute *cintiq_led_attrs[] = {
666 &dev_attr_status_led0_select.attr,
667 &dev_attr_status_led1_select.attr,
668 NULL
669};
670
671static struct attribute_group cintiq_led_attr_group = {
672 .name = "wacom_led",
673 .attrs = cintiq_led_attrs,
674};
675
676static 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
667static struct attribute_group wacom_led_attr_group = { 692static 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
672static int wacom_initialize_leds(struct wacom *wacom) 697static 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
698static void wacom_destroy_leds(struct wacom *wacom) 739static 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