From patchwork Wed Jun 7 10:00:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18718 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 7931AC328F for ; Wed, 7 Jun 2023 10:01:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2724E6289E; Wed, 7 Jun 2023 12:01:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1686132071; bh=1QHR3dWY/MwiYLi2cYyB4VKJ3Gu++TAPUEAXFfnn3l8=; 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=ak7CATQuMkpXW4tfHGixy5vYEz+fgbU8ohgQ8KuCbOhqGoLapKPUCN7adaVfGK+lq zQB2shGr0qDKxkjWPvLg+pOOJFDjnKdpC5cpeL/ZbhM2WXlU+WzSdFzDaPZqEk8qE1 2knThWNSjENDM9l/iRE1fIQW/av4tV90KP/bbflqAQywxvCTOs0yqvHv3JPoqa8SF+ lqnYc4k1wjArw4daty33YpKcgLqs3ES/SYbQLNSDhMlMuMLg1nx8s84MvlnSu1rnjg 7dgYubCs/Vli9bM71evALvk/tLlO/HRMIRtzcHKnxBdf7RTlvs8tLRuEF+ZTGjTskS EfkH/FKdKFDiA== 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 209BD6289C for ; Wed, 7 Jun 2023 12:01:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ABNyOlI6"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f6d7abe934so59962075e9.2 for ; Wed, 07 Jun 2023 03:01:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1686132067; x=1688724067; 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=sxn5Q6k3mqIDixUudApfDx57EnlB3OjVXlUEML5ains=; b=ABNyOlI6AGeI4niZ5A1xoBR4JBcc+Tj65xGe+rl7AQbmygdtAunGkyqEFIbKbLBYRu QJ2PgOcZqPWdSVgPw7BqquMhggFLdQe3+mFnMvlZIu+5iBywVn3WQiucSGGSeXW6FW24 P6m9qTdYHgr4ZbuER27vYltsZVWrxm4KQIaj6TSSOWBQ+IFwR+6JILEXVRCUWAqAowNi tsQ4MlKg3SpSPYY2By/enmtw/snzcjaT6oMD7aeASMIWCieHhu4naKzXuJ/5F5cqm1ox YyXYPPUJPIqhNIdvwP+BZxlVLJ9VtZv9+oFL/Tr0R9W0vOz0ha669V8NIPp+KNyN7QiB vh8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686132067; x=1688724067; 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=sxn5Q6k3mqIDixUudApfDx57EnlB3OjVXlUEML5ains=; b=i7qcshU+zWghWM6nGaNrGbQ4MjEdjiuIVPZa19bxYeImCI/8RJFiYBiCb8YFh/Z8E6 6XUshEpW6BQDmEMo3K9tAeKj5hSv2efotUY5T+vcCPZ5zK9ulPOB+fQzQD1sut1PDEKm 0ni00w+dck4rFdPplGZcw4gwpSyEtmKmc3oy0izJLPi+FYBnVhTWnUR79t4BJxEMujZV nzFjuBTATB8rAuFRJicksedgeO+1kyRsYAr3wiizhedVcyJaHBJfra6M9f5Qi0ZsnCOd g7DnMr+LRzUsnSplotwcNR5Q6zyPFuCqckFJ/f7Oo+MaQqJroHHadJbWDONIbO/f3PGS LApg== X-Gm-Message-State: AC+VfDz3XVHHbAtDS4a9NkyNMbNCDTp4YOWXy5inUAB1h7Z/KKXij6Uv wmWuNMz60EhLnOhEwkIGKVsiOHDlmqBd7mP7uYshhg== X-Google-Smtp-Source: ACHHUZ45j/LjvOFNfWHViyN7f6mWDHT3TguLblhbNviU7tE3YDLIogQLr/jDuohSlyZJc2J+e9vitA== X-Received: by 2002:a05:600c:2258:b0:3f4:298f:4d01 with SMTP id a24-20020a05600c225800b003f4298f4d01mr4219532wmm.26.1686132067295; Wed, 07 Jun 2023 03:01:07 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id t7-20020a1c7707000000b003f6cf9afc25sm1556889wmi.40.2023.06.07.03.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 03:01:06 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jun 2023 11:00:54 +0100 Message-Id: <20230607100054.4576-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607100054.4576-1-naush@raspberrypi.com> References: <20230607100054.4576-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 3/3] ipa: rpi: agc: Gracefully handle missing agc modes 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" If a metering/exposure/constraint mode is not listed in the sensor tuning file, and a control for the missing mode is set on the agc, we terminate the application with a fatal log message. Instead of this fatal termination, log a warning message and switch to the appropriate default mode so that the application continues running. Reported-on: https://github.com/raspberrypi/libcamera/issues/59 Reported-on: https://github.com/ayufan/camera-streamer/issues/67 Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/ipa/rpi/controller/rpi/agc.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/agc.cpp b/src/ipa/rpi/controller/rpi/agc.cpp index b611157af1f0..1b05d478818e 100644 --- a/src/ipa/rpi/controller/rpi/agc.cpp +++ b/src/ipa/rpi/controller/rpi/agc.cpp @@ -540,24 +540,36 @@ void Agc::housekeepConfig() */ if (meteringModeName_ != status_.meteringMode) { auto it = config_.meteringModes.find(meteringModeName_); - if (it == config_.meteringModes.end()) - LOG(RPiAgc, Fatal) << "No metering mode " << meteringModeName_; - meteringMode_ = &it->second; + if (it == config_.meteringModes.end()) { + LOG(RPiAgc, Warning) << "No metering mode " << meteringModeName_ + << ", defaulting to " << config_.defaultMeteringMode; + meteringModeName_ = config_.defaultMeteringMode; + meteringMode_ = &config_.meteringModes[meteringModeName_]; + } else + meteringMode_ = &it->second; status_.meteringMode = meteringModeName_; } if (exposureModeName_ != status_.exposureMode) { auto it = config_.exposureModes.find(exposureModeName_); - if (it == config_.exposureModes.end()) - LOG(RPiAgc, Fatal) << "No exposure profile " << exposureModeName_; - exposureMode_ = &it->second; + if (it == config_.exposureModes.end()) { + LOG(RPiAgc, Warning) << "No exposure profile " << exposureModeName_ + << ", defaulting to " << config_.defaultExposureMode; + exposureModeName_ = config_.defaultExposureMode; + exposureMode_ = &config_.exposureModes[exposureModeName_]; + } else + exposureMode_ = &it->second; status_.exposureMode = exposureModeName_; } if (constraintModeName_ != status_.constraintMode) { auto it = config_.constraintModes.find(constraintModeName_); - if (it == config_.constraintModes.end()) - LOG(RPiAgc, Fatal) << "No constraint list " << constraintModeName_; - constraintMode_ = &it->second; + if (it == config_.constraintModes.end()) { + LOG(RPiAgc, Warning) << "No constraint list " << constraintModeName_ + << ", defaulting to " << config_.defaultConstraintMode; + constraintModeName_ = config_.defaultConstraintMode; + constraintMode_ = &config_.constraintModes[constraintModeName_]; + } else + constraintMode_ = &it->second; status_.constraintMode = constraintModeName_; } LOG(RPiAgc, Debug) << "exposureMode "