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=1796020218; b=iVJPVrDL/JBLe+pxXGRI1VwEcxcq2ycfSYO7OUcdmdAkQg7DPAkk+oqe1k50wDleDyS/ B9JdKngICiUkTmK8OH/sYIi5RBRbevug63GwG6jE0H6OdJE/4CpE2JuqXsmVf9qHz5gZX 6OiSNn3hyX8OHz7W9amgXTF2ATJDdxkj4QxcfmHmkSQvDIQhzNn3KlVlmO7m6FbkP2pSb 6yR1mggZPzkbq4CNwbhmRHgec2b8wayoS6+4WzeJ1qA+XSCa7i6rveO+csxt0aSLsmWmc 9kHMbZdntOhvJ9u50xYTnB0Dy8j8zpLuWXdPurN6GBP9XuU8X6XmleQKKGaXM5NNS9Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020218; 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=hh6vN2GVBEDxokoKcMUpYTAwnlP7CuryNfuPXSFC0eA=; b=Id0zhwvjKKYi6rOUc7Kez8VOiAyrt4Xbl6w8myvWXCW336e0WFHw7fnxLX0SCjCmnQsc Coil8LbW5z34SKbhFMDENIu7uWhVHZn3A5y/q8RQHeiETJfBsgKN1Xisc0o6UXK8sz7fq m1UuqTBr6rdfvbnIKHVkeSNHTEDeTMTydPZ5TceNoCDE9xY4yWmsGKm4HuueVPYDHV1hi fpSnvwLSVmAiIne36MZu+OgiEGF8D5jWRjdT6NludSkG1cm4jgP4+ErAMgKwDWQKqqhCL FFAC6et5IQunn4nVW7J+1H26f8YPpVQIt25uZsqKREj+uK1yulFkhySLySh/rCgQW9Q== 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=epgeYyBb; 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 B9B05606A320 for ; Mon, 30 Nov 2026 06:30:18 +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=epgeYyBb 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=1796020218; b=IsQuEldSPeYhh7X35vQOfey8VU1ehOVlhRMzDoHwAuSz3huuiie0pkdC5dPIT9GROXEW /bC3VX4KuAvtUKgS6lnW1EJr4mVsHCrfgZ/udzAC9dFnRc+aoJF/+Ue44QMEbfVSW106f 3mNkKUR2y+lrWfgU3/Dpsx1sY0hTuROfnKoRhptbijRMEIIirKOHBTwQqtAnQXWeY5FpW l4JL4kStKYMd5jR7FKGiIHIEcRAbq2+GZedrgYdYrvq1elcpIOVUZXZdqsKMGZdq7aMDp bsovF5prefvDgBCzcnMy3eahtoHuloPAdQb7xFWPR14PYjyZ80wcE5gspjuYiCTa7Gw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796020218; 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=hh6vN2GVBEDxokoKcMUpYTAwnlP7CuryNfuPXSFC0eA=; b=vpMD5VbGni3zCH1RpqY4Kry4rDSaIxt2M9cs3bNmQPa1QE0BNvbf7ETy2C7Ht7Lir8HS 296K7BmyV5CQZ2JL1fmc/BJ4pIJpDe1SEZpAAkkginW5/v9ZAXhLbLiPn+kMRl4NXxUA8 eDfuV6T1cOp3/XecnvAx4HpST8NfDUoPNl0BlxGaAXyE7dw7P7pnkXzmFs0KM9S7k4B3p ZL28BUGMEDCEjw/Ul02ZyzgwNP5gIAyfIL3lIllnS9EG3izvt4dhP/ApA/xFu6go/JLpM LZXQQ/vtVnvm3+/W2tz0dAWm3HL4XpbXWx1UuPVHbmq2h22jdcdlTrJ5XliYiuuREUQ== 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 056F91F0089C; Mon, 30 Nov 2026 06:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796020218; bh=hh6vN2GVBEDxokoKcMUpYTAwnlP7CuryNfuPXSFC0eA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=epgeYyBbcv1QHzIuxZoToEdFsHsBokYXstQUbT/ezSOkxrmdC9FpavaIf5h59rN29 gO9ojr3AZdfypVmuGN21JL6KYzfn0JXkvRZZzGgKHnUjlOmlqejdiSxpfHC7rYZOO+ ZBDiuAdGD4d+KwYevnsrLjh2uZB2WHDBoT3Bvk+enL2HivNq48npgvfTeHk6ZWvNYg gP0nnzRlGa7JTFPc1/29uPgytNCEoem/Nnnm/K6dIq1xEDJVPaSh0UkY7vMmhY2zzr u+GW0jA+2nv3v//R5l8QMujFmE+kzZ5eo/v3xBgNujNDKm4Ej8/tGRE0h30l1uxXop JzIq1EIPLVgeQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 27F7A4E70E; Mon, 30 Nov 2026 06:29:56 +0000 (UTC) From: He Xin via B4 Relay Date: Mon, 30 Nov 2026 14:29:38 +0800 Subject: [PATCH v2 09/18] iio: accel: da280: 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-9-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=2041; i=hexin@hexin.host; s=20261130; h=from:subject:message-id; bh=TSDjAvjUS/GE7AV0y50zIiPxJgN3WdtZVwi7+r70RNA=; b=jbDS5ZjI4HzXG8ZHOBOjoUVsGspPLpWJA+CGnk//ripAucFuh44xTKtoFVeCAq+wSvVuQbd5e 5yYSFQgdPh/Bx/bnUglaeY50Lu2JBfQtidIQq3UzzB4HbSJSfs9ab07 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/da280.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c index 15acbe1c2c..7ed3624221 100644 --- a/drivers/iio/accel/da280.c +++ b/drivers/iio/accel/da280.c @@ -30,8 +30,18 @@ static const int da280_nscale = 2395019; +static const struct iio_mount_matrix * +da280_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan); + +static const struct iio_chan_spec_ext_info da280_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, da280_get_mount_matrix), + { } +}; + #define DA280_CHANNEL(reg, axis) { \ .type = IIO_ACCEL, \ + .ext_info = da280_ext_info,\ .address = reg, \ .modified = 1, \ .channel2 = IIO_MOD_##axis, \ @@ -52,8 +62,18 @@ struct da280_match_data { struct da280_data { struct i2c_client *client; + struct iio_mount_matrix orientation; }; +static const struct iio_mount_matrix * +da280_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct da280_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + static int da280_enable(struct i2c_client *client, bool enable) { u8 data = enable ? DA280_MODE_ENABLE : DA280_MODE_DISABLE; @@ -119,6 +139,11 @@ static int da280_probe(struct i2c_client *client) return -ENOMEM; data = iio_priv(indio_dev); + + ret = iio_read_mount_matrix(&client->dev, &data->orientation); + if (ret) + return ret; + data->client = client; indio_dev->info = &da280_info; -- 2.53.0