From patchwork Wed Jul 1 21:09:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8547 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 27A6ABFFE2 for ; Wed, 1 Jul 2020 21:10:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0166160C53; Wed, 1 Jul 2020 23:10:08 +0200 (CEST) Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8956560C53 for ; Wed, 1 Jul 2020 23:10:04 +0200 (CEST) X-Halon-ID: 3ab62c72-bbdf-11ea-933e-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 3ab62c72-bbdf-11ea-933e-005056917a89; Wed, 01 Jul 2020 23:10:02 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Jul 2020 23:09:48 +0200 Message-Id: <20200701210948.999363-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200701210948.999363-1-niklas.soderlund@ragnatech.se> References: <20200701210948.999363-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] libcamera: ipu3: cio2: Make use of utils::map_keys() helper X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use a helper instead of local code to retrieve all keys from a map. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/ipu3/cio2.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index aa1459fb3599283b..7941c6845cbc9a9a 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -95,11 +95,7 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index) * utils::set_overlap requires the ranges to be sorted, keep the * cio2Codes vector sorted in ascending order. */ - std::vector cio2Codes; - cio2Codes.reserve(mbusCodesToInfo.size()); - std::transform(mbusCodesToInfo.begin(), mbusCodesToInfo.end(), - std::back_inserter(cio2Codes), - [](auto &pair) { return pair.first; }); + std::vector cio2Codes = utils::map_keys(mbusCodesToInfo); const std::vector &sensorCodes = sensor_->mbusCodes(); if (!utils::set_overlap(sensorCodes.begin(), sensorCodes.end(), cio2Codes.begin(), cio2Codes.end())) { @@ -145,12 +141,7 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat) * Apply the selected format to the sensor, the CSI-2 receiver and * the CIO2 output device. */ - std::vector mbusCodes; - mbusCodes.reserve(mbusCodesToInfo.size()); - std::transform(mbusCodesToInfo.begin(), mbusCodesToInfo.end(), - std::back_inserter(mbusCodes), - [](auto &pair) { return pair.first; }); - + std::vector mbusCodes = utils::map_keys(mbusCodesToInfo); sensorFormat = sensor_->getFormat(mbusCodes, size); ret = sensor_->setFormat(&sensorFormat); if (ret) @@ -189,11 +180,7 @@ CIO2Device::generateConfiguration(Size size) const size = sensor_->resolution(); /* Query the sensor static information for closest match. */ - std::vector mbusCodes; - std::transform(mbusCodesToInfo.begin(), mbusCodesToInfo.end(), - std::back_inserter(mbusCodes), - [](auto &pair) { return pair.first; }); - + std::vector mbusCodes = utils::map_keys(mbusCodesToInfo); V4L2SubdeviceFormat sensorFormat = sensor_->getFormat(mbusCodes, size); if (!sensorFormat.mbus_code) { LOG(IPU3, Error) << "Sensor does not support mbus code";