2021-04-06 09:26:52

by Hans de Goede

[permalink] [raw]
Subject: [PATCH v2 resend 2/2] iio: documentation: Document accelerometer label use

Some 2-in-1 laptops / convertibles with 360° (yoga-style) hinges,
have 2 accelerometers, 1 in their base and 1 in their display.

In many cases the kernel can detect the location of each accelerometer
based on e.g. information from the ACPI tables.

It is important for userspace to know the location of the 2 accelerometers.
Rather then adding a new sysfs-attribute for this we can relay this
information to userspace by using standardized label strings for this.
This mirrors how this is done for proximity sensors.

This commit documents 2 new standardized label strings for this purpose:
"accel-base"
"accel-display"

Note the "base" and "display" suffixes were chosen to match the values
used for the systemd/udev hwdb.d/60-sensor.hwdb file's ACCEL_LOCATION
property.

Cc: Dmitry Torokhov <[email protected]>
Cc: Mark Pearson <[email protected]>
Cc: Bastien Nocera <[email protected]>
Signed-off-by: Hans de Goede <[email protected]>
---
Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 7379e40d862d..b7529bca83f5 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -72,6 +72,13 @@ Description:
calculated by firmware from other sensor readings, rather then
being a raw sensor reading.

+ For accelerometers used in 2-in-1s with 360° (yoga-style) hinges,
+ which have an accelerometer in both their base and their display,
+ the following standardized labels are used:
+
+ * "accel-base"
+ * "accel-display"
+
What: /sys/bus/iio/devices/iio:deviceX/current_timestamp_clock
KernelVersion: 4.5
Contact: [email protected]
--
2.30.2


2021-04-16 11:34:05

by Hans de Goede

[permalink] [raw]
Subject: Re: [PATCH v2 resend 2/2] iio: documentation: Document accelerometer label use

Hi,

