Patch Detail
Show a patch.
GET /api/patches/9061/?format=api
{ "id": 9061, "url": "https://patchwork.libcamera.org/api/patches/9061/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9061/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200729093154.12296-3-david.plowman@raspberrypi.com>", "date": "2020-07-29T09:31:51", "name": "[libcamera-devel,2/5] libcamera: raspberrypi: Apply transform and pass through to IPA", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "23af2b77da917c75ec119c54bb9cfe65fbe8c2a7", "submitter": { "id": 42, "url": "https://patchwork.libcamera.org/api/people/42/?format=api", "name": "David Plowman", "email": "david.plowman@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9061/mbox/", "series": [ { "id": 1160, "url": "https://patchwork.libcamera.org/api/series/1160/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1160", "date": "2020-07-29T09:31:50", "name": "Transform implementation", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1160/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9061/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9061/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 920F4BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Jul 2020 09:32:06 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D9FCD616FF;\n\tWed, 29 Jul 2020 11:32:04 +0200 (CEST)", "from mail-wm1-x341.google.com (mail-wm1-x341.google.com\n\t[IPv6:2a00:1450:4864:20::341])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AB787605B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Jul 2020 11:32:02 +0200 (CEST)", "by mail-wm1-x341.google.com with SMTP id 184so2262403wmb.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Jul 2020 02:32:02 -0700 (PDT)", "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tc15sm3709921wme.23.2020.07.29.02.32.01\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 29 Jul 2020 02:32:01 -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=\"E5/rv9y1\"; 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=HKmAuBxwIumr230KzlwI2CVDGfwWcBPc8QjmYgrFHx0=;\n\tb=E5/rv9y15EmQedP9cGMPqnZkyVkpaBOpS2W3M1mUPRN/5DjelgK0SCEXVeQn5ldOfI\n\ta1v2er30GXQrQRIG6kJ3gx8DOx4IMr1DdYxUp90C8LJ3cg71GMhIR8ijddbAzdWjLvPj\n\teOpZdXDO9q129ZBPrDakuz3oV5MuXPSyJMdMg1W1IfCtJj7fRhIDjQILulg1JMm0ZXRH\n\tSJ5uOAxDpvdAZAg/3qKkAqS0LzB69K3UK5vjWG6dUgEigURXKgeEIjloHzGMEFS0aM/i\n\taEXr3ZRMg1BrLwTooEfQ/m8r9hs2L+nL919NO+w0ykcE31IUzNyvsXWeXjExrwiBe5BH\n\tfA1Q==", "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=HKmAuBxwIumr230KzlwI2CVDGfwWcBPc8QjmYgrFHx0=;\n\tb=cZK6iXy9QyTxhwMRM8fBbkniaTPVxv6n/POL/prYCMaoqjsfEm/W+EQ9iHgx86LXdX\n\tok9JcZbLjEpESjgDbynBNHVf+l+q13BWt/Nb0C4PT3zj6+D4pYLklC5liSjymkC7YFiI\n\tn53BgJYHmBItfrNT0DHNyVQnwA6Etz5YowBpYVKUjcFSfLki0XDpn7BM7cSNgB5yocuV\n\t+NzL4rAeP30n/fKcmttk2uS165dfXBOd4FA1U7uOzWpr/2nubqIaoYTlvj7KsV7CmgLQ\n\t1JTeMGcrB4e/ijQCVtBvt/Rqjo4AI0zqk+h3tyLvG6OaxZLfN02KvHB/N6z/tLyc0Onv\n\tXrpw==", "X-Gm-Message-State": "AOAM533jebKUmaHGbS0N01tlGPL5Oc88m1rwMg6nkH1lX8+F4PD+5ffY\n\tjiEHdcuSvC/73xai40BgiICCPbMGPqGwYw==", "X-Google-Smtp-Source": "ABdhPJx3lc34VHsZNJ8gokXd7ru+x6odi7uLWe6vmQ6gUUTcrwO2tmHb/4eT0MOddQTDN+CZzt/xdg==", "X-Received": "by 2002:a7b:c054:: with SMTP id u20mr7665782wmc.2.1596015121835; \n\tWed, 29 Jul 2020 02:32:01 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 29 Jul 2020 10:31:51 +0100", "Message-Id": "<20200729093154.12296-3-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20200729093154.12296-1-david.plowman@raspberrypi.com>", "References": "<20200729093154.12296-1-david.plowman@raspberrypi.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 2/5] libcamera: raspberrypi: Apply\n\ttransform and pass through to IPA", "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 user-supplied transform is applied to the camera, taking account\nof any pre-existing rotation. It is then also plumbed through to the\nIPA so that it will (in a further commit) be able to make use of\nit.\n---\n include/libcamera/ipa/raspberrypi.h | 1 +\n src/ipa/raspberrypi/raspberrypi.cpp | 13 ++++++++-\n .../pipeline/raspberrypi/raspberrypi.cpp | 27 +++++++++++++++++--\n 3 files changed, 38 insertions(+), 3 deletions(-)", "diff": "diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex ca62990..3905a4a 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -14,6 +14,7 @@ enum RPiConfigParameters {\n \tRPI_IPA_CONFIG_LS_TABLE = (1 << 0),\n \tRPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1),\n \tRPI_IPA_CONFIG_SENSOR = (1 << 2),\n+\tRPI_IPA_CONFIG_TRANSFORM = (1 << 3),\n };\n \n enum RPiOperations {\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 3747208..2809521 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -21,6 +21,7 @@\n #include <libcamera/ipa/raspberrypi.h>\n #include <libcamera/request.h>\n #include <libcamera/span.h>\n+#include <libcamera/transform.h>\n \n #include <libipa/ipa_interface_wrapper.h>\n \n@@ -144,6 +145,9 @@ private:\n \t/* LS table allocation passed in from the pipeline handler. */\n \tFileDescriptor lsTableHandle_;\n \tvoid *lsTable_;\n+\n+\t/* This is the transform requested by the user/application driving libcamera. */\n+\tTransform userTransform_;\n };\n \n int IPARPi::init(const IPASettings &settings)\n@@ -282,6 +286,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \tlastMode_ = mode_;\n \n \t/* Store the lens shading table pointer and handle if available. */\n+\tunsigned int next_element = 0;\n \tif (ipaConfig.operation & RPI_IPA_CONFIG_LS_TABLE) {\n \t\t/* Remove any previous table, if there was one. */\n \t\tif (lsTable_) {\n@@ -290,7 +295,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t\t}\n \n \t\t/* Map the LS table buffer into user space. */\n-\t\tlsTableHandle_ = FileDescriptor(ipaConfig.data[0]);\n+\t\tlsTableHandle_ = FileDescriptor(ipaConfig.data[next_element++]);\n \t\tif (lsTableHandle_.isValid()) {\n \t\t\tlsTable_ = mmap(nullptr, MAX_LS_GRID_SIZE, PROT_READ | PROT_WRITE,\n \t\t\t\t\tMAP_SHARED, lsTableHandle_.fd(), 0);\n@@ -301,6 +306,12 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t\t\t}\n \t\t}\n \t}\n+\n+\t/* Fish out any transform set by the user/application. */\n+\tif (ipaConfig.operation & RPI_IPA_CONFIG_TRANSFORM) {\n+\t\tuint32_t transformType = ipaConfig.data[next_element++];\n+\t\tuserTransform_ = reinterpret_cast<Transform &>(transformType);\n+\t}\n }\n \n void IPARPi::mapBuffers(const std::vector<IPABuffer> &buffers)\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 82a0a4d..5fb427a 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -324,6 +324,9 @@ public:\n \tuint32_t expectedSequence_;\n \tbool sensorMetadata_;\n \n+\t/* This is the transform requested by the user/application driving libcamera. */\n+\tTransform userTransform_;\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,6 +403,9 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \tif (config_.empty())\n \t\treturn Invalid;\n \n+\tif (userTransform.contains(Transform::transpose()))\n+\t\treturn Invalid;\n+\n \tunsigned int rawCount = 0, outCount = 0, count = 0, maxIndex = 0;\n \tstd::pair<int, Size> outSize[2];\n \tSize maxSize;\n@@ -609,6 +615,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \tunsigned int maxIndex = 0;\n \tbool rawStream = false;\n \n+\t/* Record the transform requested by the application. */\n+\tdata->userTransform_ = config->userTransform;\n+\n \t/*\n \t * Look for the RAW stream (if given) size as well as the largest\n \t * ISP output size.\n@@ -1140,6 +1149,11 @@ int RPiCameraData::configureIPA()\n \t\tipaConfig.data = { static_cast<unsigned int>(lsTable_.fd()) };\n \t}\n \n+\t/* We must pass the user transform to the IPA too. */\n+\tuint32_t transformType = reinterpret_cast<uint32_t &>(userTransform_);\n+\tipaConfig.operation |= RPI_IPA_CONFIG_TRANSFORM;\n+\tipaConfig.data.push_back(transformType);\n+\n \tCameraSensorInfo sensorInfo = {};\n \tint ret = sensor_->sensorInfo(&sensorInfo);\n \tif (ret) {\n@@ -1168,8 +1182,17 @@ 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+\n+\t\t/* The camera needs to compose the user transform with the rotation. */\n+\t\tTransform rotationTransform;\n+\t\tif (Transform::rotation(rotation, rotationTransform) == false)\n+\t\t\treturn -EINVAL;\n+\t\tTransform transform = userTransform_ * rotationTransform;\n+\n+\t\tctrls.set(V4L2_CID_HFLIP,\n+\t\t\t static_cast<int32_t>(transform.contains(Transform::hflip())));\n+\t\tctrls.set(V4L2_CID_VFLIP,\n+\t\t\t static_cast<int32_t>(transform.contains(Transform::vflip())));\n \t\tunicam_[Unicam::Image].dev()->setControls(&ctrls);\n \t}\n \n", "prefixes": [ "libcamera-devel", "2/5" ] }