Patch Detail
Show a patch.
GET /api/1.1/patches/20996/?format=api
{ "id": 20996, "url": "https://patchwork.libcamera.org/api/1.1/patches/20996/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20996/", "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": "<20240822153527.25320-8-laurent.pinchart+renesas@ideasonboard.com>", "date": "2024-08-22T15:35:27", "name": "[v2,7/7,DNI] media: renesas: vsp1: Validate all links through .link_validate()", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "93133ebc9dd4c39d85b63583b7dbc7a00c40c6ed", "submitter": { "id": 204, "url": "https://patchwork.libcamera.org/api/1.1/people/204/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart+renesas@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20996/mbox/", "series": [ { "id": 4533, "url": "https://patchwork.libcamera.org/api/1.1/series/4533/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4533", "date": "2024-08-22T15:35:20", "name": "media: v4l2: Improve media link validation", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4533/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20996/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20996/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 DA1EEC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Aug 2024 15:35:50 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2E32463417;\n\tThu, 22 Aug 2024 17:35:50 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BE727633E4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Aug 2024 17:35:40 +0200 (CEST)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 249F516CD;\n\tThu, 22 Aug 2024 17:34:37 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Xdu4AsXQ\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1724340877;\n\tbh=DkRVYKPomm0xFTm0bbXZFEt4UkD+SR8c0EiOkFYeAxo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Xdu4AsXQiLtxZCYKB/M+Pm5YQkWaj3ZIrWmm8JtnFE0czPx+8hLq5+kT/SuvrY+aL\n\tb03hpaRSPxIunZ5c4/Kry04xRXPuEbU0B7mjpA6s97JgTf1B5su4gKLD2LaTY689E6\n\tr59upnPyirZrS/usL6Z8LtVqvvI5Q3f7YGxouH48=", "From": "Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Chen-Yu Tsai <wens@csie.org>, Eugen Hristev <eugen.hristev@collabora.com>,\n\tHans Verkuil <hverkuil-cisco@xs4all.nl>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tMaxime Ripard <mripard@kernel.org>, Sakari Ailus <sakari.ailus@iki.fi>,\n\tTomi Valkeinen <tomi.valkeinen@ideasonboard.com>,\n\tlinux-renesas-soc@vger.kernel.org, linux-sunxi@lists.linux.dev", "Subject": "[PATCH v2 7/7] [DNI] media: renesas: vsp1: Validate all links\n\tthrough .link_validate()", "Date": "Thu, 22 Aug 2024 18:35:27 +0300", "Message-ID": "<20240822153527.25320-8-laurent.pinchart+renesas@ideasonboard.com>", "X-Mailer": "git-send-email 2.44.2", "In-Reply-To": "<20240822153527.25320-1-laurent.pinchart+renesas@ideasonboard.com>", "References": "<20240822153527.25320-1-laurent.pinchart+renesas@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Move validation of the links between video devices and subdevs,\nperformed manually in vsp1_video_streamon(), to the video device\n.link_validate() handler.\n\nThis is how drivers should be implemented, but sadly, doing so for the\nvsp1 driver could break userspace, introducing a regression. This patch\nserves as an example to showcase usage of the .link_validate()\noperation, but should not be merged.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>\n---\n .../media/platform/renesas/vsp1/vsp1_video.c | 98 +++++++------------\n 1 file changed, 37 insertions(+), 61 deletions(-)", "diff": "diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.c\nindex e728f9f5160e..14575698bbe7 100644\n--- a/drivers/media/platform/renesas/vsp1/vsp1_video.c\n+++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c\n@@ -45,51 +45,6 @@\n * Helper functions\n */\n \n-static struct v4l2_subdev *\n-vsp1_video_remote_subdev(struct media_pad *local, u32 *pad)\n-{\n-\tstruct media_pad *remote;\n-\n-\tremote = media_pad_remote_pad_first(local);\n-\tif (!remote || !is_media_entity_v4l2_subdev(remote->entity))\n-\t\treturn NULL;\n-\n-\tif (pad)\n-\t\t*pad = remote->index;\n-\n-\treturn media_entity_to_v4l2_subdev(remote->entity);\n-}\n-\n-static int vsp1_video_verify_format(struct vsp1_video *video)\n-{\n-\tstruct v4l2_subdev_format fmt = {\n-\t\t.which = V4L2_SUBDEV_FORMAT_ACTIVE,\n-\t};\n-\tstruct v4l2_subdev *subdev;\n-\tint ret;\n-\n-\tsubdev = vsp1_video_remote_subdev(&video->pad, &fmt.pad);\n-\tif (subdev == NULL)\n-\t\treturn -EINVAL;\n-\n-\tret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);\n-\tif (ret < 0)\n-\t\treturn ret == -ENOIOCTLCMD ? -EINVAL : ret;\n-\n-\tif (video->rwpf->fmtinfo->mbus != fmt.format.code ||\n-\t video->rwpf->format.height != fmt.format.height ||\n-\t video->rwpf->format.width != fmt.format.width) {\n-\t\tdev_dbg(video->vsp1->dev,\n-\t\t\t\"Format mismatch: 0x%04x/%ux%u != 0x%04x/%ux%u\\n\",\n-\t\t\tvideo->rwpf->fmtinfo->mbus, video->rwpf->format.width,\n-\t\t\tvideo->rwpf->format.height, fmt.format.code,\n-\t\t\tfmt.format.width, fmt.format.height);\n-\t\treturn -EPIPE;\n-\t}\n-\n-\treturn 0;\n-}\n-\n static int __vsp1_video_try_format(struct vsp1_video *video,\n \t\t\t\t struct v4l2_pix_format_mplane *pix,\n \t\t\t\t const struct vsp1_format_info **fmtinfo)\n@@ -991,14 +946,6 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)\n \n \tmutex_unlock(&mdev->graph_mutex);\n \n-\t/*\n-\t * Verify that the configured format matches the output of the connected\n-\t * subdev.\n-\t */\n-\tret = vsp1_video_verify_format(video);\n-\tif (ret < 0)\n-\t\tgoto err_stop;\n-\n \t/* Start the queue. */\n \tret = vb2_streamon(&video->queue, type);\n \tif (ret < 0)\n@@ -1087,14 +1034,43 @@ static const struct v4l2_file_operations vsp1_video_fops = {\n \n static int vsp1_video_link_validate(struct media_link *link)\n {\n-\t/*\n-\t * Ideally, link validation should be implemented here instead of\n-\t * calling vsp1_video_verify_format() in vsp1_video_streamon()\n-\t * manually. That would however break userspace that start one video\n-\t * device before configures formats on other video devices in the\n-\t * pipeline. This operation is just a no-op to silence the warnings\n-\t * from v4l2_subdev_link_validate().\n-\t */\n+\tstruct v4l2_subdev_format fmt = {\n+\t\t.which = V4L2_SUBDEV_FORMAT_ACTIVE,\n+\t};\n+\tstruct v4l2_subdev *subdev;\n+\tstruct media_entity *entity;\n+\tstruct media_pad *remote;\n+\tstruct vsp1_video *video;\n+\tint ret;\n+\n+\tif (is_media_entity_v4l2_video_device(link->source->entity)) {\n+\t\tentity = link->source->entity;\n+\t\tremote = link->sink;\n+\t} else {\n+\t\tentity = link->sink->entity;\n+\t\tremote = link->source;\n+\t}\n+\n+\tfmt.pad = remote->index;\n+\n+\tsubdev = media_entity_to_v4l2_subdev(remote->entity);\n+\tret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);\n+\tif (ret < 0)\n+\t\treturn ret == -ENOIOCTLCMD ? -EINVAL : ret;\n+\n+\tvideo = to_vsp1_video(media_entity_to_video_device(entity));\n+\n+\tif (video->rwpf->fmtinfo->mbus != fmt.format.code ||\n+\t video->rwpf->format.height != fmt.format.height ||\n+\t video->rwpf->format.width != fmt.format.width) {\n+\t\tdev_dbg(video->vsp1->dev,\n+\t\t\t\"Format mismatch: 0x%04x/%ux%u != 0x%04x/%ux%u\\n\",\n+\t\t\tvideo->rwpf->fmtinfo->mbus, video->rwpf->format.width,\n+\t\t\tvideo->rwpf->format.height, fmt.format.code,\n+\t\t\tfmt.format.width, fmt.format.height);\n+\t\treturn -EPIPE;\n+\t}\n+\n \treturn 0;\n }\n \n", "prefixes": [ "v2", "7/7", "DNI" ] }