From patchwork Fri May 29 11:03:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3878 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3159D61012 for ; Fri, 29 May 2020 13:00:30 +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 relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 9C000E0009; Fri, 29 May 2020 11:00:29 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 29 May 2020 13:03:31 +0200 Message-Id: <20200529110335.620503-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200529110335.620503-1-jacopo@jmondi.org> References: <20200529110335.620503-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] libcamera: formats: Make ImageFormats a templated class 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: Fri, 29 May 2020 11:00:30 -0000 The ImageFormats class was originally designed to be used by both V4L2VideoDevices and V4L2Subdevices. As video devices enumerates their image formats using V4L2PixelFormat instances, the ImageFormats class cannot be used there anymore and it has been replaced by raw maps. Prepare to re-introduce usage of ImageFormats in the V4L2VideoDevice class and its users by making ImageFormats a templated class that indexes the image sizes using on keys of variadic type. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/camera_sensor.h | 2 +- include/libcamera/internal/formats.h | 64 ++++++++++- include/libcamera/internal/v4l2_subdevice.h | 2 +- src/libcamera/formats.cpp | 117 +++++++++++++------- src/libcamera/v4l2_subdevice.cpp | 6 +- test/v4l2_subdevice/list_formats.cpp | 2 +- 6 files changed, 138 insertions(+), 55 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index d79bd9ce9d58..5c1d5789fe79 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -75,7 +75,7 @@ private: std::string model_; - ImageFormats formats_; + ImageFormats formats_; Size resolution_; std::vector mbusCodes_; std::vector sizes_; diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index 4092a93ef973..e20c031e857f 100644 --- a/include/libcamera/internal/formats.h +++ b/include/libcamera/internal/formats.h @@ -18,18 +18,70 @@ namespace libcamera { +template class ImageFormats { public: - int addFormat(unsigned int format, const std::vector &sizes); + using iterator = typename std::map>::iterator; + using const_iterator = typename std::map>::const_iterator; + using value_type = typename std::map>::value_type; - bool isEmpty() const; - std::vector formats() const; - const std::vector &sizes(unsigned int format) const; - const std::map> &data() const; + iterator begin() { return data_.begin(); } + const_iterator begin() const { return data_.begin(); } + iterator end() { return data_.end(); } + const_iterator end() const { return data_.end(); } + + iterator find(const T format) { return data_.find(format); } + const iterator find(T format) const { return data_.find(format); } + + template + std::pair emplace(Args&&... args) + { + return data_.emplace(args...); + } + + int addFormat(T format, const std::vector &sizes) + { + if (data_.find(format) != data_.end()) + return -EEXIST; + + data_[format] = sizes; + + return 0; + } + + bool isEmpty() const { return data_.empty(); } + + std::vector formats() const + { + std::vector formats; + formats.reserve(data_.size()); + + /* \todo: Should this be cached instead of computed each time? */ + for (auto const &it : data_) + formats.push_back(it.first); + + return formats; + } + + const std::vector &sizes(T format) const + { + static const std::vector empty; + + auto const &it = data_.find(format); + if (it == data_.end()) + return empty; + + return it->second; + } + + const std::map> &data() const + { + return data_; + } private: - std::map> data_; + std::map> data_; }; class PixelFormatInfo diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index 1be454f0ddda..0ce6da48f58a 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -51,7 +51,7 @@ public: int setSelection(unsigned int pad, unsigned int target, Rectangle *rect); - ImageFormats formats(unsigned int pad); + ImageFormats formats(unsigned int pad); int getFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence = ActiveFormat); diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 2ac3b412ecdb..a7922077d9c5 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -22,20 +22,85 @@ LOG_DEFINE_CATEGORY(Formats) /** * \class ImageFormats - * \brief Describe V4L2Device and V4L2SubDevice image formats + * \brief Describe V4L2Device and V4L2SubDevice image formats and associated + * image resolutions * - * This class stores a list of image formats, each associated with a + * This class stores a list of image formats, each of them associated with a * corresponding set of image sizes. It is used to describe the formats and * sizes supported by a V4L2Device or V4L2Subdevice. * - * Formats are stored as an integer. When used for a V4L2Device, the image - * formats are fourcc pixel formats. When used for a V4L2Subdevice they are - * media bus codes. Both are defined by the V4L2 specification. + * When used for a V4L2Device, the image formats are V4L2PixelFormat instances. + * When used for a V4L2Subdevice formats are integer media bus codes. * * Sizes are stored as a list of SizeRange. */ /** + * \typedef ImageFormats::iterator + * \brief Iterator for the formats map + */ + +/** + * \typedef ImageFormats::const_iterator + * \brief Const iterator for the formats map + */ + +/** + * \typedef ImageFormats::value_type + * \brief Value type of the entries in the formats map + */ + +/** + * \fn iterator ImageFormats::begin() + * \brief Retrieve an iterator to the first element in the formats map + * \return An iterator to the first format map + */ + +/** + * \fn const_iterator ImageFormats::begin() const + * \brief Retrieve an const iterator to the first element in the formats map + * \return A const iterator to the first format map + */ + +/** + * \fn iterator ImageFormats::end() + * \brief Retrieve an iterator pointing to the past-the-end element in the + * formats map + * \return An iterator to the element following the last format + */ + +/** + * \fn const_iterator ImageFormats::end() const + * \brief Retrieve a const iterator pointing to the past-the-end element in the + * formats map + * \return A const iterator to the element following the last format + */ + +/** + * \fn iterator ImageFormats::find(const T format) + * \brief Find an element with key equal to \a format + * \param[in] format The format to search for + * \return An iterator to the vector of sizes associated with \a format + */ + +/** + * \fn const_iterator ImageFormats::find(const T format) const + * \brief Find a const element with key equal to \a format + * \param[in] format The format to search for + * \return An const iterator to the vector of sizes associated with \a format + */ + +/** + * \fn std::pair ImageFormats::emplace(Args&&... args) + * \brief Insert a new element in the formats map constructed in place with the + * given \a args + * \param[in] args The argument pack used to construct the new entry in place + * \return A pair consisting of an iterator to the inserted element, and a bool + * denoting whether the insertion took place + */ + +/** + * \fn ImageFormats::addFormat(T format, const std::vector &sizes) * \brief Add a format and corresponding sizes to the description * \param[in] format Pixel format or media bus code to describe * \param[in] sizes List of supported size ranges for the format @@ -43,42 +108,21 @@ LOG_DEFINE_CATEGORY(Formats) * \return 0 on success or a negative error code otherwise * \retval -EEXIST The format is already described */ -int ImageFormats::addFormat(unsigned int format, const std::vector &sizes) -{ - if (data_.find(format) != data_.end()) - return -EEXIST; - - data_[format] = sizes; - - return 0; -} /** + * \fn ImageFormats::isEmpty() const * \brief Check if the list of devices supported formats is empty * \return True if the list of supported formats is empty */ -bool ImageFormats::isEmpty() const -{ - return data_.empty(); -} /** + * \fn ImageFormats::formats() const * \brief Retrieve a list of all supported image formats * \return List of pixel formats or media bus codes */ -std::vector ImageFormats::formats() const -{ - std::vector formats; - formats.reserve(data_.size()); - - /* \todo: Should this be cached instead of computed each time? */ - for (auto const &it : data_) - formats.push_back(it.first); - - return formats; -} /** + * \fn ImageFormats::sizes(T format) const * \brief Retrieve all sizes for a specific format * \param[in] format The pixel format or mbus code * @@ -88,25 +132,12 @@ std::vector ImageFormats::formats() const * \return The list of image sizes supported for \a format, or an empty list if * the format is not supported */ -const std::vector &ImageFormats::sizes(unsigned int format) const -{ - static const std::vector empty; - - auto const &it = data_.find(format); - if (it == data_.end()) - return empty; - - return it->second; -} /** + * \fn ImageFormats::data() const * \brief Retrieve the map that associates formats to image sizes * \return The map that associates formats to image sizes */ -const std::map> &ImageFormats::data() const -{ - return data_; -} /** * \class PixelFormatInfo diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 7aefc1be032d..9fa20e84a904 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -320,16 +320,16 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, * * \return A list of the supported device formats */ -ImageFormats V4L2Subdevice::formats(unsigned int pad) +ImageFormats V4L2Subdevice::formats(unsigned int pad) { - ImageFormats formats; + ImageFormats formats; if (pad >= entity_->pads().size()) { LOG(V4L2, Error) << "Invalid pad: " << pad; return {}; } - for (unsigned int code : enumPadCodes(pad)) { + for (uint32_t code : enumPadCodes(pad)) { std::vector sizes = enumPadSizes(pad, code); if (sizes.empty()) return {}; diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp index 25503c3334e5..f66bb633fb00 100644 --- a/test/v4l2_subdevice/list_formats.cpp +++ b/test/v4l2_subdevice/list_formats.cpp @@ -48,7 +48,7 @@ void ListFormatsTest::printFormats(unsigned int pad, int ListFormatsTest::run() { /* List all formats available on existing "Scaler" pads. */ - ImageFormats formats; + ImageFormats formats; formats = scaler_->formats(0); if (formats.isEmpty()) { From patchwork Fri May 29 11:03:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3879 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E76CD61012 for ; Fri, 29 May 2020 13:00:30 +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 relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 62CBBE0009; Fri, 29 May 2020 11:00:30 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 29 May 2020 13:03:32 +0200 Message-Id: <20200529110335.620503-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200529110335.620503-1-jacopo@jmondi.org> References: <20200529110335.620503-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] libcamera: v4l2_videodevice: Use 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: Fri, 29 May 2020 11:00:31 -0000 ImageFormats was meant to be used not only for V4L2Subdevice but for video devices as well. Since the introduction of of V4L2PixelFormat the V4L2VideoDevice class and its users have been using a raw map to enumerate and inspect the V4L2VideoDevice formats. Use the ImageFormats specialization in place of a raw map and update its usage in pipeline handlers. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/v4l2_videodevice.h | 2 +- .../pipeline/raspberrypi/raspberrypi.cpp | 17 +++++++---------- src/libcamera/pipeline/simple/simple.cpp | 3 +-- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 3 +-- src/libcamera/v4l2_videodevice.cpp | 4 ++-- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index dc259523599c..de4745982e94 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -187,7 +187,7 @@ public: int getFormat(V4L2DeviceFormat *format); int setFormat(V4L2DeviceFormat *format); - std::map> formats(uint32_t code = 0); + ImageFormats formats(uint32_t code = 0); int setSelection(unsigned int target, Rectangle *rect); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index e16a9c7f10d3..64364afb3f7e 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -37,8 +37,6 @@ namespace libcamera { LOG_DEFINE_CATEGORY(RPI) -using V4L2PixFmtMap = std::map>; - namespace { bool isRaw(PixelFormat &pixFmt) @@ -67,7 +65,7 @@ double scoreFormat(double desired, double actual) return score; } -V4L2DeviceFormat findBestMode(V4L2PixFmtMap &formatsMap, const Size &req) +V4L2DeviceFormat findBestMode(ImageFormats &formatsMap, const Size &req) { double bestScore = 9e9, score; V4L2DeviceFormat bestMode = {}; @@ -79,12 +77,11 @@ V4L2DeviceFormat findBestMode(V4L2PixFmtMap &formatsMap, const Size &req) #define PENALTY_UNPACKED 500.0 /* Calculate the closest/best mode from the user requested size. */ - for (const auto &iter : formatsMap) { - V4L2PixelFormat v4l2Format = iter.first; + for (const auto &v4l2Format : formatsMap.formats()) { PixelFormat pixelFormat = v4l2Format.toPixelFormat(); const PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat); - for (const SizeRange &sz : iter.second) { + for (const SizeRange &sz : formatsMap.sizes(v4l2Format)) { double modeWidth = sz.contains(req) ? req.width : sz.max.width; double modeHeight = sz.contains(req) ? req.height : sz.max.height; double reqAr = static_cast(req.width) / req.height; @@ -427,7 +424,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * Calculate the best sensor mode we can use based on * the user request. */ - V4L2PixFmtMap fmts = data_->unicam_[Unicam::Image].dev()->formats(); + ImageFormats fmts = data_->unicam_[Unicam::Image].dev()->formats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size); PixelFormat sensorPixFormat = sensorFormat.fourcc.toPixelFormat(); if (cfg.size != sensorFormat.size || @@ -481,7 +478,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * */ PixelFormat &cfgPixFmt = config_.at(outSize[i].first).pixelFormat; - V4L2PixFmtMap fmts; + ImageFormats fmts; if (i == maxIndex) fmts = data_->isp_[Isp::Output0].dev()->formats(); @@ -518,7 +515,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, RPiCameraData *data = cameraData(camera); CameraConfiguration *config = new RPiCameraConfiguration(data); V4L2DeviceFormat sensorFormat; - V4L2PixFmtMap fmts; + ImageFormats fmts; if (roles.empty()) return config; @@ -605,7 +602,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) } /* First calculate the best sensor mode we can use based on the user request. */ - V4L2PixFmtMap fmts = data->unicam_[Unicam::Image].dev()->formats(); + ImageFormats fmts = data->unicam_[Unicam::Image].dev()->formats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize); /* diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 1ec8d0f7de03..f3e03ba60196 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -275,8 +275,7 @@ int SimpleCameraData::init() return ret; } - std::map> videoFormats = - video_->formats(format.mbus_code); + ImageFormats videoFormats = video_->formats(format.mbus_code); LOG(SimplePipeline, Debug) << "Adding configuration for " << format.size.toString() diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index a074909499f1..dbd835f5c5ef 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -159,8 +159,7 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, if (roles.empty()) return config; - std::map> v4l2Formats = - data->video_->formats(); + ImageFormats v4l2Formats = data->video_->formats(); std::map> deviceFormats; std::transform(v4l2Formats.begin(), v4l2Formats.end(), std::inserter(deviceFormats, deviceFormats.begin()), diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 3614b2ed1cbc..ea952444e0ad 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -925,9 +925,9 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format) * * \return A list of the supported video device formats */ -std::map> V4L2VideoDevice::formats(uint32_t code) +ImageFormats V4L2VideoDevice::formats(uint32_t code) { - std::map> formats; + ImageFormats formats; for (V4L2PixelFormat pixelFormat : enumPixelformats(code)) { std::vector sizes = enumSizes(pixelFormat); From patchwork Fri May 29 11:03:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3880 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C2E72610DA for ; Fri, 29 May 2020 13:00:31 +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 relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 2A336E0005; Fri, 29 May 2020 11:00:30 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 29 May 2020 13:03:33 +0200 Message-Id: <20200529110335.620503-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200529110335.620503-1-jacopo@jmondi.org> References: <20200529110335.620503-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] libcamera: Rename 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: Fri, 29 May 2020 11:00:32 -0000 The ImageFormats class is actually a map. Convey that in the class name. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/camera_sensor.h | 2 +- include/libcamera/internal/formats.h | 2 +- include/libcamera/internal/v4l2_subdevice.h | 2 +- include/libcamera/internal/v4l2_videodevice.h | 2 +- src/libcamera/formats.cpp | 32 +++++++++---------- .../pipeline/raspberrypi/raspberrypi.cpp | 10 +++--- src/libcamera/pipeline/simple/simple.cpp | 2 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 2 +- src/libcamera/v4l2_subdevice.cpp | 4 +-- src/libcamera/v4l2_videodevice.cpp | 4 +-- test/v4l2_subdevice/list_formats.cpp | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 5c1d5789fe79..52eedb9ef880 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -75,7 +75,7 @@ private: std::string model_; - ImageFormats formats_; + ImageFormatsMap formats_; Size resolution_; std::vector mbusCodes_; std::vector sizes_; diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index e20c031e857f..cc56e256f54c 100644 --- a/include/libcamera/internal/formats.h +++ b/include/libcamera/internal/formats.h @@ -19,7 +19,7 @@ namespace libcamera { template -class ImageFormats +class ImageFormatsMap { public: using iterator = typename std::map>::iterator; diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index 0ce6da48f58a..c9aa3428f93c 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -51,7 +51,7 @@ public: int setSelection(unsigned int pad, unsigned int target, Rectangle *rect); - ImageFormats formats(unsigned int pad); + ImageFormatsMap formats(unsigned int pad); int getFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence = ActiveFormat); diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index de4745982e94..02d101db0b2b 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -187,7 +187,7 @@ public: int getFormat(V4L2DeviceFormat *format); int setFormat(V4L2DeviceFormat *format); - ImageFormats formats(uint32_t code = 0); + ImageFormatsMap formats(uint32_t code = 0); int setSelection(unsigned int target, Rectangle *rect); diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index a7922077d9c5..3acb6fe6284e 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -21,7 +21,7 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Formats) /** - * \class ImageFormats + * \class ImageFormatsMap * \brief Describe V4L2Device and V4L2SubDevice image formats and associated * image resolutions * @@ -36,62 +36,62 @@ LOG_DEFINE_CATEGORY(Formats) */ /** - * \typedef ImageFormats::iterator + * \typedef ImageFormatsMap::iterator * \brief Iterator for the formats map */ /** - * \typedef ImageFormats::const_iterator + * \typedef ImageFormatsMap::const_iterator * \brief Const iterator for the formats map */ /** - * \typedef ImageFormats::value_type + * \typedef ImageFormatsMap::value_type * \brief Value type of the entries in the formats map */ /** - * \fn iterator ImageFormats::begin() + * \fn iterator ImageFormatsMap::begin() * \brief Retrieve an iterator to the first element in the formats map * \return An iterator to the first format map */ /** - * \fn const_iterator ImageFormats::begin() const + * \fn const_iterator ImageFormatsMap::begin() const * \brief Retrieve an const iterator to the first element in the formats map * \return A const iterator to the first format map */ /** - * \fn iterator ImageFormats::end() + * \fn iterator ImageFormatsMap::end() * \brief Retrieve an iterator pointing to the past-the-end element in the * formats map * \return An iterator to the element following the last format */ /** - * \fn const_iterator ImageFormats::end() const + * \fn const_iterator ImageFormatsMap::end() const * \brief Retrieve a const iterator pointing to the past-the-end element in the * formats map * \return A const iterator to the element following the last format */ /** - * \fn iterator ImageFormats::find(const T format) + * \fn iterator ImageFormatsMap::find(const T format) * \brief Find an element with key equal to \a format * \param[in] format The format to search for * \return An iterator to the vector of sizes associated with \a format */ /** - * \fn const_iterator ImageFormats::find(const T format) const + * \fn const_iterator ImageFormatsMap::find(const T format) const * \brief Find a const element with key equal to \a format * \param[in] format The format to search for * \return An const iterator to the vector of sizes associated with \a format */ /** - * \fn std::pair ImageFormats::emplace(Args&&... args) + * \fn std::pair ImageFormatsMap::emplace(Args&&... args) * \brief Insert a new element in the formats map constructed in place with the * given \a args * \param[in] args The argument pack used to construct the new entry in place @@ -100,7 +100,7 @@ LOG_DEFINE_CATEGORY(Formats) */ /** - * \fn ImageFormats::addFormat(T format, const std::vector &sizes) + * \fn ImageFormatsMap::addFormat(T format, const std::vector &sizes) * \brief Add a format and corresponding sizes to the description * \param[in] format Pixel format or media bus code to describe * \param[in] sizes List of supported size ranges for the format @@ -110,19 +110,19 @@ LOG_DEFINE_CATEGORY(Formats) */ /** - * \fn ImageFormats::isEmpty() const + * \fn ImageFormatsMap::isEmpty() const * \brief Check if the list of devices supported formats is empty * \return True if the list of supported formats is empty */ /** - * \fn ImageFormats::formats() const + * \fn ImageFormatsMap::formats() const * \brief Retrieve a list of all supported image formats * \return List of pixel formats or media bus codes */ /** - * \fn ImageFormats::sizes(T format) const + * \fn ImageFormatsMap::sizes(T format) const * \brief Retrieve all sizes for a specific format * \param[in] format The pixel format or mbus code * @@ -134,7 +134,7 @@ LOG_DEFINE_CATEGORY(Formats) */ /** - * \fn ImageFormats::data() const + * \fn ImageFormatsMap::data() const * \brief Retrieve the map that associates formats to image sizes * \return The map that associates formats to image sizes */ diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 64364afb3f7e..e0132113b072 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -65,7 +65,7 @@ double scoreFormat(double desired, double actual) return score; } -V4L2DeviceFormat findBestMode(ImageFormats &formatsMap, const Size &req) +V4L2DeviceFormat findBestMode(ImageFormatsMap &formatsMap, const Size &req) { double bestScore = 9e9, score; V4L2DeviceFormat bestMode = {}; @@ -424,7 +424,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * Calculate the best sensor mode we can use based on * the user request. */ - ImageFormats fmts = data_->unicam_[Unicam::Image].dev()->formats(); + ImageFormatsMap fmts = data_->unicam_[Unicam::Image].dev()->formats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size); PixelFormat sensorPixFormat = sensorFormat.fourcc.toPixelFormat(); if (cfg.size != sensorFormat.size || @@ -478,7 +478,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * */ PixelFormat &cfgPixFmt = config_.at(outSize[i].first).pixelFormat; - ImageFormats fmts; + ImageFormatsMap fmts; if (i == maxIndex) fmts = data_->isp_[Isp::Output0].dev()->formats(); @@ -515,7 +515,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, RPiCameraData *data = cameraData(camera); CameraConfiguration *config = new RPiCameraConfiguration(data); V4L2DeviceFormat sensorFormat; - ImageFormats fmts; + ImageFormatsMap fmts; if (roles.empty()) return config; @@ -602,7 +602,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) } /* First calculate the best sensor mode we can use based on the user request. */ - ImageFormats fmts = data->unicam_[Unicam::Image].dev()->formats(); + ImageFormatsMap fmts = data->unicam_[Unicam::Image].dev()->formats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize); /* diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index f3e03ba60196..62906b560d6a 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -275,7 +275,7 @@ int SimpleCameraData::init() return ret; } - ImageFormats videoFormats = video_->formats(format.mbus_code); + ImageFormatsMap videoFormats = video_->formats(format.mbus_code); LOG(SimplePipeline, Debug) << "Adding configuration for " << format.size.toString() diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index dbd835f5c5ef..e1b1ae32b821 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -159,7 +159,7 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, if (roles.empty()) return config; - ImageFormats v4l2Formats = data->video_->formats(); + ImageFormatsMap v4l2Formats = data->video_->formats(); std::map> deviceFormats; std::transform(v4l2Formats.begin(), v4l2Formats.end(), std::inserter(deviceFormats, deviceFormats.begin()), diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 9fa20e84a904..80db4cda82bb 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -320,9 +320,9 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, * * \return A list of the supported device formats */ -ImageFormats V4L2Subdevice::formats(unsigned int pad) +ImageFormatsMap V4L2Subdevice::formats(unsigned int pad) { - ImageFormats formats; + ImageFormatsMap formats; if (pad >= entity_->pads().size()) { LOG(V4L2, Error) << "Invalid pad: " << pad; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index ea952444e0ad..b264915cb73a 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -925,9 +925,9 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format) * * \return A list of the supported video device formats */ -ImageFormats V4L2VideoDevice::formats(uint32_t code) +ImageFormatsMap V4L2VideoDevice::formats(uint32_t code) { - ImageFormats formats; + ImageFormatsMap formats; for (V4L2PixelFormat pixelFormat : enumPixelformats(code)) { std::vector sizes = enumSizes(pixelFormat); diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp index f66bb633fb00..adcf5606c961 100644 --- a/test/v4l2_subdevice/list_formats.cpp +++ b/test/v4l2_subdevice/list_formats.cpp @@ -48,7 +48,7 @@ void ListFormatsTest::printFormats(unsigned int pad, int ListFormatsTest::run() { /* List all formats available on existing "Scaler" pads. */ - ImageFormats formats; + ImageFormatsMap formats; formats = scaler_->formats(0); if (formats.isEmpty()) { From patchwork Fri May 29 11:03:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3881 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 77EBA603CF for ; Fri, 29 May 2020 13:00:32 +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 relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 00933E000A; Fri, 29 May 2020 11:00:31 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 29 May 2020 13:03:34 +0200 Message-Id: <20200529110335.620503-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200529110335.620503-1-jacopo@jmondi.org> References: <20200529110335.620503-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] libcamera: v4l2_device: Add formatsMap typedef 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: Fri, 29 May 2020 11:00:32 -0000 Provide a type definition in the V4L2VideoDevice and V4L2Subdevice classes to shorten the ImageFormatsMap and ImageFormatsMap spcialization names. The new types reads as V4L2VideoDevice::formatsMap and V4L2Subdevice::formatsMap respectively. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/camera_sensor.h | 6 ++---- include/libcamera/internal/v4l2_subdevice.h | 4 +++- include/libcamera/internal/v4l2_videodevice.h | 4 +++- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 11 ++++++----- src/libcamera/pipeline/simple/simple.cpp | 2 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 2 +- src/libcamera/v4l2_subdevice.cpp | 9 +++++++-- src/libcamera/v4l2_videodevice.cpp | 9 +++++++-- test/v4l2_subdevice/list_formats.cpp | 2 +- 9 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 52eedb9ef880..1353edb1da28 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -16,13 +16,11 @@ #include "libcamera/internal/formats.h" #include "libcamera/internal/log.h" +#include "libcamera/internal/v4l2_subdevice.h" namespace libcamera { class MediaEntity; -class V4L2Subdevice; - -struct V4L2SubdeviceFormat; struct CameraSensorInfo { std::string model; @@ -75,7 +73,7 @@ private: std::string model_; - ImageFormatsMap formats_; + V4L2Subdevice::formatsMap formats_; Size resolution_; std::vector mbusCodes_; std::vector sizes_; diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index c9aa3428f93c..06f10d7b4c5d 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -32,6 +32,8 @@ struct V4L2SubdeviceFormat { class V4L2Subdevice : public V4L2Device { public: + using formatsMap = ImageFormatsMap; + enum Whence { ActiveFormat, TryFormat, @@ -51,7 +53,7 @@ public: int setSelection(unsigned int pad, unsigned int target, Rectangle *rect); - ImageFormatsMap formats(unsigned int pad); + formatsMap formats(unsigned int pad); int getFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence = ActiveFormat); diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 02d101db0b2b..9632ad71b988 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -168,6 +168,8 @@ public: class V4L2VideoDevice : public V4L2Device { public: + using formatsMap = ImageFormatsMap; + explicit V4L2VideoDevice(const std::string &deviceNode); explicit V4L2VideoDevice(const MediaEntity *entity); V4L2VideoDevice(const V4L2VideoDevice &) = delete; @@ -187,7 +189,7 @@ public: int getFormat(V4L2DeviceFormat *format); int setFormat(V4L2DeviceFormat *format); - ImageFormatsMap formats(uint32_t code = 0); + formatsMap formats(uint32_t code = 0); int setSelection(unsigned int target, Rectangle *rect); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index e0132113b072..7dd579090ec6 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -65,7 +65,7 @@ double scoreFormat(double desired, double actual) return score; } -V4L2DeviceFormat findBestMode(ImageFormatsMap &formatsMap, const Size &req) +V4L2DeviceFormat findBestMode(V4L2VideoDevice::formatsMap &formatsMap, const Size &req) { double bestScore = 9e9, score; V4L2DeviceFormat bestMode = {}; @@ -424,7 +424,8 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * Calculate the best sensor mode we can use based on * the user request. */ - ImageFormatsMap fmts = data_->unicam_[Unicam::Image].dev()->formats(); + V4L2VideoDevice::formatsMap fmts = + data_->unicam_[Unicam::Image].dev()->formats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size); PixelFormat sensorPixFormat = sensorFormat.fourcc.toPixelFormat(); if (cfg.size != sensorFormat.size || @@ -478,7 +479,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * */ PixelFormat &cfgPixFmt = config_.at(outSize[i].first).pixelFormat; - ImageFormatsMap fmts; + V4L2VideoDevice::formatsMap fmts; if (i == maxIndex) fmts = data_->isp_[Isp::Output0].dev()->formats(); @@ -515,7 +516,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, RPiCameraData *data = cameraData(camera); CameraConfiguration *config = new RPiCameraConfiguration(data); V4L2DeviceFormat sensorFormat; - ImageFormatsMap fmts; + V4L2VideoDevice::formatsMap fmts; if (roles.empty()) return config; @@ -602,7 +603,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) } /* First calculate the best sensor mode we can use based on the user request. */ - ImageFormatsMap fmts = data->unicam_[Unicam::Image].dev()->formats(); + V4L2VideoDevice::formatsMap fmts = data->unicam_[Unicam::Image].dev()->formats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize); /* diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 62906b560d6a..feaa2854f037 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -275,7 +275,7 @@ int SimpleCameraData::init() return ret; } - ImageFormatsMap videoFormats = video_->formats(format.mbus_code); + V4L2VideoDevice::formatsMap videoFormats = video_->formats(format.mbus_code); LOG(SimplePipeline, Debug) << "Adding configuration for " << format.size.toString() diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index e1b1ae32b821..6250186e9390 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -159,7 +159,7 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, if (roles.empty()) return config; - ImageFormatsMap v4l2Formats = data->video_->formats(); + V4L2VideoDevice::formatsMap v4l2Formats = data->video_->formats(); std::map> deviceFormats; std::transform(v4l2Formats.begin(), v4l2Formats.end(), std::inserter(deviceFormats, deviceFormats.begin()), diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 80db4cda82bb..0dd8e8686967 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -197,6 +197,11 @@ uint8_t V4L2SubdeviceFormat::bitsPerPixel() const * any device left open will be closed, and any resources released. */ +/** + * \typedef V4L2Subdevice::formatsMap + * \brief Map of media bus codes to associated image sizes + */ + /** * \enum V4L2Subdevice::Whence * \brief Specify the type of format for getFormat() and setFormat() operations @@ -320,9 +325,9 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, * * \return A list of the supported device formats */ -ImageFormatsMap V4L2Subdevice::formats(unsigned int pad) +V4L2Subdevice::formatsMap V4L2Subdevice::formats(unsigned int pad) { - ImageFormatsMap formats; + formatsMap formats; if (pad >= entity_->pads().size()) { LOG(V4L2, Error) << "Invalid pad: " << pad; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index b264915cb73a..6d48018396c3 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -461,6 +461,11 @@ const std::string V4L2DeviceFormat::toString() const * \context This class is \threadbound. */ +/** + * \typedef V4L2VideoDevice::formatsMap + * \brief Map of V4l2PixelFormat to associated image sizes + */ + /** * \brief Construct a V4L2VideoDevice * \param[in] deviceNode The file-system path to the video device node @@ -925,9 +930,9 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format) * * \return A list of the supported video device formats */ -ImageFormatsMap V4L2VideoDevice::formats(uint32_t code) +V4L2VideoDevice::formatsMap V4L2VideoDevice::formats(uint32_t code) { - ImageFormatsMap formats; + formatsMap formats; for (V4L2PixelFormat pixelFormat : enumPixelformats(code)) { std::vector sizes = enumSizes(pixelFormat); diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp index adcf5606c961..a32f5c833c28 100644 --- a/test/v4l2_subdevice/list_formats.cpp +++ b/test/v4l2_subdevice/list_formats.cpp @@ -48,7 +48,7 @@ void ListFormatsTest::printFormats(unsigned int pad, int ListFormatsTest::run() { /* List all formats available on existing "Scaler" pads. */ - ImageFormatsMap formats; + V4L2Subdevice::formatsMap formats; formats = scaler_->formats(0); if (formats.isEmpty()) { From patchwork Fri May 29 11:03:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3882 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 69543603CF for ; Fri, 29 May 2020 13:00:33 +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 relay4-d.mail.gandi.net (Postfix) with ESMTPSA id BC7F0E0009; Fri, 29 May 2020 11:00:32 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 29 May 2020 13:03:35 +0200 Message-Id: <20200529110335.620503-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200529110335.620503-1-jacopo@jmondi.org> References: <20200529110335.620503-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] libcamera: v4l2_device: Rename formats() method 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: Fri, 29 May 2020 11:00:33 -0000 Both the V4L2VideoDevice and V4L2Subdevice classes provide a formats() methods which returns an ImageFormatMap specialization. The method name formats() collides with ImageFormatsMap::formats() and makes accessing the map or the list of supported format identifiers confusing. Rename the V4L2VideoDevice and V4L2Subdevice methods to imageFormats(), to distinguish the two. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/internal/v4l2_subdevice.h | 2 +- include/libcamera/internal/v4l2_videodevice.h | 2 +- src/libcamera/camera_sensor.cpp | 2 +- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++----- src/libcamera/pipeline/simple/simple.cpp | 2 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 2 +- src/libcamera/v4l2_subdevice.cpp | 2 +- src/libcamera/v4l2_videodevice.cpp | 2 +- test/v4l2_subdevice/list_formats.cpp | 6 +++--- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index 06f10d7b4c5d..2218e90c1da6 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -53,7 +53,7 @@ public: int setSelection(unsigned int pad, unsigned int target, Rectangle *rect); - formatsMap formats(unsigned int pad); + formatsMap imageFormats(unsigned int pad); int getFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence = ActiveFormat); diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index 9632ad71b988..2d968797ee86 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -189,7 +189,7 @@ public: int getFormat(V4L2DeviceFormat *format); int setFormat(V4L2DeviceFormat *format); - formatsMap formats(uint32_t code = 0); + formatsMap imageFormats(uint32_t code = 0); int setSelection(unsigned int target, Rectangle *rect); diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index b14b4051dca6..8aafdfe76299 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -244,7 +244,7 @@ int CameraSensor::init() properties_.set(properties::Rotation, propertyValue); /* Enumerate, sort and cache media bus codes and sizes. */ - formats_ = subdev_->formats(pad_); + formats_ = subdev_->imageFormats(pad_); if (formats_.isEmpty()) { LOG(CameraSensor, Error) << "No image format found"; return -EINVAL; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 7dd579090ec6..a407945819be 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -425,7 +425,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * the user request. */ V4L2VideoDevice::formatsMap fmts = - data_->unicam_[Unicam::Image].dev()->formats(); + data_->unicam_[Unicam::Image].dev()->imageFormats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size); PixelFormat sensorPixFormat = sensorFormat.fourcc.toPixelFormat(); if (cfg.size != sensorFormat.size || @@ -482,9 +482,9 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() V4L2VideoDevice::formatsMap fmts; if (i == maxIndex) - fmts = data_->isp_[Isp::Output0].dev()->formats(); + fmts = data_->isp_[Isp::Output0].dev()->imageFormats(); else - fmts = data_->isp_[Isp::Output1].dev()->formats(); + fmts = data_->isp_[Isp::Output1].dev()->imageFormats(); if (fmts.find(V4L2PixelFormat::fromPixelFormat(cfgPixFmt, false)) == fmts.end()) { /* If we cannot find a native format, use a default one. */ @@ -527,7 +527,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, switch (role) { case StreamRole::StillCaptureRaw: cfg.size = data->sensor_->resolution(); - fmts = data->unicam_[Unicam::Image].dev()->formats(); + fmts = data->unicam_[Unicam::Image].dev()->imageFormats(); sensorFormat = findBestMode(fmts, cfg.size); cfg.pixelFormat = sensorFormat.fourcc.toPixelFormat(); ASSERT(cfg.pixelFormat.isValid()); @@ -603,7 +603,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) } /* First calculate the best sensor mode we can use based on the user request. */ - V4L2VideoDevice::formatsMap fmts = data->unicam_[Unicam::Image].dev()->formats(); + V4L2VideoDevice::formatsMap fmts = data->unicam_[Unicam::Image].dev()->imageFormats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize); /* diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index feaa2854f037..6857ec75cb1f 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -275,7 +275,7 @@ int SimpleCameraData::init() return ret; } - V4L2VideoDevice::formatsMap videoFormats = video_->formats(format.mbus_code); + V4L2VideoDevice::formatsMap videoFormats = video_->imageFormats(format.mbus_code); LOG(SimplePipeline, Debug) << "Adding configuration for " << format.size.toString() diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 6250186e9390..39c8353a2adf 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -159,7 +159,7 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, if (roles.empty()) return config; - V4L2VideoDevice::formatsMap v4l2Formats = data->video_->formats(); + V4L2VideoDevice::formatsMap v4l2Formats = data->video_->imageFormats(); std::map> deviceFormats; std::transform(v4l2Formats.begin(), v4l2Formats.end(), std::inserter(deviceFormats, deviceFormats.begin()), diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 0dd8e8686967..24ca6d80b27e 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -325,7 +325,7 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, * * \return A list of the supported device formats */ -V4L2Subdevice::formatsMap V4L2Subdevice::formats(unsigned int pad) +V4L2Subdevice::formatsMap V4L2Subdevice::imageFormats(unsigned int pad) { formatsMap formats; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 6d48018396c3..08cae92978d4 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -930,7 +930,7 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format) * * \return A list of the supported video device formats */ -V4L2VideoDevice::formatsMap V4L2VideoDevice::formats(uint32_t code) +V4L2VideoDevice::formatsMap V4L2VideoDevice::imageFormats(uint32_t code) { formatsMap formats; diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp index a32f5c833c28..262362dee3c9 100644 --- a/test/v4l2_subdevice/list_formats.cpp +++ b/test/v4l2_subdevice/list_formats.cpp @@ -50,7 +50,7 @@ int ListFormatsTest::run() /* List all formats available on existing "Scaler" pads. */ V4L2Subdevice::formatsMap formats; - formats = scaler_->formats(0); + formats = scaler_->imageFormats(0); if (formats.isEmpty()) { cerr << "Failed to list formats on pad 0 of subdevice " << scaler_->entity()->name() << endl; @@ -59,7 +59,7 @@ int ListFormatsTest::run() for (unsigned int code : formats.formats()) printFormats(0, code, formats.sizes(code)); - formats = scaler_->formats(1); + formats = scaler_->imageFormats(1); if (formats.isEmpty()) { cerr << "Failed to list formats on pad 1 of subdevice " << scaler_->entity()->name() << endl; @@ -69,7 +69,7 @@ int ListFormatsTest::run() printFormats(1, code, formats.sizes(code)); /* List format on a non-existing pad, format vector shall be empty. */ - formats = scaler_->formats(2); + formats = scaler_->imageFormats(2); if (!formats.isEmpty()) { cerr << "Listing formats on non-existing pad 2 of subdevice " << scaler_->entity()->name()