Show a patch.

GET /api/patches/8770/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 8770,
    "url": "https://patchwork.libcamera.org/api/patches/8770/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/8770/",
    "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": "<20200713132451.2944673-10-kieran.bingham@ideasonboard.com>",
    "date": "2020-07-13T13:24:51",
    "name": "[libcamera-devel,9/9] libcamera: pipeline: vivid: Handle controls",
    "commit_ref": null,
    "pull_url": null,
    "state": "awaiting-upstream",
    "archived": false,
    "hash": "f60d36e86b8cc1d2fe301cd4a2bab58c32fb23e1",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/8770/mbox/",
    "series": [
        {
            "id": 1102,
            "url": "https://patchwork.libcamera.org/api/series/1102/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1102",
            "date": "2020-07-13T13:24:42",
            "name": "Introduce a new PipelineHandler",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1102/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/8770/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/8770/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 48D3DBD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jul 2020 13:25:05 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 001FB60747;\n\tMon, 13 Jul 2020 15:25:04 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AF81A60738\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jul 2020 15:24:59 +0200 (CEST)",
            "from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net\n\t[86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 43C77C9;\n\tMon, 13 Jul 2020 15:24:59 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"KREH8MEp\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594646699;\n\tbh=en3WNCtzsrzMaVAGICOtBDR4g4O6Y/DhcC/0yQdACcc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=KREH8MEpuHtt6z7J4HTUDReFbisC4fy3nQN9IleTGXXVVvRVv5CczKUhvYRpBxRtv\n\t9Z78oX8oP2BGaBfrpHJcgH9BAWdI6fgoXYbbqLtuePnZtuugvRh2cdn6FRIes7Ggf8\n\t7akbOLBpqZQJIQTh6DsDywFjLQIhscqlq/9qJlNs=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Mon, 13 Jul 2020 14:24:51 +0100",
        "Message-Id": "<20200713132451.2944673-10-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200713132451.2944673-1-kieran.bingham@ideasonboard.com>",
        "References": "<20200713132451.2944673-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 9/9] libcamera: pipeline: vivid: Handle\n\tcontrols",
        "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>",
        "Cc": "Chris Ward <chris@gregariousmammal.com>",
        "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": "When constructing the camera, we parse the available controls on the\nvideo capture device, and map supported controls to libcamera controls,\nand initialise the defaults.\n\nThe controls are handled during queueRequestDevice for each request and\napplied to the device through the capture node.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/pipeline/vivid/vivid.cpp | 80 +++++++++++++++++++++++++-\n 1 file changed, 79 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/libcamera/pipeline/vivid/vivid.cpp b/src/libcamera/pipeline/vivid/vivid.cpp\nindex 1744d78f2f28..b8b8e3ae0287 100644\n--- a/src/libcamera/pipeline/vivid/vivid.cpp\n+++ b/src/libcamera/pipeline/vivid/vivid.cpp\n@@ -5,7 +5,11 @@\n  * vivid.cpp - Pipeline handler for the vivid capture device\n  */\n \n+#include <math.h>\n+\n #include <libcamera/camera.h>\n+#include <libcamera/control_ids.h>\n+#include <libcamera/controls.h>\n #include <libcamera/formats.h>\n \n #include \"libcamera/internal/device_enumerator.h\"\n@@ -239,6 +243,46 @@ void PipelineHandlerVivid::stop(Camera *camera)\n \tdata->video_->releaseBuffers();\n }\n \n+int PipelineHandlerVivid::processControls(VividCameraData *data, Request *request)\n+{\n+\tControlList controls(data->video_->controls());\n+\n+\tfor (auto it : request->controls()) {\n+\t\tunsigned int id = it.first;\n+\t\tunsigned int offset;\n+\t\tuint32_t cid;\n+\n+\t\tif (id == controls::Brightness) {\n+\t\t\tcid = V4L2_CID_BRIGHTNESS;\n+\t\t\toffset = 128;\n+\t\t} else if (id == controls::Contrast) {\n+\t\t\tcid = V4L2_CID_CONTRAST;\n+\t\t\toffset = 0;\n+\t\t} else if (id == controls::Saturation) {\n+\t\t\tcid = V4L2_CID_SATURATION;\n+\t\t\toffset = 0;\n+\t\t} else {\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tint32_t value = lroundf(it.second.get<float>() * 128 + offset);\n+\t\tcontrols.set(cid, utils::clamp(value, 0, 255));\n+\t}\n+\n+\tfor (const auto &ctrl : controls)\n+\t\tLOG(VIVID, Debug)\n+\t\t\t<< \"Setting control \" << utils::hex(ctrl.first)\n+\t\t\t<< \" to \" << ctrl.second.toString();\n+\n+\tint ret = data->video_->setControls(&controls);\n+\tif (ret) {\n+\t\tLOG(VIVID, Error) << \"Failed to set controls: \" << ret;\n+\t\treturn ret < 0 ? ret : -EINVAL;\n+\t}\n+\n+\treturn ret;\n+}\n+\n int PipelineHandlerVivid::queueRequestDevice(Camera *camera, Request *request)\n {\n \tVividCameraData *data = cameraData(camera);\n@@ -250,7 +294,11 @@ int PipelineHandlerVivid::queueRequestDevice(Camera *camera, Request *request)\n \t\treturn -ENOENT;\n \t}\n \n-\tint ret = data->video_->queueBuffer(buffer);\n+\tint ret = processControls(data, request);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\tret = data->video_->queueBuffer(buffer);\n \tif (ret < 0)\n \t\treturn ret;\n \n@@ -288,6 +336,36 @@ int VividCameraData::init()\n \n \tvideo_->bufferReady.connect(this, &VividCameraData::bufferReady);\n \n+\t/* Initialise the supported controls. */\n+\tconst ControlInfoMap &controls = video_->controls();\n+\tControlInfoMap::Map ctrls;\n+\n+\tfor (const auto &ctrl : controls) {\n+\t\tconst ControlId *id;\n+\t\tControlInfo info;\n+\n+\t\tswitch (ctrl.first->id()) {\n+\t\tcase V4L2_CID_BRIGHTNESS:\n+\t\t\tid = &controls::Brightness;\n+\t\t\tinfo = ControlInfo{ { -1.0f }, { 1.0f }, { 0.0f } };\n+\t\t\tbreak;\n+\t\tcase V4L2_CID_CONTRAST:\n+\t\t\tid = &controls::Contrast;\n+\t\t\tinfo = ControlInfo{ { 0.0f }, { 2.0f }, { 1.0f } };\n+\t\t\tbreak;\n+\t\tcase V4L2_CID_SATURATION:\n+\t\t\tid = &controls::Saturation;\n+\t\t\tinfo = ControlInfo{ { 0.0f }, { 2.0f }, { 1.0f } };\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tctrls.emplace(id, info);\n+\t}\n+\n+\tcontrolInfo_ = std::move(ctrls);\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "9/9"
    ]
}