From patchwork Fri Nov 27 13:30:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10514 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 61C2FBE08A for ; Fri, 27 Nov 2020 13:30:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E8A256346E; Fri, 27 Nov 2020 14:30:37 +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="IgdzUavi"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 987A9632EE for ; Fri, 27 Nov 2020 14:30:36 +0100 (CET) Received: by mail-wm1-x334.google.com with SMTP id h21so6531686wmb.2 for ; Fri, 27 Nov 2020 05:30:36 -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=c5u+7kK7gaL3YrmjBIpJG4sIyhM9GSoffX8wgpE3mBc=; b=IgdzUavisqHfhtsCimIuwbvQfDT6x7VXkdf7y38NH+vi5RQsP2Eq098lud+NhbTso5 PMRWx+HAh/AIH34FWky0oLstULGdjY5F187muBORQcs6JT89l7I+csV4UnodhEoZ/Uch QAZfwiK1VSFWbVP0YYej0aBqNOdQBCC4rnbTPp+CZkPq1GyyMS2DZccqt8qShR6E1Z9c kA/vuBn1EmXnKRFpZ2tZlpoq7BJcCwg603mcd/wrNVx8gQg8kW0EXCOaLUX/bNSwMz8C /d2sLCmSJWMfvWPz8OpFhLIPvdJRwc1T5e2RjZDaRn3CDM3UIPmFC/mngStK14+OVGur 3O+g== 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=c5u+7kK7gaL3YrmjBIpJG4sIyhM9GSoffX8wgpE3mBc=; b=oix3ELfUzKUNUkAlpYRebJK3VyAgtgU9z+BGGFP2cDJ3sb8xyDjKLI1r8cV5cWzg2Y 25ztCt5CH112HjGoFIVJ96CzEU/9Gu29IIGx+nWF73X9kicOZ4KeAXbqDdhjvPMjUuZy 1T9dN4RMLwbwZInLVMTv8BpN7vsiYOsVdWRTikNNtTNPE2kU56kVpIJZbfMmMNGLO7Ty VlsPdkF1wOdy1Btp5jYTV1VW4Vf55lVu7C8V3ZiRypkpqhyXBIKBpg5apiUSFKRrjA9R u3vLV4Bpcqzc8DGUc9mW8AiWzR5dIQ1nnUMQq09svKZtzf3qDY/rH2OorbEB87hbCTaX 434w== X-Gm-Message-State: AOAM530YSb6A/gmYy6htVHa2uzBu6RThG2/5OLFVDVXUFKHrPJsjgsu0 ea/DqF61EvmfosCW6OR4Ugio0+sK93Qb4g== X-Google-Smtp-Source: ABdhPJzyn9FSwPRQhYGR0BObGTP/L7fXd4GVzeEeYDr6GrG1/I/bQGLxZZN2gRr8T43EJpiooPu0YA== X-Received: by 2002:a1c:1b85:: with SMTP id b127mr9020848wmb.163.1606483835927; Fri, 27 Nov 2020 05:30:35 -0800 (PST) Received: from naushir-VirtualBox.pitowers.org ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2]) by smtp.gmail.com with ESMTPSA id c17sm15156773wro.19.2020.11.27.05.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 05:30:34 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Nov 2020 13:30:31 +0000 Message-Id: <20201127133031.1103686-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] pipeline: ipa: raspberrypi: Handle failures during IPA configuration 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 IPA fails during configuration, return an error flag to the pipeline handler and fail the use case gracefully. At preset, the IPA configuration can fail for the following reasons: - The sensor is not recognised, and fails to open a CamHelper object. - The pipeline handler did not pass in controls for the ISP and sensor. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- include/libcamera/ipa/raspberrypi.h | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 16 ++++++++++++++-- .../pipeline/raspberrypi/raspberrypi.cpp | 5 +++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index 2b55dbfc..86c97ffa 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -21,6 +21,7 @@ enum ConfigParameters { IPA_CONFIG_STAGGERED_WRITE = (1 << 1), IPA_CONFIG_SENSOR = (1 << 2), IPA_CONFIG_DROP_FRAMES = (1 << 3), + IPA_CONFIG_FAILED = (1 << 4), }; enum Operations { diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 9853a343..7542dd26 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -197,8 +197,14 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, const IPAOperationData &ipaConfig, IPAOperationData *result) { - if (entityControls.empty()) + std::string cameraName(sensorInfo.model); + + if (entityControls.size() != 2) { + LOG(IPARPI, Error) << "No ISP or sensor controls found for " + << cameraName; + result->operation = RPi::IPA_CONFIG_FAILED; return; + } result->operation = 0; @@ -213,10 +219,16 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo, * that the kernel driver doesn't. We only do this the first time; we don't need * to re-parse the metadata after a simple mode-switch for no reason. */ - std::string cameraName(sensorInfo.model); if (!helper_) { helper_ = std::unique_ptr(RPiController::CamHelper::Create(cameraName)); + if (!helper_) { + LOG(IPARPI, Error) << "Could not create camera helper for " + << cameraName; + result->operation = RPi::IPA_CONFIG_FAILED; + return; + } + /* * Pass out the sensor config to the pipeline handler in order * to setup the staggered writer class. diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 6fcdf557..76252806 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1194,6 +1194,11 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) ipa_->configure(sensorInfo_, streamConfig, entityControls, ipaConfig, &result); + if (result.operation & RPi::IPA_CONFIG_FAILED) { + LOG(RPI, Error) << "IPA configuration failed!"; + return -EPIPE; + } + unsigned int resultIdx = 0; if (result.operation & RPi::IPA_CONFIG_STAGGERED_WRITE) { /*