On 4/16/21 12:56 PM, Bastien Nocera wrote:
> On Mon, 2021-04-05 at 22:39 +0200, Hans de Goede wrote:
>> Some 2-in-1 laptops / convertibles with 360° (yoga-style) hinges,
>> have 2 accelerometers, 1 in their base and 1 in their display.
>>
>> In many cases the kernel can detect the location of each
>> accelerometer
>> based on e.g. information from the ACPI tables.
>>
>> It is important for userspace to know the location of the 2
>> accelerometers.
>> Rather then adding a new sysfs-attribute for this we can relay this
>> information to userspace by using standardized label strings for
>> this.
>> This mirrors how this is done for proximity sensors.
>>
>> This commit documents 2 new standardized label strings for this
>> purpose:
>> "accel-base"
>> "accel-display"
>
> If we have a combined proximity and accelerometer sensor (which
> wouldn't be unheard off with sensor hubs being used), how are multiple
> labels, say "proximity-wifi" and "accel-base" documented?

Sensor hubs typically use one iio device per sensor, see e.g.
how HID-sensors work. And if a device which does not use separate
iio-devices per sensor shows up then the plan is to use per
channel-labels which are already supported by iio.

Regards,

Hans



>> Note the "base" and "display" suffixes were chosen to match the
>> values
>> used for the systemd/udev hwdb.d/60-sensor.hwdb file's ACCEL_LOCATION
>> property.
>>
>> Cc: Dmitry Torokhov <[email protected]>
>> Cc: Mark Pearson <[email protected]>
>> Cc: Bastien Nocera <[email protected]>
>> Signed-off-by: Hans de Goede <[email protected]>
>> ---
>>  Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-bus-iio
>> b/Documentation/ABI/testing/sysfs-bus-iio
>> index 7379e40d862d..b7529bca83f5 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-iio
>> +++ b/Documentation/ABI/testing/sysfs-bus-iio
>> @@ -72,6 +72,13 @@ Description:
>>                 calculated by firmware from other sensor readings,
>> rather then
>>                 being a raw sensor reading.
>>  
>> +               For accelerometers used in 2-in-1s with 360° (yoga-
>> style) hinges,
>> +               which have an accelerometer in both their base and
>> their display,
>> +               the following standardized labels are used:
>> +
>> +               * "accel-base"
>> +               * "accel-display"
>> +
>>  What:          /sys/bus/iio/devices/iio:deviceX/current_timestamp_cl
>> ock
>>  KernelVersion: 4.5
>>  Contact:       [email protected]
>
>

2021-04-16 12:08:58

by Bastien Nocera

[permalink] [raw]
Subject: Re: [PATCH v2 resend 2/2] iio: documentation: Document accelerometer label use

On Mon, 2021-04-05 at 22:39 +0200, Hans de Goede wrote:
> Some 2-in-1 laptops / convertibles with 360° (yoga-style) hinges,
> have 2 accelerometers, 1 in their base and 1 in their display.
>
> In many cases the kernel can detect the location of each
> accelerometer
> based on e.g. information from the ACPI tables.
>
> It is important for userspace to know the location of the 2
> accelerometers.
> Rather then adding a new sysfs-attribute for this we can relay this
> information to userspace by using standardized label strings for
> this.
> This mirrors how this is done for proximity sensors.
>
> This commit documents 2 new standardized label strings for this
> purpose:
> "accel-base"
> "accel-display"

If we have a combined proximity and accelerometer sensor (which
wouldn't be unheard off with sensor hubs being used), how are multiple
labels, say "proximity-wifi" and "accel-base" documented?

I think that it might be worth using a separate sysfs attribute for
this, say "location" which would have "display" or "base" as a value,
and which iio-sensor-proxy could already consume.

This would also make it easier to funnel values from DeviceTree or ACPI
to udev and/or a single sysfs kernel attribute one-to-one.

Cheers

>
> Note the "base" and "display" suffixes were chosen to match the
> values
> used for the systemd/udev hwdb.d/60-sensor.hwdb file's ACCEL_LOCATION
> property.
>
> Cc: Dmitry Torokhov <[email protected]>
> Cc: Mark Pearson <[email protected]>
> Cc: Bastien Nocera <[email protected]>
> Signed-off-by: Hans de Goede <[email protected]>
> ---
>  Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio
> b/Documentation/ABI/testing/sysfs-bus-iio
> index 7379e40d862d..b7529bca83f5 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -72,6 +72,13 @@ Description:
>                 calculated by firmware from other sensor readings,
> rather then
>                 being a raw sensor reading.
>  
> +               For accelerometers used in 2-in-1s with 360° (yoga-
> style) hinges,
> +               which have an accelerometer in both their base and
> their display,
> +               the following standardized labels are used:
> +
> +               * "accel-base"
> +               * "accel-display"
> +
>  What:          /sys/bus/iio/devices/iio:deviceX/current_timestamp_cl
> ock
>  KernelVersion: 4.5
>  Contact:       [email protected]


2021-04-16 12:32:16

by Bastien Nocera

[permalink] [raw]
Subject: Re: [PATCH v2 resend 2/2] iio: documentation: Document accelerometer label use

On Fri, 2021-04-16 at 13:05 +0200, Hans de Goede wrote:
> Hi,
>
> On 4/16/21 12:56 PM, Bastien Nocera wrote:
> > On Mon, 2021-04-05 at 22:39 +0200, Hans de Goede wrote:
> > > Some 2-in-1 laptops / convertibles with 360° (yoga-style) hinges,
> > > have 2 accelerometers, 1 in their base and 1 in their display.
> > >
> > > In many cases the kernel can detect the location of each
> > > accelerometer
> > > based on e.g. information from the ACPI tables.
> > >
> > > It is important for userspace to know the location of the 2
> > > accelerometers.
> > > Rather then adding a new sysfs-attribute for this we can relay
> > > this
> > > information to userspace by using standardized label strings for
> > > this.
> > > This mirrors how this is done for proximity sensors.
> > >
> > > This commit documents 2 new standardized label strings for this
> > > purpose:
> > > "accel-base"
> > > "accel-display"
> >
> > If we have a combined proximity and accelerometer sensor (which
> > wouldn't be unheard off with sensor hubs being used), how are
> > multiple
> > labels, say "proximity-wifi" and "accel-base" documented?
>
> Sensor hubs typically use one iio device per sensor, see e.g.
> how HID-sensors work. And if a device which does not use separate
> iio-devices per sensor shows up then the plan is to use per
> channel-labels which are already supported by iio.

OK.

>
> Regards,
>
> Hans
>
>
>
> > > Note the "base" and "display" suffixes were chosen to match the
> > > values
> > > used for the systemd/udev hwdb.d/60-sensor.hwdb file's
> > > ACCEL_LOCATION
> > > property.
> > >
> > > Cc: Dmitry Torokhov <[email protected]>
> > > Cc: Mark Pearson <[email protected]>
> > > Cc: Bastien Nocera <[email protected]>
> > > Signed-off-by: Hans de Goede <[email protected]>
> > > ---
> > >  Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/Documentation/ABI/testing/sysfs-bus-iio
> > > b/Documentation/ABI/testing/sysfs-bus-iio
> > > index 7379e40d862d..b7529bca83f5 100644
> > > --- a/Documentation/ABI/testing/sysfs-bus-iio
> > > +++ b/Documentation/ABI/testing/sysfs-bus-iio
> > > @@ -72,6 +72,13 @@ Description:
> > >                 calculated by firmware from other sensor
> > > readings,
> > > rather then
> > >                 being a raw sensor reading.
> > >  
> > > +               For accelerometers used in 2-in-1s with 360°
> > > (yoga-
> > > style) hinges,
> > > +               which have an accelerometer in both their base
> > > and
> > > their display,
> > > +               the following standardized labels are used:
> > > +
> > > +               * "accel-base"
> > > +               * "accel-display"
> > > +
> > >  What:          /sys/bus/iio/devices/iio:deviceX/current_timestam
> > > p_cl
> > > ock
> > >  KernelVersion: 4.5
> > >  Contact:       [email protected]
> >
> >
>