Commit graph

127 commits

Author SHA1 Message Date
Barnabás Pőcze
1e09827953 spa: libcamera: don't use fixed size buffers for properties
Use `std::string` and `std::ostringstream` when processing the
camera properties, in order to avoid truncation.

See !2095
See !2268
2025-02-03 17:20:25 +00:00
Barnabás Pőcze
41045c5e61 spa: libcamera: use references when getting camera properties
The argument is not nullable, so use a const lvalue reference
to express that clearly.
2025-02-03 17:20:25 +00:00
Wim Taymans
41e35c7b17 v4l2: use dll to track rate difference
Track the difference between the configured and real framerate and use
that as the rate correction to adjust the next_nsec clock field.
2024-11-26 17:14:26 +01:00
Wim Taymans
043245ca11 v4l2: set the NO_RATE clock flag
These sources have very inaccurate position/duration/rate information
that is not suitable for use as a clock so set the NO_RATE flag.
2024-11-26 17:05:20 +01:00
Elliot Chen
d5e2a0df6c libcamera: update buffers datas information according to plane info 2024-11-04 17:00:18 +00:00
Elliot
d67882fa10 libcamera: allocate memory according to the number of discontiguous memory 2024-10-30 15:20:21 +00:00
Robert Mader
d59158529b libcamera: reset ringbuffer when clearing buffers
Keeping the ringbuffer state around resulted in a high chance of
using wrong buffer IDs for consequent streams, causing various issues.
2024-08-30 06:49:17 +02:00
Hans de Goede
00a8ce8db6 spa: libcamera: Increase devices_str[] buffer size
Some complex camera pipelines, like the IPU6 can involve many /dev/video#
nodes (32 in the IPU6 case) and the current size of 128 chars is not enough
to hold all /dev/video# nodes in this cases causing SPA_KEY_DEVICE_DEVIDS
to get truncated, which in turn breaks the filtering of V4L2 devices which
are used by a libcamera driven camera in wireplumber.

Fix this by increasing the size of devices_str[] to 256.

This fixes wireplumber adding a bunch of non-function V4L2 video sources,
e.g. before this "wpctl status" outputs the following video sources:

Video
 ├─ Devices:
...
 ├─ Sources:
 │      90. ov2740
 │  *  115. ipu6 (V4L2)
...
 │     135. ipu6 (V4L2)
 │
 ├─ Filters:

After this fix the output is:

Video
 ├─ Devices:
...
 ├─ Sources:
 │  *   92. ov2740
 │
 ├─ Filters:

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2024-08-06 15:14:27 +02:00
Sven Püschel
0c07c78621 spa: libcamera: uncomment setting integer controls
When using Open Broadcaster Software with Pipewire and a libcamera
camera node, changing the ExposureTime doesn't work.

The commit introducing the camera control setting has commented out the
integer case: ef4b9745b2 ("libcamera: handle canceled requests")
But as it doesn't give a reson for the comment, it looks like an
oversight.

Therefore removing the comment to allow setting the ExposureTime integer.

Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
2024-07-17 16:00:23 +00:00
Barnabás Pőcze
ec521ca870 meson.build: enable -Werror=format 2024-06-27 21:18:06 +00:00
Wim Taymans
9d1d1fcbef impl-port: add port.group property
Can be used to group ports together. Mostly because they are all from
the same stream and split into multiple ports by audioconvert/adapter.

Also useful for the alsa sequence to group client ports together.

Also interesting when pw-filter would be able to handle streams in the
future to find out what ports belong to what streams.
2024-06-24 13:38:09 +02:00
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
8e495a3a2c spa: libcamera: remove unused includes 2024-05-15 08:31:03 +00:00
Barnabás Pőcze
55fafe8f0b spa: libcamera: remove two unused members 2024-05-15 08:31:03 +00:00
Barnabás Pőcze
87368c8e4f spa: libcamera: remove wrong prefix from log message 2024-05-15 08:31:03 +00:00
Barnabás Pőcze
b7ef5c92bc spa: libcamera: remove unnecessary snprintf() 2024-05-15 08:31:03 +00:00
Barnabás Pőcze
9eab76d862 spa: libcamera: don't calculate id twice 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
Barnabás Pőcze
da1dbc1120 treewide: fix C++20 compilation error wrt. designated initializers
C++20 introduced designated initializers similar to the ones found
in C99, however, in C++ designated initializers cannot be mixed
with non-designated initializers. GCC rejects mixed initializers
with an error.
2024-05-03 07:16:57 +00:00
Ashok Sidipotu
4d3d15aebe spa: libcamera: encode device ids into a json array 2024-04-18 14:02:54 +05:30
Robert Mader
bd5cc52c5c libcamera: add camera rotation property on nodes
Like the location, the orientation is a static property of libcamera
devices. While the rotation is already exposed as buffer transform,
knowing the property can be handy for applications in various ways.

