From patchwork Fri Oct 20 08:40:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19166 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 76C2CC3275 for ; Fri, 20 Oct 2023 08:40:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 245E562982; Fri, 20 Oct 2023 10:40:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697791236; bh=ylFITJcGz25qrF6i5eL+oH9LlPjYqrPKrAPETAxOwoY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mmEEJo+z6ewRBHi0JUZwfV8VXZgaMGyeY/74dryaTsbe+CXqQh0B3TEWlFKyAUM1y vxErD839o76px9nKs4rkc0wFTnJEtY+vKjnOY84fyf8ZHCeLKnwmcXMRl869GHUnC7 gxV3Hc9Gs1AoDAR8hGW3Nl7LEeQ9RCD7GQ6+l2hpsIBQnNO6Bwq8oaObb+EPLT7HGi FXZTvlT7JkYUXXRh75oq+fP/uss5yn2vZlRZQaTL3GuqCgFBmti8d1a4w7jT+KR3V9 Jhn74F3cLstoE8S3+K1F55lO/W67RJ4SVrwRUwqYJnRgaEFOS/D6ut2VmQgWcWP7wL yAfuZ2VTnajFQ== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B26B61DCF for ; Fri, 20 Oct 2023 10:40:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="dLUBsBAo"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-32d9b507b00so434590f8f.1 for ; Fri, 20 Oct 2023 01:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697791230; x=1698396030; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A0D0tXnU990HtWARhVc3XMkpdyaSBOIWYzTRIuhHRcc=; b=dLUBsBAoKSQq8Fx6SUOG+YYxWPdiJMeOBCSClTvg/fM8BTZs+XSz136CViSFxzIXGU 396Cel1JSljFsKe4KjyyOZLy6gJMQedooZKp9RST4hK6aJ14EP0H1j9MyH0bnVe3HwPS 4E2jIlbObFHRdTX/U6Xv9JSMHlqmp0Evkqx45Km0MSDCWtyOCowpQBScP0ot6B8Q6/pp SOcGr5Vj0C9az/1L+ngxI6dMciYwwIRYTfh4bja2Og1AXIXpftAuXRlVYonIouT7fsum wTLf1rhneyKB7AWvRyKTYdntFHAhX1edcMwKqj2ejgVvAPf1iMH70CLVVIVzGx9CICF9 5wLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697791230; x=1698396030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A0D0tXnU990HtWARhVc3XMkpdyaSBOIWYzTRIuhHRcc=; b=F+jDQWDMvP4wzvksR17ttRo7008ZpvAW5bqF47R7/clrr8YzX4zDPmAFozOf0CetI2 td/7XZDZnl1RT+f0tv+83p6gxQgnDs1qfiG4zcF4E5A+R8vyMa2oqXhe9b8HngwhPAhj Qrs+eJVkKBKIzAC5qzoW4x33NqJfG6TwNRojiJAw9N0hrN97R6OMY6FtTfeupWv2IX4L Vn4dABuMF7DFHye65EYMI70Mnyz3I2xU1tpwwEdk9ikhuFCUH3/zV+LBAbLxjYpAqcLf rDCo9ayVsVvgVt7APVG+OfqAChdjxqlrhyU0rZNcPbsJoxx1taj9qJh6N4vtieHd2Z14 dePQ== X-Gm-Message-State: AOJu0Ywdy0e4HKn+TWGXpljYPukVhnWBFtZz0jVHVmYYpXkEn8BClDYf pYDK73yTUKVIPCmu5h739Cujb/GQ8z9zfZTsHk95JQ== X-Google-Smtp-Source: AGHT+IHNtWK8arF3ev0j4V8har8751+XVA0bwLcUQuP0IBRCh4IRXcvBZSuZt8In9KvWddSnaZeiVA== X-Received: by 2002:adf:e5c8:0:b0:32d:6891:f819 with SMTP id a8-20020adfe5c8000000b0032d6891f819mr937397wrn.41.1697791230448; Fri, 20 Oct 2023 01:40:30 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id r3-20020adff103000000b0032d9337e7d1sm1213356wro.11.2023.10.20.01.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:40:29 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 20 Oct 2023 09:40:01 +0100 Message-Id: <20231020084002.30665-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020084002.30665-1-naush@raspberrypi.com> References: <20231020084002.30665-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 5/6] ipa: rpi: agc: Fetch AWB status in the prepare method 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: David Plowman AWB writes this out during prepare, so we may as well read it in AGC prepare as well. Reading it in process is wrong on the PiSP platform because process runs before prepare, so the AWB status won't be there (on vc4 it made no difference). Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/rpi/controller/rpi/agc_channel.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp index 3efb6482b67f..8d374b53689d 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp @@ -270,7 +270,11 @@ AgcChannel::AgcChannel() lastTargetExposure_(0s), ev_(1.0), flickerPeriod_(0s), maxShutter_(0s), fixedShutter_(0s), fixedAnalogueGain_(0.0) { - memset(&awb_, 0, sizeof(awb_)); + /* Set AWB default values in case early frames have no updates in metadata. */ + awb_.gainR = 1.0; + awb_.gainG = 1.0; + awb_.gainB = 1.0; + /* * Setting status_.totalExposureValue_ to zero initially tells us * it's not been calculated yet (i.e. Process hasn't yet run). @@ -409,7 +413,6 @@ void AgcChannel::switchMode(CameraMode const &cameraMode, Duration fixedShutter = limitShutter(fixedShutter_); if (fixedShutter && fixedAnalogueGain_) { /* We're going to reset the algorithm here with these fixed values. */ - fetchAwbStatus(metadata); double minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 }); ASSERT(minColourGain != 0.0); @@ -464,6 +467,9 @@ void AgcChannel::prepare(Metadata *imageMetadata) AgcStatus delayedStatus; AgcPrepareStatus prepareStatus; + /* Fetch the AWB status now because AWB also sets it in the prepare method. */ + fetchAwbStatus(imageMetadata); + if (!imageMetadata->get("agc.delayed_status", delayedStatus)) totalExposureValue = delayedStatus.totalExposureValue; @@ -507,8 +513,6 @@ void AgcChannel::process(StatisticsPtr &stats, DeviceStatus const &deviceStatus, * configuration, that kind of thing. */ housekeepConfig(); - /* Fetch the AWB status immediately, so that we can assume it's there. */ - fetchAwbStatus(imageMetadata); /* Get the current exposure values for the frame that's just arrived. */ fetchCurrentExposure(deviceStatus); /* Compute the total gain we require relative to the current exposure. */ @@ -637,9 +641,6 @@ void AgcChannel::fetchCurrentExposure(DeviceStatus const &deviceStatus) void AgcChannel::fetchAwbStatus(Metadata *imageMetadata) { - awb_.gainR = 1.0; /* in case not found in metadata */ - awb_.gainG = 1.0; - awb_.gainB = 1.0; if (imageMetadata->get("awb.status", awb_) != 0) LOG(RPiAgc, Debug) << "No AWB status found"; }