summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_subdevice.cpp
AgeCommit message (Collapse)Author
2021-06-25libcamera/base: Move extended base functionalityKieran Bingham
Move the functionality for the following components to the new base support library: - BoundMethod - EventDispatcher - EventDispatcherPoll - Log - Message - Object - Signal - Semaphore - Thread - Timer While it would be preferable to see these split to move one component per commit, these components are all interdependent upon each other, which leaves us with one big change performing the move for all of them. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-25libcamera/base: Move utils to the base libraryKieran Bingham
Move the utils functionality to the libcamera/base library. Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-12-09libcamera: v4l2_subdevice: Return a unique pointer from fromEntityName()Laurent Pinchart
The fromEntityName() function returns a pointer to a newly allocated V4L2Subdevice instance, which must be deleted by the caller. This opens the door to memory leaks. Return a unique pointer instead, which conveys the API semantics better than a sentence in the documentation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-07-23libcamera: v4l2_subdevice: Replace ImageFormats with a mapNiklas Söderlund
Replace the V4L2Subdevice usage of the ImageFormats class with a std::map and the utils::map_keys() helper. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-06-15libcamera: v4l2subdev: Print mbus string instead of codeKaaira Gupta
Modify toString() to print mbus format name instead of its hex code as the name is easier to understand. Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-05-16libcamera: Move internal headers to include/libcamera/internal/Laurent Pinchart
The libcamera internal headers are located in src/libcamera/include/. The directory is added to the compiler headers search path with a meson include_directories() directive, and internal headers are included with (e.g. for the internal semaphore.h header) #include "semaphore.h" All was well, until libcxx decided to implement the C++20 synchronization library. The __threading_support header gained a #include <semaphore.h> to include the pthread's semaphore support. As include_directories() adds src/libcamera/include/ to the compiler search path with -I, the internal semaphore.h is included instead of the pthread version. Needless to say, the compiler isn't happy. Three options have been considered to fix this issue: - Use -iquote instead of -I. The -iquote option instructs gcc to only consider the header search path for headers included with the "" version. Meson unfortunately doesn't support this option. - Rename the internal semaphore.h header. This was deemed to be the beginning of a long whack-a-mole game, where namespace clashes with system libraries would appear over time (possibly dependent on particular system configurations) and would need to be constantly fixed. - Move the internal headers to another directory to create a unique namespace through path components. This causes lots of churn in all the existing source files through the all project. The first option would be best, but isn't available to us due to missing support in meson. Even if -iquote support was added, we would need to fix the problem before a new version of meson containing the required support would be released. The third option is thus the only practical solution available. Bite the bullet, and do it, moving headers to include/libcamera/internal/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2020-04-28libcamera: v4l2_subdevice: Add format informationJacopo Mondi
Define a map of static information associated with a media bus code. Start by reporting the bits-per-pixel for each media bus code defined by the V4L2 kernel API, to later expand it when necessary. Add to the V4L2SubdeviceFormat class a method to return the bits per pixel, retrieved by inspecting the static map of format information. While at it, remove a rogue map inclusion from header file. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-04-28libcamera: v4l2_subdevice: Implement getSelection()Jacopo Mondi
Implement V4L2Subdevice::getSelection() to support retrieving selection rectangles from the V4L2 subdevice. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-04-28libcamera: v4l2_subdevice: Expose setSelection()Jacopo Mondi
Expose V4L2Subdevice::setSelection() method and drop V4L2Subdevice::setCrop() and V4L2Subdevice::setComopse() as wrapping each target with a single function does not provide any benefit. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-04-26libcamera: geometry: Rename Rectangle fieldsJacopo Mondi
The Rectangle class members that represents the rectangle horizontal and vertical sizes are named 'w' and 'h', in contrast with the Size and SizeRange classes which use 'width' and 'height', resulting in having to look at class definition every time to know which names to use. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-04-15libcamera: v4l2_subdevice: Don't use doxygen \ref needlesslyLaurent Pinchart
The doxygen \ref command is used to generate a reference to a function, while adding parentheses after the function name is enough. Simplify the documentation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-04-15libcamera: v4l2_subdevice: Extend [gs]etFormat() to specify format typeLaurent Pinchart
The V4L2 subdevice API exposes ACTIVE and TRY formats, but the V4L2Subdevice getFormat() and setFormat() operations only apply on ACTIVE formats. Extend them to support TRY formats as well. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-03-19libcamera: geometry: Construct SizeRange from SizeLaurent Pinchart
The SizeRange constructors take minimum and maximum width and height values as separate arguments. We have a Size class to convey size information, use it in the constructors, and update the callers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-10-15libcamera: utils: Add hex stream output helperLaurent Pinchart
Add a utils::hex() function that simplifies writing hexadecimal values to an ostream. The function handles the '0x' prefix, the field width and the fill character automatically. Use it through the libcamera code base, and add a test. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-06-19libcamera: Introduce V4L2Device base classJacopo Mondi
The V4L2 devices and subdevices share a few common operations,like opening and closing a device node, and perform IOCTLs on the device. With the forthcoming introduction of support for V4L2 controls, the quantity of shared code will increase, as the control support implementation is identical for the two derived classes. To maximize code re-use and avoid duplications, provide a V4L2Device base class which groups the common operations and members. The newly introduced base class provides methods to open/close a device node, access the file descriptor, and perform IOCTLs on the device. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-06-19libcamera: Rename V4L2Device to V4L2VideoDeviceJacopo Mondi
In preparation of creating a new V4L2Device base class, rename V4L2Device to V4L2VideoDevice. This is a project wide rename without any intended functional change. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-06-19libcamera: v4l2_subdevice: Replace FormatEnum with ImageFormatsNiklas Söderlund
Replace all usage of FormatEnum with ImageFormats and completely remove FormatEnum which is no longer needed. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-06-19libcamera: v4l2_subdevice: Rework enumPadSizes()Niklas Söderlund
Align the enumPadSizes() interface and implementation with that of enumPadCodes(). There is no functional change. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-06-19libcamera: v4l2_subdevice: Breakout mbus code enumerationNiklas Söderlund
Simplify frame size enumeration by breaking out mbus code enumeration in a helper, making the code easier to read while also preparing for enhancing the frame size enumeration. There is no functional change. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-30libcamera: Use the Size class through libcameraLaurent Pinchart
Several of our structures include width and height fields that model a size while we have a Size class for that purpose. Use the Size class through libcamera, and give it a toString() method like other geometry and format classes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-04-19libcamera: Include header related to source file firstLaurent Pinchart
Include the header file corresponding to the source file in the very first position. This complies with the Google C++ coding style guideliens, and helps ensuring that the headers are self-contained. Three bugs are already caught by this change (missing includes or forward declarations) in device_enumerator.h, event_dispatcher_poll.h and pipeline_handler.h. Fix them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-19libcamera: Document documentation style and update the code accordinglyLaurent Pinchart
The documentation style for the Doxygen comment blocks is inconsistent in the library. Document the expectations and update all existing comment blocks to match. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18libcamera: v4l2_subdevice: Add method to retrieve the media entityLaurent Pinchart
Add a method to retrieve the media entity associated with a subdevice. The entityName() and deviceNode() methods are not needed anymore as they can be accessed through the media entity, remove them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18libcamera: v4l2_subdevice: Close subdevice when destroyedLaurent Pinchart
Make sure the subdevice file descriptor isn't leaked by closing it when the V4L2Subdevice instance is destroyed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-05libcamera: Make geometry.h a public headerNiklas Söderlund
Make the geometry header public so it can be used by the API facing applications. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-02libcamera: v4l2_subdevice: Create device from entity nameJacopo Mondi
Add a static method to V4L2Subdevice class to create a V4L2Subdevice instance from a media entity name. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-02libcamera: v4l2_subdevice: Rename deviceName() methodJacopo Mondi
Rename the 'deviceName()' method to 'entityName()' as it actually returns the name of the entity backing the v4l2 subdevice. While at it, make the names getter methods return a const reference instead of returning by copy. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-02libcamera: formats: Define FormatEnum typeJacopo Mondi
Add an internal format.h and format.cpp files to collect libcamera image format related types, helpers and structures. Define and document the FormatEnum type, used to enumerate pixel image formats and associated image resolutions. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-02libcamera: formats: Add toString() methodsJacopo Mondi
Add toString() helpers to pretty print out a V4L2Device or V4L2Subdevice format. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-03-02libcamera: v4l2_subdevice: Cosmetic updateJacopo Mondi
Cosmetic updated of V4L2Subdevice class: re-sort methods and comments to reflect the declaration order in the class definition. Cosmetic update, no functional changes intended. Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-03-02libcamera: v4l2_subdevice: Implement ENUM_FRAME_SIZESJacopo Mondi
Implement format and size enumeration methods to list all the available subdevice image resolutions and formats. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-03-01libcamera: v4l2_subdevice: Update crop/compose rectangleJacopo Mondi
Update the crop/compose rectangle provided to setCrop()/setCompose() methods with the rectangle sizes set by the device driver after a S_SELECTION ioctl operation. While at there, fix the use of 'top' and 'left' field of the selection rectangle, which where wrongly used. Fixes: 468176fa07d9 ("libcamera: Add V4L2Subdevice") Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-03-01libcamera: v4l2_subdevice: Inherit from LoggableJacopo Mondi
Prefix the V4L2Subdevice error messages with the name of the entity. Remove the manually printed name from log messages where it was used and standardize error messages while at there. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-03-01libcamera: v4l2_subdevice: Store media entityJacopo Mondi
Store the media entity backing the V4L2Subdevice and add a deviceName() method to retrieve the human readable name of the subdevice, which is created using the name of the associated media entity. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-27libcamera: align the documentation for numeric error codesNiklas Söderlund
Rapid growth of the library have resulted in slightly different wording to document that a function returns 0 on success or a negative error code otherwise. Align all different variations. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-19libcamera: v4l2_subdevice: Fix S_SELECTION ioctl argumentJacopo Mondi
The SUBDEV_S_SELECTION argument needs to be a pointer. Fix it. Fixes: 468176fa07d9 ("libcamera: Add V4L2Subdevice") Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-13libcamera: v4l2_subdevice: Fix LOG usageKieran Bingham
Add the V4L2Subdev category to the last LOG() call requiring it. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-06libcamera: Add V4L2SubdeviceJacopo Mondi
Add V4L2Subdevice class that provides an interface to interact with V4L2 defined sub-devices. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>