{"id":9420,"url":"https://patchwork.libcamera.org/api/1.1/patches/9420/?format=json","web_url":"https://patchwork.libcamera.org/patch/9420/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20200828144110.17303-6-david.plowman@raspberrypi.com>","date":"2020-08-28T14:41:08","name":"[libcamera-devel,v4,5/7] libcamera: raspberrypi: Set camera flips correctly from user transform","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"467e346c480c93591847834290a33e239581adbf","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9420/mbox/","series":[{"id":1250,"url":"https://patchwork.libcamera.org/api/1.1/series/1250/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1250","date":"2020-08-28T14:41:03","name":"2D transforms","version":4,"mbox":"https://patchwork.libcamera.org/series/1250/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9420/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9420/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 012C9BF019\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Aug 2020 14:41:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BD8B8628EE;\n\tFri, 28 Aug 2020 16:41:24 +0200 (CEST)","from mail-wm1-x329.google.com (mail-wm1-x329.google.com\n\t[IPv6:2a00:1450:4864:20::329])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 21B6E62919\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Aug 2020 16:41:21 +0200 (CEST)","by mail-wm1-x329.google.com with SMTP id o21so1147145wmc.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Aug 2020 07:41:21 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\ts12sm2493724wmj.26.2020.08.28.07.41.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 28 Aug 2020 07:41:19 -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=\"ApAztjra\"; 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=5RQ8Tgj+C3/uKLvM1ptBLXMv3MS0gQ7Sq45idn4oLKg=;\n\tb=ApAztjraLYr+3faisoVdCNOg2X8Py+eGRLufcnbvR9e1BGr5lmVRGdcb80K9Xq/rKp\n\tYOM0kfTzY4Em9/gd8p1TK/FSKPQHaUwd47kAUJ2f4VBZYO9OCBZX95gYoFe/netsD3na\n\tzObHrWAwO/nwBT0OtPJVOpL/2ga99v4oN3v6k58Dt2P5AiNCb271uWp8u3r7OhDtPpUe\n\tcS0l/N2hPccqKfWHBTIU/80ijc/E3NhoQ2Dy5+kWS0BGZwD5lkc4IbdhFBdklgfwc+At\n\tzKC+8aZ176rM6jmMZ2K9QsmkdrK8Am6So1KCJ6hOJGsAf58930qdUnflPfFn24E8C61g\n\t9N8g==","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=5RQ8Tgj+C3/uKLvM1ptBLXMv3MS0gQ7Sq45idn4oLKg=;\n\tb=lMN3C+yXHpT2C+1PhlEFZQtIOSIpYLe6WDlqDUIKqi+N19khwo/wQz7lqD5jiqUK7h\n\tb1wCWO1dCi1zJGbiQ3uPc/V8yc+DyA6Y9TqS16A/5EYmytZSyzZICNK590WqD82iw2dw\n\tYpl9P1Na4YMzLN7X+X7WYTgnexaaw2bpPVQRSGIrj8KBfvlhbwfJrAq+G5YjGXzIpP4T\n\tS0F3+68CrAUhnSm+Hs1FlAK56zon/HgSqZ3xI/fpmxWCVGHez+xnUcs/DvPFtqJckGEO\n\tJIYiYrKeuVIa67PeprrOxH1yrlM7I4aVXXKSHpFndDENp3suhzwiX3VtlzObiVkHIXxf\n\tu1wQ==","X-Gm-Message-State":"AOAM530hT3aaqhDie/HeEbZy46F8VkHgX4XneHRB/JIy5vfnAmfkudts\n\tSzvwyjiLXZsg1MKfZPrhhzx47o5WyWfkkQ==","X-Google-Smtp-Source":"ABdhPJwMb30vppxLRTVGB+HspBbQcQPPjZqC7mUKxAr9v07ZzWWpVo5ySB4ZjbK6WegdsBKWzvO4Vg==","X-Received":"by 2002:a1c:2501:: with SMTP id l1mr2148725wml.16.1598625680577; \n\tFri, 28 Aug 2020 07:41:20 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 28 Aug 2020 15:41:08 +0100","Message-Id":"<20200828144110.17303-6-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20200828144110.17303-1-david.plowman@raspberrypi.com>","References":"<20200828144110.17303-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v4 5/7] 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      | 42 +++++++++++++++----\n 1 file changed, 34 insertions(+), 8 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex dc36f53..6ea1432 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -400,20 +400,46 @@ 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 * In this case, flipping only the transpose bit is helpful to\n+\t * applications - they either get the transform they requested, or have\n+\t * to do a simple transpose themselves (they don't have to worry about\n+\t * the other possible cases).\n+\t */\n+\tif (!!(combined & Transform::Transpose)) {\n+\t\t/*\n+\t\t * Flipping the transpose bit in \"transform\" flips it in\n+\t\t * combined result too (as it's the last thing that happens).\n+\t\t */\n+\t\ttransform ^= Transform::Transpose;\n+\t\tcombined ^= Transform::Transpose;\n \t\tstatus = Adjusted;\n \t}\n \n \t/*\n-\t * Configure the H/V flip controls based on the sensor rotation. We do\n-\t * this here so that the sensor has the correct Bayer format that will\n-\t * get advertised in the configuration of any raw streams.\n+\t * Configure the H/V flip controls based on the combination of the\n+\t * sensor rotation and the user transform. We do this here so that the\n+\t * sensor has the correct Bayer format that will get advertised in the\n+\t * configuration of any raw streams.\n \t */\n \tControlList ctrls(data_->unicam_[Unicam::Image].dev()->controls());\n-\tint32_t rotation = data_->sensor_->properties().get(properties::Rotation);\n-\tctrls.set(V4L2_CID_HFLIP, static_cast<int32_t>(!!rotation));\n-\tctrls.set(V4L2_CID_VFLIP, static_cast<int32_t>(!!rotation));\n+\tctrls.set(V4L2_CID_HFLIP, static_cast<int32_t>(!!(combined & Transform::HFlip)));\n+\tctrls.set(V4L2_CID_VFLIP, static_cast<int32_t>(!!(combined & Transform::VFlip)));\n \tdata_->unicam_[Unicam::Image].dev()->setControls(&ctrls);\n \n \tunsigned int rawCount = 0, outCount = 0, count = 0, maxIndex = 0;\n","prefixes":["libcamera-devel","v4","5/7"]}