{"id":749,"url":"https://patchwork.libcamera.org/api/1.1/patches/749/?format=json","web_url":"https://patchwork.libcamera.org/patch/749/","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":"<20190320163055.22056-4-jacopo@jmondi.org>","date":"2019-03-20T16:30:27","name":"[libcamera-devel,v4,03/31] libcamera: ipu3: Make sure sensor provides a compatible format","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ee93cbc244a4c008e4916784488f898c1bb170b4","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/749/mbox/","series":[{"id":214,"url":"https://patchwork.libcamera.org/api/1.1/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/749/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/749/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 00CAA61111\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Mar 2019 17:30:29 +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 933DF20000F;\n\tWed, 20 Mar 2019 16:30:29 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 20 Mar 2019 17:30:27 +0100","Message-Id":"<20190320163055.22056-4-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 03/31] libcamera: ipu3: Make sure\n\tsensor provides a compatible format","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":"When creating a camera, make sure a the image sensor provides images in\na format compatible with IPU3 CIO2 unit requirements.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 43 ++++++++++++++++++++++++++--\n 1 file changed, 41 insertions(+), 2 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 55489c31df2d..2602f89617a3 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -8,6 +8,8 @@\n #include <memory>\n #include <vector>\n \n+#include <linux/media-bus-format.h>\n+\n #include <libcamera/camera.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n@@ -78,6 +80,8 @@ private:\n \t\t\tPipelineHandler::cameraData(camera));\n \t}\n \n+\tint mediaBusToCIO2Format(unsigned int code);\n+\n \tvoid registerCameras();\n \n \tstd::shared_ptr<MediaDevice> cio2_;\n@@ -327,6 +331,22 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n \treturn true;\n }\n \n+int PipelineHandlerIPU3::mediaBusToCIO2Format(unsigned int code)\n+{\n+\tswitch (code) {\n+\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n+\t\treturn V4L2_PIX_FMT_IPU3_SBGGR10;\n+\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n+\t\treturn V4L2_PIX_FMT_IPU3_SGBRG10;\n+\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n+\t\treturn V4L2_PIX_FMT_IPU3_SGRBG10;\n+\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n+\t\treturn V4L2_PIX_FMT_IPU3_SRGGB10;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+}\n+\n /*\n  * Cameras are created associating an image sensor (represented by a\n  * media entity with function MEDIA_ENT_F_CAM_SENSOR) to one of the four\n@@ -404,18 +424,37 @@ void PipelineHandlerIPU3::registerCameras()\n \t\tif (ret)\n \t\t\tcontinue;\n \n-\t\tdata->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n-\n+\t\t/*\n+\t\t * Make sure the sensor produces at least one image format\n+\t\t * compatible with IPU3 CIO2 requirements.\n+\t\t */\n \t\tdata->sensor_ = new V4L2Subdevice(sensor);\n \t\tret = data->sensor_->open();\n \t\tif (ret)\n \t\t\tcontinue;\n \n+\t\tconst FormatEnum formats = data->sensor_->formats(0);\n+\t\tauto it = formats.begin();\n+\t\tfor (; it != formats.end(); ++it) {\n+\t\t\tif (mediaBusToCIO2Format(it->first) != -EINVAL)\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tif (it == formats.end()) {\n+\t\t\tLOG(IPU3, Info)\n+\t\t\t\t<< \"Sensor '\" << data->sensor_->deviceName()\n+\t\t\t\t<< \"' detected, but no supported image format \"\n+\t\t\t\t<< \" found: skip camera creation\";\n+\t\t\tcontinue;\n+\t\t}\n+\n \t\tdata->csi2_ = new V4L2Subdevice(csi2);\n \t\tret = data->csi2_->open();\n \t\tif (ret)\n \t\t\tcontinue;\n \n+\t\tdata->cio2_->bufferReady.connect(data.get(),\n+\t\t\t\t\t\t &IPU3CameraData::bufferReady);\n+\n \t\tregisterCamera(std::move(camera), std::move(data));\n \n \t\tLOG(IPU3, Info)\n","prefixes":["libcamera-devel","v4","03/31"]}