linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Reporting screen/laptop orientation data to userspace
@ 2011-05-29  7:49 Alberto Mardegan
  2011-06-02 22:19 ` Pavel Machek
  2011-06-03 15:55 ` Bastien Nocera
  0 siblings, 2 replies; 10+ messages in thread
From: Alberto Mardegan @ 2011-05-29  7:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Javier S. Pedro, linux-input

Hi all,
  the WMI interfaces in some Lenovo Ideapad laptops provide notification
callbacks when the laptop orientation changes, reporting 4 different
values defining the new orientation.

I'd like to extend the ideapad-laptop driver with this information; but
how should it be reported to userspace? I initially thought of the input
subsystem, but I cannot find any suitable event codes; then I would
probably export it as a device under /sys, or are there better options?

Are there other devices which provide coarse orientation data to
userspace, which I might want to use as a reference?
I guess that at least some display screens have this feature.

TIA,
  Alberto

-- 
http://blog.mardy.it <- geek in un lingua international!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reporting screen/laptop orientation data to userspace
  2011-05-29  7:49 Reporting screen/laptop orientation data to userspace Alberto Mardegan
@ 2011-06-02 22:19 ` Pavel Machek
  2011-06-03 15:55 ` Bastien Nocera
  1 sibling, 0 replies; 10+ messages in thread
From: Pavel Machek @ 2011-06-02 22:19 UTC (permalink / raw)
  To: Alberto Mardegan; +Cc: linux-kernel, Javier S. Pedro, linux-input

Hi!

>   the WMI interfaces in some Lenovo Ideapad laptops provide notification
> callbacks when the laptop orientation changes, reporting 4 different
> values defining the new orientation.

Zaurus has two microswitches, indicating one of 3 configurations:

notebook, closed

notebook, open

tablet

They are exported as event/switch in the input. If possible, it would
be nice to have one interface for that, too. (And it probably should
be input,  and not fake-accelerator based; after all, there are no
accelerometers on zaurus-like systems).

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reporting screen/laptop orientation data to userspace
  2011-05-29  7:49 Reporting screen/laptop orientation data to userspace Alberto Mardegan
  2011-06-02 22:19 ` Pavel Machek
@ 2011-06-03 15:55 ` Bastien Nocera
  2011-06-04 17:13   ` Mohamed Ikbel Boulabiar
  2011-06-06  6:53   ` Alberto Mardegan
  1 sibling, 2 replies; 10+ messages in thread
From: Bastien Nocera @ 2011-06-03 15:55 UTC (permalink / raw)
  To: Alberto Mardegan; +Cc: linux-kernel, Javier S. Pedro, linux-input

On Sun, 2011-05-29 at 10:49 +0300, Alberto Mardegan wrote:
> Hi all,
>   the WMI interfaces in some Lenovo Ideapad laptops provide notification
> callbacks when the laptop orientation changes, reporting 4 different
> values defining the new orientation.
> 
> I'd like to extend the ideapad-laptop driver with this information; but
> how should it be reported to userspace? I initially thought of the input
> subsystem, but I cannot find any suitable event codes; then I would
> probably export it as a device under /sys, or are there better options?
> 
> Are there other devices which provide coarse orientation data to
> userspace, which I might want to use as a reference?
> I guess that at least some display screens have this feature.

Do you also have a discrete accelerometer with that? Or you only ever
get notification through there?

If there is a discrete accelerometer, I'd drop the extra metadata, and
send an event through udev, and expect user-space to read from the
accelerometer instead.

If there isn't a discrete accelerometer, create a fake one, with some
hardcoded data based on the actual orientation of the device.

The accelerometer (whether real or fake) should show 3 axis (X/Y/Z).

As soon as it's seen some testing, I'll be showing the work I did for
GNOME support for automatic rotation based on orientation.

Cheers


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reporting screen/laptop orientation data to userspace
  2011-06-03 15:55 ` Bastien Nocera
@ 2011-06-04 17:13   ` Mohamed Ikbel Boulabiar
  2011-06-06 17:53     ` Bastien Nocera
  2011-06-06  6:53   ` Alberto Mardegan
  1 sibling, 1 reply; 10+ messages in thread
From: Mohamed Ikbel Boulabiar @ 2011-06-04 17:13 UTC (permalink / raw)
  To: Bastien Nocera
  Cc: Alberto Mardegan, linux-kernel, Javier S. Pedro, linux-input

On Fri, Jun 3, 2011 at 5:55 PM, Bastien Nocera <hadess@hadess.net> wrote:
>
> As soon as it's seen some testing, I'll be showing the work I did for
> GNOME support for automatic rotation based on orientation.

And how you handle these events through X ?

