From nobody Sat Oct 4 11:14:54 2025 Received: from mail-io1-f74.google.com (mail-io1-f74.google.com [209.85.166.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FACB322764 for ; Mon, 18 Aug 2025 14:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755527348; cv=none; b=GB/fuwhfqMgHf+rF+jipTCVZiXEME88ghA+G3nYMtx+o/8Nz8STXAUNosaGN3rX02+Gfsif/cePBzlAYaKIGIxbqoOmzJfGvU/TYgYZaxmqbD82wb2XhLvIPXcLEg4bGQdOsdwWks3BqQQDY8ruXEGbqyL7H2VM3TyM6u6SS82g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755527348; c=relaxed/simple; bh=Atcf/onrjtwlUDJDKbgX+nxH8WoEO/HoYTnRVc1sXTk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QCo7pxo5eV5VEHJpJLHlfl1sMCMFY6fyt3th7qMBeFbfDp8zSKJSo46EYOUSLojUQ2c6AecyLTLGiB1MmcbG8BPfUdaS5m0gl6/REoQIEaJe+MdqTLob6IZDkp+VPcxug16J/2FaXdb9Tcu3HTO5RKPYPMbqVpqt+YZjW76GCaY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jdenose.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=3Ct0a0Gt; arc=none smtp.client-ip=209.85.166.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jdenose.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="3Ct0a0Gt" Received: by mail-io1-f74.google.com with SMTP id ca18e2360f4ac-88432ccc4f9so1122151939f.0 for ; Mon, 18 Aug 2025 07:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1755527346; x=1756132146; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=q1k1mjvOHwuify9LTlOteZLmh387iXArNoe6DszPTuA=; b=3Ct0a0GtXUmplU5qI0Q8BVm/wBsDt2ZGxAPGxK0wRomjXvqDHSKxAlWMtNSJZLX+Oy 5fSGc4ctmtpVJEzmAb+Jitdk/PnY0wOMm2vGlh45cePIFqtawEO06OlUJt8bJpJRdn7b THO62ceIv5nIo6CwMS8L8D14lJwpmd/BeukBu9kxtv5SAEBb8Ty4cZuVDszVdYUhAjMS 8ufY/OShbuP4ySi/9E5ZrDCNRgwWcmYGYtBgbbkQitc+d0tIoH2fMwFgoLdOk7CmOmbx vvulinrMHFJzs0rRJzK+Leyh+CnhVnEN1e1eD3OmQvFnMFBMddLpTLymgy39m2+tDNaj Fgsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755527346; x=1756132146; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=q1k1mjvOHwuify9LTlOteZLmh387iXArNoe6DszPTuA=; b=uJidIHdqvo6QbKTX17kBa3CTo+yoxVmkXMq8K5ZQwYxKMgBE0uVWBxG7PKdZAlBodD f4Lo3+QaNT6ll56DAB1JLHx4pwovXx1vjY1TydX5+k1i2OYoPVGZ7fYuKiSFXFMBW9sG cpuGmqFK+okKI2dNxcYh9cW8NhcATxifERjNn0NULUkxoEmAmbV2Pb3RIG5kxJUX4rn5 /z6Vvn/ARg9PkfexdjQKVHkMBnEmu7mlmhNsXs6H6DvgactksE8/kIprYKYmAyYqNv+S 1LXkpAxZ+KmHtC3/xU5zimc8wnijrJB498RCkH/WOnLeg+8TpRzAYvK6UaAyzsF07UcB 6qdg== X-Forwarded-Encrypted: i=1; AJvYcCV0FIEZVKtZtR4FAFywvDjVFkHtzSMAlUpU2X3Sxsss3VvlIYR69zG9i/yNz0OxoV46dL4AH3P7alIDZIc=@vger.kernel.org X-Gm-Message-State: AOJu0YwCI7qJVwt+vwO4pyYj1vdxXvJzUasZHB9JYLxkbfaRjQ3gCNje fot+RnmR1atQy6X3fGH1H9q2Bk10FfD4tMxQp4cKLRurwFh+owJvqpbFrSDmb2F7dLKZNLAC3aE VZ9TPbfHpyQ== X-Google-Smtp-Source: AGHT+IHskcxyJpFYjk5Ryp9JEoiKYpePKMrSar2kRX1rGmIsjtIdsVkijDGJ4H7+mfWpdUH3OI2LF6xfPnW8 X-Received: from iobce3.prod.google.com ([2002:a05:6602:42c3:b0:881:9efa:4bc8]) (user=jdenose job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6602:2cd3:b0:876:7555:9cb4 with SMTP id ca18e2360f4ac-884470f7150mr1505137639f.1.1755527346152; Mon, 18 Aug 2025 07:29:06 -0700 (PDT) Date: Mon, 18 Aug 2025 14:28:07 +0000 In-Reply-To: <20250818-support-forcepads-v2-0-ca2546e319d5@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250818-support-forcepads-v2-0-ca2546e319d5@google.com> X-Mailer: b4 0.14.2 Message-ID: <20250818-support-forcepads-v2-7-ca2546e319d5@google.com> Subject: [PATCH v2 07/11] HID: input: calculate resolution for pressure From: Jonathan Denose To: Jiri Kosina , Benjamin Tissoires , Dmitry Torokhov , Jonathan Corbet , Henrik Rydberg Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Angela Czubak , "Sean O'Brien" , Jonathan Denose Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Angela Czubak 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 Co-developed-by: Jonathan Denose Signed-off-by: Jonathan Denose --- 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 d42c1fbd20a1cc01c04f93cf10f1d1c18043929c..1d59787bd0c0e251698e2a2944d= ae1c4a96adefe 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -303,6 +303,19 @@ __s32 hidinput_calc_abs_res(const struct hid_field *fi= eld, __u16 code) } break; =20 + case ABS_PRESSURE: + case ABS_MT_PRESSURE: + if (field->unit =3D=3D HID_UNIT_NEWTON) { + /* Convert to grams, 1 newton is 101.97 grams */ + prev =3D physical_extents; + physical_extents *=3D 10197; + if (physical_extents < prev) + return 0; + unit_exponent -=3D 2; + } else if (field->unit !=3D HID_UNIT_GRAM) { + return 0; + } + break; default: return 0; } --=20 2.51.0.rc1.163.g2494970778-goog