From patchwork Sat Sep 12 10:11:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9581 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 C094EC3B5B for ; Sat, 12 Sep 2020 10:07:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C76062DAB; Sat, 12 Sep 2020 12:07:55 +0200 (CEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D1BD562C8C for ; Sat, 12 Sep 2020 12:07:54 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 5C1101BF204; Sat, 12 Sep 2020 10:07:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Sat, 12 Sep 2020 12:11:20 +0200 Message-Id: <20200912101129.12625-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200912101129.12625-1-jacopo@jmondi.org> References: <20200912101129.12625-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 01/10] 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: hanlinchen@chromium.org 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: Hirokazu Honda Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Signed-off-by: Jacopo Mondi --- 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 93659e91f980..ebebdac38e28 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -398,10 +398,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; }