From 846d4c7d3ee7ca059074b2c2d3aeaa941c3f0870 Mon Sep 17 00:00:00 2001 From: Mickael Guene Date: Tue, 11 Jun 2019 13:37:11 +0200 Subject: libcamera: Fix CameraSensor::getFormat() search order According to the documentation, the CameraSensor::getFormat() method should select the first media bus code from the mbusCodes parameter that is supported by the sensor. However, the current implementation wrongly selects the first media bus code from the codes supported by the sensor that is listed in the mbusCodes parameter. This results in the preference order specified by the caller being ignored. Fix it. Signed-off-by: Mickael Guene Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/libcamera/camera_sensor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libcamera/camera_sensor.cpp') diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 2b9d8fa5..cb6649ef 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -191,8 +191,8 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector &mbu { V4L2SubdeviceFormat format{}; - for (unsigned int code : mbusCodes_) { - if (std::any_of(mbusCodes.begin(), mbusCodes.end(), + for (unsigned int code : mbusCodes) { + if (std::any_of(mbusCodes_.begin(), mbusCodes_.end(), [code](unsigned int c) { return c == code; })) { format.mbus_code = code; break; -- cgit v1.2.1