Commit graph

3424 commits

Author SHA1 Message Date
Wim Taymans
b2ce24e20e v4l2: queue dropped first buffer again
When we drop the first buffer to avoid timestamp problems, queue it
again in the driver or else we will not be able to dequeue is again
later and we will be running with a buffer less.
2024-09-19 09:49:53 +02:00
Severin von Wnuck-Lipinski
55dc9c3c27 bluez5: backend-native: Handle AT+CCWA command
Claim that call waiting notifications are supported.
Required for some devices (e.g. Soundcore Motion 300),
as they stop sending commands if the reply to CCWA is not OK.
2024-09-17 11:35:54 +02:00
Wim Taymans
bc435dc6f3 audioadapter: recheck formats when EnumFormat changes
When the follower has new EnumFormat, make sure we recheck the formats
the next time the node is started.
2024-09-17 11:18:43 +02:00
Wim Taymans
29595ca7bf audioadapter: clear buffers when format is reconfigured
Always clear the Buffers when the format is reconfigured because they
depend on the Format.
2024-09-17 11:18:43 +02:00
Wim Taymans
7114e9a31a v4l2: Improve format and control enumeration
Use dynamic pod builder so that we can also build complex formats.

Make sure we zero the format before we parse it or else we end up with
potentially uninitialized values.

When ENUM_FRAMESIZES or VIDIOC_ENUM_FRAMEINTERVALS return EINVAL for the
first index, make a dummy result and continue with that. This will
trigger an intersect withe filter so that we end up with something valid
instead of nothing.

Handle 0 framerates without crashing.

See #4063
2024-08-07 10:44:26 +02:00
Wim Taymans
bc9eb76a6e v4l2: use a dynamic pod builder to handle larger PropInfo
The labels from the vivid driver need more space so use a dynamic
builder to make sure we can handle them.

See #4063
2024-08-07 10:42:29 +02:00
Hans de Goede
b79f77b73d 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-07 10:40:55 +02:00
Wim Taymans
3c9bd37fa1 acp: handle some errors better
Handle allocation failure and size overflow.
2024-05-24 11:01:06 +02:00
Pauli Virtanen
2335657343 bluez5: media-sink: keep one more buffer free
We delay the audio a bit to keep packet intervals equal, which keeps
some data in buffers.

In theory the calculation keeps one buffer free, but it doesn't
explicitly keep "extra" buffer space so in theory might flush too late
and next process() might not have free buffers.  However, as we encode
next packet right away this shouldn't really occur...

Try to keep one extra spare buffer free so that the flush time is
certainly early enough.
2024-05-06 18:21:33 +03:00
Pauli Virtanen
513495eaaa bluez5: drop queued data on node stop
Clear queued buffers when stopping consuming, to ensure that all buffers
are usable when we start again.

Do for A2DP as we already do for SCO.
2024-05-06 18:21:29 +03:00
Robert Mader
60deeb2555 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 09:53:50 +02:00
Barnabás Pőcze
f524271b81 treewide: fix errno assignments
Do not set `errno` to a negative value.
2024-05-03 12:12:05 +02:00
Lukas Rusak
1b115eaf31 alsa-pcm: don't force quantum for iec958 formats
This fixes an issue introduced in 771f71f622
where the quantum is forced and may break applications the specify their
own quantum.

Signed-off-by: Lukas Rusak <lorusak@gmail.com>
2024-05-03 12:10:54 +02:00
Pauli Virtanen
d3980f7cef journal: prepend code location to messages at debug log levels
Debug and trace log messages are often written based on the stderr
logging, where code location is always visible.

journalctl does not show the code location without extra tricks,
which makes user-submitted debug logs from journal more cryptic.

Make journal log more similar to stderr logs by prepending the code
location and log level in the log message when the log topic
level is >= DEBUG.
2024-04-29 16:30:06 +02:00
Barnabás Pőcze
8a4ff447d9 treewide: fix some format string issues
Use the proper specifier, and cast to a known type where the type
is not guaranteed by any standard.

