summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-09-23test: ipa: libipa: Add tets for InterpolatorStefan Klug
Add tests for the Interpolator class. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23ipa: libipa: Add generic Interpolator classStefan Klug
The MatrixInterpolator is great for interpolation of matrices for different color temperatures. It has however one limitation - it can only handle matrices. For LSC it would be great to interpolate the LSC tables (or even polynomials) using the same approach. Add a generic Interpolator class based on the existing MatrixInterpolator. This class can be adapted to any other type using partial template specialization. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23libcamera: yaml-parser: Differentiate between empty and empty stringStefan Klug
When accessing a nonexistent key on a dict the YamlObject returns an empty element. This element can happily be cast to a string which is unexpected. For example the following statement: yamlDict["nonexistent"].get<string>("default") is expected to return "default" but actually returns "". Fix this by introducing an empty type to distinguish between an empty YamlObject and a YamlObject of type value containing an empty string. For completeness add an isEmpty() function and an explicit cast to bool to be able to test for that type. Extend the tests accordingly. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23libcamera: yaml-parser: Add failing test for unexpected behaviorStefan Klug
When accessing a nonexistent key on a dict the YamlObject returns an empty element. This element can happily be cast to a string. This is unexpected. For example the following statement: yamlDict["nonexistent"].get<string>("default") is expected to return "default" but actually returns "". Add a (failing) testcase for that behavior. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-23libcamera: yaml-parser: Add additional testsStefan Klug
Add additional tests in preparation for upcoming modifications on the yaml parser. These tests handle the case where the yaml file contains empty items in dictionaries or lists. E.g.: dict: key_with_value: value key_without_value: Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-20libcamera: debayer_cpu: Sync DMABUFsRobert Mader
Using `DMA_BUF_IOCTL_SYNC` is required for DMABUFs in order to ensure correct output. Not doing so currently results in occasional tearing and/or backlashes in GL/VK clients that use the buffers directly for rendering. An alternative approach to have the sync code in `MappedFrameBuffer` was considered but rejected for now, in order to allow clients more flexibility. While the new helper is added to an annoymous namespace, add timeDiff to the same namespace and remove the static definition as a drive by. Signed-off-by: Robert Mader <robert.mader@collabora.com> Tested-by: Milan Zamazal <mzamazal@redhat.com> # Debix Tested-by: Hans de Goede <hdegoede@redhat.com> # IPU6 + ov2740 Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> # Lenovo X13s + OV5675 Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12libcamera: pipeline: simple: Use MediaLink string helperKieran Bingham
Replace the open-coded implementation of a link representation with the operator<< overload string representation to simplify the code and unify appearance of reporting MediaLinks. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12libcamera: media_device: Use MediaLink string helperKieran Bingham
Replace the two open-coded implementations of a link representation with the operator<< overload string representation to simplify the code and unify appearance of reporting MediaLinks. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12libcamera: media_object: Add MediaLink string representationsKieran Bingham
Various parts of libcamera print the representation of a MediaLink by inline joining the parts to make a string representation. This repeated use case can be supported with a common helper to print the MediaLink in a common manner using the existing toString() and operator<< overload style to make it easier to report on MediaLink types. This implementation will report in the following style: 'imx283 1-001a'[0] -> 'video-mux'[0] Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12libcamera: media_object: Add MediaPad string representationsKieran Bingham
Facilitate easy representations of a MediaPad object by preparing it as a string and supporting output streams. A MediaPad will be report in the following style: 'imx283 1-001a'[0] Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12pipeline: simple: Remove media member variablePaul Elder
There is no need for the simple pipeline handler to save the media device. Remove it. Signed-off-by: Paul Elder <paul.elder@ideasonboard.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>
2024-09-12libcamera: v4l2_videodevice: Improve readabilityStefan Klug
The handling for the sequence number validation within V4L2VideoDevice::dequeueBuffer makes use of a std::optional, which can be used as a boolean in conditional statements. This has the impact in this use case that it can be mis-read to be interpretting the value for firstFrame_ which is assigned as the buf.sequence. Remove this potential for confusion by making it clear that the first frame handling is only performed when firstFrame_ does not have a value assigned. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [Kieran: Rework commit message] Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12libcamera: pipeline: simple: Fix typos in match routing commentKieran Bingham
Fix a small typo in the comment regarding the default routing table configuration. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12libcamera: libipa: camera_sensor: Add IMX283 black levelKieran Bingham
Report the default sensor black level reported by the datasheet. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-12ipa: rpi: Adding IMX283 supportwill whang
Add support for the IMX283 sensor for the VC4 target. Signed-off-by: will whang <will@willwhang.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-11qcam: viewfinder_gl: Render image centered in letterboxLaurent Pinchart
Mimic the letterbox behaviour of the Qt viewfinder by rendering the image centered. This is done by adding a projection matrix to the vertex shader to scale the rendered rectangle. Another option would have been to keep using glViewport() (which would have needed to be moved to paintGL(), as Qt resets the viewport to span the full widget before calling). Hidpi displays would then need special handling of the device pixel ratio, which is done automatically by Qt when it sets the default viewport. Using a projection matrix avoids this complication. 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>
2024-09-11qcam: viewfinder_gl: Drop duplicate glClearColor()Laurent Pinchart
There's no need to call glClearColor() twice before drawing any GL content. Drop the first call. This doesn't introduce any functional change. While at it, pass floats instead of doubles to glClearColor(), as required by the function. 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>
2024-09-11qcam: viewfinder_gl: Fix binding of vertex buffer and shader programLaurent Pinchart
Starting in Qt 6.7.0, vertex buffers and shader programs are unbound just before calling QOpenGLWidget::paintGL(). This breaks rendering in the GL viewfinder in two ways. First, we bind the vertex buffer only once at initialization time. There is therefore no vertex buffer mapped at rendering time, preventing both the vertex shader from having access to the vertex and texture coordinates. Then, we bind the shader program only when rendering the first frame. There is thus no shader program bound for all subsequent frames, breaking rendering. Fix this by binding the vertex buffer where needed, when setting attribute buffers for the shader program, and binding the shader program for every frame. As we use a single vertex buffer, we could bind it at the beginning of paintGL() and keep it bound indefinitely. That would however fail to clearly indicate in the source code where the vertex buffer is needed, making the code more difficult to understand as it would rely on implicit assumptions. Release the vertex buffer explicitly when we don't need it anymore to avoid this. While at it, fix a coding style violation by adding missing curly brackets. 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>
2024-09-11qcam: viewfinder_qt: Draw the letterbox background blackLaurent Pinchart
When the widget's aspect ratio doesn't match the camera aspect ratio, the viewfinder is rendered letter-boxed. The side rectangles are not painted by the viewfinder, and Qt thus renders the parent widget background to fill that space. To make it black, we have two options: - The simplest option is to set the widget's autoFillBackground property to true. This causes Qt to paint the whole widget with its background colour before calling paintEvent(). As the camera image typically covers most (if not all) of the viewfinder widget, this is less efficient. - The more complicated option is to paint the letterbox rectangles manually. We can additionally set the widget's WA_OpaquePaintEvent attribute to instruct Qt to skip painting the parent widget. This reduces CPU usage by about 1% (and may reduce GPU usage as well). Note that the WA_OpaquePaintEvent attribute has to be disabled when we render the stopped icon, as the icon has a transparent background. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-11qcam: Drop Qt version checksLaurent Pinchart
The Qt version checks to support different minor Qt5 versions are not needed anymore, now that we switched to Qt6. Drop them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Neal Gompa <neal@gompa.dev>
2024-09-11qcam: Decrease minimum width of selector dialogLuca Weiss
On phone screens the default width is too wide, so the OK button cannot be clicked. Fix this by decreasing the minimum size of the dialog so it fits nicely. Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-10v4l2: Support setting frame rate in the V4L2 Adaptation layerNejc Galof
The V4L2 adaptation layer can already support streaming with components such as OpenCV, however it is not accepting, or handling any requests to configure the frame rate. In V4L2 the frame rate is set by configuring the timeperframe component of the v4l2_streamparm structure through the VIDIOC_S_PARM ioctl. Extend the V4L2 compatibility layer to accept the VIDIOC_S_PARM ioctls and provide an interface for setting controls on the V4L2Camera class to set the requested rate when starting the camera. Signed-off-by: Nejc Galof <galof.nejc@gmail.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
2024-09-09ipa: rpi: agc: Ignore stable region when exposure/gain set manuallyDavid Plowman
When a user is taking control of exposure and gain, setting them manually, we set the AGC "stable region" to zero. This means that any user changes, however small, will be applied, and they won't be regarded as "too small to bother with". Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-05pipeline: rkisp1: Use ScopeExitActions to simplify error handling in startLaurent Pinchart
Error handling in the PipelineHandlerRkISP1::start() function is cumbersome. Simplify it using the utils::ScopeExitActions class. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2024-09-05libcamera: utils: Add ScopeExitActions classLaurent Pinchart
The ScopeExitActions class is a simple object that performs user-provided actions upon destruction. It is meant to simplify cleanup tasks in error handling paths. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2024-09-04utils: checkstyle: Remove style checker for python pep8Stefan Klug
The issues detected and fixed by autopep8 are the same as the ones detected by pycodestyle. As the formatter runs unconditionally we can remove the checker. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-04utils: checkstyle: Add a python formatterStefan Klug
Reporting style issues on python files is great, automatically fixing them is even better. Add a call to autopep8 for python files. This fixes the same issues as the ones reported by pycodestyle. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2024-09-03libcamera: ipa: Drop unneded includes from ipa_interface.hLaurent Pinchart
The ipa_interface.h file includes a number of headers that are not directly used. Remove them, and add them to the source files that include ipa_interface.h as required. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-09-03utils: ipc: Include <string> in generated headers where neededLaurent Pinchart
Depending on the types used in the IPA interface, generated headers may use the std::string class. Include <string> when needed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
2024-09-02libcamera: includes: Formatting improvementsMilan Zamazal
The LSP autoformatter doesn't like some of the current formatting, let's make it happier. Note that not all of its suggestions were accepted because readability is preferred and adjusting .clang-format may not be easy or possible. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: includes: Remove unused includesMilan Zamazal
The includes that are not used can be removed. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: includes: Add missing includesMilan Zamazal
Let's add direct includes for classes currently included indirectly, through other header files. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: libcamera: Formatting improvementsMilan Zamazal
The LSP autoformatter doesn't like some of the current formatting, let's make it happier. Note that not all of its suggestions were accepted because readability is preferred and adjusting .clang-format may not be easy or possible. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: libcamera: Add missing includesMilan Zamazal
Let's add direct includes for classes currently included indirectly, through other header files. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: libcamera: Remove unused includesMilan Zamazal
The includes that are not used can be removed. Additionally, add some directly used includes not listed. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: ipa: Remove unused includesMilan Zamazal
The includes that are not used can be removed. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: v4l2: Fix indirect includeMilan Zamazal
Use the direct include of V4L2PixelFormat. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: v4l2: Fix an include placementMilan Zamazal
Put the inclusion of geometry.h to the right place. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: v4l2: Remove unused includesMilan Zamazal
The includes that are not used can be removed. Also, some directly used includes not listed are added. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: uvcvideo: Fix includesMilan Zamazal
The includes that are not used can be removed and there are also directly used includes not listed. Let's fix both. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: libipa: Remove unused includesMilan Zamazal
The includes that are not used can be removed. And two identified missing includes (directly used but available only through other includes) are added. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: rkisp1: Formatting improvementsMilan Zamazal
The LSP autoformatter doesn't like some of the current formatting, let's make it happier. Note that not all of its suggestions were accepted because readability is preferred and adjusting .clang-format may not be easy or possible. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: rkisp1: Remove unused includesMilan Zamazal
The includes that are not used can be removed. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: ipu3: Formatting improvementsMilan Zamazal
The LSP autoformatter doesn't like some of the current formatting, let's make it happier. Note that not all of its suggestions were accepted because readability is preferred and adjusting .clang-format may not be easy or possible. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: ipu3: Replace wrong includeMilan Zamazal
v4l2_videodevice.h is not used but logging is imported through it. Remove the unused include and include log.h instead. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02libcamera: ipu3: Remove unused includesMilan Zamazal
The includes that are not used can be removed. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-09-02tests: Add a missing iostream includeMilan Zamazal
generated_serializer_test.cpp uses iostream without including it, relying on imports from another included header. Let's include iostream there. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-08-30pipeline: uvcvideo: Implement acquireDevice() + releaseDevice()Hans de Goede
The uvcvideo pipeline handler always keeps the uvcvideo /dev/video# node for a pipeline open after enumerating the camera. This is a problem for uvcvideo, as keeping the /dev/video# node open stops the underlying USB device and the USB bus controller from being able to enter runtime-suspend causing significant unnecessary power-usage. Implement acquireDevice() + releaseDevice(), openening /dev/video# on acquire and closing it on release to fix this. And make validate do a local video_->open() + close() around validate() when not open yet, to keep validate() working on unacquired cameras. Bug: https://bugs.libcamera.org/show_bug.cgi?id=168 Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-08-30libcamera: camera: Use invokeMethod() for pipe_->acquire() and pipe_->release()Hans de Goede
The uvcvideo driver needs to open / close its /dev/video# node from pipe_->acquireDevices() / pipe_->releaseDevices(). V4L2VideoDevice::open() creates an EventNotifier and this notifier needs to be created from the CameraManager thread. Use invokeMethod() for pipe_->acquire() and pipe_->release() so that the EventNotifiers are created from the CameraManager thread context. Running pipe_->acquire() and pipe_->release() from the CameraManager thread context serializes all calls to them. Drop PipelineHandler::lock_ this now is no longer necessary and update the "\context" part of the documentation for acquire[Device]() and release[Device]() to match. Note the delayed opening of /dev/video# is a special case because the kernel uvcvideo driver powers on the USB device as soon as /dev/video# is opened. This behavior should *not* be copied by other pipeline handlers. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2024-08-30pipeline_handler: Add acquireDevice() function to mirror releaseDevice()Hans de Goede
libcamera always keeps all /dev/video# and /dev/v4l2_subdev# nodes for a pipeline open after enumerating the camera. This is a problem for the uvcvideo pipeline handler. Keeping /dev/video# open stops the UVC USB device from being able to enter runtime-suspend causing significant unnecessary power-usage. Add a stub acquireDevice() function to the PipelineHandler class which pipeline handlers can override. The uvcvideo pipeline handler will use this to delay opening /dev/video# until the device is acquired. This is a special case because the kernel uvcvideo driver powers on the USB device as soon as /dev/video# is opened. This behavior should *not* be copied by other pipeline handlers. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Harvey Yang <chenghaoyang@chromium.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>