Patch Detail
Show a patch.
GET /api/patches/9703/?format=api
{ "id": 9703, "url": "https://patchwork.libcamera.org/api/patches/9703/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9703/", "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": "<20200922100400.30766-6-david.plowman@raspberrypi.com>", "date": "2020-09-22T10:03:59", "name": "[libcamera-devel,5/6] libcamera: pipeline: raspberrypi: Implementation of digital zoom", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "aeaa515886aa5cbf0b9d0091fd69ce098da06d9f", "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/9703/mbox/", "series": [ { "id": 1308, "url": "https://patchwork.libcamera.org/api/series/1308/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1308", "date": "2020-09-22T10:03:54", "name": "Digital zoom", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1308/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9703/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9703/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 475DCBF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Sep 2020 10:04:15 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1009A62FDD;\n\tTue, 22 Sep 2020 12:04:15 +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 C05F462FDE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Sep 2020 12:04:11 +0200 (CEST)", "by mail-wm1-x334.google.com with SMTP id v12so870331wmh.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Sep 2020 03:04:11 -0700 (PDT)", "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tg14sm26369595wrv.25.2020.09.22.03.04.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 22 Sep 2020 03:04:10 -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=\"UH66klOF\"; 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=Z8SrpSgEre5Ub0KUWcgKZOT5DdvwoJNRhtRvy7mkJDc=;\n\tb=UH66klOFOyHdgLxev0DIrrKMRajL7Q7tvgqW3/9zYyPdYYPl4E04+XRl2Ir3obNmsr\n\tfoRCo3nxRc4msL4zTtwvAqsCXwed/F7r9cj6dXFnN6YF0c3NiAQUzWRHvR6gxlBeY6QX\n\t23enUqK7caOwjMd5uVJWraB8BEVsJquRBKpXlRdv8FTaPx2lE652hE1dI98NQ0biz6wk\n\tsO0pb/E/PbzE5Rm6Oj7v5bzOoRdG5HeljsUvMw5wdeDDQ/r7t+XXf6jDzDJ9GrpTluRv\n\tUSIioCb71Xr0Du0+CHl03vVjoF2jwPs1zZOeaxx9UAdzV7NXzfx4vLDqxbh4sPEqQUXS\n\tjEEA==", "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=Z8SrpSgEre5Ub0KUWcgKZOT5DdvwoJNRhtRvy7mkJDc=;\n\tb=pGRROBGk2tEk8QVOsVsYtCo7PiH2QFhEp2OsWSrkKwgOKHQf2QQy+qVO7Q1jQXB4Co\n\tiDIHHQ/x0PG1H1Wi7WY7HZvcyDN5E105mIV5OYS0liOLVYmBU9MXO4MuJ5AbhiSVEyEU\n\tnvFwJVxxx6Wh0WyVi01oh2mvT/DH1K5sckQs0vUXzHtuCQ1GueDvWInDeHPln9m7/NHn\n\tBhK43sZv9xadBirWdSZj35KQBi0FYG58hnCh3+yNnESDGqnDdD+s8FqTYTElb5Rh8NMF\n\t/w36ovSdEWInR+vJFXSajE73U/Qn4veou7psMvNpr5U8OVL4Gb2AYSLmZ+M3uruZFHGP\n\tYaDw==", "X-Gm-Message-State": "AOAM533fqh1SMcfhonJ8OcSDImxBpjpfPA0GEIzLZxrYZ9jAh65G2gL2\n\t4aKxs4tPIozFEKcbRKP44uZlwEIir+kgnA==", "X-Google-Smtp-Source": "ABdhPJyVyHBAWEg2ZqcSjKxIEC07SODzp2KGWCGZ+WHUex3ndoVFIr9qWSpoujHuN0JoL5VgO51Rxg==", "X-Received": "by 2002:a05:600c:245:: with SMTP id\n\t5mr133657wmj.33.1600769051128; \n\tTue, 22 Sep 2020 03:04:11 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 22 Sep 2020 11:03:59 +0100", "Message-Id": "<20200922100400.30766-6-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20200922100400.30766-1-david.plowman@raspberrypi.com>", "References": "<20200922100400.30766-1-david.plowman@raspberrypi.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 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>\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 dd6ebea..91a1892 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -58,6 +58,7 @@ static const ControlInfoMap RPiControls = {\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(0, 0, 0, 0), Rectangle(65535, 65535, 65535, 65535), Rectangle(0, 0, 0, 0)) },\n };\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 0555cc4..64f0e35 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -687,6 +687,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 50f0718..1674f8f 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -182,6 +182,11 @@ public:\n \tstd::queue<FrameBuffer *> embeddedQueue_;\n \tstd::deque<Request *> requestQueue_;\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@@ -496,6 +501,14 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \tLOG(RPI, Info) << \"Sensor: \" << camera->id()\n \t\t << \" - Selected mode: \" << sensorFormat.toString();\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 * This format may be reset on start() if the bayer order has changed\n \t * because of flips in the sensor.\n@@ -592,6 +605,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@@ -608,6 +631,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();\n \tif (ret)\n \t\tLOG(RPI, Error) << \"Failed to configure the IPA: \" << ret;\n@@ -1449,6 +1474,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", "5/6" ] }