From patchwork Wed May 31 14:39:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18673 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 5BD81C31E9 for ; Wed, 31 May 2023 14:39:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1F0AA627D1; Wed, 31 May 2023 16:39:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1685543991; bh=7BZN1AlolWFBEMGDgGFilHATZjbmFpEyNl3QkaYxdDs=; 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=JYutwI9qi+Z5cp6Hzgn4DbKzVzA7uMZXfsJaJEUCOehPiydAVGn/Md83emhQQIRfu OLYnxedDbsS69TTsYAHvnaIp8ArtFrw5nIN7MpSfS0bgay7Mb7hIp//ArgCBVMt3pD KJH1ktCMleQtZhrcdYXK+QQ+dFsrH+vGrM7kSEBXVjlG96NDNnD+6+Ctjibim9FtP/ DtiyldBbX2glAxREQQnO5Xbud4SD+VAB92i+5lgp+Yvzem2ucU3yBahepn3IxtsVwP pws3pfQ13nfaXiLUMJ/2jEjZDvs+wja0Zwgdq8ZNPXiEOjH8+8fymBXMV2/pRQRwy6 FYXTpdUAiFkIA== Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9D7AE62763 for ; Wed, 31 May 2023 16:39:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="FWNEhpex"; dkim-atps=neutral Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4f004cc54f4so6927665e87.3 for ; Wed, 31 May 2023 07:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1685543987; x=1688135987; 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=tcqo6e3wIxKk44o7NyMRaUqwC8ijo2NlEHwDdfflmN8=; b=FWNEhpexzIrlSC6ViOIo3AnsRjui3NvExjMP2T8Br5ngqKvrRWRiGkGqoJ/vuEzpRg Aiw28O7Obxj7je/AwVrMeyZo88GAh94VSHEryYQh7b9ngRShWbOQ/aKyESTOrhhxVcWm RqfZt2dtTJxQ+KHkSsCC7LnnD6vI2ioCbo8aIjkH1mVE5lDlZrCt1dniN3rvUkRI7DSZ 9I0HIU8cC22c1v5L6CB0CNNpBKcYLWYexU69aYFaM/UwOilNqVWC2f3c0AZZpDo9DgYf 6/cFihqNjKOy/602Xd5aHPyYK2xVigIRsHzmNEG8Kkfw8TSb7dpZMYv9s4oO6IEod0/a pS8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685543987; x=1688135987; 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=tcqo6e3wIxKk44o7NyMRaUqwC8ijo2NlEHwDdfflmN8=; b=JOUoYRskdG0D4ACraN/kLR7KxhEp1zaeWqkZx6IsN61xKOxh0n/A6WvEjCO0l55QJg /rJxt0/DK+whu0gp0OBH85AtT1bcTu+7qHuIOkxx7k8y7WRPlWhGw4lFVofU8MZy79cM pBWFNulbWnh1eD8m84oN+PoAGOZ9NuTgaa+Ktjd8tXbjycZZA0Ed7Ch5UY/m3LAlforq QQKWUnXbY3BCWtOUE7fbRzTp7TIqtnUYZnS00yZpZV8cRxaBJOaNsQLLXTRLdSGcQ2lY eq0W3844UyyZjDVzEycjEEcOlxP/hCfPXR7PX9gmdQSBsJrTQvu5vVQXA8TJ5eS0G+cW lgnA== X-Gm-Message-State: AC+VfDwsHWhkxpBEGF7UQZ1OyDO+QduaOcf282phP5KWzmCnCKhNZf9v NrNhKu97nH4S8kSWLw2q/cXLQ/BeBxyUF/1frXaQeQ== X-Google-Smtp-Source: ACHHUZ6+dByuE2IphRNlk9Nv2glEW9bM5H65SGVwCWFheykryr4f+9et8HZNzxIbve8T2CBjnDk/sQ== X-Received: by 2002:ac2:599e:0:b0:4f4:d83e:4134 with SMTP id w30-20020ac2599e000000b004f4d83e4134mr2626348lfn.57.1685543987420; Wed, 31 May 2023 07:39:47 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bf3-20020a0560001cc300b00307b5376b2csm6950706wrb.90.2023.05.31.07.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 07:39:47 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 31 May 2023 15:39:46 +0100 Message-Id: <20230531143946.23571-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531143946.23571-1-naush@raspberrypi.com> References: <20230531143946.23571-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/2] ipa: rpi: Handle controls for mono variant sensors 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" Do not advertise colour related controls (i.e. [A]WB, colour saturation) in the ControlInfoMap of available controls returned out to the application. Silently fail these controls in the control handler in case applications don't use the advertised ControlInfoMap to validate controls. As a drive-by, don't advertise controls::ColourCorrectionMatrix in the ControlInfoMap as it is not handled by the IPA. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/rpi/common/ipa_base.cpp | 34 ++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 150fe433d0df..8de454637cfe 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -60,19 +60,22 @@ const ControlInfoMap::Map ipaControls{ { &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) }, { &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) }, { &controls::ExposureValue, ControlInfo(-8.0f, 8.0f, 0.0f) }, - { &controls::AwbEnable, ControlInfo(false, true) }, - { &controls::ColourGains, ControlInfo(0.0f, 32.0f) }, - { &controls::AwbMode, ControlInfo(controls::AwbModeValues) }, { &controls::Brightness, ControlInfo(-1.0f, 1.0f, 0.0f) }, { &controls::Contrast, ControlInfo(0.0f, 32.0f, 1.0f) }, - { &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) }, { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) }, - { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) }, { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, { &controls::FrameDurationLimits, ControlInfo(INT64_C(33333), INT64_C(120000)) }, { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) } }; +/* IPA controls handled conditionally, if the sensor is not mono */ +const ControlInfoMap::Map ipaColourControls{ + { &controls::AwbEnable, ControlInfo(false, true) }, + { &controls::AwbMode, ControlInfo(controls::AwbModeValues) }, + { &controls::ColourGains, ControlInfo(0.0f, 32.0f) }, + { &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) }, +}; + /* IPA controls handled conditionally, if the lens has a focus control */ const ControlInfoMap::Map ipaAfControls{ { &controls::AfMode, ControlInfo(controls::AfModeValues) }, @@ -145,6 +148,8 @@ int32_t IpaBase::init(const IPASettings &settings, const InitParams ¶ms, Ini /* Return the controls handled by the IPA */ ControlInfoMap::Map ctrlMap = ipaControls; + if (!monoSensor_) + ctrlMap.merge(ControlInfoMap::Map(ipaColourControls)); if (lensPresent_) ctrlMap.merge(ControlInfoMap::Map(ipaAfControls)); result->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls); @@ -221,6 +226,9 @@ int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa ControlInfo(static_cast(mode_.minShutter.get()), static_cast(mode_.maxShutter.get())); + if (!monoSensor_) + ctrlMap.merge(ControlInfoMap::Map(ipaColourControls)); + /* Declare Autofocus controls, only if we have a controllable lens */ if (lensPresent_) ctrlMap.merge(ControlInfoMap::Map(ipaAfControls)); @@ -781,6 +789,10 @@ void IpaBase::applyControls(const ControlList &controls) } case controls::AWB_ENABLE: { + /* Silently ignore this control for a mono sensor. */ + if (monoSensor_) + break; + RPiController::AwbAlgorithm *awb = dynamic_cast( controller_.getAlgorithm("awb")); if (!awb) { @@ -800,6 +812,10 @@ void IpaBase::applyControls(const ControlList &controls) } case controls::AWB_MODE: { + /* Silently ignore this control for a mono sensor. */ + if (monoSensor_) + break; + RPiController::AwbAlgorithm *awb = dynamic_cast( controller_.getAlgorithm("awb")); if (!awb) { @@ -820,6 +836,10 @@ void IpaBase::applyControls(const ControlList &controls) } case controls::COLOUR_GAINS: { + /* Silently ignore this control for a mono sensor. */ + if (monoSensor_) + break; + auto gains = ctrl.second.get>(); RPiController::AwbAlgorithm *awb = dynamic_cast( controller_.getAlgorithm("awb")); @@ -868,6 +888,10 @@ void IpaBase::applyControls(const ControlList &controls) } case controls::SATURATION: { + /* Silently ignore this control for a mono sensor. */ + if (monoSensor_) + break; + RPiController::CcmAlgorithm *ccm = dynamic_cast( controller_.getAlgorithm("ccm")); if (!ccm) {