i

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reporting screen/laptop orientation data to userspace
  2011-06-03 15:55 ` Bastien Nocera
  2011-06-04 17:13   ` Mohamed Ikbel Boulabiar
@ 2011-06-06  6:53   ` Alberto Mardegan
  2011-06-06  8:42     ` Jonathan Cameron
  2011-06-06 17:50     ` Bastien Nocera
  1 sibling, 2 replies; 10+ messages in thread
From: Alberto Mardegan @ 2011-06-06  6:53 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-kernel, Javier S. Pedro, linux-input

On 06/03/2011 06:55 PM, Bastien Nocera wrote:
> Do you also have a discrete accelerometer with that? Or you only ever
> get notification through there?

There's a discrete accelerometer, but I suspect that it might be hard for its 
driver to get accepted into the mainline kernel, since it's directly playing 
with the EC I/O ports. It's this one:

https://gitorious.org/iaps/iaps/blobs/master/iaps.c

The coarse data OTOH comes via a clean WMI interface.

> If there is a discrete accelerometer, I'd drop the extra metadata, and
> send an event through udev, and expect user-space to read from the
> accelerometer instead.

You mean, send an event through udev when the WMI interface reports that the 
orientation has changed, and then expect the userspace to read the values from 
the accelerometer?
IMHO, reporting an event with no context data, it's inefficient and ugly 
(because it forces the userspace to perform additional acctions in order to get 
the data).

> If there isn't a discrete accelerometer, create a fake one, with some
> hardcoded data based on the actual orientation of the device.

This could be a solution in both cases (i.e., even if a discrete accelerometer 
is available). But it would be nice to have some flags on the input device which 
tell that this accelerometer is not as precise as one could desire. Is there 
such a thing?

> The accelerometer (whether real or fake) should show 3 axis (X/Y/Z).
>
> As soon as it's seen some testing, I'll be showing the work I did for
> GNOME support for automatic rotation based on orientation.

Do you support choosing the accelerometer device to be used?

The device that I wanted to create is actually something much simpler than an 
accelerometer; it would just report screen orientation. I believe that some 
computer screens might have something similar, detecting the screen orientation 
based on the angle formed between the screen base (or wall mount) and the screen 
panel... I would assume that if such information exists, this Lenovo Ideapad 
screen orientation should be reported in a similar way.

Ciao,
   Alberto

-- 
http://blog.mardy.it <-- geek in un lingua international!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reporting screen/laptop orientation data to userspace
  2011-06-06  6:53   ` Alberto Mardegan
@ 2011-06-06  8:42     ` Jonathan Cameron
  2011-06-06 17:50     ` Bastien Nocera
  1 sibling, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2011-06-06  8:42 UTC (permalink / raw)
  To: Alberto Mardegan
  Cc: Bastien Nocera, linux-kernel, Javier S. Pedro, linux-input

On 06/06/11 07:53, Alberto Mardegan wrote:
> On 06/03/2011 06:55 PM, Bastien Nocera wrote:
>> Do you also have a discrete accelerometer with that? Or you only ever
>> get notification through there?
> 
> There's a discrete accelerometer, but I suspect that it might be hard for its driver to get accepted into the mainline kernel, since it's directly playing with the EC I/O ports. It's this one:
> 
> https://gitorious.org/iaps/iaps/blobs/master/iaps.c
> 
> The coarse data OTOH comes via a clean WMI interface.
> 
>> If there is a discrete accelerometer, I'd drop the extra metadata, and
>> send an event through udev, and expect user-space to read from the
>> accelerometer instead.
> 
> You mean, send an event through udev when the WMI interface reports that the orientation has changed, and then expect the userspace to read the values from the accelerometer?
> IMHO, reporting an event with no context data, it's inefficient and ugly (because it forces the userspace to perform additional acctions in order to get the data).
> 
>> If there isn't a discrete accelerometer, create a fake one, with some
>> hardcoded data based on the actual orientation of the device.
> 
> This could be a solution in both cases (i.e., even if a discrete accelerometer is available). But it would be nice to have some flags on the input device which tell that this accelerometer is not as precise as one could desire. Is there such a thing?
> 
>> The accelerometer (whether real or fake) should show 3 axis (X/Y/Z).
>>
>> As soon as it's seen some testing, I'll be showing the work I did for
>> GNOME support for automatic rotation based on orientation.
> 
> Do you support choosing the accelerometer device to be used?
> 
> The device that I wanted to create is actually something much simpler than an accelerometer; it would just report screen orientation. I believe that some computer screens might have something similar, detecting the screen orientation based on the angle formed between the screen base (or wall mount) and the screen panel... I would assume that if such information exists, this Lenovo Ideapad screen orientation should be reported in a similar way.
Just for reference, there are devices on the market which do just
orientation detection (using an accelerometer inside).  I think
the ST FC30 is an example of this. Quoting from data sheet:

