Patch Detail
Show a patch.
GET /api/1.1/patches/16252/?format=api
{ "id": 16252, "url": "https://patchwork.libcamera.org/api/1.1/patches/16252/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16252/", "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": "<20220616182350.17352-5-laurent.pinchart@ideasonboard.com>", "date": "2022-06-16T18:23:47", "name": "[libcamera-devel,4/7] media: v4l2: Make colorspace validity checks more future-proof", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "7c9f1d92687c1ecfd0c123a92cd1b8b40b185efb", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16252/mbox/", "series": [ { "id": 3183, "url": "https://patchwork.libcamera.org/api/1.1/series/3183/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3183", "date": "2022-06-16T18:23:44", "name": "[libcamera-devel,1/7] media: v4l: Add packed YUV 4:4:4 YUVA and YUVX pixel formats", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3183/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16252/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16252/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 0010AC3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Jun 2022 18:24:14 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 77F936563F;\n\tThu, 16 Jun 2022 20:24:14 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2FAF065634\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Jun 2022 20:24:09 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7683E8AF;\n\tThu, 16 Jun 2022 20:24:08 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655403854;\n\tbh=4oraDFQGac7iP6sqkblu/Ky4ylMjLz5Y9aGH+ReEdXc=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=fJjmpLRcLoLwissGvhP62SEaFNYRiJguTGEPwemruEfq6Dr8yvctbdR1Qs7uRZ6h2\n\tH0M45VW2/OeKJh6xKoiWinGDOuIr2rlHjiFl9gkYbU012Pf2ocIxmykkkoh1pjAG5N\n\tGEoXHw0wGe+ytNlKoRMk90qerQGNUP/YbKs42t2JNXtwd++HteubD1U23bMf2FgIkQ\n\tcFkptBc7MyNaBaV2rE5PoMnRPIUjSV9CCbUcku9KV6VlSn4CDTLBM8w/UwnjzR+T6x\n\tdjg2NQicEJ/oHY9MpDLoO5WrAXc7LFM/KQHnx4O+NIl7GHZO6p7nGsORnf1Jko8+tN\n\t0x5b5N6fleV8Q==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655403849;\n\tbh=4oraDFQGac7iP6sqkblu/Ky4ylMjLz5Y9aGH+ReEdXc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Tv8WrHlySezVN6fDhTI1NYNOTwfDe8bmAg8OzSLwB/5wd6owwcUG6rL4uAo5+ukmz\n\tL1Aq07ueaGPPScgZN50j9X3BMiLj8m+6sccGbq5URgoUL4qNHYZ3X2Glyk44BWmm90\n\tWu88U4ZbfluP5fALCbNBBkV9wgM8ZArTIGZTbgXI=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Tv8WrHly\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 16 Jun 2022 21:23:47 +0300", "Message-Id": "<20220616182350.17352-5-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20220616182350.17352-1-laurent.pinchart@ideasonboard.com>", "References": "<20220616182350.17352-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 4/7] media: v4l2: Make colorspace validity\n\tchecks more future-proof", "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>", "Cc": "Sakari Ailus <sakari.ailus@iki.fi>, linux-imx@nxp.com,\n\tkernel@pengutronix.de, Hans Verkuil <hverkuil-cisco@xs4all.nl>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The helper functions that test validity of colorspace-related fields\nuse the last value of the corresponding enums. This isn't very\nfuture-proof, as there's a high chance someone adding a new value may\nforget to update the helpers. Add new \"LAST\" entries to the enumerations\nto improve this, and keep them private to the kernel.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nAcked-by: Sakari Ailus <sakari.ailus@linux.intel.com>\n---\nChanges since v1:\n\n- Let the compiler assign a value to the *_LAST enum entries\n---\n include/media/v4l2-common.h | 10 +++++-----\n include/uapi/linux/videodev2.h | 29 +++++++++++++++++++++++++++++\n 2 files changed, 34 insertions(+), 5 deletions(-)", "diff": "diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h\nindex 3eb202259e8c..ccc138a9104d 100644\n--- a/include/media/v4l2-common.h\n+++ b/include/media/v4l2-common.h\n@@ -563,19 +563,19 @@ static inline void v4l2_buffer_set_timestamp(struct v4l2_buffer *buf,\n static inline bool v4l2_is_colorspace_valid(__u32 colorspace)\n {\n \treturn colorspace > V4L2_COLORSPACE_DEFAULT &&\n-\t colorspace <= V4L2_COLORSPACE_DCI_P3;\n+\t colorspace < V4L2_COLORSPACE_LAST;\n }\n \n static inline bool v4l2_is_xfer_func_valid(__u32 xfer_func)\n {\n \treturn xfer_func > V4L2_XFER_FUNC_DEFAULT &&\n-\t xfer_func <= V4L2_XFER_FUNC_SMPTE2084;\n+\t xfer_func < V4L2_XFER_FUNC_LAST;\n }\n \n static inline bool v4l2_is_ycbcr_enc_valid(__u8 ycbcr_enc)\n {\n \treturn ycbcr_enc > V4L2_YCBCR_ENC_DEFAULT &&\n-\t ycbcr_enc <= V4L2_YCBCR_ENC_SMPTE240M;\n+\t ycbcr_enc < V4L2_YCBCR_ENC_LAST;\n }\n \n static inline bool v4l2_is_hsv_enc_valid(__u8 hsv_enc)\n@@ -585,8 +585,8 @@ static inline bool v4l2_is_hsv_enc_valid(__u8 hsv_enc)\n \n static inline bool v4l2_is_quant_valid(__u8 quantization)\n {\n-\treturn quantization == V4L2_QUANTIZATION_FULL_RANGE ||\n-\t quantization == V4L2_QUANTIZATION_LIM_RANGE;\n+\treturn quantization > V4L2_QUANTIZATION_DEFAULT &&\n+\t quantization < V4L2_QUANTIZATION_LAST;\n }\n \n #endif /* V4L2_COMMON_H_ */\ndiff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h\nindex f6f9a690971e..7b7d852dc74b 100644\n--- a/include/uapi/linux/videodev2.h\n+++ b/include/uapi/linux/videodev2.h\n@@ -245,6 +245,14 @@ enum v4l2_colorspace {\n \n \t/* DCI-P3 colorspace, used by cinema projectors */\n \tV4L2_COLORSPACE_DCI_P3 = 12,\n+\n+#ifdef __KERNEL__\n+\t/*\n+\t * Largest supported colorspace value, assigned by the compiler, used\n+\t * by the framework to check for invalid values.\n+\t */\n+\tV4L2_COLORSPACE_LAST,\n+#endif\n };\n \n /*\n@@ -283,6 +291,13 @@ enum v4l2_xfer_func {\n \tV4L2_XFER_FUNC_NONE = 5,\n \tV4L2_XFER_FUNC_DCI_P3 = 6,\n \tV4L2_XFER_FUNC_SMPTE2084 = 7,\n+#ifdef __KERNEL__\n+\t/*\n+\t * Largest supported transfer function value, assigned by the compiler,\n+\t * used by the framework to check for invalid values.\n+\t */\n+\tV4L2_XFER_FUNC_LAST,\n+#endif\n };\n \n /*\n@@ -343,6 +358,13 @@ enum v4l2_ycbcr_encoding {\n \n \t/* SMPTE 240M -- Obsolete HDTV */\n \tV4L2_YCBCR_ENC_SMPTE240M = 8,\n+#ifdef __KERNEL__\n+\t/*\n+\t * Largest supported encoding value, assigned by the compiler, used by\n+\t * the framework to check for invalid values.\n+\t */\n+\tV4L2_YCBCR_ENC_LAST,\n+#endif\n };\n \n /*\n@@ -378,6 +400,13 @@ enum v4l2_quantization {\n \tV4L2_QUANTIZATION_DEFAULT = 0,\n \tV4L2_QUANTIZATION_FULL_RANGE = 1,\n \tV4L2_QUANTIZATION_LIM_RANGE = 2,\n+#ifdef __KERNEL__\n+\t/*\n+\t * Largest supported quantization value, assigned by the compiler, used\n+\t * by the framework to check for invalid values.\n+\t */\n+\tV4L2_QUANTIZATION_LAST,\n+#endif\n };\n \n /*\n", "prefixes": [ "libcamera-devel", "4/7" ] }