summaryrefslogtreecommitdiff
path: root/src/libcamera
AgeCommit message (Collapse)Author
2019-09-15libcamera: Move ipa includes to the same level as libcameraLaurent Pinchart
The ipa includes are located in include/libcamera/ipa/. This gives an incorrect impression that they are a sub-part of the rest of the libcamera API, while they are the API towards the IPA the same way that include/libcamera/ contains the API towards applications. To clarify this, move them to include/ipa/. The IPA headers are however still part of libcamera, so installing them to ${prefix}/include/ipa/ would make little sense. To fix this, move the application facing API to ${prefix}/include/libcamera/libcamera/ when installed, and the IPA to ${prefix}/include/libcamera/ipa/. When major versions of libcamera will be released, they could then be installed side by side in ${prefix}/include/libcamera-${version}/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-09-14libcamera: Switch to the std::chrono APILaurent Pinchart
Replace the clock_gettime()-based API with durations expressed as integers with the std::chrono API. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-09-14libcamera: utils: Add clock helpersLaurent Pinchart
In preparation for standardisation of the std::chrono::steady_clock as the libcamera default clock, define aliases for the clock, duration and time point, and add helper functions to convert a duration to a timespec and a time point to a string. More helpers will be added later as needed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-09-13libcamera: device_enumerator_udev: Support entities sharing device nodesLaurent Pinchart
Some media devices, such as V4L2 M2M devices, share the same device node for multiple entities. The udev enumerator used to support this, but commit 6e620349009d ("libcamera: device_enumerator: fix udev media graph loading dependency") broke this. To fix the problem, rework the media device to V4L2 devices matching code. A new MediaDeviceDeps internal struct stores unmet device number dependencies for a media device, and is stored in a list of pending media devices. To avoid linear lookups, the dependencies are cached in a reverse map of device number to media device dependencies. Fixes: 6e620349009d ("libcamera: device_enumerator: fix udev media graph loading dependency") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-09-13libcamera: device_enumerator_udev: Avoid double list lookupLaurent Pinchart
DeviceEnumeratorUdev::populateMediaDevice() searches for orphan devices in an std::list, and if found removes them using std::list::remove(). This ends up looking up the entry twice. Replace the remove() call with erase() to fix it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-09-13libcamera: device_enumerator_udev: Delay device node lookupLaurent Pinchart
When populating media devices, we look up device nodes for every entity in the media device, regardless of if the entity is present in the orphans list. This causes unnecessary lookups (that may also fail as the device node may not be ready yet at that time). Move the lookup at a later time, when the device node is actually needed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-09-13libcamera: device_enumerator: Move lookupDeviceNode() to child classesLaurent Pinchart
The lookupDeviceNode() method is declared as pure virtual in the base DeviceEnumerator class, but is only called by derived classes. Move it to the DeviceEnumeratorSysfs and DeviceEnumeratorUdev. This allows changing the udev version to take a dev_t instead of separate major/minor, as that's what both the caller and the callee end up using. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-09-09src/libcamera/meson.build: link with atomic when neededFabrice Fontaine
On some architectures, atomic binutils are provided by the libatomic library from gcc. Linking with libatomic is therefore necessary, otherwise the build fails with: src/libcamera/4ab8042@@camera@sha/message.cpp.o: In function `libcamera::Message::registerMessageType()': message.cpp:(.text+0x178): undefined reference to `__atomic_fetch_add_4' collect2: error: ld returned 1 exit status This is often for example the case on sparc v8 32 bits. Fixes: - http://autobuild.buildroot.org/results/1f0b8338f5f39aa86b9d432598dae2f53c5f7c84 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> [Kieran: Updated commit message to refer to build failure on current master, rather than the old code currently built by buildroot] Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-09-08libcamera: device_enumerator: fix udev media graph loading dependencyPaul Elder
When a MediaDevice is enumerated and populated by the DeviceEnumeratorUdev, there is a possibility that the member device nodes of the media graph would not be ready (either not created, or without proper permissions set by udev yet). The MediaDevice is still passed up to the pipeline handler, where an attempt to access the device nodes will fail in EPERM. This whole issue is especially likely to happen when libcamera is run at system init time. To fix this, we first split DeviceEnumerator::addDevice() into three methods: - createDevice() to simply create the MediaDevice - populateMediaDevice() to populate the MediaDevice - addDevice() to pass the MediaDevice up to the pipeline handler DeviceEnumeratorSysfs calls these methods in succession, similar to what it did before when they were all together as addDevice(). DeviceEnumeratorUdev additionally keeps a map of MediaDevices to a list of pending device nodes (plus some other auxillary maps), and a simple list of orphan device nodes. If a v4l device node is ready and there does not exist any MediaDevice node for it, then it goes to the orphan list, otherwise it is initialized and removed from the pending list of the corresponding MediaDevice in the dependency map. When a MediaDevice is populated via DeviceEnumeratorUdev::populateMediaDevice(), it first checks the orphan list to see if the device nodes it needs are there, otherwise it tries to initialize the device nodes and if it fails, then it adds the device nodes it wants to its list in the dependency map. This allows MediaDevice instances to be created and initialized properly with udev when v4l device nodes in the media graph may not be ready when the MediaDevice is populated. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-08-29libcamera: v4l2_device: Fix error messages in setControls()Niklas Söderlund
The error messages are copied from getControls() without being updated for the set controls case, fix this. Fixes: eb068f4e67eedacd ("libcamera: v4l2_device: Implement get and set controls") Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-08-22libcamera: process: Properly ignore unused result with gccLaurent Pinchart
Casting the return value of a function to (void) doesn't ignore the unused result warning with gcc. Use a #pragma to fix this properly, to fix compilation with _FORTIFY_SOURCE. Fixes: df23ab95f3d7 ("libcamera: process: fix compilation on Chromium OS") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2019-08-21libcamera: v4l2_videodevice: Support MPLANE M2M devicesKieran Bingham
M2M devices using MPLANE API will set the V4L2_CAP_VIDEO_M2M_MPLANE capability flag. Ensure that this is matched when checking for Multiplanar capabilities. Fixes: 4f7625cca7ec ("libcamera: v4l2_videodevice: Support M2M devices") Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-19libcamera: camera_manager: Construct CameraManager instances manuallyLaurent Pinchart
The CameraManager class is not supposed to be instantiated multiple times, which led to a singleton implementation. This requires a global instance of the CameraManager, which is destroyed when the global destructors are executed. Relying on global instances causes issues with cleanup, as the order in which the global destructors are run can't be controlled. In particular, the Android camera HAL implementation ends up destroying the CameraHalManager after the CameraManager, which leads to use-after-free problems. To solve this, remove the CameraManager::instance() method and make the CameraManager class instantiable directly. Multiple instances are still not allowed, and this is enforced by storing the instance pointer internally to be checked when an instance is created. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19libcamera: proxy: Get event dispatcher from current threadLaurent Pinchart
Get the event dispatcher from the current thread instead of the camera manager. This prepares for the removal of CameraManager::instance(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-19libcamera: device_enumerator: Print media device name in error messageLaurent Pinchart
The device enumerator logs an error message when a media device is removed while still in use. Add the device name to the message to help debugging. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-17libcamera: Add parent argument to constructors of Object-derived classesLaurent Pinchart
Now that the Object class implements parent-child relationships, make it possible to create EventNotifier and Timer instances with a parent by adding a parent argument to their constructors. 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>
2019-08-17libcamera: object: Create parent-child relationshipsLaurent Pinchart
Add a parent Object to Object instances, and track the parent-children relationships. Children are bound to the same thread as their parent, and moving an Object to a thread automatically moves all its children. 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>
2019-08-17libcamera: timer: Bind timers to threadsLaurent Pinchart
The Timer instances are registered with the event dispatcher instance of the CameraManager. This makes it impossible to use timers in other threads. Fix this by inheriting from Object, which allows binding instances to a thread, and register them with the event dispatcher for the thread they are bound to. 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>
2019-08-17libcamera: event_notifier: Bind event notifiers to threadsLaurent Pinchart
The EventNotifier instances are registered with the event dispatcher instance of the CameraManager. This makes it impossible to use event notifiers in other threads. Fix this by inheriting from Object, which allows binding instances to a thread, and register them with the event dispatcher for the thread they are bound to. 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>
2019-08-17libcamera: camera_manager: Bind CameraManager to threadsLaurent Pinchart
The CameraManager class uses the event dispatcher of the current thread. This makes the CameraManager::eventDispatcher() and CameraManager::setEventDispatcher() methods inconsistent, as they access different event dispatcher instances depending on the calling thread. Fix this by inheriting from the Object class, which binds the CameraManager to a thread, and use the event dispatcher of the bound thread. 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>
2019-08-17libcamera: object: Notify objects of thread moveLaurent Pinchart
Send a synchronous message to objects just before they get moved to a new thread. This allows the object to perform any required processing. EventNotifier and Timer objects will use this mechanism to move themselves to the new thread's event disaptcher. 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>
2019-08-17libcamera: object: Add an asynchronous method invocation methodLaurent Pinchart
Add a helper invokeMethod() to the Object class that allows asynchrnous invocation of any method of an Object instance. Asynchronous invocation occurs when control returns to the event dispatcher of the target object's thread, in the context of that thread. To support this, generalise the SignalMessage implementation to support automatic deletion of the associated BoundMethod, and rename the message to InvokeMessage to reflect the more generic purpose. 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>
2019-08-17libcamera: bound_method: Decouple from Signal implementationLaurent Pinchart
To make the BoundMethod classes more generic, replace direct access to private member from Signal classes with accessors or helper functions. This allows removal of friend statements from the BoundMethod classes. 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>
2019-08-17libcamera: signal: Split Slot implementation to reusable classesLaurent Pinchart
Move the Slot* classes to bound_method.{h,cpp} and rename them to Bound*Method*. They will be reused to implement asynchronous method invocation similar to cross-thread signal delivery. This is only a move and rename, no functional changes are included. 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>
2019-08-17libcamera: thread: Support dispatching messages to main threadLaurent Pinchart
Threads contain message queues and dispatch queued messages in their event loop, in Thread::exec(). This mechanism prevents the main thread from dispatching messages as it doesn't run Thread::exec(). Fix this by moving message dispatching from Thread::exec() to EventDispatcher::processEvents(). 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>
2019-08-17libcamera: thread: Wake up target thread when moving objectsLaurent Pinchart
When moving an object to a different thread, messages posted for the object are moved to the message queue of the new thread. Wake up the new thread to ensure it processes the moved messages. 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>
2019-08-13libcamera: v4l2_videodevice: Support M2M devicesKieran Bingham
V4L2 M2M devices represent a V4L2Device with two queues: One output, and one capture on a single device node. Represent this by instantiating a V4L2VideoDevice for each queue type, and preparing each device for its queue. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-13libcamera: v4l2_videodevice: Fix ordering of debug statementKieran Bingham
The "Opened device" statement occurs before the buffertype_ is set. This causes all devices to report that they are [out] devices at open() regardless of their type. As the message operates in the past-tense, move the statement to the end of the function when all work has been completed. Fixes: 04d5be7f76fe ("libcamera: v4l2_device: Inherit from Loggable to print device node name") Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-13libcamera: v4l2_device: Add setFd()Kieran Bingham
Provide a means for V4L2 device instances to set the fd_ explicitly. This allows for V4L2Devices to operate when they must use an external open() call. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-12android: hal: Add Camera3 HALJacopo Mondi
Add libcamera Android Camera HALv3 implementation. The initial camera HAL implementation supports the LIMITED hardware level and uses statically defined metadata and camera characteristics. Add a build option named 'android' and adjust the build system to selectively compile the Android camera HAL and link it against the required Android libraries. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-08-11libcamera: pipeline: vimc: Switch to using the RGB/YUV Capture video nodeNiklas Söderlund
Linux commit 85ab1aa1fac17bcd ("media: vimc: deb: fix default sink bayer format") which is part of v5.2 changes the default media bus format for the debayer subdevices. This leads to a -EPIPE error when trying to use the raw capture video device nodes. Fix this by moving the vimc pipeline to use the RGB/YUV Capture capture video node. As a consequence of this change the scaler in the vimc pipeline is used and a hard coded upscale of 3 is present in the video pipeline. This limits the sizes exposed and accepted by libcamera to multiples of 3. Update the buffer import test case to match this new format constraint by setting the resolution to 1920x1080, a resolution which works with both vimc and vivid. With this new resolution the buffer import test takes a bit more time to complete 60 buffers and it's runtime also needs to be increased. The raw capture video node still needs to be handled by the pipeline as its format needs to be updated to allow the pipeline format validation to pass. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-08-11libcamera: pipeline: vimc: Initialize device pointersNiklas Söderlund
As the device pointers are deleted in the pipelines destructor it's not a good idea to have them uninitialized. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-08-09libcamera: pipeline: RKISP1 configure isp output padHelen Koike
ISP output pad should be set to YUYV8_2X8 for non-bayer output format. Bayer formats are not listed in RkISP1CameraConfiguration::validate(), only non-bayer are listed, so we can set YUYV8_2X8 directly. This will need to be changed if we add support for bayer output with libcamera. Signed-off-by: Helen Koike <helen.koike@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-08-01libcamera: ipa_module: prevent uninitialised accessKieran Bingham
The IPAModule::loadIPAModuleInfo() function includes a *data pointer which is used as a null-pointer comparison in the error path with a conditional statement of "if (ret || !data)". The data variable is not initialised, and a single error path evaluates this as "if (true || uninitialised)". Whilst this error path does not incorrectly utilise the uninitialised data, as the ret evaluates to true already, it does leave a statement which includes an uninitialised variable. Help the static analysers by initialising the data variable when it is defined. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-31libcamera: process: Fail loudly on isolateJacopo Mondi
Add an error debug message when disassociating part of a process execution context using unshare fails. As this is currently used to isolate a child process which is immediately terminated silently if unshare fails, add a debug printout and propagate up the error code to make the failure more visible. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-07-30libcamera: pipeline: ipu3: Fix argument name mismatchLaurent Pinchart
Fix an argument name mismatch between method declaration and definition. Reported-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-17libcamera: logging: add syslog, stream, and nowhere logging targetsPaul Elder
Allow logging to syslog, or any given ostream, or to nowhere. The logging API is updated to accomodate these new logging destinations. LogMessage is modified to allow this. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-07-17libcamera: ipu3: Do not re-queue cancelled buffersJacopo Mondi
When a video device is stopped all the buffers there queued are released and their state is set to BufferCancelled. Currently, on buffer completion, cancelled buffers are blindly re-queued to the ImgU input or CIO2 output devices, preventing them to be re-started succesfully in future capture sessions. Fix that by inspecting the buffers status and skip re-queueing if they're reported as cancelled. For the ImgU output buffer this is not required, as cancelled request should be reported to applications in order to report them failure of the capture operations. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-07-17libcamera: ipu3: Disable links at configure() timeJacopo Mondi
With the current IPU3 kernel driver implementation, a linked pipe shall be used (buffers should be queued on it) in order not to block all other pipes. Currently all links on the ImgU device are only disabled at match() time, implying that once an ImgU pipe gets linked, it should be used until the whole pipeline is not re-matched and links disabled again. This is a severe limitation for applications that wants to switch between cameras using different pipes going through a full library tear-down and reload. Perform link disabling at configure() time as well, so that a camera configuration operation always unlock the usage of the assigned pipe, regardless of the previously linked ones. Unfortunately this requires a camera start/stop sequence to always go through a configure step, a requirement that is not enforced by the Camera state machine. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-07-16libcamera: message: Add user message typesJacopo Mondi
Reserve identifiers for user-defined message types and add an operation to the Message class to register the type identifiers. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-07-16libcamera: message: Document Message::SignalMessageLaurent Pinchart
The SignalMessage type is undocumented. Fix it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-07-16libcamera: stream: Initialise pixelFormat in StreamConfiguration()Laurent Pinchart
To avoid depending on unitialised values, set the pixelFormat field of the StreamConfiguration class to 0 in the constructor. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-16libcamera: pipeline: ipu3: Free internal buffers after stopping streamingLaurent Pinchart
The internal buffers between the CIO2 and ImgU are freed by the CIO2Device::stop() method, which is called first when stopping streaming. The ImgUDevice::stop() method is then called, and attempts to report completion for all queued buffers, which we have just freed. The use-after-free corrupts memory, leading to crashes. Fix this by moving the vector of internal buffers to the IPU3CameraData where it belongs, and free the buffers after stopping both devices. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-16libcamera: pipeline: ipu3: Initialise pixel format to NV12 in new configLaurent Pinchart
To avoid printing debugging messages related to stream configuration adjustement when generating a new configuration, set the pixel format explicitly instead of relying on the internal validate() call to do so. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
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: pipeline: Support importing buffersJacopo Mondi
Add support for importing external buffers in all pipeline handlers. Use the stream memory type in the pipeline handlers during buffer allocation to import buffers to or export buffers from the video device. 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: 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: buffer: Add dmabuf file descriptorsJacopo Mondi
In addition to referencing buffer memory by index, add support to referencing it using dmabuf file descriptors. This will be used to reference buffer memory allocated outside of libcamera and import it. The dmabuf file descriptors are stored in an array in the Buffer class, and a new Stream::createBuffer() overload is added to construct a buffer from dmabuf file descriptor. 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: 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>