diff options
-rw-r--r-- | drivers/hid/wacom_sys.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index f5c9c56c0975..a12cd9c3a6ee 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #define WAC_CMD_LED_CONTROL 0x20 | 20 | #define WAC_CMD_LED_CONTROL 0x20 |
21 | #define WAC_CMD_ICON_START 0x21 | 21 | #define WAC_CMD_ICON_START 0x21 |
22 | #define WAC_CMD_ICON_XFER 0x23 | 22 | #define WAC_CMD_ICON_XFER 0x23 |
23 | #define WAC_CMD_ICON_BT_XFER 0x26 | ||
23 | #define WAC_CMD_RETRIES 10 | 24 | #define WAC_CMD_RETRIES 10 |
24 | 25 | ||
25 | static int wacom_get_report(struct hid_device *hdev, u8 type, u8 id, | 26 | static int wacom_get_report(struct hid_device *hdev, u8 type, u8 id, |
@@ -526,12 +527,14 @@ static int wacom_led_control(struct wacom *wacom) | |||
526 | return retval; | 527 | return retval; |
527 | } | 528 | } |
528 | 529 | ||
529 | static int wacom_led_putimage(struct wacom *wacom, int button_id, const void *img) | 530 | static int wacom_led_putimage(struct wacom *wacom, int button_id, u8 xfer_id, |
531 | const unsigned len, const void *img) | ||
530 | { | 532 | { |
531 | unsigned char *buf; | 533 | unsigned char *buf; |
532 | int i, retval; | 534 | int i, retval; |
535 | const unsigned chunk_len = len / 4; /* 4 chunks are needed to be sent */ | ||
533 | 536 | ||
534 | buf = kzalloc(259, GFP_KERNEL); | 537 | buf = kzalloc(chunk_len + 3 , GFP_KERNEL); |
535 | if (!buf) | 538 | if (!buf) |
536 | return -ENOMEM; | 539 | return -ENOMEM; |
537 | 540 | ||
@@ -543,15 +546,15 @@ static int wacom_led_putimage(struct wacom *wacom, int button_id, const void *im | |||
543 | if (retval < 0) | 546 | if (retval < 0) |
544 | goto out; | 547 | goto out; |
545 | 548 | ||
546 | buf[0] = WAC_CMD_ICON_XFER; | 549 | buf[0] = xfer_id; |
547 | buf[1] = button_id & 0x07; | 550 | buf[1] = button_id & 0x07; |
548 | for (i = 0; i < 4; i++) { | 551 | for (i = 0; i < 4; i++) { |
549 | buf[2] = i; | 552 | buf[2] = i; |
550 | memcpy(buf + 3, img + i * 256, 256); | 553 | memcpy(buf + 3, img + i * chunk_len, chunk_len); |
551 | 554 | ||
552 | retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, | 555 | retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, |
553 | WAC_CMD_ICON_XFER, | 556 | xfer_id, buf, chunk_len + 3, |
554 | buf, 259, WAC_CMD_RETRIES); | 557 | WAC_CMD_RETRIES); |
555 | if (retval < 0) | 558 | if (retval < 0) |
556 | break; | 559 | break; |
557 | } | 560 | } |
@@ -652,13 +655,23 @@ static ssize_t wacom_button_image_store(struct device *dev, int button_id, | |||
652 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 655 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
653 | struct wacom *wacom = hid_get_drvdata(hdev); | 656 | struct wacom *wacom = hid_get_drvdata(hdev); |
654 | int err; | 657 | int err; |
658 | unsigned len; | ||
659 | u8 xfer_id; | ||
655 | 660 | ||
656 | if (count != 1024) | 661 | if (hdev->bus == BUS_BLUETOOTH) { |
662 | len = 256; | ||
663 | xfer_id = WAC_CMD_ICON_BT_XFER; | ||
664 | } else { | ||
665 | len = 1024; | ||
666 | xfer_id = WAC_CMD_ICON_XFER; | ||
667 | } | ||
668 | |||
669 | if (count != len) | ||
657 | return -EINVAL; | 670 | return -EINVAL; |
658 | 671 | ||
659 | mutex_lock(&wacom->lock); | 672 | mutex_lock(&wacom->lock); |
660 | 673 | ||
661 | err = wacom_led_putimage(wacom, button_id, buf); | 674 | err = wacom_led_putimage(wacom, button_id, xfer_id, len, buf); |
662 | 675 | ||
663 | mutex_unlock(&wacom->lock); | 676 | mutex_unlock(&wacom->lock); |
664 | 677 | ||