From patchwork Wed Sep 2 15:22:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9462 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 F169FBE174 for ; Wed, 2 Sep 2020 15:19:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B69C562984; Wed, 2 Sep 2020 17:19:00 +0200 (CEST) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 82A51629A3 for ; Wed, 2 Sep 2020 17:18:58 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 42DF4240009; Wed, 2 Sep 2020 15:18:57 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 2 Sep 2020 17:22:25 +0200 Message-Id: <20200902152236.69770-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200902152236.69770-1-jacopo@jmondi.org> References: <20200902152236.69770-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 01/12] android: camera_device: Refuse unsupported formats 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: , Cc: tfiga@google.com, hiroh@google.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The current implementation of CameraDevice::initializeStreamConfigurations() fails if an image format marked as mandatory is not supported by the libcamera::Camera device, but erroneously accepts non-mandatory non-supported formats in the list of accepted ones. Fix this by ignoring non supported image formats which are not marked as mandatory. Reviewed-by: Kieran Bingham Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Hirokazu Honda --- src/android/camera_device.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 9605b9e9069e..ad0d7fd15d90 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -392,10 +392,16 @@ int CameraDevice::initializeStreamConfigurations() break; } } - if (camera3Format.mandatory && !mappedFormat.isValid()) { - LOG(HAL, Error) << "Failed to map Android format " - << camera3Format.name << " (" - << utils::hex(androidFormat) << ")"; + + if (!mappedFormat.isValid()) { + /* If the format is not mandatory, skip it. */ + if (!camera3Format.mandatory) + continue; + + LOG(HAL, Error) + << "Failed to map mandatory Android format " + << camera3Format.name << " (" + << utils::hex(androidFormat) << "): aborting"; return -EINVAL; }