From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C918ECCD1A5 for ; Wed, 18 Sep 2024 13:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YY5fjMhugvxOtRn3XdK4oMNzOo7yd5YBOQwW46C1SFU=; b=kCm/sQgvld2uuYqMBsPrj73VxL Tv66RNGnzpPlc4r58cuziBEJQ+mcgNSHpT20rhuoU53Q4puYKs5teGLRzfGU+aaFHaZYHx0G+jEW1 e4NBtFNgdLr4da5wyIsTCmwfy4KXz6VzzdLSM+Dffg0fd7YKs3gMR6vx48B+/SLSQYu+IlnhCpD0o IMdbLoBUm1luCe8eYX5/jXeaDc+q4bUUVgaFzQIPj1oc6n0YUGYBv2nUrWrbxNlN5hRvtLyB9mtHY drAWa/fgqJpWdwiL8J8nfttEr5dE6meEJi2WCqngjctO6QJcLvYb4EKanBGYEAl37orGaBZvKsFgW b/GNZQuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1squxR-00000008MLU-0pQ4; Wed, 18 Sep 2024 13:43:01 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1squwK-00000008MB9-2p1e for linux-arm-kernel@lists.infradead.org; Wed, 18 Sep 2024 13:41:54 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5356aa9a0afso8427848e87.2 for ; Wed, 18 Sep 2024 06:41:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726666911; x=1727271711; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=YY5fjMhugvxOtRn3XdK4oMNzOo7yd5YBOQwW46C1SFU=; b=S++ijmVOGjTVVULO8J6qXChCduMOjEaTuUPeyObzWKkqrrA5NSZD/nVCBvgsxzdnWm +VRxEXwti1gvlieGUmVNh7BWuTqS3COCoNc/xDdNrBaB7OzmPxG0xlvQ2BBbsMlv2tri WwcEkp7+meGi3Hk6Ygv3gwAAdkqcWROdWexI7UYHYgTfD3qPB6e3dhURpK0Ky+nrWSmE shIljjS8ki77BqbCOr9x9fDOuxdXeOlWsyMnO3jip5HQR7XXuioQt+NH3RrEdA/Nk0g7 piQg/qrXMqsJmZ9QNTc8CaMWZsO48Y7yCE3JHIR7qm+UJAn0cYS2GEiDV4A70vYtBMUl XDnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726666911; x=1727271711; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YY5fjMhugvxOtRn3XdK4oMNzOo7yd5YBOQwW46C1SFU=; b=W6QVCI0mvL17R/+WzAuI6Q35rhj727RMBFXRLnrZZ3L/SnQoNQvsyI5t2bVJk+7KTw ve+jeB0GuhLJHP4mbp+NrzheJFN4AdQ49djNyc9U+/xvdxVTHXsMes2SJchwaEIlOe+M 4ChSWEPq7hSAMOxqZd/480T2Cf60mfXYBLpTgVQx43DBeCWazYNh1dzDfHdTiXiNBJQM XWUUY+NAfC6KT+GaH0p8+Z2qCirFGkpf4+SYOfdlcN1lo90k++NQFnQ9dsXbbUTunnq2 l8PrE0/2L68trl0t0YT6Lc1N6Yb+LA+6qqUIlrMI89sfZEWH0UsQd0UpaUgpfIGsBQjb EOEA== X-Forwarded-Encrypted: i=1; AJvYcCVKbGcXf47s9XoH+lclR4aZf1CPmq6wkptk8Jyx4VTpS+LGDZ5xetsfLdsM8gkXbYq06rXAnP2WaBKH1MS1QGgR@lists.infradead.org X-Gm-Message-State: AOJu0YxFn7NnohxcG1Xux+pvYAA49kKEqq0LxYUgUmlBFzess+4nQITe ofx3dy//4mcjnbYzmuHbTTa4zSDMhF5/3q2zRwo5Gf9M46Bq8Ktx X-Google-Smtp-Source: AGHT+IGJPlDhWmbSrgnN5jY/pQxEpLZg/M92xSm/3MhX8NPG55UAA6a1JTCbvH8r3kBfigS6vtTIew== X-Received: by 2002:a05:6512:32c7:b0:533:4620:ebec with SMTP id 2adb3069b0e04-5367feb9639mr15152534e87.3.1726666910279; Wed, 18 Sep 2024 06:41:50 -0700 (PDT) Received: from localhost ([94.19.228.143]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-536870bb955sm1514485e87.301.2024.09.18.06.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2024 06:41:49 -0700 (PDT) Date: Wed, 18 Sep 2024 16:41:49 +0300 From: Andrey Skvortsov To: Dragan Simic Cc: Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?utf-8?Q?Ond=C5=99ej?= Jirman Subject: Re: [PATCH] arm64: dts: sun50i-a64-pinephone: Add mount matrix for accelerometer Message-ID: Mail-Followup-To: Andrey Skvortsov , Dragan Simic , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?utf-8?Q?Ond=C5=99ej?= Jirman References: <20240916204521.2033218-1-andrej.skvortzov@gmail.com> <6e5d0e9978bff30559c17f30d1495b59@manjaro.org> <8df5fc79a3e899738aa944a290774c72@manjaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8df5fc79a3e899738aa944a290774c72@manjaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240918_064152_737660_BE4EB0EA X-CRM114-Status: GOOD ( 31.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 24-09-18 13:27, Dragan Simic wrote: > > > > > > After going through the InvenSense MPU-6050 datasheet, [1] the > > > MPU-6050 evaluation board user guide, the PinePhone schematic, > > > the PinePhone mainboard component placement, [2] and the kernel > > > bindings documentation for mount-matrix, [3] I can conslude that > > > only the direction of the accelerometer's y-axis is inverted, > > > while the direction of the z-axis remain unchanged, according > > > to the right-hand rule. > > > > yes, it looks so on the first glance, but in MPU-6050 datasheet there > > is also following information: > > > > 7.8 Three-Axis MEMS Accelerometer with 16-bit ADCs and Signal > > Conditioning > > > > When the device is placed on a flat surface, it will measure > > 0g on the X- and Y-axes and +1g on the Z-axis. I'll try to explain how I read sensor's documentation and what bothers me. Picture 1. up ^ Z ! ! X=Y=0 ++++++++++ ! ! +--------+ ! ! v gravity down Screen (drawn as ++++++++++) is looking upwards. Device is on the flat surface. Sensor returns +1g, although gravity points into *apposite* direction. Experiment: When I put PinePhone like in the sensor's documentation with the screen upwards (Picture 1), gravity and Z axis point into different directions, I read positive values from the sensor. So sensor works as it's described in the documentation. > > > > So sensors reports positive acceleration values for Z-axis, when > > the gravity points to Z-minus. I see the same on device. positive > > values are returned, when screen and IC point upwards (not the center > > for gravity). > > In device tree mount-matrix documentation [3] there is > > > > users would likely expect a value of 9.81 m/s^2 upwards along the (z) > > axis, i.e. out of the screen when the device is held with its screen > > flat on the planets surface. > > how I read kernel documentation. Picture 2. up +--------+ ! ! ++++++++++ ! ! v gravity, Z down Screen (drawn as ++++++++++) is looking downwards ("its screen flat on the planets surface"). Gravity and Z axis point into the same direction and it's expected to read positive value. Notice, that Z-axis on Picture 1 and Picture 2 point into different directions to get positive values. Experiment: Now, I go to the real device and check how the sensor actually works. When I put PinePhone like is described in the kernel documentation with the screen downwards, "screen flat on the planets surface" (Picture 2), gravity and Z axis point into the same direction, but I read negative values from the sensor. So the sensor works not as expected by kernel documentation, when I understand documentation correctly. Z-axis inversion comes from this. > > According to that, it looks like Z-axis here has to be inverted. > > Yes, reporting +1 g on the z-axis with the device remaining stationary > on a level surface is the normal behavior, and the returned positive > value actually goes along with the quoted description from the kernel > documentation. The z-axis of the MPU-6050 goes upward and out of the > screen, the way the MPU-6050 is placed inside the PinePhone. > > It applies to other axes as well. And because of that I came from > > (only Y-axis is inverted) > > > > x' = -y > > y' = x > > z' = z > > > > to inverted solution (Y-axis is kept, but X and Z are inverted). > > > > x' = y > > y' = -x > > z' = -z > > > > probably should put this information into commit description. > > Wouldn't inverting the direction of the z-axis go against the > above-quoted description from the kernel documentation? See my comments above. > > > [1] https://rimgo.reallyaweso.me/vrBXQPq.png > > > [2] https://rimgo.reallyaweso.me/uTmT1pr.png > > > [3] https://www.kernel.org/doc/Documentation/devicetree/bindings/iio/mount-matrix.txt -- Best regards, Andrey Skvortsov