From patchwork Thu Aug 6 16:36:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 9266 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 76C6ABD86F for ; Thu, 6 Aug 2020 16:36:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F11460DF1; Thu, 6 Aug 2020 18:36:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="KSDU7Hyx"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 76E0560392 for ; Thu, 6 Aug 2020 18:36:52 +0200 (CEST) Received: by mail-wr1-x42d.google.com with SMTP id a14so44655794wra.5 for ; Thu, 06 Aug 2020 09:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=defdvotbVHVlh1WFgVd8CY4nNYsHR1HxniuD+N+F9aI=; b=KSDU7HyxdOuGD+qeutuGl7HW/nPtrA/TmIMZqNACkfCpsVcojWGkDNEpgCxPlLBsiK 2bJER2DVqoe/JGDuPTCcnSOtPIGSzYnRpwjfDYDX65mZPx7aT4JJD78sXmaeo/8ufywB z/ng4CgkdOd/00epR8p6B9ddJti8DJzQCj5t+nIrcRXZqlcjKtI+xjDtkD1wugDSBGTs FJVKr0bo07e7nSZA25YLPZPZtIO4ejEZooqYTj6vPV/oi16jJ/BfugpCkDNQNFp1Azx5 zQVifpDrKrmRjx1+PY90DKMlj7OaHfpnMu9bvnRW3DlK19L6Agc4WrdZupnGCrOh9sW+ wwqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=defdvotbVHVlh1WFgVd8CY4nNYsHR1HxniuD+N+F9aI=; b=tQVjBufHo4kcdP2KEr9sOv6CpYg5Cb2ASREumez4RSwgEZPmY/sWIKorIPL6PvY3ud FlBQYnUNzuUz/wk+4Gu2WmkmfPkze+hQLIJLPG7ECyoWwdy3bZf2I0oCI1WkxzMYMw+4 s9pAjORX9OEiKokuIk9jCdWtQI9+1XZFSRMVoBd02S6NTn0dhyWHFsMKsCBXTe4jT1JQ 03v1S6pWC0QtdciaPfsmFVIpCujBfOuEu6dm8m80ARgd7TPoPCd7JkY+EB65O4c8/pcJ uxftAYDL+NjqKYrEgIMgZYaDgLZVJMSqJ1WgFIlk1/in68OJ46yGWkAIYrSywcOCHccA ltPg== X-Gm-Message-State: AOAM533MUVP3AvIO09DmJeeOvRIEVSQwg6jJn6PR+wwwVxkRL7EUy1Zw YcIXDrf60Hke0LcLqrAWiknFMKjceDmR7Q== X-Google-Smtp-Source: ABdhPJyaTpJj38JYqGtoFqxCaq/9+ePcTbVCxu4tBIGmBX+W3t6WhukFO0ysWYCPVz6iVkN1QRrqnw== X-Received: by 2002:adf:ed0c:: with SMTP id a12mr8067486wro.24.1596731811722; Thu, 06 Aug 2020 09:36:51 -0700 (PDT) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id e5sm7405076wrc.37.2020.08.06.09.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 09:36:50 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 6 Aug 2020 17:36:37 +0100 Message-Id: <20200806163639.12971-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200806163639.12971-1-david.plowman@raspberrypi.com> References: <20200806163639.12971-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/5] libcamera: raspberrypi: Set camera flips correctly from user transform 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" The Raspberry Pi pipeline handler allows all transforms except those involving a transpose. The user transform is combined with any inherent rotation of the camera, and the camera's H and V flip bits are set accordingly. --- .../pipeline/raspberrypi/raspberrypi.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 236aa5c..9d183e3 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -324,6 +324,8 @@ public: uint32_t expectedSequence_; bool sensorMetadata_; + Transform transform_; + /* * All the functions in this class are called from a single calling * thread. So, we do not need to have any mutex to protect access to any @@ -400,8 +402,9 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() if (config_.empty()) return Invalid; - if (transform != Transform::Identity) { - transform = Transform::Identity; + /* We cannot do Transforms with a transpose in them. */ + if (!!(transform & Transform::Transpose)) { + transform = transform ^ Transform::Transpose; status = Adjusted; } @@ -610,6 +613,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) for (auto const stream : data->streams_) stream->reset(); + /* We will want to know the transform requested by the application. */ + data->transform_ = config->transform; + Size maxSize, sensorSize; unsigned int maxIndex = 0; bool rawStream = false; @@ -1174,8 +1180,14 @@ int RPiCameraData::configureIPA() /* Configure the H/V flip controls based on the sensor rotation. */ ControlList ctrls(unicam_[Unicam::Image].dev()->controls()); int32_t rotation = sensor_->properties().get(properties::Rotation); - ctrls.set(V4L2_CID_HFLIP, static_cast(!!rotation)); - ctrls.set(V4L2_CID_VFLIP, static_cast(!!rotation)); + bool success; + Transform combined = transform_ * transformFromRotation(rotation, &success); + if (!success) { + LOG(RPI, Error) << "Invalid rotation: " << rotation; + return -EINVAL; + } + ctrls.set(V4L2_CID_HFLIP, static_cast(!!(combined & Transform::HFlip))); + ctrls.set(V4L2_CID_VFLIP, static_cast(!!(combined & Transform::VFlip))); unicam_[Unicam::Image].dev()->setControls(&ctrls); }