From patchwork Wed Sep 9 10:47:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 9547 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id F306FBDB1C for ; Wed, 9 Sep 2020 10:48:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A70E62CBA; Wed, 9 Sep 2020 12:48:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=uajain.com header.i=@uajain.com header.b="mlXNszYT"; dkim-atps=neutral Received: from mail.uajain.com (static.126.159.217.95.clients.your-server.de [95.217.159.126]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0425D60534 for ; Wed, 9 Sep 2020 12:48:00 +0200 (CEST) From: Umang Jain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail; t=1599648479; bh=ibukZ4NBXyyovdTmeSSkYu/Z+mtD81B6T+QAlnTqTZw=; h=From:To:Cc:Subject; b=mlXNszYTid1i3Wq3sI7cwzpLkRvvbcBwIT3NfKeffg+PR7pu2ZMWQ7ZKwIbuAu12t OIKasVVXOwSifBU9na3OVb3olsTIHSfryVs5UjNIm5pGrBbK6oUDt82MbKnYILvjMV BUXgdJD9T8WwmsynDfeTItkeiNS/5GRr7nJqQy01c0RlKzw/eUojJ6QQSIFQnXtnWO 1q9z0l8Re4i3L4QojmOtu3w6RqM/+I128gc7jvTPlvSO2WSIlusGEUTrnlDpolMwLB HCbVkY3qHZSI73NaoDjVHR5tM/h06oCyEW3LGhzH1+B1gXe9eOHNwELBZ3y+2Rh+Sr mtArydfeMvULg== To: libcamera-devel@lists.libcamera.org Date: Wed, 9 Sep 2020 16:17:54 +0530 Message-Id: <20200909104754.25940-1-email@uajain.com> Mime-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] android: camera_device: Fix value of orientation metadata X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Android's orientation metadata cannot have identical numerical value to libcamera's rotation property. This is due to the fact that libcamera's rotation property specify the correction angle in anticlockwise direction whereas Android's orientation metadata specifies the value in clockwise direction. Fix that by computing corresponding value for clockwise direction from libcamera's rotation property. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 2582991..8be846b 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -265,12 +265,17 @@ int CameraDevice::initialize() } /* - * The Android orientation metadata and libcamera rotation property are - * defined differently but have identical numerical values for Android - * devices such as phones and tablets. + * The Android orientation metadata specifies its rotation correction + * value in clockwise direction whereas libcamera specifies the + * rotation property in anticlockwise direction. Read the libcamera's + * rotation property (anticlockwise) and compute the corresponding + * value for clockwise direction as required by the Android orientation + * metadata. */ - if (properties.contains(properties::Rotation)) - orientation_ = properties.get(properties::Rotation); + if (properties.contains(properties::Rotation)) { + int rotation = properties.get(properties::Rotation); + orientation_ = (360 - rotation) % 360; + } int ret = camera_->acquire(); if (ret) {