Patch Detail
Show a patch.
GET /api/patches/17689/?format=api
{ "id": 17689, "url": "https://patchwork.libcamera.org/api/patches/17689/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17689/", "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": "<20221025012131.12943-1-laurent.pinchart@ideasonboard.com>", "date": "2022-10-25T01:21:31", "name": "[libcamera-devel,RFC] libcamera: v4l2_device: Always set all four V4L2 colorspace fields", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "ab0fdeef0736128be58e7efc68a01af053e1954a", "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/17689/mbox/", "series": [ { "id": 3577, "url": "https://patchwork.libcamera.org/api/series/3577/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3577", "date": "2022-10-25T01:21:31", "name": "[libcamera-devel,RFC] libcamera: v4l2_device: Always set all four V4L2 colorspace fields", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3577/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17689/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17689/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 66FF0BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Oct 2022 01:22:00 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CFE3A62F2C;\n\tTue, 25 Oct 2022 03:21:59 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B8DC262EAE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Oct 2022 03:21:57 +0200 (CEST)", "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1EEBCD3C;\n\tTue, 25 Oct 2022 03:21:57 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666660919;\n\tbh=GuyCrJs8jIgN4JZOHr421WT3T/c3MnSoVFNfD2uLprk=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=Hy00GaGKoFKWPrNJFSFb0SohfQMr0DuA8/Od0rnYJhlV2o0hgu14Jlqg6rtBrKUx9\n\tZoPcs8+ceGMOR3FtWRJjuCzmsxYLtGTUxGshHUZ83fTzqulsjmvJW6kX4kgvg8IWTO\n\t/ZLy2rR7l4oD5B+uHXul0R9ot+S2c3LYt2L+iol19Nb8GGdjAlNppzMO4NUnmVrkhQ\n\ttRp46NF0rsUdJ8toePgrxQL2dM/yaiueZn7FHSd49Z8maUkCY/NXk/mYu1vyL9gDmp\n\t7HfS6rkwguHi484+WUI/O/NR9u1G7QbNFtuNJaJpzxOwCkrZ786XB4zGoA+KMXRMY3\n\tyAaWsMnIb7Pnw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1666660917;\n\tbh=GuyCrJs8jIgN4JZOHr421WT3T/c3MnSoVFNfD2uLprk=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=JCc3NrTMhWrDixxNqMVuwLCRsSdoo8NCvcNXtw+vp3rq5JeDB82Wp+RdDx/fJADhW\n\tNOiy2QsrbOhytUBZ4jQG+exsa+OWDArOv+FKSM57xNAwBxv2cqrf3uCNcuXP+kE5Ez\n\tuUbzGiwOVVsL7rks+DtuPAZPLGTFHMUccnstNphY=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"JCc3NrTM\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 25 Oct 2022 04:21:31 +0300", "Message-Id": "<20221025012131.12943-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.37.4", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC PATCH] libcamera: v4l2_device: Always set\n\tall four V4L2 colorspace fields", "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>", "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "When setting a colorspace on a V4L2 video capture device or a subdev\nsource pad, the kernel considers the colorspace, xfer_func, ycbcr_enc\nand quantization fields as four independent values. Any field set to\nV4L2_*_DEFAULT by userspace is ignored, and the driver keeps its current\nconfiguration for that field. This behaviour, while not necessarily well\nknown, is clearly documented in [1] and [2], and is implemented by the\nrkisp1 driver.\n\nThe V4L2Device::fromColorSpace() function, when converting from a\nlibcamera ColorSpace to the V4L2 format colorspace-related fields, first\nattempts to find a match for a colorspace preset. If found, it only sets\nthe colorspace field, and leaves the xfer_func, ycbcr_enc and\nquantization fields to V4L2_*_DEFAULT. This contradicts the V4L2\nspecification, and prevents setting the transfer function, YCbCr\nencoding and quantization on at least rkisp1.\n\nFix this issue by dropping the preset lookup, and set all four\ncolorspace-related fields explicitly.\n\n[1] https://linuxtv.org/downloads/v4l-dvb-apis/userspace-api/v4l/pixfmt-v4l2.html#id2\n[2] https://linuxtv.org/downloads/v4l-dvb-apis/userspace-api/v4l/subdev-formats.html#id2\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nI expect this change to cause breakages on Raspberry Pi, hence the RFC.\n\nThe bcm2835-isp driver doesn't comply with the V4L2 API specification. I\ncertainly won't blame it, as I implemented the same non-compliant\nbehaviour in the rkisp1 driver initially, before realizing that V4L2\ndoesn't consider the colorspace field as a preset in set format calls\n(this has been confirmed by Hans). The question is how to move forward\nhere. Fixing the driver to make it compliant with V4L2 wouldn't be\ndifficult, but I expect non-libcamera users to be surprised. I don't\nexpect many such users though, so if that's fine, the only possible\nissue would be synchronizing the changes in the driver and in libcamera.\n\nOther options may be possible. I don't think updating the V4L2 API\nspecification to consider the colorspace field as a preset will be well\nreceived upstream (and I don't think I would like that much myself to be\nhonest). Keeping a non-compliant implementation in the bcm2835-isp\ndriver with specific handling in libcamera could be done, but I don't\nthink it would be upstreamable.\n\n---\n src/libcamera/v4l2_device.cpp | 14 --------------\n 1 file changed, 14 deletions(-)", "diff": "diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex c17b323f8af0..e60a9ae217de 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -915,20 +915,6 @@ int V4L2Device::fromColorSpace(const std::optional<ColorSpace> &colorSpace, T &v\n \tif (!colorSpace)\n \t\treturn 0;\n \n-\tauto itColor = std::find_if(colorSpaceToV4l2.begin(), colorSpaceToV4l2.end(),\n-\t\t\t\t [&colorSpace](const auto &item) {\n-\t\t\t\t\t return colorSpace == item.first;\n-\t\t\t\t });\n-\tif (itColor != colorSpaceToV4l2.end()) {\n-\t\tv4l2Format.colorspace = itColor->second;\n-\t\t/* Leaving all the other fields as \"default\" should be fine. */\n-\t\treturn 0;\n-\t}\n-\n-\t/*\n-\t * If the colorSpace doesn't precisely match a standard color space,\n-\t * then we must choose a V4L2 colorspace with matching primaries.\n-\t */\n \tint ret = 0;\n \n \tauto itPrimaries = primariesToV4l2.find(colorSpace->primaries);\n", "prefixes": [ "libcamera-devel", "RFC" ] }