Skip to content

Commit 10c55ca

Browse files
skomraJiri Kosina
authored andcommitted
HID: wacom: generic: support LEDs
Add support for the LEDs around the mode switch to the generic code path in support of the second generation Intuos Pro. Signed-off-by: Aaron Skomra <[email protected]> Reviewed-by: Ping Cheng <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent d2ec58a commit 10c55ca

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

drivers/hid/wacom.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ struct wacom {
168168
struct work_struct remote_work;
169169
struct delayed_work init_work;
170170
struct wacom_remote *remote;
171+
bool generic_has_leds;
171172
struct wacom_leds {
172173
struct wacom_group_leds *groups;
173174
unsigned int count;
@@ -220,4 +221,5 @@ struct wacom_led *wacom_led_find(struct wacom *wacom, unsigned int group,
220221
unsigned int id);
221222
struct wacom_led *wacom_led_next(struct wacom *wacom, struct wacom_led *cur);
222223
int wacom_equivalent_usage(int usage);
224+
int wacom_initialize_leds(struct wacom *wacom);
223225
#endif

drivers/hid/wacom_sys.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,13 @@ static int wacom_led_control(struct wacom *wacom)
771771
if (!buf)
772772
return -ENOMEM;
773773

774-
if (wacom->wacom_wac.features.type >= INTUOS5S &&
775-
wacom->wacom_wac.features.type <= INTUOSPL) {
774+
if (wacom->wacom_wac.features.type == HID_GENERIC) {
775+
buf[0] = WAC_CMD_LED_CONTROL_GENERIC;
776+
buf[1] = wacom->led.llv;
777+
buf[2] = wacom->led.groups[0].select & 0x03;
778+
779+
} else if ((wacom->wacom_wac.features.type >= INTUOS5S &&
780+
wacom->wacom_wac.features.type <= INTUOSPL)) {
776781
/*
777782
* Touch Ring and crop mark LED luminance may take on
778783
* one of four values:
@@ -1042,6 +1047,17 @@ static struct attribute_group intuos5_led_attr_group = {
10421047
.attrs = intuos5_led_attrs,
10431048
};
10441049

1050+
static struct attribute *generic_led_attrs[] = {
1051+
&dev_attr_status0_luminance.attr,
1052+
&dev_attr_status_led0_select.attr,
1053+
NULL
1054+
};
1055+
1056+
static struct attribute_group generic_led_attr_group = {
1057+
.name = "wacom_led",
1058+
.attrs = generic_led_attrs,
1059+
};
1060+
10451061
struct wacom_sysfs_group_devres {
10461062
struct attribute_group *group;
10471063
struct kobject *root;
@@ -1363,7 +1379,7 @@ static int wacom_leds_alloc_and_register(struct wacom *wacom, int group_count,
13631379
return 0;
13641380
}
13651381

1366-
static int wacom_initialize_leds(struct wacom *wacom)
1382+
int wacom_initialize_leds(struct wacom *wacom)
13671383
{
13681384
int error;
13691385

@@ -1372,6 +1388,23 @@ static int wacom_initialize_leds(struct wacom *wacom)
13721388

13731389
/* Initialize default values */
13741390
switch (wacom->wacom_wac.features.type) {
1391+
case HID_GENERIC:
1392+
if (!wacom->generic_has_leds)
1393+
return 0;
1394+
wacom->led.llv = 100;
1395+
wacom->led.max_llv = 100;
1396+
1397+
error = wacom_leds_alloc_and_register(wacom, 1, 4, false);
1398+
if (error) {
1399+
hid_err(wacom->hdev,
1400+
"cannot create leds err: %d\n", error);
1401+
return error;
1402+
}
1403+
1404+
error = wacom_devm_sysfs_create_group(wacom,
1405+
&generic_led_attr_group);
1406+
break;
1407+
13751408
case INTUOS4S:
13761409
case INTUOS4:
13771410
case INTUOS4WL:

drivers/hid/wacom_wac.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ static void wacom_report_numbered_buttons(struct input_dev *input_dev,
4343

4444
static int wacom_numbered_button_to_key(int n);
4545

46+
static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
47+
int group);
4648
/*
4749
* Percent of battery capacity for Graphire.
4850
* 8th value means AC online and show 100% capacity.
@@ -1715,12 +1717,14 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
17151717
wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
17161718
features->device_type |= WACOM_DEVICETYPE_PAD;
17171719
break;
1720+
case WACOM_HID_WD_BUTTONCENTER:
1721+
wacom->generic_has_leds = true;
1722+
/* fall through */
17181723
case WACOM_HID_WD_BUTTONHOME:
17191724
case WACOM_HID_WD_BUTTONUP:
17201725
case WACOM_HID_WD_BUTTONDOWN:
17211726
case WACOM_HID_WD_BUTTONLEFT:
17221727
case WACOM_HID_WD_BUTTONRIGHT:
1723-
case WACOM_HID_WD_BUTTONCENTER:
17241728
wacom_map_usage(input, usage, field, EV_KEY,
17251729
wacom_numbered_button_to_key(features->numbered_buttons),
17261730
0);
@@ -1797,7 +1801,9 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
17971801
struct wacom *wacom = hid_get_drvdata(hdev);
17981802
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
17991803
struct input_dev *input = wacom_wac->pad_input;
1804+
struct wacom_features *features = &wacom_wac->features;
18001805
unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
1806+
int i;
18011807

18021808
/*
18031809
* Avoid reporting this event and setting inrange_state if this usage
@@ -1824,6 +1830,12 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
18241830
input_sync(wacom_wac->shared->touch_input);
18251831
}
18261832
break;
1833+
1834+
case WACOM_HID_WD_BUTTONCENTER:
1835+
for (i = 0; i < wacom->led.count; i++)
1836+
wacom_update_led(wacom, features->numbered_buttons,
1837+
value, i);
1838+
/* fall through*/
18271839
default:
18281840
input_event(input, usage->type, usage->code, value);
18291841
break;

drivers/hid/wacom_wac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
#define WAC_CMD_ICON_XFER 0x23
8080
#define WAC_CMD_ICON_BT_XFER 0x26
8181
#define WAC_CMD_DELETE_PAIRING 0x20
82+
#define WAC_CMD_LED_CONTROL_GENERIC 0x32
8283
#define WAC_CMD_UNPAIR_ALL 0xFF
8384
#define WAC_CMD_WL_INTUOSP2 0x82
8485

0 commit comments

Comments
 (0)