From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.2 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796231939; b=QScuxsiPhJCKR4362Fz+6soplWkVLQCYeBC/ifwkxZbYoZR0B7xgNki5dIO1Pro/+mUv KmjoLzT7HZV/q5L7+55QedqSEbPAPAj0uo1edw6oGCjyjiWiez5aFmttlBeJOzCVXCC0W m6iySfYJ5xJ29vHJvOkA9l9bxVkBPmzxvDDIXE4/JqN7iY6gs+ErDzLZu6Tdla9Euf416 NbG903bzC/Zism7+IHUp7W3UBwuvTtoKbcPZnb5V3af/i5daLrhtLnGstZewK+5qbUiGa kW9jYtxestX/6BmYO5yCqsmwD/gGb62/OGuxFCzLyPwZjCpwvBfbW14ueAnb8xpo+2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796231939; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam: X-CM-SenderInfo; bh=37CXvH1DpZg6uX4B2u+T3Obx2gZ2Tl8RqvN5Ly3utRc=; b=fGMCcR0UJbEgUnVkLmGxIEBPkMIR7JK5UQCgXgthSKrsuCKk+FjIqDdjioh/3iEpAPwp AIFJSGXKxCx3Wk3se7ysvwpnj0nxZuN7ufY5g/TaYtEehIDhCD6u3/4550+hGPOHoUInU 5TKgm+yVV6H3tMg4YsrzXVtN4xbvXk6u9SJSeNOJeVUQJnqFVj2kBwsQ7xqekod7/GFZ8 fdKXNaF9wgRT7jZam+XoWbzK5etdF26gf2vx3GuKeajjJY+iAqrEVSOl99pK4l4SxNx3l 7JvRFHw8ePFY0XD+SNnPCQIgh+Mpt8KJ85hGzSs9CdTvBplvj3grDGUHKN2tpXpYPQA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=lEDCzj0Z; arc=none smtp.remote-ip=117.135.210.2 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 194C2606A31A; Wed, 2 Dec 2026 17:18:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 194C2606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=lEDCzj0Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=37 CXvH1DpZg6uX4B2u+T3Obx2gZ2Tl8RqvN5Ly3utRc=; b=lEDCzj0Z/AHeAAub0k bpP3NJnYlfSgMSkPrChPoRUawYu62oZLEaSeYoQ7BUahCN6j2b/TpCkS2ge8gqsV 4mjuWXf/LzK5eB1A0RrpJr1oxVdqjusAojamWwMw6l8mowiB4OI6KJuw220D4kcr x7+P0OiJ7ms6SH4TJ1k5+9dIw= Received: from Ubuntu26.04LTS (unknown []) by gzga-smtp-mtada-g0-1 (Coremail) with SMTP id _____wCnhBDjUhBrjnKcLw--.61858S3; Thu, 03 Dec 2026 01:18:29 +0800 (CST) From: Jiaqi Shi To: linux-media@vger.kernel.org, imx@lists.linux.dev, linux-staging@lists.linux.dev Cc: slongerbeam@gmail.com, p.zabel@pengutronix.de, mchehab@kernel.org, gregkh@linuxfoundation.org, Frank.Li@nxp.com, kernel@pengutronix.de, festevam@gmail.com, Jiaqi Shi Subject: [PATCH v9 1/3] media: imx: remove subdev control inheritance to capture video nodes Date: Thu, 3 Dec 2026 01:18:25 +0800 Message-ID: <20261202171827.867089-2-shijiaqi_develop@163.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261202171827.867089-1-shijiaqi_develop@163.com> References: <20261202171827.867089-1-shijiaqi_develop@163.com> X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wCnhBDjUhBrjnKcLw--.61858S3 X-Coremail-Antispam: 1Uf129KBjvJXoW3ZFWDGr45trykAryruw4UJwb_yoWktr1rpF 4Fy3W2krW8Xr45Ww4UJa1UZFy3Z34SkaySgw17Wwn7KryayFnIqFyxta4UAFy5Gr93ua4a yF45WrWUu3yYyF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziJ5r5UUUUU= X-CM-SenderInfo: xvklyxpdtlsvxhyhz0rs6rljoofrz/xtbC7wWsAGsQUuWocAAA3S Capture video nodes inherited controls from the pipeline subdevs and refreshed them in the link_notify callback. Userspace should use the subdev-based API instead, so drop the inheritance and the per-video-device control handler it needs. Signed-off-by: Jiaqi Shi --- Documentation/admin-guide/media/imx.rst | 10 +- drivers/staging/media/imx/TODO | 6 - drivers/staging/media/imx/imx-ic-prpencvf.c | 5 +- drivers/staging/media/imx/imx-media-capture.c | 19 --- drivers/staging/media/imx/imx-media-csi.c | 5 +- .../staging/media/imx/imx-media-dev-common.c | 113 +----------------- drivers/staging/media/imx/imx-media.h | 7 +- 7 files changed, 8 insertions(+), 157 deletions(-) diff --git a/Documentation/admin-guide/media/imx.rst b/Documentation/admin-guide/media/imx.rst index bb68100d8acb..b1c5fecfaef7 100644 --- a/Documentation/admin-guide/media/imx.rst +++ b/Documentation/admin-guide/media/imx.rst @@ -394,13 +394,9 @@ scaling up to 1024x1024, CSC, flip, and rotation: Usage Notes ----------- -To aid in configuration and for backward compatibility with V4L2 -applications that access controls only from video device nodes, the -capture device interfaces inherit controls from the active entities -in the current pipeline, so controls can be accessed either directly -from the subdev or from the active capture device interface. For -example, the FIM controls are available either from the ipuX_csiY -subdevs or from the active capture device. +Controls for pipeline entities are accessed through their subdev device +nodes. For example, the FIM controls are available from the ipuX_csiY +subdevs. The following are specific usage notes for the Sabre* reference boards: diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO index 11c9e10d34ae..db82dd684869 100644 --- a/drivers/staging/media/imx/TODO +++ b/drivers/staging/media/imx/TODO @@ -2,12 +2,6 @@ - The Frame Interval Monitor could be exported to v4l2-core for general use. -- This media driver supports inheriting V4L2 controls to the - video capture devices, from the subdevices in the capture device's - pipeline. The controls for each capture device are updated in the - link_notify callback when the pipeline is modified. This feature should be - removed, userspace should use the subdev-based userspace API instead. - - Similarly to the legacy control handling, legacy format handling where formats on the video nodes are influenced by the active format of the connected subdev should be removed. diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index aaa2248780a8..0056d9d2e66c 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -1285,7 +1285,7 @@ static int prp_registered(struct v4l2_subdev *sd) ret = imx_media_capture_device_register(priv->vdev, 0); if (ret) - goto remove_vdev; + return ret; ret = prp_init_controls(priv); if (ret) @@ -1295,8 +1295,6 @@ static int prp_registered(struct v4l2_subdev *sd) unreg_vdev: imx_media_capture_device_unregister(priv->vdev); -remove_vdev: - imx_media_capture_device_remove(priv->vdev); return ret; } @@ -1305,7 +1303,6 @@ static void prp_unregistered(struct v4l2_subdev *sd) struct prp_priv *priv = sd_to_priv(sd); imx_media_capture_device_unregister(priv->vdev); - imx_media_capture_device_remove(priv->vdev); v4l2_ctrl_handler_free(&priv->ctrl_hdlr); } diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index 9216a221b72f..4dcfa0fdf1a4 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -42,8 +41,6 @@ struct capture_priv { struct list_head ready_q; /* List of queued buffers */ spinlock_t q_lock; /* Protect ready_q */ - struct v4l2_ctrl_handler ctrl_hdlr; /* Controls inherited from subdevs */ - bool legacy_api; /* Use the legacy (pre-MC) API */ }; @@ -553,8 +550,6 @@ static int capture_legacy_subscribe_event(struct v4l2_fh *fh, return v4l2_event_subscribe(fh, sub, 0, NULL); case V4L2_EVENT_SOURCE_CHANGE: return v4l2_src_change_event_subscribe(fh, sub); - case V4L2_EVENT_CTRL: - return v4l2_ctrl_subscribe_event(fh, sub); default: return -EINVAL; } @@ -1031,24 +1026,10 @@ imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, return ERR_PTR(ret); } - if (legacy_api) { - /* Initialize the control handler. */ - v4l2_ctrl_handler_init(&priv->ctrl_hdlr, 0); - vfd->ctrl_handler = &priv->ctrl_hdlr; - } - return &priv->vdev; } EXPORT_SYMBOL_GPL(imx_media_capture_device_init); -void imx_media_capture_device_remove(struct imx_media_video_dev *vdev) -{ - struct capture_priv *priv = to_capture_priv(vdev); - - v4l2_ctrl_handler_free(&priv->ctrl_hdlr); -} -EXPORT_SYMBOL_GPL(imx_media_capture_device_remove); - MODULE_DESCRIPTION("i.MX5/6 v4l2 video capture interface driver"); MODULE_AUTHOR("Steve Longerbeam "); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 2c153a5f9613..cebd1b20b6e8 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1823,12 +1823,10 @@ static int csi_registered(struct v4l2_subdev *sd) ret = imx_media_capture_device_register(priv->vdev, 0); if (ret) - goto remove_vdev; + goto free_fim; return 0; -remove_vdev: - imx_media_capture_device_remove(priv->vdev); free_fim: if (priv->fim) imx_media_fim_free(priv->fim); @@ -1842,7 +1840,6 @@ static void csi_unregistered(struct v4l2_subdev *sd) struct csi_priv *priv = v4l2_get_subdevdata(sd); imx_media_capture_device_unregister(priv->vdev); - imx_media_capture_device_remove(priv->vdev); if (priv->fim) imx_media_fim_free(priv->fim); diff --git a/drivers/staging/media/imx/imx-media-dev-common.c b/drivers/staging/media/imx/imx-media-dev-common.c index be445df93518..3a34fb0a7c61 100644 --- a/drivers/staging/media/imx/imx-media-dev-common.c +++ b/drivers/staging/media/imx/imx-media-dev-common.c @@ -6,7 +6,6 @@ * Copyright (c) 2016 Mentor Graphics Inc. */ -#include #include #include #include @@ -189,116 +188,6 @@ int imx_media_probe_complete(struct v4l2_async_notifier *notifier) } EXPORT_SYMBOL_GPL(imx_media_probe_complete); -/* - * adds controls to a video device from an entity subdevice. - * Continues upstream from the entity's sink pads. - */ -static int imx_media_inherit_controls(struct imx_media_dev *imxmd, - struct video_device *vfd, - struct media_entity *entity) -{ - int i, ret = 0; - - if (is_media_entity_v4l2_subdev(entity)) { - struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); - - dev_dbg(imxmd->md.dev, - "adding controls to %s from %s\n", - vfd->entity.name, sd->entity.name); - - ret = v4l2_ctrl_add_handler(vfd->ctrl_handler, - sd->ctrl_handler, - NULL, true); - if (ret) - return ret; - } - - /* move upstream */ - for (i = 0; i < entity->num_pads; i++) { - struct media_pad *pad, *spad = &entity->pads[i]; - - if (!(spad->flags & MEDIA_PAD_FL_SINK)) - continue; - - pad = media_pad_remote_pad_first(spad); - if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) - continue; - - ret = imx_media_inherit_controls(imxmd, vfd, pad->entity); - if (ret) - break; - } - - return ret; -} - -static int imx_media_link_notify(struct media_link *link, u32 flags, - unsigned int notification) -{ - struct imx_media_dev *imxmd = container_of(link->graph_obj.mdev, - struct imx_media_dev, md); - struct media_entity *source = link->source->entity; - struct imx_media_pad_vdev *pad_vdev; - struct list_head *pad_vdev_list; - struct video_device *vfd; - struct v4l2_subdev *sd; - int pad_idx, ret; - - ret = v4l2_pipeline_link_notify(link, flags, notification); - if (ret) - return ret; - - /* don't bother if source is not a subdev */ - if (!is_media_entity_v4l2_subdev(source)) - return 0; - - sd = media_entity_to_v4l2_subdev(source); - pad_idx = link->source->index; - - pad_vdev_list = to_pad_vdev_list(sd, pad_idx); - if (!pad_vdev_list) { - /* nothing to do if source sd has no pad vdev list */ - return 0; - } - - /* - * Before disabling a link, reset controls for all video - * devices reachable from this link. - * - * After enabling a link, refresh controls for all video - * devices reachable from this link. - */ - if (notification == MEDIA_DEV_NOTIFY_PRE_LINK_CH && - !(flags & MEDIA_LNK_FL_ENABLED)) { - list_for_each_entry(pad_vdev, pad_vdev_list, list) { - vfd = pad_vdev->vdev->vfd; - if (!vfd->ctrl_handler) - continue; - dev_dbg(imxmd->md.dev, - "reset controls for %s\n", - vfd->entity.name); - v4l2_ctrl_handler_free(vfd->ctrl_handler); - v4l2_ctrl_handler_init(vfd->ctrl_handler, 0); - } - } else if (notification == MEDIA_DEV_NOTIFY_POST_LINK_CH && - (link->flags & MEDIA_LNK_FL_ENABLED)) { - list_for_each_entry(pad_vdev, pad_vdev_list, list) { - vfd = pad_vdev->vdev->vfd; - if (!vfd->ctrl_handler) - continue; - dev_dbg(imxmd->md.dev, - "refresh controls for %s\n", - vfd->entity.name); - ret = imx_media_inherit_controls(imxmd, vfd, - &vfd->entity); - if (ret) - break; - } - } - - return ret; -} - static void imx_media_notify(struct v4l2_subdev *sd, unsigned int notification, void *arg) { @@ -326,7 +215,7 @@ static const struct v4l2_async_notifier_operations imx_media_notifier_ops = { }; static const struct media_device_ops imx_media_md_ops = { - .link_notify = imx_media_link_notify, + .link_notify = v4l2_pipeline_link_notify, }; struct imx_media_dev *imx_media_dev_init(struct device *dev, diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 537558a7bece..832c9d292353 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -125,10 +125,8 @@ static inline struct imx_media_buffer *to_imx_media_vb(struct vb2_buffer *vb) } /* - * to support control inheritance to video devices, this - * retrieves a pad's list_head of video devices that can - * be reached from the pad. Note that only the lists in - * source pads get populated, sink pads have empty lists. + * Retrieve a pad's list of video devices reachable from the pad for + * subdev event forwarding. Only source pad lists are populated. */ static inline struct list_head * to_pad_vdev_list(struct v4l2_subdev *sd, int pad_index) @@ -271,7 +269,6 @@ int imx_media_ic_unregister(struct v4l2_subdev *sd); struct imx_media_video_dev * imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd, int pad, bool legacy_api); -void imx_media_capture_device_remove(struct imx_media_video_dev *vdev); int imx_media_capture_device_register(struct imx_media_video_dev *vdev, u32 link_flags); void imx_media_capture_device_unregister(struct imx_media_video_dev *vdev); -- 2.53.0