See also: cd8ac5c1a ("libcamera: add camera location property on nodes")
2024-03-31 13:24:19 +02: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
Wim Taymans
b4c7973d49 meson: fix build with missing libudev-devel 2024-02-06 11:49:40 +01:00
Barnabás Pőcze
4b145ad444 spa: libcamera: bump minimum supported version to 0.2.0 2024-01-11 12:04:27 +00: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
Pauli Virtanen
eaea03c26c spa: export log topic enumerations 2024-01-04 10:02:55 +00:00
Wim Taymans
e4cee8eec2 libcamera: add latency param query
JACK queries this unconditionally but it's a good idea to implement this
like v4l2-source.
2023-11-20 17:51:27 +01:00
Barnabás Pőcze
08002f0497 spa: libcamera: get rid of an unnecessary snprintf() call
Simply use the returned string for populating the spa_dict
instead of doing a copy into a fixed size buffer on the stack.
2023-11-06 19:01:20 +01:00
Barnabás Pőcze
8256a2d5a6 spa: remove unnecessary indirection for some spa_log_topics
This results in shorter machine code since it removes one
pointer load and a NULL check.
2023-10-06 13:08:24 +00:00
Robert Mader
5bac089229 spa: libcamera: add libcamera version check for properties::SystemDevices 2023-07-19 09:21:03 +00:00
Ashok Sidipotu
79518d13ae spa: libcamera: consume the device numbers libcamera property
Pass on the device numbers property of libcamera to session managers, with they
are better equipped to filter the camera/video devices across v4l2 and libcamera.
2023-07-19 09:21:03 +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
Dmitry Sharshakov
6d712d17e7 meson: libcamera: remove libdrm dependency
Seems to no longer be used in plugin headers, thus not a direct dependency.
2023-02-10 09:21:58 +00:00
Barnabás Pőcze
1cde814cdf spa: libcamera: remove unused libcamera-client.c 2023-02-09 22:02:48 +01: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
f472fd736d fix includes
Only include debug we need. We usually only need the debug types.
2023-01-18 13:12:16 +01:00
Robert Mader
714b438814 libcamera: Check format info for correct flags and modifier 2023-01-12 11:22:25 +00:00
Wim Taymans
afedd107a8 Revert "video: Add extra field indicating if modifier value is valid"
This reverts commit 1e6920c33b.

Causes an ABI break.
2023-01-11 12:21:42 +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
1e6920c33b video: Add extra field indicating if modifier value is valid
The drm format modifier value `0` is actually `DRM_FORMAT_MOD_LINEAR`,
a commonly used modifier. Unfortunately there appears to be no value
that can savely used as placeholder for "no value", as e.g.
`DRM_FORMAT_MOD_INVALID` is often used to indicate an implicit modifier.

Thus add an extra field that clearly indicates whether the modifier
value is set or not, add it to the util fuctions and use it for the
current only user, the libcamera backend.

Fixes 5a6da7d5e1

Closes https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2943
2023-01-10 22:01:31 +01:00
Wim Taymans
97aafe2234 fix use_buffers checks
We can set 0 buffers even if there is no format.
Return -ENOSPC when too many buffers are set.
2023-01-10 12:30:25 +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
93d2571b30 libcamera: fix device id assignment
Find a free id from the available ids instead of just taking the current
number of devices, which would give assign the same id to multiple
cameras when: added 0, added 1, removed 0, added 1.
2022-11-14 16:04:21 +01:00
Wim Taymans
a57590e334 libcamera: emit device removal event
We need to emit the device id with NULL info to emit a device remove
event.

Also indent some code properly.
2022-11-14 15:38:16 +01:00