Skip to content

Commit 88b2056

Browse files
committed
uclogic: Add report descriptor size variables
Add report descriptor size variables to hid-uclogic.c to prepare for moving report descriptors to a separate module. Rename report descriptor variables for clarity.
1 parent 01372a4 commit 88b2056

1 file changed

Lines changed: 85 additions & 46 deletions

File tree

hid-uclogic.c

Lines changed: 85 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE 212
2929

3030
/* Fixed WP4030U report descriptor */
31-
static __u8 uclogic_rdesc_wp4030u_fixed[] = {
31+
static __u8 uclogic_rdesc_wp4030u_fixed_arr[] = {
3232
0x05, 0x0D, /* Usage Page (Digitizer), */
3333
0x09, 0x02, /* Usage (Pen), */
3434
0xA1, 0x01, /* Collection (Application), */
@@ -69,8 +69,11 @@ static __u8 uclogic_rdesc_wp4030u_fixed[] = {
6969
0xC0 /* End Collection */
7070
};
7171

72+
static const size_t uclogic_rdesc_wp4030u_fixed_size =
73+
sizeof(uclogic_rdesc_wp4030u_fixed_arr);
74+
7275
/* Fixed WP5540U report descriptor */
73-
static __u8 uclogic_rdesc_wp5540u_fixed[] = {
76+
static __u8 uclogic_rdesc_wp5540u_fixed_arr[] = {
7477
0x05, 0x0D, /* Usage Page (Digitizer), */
7578
0x09, 0x02, /* Usage (Pen), */
7679
0xA1, 0x01, /* Collection (Application), */
@@ -143,8 +146,11 @@ static __u8 uclogic_rdesc_wp5540u_fixed[] = {
143146
0xC0 /* End Collection */
144147
};
145148

149+
static const size_t uclogic_rdesc_wp5540u_fixed_size =
150+
sizeof(uclogic_rdesc_wp5540u_fixed_arr);
151+
146152
/* Fixed WP8060U report descriptor */
147-
static __u8 uclogic_rdesc_wp8060u_fixed[] = {
153+
static __u8 uclogic_rdesc_wp8060u_fixed_arr[] = {
148154
0x05, 0x0D, /* Usage Page (Digitizer), */
149155
0x09, 0x02, /* Usage (Pen), */
150156
0xA1, 0x01, /* Collection (Application), */
@@ -217,14 +223,17 @@ static __u8 uclogic_rdesc_wp8060u_fixed[] = {
217223
0xC0 /* End Collection */
218224
};
219225

226+
static const size_t uclogic_rdesc_wp8060u_fixed_size =
227+
sizeof(uclogic_rdesc_wp8060u_fixed_arr);
228+
220229
/* Size of the original descriptor of the new WP5540U tablet */
221230
#define UCLOGIC_RDESC_WP5540U_V2_ORIG_SIZE 232
222231

223232
/* Size of the original descriptor of WP1062 tablet */
224233
#define UCLOGIC_RDESC_WP1062_ORIG_SIZE 254
225234

226235
/* Fixed WP1062 report descriptor */
227-
static __u8 uclogic_rdesc_wp1062_fixed[] = {
236+
static __u8 uclogic_rdesc_wp1062_fixed_arr[] = {
228237
0x05, 0x0D, /* Usage Page (Digitizer), */
229238
0x09, 0x02, /* Usage (Pen), */
230239
0xA1, 0x01, /* Collection (Application), */
@@ -268,11 +277,14 @@ static __u8 uclogic_rdesc_wp1062_fixed[] = {
268277
0xC0 /* End Collection */
269278
};
270279

280+
static const size_t uclogic_rdesc_wp1062_fixed_size =
281+
sizeof(uclogic_rdesc_wp1062_fixed_arr);
282+
271283
/* Size of the original descriptor of PF1209 tablet */
272284
#define UCLOGIC_RDESC_PF1209_ORIG_SIZE 234
273285

274286
/* Fixed PF1209 report descriptor */
275-
static __u8 uclogic_rdesc_pf1209_fixed[] = {
287+
static __u8 uclogic_rdesc_pf1209_fixed_arr[] = {
276288
0x05, 0x0D, /* Usage Page (Digitizer), */
277289
0x09, 0x02, /* Usage (Pen), */
278290
0xA1, 0x01, /* Collection (Application), */
@@ -345,13 +357,16 @@ static __u8 uclogic_rdesc_pf1209_fixed[] = {
345357
0xC0 /* End Collection */
346358
};
347359

360+
static const size_t uclogic_rdesc_pf1209_fixed_size =
361+
sizeof(uclogic_rdesc_pf1209_fixed_arr);
362+
348363
/* Size of the original descriptors of TWHL850 tablet */
349364
#define UCLOGIC_RDESC_TWHL850_ORIG_SIZE0 182
350365
#define UCLOGIC_RDESC_TWHL850_ORIG_SIZE1 161
351366
#define UCLOGIC_RDESC_TWHL850_ORIG_SIZE2 92
352367

353368
/* Fixed PID 0522 tablet report descriptor, interface 0 (stylus) */
354-
static __u8 uclogic_rdesc_twhl850_fixed0[] = {
369+
static __u8 uclogic_rdesc_twhl850_fixed0_arr[] = {
355370
0x05, 0x0D, /* Usage Page (Digitizer), */
356371
0x09, 0x02, /* Usage (Pen), */
357372
0xA1, 0x01, /* Collection (Application), */
@@ -393,8 +408,11 @@ static __u8 uclogic_rdesc_twhl850_fixed0[] = {
393408
0xC0 /* End Collection */
394409
};
395410

411+
static const size_t uclogic_rdesc_twhl850_fixed0_size =
412+
sizeof(uclogic_rdesc_twhl850_fixed0_arr);
413+
396414
/* Fixed PID 0522 tablet report descriptor, interface 1 (mouse) */
397-
static __u8 uclogic_rdesc_twhl850_fixed1[] = {
415+
static __u8 uclogic_rdesc_twhl850_fixed1_arr[] = {
398416
0x05, 0x01, /* Usage Page (Desktop), */
399417
0x09, 0x02, /* Usage (Mouse), */
400418
0xA1, 0x01, /* Collection (Application), */
@@ -430,8 +448,11 @@ static __u8 uclogic_rdesc_twhl850_fixed1[] = {
430448
0xC0 /* End Collection */
431449
};
432450

451+
static const size_t uclogic_rdesc_twhl850_fixed1_size =
452+
sizeof(uclogic_rdesc_twhl850_fixed1_arr);
453+
433454
/* Fixed PID 0522 tablet report descriptor, interface 2 (frame buttons) */
434-
static __u8 uclogic_rdesc_twhl850_fixed2[] = {
455+
static __u8 uclogic_rdesc_twhl850_fixed2_arr[] = {
435456
0x05, 0x01, /* Usage Page (Desktop), */
436457
0x09, 0x06, /* Usage (Keyboard), */
437458
0xA1, 0x01, /* Collection (Application), */
@@ -453,12 +474,15 @@ static __u8 uclogic_rdesc_twhl850_fixed2[] = {
453474
0xC0 /* End Collection */
454475
};
455476

477+
static const size_t uclogic_rdesc_twhl850_fixed2_size =
478+
sizeof(uclogic_rdesc_twhl850_fixed2_arr);
479+
456480
/* Size of the original descriptors of TWHA60 tablet */
457481
#define UCLOGIC_RDESC_TWHA60_ORIG_SIZE0 254
458482
#define UCLOGIC_RDESC_TWHA60_ORIG_SIZE1 139
459483

460484
/* Fixed TWHA60 report descriptor, interface 0 (stylus) */
461-
static __u8 uclogic_rdesc_twha60_fixed0[] = {
485+
static __u8 uclogic_rdesc_twha60_fixed0_arr[] = {
462486
0x05, 0x0D, /* Usage Page (Digitizer), */
463487
0x09, 0x02, /* Usage (Pen), */
464488
0xA1, 0x01, /* Collection (Application), */
@@ -503,8 +527,11 @@ static __u8 uclogic_rdesc_twha60_fixed0[] = {
503527
0xC0 /* End Collection */
504528
};
505529

530+
static const size_t uclogic_rdesc_twha60_fixed0_size =
531+
sizeof(uclogic_rdesc_twha60_fixed0_arr);
532+
506533
/* Fixed TWHA60 report descriptor, interface 1 (frame buttons) */
507-
static __u8 uclogic_rdesc_twha60_fixed1[] = {
534+
static __u8 uclogic_rdesc_twha60_fixed1_arr[] = {
508535
0x05, 0x01, /* Usage Page (Desktop), */
509536
0x09, 0x06, /* Usage (Keyboard), */
510537
0xA1, 0x01, /* Collection (Application), */
@@ -528,6 +555,9 @@ static __u8 uclogic_rdesc_twha60_fixed1[] = {
528555
0xC0 /* End Collection */
529556
};
530557

558+
static const size_t uclogic_rdesc_twha60_fixed1_size =
559+
sizeof(uclogic_rdesc_twha60_fixed1_arr);
560+
531561
/* Report descriptor template placeholder head */
532562
#define UCLOGIC_RDESC_PH_HEAD 0xFE, 0xED, 0x1D
533563

@@ -546,7 +576,7 @@ enum uclogic_rdesc_ph_id {
546576
#define UCLOGIC_PEN_REPORT_ID 0x07
547577

548578
/* Fixed report descriptor template */
549-
static const __u8 uclogic_rdesc_tablet_template[] = {
579+
static const __u8 uclogic_rdesc_tablet_template_arr[] = {
550580
0x05, 0x0D, /* Usage Page (Digitizer), */
551581
0x09, 0x02, /* Usage (Pen), */
552582
0xA1, 0x01, /* Collection (Application), */
@@ -597,8 +627,11 @@ static const __u8 uclogic_rdesc_tablet_template[] = {
597627
0xC0 /* End Collection */
598628
};
599629

630+
static const size_t uclogic_rdesc_tablet_template_size =
631+
sizeof(uclogic_rdesc_tablet_template_arr);
632+
600633
/* Fixed report descriptor template for Ugee EX07 */
601-
static const __u8 uclogic_rdesc_ugee_ex07_template[] = {
634+
static const __u8 uclogic_rdesc_ugee_ex07_template_arr[] = {
602635
0x05, 0x0D, /* Usage Page (Digitizer), */
603636
0x09, 0x02, /* Usage (Pen), */
604637
0xA1, 0x01, /* Collection (Application), */
@@ -687,8 +720,11 @@ static const __u8 uclogic_rdesc_ugee_ex07_template[] = {
687720
0xC0 /* End Collection */
688721
};
689722

723+
static const size_t uclogic_rdesc_ugee_ex07_template_size =
724+
sizeof(uclogic_rdesc_ugee_ex07_template_arr);
725+
690726
/* Fixed virtual pad report descriptor */
691-
static const __u8 uclogic_rdesc_buttonpad[] = {
727+
static const __u8 uclogic_rdesc_buttonpad_arr[] = {
692728
0x05, 0x01, /* Usage Page (Desktop), */
693729
0x09, 0x07, /* Usage (Keypad), */
694730
0xA1, 0x01, /* Collection (Application), */
@@ -725,6 +761,9 @@ static const __u8 uclogic_rdesc_buttonpad[] = {
725761
0xC0 /* End Collection */
726762
};
727763

764+
static const size_t uclogic_rdesc_buttonpad_size =
765+
sizeof(uclogic_rdesc_buttonpad_arr);
766+
728767
/* Parameter indices */
729768
enum uclogic_prm {
730769
UCLOGIC_PRM_X_LM = 1,
@@ -761,52 +800,52 @@ static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
761800
switch (hdev->product) {
762801
case USB_DEVICE_ID_UCLOGIC_TABLET_PF1209:
763802
if (*rsize == UCLOGIC_RDESC_PF1209_ORIG_SIZE) {
764-
rdesc = uclogic_rdesc_pf1209_fixed;
765-
*rsize = sizeof(uclogic_rdesc_pf1209_fixed);
803+
rdesc = uclogic_rdesc_pf1209_fixed_arr;
804+
*rsize = uclogic_rdesc_pf1209_fixed_size;
766805
}
767806
break;
768807
case USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U:
769808
if (*rsize == UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE) {
770-
rdesc = uclogic_rdesc_wp4030u_fixed;
771-
*rsize = sizeof(uclogic_rdesc_wp4030u_fixed);
809+
rdesc = uclogic_rdesc_wp4030u_fixed_arr;
810+
*rsize = uclogic_rdesc_wp4030u_fixed_size;
772811
}
773812
break;
774813
case USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U:
775814
if (*rsize == UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE) {
776-
rdesc = uclogic_rdesc_wp5540u_fixed;
777-
*rsize = sizeof(uclogic_rdesc_wp5540u_fixed);
815+
rdesc = uclogic_rdesc_wp5540u_fixed_arr;
816+
*rsize = uclogic_rdesc_wp5540u_fixed_size;
778817
}
779818
break;
780819
case USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U:
781820
if (*rsize == UCLOGIC_RDESC_WPXXXXU_ORIG_SIZE) {
782-
rdesc = uclogic_rdesc_wp8060u_fixed;
783-
*rsize = sizeof(uclogic_rdesc_wp8060u_fixed);
821+
rdesc = uclogic_rdesc_wp8060u_fixed_arr;
822+
*rsize = uclogic_rdesc_wp8060u_fixed_size;
784823
}
785824
break;
786825
case USB_DEVICE_ID_UCLOGIC_TABLET_WP1062:
787826
if (*rsize == UCLOGIC_RDESC_WP1062_ORIG_SIZE) {
788-
rdesc = uclogic_rdesc_wp1062_fixed;
789-
*rsize = sizeof(uclogic_rdesc_wp1062_fixed);
827+
rdesc = uclogic_rdesc_wp1062_fixed_arr;
828+
*rsize = uclogic_rdesc_wp1062_fixed_size;
790829
}
791830
break;
792831
case USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850:
793832
switch (iface_num) {
794833
case 0:
795834
if (*rsize == UCLOGIC_RDESC_TWHL850_ORIG_SIZE0) {
796-
rdesc = uclogic_rdesc_twhl850_fixed0;
797-
*rsize = sizeof(uclogic_rdesc_twhl850_fixed0);
835+
rdesc = uclogic_rdesc_twhl850_fixed0_arr;
836+
*rsize = uclogic_rdesc_twhl850_fixed0_size;
798837
}
799838
break;
800839
case 1:
801840
if (*rsize == UCLOGIC_RDESC_TWHL850_ORIG_SIZE1) {
802-
rdesc = uclogic_rdesc_twhl850_fixed1;
803-
*rsize = sizeof(uclogic_rdesc_twhl850_fixed1);
841+
rdesc = uclogic_rdesc_twhl850_fixed1_arr;
842+
*rsize = uclogic_rdesc_twhl850_fixed1_size;
804843
}
805844
break;
806845
case 2:
807846
if (*rsize == UCLOGIC_RDESC_TWHL850_ORIG_SIZE2) {
808-
rdesc = uclogic_rdesc_twhl850_fixed2;
809-
*rsize = sizeof(uclogic_rdesc_twhl850_fixed2);
847+
rdesc = uclogic_rdesc_twhl850_fixed2_arr;
848+
*rsize = uclogic_rdesc_twhl850_fixed2_size;
810849
}
811850
break;
812851
}
@@ -815,14 +854,14 @@ static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
815854
switch (iface_num) {
816855
case 0:
817856
if (*rsize == UCLOGIC_RDESC_TWHA60_ORIG_SIZE0) {
818-
rdesc = uclogic_rdesc_twha60_fixed0;
819-
*rsize = sizeof(uclogic_rdesc_twha60_fixed0);
857+
rdesc = uclogic_rdesc_twha60_fixed0_arr;
858+
*rsize = uclogic_rdesc_twha60_fixed0_size;
820859
}
821860
break;
822861
case 1:
823862
if (*rsize == UCLOGIC_RDESC_TWHA60_ORIG_SIZE1) {
824-
rdesc = uclogic_rdesc_twha60_fixed1;
825-
*rsize = sizeof(uclogic_rdesc_twha60_fixed1);
863+
rdesc = uclogic_rdesc_twha60_fixed1_arr;
864+
*rsize = uclogic_rdesc_twha60_fixed1_size;
826865
}
827866
break;
828867
}
@@ -1091,7 +1130,7 @@ static int uclogic_probe_buttons(struct hid_device *hdev)
10911130
}
10921131

10931132
/* Re-allocate fixed report descriptor */
1094-
rdesc_len = drvdata->rsize + sizeof(uclogic_rdesc_buttonpad);
1133+
rdesc_len = drvdata->rsize + uclogic_rdesc_buttonpad_size;
10951134
rdesc = devm_kzalloc(&hdev->dev, rdesc_len, GFP_KERNEL);
10961135
if (!rdesc) {
10971136
rc = -ENOMEM;
@@ -1101,8 +1140,8 @@ static int uclogic_probe_buttons(struct hid_device *hdev)
11011140
memcpy(rdesc, drvdata->rdesc, drvdata->rsize);
11021141

11031142
/* Append the buttonpad descriptor */
1104-
memcpy(rdesc + drvdata->rsize, uclogic_rdesc_buttonpad,
1105-
sizeof(uclogic_rdesc_buttonpad));
1143+
memcpy(rdesc + drvdata->rsize, uclogic_rdesc_buttonpad_arr,
1144+
uclogic_rdesc_buttonpad_size);
11061145

11071146
/* clean up old rdesc and use the new one */
11081147
drvdata->rsize = rdesc_len;
@@ -1148,8 +1187,8 @@ static int uclogic_probe(struct hid_device *hdev,
11481187
if (intf->cur_altsetting->desc.bInterfaceNumber == 0) {
11491188
rc = uclogic_probe_tablet(
11501189
hdev,
1151-
uclogic_rdesc_tablet_template,
1152-
sizeof(uclogic_rdesc_tablet_template));
1190+
uclogic_rdesc_tablet_template_arr,
1191+
uclogic_rdesc_tablet_template_size);
11531192
if (rc) {
11541193
hid_err(hdev, "tablet enabling failed\n");
11551194
return rc;
@@ -1168,8 +1207,8 @@ static int uclogic_probe(struct hid_device *hdev,
11681207
if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
11691208
rc = uclogic_probe_tablet(
11701209
hdev,
1171-
uclogic_rdesc_tablet_template,
1172-
sizeof(uclogic_rdesc_tablet_template));
1210+
uclogic_rdesc_tablet_template_arr,
1211+
uclogic_rdesc_tablet_template_size);
11731212
if (rc) {
11741213
hid_err(hdev, "tablet enabling failed\n");
11751214
return rc;
@@ -1184,8 +1223,8 @@ static int uclogic_probe(struct hid_device *hdev,
11841223
if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
11851224
rc = uclogic_probe_tablet(
11861225
hdev,
1187-
uclogic_rdesc_ugee_ex07_template,
1188-
sizeof(uclogic_rdesc_ugee_ex07_template));
1226+
uclogic_rdesc_ugee_ex07_template_arr,
1227+
uclogic_rdesc_ugee_ex07_template_size);
11891228
if (rc) {
11901229
hid_err(hdev, "tablet enabling failed\n");
11911230
return rc;
@@ -1206,8 +1245,8 @@ static int uclogic_probe(struct hid_device *hdev,
12061245
if (intf->cur_altsetting->desc.bInterfaceNumber == 0) {
12071246
rc = uclogic_probe_tablet(
12081247
hdev,
1209-
uclogic_rdesc_tablet_template,
1210-
sizeof(uclogic_rdesc_tablet_template));
1248+
uclogic_rdesc_tablet_template_arr,
1249+
uclogic_rdesc_tablet_template_size);
12111250
if (rc) {
12121251
hid_err(hdev, "tablet enabling failed\n");
12131252
return rc;
@@ -1227,8 +1266,8 @@ static int uclogic_probe(struct hid_device *hdev,
12271266
intf->cur_altsetting->desc.bInterfaceNumber == 0) {
12281267
rc = uclogic_probe_tablet(
12291268
hdev,
1230-
uclogic_rdesc_tablet_template,
1231-
sizeof(uclogic_rdesc_tablet_template));
1269+
uclogic_rdesc_tablet_template_arr,
1270+
uclogic_rdesc_tablet_template_size);
12321271
if (rc) {
12331272
hid_err(hdev, "tablet enabling failed\n");
12341273
return rc;

0 commit comments

Comments
 (0)