linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: linux-input <linux-input@vger.kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Eric Piel <eric.piel@tremplin-utc.net>,
	linux-iio <linux-iio@vger.kernel.org>,
	kernel@pyra-handheld.com, lkml <linux-kernel@vger.kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Discussions about the Letux Kernel 
	<letux-kernel@openphoenux.org>
Subject: Re: [Letux-kernel] [RFC v2] iio: input-bridge: optionally bridge iio acceleometers to create a /dev/input interface
Date: Sat, 11 May 2019 12:05:36 +0100	[thread overview]
Message-ID: <20190511120536.647c8676@archlinux> (raw)
In-Reply-To: <D4F87479-4FF7-4DBC-81D5-1BA836D2C889@goldelico.com>

On Thu, 9 May 2019 19:02:49 +0200
"H. Nikolaus Schaller" <hns@goldelico.com> wrote:

> > Am 09.05.2019 um 11:09 schrieb H. Nikolaus Schaller <hns@goldelico.com>:
> > 
> > Hi Jonathan,  
> >> 
> >> 
> >> And how does that work on the common case of a sensor in the lid of a laptop?
> >> how do you know what angle the screen is at?    
> > 
> > Well, I am not aware of laptops where the sensor is in the lid because I am in the handhelds
> > business, but let's assume it is common.
> > 
> > I realized that if the sensor orientation is related to the lid position, while the reference
> > frame reported to user space is to be referenced to the lap or keyboard of the laptop, there does
> > not exist a static mount-matrix to describe it properly. So no driver can report that correctly.
> > 
> > Therefore, such a device needs a dynamic mount matrix, i.e. there should be a kernel driver that
> > reads out the lid angle sensor and modifies the mount-matrix of the accelerometer by some sin()/cos()
> > table.  
> 
> One more thought on this topic.
> 
> My answer to the question "how do you know what angle the screen is at?" by requiring an ADC to
> measure some potentiometer in the hinge to make the mount matrix dynamic is probably completely
> wrong...

There are lid angle sensors out independent of this discussion that might work
as you describe but so far they are rare.  There is one under review for
cros_ec for example - how it is implemented, no idea!

> 
> If we take the definition for the mount matrix, it defines a specific g-vector pointing to
> center of earth if the user is holding the device in a specific position and looking on the display
> or the keyboard.
> 
> So far the description assumes that there is a single accelerometer and display and keys of a phone
> are in a single plane, i.e. there is no angle and everything is fine.
> 
> Now if we simply take the two accelerometers separately, one z-axis is going through the keyboard
> and the other through the display. Which means if the mount matrices are well defined, the accelerometers
> should report almost the same values if the display is fully opened by 180 degrees, i.e. the display
> is sitting flat on the table. This is what my RFC does by autoscaling. The values differ only
> by noise.
> 
> Now what about measuring the lid angle? Well, it is already measured by both accelerometers! If they
> do not agree, the angle can be calculated by some arctan() based on y and z axis reports...
Agreed. This is how it is done.
> 
> If you close the lid, the display is turned upside down and y and z axes reverse sign.
> 
> So there remains only the issue that user-space must know which sensor device file is which sensor
> and can do the calculation of the lid angle. This is possible because the iio accelerometer name
> is available through the input event ioctls.
> 
> In summary this case also does not need policy or configuration. Just user space using the information
> that is already presented.

I disagree with that last statement.  If there is a lid angle sensor, policy is
needed to know which of your associated orientation is the base one and which
device indicates the lid angle.

Actually most of the time what you will do is pick one 'correct' sensor under
some configuration of the device and use that.  That is policy.  Yes, you could
bake the policy in to device tree, but then you can also bake in the association
between the underlying IIO sensor and any virtual input sensor.

Anyhow, we still disagree on whether any such virtual input interface
should be a userspace policy decision.  So far I haven't seen any compelling
argument why it shouldn't be and the flexibility such a policy based interface
provides is its major advantage.

Thanks,

Jonathan

  reply	other threads:[~2019-05-11 11:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-31 10:09 [RFC v2] iio: input-bridge: optionally bridge iio acceleometers to create a /dev/input interface H. Nikolaus Schaller
2019-04-07 12:30 ` Jonathan Cameron
     [not found]   ` <CD44AFA0-6676-4842-9C80-61BB363DD556@goldelico.com>
2019-04-14 11:40     ` Jonathan Cameron
2019-04-14 16:26       ` Roderick Colenbrander
2019-05-10  8:57         ` Bastien Nocera
2019-05-11 18:47           ` Roderick Colenbrander
     [not found]       ` <CD6219BE-61FF-4C38-9532-054C60A77F89@goldelico.com>
2019-04-22 14:20         ` Jonathan Cameron
2019-05-09  9:09           ` H. Nikolaus Schaller
2019-05-09 17:02             ` [Letux-kernel] " H. Nikolaus Schaller
2019-05-11 11:05               ` Jonathan Cameron [this message]
     [not found]                 ` <CCD87A8D-FF65-4681-964B-22870716D655@goldelico.com>
2019-06-08 10:52                   ` Jonathan Cameron
2019-05-11 10:54             ` Jonathan Cameron
2019-05-10  8:57           ` Bastien Nocera
2019-05-10  9:33             ` H. Nikolaus Schaller
2019-05-10  9:35               ` Bastien Nocera
2019-05-10 10:06                 ` H. Nikolaus Schaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190511120536.647c8676@archlinux \
    --to=jic23@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=eric.piel@tremplin-utc.net \
    --cc=hns@goldelico.com \
    --cc=kernel@pyra-handheld.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=letux-kernel@openphoenux.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).