Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2388493imw; Sun, 17 Jul 2022 07:46:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uj65wGbs9JMPQymRlze2iMi4lL4BvHR7FuW4hooPWKturf+LY0nDdUmJacuYDSF6gB7VFn X-Received: by 2002:a17:907:2722:b0:72b:6a93:bf9a with SMTP id d2-20020a170907272200b0072b6a93bf9amr21092190ejl.424.1658069184618; Sun, 17 Jul 2022 07:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658069184; cv=none; d=google.com; s=arc-20160816; b=kFM15+StUNmiGlU5DhVmfFDwbnlRTpevjmCZqvE2ZKBBfB3WgmyIgTHaYcqxSoN9pV XTwnGN+ZI7656x7ZocBJMmFPQMvPZPKyh+GC6Lu7inuhAHCTf0sutwnl6LdXVfKFteM7 RIHyRc33GqiG3p6Jb00NjGHbJeto1I2UQ+71vPzLXu0430IuT7bHfQBZ9OT2xdYq/Y79 a7XXKeUzK3WzscZf2P2CpuNJuICTDy1VyU1VW02K87ijUXoLMnR55dUIq8qq1+xfjs8L BEaxNWP3iOIXaNG5oEspqQg9fOovsA6A00QY0w913TdNhidZ97HOxu8unPSTBrjsCau7 2++w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PQ1NQYAY40VdIfaKD7aTOcgtuEul8hn8SxDvqqcPU2M=; b=Tdy47irOtixKMQeKuwROIvYUA8kdb0WUXnQf2dBUMRPxCNDnUP5p2kVvsHAF/ygKus 2psvG9nkepH3HoWw7SAGHd6p5a0EC5bITqCJa5BkgBFND74ogg2h5iqn/6Vt00yUxhr6 PVHCvngn5yZJWWQjYwActrx5DUxF0X7uHLy1JZS0p4PS8mT2r9U/Qk1XZdjjfHxpxoft IEkgI4zE2nPtj7aRvMBEwlEpI/HW+OwsBsJocGhb98UWwrCqBJRtoQmlcpl9bnzNkPo8 nC/1yn1YMSBS4dar7NL1IcPHQ5GzUiqqUxLJMi6JLcd3sBxKXpdMI656xduJ4JSXiaUM j1CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ikvvcQRq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf27-20020a1709077f1b00b0072af7d4a334si10740769ejc.646.2022.07.17.07.46.00; Sun, 17 Jul 2022 07:46:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ikvvcQRq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232929AbiGQOoH (ORCPT + 99 others); Sun, 17 Jul 2022 10:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232458AbiGQOnp (ORCPT ); Sun, 17 Jul 2022 10:43:45 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8215F68; Sun, 17 Jul 2022 07:43:43 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id n12so691887wrc.8; Sun, 17 Jul 2022 07:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PQ1NQYAY40VdIfaKD7aTOcgtuEul8hn8SxDvqqcPU2M=; b=ikvvcQRqGWvJ/WJZVtSdtagXjZ5UVt03LXCmCXnoP7UIGyf5J3LiJZy39cN9rHvfxI oc1UTMHxxsd3hHU/K2vLpNVRPBTc4uxEGsUVGjjSsVT0U7uT3zlc8EYfZW6uybfkD7Wh J6i6ILslh0EbqxI1PEBJrpxnR0zgqhvQAGIIMVl2pYUFOTvjnlDRjkl0OqhQdjxIPovQ eqaBkqsVA3OyPwdjFZV+9OPwM6/CXzQIHMbXPbZJ3iOh1ZgIJamZb6vWhl2OnnN6uUH/ dBoVHnGoCnOa4CPBjS90Fu4KKiVWE0ynNdS5svDFplq+LzsWjx86XIYfx1GlVzl2lk7W Eikw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PQ1NQYAY40VdIfaKD7aTOcgtuEul8hn8SxDvqqcPU2M=; b=w/nL2i0rw241p9lvUHnh0sDeUixCDT5zJXS+IdWrsUrGjvzs7lyE5W0rPClcz2i5eG aDpzXsFUuzs5YLC6Lx1KlIVDPr3JgyhLbgg6jYbO4GExuutQzheqxAFJCd4M5sr3IEBj m0Y7+zyObCokL5NpmN2xk4X/u9K+ox3HtrSyytIT7APMC7vyNiOguIJoUbSc4ACpqJdV Hxe5S2Lr8ItEoNGfr97cH/L59wPwJecKsJfszkW338iU0WKUq36R5zHxDOslA8QBwfdE S+/diYgI9MOMzYGNc+X3bTK2Gz5S9R6zVxlwKXCQkuXdmXKZwqCMVl0UEhzuZmuy7Dc9 Wk4Q== X-Gm-Message-State: AJIora8msBGJ/klBPaY2qwtpSl4wNUwiKDMS/Hn4+Y7AOMeyS7cLOdZb AMnbB1Bv0GCbsBuKIwfDpjE= X-Received: by 2002:adf:f847:0:b0:21d:6c3b:ecbf with SMTP id d7-20020adff847000000b0021d6c3becbfmr19584148wrq.423.1658069022140; Sun, 17 Jul 2022 07:43:42 -0700 (PDT) Received: from localhost.localdomain ([94.73.36.185]) by smtp.gmail.com with ESMTPSA id h8-20020adff4c8000000b0021d887f9468sm8432001wrp.25.2022.07.17.07.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jul 2022 07:43:41 -0700 (PDT) From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= To: jikos@kernel.org Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com, j.witteveen@gmail.com, stefanberzl@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Subject: [PATCH v2 6/7] HID: uclogic: Add support for UGEE v2 mouse frames Date: Sun, 17 Jul 2022 16:43:32 +0200 Message-Id: <20220717144333.251190-7-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220717144333.251190-1-jose.exposito89@gmail.com> References: <20220717144333.251190-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the required HID descriptors and the initialization function for UGEE v2 frames with a mouse in the frame. Tested-by: Jouke Witteveen Signed-off-by: José Expósito --- drivers/hid/hid-uclogic-params.c | 31 +++++++++++++++++++++++++++++ drivers/hid/hid-uclogic-rdesc.c | 34 ++++++++++++++++++++++++++++++++ drivers/hid/hid-uclogic-rdesc.h | 4 ++++ 3 files changed, 69 insertions(+) diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c index 8ac7caeda535..f25c483b794b 100644 --- a/drivers/hid/hid-uclogic-params.c +++ b/drivers/hid/hid-uclogic-params.c @@ -1188,6 +1188,31 @@ static int uclogic_params_ugee_v2_init_frame_dial(struct uclogic_params *p, return 0; } +/** + * uclogic_params_ugee_v2_init_frame_mouse() - initialize a UGEE v2 frame with a + * mouse. + * @p: Parameters to fill in, cannot be NULL. + * + * Returns: + * Zero, if successful. A negative errno code on error. + */ +static int uclogic_params_ugee_v2_init_frame_mouse(struct uclogic_params *p) +{ + int rc = 0; + + if (!p) + return -EINVAL; + + rc = uclogic_params_frame_init_with_desc(&p->frame_list[1], + uclogic_rdesc_ugee_v2_frame_mouse_template_arr, + uclogic_rdesc_ugee_v2_frame_dial_template_size, + UCLOGIC_RDESC_V1_FRAME_ID); + if (rc) + return rc; + + return 0; +} + /** * uclogic_params_ugee_v2_init() - initialize a UGEE graphics tablets by * discovering their parameters. @@ -1231,6 +1256,12 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params, iface = to_usb_interface(hdev->dev.parent); bInterfaceNumber = iface->cur_altsetting->desc.bInterfaceNumber; + + if (bInterfaceNumber == 0) { + uclogic_params_ugee_v2_init_frame_mouse(&p); + goto output; + } + if (bInterfaceNumber != 2) { uclogic_params_init_invalid(&p); goto output; diff --git a/drivers/hid/hid-uclogic-rdesc.c b/drivers/hid/hid-uclogic-rdesc.c index 22429df693fc..fb9ca69f72c2 100644 --- a/drivers/hid/hid-uclogic-rdesc.c +++ b/drivers/hid/hid-uclogic-rdesc.c @@ -1001,6 +1001,40 @@ const __u8 uclogic_rdesc_ugee_v2_frame_dial_template_arr[] = { const size_t uclogic_rdesc_ugee_v2_frame_dial_template_size = sizeof(uclogic_rdesc_ugee_v2_frame_dial_template_arr); +/* Fixed report descriptor template for UGEE v2 frame reports (mouse) */ +const __u8 uclogic_rdesc_ugee_v2_frame_mouse_template_arr[] = { + 0x05, 0x01, /* Usage Page (Desktop), */ + 0x09, 0x02, /* Usage (Mouse), */ + 0xA1, 0x01, /* Collection (Application), */ + 0x85, 0x01, /* Report ID (1), */ + 0x05, 0x01, /* Usage Page (Pointer), */ + 0xA0, /* Collection (Physical), */ + 0x75, 0x01, /* Report Size (1), */ + 0x95, 0x02, /* Report Count (2), */ + 0x05, 0x09, /* Usage Page (Button), */ + 0x19, 0x01, /* Usage Minimum (01h), */ + 0x29, 0x02, /* Usage Maximum (02h), */ + 0x14, /* Logical Minimum (0), */ + 0x25, 0x01, /* Logical Maximum (1), */ + 0x81, 0x02, /* Input (Variable), */ + 0x95, 0x06, /* Report Count (6), */ + 0x81, 0x01, /* Input (Constant), */ + 0x05, 0x01, /* Usage Page (Generic Desktop), */ + 0x09, 0x30, /* Usage (X), */ + 0x09, 0x31, /* Usage (Y), */ + 0x75, 0x10, /* Report Size (16), */ + 0x95, 0x02, /* Report Count (2), */ + 0x16, 0x00, 0x80, /* Logical Minimum (-32768), */ + 0x26, 0xFF, 0x7F, /* Logical Maximum (32767), */ + 0x81, 0x06, /* Input (Variable, Relative), */ + 0x95, 0x01, /* Report Count (1), */ + 0x81, 0x01, /* Input (Constant), */ + 0xC0, /* End Collection, */ + 0xC0 /* End Collection */ +}; +const size_t uclogic_rdesc_ugee_v2_frame_mouse_template_size = + sizeof(uclogic_rdesc_ugee_v2_frame_mouse_template_arr); + /* Fixed report descriptor for Ugee EX07 frame */ const __u8 uclogic_rdesc_ugee_ex07_frame_arr[] = { 0x05, 0x01, /* Usage Page (Desktop), */ diff --git a/drivers/hid/hid-uclogic-rdesc.h b/drivers/hid/hid-uclogic-rdesc.h index 1a2d658bad3a..0502a0656496 100644 --- a/drivers/hid/hid-uclogic-rdesc.h +++ b/drivers/hid/hid-uclogic-rdesc.h @@ -173,6 +173,10 @@ extern const size_t uclogic_rdesc_ugee_v2_frame_btn_template_size; extern const __u8 uclogic_rdesc_ugee_v2_frame_dial_template_arr[]; extern const size_t uclogic_rdesc_ugee_v2_frame_dial_template_size; +/* Fixed report descriptor template for UGEE v2 frame reports (mouse) */ +extern const __u8 uclogic_rdesc_ugee_v2_frame_mouse_template_arr[]; +extern const size_t uclogic_rdesc_ugee_v2_frame_mouse_template_size; + /* Fixed report descriptor for Ugee EX07 frame */ extern const __u8 uclogic_rdesc_ugee_ex07_frame_arr[]; extern const size_t uclogic_rdesc_ugee_ex07_frame_size; -- 2.25.1