From patchwork Tue Jun 11 11:37:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mickael GUENE X-Patchwork-Id: 1392 Return-Path: Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [62.209.51.94]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 201AE62FAD for ; Tue, 11 Jun 2019 13:37:16 +0200 (CEST) Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5BBabjY024367 for ; Tue, 11 Jun 2019 13:37:16 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=STMicroelectronics; bh=9+jUD6EL6zJ3U5QhBg5iXN6r0769tnzIG848GPscfUM=; b=yJmxJY/5V3dWrEQf8gYHPgtZW6mN+SwhWNF/4CBI2u6l73ZNxnfxc9lbwki3ZSzdLvun 3EIBJhGsx5j7bNxICCCFcKTsCjGngyoT8WOfKOkuDUWeUiVeqN8SlsURN4yKDXiemVmL BN4YHWvKRg00glFnXlQEjk1b65cm0yN2si1oUxWuVr3PHLCEhfxCXyFOmhdHZL0JYS1Q bkrOxBHNvFuHTMyf6om2nt+7kaVa5ME0/b6zz0D4Ny2AD6EyzwlWzB4+tv4r70s4rBmL R7bjNqv6Q1Idh7h9786d8Ls1Vl6qpfH8lK6RyUUBfxktxFiEdRiYJXNOBrSpFze5KANF Pw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2t26rm9nd2-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 11 Jun 2019 13:37:16 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C348F34 for ; Tue, 11 Jun 2019 11:37:15 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas24.st.com [10.75.90.94]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 735E82920 for ; Tue, 11 Jun 2019 11:37:15 +0000 (GMT) Received: from SAFEX1HUBCAS21.st.com (10.75.90.45) by Safex1hubcas24.st.com (10.75.90.94) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 11 Jun 2019 13:37:15 +0200 Received: from localhost (10.129.172.100) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 11 Jun 2019 13:37:14 +0200 From: Mickael Guene To: CC: Mickael Guene Date: Tue, 11 Jun 2019 13:37:11 +0200 Message-ID: <1560253031-98823-1-git-send-email-mickael.guene@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.129.172.100] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-11_05:, , signatures=0 X-Mailman-Approved-At: Tue, 11 Jun 2019 13:43:07 +0200 Subject: [libcamera-devel] [PATCH] libcamera: Fix CameraSensor::getFormat() search order X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Jun 2019 11:37:17 -0000 According to the documentation, CameraSensor::getFormat() should select Media bus code from mbusCodes parameter list. It should select the first code from the list that is supported by the sensor. Current implementation will wrongly select Media bus code from mbusCodes_ order instead. This patch aims to fix this wrong behavior. Signed-off-by: Mickael Guene Reviewed-by: Jacopo Mondi --- src/libcamera/camera_sensor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 2b9d8fa..cb6649e 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;