{"id":9351,"url":"https://patchwork.libcamera.org/api/patches/9351/?format=json","web_url":"https://patchwork.libcamera.org/patch/9351/","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":"<20200821155641.11839-4-david.plowman@raspberrypi.com>","date":"2020-08-21T15:56:39","name":"[libcamera-devel,v3,3/5] libcamera: raspberrypi: Set camera flips correctly from user transform","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"97a7df694a398a8e935a2696f61cc5febcbbe8e4","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/9351/mbox/","series":[{"id":1228,"url":"https://patchwork.libcamera.org/api/series/1228/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1228","date":"2020-08-21T15:56:36","name":"2D transforms","version":3,"mbox":"https://patchwork.libcamera.org/series/1228/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9351/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9351/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 D2501BE174\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 21 Aug 2020 15:57:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1CEFD626D3;\n\tFri, 21 Aug 2020 17:57:07 +0200 (CEST)","from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 357B661B4F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Aug 2020 17:57:05 +0200 (CEST)","by mail-wm1-x334.google.com with SMTP id g75so2316877wme.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Aug 2020 08:57:05 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tl11sm5627385wme.11.2020.08.21.08.57.03\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 21 Aug 2020 08:57:03 -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=\"dmpYDFhn\"; 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=yc0n4NwlChACJCfwMFnscjpJL7xovCWYjrqOiaomR8Y=;\n\tb=dmpYDFhnYSonRiSE32rqFQWMmkiKCaO1OCkkJXllooy28+uZGMO3hYTZxc4Qn8GkjM\n\t68TW0H2nZMp2VocU9yaJV/IRrWB2+hR8nUw7mIWaQVj1RY+iqQwMu0ZoG7o7/fIoyZYt\n\tk25jbsqSPGXv1iJ6bb/LhXDNp11KYONXVXAjPGB5qONht2mJ6iIVpNEQq12Epe1XgEsR\n\tJUI/K5AycfFrJJXobGOQm0CcUAvT489JVQZ1axJ8BPWwGG+pvOiHpD/Ye6ticnUX3VTQ\n\tRJswvF81tGQYgIyNZ2zWErtQ+2WeZFTD1+yFhvJSxI80x+lBSSczkCFggOLa1PHbv1Zt\n\tp66Q==","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=yc0n4NwlChACJCfwMFnscjpJL7xovCWYjrqOiaomR8Y=;\n\tb=VSUTftc2rTls2g5nfnUlTu0lkvbiL+wCwXuq5MUTdjv1X3JIijAUQ/1OHEBJjKFlDR\n\t9ndxJZ34NvtcwGkn5XB8hENwoWDAsWzOq1FDfEK/m9ntK/Tc7z5qUbRmX+twt204jFSH\n\tXSUHZujfbm/fDQxcNnrUu5kT2XJ7ZhHDqKasJvZZq4GPxVtwWzjVaOJtb/AF2LkZrkpS\n\t8Ax8J1sdB4/hRhLvfhWaJLvX0Gv4GmilHrXzP9c16SKxcnNXK05baWVZOPZlAXHnGZr6\n\t23V68VVyBGXpmIJJAZ8aEl+cn08CLuUempbL+3U+9AfaCiBX4lHcLppBCM2HgnKv7ots\n\tmA0A==","X-Gm-Message-State":"AOAM533pbSqVUZQCLPqWtErPxyOXQanR7DDY4qAKy0wWJzwS42T7sVex\n\t2p1AMK5wWN9JSz9/w0FvY7wQfT1aeOdLiQ==","X-Google-Smtp-Source":"ABdhPJyK4zmQa1TRe8iEuv3+b11YxvvdCn49FDRO+lSj4rvPzn/x2Dww8B4kujAsF7pg2TDxBlVjQw==","X-Received":"by 2002:a1c:ab8b:: with SMTP id\n\tu133mr3695642wme.108.1598025424347; \n\tFri, 21 Aug 2020 08:57:04 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 21 Aug 2020 16:56:39 +0100","Message-Id":"<20200821155641.11839-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20200821155641.11839-1-david.plowman@raspberrypi.com>","References":"<20200821155641.11839-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 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\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 34 ++++++++++++++++---\n 1 file changed, 30 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 236aa5c..a3f8438 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,27 @@ 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/*\n+\t * What if the platform has a non-90 degree rotation? We can't even\n+\t * \"adjust\" the configuration and carry on. Alternatively, raising an\n+\t * error means the platform can never run. Let's just print a warning\n+\t * and continue regardless; the rotation is effectively set to zero.\n+\t */\n+\tint32_t rotation = data_->sensor_->properties().get(properties::Rotation);\n+\tbool success;\n+\tTransform combined = transform * transformFromRotation(rotation, &success);\n+\tif (!success)\n+\t\tLOG(RPI, Warning) << \"Invalid rotation of \" << rotation\n+\t\t\t\t  << \" degrees - ignoring\";\n+\n+\t/*\n+\t * We combine the platform and user transform, but must \"adjust away\"\n+\t * any combined result that includes a transform, as we can't do those.\n+\t * Flipping the transpose bit in either input transform causes the\n+\t * corresponding bit in the combined result to flip.\n+\t */\n+\tif (!!(combined & Transform::Transpose)) {\n+\t\ttransform ^= Transform::Transpose;\n \t\tstatus = Adjusted;\n \t}\n \n@@ -610,6 +631,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 +1198,10 @@ 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\t/* The rotation was already checked in RPiCameraConfiguration::validate. */\n+\t\tTransform combined = transform_ * transformFromRotation(rotation);\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","v3","3/5"]}