{"id":9266,"url":"https://patchwork.libcamera.org/api/patches/9266/?format=json","web_url":"https://patchwork.libcamera.org/patch/9266/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200806163639.12971-4-david.plowman@raspberrypi.com>","date":"2020-08-06T16:36:37","name":"[libcamera-devel,v2,3/5] libcamera: raspberrypi: Set camera flips correctly from user transform","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b33ad18be95dcd5c025cc1fa5c5eb6f00b26abbd","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9266/mbox/","series":[{"id":1208,"url":"https://patchwork.libcamera.org/api/series/1208/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1208","date":"2020-08-06T16:36:34","name":"Transform implementation","version":2,"mbox":"https://patchwork.libcamera.org/series/1208/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9266/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9266/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 76C6ABD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  6 Aug 2020 16:36:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3F11460DF1;\n\tThu,  6 Aug 2020 18:36:54 +0200 (CEST)","from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n\t[IPv6:2a00:1450:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 76E0560392\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Aug 2020 18:36:52 +0200 (CEST)","by mail-wr1-x42d.google.com with SMTP id a14so44655794wra.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 06 Aug 2020 09:36:52 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\te5sm7405076wrc.37.2020.08.06.09.36.50\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 06 Aug 2020 09:36:50 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"KSDU7Hyx\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=defdvotbVHVlh1WFgVd8CY4nNYsHR1HxniuD+N+F9aI=;\n\tb=KSDU7HyxdOuGD+qeutuGl7HW/nPtrA/TmIMZqNACkfCpsVcojWGkDNEpgCxPlLBsiK\n\t2bJER2DVqoe/JGDuPTCcnSOtPIGSzYnRpwjfDYDX65mZPx7aT4JJD78sXmaeo/8ufywB\n\tz/ng4CgkdOd/00epR8p6B9ddJti8DJzQCj5t+nIrcRXZqlcjKtI+xjDtkD1wugDSBGTs\n\tFJVKr0bo07e7nSZA25YLPZPZtIO4ejEZooqYTj6vPV/oi16jJ/BfugpCkDNQNFp1Azx5\n\tzQVifpDrKrmRjx1+PY90DKMlj7OaHfpnMu9bvnRW3DlK19L6Agc4WrdZupnGCrOh9sW+\n\twwqA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=defdvotbVHVlh1WFgVd8CY4nNYsHR1HxniuD+N+F9aI=;\n\tb=tQVjBufHo4kcdP2KEr9sOv6CpYg5Cb2ASREumez4RSwgEZPmY/sWIKorIPL6PvY3ud\n\tFlBQYnUNzuUz/wk+4Gu2WmkmfPkze+hQLIJLPG7ECyoWwdy3bZf2I0oCI1WkxzMYMw+4\n\ts9pAjORX9OEiKokuIk9jCdWtQI9+1XZFSRMVoBd02S6NTn0dhyWHFsMKsCBXTe4jT1JQ\n\t03v1S6pWC0QtdciaPfsmFVIpCujBfOuEu6dm8m80ARgd7TPoPCd7JkY+EB65O4c8/pcJ\n\tuxftAYDL+NjqKYrEgIMgZYaDgLZVJMSqJ1WgFIlk1/in68OJ46yGWkAIYrSywcOCHccA\n\tltPg==","X-Gm-Message-State":"AOAM533MUVP3AvIO09DmJeeOvRIEVSQwg6jJn6PR+wwwVxkRL7EUy1Zw\n\tYcIXDrf60Hke0LcLqrAWiknFMKjceDmR7Q==","X-Google-Smtp-Source":"ABdhPJyaTpJj38JYqGtoFqxCaq/9+ePcTbVCxu4tBIGmBX+W3t6WhukFO0ysWYCPVz6iVkN1QRrqnw==","X-Received":"by 2002:adf:ed0c:: with SMTP id a12mr8067486wro.24.1596731811722;\n\tThu, 06 Aug 2020 09:36:51 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","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\n\tflips correctly from user transform","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The Raspberry Pi pipeline handler allows all transforms except those\ninvolving a transpose. The user transform is combined with any\ninherent rotation of the camera, and the camera's H and V flip bits\nare set accordingly.\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 20 +++++++++++++++----\n 1 file changed, 16 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 236aa5c..9d183e3 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -324,6 +324,8 @@ public:\n \tuint32_t expectedSequence_;\n \tbool sensorMetadata_;\n \n+\tTransform transform_;\n+\n \t/*\n \t * All the functions in this class are called from a single calling\n \t * thread. So, we do not need to have any mutex to protect access to any\n@@ -400,8 +402,9 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \tif (config_.empty())\n \t\treturn Invalid;\n \n-\tif (transform != Transform::Identity) {\n-\t\ttransform = Transform::Identity;\n+\t/* We cannot do Transforms with a transpose in them. */\n+\tif (!!(transform & Transform::Transpose)) {\n+\t\ttransform = transform ^ Transform::Transpose;\n \t\tstatus = Adjusted;\n \t}\n \n@@ -610,6 +613,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \tfor (auto const stream : data->streams_)\n \t\tstream->reset();\n \n+\t/* We will want to know the transform requested by the application. */\n+\tdata->transform_ = config->transform;\n+\n \tSize maxSize, sensorSize;\n \tunsigned int maxIndex = 0;\n \tbool rawStream = false;\n@@ -1174,8 +1180,14 @@ int RPiCameraData::configureIPA()\n \t\t/* Configure the H/V flip controls based on the sensor rotation. */\n \t\tControlList ctrls(unicam_[Unicam::Image].dev()->controls());\n \t\tint32_t rotation = sensor_->properties().get(properties::Rotation);\n-\t\tctrls.set(V4L2_CID_HFLIP, static_cast<int32_t>(!!rotation));\n-\t\tctrls.set(V4L2_CID_VFLIP, static_cast<int32_t>(!!rotation));\n+\t\tbool success;\n+\t\tTransform combined = transform_ * transformFromRotation(rotation, &success);\n+\t\tif (!success) {\n+\t\t\tLOG(RPI, Error) << \"Invalid rotation: \" << rotation;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tctrls.set(V4L2_CID_HFLIP, static_cast<int32_t>(!!(combined & Transform::HFlip)));\n+\t\tctrls.set(V4L2_CID_VFLIP, static_cast<int32_t>(!!(combined & Transform::VFlip)));\n \t\tunicam_[Unicam::Image].dev()->setControls(&ctrls);\n \t}\n \n","prefixes":["libcamera-devel","v2","3/5"]}