Commit graph

31 commits

Author SHA1 Message Date
Diego Viola
7410755c03 Fix typos
found them with codespell.

Signed-off-by: Diego Viola <diego.viola@gmail.com>
2024-05-22 09:19:34 +02:00
Barnabás Pőcze
87368c8e4f spa: libcamera: remove wrong prefix from log message 2024-05-15 08:31:03 +00:00
Robert Mader
b3ff293263 spa: libcamera: fix RGB mappings
Libcamera formats are generally little-endian, matching DMA DRM
fourccs, while PW ones are big-endian. Thus we have to invert the
order.

Only RGB and BGR where tested, as these are the formats currently
supported by the software ISP. This fixes inverted red and blue in
Snapshot on the Librem5 and Pinephone (OG).

See also gstlibcamera-utils.cpp in libcamera.
2024-05-06 07:41:33 +00:00
Wim Taymans
858d4e9e1c buffer: add MAPPABLE data flag
Add a MAPPABLE data flag that hints that the fd in the data is mappable
with a simple mmap/munmap. Normally, DmaBuf is not mappable like that
unless explicitly indicated with this flag.

Set the MAPPABLE flag on the DmaBuf from v4l2 and libcamera fd.

When asked, mmap the buffer memory in all cases when the MAPPABLE
flag is set.

This solves the case where v4l2 has exported DmaBuf and is streaming to
node A and then node B links but doesn't get automatically mmaped
memory.

Fixes #3840
2024-02-08 18:09:08 +01:00
Barnabás Pőcze
268f4856f8 spa: libcamera: use CameraConfiguration::orientation
libcamera commit cc65629b68d49d ("libcamera: camera: Introduce Orientation") [0]
introduced to the `CameraConfiguration::orientation` member to describe the
orientation of the image in the received memory buffers.

Then c65e40b8480ffb ("libcamera: Use CameraConfiguration::orientation") [1]
removed `CameraConfiguration::transform`, which broke the libcamera plugin.

Fix that by using the new `orientation` member.

[0]: https://git.linuxtv.org/libcamera.git/commit/?id=cc65629b68d49d5f2a4d61537584c56ba510a335
[1]: https://git.linuxtv.org/libcamera.git/commit/?id=c65e40b8480ffb5f50e01a4e6713164c7194a937
2024-01-11 12:04:27 +00:00
Barnabás Pőcze
ab6ff1bcde spa: libcamera: use init list when calling generateConfiguration()
Pass an initializer list to `Camera::generateConfiguration()` instead
of constructing a vector and adding the single element "manually".
2023-07-03 19:40:31 +02:00
Wim Taymans
a0457a3bdf camera: work around target_ mishandling
A driver node should use the target_duration and target_rate to adjust
the quantum and rate when the graph starts.

The camera nodes don't currently support any of this and simply enforce
a specific rate and duration for the graph clock. Mark this with a
FIXME. Otherwise, pipewire will complain that the node is ignoring the
configured graph rate.

We should really look at the graph target rate/quantum and only produce
a buffer when it is inside the current graph cycle. This would make it
possible to join audio and camera nodes and have them be in sync.
2023-03-27 09:59:21 +02:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Wim Taymans
73cc5d1dde libcamera: map controls to standard ids
Map the control id from libcamera to standard pipewire ones and
vice versa.
2023-02-05 10:27:47 +01:00
Wim Taymans
bdc0720bcb Revert "libcamera: Implement proper dmabuf negotiation support"
This reverts commit 950b62a8d8.

It depends on ABI break
2023-01-11 12:21:32 +01:00
Robert Mader
950b62a8d8 libcamera: Implement proper dmabuf negotiation support
According to https://docs.pipewire.org/page_dma_buf.html, i.e. announce
each format once with, once without `SPA_FORMAT_VIDEO_modifier`
property.

Note: currently libcamera always uses `DRM_FORMAT_MOD_LINEAR` (`== 0`),
so `pix.modifier()` returning `0` does not mean that no modifier is
supported.

This is needed for clients using the new DMABuf negotiation pattern,
such as gstpipewiresrc after 602aa7d5.
2023-01-11 01:39:42 +01:00
Robert Mader
59d393bd30 libcamera: Fix 90/270 degree transforms
`Transform::Rot90` means the client should rotate 90 deg. clockwise,
which matches `SPA_META_TRANSFORMATION_90`, i.e. the buffer was
rotated 90 deg. anti-clockwise. The flipped cases should be correct
though.

