* [PATCH v2 00/18] iio: accel: add mount matrix support to 18 accelerometer drivers
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
These drivers ignore the "mount-matrix" property that other accelerometer
drivers already honour, so userspace gets raw sensor axes on any board
whose sensor is not mounted axis-aligned with the display. A udev/hwdb
override does not cover it either: it keys off the sensor modalias and
DMI, which do not tell such boards apart.
Each patch is mechanical and independent: store the matrix in the driver's
private data, add an IIO_MOUNT_MATRIX() ext_info entry to the accelerometer
channels, and read the property once in probe.
One behaviour change: a board whose firmware describes a matrix with the
wrong number of entries now fails to probe with -EINVAL instead of being
ignored, which is what the drivers that already support the property do.
Not converted here, because the change would not have the same shape:
adis16201, adis16209 and sca3000 list their channels as array literals,
adxl313_core and fxls8962af-core keep the probe in the bus wrappers, and
mma9551/mma9553 differ in both. hid-sensor-accel-3d, ssp_accel_sensor and
cros_ec_accel_legacy take the orientation from the HID/SSP/EC side rather
than from a firmware property.
Changes in v2:
- move stk8ba50 to patch 1
- place the mount matrix before the __aligned(IIO_DMA_MINALIGN) members in
adxl345, adxl355, adxl367, adxl380, bma220, bmi088 and sca3300, so the
DMA buffers keep their own cacheline
- add the missing blank line after the mount matrix read in probe
- add the @orientation kernel-doc entry for msa311 and sca3300
- shorten the stk8ba50 test note to the behaviour observed on the device
- v1 lost its threading because the sending MTA rewrote Message-IDs while
leaving References untouched; v2 is posted as a new series
Build tested with allmodconfig: drivers/iio/accel, 71 objects, no warnings;
checkpatch.pl is silent in default and in --strict mode. Only stk8ba50 was
tested on hardware; the other 17 are compile tested.
Link: https://lore.kernel.org/linux-iio/5F08289E852625FC+20261127030810.3150676-1-hexin@hexin.host/
Signed-off-by: He Xin <hexin@hexin.host>
---
He Xin (18):
iio: accel: stk8ba50: support mount matrix
iio: accel: adxl345_core: support mount matrix
iio: accel: adxl355_core: support mount matrix
iio: accel: adxl367: support mount matrix
iio: accel: adxl372: support mount matrix
iio: accel: adxl380: support mount matrix
iio: accel: bma220_core: support mount matrix
iio: accel: bmi088-accel-core: support mount matrix
iio: accel: da280: support mount matrix
iio: accel: da311: support mount matrix
iio: accel: dmard06: support mount matrix
iio: accel: dmard09: support mount matrix
iio: accel: dmard10: support mount matrix
iio: accel: mma7455_core: support mount matrix
iio: accel: msa311: support mount matrix
iio: accel: mxc6255: support mount matrix
iio: accel: sca3300: support mount matrix
iio: accel: stk8312: support mount matrix
drivers/iio/accel/adxl345_core.c | 21 +++++++++++++++++++++
drivers/iio/accel/adxl355_core.c | 21 +++++++++++++++++++++
drivers/iio/accel/adxl367.c | 21 +++++++++++++++++++++
drivers/iio/accel/adxl372.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/adxl380.c | 20 ++++++++++++++++++++
drivers/iio/accel/bma220_core.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/bmi088-accel-core.c | 21 +++++++++++++++++++++
drivers/iio/accel/da280.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/da311.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/dmard06.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/dmard09.c | 21 +++++++++++++++++++++
drivers/iio/accel/dmard10.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/mma7455_core.c | 21 +++++++++++++++++++++
drivers/iio/accel/msa311.c | 22 ++++++++++++++++++++++
drivers/iio/accel/mxc6255.c | 21 +++++++++++++++++++++
drivers/iio/accel/sca3300.c | 26 ++++++++++++++++++++++++++
drivers/iio/accel/stk8312.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/stk8ba50.c | 21 +++++++++++++++++++++
18 files changed, 411 insertions(+)
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20261130-work-ab0d96ec614e
Best regards,
--
He Xin <hexin@hexin.host>
^ permalink raw reply [flat|nested] 44+ messages in thread
* [PATCH v2 00/18] iio: accel: add mount matrix support to 18 accelerometer drivers
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
These drivers ignore the "mount-matrix" property that other accelerometer
drivers already honour, so userspace gets raw sensor axes on any board
whose sensor is not mounted axis-aligned with the display. A udev/hwdb
override does not cover it either: it keys off the sensor modalias and
DMI, which do not tell such boards apart.
Each patch is mechanical and independent: store the matrix in the driver's
private data, add an IIO_MOUNT_MATRIX() ext_info entry to the accelerometer
channels, and read the property once in probe.
One behaviour change: a board whose firmware describes a matrix with the
wrong number of entries now fails to probe with -EINVAL instead of being
ignored, which is what the drivers that already support the property do.
Not converted here, because the change would not have the same shape:
adis16201, adis16209 and sca3000 list their channels as array literals,
adxl313_core and fxls8962af-core keep the probe in the bus wrappers, and
mma9551/mma9553 differ in both. hid-sensor-accel-3d, ssp_accel_sensor and
cros_ec_accel_legacy take the orientation from the HID/SSP/EC side rather
than from a firmware property.
Changes in v2:
- move stk8ba50 to patch 1
- place the mount matrix before the __aligned(IIO_DMA_MINALIGN) members in
adxl345, adxl355, adxl367, adxl380, bma220, bmi088 and sca3300, so the
DMA buffers keep their own cacheline
- add the missing blank line after the mount matrix read in probe
- add the @orientation kernel-doc entry for msa311 and sca3300
- shorten the stk8ba50 test note to the behaviour observed on the device
- v1 lost its threading because the sending MTA rewrote Message-IDs while
leaving References untouched; v2 is posted as a new series
Build tested with allmodconfig: drivers/iio/accel, 71 objects, no warnings;
checkpatch.pl is silent in default and in --strict mode. Only stk8ba50 was
tested on hardware; the other 17 are compile tested.
Link: https://lore.kernel.org/linux-iio/5F08289E852625FC+20261127030810.3150676-1-hexin@hexin.host/
Signed-off-by: He Xin <hexin@hexin.host>
---
He Xin (18):
iio: accel: stk8ba50: support mount matrix
iio: accel: adxl345_core: support mount matrix
iio: accel: adxl355_core: support mount matrix
iio: accel: adxl367: support mount matrix
iio: accel: adxl372: support mount matrix
iio: accel: adxl380: support mount matrix
iio: accel: bma220_core: support mount matrix
iio: accel: bmi088-accel-core: support mount matrix
iio: accel: da280: support mount matrix
iio: accel: da311: support mount matrix
iio: accel: dmard06: support mount matrix
iio: accel: dmard09: support mount matrix
iio: accel: dmard10: support mount matrix
iio: accel: mma7455_core: support mount matrix
iio: accel: msa311: support mount matrix
iio: accel: mxc6255: support mount matrix
iio: accel: sca3300: support mount matrix
iio: accel: stk8312: support mount matrix
drivers/iio/accel/adxl345_core.c | 21 +++++++++++++++++++++
drivers/iio/accel/adxl355_core.c | 21 +++++++++++++++++++++
drivers/iio/accel/adxl367.c | 21 +++++++++++++++++++++
drivers/iio/accel/adxl372.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/adxl380.c | 20 ++++++++++++++++++++
drivers/iio/accel/bma220_core.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/bmi088-accel-core.c | 21 +++++++++++++++++++++
drivers/iio/accel/da280.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/da311.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/dmard06.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/dmard09.c | 21 +++++++++++++++++++++
drivers/iio/accel/dmard10.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/mma7455_core.c | 21 +++++++++++++++++++++
drivers/iio/accel/msa311.c | 22 ++++++++++++++++++++++
drivers/iio/accel/mxc6255.c | 21 +++++++++++++++++++++
drivers/iio/accel/sca3300.c | 26 ++++++++++++++++++++++++++
drivers/iio/accel/stk8312.c | 25 +++++++++++++++++++++++++
drivers/iio/accel/stk8ba50.c | 21 +++++++++++++++++++++
18 files changed, 411 insertions(+)
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20261130-work-ab0d96ec614e
Best regards,
--
He Xin <hexin@hexin.host>
^ permalink raw reply [flat|nested] 44+ messages in thread
* [PATCH v2 01/18] iio: accel: stk8ba50: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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.
Tested on a tablet whose sensor is mounted rotated 180 degrees about X:
without the patch in_accel_mount_matrix is absent, so iio-sensor-proxy has
to fall back to a udev/hwdb override; with it the matrix from _DSD is
reported and the orientation comes out correct.
Signed-off-by: He Xin <hexin@hexin.host>
---
drivers/iio/accel/stk8ba50.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
index 6c1e286c0a..f510013570 100644
--- a/drivers/iio/accel/stk8ba50.c
+++ b/drivers/iio/accel/stk8ba50.c
@@ -102,10 +102,26 @@ struct stk8ba50_data {
s16 chans[3];
aligned_s64 timetamp;
} scan;
+ struct iio_mount_matrix orientation;
+};
+
+static const struct iio_mount_matrix *
+stk8ba50_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct stk8ba50_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info stk8ba50_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, stk8ba50_get_mount_matrix),
+ { }
};
#define STK8BA50_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = stk8ba50_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -395,6 +411,11 @@ static int stk8ba50_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;
i2c_set_clientdata(client, indio_dev);
mutex_init(&data->lock);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 01/18] iio: accel: stk8ba50: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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.
Tested on a tablet whose sensor is mounted rotated 180 degrees about X:
without the patch in_accel_mount_matrix is absent, so iio-sensor-proxy has
to fall back to a udev/hwdb override; with it the matrix from _DSD is
reported and the orientation comes out correct.
Signed-off-by: He Xin <hexin@hexin.host>
---
drivers/iio/accel/stk8ba50.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
index 6c1e286c0a..f510013570 100644
--- a/drivers/iio/accel/stk8ba50.c
+++ b/drivers/iio/accel/stk8ba50.c
@@ -102,10 +102,26 @@ struct stk8ba50_data {
s16 chans[3];
aligned_s64 timetamp;
} scan;
+ struct iio_mount_matrix orientation;
+};
+
+static const struct iio_mount_matrix *
+stk8ba50_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct stk8ba50_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info stk8ba50_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, stk8ba50_get_mount_matrix),
+ { }
};
#define STK8BA50_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = stk8ba50_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -395,6 +411,11 @@ static int stk8ba50_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;
i2c_set_clientdata(client, indio_dev);
mutex_init(&data->lock);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 02/18] iio: accel: adxl345_core: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/adxl345_core.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index 6c9080d88c..44816b48f6 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -203,6 +203,7 @@ struct adxl345_state {
u32 tap_latent_us;
u32 tap_window_us;
+ struct iio_mount_matrix orientation;
__le16 fifo_buf[ADXL345_DIRS * ADXL345_FIFO_SIZE + 1] __aligned(IIO_DMA_MINALIGN);
};
@@ -248,8 +249,23 @@ static const struct iio_event_spec adxl345_events[] = {
},
};
+static const struct iio_mount_matrix *
+adxl345_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct adxl345_state *st = iio_priv(indio_dev);
+
+ return &st->orientation;
+}
+
+static const struct iio_chan_spec_ext_info adxl345_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, adxl345_core_get_mount_matrix),
+ { }
+};
+
#define ADXL345_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = adxl345_core_ext_info, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
.address = (reg), \
@@ -1902,6 +1918,11 @@ int adxl345_core_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;
+
st->regmap = regmap;
st->info = device_get_match_data(dev);
if (!st->info)
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 02/18] iio: accel: adxl345_core: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/adxl345_core.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index 6c9080d88c..44816b48f6 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -203,6 +203,7 @@ struct adxl345_state {
u32 tap_latent_us;
u32 tap_window_us;
+ struct iio_mount_matrix orientation;
__le16 fifo_buf[ADXL345_DIRS * ADXL345_FIFO_SIZE + 1] __aligned(IIO_DMA_MINALIGN);
};
@@ -248,8 +249,23 @@ static const struct iio_event_spec adxl345_events[] = {
},
};
+static const struct iio_mount_matrix *
+adxl345_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct adxl345_state *st = iio_priv(indio_dev);
+
+ return &st->orientation;
+}
+
+static const struct iio_chan_spec_ext_info adxl345_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, adxl345_core_get_mount_matrix),
+ { }
+};
+
#define ADXL345_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = adxl345_core_ext_info, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
.address = (reg), \
@@ -1902,6 +1918,11 @@ int adxl345_core_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;
+
st->regmap = regmap;
st->info = device_get_match_data(dev);
if (!st->info)
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 03/18] iio: accel: adxl355_core: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/adxl355_core.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/adxl355_core.c b/drivers/iio/accel/adxl355_core.c
index 080c9f6f9a..1e66238222 100644
--- a/drivers/iio/accel/adxl355_core.c
+++ b/drivers/iio/accel/adxl355_core.c
@@ -228,6 +228,7 @@ struct adxl355_data {
int calibbias[3];
int adxl355_hpf_3db_table[7][2];
struct iio_trigger *dready_trig;
+ struct iio_mount_matrix orientation;
union {
u8 transf_buf[3];
struct {
@@ -707,8 +708,23 @@ static irqreturn_t adxl355_trigger_handler(int irq, void *p)
return IRQ_HANDLED;
}
+static const struct iio_mount_matrix *
+adxl355_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct adxl355_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info adxl355_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, adxl355_core_get_mount_matrix),
+ { }
+};
+
#define ADXL355_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = adxl355_core_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -792,6 +808,11 @@ int adxl355_core_probe(struct device *dev, struct regmap *regmap,
return -ENOMEM;
data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &data->orientation);
+ if (ret)
+ return ret;
+
data->regmap = regmap;
data->dev = dev;
data->op_mode = ADXL355_STANDBY;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 03/18] iio: accel: adxl355_core: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/adxl355_core.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/adxl355_core.c b/drivers/iio/accel/adxl355_core.c
index 080c9f6f9a..1e66238222 100644
--- a/drivers/iio/accel/adxl355_core.c
+++ b/drivers/iio/accel/adxl355_core.c
@@ -228,6 +228,7 @@ struct adxl355_data {
int calibbias[3];
int adxl355_hpf_3db_table[7][2];
struct iio_trigger *dready_trig;
+ struct iio_mount_matrix orientation;
union {
u8 transf_buf[3];
struct {
@@ -707,8 +708,23 @@ static irqreturn_t adxl355_trigger_handler(int irq, void *p)
return IRQ_HANDLED;
}
+static const struct iio_mount_matrix *
+adxl355_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct adxl355_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info adxl355_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, adxl355_core_get_mount_matrix),
+ { }
+};
+
#define ADXL355_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = adxl355_core_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -792,6 +808,11 @@ int adxl355_core_probe(struct device *dev, struct regmap *regmap,
return -ENOMEM;
data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &data->orientation);
+ if (ret)
+ return ret;
+
data->regmap = regmap;
data->dev = dev;
data->op_mode = ADXL355_STANDBY;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 04/18] iio: accel: adxl367: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/adxl367.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
index 026db73057..9a0eda5b01 100644
--- a/drivers/iio/accel/adxl367.c
+++ b/drivers/iio/accel/adxl367.c
@@ -180,6 +180,7 @@ struct adxl367_state {
unsigned int fifo_set_size;
unsigned int fifo_watermark;
+ struct iio_mount_matrix orientation;
__be16 fifo_buf[ADXL367_FIFO_SIZE] __aligned(IIO_DMA_MINALIGN);
__be16 sample_buf;
u8 act_threshold_buf[2];
@@ -1336,8 +1337,23 @@ static const struct iio_event_spec adxl367_events[] = {
},
};
+static const struct iio_mount_matrix *
+adxl367_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct adxl367_state *st = iio_priv(indio_dev);
+
+ return &st->orientation;
+}
+
+static const struct iio_chan_spec_ext_info adxl367_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, adxl367_get_mount_matrix),
+ { }
+};
+
#define ADXL367_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = adxl367_ext_info, \
.address = (reg), \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -1477,6 +1493,11 @@ int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
return -ENOMEM;
st = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &st->orientation);
+ if (ret)
+ return ret;
+
st->dev = dev;
st->regmap = regmap;
st->context = context;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 04/18] iio: accel: adxl367: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/adxl367.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
index 026db73057..9a0eda5b01 100644
--- a/drivers/iio/accel/adxl367.c
+++ b/drivers/iio/accel/adxl367.c
@@ -180,6 +180,7 @@ struct adxl367_state {
unsigned int fifo_set_size;
unsigned int fifo_watermark;
+ struct iio_mount_matrix orientation;
__be16 fifo_buf[ADXL367_FIFO_SIZE] __aligned(IIO_DMA_MINALIGN);
__be16 sample_buf;
u8 act_threshold_buf[2];
@@ -1336,8 +1337,23 @@ static const struct iio_event_spec adxl367_events[] = {
},
};
+static const struct iio_mount_matrix *
+adxl367_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct adxl367_state *st = iio_priv(indio_dev);
+
+ return &st->orientation;
+}
+
+static const struct iio_chan_spec_ext_info adxl367_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, adxl367_get_mount_matrix),
+ { }
+};
+
#define ADXL367_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = adxl367_ext_info, \
.address = (reg), \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -1477,6 +1493,11 @@ int adxl367_probe(struct device *dev, const struct adxl367_ops *ops,
return -ENOMEM;
st = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &st->orientation);
+ if (ret)
+ return ret;
+
st->dev = dev;
st->regmap = regmap;
st->context = context;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 05/18] iio: accel: adxl372: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
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
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 05/18] iio: accel: adxl372: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
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
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 06/18] iio: accel: adxl380: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/adxl380.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
index 03b1403035..ca94303a49 100644
--- a/drivers/iio/accel/adxl380.c
+++ b/drivers/iio/accel/adxl380.c
@@ -223,6 +223,7 @@ struct adxl380_state {
int lpf_tbl[4];
int hpf_tbl[7][2];
+ struct iio_mount_matrix orientation;
__be16 fifo_buf[ADXL380_FIFO_SAMPLES] __aligned(IIO_DMA_MINALIGN);
};
@@ -1785,8 +1786,23 @@ static const struct iio_event_spec adxl380_events[] = {
},
};
+static const struct iio_mount_matrix *
+adxl380_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct adxl380_state *st = iio_priv(indio_dev);
+
+ return &st->orientation;
+}
+
+static const struct iio_chan_spec_ext_info adxl380_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, adxl380_get_mount_matrix),
+ { }
+};
+
#define ADXL380_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = adxl380_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -1978,6 +1994,10 @@ int adxl380_probe(struct device *dev, struct regmap *regmap,
st = iio_priv(indio_dev);
+ ret = iio_read_mount_matrix(dev, &st->orientation);
+ if (ret)
+ return ret;
+
st->dev = dev;
st->regmap = regmap;
st->chip_info = chip_info;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 06/18] iio: accel: adxl380: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/adxl380.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
index 03b1403035..ca94303a49 100644
--- a/drivers/iio/accel/adxl380.c
+++ b/drivers/iio/accel/adxl380.c
@@ -223,6 +223,7 @@ struct adxl380_state {
int lpf_tbl[4];
int hpf_tbl[7][2];
+ struct iio_mount_matrix orientation;
__be16 fifo_buf[ADXL380_FIFO_SAMPLES] __aligned(IIO_DMA_MINALIGN);
};
@@ -1785,8 +1786,23 @@ static const struct iio_event_spec adxl380_events[] = {
},
};
+static const struct iio_mount_matrix *
+adxl380_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct adxl380_state *st = iio_priv(indio_dev);
+
+ return &st->orientation;
+}
+
+static const struct iio_chan_spec_ext_info adxl380_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, adxl380_get_mount_matrix),
+ { }
+};
+
#define ADXL380_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = adxl380_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -1978,6 +1994,10 @@ int adxl380_probe(struct device *dev, struct regmap *regmap,
st = iio_priv(indio_dev);
+ ret = iio_read_mount_matrix(dev, &st->orientation);
+ if (ret)
+ return ret;
+
st->dev = dev;
st->regmap = regmap;
st->chip_info = chip_info;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 07/18] iio: accel: bma220_core: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/bma220_core.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/iio/accel/bma220_core.c b/drivers/iio/accel/bma220_core.c
index b83abfdd84..c718098cad 100644
--- a/drivers/iio/accel/bma220_core.c
+++ b/drivers/iio/accel/bma220_core.c
@@ -94,8 +94,18 @@
#define BMA220_COF_64Hz 0x4
#define BMA220_COF_32Hz 0x5
+static const struct iio_mount_matrix *
+bma220_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan);
+
+static const struct iio_chan_spec_ext_info bma220_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, bma220_core_get_mount_matrix),
+ { }
+};
+
#define BMA220_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = bma220_core_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -130,6 +140,7 @@ struct bma220_data {
u8 lpf_3dB_freq_idx;
u8 range_idx;
struct iio_trigger *trig;
+ struct iio_mount_matrix orientation;
struct {
s8 chans[3];
/* Ensure timestamp is naturally aligned. */
@@ -137,6 +148,15 @@ struct bma220_data {
} scan __aligned(IIO_DMA_MINALIGN);
};
+static const struct iio_mount_matrix *
+bma220_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct bma220_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
static const struct iio_chan_spec bma220_channels[] = {
BMA220_ACCEL_CHANNEL(0, BMA220_REG_ACCEL_X, X),
BMA220_ACCEL_CHANNEL(1, BMA220_REG_ACCEL_Y, Y),
@@ -508,6 +528,11 @@ int bma220_common_probe(struct device *dev, struct regmap *regmap, int irq)
return -ENOMEM;
data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &data->orientation);
+ if (ret)
+ return ret;
+
data->regmap = regmap;
ret = bma220_init(dev, data);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 07/18] iio: accel: bma220_core: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/bma220_core.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/iio/accel/bma220_core.c b/drivers/iio/accel/bma220_core.c
index b83abfdd84..c718098cad 100644
--- a/drivers/iio/accel/bma220_core.c
+++ b/drivers/iio/accel/bma220_core.c
@@ -94,8 +94,18 @@
#define BMA220_COF_64Hz 0x4
#define BMA220_COF_32Hz 0x5
+static const struct iio_mount_matrix *
+bma220_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan);
+
+static const struct iio_chan_spec_ext_info bma220_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, bma220_core_get_mount_matrix),
+ { }
+};
+
#define BMA220_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = bma220_core_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -130,6 +140,7 @@ struct bma220_data {
u8 lpf_3dB_freq_idx;
u8 range_idx;
struct iio_trigger *trig;
+ struct iio_mount_matrix orientation;
struct {
s8 chans[3];
/* Ensure timestamp is naturally aligned. */
@@ -137,6 +148,15 @@ struct bma220_data {
} scan __aligned(IIO_DMA_MINALIGN);
};
+static const struct iio_mount_matrix *
+bma220_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct bma220_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
static const struct iio_chan_spec bma220_channels[] = {
BMA220_ACCEL_CHANNEL(0, BMA220_REG_ACCEL_X, X),
BMA220_ACCEL_CHANNEL(1, BMA220_REG_ACCEL_Y, Y),
@@ -508,6 +528,11 @@ int bma220_common_probe(struct device *dev, struct regmap *regmap, int irq)
return -ENOMEM;
data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &data->orientation);
+ if (ret)
+ return ret;
+
data->regmap = regmap;
ret = bma220_init(dev, data);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 08/18] iio: accel: bmi088-accel-core: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/bmi088-accel-core.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index c7da90af0d..dea150b33c 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -125,6 +125,7 @@ struct bmi088_accel_chip_info {
struct bmi088_accel_data {
struct regmap *regmap;
const struct bmi088_accel_chip_info *chip_info;
+ struct iio_mount_matrix orientation;
u8 buffer[2] __aligned(IIO_DMA_MINALIGN); /* shared DMA safe buffer */
};
@@ -433,8 +434,23 @@ static int bmi088_accel_write_raw(struct iio_dev *indio_dev,
}
}
+static const struct iio_mount_matrix *
+bmi088_accel_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct bmi088_accel_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info bmi088_accel_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, bmi088_accel_core_get_mount_matrix),
+ { }
+};
+
#define BMI088_ACCEL_CHANNEL(_axis) { \
.type = IIO_ACCEL, \
+ .ext_info = bmi088_accel_core_ext_info,\
.modified = 1, \
.channel2 = IIO_MOD_##_axis, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
@@ -555,6 +571,11 @@ int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap,
return -ENOMEM;
data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &data->orientation);
+ if (ret)
+ return ret;
+
dev_set_drvdata(dev, indio_dev);
data->regmap = regmap;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 08/18] iio: accel: bmi088-accel-core: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/bmi088-accel-core.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index c7da90af0d..dea150b33c 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -125,6 +125,7 @@ struct bmi088_accel_chip_info {
struct bmi088_accel_data {
struct regmap *regmap;
const struct bmi088_accel_chip_info *chip_info;
+ struct iio_mount_matrix orientation;
u8 buffer[2] __aligned(IIO_DMA_MINALIGN); /* shared DMA safe buffer */
};
@@ -433,8 +434,23 @@ static int bmi088_accel_write_raw(struct iio_dev *indio_dev,
}
}
+static const struct iio_mount_matrix *
+bmi088_accel_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct bmi088_accel_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info bmi088_accel_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, bmi088_accel_core_get_mount_matrix),
+ { }
+};
+
#define BMI088_ACCEL_CHANNEL(_axis) { \
.type = IIO_ACCEL, \
+ .ext_info = bmi088_accel_core_ext_info,\
.modified = 1, \
.channel2 = IIO_MOD_##_axis, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
@@ -555,6 +571,11 @@ int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap,
return -ENOMEM;
data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &data->orientation);
+ if (ret)
+ return ret;
+
dev_set_drvdata(dev, indio_dev);
data->regmap = regmap;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 09/18] iio: accel: da280: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
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
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 09/18] iio: accel: da280: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
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
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 10/18] iio: accel: da311: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/da311.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c
index dcb69c8eaf..a3d0105428 100644
--- a/drivers/iio/accel/da311.c
+++ b/drivers/iio/accel/da311.c
@@ -77,8 +77,18 @@
static const int da311_nscale = 9580078;
+static const struct iio_mount_matrix *
+da311_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan);
+
+static const struct iio_chan_spec_ext_info da311_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, da311_get_mount_matrix),
+ { }
+};
+
#define DA311_CHANNEL(reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = da311_ext_info,\
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -95,8 +105,18 @@ static const struct iio_chan_spec da311_channels[] = {
struct da311_data {
struct i2c_client *client;
+ struct iio_mount_matrix orientation;
};
+static const struct iio_mount_matrix *
+da311_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct da311_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
static int da311_register_mask_write(struct i2c_client *client, u16 addr,
u8 mask, u8 data)
{
@@ -232,6 +252,11 @@ static int da311_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 = &da311_info;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 10/18] iio: accel: da311: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/da311.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c
index dcb69c8eaf..a3d0105428 100644
--- a/drivers/iio/accel/da311.c
+++ b/drivers/iio/accel/da311.c
@@ -77,8 +77,18 @@
static const int da311_nscale = 9580078;
+static const struct iio_mount_matrix *
+da311_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan);
+
+static const struct iio_chan_spec_ext_info da311_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, da311_get_mount_matrix),
+ { }
+};
+
#define DA311_CHANNEL(reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = da311_ext_info,\
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -95,8 +105,18 @@ static const struct iio_chan_spec da311_channels[] = {
struct da311_data {
struct i2c_client *client;
+ struct iio_mount_matrix orientation;
};
+static const struct iio_mount_matrix *
+da311_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct da311_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
static int da311_register_mask_write(struct i2c_client *client, u16 addr,
u8 mask, u8 data)
{
@@ -232,6 +252,11 @@ static int da311_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 = &da311_info;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 11/18] iio: accel: dmard06: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
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
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 11/18] iio: accel: dmard06: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
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
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 12/18] iio: accel: dmard09: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/dmard09.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/dmard09.c b/drivers/iio/accel/dmard09.c
index 6f0497ab61..7990072b13 100644
--- a/drivers/iio/accel/dmard09.c
+++ b/drivers/iio/accel/dmard09.c
@@ -30,10 +30,26 @@
struct dmard09_data {
struct i2c_client *client;
+ struct iio_mount_matrix orientation;
+};
+
+static const struct iio_mount_matrix *
+dmard09_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct dmard09_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info dmard09_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, dmard09_get_mount_matrix),
+ { }
};
#define DMARD09_CHANNEL(_axis, offset) { \
.type = IIO_ACCEL, \
+ .ext_info = dmard09_ext_info, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
.modified = 1, \
@@ -106,6 +122,11 @@ static int dmard09_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;
ret = i2c_smbus_read_byte_data(data->client, DMARD09_REG_CHIPID);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 12/18] iio: accel: dmard09: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/dmard09.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/dmard09.c b/drivers/iio/accel/dmard09.c
index 6f0497ab61..7990072b13 100644
--- a/drivers/iio/accel/dmard09.c
+++ b/drivers/iio/accel/dmard09.c
@@ -30,10 +30,26 @@
struct dmard09_data {
struct i2c_client *client;
+ struct iio_mount_matrix orientation;
+};
+
+static const struct iio_mount_matrix *
+dmard09_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct dmard09_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info dmard09_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, dmard09_get_mount_matrix),
+ { }
};
#define DMARD09_CHANNEL(_axis, offset) { \
.type = IIO_ACCEL, \
+ .ext_info = dmard09_ext_info, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
.modified = 1, \
@@ -106,6 +122,11 @@ static int dmard09_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;
ret = i2c_smbus_read_byte_data(data->client, DMARD09_REG_CHIPID);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 13/18] iio: accel: dmard10: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
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
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 13/18] iio: accel: dmard10: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
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
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 14/18] iio: accel: mma7455_core: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/mma7455_core.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c
index a2b5bdf14d..0d180a6662 100644
--- a/drivers/iio/accel/mma7455_core.c
+++ b/drivers/iio/accel/mma7455_core.c
@@ -61,6 +61,7 @@ struct mma7455_data {
__le16 channels[3];
aligned_s64 ts;
} scan;
+ struct iio_mount_matrix orientation;
};
static int mma7455_drdy(struct mma7455_data *mma7455)
@@ -209,8 +210,23 @@ static const struct iio_info mma7455_info = {
.write_raw = mma7455_write_raw,
};
+static const struct iio_mount_matrix *
+mma7455_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct mma7455_data *mma7455 = iio_priv(indio_dev);
+
+ return &mma7455->orientation;
+}
+
+static const struct iio_chan_spec_ext_info mma7455_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, mma7455_core_get_mount_matrix),
+ { }
+};
+
#define MMA7455_CHANNEL(axis, idx) { \
.type = IIO_ACCEL, \
+ .ext_info = mma7455_core_ext_info,\
.modified = 1, \
.address = MMA7455_REG_##axis##OUTL,\
.channel2 = IIO_MOD_##axis, \
@@ -267,6 +283,11 @@ int mma7455_core_probe(struct device *dev, struct regmap *regmap,
dev_set_drvdata(dev, indio_dev);
mma7455 = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &mma7455->orientation);
+ if (ret)
+ return ret;
+
mma7455->regmap = regmap;
indio_dev->info = &mma7455_info;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 14/18] iio: accel: mma7455_core: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/mma7455_core.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c
index a2b5bdf14d..0d180a6662 100644
--- a/drivers/iio/accel/mma7455_core.c
+++ b/drivers/iio/accel/mma7455_core.c
@@ -61,6 +61,7 @@ struct mma7455_data {
__le16 channels[3];
aligned_s64 ts;
} scan;
+ struct iio_mount_matrix orientation;
};
static int mma7455_drdy(struct mma7455_data *mma7455)
@@ -209,8 +210,23 @@ static const struct iio_info mma7455_info = {
.write_raw = mma7455_write_raw,
};
+static const struct iio_mount_matrix *
+mma7455_core_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct mma7455_data *mma7455 = iio_priv(indio_dev);
+
+ return &mma7455->orientation;
+}
+
+static const struct iio_chan_spec_ext_info mma7455_core_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, mma7455_core_get_mount_matrix),
+ { }
+};
+
#define MMA7455_CHANNEL(axis, idx) { \
.type = IIO_ACCEL, \
+ .ext_info = mma7455_core_ext_info,\
.modified = 1, \
.address = MMA7455_REG_##axis##OUTL,\
.channel2 = IIO_MOD_##axis, \
@@ -267,6 +283,11 @@ int mma7455_core_probe(struct device *dev, struct regmap *regmap,
dev_set_drvdata(dev, indio_dev);
mma7455 = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(dev, &mma7455->orientation);
+ if (ret)
+ return ret;
+
mma7455->regmap = regmap;
indio_dev->info = &mma7455_info;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 15/18] iio: accel: msa311: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/msa311.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/iio/accel/msa311.c b/drivers/iio/accel/msa311.c
index caf9b1b639..ccbdcaf524 100644
--- a/drivers/iio/accel/msa311.c
+++ b/drivers/iio/accel/msa311.c
@@ -351,6 +351,7 @@ static const struct regmap_config msa311_regmap_config = {
* @chip_name: Chip name in the format "msa311-%02x" % partid
* @new_data_trig: Optional NEW_DATA interrupt driven trigger used
* to notify external consumers a new sample is ready
+ * @orientation: mount matrix describing the sensor mounting orientation
*/
struct msa311_priv {
struct regmap *regs;
@@ -361,6 +362,7 @@ struct msa311_priv {
char *chip_name;
struct iio_trigger *new_data_trig;
+ struct iio_mount_matrix orientation;
};
enum msa311_si {
@@ -370,8 +372,23 @@ enum msa311_si {
MSA311_SI_TIMESTAMP,
};
+static const struct iio_mount_matrix *
+msa311_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct msa311_priv *msa311 = iio_priv(indio_dev);
+
+ return &msa311->orientation;
+}
+
+static const struct iio_chan_spec_ext_info msa311_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, msa311_get_mount_matrix),
+ { }
+};
+
#define MSA311_ACCEL_CHANNEL(axis) { \
.type = IIO_ACCEL, \
+ .ext_info = msa311_ext_info, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
@@ -1149,6 +1166,11 @@ static int msa311_probe(struct i2c_client *i2c)
return -ENOMEM;
msa311 = iio_priv(indio_dev);
+
+ err = iio_read_mount_matrix(dev, &msa311->orientation);
+ if (err)
+ return err;
+
msa311->dev = dev;
i2c_set_clientdata(i2c, indio_dev);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 15/18] iio: accel: msa311: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/msa311.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/iio/accel/msa311.c b/drivers/iio/accel/msa311.c
index caf9b1b639..ccbdcaf524 100644
--- a/drivers/iio/accel/msa311.c
+++ b/drivers/iio/accel/msa311.c
@@ -351,6 +351,7 @@ static const struct regmap_config msa311_regmap_config = {
* @chip_name: Chip name in the format "msa311-%02x" % partid
* @new_data_trig: Optional NEW_DATA interrupt driven trigger used
* to notify external consumers a new sample is ready
+ * @orientation: mount matrix describing the sensor mounting orientation
*/
struct msa311_priv {
struct regmap *regs;
@@ -361,6 +362,7 @@ struct msa311_priv {
char *chip_name;
struct iio_trigger *new_data_trig;
+ struct iio_mount_matrix orientation;
};
enum msa311_si {
@@ -370,8 +372,23 @@ enum msa311_si {
MSA311_SI_TIMESTAMP,
};
+static const struct iio_mount_matrix *
+msa311_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct msa311_priv *msa311 = iio_priv(indio_dev);
+
+ return &msa311->orientation;
+}
+
+static const struct iio_chan_spec_ext_info msa311_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, msa311_get_mount_matrix),
+ { }
+};
+
#define MSA311_ACCEL_CHANNEL(axis) { \
.type = IIO_ACCEL, \
+ .ext_info = msa311_ext_info, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
@@ -1149,6 +1166,11 @@ static int msa311_probe(struct i2c_client *i2c)
return -ENOMEM;
msa311 = iio_priv(indio_dev);
+
+ err = iio_read_mount_matrix(dev, &msa311->orientation);
+ if (err)
+ return err;
+
msa311->dev = dev;
i2c_set_clientdata(i2c, indio_dev);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 16/18] iio: accel: mxc6255: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/mxc6255.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c
index a9f41cf27a..7a53cdff50 100644
--- a/drivers/iio/accel/mxc6255.c
+++ b/drivers/iio/accel/mxc6255.c
@@ -42,6 +42,7 @@ enum mxc6255_axis {
struct mxc6255_data {
struct i2c_client *client;
struct regmap *regmap;
+ struct iio_mount_matrix orientation;
};
static int mxc6255_read_raw(struct iio_dev *indio_dev,
@@ -76,8 +77,23 @@ static const struct iio_info mxc6255_info = {
.read_raw = mxc6255_read_raw,
};
+static const struct iio_mount_matrix *
+mxc6255_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct mxc6255_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info mxc6255_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, mxc6255_get_mount_matrix),
+ { }
+};
+
#define MXC6255_CHANNEL(_axis, reg) { \
.type = IIO_ACCEL, \
+ .ext_info = mxc6255_ext_info, \
.modified = 1, \
.channel2 = IIO_MOD_##_axis, \
.address = reg, \
@@ -130,6 +146,11 @@ static int mxc6255_probe(struct i2c_client *client)
}
data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(&client->dev, &data->orientation);
+ if (ret)
+ return ret;
+
i2c_set_clientdata(client, indio_dev);
data->client = client;
data->regmap = regmap;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 16/18] iio: accel: mxc6255: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/mxc6255.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c
index a9f41cf27a..7a53cdff50 100644
--- a/drivers/iio/accel/mxc6255.c
+++ b/drivers/iio/accel/mxc6255.c
@@ -42,6 +42,7 @@ enum mxc6255_axis {
struct mxc6255_data {
struct i2c_client *client;
struct regmap *regmap;
+ struct iio_mount_matrix orientation;
};
static int mxc6255_read_raw(struct iio_dev *indio_dev,
@@ -76,8 +77,23 @@ static const struct iio_info mxc6255_info = {
.read_raw = mxc6255_read_raw,
};
+static const struct iio_mount_matrix *
+mxc6255_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct mxc6255_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info mxc6255_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, mxc6255_get_mount_matrix),
+ { }
+};
+
#define MXC6255_CHANNEL(_axis, reg) { \
.type = IIO_ACCEL, \
+ .ext_info = mxc6255_ext_info, \
.modified = 1, \
.channel2 = IIO_MOD_##_axis, \
.address = reg, \
@@ -130,6 +146,11 @@ static int mxc6255_probe(struct i2c_client *client)
}
data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(&client->dev, &data->orientation);
+ if (ret)
+ return ret;
+
i2c_set_clientdata(client, indio_dev);
data->client = client;
data->regmap = regmap;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 17/18] iio: accel: sca3300: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/sca3300.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c
index 67582cc341..2b4d0df48e 100644
--- a/drivers/iio/accel/sca3300.c
+++ b/drivers/iio/accel/sca3300.c
@@ -56,8 +56,18 @@ enum sca3300_scan_indexes {
SCA3300_SCAN_MAX
};
+static const struct iio_mount_matrix *
+sca3300_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan);
+
+static const struct iio_chan_spec_ext_info sca3300_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, sca3300_get_mount_matrix),
+ { }
+};
+
#define SCA3300_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = sca3300_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -184,15 +194,26 @@ struct sca3300_chip_info {
* @chip: Sensor chip specific information
* @txbuf: Transmit buffer
* @rxbuf: Receive buffer
+ * @orientation: mount matrix describing the sensor mounting orientation
*/
struct sca3300_data {
struct spi_device *spi;
struct mutex lock;
const struct sca3300_chip_info *chip;
+ struct iio_mount_matrix orientation;
u8 txbuf[4] __aligned(IIO_DMA_MINALIGN);
u8 rxbuf[4];
};
+static const struct iio_mount_matrix *
+sca3300_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct sca3300_data *sca_data = iio_priv(indio_dev);
+
+ return &sca_data->orientation;
+}
+
static const struct sca3300_chip_info sca3300_chip_tbl[] = {
{
.name = "sca3300",
@@ -619,6 +640,11 @@ static int sca3300_probe(struct spi_device *spi)
return -ENOMEM;
sca_data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(&spi->dev, &sca_data->orientation);
+ if (ret)
+ return ret;
+
mutex_init(&sca_data->lock);
sca_data->spi = spi;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 17/18] iio: accel: sca3300: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/sca3300.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c
index 67582cc341..2b4d0df48e 100644
--- a/drivers/iio/accel/sca3300.c
+++ b/drivers/iio/accel/sca3300.c
@@ -56,8 +56,18 @@ enum sca3300_scan_indexes {
SCA3300_SCAN_MAX
};
+static const struct iio_mount_matrix *
+sca3300_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan);
+
+static const struct iio_chan_spec_ext_info sca3300_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, sca3300_get_mount_matrix),
+ { }
+};
+
#define SCA3300_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = sca3300_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -184,15 +194,26 @@ struct sca3300_chip_info {
* @chip: Sensor chip specific information
* @txbuf: Transmit buffer
* @rxbuf: Receive buffer
+ * @orientation: mount matrix describing the sensor mounting orientation
*/
struct sca3300_data {
struct spi_device *spi;
struct mutex lock;
const struct sca3300_chip_info *chip;
+ struct iio_mount_matrix orientation;
u8 txbuf[4] __aligned(IIO_DMA_MINALIGN);
u8 rxbuf[4];
};
+static const struct iio_mount_matrix *
+sca3300_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct sca3300_data *sca_data = iio_priv(indio_dev);
+
+ return &sca_data->orientation;
+}
+
static const struct sca3300_chip_info sca3300_chip_tbl[] = {
{
.name = "sca3300",
@@ -619,6 +640,11 @@ static int sca3300_probe(struct spi_device *spi)
return -ENOMEM;
sca_data = iio_priv(indio_dev);
+
+ ret = iio_read_mount_matrix(&spi->dev, &sca_data->orientation);
+ if (ret)
+ return ret;
+
mutex_init(&sca_data->lock);
sca_data->spi = spi;
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 18/18] iio: accel: stk8312: support mount matrix
2026-11-30 6:29 ` He Xin
@ 2026-11-30 6:29 ` He Xin
-1 siblings, 0 replies; 44+ messages in thread
From: He Xin via B4 Relay @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, He Xin
From: He Xin <hexin@hexin.host>
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 <hexin@hexin.host>
---
drivers/iio/accel/stk8312.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
index 50840c3440..146cfc8c9f 100644
--- a/drivers/iio/accel/stk8312.c
+++ b/drivers/iio/accel/stk8312.c
@@ -78,8 +78,18 @@ static const struct {
{12, 500000}, {6, 250000}, {3, 125000}
};
+static const struct iio_mount_matrix *
+stk8312_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan);
+
+static const struct iio_chan_spec_ext_info stk8312_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, stk8312_get_mount_matrix),
+ { }
+};
+
#define STK8312_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = stk8312_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -115,8 +125,18 @@ struct stk8312_data {
s8 chans[3];
aligned_s64 timestamp;
} scan;
+ struct iio_mount_matrix orientation;
};
+static const struct iio_mount_matrix *
+stk8312_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct stk8312_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL);
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("3.125 6.25 12.5 25 50 100 200 400");
@@ -516,6 +536,11 @@ static int stk8312_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;
i2c_set_clientdata(client, indio_dev);
mutex_init(&data->lock);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* [PATCH v2 18/18] iio: accel: stk8312: support mount matrix
@ 2026-11-30 6:29 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-11-30 6:29 UTC (permalink / raw)
To: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux, 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 <hexin@hexin.host>
---
drivers/iio/accel/stk8312.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
index 50840c3440..146cfc8c9f 100644
--- a/drivers/iio/accel/stk8312.c
+++ b/drivers/iio/accel/stk8312.c
@@ -78,8 +78,18 @@ static const struct {
{12, 500000}, {6, 250000}, {3, 125000}
};
+static const struct iio_mount_matrix *
+stk8312_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan);
+
+static const struct iio_chan_spec_ext_info stk8312_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, stk8312_get_mount_matrix),
+ { }
+};
+
#define STK8312_ACCEL_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
+ .ext_info = stk8312_ext_info, \
.address = reg, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
@@ -115,8 +125,18 @@ struct stk8312_data {
s8 chans[3];
aligned_s64 timestamp;
} scan;
+ struct iio_mount_matrix orientation;
};
+static const struct iio_mount_matrix *
+stk8312_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct stk8312_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL);
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("3.125 6.25 12.5 25 50 100 200 400");
@@ -516,6 +536,11 @@ static int stk8312_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;
i2c_set_clientdata(client, indio_dev);
mutex_init(&data->lock);
--
2.53.0
^ permalink raw reply related [flat|nested] 44+ messages in thread
* Re: [PATCH v2 00/18] iio: accel: add mount matrix support to 18 accelerometer drivers
2026-11-30 6:29 ` He Xin
` (18 preceding siblings ...)
(?)
@ 2026-11-30 11:34 ` Joshua Crofts
-1 siblings, 0 replies; 44+ messages in thread
From: Joshua Crofts @ 2026-11-30 11:34 UTC (permalink / raw)
To: hexin, linux-iio, Michael Hennerich, Puranjay Mohan,
Marcelo Schmitt, Antoniu Miclaus, Ramona Gradinariu, Petre Rodan
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
linux
On 30-Nov-26 7:29, He Xin via B4 Relay wrote:
> These drivers ignore the "mount-matrix" property that other accelerometer
> drivers already honour, so userspace gets raw sensor axes on any board
> whose sensor is not mounted axis-aligned with the display. A udev/hwdb
> override does not cover it either: it keys off the sensor modalias and
> DMI, which do not tell such boards apart.
>
> Each patch is mechanical and independent: store the matrix in the driver's
> private data, add an IIO_MOUNT_MATRIX() ext_info entry to the accelerometer
> channels, and read the property once in probe.
>
> One behaviour change: a board whose firmware describes a matrix with the
> wrong number of entries now fails to probe with -EINVAL instead of being
> ignored, which is what the drivers that already support the property do.
>
> Not converted here, because the change would not have the same shape:
> adis16201, adis16209 and sca3000 list their channels as array literals,
> adxl313_core and fxls8962af-core keep the probe in the bus wrappers, and
> mma9551/mma9553 differ in both. hid-sensor-accel-3d, ssp_accel_sensor and
> cros_ec_accel_legacy take the orientation from the HID/SSP/EC side rather
> than from a firmware property.
>
> Changes in v2:
> - move stk8ba50 to patch 1
> - place the mount matrix before the __aligned(IIO_DMA_MINALIGN) members in
> adxl345, adxl355, adxl367, adxl380, bma220, bmi088 and sca3300, so the
> DMA buffers keep their own cacheline
> - add the missing blank line after the mount matrix read in probe
> - add the @orientation kernel-doc entry for msa311 and sca3300
> - shorten the stk8ba50 test note to the behaviour observed on the device
> - v1 lost its threading because the sending MTA rewrote Message-IDs while
> leaving References untouched; v2 is posted as a new series
>
> Build tested with allmodconfig: drivers/iio/accel, 71 objects, no warnings;
> checkpatch.pl is silent in default and in --strict mode. Only stk8ba50 was
> tested on hardware; the other 17 are compile tested.
>
> Link: https://lore.kernel.org/linux-iio/5F08289E852625FC+20261127030810.3150676-1-hexin@hexin.host/
> Signed-off-by: He Xin <hexin@hexin.host>
> ---
I haven't checked the placements in the data structs with pahole, but otherwise
this LGTM.
For the series,
Reviewed-by: Joshua Crofts <crofts@kernel.org>
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 01/18] iio: accel: stk8ba50: support mount matrix
2026-11-30 6:29 ` He Xin
(?)
@ 2026-12-01 10:24 ` Andy Shevchenko
2026-12-02 2:18 ` 何鑫
-1 siblings, 1 reply; 44+ messages in thread
From: Andy Shevchenko @ 2026-12-01 10:24 UTC (permalink / raw)
To: hexin
Cc: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux
On Mon, Nov 30, 2026 at 02:29:30PM +0800, He Xin via B4 Relay wrote:
>
> 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.
Why is this used on ACPI platform to begin with?!
ACPI has its own established method(s) (okay, de facto), which we use across
the drivers. It's called ROTM IIRC.
> Read the mount matrix at probe time and expose it through
> IIO_MOUNT_MATRIX(), as several other accelerometer drivers already do.
>
> Tested on a tablet whose sensor is mounted rotated 180 degrees about X:
> without the patch in_accel_mount_matrix is absent, so iio-sensor-proxy has
> to fall back to a udev/hwdb override; with it the matrix from _DSD is
> reported and the orientation comes out correct.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 00/18] iio: accel: add mount matrix support to 18 accelerometer drivers
2026-11-30 6:29 ` He Xin
` (19 preceding siblings ...)
(?)
@ 2026-12-01 10:27 ` Andy Shevchenko
2026-12-02 2:23 ` He Xin
-1 siblings, 1 reply; 44+ messages in thread
From: Andy Shevchenko @ 2026-12-01 10:27 UTC (permalink / raw)
To: hexin
Cc: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux
On Mon, Nov 30, 2026 at 02:29:29PM +0800, He Xin via B4 Relay wrote:
> These drivers ignore the "mount-matrix" property that other accelerometer
> drivers already honour, so userspace gets raw sensor axes on any board
> whose sensor is not mounted axis-aligned with the display. A udev/hwdb
> override does not cover it either: it keys off the sensor modalias and
> DMI, which do not tell such boards apart.
So, have you tested all of them? What the hardware platforms have been tested?
> Each patch is mechanical and independent: store the matrix in the driver's
> private data, add an IIO_MOUNT_MATRIX() ext_info entry to the accelerometer
> channels, and read the property once in probe.
>
> One behaviour change: a board whose firmware describes a matrix with the
> wrong number of entries now fails to probe with -EINVAL instead of being
> ignored, which is what the drivers that already support the property do.
>
> Not converted here, because the change would not have the same shape:
> adis16201, adis16209 and sca3000 list their channels as array literals,
> adxl313_core and fxls8962af-core keep the probe in the bus wrappers, and
> mma9551/mma9553 differ in both. hid-sensor-accel-3d, ssp_accel_sensor and
> cros_ec_accel_legacy take the orientation from the HID/SSP/EC side rather
> than from a firmware property.
This change is questionable. Do you play with DIY boards and add locally
SSDT or _DSD to provide mount matrix? From ACPI point of view and based
on the comment I gave against patch 1, this requires a lot more information
to understand what's going on here.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 16/18] iio: accel: mxc6255: support mount matrix
2026-11-30 6:29 ` He Xin
(?)
@ 2026-12-01 10:29 ` Andy Shevchenko
-1 siblings, 0 replies; 44+ messages in thread
From: Andy Shevchenko @ 2026-12-01 10:29 UTC (permalink / raw)
To: hexin
Cc: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux
On Mon, Nov 30, 2026 at 02:29:45PM +0800, He Xin via B4 Relay wrote:
>
> 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.
...
> struct mxc6255_data {
> struct i2c_client *client;
> struct regmap *regmap;
> + struct iio_mount_matrix orientation;
Looking at number of patches doing the same, the proper location for this most
likely is IIO opaque structure with the parser filling it and IIO core handle
without exposing to each user that needs it.
TL;DR: I don't like the idea of duplication.
Jonathan, what's your view on this?
> };
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 01/18] iio: accel: stk8ba50: support mount matrix
2026-12-01 10:24 ` Andy Shevchenko
@ 2026-12-02 2:18 ` 何鑫
0 siblings, 0 replies; 44+ messages in thread
From: 何鑫 @ 2026-12-02 2:18 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux
> Why is this used on ACPI platform to begin with?!
> ACPI has its own established method(s) (okay, de facto), which we use
across
> the drivers. It's called ROTM IIRC.
You are right, and the next revision reads it. The probe becomes
if (!iio_read_acpi_mount_matrix(dev, &priv->orientation, "ROTM")) {
ret = iio_read_mount_matrix(dev, &priv->orientation);
if (ret)
return ret;
}
which is the same shape as kxcjk-1013, bmc150-accel, mxc4005, bmi323 and
st_lsm6dsx.
The property fallback stays because the firmware on the board this was
tested
on describes the orientation in _DSD "mount-matrix" rather than
implementing a
ROTM method, and the ACPI tables there are part of the board firmware, not a
locally applied SSDT. Once that firmware gains a ROTM method the
drivers pick
it up without another change, and a board that provides neither still
gets the
identity matrix.
Thanks,
He Xin
^ permalink raw reply [flat|nested] 44+ messages in thread
* Re: [PATCH v2 00/18] iio: accel: add mount matrix support to 18 accelerometer drivers
2026-12-01 10:27 ` Andy Shevchenko
@ 2026-12-02 2:23 ` He Xin
0 siblings, 0 replies; 44+ messages in thread
From: He Xin @ 2026-12-02 2:23 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-iio, Michael Hennerich, Puranjay Mohan, Marcelo Schmitt,
Antoniu Miclaus, Ramona Gradinariu, Petre Rodan, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, linux
> So, have you tested all of them? What the hardware platforms have been tested?
One board: stk8ba50, the driver this series started from, was tested on that
board's tablet. The other 17 are compile tested only - allmodconfig,
drivers/iio/accel, 71 objects, no warnings. I do not have hardware for
them,
which is why the patches are kept mechanical and independent.
> This change is questionable. Do you play with DIY boards and add locally
> SSDT or _DSD to provide mount matrix? From ACPI point of view and based
> on the comment I gave against patch 1, this requires a lot more information
> to understand what's going on here.
No, this is the board's own firmware: the DSDT is built from the platform
source tree and shipped in the BIOS image, there is no local SSDT overlay.
On the ACPI side you were right and v2 missed it. The next revision
reads ROTM
first and falls back to the "mount-matrix" property, which is what that
firmware describes today; the fallback is what makes the tablet usable now,
and the ROTM method can be added to the firmware later without touching the
drivers. I am holding that revision until Jonathan answers your question on
mxc6255 about moving this into the IIO core.
Thanks,
He Xin
^ permalink raw reply [flat|nested] 44+ messages in thread
end of thread, other threads:[~2026-12-02 2:23 UTC | newest]
Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 6:29 [PATCH v2 00/18] iio: accel: add mount matrix support to 18 accelerometer drivers He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 01/18] iio: accel: stk8ba50: support mount matrix He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-12-01 10:24 ` Andy Shevchenko
2026-12-02 2:18 ` 何鑫
2026-11-30 6:29 ` [PATCH v2 02/18] iio: accel: adxl345_core: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 03/18] iio: accel: adxl355_core: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 04/18] iio: accel: adxl367: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 05/18] iio: accel: adxl372: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 06/18] iio: accel: adxl380: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 07/18] iio: accel: bma220_core: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 08/18] iio: accel: bmi088-accel-core: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 09/18] iio: accel: da280: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 10/18] iio: accel: da311: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 11/18] iio: accel: dmard06: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 12/18] iio: accel: dmard09: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 13/18] iio: accel: dmard10: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 14/18] iio: accel: mma7455_core: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 15/18] iio: accel: msa311: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 16/18] iio: accel: mxc6255: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-12-01 10:29 ` Andy Shevchenko
2026-11-30 6:29 ` [PATCH v2 17/18] iio: accel: sca3300: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 6:29 ` [PATCH v2 18/18] iio: accel: stk8312: " He Xin via B4 Relay
2026-11-30 6:29 ` He Xin
2026-11-30 11:34 ` [PATCH v2 00/18] iio: accel: add mount matrix support to 18 accelerometer drivers Joshua Crofts
2026-12-01 10:27 ` Andy Shevchenko
2026-12-02 2:23 ` He Xin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.