From patchwork Wed Jan 5 08:55:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 15250 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5D963C3259 for ; Wed, 5 Jan 2022 08:56:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 620A06092D; Wed, 5 Jan 2022 09:56:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="nHS6l6QL"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 07B1960926 for ; Wed, 5 Jan 2022 09:56:11 +0100 (CET) Received: by mail-wr1-x42d.google.com with SMTP id w20so72469522wra.9 for ; Wed, 05 Jan 2022 00:56:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2iOjoJzhQiUFBoBAf6DIvEvkVxPUvfqaF5r4J7kxYJ0=; b=nHS6l6QLkUHnV5MvoSDLTa0SHfxegf/fPkXvvteNziWNtIRKuDJLxYSJf32owsLunC LKaPAvJZjRWV7KUX9KMpXfDEhxtAFAgrGadL5xw9LAOZ2o6apBKAuvNFCbNvFNukd48D KtGwdjHKcp3jI1e37yZzPALtpjJwNbFBYscBy2eFhx+hAzI4brkN22zE9Vatogzv0hVe 1L76Z31bCFG4m8DwKK67BFdMRGL/IgmUy2lqW4x8BePKdQhvxI76GIeP3lJ0sIXWsgD6 wBKhss29YCg5jqpr39cFiiIcsNxutJ+D64rzJdpjMNVy6mQMbCyPLADorsk7+idiJJT9 BjNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2iOjoJzhQiUFBoBAf6DIvEvkVxPUvfqaF5r4J7kxYJ0=; b=sV/skqTJ9a11KOR4eMOK57ze6i2KhmyFcJLojWb3Hi2DiK9OJlLK8NgWcDWDzqgiWv /thX0EIA7Z4R12WOPDS3+mcPrVRW36XkcJBTD7nraIJywi/fQaxZMqhy6J8bmVkrbBK9 uvGM4/svnYQ/dImzcnAAxn3zSXBMtZkHsXr/2B5kb4Z14Q+dGeDYkN37b6wextZU9Tsx A3xwTRPMLDtMDxlVyEJbFe6+NDHtUi5oolVZ6LJMjfQDSKQ4BchDnqCmhQyQyKUt7b7J O0W1+sxWyAMbEspqJNYjP4vJ32phHvMKrqljqM5AYX12ZPkuXS4PvCq2BMSiHK21bFoG 7aUg== X-Gm-Message-State: AOAM53254KBoM+RCoT7yllHG62m2B90Ri1eKzNUXP7aC3vYsuaqqqygx 7UysflLufl2yFKKO9tjWkApIFQpDA57LDa4+ X-Google-Smtp-Source: ABdhPJwf6dItMK2XXD9qIUlqPppdMLf0wqsfmTTzNlqJt22vlwE3Tu8C4Fqy0zsOviiDXBPvESGoUw== X-Received: by 2002:adf:ecc3:: with SMTP id s3mr45016881wro.713.1641372970526; Wed, 05 Jan 2022 00:56:10 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id g8sm1902149wmh.17.2022.01.05.00.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 00:56:10 -0800 (PST) From: David Plowman 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 Subject: [libcamera-devel] [PATCH v2 3/3] libcamera: pipeline: raspberrypi: Update sensor's V4L2_CID_NOTIFY_GAINS control X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If the sensor exposes the V4L2_CID_NOTIFY_GAINS control, assume it means the sensor wants to be told the latest colour gains. Signed-off-by: David Plowman --- .../pipeline/raspberrypi/raspberrypi.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index b5c687da..0d4b5a57 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1495,6 +1495,32 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList & Request *request = requestQueue_.front(); request->metadata().merge(controls); + /* + * If the sensor has the V4L2_CID_NOTIFY_GAIN control then it wants + * to be notified of the latest colour gains. + */ + auto it = sensor_->controls().find(V4L2_CID_NOTIFY_GAINS); + if (it != sensor_->controls().end()) { + if (controls.contains(libcamera::controls::ColourGains)) { + libcamera::Span colourGains = controls.get(libcamera::controls::ColourGains); + /* + * This control is a linear gain value where the default is + * defined to correspond to a gain of 1. The order of the gains + * is always B, Gb, Gr, R. + */ + int unity = it->second.def().get(); + ControlList ctrls(sensor_->controls()); + int32_t gains[4] = { static_cast(colourGains[1] * unity), + unity, unity, + static_cast(colourGains[0] * unity) }; + ControlValue c(Span{ reinterpret_cast(gains), + sizeof(gains) }); + ctrls.set(V4L2_CID_NOTIFY_GAINS, c); + + sensor_->setControls(&ctrls); + } + } + state_ = State::IpaComplete; handleState(); }