Patch Detail
Show a patch.
GET /api/patches/16471/?format=api
{ "id": 16471, "url": "https://patchwork.libcamera.org/api/patches/16471/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16471/", "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": "<20220630133902.321099-15-jacopo@jmondi.org>", "date": "2022-06-30T13:38:53", "name": "[libcamera-devel,v3,14/23] libcamera: camera_sensor: Translate libcamera/V4L2 controls", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": true, "hash": "917695551be8788e0aacccac50691454ba2046e5", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16471/mbox/", "series": [ { "id": 3238, "url": "https://patchwork.libcamera.org/api/series/3238/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3238", "date": "2022-06-30T13:38:39", "name": "Internal controls, sensor delays and IPA rework", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3238/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16471/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16471/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 38F72C3274\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jun 2022 13:39:44 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 650EB6564E;\n\tThu, 30 Jun 2022 15:39:43 +0200 (CEST)", "from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BDA4665699\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Jun 2022 15:39:36 +0200 (CEST)", "(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 074B8240007;\n\tThu, 30 Jun 2022 13:39:35 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656596383;\n\tbh=9ySY97JDsTSmnDSL7AIXOmHeC6+kW/Mb73b7umzzwqs=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=pkAn96Ad3BRrJDKlRqIPqbBlIE8hSVfXoghd4FxVk71+QECN0KN4Gl0/7W2f1kbhp\n\tJ6rcUH8w8yvr/l+kV/jPiuJ/xd5DU+/wqPEdQ8Mx7ffs2VEWqf5azLQxXM3oAiphep\n\tcY4GNuP/Dj4X/lXaDdWLzLWM4qARvfHd4qEIP6+j/WMJnO8QNqmdMS4ory9VnwReeR\n\tSSmlZuwlR8kZzNkUW0Y0Fp5ERi3mmspvr/lH4mn/U2UuPWGCTO2UohmhAtPQkxSGsL\n\t8RHxOIaEYwBSKHf3VvsFjg7jC84KE9Yg22o1cf73Ia6zROoKwRdtKmra31sQxnfxFo\n\tm5UwliY40KbcA==", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 30 Jun 2022 15:38:53 +0200", "Message-Id": "<20220630133902.321099-15-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.36.1", "In-Reply-To": "<20220630133902.321099-1-jacopo@jmondi.org>", "References": "<20220630133902.321099-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 14/23] libcamera: camera_sensor:\n\tTranslate libcamera/V4L2 controls", "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>", "From": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Jacopo Mondi <jacopo@jmondi.org>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "In the process of moving the CameraSensor class control interface\nto use libcamera::internal controls modify the\nCameraSensor::pushControls() and CameraSensor::getControls() to\nuse lists of libcamera controls and translate to and from V4L2 controls\nto interface with DelayedControls, which will actually take care of\napplying controls to the V4L2 subdevice.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/camera_sensor/camera_sensor.cpp | 67 ++++++++++++++++++-\n 1 file changed, 65 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/libcamera/camera_sensor/camera_sensor.cpp b/src/libcamera/camera_sensor/camera_sensor.cpp\nindex cc4cbd4ad509..02810c7c5ad0 100644\n--- a/src/libcamera/camera_sensor/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor/camera_sensor.cpp\n@@ -1038,19 +1038,82 @@ void CameraSensor::frameStart(uint32_t sequence)\n /**\n * \\brief Push a new set of controls to the CameraSensor\n * \\param[in] ctrls The list of controls to push to the sensor\n+ *\n+ * \\a ctrls contains a list of libcamera::controls::internal controls\n */\n void CameraSensor::pushControls(const ControlList &ctrls)\n {\n-\tdelayedCtrls_->push(ctrls);\n+\tControlList v4l2Ctrls(subdev_->controls());\n+\n+\t/*\n+\t * DelayedControls applies V4L2 controls for us to the subdevice.\n+\t * Translate here between libcamera controls and V4L2 controls.\n+\t *\n+\t * The currently supported controls are V4L2_CID_VBLANK,\n+\t * V4L2_CID_EXPOSURE and V4L2_CID_ANALOGUE_GAIN.\n+\t */\n+\n+\tif (ctrls.contains(controls::internal::AnalogueGain)) {\n+\t\tfloat gain = ctrls.get(controls::internal::AnalogueGain);\n+\t\tint32_t gainCode = helper_->gainCode(gain);\n+\n+\t\tv4l2Ctrls.set(V4L2_CID_ANALOGUE_GAIN, ControlValue(gainCode));\n+\t}\n+\n+\tif (ctrls.contains(controls::internal::ExposureTime)) {\n+\t\tuint32_t exposureTime = ctrls.get(controls::internal::ExposureTime);\n+\t\tint32_t exposure = exposureTime / config_.lineDuration;\n+\n+\t\tv4l2Ctrls.set(V4L2_CID_EXPOSURE, ControlValue(exposure));\n+\t}\n+\n+\tif (ctrls.contains(controls::internal::FrameDuration)) {\n+\t\tuint64_t duration = ctrls.get(controls::internal::FrameDuration);\n+\t\tuint32_t frameSize = duration / (1000000.0F / config_.pixelRate);\n+\t\tuint32_t lineLength = config_.outputFormat.size.width + config_.hblank;\n+\t\tint32_t vblank = frameSize / lineLength - config_.outputFormat.size.height;\n+\n+\t\tv4l2Ctrls.set(V4L2_CID_VBLANK, vblank);\n+\t}\n+\n+\tdelayedCtrls_->push(v4l2Ctrls);\n }\n \n /**\n * \\brief Get the list of controls applied at frame \\a sequence\n * \\param[in] sequence The frame sequence number\n+ *\n+ * The returned controls list contains libcamera::controls::internal controls\n */\n ControlList CameraSensor::getControls(uint32_t sequence)\n {\n-\treturn delayedCtrls_->get(sequence);\n+\tControlList ctrls(controls::internal::controls);\n+\tControlList v4l2Ctrls = delayedCtrls_->get(sequence);\n+\n+\tif (v4l2Ctrls.contains(V4L2_CID_ANALOGUE_GAIN)) {\n+\t\tuint32_t gainCode = v4l2Ctrls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>();\n+\t\tfloat gain = static_cast<float>(helper_->gain(gainCode));\n+\n+\t\tctrls.set(controls::internal::AnalogueGain, gain);\n+\t}\n+\n+\tif (v4l2Ctrls.contains(V4L2_CID_EXPOSURE)) {\n+\t\tuint32_t exposure = v4l2Ctrls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n+\t\tuint32_t exposureTime = exposure * config_.lineDuration;\n+\n+\t\tctrls.set(controls::internal::ExposureTime, exposureTime);\n+\t}\n+\n+\tif (v4l2Ctrls.contains(V4L2_CID_VBLANK)) {\n+\t\tuint32_t vblank = v4l2Ctrls.get(V4L2_CID_VBLANK).get<int32_t>();\n+\t\tuint32_t frameSize = (config_.outputFormat.size.width + config_.hblank)\n+\t\t\t\t * (config_.outputFormat.size.height + vblank);\n+\t\tuint64_t duration = frameSize / (config_.pixelRate / 1000000.0F);\n+\n+\t\tctrls.set(controls::internal::FrameDuration, duration);\n+\t}\n+\n+\treturn ctrls;\n }\n \n /**\n", "prefixes": [ "libcamera-devel", "v3", "14/23" ] }