Patch Detail
Show a patch.
GET /api/1.1/patches/9868/?format=api
{ "id": 9868, "url": "https://patchwork.libcamera.org/api/1.1/patches/9868/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9868/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20200929164000.15429-6-david.plowman@raspberrypi.com>", "date": "2020-09-29T16:39:59", "name": "[libcamera-devel,v3,5/6] libcamera: pipeline: raspberrypi: Implementation of digital zoom", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "67b46a75a18a7990d0f3014aa60487c5488f54e6", "submitter": { "id": 42, "url": "https://patchwork.libcamera.org/api/1.1/people/42/?format=api", "name": "David Plowman", "email": "david.plowman@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9868/mbox/", "series": [ { "id": 1337, "url": "https://patchwork.libcamera.org/api/1.1/series/1337/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1337", "date": "2020-09-29T16:39:54", "name": "Digital zoom", "version": 3, "mbox": "https://patchwork.libcamera.org/series/1337/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9868/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9868/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 5510CC3B5B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Sep 2020 16:40:14 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0AF086221D;\n\tTue, 29 Sep 2020 18:40:14 +0200 (CEST)", "from mail-wr1-x436.google.com (mail-wr1-x436.google.com\n\t[IPv6:2a00:1450:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 02143621EA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Sep 2020 18:40:10 +0200 (CEST)", "by mail-wr1-x436.google.com with SMTP id k10so6162206wru.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Sep 2020 09:40:10 -0700 (PDT)", "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tq12sm6977393wrs.48.2020.09.29.09.40.08\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 29 Sep 2020 09:40:08 -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=\"Uck40433\"; 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=U07BFgIs43AOzvJHddqiQga4NTJKjxfhWxvHzgV1B3M=;\n\tb=Uck40433/9a5V1F/Es2ZnjVSef7VdeseZ2ALqCgFm76A7klfLwlN2v3cXh2dW8dIrI\n\tQMALrQePc/1vlZyN3Jsq+Y73BsNvVmO5ms3RLns+7gZB2j0IPvX+Sh/7yq1JCtzfWU9+\n\thaTQW3ww5pSm6qqE1zv1l7CGv6ENumQGILtko8u9HhJMXOnoJgguyxlVhUUhZKPTOZtp\n\t250MuFaQ1/gX/bxqr+Sxi3XiVns4SnlVkB7vS5JqfWK6ER8DEipYkihrx02mc2DXc0P0\n\t07Yt/0PwOuL+AnBL6GqVSV6kUOJQmz7Zs9eqUuVfUYr+9On8UzXAx2ensUALz+7aVsbK\n\ttnzg==", "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=U07BFgIs43AOzvJHddqiQga4NTJKjxfhWxvHzgV1B3M=;\n\tb=q2wHZvB/EcMMIz8gDq4PGDCyuDIPdtTVedQdCG6OYGxteevlCkmmbKcBjYO40GXqM0\n\tqwnn8Z+yD8EspxSUjJ3ACkqFkqfydgKAAbVFKXLgvQrQ3nLqZ6jJc59A1RnJzBY4kQlp\n\tHiz/eg8X4hxygTvIaIDMyX4v6zOquvfRTCmCn0/I0AuZ4RGjciWfkdb7egnRSRTKFO4J\n\tZiaLntfhsp0QZYmH+GAdEIx8XmMS2tx1HovFbXwC+2n+XD3vKdPHkjFjrh9i9NwzGPh0\n\tZxmb8n9K+ER50A5AG4PQyIBlXxDRHTyPzPp5559qPKLF+XHS3CeWNhQ6hKDxeADYLCNg\n\tIRBw==", "X-Gm-Message-State": "AOAM530kpsmU3vZ0abkQbjtFtvzWtr3hlbhS6fT6UpvDou/2CDDdKblV\n\te373sM0QIera9PjiGk6guTusfZt0gDPyfA==", "X-Google-Smtp-Source": "ABdhPJz4DfhL36AfbjDrbvYaeaV1n6+rtyx9ZJ95NldnIHx8qXLNqBW4O04JRQGLL8BJh0kQWoMX/w==", "X-Received": "by 2002:adf:f34f:: with SMTP id\n\te15mr5092303wrp.387.1601397609303; \n\tTue, 29 Sep 2020 09:40:09 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 29 Sep 2020 17:39:59 +0100", "Message-Id": "<20200929164000.15429-6-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20200929164000.15429-1-david.plowman@raspberrypi.com>", "References": "<20200929164000.15429-1-david.plowman@raspberrypi.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v3 5/6] libcamera: pipeline: raspberrypi:\n\tImplementation of digital zoom", "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": "During configure() we update the SensorOutputSize to the correct value\nfor this camera mode (which we also note internally) and work out the\nminimum crop size allowed by the ISP.\n\nWhenever a new IspCrop request is received we check it's valid and\napply it to the ISP V4L2 device. We also forward it to the IPA so that\nthe IPA can return the values used in the image metadata.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/ipa/raspberrypi.h | 1 +\n src/ipa/raspberrypi/raspberrypi.cpp | 7 +++\n .../pipeline/raspberrypi/raspberrypi.cpp | 47 +++++++++++++++++++\n 3 files changed, 55 insertions(+)", "diff": "diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex b3041591..9ef5f6fc 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -60,6 +60,7 @@ static const ControlInfoMap Controls = {\n \t{ &controls::Saturation, ControlInfo(0.0f, 32.0f) },\n \t{ &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) },\n \t{ &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) },\n+\t{ &controls::IspCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) },\n };\n \n } /* namespace RPi */\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex b0c7d1c1..dc73c20b 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -699,6 +699,13 @@ void IPARPi::queueRequest(const ControlList &controls)\n \t\t\tbreak;\n \t\t}\n \n+\t\tcase controls::ISP_CROP: {\n+\t\t\t/* Just copy the information back. */\n+\t\t\tRectangle crop = ctrl.second.get<Rectangle>();\n+\t\t\tlibcameraMetadata_.set(controls::IspCrop, crop);\n+\t\t\tbreak;\n+\t\t}\n+\n \t\tdefault:\n \t\t\tLOG(IPARPI, Warning)\n \t\t\t\t<< \"Ctrl \" << controls::controls.at(ctrl.first)->name()\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex d2bee150..4a6d0bf4 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -193,6 +193,11 @@ public:\n \tbool flipsAlterBayerOrder_;\n \tBayerFormat::Order nativeBayerOrder_;\n \n+\t/* For handling digital zoom. */\n+\tSize ispMinSize_;\n+\tSize sensorOutputSize_;\n+\tRectangle lastIspCrop_;\n+\n \tunsigned int dropFrameCount_;\n \n private:\n@@ -587,6 +592,14 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t */\n \tret = data->isp_[Isp::Input].dev()->setFormat(&sensorFormat);\n \n+\t/*\n+\t * Update the SensorOutputSize to the correct value for this camera mode.\n+\t *\n+\t * \\todo Move this property to CameraConfiguration when that\n+\t * feature will be made available and set it at validate() time\n+\t */\n+\tdata->properties_.set(properties::SensorOutputSize, sensorFormat.size);\n+\n \t/*\n \t * See which streams are requested, and route the user\n \t * StreamConfiguration appropriately.\n@@ -677,6 +690,16 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t\treturn ret;\n \t}\n \n+\t/*\n+\t * Figure out the smallest selection the ISP will allow. We also store\n+\t * the output image size, in pixels, from the sensor. These will be\n+\t * used for digital zoom.\n+\t */\n+\tRectangle testCrop(0, 0, 1, 1);\n+\tdata->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &testCrop);\n+\tdata->ispMinSize_ = testCrop.size();\n+\tdata->sensorOutputSize_ = sensorFormat.size;\n+\n \t/* Adjust aspect ratio by providing crops on the input image. */\n \tRectangle crop{ 0, 0, sensorFormat.size };\n \n@@ -693,6 +716,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \tcrop.y = (sensorFormat.size.height - crop.height) >> 1;\n \tdata->isp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop);\n \n+\tdata->lastIspCrop_ = crop;\n+\n \tret = data->configureIPA(config);\n \tif (ret)\n \t\tLOG(RPI, Error) << \"Failed to configure the IPA: \" << ret;\n@@ -1588,6 +1613,28 @@ void RPiCameraData::tryRunPipeline()\n \t/* Take the first request from the queue and action the IPA. */\n \tRequest *request = requestQueue_.front();\n \n+\tif (request->controls().contains(controls::IspCrop)) {\n+\t\tRectangle crop = request->controls().get<Rectangle>(controls::IspCrop);\n+\t\tif (crop.width && crop.height) {\n+\t\t\t/*\n+\t\t\t * The crop that we set must be:\n+\t\t\t * 1. At least as big as ispMinSize_, once that's been\n+\t\t\t * enlarged to the same aspect ratio.\n+\t\t\t * 2. With the same mid-point, if possible.\n+\t\t\t * 3. But it can't go outside the sensor area.\n+\t\t\t */\n+\t\t\tSize minSize = ispMinSize_.alignedUpToAspectRatio(crop.size());\n+\t\t\tSize size = crop.size().expandedTo(minSize);\n+\t\t\tcrop = size.centredTo(crop).boundedTo(Rectangle(sensorOutputSize_));\n+\n+\t\t\tif (crop != lastIspCrop_)\n+\t\t\t\tisp_[Isp::Input].dev()->setSelection(V4L2_SEL_TGT_CROP, &crop);\n+\t\t\tlastIspCrop_ = crop;\n+\t\t}\n+\n+\t\trequest->controls().set(controls::IspCrop, lastIspCrop_);\n+\t}\n+\n \t/*\n \t * Process all the user controls by the IPA. Once this is complete, we\n \t * queue the ISP output buffer listed in the request to start the HW\n", "prefixes": [ "libcamera-devel", "v3", "5/6" ] }