From patchwork Sat Sep 3 18:10:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17290 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 5AB74C3272 for ; Sat, 3 Sep 2022 18:10:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0C67862048; Sat, 3 Sep 2022 20:10:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1662228657; bh=YoHGUU+J9t51mCK0KvdpqzuRO7l4o4hUUuhgOmBgcf8=; 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=Ef09zyUNhYWbvyZVDcVLT++d9PXNhfyC8+S4tordDqS5UkZLi1/kM3dB+c0i5edIx 8ZWWDeXZ7PQrwsMeMd52T7YNzWqbBNCdDmR0izt6rTqc3adVEUmKJExZwTiqTX0R0I 1c2a0b0hqBmHa1MgP0QiIdJyALhJM0lTIGgnujeO918qlyKlLFq0UFx5TXxtvgVkLS MeupuG+nG3JkjC6YQ2qRwcgGDYw2p1wyAy4LFFCIo0EXO/Ar7KhmdBxqsFbufRG+pB WhjkFTPzTfUAbhftxTMGycrcG+M4zlBMWoH53aLz18aPXn49McEwPo5cB7l0cWoQII p//BP519xr8kg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97EF562033 for ; Sat, 3 Sep 2022 20:10:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DY5ie0OA"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1FC6F51E; Sat, 3 Sep 2022 20:10:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1662228654; bh=YoHGUU+J9t51mCK0KvdpqzuRO7l4o4hUUuhgOmBgcf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DY5ie0OAsm+mMlutpEtOp88T88XCcUFdMsxetb0FlvmpVvLfqmBPi+njlj/OmC8xI KBmQT1LZI1KGsSFC/QYN5OUFPdIJn2jekJq9Bwfkw4N+h9HLOZEGqiIut/+W1d8A+A VDNoO61FQW2ZkmfuTWWZMRDdUpJJglXvrNp6Nfxs= To: libcamera-devel@lists.libcamera.org Date: Sat, 3 Sep 2022 21:10:37 +0300 Message-Id: <20220903181037.1406-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220903181037.1406-1-laurent.pinchart@ideasonboard.com> References: <20220903181037.1406-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] pipeline: uvcvideo: Fail match() if the camera has no supported format 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" A UVC device could expose only formats that are not supported by libcamera. The pipeline handler doesn't currently consider this as an error, and happily creates a camera. The camera won't be usable, and worse, generateConfiguration() and validate() will crash as those functions assume that at least one format is supported. Fix this by failing match() if none of the formats exposed by the camera are supported. Log an error message in that case to notify the user. Bug: https://bugs.libcamera.org/show_bug.cgi?id=145 Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index be0fbaea508a..a28195450634 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -457,6 +457,13 @@ int UVCCameraData::init(MediaDevice *media) } } + if (formats_.empty()) { + LOG(UVC, Error) + << "Camera " << id_ << " (" << media->model() + << ") doesn't expose any supported format"; + return -EINVAL; + } + /* Populate the camera properties. */ properties_.set(properties::Model, utils::toAscii(media->model()));