Skip to content

Commit 973d690

Browse files
author
Jiri Kosina
committed
Merge branches 'for-6.14/wacom' and 'for-6.14/wacom-pci' into for-linus
- improvement of behavior for non-standard LED brightness values (Jason Gerecke) - PCI Wacom device supports (depends on Intel THC support) (Even Xu)
3 parents 5a68172 + d2c3423 + c4c1235 commit 973d690

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

drivers/hid/wacom.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ static inline __u32 wacom_s32tou(s32 value, __u8 n)
218218
return value & (1 << (n - 1)) ? value & (~(~0U << n)) : value;
219219
}
220220

221+
static inline u32 wacom_rescale(u32 value, u32 in_max, u32 out_max)
222+
{
223+
if (in_max == 0 || out_max == 0)
224+
return 0;
225+
value = clamp(value, 0, in_max);
226+
return DIV_ROUND_CLOSEST(value * out_max, in_max);
227+
}
228+
221229
extern const struct hid_device_id wacom_ids[];
222230

223231
void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);

drivers/hid/wacom_sys.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,17 @@ static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest,
10841084
mutex_lock(&wacom->lock);
10851085

10861086
*dest = value & 0x7f;
1087+
for (unsigned int i = 0; i < wacom->led.count; i++) {
1088+
struct wacom_group_leds *group = &wacom->led.groups[i];
1089+
1090+
for (unsigned int j = 0; j < group->count; j++) {
1091+
if (dest == &wacom->led.llv)
1092+
group->leds[j].llv = *dest;
1093+
else if (dest == &wacom->led.hlv)
1094+
group->leds[j].hlv = *dest;
1095+
}
1096+
}
1097+
10871098
err = wacom_led_control(wacom);
10881099

10891100
mutex_unlock(&wacom->lock);
@@ -1302,10 +1313,10 @@ enum led_brightness wacom_leds_brightness_get(struct wacom_led *led)
13021313
struct wacom *wacom = led->wacom;
13031314

13041315
if (wacom->led.max_hlv)
1305-
return led->hlv * LED_FULL / wacom->led.max_hlv;
1316+
return wacom_rescale(led->hlv, wacom->led.max_hlv, LED_FULL);
13061317

13071318
if (wacom->led.max_llv)
1308-
return led->llv * LED_FULL / wacom->led.max_llv;
1319+
return wacom_rescale(led->llv, wacom->led.max_llv, LED_FULL);
13091320

13101321
/* device doesn't support brightness tuning */
13111322
return LED_FULL;
@@ -1337,8 +1348,8 @@ static int wacom_led_brightness_set(struct led_classdev *cdev,
13371348
goto out;
13381349
}
13391350

1340-
led->llv = wacom->led.llv = wacom->led.max_llv * brightness / LED_FULL;
1341-
led->hlv = wacom->led.hlv = wacom->led.max_hlv * brightness / LED_FULL;
1351+
led->llv = wacom->led.llv = wacom_rescale(brightness, LED_FULL, wacom->led.max_llv);
1352+
led->hlv = wacom->led.hlv = wacom_rescale(brightness, LED_FULL, wacom->led.max_hlv);
13421353

13431354
wacom->led.groups[led->group].select = led->id;
13441355

drivers/hid/wacom_wac.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4946,6 +4946,10 @@ static const struct wacom_features wacom_features_0x94 =
49464946
HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
49474947
.driver_data = (kernel_ulong_t)&wacom_features_##prod
49484948

4949+
#define PCI_DEVICE_WACOM(prod) \
4950+
HID_DEVICE(BUS_PCI, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
4951+
.driver_data = (kernel_ulong_t)&wacom_features_##prod
4952+
49494953
#define USB_DEVICE_LENOVO(prod) \
49504954
HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
49514955
.driver_data = (kernel_ulong_t)&wacom_features_##prod
@@ -5115,6 +5119,7 @@ const struct hid_device_id wacom_ids[] = {
51155119

51165120
{ USB_DEVICE_WACOM(HID_ANY_ID) },
51175121
{ I2C_DEVICE_WACOM(HID_ANY_ID) },
5122+
{ PCI_DEVICE_WACOM(HID_ANY_ID) },
51185123
{ BT_DEVICE_WACOM(HID_ANY_ID) },
51195124
{ }
51205125
};

0 commit comments

Comments
 (0)