@@ -261,6 +261,21 @@ std::optional<int> CameraSensorRaw::init()
if (ret)
return { ret };
+ /* Activate all routes to query pads formats */
+ V4L2Subdevice::Routing routingActive = routing;
+ for (V4L2Subdevice::Route &route : routingActive) {
+ if (route.source.pad != sourcePad) {
+ LOG(CameraSensor, Error) << "Invalid route " << route;
+ return { -EINVAL };
+ }
+ route.flags = V4L2_SUBDEV_ROUTE_FL_ACTIVE;
+ }
+ ret = subdev_->setRouting(&routingActive);
+ if (ret) {
+ LOG(CameraSensor, Error) << "Could not set routes to active";
+ return { -EINVAL };
+ }
+
bool imageStreamFound = false;
for (const V4L2Subdevice::Route &route : routing) {
@@ -348,6 +363,13 @@ std::optional<int> CameraSensorRaw::init()
<< "Found embedded data stream " << streams_.edata->sink
<< " -> " << streams_.edata->source;
+ /* Restore the routes to their initial state */
+ ret = subdev_->setRouting(&routing);
+ if (ret) {
+ LOG(CameraSensor, Error) << "Could not restore routes state";
+ return { -EINVAL };
+ }
+
/*
* 2. Enumerate and cache the media bus codes, sizes and colour filter
* array order for the image stream.
When a V4L2 device supports streams, the route activating a stream needs to be active so that this stream format can be queried. For a raw camera sensor, an internal route may be inactive by default when it is mutable. Implementation of CameraSensorRaw::init() probes at startup time the format of the pads/streams attached to the internal routes of a camera subdevice, in order to identify the streams it exposes and their type. To make sure the format of the streams can be retrieved, activate the internal routes of the subdevice before querying, and restore the initial route states when finished. Signed-off-by: Julien Vuillaumier <julien.vuillaumier@nxp.com> --- src/libcamera/sensor/camera_sensor_raw.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)