From patchwork Tue Jan 26 15:47:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 11008 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 4961FC0F2B for ; Tue, 26 Jan 2021 15:47:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BE04C6830F; Tue, 26 Jan 2021 16:47:31 +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="mn9P5KgI"; dkim-atps=neutral Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 22A4068301 for ; Tue, 26 Jan 2021 16:47:30 +0100 (CET) Received: by mail-ej1-x633.google.com with SMTP id g3so23610401ejb.6 for ; Tue, 26 Jan 2021 07:47:29 -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:mime-version :content-transfer-encoding; bh=UZGTEGqk3F9NqM5bFNbmjHK/uu8P7EOytQl9bnSvWcg=; b=mn9P5KgIssSMiETvIl4AZsZ5NxaxdW27idwq16odK/cmqzqD/zB5BGp4IDLzGi68Wo l5rdkB/Hniy0dPtJBhspRUcN3TcwNfulDidlZdeFuLWcrNkDYgcSUdZA5d3m/KYRpyTx 35xZe21qn9/UqpKnsQhsbOlmpbbith1xzg0oxSf7oV0ezo2si5fj8RB+3L5PyS3K8vhZ eyNwEuPu2+x1qgpSgFkMEemAdKUo2aG/TO8mQO3G+aeDonK3ASuTdY64VpbmNepceKY+ sFetBfM0yltJt0bHkfC9+gFK/IOvatt5E5tuhA0Mm08dW0cJ4bn4qKCzGExh5Daqca0d HdFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UZGTEGqk3F9NqM5bFNbmjHK/uu8P7EOytQl9bnSvWcg=; b=Jm7pams2yp3NtF5/XJSCHwscO1hlSu7SWFIv2TZ81hotl/zb6/cDAkJILm/Kxzt8O4 UeY/IFceKia4YAsXm3w1EwdMyZHIc8iaAgZQYqpyndxTdopRsGYSrvl2RALRU48fSWcx 49BsozD2nmvftKUknMHOAGm0ETOUWFn2wNpKx9WZoAhXCQYaMqW3+eWngGFJF43KmeAb +z+j8sqjMf7Ncq4Zm5L9PAlNZThhp7gRe4tsgdtE//Sg5S57Tgimldn/xVGv4EYXq6nj orSGMMs6Vsm43xnqFJCNtxrdzEb31yGpQH9zJH/XsiH5vURRmcRfO/75uF93amG9L0nl m6dQ== X-Gm-Message-State: AOAM530shsLzQRh8Zqjznp7QIYR/uj5iBN7B90lDh5oNAbdSK8wua+ff et8tpVnvxR8Ki4Lav9J1P05jYQX/X9xSYohX X-Google-Smtp-Source: ABdhPJzzEO9pke8zD+pGzZ0MpPBZBWG/6NM+WqoiYQhXBfIj+sTWr565qZRdSGMOe2qFFN3Vpt5skA== X-Received: by 2002:a17:906:17c3:: with SMTP id u3mr3736103eje.304.1611676049255; Tue, 26 Jan 2021 07:47:29 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id l16sm12631384edw.10.2021.01.26.07.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 07:47:28 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 15:47:24 +0000 Message-Id: <20210126154724.7155-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] ipa: raspberrypi: Warn when control algorithms are missing; do not fail 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" Users are free to avoid loading certain control algorithms from the json tuning file if they wish. Under such circumstances, failing completely when an application tries to set parameters for that algorithm is unhelpful, and it is better just to issue a warning. Signed-off-by: David Plowman Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/raspberrypi.cpp | 86 ++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 14 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 5ccc7a65..b57d77e9 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -627,7 +627,12 @@ void IPARPi::queueRequest(const ControlList &controls) switch (ctrl.first) { case controls::AE_ENABLE: { RPiController::Algorithm *agc = controller_.GetAlgorithm("agc"); - ASSERT(agc); + if (!agc) { + LOG(IPARPI, Warning) + << "Could not set AE_ENABLE - no AGC algorithm"; + break; + } + if (ctrl.second.get() == false) agc->Pause(); else @@ -640,7 +645,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::EXPOSURE_TIME: { RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.GetAlgorithm("agc")); - ASSERT(agc); + if (!agc) { + LOG(IPARPI, Warning) + << "Could not set EXPOSURE_TIME - no AGC algorithm"; + break; + } /* This expects units of micro-seconds. */ agc->SetFixedShutter(ctrl.second.get()); @@ -652,7 +661,12 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::ANALOGUE_GAIN: { RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.GetAlgorithm("agc")); - ASSERT(agc); + if (!agc) { + LOG(IPARPI, Warning) + << "Could not set ANALOGUE_GAIN - no AGC algorithm"; + break; + } + agc->SetFixedAnalogueGain(ctrl.second.get()); libcameraMetadata_.set(controls::AnalogueGain, @@ -663,7 +677,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AE_METERING_MODE: { RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.GetAlgorithm("agc")); - ASSERT(agc); + if (!agc) { + LOG(IPARPI, Warning) + << "Could not set AE_METERING_MODE - no AGC algorithm"; + break; + } int32_t idx = ctrl.second.get(); if (MeteringModeTable.count(idx)) { @@ -679,7 +697,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AE_CONSTRAINT_MODE: { RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.GetAlgorithm("agc")); - ASSERT(agc); + if (!agc) { + LOG(IPARPI, Warning) + << "Could not set AE_CONSTRAINT_MODE - no AGC algorithm"; + break; + } int32_t idx = ctrl.second.get(); if (ConstraintModeTable.count(idx)) { @@ -695,7 +717,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AE_EXPOSURE_MODE: { RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.GetAlgorithm("agc")); - ASSERT(agc); + if (!agc) { + LOG(IPARPI, Warning) + << "Could not set AE_EXPOSURE_MODE - no AGC algorithm"; + break; + } int32_t idx = ctrl.second.get(); if (ExposureModeTable.count(idx)) { @@ -711,7 +737,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::EXPOSURE_VALUE: { RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.GetAlgorithm("agc")); - ASSERT(agc); + if (!agc) { + LOG(IPARPI, Warning) + << "Could not set EXPOSURE_VALUE - no AGC algorithm"; + break; + } /* * The SetEv() method takes in a direct exposure multiplier. @@ -726,7 +756,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AWB_ENABLE: { RPiController::Algorithm *awb = controller_.GetAlgorithm("awb"); - ASSERT(awb); + if (!awb) { + LOG(IPARPI, Warning) + << "Could not set AWB_ENABLE - no AWB algorithm"; + break; + } if (ctrl.second.get() == false) awb->Pause(); @@ -741,7 +775,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AWB_MODE: { RPiController::AwbAlgorithm *awb = dynamic_cast( controller_.GetAlgorithm("awb")); - ASSERT(awb); + if (!awb) { + LOG(IPARPI, Warning) + << "Could not set AWB_MODE - no AWB algorithm"; + break; + } int32_t idx = ctrl.second.get(); if (AwbModeTable.count(idx)) { @@ -758,7 +796,11 @@ void IPARPi::queueRequest(const ControlList &controls) auto gains = ctrl.second.get>(); RPiController::AwbAlgorithm *awb = dynamic_cast( controller_.GetAlgorithm("awb")); - ASSERT(awb); + if (!awb) { + LOG(IPARPI, Warning) + << "Could not set COLOUR_GAINS - no AWB algorithm"; + break; + } awb->SetManualGains(gains[0], gains[1]); if (gains[0] != 0.0f && gains[1] != 0.0f) @@ -771,7 +813,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::BRIGHTNESS: { RPiController::ContrastAlgorithm *contrast = dynamic_cast( controller_.GetAlgorithm("contrast")); - ASSERT(contrast); + if (!contrast) { + LOG(IPARPI, Warning) + << "Could not set BRIGHTNESS - no contrast algorithm"; + break; + } contrast->SetBrightness(ctrl.second.get() * 65536); libcameraMetadata_.set(controls::Brightness, @@ -782,7 +828,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::CONTRAST: { RPiController::ContrastAlgorithm *contrast = dynamic_cast( controller_.GetAlgorithm("contrast")); - ASSERT(contrast); + if (!contrast) { + LOG(IPARPI, Warning) + << "Could not set CONTRAST - no contrast algorithm"; + break; + } contrast->SetContrast(ctrl.second.get()); libcameraMetadata_.set(controls::Contrast, @@ -793,7 +843,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::SATURATION: { RPiController::CcmAlgorithm *ccm = dynamic_cast( controller_.GetAlgorithm("ccm")); - ASSERT(ccm); + if (!ccm) { + LOG(IPARPI, Warning) + << "Could not set SATURATION - no ccm algorithm"; + break; + } ccm->SetSaturation(ctrl.second.get()); libcameraMetadata_.set(controls::Saturation, @@ -804,7 +858,11 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::SHARPNESS: { RPiController::SharpenAlgorithm *sharpen = dynamic_cast( controller_.GetAlgorithm("sharpen")); - ASSERT(sharpen); + if (!sharpen) { + LOG(IPARPI, Warning) + << "Could not set SHARPNESS - no sharpen algorithm"; + break; + } sharpen->SetStrength(ctrl.second.get()); libcameraMetadata_.set(controls::Sharpness,