Patch Detail
Show a patch.
GET /api/1.1/patches/3514/?format=api
{ "id": 3514, "url": "https://patchwork.libcamera.org/api/1.1/patches/3514/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3514/", "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": "<20200424104700.26819-3-naush@raspberrypi.com>", "date": "2020-04-24T10:46:57", "name": "[libcamera-devel,v4,2/5] libcamera: controls: Updates to gain and exposure controls", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8e250028ea485027e7f4060b258c3d55799e3f9f", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3514/mbox/", "series": [ { "id": 821, "url": "https://patchwork.libcamera.org/api/1.1/series/821/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=821", "date": "2020-04-24T10:46:55", "name": "Patchset for libcamera controls", "version": 4, "mbox": "https://patchwork.libcamera.org/series/821/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3514/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3514/checks/", "tags": {}, "headers": { "Return-Path": "<naush@raspberrypi.com>", "Received": [ "from mail-wm1-x344.google.com (mail-wm1-x344.google.com\n\t[IPv6:2a00:1450:4864:20::344])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7854062E4D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2020 12:47:14 +0200 (CEST)", "by mail-wm1-x344.google.com with SMTP id v4so9683130wme.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Apr 2020 03:47:14 -0700 (PDT)", "from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tj68sm7884997wrj.32.2020.04.24.03.47.13\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 24 Apr 2020 03:47:13 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"qos4tUx7\"; 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\tbh=gTRrnru+PEsPZVPxI0mivFWeXV0qYZx2apBaEDWKgbI=;\n\tb=qos4tUx7wSzuke2rPZSlwDe3iG2qdsEXTD2mRSvwFeMAK4RhYNBRYCdbs3SQTmRa5J\n\tQ1FUdL+joqiENOYT5dkL4L3KMlfFUm+hL9flRp2JF4lR4jj9FFlf3E8fPf6jxNmblqZs\n\tsKLztGViVndgYxrEtPslpOb+vZltFavf/ByU9h8WOuWjB0w12bCTjDsVTEN0QXNw0Nu2\n\tuqhEC6gfxa+zPTbR+DMcPzS6cwqxjIW++k5KQw8g+Lg4YVUnmCzA0A/+wtA2CA6Fso/M\n\tbSw06JbgCkrpIoZzL4EDmxbpnqyjqxOZpSIqlBU37W2oy/0jz7zIcUsjIfQdmR7X99ya\n\tZHvQ==", "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;\n\tbh=gTRrnru+PEsPZVPxI0mivFWeXV0qYZx2apBaEDWKgbI=;\n\tb=aZsxxHDZzNTMSJS5cggM0u2XVoJm/rsJ4QFHsJqrNsQWqUPKs5oi8gD2g9xqQ6PO45\n\tGxaFfDhh7CSUPbjX61YaKsEILYXY+Q2kujYh35TEGW0/qF15Te6ZXbeKm6hEGQvfV1K8\n\t+az7Ab2FrlOlCrWw8+Y1FVvO0zAQXy1jzM7dorgCUIr6yYELqs48iCVs0yI0cbGQFNBR\n\tTHgvq6YZCdrm/gMDS2FGFK/hqW+tGb5ufBdNU/9tNcphKsNU8sFcwQaYQm4g+8zCV8Bc\n\tAY4XRR371QmyQEVb1+PL9ZnBmVhxdQbWJ1fIr74VczIJfxFlJv3bOuOXAM6shCMPP2Wb\n\t/yjQ==", "X-Gm-Message-State": "AGi0Pua1tYgUbLw8hcEDUDrwIdNZPLSzVs/CiR5BgttIM0zoFJlTCaL+\n\tLyfolOWRknpi8WT81bTw/cjEm37F9rM1mw==", "X-Google-Smtp-Source": "APiQypIiVH0IeCi/DR3TE+Y4QwL726AmNiT3cLXncfHsN+20cLKTIoneCd9pLqOyS3RbdMjuwx2X3Q==", "X-Received": "by 2002:a1c:770f:: with SMTP id\n\tt15mr9250290wmi.178.1587725233726; \n\tFri, 24 Apr 2020 03:47:13 -0700 (PDT)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 24 Apr 2020 11:46:57 +0100", "Message-Id": "<20200424104700.26819-3-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20200424104700.26819-1-naush@raspberrypi.com>", "References": "<20200424104700.26819-1-naush@raspberrypi.com>", "Subject": "[libcamera-devel] [PATCH v4 2/5] libcamera: controls: Updates to\n\tgain and exposure 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>", "X-List-Received-Date": "Fri, 24 Apr 2020 10:47:14 -0000" }, "content": "Rename:\nManualExposure -> ExposureTime\nManualGain -> AnalogueGain\n\nUse micro-seconds units for ExposureTime. This is changed from milli-\nseconds. The latter would not allow very low exposure times.\nAnalogueGain switch to use a float to allow fractional gain adjustments.\n\nUpdate the uvcvideo pipeline handler to use the new exposure and gain\nunits. For ExposureTime, UVC uses units of 100 micro-seconds, so map\nthe values before setting V4L2_CID_EXPOSURE_ABSOLUTE. For AnalogueGain,\nUVC has no explicit gain units, so map the default gain value to 1.0\nand linearly scale to the requested value.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/control_ids.yaml | 22 +++++++-----\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 37 ++++++++++++++++----\n 2 files changed, 44 insertions(+), 15 deletions(-)", "diff": "diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml\nindex bcbab195..d8bdb382 100644\n--- a/src/libcamera/control_ids.yaml\n+++ b/src/libcamera/control_ids.yaml\n@@ -12,7 +12,7 @@ controls:\n description: |\n Enable or disable the AE.\n \n- \\sa ManualExposure\n+ \\sa ExposureTime AnalogueGain\n \n - AeLocked:\n type: bool\n@@ -30,8 +30,6 @@ controls:\n description: |\n Enable or disable the AWB.\n \n- \\sa ManualGain\n-\n - Brightness:\n type: int32_t\n description: Specify a fixed brightness parameter\n@@ -44,12 +42,20 @@ controls:\n type: int32_t\n description: Specify a fixed saturation parameter\n \n- - ManualExposure:\n+ - ExposureTime:\n type: int32_t\n- description: Specify a fixed exposure time in milli-seconds\n+ description: |\n+ Exposure time (shutter speed) for the frame applied in the sensor\n+ device. This value is specified in micro-seconds.\n \n- - ManualGain:\n- type: int32_t\n- description: Specify a fixed gain parameter\n+ \\sa AnalogueGain AeEnable\n+\n+ - AnalogueGain:\n+ type: float\n+ description: |\n+ Analogue gain value applied in the sensor device.\n+ The value of the control specifies the gain multiplier applied to all\n+ colour channels. This value cannot be lower than 1.0.\n \n+ \\sa ExposureTime AeEnable\n ...\ndiff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex ffbddf27..b518ad16 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -7,6 +7,7 @@\n \n #include <algorithm>\n #include <iomanip>\n+#include <math.h>\n #include <sys/sysmacros.h>\n #include <tuple>\n \n@@ -251,11 +252,24 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n \t\t\tcontrols.set(V4L2_CID_CONTRAST, value);\n \t\t} else if (id == controls::Saturation) {\n \t\t\tcontrols.set(V4L2_CID_SATURATION, value);\n-\t\t} else if (id == controls::ManualExposure) {\n+\t\t} else if (id == controls::ExposureTime) {\n \t\t\tcontrols.set(V4L2_CID_EXPOSURE_AUTO, static_cast<int32_t>(1));\n-\t\t\tcontrols.set(V4L2_CID_EXPOSURE_ABSOLUTE, value);\n-\t\t} else if (id == controls::ManualGain) {\n-\t\t\tcontrols.set(V4L2_CID_GAIN, value);\n+\t\t\t/*\n+\t\t\t * controls::ExposureTime is in units of 1 us, and UVC\n+\t\t\t * expects V4L2_CID_EXPOSURE_ABSOLUTE in units of 100 us.\n+\t\t\t */\n+\t\t\tcontrols.set(V4L2_CID_EXPOSURE_ABSOLUTE,\n+\t\t\t\t value.get<int32_t>() / 100);\n+\t\t} else if (id == controls::AnalogueGain) {\n+\t\t\t/*\n+\t\t\t * controls::AnalogueGain is specified as an absolute\n+\t\t\t * multiplier for all RGB samples. Map this multiplier\n+\t\t\t * in a linear way such that 1.0 -> default gain\n+\t\t\t * of the V4L2_CID_GAIN control on the uvcvideo device.\n+\t\t\t */\n+\t\t\tconst ControlInfo &gainInfo = controls.infoMap()->at(V4L2_CID_GAIN);\n+\t\t\tint32_t gain = lroundf(value.get<float>() * gainInfo.def().get<int32_t>());\n+\t\t\tcontrols.set(V4L2_CID_GAIN, gain);\n \t\t}\n \t}\n \n@@ -350,7 +364,7 @@ int UVCCameraData::init(MediaEntity *entity)\n \tControlInfoMap::Map ctrls;\n \n \tfor (const auto &ctrl : controls) {\n-\t\tconst ControlInfo &info = ctrl.second;\n+\t\tControlInfo info = ctrl.second;\n \t\tconst ControlId *id;\n \n \t\tswitch (ctrl.first->id()) {\n@@ -364,10 +378,19 @@ int UVCCameraData::init(MediaEntity *entity)\n \t\t\tid = &controls::Saturation;\n \t\t\tbreak;\n \t\tcase V4L2_CID_EXPOSURE_ABSOLUTE:\n-\t\t\tid = &controls::ManualExposure;\n+\t\t\tid = &controls::ExposureTime;\n \t\t\tbreak;\n \t\tcase V4L2_CID_GAIN:\n-\t\t\tid = &controls::ManualGain;\n+\t\t\tid = &controls::AnalogueGain;\n+\t\t\t/*\n+\t\t\t * AnalogueGain is a float control, convert the type of\n+\t\t\t * the range.\n+\t\t\t */\n+\t\t\tinfo = ControlInfo{\n+\t\t\t\t{ static_cast<float>(info.min().get<int32_t>()) },\n+\t\t\t\t{ static_cast<float>(info.max().get<int32_t>()) },\n+\t\t\t\t{ static_cast<float>(info.def().get<int32_t>()) }\n+\t\t\t};\n \t\t\tbreak;\n \t\tdefault:\n \t\t\tcontinue;\n", "prefixes": [ "libcamera-devel", "v4", "2/5" ] }