See #3975
2024-04-29 16:19:15 +02:00
Wim Taymans
5066ea9a72 v4l2: fix printf format 2024-04-23 11:16:40 +02:00
Ashok Sidipotu
7728586601 spa: v4l2: encode device id into a json array 2024-04-23 11:16:40 +02:00
Ashok Sidipotu
4c19da1127 spa: libcamera: encode device ids into a json array 2024-04-23 11:16:40 +02:00
Wim Taymans
17a2c21573 audioconvert: also clamp monitor volume to min/max
When we set a min/max value, also clamp the monitor volume to it.

Fixes #3962
2024-04-16 09:56:48 +02:00
Wim Taymans
b5284791fc v4l2: handle empty properties gracefully
When a property is not found or is empty, go on to the next format
instead of failing.

See #3959
2024-04-10 11:10:20 +02:00
Adam Gensler
582dcf773d Update 90-pipewire-alsa.rules with support for Astro Mixamp Pro TR. 2024-04-02 13:30:02 +02:00
Robert Mader
f9bac4889c v4l2: Drop the first frame after camera startup
A quite big number of UVC cameras - due to firmware or kernel driver
issues - have bad timestamps of the first frame, confusing clients
like pipewiresrc.
Drop the first frame, as this seems to be the most reliable workaround
for the time being.

Closes https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3910
2024-03-31 13:15:20 +02:00
Wim Taymans
3ea4193bf6 spa: improve null-audio-sink channels
We can just update the channels in the props, we don't need an extra
property that can go out of sync with the channels.

See #3931
2024-03-31 12:50:19 +02:00
George Kiagiadakis
a66aa7ae84 bluez: print a nicer warning when the bluez service is not available 2024-03-31 12:38:39 +02:00
Samuel Thibault
048285af7f spa plugins: Include Linux headers on Linux only 2024-03-31 12:38:27 +02:00
Wim Taymans
cc8b88cb51 alsa: add option to skip the busy check
Makes the card exposed even if some of the pcms are busy.

Fixes #3914
2024-03-30 18:27:06 +01:00
Wim Taymans
30f01b117e v4l2: set latency on port
Use the duration of one frame as the latency.

See #3910
2024-03-30 18:26:24 +01:00
Wim Taymans
cc841a7667 acp: add more properties for the card
Use snd_ctl_card_info to set some more card properties such as the
alsa.id, alsa.mixer_name and alsa.components.

alsa.id is interesting because it is possible to use udev rules to set a
custom id, which is handy when you have two identical cards in the
system and want to assign unique ids to them.

See #3912
2024-03-30 18:24:29 +01:00
Wim Taymans
010c9f1b93 audioconvert: also place resample output in rate_io
We can also place the estimated size that the resampler will produce in
the rate_io for output streams.

See #3750
2024-03-30 18:19:16 +01:00
Wim Taymans
13d4bb4b42 audioconvert: implement resample_out_len() 2024-03-30 18:19:16 +01:00
Arun Raghavan
e3fc41bf41 spa: alsa: Read ctl events instead of doing a global diff
This does a couple of things: first, we implement revents demangling,
which seems to be required (although hw: devices work fine without it).

The second is to actually read the ctl events so we can tell when
elements we care about have changed, instead of reading everything and
trying to do a diff.

The latter is also required from a correctness perspective, as otherwise
the ctl might keep triggering wakeups while the fd is ready to be read.
2024-03-15 12:20:38 -04:00
Wim Taymans
863b3be343 audioconvert: add monitor.passthrough option
Add a monitor.passthrough option. This will pass all latency information
directly between the port and its monitor ports.

This is interesting when the adapter (and audioconvert) is used with a
null-audio-sink that simply forwards the data to a real sink/souce. In
that case, we want the sink/source latency to be passed unmodified.

Set the monitor.passthrough on the pulseaudio null-sink because
a passthrough virtual sink is the most likely use case for this.

Add some monitor.passthrough default config where it makes sense.

