{"id":15250,"url":"https://patchwork.libcamera.org/api/patches/15250/?format=json","web_url":"https://patchwork.libcamera.org/patch/15250/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20220105085553.12092-4-david.plowman@raspberrypi.com>","date":"2022-01-05T08:55:53","name":"[libcamera-devel,v2,3/3] libcamera: pipeline: raspberrypi: Update sensor's V4L2_CID_NOTIFY_GAINS control","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8bce9c31d6538a1ecfe565f9db1b39a9abf481c4","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15250/mbox/","series":[{"id":2878,"url":"https://patchwork.libcamera.org/api/series/2878/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2878","date":"2022-01-05T08:55:50","name":"Make use of V4L2_CID_NOTIFY_GAINS","version":2,"mbox":"https://patchwork.libcamera.org/series/2878/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15250/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15250/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 5D963C3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jan 2022 08:56:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 620A06092D;\n\tWed,  5 Jan 2022 09:56:13 +0100 (CET)","from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n\t[IPv6:2a00:1450:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 07B1960926\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jan 2022 09:56:11 +0100 (CET)","by mail-wr1-x42d.google.com with SMTP id w20so72469522wra.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 05 Jan 2022 00:56:11 -0800 (PST)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tg8sm1902149wmh.17.2022.01.05.00.56.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 05 Jan 2022 00:56:10 -0800 (PST)"],"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=\"nHS6l6QL\"; 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=2iOjoJzhQiUFBoBAf6DIvEvkVxPUvfqaF5r4J7kxYJ0=;\n\tb=nHS6l6QLkUHnV5MvoSDLTa0SHfxegf/fPkXvvteNziWNtIRKuDJLxYSJf32owsLunC\n\tLKaPAvJZjRWV7KUX9KMpXfDEhxtAFAgrGadL5xw9LAOZ2o6apBKAuvNFCbNvFNukd48D\n\tKtGwdjHKcp3jI1e37yZzPALtpjJwNbFBYscBy2eFhx+hAzI4brkN22zE9Vatogzv0hVe\n\t1L76Z31bCFG4m8DwKK67BFdMRGL/IgmUy2lqW4x8BePKdQhvxI76GIeP3lJ0sIXWsgD6\n\twBKhss29YCg5jqpr39cFiiIcsNxutJ+D64rzJdpjMNVy6mQMbCyPLADorsk7+idiJJT9\n\tBjNw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=2iOjoJzhQiUFBoBAf6DIvEvkVxPUvfqaF5r4J7kxYJ0=;\n\tb=sV/skqTJ9a11KOR4eMOK57ze6i2KhmyFcJLojWb3Hi2DiK9OJlLK8NgWcDWDzqgiWv\n\t/thX0EIA7Z4R12WOPDS3+mcPrVRW36XkcJBTD7nraIJywi/fQaxZMqhy6J8bmVkrbBK9\n\tuvGM4/svnYQ/dImzcnAAxn3zSXBMtZkHsXr/2B5kb4Z14Q+dGeDYkN37b6wextZU9Tsx\n\tA3xwTRPMLDtMDxlVyEJbFe6+NDHtUi5oolVZ6LJMjfQDSKQ4BchDnqCmhQyQyKUt7b7J\n\tO0W1+sxWyAMbEspqJNYjP4vJ32phHvMKrqljqM5AYX12ZPkuXS4PvCq2BMSiHK21bFoG\n\t7aUg==","X-Gm-Message-State":"AOAM53254KBoM+RCoT7yllHG62m2B90Ri1eKzNUXP7aC3vYsuaqqqygx\n\t7UysflLufl2yFKKO9tjWkApIFQpDA57LDa4+","X-Google-Smtp-Source":"ABdhPJwf6dItMK2XXD9qIUlqPppdMLf0wqsfmTTzNlqJt22vlwE3Tu8C4Fqy0zsOviiDXBPvESGoUw==","X-Received":"by 2002:adf:ecc3:: with SMTP id\n\ts3mr45016881wro.713.1641372970526; \n\tWed, 05 Jan 2022 00:56:10 -0800 (PST)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  5 Jan 2022 08:55:53 +0000","Message-Id":"<20220105085553.12092-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20220105085553.12092-1-david.plowman@raspberrypi.com>","References":"<20220105085553.12092-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 3/3] libcamera: pipeline: raspberrypi:\n\tUpdate sensor's V4L2_CID_NOTIFY_GAINS 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"If the sensor exposes the V4L2_CID_NOTIFY_GAINS control, assume it\nmeans the sensor wants to be told the latest colour gains.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 26 +++++++++++++++++++\n 1 file changed, 26 insertions(+)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex b5c687da..0d4b5a57 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1495,6 +1495,32 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &\n \tRequest *request = requestQueue_.front();\n \trequest->metadata().merge(controls);\n \n+\t/*\n+\t * If the sensor has the V4L2_CID_NOTIFY_GAIN control then it wants\n+\t * to be notified of the latest colour gains.\n+\t */\n+\tauto it = sensor_->controls().find(V4L2_CID_NOTIFY_GAINS);\n+\tif (it != sensor_->controls().end()) {\n+\t\tif (controls.contains(libcamera::controls::ColourGains)) {\n+\t\t\tlibcamera::Span<const float> colourGains = controls.get(libcamera::controls::ColourGains);\n+\t\t\t/*\n+\t\t\t * This control is a linear gain value where the default is\n+\t\t\t * defined to correspond to a gain of 1. The order of the gains\n+\t\t\t * is always B, Gb, Gr, R.\n+\t\t\t */\n+\t\t\tint unity = it->second.def().get<int32_t>();\n+\t\t\tControlList ctrls(sensor_->controls());\n+\t\t\tint32_t gains[4] = { static_cast<int32_t>(colourGains[1] * unity),\n+\t\t\t\t\t     unity, unity,\n+\t\t\t\t\t     static_cast<int32_t>(colourGains[0] * unity) };\n+\t\t\tControlValue c(Span<const uint8_t>{ reinterpret_cast<uint8_t *>(gains),\n+\t\t\t\t\t\t\t    sizeof(gains) });\n+\t\t\tctrls.set(V4L2_CID_NOTIFY_GAINS, c);\n+\n+\t\t\tsensor_->setControls(&ctrls);\n+\t\t}\n+\t}\n+\n \tstate_ = State::IpaComplete;\n \thandleState();\n }\n","prefixes":["libcamera-devel","v2","3/3"]}