[0/3] libcamera: Finer grained MediaDevice locking
mbox series

Message ID 20260408115630.12456-1-johannes.goede@oss.qualcomm.com
Headers show
Series
  • libcamera: Finer grained MediaDevice locking
Related show

Message

Hans de Goede April 8, 2026, 11:56 a.m. UTC
Hi All,

On Qualcomm chips any CSI-phy can be connected to any CSI-decoder and
any CSI-decoder can be connected to any Video-Front-End (VFE, DMA write
engine and co). Basically there are 2 big cross-switches between PHYs
and decoders and between decoders and VFEs which can be controlled through
media-controller links.

As such the entite CAMSS block with CSI-phys, decoders and VFEs is
represented to userspace as a single /dev/media# node.

As long as active links from unrelated cameras are not touched when setting
up a new camera 2 independent raw data-streams can be run and managed by 2
different libcamera instances.

But the standard locking of the /dev/media# node by the first libcamera
instance to start streaming from one of the cameras blocks this.

This patch series allows pipeline-handlers to opt-out of the base
PipelineHandler MediaDevice locking and adds 2 helpers for pipeline
handlers to implement finer grained locking.

This is the second of 3 series which together introduce the camss pipeline
handler. Here is a branch with all 3 series:
https://github.com/jwrdegoede/libcamera/commits/camss_pipeline_v1/

I hope to get this prep series merged while work continues on the camss
pipeline handler itself.

For an example of how to use this, see this commmit implementing finer
grained locking for the camss pipeline handler:

https://github.com/jwrdegoede/libcamera/commit/4ffd7b47119978940b543ad0914bf46c767573ad

For the first patch an alternative approach would be add a lockingRequired
flag to the MediaDevice class, allowing opting out of the locking on a per
media device base.

Regards,

Hans


Hans de Goede (3):
  libcamera: pipeline: Allow pipeline-handlers to opt out of locking the
    media devices
  libcamera: media_object: Add MediaEntity::disableLinks()
  libcamera: v4l2_device: add lock() and unlock() methods

 include/libcamera/internal/media_object.h     |  1 +
 include/libcamera/internal/pipeline_handler.h |  2 +
 include/libcamera/internal/v4l2_device.h      |  3 ++
 src/libcamera/media_device.cpp                | 16 ++------
 src/libcamera/media_object.cpp                | 27 ++++++++++++++
 src/libcamera/pipeline_handler.cpp            |  8 ++--
 src/libcamera/v4l2_device.cpp                 | 37 +++++++++++++++++++
 7 files changed, 77 insertions(+), 17 deletions(-)