Fixes #3888
2024-03-12 17:39:33 +01:00
David Turner
e5c810c0fa Add SOC-style jack names to HDMI audio paths
Currently the HDMI output paths have jack mixers named "HDMI/DP" and
with append-pcm-to-name=true.  However, most of the SOC audio drivers
are just named "HDMI" and don't add the ",pcm=N".  Add these alternate
jack names to the HDMI audio path files so that jack detection will work
on these SOCs.
2024-03-01 13:55:34 +01:00
Wim Taymans
b41e2391bd audioconvert: handle invalid ports better
Keep track of the valid ports and don't emit port info for
invalid ports. When a listener is added while the ports are being
created, it is possible that the ports are still NULL or invalid.
2024-03-01 13:54:29 +01:00
Wim Taymans
8942b74c18 audioconvert: handle port remove
The info is NULL when the port is removed, don't crash on that.
2024-03-01 13:53:56 +01:00
Dimitrios Katsaros
67e0ebc336 alsa: Added handle for controlling htimestamp autodisable
You can now do this to permanently enable htimestamp:

pw-cli s 38 Props '{ params: [ api.alsa.htimestamp.max-errors: 0, api.alsa.htimestamp: true ]}'
2024-03-01 13:51:49 +01:00
Jonas Holmberg
c51ced42b4 pipewire-alsa: Propagate errors from eventfd().
Propagate the error if spa_system_eventfd_create() fails. Also copy
errno before calling spa_log_debug() in spa_system_eventfd_create() to
make sure it is not overwritten.
2024-03-01 13:50:31 +01:00
Ruben Gonzalez
876c3f43ab logger: minor performance improvement to avoid syscall done by isatty 2024-02-19 09:01:34 +01:00
Dimitrios Katsaros
1f578e858c resampler: Only use copy when rate is 1.0
The rate we get from dlls can have a subsample precision. However,
the check for using process_copy is in sample precision. This means
that an adaptive stream will oscillate rather then lock into the
exact rate.
2024-02-19 09:01:30 +01:00
Dimitrios Katsaros
e25f7716b5 resample: use a float phase in update_rate
My making the phase into a float, the resampler can do finer grained
adjustments, which should improve the stability of adaptive
resampling
2024-02-19 09:01:22 +01:00
Wim Taymans
119636cb3f alsa: split irq and timer wakeup functions
Because it's easy to do and avoids some runtime checks.
2024-02-16 10:00:35 +01:00
Dimitrios Katsaros
32f507d687 alsa: Reduce jitter in irq based software timestamping
We would timestamp within an unlikely block, which would introduce
additional jitter to current_time, which would have an impact on
the performance of the timer sensitive code.
2024-02-16 09:59:32 +01:00
Wim Taymans
151a2f0dea spa: use errno values in warnings
Propagate the errno values from syscalls and use them in the warning
messages to give info about what is going on.
2024-02-12 10:55:14 +01:00
Wim Taymans
acf9b67067 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-12 10:49:56 +01:00
Wim Taymans
b147753554 alsa: always reevaluate matching when driver changed
Always reevaluate the rate matching even when we did not change the
follower state.

It is possible that we were a follower from some node with the same
clock and now become a follower of a node with a different clock. The
follower state doesn't change but we need to activate the rate matching
logic in that case.

Fixes rate matching in pro audio (playback) when capture and playback
are moved to another driver.
2024-02-02 14:06:45 +01:00
Arun Raghavan
1f40695b69 node-driver: Log when we resync 2024-01-30 18:43:08 +01:00
Wim Taymans
c690aedc89 v4l2: probe EXPBUF and disable alloc_buffer flag
After we set the format, probe if we can do EXPBUF and enable/disable
the ALLOC_BUFFERS flag on the port.

This should gracefully handle the case where EXPBUF is not available.

Fixes #3821
2024-01-30 18:42:58 +01:00
Wim Taymans
18b112bcfe v4l2: clear support for alloc_buffers on failure
When we try to alloc buffers but EXPBUF is not supported, make sure to
clear the alloc_buffers flag so that the caller can try again with
allocated buffers instead.

See #3821
2024-01-30 18:42:53 +01:00
Dmitry Sharshakov
73cda0c152 node-driver: allow fractional resync-ms 2024-01-25 12:07:11 +01:00
Wim Taymans
c28311fc97 support: add resync.ms option to node.driver
Move some of the tracking code for the DLL to where it is used.

Add resync.ms (default 10) option at which we give up rate adjusting
and instead do a hard resync. This results in a jump in the position
of the graph clock.
2024-01-25 12:06:50 +01:00