Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3112922yba; Sat, 11 May 2019 04:08:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/YKxJXFb9ngJifyId4PtkvYqnYW/8BBz++t49DmMkiHo+z04QL8iGHf9weYBO5LZGWIqi X-Received: by 2002:a17:902:7084:: with SMTP id z4mr19329777plk.259.1557572887842; Sat, 11 May 2019 04:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557572887; cv=none; d=google.com; s=arc-20160816; b=EDKaG90BLVWtIhyDQoV887s2xFcUwCkrEyJOt7tvqiYxAqxCQ+1ot+DVOj25Opk39c KsTJrZCC6KsU7eNI/sElxIdIzftFFFcUZDLIisNoPp0BQVs5IuDq72uhypySrR1aYdPB 6wbJmAszBP9OIImib/LEhSg55Kb8srdMbKYGXIZjJ+/Gju/zQlbMKvwGwJvPmUBHRf0W qnnfF3CYNZmHE3OmSmhs06YFgq45nioMDxbVn+Jns8VZ5zeoicemWxaD4wnmnBtem9Pc cnoEZ95B0gIietIvmdY5wHCsg/BxIRMGNQGWtFegZFgrV8Bb5jkA90NBU2DfIn9O4G0a /HPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=L8JKQNFWdqbfb3bHTMu8ox6PKDucgZM31iPMVMsDO9E=; b=v8V2Wr6mDW5f9rGaPUp6lstrKiMiXjfeA78YkrLeuQ2a5nI6cyUGQgVXo+QsmiXwJr Bpuj0WqZUCqvuP6zHSXJPuJPRfJiBNNogYsClx8LHtqulUeojPCs/ub82b9bCG7VxQPs 6Qy0QDjA5xF1eVn98e6uRo4JSzkw+KEB6J1XwLkiuC7zU3ASLCzTvqe77ysbveTYnEii 8uL2FVqEqOVdX5I1jB5lDInjn+VXsmuzTcHp/CKN4Udh9/sF8YBOYSZ2lTi1LFUue933 L2K+69m3rohZYgAEeCAt85cnwVTSVoqGdTZk6L9ml9gMJodcS9FUA615qYB/ChB+qWek EQ2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xKbDZt6G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si11390833pgo.168.2019.05.11.04.07.51; Sat, 11 May 2019 04:08:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xKbDZt6G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728544AbfEKLFn (ORCPT + 99 others); Sat, 11 May 2019 07:05:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:54330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726240AbfEKLFn (ORCPT ); Sat, 11 May 2019 07:05:43 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B9CEA217F9; Sat, 11 May 2019 11:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557572741; bh=OP5PzMKNdv7eZTclz6nMXr+GPXx4HBbNzjUZYRYUa/U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=xKbDZt6GAyBICk/pLUZM4FgM6vLQ8lH5jT1N5OdVcsZXE84mIFZVF+4Y/jkngLSQX 6NQeV8XCW6snF6a6WMTDHT+qjSBW/3PNaUz+yp8Fhhs9wt12SmRlx6kNLL2C5C51ix a9MkDcGf+JfuUrBOIgkq3n2wgIt1fHkRLc1v7rNY= Date: Sat, 11 May 2019 12:05:36 +0100 From: Jonathan Cameron To: "H. Nikolaus Schaller" Cc: linux-input , Dmitry Torokhov , Eric Piel , linux-iio , kernel@pyra-handheld.com, lkml , Lars-Peter Clausen , Peter Meerwald-Stadler , Hartmut Knaack , Discussions about the Letux Kernel Subject: Re: [Letux-kernel] [RFC v2] iio: input-bridge: optionally bridge iio acceleometers to create a /dev/input interface Message-ID: <20190511120536.647c8676@archlinux> In-Reply-To: References: <195994ebff28de22eae872df134d086c761b83b8.1554026986.git.hns@goldelico.com> <20190407133037.0ad98897@archlinux> <20190414124029.1f1f6084@archlinux> <20190422152014.7c6637ab@archlinux> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 9 May 2019 19:02:49 +0200 "H. Nikolaus Schaller" wrote: > > Am 09.05.2019 um 11:09 schrieb H. Nikolaus Schaller : > > > > 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