{"id":4133,"url":"https://patchwork.libcamera.org/api/1.1/patches/4133/?format=json","web_url":"https://patchwork.libcamera.org/patch/4133/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200623020930.1781469-7-niklas.soderlund@ragnatech.se>","date":"2020-06-23T02:09:26","name":"[libcamera-devel,v3,06/10] libcamera: ipu3: cio2: Consolidate information about formats","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"3f1974b2011ca8a8fa50bfb5edb98c4281a84c86","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/4133/mbox/","series":[{"id":1027,"url":"https://patchwork.libcamera.org/api/1.1/series/1027/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1027","date":"2020-06-23T02:09:20","name":"libcamera: ipu3: Allow zero-copy RAW stream","version":3,"mbox":"https://patchwork.libcamera.org/series/1027/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/4133/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/4133/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C8D3609A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 04:09:47 +0200 (CEST)","from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de\n\t[79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 9c2e33f2-b4f6-11ea-933e-005056917a89;\n\tTue, 23 Jun 2020 04:09:46 +0200 (CEST)"],"X-Halon-ID":"9c2e33f2-b4f6-11ea-933e-005056917a89","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 23 Jun 2020 04:09:26 +0200","Message-Id":"<20200623020930.1781469-7-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200623020930.1781469-1-niklas.soderlund@ragnatech.se>","References":"<20200623020930.1781469-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 06/10] libcamera: ipu3: cio2:\n\tConsolidate information about formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 23 Jun 2020 02:09:47 -0000"},"content":"Instead of spreading the mapping between media bus codes and V4L2 FourCC\nall over the CIO2 code collect it in a single map and extract the data\nfrom it. This is done in preparation of adding PixelFormat information\nto the mix.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/libcamera/pipeline/ipu3/cio2.cpp | 50 +++++++++++++---------------\n 1 file changed, 24 insertions(+), 26 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\nindex dbbcf79c7b2ed5c1..f23128d412e6b1a5 100644\n--- a/src/libcamera/pipeline/ipu3/cio2.cpp\n+++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n@@ -18,6 +18,17 @@ namespace libcamera {\n \n LOG_DECLARE_CATEGORY(IPU3)\n \n+namespace {\n+\n+static const std::map<uint32_t, V4L2PixelFormat> mbusCodesToInfo = {\n+\t{ MEDIA_BUS_FMT_SBGGR10_1X10, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10) },\n+\t{ MEDIA_BUS_FMT_SGBRG10_1X10, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10) },\n+\t{ MEDIA_BUS_FMT_SGRBG10_1X10, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10) },\n+\t{ MEDIA_BUS_FMT_SRGGB10_1X10, V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10) },\n+};\n+\n+} /* namespace */\n+\n CIO2Device::CIO2Device()\n \t: output_(nullptr), csi2_(nullptr), sensor_(nullptr)\n {\n@@ -78,10 +89,10 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n \t * Make sure the sensor produces at least one format compatible with\n \t * the CIO2 requirements.\n \t */\n-\tconst std::set<unsigned int> cio2Codes{ MEDIA_BUS_FMT_SBGGR10_1X10,\n-\t\t\t\t\t\tMEDIA_BUS_FMT_SGRBG10_1X10,\n-\t\t\t\t\t\tMEDIA_BUS_FMT_SGBRG10_1X10,\n-\t\t\t\t\t\tMEDIA_BUS_FMT_SRGGB10_1X10 };\n+\tstd::set<unsigned int> cio2Codes;\n+\tstd::transform(mbusCodesToInfo.begin(), mbusCodesToInfo.end(),\n+\t\tstd::inserter(cio2Codes, cio2Codes.begin()),\n+\t\t[](const std::map<uint32_t, V4L2PixelFormat>::value_type &pair){ return pair.first; });\n \tconst std::set<unsigned int> &sensorCodes = sensor_->mbusCodes();\n \tif (!utils::set_overlap(sensorCodes.begin(), sensorCodes.end(),\n \t\t\t\tcio2Codes.begin(), cio2Codes.end())) {\n@@ -125,11 +136,12 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat)\n \t * Apply the selected format to the sensor, the CSI-2 receiver and\n \t * the CIO2 output device.\n \t */\n-\tsensorFormat = sensor_->getFormat({ MEDIA_BUS_FMT_SBGGR10_1X10,\n-\t\t\t\t\t    MEDIA_BUS_FMT_SGBRG10_1X10,\n-\t\t\t\t\t    MEDIA_BUS_FMT_SGRBG10_1X10,\n-\t\t\t\t\t    MEDIA_BUS_FMT_SRGGB10_1X10 },\n-\t\t\t\t\t  size);\n+\tstd::vector<unsigned int> mbusCodes;\n+\tstd::transform(mbusCodesToInfo.begin(), mbusCodesToInfo.end(),\n+\t\tstd::back_inserter(mbusCodes),\n+\t\t[](const std::map<uint32_t, V4L2PixelFormat>::value_type &pair){ return pair.first; });\n+\n+\tsensorFormat = sensor_->getFormat(mbusCodes, size);\n \tret = sensor_->setFormat(&sensorFormat);\n \tif (ret)\n \t\treturn ret;\n@@ -138,25 +150,11 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat)\n \tif (ret)\n \t\treturn ret;\n \n-\tV4L2PixelFormat v4l2Format;\n-\tswitch (sensorFormat.mbus_code) {\n-\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n-\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10);\n-\t\tbreak;\n-\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n-\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10);\n-\t\tbreak;\n-\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n-\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10);\n-\t\tbreak;\n-\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n-\t\tv4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10);\n-\t\tbreak;\n-\tdefault:\n+\tconst auto &itInfo = mbusCodesToInfo.find(sensorFormat.mbus_code);\n+\tif (itInfo == mbusCodesToInfo.end())\n \t\treturn -EINVAL;\n-\t}\n \n-\toutputFormat->fourcc = v4l2Format;\n+\toutputFormat->fourcc = itInfo->second;\n \toutputFormat->size = sensorFormat.size;\n \toutputFormat->planesCount = 1;\n \n","prefixes":["libcamera-devel","v3","06/10"]}