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=uoRViqWbtobkfTPcgryyd0mMORt/j80iL1c4akbHU+NTIdNe5JHA38+a3ROtI5tKC4Hj SZkLDCE+gHiGD8JG8r04NwvKNR2UEGv0d7vz1mLoAg29sR3UMttXX7Kly77/AaXqMwGUl 05zoDEZTeXGagGASXMeZCNkKRTd/kA/61BJjedCWakZ+dNxxDdd+5Ehg52DpjKMpmo01H XN15yogqpLHDkqsG3/H3chTWASE32C+RhiBzdFmuavN8t2pa1lgd8BpqsbQpYq4q3ZYSr hX2QStqZp4eYtS2hFW00zdJ0/U3Wy7mJMs42ZhmVN1W6D0ROd7XKQ8FHJE8P1jUsQGg== 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=4jqoXregUMN4E3+bwgRx+pn2hOyOfuN1Uc7vTbIcoFc=; b=XoxNBaHz/QMivp/W2Ui2Lw+RwQU3l4vbiAYsDMUStJdEeL1QgZOQxD4NksOHu6eH8Z++ /sDYsYF5ryczdtaQe6KhWhe+9kObt9Z5a6KB3bCRmImvMVUBCNsAdl2+DnGndeF0l5tJM 5oYxegLuft2/UKKyibwOgQZxKEdTJEjuEna7l6FLVf8Ni+8t0o73O3gWxgNXp/+l+ruPv iaXMVDUgTkk9oa6slo+7/lNbItYzwdbbVWBY19n3yhCZRNc6hNwxdOYVVj1BQ5B1zN3s6 gibpdZlgAIXgsAos4xsmmr1Fc1PCwo8BY9O7BCpsGwJnXdmBjttevPVytCyfI4ww24g== 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=YZRLe8s5; 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 55959606A33C 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=YZRLe8s5 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=NhXr4CoVNtdeV/jy4LhBqTnhHY7CaB7oUlwXKARIJoKX/syLXR08mzbGW+ZEKIlP4s3N 0AjzEn2AaUXOQ3XArWo7Uq6/fYoE9Z1cZefbOJoje/ad14jtcLk+4SrE9G4/q4BJzBPYR wQ4sQBr4ZIA+Qqrbs1DkCh5nXPI2gaBrhHSCIUDXtbggqo1uzQejMS5lJqaIluiB30ljM PtCO3oNv5SPK4oY+rq5C+vbGYDvXz2PySm+d6duqLokEiK1qQNPi7Quhr9T9it3iPamgG xZWCgW57F4KWADeM3KdeX/PhbWmXbtpMYYUeaBzImFwpcnuYzbjGiF42/uwRTRVpqNw== 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=4jqoXregUMN4E3+bwgRx+pn2hOyOfuN1Uc7vTbIcoFc=; b=U0YwIuJX5xcxdyCnm3ixWNWUYIhRrFfhl3AQ29lGtnb6phM8QVZkCE1ipQTVjw25c8R+ vQ6HSvZiNNZ4NWO1uVf3RQT9J0gSMYW2q9n8U5UZwFrWoCw301yHuK3UcUPCVvGZCVsPh ZoQ0PaghiHLLapyn8E+yRUs+Ufq3/663bYrE67/aZba2ovQcMBer7Qc8nUlYdy+7+ittw WYv3n4djjsbyUD0+ON8twiu5+vMpg2QBvAA81/DnysZs5sazNvWoNIoTNw0ajUrZ8Etea 98Yr1EIaQ6f/raFv0XVuBwdchmpWJaRijYXnoTTorClydaG9qPKC61wpzwo3ZAY1dmw== 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 751B61F0092B; Mon, 30 Nov 2026 06:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796020218; bh=4jqoXregUMN4E3+bwgRx+pn2hOyOfuN1Uc7vTbIcoFc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=YZRLe8s5BgttelcwtbvBCf0HUIzDHTAoACht+nJpkKBG1nwnCQOsej3jc2ofAosbe V8NOAgeAG1oqP5ixMZ0FDNx3lSj33O8avOu/eZC/j2poEOkczFX1rC5xSJh5uj0bFf YZKuGpA19tZPFJAfTcT8kucRJbD87br1DHT5nftedf2bWP96tHrr0PzcUPJK3QanmL /ztX8xffU5XP6Twey0aGonC7QvLwHt48o4sKY4DjV3930No+PmBZC3S78WWsWs3lcE 7uR9d945i4QIl/0hVTEcj5djyp1i+Fc9MSKkYY9IjmDaQVu7xsHLsS2iJuH4a5DrH7 ALFyDGwfTiYfA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id C25A84E71E; Mon, 30 Nov 2026 06:29:56 +0000 (UTC) From: He Xin via B4 Relay Date: Mon, 30 Nov 2026 14:29:42 +0800 Subject: [PATCH v2 13/18] iio: accel: dmard10: 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-13-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=2073; i=hexin@hexin.host; s=20261130; h=from:subject:message-id; bh=d6iblK23W7E6JNWK48fSH6SBMRnoM2EUo11SltDBxfA=; b=FSOzBAXawz6SgJZ4RHjzeB0V5Nx9j4aeiAbkgf5aY+7isAGTIbDOuhnykCCeX+ph2+fKF+Omf 2gJjXY90uLuCck9sLV9QIXgI1aRIAYC42W0hkBgLLfqOJE+NA2ZKrnF 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/dmard10.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/iio/accel/dmard10.c b/drivers/iio/accel/dmard10.c index 8ba00fd579..0d9e6473be 100644 --- a/drivers/iio/accel/dmard10.c +++ b/drivers/iio/accel/dmard10.c @@ -51,8 +51,18 @@ static const int dmard10_nscale = 76640625; +static const struct iio_mount_matrix * +dmard10_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan); + +static const struct iio_chan_spec_ext_info dmard10_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, dmard10_get_mount_matrix), + { } +}; + #define DMARD10_CHANNEL(reg, axis) { \ .type = IIO_ACCEL, \ + .ext_info = dmard10_ext_info,\ .address = reg, \ .modified = 1, \ .channel2 = IIO_MOD_##axis, \ @@ -68,8 +78,18 @@ static const struct iio_chan_spec dmard10_channels[] = { struct dmard10_data { struct i2c_client *client; + struct iio_mount_matrix orientation; }; +static const struct iio_mount_matrix * +dmard10_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct dmard10_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + /* Init sequence taken from the android driver */ static int dmard10_reset(struct i2c_client *client) { @@ -195,6 +215,11 @@ static int dmard10_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 = &dmard10_info; -- 2.53.0