From patchwork Fri Jan 14 18:31:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angela Czubak X-Patchwork-Id: 532147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C872C433EF for ; Fri, 14 Jan 2022 18:32:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243007AbiANScY (ORCPT ); Fri, 14 Jan 2022 13:32:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242991AbiANScY (ORCPT ); Fri, 14 Jan 2022 13:32:24 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5EEFC061574 for ; Fri, 14 Jan 2022 10:32:23 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id p1-20020a1c7401000000b00345c2d068bdso8840560wmc.3 for ; Fri, 14 Jan 2022 10:32:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sz6tgUi+1lixPu1s8iY/vOhgmToeWlY9JUjdC2Z9s5w=; b=lkhgaiqkgO/6KMIZ+NRyolQdiRweXZqmCGKnd8XykoSt7gVlGjTrD6m2qTJsbGiAAG PhzJV9LyUEjM0eqfXl5H8jL4SPeKVwvZFfRVpkkpASSgruXS/eiA+edkfvhTeY/59XOF gHsWIE5np8nAT8cVT7JtKgFgY0/M0KKo+YG8ujlJVTywfUw4MH8XTW1ckZ2SdEkHoWdv bWLhKul4BA9uH/sQ103dBcao6Lp4XK1Kujo5zKKTTkC30AnsadvG3/SVVF8QHPF/h2+N KrGKGoYWx7B+HeskZ2m//+sgHRz3O47NPJU4NWnahNI6yZ9+innxIkYKDMUwwJt178GH kIZQ== 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=Sz6tgUi+1lixPu1s8iY/vOhgmToeWlY9JUjdC2Z9s5w=; b=nWK5oNd/jmOd+DG/Ncd6FX7+2qQX2rRCiZGwCCW/1ZytLdnqynSdlxTRcrNI2CbvuL AP9z/zp1KGlTaVQmM3az1DeFk17oAQAg7d6722tRMX46ibNWg4bTdKNe+u4l3hhn1Luk VjcDdlYkr/uMbG+Bq2in3/T+7CxF9otJj0sXYGPKF8Kw6fWnNJ/UjFthvykhr+jbxW0T 03YZhr5rnzSzY6GoqUYEeOU3MJdJtVAdAaZ7gi/afJ/zXH6r7o6HPXWArF9VRt0o/jzC Od85kSG4YwaXXzfGCcoistGEZ/BJ4jtXFbkk/PdjaCt63Pcs5s0cDvTe5Lwxtfx+47ZN exWQ== X-Gm-Message-State: AOAM530FchQU0ogl8W5U7DYBIYi1I+Ee+wvyQMWHYxTAXVMw9rIzgkuJ PDlVkFQXFlgor+dCvoGv+9zQJq2y9z6fsTMq4Ws= X-Google-Smtp-Source: ABdhPJwjZ2BsPpbnRl5pRs0+jBVUZvEVqhbgzTloQOp9BOwRrlbCtlYMK/QksbvnpMa2M9pl9NZQAA== X-Received: by 2002:a05:600c:1c9f:: with SMTP id k31mr5674211wms.40.1642185142255; Fri, 14 Jan 2022 10:32:22 -0800 (PST) Received: from aczubak.c.googlers.com.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id az4sm6410984wrb.14.2022.01.14.10.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 10:32:22 -0800 (PST) From: Angela Czubak To: linux-input@vger.kernel.org Cc: upstream@semihalf.com, dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org, Angela Czubak Subject: [PATCH v2 01/16] HID: add haptics page defines Date: Fri, 14 Jan 2022 18:31:37 +0000 Message-Id: <20220114183152.1691659-2-acz@semihalf.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220114183152.1691659-1-acz@semihalf.com> References: <20220114183152.1691659-1-acz@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Introduce haptic usages as defined in HID Usage Tables specification. Add HID units for newton and gram. Signed-off-by: Angela Czubak --- include/linux/hid.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/linux/hid.h b/include/linux/hid.h index 7487b0586fe6..4584ce744d02 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -153,6 +153,7 @@ struct hid_item { #define HID_UP_TELEPHONY 0x000b0000 #define HID_UP_CONSUMER 0x000c0000 #define HID_UP_DIGITIZER 0x000d0000 +#define HID_UP_HAPTIC 0x000e0000 #define HID_UP_PID 0x000f0000 #define HID_UP_BATTERY 0x00850000 #define HID_UP_HPVENDOR 0xff7f0000 @@ -311,6 +312,28 @@ struct hid_item { #define HID_DG_TOOLSERIALNUMBER 0x000d005b #define HID_DG_LATENCYMODE 0x000d0060 +#define HID_HP_SIMPLECONTROLLER 0x000e0001 +#define HID_HP_WAVEFORMLIST 0x000e0010 +#define HID_HP_DURATIONLIST 0x000e0011 +#define HID_HP_AUTOTRIGGER 0x000e0020 +#define HID_HP_MANUALTRIGGER 0x000e0021 +#define HID_HP_AUTOTRIGGERASSOCIATEDCONTROL 0x000e0022 +#define HID_HP_INTENSITY 0x000e0023 +#define HID_HP_REPEATCOUNT 0x000e0024 +#define HID_HP_RETRIGGERPERIOD 0x000e0025 +#define HID_HP_WAVEFORMVENDORPAGE 0x000e0026 +#define HID_HP_WAVEFORMVENDORID 0x000e0027 +#define HID_HP_WAVEFORMCUTOFFTIME 0x000e0028 +#define HID_HP_WAVEFORMNONE 0x000e1001 +#define HID_HP_WAVEFORMSTOP 0x000e1002 +#define HID_HP_WAVEFORMCLICK 0x000e1003 +#define HID_HP_WAVEFORMBUZZCONTINUOUS 0x000e1004 +#define HID_HP_WAVEFORMRUMBLECONTINUOUS 0x000e1005 +#define HID_HP_WAVEFORMPRESS 0x000e1006 +#define HID_HP_WAVEFORMRELEASE 0x000e1007 +#define HID_HP_VENDORWAVEFORMMIN 0x000e2001 +#define HID_HP_VENDORWAVEFORMMAX 0x000e2fff + #define HID_BAT_ABSOLUTESTATEOFCHARGE 0x00850065 #define HID_VD_ASUS_CUSTOM_MEDIA_KEYS 0xff310076 @@ -398,6 +421,12 @@ struct hid_item { #define HID_REPORT_PROTOCOL 1 #define HID_BOOT_PROTOCOL 0 +/* + * HID units + */ +#define HID_UNIT_GRAM 0x0101 +#define HID_UNIT_NEWTON 0xe111 + /* * This is the global environment of the parser. This information is * persistent for main-items. The global environment can be saved and From patchwork Fri Jan 14 18:31:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angela Czubak X-Patchwork-Id: 532146 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E88BAC433EF for ; Fri, 14 Jan 2022 18:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243022AbiANSc0 (ORCPT ); Fri, 14 Jan 2022 13:32:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242991AbiANSc0 (ORCPT ); Fri, 14 Jan 2022 13:32:26 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D9FCC061574 for ; Fri, 14 Jan 2022 10:32:26 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id n19-20020a7bc5d3000000b003466ef16375so8865621wmk.1 for ; Fri, 14 Jan 2022 10:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Abe1KfF+lJ/PybXuWerxm4ZC1PLP/89AOoSNsN3Hla0=; b=4Jfa4HP8Uu+mME3E7E5ygZltxj0CTwO5kEfCCcOb1o64YCBWqQBuiD8ikSsMlJY5Co LE7qDMIe2lmdB9to+ToUbCYUELvR0PnA69kh0MXP2ntE8y2qpEWUFIpr0sG09Jc8VZyR Kd4gYEqR9RN+uCrXJiK2O4pfrHs3ASDx+7NXGnIfhahNXlJIOCXVgbpOaYF8HTmAO2LF tih8cnexU74DTs/1a4suN3tqxir93gvkICfnZjpAvJR0R6j67t1Oxtcdwqi5y3+FpSvb 0xInqhHMqLRzpbhs+H/1SFvHNXIpMGr4X1PEFNMPx11vGn6yXz6x1T4dOWomLUocDFnh us2w== 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=Abe1KfF+lJ/PybXuWerxm4ZC1PLP/89AOoSNsN3Hla0=; b=WlCBm3kim32fMSy4iW3tLnza2DM9mbROEsNDJotqURfcL+ORNPb5mnaP1UeuWsFqf+ bBPco9WWAN6XyMDPSCx4GotCgqWRL4hhLGiG2ikNsASx+OFheWacAmsoAt6SfEhcI3Cn 5wuH5GM5QHHrbf4Mfgon7sVcTBC1wT/oTYaEV0H/NX7Egd6XalW6MV9q88WC3v/jHmHl 7zaZD5plHXgdOXFbtIOg6qw+DgunTxEnimEv3Bd9lXWugtWvLwIJBTyVqAW3TN8NQ59C HCfeFBqTsCSY+Xu02FtHeJYJlNRBvr6y8ZNxr1vaOIfhdp4U+SiB+VWf+rWX5aPzK4hm MebQ== X-Gm-Message-State: AOAM530T3OSYcRADszpsB+cKlJQaY1Bo9oKyRjuaBO5wye2PE1awIL/S WQhObUdkVEr/BPf3MftByXLqB6PiRnUDhnEGxBI= X-Google-Smtp-Source: ABdhPJzFK66wNPvM9JVuDTuZIlGmuFKcBCZxuVRGV+8ZwehFJnfFxx9msA512GelRP1IATLLBeSyIw== X-Received: by 2002:a05:600c:3ac8:: with SMTP id d8mr9619818wms.72.1642185144683; Fri, 14 Jan 2022 10:32:24 -0800 (PST) Received: from aczubak.c.googlers.com.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id az4sm6410984wrb.14.2022.01.14.10.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 10:32:24 -0800 (PST) From: Angela Czubak To: linux-input@vger.kernel.org Cc: upstream@semihalf.com, dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org, Angela Czubak Subject: [PATCH v2 03/16] Input: add INPUT_PROP_HAPTIC_TOUCHPAD Date: Fri, 14 Jan 2022 18:31:39 +0000 Message-Id: <20220114183152.1691659-4-acz@semihalf.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220114183152.1691659-1-acz@semihalf.com> References: <20220114183152.1691659-1-acz@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org INPUT_PROP_HAPTIC_TOUCHPAD property is to be set for a device with simple haptic capabilities. Signed-off-by: Angela Czubak --- Documentation/input/event-codes.rst | 14 ++++++++++++++ include/uapi/linux/input-event-codes.h | 1 + 2 files changed, 15 insertions(+) diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst index b24ae7d292cc..bbf2510c2b1a 100644 --- a/Documentation/input/event-codes.rst +++ b/Documentation/input/event-codes.rst @@ -390,6 +390,20 @@ can report through the rotational axes (absolute and/or relative rx, ry, rz). All other axes retain their meaning. A device must not mix regular directional axes and accelerometer axes on the same event node. +INPUT_PROP_HAPTIC_TOUCHPAD +-------------------------- + +The INPUT_PROP_HAPTIC_TOUCHPAD property indicates that device: +- supports simple haptic auto and manual triggering +- can differentiate between at least 5 fingers +- uses correct resolution for the X/Y (units and value) +- report correct force per touch, and correct units for them (newtons or grams) +- follows the MT protocol type B + +Summing up, such devices follow the MS spec for input devices in +Win8 and Win8.1, and in addition support the Simple haptic controller HID table, +and report correct units for the pressure. + Guidelines ========== diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h index 225ec87d4f22..df2ba5da4eaa 100644 --- a/include/uapi/linux/input-event-codes.h +++ b/include/uapi/linux/input-event-codes.h @@ -27,6 +27,7 @@ #define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */ #define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */ #define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */ +#define INPUT_PROP_HAPTIC_TOUCHPAD 0x07 /* is a haptic touchpad */ #define INPUT_PROP_MAX 0x1f #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) From patchwork Fri Jan 14 18:31:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angela Czubak X-Patchwork-Id: 532145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF8F3C433FE for ; Fri, 14 Jan 2022 18:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243074AbiANSca (ORCPT ); Fri, 14 Jan 2022 13:32:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243079AbiANSc2 (ORCPT ); Fri, 14 Jan 2022 13:32:28 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 061A2C06161C for ; Fri, 14 Jan 2022 10:32:28 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id d187-20020a1c1dc4000000b003474b4b7ebcso7228898wmd.5 for ; Fri, 14 Jan 2022 10:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CC3fg4tLPbBqyg9QQ9rodaBfRAw+nKJ9yBWklaxbIJ8=; b=yL56HZREeP5piwVRAutc0USqp6uguNrvllYOvMvFkfw7Yx6IOdDhq3EOfUP1nDGanK sFh6b5+6n+09yA/xcqiZDVf6X19LeQgtK+nYG0BIlEX8uZhEex6wfIe5BhEAmDroviVW 2uhC5kuN6EC/h/+7mLqqJkD+je7d4opNAQXTDolzWbDdnsd08BdZlo0kItYZyhW2k8Wg xzgYqLxqjM+Lm5kqIFdNe5/c+d9+Q1Ow4D8KAX/9IbMK8qGqoixBnWPBlOuCTmwjbmvG wH7STa7+5z2U46rNfJKVXyle4HInMgfM6crM2EWF/JVCMyhYjvn5YRQy6okx2bk2swSH GIdw== 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=CC3fg4tLPbBqyg9QQ9rodaBfRAw+nKJ9yBWklaxbIJ8=; b=8BUVCH7MKwP76uDgb66erzmaOKZvNmB5QtWnJPHthnd7gNPLY4u3xHH2MoCXIU/E+S EVeETfuvywVH4Zr3N2eHh9CGzd+LW4yyOjg88UcVSYHl4z+69grTKkuOHTXoguEgGb4k 8431ySyWu83S/OlTLtwpnBnDYIDsEBEkrzkupUnEumxio93x3O1DDchjySNg/+lg0jC8 bk2okPqpU3PCTh8X951JvA5snlz8wAmmmNy/mnXN2C7MwsAsYt6bV6V7LYh0YXPw1nt7 o6EkdI9fCXcvOgWUtqfK8YQL4NE8qlQteYzllpAPrVF7rHQUMFr9oyfykHEnsXPlLX9w 8rbQ== X-Gm-Message-State: AOAM532VXSFhIY95EzBusKMKJYpO+KBGqPrWED149tENT9cXuDW9jalg AtqLXwGu95QqXhMEXOWQDuza8KqGyabTQmOa60s= X-Google-Smtp-Source: ABdhPJxORal5+LDne3fPR6Hsj8VAWGtv8FRkPOJ3SS6b9gOMj+b+hBcp1h2U5eY2VWLmB3YepAcvjA== X-Received: by 2002:a05:600c:4f13:: with SMTP id l19mr16546258wmq.152.1642185146657; Fri, 14 Jan 2022 10:32:26 -0800 (PST) Received: from aczubak.c.googlers.com.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id az4sm6410984wrb.14.2022.01.14.10.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 10:32:26 -0800 (PST) From: Angela Czubak To: linux-input@vger.kernel.org Cc: upstream@semihalf.com, dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org, Angela Czubak Subject: [PATCH v2 05/16] HID: input: allow mapping of haptic output Date: Fri, 14 Jan 2022 18:31:41 +0000 Message-Id: <20220114183152.1691659-6-acz@semihalf.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220114183152.1691659-1-acz@semihalf.com> References: <20220114183152.1691659-1-acz@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This change makes it possible to parse output reports by input mapping functions by HID drivers. Signed-off-by: Angela Czubak --- drivers/hid/hid-input.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 1ce75e8b49d5..9dd4a146576a 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -600,9 +600,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel if (field->report_count < 1) goto ignore; - /* only LED usages are supported in output fields */ + /* only LED and HAPTIC usages are supported in output fields */ if (field->report_type == HID_OUTPUT_REPORT && - (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) { + (usage->hid & HID_USAGE_PAGE) != HID_UP_LED && + (usage->hid & HID_USAGE_PAGE) != HID_UP_HAPTIC) { goto ignore; } From patchwork Fri Jan 14 18:31:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angela Czubak X-Patchwork-Id: 532144 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 242B0C433F5 for ; Fri, 14 Jan 2022 18:32:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243108AbiANSce (ORCPT ); Fri, 14 Jan 2022 13:32:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243105AbiANSca (ORCPT ); Fri, 14 Jan 2022 13:32:30 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25110C06173E for ; Fri, 14 Jan 2022 10:32:30 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id l12-20020a7bc34c000000b003467c58cbdfso8854656wmj.2 for ; Fri, 14 Jan 2022 10:32:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AHLt3sUb2fMQkhkkdlUxnnWbR3Lx+wdC9flrm9iGQO4=; b=7Dkb/qKDO1L36vg4sgekDMMyZEbKiIjHLqOhnAX4i5bJokoxq51rirgz77tYhEspC5 2WxVFGlfhrCvqC6pIIySX7D3LfAsiE47oF6rPyG+cwqQ2FVt7vG0y3QHdL+dEfsmwDpq 6t0aw1j5iVuSwnQVaxHO3CdIdoRUwoOmx0/TvxwCjtJT16d9hQ2WBiWqh+f5EZGekoMb aYv2B0g+Q8SHO79LhbJmKVWLni643HXPZIqdjGkoF2B+ybiAYLJFeEixMwkFa3Qp1E2w 18LNwIT/35FAmBXL4w7GjwNWkZVdH2TUquNeYXPhn8rMXh7uE1rf2m+vy0PbLaktskGU 128A== 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=AHLt3sUb2fMQkhkkdlUxnnWbR3Lx+wdC9flrm9iGQO4=; b=56vZrwMCFOR5j7dZPquDbJmlKNXZBAvjSQdZb1ev0+wilpidX/h9XIoQ9n5H28twnU vqcCiNj95lmNYhx5EpIP/esqm7PQKMYGAS2k3rRkHSW4u5PU9hjqnPpOU29G/r8AmLez lwMEKTF/kxmC6GCa0r9W+cYA33t+0VqO8jB4X3QcyYO1a2+mq6/gvdBbbnY58kfBvapP FMW78s9GyKftV0xENizXMFCB4RSDeInmws2rwa+pW50kJV/h0mjxPDgBa0eST2bb3/PF FFjwmUxgKKCsWcpUpjvutbK9oALth26Gx3LlTGjXmV+9dZtAHkANTcl/H939NgJTpPnw oO2w== X-Gm-Message-State: AOAM533kkLmyaEm4c7qYKBwJ4Jy64TEvZ/jXDy7Y3/8QyqXd1BaH1QBW ugQhNLd7UrL9KNApCpbfntloORdRomz2jXVEBLU= X-Google-Smtp-Source: ABdhPJzHpNIBoYVgPg0UAQdrRibUhkAc2A9nn2eUjVaOTp7QZB7vi2udrcM8Mx8MFzWV6i47Qo1RFQ== X-Received: by 2002:a05:600c:1991:: with SMTP id t17mr16558965wmq.21.1642185148766; Fri, 14 Jan 2022 10:32:28 -0800 (PST) Received: from aczubak.c.googlers.com.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id az4sm6410984wrb.14.2022.01.14.10.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 10:32:28 -0800 (PST) From: Angela Czubak To: linux-input@vger.kernel.org Cc: upstream@semihalf.com, dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org, Angela Czubak Subject: [PATCH v2 07/16] Input: add shared effects Date: Fri, 14 Jan 2022 18:31:43 +0000 Message-Id: <20220114183152.1691659-8-acz@semihalf.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220114183152.1691659-1-acz@semihalf.com> References: <20220114183152.1691659-1-acz@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org If an effect is uploaded with file handle equal UINTPTR_MAX assume this effect should be shared and so may be modified using different file handles. Signed-off-by: Angela Czubak --- drivers/input/ff-core.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/drivers/input/ff-core.c b/drivers/input/ff-core.c index 1cf5deda06e1..960ae0e29348 100644 --- a/drivers/input/ff-core.c +++ b/drivers/input/ff-core.c @@ -34,6 +34,23 @@ static int check_effect_access(struct ff_device *ff, int effect_id, return 0; } +/* + * Check that the effect_id is a valid effect and whether the effect + * is shared + */ +static int check_effect_shared(struct ff_device *ff, int effect_id) +{ + if (effect_id < 0 || effect_id >= ff->max_effects || + !ff->effect_owners[effect_id]) + return -EINVAL; + + /* Shared effect */ + if (ff->effect_owners[effect_id] == (struct file *)UINTPTR_MAX) + return 0; + + return -EACCES; +} + /* * Checks whether 2 effects can be combined together */ @@ -139,8 +156,11 @@ int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, id = effect->id; ret = check_effect_access(ff, id, file); - if (ret) - goto out; + if (ret) { + ret = check_effect_shared(ff, id); + if (ret) + goto out; + } old = &ff->effects[id]; @@ -174,21 +194,29 @@ static int erase_effect(struct input_dev *dev, int effect_id, { struct ff_device *ff = dev->ff; int error; + bool shared = false; error = check_effect_access(ff, effect_id, file); - if (error) - return error; + if (error) { + error = check_effect_shared(ff, effect_id); + if (!error) + shared = true; + else + return error; + } spin_lock_irq(&dev->event_lock); ff->playback(dev, effect_id, 0); - ff->effect_owners[effect_id] = NULL; + if (!shared) + ff->effect_owners[effect_id] = NULL; spin_unlock_irq(&dev->event_lock); if (ff->erase) { error = ff->erase(dev, effect_id); if (error) { spin_lock_irq(&dev->event_lock); - ff->effect_owners[effect_id] = file; + if (!shared) + ff->effect_owners[effect_id] = file; spin_unlock_irq(&dev->event_lock); return error; From patchwork Fri Jan 14 18:31:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angela Czubak X-Patchwork-Id: 532143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D291C433EF for ; Fri, 14 Jan 2022 18:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243146AbiANScg (ORCPT ); Fri, 14 Jan 2022 13:32:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243050AbiANScc (ORCPT ); Fri, 14 Jan 2022 13:32:32 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3788BC061574 for ; Fri, 14 Jan 2022 10:32:32 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id l4so7656907wmq.3 for ; Fri, 14 Jan 2022 10:32:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6cBfTFoWrKbOrWZZ9T9FRTNRu/mK8t2sxofNFZHrCmc=; b=CqMso+/WKJkZW/QUimeNOXpAZ2lCmr0Uxfg1GsSab0TTW56uiqnwtHXIe1vO7UvMoE vdNUigvnJqDjt1mkc3Xds7BpPT0JhucXnpNro3wzhoGLH7/YYmthpGiHZshaFaIchtDH POx+5xMRBAEAyaYiJuYidoWB13TqBiQsUp601dPiDBRJVqJ5ih9hrIrcz3OduZ7yvBKk G9FbkK4MRGS+twY1u4T8fEKAvi4GwrTlOiyr7NCC2m+jDeHsCrvThV1g612Gq5XIVsqu fae2IFBCm2aV0ncJ7pJvOa/WDmHZ2QshMul0DdeQOJnFiGW1hQQ2hLK8aooERS4NzXbx glNQ== 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=6cBfTFoWrKbOrWZZ9T9FRTNRu/mK8t2sxofNFZHrCmc=; b=KCkmofyBUHib0IHWhNi3p3oNdZtkMHDDmNJIAt48V8OPMRR6t10H/eVp/tZgm67G0B 7xG74xqcaYJwNMOZevbfs6P6/vy7AJ4eOvCSQ4K9/mzrM4bEYzXGUpuMuQlQss+6cMC0 5haLp7Do/eVk7nsOfQL9kkzXL652IukanYAq77RrFS0ERWnmstZUvHI7yXUtcPl1eZhF mBlEZ6ZoJJ+zPUI+TYlTXFbwhC9DODvmvr7hMJcixO3VzC3QU/EnWy5IzFde83CQU1qn 9hsTAiaGTtZoTW7qy+LSh2g8xW58It7CuqfN3C7kqHQwnl9xWT/ty6l8aeP0GjIVZaS3 bEQA== X-Gm-Message-State: AOAM532Myez63O0yg4mIXpGRj6A27ks0xf8GBxL/xEOzmgi+kATxWYg9 eo9I5zD7Fobw6ARCRQFo+4EgoPh2fAmX9shmvw0= X-Google-Smtp-Source: ABdhPJy7Ygo+l6lws6cw8Uo5nHSbpaobPdg6Lh0XO5bGEGqVl6rxuR8TjS0s/8EhflFH6puDVqLECw== X-Received: by 2002:a05:600c:4caa:: with SMTP id g42mr12704671wmp.60.1642185150812; Fri, 14 Jan 2022 10:32:30 -0800 (PST) Received: from aczubak.c.googlers.com.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id az4sm6410984wrb.14.2022.01.14.10.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 10:32:30 -0800 (PST) From: Angela Czubak To: linux-input@vger.kernel.org Cc: upstream@semihalf.com, dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org, Angela Czubak Subject: [PATCH v2 09/16] HID: input: calculate resolution for pressure Date: Fri, 14 Jan 2022 18:31:45 +0000 Message-Id: <20220114183152.1691659-10-acz@semihalf.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220114183152.1691659-1-acz@semihalf.com> References: <20220114183152.1691659-1-acz@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Assume that if the pressure is given in newtons it should be normalized to grams. If the pressure has no unit do not calculate resolution. Signed-off-by: Angela Czubak --- drivers/hid/hid-input.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 9dd4a146576a..4917cdf5df27 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -258,6 +258,19 @@ __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) } break; + case ABS_PRESSURE: + case ABS_MT_PRESSURE: + if (field->unit == HID_UNIT_NEWTON) { + /* Convert to grams, 1 newton is 101.97 grams */ + prev = physical_extents; + physical_extents *= 10197; + if (physical_extents < prev) + return 0; + unit_exponent -= 2; + } else if (field->unit != HID_UNIT_GRAM) { + return 0; + } + break; default: return 0; } From patchwork Fri Jan 14 18:31:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angela Czubak X-Patchwork-Id: 532142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 168B7C433F5 for ; Fri, 14 Jan 2022 18:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243100AbiANScl (ORCPT ); Fri, 14 Jan 2022 13:32:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243134AbiANSce (ORCPT ); Fri, 14 Jan 2022 13:32:34 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 425E8C061747 for ; Fri, 14 Jan 2022 10:32:34 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id ay4-20020a05600c1e0400b0034a81a94607so6318001wmb.1 for ; Fri, 14 Jan 2022 10:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1MvDm6chj8/OR9+iaUSWg8PUJVBeuAtEH6jWvTqle30=; b=WfWX+StJf1W7YZDUDy2Y4/pzgqNnbJB5yhmqQXNI6m/pBs+Jk/U9SjeF2YR5Tj3++2 2aUAkfdzTv1uEP2ap4ejIVZDsi8Pc1wY2QplVY2fVLVVmnL4XITZfI+1KNMcvw471FO+ A4vFSH5Uuij0PLt+VdHIvbstf4vunqVEcgiplqBoxcNGQS3D0sBBTXeXuqwY54XiOYYs igIf8ilPHkLPky21Ni1/2ccXX2t4mp+BOOawGBP/m/rf7Q05PlnhjRhKpbE91tw2sI7X 6saPybCHbTrmE8xCcvervO921XmDQ9thEWnRsdoKkzKoPXp9DUySuhcHT3OFnDEQVjd4 LNPA== 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=1MvDm6chj8/OR9+iaUSWg8PUJVBeuAtEH6jWvTqle30=; b=qKFU1xu+eK24w2+GpMXKlxAAREHfTE2TsVgYtRzCvJumGbYwrhlGzglELsx/kdH5M2 WjxAezZxVuZomxygpU0KjUcMq8QUpHwihczgEuTORpQN9mWcoqXj3ygWKI6JeXP/JbyD gZuR/wW8IboSrKEAF+ViOFArSYW781YUGZbaybnYf9Vwgj7lBEDlog1OtESvUNI3uXlA 0X6r1jm+Pi8psQWv8tOYwIfT7TgOfWYYflWT64A2wq6iSQGG6PKUmg/NwGV2iqtrB1Mj BopQx+wp0OXjDN/06Jmb9WXBboBwH+cukJukMdzZDAFC1jGZsGE6SUx1E+THMaCcUptC tGrw== X-Gm-Message-State: AOAM532F5qqOQN+nOo4s9G6Q2ticE5ZUcWDf9XUufgOvic69F4WfS2Bk Qru71344uI3FY63PT9WxScLZnabH71thh53qjPE= X-Google-Smtp-Source: ABdhPJxXb0FldDTrIzr8XBsZPladkRnhhCwiEWF2dQnXpNTtgHf95ZmXFtyY7Dw50Un9Ph2GjP8DkQ== X-Received: by 2002:adf:ec8c:: with SMTP id z12mr9543167wrn.176.1642185152892; Fri, 14 Jan 2022 10:32:32 -0800 (PST) Received: from aczubak.c.googlers.com.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id az4sm6410984wrb.14.2022.01.14.10.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 10:32:32 -0800 (PST) From: Angela Czubak To: linux-input@vger.kernel.org Cc: upstream@semihalf.com, dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org, Angela Czubak Subject: [PATCH v2 11/16] Input: MT - add INPUT_MT_TOTAL_FORCE flags Date: Fri, 14 Jan 2022 18:31:47 +0000 Message-Id: <20220114183152.1691659-12-acz@semihalf.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220114183152.1691659-1-acz@semihalf.com> References: <20220114183152.1691659-1-acz@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add a flag to generate ABS_PRESSURE as sum of ABS_MT_PRESSURE across all slots. This flag should be set if one knows a device reports true force and would like to report total force to the userspace. Signed-off-by: Angela Czubak --- drivers/input/input-mt.c | 14 ++++++++++---- include/linux/input/mt.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c index 44fe6f2f063c..d84768329083 100644 --- a/drivers/input/input-mt.c +++ b/drivers/input/input-mt.c @@ -197,6 +197,7 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count) struct input_mt *mt = dev->mt; struct input_mt_slot *oldest; int oldid, count, i; + int p, reported_p = 0; if (!mt) return; @@ -215,6 +216,13 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count) oldest = ps; oldid = id; } + if (test_bit(ABS_MT_PRESSURE, dev->absbit)) { + p = input_mt_get_value(ps, ABS_MT_PRESSURE); + if (mt->flags & INPUT_MT_TOTAL_FORCE) + reported_p += p; + else if (oldid == id) + reported_p = p; + } count++; } @@ -244,10 +252,8 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count) input_event(dev, EV_ABS, ABS_X, x); input_event(dev, EV_ABS, ABS_Y, y); - if (test_bit(ABS_MT_PRESSURE, dev->absbit)) { - int p = input_mt_get_value(oldest, ABS_MT_PRESSURE); - input_event(dev, EV_ABS, ABS_PRESSURE, p); - } + if (test_bit(ABS_MT_PRESSURE, dev->absbit)) + input_event(dev, EV_ABS, ABS_PRESSURE, reported_p); } else { if (test_bit(ABS_MT_PRESSURE, dev->absbit)) input_event(dev, EV_ABS, ABS_PRESSURE, 0); diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h index 3b8580bd33c1..58d5402d382a 100644 --- a/include/linux/input/mt.h +++ b/include/linux/input/mt.h @@ -17,6 +17,7 @@ #define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */ #define INPUT_MT_TRACK 0x0008 /* use in-kernel tracking */ #define INPUT_MT_SEMI_MT 0x0010 /* semi-mt device, finger count handled manually */ +#define INPUT_MT_TOTAL_FORCE 0x0020 /* calculate total force from slots pressure */ /** * struct input_mt_slot - represents the state of an input MT slot From patchwork Fri Jan 14 18:31:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angela Czubak X-Patchwork-Id: 532141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB35AC433FE for ; Fri, 14 Jan 2022 18:32:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243143AbiANSco (ORCPT ); Fri, 14 Jan 2022 13:32:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243123AbiANScg (ORCPT ); Fri, 14 Jan 2022 13:32:36 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C634C061574 for ; Fri, 14 Jan 2022 10:32:36 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id ay4-20020a05600c1e0400b0034a81a94607so6318232wmb.1 for ; Fri, 14 Jan 2022 10:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PayoLFvRwC+37a4oakMmMBF6Q5SFDBpj4RWVePynPxo=; b=c4LkiYwffb39zsEmgIz+bGA02zqLWHItPK9DSorW9/8J6tosUJ2whjV8iTipO3HbJA nF7pjV4JXt78kGhVgKMDcsCHJbSYVXoqtPODxSDhHE60AuSUrfTyPZ6UncZsiGH710QP I9Z33+lk6B+Dv+6dQ0ucBRHF05Y3akW/Ar2xlXBVsFQzrwtNfrgNB443ONlJ5ze1uH7E /MCz5AXqSYl5l1kBTON02i+erj66kA9vPDSYi7ZQ+CLgZhxpi1N3PnDb9WF6GcN5kGRx j/yMmDUVuRV9gSOXZAZ2CEcgTihIKgIQBBR63eycD/fR107yQXUqycokvpAxqt6h4QPM UtJg== 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=PayoLFvRwC+37a4oakMmMBF6Q5SFDBpj4RWVePynPxo=; b=djq8/sXfzbS+Y4366VS1jPRTDWr28zNZDm78BEOBHIlDcpPMxYUWxTXlNpkOX6w9yw LURgp1PrinbdtKRW9v0CW2tL6m1BZLejGruoFWCQVPR5Px/XqMo8qro3n5tQu8Ns0YKc qIVz7+qQkFYnkWgCsaYYv5ZOE0dmDRkIzfIHumAdvsfC0zbREfPCdwKUO928ovlwKxlv Vk2zJ3JfXkHTN2b/WXdGFwtX+Td0sEBQ8u7/rq7xjSgLNsrlfsbakX4g8owxWZyTkYHH 3pzFd9Ov5oX2JxynQ6IJ/hIBtn8YhsIrBYDTLecHrc4gmtQOYBgYqb3mW5yLvye5eMyo doZA== X-Gm-Message-State: AOAM533LpooI/xepeU3eKi8pGKbsDuBq+qJTxcw5Hgrd0eEYUfmVXVAI gVR2XwtreTxYxBwwuWE8t3GmIC4fUp3ECFZSRiU= X-Google-Smtp-Source: ABdhPJxUumeoJo+uP6/WboGqTv5cQk3DqKo/V6LKfiBxxu2TlsQ8jae67wEBy+kL5Gs00wCwX/ME8w== X-Received: by 2002:adf:fa02:: with SMTP id m2mr8943201wrr.571.1642185154831; Fri, 14 Jan 2022 10:32:34 -0800 (PST) Received: from aczubak.c.googlers.com.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id az4sm6410984wrb.14.2022.01.14.10.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 10:32:34 -0800 (PST) From: Angela Czubak To: linux-input@vger.kernel.org Cc: upstream@semihalf.com, dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org, Angela Czubak Subject: [PATCH v2 13/16] HID: multitouch: add haptic multitouch support Date: Fri, 14 Jan 2022 18:31:49 +0000 Message-Id: <20220114183152.1691659-14-acz@semihalf.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220114183152.1691659-1-acz@semihalf.com> References: <20220114183152.1691659-1-acz@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add new option (MULTITOUCH_HAPTIC) to mark whether hid-multitouch should try and configure simple haptic device. Once this option is configured, and the device is recognized to have simple haptic capabilities, check input frames for pressure and handle it using hid_haptic_* API. Signed-off-by: Angela Czubak --- drivers/hid/Kconfig | 11 ++++++ drivers/hid/hid-multitouch.c | 74 +++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 3e7555b868e7..a202f01de912 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -755,6 +755,17 @@ config HID_MULTITOUCH To compile this driver as a module, choose M here: the module will be called hid-multitouch. +config MULTITOUCH_HAPTIC + bool "Simple haptic multitouch support" + depends on HID_MULTITOUCH + select HID_HAPTIC + default n + help + Support for simple multitouch haptic devices. + Adds extra parsing and FF device for the hid multitouch driver. + It can be used for Elan 2703 haptic touchpad. + To enable, say Y. + config HID_NINTENDO tristate "Nintendo Joy-Con and Pro Controller support" depends on HID diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 99eabfb4145b..ec51e189bb1d 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -48,6 +48,8 @@ MODULE_LICENSE("GPL"); #include "hid-ids.h" +#include "hid-haptic.h" + /* quirks to control the device */ #define MT_QUIRK_NOT_SEEN_MEANS_UP BIT(0) #define MT_QUIRK_SLOT_IS_CONTACTID BIT(1) @@ -159,11 +161,13 @@ struct mt_report_data { struct mt_device { struct mt_class mtclass; /* our mt device class */ struct timer_list release_timer; /* to release sticky fingers */ + struct hid_haptic_device *haptic; /* haptic related configuration */ struct hid_device *hdev; /* hid_device we're attached to */ unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */ __u8 inputmode_value; /* InputMode HID feature value */ __u8 maxcontacts; bool is_buttonpad; /* is this device a button pad? */ + bool is_haptic_touchpad; /* is this device a haptic touchpad? */ bool serial_maybe; /* need to check for serial protocol */ struct list_head applications; @@ -501,6 +505,8 @@ static void mt_feature_mapping(struct hid_device *hdev, mt_get_feature(hdev, field->report); break; } + + hid_haptic_feature_mapping(hdev, td->haptic, field, usage); } static void set_abs(struct input_dev *input, unsigned int code, @@ -831,6 +837,9 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, case HID_DG_TIPPRESSURE: set_abs(hi->input, ABS_MT_PRESSURE, field, cls->sn_pressure); + td->is_haptic_touchpad = + hid_haptic_check_pressure_unit(td->haptic, + hi, field); MT_STORE_FIELD(p); return 1; case HID_DG_SCANTIME: @@ -944,8 +953,16 @@ static void mt_release_pending_palms(struct mt_device *td, static void mt_sync_frame(struct mt_device *td, struct mt_application *app, struct input_dev *input) { - if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) - input_event(input, EV_KEY, BTN_LEFT, app->left_button_state); + if (td->is_haptic_touchpad) + hid_haptic_handle_press_release(td->haptic); + + if (app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) { + if (!(td->is_haptic_touchpad && + hid_haptic_handle_input(td->haptic))) { + input_event(input, EV_KEY, BTN_LEFT, + app->left_button_state); + } + } input_mt_sync_frame(input); input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); @@ -955,6 +972,8 @@ static void mt_sync_frame(struct mt_device *td, struct mt_application *app, app->num_received = 0; app->left_button_state = 0; + if (td->is_haptic_touchpad) + hid_haptic_pressure_reset(td->haptic); if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) set_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); @@ -1104,6 +1123,9 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input, minor = minor >> 1; } + if (td->is_haptic_touchpad) + hid_haptic_pressure_increase(td->haptic, *slot->p); + input_event(input, EV_ABS, ABS_MT_POSITION_X, *slot->x); input_event(input, EV_ABS, ABS_MT_POSITION_Y, *slot->y); input_event(input, EV_ABS, ABS_MT_TOOL_X, *slot->cx); @@ -1278,6 +1300,9 @@ static int mt_touch_input_configured(struct hid_device *hdev, if (cls->is_indirect) app->mt_flags |= INPUT_MT_POINTER; + if (td->is_haptic_touchpad) + app->mt_flags |= INPUT_MT_TOTAL_FORCE; + if (app->quirks & MT_QUIRK_NOT_SEEN_MEANS_UP) app->mt_flags |= INPUT_MT_DROP_UNUSED; @@ -1313,6 +1338,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct mt_device *td = hid_get_drvdata(hdev); struct mt_application *application; struct mt_report_data *rdata; + int ret; rdata = mt_find_report_data(td, field->report); if (!rdata) { @@ -1375,6 +1401,11 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, if (field->physical == HID_DG_STYLUS) hi->application = HID_DG_STYLUS; + ret = hid_haptic_input_mapping(hdev, td->haptic, hi, field, usage, bit, + max); + if (ret != 0) + return ret; + /* let hid-core decide for the others */ return 0; } @@ -1568,6 +1599,14 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) struct hid_report *report; int ret; + if (td->is_haptic_touchpad && (td->mtclass.name == MT_CLS_WIN_8 || + td->mtclass.name == MT_CLS_WIN_8_FORCE_MULTI_INPUT)) { + if (hid_haptic_input_configured(hdev, td->haptic, hi) == 0) + td->is_haptic_touchpad = false; + } else { + td->is_haptic_touchpad = false; + } + list_for_each_entry(report, &hi->reports, hidinput_list) { rdata = mt_find_report_data(td, report); if (!rdata) { @@ -1713,6 +1752,9 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) dev_err(&hdev->dev, "cannot allocate multitouch data\n"); return -ENOMEM; } + td->haptic = kzalloc(sizeof(*(td->haptic)), GFP_KERNEL); + if (!td->haptic) + return -ENOMEM; td->hdev = hdev; td->mtclass = *mtclass; td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN; @@ -1764,6 +1806,17 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) mt_set_modes(hdev, HID_LATENCY_NORMAL, true, true); + if (td->is_haptic_touchpad) { + if (hid_haptic_init(hdev, &td->haptic)) { + dev_warn(&hdev->dev, "Cannot allocate haptic for %s\n", + hdev->name); + td->is_haptic_touchpad = false; + kfree(td->haptic); + } + } else { + kfree(td->haptic); + } + return 0; } @@ -1771,6 +1824,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) static int mt_suspend(struct hid_device *hdev, pm_message_t state) { struct mt_device *td = hid_get_drvdata(hdev); + struct hid_haptic_device *haptic = td->haptic; /* High latency is desirable for power savings during S3/S0ix */ if ((td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) || @@ -1779,18 +1833,31 @@ static int mt_suspend(struct hid_device *hdev, pm_message_t state) else mt_set_modes(hdev, HID_LATENCY_HIGH, true, true); + if (td->is_haptic_touchpad) + hid_haptic_resume(hdev, haptic); + return 0; } static int mt_reset_resume(struct hid_device *hdev) { + struct mt_device *td = hid_get_drvdata(hdev); + struct hid_haptic_device *haptic = td->haptic; + mt_release_contacts(hdev); mt_set_modes(hdev, HID_LATENCY_NORMAL, true, true); + + if (td->is_haptic_touchpad) + hid_haptic_resume(hdev, haptic); + return 0; } static int mt_resume(struct hid_device *hdev) { + struct mt_device *td = hid_get_drvdata(hdev); + struct hid_haptic_device *haptic = td->haptic; + /* Some Elan legacy devices require SET_IDLE to be set on resume. * It should be safe to send it to other devices too. * Tested on 3M, Stantum, Cypress, Zytronic, eGalax, and Elan panels. */ @@ -1799,6 +1866,9 @@ static int mt_resume(struct hid_device *hdev) mt_set_modes(hdev, HID_LATENCY_NORMAL, true, true); + if (td->is_haptic_touchpad) + hid_haptic_suspend(hdev, haptic); + return 0; } #endif From patchwork Fri Jan 14 18:31:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angela Czubak X-Patchwork-Id: 532140 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CCCCC433F5 for ; Fri, 14 Jan 2022 18:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243050AbiANScq (ORCPT ); Fri, 14 Jan 2022 13:32:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243088AbiANSci (ORCPT ); Fri, 14 Jan 2022 13:32:38 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5279CC06173E for ; Fri, 14 Jan 2022 10:32:38 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id v123so7670121wme.2 for ; Fri, 14 Jan 2022 10:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9VwfXgg7eLphDCQdohq0yPt7WdrkP6UeE6DuepexdMI=; b=EpsmghBASmSA+4g472Dn0yVR4I4XgNi26rX/vNP8n2bY/Y9e0jSZnRtWnRu7u9l3Uk EeQQ+43ibRel2q10vbw8KdRkAPc4uxBM/APYNC/tOdTvG1gPvCqudjMAqtizLLVI8kCW M8uu6JAC//6jcemIDX7w9Pz50g9a0CR6/53f/97Me0QAOOGdD4OBjthZy78p6snZs1uq LCckxnDDIRgk5jbb4+Xt0fg9rkhbHRE+CP74irY0E2U15dmga70HJoL8FCLZI02L+Eq8 hsJ4vCOV76Xw6GD6a4yTmd6g/NQNG9GV61pVBgIPlTkRK8h3lpL1cr6QNB7Rhd33JLpQ g0SA== 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=9VwfXgg7eLphDCQdohq0yPt7WdrkP6UeE6DuepexdMI=; b=lFuaPHAULZubKYYV1+OaP8tBNwx1b8uzzbSW3XEEfeUuLEqsiEzYBB7a+d97NM0X1C VHdOWjIgl8M+/d7px2CzDUViZNjsdJPVf2rmUVZaULclUYNDoO66zDCY/M1zZwLeh/aC 38nwGzAllU0pNKutqa2pgiB5+e6uHEco0mgH7QP5xaXq7dtvvPGPbUC5QYqRTKj1cH8b EepzG6PhmomzAvFIUe6PDsQYdGl4WUZjUop43bpWgbkZfp062AOCIpgVLLPIFUeAFId+ WsPqdUO7f1c7ZtT5TdIobz8tNPN72MBDYen4AiJKsB6SJ/4RvyHvX3P4J0zsVTBxCxS3 LFpQ== X-Gm-Message-State: AOAM532J4XTyUZT8SAic8zyB6MY/Q0ARCXOvYVrMfLYJO5EHAmOEatX+ 18LaOg2EzdSm6pXNb0V4UEoVZUSJZoFDtqP1yFQ= X-Google-Smtp-Source: ABdhPJyoYuElB9cp9svuaSkC6agItX7Vh885eixvtHTL6hr2+hvG44A0Ayt7bpptO6mV2p5k+X5pZw== X-Received: by 2002:a5d:4c81:: with SMTP id z1mr9595982wrs.204.1642185156929; Fri, 14 Jan 2022 10:32:36 -0800 (PST) Received: from aczubak.c.googlers.com.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id az4sm6410984wrb.14.2022.01.14.10.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 10:32:36 -0800 (PST) From: Angela Czubak To: linux-input@vger.kernel.org Cc: upstream@semihalf.com, dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, jikos@kernel.org, Angela Czubak Subject: [PATCH v2 15/16] HID: haptic: add hid_haptic_change_control Date: Fri, 14 Jan 2022 18:31:51 +0000 Message-Id: <20220114183152.1691659-16-acz@semihalf.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog In-Reply-To: <20220114183152.1691659-1-acz@semihalf.com> References: <20220114183152.1691659-1-acz@semihalf.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Implement change_control callbacks for simple haptic device. If anybody has requested control over an effect, do not generate it in kernel. Signed-off-by: Angela Czubak --- drivers/hid/hid-haptic.c | 50 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-haptic.c b/drivers/hid/hid-haptic.c index 2035b8a6037f..adc11bd1d84b 100644 --- a/drivers/hid/hid-haptic.c +++ b/drivers/hid/hid-haptic.c @@ -6,6 +6,7 @@ */ #include +#include #include #include "hid-haptic.h" @@ -343,6 +344,46 @@ static int hid_haptic_playback(struct input_dev *dev, int effect_id, int value) return 0; } +static int hid_haptic_change_control(struct input_dev *dev, int effect_id, + struct file *file, int take) +{ + struct hid_haptic_device *haptic = dev->ff->private; + struct hid_haptic_effect_node *effect_node; + struct hid_haptic_effect *effect; + bool found = false; + int ret = 0; + + effect = &haptic->effect[effect_id]; + mutex_lock(&effect->control_mutex); + list_for_each_entry(effect_node, &effect->control, node) { + if (effect_node->file == file) { + found = true; + break; + } + } + if (take) { + if (!found) { + effect_node = kvzalloc(sizeof(struct hid_haptic_effect), + GFP_KERNEL); + if (!effect_node) { + ret = -ENOMEM; + goto exit; + } + effect_node->file = file; + } + list_add(&effect_node->node, &effect->control); + } else { + if (found) { + list_del(&effect_node->node); + kvfree(effect_node); + } + } +exit: + mutex_unlock(&effect->control_mutex); + + return ret; +} + static void effect_set_default(struct ff_effect *effect) { effect->type = FF_HID; @@ -527,6 +568,8 @@ int hid_haptic_init(struct hid_device *hdev, } haptic->effect[r].input_dev = dev; INIT_WORK(&haptic->effect[r].work, haptic_work_handler); + INIT_LIST_HEAD(&haptic->effect[r].control); + mutex_init(&haptic->effect[r].control_mutex); } haptic->stop_effect.report_buf = hid_alloc_report_buf(haptic->manual_trigger_report, @@ -563,6 +606,7 @@ int hid_haptic_init(struct hid_device *hdev, ff->private = haptic; ff->upload = hid_haptic_upload_effect; ff->playback = hid_haptic_playback; + ff->change_control = hid_haptic_change_control; ff->erase = hid_haptic_erase; ff->destroy = hid_haptic_destroy; if (!try_module_get(THIS_MODULE)) { @@ -652,13 +696,15 @@ void hid_haptic_handle_press_release(struct hid_haptic_device *haptic) else if (haptic->pressure_sum < haptic->release_threshold) haptic->pressed_state = 0; if (!prev_pressed_state && haptic->pressed_state && - haptic->mode == HID_HAPTIC_MODE_KERNEL) { + haptic->mode == HID_HAPTIC_MODE_KERNEL && + list_empty(&haptic->effect[HID_HAPTIC_PRESS_EFFECT_ID].control)) { spin_lock_irqsave(&input->event_lock, flags); input->ff->playback(input, HID_HAPTIC_PRESS_EFFECT_ID, 1); spin_unlock_irqrestore(&input->event_lock, flags); } if (prev_pressed_state && !haptic->pressed_state && - haptic->mode == HID_HAPTIC_MODE_KERNEL) { + haptic->mode == HID_HAPTIC_MODE_KERNEL && + list_empty(&haptic->effect[HID_HAPTIC_RELEASE_EFFECT_ID].control)) { spin_lock_irqsave(&input->event_lock, flags); input->ff->playback(input, HID_HAPTIC_RELEASE_EFFECT_ID, 1); spin_unlock_irqrestore(&input->event_lock, flags);