summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_device.cpp
AgeCommit message (Collapse)Author
2019-06-02libcamera: v4l2_device: Add support for META_OUTPUTJacopo Mondi
Add support for output devices that expose the META_OUTPUT capabilities. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-05-03libcamera: v4l2_device: Increase error level for unsupported devicesKieran Bingham
If a component tries to open an unsupported device type, no error is presented unless debug is enabled. Report an error if an unsupported device type is opened to ease pipeline development. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-05-03libcamera: v4l2_device: Fix debug spacingKieran Bingham
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@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-27libcamera: v4l2_device: Prefix V4L2 direction in log messagesKieran Bingham
The V4L2Device will use the same deviceNode for two directions in the case of an M2M device. Add the direction to identify the queue direction on each instance. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-26libcamera: Remove outdated \todo commentsLaurent Pinchart
Some \todo comments are outdated and refer to tasks that have been completed. Remove them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-26libcamera: v4l2_device: Buffer is not a structLaurent Pinchart
Buffer is a class, not a struct. Fix a variable declaration accordingly. 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-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_device: Propagate releaseBuffers() errorJacopo Mondi
The error code returned by requestBuffers(0) was not propagated to the caller. Fix it. 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>
2019-04-02libcamera: v4l2_device: Create device from entity nameJacopo Mondi
Add a static method to V4L2Device class to create a V4L2Device 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: 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-20libcamera: v4l2_device: Fix trivial spelling errorsKieran Bingham
succcess -> success categorized -> categorised Acked-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-03-05libcamera: v4l2_device: Close Plane dmabuf fdKieran Bingham
When constructing a Plane, the exported buffer provides a dmabuf handle which is set to the Plane object. This action duplicates the handle for internal storage, and the original fd is not used and needs to be closed. Close the handle, ensuring that the resources can be correctly managed. Fixes: 771befc6dc0e ("libcamera: v4l2_device: Request buffers from the device") Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-03-02libcamera: v4l2_device: Cosmetic updateJacopo Mondi
Cosmetic update of V4L2Device class: remove the return type from Doxygen documentation of inline functions. Cosmetic update, no functional changes intended. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-03-02libcamera: v4l2_device: Add support for META_CAPTURE devicesJacopo Mondi
Add support for devices that provide video meta-data to v4l2_device.cpp and re-arrange bufferType handling in open() method. 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: Handle request completion explicitly in pipeline handlersLaurent Pinchart
Request complete by themselves when all the buffers they contain have completed, connecting the buffer's completed signal to be notified of buffer completion. While this works for now, it prevents pipelines from delaying request completion until all metadata is available, and makes it impossible to ensure that requests complete in the order they are queued. To fix this, make request completion handling explicit in pipeline handlers. The base PipelineHandler class is extended with implementations of the queueRequest() and stop() methods and gets new completeBuffer() and completeRequest() methods to help pipeline handlers tracking requests and buffers. The three existing pipeline handlers connect the bufferReady signal of their capture video node to a slot of their respective camera data instance, where they use the PipelineHandler helpers to notify buffer and request completion. Request completion is handled synchronously with buffer completion as the pipeline handlers don't need to support more advanced use cases, but this paves the road for future work. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-03-01libcamera: buffer: Add buffer completion statusLaurent Pinchart
Add a new field to the Buffer class to report its completion status, with a new cancel() method to mark the buffer as cancelled. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-03-01libcamera: v4l2_device: Expose the device node pathJacopo Mondi
Provide a getter method to access the device node path. For video devices it is usually the most informative description. 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-13libcamera: v4l2_device: importBuffers supportKieran Bingham
Provide the ability to import a BufferPool into the V4L2Device allowing external dmabuf backed buffers to be queued. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-13libcamera: v4l2_device: Simplify exportBuffers()Kieran Bingham
exportBuffers() can only operate on an existing BufferPool allocation. The pool identifies its size through its .count() method. Passing a count in to the exportBuffers() call is redundant and can be incorrect if the value is not the same as the BufferPool size. Simplify the function and remove the unnecessary argument, correcting all uses throughout the code base. While we're here, remove the createBuffers() helper from the V4L2DeviceTest which only served to obfuscate which pool the buffers were being allocated for. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-13libcamera: v4l2_device: Use non-interlaced framesKieran Bingham
Use V4L2_FIELD_NONE where applicable to disable support for interlaced frames. We are unlikely to support interlaced frames on cameras so hardcode this field type for now. If we decide to support interlacing later it can be revisited. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-13libcamera: v4l2_device: Support queueing buffers to an output deviceKieran Bingham
To queue a buffer to an output device, we must set the buffer properties. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-13libcamera: v4l2_device: Fix LOG usageKieran Bingham
Add the V4L2 category to the LOG() statements. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-02-11libcamera: v4l2_device: Inherit from Loggable to print device node nameLaurent Pinchart
Automate printing of device node name in log messages by inheriting from the Loggable class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-06libcamera: v4l2_device: Add comments to method parametersJacopo Mondi
Add missing parameter documentation for set and get format methods. 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>
2019-02-06libcamera: v4l2_device: Update dequeued buffer informationNiklas Söderlund
Copy the information from the struct v4l2_buffer when dequeueing the buffer as applications need this information to make sense of the captured data. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-02-06libcamera: v4l2_device: Implement stream{On,Off}Kieran Bingham
Support starting and stopping a stream on a V4L2 device. Buffers must be queued before the stream is started. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-06libcamera: v4l2_device: Implement queue/dequeue operationsKieran Bingham
Provide queueBuffer() and dequeueBuffer() methods to interact with the V4L2Device. Buffers will be directly referenced from the bufferPool of the V4L2Device based on the index in the pool. The V4L2Device is now opened in non-blocking mode in order to avoid blocking the dequeueBuffer() method. A signal is emitted when a buffer is ready and has been dequeued. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-06libcamera: v4l2_device: Request buffers from the deviceKieran Bingham
Provide an exportBuffers() function which allocates buffers with the MMAP method, exports them using the dmabuf API and populates the given BufferPool. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-02-05libcamera: v4l2_device: Improve documentationJacopo Mondi
Improve the V4L2DeviceFormat documentation as suggested during patches review. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-05libcamera: v4l2_device: s_format: Return the device formatJacopo Mondi
Return the device format actually applied to the device on setFormat(). Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-05libcamera: v4l2_device: Construct from MediaEntity*Jacopo Mondi
The V4L2Device constructor wants a "const MediaEntity &", while entities are usually retrieved by pointer before being used to construct a V4L2Device. Change the constructor argument to "const MediaEntity *". Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-03libcamera: v4l2_device: Set bytesperline in single plane S_FMTJacopo Mondi
The 'bytesperline' field of 'struct v4l2_pix_format' has to be set for the single planar set format use case. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-03libcamera: v4l2_device: Zero-initialize V4L2 formatJacopo Mondi
Zero initialize v4l2_format structures used to set and get format on the V4L2 device. Fixes: ba8da0f2fcd0 ("libcamera: v4l2_device: Add methods to get/set 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-02-03libcamera: v4l2_device: Rename plane format fieldsJacopo Mondi
Rename the number of valid plane formats to 'planesCount' and the actual per-plane size information array to 'planes'. Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-03libcamera: v4l2_device: Rename parameters to s/g_fmtJacopo Mondi
Rename parameters to get and set format functions to expand 'fmt' to 'format'. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-02-03libcamera: v4l2_device: Fix getFormatSingleplane ioctlJacopo Mondi
The single plane getFormat() function wrongly used the VIDIOC_S_FMT ioctl. Fix that by using the more opportune VIDIOC_G_FMT one. Fixes: ba8da0f2fcd0 ("libcamera: v4l2_device: Add methods to get/set 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-02-03libcamera: v4l2_device: Rename format() method to getFormat()Jacopo Mondi
Rename format() to getFormat() to reflect the v4l2 API names more closely. 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-01-29libcamera: v4l2_device: Add methods to get/set formatJacopo Mondi
Add methods to set and get the image format programmed on a V4L2Device for both the single and multi planar use case. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-29libcamera: v4l2-format: Add V4L2DeviceFormatJacopo Mondi
Add a V4L2DeviceFormat class aimed to be used to provide format configuration requests to a V4L2Device. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-26libcamera: v4l2_device: Fix wording in documentationLaurent Pinchart
Fix one wording issue in documentation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-25libcamera: v4l2_device: Identify multiplanar formatsJacopo Mondi
Add functions to V4L2Capability to identify if a V4L2 device supports multiplanar V4L2 APIs. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-23libcamera: v4l2device: Obtain device capabilitiesKieran Bingham
The capabilities structure from the kernel can return capabilities of the driver, or potentially more specific device capabilities. Handle this with an inline function 'device_caps()' to return the device specific capabilities when available, or fall back to the driver capabilities otherwise. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-01-22libcamera: Global s/devnode/deviceNode renameJacopo Mondi
Do not use the abreviated version for members, variables and getter methods. Library-wise rename, no intended functional changes. 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>
2019-01-22libcamera: v4l2_device: Add MediaEntity contructorJacopo Mondi
Construct a V4L2Device from a MediaEntity device node path. While at there mark constructor as explicit to avoid copy-construction. 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>
2019-01-21libcamera: Use log categoriesLaurent Pinchart
Use log categories in the whole existing code base. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-17libcamera: Add V4L2 Device objectKieran Bingham
Provide a helper V4L2 device object capable of interacting with the V4L2 Linux Kernel APIs. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>