summaryrefslogtreecommitdiff
path: root/src/libcamera
AgeCommit message (Collapse)Author
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-18libcamera: utils: Add set_overlap() functionLaurent Pinchart
The new set_overlap() function counts the number of overlapping elements in the intersection of two sorted ranges defined by their beginning and ending iterators. 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: geometry: Add comparison operators to geometry classesLaurent Pinchart
Add equality and inequality comparison operators for the Rectangle, Size and SizeRange classes. For the Size class, also add ordering operators. Sizes are first compared on combined width and height, then on area, and finally on width only to achieve a stable ordering. 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: geometry: Use Size to store min and max in SizeRangeLaurent Pinchart
Instead of storing four integers for the minimum and maximum width and height in the SizeRange class, use two instance of the Size class for the minimum and maximum sizes. While it at replace the mention of image size with size in the SizeRange documentation, as the Size class isn't limited to image sizes. 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: geometry: Sort classes alphabeticallyLaurent Pinchart
Move the Size class before the SizeRange class. No functional change. 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: camera: Log requested configuration in configureStreams()Laurent Pinchart
The IPU3 pipeline handler logs the requested configuration in its configureStreams() handler. This is useful for other pipeline handlers as well, move it to the Camera class. 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: log: Mark Loggable::_log() methods as constLaurent Pinchart
The methods don't modify the object instance, mark them as const. This allows using the LOG() macro from a const method of a Loggable object. 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: buffer: Store Request reference in BufferJacopo Mondi
Add to the Buffer class methods to set and retrieve a reference to the Request instance the buffer is part of. As buffers outlive the Request they are associated with, the reference is only temporary valid during the buffer completion interval (from when the buffer gets queued to Camera for processing, until it gets marked as completed). 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-18libcamera: request: Expose the Stream to Buffers mapJacopo Mondi
Add to the Request class a method to access the map of Stream to Buffer. With the introduction of multiple stream support, pipeline handler should be able to access the map of streams at request queueing time. 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-18libcamera: camera: Validate Request before queueing itJacopo Mondi
Extend the Request::prepare() operation to validate the request before preparing it. Return an error if the request is invalid, which for now is limited to ensuring that the request contains at least one buffer. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-18libcamera: request: Add hasPendingBuffers() methodJacopo Mondi
Add method to verify if a request has pending buffers yet to be completed. 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-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-18libcamera: camera: Don't call freeBuffer() on allocateBuffer() errorJacopo Mondi
Do not assume the freeBuffer() function can handle allocateBuffer() method failures, as error handling and clean up should be performed by allocateBuffer() method itself. Perform clean-up on allocations failures in the IPU3 pipeline handler, now that freeBuffers() is not called anymore. 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-17libcamera: camera: Pass the stream set to allocate/freeBuffers()Jacopo Mondi
Pipeline handlers might need to perform allocation of internal buffers, setup operations, or simple sanity check before going into the per-stream buffer allocation. As of now, PipelineHandler::allocateBuffers() is called once for each active stream, leaving no space for stream-independent configuration. Change this by providing to the pipeline handlers the full set of active streams, and ask them to loop over them to perform per-streams memory allocations and freeing. 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-14libcamera: pipeline_handler: Add missing forward declaration of StreamUsageNiklas Söderlund
When switching to stream usages in the PipelineHandler StreamUsage was was not forward declared as it should and was hid by other include files, fix this. Fixes: 20a6455e0b62575b ("libcamera: camera: Add support for stream usages") Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-09libcamera: Add missing header files to meson.buildNiklas Söderlund
Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-09libcamera: Switch to CameraConfigurationNiklas Söderlund
Implement the camera configuration thru out the library, tests, cam and qcam tools. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-09libcamera: camera: Add CameraConfigurationNiklas Söderlund
To properly support both multiple streams and stream usages the library must provide a method to map the stream usages to the returned streams configurations. Add a camera configuration object to handle this mapping. Applications can iterate over the returned camera configuration to retrieve the streams selected by the library in the same order as the usages it provided to the library. Applications can use the operator[] to retrieve the stream pointer and the stream configuration. Using a numerical index retrieves the stream pointer, the numerical indexes corresponds to the insertion order of usages in the CameraConfiguration, using the stream pointer retrieves the stream's configuration. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-05libcamera: camera: Add support for stream usagesNiklas Söderlund
Instead of requesting the default configuration for a set of streams where the application has to figure out which streams provided by the camera is best suited for its intended usage, have the library figure this out by using stream usages. The application asks the library for a list of streams and a suggested default configuration for them by supplying a list of stream usages. Once the list is retrieved the application can fine-tune the returned configuration and then try to apply it to the camera. Currently no pipeline handler is prepared to handle stream usages but nor did it make use of the list of Stream IDs which was the previous interface. The main reason for this is that all cameras currently only provide one stream each. This will still be the case but the API will be prepared to expand both pipeline handlers and applications to support streams usages. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-04-05libcamera: stream: Add basic stream usagesNiklas Söderlund
In preparation of reworking how a default configuration is retrieved from a camera add stream usages. The usages will be used by applications to describe how they intend to use a camera and replace the Stream IDs when retrieving default configuration from the camera using streamConfiguration(). Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
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-03libcamera: ipu3: Catch return value when disabling linksKieran Bingham
Ensure that any error from the disableLinks() call during match() is propogated to the caller. Fixes: d698ed27494a ("libcamera: ipu3: Create ImgUDevice class") Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-03libcamera: ipu3: Enable ImgU media linksJacopo Mondi
As the lengthy comment reports, link enable/disable is not trivial, as links in one ImgU instance interfere with capture operations in the other one. As it is not yet clear if this behaviour is intended, as of now reset the media graph during pipeline's match() and enable the required links at streamConfiguration time. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Limit resolution to 2560x1920Jacopo Mondi
As the procedure to configure the intermediate sizes and the alignement requirements of the ImgU device have not been clarified yet, return as default configuration the (2560x1920) resolution that has been validated for both cameras. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Set stream configurationJacopo Mondi
Use the cached sensor maximum resolution and the pixel format generated by the ImgU output devices as default stream configuration. While at it, replace the hardcoded numerical value for the number of buffers with a named constexpr. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Connect CIO2 and ImgU bufferReady signalsJacopo Mondi
Connect the CIO2 output bufferRead signal to a slot that simply queue the received buffer to ImgU for processing, and connect the ImgU main output bufferReady signal to the cameraData slot that notifies to applications that a new image buffer is available. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Queue requests to ImgUJacopo Mondi
Implement queueRequest for the IPU3 pipeline manager. When a request is queued, a new buffer is queued to the ImgU output for capture. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Implement camera start/stopJacopo Mondi
Start and stop video devices in the pipeline. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Implement memory handlingJacopo Mondi
Implement buffer allocation and release in IPU3 pipeline handlers. As the pipeline handler currently supports a single stream, provide two internal buffer pools for 'viewfinder' and 'stat' video devices, and export the 'output' video device buffers to the stream's pool. This works around the fact that the ImgU requires buffers to be queued on all its outputs, even when they are not in use. Share buffers between the CIO2 output and the ImgU input video devices, as the output of the former should immediately be provided to the latter for further processing. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Apply image format to the pipelineJacopo Mondi
Apply the requested stream configuration to the CIO2 device, and propagate formats through the the ImgU subdevice and its input and output video devices. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Create ImgUDevice classJacopo Mondi
Group ImgU components in a class associated with a camera at camera registration time and provide an intialization method to create and open all video devices and subdevices of the ImgU. Statically assign imgu0 to the first camera and imgu1 to the second one and limit support to two cameras. This will have to be revised in the future. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Cache the sensor size and formatJacopo Mondi
Cache the sensor maximum size and the media bus code used to produce it. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: ipu3: Create CIO2Device classJacopo Mondi
Group CIO2 components (cio2, csi2 and image sensor) in a class associated with the CameraData, to ease management and initialization of CIO2 unit at camera registration time. A CIO2 unit will always be associated with a single Camera only. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: geometry: Add Size structureJacopo Mondi
Add a simple Size structure that contains an image width and height. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: geometry: Add 0-initialized SizeRange constructorJacopo Mondi
Add constructor to SizeRange which initialize all the size range fields to 0. While at there make the in-line constructor declarations respect the coding style by moving braces to a new line. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-04-03libcamera: utils: Use internal secure_getenv() implementationKieran Bingham
The secure_getenv() call is not provided by all C libraries. Support this feature by implementing our own version. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-03libcamera: utils: Use internal basename implementation.Kieran Bingham
Differing implementations of basename() exist, some of which may modify the content of the string passed as an argument. The implementation of basename() is trivial, thus to support different C librariese, provide our own version which accepts and returns a const char *. Update the call sites to use the new implementation. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@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_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: 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: geometry: Add toString to RectangleJacopo Mondi
Add toString() helpers to pretty print out the sizes of a Rectangle. 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-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-20libcamera: media_device: Initialise local variableKieran Bingham
The local variable ifaceId generates a compiler warning that it is used without initialisation. The loop, and check against the loop iterator, and the topology.num_interfaces actually ensures that this isn't the case, and that ifaceId can only be used when set to a valid ID. The media_v2_interface.id field documents the ID as simply "Unique ID for the interface" but does not specify if zero is a valid ID or not. As such we don't further check the pre-initialised ID for validity and keep the existing check on the iterator count to determine if the ID had been discovered successfully. Fixes: d4af90d72901 ("libcamera: media_device: Create entities with major and minor numbers") Acked-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-03-10libcamera: camera: Fix access bug in configureStreams()Niklas Söderlund
It is not permitted to configure streams before a camera is acquired. Fixes: 77100a7578d8a0cc ("libcamera: camera: add state machine to control access from applications") Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-03-05libcamera: camera: ensure streams belong to cameraNiklas Söderlund
Before calling into the pipeline handler make sure the streams provided by the application actually belongs to the camera. 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-03-05libcamera: camera: Unmap buffers before releaseKieran Bingham
Buffers must have all mappings destroyed before buffers can be freed by the V4L2 device that has allocated them. Swap the ordering of freeBuffers() and destroyBuffers() to correct this. Fixes: bd38112b7795 ("libcamera: camera: Extend the interface to support capture") Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 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>