Skip to content

Commit fb59a52

Browse files
author
Jiri Kosina
committed
Merge branch 'for-6.10/kye' into for-linus
2 parents 611d9ca + f273cbf commit fb59a52

File tree

1 file changed

+44
-31
lines changed

1 file changed

+44
-31
lines changed

drivers/hid/hid-kye.c

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static const __u8 pensketch_t609a_control_rdesc[] = {
209209
0xC0 /* End Collection */
210210
};
211211

212-
/* Fix indexes in kye_tablet_fixup if you change this */
212+
/* Fix indexes in kye_tablet_fixup() if you change this */
213213
static const __u8 kye_tablet_rdesc[] = {
214214
0x06, 0x00, 0xFF, /* Usage Page (FF00h), */
215215
0x09, 0x01, /* Usage (01h), */
@@ -262,12 +262,16 @@ static const __u8 kye_tablet_rdesc[] = {
262262
0x27, 0xFF, 0x07, 0x00, 0x00, /* Logical Maximum (2047), */
263263
0x81, 0x02, /* Input (Variable), */
264264
0xC0, /* End Collection, */
265-
0xC0, /* End Collection, */
266-
0x05, 0x0D, /* Usage Page (Digitizer), */
267-
0x09, 0x21, /* Usage (Puck), */
265+
0xC0 /* End Collection, */
266+
};
267+
268+
/* Fix indexes in kye_tablet_fixup() if you change this */
269+
static const __u8 kye_tablet_mouse_rdesc[] = {
270+
0x05, 0x01, /* Usage Page (Desktop), */
271+
0x09, 0x02, /* Usage (Mouse), */
268272
0xA1, 0x01, /* Collection (Application), */
269273
0x85, 0x11, /* Report ID (17), */
270-
0x09, 0x21, /* Usage (Puck), */
274+
0x09, 0x01, /* Usage (Pointer), */
271275
0xA0, /* Collection (Physical), */
272276
0x05, 0x09, /* Usage Page (Button), */
273277
0x19, 0x01, /* Usage Minimum (01h), */
@@ -280,7 +284,7 @@ static const __u8 kye_tablet_rdesc[] = {
280284
0x95, 0x04, /* Report Count (4), */
281285
0x81, 0x01, /* Input (Constant), */
282286
0x05, 0x0D, /* Usage Page (Digitizer), */
283-
0x09, 0x32, /* Usage (In Range), */
287+
0x09, 0x37, /* Usage (Data Valid), */
284288
0x95, 0x01, /* Report Count (1), */
285289
0x81, 0x02, /* Input (Variable), */
286290
0x05, 0x01, /* Usage Page (Desktop), */
@@ -317,7 +321,7 @@ static const struct kye_tablet_info {
317321
__s32 y_physical_maximum;
318322
__s8 unit_exponent;
319323
__s8 unit;
320-
bool has_punk;
324+
bool has_mouse;
321325
unsigned int control_rsize;
322326
const __u8 *control_rdesc;
323327
} kye_tablets_info[] = {
@@ -402,7 +406,7 @@ static __u8 *kye_consumer_control_fixup(struct hid_device *hdev, __u8 *rdesc,
402406
static __u8 *kye_tablet_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int *rsize)
403407
{
404408
const struct kye_tablet_info *info;
405-
unsigned int newsize;
409+
__u8 *newdesc = rdesc;
406410

407411
if (*rsize < sizeof(kye_tablet_rdesc)) {
408412
hid_warn(hdev,
@@ -420,36 +424,45 @@ static __u8 *kye_tablet_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int
420424
return rdesc;
421425
}
422426

423-
newsize = info->has_punk ? sizeof(kye_tablet_rdesc) : 112;
424-
memcpy(rdesc, kye_tablet_rdesc, newsize);
425-
426-
put_unaligned_le32(info->x_logical_maximum, rdesc + 66);
427-
put_unaligned_le32(info->x_physical_maximum, rdesc + 72);
428-
rdesc[77] = info->unit;
429-
rdesc[79] = info->unit_exponent;
430-
put_unaligned_le32(info->y_logical_maximum, rdesc + 87);
431-
put_unaligned_le32(info->y_physical_maximum, rdesc + 92);
432-
put_unaligned_le32(info->pressure_logical_maximum, rdesc + 104);
433-
434-
if (info->has_punk) {
435-
put_unaligned_le32(info->x_logical_maximum, rdesc + 156);
436-
put_unaligned_le32(info->x_physical_maximum, rdesc + 162);
437-
rdesc[167] = info->unit;
438-
rdesc[169] = info->unit_exponent;
439-
put_unaligned_le32(info->y_logical_maximum, rdesc + 177);
440-
put_unaligned_le32(info->y_physical_maximum, rdesc + 182);
427+
memcpy(newdesc, kye_tablet_rdesc, sizeof(kye_tablet_rdesc));
428+
429+
put_unaligned_le32(info->x_logical_maximum, newdesc + 66);
430+
put_unaligned_le32(info->x_physical_maximum, newdesc + 72);
431+
newdesc[77] = info->unit;
432+
newdesc[79] = info->unit_exponent;
433+
put_unaligned_le32(info->y_logical_maximum, newdesc + 87);
434+
put_unaligned_le32(info->y_physical_maximum, newdesc + 92);
435+
put_unaligned_le32(info->pressure_logical_maximum, newdesc + 104);
436+
437+
newdesc += sizeof(kye_tablet_rdesc);
438+
439+
if (info->has_mouse) {
440+
if (newdesc + sizeof(kye_tablet_mouse_rdesc) > rdesc + *rsize)
441+
hid_err(hdev, "control desc unexpectedly large\n");
442+
else {
443+
memcpy(newdesc, kye_tablet_mouse_rdesc, sizeof(kye_tablet_mouse_rdesc));
444+
445+
put_unaligned_le32(info->x_logical_maximum, newdesc + 44);
446+
put_unaligned_le32(info->x_physical_maximum, newdesc + 50);
447+
newdesc[55] = info->unit;
448+
newdesc[57] = info->unit_exponent;
449+
put_unaligned_le32(info->y_logical_maximum, newdesc + 65);
450+
put_unaligned_le32(info->y_physical_maximum, newdesc + 70);
451+
452+
newdesc += sizeof(kye_tablet_mouse_rdesc);
453+
}
441454
}
442455

443456
if (info->control_rsize) {
444-
if (newsize + info->control_rsize > *rsize)
445-
hid_err(hdev, "control rdesc unexpectedly large");
457+
if (newdesc + info->control_rsize > rdesc + *rsize)
458+
hid_err(hdev, "control desc unexpectedly large\n");
446459
else {
447-
memcpy(rdesc + newsize, info->control_rdesc, info->control_rsize);
448-
newsize += info->control_rsize;
460+
memcpy(newdesc, info->control_rdesc, info->control_rsize);
461+
newdesc += info->control_rsize;
449462
}
450463
}
451464

452-
*rsize = newsize;
465+
*rsize = newdesc - rdesc;
453466
return rdesc;
454467
}
455468

0 commit comments

Comments
 (0)