From patchwork Thu Dec 23 08:01:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 15216 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 4BA1BBF415 for ; Thu, 23 Dec 2021 08:01:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CD8F36090B; Thu, 23 Dec 2021 09:01:52 +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="meQa8Mas"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8EAFB608E9 for ; Thu, 23 Dec 2021 09:01:49 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id g132so3097427wmg.2 for ; Thu, 23 Dec 2021 00:01:49 -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=1QsZ86bS7xwdusxElYMZXbDSb1QXgHVtUoaZ6zHoxL4=; b=meQa8Mas+VGmExFWYetmUq2j9vr4iQERxhUJhOkgZTfJg8VqDw/Az7BKfzRk195Prj 6wPgqfFFriulTzau193hY58zcJPkAYXhsVNTtg/gRlxAKXFWSPaV3Tx6rNwRulVEmBYY zl8zFtH8FHeMrX6pC/n2LDsnsBw0TfF1lpmhdNew+y0v94DUumN3FsswJlJyeM7S3oEI yX67iJ4BCEfbPgFiDhBpwTRgqNXlTiw0X75rjS5iQ5loOPeEKW9DpINFCvOe4trAFuvO kUMTowYlh4LzygPb9Cakcj5+KdYIks91juI1qfYniA3GClrbEvKm6zoX1iqUcWZJ9ebY QUXg== 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=1QsZ86bS7xwdusxElYMZXbDSb1QXgHVtUoaZ6zHoxL4=; b=W5sIg7ktTXlQc0jsvUUSrCqxK8CW1XXqjgIzYYq8uLDjW1mMKUPeynChYH3aaWk52a W6ogmKe/BM0VJOjdeQ65PdXMRk5r/fHxJ//07E88zmg1vTXFRMeZifh7QIYhHxsuuoEK oFj52XQGsfG1rm2/YAEV2ungN40rncwtxAlB/Ch20+caA3SbJ+oxsmKrA9P+4g91m4T7 uhXdU9kYWLaxEmNUOa7Lezl1X0vEo1g3P2+Imp64BW4CsKdFGp+ytBrtMGPgCvd4skWO 5Gcn4NSwT28/Wje7mTLI17fmLSRdHyMFqiJ9A8d27V1pwZL9XdOu36yTr8Uvrx3SxFUf dcEw== X-Gm-Message-State: AOAM5303XiO513rPT7f0Hf2VOEJGcFW6YQH84dcfoddewd6Dc++ARyHZ UU9rjZQ2CaT09xFU4R3Em42W4T0LXfwQ6w== X-Google-Smtp-Source: ABdhPJwoswSGVibwNvMbwKvtEyTkQVV2+lknzt5tNy9bj1RfT9cygTWjC9JhnfhB1BI69pDZjwIoWQ== X-Received: by 2002:a1c:ed07:: with SMTP id l7mr773617wmh.12.1640246509098; Thu, 23 Dec 2021 00:01:49 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id a3sm4692730wri.98.2021.12.23.00.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 00:01:48 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 23 Dec 2021 08:01:08 +0000 Message-Id: <20211223080110.9766-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211223080110.9766-1-david.plowman@raspberrypi.com> References: <20211223080110.9766-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] include: linux: Add 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" Add this control which is already present upstream. Signed-off-by: David Plowman --- include/linux/v4l2-controls.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/v4l2-controls.h b/include/linux/v4l2-controls.h index 59a57418..9db06cb2 100644 --- a/include/linux/v4l2-controls.h +++ b/include/linux/v4l2-controls.h @@ -1109,6 +1109,7 @@ enum v4l2_jpeg_chroma_subsampling { #define V4L2_CID_TEST_PATTERN_BLUE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 6) #define V4L2_CID_TEST_PATTERN_GREENB (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 7) #define V4L2_CID_UNIT_CELL_SIZE (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 8) +#define V4L2_CID_NOTIFY_GAINS (V4L2_CID_IMAGE_SOURCE_CLASS_BASE + 9) /* Image processing controls */ From patchwork Thu Dec 23 08:01:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 15217 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 7903DC3258 for ; Thu, 23 Dec 2021 08:01:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A07CD60908; Thu, 23 Dec 2021 09:01:53 +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="jAUfGyaw"; dkim-atps=neutral Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7023F608E9 for ; Thu, 23 Dec 2021 09:01:50 +0100 (CET) Received: by mail-wm1-x32f.google.com with SMTP id c66so3077876wma.5 for ; Thu, 23 Dec 2021 00:01:50 -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=rfKOot9GmUhxezKsQbyuCgb3G0DBk/IKhALkQP2p3VU=; b=jAUfGyaw/LZdEcSqY7votC9beJtZ9nTIm/UckTgDF733s2XKeI8DLj9R6/crAClO3v Lhpm4+sKX9YuJQ9VTKGsnT8KjPFLPMWw+tMlrwd7LDRDOnDIwQN2U3hTNWIQXYA2qCi1 TA6+ew4v4tciJOw5ZhWkLiszhNt+5Kxp2EcnK3PnVuClvqivbbL241EB3Jg7k3eDJg/9 KMTDpljDXnCJB2aGTW67RT2RcbRGRxkrKe7tLlLxkkwesShmJwbfpvlTL5MgwxwsJj6x jwYCt9rVeOPBf/Trob+lEEUtdMa7IC9T7eJ4TaAziEK52iaGgIdgg0XxXV/i4PJgvvou PJSQ== 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=rfKOot9GmUhxezKsQbyuCgb3G0DBk/IKhALkQP2p3VU=; b=3H1bE1bt8FWJm+Ka+Zwzss3LFvNgt+Q0ssiY06VMRqNuMPlt8/t3AS/BPPBkS4f0JV aKbsRxDHK/M7F6MgAGOFtinJIoLWGVYoBWlMAX0nd2pHGFesveFLje29kocotW/Z4vBf Vkom6Gesm1A6NCD16RG/nFGfkyaApARSElYgYEEOMcGrS+3ouHKEZrxPr0B+8fbiOB5F DiChPnuo2gWptqLDrwQelbA//xkqDADgvkYryVY/zA3IUtNU861Cqvu8hOUSMXag+4xG /ZH7kdttMN0Pn16eawI6szLDdhWock1OwQMHkkuzRfdMJLZCjWLFme3o76ckJ48JHntg pfoA== X-Gm-Message-State: AOAM532g6tEUYAfk82bg40vpWv1LRdeh0heJsWV3xURF5rxFCezO51Kp VTHOzr+oYbpUpl79rTXQ69h/x3cbgjb8oA== X-Google-Smtp-Source: ABdhPJwBJj65SC+tr6VqGJ+HEDVccznj5PThgqnFQOh0jWW331QLAwspkpjHaAHQukYMBjZ0teQ5VA== X-Received: by 2002:a1c:f304:: with SMTP id q4mr771754wmq.162.1640246509961; Thu, 23 Dec 2021 00:01:49 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id a3sm4692730wri.98.2021.12.23.00.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 00:01:49 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 23 Dec 2021 08:01:09 +0000 Message-Id: <20211223080110.9766-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211223080110.9766-1-david.plowman@raspberrypi.com> References: <20211223080110.9766-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] libcamera: v4l2_device: Add support for integer array controls 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" Signed-off-by: David Plowman --- src/libcamera/v4l2_device.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 62c91779..6f9de8ad 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -316,6 +316,18 @@ int V4L2Device::setControls(ControlList *ctrls) break; } + case ControlTypeInteger32: { + if (value.isArray()) { + Span data = value.data(); + v4l2Ctrl.p_u32 = reinterpret_cast(data.data()); + v4l2Ctrl.size = data.size(); + } else { + v4l2Ctrl.value = value.get(); + } + + break; + } + default: /* \todo To be changed to support strings. */ v4l2Ctrl.value = value.get(); From patchwork Thu Dec 23 08:01:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 15218 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 435B4BF415 for ; Thu, 23 Dec 2021 08:01:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7E65D60909; Thu, 23 Dec 2021 09:01:55 +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="V2dr61pd"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 595AA60908 for ; Thu, 23 Dec 2021 09:01:51 +0100 (CET) Received: by mail-wm1-x335.google.com with SMTP id g132so3097458wmg.2 for ; Thu, 23 Dec 2021 00:01:51 -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=1xgOi85a1Kf11O4bZiB4HzBhTUoQ8d1X9czgP0d1Soc=; b=V2dr61pdNkmcA4lKvpZQ0B1STFsYrJ3gmbzqn2i3bOo9/MC7PuqUicgwW6zJuso9Cm J9wbFBv5Ws7GQkhCY2YlOs6VvdiWnk+qS3dKurV6ocm2u57EqC7UyCm60kdGuNMOI5R1 jU0JCPhgebWiXMG4xQl5Ssspn84ie3VVC93bh0hazjgsCd8M/vskymEnr9Ai0fhUcK+h RRiXkXdC7jEWO8YMvq2QiOUUUxx7WWJEU3shF1FbRuCAreXS33q/S9haSGxinKIMikIc HQSjyoM0LMkVJ6gY1hc0ED7ncQefUtnx0jP5MChRDm00bCJAuDfr+5vQdz3xK/ziAfsI FoxA== 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=1xgOi85a1Kf11O4bZiB4HzBhTUoQ8d1X9czgP0d1Soc=; b=3gapPzRJvxYXBfv88FOJVeGOlMZaoDgC77JiosGBetiwsDjr2sgut2oeDonh1bxT5h NgmObXCSS9TAMFdt/cnmzZgVDWabrg9UC9tVRz7j+kwxZJzOxAWEavIUQngXysjGUPMS CnWLajUzQbmiVWIktTAoex+OINT1sWbC8S2zJoupgf7Y/xe0tn+Uu4cEsxWC8/c9GUKm ibZffDlvT/poHZRrKg7bT65MNYeW+79XI1Fw5azMpUMLQHZhhUhT42oQ6SFrk2e5OKV5 PrssopGCwyxotKx+5cT7o/MvQ8cAazGuDnDozoCmGX4E6osOJDys1sxCoUzVsd0/J0/d ZvOw== X-Gm-Message-State: AOAM530VzS5J6u8Zj9RZggwQo04GGpojKC3TntS8NF686TLQc5l/PpCX wNXICxUE5y9tB8ScrbeKXIh1jf4BUCAHZw== X-Google-Smtp-Source: ABdhPJzwYIatLBPU1aVT0B5xP/8SwF8iplS+KWl4vQ0y9OZJ1HwdXmi0xavSsMaioTsezvJ2vyXlZA== X-Received: by 2002:a05:600c:5009:: with SMTP id n9mr907038wmr.162.1640246510594; Thu, 23 Dec 2021 00:01:50 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id a3sm4692730wri.98.2021.12.23.00.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 00:01:50 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Thu, 23 Dec 2021 08:01:10 +0000 Message-Id: <20211223080110.9766-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211223080110.9766-1-david.plowman@raspberrypi.com> References: <20211223080110.9766-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] ipa: raspberrypi: Update sensor's V4L2_CID_NOTIFY_GAINS control when present 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 controls, assume it wants to be told the colour gains. We want these to be applied as soon as possible so we add a new setSensorControls signal to the IPA which passes these back to the pipeline handler without using the DelayedControls mechanism. Signed-off-by: David Plowman --- include/libcamera/ipa/raspberrypi.mojom | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 22 +++++++++++++++++++ .../pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++++ 3 files changed, 33 insertions(+) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index acd3cafe..e7647724 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -123,6 +123,7 @@ interface IPARPiEventInterface { statsMetadataComplete(uint32 bufferId, libcamera.ControlList controls); runIsp(uint32 bufferId); embeddedComplete(uint32 bufferId); + setSensorControls(libcamera.ControlList controls); setIspControls(libcamera.ControlList controls); setDelayedControls(libcamera.ControlList controls); }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 0ed41385..8c20c066 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1061,6 +1061,28 @@ void IPARPi::processStats(unsigned int bufferId) setDelayedControls.emit(ctrls); } + + auto itCtrl = sensorCtrls_.find(V4L2_CID_NOTIFY_GAINS); + if (itCtrl != sensorCtrls_.end()) { + struct AwbStatus awbStatus; + if (rpiMetadata_.Get("awb.status", awbStatus) == 0) { + /* + * 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 = itCtrl->second.def().get(); + ControlList ctrls(sensorCtrls_); + int32_t gains[4] = { static_cast(awbStatus.gain_b * unity), + unity, unity, + static_cast(awbStatus.gain_r * unity) }; + ControlValue c(Span{ reinterpret_cast(gains), + sizeof(gains) }); + ctrls.set(V4L2_CID_NOTIFY_GAINS, c); + + setSensorControls.emit(ctrls); + } + } } void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index b5c687da..59d3bbd8 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -196,6 +196,7 @@ public: void statsMetadataComplete(uint32_t bufferId, const ControlList &controls); void runIsp(uint32_t bufferId); void embeddedComplete(uint32_t bufferId); + void setSensorControls(const ControlList &controls); void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls); void setSensorControls(ControlList &controls); @@ -1405,6 +1406,7 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig) ipa_->statsMetadataComplete.connect(this, &RPiCameraData::statsMetadataComplete); ipa_->runIsp.connect(this, &RPiCameraData::runIsp); ipa_->embeddedComplete.connect(this, &RPiCameraData::embeddedComplete); + ipa_->setSensorControls.connect(this, &RPiCameraData::setSensorControls); ipa_->setIspControls.connect(this, &RPiCameraData::setIspControls); ipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls); @@ -1524,6 +1526,14 @@ void RPiCameraData::embeddedComplete(uint32_t bufferId) handleState(); } +void RPiCameraData::setSensorControls(const ControlList &controls) +{ + ControlList ctrls = controls; + + sensor_->setControls(&ctrls); + handleState(); +} + void RPiCameraData::setIspControls(const ControlList &controls) { ControlList ctrls = controls;