Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1863728rwb; Fri, 19 Aug 2022 10:38:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR7u3gjkqOXt56WMZixPupKc1dB1Dsgb0k31JKm48A9rXc1Bnhy2/AXSo7QyyV5Wd8m6MkAz X-Received: by 2002:a17:902:8f87:b0:172:83b5:d771 with SMTP id z7-20020a1709028f8700b0017283b5d771mr8595372plo.159.1660930721968; Fri, 19 Aug 2022 10:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930721; cv=none; d=google.com; s=arc-20160816; b=JJhsmDYk44BwmHM1ucVyJuWQhNMds77fXJYlCpm4pjjf57e1H52rcrLdW7s1m4diQ5 OYKxK88yNPVVacrwbvY/+M1UD8SjQ2SrK5t9I/+7hjwpnfD2VC+xlHiFmRlN0gMDKUpK aTI9TVrREyfaMk/X4bLt/+/0fzdU1iUvXZpENQ6rsSAqhMVKtmOYCyxSNEPR3n/HEUne X5nngQ1Kcs47bYknPFC9CHY15Fw1XIzLhW46XDFEh+hPRFb3Y9nrIL+xPOr55o0lDjNV ktOSXzFhfwf04LvYUUyFZ7jAvShhjtG5WkIC1JBm99JUZedSDd7xweE6VXOt6hsLgf06 prcg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W4WDOWWM4tS6nq59VUQ67ci3sSkUUXo5iP/CBaJwca4=; b=PrDH7dQpHcwmYjEchreuxY9mERv1HQIT8R69Wca9hExftQVvogsv6mNA8wuY9dpjX0 eynVrDsFoNwji4+So64HIThQk3QpoM7+Fxj+wKeQV7/EDSBi3+Rn2kvArsh9r7PxAkx3 6XJuMk7mN37Gx5Soe0Gpk/4OQtNV30cidjUYZZ4df+kNDpS0svDR47OdlxN1zxIY33uA OCKRzvhcJlAsHKvx7XAzqEUTJEF5n/XjIIt1t/lK/yGkuohPxdfrFLtMMIC2gfF5j4iW hxGqvJHLMAlcoqg5z4QvjhIp8LiaT74qEuXTKaNyr553JqBYP8ccydsFlODcEJ+sUhL0 O/6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j3JRfPsl; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj15-20020a056a02018f00b00410702fefc2si4643552pgb.390.2022.08.19.10.38.31; Fri, 19 Aug 2022 10:38:41 -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=@linuxfoundation.org header.s=korg header.b=j3JRfPsl; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349981AbiHSPqb (ORCPT + 99 others); Fri, 19 Aug 2022 11:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350090AbiHSPqR (ORCPT ); Fri, 19 Aug 2022 11:46:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F27126DF; Fri, 19 Aug 2022 08:46:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C347161562; Fri, 19 Aug 2022 15:46:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4891C433D6; Fri, 19 Aug 2022 15:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660923968; bh=5kiUs4sPPJU/Wj5M37mT4DSsBeG8+nlzUmmHSuqPbYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j3JRfPslqTfGs6IcgGOorPbBzpOddhH5w5J6FTodqFVQujKTKAyWfPdiZZ5NjPPig Bxur6sxQxSR40asrqIxXgsXwDvem9qcpVr+AGroylh8zuy1q0NRj/K+jYdx6apcrBD GYmRCvvyJC3ulbBA+ifcfrevBR08gZy6iPtRnzfM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ping Cheng , Jason Gerecke , Jiri Kosina Subject: [PATCH 5.10 012/545] HID: wacom: Only report rotation for art pen Date: Fri, 19 Aug 2022 17:36:22 +0200 Message-Id: <20220819153829.731267299@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Ping Cheng commit 7ccced33a0ba39b0103ae1dfbf7f1dffdc0a1bc2 upstream. The generic routine, wacom_wac_pen_event, turns rotation value 90 degree anti-clockwise before posting the events. This non-zero event trggers a non-zero ABS_Z event for non art pen tools. However, HID_DG_TWIST is only supported by art pen. [jkosina@suse.cz: fix build: add missing brace] Cc: stable@vger.kernel.org Signed-off-by: Ping Cheng Reviewed-by: Jason Gerecke Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/wacom_wac.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -638,9 +638,26 @@ static int wacom_intuos_id_mangle(int to return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF); } +static bool wacom_is_art_pen(int tool_id) +{ + bool is_art_pen = false; + + switch (tool_id) { + case 0x885: /* Intuos3 Marker Pen */ + case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */ + case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */ + is_art_pen = true; + break; + } + return is_art_pen; +} + static int wacom_intuos_get_tool_type(int tool_id) { - int tool_type; + int tool_type = BTN_TOOL_PEN; + + if (wacom_is_art_pen(tool_id)) + return tool_type; switch (tool_id) { case 0x812: /* Inking pen */ @@ -655,12 +672,9 @@ static int wacom_intuos_get_tool_type(in case 0x852: case 0x823: /* Intuos3 Grip Pen */ case 0x813: /* Intuos3 Classic Pen */ - case 0x885: /* Intuos3 Marker Pen */ case 0x802: /* Intuos4/5 13HD/24HD General Pen */ - case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */ case 0x8e2: /* IntuosHT2 pen */ case 0x022: - case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */ case 0x10842: /* MobileStudio Pro Pro Pen slim */ case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */ case 0x16802: /* Cintiq 13HD Pro Pen */ @@ -718,10 +732,6 @@ static int wacom_intuos_get_tool_type(in case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */ tool_type = BTN_TOOL_AIRBRUSH; break; - - default: /* Unknown tool */ - tool_type = BTN_TOOL_PEN; - break; } return tool_type; } @@ -2312,6 +2322,9 @@ static void wacom_wac_pen_event(struct h } return; case HID_DG_TWIST: + /* don't modify the value if the pen doesn't support the feature */ + if (!wacom_is_art_pen(wacom_wac->id[0])) return; + /* * Userspace expects pen twist to have its zero point when * the buttons/finger is on the tablet's left. HID values