{"id":10891,"url":"https://patchwork.libcamera.org/api/1.1/patches/10891/?format=json","web_url":"https://patchwork.libcamera.org/patch/10891/","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":"<20210119143711.153517-4-jacopo@jmondi.org>","date":"2021-01-19T14:37:03","name":"[libcamera-devel,v2,03/11] libcamera: ipu3: Register Exposure control","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b13205ebfcf2784a91e27efde29da6a7700cb973","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/1.1/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/10891/mbox/","series":[{"id":1584,"url":"https://patchwork.libcamera.org/api/1.1/series/1584/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1584","date":"2021-01-19T14:37:00","name":"android: Exposure times + scaler crop + android metadata","version":2,"mbox":"https://patchwork.libcamera.org/series/1584/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10891/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10891/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 7143CBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Jan 2021 14:37:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B3FF96815D;\n\tTue, 19 Jan 2021 15:37:00 +0100 (CET)","from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 726C368146\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Jan 2021 15:36:58 +0100 (CET)","from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 365FFC001F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Jan 2021 14:36:58 +0000 (UTC)"],"X-Originating-IP":"93.61.96.190","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 19 Jan 2021 15:37:03 +0100","Message-Id":"<20210119143711.153517-4-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.29.2","In-Reply-To":"<20210119143711.153517-1-jacopo@jmondi.org>","References":"<20210119143711.153517-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 03/11] libcamera: ipu3: Register\n\tExposure control","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":"Calculate the controls::Exposure limits at camera registration time\nand register it in the list of camera supported controls.\n\nCache the default exposure value to report it in the request metadata.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 66 ++++++++++++++++++++++++++--\n 1 file changed, 62 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 73304ea73050..f928af4d92a2 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -41,7 +41,7 @@ static constexpr unsigned int IMGU_OUTPUT_HEIGHT_ALIGN = 4;\n static constexpr unsigned int IMGU_OUTPUT_WIDTH_MARGIN = 64;\n static constexpr unsigned int IMGU_OUTPUT_HEIGHT_MARGIN = 32;\n \n-static const ControlInfoMap IPU3Controls = {\n+static const ControlInfoMap::Map IPU3Controls = {\n \t{ &controls::draft::PipelineDepth, ControlInfo(2, 3) },\n };\n \n@@ -49,7 +49,7 @@ class IPU3CameraData : public CameraData\n {\n public:\n \tIPU3CameraData(PipelineHandler *pipe)\n-\t\t: CameraData(pipe)\n+\t\t: CameraData(pipe), exposureTime_(0)\n \t{\n \t}\n \n@@ -62,6 +62,8 @@ public:\n \tStream outStream_;\n \tStream vfStream_;\n \tStream rawStream_;\n+\n+\tuint32_t exposureTime_;\n };\n \n class IPU3CameraConfiguration : public CameraConfiguration\n@@ -119,6 +121,7 @@ private:\n \t\t\tPipelineHandler::cameraData(camera));\n \t}\n \n+\tint initControls(IPU3CameraData *data);\n \tint registerCameras();\n \n \tint allocateBuffers(Camera *camera);\n@@ -730,6 +733,58 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n \treturn ret == 0;\n }\n \n+/**\n+ * \\brief Initialize the camera controls\n+ * \\param[in] data The camera data\n+ *\n+ * Initialize the camera controls as the union of the static pipeline handler\n+ * controls (IPU3Controls) and controls created dynamically from the sensor\n+ * capabilities.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int PipelineHandlerIPU3::initControls(IPU3CameraData *data)\n+{\n+\tconst CameraSensor *sensor = data->cio2_.sensor();\n+\tCameraSensorInfo sensorInfo{};\n+\n+\tint ret = sensor->sensorInfo(&sensorInfo);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tControlInfoMap::Map controls = IPU3Controls;\n+\n+\t/*\n+\t * Compute exposure time limits.\n+\t *\n+\t * \\todo The exposure limits depend on the sensor configuration.\n+\t * Initialize the control using the line length and pixel rate of the\n+\t * current configuration converted to microseconds. Use the\n+\t * V4L2_CID_EXPOSURE control to get exposure min, max and default and\n+\t * convert it from lines to microseconds.\n+\t */\n+\tdouble lineDuration = sensorInfo.lineLength\n+\t\t\t    / (sensorInfo.pixelRate / 1e6f);\n+\tconst ControlInfoMap &sensorControls = sensor->controls();\n+\tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n+\tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n+\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n+\tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n+\n+\t/*\n+\t * \\todo Report the actual exposure time, use the default for the\n+\t * moment.\n+\t */\n+\tdata->exposureTime_ = defExposure;\n+\n+\tcontrols[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n+\t\t\t\t\t\t\tdefExposure);\n+\n+\tdata->controlInfo_ = std::move(controls);\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\brief Initialise ImgU and CIO2 devices associated with cameras\n  *\n@@ -775,8 +830,9 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t/* Initialize the camera properties. */\n \t\tdata->properties_ = cio2->sensor()->properties();\n \n-\t\t/* Initialze the camera controls. */\n-\t\tdata->controlInfo_ = IPU3Controls;\n+\t\tret = initControls(data.get());\n+\t\tif (ret)\n+\t\t\tcontinue;\n \n \t\t/**\n \t\t * \\todo Dynamically assign ImgU and output devices to each\n@@ -841,6 +897,8 @@ void IPU3CameraData::imguOutputBufferReady(FrameBuffer *buffer)\n \n \t/* Mark the request as complete. */\n \trequest->metadata().set(controls::draft::PipelineDepth, 3);\n+\t/* \\todo Move the ExposureTime control to the IPA. */\n+\trequest->metadata().set(controls::ExposureTime, exposureTime_);\n \tpipe_->completeRequest(request);\n }\n \n","prefixes":["libcamera-devel","v2","03/11"]}