Patch Detail
Show a patch.
GET /api/1.1/patches/1456/?format=api
{ "id": 1456, "url": "https://patchwork.libcamera.org/api/1.1/patches/1456/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1456/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20190619025129.21164-7-niklas.soderlund@ragnatech.se>", "date": "2019-06-19T02:51:19", "name": "[libcamera-devel,v4,06/16] libcamera: v4l2_subdevice: Breakout mbus code enumeration", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "bcae38547db8593a21beb046c409a6d02f7f8be0", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1456/mbox/", "series": [ { "id": 361, "url": "https://patchwork.libcamera.org/api/1.1/series/361/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=361", "date": "2019-06-19T02:51:13", "name": "libcamera: Add support for format information and validation", "version": 4, "mbox": "https://patchwork.libcamera.org/series/361/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1456/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1456/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A2E0361A54\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Jun 2019 04:52:26 +0200 (CEST)", "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 3cfa4602-923d-11e9-8ab4-005056917a89;\n\tWed, 19 Jun 2019 04:52:12 +0200 (CEST)" ], "X-Halon-ID": "3cfa4602-923d-11e9-8ab4-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": "Wed, 19 Jun 2019 04:51:19 +0200", "Message-Id": "<20190619025129.21164-7-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190619025129.21164-1-niklas.soderlund@ragnatech.se>", "References": "<20190619025129.21164-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 06/16] libcamera: v4l2_subdevice:\n\tBreakout mbus code enumeration", "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, 19 Jun 2019 02:52:27 -0000" }, "content": "Simplify frame size enumeration by breaking out mbus code enumeration in\na helper, making the code easier to read while also preparing for\nenhancing the frame size enumeration. There is no functional change.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/v4l2_subdevice.h | 1 +\n src/libcamera/v4l2_subdevice.cpp | 59 ++++++++++++++------------\n 2 files changed, 34 insertions(+), 26 deletions(-)", "diff": "diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex 3e4e5107aebeee06..e714e2575022c04d 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -57,6 +57,7 @@ protected:\n \tstd::string logPrefix() const;\n \n private:\n+\tstd::vector<unsigned int> enumPadCodes(unsigned int pad);\n \tint enumPadSizes(unsigned int pad, unsigned int code,\n \t\t\t std::vector<SizeRange> *size);\n \ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex fceee33156e94212..99e202fa264af5a6 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -203,37 +203,15 @@ int V4L2Subdevice::setCompose(unsigned int pad, Rectangle *rect)\n FormatEnum V4L2Subdevice::formats(unsigned int pad)\n {\n \tFormatEnum formatMap = {};\n-\tstruct v4l2_subdev_mbus_code_enum mbusEnum = {};\n-\tint ret;\n \n \tif (pad >= entity_->pads().size()) {\n \t\tLOG(V4L2Subdev, Error) << \"Invalid pad: \" << pad;\n-\t\treturn formatMap;\n+\t\treturn {};\n \t}\n \n-\tmbusEnum.pad = pad;\n-\tmbusEnum.index = 0;\n-\tmbusEnum.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n-\twhile (true) {\n-\t\tret = ioctl(fd_, VIDIOC_SUBDEV_ENUM_MBUS_CODE, &mbusEnum);\n-\t\tif (ret)\n-\t\t\tbreak;\n-\n-\t\tret = enumPadSizes(pad, mbusEnum.code,\n-\t\t\t\t &formatMap[mbusEnum.code]);\n-\t\tif (ret)\n-\t\t\tbreak;\n-\n-\t\tmbusEnum.index++;\n-\t}\n-\n-\tif (ret && (errno != EINVAL && errno != ENOTTY)) {\n-\t\tret = -errno;\n-\t\tLOG(V4L2Subdev, Error)\n-\t\t\t<< \"Unable to enumerate formats on pad \" << pad\n-\t\t\t<< \": \" << strerror(-ret);\n-\t\tformatMap.clear();\n-\t}\n+\tfor (unsigned int code : enumPadCodes(pad))\n+\t\tif (enumPadSizes(pad, code, &formatMap[code]))\n+\t\t\treturn {};\n \n \treturn formatMap;\n }\n@@ -328,6 +306,35 @@ std::string V4L2Subdevice::logPrefix() const\n \treturn \"'\" + entity_->name() + \"'\";\n }\n \n+std::vector<unsigned int> V4L2Subdevice::enumPadCodes(unsigned int pad)\n+{\n+\tstd::vector<unsigned int> codes;\n+\tint ret;\n+\n+\tfor (unsigned int index = 0; ; index++) {\n+\t\tstruct v4l2_subdev_mbus_code_enum mbusEnum = {};\n+\t\tmbusEnum.pad = pad;\n+\t\tmbusEnum.index = index;\n+\t\tmbusEnum.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n+\n+\t\tret = ioctl(fd_, VIDIOC_SUBDEV_ENUM_MBUS_CODE, &mbusEnum);\n+\t\tif (ret)\n+\t\t\tbreak;\n+\n+\t\tcodes.push_back(mbusEnum.code);\n+\t}\n+\n+\tif (ret && errno != EINVAL) {\n+\t\tret = errno;\n+\t\tLOG(V4L2Subdev, Error)\n+\t\t\t<< \"Unable to enumerate formats on pad \" << pad\n+\t\t\t<< \": \" << strerror(ret);\n+\t\treturn {};\n+\t}\n+\n+\treturn codes;\n+}\n+\n int V4L2Subdevice::enumPadSizes(unsigned int pad,unsigned int code,\n \t\t\t\tstd::vector<SizeRange> *sizes)\n {\n", "prefixes": [ "libcamera-devel", "v4", "06/16" ] }