From patchwork Wed Sep 9 07:38:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 9546 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 5BC1DBDB1C for ; Wed, 9 Sep 2020 07:38:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DDD1C62C30; Wed, 9 Sep 2020 09:38:48 +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="EVk7ORoH"; 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 B45B4603ED for ; Wed, 9 Sep 2020 09:38:46 +0200 (CEST) From: Umang Jain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=uajain.com; s=mail; t=1599637125; bh=miYIMDtRDfzDxoBql3h+SttZ8edwZs//iIdwrmg7Ruk=; h=From:To:Cc:Subject; b=EVk7ORoHpty0VnmoxTqtYMMjh0BZaaErzRgjMMtkoa9PBF+y8JHEz6VDziJLklX6m E9johdsTQf1BCbSS0WcrFshhNqUuJLY6gIcqwfNQMH/MqJvR6pUNT1/dp/B64A3TLn ACMmaglaf7aszpNTbPummre7u2/1xW8wRuuWnPog99uWzlgoVGG0K9Kku6gh268wkv 02IcjPBX+Y64vUzNJzcx6jNyXHcPnsj4RyZ2fXVVhgeYVyOYYn6Aewe4/dW8pC1zbg 4eKzScizBhxyS7xOadpwT+jAgNuz7GPvGkwVaSOWXaEi+Pc4LpuC09sE9PfgSjDzqy 0aQVasqUNG5Dg== To: libcamera-devel@lists.libcamera.org Date: Wed, 9 Sep 2020 13:08:33 +0530 Message-Id: <20200909073833.16465-1-email@uajain.com> Mime-Version: 1.0 Subject: [libcamera-devel] [PATCH] 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 anti-clockwise 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 --- 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..35aa6c4 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 anti-clockwise direction. Read the libcamera's + * rotation property(anti-clockwise) 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 libcameraRotation = properties.get(properties::Rotation); + orientation_ = (360 - libcameraRotation) % 360; + } int ret = camera_->acquire(); if (ret) {