[0/4] Add generic V4L2 Events support
mbox series

Message ID 20260925-v4l2-events-v1-0-b2ec212eb5d0@ideasonboard.com
Headers show
Series
  • Add generic V4L2 Events support
Related show

Message

Daniel Scally Sept. 25, 2026, 3:16 p.m. UTC
At present class V4L2Device allows subscriptions to V4L2 Events of
type V4L2_EVENT_FRAME_SYNC through a very specific API; support is
verified with "supportsFrameSyncEvents()" and subscription enabled
with "setFrameStartEnabled()". The arrival of an event is signalled
with a Signal<uint32_t> which passes the frame sequence number to
the slot.

This is adequate, but limited, and expansion to support other event
types in a similar manner would be quite clunky. This series adapts
the event support to be more generic with the aim of facilitating
easy use of other event types.

My plan was originally to just rename the functions and parametise
them such that support for a given event type could be checked and
enabled, however the fact that the existing frameStart Signal takes
only a uint32_t as parameter means it cannot be renamed to apply to
other events too, as the details of the other event types could not
be conveyed through a single uint32_t. Having separate Signals for
each event type seems ugly, and so I settled on the idea of having a
Signal<std::shared_ptr<V4L2Event>> and letting the Slot deal with
figuring out what the type of event is and which of V4L2Event's
derived classes it actually represents.

We don't have any upstream users of anything but the FrameSync event
yet, but not including the others seemed incomplete, so I did.

Thanks
Dan

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
Daniel Scally (4):
      libcamera: v4l2_event: Add V4L2Event class and functionality
      libcamera: v4l2_device: Make supportsFrameStartEvent() generic
      libcamera: v4l2_device: Emit signals for V4L2Events generically
      libcamera: v4l2_device: Make setFrameStartEnabled() generic

 include/libcamera/internal/v4l2_device.h           |  10 +-
 include/libcamera/internal/v4l2_event.h            | 158 +++++++++++
 src/libcamera/meson.build                          |   1 +
 src/libcamera/pipeline/ipu3/cio2.cpp               |   6 +-
 src/libcamera/pipeline/ipu3/cio2.h                 |   3 +-
 src/libcamera/pipeline/ipu3/ipu3.cpp               |  17 +-
 src/libcamera/pipeline/mali-c55/mali-c55.cpp       |  24 +-
 src/libcamera/pipeline/rkisp1/rkisp1.cpp           |  23 +-
 .../pipeline/rpi/common/pipeline_base.cpp          |  20 +-
 src/libcamera/pipeline/rpi/common/pipeline_base.h  |   3 +-
 src/libcamera/pipeline/simple/simple.cpp           |  29 ++-
 src/libcamera/v4l2_device.cpp                      |  65 +++--
 src/libcamera/v4l2_event.cpp                       | 288 +++++++++++++++++++++
 13 files changed, 587 insertions(+), 60 deletions(-)
---
base-commit: 279d355ef8f7a4f98bb0a3004c0f788387814506
change-id: 20260918-v4l2-events-3e74a7ae6862

Best regards,