From patchwork Mon Mar 16 02:40:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 3106 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E8F8462928 for ; Mon, 16 Mar 2020 03:41:35 +0100 (CET) X-Halon-ID: 94d38ed0-672f-11ea-9f40-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 94d38ed0-672f-11ea-9f40-0050569116f7; Mon, 16 Mar 2020 03:41:04 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 16 Mar 2020 03:40:34 +0100 Message-Id: <20200316024036.2474307-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316024036.2474307-1-niklas.soderlund@ragnatech.se> References: <20200316024036.2474307-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] libcamera: v4l2_videodevice: Remove usage of ImageFormats 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-List-Received-Date: Mon, 16 Mar 2020 02:41:36 -0000 The ImageFormats class is not very nice as it forces the pixel format to be an unsigned integer. Replace it with a map of PixelFormat to vector of sizes. Signed-off-by: Niklas Söderlund --- src/libcamera/include/v4l2_videodevice.h | 2 +- src/libcamera/pipeline/uvcvideo.cpp | 3 +-- src/libcamera/v4l2_videodevice.cpp | 11 +++-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h index 2507daf23efac66f..38dfd92544fa2c0e 100644 --- a/src/libcamera/include/v4l2_videodevice.h +++ b/src/libcamera/include/v4l2_videodevice.h @@ -184,7 +184,7 @@ public: int getFormat(V4L2DeviceFormat *format); int setFormat(V4L2DeviceFormat *format); - ImageFormats formats(); + std::map> formats(); int setCrop(Rectangle *rect); int setCompose(Rectangle *rect); diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 320da2685795c041..b5f98a96a14fe348 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -153,8 +153,7 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, if (roles.empty()) return config; - ImageFormats v4l2formats = data->video_->formats(); - StreamFormats formats(v4l2formats.data()); + StreamFormats formats(data->video_->formats()); StreamConfiguration cfg(formats); cfg.pixelFormat = formats.pixelformats().front(); diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 858310c3b810350a..f9c59d5e3fb65737 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -901,21 +901,16 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format) * * \return A list of the supported video device formats */ -ImageFormats V4L2VideoDevice::formats() +std::map> V4L2VideoDevice::formats() { - ImageFormats formats; + std::map> formats; for (unsigned int pixelformat : enumPixelformats()) { std::vector sizes = enumSizes(pixelformat); if (sizes.empty()) return {}; - if (formats.addFormat(pixelformat, sizes)) { - LOG(V4L2, Error) - << "Could not add sizes for pixel format " - << pixelformat; - return {}; - } + formats[pixelformat] = sizes; } return formats;