"When in a steady position, it is able to detect 6
different orientations with respect to the gravity
field, with notification provided through dedicated
signal lines."

Guess that fits into what you are discussing as well.

Personally I like the convenience of a 'fake' accelerometer
output.  Devices with decent orientation detection support
are, I think, less common that unprocessed accelerometers so
best to use an interface that will work with them as well
(maybe with some smart stuff to change their threshold interrupts
to provide equivalent functionality.)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reporting screen/laptop orientation data to userspace
  2011-06-06  6:53   ` Alberto Mardegan
  2011-06-06  8:42     ` Jonathan Cameron
@ 2011-06-06 17:50     ` Bastien Nocera
  2011-06-06 18:41       ` Alan Cox
  1 sibling, 1 reply; 10+ messages in thread
From: Bastien Nocera @ 2011-06-06 17:50 UTC (permalink / raw)
  To: Alberto Mardegan; +Cc: linux-kernel, Javier S. Pedro, linux-input

On Mon, 2011-06-06 at 09:53 +0300, Alberto Mardegan wrote:
> On 06/03/2011 06:55 PM, Bastien Nocera wrote:
> > Do you also have a discrete accelerometer with that? Or you only ever
> > get notification through there?
> 
> There's a discrete accelerometer, but I suspect that it might be hard for its 
> driver to get accepted into the mainline kernel, since it's directly playing 
> with the EC I/O ports. It's this one:
> 
> https://gitorious.org/iaps/iaps/blobs/master/iaps.c
> 
> The coarse data OTOH comes via a clean WMI interface.

OK.

> > If there is a discrete accelerometer, I'd drop the extra metadata, and
> > send an event through udev, and expect user-space to read from the
> > accelerometer instead.
> 
> You mean, send an event through udev when the WMI interface reports that the 
> orientation has changed, and then expect the userspace to read the values from 
> the accelerometer?
> IMHO, reporting an event with no context data, it's inefficient and ugly 
> (because it forces the userspace to perform additional acctions in order to get 
> the data).

You'll always need to have something in user-space reading the data from
your device, somehow, kernel events don't carry any data, it just says
"foo has changed". Up to the udev rules, and user-space to check up on
it.

> > If there isn't a discrete accelerometer, create a fake one, with some
> > hardcoded data based on the actual orientation of the device.
> 
> This could be a solution in both cases (i.e., even if a discrete accelerometer 
> is available). But it would be nice to have some flags on the input device which 
> tell that this accelerometer is not as precise as one could desire. Is there 
> such a thing?
> 
> > The accelerometer (whether real or fake) should show 3 axis (X/Y/Z).
> >
> > As soon as it's seen some testing, I'll be showing the work I did for
> > GNOME support for automatic rotation based on orientation.
> 
> Do you support choosing the accelerometer device to be used?

Nope. There's usually none, or just the one (and its children).

> The device that I wanted to create is actually something much simpler than an 
> accelerometer; it would just report screen orientation. I believe that some 
> computer screens might have something similar, detecting the screen orientation 
> based on the angle formed between the screen base (or wall mount) and the screen 
> panel... I would assume that if such information exists, this Lenovo Ideapad 
> screen orientation should be reported in a similar way.

Comparing it to the orientation mechanism used in some screens is a
great disservice here. There's no agreed-upon way of receiving events
about it, or how to read the current orientation. It's currently all
per-vendor undocumented gunk (topic came up recently on IRC, and the X
hackers skimmed through the interwebs to find information, there's
none).

This is the latest work I've done[1]:
http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;h=24569e24dc94a7cffb8031eb0055e8d06cbdcb72

So to support the IdeaPad, I would:
- make it export the orientation of the device in sysfs (kernel-side)
- add a rule in udev to tag that particular device with
ID_INPUT_ACCELEROMETER=1
- add a simple helper (or tweak the accelerometer one in udev) to export
the current orientation through ID_INPUT_ACCELEROMETER_ORIENTATION
- Profit

The only thing I might need to change in gnome-settings-daemon (which
just listens for events, reads the orientation, and changes the XRandR
orientation) is the subsystem used, if your device isn't in the input
subsystem.

The GNOME code lives at:
http://git.gnome.org/browse/gnome-settings-daemon/tree/plugins/orientation

Cheers

[1]: The commit message is missing, here it is:
---8<---
When an "change" event is received on an accelerometer,
open its device node, and from the value, as well as the previous
value of the property, calculate the device's new orientation,
and export it as ID_INPUT_ACCELEROMETER_ORIENTATION.
    
