summaryrefslogtreecommitdiff
path: root/src/libcamera/camera.cpp
AgeCommit message (Collapse)Author
2021-07-12libcamera: Drop the LIBCAMERA_D_PTR macro in favour of the _d() functionLaurent Pinchart
Now that all Extensible classes expose a _d() function that performs appropriate casts, the LIBCAMERA_D_PTR brings no real additional value. Replace it with direct calls to the _d() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-07-06libcamera: camera: Make stop() idempotentNícolas F. R. A. Prado
Make Camera::stop() idempotent so that it can be called in any state and consecutive times. When called in any state other than CameraRunning, it is a no-op. This simplifies the cleanup path for applications. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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-04-22libcamera: camera: Assert pipelines complete all requestsKieran Bingham
When the camera manager calls stop on a pipeline, it is expected that the pipeline handler guarantees all requests are returned back to the application before the camera has stopped. Ensure that this guarantee is met by providing an accessor on the pipeline handler to validate that all pending requests are removed. Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-04-03libcamera: pipeline_handler: Make queueRequest() void functionHirokazu Honda
PipelineHandler::queueRequest() is asynchronously invoked in Camera::queueRequest(). Therefore the return value of PipelineHandler::queueRequest() is useless. This changes the function to a void function. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2021-03-29libcamera: camera: Extend with a Stopping stateKieran Bingham
When the camera is being stop()ped, active requests will complete. These may trigger an application to re-queue those requests to the camera but that is not permitted, and is an error in the application. Extend the camera state to include a stopping state which is entered as soon as a call to stop() is made. At this point, any request queued will be rejected with a warning, while any pending requests are either successfully completed or cancelled. When the pipeline handler has finished stopping, the camera state will transition to the CameraConfigured state where it can begin to accept requests again, and be restarted. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-29libcamera: camera: Report function which fails access controlKieran Bingham
The camera object has a state machine to ensure calls are only made when in the correct state. It isn't easy to identify where things happen when assertions fail so add extra information to make this clearer. The error level of the isAccessAllowed is raised from Debug to Error as this is important information for applications to know if they have made a request in an invalid state. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-29libcamera: camera: Validate requests are completed in Running stateKieran Bingham
All requests must have completed before the Camera has fully stopped. Requests completing when the camera is not running represent an internal pipeline handler bug. Trap this event with a fatal error. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-02-21libcamera: camera: Constify controls argument to start()Laurent Pinchart
The ControlList passed to the Camera::start() function isn't modified. Make it const. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2021-01-05libcamera: camera: Fix-typoSebastian Fricke
s/chance/change/ Signed-off-by: Sebastian Fricke <sebastian.fricke.linux@gmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-12-28libcamera: pipeline_handler: Remove Camera argument from request handlingNiklas Söderlund
There is no need to pass the Camera pointer to queueRequest(), completeBuffer() and completeRequest() as the Request also passed contains the same information. Remove the Camera argument to avoid situations where the information in the Request and the argument differ. There is no functional change and no public API change as the interface is only used between the Camera and PipelineHandler. 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>
2020-12-14libcamera: Replace ARRAY_SIZE() with std::size()Laurent Pinchart
C++17 has a std::size() function that returns the size of a C-style array. Use it instead of the custom ARRAY_SIZE macro. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-12-08libcamera: pipeline: Pass libcamera controls into pipeline_handler::start()Naushir Patuck
Applications now have the ability to pass in controls that need to be applied on startup, rather than doing it through Request where there might be some frames of delay in getting the controls applied. This commit adds the ability to pass in a set of libcamera controls into the pipeline handlers through the pipeline_handler::start() method. These controls are provided by the application through the camera::start() public API. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Tested-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-11-24libcamera: camera: Document the camera and pipeline modelLaurent Pinchart
Introduce a pipeline model that lists the operations applied by the camera pipeline. This is a first step towards defining explicitly how the camera processes images, and how the libcamera controls affect the processing. The initial list of operations is meant to be expanded, and possibly refactored (a block diagram should also be considered to make this easier to read). How the controls affect the pipeline is largely missing at this stage, with only a short explanation of the digital zoom to show how this is meant to be documented. More documentation will be added over time. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Sebastian Fricke <sebastian.fricke.linux@gmail.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-11-08libcamera: camera: Inherit from ExtensibleLaurent Pinchart
Use the d-pointer infrastructure offered by the Extensible class to replace the custom implementation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-10-12libcamera, android, cam, gstreamer, qcam, v4l2: Reuse RequestPaul Elder
Allow reuse of the Request object by implementing reuse(). This means the applications now have the responsibility of freeing the Request objects, so make all libcamera users (cam, qcam, v4l2-compat, gstreamer, android) do so. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-09-29libcamera: Add user Transform to CameraConfigurationDavid Plowman
Add a field to the CameraConfiguration (including the necessary documentation) to represent a 2D transform requested by the application. All pipeline handlers are amended to coerce this to the Identity, marking the configuration as "adjusted" if something different had been requested. Pipeline handlers that support Transforms can be amended subsequently. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-09-20libcamera: camera: Optimize camera deletionLaurent Pinchart
In most cases the last reference to a Camera instance will be the one held by the CameraManager. That reference gets released when the CameraManager thread cleans up, just before it stops. There's no need to delete the camera with deleteLater() in that case. To optimize this case, use deleteLater() only when the camera gets deleted from a different thread, and delete is synchronously otherwise. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <email@uajain.com>
2020-08-16libcamera: camera: Mark controls() and properties() as const operationsNiklas Söderlund
Reading the controls and properties does not modify the camera's state and can be marked as const operations. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-14libcamera: request: Make Stream pointer constNiklas Söderlund
The Stream pointer just acts as a key in the Request object. There is no good use-case to modify a stream from a pointer retrieved from the Request, make it const. This allows pipeline handlers to better express that the Stream pointer is retrieved in a Request should just be treated as a key. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-08-05libcamera: camera: Rename name() to id()Niklas Söderlund
Rename Camera::name() to camera::id() to better describe what it represents, a unique and stable ID for the camera. While at it improve the documentation for the camera ID to describe it needs to be stable for a camera between resets of the system. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-08-03libcamera: camera: Zero streams before validate()Jacopo Mondi
The current implementation of the Camera::configure() method zeroes the stream pointers assigned to the StreamConfiguration items before calling the pipeline handler configure() operation, just after the CameraConfiguration has been validated. This discards the stream assignment performed at pipeline hander validation time, requiring platforms that need to perform that early assignment to maintain the association in place with custom data structures. To allow pipeline handlers to use StreamConfiguration::setStream() at validate() time, zero the stream assignment before calling validate(). 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>
2020-07-31libcamera: camera: Ensure deletion via deleteLater()Umang Jain
Object::deleteLater() ensures that the deletion of the Object takes place in a thread it is bound to. Deleting the Object in a different thread is a violation according to the libcamera threading model. On hot-unplug of a currently streaming camera, the last reference of Camera when dropped from the application thread (for e.g. QCam's thread), the destructor is then called from this thread. This is not allowed by the libcamera threading model. Camera is meant to be deleted in the thread it is bound to - in this case the CameraManager's thread. Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-05libcamera: camera: Order parameter documentation correctlyMarvin Schmidt
Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-06-04libcamera: camera: Return -EINVAL if any stream is null while configure()Umang Jain
Fail and return the Camera::configure() operation if any of the stream turns out to be a nullptr even after the PipelineHandler handler seems to have configured the config successfully. This prevents a null-dereference below in the loop. Reported-by: Coverity CID=279069 Signed-off-by: Umang Jain <email@uajain.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-06-04libcamera: camera: Drop full stop from \returnJacopo Mondi
We don't use full stops at the end of \return directives in Doxygen documentation. Drop it. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
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-03-18libcamera: framebuffer_allocator: Lift camera restrictions on allocatorLaurent Pinchart
The Camera class currently requires the allocator to have no allocated buffer before the camera is reconfigured, and the allocator to be destroyed before the camera is released. There's no basis for these restrictions anymore, remove them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-03-18libcamera: pipeline_handler: Fold buffer management with start/stopLaurent Pinchart
There's no need anymore to have the Camera object control how and when pipeline handlers allocate and free the buffers for the application-facing video devices. Fold those operations, currently performed by importFrameBuffers() and freeFrameBuffers(), into the start() and stop() functions. This simplifies the pipeline handler API, its implementation, and the implementation of the Camera class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-03-18libcamera: pipeline_handler: Decouple buffer import and exportLaurent Pinchart
Use the V4L2 buffer orphaning feature, exposed through V4L2VideoDevice::exportBuffers(), to decouple buffer import and export. The PipelineHandler::importFrameBuffers() function is now called for all streams regardless of whether exportFrameBuffers() has been called or not. This simplifies the Camera implementation slightly, and opens the door to additional simplifications. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-03-18libcamera: camera: Propagate error value from importFrameBufferLaurent Pinchart
The PipelineHandler::importFrameBuffer() function, called by Camera::start() may return an error, but its return value is ignored. Propagate it to the caller to fix this. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-02-14libcamera: camera: Add Camera propertiesJacopo Mondi
Add a method to the Camera class to retrieve the Camera properties registered by the pipeline handler. While at it, reword the Camera::controls() operation documentation to specify that the camera control information are constant during the camera lifetime not their value, while the camera properties value are the actually static information. 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>
2020-02-13libcamera: camera: Implement the threading modelLaurent Pinchart
Document the threading model of the Camera class and implement it. Selected functions become thread-safe, and require a few functions of the PipelineHandler class to be called through cross-thread invocation as the pipeline handlers live in the camera manager thread, while the Camera class is mostly accessed from the application thread. The PipelineHandler is made to inherit from the Object class to support this. Disconnection is currently left out as it is not implemented in pipeline handlers, and isn't fully supported in the Camera class either. This will be revisited when implementing proper hotplug support. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-01-23libcamera: camera: Centralize state checks in Private classLaurent Pinchart
Move all accesses to the state_ and disconnected_ members to functions of the Private class. This will make it easier to implement synchronization, and simplifies the Camera class implementation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-01-23libcamera: camera: Move private data members to private implementationLaurent Pinchart
Use the d-pointer idiom ([1], [2]) to hide the private data members from the Camera class interface. This will ease maintaining ABI compatibility, and prepares for the implementation of the Camera class threading model. The FrameBufferAllocator class accesses the Camera private data members directly. In order to hide them, this pattern is replaced with new private member functions in the Camera class, and the FrameBufferAllocator is updated accordingly. [1] https://wiki.qt.io/D-Pointer [2] https://en.cppreference.com/w/cpp/language/pimpl Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-01-12libcamera: camera: Remove the prepared stateNiklas Söderlund
With the FrameBuffer rework completed there is no reason to keep the camera prepared state around as buffer allocations are now decoupled from the camera state. Remove the camera state simplifying the API. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-12libcamera: pipeline: Remove explicit buffer handlingNiklas Söderlund
With the FrameBuffer interface in place there is no need for the Camera to call into the specific pipelines allocation and freeing of buffers as it no longer needs to be synchronized with buffer allocation by the application. Remove the function prototypes in the pipeline handler base class and fold the functionality in the pipelines start() and stop() functions where needed. A follow up patch will remove the now no-op Camera::allocateBuffers() and Camera::freeBuffers(). Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-12libcamera: Switch to FrameBuffer interfaceNiklas Söderlund
Switch to the FrameBuffer interface where all buffers are treated as external buffers and are allocated outside the camera. Applications allocating buffers using libcamera are switched to use the FrameBufferAllocator helper. Follow-up changes to this one will finalize the transition to the new FrameBuffer interface by removing code that is left unused after this change. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-12libcamera: allocator: Add FrameBufferAllocator to help applications allocate ↵Niklas Söderlund
buffers The FrameBuffer interface is based on the idea that all buffers are allocated externally to libcamera and are only used by it. This is meant to create a simpler API centered around usage of buffers, regardless of where they come from. Linux however lacks a centralized allocator at the moment, and not all users of libcamera are expected to use another device that could provide suitable buffers for the camera. This patch thus adds a helper class to allocate buffers internally in libcamera, in a way that matches the needs of the FrameBuffer-based API. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-12libcamera: request: remove prepare()Niklas Söderlund
The association of buffers to a request can be done directly in addBuffer() instead of when the request is queued to the camera. Keep the check that a request contains buffers by moving it to Camera::queueRequest() where prepare() was previously called. As a bonus we can remove a friend statement in Request. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-11-19libcamera: camera: Remove explicit stream to buffer map in requestCompleted ↵Niklas Söderlund
signal The stream to buffer map in the requestCompleted signal is taken directly from the request which is part of the same signal. Remove the map as it can be fetched directly from the request. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-15libcamera: Fix spellings and grammarKieran Bingham
Fix a number of spelling errors and word duplications throughout the comments within libcamera. These were picked up with spellintian. Also one capitalisation of the first word of a \return statement picked up by checkstyle.py while creating this patch. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-07-14libcamera: stream: Map external buffers to indexesJacopo Mondi
Add and use an operation to assign to Buffer representing external memory locations an index at queueRequest() time. The index is used to identify the memory buffer to be queued to the video device once the buffer will be queued in a Request. In order to minimize relocations in the V4L2 backend, this method provides a best-effort caching mechanisms that attempts to reuse BufferMemory previously mapped to the buffer's dmabuf file descriptors, if any. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-14libcamera: buffer: Add an accessor to the BufferMemoryLaurent Pinchart
Buffer instances reference memory, which is modelled internally by a BufferMemory instance. Store a pointer to the BufferMemory in the Buffer class, and populate it when the buffer is queued to the camera through a request. This is useful for applications to access the buffer memory in the buffer or request completion handler. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-14libcamera: stream: Add Stream memory typeJacopo Mondi
Define the memory type a Stream uses and allow application to set it through the associated StreamConfiguration. A Stream can use either internal or external memory allocation methods, depending on where the data produced by the stream is actually saved. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-14libcamera: stream: Shorten access to the bufferPoolJacopo Mondi
All interactions with the Stream's buffers currently go through the BufferPool. In order to shorten accessing the buffers array, and eventually restrict access to the Stream's internal buffer pool, provide operations to access, create and destroy buffers. It is still possible to access the pool for pipeline handlers to populate it by exporting buffers from a video device to Stream's pool. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-14libcamera: request: Add cookie to make request tracking easierLaurent Pinchart
Applications often have to map requests queued to a camera to external resources. To make this easy, add a 64-bit integer cookie to the Request class that is set when the request is created and can be retrieved at any time, especially in the request completion handler. The cookie is completely transparent for libcamera and is never modified. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-14libcamera: camera: Don't check buffer count before freeing buffersLaurent Pinchart
There's no need to check if buffers have been allocated before freeing them as the BufferPool::destroyBuffers() method is a no-op when no buffers have been allocated. Document this fact explicitly, and remove the buffer count check. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-14libcamera: camera: Don't move buffers away from request at completionLaurent Pinchart
For a historical reason that isn't fully understood, the request completion handler in the Camera class moves all buffers away from the request's buffer map to a local variable before emitting the request completion signal. There's no reason to do so, and it makes it impossible for requests to access buffers in their destructor. Fix it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-02libcamera: camera: Provide a list of ControlInfoKieran Bingham
Extend the Camera class to expose the controls it supports. Each pipeline should generate a list of controls supported by each camera it creates. These are represented by a ControlInfoMap, and an associated ControlList of default values. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>