From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E6443C00BC; Thu, 15 Jan 2026 17:26:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768498004; cv=none; b=iiXlKALk/s6YtOyhVdBbQSFuU/8T4y5sSLhBR2188dp9yhZOr6v4LFh/2Xbh9mO6Y5oSBZ6oAgdGnHayCjFPFyQ5PqtwS46bdnkNU7t47iSqL8QC+NXKC+fVfG9Z7wQ0onCGwsV1t6A+twKBgV1Ou0Jzew/o1gzKmMcsKCV4Sys= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768498004; c=relaxed/simple; bh=GNgVOI9xn22Kn0TiFZ79Jpbw42rD9w9fczeapYqbLPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CrQ3UdcGIM/vHC5+9WO2Pf0+fJ5Kdu3hxmUE8BcmTCNJRol+C0FbIEL80wikJMy71p4LsYz6p3m2g1zQUf/N+DlLXIVEaOSAb2pP77p8y62r+ZkUKKhv7IUq480gT0eB/OWJ0ZhE7ylxjG0s8oliJZmdr/hdplMsP7y47aTFxN4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wvB4t0qd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wvB4t0qd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05424C116D0; Thu, 15 Jan 2026 17:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768498004; bh=GNgVOI9xn22Kn0TiFZ79Jpbw42rD9w9fczeapYqbLPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wvB4t0qdVMNzab4igLeUfTL0eIbZadgJB7gs2vTumYCiCJQU06tIzCOSxZS591pIL cy5Kh/beMtbNkgw2ka8jOSgxcJORKXCJWyMnG+Xr7qIHzUT+lfO8wo8yDsxVezcC/E i+6pmcvm52Dmr0clb8bP/XcKt+JCN56dXQdwH3oo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ping Cheng , stable@kernel.org, Jiri Kosina Subject: [PATCH 5.15 246/554] HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen Date: Thu, 15 Jan 2026 17:45:12 +0100 Message-ID: <20260115164255.145276710@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164246.225995385@linuxfoundation.org> References: <20260115164246.225995385@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ping Cheng commit 7953794f741e94d30df9dafaaa4c031c85b891d6 upstream. HID_GD_Z is mapped to ABS_Z for stylus and pen in hid-input.c. But HID_GD_Z should be used to report ABS_DISTANCE for stylus and pen as described at: Documentation/input/event-codes.rst#n226 * ABS_DISTANCE: - Used to describe the distance of a tool from an interaction surface. This event should only be emitted while the tool is hovering, meaning in close proximity of the device and while the value of the BTN_TOUCH code is 0. If the input device may be used freely in three dimensions, consider ABS_Z instead. - BTN_TOOL_ should be set to 1 when the tool comes into detectable proximity and set to 0 when the tool leaves detectable proximity. BTN_TOOL_ signals the type of tool that is currently detected by the hardware and is otherwise independent of ABS_DISTANCE and/or BTN_TOUCH. This patch makes the correct mapping. The ABS_DISTANCE is currently not mapped by any HID usage in hid-generic driver. Signed-off-by: Ping Cheng Cc: stable@kernel.org Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-input.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -752,7 +752,7 @@ static void hidinput_configure_usage(str switch (usage->hid) { /* These usage IDs map directly to the usage codes. */ - case HID_GD_X: case HID_GD_Y: case HID_GD_Z: + case HID_GD_X: case HID_GD_Y: case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ: if (field->flags & HID_MAIN_ITEM_RELATIVE) map_rel(usage->hid & 0xf); @@ -760,6 +760,22 @@ static void hidinput_configure_usage(str map_abs_clear(usage->hid & 0xf); break; + case HID_GD_Z: + /* HID_GD_Z is mapped to ABS_DISTANCE for stylus/pen */ + if (field->flags & HID_MAIN_ITEM_RELATIVE) { + map_rel(usage->hid & 0xf); + } else { + if (field->application == HID_DG_PEN || + field->physical == HID_DG_PEN || + field->logical == HID_DG_STYLUS || + field->physical == HID_DG_STYLUS || + field->application == HID_DG_DIGITIZER) + map_abs_clear(ABS_DISTANCE); + else + map_abs_clear(usage->hid & 0xf); + } + break; + case HID_GD_WHEEL: if (field->flags & HID_MAIN_ITEM_RELATIVE) { set_bit(REL_WHEEL, input->relbit);