Skip to content

Commit b67439d

Browse files
JoseExpositoJiri Kosina
authored andcommitted
HID: uclogic: Add support for UGEE v2 dial frames
Add the required HID descriptors and the initialization function for UGEE v2 frames with a bitmap dial. Tested-by: Jouke Witteveen <[email protected]> Signed-off-by: José Expósito <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent a092986 commit b67439d

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

drivers/hid/hid-uclogic-params.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,45 @@ static int uclogic_params_ugee_v2_init_frame_buttons(struct uclogic_params *p,
11501150
return rc;
11511151
}
11521152

1153+
/**
1154+
* uclogic_params_ugee_v2_init_frame_dial() - initialize a UGEE v2 frame with a
1155+
* bitmap dial.
1156+
* @p: Parameters to fill in, cannot be NULL.
1157+
* @desc_params: Device description params list.
1158+
* @desc_params_size: Size of the description params list.
1159+
*
1160+
* Returns:
1161+
* Zero, if successful. A negative errno code on error.
1162+
*/
1163+
static int uclogic_params_ugee_v2_init_frame_dial(struct uclogic_params *p,
1164+
const s32 *desc_params,
1165+
size_t desc_params_size)
1166+
{
1167+
__u8 *rdesc_frame = NULL;
1168+
int rc = 0;
1169+
1170+
if (!p || desc_params_size != UCLOGIC_RDESC_PH_ID_NUM)
1171+
return -EINVAL;
1172+
1173+
rdesc_frame = uclogic_rdesc_template_apply(
1174+
uclogic_rdesc_ugee_v2_frame_dial_template_arr,
1175+
uclogic_rdesc_ugee_v2_frame_dial_template_size,
1176+
desc_params, UCLOGIC_RDESC_PH_ID_NUM);
1177+
if (!rdesc_frame)
1178+
return -ENOMEM;
1179+
1180+
rc = uclogic_params_frame_init_with_desc(&p->frame_list[0],
1181+
rdesc_frame,
1182+
uclogic_rdesc_ugee_v2_frame_dial_template_size,
1183+
UCLOGIC_RDESC_V1_FRAME_ID);
1184+
kfree(rdesc_frame);
1185+
if (rc)
1186+
return rc;
1187+
1188+
p->frame_list[0].bitmap_dial_byte = 7;
1189+
return 0;
1190+
}
1191+
11531192
/**
11541193
* uclogic_params_ugee_v2_init() - initialize a UGEE graphics tablets by
11551194
* discovering their parameters.
@@ -1249,6 +1288,11 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
12491288

12501289
/* Initialize the frame interface */
12511290
switch (frame_type) {
1291+
case UCLOGIC_PARAMS_FRAME_DIAL:
1292+
case UCLOGIC_PARAMS_FRAME_MOUSE:
1293+
rc = uclogic_params_ugee_v2_init_frame_dial(&p, desc_params,
1294+
ARRAY_SIZE(desc_params));
1295+
break;
12521296
case UCLOGIC_PARAMS_FRAME_BUTTONS:
12531297
default:
12541298
rc = uclogic_params_ugee_v2_init_frame_buttons(&p, desc_params,

drivers/hid/hid-uclogic-rdesc.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,46 @@ const __u8 uclogic_rdesc_ugee_v2_frame_btn_template_arr[] = {
961961
const size_t uclogic_rdesc_ugee_v2_frame_btn_template_size =
962962
sizeof(uclogic_rdesc_ugee_v2_frame_btn_template_arr);
963963

964+
/* Fixed report descriptor template for UGEE v2 frame reports (dial) */
965+
const __u8 uclogic_rdesc_ugee_v2_frame_dial_template_arr[] = {
966+
0x05, 0x01, /* Usage Page (Desktop), */
967+
0x09, 0x07, /* Usage (Keypad), */
968+
0xA1, 0x01, /* Collection (Application), */
969+
0x85, UCLOGIC_RDESC_V1_FRAME_ID,
970+
/* Report ID, */
971+
0x05, 0x0D, /* Usage Page (Digitizer), */
972+
0x09, 0x39, /* Usage (Tablet Function Keys), */
973+
0xA0, /* Collection (Physical), */
974+
0x75, 0x01, /* Report Size (1), */
975+
0x95, 0x08, /* Report Count (8), */
976+
0x81, 0x01, /* Input (Constant), */
977+
0x05, 0x09, /* Usage Page (Button), */
978+
0x19, 0x01, /* Usage Minimum (01h), */
979+
UCLOGIC_RDESC_FRAME_PH_BTN,
980+
/* Usage Maximum (PLACEHOLDER), */
981+
0x95, 0x0A, /* Report Count (10), */
982+
0x14, /* Logical Minimum (0), */
983+
0x25, 0x01, /* Logical Maximum (1), */
984+
0x81, 0x02, /* Input (Variable), */
985+
0x95, 0x06, /* Report Count (6), */
986+
0x81, 0x01, /* Input (Constant), */
987+
0x75, 0x08, /* Report Size (8), */
988+
0x95, 0x03, /* Report Count (3), */
989+
0x81, 0x01, /* Input (Constant), */
990+
0x05, 0x01, /* Usage Page (Desktop), */
991+
0x09, 0x38, /* Usage (Wheel), */
992+
0x95, 0x01, /* Report Count (1), */
993+
0x15, 0xFF, /* Logical Minimum (-1), */
994+
0x25, 0x01, /* Logical Maximum (1), */
995+
0x81, 0x06, /* Input (Variable, Relative), */
996+
0x95, 0x02, /* Report Count (2), */
997+
0x81, 0x01, /* Input (Constant), */
998+
0xC0, /* End Collection, */
999+
0xC0 /* End Collection */
1000+
};
1001+
const size_t uclogic_rdesc_ugee_v2_frame_dial_template_size =
1002+
sizeof(uclogic_rdesc_ugee_v2_frame_dial_template_arr);
1003+
9641004
/* Fixed report descriptor for Ugee EX07 frame */
9651005
const __u8 uclogic_rdesc_ugee_ex07_frame_arr[] = {
9661006
0x05, 0x01, /* Usage Page (Desktop), */

drivers/hid/hid-uclogic-rdesc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ extern const size_t uclogic_rdesc_ugee_v2_pen_template_size;
169169
extern const __u8 uclogic_rdesc_ugee_v2_frame_btn_template_arr[];
170170
extern const size_t uclogic_rdesc_ugee_v2_frame_btn_template_size;
171171

172+
/* Fixed report descriptor template for UGEE v2 frame reports (dial) */
173+
extern const __u8 uclogic_rdesc_ugee_v2_frame_dial_template_arr[];
174+
extern const size_t uclogic_rdesc_ugee_v2_frame_dial_template_size;
175+
172176
/* Fixed report descriptor for Ugee EX07 frame */
173177
extern const __u8 uclogic_rdesc_ugee_ex07_frame_arr[];
174178
extern const size_t uclogic_rdesc_ugee_ex07_frame_size;

0 commit comments

Comments
 (0)