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=1796020219; b=pyRaySCpTg98KXeG1v1SVwoaA6z3Eiel5uJy7DihvwJuBJpk1cK6Y6qQsIkNy3NkCYo/ VQw0gd9OUC1EtiF8J5y8Q1bx7o/6FVzZFbxAWQTepAmsMAsNWvQLN0J8MdxvXMROCUpM+ Hob7yCuaAh3Prt20A0Y7ydVbJH2GB6hEc5axWn7m4X41TP23KTma6Lm/wAXVYDRmnGI7T Bu8L+8fdaQUfToebP0KA8cgwlJxiZgwT5Bp6RMWWBajFmxSbooqFuleh5ketXbEdvgZIJ PHu7pLL9fXCUuGVTnz7vPoKUreIpSXAMWST6/UEATYx1unux8YvbgPCHFNBxdYYNvmw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796020219; 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=GcuLOe2ATCRSzHzA3cF79YbTJLsTNYTfGZqFcmomLKc=; b=D0oZaT7wRVk/LXtHAaODRBFTYa5ULJTQDEndYNbTIRKDomShQ2Jc5uyN2QPYfQFd38tL xmKe3ek+MWuQVBi9Q+fjYnOwJefsTcu8BieO0QcyqFhOiGjA3Vcf5C3Lcfud+OEs4TsVq N4ZKvuA5spd8F5GsuMEMEEFD3dLkt042qC75NdW8In+2StWxFfO54/e4mh7mGN30g/CHL hgvfFQIDz5lviqD+6YopWEvDNWw3sdDWTPuZh2zOqNzXIBwLgxlzstVIs5hORD5Ny7mPV pDG+9EuchkzjQ9TwwsC/Lo9XT7eiBeJPePSylKwte4ryWvOlfI3XHhMQ41ISyI8bhFA== 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="Fx8O/y1V"; 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 36ABE606A681 for ; Mon, 30 Nov 2026 06:30:19 +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=Fx8O/y1V 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=1796020219; b=crGGg0bb9AhZzmQ5YrkGyubyUNiYPh+mctTmit0dvAfwL8GkKp/1DiwfUsVJVO4Hq3Ni E2AkCs5MeeePeRypHkrWsX2ZWLBt4eOhlhipJmbUinQlnTkLn7c2xkVqxExUKeWaQBT3j JqWw7m8HcwAvFCJglkygg2mDO0BzTstPs776UzeYxunWtRJ/f9HyszjTl8K1CTx75t2/3 0zJo1p2IXUbnj20OeKxEdPU2Mt8K/HO+eBYp7mmfOAPk7DnvDHvew1stUQWk2jsAkPTWV QRy2SL/zes7FXm+1Niqe9oazkEI0xyZdwYCb3MxVkoV8GTOhP54esoYXgf/uiCHi/2Q== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796020219; 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=GcuLOe2ATCRSzHzA3cF79YbTJLsTNYTfGZqFcmomLKc=; b=2iZKRaC6wxh6b3hh04+BhLwYE3jzQhm0znqAnGrPIKUoO1yfDMpevzW7kmgM4us+dp6o MA2dQTqR1SAAWMC479dPDgDVmUEyca9Y/NvcUOXFYiZ+Dh7s49WWC8A6b2kYgOTAUIaiw oDHKO2T8RdZtLmwhB9M/bnEP4p4dNMLrazTty+FRYuLsSLGnbiXfdSUBBRjtKLvYuhgav dDyWSAmXzGF2jqCpZv2Ysvhf1psw6VSYd+byJl5kTagx+0+awBbcEY2cd3aZbvkIn2gMr aaGPW8Q5qaBJhcOzHoIvFLJV1kdHv+kz1o6OsYfxDRX1rPL6EhZ4qWx/v9DiivNovWQ== 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 B9FEC1F0089A; Mon, 30 Nov 2026 06:30:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796020218; bh=GcuLOe2ATCRSzHzA3cF79YbTJLsTNYTfGZqFcmomLKc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=Fx8O/y1VIq/Dgd6k5lY/frbdCO8B5e8owW98ZWmOgjZIKXR7KiGY0UCYsh+sxcKDr CSY8znYaJ/nkA/qGsMc5XP9+PQlmK4SUyFKEflbJ7X62LDT5RYVwo6xJzixArIPER8 EOECN/lZvp7mpEzu0gu3uo+jdzmWVe+HdPY9MhiF7s4/owEYS74xWRqlOQ169iAm0h TzKnsh7uC26pLw74qUA0Bru/BL8QveGVNegjBAqwicXhEgH12+rs8AL7bz4DCbqnZN gA4vY5VX2fxsfo3GqGO6nNi85hojqkf97L4R067zDUMX9LGmmh19jjkg2lpkIYogHv GlOhbXrIMd8ng== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 759614E716; Mon, 30 Nov 2026 06:29:56 +0000 (UTC) From: He Xin via B4 Relay Date: Mon, 30 Nov 2026 14:29:40 +0800 Subject: [PATCH v2 11/18] iio: accel: dmard06: 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-11-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=2232; i=hexin@hexin.host; s=20261130; h=from:subject:message-id; bh=8Y3QBl0SH8DtdEdPYy3FmDZsdje9j9j5yzNY+qB4Blc=; b=Xfp+hlxwD4x1v3ydfLCzsxoS06lgz+qsuBDQ24nTytnA479Qhh1/4Lgh2MRgCw6CvWroshIg2 NomCYkJKup4DaU5OMlnHRHZzAneEscNtLP9eQu2pBtLc1H/jmkztkx9 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/dmard06.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/iio/accel/dmard06.c b/drivers/iio/accel/dmard06.c index 82816fa443..37f28b0c48 100644 --- a/drivers/iio/accel/dmard06.c +++ b/drivers/iio/accel/dmard06.c @@ -34,9 +34,19 @@ #define DMARD06_MODE_NORMAL 0x27 #define DMARD06_MODE_POWERDOWN 0x00 +static const struct iio_mount_matrix * +dmard06_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan); + +static const struct iio_chan_spec_ext_info dmard06_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, dmard06_get_mount_matrix), + { } +}; + /* Device channels */ #define DMARD06_ACCEL_CHANNEL(_axis, _reg) { \ .type = IIO_ACCEL, \ + .ext_info = dmard06_ext_info, \ .address = _reg, \ .channel2 = IIO_MOD_##_axis, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ @@ -54,8 +64,18 @@ struct dmard06_data { struct i2c_client *client; u8 chip_id; + struct iio_mount_matrix orientation; }; +static const struct iio_mount_matrix * +dmard06_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct dmard06_data *dmard06 = iio_priv(indio_dev); + + return &dmard06->orientation; +} + static const struct iio_chan_spec dmard06_channels[] = { DMARD06_ACCEL_CHANNEL(X, DMARD06_XOUT_REG), DMARD06_ACCEL_CHANNEL(Y, DMARD06_YOUT_REG), @@ -140,6 +160,11 @@ static int dmard06_probe(struct i2c_client *client) return -ENOMEM; dmard06 = iio_priv(indio_dev); + + ret = iio_read_mount_matrix(&client->dev, &dmard06->orientation); + if (ret) + return ret; + dmard06->client = client; ret = i2c_smbus_read_byte_data(dmard06->client, DMARD06_CHIP_ID_REG); -- 2.53.0