Patch Detail
Show a patch.
GET /api/patches/1059/?format=api
{ "id": 1059, "url": "https://patchwork.libcamera.org/api/patches/1059/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1059/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190418141437.14014-13-laurent.pinchart@ideasonboard.com>", "date": "2019-04-18T14:14:36", "name": "[libcamera-devel,v3,12/13] libcamera: pipeline: ipu3: Use the new CameraSensor class", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "657986dfd8596d23b823a1dc95bd335dc270ab60", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1059/mbox/", "series": [ { "id": 256, "url": "https://patchwork.libcamera.org/api/series/256/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=256", "date": "2019-04-18T14:14:24", "name": "Rockchip ISP pipeline handler", "version": 3, "mbox": "https://patchwork.libcamera.org/series/256/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1059/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1059/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5340660DC7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Apr 2019 16:14:59 +0200 (CEST)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E5C35B85\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Apr 2019 16:14:58 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1555596899;\n\tbh=2T13HuQWuqQbpNPNwWxSXU2xV147Zj4zVVhqREiXTQg=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=pZb/oRZdkryrYecU09r7l40evC2jGRxZycG3Fhn4JMgjxrXWsE6dQrEQXnMeihe/K\n\tiMQx0qgbDv4m+xHGzgssqiLsrhZrsakaeuJo1pK9kHdQX6c+ccaJc2XFqW0G1jH8AI\n\tRoSXIEHLeBdno/U/SOVjYm7fxA4Wn+JBNF0+7IjA=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 18 Apr 2019 17:14:36 +0300", "Message-Id": "<20190418141437.14014-13-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190418141437.14014-1-laurent.pinchart@ideasonboard.com>", "References": "<20190418141437.14014-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 12/13] libcamera: pipeline: ipu3: Use\n\tthe new CameraSensor class", "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": "Thu, 18 Apr 2019 14:15:00 -0000" }, "content": "Replace the manual handling of sensor formats with usage of the new\nCameraSensor class.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\nChanges since v2:\n\n- Properly sort the CIO2 supported media bus codes numerically\n\nChanges since v1:\n\n- Move sensor entity function check to CameraSensor class\n- Verify sensor media bus codes at init time\n---\n src/libcamera/pipeline/ipu3/ipu3.cpp | 107 +++++++++------------------\n 1 file changed, 36 insertions(+), 71 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex f43969099b48..c677ee9b51da 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 <algorithm>\n #include <iomanip>\n #include <memory>\n #include <vector>\n@@ -15,6 +16,7 @@\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n+#include \"camera_sensor.h\"\n #include \"device_enumerator.h\"\n #include \"log.h\"\n #include \"media_device.h\"\n@@ -124,11 +126,7 @@ public:\n \n \tV4L2Device *output_;\n \tV4L2Subdevice *csi2_;\n-\tV4L2Subdevice *sensor_;\n-\n-\t/* Maximum sizes and the mbus code used to produce them. */\n-\tunsigned int mbusCode_;\n-\tSize maxSize_;\n+\tCameraSensor *sensor_;\n \n \tBufferPool pool_;\n };\n@@ -257,8 +255,9 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n \t\treturn -EINVAL;\n \t}\n \n-\tif (cfg.width > cio2->maxSize_.width ||\n-\t cfg.height > cio2->maxSize_.height) {\n+\tconst Size &resolution = cio2->sensor_->resolution();\n+\tif (cfg.width > resolution.width ||\n+\t cfg.height > resolution.height) {\n \t\tLOG(IPU3, Error)\n \t\t\t<< \"Invalid stream size: larger than sensor resolution\";\n \t\treturn -EINVAL;\n@@ -1032,45 +1031,39 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n \n \tMediaLink *link = links[0];\n \tMediaEntity *sensorEntity = link->source()->entity();\n-\tif (sensorEntity->function() != MEDIA_ENT_F_CAM_SENSOR)\n-\t\treturn -ENODEV;\n+\tsensor_ = new CameraSensor(sensorEntity);\n+\tret = sensor_->init();\n+\tif (ret)\n+\t\treturn ret;\n \n \tret = link->setEnabled(true);\n \tif (ret)\n \t\treturn ret;\n \n \t/*\n-\t * Now that we're sure a sensor subdevice is connected, make sure it\n-\t * produces at least one image format compatible with CIO2 requirements\n-\t * and cache the camera maximum size.\n+\t * Make sure the sensor produces at least one format compatible with\n+\t * the CIO2 requirements.\n \t *\n+\t * utils::set_overlap requires the ranges to be sorted, keep the\n+\t * cio2Codes vector sorted in ascending order.\n+\t */\n+\tconst std::vector<unsigned int> cio2Codes{ MEDIA_BUS_FMT_SBGGR10_1X10,\n+\t\t\t\t\t\t MEDIA_BUS_FMT_SGRBG10_1X10,\n+\t\t\t\t\t\t MEDIA_BUS_FMT_SGBRG10_1X10,\n+\t\t\t\t\t\t MEDIA_BUS_FMT_SRGGB10_1X10 };\n+\tconst std::vector<unsigned int> &sensorCodes = sensor_->mbusCodes();\n+\tif (!utils::set_overlap(sensorCodes.begin(), sensorCodes.end(),\n+\t\t\t\tcio2Codes.begin(), cio2Codes.end())) {\n+\t\tLOG(IPU3, Error)\n+\t\t\t<< \"Sensor \" << sensor_->entity()->name()\n+\t\t\t<< \" has not format compatible with the IPU3\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/*\n \t * \\todo Define when to open and close video device nodes, as they\n \t * might impact on power consumption.\n \t */\n-\tsensor_ = new V4L2Subdevice(sensorEntity);\n-\tret = sensor_->open();\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tfor (auto it : sensor_->formats(0)) {\n-\t\tint mbusCode = mediaBusToFormat(it.first);\n-\t\tif (mbusCode < 0)\n-\t\t\tcontinue;\n-\n-\t\tfor (const SizeRange &size : it.second) {\n-\t\t\tif (maxSize_.width < size.max.width &&\n-\t\t\t maxSize_.height < size.max.height) {\n-\t\t\t\tmaxSize_ = size.max;\n-\t\t\t\tmbusCode_ = mbusCode;\n-\t\t\t}\n-\t\t}\n-\t}\n-\tif (maxSize_.width == 0) {\n-\t\tLOG(IPU3, Info) << \"Sensor '\" << sensor_->entity()->name()\n-\t\t\t\t<< \"' detected, but no supported image format \"\n-\t\t\t\t<< \" found: skip camera creation\";\n-\t\treturn -ENODEV;\n-\t}\n \n \tcsi2_ = new V4L2Subdevice(csi2Entity);\n \tret = csi2_->open();\n@@ -1096,47 +1089,19 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n int CIO2Device::configure(const StreamConfiguration &config,\n \t\t\t V4L2DeviceFormat *outputFormat)\n {\n-\tunsigned int imageSize = config.width * config.height;\n-\tV4L2SubdeviceFormat sensorFormat = {};\n-\tunsigned int best = ~0;\n+\tV4L2SubdeviceFormat sensorFormat;\n \tint ret;\n \n-\tfor (auto it : sensor_->formats(0)) {\n-\t\t/* Only consider formats consumable by the CIO2 unit. */\n-\t\tif (mediaBusToFormat(it.first) < 0)\n-\t\t\tcontinue;\n-\n-\t\tfor (const SizeRange &size : it.second) {\n-\t\t\t/*\n-\t\t\t * Only select formats bigger than the requested sizes\n-\t\t\t * as the IPU3 cannot up-scale.\n-\t\t\t *\n-\t\t\t * \\todo: Unconditionally scale on the sensor as much\n-\t\t\t * as possible. This will need to be revisited when\n-\t\t\t * implementing the scaling policy.\n-\t\t\t */\n-\t\t\tif (size.max.width < config.width ||\n-\t\t\t size.max.height < config.height)\n-\t\t\t\tcontinue;\n-\n-\t\t\tunsigned int diff = size.max.width * size.max.height\n-\t\t\t\t\t - imageSize;\n-\t\t\tif (diff >= best)\n-\t\t\t\tcontinue;\n-\n-\t\t\tbest = diff;\n-\n-\t\t\tsensorFormat.width = size.max.width;\n-\t\t\tsensorFormat.height = size.max.height;\n-\t\t\tsensorFormat.mbus_code = it.first;\n-\t\t}\n-\t}\n-\n \t/*\n \t * Apply the selected format to the sensor, the CSI-2 receiver and\n \t * the CIO2 output device.\n \t */\n-\tret = sensor_->setFormat(0, &sensorFormat);\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(config.width, config.height));\n+\tret = sensor_->setFormat(&sensorFormat);\n \tif (ret)\n \t\treturn ret;\n \n", "prefixes": [ "libcamera-devel", "v3", "12/13" ] }