Skip to content

Commit bd85c13

Browse files
JoseExpositoJiri Kosina
authored and
Jiri Kosina
committed
HID: uclogic: Refactor UGEEv2 probe magic data
A fututure patch will need to use the array of magic data that the UGEEv2 devices expect on probe and the endpoint number. Move them to a common place. Refactor, no functional changes. Tested-by: Mia Kanashi <[email protected]> Tested-by: Andreas Grosse <[email protected]> Signed-off-by: José Expósito <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent f60c377 commit bd85c13

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

drivers/hid/hid-uclogic-params.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,8 @@ static int uclogic_params_huion_init(struct uclogic_params *params,
10211021
* Returns:
10221022
* Zero, if successful. A negative errno code on error.
10231023
*/
1024-
static int uclogic_probe_interface(struct hid_device *hdev, u8 *magic_arr,
1025-
int magic_size, int endpoint)
1024+
static int uclogic_probe_interface(struct hid_device *hdev, const u8 *magic_arr,
1025+
size_t magic_size, int endpoint)
10261026
{
10271027
struct usb_device *udev;
10281028
unsigned int pipe = 0;
@@ -1311,9 +1311,6 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
13111311
__u8 *rdesc_pen = NULL;
13121312
s32 desc_params[UCLOGIC_RDESC_PH_ID_NUM];
13131313
enum uclogic_params_frame_type frame_type;
1314-
__u8 magic_arr[] = {
1315-
0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1316-
};
13171314
/* The resulting parameters (noop) */
13181315
struct uclogic_params p = {0, };
13191316

@@ -1344,7 +1341,9 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
13441341
* The specific data was discovered by sniffing the Windows driver
13451342
* traffic.
13461343
*/
1347-
rc = uclogic_probe_interface(hdev, magic_arr, sizeof(magic_arr), 0x03);
1344+
rc = uclogic_probe_interface(hdev, uclogic_ugee_v2_probe_arr,
1345+
uclogic_ugee_v2_probe_size,
1346+
uclogic_ugee_v2_probe_endpoint);
13481347
if (rc) {
13491348
uclogic_params_init_invalid(&p);
13501349
goto output;

drivers/hid/hid-uclogic-rdesc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,12 @@ const __u8 uclogic_rdesc_v2_frame_dial_arr[] = {
859859
const size_t uclogic_rdesc_v2_frame_dial_size =
860860
sizeof(uclogic_rdesc_v2_frame_dial_arr);
861861

862+
const __u8 uclogic_ugee_v2_probe_arr[] = {
863+
0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
864+
};
865+
const size_t uclogic_ugee_v2_probe_size = sizeof(uclogic_ugee_v2_probe_arr);
866+
const int uclogic_ugee_v2_probe_endpoint = 0x03;
867+
862868
/* Fixed report descriptor template for UGEE v2 pen reports */
863869
const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[] = {
864870
0x05, 0x0d, /* Usage Page (Digitizers), */

drivers/hid/hid-uclogic-rdesc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ extern const size_t uclogic_rdesc_v2_frame_dial_size;
164164
/* Report ID for tweaked UGEE v2 battery reports */
165165
#define UCLOGIC_RDESC_UGEE_V2_BATTERY_ID 0xba
166166

167+
/* Magic data expected by UGEEv2 devices on probe */
168+
extern const __u8 uclogic_ugee_v2_probe_arr[];
169+
extern const size_t uclogic_ugee_v2_probe_size;
170+
extern const int uclogic_ugee_v2_probe_endpoint;
171+
167172
/* Fixed report descriptor template for UGEE v2 pen reports */
168173
extern const __u8 uclogic_rdesc_ugee_v2_pen_template_arr[];
169174
extern const size_t uclogic_rdesc_ugee_v2_pen_template_size;

0 commit comments

Comments
 (0)