[UCLOGIC_RDESC_PEN_PH_ID_X_PM] = 0xBB,
};
+static const s32 params_frame_all[UCLOGIC_RDESC_PH_ID_NUM] = {
+ [UCLOGIC_RDESC_FRAME_PH_ID_UM] = 0xFF,
+};
+
static const __u8 template_empty[] = { };
static const __u8 template_small[] = { 0x00 };
static const __u8 template_no_ph[] = { 0xAA, 0xFE, 0xAA, 0xED, 0x1D };
0xAA, 0xBB, UCLOGIC_RDESC_PEN_PH_HEAD
};
+static const __u8 template_btn_ph_end[] = {
+ 0xAA, 0xBB, UCLOGIC_RDESC_FRAME_PH_BTN_HEAD
+};
+
static const __u8 template_pen_all_params[] = {
UCLOGIC_RDESC_PEN_PH(X_LM),
0x47, UCLOGIC_RDESC_PEN_PH(X_PM),
0x00, 0xEE, 0x00, 0x00, 0x00,
};
+static const __u8 template_frame_all_params[] = {
+ 0x01, 0x02,
+ UCLOGIC_RDESC_FRAME_PH_BTN,
+ 0x99,
+};
+
+static const __u8 expected_frame_all_params[] = {
+ 0x01, 0x02,
+ 0x2A, 0xFF, 0x00,
+ 0x99,
+};
+
static const __u8 template_pen_some_params[] = {
0x01, 0x02,
UCLOGIC_RDESC_PEN_PH(X_LM),
.param_num = ARRAY_SIZE(params_pen_all),
.expected = template_pen_ph_end,
},
+ {
+ .name = "Frame button placeholder at the end, without ID",
+ .template = template_btn_ph_end,
+ .template_size = sizeof(template_btn_ph_end),
+ .param_list = params_frame_all,
+ .param_num = ARRAY_SIZE(params_frame_all),
+ .expected = template_btn_ph_end,
+ },
{
.name = "All params present in the pen template",
.template = template_pen_all_params,
.param_num = ARRAY_SIZE(params_pen_all),
.expected = expected_pen_all_params,
},
+ {
+ .name = "All params present in the frame template",
+ .template = template_frame_all_params,
+ .template_size = sizeof(template_frame_all_params),
+ .param_list = params_frame_all,
+ .param_num = ARRAY_SIZE(params_frame_all),
+ .expected = expected_frame_all_params,
+ },
{
.name = "Some params present in the pen template (complete param list)",
.template = template_pen_some_params,
* uclogic_rdesc_template_apply() - apply report descriptor parameters to a
* report descriptor template, creating a report descriptor. Copies the
* template over to the new report descriptor and replaces every occurrence of
- * UCLOGIC_RDESC_PEN_PH_HEAD, followed by an index byte, with the value from the
+ * the template placeholders, followed by an index byte, with the value from the
* parameter list at that index.
*
* @template_ptr: Pointer to the template buffer.
const s32 *param_list,
size_t param_num)
{
+ static const __u8 btn_head[] = {UCLOGIC_RDESC_FRAME_PH_BTN_HEAD};
static const __u8 pen_head[] = {UCLOGIC_RDESC_PEN_PH_HEAD};
__u8 *rdesc_ptr;
__u8 *p;
if (rdesc_ptr == NULL)
return NULL;
- for (p = rdesc_ptr; p + sizeof(pen_head) < rdesc_ptr + template_size;) {
- if (memcmp(p, pen_head, sizeof(pen_head)) == 0 &&
+ for (p = rdesc_ptr; p + sizeof(btn_head) < rdesc_ptr + template_size;) {
+ if (p + sizeof(pen_head) < rdesc_ptr + template_size &&
+ memcmp(p, pen_head, sizeof(pen_head)) == 0 &&
p[sizeof(pen_head)] < param_num) {
v = param_list[p[sizeof(pen_head)]];
put_unaligned(cpu_to_le32(v), (s32 *)p);
p += sizeof(pen_head) + 1;
+ } else if (memcmp(p, btn_head, sizeof(btn_head)) == 0 &&
+ p[sizeof(btn_head)] < param_num) {
+ v = param_list[p[sizeof(btn_head)]];
+ put_unaligned((__u8)0x2A, p); /* Usage Maximum */
+ put_unaligned_le16((__force u16)cpu_to_le16(v), p + 1);
+ p += sizeof(btn_head) + 1;
} else {
p++;
}
/* Report descriptor template placeholder head */
#define UCLOGIC_RDESC_PEN_PH_HEAD 0xFE, 0xED, 0x1D
+#define UCLOGIC_RDESC_FRAME_PH_BTN_HEAD 0xFE, 0xED
/* Apply report descriptor parameters to a report descriptor template */
extern __u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr,
UCLOGIC_RDESC_PEN_PH_ID_Y_LM,
UCLOGIC_RDESC_PEN_PH_ID_Y_PM,
UCLOGIC_RDESC_PEN_PH_ID_PRESSURE_LM,
+ UCLOGIC_RDESC_FRAME_PH_ID_UM,
UCLOGIC_RDESC_PH_ID_NUM
};
#define UCLOGIC_RDESC_PEN_PH(_ID) \
UCLOGIC_RDESC_PEN_PH_HEAD, UCLOGIC_RDESC_PEN_PH_ID_##_ID
+/* Report descriptor frame buttons template placeholder */
+#define UCLOGIC_RDESC_FRAME_PH_BTN \
+ UCLOGIC_RDESC_FRAME_PH_BTN_HEAD, UCLOGIC_RDESC_FRAME_PH_ID_UM
+
/* Report ID for v1 pen reports */
#define UCLOGIC_RDESC_V1_PEN_ID 0x07