{"id":750,"url":"https://patchwork.libcamera.org/api/patches/750/?format=json","web_url":"https://patchwork.libcamera.org/patch/750/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20190320163055.22056-5-jacopo@jmondi.org>","date":"2019-03-20T16:30:28","name":"[libcamera-devel,v4,04/31] libcamera: ipu3: Set stream configuration from sensor","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"64da687fcf28550fc755914c70a16baaacc3444f","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/750/mbox/","series":[{"id":214,"url":"https://patchwork.libcamera.org/api/series/214/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=214","date":"2019-03-20T16:30:24","name":"libcamera: ipu3: Add ImgU support + multiple streams","version":4,"mbox":"https://patchwork.libcamera.org/series/214/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/750/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/750/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 935746110E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Mar 2019 17:30:30 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 2F0EB200009;\n\tWed, 20 Mar 2019 16:30:30 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 20 Mar 2019 17:30:28 +0100","Message-Id":"<20190320163055.22056-5-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190320163055.22056-1-jacopo@jmondi.org>","References":"<20190320163055.22056-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 04/31] libcamera: ipu3: Set stream\n\tconfiguration from sensor","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Wed, 20 Mar 2019 16:30:30 -0000"},"content":"Inspect all image sizes provided by the sensor and select the\nbiggest of them, associated with an image format code supported by the\nCIO2 unit.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 47 +++++++++++++++++++---------\n 1 file changed, 32 insertions(+), 15 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 2602f89617a3..1df074553fd1 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -5,6 +5,7 @@\n  * ipu3.cpp - Pipeline handler for Intel IPU3\n  */\n \n+#include <iomanip>\n #include <memory>\n #include <vector>\n \n@@ -74,6 +75,8 @@ private:\n \t\tStream stream_;\n \t};\n \n+\tstatic constexpr unsigned int IPU3_BUFFER_COUNT = 4;\n+\n \tIPU3CameraData *cameraData(const Camera *camera)\n \t{\n \t\treturn static_cast<IPU3CameraData *>(\n@@ -106,26 +109,40 @@ std::map<Stream *, StreamConfiguration>\n PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n \t\t\t\t\t std::set<Stream *> &streams)\n {\n-\tIPU3CameraData *data = cameraData(camera);\n \tstd::map<Stream *, StreamConfiguration> configs;\n-\tV4L2SubdeviceFormat format = {};\n+\tIPU3CameraData *data = cameraData(camera);\n+\tV4L2Subdevice *sensor = data->sensor_;\n+\tStreamConfiguration *config = &configs[&data->stream_];\n+\tunsigned int bestSize = 0;\n \n-\t/*\n-\t * FIXME: As of now, return the image format reported by the sensor.\n-\t * In future good defaults should be provided for each stream.\n-\t */\n-\tif (data->sensor_->getFormat(0, &format)) {\n-\t\tLOG(IPU3, Error) << \"Failed to create stream configurations\";\n-\t\treturn configs;\n+\tconst FormatEnum formats = sensor->formats(0);\n+\tfor (auto it = formats.begin(); it != formats.end(); ++it) {\n+\t\tint cio2Code = mediaBusToCIO2Format(it->first);\n+\t\tif (cio2Code == -EINVAL)\n+\t\t\tcontinue;\n+\n+\t\tfor (const SizeRange &range : it->second) {\n+\t\t\tunsigned int frameSize = range.maxWidth\n+\t\t\t\t\t       * range.maxHeight;\n+\n+\t\t\t/*  Use the largest image size the sensor provides. */\n+\t\t\tif (frameSize < bestSize)\n+\t\t\t\tcontinue;\n+\n+\t\t\tbestSize = frameSize;\n+\n+\t\t\tconfig->width = range.maxWidth;\n+\t\t\tconfig->height = range.maxHeight;\n+\t\t\tconfig->pixelFormat = cio2Code;\n+\t\t}\n \t}\n \n-\tStreamConfiguration config = {};\n-\tconfig.width = format.width;\n-\tconfig.height = format.height;\n-\tconfig.pixelFormat = V4L2_PIX_FMT_IPU3_SGRBG10;\n-\tconfig.bufferCount = 4;\n+\tconfig->bufferCount = IPU3_BUFFER_COUNT;\n \n-\tconfigs[&data->stream_] = config;\n+\tLOG(IPU3, Debug)\n+\t\t<< \"Stream format set to: \" << config->width << \"x\"\n+\t\t<< config->height << \"- 0x\" << std::hex << std::setfill('0')\n+\t\t<< std::setw(4) << config->pixelFormat;\n \n \treturn configs;\n }\n","prefixes":["libcamera-devel","v4","04/31"]}