From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796020212; b=rZe75nWQ/wxoPG9PhCQj20UBu7jRTdwLbYQqybDd/wXlHC+Mdcb0HYLKGlLVRDVTbEJh HDILAoFH7lWPnG3i2YWIl3rehQiHxNbSdNYSa2j5lLViDnK3HKEDLzfJEiaIn8ofSKQax tBzzYa0TADD6eonT3WMsSXKhwj9nG1SICAW+aNy3POIuu56EvXuW+TVg6GRPNsh0LQCGb 2+jO7TEmtVdVZpIO8FtK+pI6AotovB2JNSupKoa0cTpCOrGgeTR6m79Tv8aAp7cYQYXWi tbleeUbBz8WNv0TPS6AAW9YIDpAqtO2+uMwSHyoFl1/tApFxpsMbJLY8ttc7cnTg5Ug== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020212; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=mYIFFKn4VSH3RnIG8Rk1Ce+9Yxv0Y2xWiPTEHQClwvE=; b=AXzb1M3FAOvM0XO2mKmr0tUckAx6JIFMy786H5s0YxH9VcbZwEhiY6UD64M040t690n3 ya3OLkrENeflX7ZcJrSxip7UbV4ALWDnHJQsq4P72tYqGTTEsruEGHHLMre21kxUAyv4E +kG/uvM2iEhB3lKVG4bnSpnafweTEGa0cNrjDJn9i+ghWiTEbQV4U3GXK4U5NEwfJozkx J8UBRXVMCC49rihXzvqGyqXqelhAoQzE7VDS0Vt2IXmycoyiHXL4fr+c4AtOCpzdF/NN8 FJwwly+9ex+sKgBpRyB6Cl/NzEfvehbY/c/4K5e053eQ6G8hVJET6A8cDeSOFKiCSUA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="eQ/qAL4f"; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52F2C606A32C for ; Mon, 30 Nov 2026 06:30:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eQ/qAL4f Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796020211; b=mo2zXvusMQPuNV8yFFNZNxGnadG108WH1aapfM/8lH9eecQSDYJ+kU8S7FrlYSYJNfmJ TiV32jjnDn+koH4kBpttqbleD95NYETEgWxL2LW8O5UOUXOSnXPL0WuS6FQOqP+tx7xY/ bK+aozqH1HIQuzmTmdI27LhrX5WGNKGDOk910UlhGTmic7A7qyPzf1Ir9pXGYzixbgHm1 v7Ao03bqEX6XuEVngMeqc72c2zoxBF2XaH5UJifhLmPXPfrgcMQC9mURbjC9+h3wwiUax p+xmW2mjNx+Ti+UVq69/2g8FfXljjqJAFUHvHK4t5FAhz4cTJtl4WC9K7/yjMCCdoGw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796020211; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=mYIFFKn4VSH3RnIG8Rk1Ce+9Yxv0Y2xWiPTEHQClwvE=; b=kzPCAjK6Id5WWtZxUWUVfwkwePAkv2SG3s2dgT4RZ6HDquZlY6BXx3dXUHqQnD450J3d q59V90o09QdhP2AlZ2+m9eq0Xp3hKVnD+QOYGmqPB+L5fjIL5jnzCqMl+RugN79B3OnwH CIS24g3vIGQBrmiyXB+zTATXRDw1N7ep5ayN+E05JuaT/CQ/fymsTKo5TuBgH6UYp4rGq FqU5hmGanhytRq/eIqNeMFfoOWi5GtRRSak8TlE3OYr267kkzxneJ2jc5X8PdtYiBllg6 QfIp7zlOB+O907+kEYmjs3k/0JC9cI4GX7Lgvwa6zeFhEWQ6GzOSY/JIMkPyZnpSt5Q== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id CFB741F00926; Mon, 30 Nov 2026 06:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796020211; bh=mYIFFKn4VSH3RnIG8Rk1Ce+9Yxv0Y2xWiPTEHQClwvE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=eQ/qAL4fWnJcdS79RizVgwGW8xRgd4x+hML71mhcvuK9j1qN/VEjcgVgeyGwYVqFI GmTjBDopaFnp+2imC8iWglR1Wiq3O1VS8bdjfY4EFzOct8vi4DVLcIFXDJBCzOACH/ IJWSkftMGDOET/BZlYSoWcSn9r71OmqE2L7oQ6h96j//zNnqngtAdUffxdaOhFwm3F Bxzk5pnawQIMY+iMMvDkOpPovziRyhcerH89wtN+FFyBu3rev9w0PJDg0gsq22L/Sj g5Vl7nx6p9D0HHjNLTHHIi3I3q6SYTs9B0tZZPjSsEMyFEaBIyn0rWi+zciiLcytBx g5jS2PZeLQZkA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 827DE4E6FE; Mon, 30 Nov 2026 06:29:55 +0000 (UTC) From: He Xin via B4 Relay Date: Mon, 30 Nov 2026 14:29:34 +0800 Subject: [PATCH v2 05/18] iio: accel: adxl372: support mount matrix X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261130-work-v2-5-9eccecc71702@hexin.host> References: <20261130-work-v2-0-9eccecc71702@hexin.host> In-Reply-To: <20261130-work-v2-0-9eccecc71702@hexin.host> To: linux-iio@vger.kernel.org, Michael Hennerich , Puranjay Mohan , Marcelo Schmitt , Antoniu Miclaus , Ramona Gradinariu , Petre Rodan Cc: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , linux@analog.com, He Xin X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796020192; l=2154; i=hexin@hexin.host; s=20261130; h=from:subject:message-id; bh=2c4diHzSSPx/fOsrHHu4L4XkAKJhTweh3NO+5t+VRVc=; b=Qhcdxe1/h8LgkF4BnTTT9jhgYkjLtJqxPdZvoEE9QUyj1UF7lNYFo0kGkplHvW5aN5XANadRN 6VVzcCdgOurCWQ8jfzaXD2+P7nza20tRvf8fSIhmoQS52Ja9XGQFFIE X-Developer-Key: i=hexin@hexin.host; a=ed25519; pk=XShmjlZrsbSLtSY1GT4Ptl+4KQ/QVjE9VGdvbN87rFk= X-Endpoint-Received: by B4 Relay for hexin@hexin.host/20261130 with auth_id=1691 X-Original-From: He Xin Reply-To: hexin@hexin.host Content-Transfer-Encoding: 7bit From: He Xin The driver ignores the mount matrix described by the firmware (ACPI _DSD "mount-matrix" or the devicetree property), so the orientation reported to userspace is wrong whenever the sensor is not mounted axis-aligned with the display. Read the mount matrix at probe time and expose it through IIO_MOUNT_MATRIX(), as several other accelerometer drivers already do. Signed-off-by: He Xin --- drivers/iio/accel/adxl372.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c index e375d068a3..b5a9c395b0 100644 --- a/drivers/iio/accel/adxl372.c +++ b/drivers/iio/accel/adxl372.c @@ -315,8 +315,18 @@ static const struct iio_event_spec adxl372_events[] = { }, }; +static const struct iio_mount_matrix * +adxl372_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan); + +static const struct iio_chan_spec_ext_info adxl372_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, adxl372_get_mount_matrix), + { } +}; + #define ADXL372_ACCEL_CHANNEL(index, reg, axis) { \ .type = IIO_ACCEL, \ + .ext_info = adxl372_ext_info, \ .address = reg, \ .modified = 1, \ .channel2 = IIO_MOD_##axis, \ @@ -368,8 +378,18 @@ struct adxl372_state { __be16 fifo_buf[ADXL372_FIFO_SIZE]; bool peak_fifo_mode_en; struct mutex threshold_m; /* lock for threshold */ + struct iio_mount_matrix orientation; }; +static const struct iio_mount_matrix * +adxl372_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct adxl372_state *st = iio_priv(indio_dev); + + return &st->orientation; +} + static const unsigned long adxl372_channel_masks[] = { BIT(0), BIT(1), BIT(2), BIT(0) | BIT(1), @@ -1292,6 +1312,11 @@ int adxl372_probe(struct device *dev, struct regmap *regmap, return -ENOMEM; st = iio_priv(indio_dev); + + ret = iio_read_mount_matrix(dev, &st->orientation); + if (ret) + return ret; + dev_set_drvdata(dev, indio_dev); st->dev = dev; -- 2.53.0