Also add the source value to the debug print for easier future
debugging.

Fixes fa799aac86
2022-12-07 14:15:59 +01:00
Robert Mader
fa799aac86 libcamera: Implement SPA_META_VideoTransform support
libcamera can detect camera transforms/rotation, e.g. from the device
tree, and makes that information usable for clients via
`CameraConfiguration::transform`.
Advertise this information via the VideoTransform meta so Pipewire
clients can adjust their output accordingly.

Rotated cameras are common in mobile devices such as the Pinephone Pro,
which was used to test this feature.
2022-12-05 18:25:36 +01:00
Robert Mader
75007ae94f libcamera: Fix build error
This is backward compatible and will be needed for libcamera 0.0.3
2022-11-30 09:53:17 +00:00
Robert Mader
b952d52b59 libcamera: Handle missing control info default values
Libcamera does not always provide default values for all control infos, see
https://git.libcamera.org/libcamera/libcamera.git/tree/src/ipa/rkisp1/rkisp1.cpp?h=v0.0.2#n98

Sanitize those values, avoiding crashes.
2022-11-30 09:53:17 +00:00
Wim Taymans
4da154c3a9 libcamera: handle errors better
Make sure we disconnect the request complete handler when we failed
to start.
Stop the camera when we failed to queue our requests.
2022-11-14 13:24:07 +01:00
Wim Taymans
cb18c5877b libcamera: check for item in map correctly
Fixes #2817
2022-11-08 10:41:18 +01:00
Wim Taymans
ef4b9745b2 libcamera: handle canceled requests
When a request is canceled, recycle it so we don't run out of buffers.
Implement getting and setting controls.
2022-10-31 19:03:55 +01:00
Wim Taymans
7182145435 libcamera: pick better default format
Pick the first format in the list of supported as something closest
to 640x480 instead of the lowest possible resolution.

Applications that don't suggest a default size will then get something
more sensible than a poster frame.
2022-10-25 12:10:42 +02:00
Wim Taymans
2086fa5ad2 libcamera: recycle buffers when no io area 2022-10-24 15:40:13 +02:00
Barnabás Pőcze
f9796fc024 spa: libcamera: remove unnecessary typedef 2022-09-15 11:17:47 +00:00
Barnabás Pőcze
02f2d6b48d spa: libcamera: remove unnecessary have_config member
An extra flag is not needed because the `config` pointer can be
checked to determine if a configuration has already been retrieved.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze
9374c15c3d spa: libcamera: use std::optional intead of separate bool flag + value
`std::optional` conveniently encapsulates a value and a bool flag,
so use that instead of manually replicating it.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze
330686d3aa spa: libcamera: rework construction/destruction of libcamera source impl
Move some things into constructors and try not to depend on the
fact that the storage is zero initialized, try to initialize
everything properly.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze
9370fbee3d spa: libcamera: indent with tabs instead of spaces 2022-09-15 11:17:47 +00:00
Wim Taymans
cad7db9f58 libcamera: close camera in error path 2022-09-05 09:25:42 +02:00
Wim Taymans
96472e259f libcamera: return empty controls instead of error 2022-05-26 18:11:06 +02:00
Barnabás Pőcze
57dae3e2b3 spa: libcamera: call get() instead of fd()
libcamera commit 560f5cf998646ddc54a20dc1c7326012834d3204
renamed the `fd()` method on `SharedFD` to `get()`.

Adjust the libcamera plugin accordingly.
2021-12-14 09:52:05 +00:00
Wim Taymans
abacea5ca0 libcamera: improve debug 2021-11-03 17:49:10 +01:00
Wim Taymans
0fd5e3fdb2 libcamera: implement allocation and dataflow
Keep track of the negotiated parameters and use those to construct
the Buffers param.

Use the FrameAllocator to allocate buffer memory. Keep a request for
each buffer and queue them.

In requestComplete, put the request metadata info into the buffer and
header and write the finished buffer id to a ringbuffer. Then wake up
the data thread to pop the finished buffer_id and push it in the
graph.

Remove some old files.
2021-11-03 17:49:10 +01:00
Wim Taymans
b2c38a2b3b libcamera: work on rewrite
Use manager to hotplug devices
Use StreamConfig to enumerate formats
2021-11-03 17:49:10 +01:00