Possible values are:
* undefined
* normal
* bottom-up
* left-up
* right-up
    
Using a udev property means that the property is persistent across
sessions, and that new orientations can be deducted from the previous
one (it allows for a threshold for switching between opposite ends
of the orientation).
    
This system should also be extensible to devices where the accelerometer
is not available to the system (no drivers), but new orientations are
advertised through ACPI events.
---8<---


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reporting screen/laptop orientation data to userspace
  2011-06-04 17:13   ` Mohamed Ikbel Boulabiar
@ 2011-06-06 17:53     ` Bastien Nocera
  0 siblings, 0 replies; 10+ messages in thread
From: Bastien Nocera @ 2011-06-06 17:53 UTC (permalink / raw)
  To: Mohamed Ikbel Boulabiar
  Cc: Alberto Mardegan, linux-kernel, Javier S. Pedro, linux-input

On Sat, 2011-06-04 at 19:13 +0200, Mohamed Ikbel Boulabiar wrote:
> On Fri, Jun 3, 2011 at 5:55 PM, Bastien Nocera <hadess@hadess.net> wrote:
> >
> > As soon as it's seen some testing, I'll be showing the work I did for
> > GNOME support for automatic rotation based on orientation.
> 
> And how you handle these events through X ?

As I mentioned to Alberto, and following on from the upstream push to
udev, the only thing the code does is look for uevents coming from
ID_INPUT_ACCELEROMETER=1 devices, and read the value of
ID_INPUT_ACCELEROMETER_ORIENTATION.

Certainly much easier than my previous attempts at using X to read the
values from a floating device.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reporting screen/laptop orientation data to userspace
  2011-06-06 17:50     ` Bastien Nocera
@ 2011-06-06 18:41       ` Alan Cox
  2011-06-20 14:53         ` Bastien Nocera
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Cox @ 2011-06-06 18:41 UTC (permalink / raw)
  To: Bastien Nocera
  Cc: Alberto Mardegan, linux-kernel, Javier S. Pedro, linux-input

> When an "change" event is received on an accelerometer,
> open its device node, and from the value, as well as the previous
> value of the property, calculate the device's new orientation,
> and export it as ID_INPUT_ACCELEROMETER_ORIENTATION.
>     
> Possible values are:
> * undefined
> * normal
> * bottom-up
> * left-up
> * right-up

For quite a few of the discrete accelerometers not being used in
'joystick' mode this would make quite a sensible input interface,
at least for those that generate inputs for their transitions.

You need a couple more values though because some devices care if they
are held up/down/left/right or if they are lying flat on their front or
on their back.

Phones for example sometimes go to speakerphone if laid flat on their
back, and go into silent mode if turned over.

Alan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Reporting screen/laptop orientation data to userspace
  2011-06-06 18:41       ` Alan Cox
@ 2011-06-20 14:53         ` Bastien Nocera
  0 siblings, 0 replies; 10+ messages in thread
From: Bastien Nocera @ 2011-06-20 14:53 UTC (permalink / raw)
  To: Alan Cox; +Cc: Alberto Mardegan, linux-kernel, Javier S. Pedro, linux-input

On Mon, 2011-06-06 at 19:41 +0100, Alan Cox wrote:
> > When an "change" event is received on an accelerometer,
> > open its device node, and from the value, as well as the previous
> > value of the property, calculate the device's new orientation,
> > and export it as ID_INPUT_ACCELEROMETER_ORIENTATION.
> >     
> > Possible values are:
> > * undefined
> > * normal
> > * bottom-up
> > * left-up
> > * right-up
> 
> For quite a few of the discrete accelerometers not being used in
> 'joystick' mode this would make quite a sensible input interface,
> at least for those that generate inputs for their transitions.
> 
> You need a couple more values though because some devices care if they
> are held up/down/left/right or if they are lying flat on their front or
> on their back.
> 
> Phones for example sometimes go to speakerphone if laid flat on their
> back, and go into silent mode if turned over.

I'm not designing for phones though, and it seems to me this should be a
separate attribute anyway (and so did the people who wrote sensorfw for
MeeGo Handset).


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-06-20 14:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-29  7:49 Reporting screen/laptop orientation data to userspace Alberto Mardegan
2011-06-02 22:19 ` Pavel Machek
2011-06-03 15:55 ` Bastien Nocera
2011-06-04 17:13   ` Mohamed Ikbel Boulabiar
2011-06-06 17:53     ` Bastien Nocera
2011-06-06  6:53   ` Alberto Mardegan
2011-06-06  8:42     ` Jonathan Cameron
2011-06-06 17:50     ` Bastien Nocera
2011-06-06 18:41       ` Alan Cox
2011-06-20 14:53         ` Bastien Nocera

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).