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 <mickael.guene@st.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Mickael Guene 2019-06-11 13:37:11 +02:00 committed by Laurent Pinchart
parent cefe067c5b
commit 846d4c7d3e

View file

@ -191,8 +191,8 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu
{ {
V4L2SubdeviceFormat format{}; V4L2SubdeviceFormat format{};
for (unsigned int code : mbusCodes_) { for (unsigned int code : mbusCodes) {
if (std::any_of(mbusCodes.begin(), mbusCodes.end(), if (std::any_of(mbusCodes_.begin(), mbusCodes_.end(),
[code](unsigned int c) { return c == code; })) { [code](unsigned int c) { return c == code; })) {
format.mbus_code = code; format.mbus_code = code;
break; break;