From patchwork Tue Feb 4 23:49:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C89D914D5 for ; Tue, 4 Feb 2020 23:49:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A757421744 for ; Tue, 4 Feb 2020 23:49:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EtqHVulX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727563AbgBDXth (ORCPT ); Tue, 4 Feb 2020 18:49:37 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:41382 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727412AbgBDXth (ORCPT ); Tue, 4 Feb 2020 18:49:37 -0500 Received: by mail-pl1-f195.google.com with SMTP id t14so64439plr.8; Tue, 04 Feb 2020 15:49:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qD7p9omT3ZqLHQdscsqkNZErSP6L23JqC4boqGiD0ds=; b=EtqHVulXx99URS3Qe05lW8Lufh6T7pcjz/KReLzLTuFZSbtVzZaf2lrMZI4wFiApPl bD+ggX05doVz354UPhFih4X+p4n34bjwn6de8Z+BcQm8zWJdRmNnAHRuONj/FUI1tjyL iUfNcGHJqDaclN9NFsMaKYb0eyF0vglFqcZmIQYZKSKeO765QpmIAsGkGffo3f+MVPkw fWPcI0cUWUGwgu16ALmpk6C0kyYdHaMVZi5Rk/UcqEnlm/XiSDfVskhmaq0Y5tuWEtxM w0N9BZodkCGw0bo3dFPXdRk7qnxnnHhU3KPxLZK0/3886wX/eYn+Rx6p2MdkH2bbzQ/c hICw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qD7p9omT3ZqLHQdscsqkNZErSP6L23JqC4boqGiD0ds=; b=hhvQfjBUVEQMIAy7aKbroqVktgA0l7GJcQT9DIRoqBkZyEHZ7j8aCR6v4oug6APF7S 3FqOJOKRwMc3gxL483DtcEzkAPguBM6eoIzF8OOiqMwfbsIkQo4mAqQSpbnr8Qutf5Xz JVoviO++BJ8vDMRvFYqr0Uw+sfGtyMssP1oCNFsnUML8mLDba1L9V3Y0QTbDnm9fP7GF KRZjDHuJq61TOtKDWFVUe0Ie3lGOrKvlF/sCLoSkpNIlgZjE/+q+5LKtP8SS2/1Qy8/N NUY0mSrWM6i3pOlBFL/OZ8VW9sDOpS3Wzxuq69rCKM2GQG4typJEtr0ChiiyJ71K1gAa 8BRg== X-Gm-Message-State: APjAAAWZKDQbMHkyg8xpNULVV0CTHwa9yBI5zb9lB6YheCBU7dMCwX/w tzm3knx3pD5nXRfZXQNNIXAgw47Q X-Google-Smtp-Source: APXvYqyBLewVzoOQa5qiRdOx7sM6iJnyGsUH+B0sJ4Kxn/9oyCmHZ7AwNaBh982pcio1KFv+l18nHg== X-Received: by 2002:a17:902:8688:: with SMTP id g8mr32079519plo.277.1580860176419; Tue, 04 Feb 2020 15:49:36 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:35 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Sakari Ailus , Laurent Pinchart , Mauro Carvalho Chehab , =?utf-8?q?Niklas_S=C3=B6derlund?= , Hans Verkuil , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 01/17] media: entity: Pass entity to get_fwnode_pad operation Date: Tue, 4 Feb 2020 15:49:02 -0800 Message-Id: <20200204234918.20425-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a missing pointer to the entity in the media_entity operation get_fwnode_pad. There are no implementers of this op yet, but a future entity that does so will almost certainly need a reference to itself to carry out the work. Fixes: ae45cd5efc120 ("[media] media: entity: Add get_fwnode_pad entity operation") Signed-off-by: Steve Longerbeam --- drivers/media/mc/mc-entity.c | 2 +- include/media/media-entity.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 7c429ce98bae..c333320f790a 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -386,7 +386,7 @@ int media_entity_get_fwnode_pad(struct media_entity *entity, if (ret) return ret; - ret = entity->ops->get_fwnode_pad(&endpoint); + ret = entity->ops->get_fwnode_pad(entity, &endpoint); if (ret < 0) return ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 8cb2c504a05c..cde80ad029b7 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -212,7 +212,8 @@ struct media_pad { * mutex held. */ struct media_entity_operations { - int (*get_fwnode_pad)(struct fwnode_endpoint *endpoint); + int (*get_fwnode_pad)(struct media_entity *entity, + struct fwnode_endpoint *endpoint); int (*link_setup)(struct media_entity *entity, const struct media_pad *local, const struct media_pad *remote, u32 flags); From patchwork Tue Feb 4 23:49:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365505 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79A9D92A for ; Tue, 4 Feb 2020 23:50:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42DB221744 for ; Tue, 4 Feb 2020 23:50:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mV4ykrXk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727698AbgBDXtk (ORCPT ); Tue, 4 Feb 2020 18:49:40 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40702 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727412AbgBDXtk (ORCPT ); Tue, 4 Feb 2020 18:49:40 -0500 Received: by mail-pf1-f193.google.com with SMTP id q8so170072pfh.7; Tue, 04 Feb 2020 15:49:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jUynGWRf9sI6R88VN+A+Lof5pz2eSFUmaeoDgeZz6dI=; b=mV4ykrXkIToVTjQOxOUTlSnm65lZiucVQSoZGKiO43gNyAML1s8k69ReqZshQWCnVX fn1BJL8gWhvgGV9jhgCCyRbIpODc8gATXsy4+mU9VTmAXOpvcVH4c+gDWPAxTTGWhSr2 I8J55yeSk/6s6BKxRyaRKb/RE07RJdVxTDeM5ITS9dVE/YHEJ5aLNDJItU7ZZ0j3y0JZ z1/zmAeqN6cmQP5k5YGrkRrfm8T77uK3J1DdDkxtgzEvEtyhmciFFEs47Gp5O9DuY6hs QDLGlTBnoZYmigrqmtCbAjq1a5Yqbf9kosgM/kSMVnXK7zYZL1UCsroQrdPMpvHFNpft IAhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jUynGWRf9sI6R88VN+A+Lof5pz2eSFUmaeoDgeZz6dI=; b=mMJkp/0WdUK49XkWebAK/v4lttgNRAPJmG3OP/PqNln4V9w4XAwdMQDXt9iBXNJnxf qvqsO1cXjMn82MUKnX6GGkCHVhvlRR4TPeuVCvd8AuTeKPxkqk7m/C/aP4rQkkA+YksX oYNxknxgMC9kHFN8i7x06IILANolQtktwh2dSrqUTxQhsZCUOjAWUb+SP5NPrcI1RvaX Bt18A9K2Cb4g8+dq6qg4ta9ZMrtLgjpTsN6TcXHMqr9Vs5wlhL6L6QAdxlHGAf2Lm1NE csi1Hl7V1OYJ1AotPPTNgBOgcDms9WPYLmA6dnyO0jwHuJb8HMoxHMl0gh5ABfydiiWA 37jg== X-Gm-Message-State: APjAAAVKK+tHWqf/N6cwoBvbQoqrFCaLWsKaN29aq0AkbcG0TTdDNiP2 Y2FO4IsjikiLU51Roj80re/rYdWK X-Google-Smtp-Source: APXvYqzcceO1lN1S91G9eSGPySGp3tSRqh1SD5abYm09FOCUxEWixWuYnXT81aaJkpZ5laS5vvtd1A== X-Received: by 2002:a63:8a42:: with SMTP id y63mr19665372pgd.266.1580860179347; Tue, 04 Feb 2020 15:49:39 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:38 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sakari Ailus , Richard Fontana , Thomas Gleixner , Andy Shevchenko , linux-kernel@vger.kernel.org (open list), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE) Subject: [PATCH v3 02/17] media: v4l2-fwnode: Pass notifier to v4l2_async_register_fwnode_subdev() Date: Tue, 4 Feb 2020 15:49:03 -0800 Message-Id: <20200204234918.20425-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Instead of allocating a notifier in v4l2_async_register_fwnode_subdev(), have the caller provide one. This allows the caller to implement notifier ops (bind, unbind). The caller is now responsible for first initializing its notifier with a call to v4l2_async_notifier_init(). Signed-off-by: Steve Longerbeam --- Changes in v3: - added the missing calls to unregister/cleanup the new subdev notifiers. Reported by Rui Silva. --- drivers/media/platform/video-mux.c | 8 +++++++- drivers/media/v4l2-core/v4l2-fwnode.c | 11 +---------- drivers/staging/media/imx/imx6-mipi-csi2.c | 7 ++++++- drivers/staging/media/imx/imx7-media-csi.c | 7 ++++++- drivers/staging/media/imx/imx7-mipi-csis.c | 9 ++++++++- include/media/v4l2-fwnode.h | 12 ++++++++---- 6 files changed, 36 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index ddd0e338f9e4..3d2a5c2b4c08 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -21,6 +21,7 @@ struct video_mux { struct v4l2_subdev subdev; + struct v4l2_async_notifier notifier; struct media_pad *pads; struct v4l2_mbus_framefmt *format_mbus; struct mux_control *mux; @@ -354,8 +355,11 @@ static int video_mux_async_register(struct video_mux *vmux, for (i = 0; i < num_input_pads; i++) ports[i] = i; + v4l2_async_notifier_init(&vmux->notifier); + ret = v4l2_async_register_fwnode_subdev( - &vmux->subdev, sizeof(struct v4l2_async_subdev), + &vmux->subdev, &vmux->notifier, + sizeof(struct v4l2_async_subdev), ports, num_input_pads, video_mux_parse_endpoint); kfree(ports); @@ -442,6 +446,8 @@ static int video_mux_remove(struct platform_device *pdev) struct video_mux *vmux = platform_get_drvdata(pdev); struct v4l2_subdev *sd = &vmux->subdev; + v4l2_async_notifier_unregister(&vmux->notifier); + v4l2_async_notifier_cleanup(&vmux->notifier); v4l2_async_unregister_subdev(sd); media_entity_cleanup(&sd->entity); diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 6ece4320e1d2..ae2cc4d6faf6 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -1164,12 +1164,12 @@ int v4l2_async_register_subdev_sensor_common(struct v4l2_subdev *sd) EXPORT_SYMBOL_GPL(v4l2_async_register_subdev_sensor_common); int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, + struct v4l2_async_notifier *notifier, size_t asd_struct_size, unsigned int *ports, unsigned int num_ports, parse_endpoint_func parse_endpoint) { - struct v4l2_async_notifier *notifier; struct device *dev = sd->dev; struct fwnode_handle *fwnode; int ret; @@ -1181,12 +1181,6 @@ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, if (!fwnode_device_is_available(fwnode)) return -ENODEV; - notifier = kzalloc(sizeof(*notifier), GFP_KERNEL); - if (!notifier) - return -ENOMEM; - - v4l2_async_notifier_init(notifier); - if (!ports) { ret = v4l2_async_notifier_parse_fwnode_endpoints(dev, notifier, asd_struct_size, @@ -1211,15 +1205,12 @@ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, if (ret < 0) goto out_unregister; - sd->subdev_notifier = notifier; - return 0; out_unregister: v4l2_async_notifier_unregister(notifier); out_cleanup: v4l2_async_notifier_cleanup(notifier); - kfree(notifier); return ret; } diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index cd3dd6e33ef0..c1d1afeea53a 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -35,6 +35,7 @@ struct csi2_dev { struct device *dev; struct v4l2_subdev sd; + struct v4l2_async_notifier notifier; struct media_pad pad[CSI2_NUM_PADS]; struct clk *dphy_clk; struct clk *pllref_clk; @@ -636,8 +637,10 @@ static int csi2_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &csi2->sd); + v4l2_async_notifier_init(&csi2->notifier); + ret = v4l2_async_register_fwnode_subdev( - &csi2->sd, sizeof(struct v4l2_async_subdev), + &csi2->sd, &csi2->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, csi2_parse_endpoint); if (ret) goto dphy_off; @@ -658,6 +661,8 @@ static int csi2_remove(struct platform_device *pdev) struct v4l2_subdev *sd = platform_get_drvdata(pdev); struct csi2_dev *csi2 = sd_to_dev(sd); + v4l2_async_notifier_unregister(&csi2->notifier); + v4l2_async_notifier_cleanup(&csi2->notifier); v4l2_async_unregister_subdev(sd); clk_disable_unprepare(csi2->dphy_clk); clk_disable_unprepare(csi2->pllref_clk); diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index db30e2c70f2f..dc6d1a28fde7 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -155,6 +155,7 @@ struct imx7_csi { struct device *dev; struct v4l2_subdev sd; + struct v4l2_async_notifier notifier; struct imx_media_video_dev *vdev; struct imx_media_dev *imxmd; struct media_pad pad[IMX7_CSI_PADS_NUM]; @@ -1266,7 +1267,9 @@ static int imx7_csi_probe(struct platform_device *pdev) if (ret < 0) goto free; - ret = v4l2_async_register_fwnode_subdev(&csi->sd, + v4l2_async_notifier_init(&csi->notifier); + + ret = v4l2_async_register_fwnode_subdev(&csi->sd, &csi->notifier, sizeof(struct v4l2_async_subdev), NULL, 0, imx7_csi_parse_endpoint); @@ -1303,6 +1306,8 @@ static int imx7_csi_remove(struct platform_device *pdev) v4l2_device_unregister(&imxmd->v4l2_dev); media_device_cleanup(&imxmd->md); + v4l2_async_notifier_unregister(&csi->notifier); + v4l2_async_notifier_cleanup(&csi->notifier); v4l2_async_unregister_subdev(sd); v4l2_ctrl_handler_free(&csi->ctrl_hdlr); diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index 383abecb3bec..4c54456318ea 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -223,6 +223,7 @@ struct csi_state { struct device *dev; struct media_pad pads[CSIS_PADS_NUM]; struct v4l2_subdev mipi_sd; + struct v4l2_async_notifier notifier; struct v4l2_subdev *src_sd; u8 index; @@ -883,7 +884,9 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, if (ret) return ret; - ret = v4l2_async_register_fwnode_subdev(mipi_sd, + v4l2_async_notifier_init(&state->notifier); + + ret = v4l2_async_register_fwnode_subdev(mipi_sd, &state->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, mipi_csis_parse_endpoint); @@ -1014,6 +1017,8 @@ static int mipi_csis_probe(struct platform_device *pdev) unregister_all: mipi_csis_debugfs_exit(state); media_entity_cleanup(&state->mipi_sd.entity); + v4l2_async_notifier_unregister(&state->notifier); + v4l2_async_notifier_cleanup(&state->notifier); v4l2_async_unregister_subdev(&state->mipi_sd); disable_clock: mipi_csis_clk_disable(state); @@ -1101,6 +1106,8 @@ static int mipi_csis_remove(struct platform_device *pdev) struct csi_state *state = mipi_sd_to_csis_state(mipi_sd); mipi_csis_debugfs_exit(state); + v4l2_async_notifier_unregister(&state->notifier); + v4l2_async_notifier_cleanup(&state->notifier); v4l2_async_unregister_subdev(&state->mipi_sd); pm_runtime_disable(&pdev->dev); diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index f6a7bcd13197..b2b61e6c3769 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -375,6 +375,7 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, * and parses fwnode endpoints * * @sd: pointer to struct &v4l2_subdev + * @notifier: the sub-device's notifier. * @asd_struct_size: size of the driver's async sub-device struct, including * sizeof(struct v4l2_async_subdev). The &struct * v4l2_async_subdev shall be the first member of @@ -387,13 +388,15 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, * endpoint. Optional. * * This function is just like v4l2_async_register_subdev() with the - * exception that calling it will also allocate a notifier for the - * sub-device, parse the sub-device's firmware node endpoints using - * v4l2_async_notifier_parse_fwnode_endpoints() or + * exception that calling it will also parse the sub-device's firmware + * node endpoints using v4l2_async_notifier_parse_fwnode_endpoints() or * v4l2_async_notifier_parse_fwnode_endpoints_by_port(), and - * registers the sub-device notifier. The sub-device is similarly + * registers the sub-device's notifier. The sub-device is similarly * unregistered by calling v4l2_async_unregister_subdev(). * + * The caller must first initialize the notifier with a call to + * v4l2_async_notifier_init(). + * * While registered, the subdev module is marked as in-use. * * An error is returned if the module is no longer loaded on any attempts @@ -401,6 +404,7 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, */ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, + struct v4l2_async_notifier *notifier, size_t asd_struct_size, unsigned int *ports, unsigned int num_ports, From patchwork Tue Feb 4 23:49:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365503 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 375C292A for ; Tue, 4 Feb 2020 23:50:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 160A621744 for ; Tue, 4 Feb 2020 23:50:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qmhbDNR9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727723AbgBDXtl (ORCPT ); Tue, 4 Feb 2020 18:49:41 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44642 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727711AbgBDXtl (ORCPT ); Tue, 4 Feb 2020 18:49:41 -0500 Received: by mail-pg1-f193.google.com with SMTP id g3so4768437pgs.11; Tue, 04 Feb 2020 15:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tEFP9EfjLyBSm2GDbhHW2vsbKN5BJT5FKVyhRHQNMY8=; b=qmhbDNR95uHywwTR96SOWFHQIuY5BcX1uVAKfd+uicZ/k1fooHXSfNBVaesqjSQuZM OQMTcnpW7TEz9K/YUDnRklPs/ToaTpYqRigLVpPQu4QcTCoIPUY150DuIMtiSb4/OEyH oJ3emGDquRgVHbaJlQYK9Fd1Ftcovqe1Bk+JATIFT7MVbxmoDSys0IY2ekFO7tQqoxLP bhQSL0C/24rpHydkRdHxijxlvhu8YM+ssVxLjZXU8FXyWrn7J88sNdv6x3XgL+gqmTrr XzMFB4qltVjlXDCHbOzNZgd94Pr/t6vht9lz9F0xzd+xATy4aNz67yWdpbTWB/kvEusB nBnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tEFP9EfjLyBSm2GDbhHW2vsbKN5BJT5FKVyhRHQNMY8=; b=cBNc6eD+tat9DI80QEgdnb8w3A3ljNuV/VDlIkBkQJmmVRmy+YBs/wxiMdxFpClTV3 NMg2C7VhQrCaBcxoe9gHmCIdTNoPDZ6ndanoymq0rT/zBrfdelfSJHigoGsMqQjZnzxm nlO8xHHoladv04x8IT5wFyAJ8yijyC83ksrL7gDuSoP7b1H1sZVRB2EDplkbOOEBZKKg IQbcO/tyoEyxtR0nWgzK+fU5ExJdsQDpS761didmrbjzq2SB/T5rWLgXMSSd5+SzLuLj LDjISiw+oL0zVru/A7EO0ipmd8rTP1zWIaltExJxfjt95bj050Stkx8cQxwEGiU8vKkJ emKQ== X-Gm-Message-State: APjAAAVyI/VJ0FFxIFHh48vG770Mnrigtc0tVsBrwbqSoRNiHe4370On /lpJhXHYtI5b7p9W37nlPwagWHNN X-Google-Smtp-Source: APXvYqyIsRF7R9F2VnqpYSRTFRZQXt11C2WQyxtCzzEwR1tv4q2JGNKz08KJv6czrUc3SW0JZ1+R3g== X-Received: by 2002:a63:9251:: with SMTP id s17mr33348585pgn.127.1580860180704; Tue, 04 Feb 2020 15:49:40 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:40 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 03/17] media: imx: csi: Implement get_fwnode_pad op Date: Tue, 4 Feb 2020 15:49:04 -0800 Message-Id: <20200204234918.20425-4-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The CSI does not have a 1:1 relationship between fwnode port numbers and pad indexes. In fact the CSI fwnode device is itself a port which is the sink, containing only a single fwnode endpoint. Implement media_entity operation get_fwnode_pad to first verify the given endpoint is the CSI's sink endpoint, and if so return the CSI sink pad index. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index b60ed4f22f6d..dc5fe25fe7b8 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1825,9 +1825,32 @@ static void csi_unregistered(struct v4l2_subdev *sd) ipu_csi_put(priv->csi); } +/* + * The CSI has only one fwnode endpoint, at the sink pad. Verify the + * endpoint belongs to us, and return CSI_SINK_PAD. + */ +static int csi_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct fwnode_handle *csi_port = dev_fwnode(priv->dev); + struct fwnode_handle *csi_ep; + int ret; + + csi_ep = fwnode_get_next_child_node(csi_port, NULL); + + ret = endpoint->local_fwnode == csi_ep ? CSI_SINK_PAD : -ENXIO; + + fwnode_handle_put(csi_ep); + + return ret; +} + static const struct media_entity_operations csi_entity_ops = { .link_setup = csi_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = csi_get_fwnode_pad, }; static const struct v4l2_subdev_core_ops csi_core_ops = { From patchwork Tue Feb 4 23:49:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365501 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F91D14D5 for ; Tue, 4 Feb 2020 23:50:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BC9121927 for ; Tue, 4 Feb 2020 23:50:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Yk0UNyyA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727744AbgBDXtn (ORCPT ); Tue, 4 Feb 2020 18:49:43 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33347 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727731AbgBDXtm (ORCPT ); Tue, 4 Feb 2020 18:49:42 -0500 Received: by mail-pl1-f196.google.com with SMTP id ay11so80174plb.0; Tue, 04 Feb 2020 15:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GoHwA/NUt6bdmcBWMk3GrpTBSbEsSYQ8eBgsnOl6FH8=; b=Yk0UNyyAlkctNhCEl0XmAo9v2tutCjwPUMuD76Z53N2E4FftV6cTkCjAHeQGoJsHj7 QIKwetLhpjlSd9i0Ats6RVGMrEEDEVRLioAxbYfLaBN5889APinEf0m55r5x3KXaVIrZ oSQTl6kQyV8sFLASP/vjlidXEX6iS/0RE8mVwS2tKLHUio+gpN488xI69k9G6e56oy9i HblJhv895SVGOBfy9iEga1oD2MUI/OGK6OvL9p3QKBzi///hzUbXJEi5AxaXBdj3RDze QjNQ3hoaGObwKZyWme74zSLdWqs4meGDHX2FHwsCWvwW5CszqBNMc8y4NEJu8dbbYXWw Aa4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GoHwA/NUt6bdmcBWMk3GrpTBSbEsSYQ8eBgsnOl6FH8=; b=np0QXmpHtU/uqjUkLJhmVY6/thDn85ltdwC/0R81vjwNFuQ8f+tA2Oxn85qcZK2d7j k/Oc8HLVACR1Jbmw6gX3iZ5mY7f2wQCBMoGhxEZbUDmVyFxqWeyCO1DyERZ6JbFM0gd/ 1j0gTQl6NQH27piGVgcqm75DSwbQlCLdpqew3UEsY4tEoO3h+7i59L6xpWftT7cxp3fB Io+Iw4Vv2yctkttx7xF2cj3K681OhuWzEla0EgziCuKF9OeKtgAh1FLl9NI3U7FyawnI mWGzj0O6knYmAI8gZvt1XwIHhxU9vFbnkF+9Rc09HR4NWIPLrJT10oaFiZNRY7MxNcwo XCbw== X-Gm-Message-State: APjAAAU7GcYahxEbUeUz88X7Hupqnt5F6Y8KY87qZ2WGRzxl/3g8UIAu ZWYbLHuh48r1AjaQy2hZTOlEdAC3 X-Google-Smtp-Source: APXvYqzscwmenowcDy7Jeog/8AGe1JciDVrcX+rmRLWuTOpy9AufsDtRKO3ndcrFvHB5apSnObXHOw== X-Received: by 2002:a17:902:a514:: with SMTP id s20mr32054509plq.300.1580860181981; Tue, 04 Feb 2020 15:49:41 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:41 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 04/17] media: imx: mipi csi-2: Implement get_fwnode_pad op Date: Tue, 4 Feb 2020 15:49:05 -0800 Message-Id: <20200204234918.20425-5-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement get_fwnode_pad operation. If the endpoint is owned by the MIPI CSI-2 receiver, return the endpoint's port number. The MIPI CSI-2 receiver maps port numbers and pad indexes 1:1. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx6-mipi-csi2.c | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index c1d1afeea53a..e27a342751fc 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -507,9 +507,37 @@ static int csi2_registered(struct v4l2_subdev *sd) 640, 480, 0, V4L2_FIELD_NONE, NULL); } +static int csi2_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct csi2_dev *csi2 = sd_to_dev(sd); + struct fwnode_handle *csi2_ep; + + /* + * If the endpoint is one of ours, return the endpoint's port + * number. This device maps port numbers and pad indexes 1:1. + */ + fwnode_graph_for_each_endpoint(dev_fwnode(csi2->dev), csi2_ep) { + if (endpoint->local_fwnode == csi2_ep) { + struct fwnode_endpoint fwep; + int ret; + + ret = fwnode_graph_parse_endpoint(csi2_ep, &fwep); + + fwnode_handle_put(csi2_ep); + + return ret ? ret : fwep.port; + } + } + + return -ENXIO; +} + static const struct media_entity_operations csi2_entity_ops = { .link_setup = csi2_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = csi2_get_fwnode_pad, }; static const struct v4l2_subdev_video_ops csi2_video_ops = { From patchwork Tue Feb 4 23:49:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365497 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82E9B92A for ; Tue, 4 Feb 2020 23:50:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F7E021D7D for ; Tue, 4 Feb 2020 23:50:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BQoE2aYg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727773AbgBDXto (ORCPT ); Tue, 4 Feb 2020 18:49:44 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38416 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727756AbgBDXto (ORCPT ); Tue, 4 Feb 2020 18:49:44 -0500 Received: by mail-pl1-f194.google.com with SMTP id t6so70818plj.5; Tue, 04 Feb 2020 15:49:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=72xnFHPEyLcodGDkHs6BcIOyiqauoZxf30bRgRrtTFY=; b=BQoE2aYg+S0CCCMxIZ0jWCqQjys5A76hZUcTbp30Q00N3hQz77rIsJc1QBKLbNOKxn kMCBfLVe6TA1ymqnIHtkBTnC0MFWfN+vRMIBOw2I43y1qOONMBg38jk285bH9TQDXB3r X7nvHi8CO+1gZ8CFaGdVqZ4IOx3p7TDuLs7TCSYfMfjbHAai370POhJEH5ETshMV9Gic l411WnVgfKpsYjgXv+WC5rqPBSyMXbqKOD0HA7xZW3Zz9bSC26r9n4qUcgXNxshYPTel MD11HclsYCfnd1ZyofkA9YfiUcQLzSgEIqB+TXbouxYhEbl0WqvWJPKVn76ec6D/MVcX Q+rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=72xnFHPEyLcodGDkHs6BcIOyiqauoZxf30bRgRrtTFY=; b=DtgAcq6xJVF0DU/TuAlp5IWXwiWwVE+Aupl74+xhKwagb2Vtl0W260VDYb+NNTLAU3 dwpsNeZTkziRnzJzKhdGz73V2Pue1F0kun5u3rjZFGvD91UwuV/viPiTW85yHpdVUkeB tfWzYKijT5u5UmQ1x896dSotvbGe2u7Swti/5PERpJE56VfFle8VvXwnjoanrOo+mL6G 77wagXzopuJDN+f36lhjduGh4DxpOSv2qBP6l6IrylgRHxKs5v/p5/urss6dguJZ6oMu jG5JVB4UQFybvhFfHSGYOjD7PkabBxoFy+/nsXfo7hk49aY+LPt3IPb9pHhQcMYJlkgE /jmA== X-Gm-Message-State: APjAAAVhRlpPEWwOzOb8FIvzQKcbPOkz8ylt4cvwQsRVp0JhTLyWjL7O qPks3uQi9iK2S01W+T5bbe4pkFit X-Google-Smtp-Source: APXvYqx/lfvQjl0NuwmTSmHbb4rgUdlAX9w43sbHEMtjKlW115UDhnyIPhaLx4OtBJm3tPnV5HChsQ== X-Received: by 2002:a17:902:8498:: with SMTP id c24mr17839937plo.233.1580860183328; Tue, 04 Feb 2020 15:49:43 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:42 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 05/17] media: video-mux: Implement get_fwnode_pad op Date: Tue, 4 Feb 2020 15:49:06 -0800 Message-Id: <20200204234918.20425-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement get_fwnode_pad operation. If the endpoint is owned by the video mux, return the endpoint's port number. The video mux maps fwnode port numbers and pad indexes 1:1. Signed-off-by: Steve Longerbeam --- drivers/media/platform/video-mux.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index 3d2a5c2b4c08..c1c477e4e33f 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -94,9 +94,38 @@ static int video_mux_link_setup(struct media_entity *entity, return ret; } +static int video_mux_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct video_mux *vmux = v4l2_subdev_to_video_mux(sd); + struct fwnode_handle *vmux_fwnode = dev_fwnode(vmux->subdev.dev); + struct fwnode_handle *vmux_ep; + + /* + * If the endpoint is one of ours, return the endpoint's port + * number. This device maps port numbers and pad indexes 1:1. + */ + fwnode_graph_for_each_endpoint(vmux_fwnode, vmux_ep) { + if (endpoint->local_fwnode == vmux_ep) { + struct fwnode_endpoint fwep; + int ret; + + ret = fwnode_graph_parse_endpoint(vmux_ep, &fwep); + + fwnode_handle_put(vmux_ep); + + return ret ? ret : fwep.port; + } + } + + return -ENXIO; +} + static const struct media_entity_operations video_mux_ops = { .link_setup = video_mux_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = video_mux_get_fwnode_pad, }; static int video_mux_s_stream(struct v4l2_subdev *sd, int enable) From patchwork Tue Feb 4 23:49:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 715CB14D5 for ; Tue, 4 Feb 2020 23:49:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46201218AC for ; Tue, 4 Feb 2020 23:49:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BsHA+vI2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727795AbgBDXtq (ORCPT ); Tue, 4 Feb 2020 18:49:46 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41389 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727782AbgBDXtq (ORCPT ); Tue, 4 Feb 2020 18:49:46 -0500 Received: by mail-pl1-f193.google.com with SMTP id t14so64574plr.8; Tue, 04 Feb 2020 15:49:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tRajCHkCPnS+6BeYHw+Smokn34AQmfROoq0aYGtX0Dg=; b=BsHA+vI2ZteLGjqZnJ0Of6RlS4vNhQ+w6afs9J+sodW8NikHp57fK8/UikcS20eMbV teyOwGAWxRsca6kTlO2nZtNar2W3teUYUU4rwoAoRIvSQcV7oALXEC1KiyHrEzKXIHPj y5g1Ai8NgwrGrXsaHMCJ3rvxayya7vzbLlUxKtcLcrFNuvgDWNmZ1eNtnWRy13soqLxZ ZLb/nqaAcW5H7hnkswovVEgoq8nmNjMbO9Cv4fvxKo3ZhQnAnU3TduxydfunduY+zJw8 +6A2MAnCO7wSKOiPkHZtOkAo6bVOCHC6STYZkJVBZ/JFmJhxHwrMztCgfCSfBANm1UON VQ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tRajCHkCPnS+6BeYHw+Smokn34AQmfROoq0aYGtX0Dg=; b=QhuJlOpMcKCp6SPJ5BWzVHUOQqWZR5hmNBQd5aSWo2upetQFJNQ6Dsqc8VKAWDyiKs 6p7fMIhaIZztdZGlfIoCIvxOR4wTx/AUP6liNmH0fZhY1EsyqLH8AznttdLlqQSSz5iA CseykEe+/o+49JhgM4h4o3x5OeP0crnuD1ZsOIlnPZruZXAmyb5Hm1h2ShEZ0WLfejzB 7kC3y59QehS46v1j2vrCC8x3jmREv6CpxamSrFRT5o7U2z1BXBoEisJLtpsAefBsJxlm KK2ypwPgDVIfQRmvWvfENjTWFGCX5nE3mPF0fn3e0Vqj8vsxleYLOMQS13ZpELFE/zhf KNzQ== X-Gm-Message-State: APjAAAVVOpgt/t0uZ54KbzH4yxTjV74PcfMiCAHKXY0kpBMxBs5rszgq G73xyLKCfoVrdY7bsOjYJCOEydEC X-Google-Smtp-Source: APXvYqzrM3QQ7DVgguy0VR8yu/rVX99Drqh5odMVERvBRVgXqYV4JU+R9EjcQv5tHly4HXPQYo0llw== X-Received: by 2002:a17:902:5a42:: with SMTP id f2mr32286551plm.19.1580860184895; Tue, 04 Feb 2020 15:49:44 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:44 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 06/17] media: imx: Add imx_media_create_fwnode_pad_link() Date: Tue, 4 Feb 2020 15:49:07 -0800 Message-Id: <20200204234918.20425-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add functions to create media links between a source and sink subdevice based on fwnode endpoint connections between them. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-utils.c | 91 +++++++++++++++++++++ drivers/staging/media/imx/imx-media.h | 4 + 2 files changed, 95 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 0788a1874557..87152bd9af22 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -729,6 +729,97 @@ void imx_media_grp_id_to_sd_name(char *sd_name, int sz, u32 grp_id, int ipu_id) } EXPORT_SYMBOL_GPL(imx_media_grp_id_to_sd_name); +/* + * Look for and create a single fwnode link that connects a source + * subdevice to a sink pad. + */ +int imx_media_create_fwnode_pad_link(struct v4l2_subdev *src_sd, + struct media_pad *sink) +{ + struct fwnode_handle *endpoint; + + /* loop thru the source's fwnode endpoints */ + fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) { + struct fwnode_handle *remote_ep; + int src_idx, sink_idx, ret; + struct media_pad *src; + + remote_ep = fwnode_graph_get_remote_endpoint(endpoint); + if (!remote_ep) + continue; + + /* + * ask the sink entity to verify that this fwnode link + * actually does connect with the entity, and if so that + * it connects to its requested sink pad. + */ + sink_idx = media_entity_get_fwnode_pad(sink->entity, + remote_ep, + MEDIA_PAD_FL_SINK); + fwnode_handle_put(remote_ep); + + if (sink_idx < 0 || sink_idx != sink->index) + continue; + + src_idx = media_entity_get_fwnode_pad(&src_sd->entity, + endpoint, + MEDIA_PAD_FL_SOURCE); + if (src_idx < 0) + continue; + + /* + * found the fwnode link that works, create the media + * link for it. + */ + + fwnode_handle_put(endpoint); + + src = &src_sd->entity.pads[src_idx]; + + /* success if it already exists */ + if (media_entity_find_link(src, sink)) + return 0; + + dev_dbg(src_sd->dev, "%s:%d -> %s:%d\n", + src_sd->entity.name, src_idx, + sink->entity->name, sink_idx); + + ret = media_create_pad_link(&src_sd->entity, src_idx, + sink->entity, sink_idx, 0); + if (ret) + dev_err(src_sd->dev, + "%s:%d -> %s:%d failed with %d\n", + src_sd->entity.name, src_idx, + sink->entity->name, sink_idx, ret); + + return ret; + } + + return -ENXIO; +} +EXPORT_SYMBOL_GPL(imx_media_create_fwnode_pad_link); + +int imx_media_create_fwnode_pad_links(struct v4l2_subdev *src_sd, + struct v4l2_subdev *sink_sd) +{ + int i; + + for (i = 0; i < sink_sd->entity.num_pads; i++) { + struct media_pad *pad = &sink_sd->entity.pads[i]; + int ret; + + if (!(pad->flags & MEDIA_PAD_FL_SINK)) + continue; + + ret = imx_media_create_fwnode_pad_link(src_sd, pad); + if (ret) + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(imx_media_create_fwnode_pad_links); + struct v4l2_subdev * imx_media_find_subdev_by_fwnode(struct imx_media_dev *imxmd, struct fwnode_handle *fwnode) diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 11861191324a..f90a65ba4ced 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -183,6 +183,10 @@ int imx_media_ipu_image_to_mbus_fmt(struct v4l2_mbus_framefmt *mbus, struct ipu_image *image); void imx_media_grp_id_to_sd_name(char *sd_name, int sz, u32 grp_id, int ipu_id); +int imx_media_create_fwnode_pad_link(struct v4l2_subdev *src_sd, + struct media_pad *sink); +int imx_media_create_fwnode_pad_links(struct v4l2_subdev *src_sd, + struct v4l2_subdev *sink_sd); struct v4l2_subdev * imx_media_find_subdev_by_fwnode(struct imx_media_dev *imxmd, struct fwnode_handle *fwnode); From patchwork Tue Feb 4 23:49:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365495 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6951B92A for ; Tue, 4 Feb 2020 23:50:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C8DE217BA for ; Tue, 4 Feb 2020 23:50:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="je6p4Jtn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727872AbgBDXug (ORCPT ); Tue, 4 Feb 2020 18:50:36 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33351 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727756AbgBDXtr (ORCPT ); Tue, 4 Feb 2020 18:49:47 -0500 Received: by mail-pl1-f196.google.com with SMTP id ay11so80231plb.0; Tue, 04 Feb 2020 15:49:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0UeHl1Dd9diRnbI2rT7HKFn8mPPNQOcd6CGGZuCp63s=; b=je6p4JtnrsQJgU5HRv7LG/DWeA5nUeQ876l1bbDqix79BNZBL1WFwSWBcPg+eNhb+v kd9GvQghy2Q2ollGwJFeSYH6iYubc+m+ZSQSruBP+joBpdpksb6g+YgDOb6wMJEV6Fy6 h462nCEEqZgtJi5qkGQ84zqt8NIN7sUkohqvVIxFzisjlN80EE5gSm7Jz8Bp71vDl4rc EyQLT5g7xHGvLQfhqwNJsuoDaaGXCQzYK01+dSINnkgLknGHFqsrJCK6SCjo8BheX5w7 cDT4TPB+YFLrF3IkQndJfH80v8/9Gw+he8uv80EN+W6ais/+le82IYf5RX7j9yPj9O/+ wvtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0UeHl1Dd9diRnbI2rT7HKFn8mPPNQOcd6CGGZuCp63s=; b=FN/8Eokg2H1uGRuUWnXKzCMVQzt52NnT5LvWnvV1JupdGUOnY2Xnmiyrf7JJ48VkbG R6l+VZtXHDIAc2Yhj155uxIqsZywcv08DufmAr5WWfxs6aqN/GXcootgoC4kauoti0XD 3lFrxLhyjL4SqeN7QeQVzgBId/075zG+g2Isfr/HKVKSwB9Yf/LdDRGwgwZra0gkN7BI m9/lbyneSVLQ2cgmTW1uY0uqe3oFa6+O7P6LRj5yGJvOSGC0Mv6KcqWpWqo0N0fz36Hr nrnLtxneuRB2B5jqoY+snoWdwgQFjGnk12YWW/E8iYvo4nJEcEoVCmN/aL5LuJu2Yic1 uvzQ== X-Gm-Message-State: APjAAAVpzSbCeG+KCB4VS2ysQl8wiLslVM1BIpjkROz/HSKaPmcuzNqu A34rsIJcFoOxO+ThS2OszB/U3Q7M X-Google-Smtp-Source: APXvYqwE9MALBruftzHtjQib2jg9yrrMeSI1bfo5Fhf0lDaNpE4ULauWZfLkuf6FZ/FiGpO4TrbJRw== X-Received: by 2002:a17:902:b612:: with SMTP id b18mr30588327pls.318.1580860185998; Tue, 04 Feb 2020 15:49:45 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:45 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 07/17] media: video-mux: Create media links in bound notifier Date: Tue, 4 Feb 2020 15:49:08 -0800 Message-Id: <20200204234918.20425-8-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the video-mux sink pad(s). Signed-off-by: Steve Longerbeam --- Changes in v3: - this version does the work inline. The previous version called a media_create_fwnode_links() which is removed in v3. --- drivers/media/platform/video-mux.c | 92 ++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index c1c477e4e33f..a6b09a79fbe3 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -36,6 +36,12 @@ static const struct v4l2_mbus_framefmt video_mux_format_mbus_default = { .field = V4L2_FIELD_NONE, }; +static inline struct video_mux * +notifier_to_video_mux(struct v4l2_async_notifier *n) +{ + return container_of(n, struct video_mux, notifier); +} + static inline struct video_mux *v4l2_subdev_to_video_mux(struct v4l2_subdev *sd) { return container_of(sd, struct video_mux, subdev); @@ -372,6 +378,90 @@ static int video_mux_parse_endpoint(struct device *dev, return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN; } +static int video_mux_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct video_mux *vmux = notifier_to_video_mux(notifier); + struct fwnode_handle *vmux_fwnode = dev_fwnode(vmux->subdev.dev); + struct fwnode_handle *sd_fwnode = dev_fwnode(sd->dev); + struct fwnode_handle *vmux_ep; + + fwnode_graph_for_each_endpoint(vmux_fwnode, vmux_ep) { + struct fwnode_handle *remote_ep, *sd_ep; + struct media_pad *src_pad, *sink_pad; + struct fwnode_endpoint fwep; + int src_idx, sink_idx, ret; + bool remote_ep_belongs; + + ret = fwnode_graph_parse_endpoint(vmux_ep, &fwep); + if (ret) + continue; + + /* only create links to the vmux sink pads */ + if (fwep.port >= vmux->subdev.entity.num_pads - 1) + continue; + + sink_idx = fwep.port; + sink_pad = &vmux->subdev.entity.pads[sink_idx]; + + remote_ep = fwnode_graph_get_remote_endpoint(vmux_ep); + if (!remote_ep) + continue; + + /* + * verify that this remote endpoint is owned by the + * sd, in case the sd does not check for that in its + * .get_fwnode_pad operation or does not implement it. + */ + remote_ep_belongs = false; + fwnode_graph_for_each_endpoint(sd_fwnode, sd_ep) { + if (sd_ep == remote_ep) { + remote_ep_belongs = true; + fwnode_handle_put(sd_ep); + break; + } + } + if (!remote_ep_belongs) + continue; + + src_idx = media_entity_get_fwnode_pad(&sd->entity, remote_ep, + MEDIA_PAD_FL_SOURCE); + fwnode_handle_put(remote_ep); + + if (src_idx < 0) + continue; + + src_pad = &sd->entity.pads[src_idx]; + + /* skip this link if it already exists */ + if (media_entity_find_link(src_pad, sink_pad)) + continue; + + ret = media_create_pad_link(&sd->entity, src_idx, + &vmux->subdev.entity, + sink_idx, 0); + if (ret) { + dev_err(vmux->subdev.dev, + "%s:%d -> %s:%d failed with %d\n", + sd->entity.name, src_idx, + vmux->subdev.entity.name, sink_idx, ret); + fwnode_handle_put(vmux_ep); + return ret; + } + + dev_dbg(vmux->subdev.dev, "%s:%d -> %s:%d\n", + sd->entity.name, src_idx, + vmux->subdev.entity.name, sink_idx); + } + + return 0; +} + +static const struct v4l2_async_notifier_operations video_mux_notify_ops = { + .bound = video_mux_notify_bound, +}; + static int video_mux_async_register(struct video_mux *vmux, unsigned int num_input_pads) { @@ -386,6 +476,8 @@ static int video_mux_async_register(struct video_mux *vmux, v4l2_async_notifier_init(&vmux->notifier); + vmux->notifier.ops = &video_mux_notify_ops; + ret = v4l2_async_register_fwnode_subdev( &vmux->subdev, &vmux->notifier, sizeof(struct v4l2_async_subdev), From patchwork Tue Feb 4 23:49:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365489 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BADAB14D5 for ; Tue, 4 Feb 2020 23:50:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 983E121744 for ; Tue, 4 Feb 2020 23:50:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Le9ycugO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727812AbgBDXtt (ORCPT ); Tue, 4 Feb 2020 18:49:49 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36119 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727804AbgBDXts (ORCPT ); Tue, 4 Feb 2020 18:49:48 -0500 Received: by mail-pl1-f193.google.com with SMTP id a6so74016plm.3; Tue, 04 Feb 2020 15:49:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j/2evpY7A0C04k+gk98K37iMCYdFmql/BmRTWB1csrg=; b=Le9ycugOfEEybykcT8+miCmVKrq1TITIUOBemZS+jQOP3orUFyi38fSpfiRSq1UyOB pf3wQI/DtHAfBlQpH/0VDZOe5UYWreuBz1Y/+MDCTgy6j66TIQr3MN4Vd0IB2qDRjGZi xAxZ/tExX08f3od/rBpZ1SHFML1yWq540pS4Wd8rvs6xrUurW1w2xy563mxmtgM7JPaV cq/cE4uhXMt7XyQ+SlAz9gA1yvX9f3sPhyUww6iz2tGkwvHyr3soulGOUCbbjfJhPJAZ ZNZlnK9SPDu6AXDVtKSgFlxbWa5feYE4EvPIKzlb1aDS98rtw7a3cMC1XvRijjJAF7hr eZMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j/2evpY7A0C04k+gk98K37iMCYdFmql/BmRTWB1csrg=; b=g4aP3lWaPgtjkWDiSuirAr5qkz+/VaKA8q2HDLPeqiGJldLZjylEfN1CAh/Bke80EZ kgzgEnqigY3YuKQobII46vzOZLwjreo6yqvxm5slTj+oeL2DDAZEJNHNpbQCZrTf5xdk MTO+xINt5ZCuHpb7v+wn2DWnGNv+UP08OKiKgwrNvDvBQjupb0K05T7+r8jbveXfvE6V cRDxwp2JDcQdggPB7p8cyIbclPMui6Sat5VRWkLXqCv2fJpVg/1dW2xNeYDxErJa0xNb wkQeOg+HtwaZcKeP2JYp2VfWHvk6r84y8yXpRM43k63gLv9yTihOuP/2QfDNnKwFoZgb R3sg== X-Gm-Message-State: APjAAAXXYU+G7W6OVUVp0/olnhG/zZqkgcLzCvTVP2o1dw9JKPXs9BS3 vBIfbxPIzfIFT8Ea7IcbfKqN50H1 X-Google-Smtp-Source: APXvYqzd5F1QfdHZ4Puy966CryZKh3FhnnA+0FjfKGt35fUDUUvC8HOzxic58qwpCy2MTsi8+gEBzA== X-Received: by 2002:a17:90a:cc02:: with SMTP id b2mr1960199pju.137.1580860187663; Tue, 04 Feb 2020 15:49:47 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:47 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 08/17] media: imx: mipi csi-2: Create media links in bound notifier Date: Tue, 4 Feb 2020 15:49:09 -0800 Message-Id: <20200204234918.20425-9-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the mipi csi-2 receiver sink pad. Signed-off-by: Steve Longerbeam --- Changes in v3: - call a local imx-media utility imx_media_create_fwnode_pad_link() that creates a single link. --- drivers/staging/media/imx/imx6-mipi-csi2.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index e27a342751fc..fddf6388348a 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -91,6 +91,11 @@ static inline struct csi2_dev *sd_to_dev(struct v4l2_subdev *sdev) return container_of(sdev, struct csi2_dev, sd); } +static inline struct csi2_dev *notifier_to_dev(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi2_dev, notifier); +} + /* * The required sequence of MIPI CSI-2 startup as specified in the i.MX6 * reference manual is as follows: @@ -584,6 +589,20 @@ static int csi2_parse_endpoint(struct device *dev, return 0; } +static int csi2_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi2_dev *csi2 = notifier_to_dev(notifier); + struct media_pad *sink = &csi2->sd.entity.pads[CSI2_SINK_PAD]; + + return imx_media_create_fwnode_pad_link(sd, sink); +} + +static const struct v4l2_async_notifier_operations csi2_notify_ops = { + .bound = csi2_notify_bound, +}; + static int csi2_probe(struct platform_device *pdev) { unsigned int sink_port = 0; @@ -667,6 +686,8 @@ static int csi2_probe(struct platform_device *pdev) v4l2_async_notifier_init(&csi2->notifier); + csi2->notifier.ops = &csi2_notify_ops; + ret = v4l2_async_register_fwnode_subdev( &csi2->sd, &csi2->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, csi2_parse_endpoint); From patchwork Tue Feb 4 23:49:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365493 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0AC792A for ; Tue, 4 Feb 2020 23:50:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D32E21744 for ; Tue, 4 Feb 2020 23:50:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N6krExxw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727973AbgBDXu3 (ORCPT ); Tue, 4 Feb 2020 18:50:29 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43803 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727810AbgBDXtu (ORCPT ); Tue, 4 Feb 2020 18:49:50 -0500 Received: by mail-pl1-f193.google.com with SMTP id p11so60646plq.10; Tue, 04 Feb 2020 15:49:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h5BHRotCYsy0a67S2KVH1ySLbRo1QXYTOC5G0a45OSw=; b=N6krExxw+iDOgtznqR14UzAobO+11LQwTqSIFnq01ZN+/cRryxOKZiPH6j258N7gnB XksOmfuX4/M+r1Ju1OKEH2S4W9cd5roKe4PJNDc5alJYXDpC9qE2xA4J38T135DvnfXl mmHfMcfbwroPCc5Lbd/vDm3uVA6hNtr4ZPTOOy8MhbKLeN/FcWNVvVktChc3ohX2InZ3 sSOOFVcIHGII58Flo8fj2sVSutv4X2heuk3jRs7L3k/wyMHyrFSHcFGqc1HSSqEuLJ+3 trYC8ZZpAuwpjNkWf31EakOElMLkmv6dZuI9Ly2ya1nNwOSMj40SKlBPa8lzkymc+aQD M+wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h5BHRotCYsy0a67S2KVH1ySLbRo1QXYTOC5G0a45OSw=; b=BSX+Ably089jeMuFXxX/UZPAeBf2+Ce1S2JsCmSuFTx/AThVKGQDue+vIKpVN6cD8Z dQewFSieEgKfMemUKyutJM7DyfjScMH2PfoizGBoKGGz1FEPjNlkt+a3An0Tqodzyhjk xWWJ7OeCsCUHG2R2mPzXREQ785NGCLmlzO5abavgYtJl6uSbv56y+iNnFsVxWDP7iQfx ibbDzXvgzVUqryTtgdWHDMSHutIKJIhKiaUI+0yPWKa5sJ+l0Klf1v4tJ3Ydq+D8t2F3 FYiIGgCVx6UfGxs257FYt2tDE/VpUguDRL0dUvTgfhQGlTyJn9YMJL2DFgT5sOtXI4ox kBjA== X-Gm-Message-State: APjAAAXsi/mB4FNkCP2J3MH+QS4eTyWTSRf1xGZDWAHYbzpcra1dB7bM D+27rUEyDq/eXImdcsDYGUUweQsw X-Google-Smtp-Source: APXvYqysNJ3RiWVPT9jFpzVjeZWRqmiw1QVTywJOVhIiqMr4BgmIi5yBgbIXD7yptVHG0IAPw4XeBA== X-Received: by 2002:a17:90a:c301:: with SMTP id g1mr2085955pjt.88.1580860189106; Tue, 04 Feb 2020 15:49:49 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:48 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 09/17] media: imx7-mipi-csis: Create media links in bound notifier Date: Tue, 4 Feb 2020 15:49:10 -0800 Message-Id: <20200204234918.20425-10-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the mipi csi-2 receiver sink pad. Signed-off-by: Steve Longerbeam --- Changes in v3: - call a local imx-media utility imx_media_create_fwnode_pad_link(). Changes in v2: - Move notifier_to_csis_state() next to mipi_sd_to_csis_state(), remove unnecessary inline, and rename to mipi_notifier_to_csis_state(). Suggested by Rui Silva. --- drivers/staging/media/imx/imx7-mipi-csis.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index 4c54456318ea..d3a83577efed 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -317,6 +317,12 @@ static int mipi_csis_dump_regs(struct csi_state *state) return 0; } +static struct csi_state * +mipi_notifier_to_csis_state(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi_state, notifier); +} + static struct csi_state *mipi_sd_to_csis_state(struct v4l2_subdev *sdev) { return container_of(sdev, struct csi_state, mipi_sd); @@ -848,6 +854,20 @@ static int mipi_csis_parse_endpoint(struct device *dev, return 0; } +static int mipi_csis_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi_state *state = mipi_notifier_to_csis_state(notifier); + struct media_pad *sink = &state->mipi_sd.entity.pads[CSIS_PAD_SINK]; + + return imx_media_create_fwnode_pad_link(sd, sink); +} + +static const struct v4l2_async_notifier_operations mipi_csis_notify_ops = { + .bound = mipi_csis_notify_bound, +}; + static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, struct platform_device *pdev, const struct v4l2_subdev_ops *ops) @@ -886,6 +906,8 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, v4l2_async_notifier_init(&state->notifier); + state->notifier.ops = &mipi_csis_notify_ops; + ret = v4l2_async_register_fwnode_subdev(mipi_sd, &state->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, From patchwork Tue Feb 4 23:49:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365471 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E79AD17E0 for ; Tue, 4 Feb 2020 23:49:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C65B0217F4 for ; Tue, 4 Feb 2020 23:49:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="clTHQOua" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727832AbgBDXtv (ORCPT ); Tue, 4 Feb 2020 18:49:51 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:37495 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727824AbgBDXtv (ORCPT ); Tue, 4 Feb 2020 18:49:51 -0500 Received: by mail-pl1-f194.google.com with SMTP id c23so72577plz.4; Tue, 04 Feb 2020 15:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ha1G3XO6Vb76DqwKYHrBrsy5rfHEKdgMuf1qeb5yKus=; b=clTHQOua5ugicz9SFwYMbXH1AC4U17gwJLFJXrYA19wFEZDaqG55wLKVpjnmar9k2w l2EduYB1bF7nKZUnVZV4SL1XhMKpPrwfuWJtzUexjbwcMPkP06YmdQWipoSiSsjtufK5 rgaGo7AUYzb2+4Qh6EGgxdlgr9KADsuDZ1sxa7zQJoEf7p9dDCDmDep8tihLj5RkgiSF 9YTTW61j1iz/Si2iudelXlgRkCGFPAwoctMg1+MCoaKLnqqajhrFYD8kmNds5jBUGCVu tyfV9t15GS18zC8XrBF98Wk+AH/PndxU40jgsCWpq2p9DW+uvMHlRAiUSJcmmB5pp2To 8mgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ha1G3XO6Vb76DqwKYHrBrsy5rfHEKdgMuf1qeb5yKus=; b=Z15KGRP9P/wdhaLLDqBbeoWSN5DrZBhyPdhB7dJ1H8s5kNTHXAW7LxkD0aikkJCT73 NqYetxrtdcuep9rPkLrS0DkvXrk51NcxN/KAJRcz71YGYYccmUHJC15Yhasn10tkKwDw sTczegtVIPL+/LJ7Qq5Vsnvt0EIxBTkCU/K2wTX1LYXCxUNJgE7cu5X6n3ZQbBixPgZu GekXMmMd3aGskNRPY2e3n0nv00N200j6kQvOR/3A+J6Hv+kbvkSyVDSCmN+nr+l86uIH JdqVGzvB3lj/tcutbdjzgK83xq9JRbcVDt/qKqcEiZAQegmdkVHqOj+r4WUFbXn5lse7 o1YA== X-Gm-Message-State: APjAAAVdIG7s7Gs+pAmV5BVLpL4Js+PO1D/u0TxcaUjgXBPjWiTFLFTS 3cP+//V5zeHTd31TLq4WlJqSmHvM X-Google-Smtp-Source: APXvYqwyLzleegvKCr9D4YaahTk1C9/W40AyYBCK/ry/o6dQcN67cWcYH3Eh8r0Gqgv52nHZiPiPWQ== X-Received: by 2002:a17:90a:c691:: with SMTP id n17mr2098311pjt.41.1580860190466; Tue, 04 Feb 2020 15:49:50 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:50 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 10/17] media: imx7-media-csi: Create media links in bound notifier Date: Tue, 4 Feb 2020 15:49:11 -0800 Message-Id: <20200204234918.20425-11-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the CSI sink pad. Signed-off-by: Steve Longerbeam Reviewed-by: Rui Miguel Silva --- Changes in v3: - call a local imx-media utility imx_media_create_fwnode_pad_link(). Changes in v2: - Rename notifier_to_dev() to imx7_csi_notifier_to_dev() and remove unnecessary inline. Suggested by Rui Silva. --- drivers/staging/media/imx/imx7-media-csi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index dc6d1a28fde7..cf9f675c53a3 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -196,6 +196,12 @@ struct imx7_csi { struct completion last_eof_completion; }; +static struct imx7_csi * +imx7_csi_notifier_to_dev(struct v4l2_async_notifier *n) +{ + return container_of(n, struct imx7_csi, notifier); +} + static u32 imx7_csi_reg_read(struct imx7_csi *csi, unsigned int offset) { return readl(csi->regbase + offset); @@ -1187,6 +1193,20 @@ static int imx7_csi_parse_endpoint(struct device *dev, return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL; } +static int imx7_csi_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct imx7_csi *csi = imx7_csi_notifier_to_dev(notifier); + struct media_pad *sink = &csi->sd.entity.pads[IMX7_CSI_PAD_SINK]; + + return imx_media_create_fwnode_pad_link(sd, sink); +} + +static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = { + .bound = imx7_csi_notify_bound, +}; + static int imx7_csi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1269,6 +1289,8 @@ static int imx7_csi_probe(struct platform_device *pdev) v4l2_async_notifier_init(&csi->notifier); + csi->notifier.ops = &imx7_csi_notify_ops; + ret = v4l2_async_register_fwnode_subdev(&csi->sd, &csi->notifier, sizeof(struct v4l2_async_subdev), NULL, 0, From patchwork Tue Feb 4 23:49:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF76314D5 for ; Tue, 4 Feb 2020 23:49:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE9DD218AC for ; Tue, 4 Feb 2020 23:49:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Yy9WKoJx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727846AbgBDXtx (ORCPT ); Tue, 4 Feb 2020 18:49:53 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:56102 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbgBDXtw (ORCPT ); Tue, 4 Feb 2020 18:49:52 -0500 Received: by mail-pj1-f66.google.com with SMTP id d5so126503pjz.5; Tue, 04 Feb 2020 15:49:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nw6qFQx6S/L6ma/0AlsKxKIDrQ4PZDVJaM1fr3Im7gQ=; b=Yy9WKoJxny1WM1LTJAaHQp4AkTgd8LBI0xpYLY6Fn0oeSdfohwks8vumgGn8JP3Yj2 +4hupFpmWJDqwsNDq4eQ/VCgwhYYJ6i2pr9H4QplI4Vw+QZKC09SCn5y7RB/PCD1ZVRG HXxnXpugQb3SFC8tfPrvcpwAnA8MLwgyuTp2Q1BdAfs7cAMfi2Jaowa0b9KSsECDGBjM Sya0BgFaa2vQEGhDhOjJoJ46panfmfwJgvYIjywdBpcZ18pznnsWs8zxyBSctFs0YgbM VovFpV/24b5dlIzNkjlJ0OkQc21k4vS6607CXahqymGABgwBU8pvIKVpBnIHLBVikYJW vHyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nw6qFQx6S/L6ma/0AlsKxKIDrQ4PZDVJaM1fr3Im7gQ=; b=B8wepfbGp3F3rAEFK/8RtfWDl3q1Pwzr9fDuXUJdCYC7QoXuGb+oH8+5l0iLb8OJJz 2L69k1+Yh+HGiPT+hz1o8fGkAKP2b3XRGEyR4mN5pMbwi36QVclntfAzM+WvQq45721G dvDhV3oPzeur2KcN5Yl89XI8u1qdZbPEWUm43T41BS29LGy0Oo0ppbRYxAaBl2k8V0RK QUQzCqYUvVz3QqCL3SgErGtAQiVlqCCOMSbo8g0ZbbNnEBpVQh08vKt02c3ZblE48X28 QVR/QCSjMx+XOXfotkLIYTgbwnPBn13u4nr+cq7ykL87LwTKkw2yj0VKEmIHzcLd9ylw MMxA== X-Gm-Message-State: APjAAAXnZ+O6eJppTfOhmFjbzRU6L7BUcWLUv9n1scvomZjMX6Q8F/DM eqeetTtxGS5LqtREKem7athvMuZs X-Google-Smtp-Source: APXvYqzubusBvsBD9wy7XWJhiFY4WOQKzM1XZxKRj5dG2YKTAV1RksFDtvGAJxFrohKb/059exTxcw== X-Received: by 2002:a17:902:8549:: with SMTP id d9mr31416618plo.153.1580860191823; Tue, 04 Feb 2020 15:49:51 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:51 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 11/17] media: imx: csi: Embed notifier in struct csi_priv Date: Tue, 4 Feb 2020 15:49:12 -0800 Message-Id: <20200204234918.20425-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Embed the notifier in 'struct csi_priv', instead of dynamically allocating it, to make it possible to retrieve csi_priv in a notifier callback op. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 25 +++++++++-------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index dc5fe25fe7b8..3e2afdd59276 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -58,6 +58,8 @@ struct csi_priv { struct ipu_soc *ipu; struct v4l2_subdev sd; struct media_pad pad[CSI_NUM_PADS]; + struct v4l2_async_notifier notifier; + /* the video device at IDMAC output pad */ struct imx_media_video_dev *vdev; struct imx_media_fim *fim; @@ -1896,31 +1898,28 @@ static int imx_csi_parse_endpoint(struct device *dev, static int imx_csi_async_register(struct csi_priv *priv) { - struct v4l2_async_notifier *notifier; struct fwnode_handle *fwnode; unsigned int port; int ret; - notifier = kzalloc(sizeof(*notifier), GFP_KERNEL); - if (!notifier) - return -ENOMEM; - - v4l2_async_notifier_init(notifier); + v4l2_async_notifier_init(&priv->notifier); fwnode = dev_fwnode(priv->dev); /* get this CSI's port id */ ret = fwnode_property_read_u32(fwnode, "reg", &port); if (ret < 0) - goto out_free; + return ret; ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port( - priv->dev->parent, notifier, sizeof(struct v4l2_async_subdev), + priv->dev->parent, &priv->notifier, + sizeof(struct v4l2_async_subdev), port, imx_csi_parse_endpoint); if (ret < 0) goto out_cleanup; - ret = v4l2_async_subdev_notifier_register(&priv->sd, notifier); + ret = v4l2_async_subdev_notifier_register(&priv->sd, + &priv->notifier); if (ret < 0) goto out_cleanup; @@ -1928,16 +1927,12 @@ static int imx_csi_async_register(struct csi_priv *priv) if (ret < 0) goto out_unregister; - priv->sd.subdev_notifier = notifier; - return 0; out_unregister: - v4l2_async_notifier_unregister(notifier); + v4l2_async_notifier_unregister(&priv->notifier); out_cleanup: - v4l2_async_notifier_cleanup(notifier); -out_free: - kfree(notifier); + v4l2_async_notifier_cleanup(&priv->notifier); return ret; } From patchwork Tue Feb 4 23:49:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF6C214D5 for ; Tue, 4 Feb 2020 23:49:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9ECE8218AC for ; Tue, 4 Feb 2020 23:49:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mNmZy7R7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727860AbgBDXty (ORCPT ); Tue, 4 Feb 2020 18:49:54 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35291 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727850AbgBDXty (ORCPT ); Tue, 4 Feb 2020 18:49:54 -0500 Received: by mail-pg1-f194.google.com with SMTP id l24so10628pgk.2; Tue, 04 Feb 2020 15:49:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WaBGbAVLvbw1Oa8PBijA4rVNFNBvvrFDnIgEYRds3L8=; b=mNmZy7R7sQunr/esl0X7WuD/YOJo3oXWxaM/3fWtqDaXMU3tA9oX7QpNB7L4WidlZN +0FhiBowT1jvElbnHRqgGrwPJslvNHKFlOxLIYgVKADNM/DLj9EVLyJKAxRSkrN2eoVX +VHxwPTpyQ3sxjsa7GNJp69XguyefpuqpxO9o1JVFfdKdevURPuboIluRlx+LVz6tOvw 1gJrULMLL3f0l435h35yYSu9MMc0rDFcWgCx1W+bs8Vn2JXjhCVn3Kyt4guYO1WDMl07 t6NUmqBpb1HOS8/HzuYODmWSMGIX0dReYtzHzhC8qOSWtTAemf0mNu2uistyoFL6widC RXOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WaBGbAVLvbw1Oa8PBijA4rVNFNBvvrFDnIgEYRds3L8=; b=DBoP00jIi05wV4IF/TVLM69XmHIgc64rbhVM2HOsfzXodI/PRzUB8QUiEdTno/64Uj MTw/J2xRIvQL5f2Uwkc0JHFnu7F8Scl8PcGqNAigpJuJAnmj4HcoKJlnHgw2fagcT8nH HGHhf4CbNlL0lUWI8Sbi5E2iS5UetcNOauTqZrR5SQjrMz2UlUEodxNksQuV32wSuIEk +L4HPxt9cjurPulh2SPQXRYKAVhbF3TaqA12nab7RWk7ooteZugyOHwcau7nI+S8DuEq EPK9FtTKgp2t+lYszvS5Z/qWh+k72TLNU4yDVl7cVPOSVlHLjoqsAiesqdj7vNfdkHFr NgPQ== X-Gm-Message-State: APjAAAW1GU6aE+1io9o8Z7o0Jmk+7Wv7RpflIfePiQlWiwg10MdGdcdR 78b7DAqs/l5qEtQv3skRWYfQlEwS X-Google-Smtp-Source: APXvYqygTNtxMuKauV7T3oKQAYlxYOiFZwSb0Z9tzIiXotDDLSjz0Ow+4RbPSU47FigltJmiEujr5Q== X-Received: by 2002:a62:878a:: with SMTP id i132mr23451540pfe.8.1580860193128; Tue, 04 Feb 2020 15:49:53 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:52 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sakari Ailus , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 12/17] media: imx: csi: Add missing notifier unregister/cleanup Date: Tue, 4 Feb 2020 15:49:13 -0800 Message-Id: <20200204234918.20425-13-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add the missing calls to unregister and cleanup the subdev notifier in imx_csi_remove(). Fixes: c893500a16baf ("media: imx: csi: Register a subdev notifier") Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 3e2afdd59276..bea6a70cc353 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -2030,6 +2030,8 @@ static int imx_csi_remove(struct platform_device *pdev) v4l2_ctrl_handler_free(&priv->ctrl_hdlr); mutex_destroy(&priv->lock); + v4l2_async_notifier_unregister(&priv->notifier); + v4l2_async_notifier_cleanup(&priv->notifier); v4l2_async_unregister_subdev(sd); media_entity_cleanup(&sd->entity); From patchwork Tue Feb 4 23:49:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E826492A for ; Tue, 4 Feb 2020 23:49:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C5E24217F4 for ; Tue, 4 Feb 2020 23:49:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iLQH3OQ/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727872AbgBDXt4 (ORCPT ); Tue, 4 Feb 2020 18:49:56 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45341 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727861AbgBDXtz (ORCPT ); Tue, 4 Feb 2020 18:49:55 -0500 Received: by mail-pf1-f196.google.com with SMTP id 2so157805pfg.12; Tue, 04 Feb 2020 15:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J4a12SBTuMD7atLLATUCugE0dEUcvKzeYrZ9OjbRkuY=; b=iLQH3OQ/O/+RY2/knhPODGNM2ct4fcN0lZHWtdgDvI2We0LfUzXOKX2vqsi1rMDnBB 0AGtySTTUvyreBqOa9GXwj6JmkE/8/4IpJ6keZb7o9GBZ6wTE5ycCUgUDkY8xwmsCVXk 6RDR6faOd47TPhAdkgtuqahcRO3Fpz60TZTshVxVocsPQLNnIpVKiVk6pfb4ZcS67lhl Ex/1P5MByc6QhtVDhEzobTJ02ls08pPmY+FbOZumQ2xki8iWuXe71Lwl7EA9MBtL+eQ8 qkVviCdflEt6ISteRSFbSoYbMllJGASrJr6ZZrVN6Cjgiam9C+ueat/yYvuBHYzSkZRj t5Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=J4a12SBTuMD7atLLATUCugE0dEUcvKzeYrZ9OjbRkuY=; b=oL7/QMnMu6CkVVtFNZcqYtkLq5NeUsUQThJZ1gDyOne6nwLfYf1GzDGQT9tu/OBpCz ub0ukruI3vZIy8Ktz/A1npkLr5+U3vYkfdw96Wl2wPcXk0DhqcOejdjTeuRAvUcnDiVw gN/ovjPrAYLCgKKAg3Td6SaiLNkzb4OEThtBdFGIHLqf8uQ8AlcXHy+mWUqHr+11sHDP +X2tQBPVqswhtUY0bjQf56sLF6lPPC2RmUzz8JsPWYucCBHN39Zb7vTR5Fwhh/TMUadh 7TsEkvXJcDs7rSSeQ23ld3UxgvrRMdoLTUAbf2GdvwSfEYb18OHW9yi2MxAxLi9x7VyZ CkFg== X-Gm-Message-State: APjAAAX0OFYrwZcbG6zi5xvXHK3nlCdrhuUh4Zq30Ek3zjnH0EE240bl YGXzPhCvmLhzrxY9ELwwx9Ikie23 X-Google-Smtp-Source: APXvYqzaJhAf6Pam+Cmnn2otTi81LaNdN5atab+90zvh137fxqERYqBVQ5oubpzGkJCsB0HBp4QJsw== X-Received: by 2002:aa7:96b6:: with SMTP id g22mr21060221pfk.206.1580860194433; Tue, 04 Feb 2020 15:49:54 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:54 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 13/17] media: imx: csi: Create media links in bound notifier Date: Tue, 4 Feb 2020 15:49:14 -0800 Message-Id: <20200204234918.20425-14-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the CSI sink pad. Signed-off-by: Steve Longerbeam --- Changes in v3: - call a local imx-media utility imx_media_create_fwnode_pad_link(). --- drivers/staging/media/imx/imx-media-csi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index bea6a70cc353..2a8f01375f78 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -120,6 +120,11 @@ static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev) return container_of(sdev, struct csi_priv, sd); } +static inline struct csi_priv *notifier_to_dev(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi_priv, notifier); +} + static inline bool is_parallel_bus(struct v4l2_fwnode_endpoint *ep) { return ep->bus_type != V4L2_MBUS_CSI2_DPHY; @@ -1896,6 +1901,20 @@ static int imx_csi_parse_endpoint(struct device *dev, return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN; } +static int imx_csi_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi_priv *priv = notifier_to_dev(notifier); + struct media_pad *sink = &priv->sd.entity.pads[CSI_SINK_PAD]; + + return imx_media_create_fwnode_pad_link(sd, sink); +} + +static const struct v4l2_async_notifier_operations csi_notify_ops = { + .bound = imx_csi_notify_bound, +}; + static int imx_csi_async_register(struct csi_priv *priv) { struct fwnode_handle *fwnode; @@ -1904,6 +1923,8 @@ static int imx_csi_async_register(struct csi_priv *priv) v4l2_async_notifier_init(&priv->notifier); + priv->notifier.ops = &csi_notify_ops; + fwnode = dev_fwnode(priv->dev); /* get this CSI's port id */ From patchwork Tue Feb 4 23:49:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365481 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E514D17E0 for ; Tue, 4 Feb 2020 23:49:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9C12217F4 for ; Tue, 4 Feb 2020 23:49:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UxqEcdYl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727885AbgBDXt5 (ORCPT ); Tue, 4 Feb 2020 18:49:57 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:37008 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727879AbgBDXt4 (ORCPT ); Tue, 4 Feb 2020 18:49:56 -0500 Received: by mail-pj1-f68.google.com with SMTP id m13so135025pjb.2; Tue, 04 Feb 2020 15:49:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rpOa6ZNketVlDD1fVg7Q22Hn4Eag+44bEMCsUONO9O8=; b=UxqEcdYlJVeiHHA12YO9pv3ytQQjQmKhJKQwvY3u3wtdIi5J1xEzSIKs039PNCLNTs HmI/0knX5WGDR8jOMi8vaWcH35JMcrHTvP0RoEzLBzXdsbyOySHAHDI0pQvGQrzH8Ajz kOINuEu576sx5HHFZsg6lMNj9VGm6tERhutEFTc6tz/QbwSjrekWu9vcjurAnIyy8uk2 2t3U3ltcTFpIrYb28vpiW31WuVPdzK9QJDFPnP3sRTt/WH26imKquOydcGYZKImSipCW 4WmlrOPCtqC5OywrC8rKvDn566cWP7JEE18ZWeg4SvA81SmlsXyfs2Y++lElrnzK56Ty OOaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rpOa6ZNketVlDD1fVg7Q22Hn4Eag+44bEMCsUONO9O8=; b=bq+K24dTFoM9q9o1UbGfWZlNQxeZlJ5w3am3TCiTQtiqHgG4LfLpVtUKIqDbt8vH9M Ef+QRMY9Z0gN8XusiHhGSirparj5Y4uNrxOtCfVrCmeNCBYS2xxb+UsNk4Nm7k9ltHYh MIPDCefPmlla7lxg0MCiKq9KyZrwx/CG2FKfu3uo5nCQDq4m/bN6+xk42faRqotWl3/l YQMljckmuHmhqwVaUdHFHoO5pv2ALlTus8FwRvr6SFnmzTlxysss6N6EOWj9aw6rV2g7 +JBPZD+JWtSP0rAyMyxIqD6O/WVxU3yTfeDBjN1bhkFE4F/hJYENPokiqkqAuZTT41y1 zohQ== X-Gm-Message-State: APjAAAWkncEOOLpy0yK8umK4cf4hvEqSToFY8oYBXfNU4OGs5MSIv4bE yR092KEhPDaHt6ozwnPkePBY5EEK X-Google-Smtp-Source: APXvYqyKFPfgvCRH/r+BzE/EtyTVGNDz9ilLfiMxWPls1ZrZOCZfuEATKaYXPq63e90SYO8U2P+Ewg== X-Received: by 2002:a17:902:8a88:: with SMTP id p8mr31573263plo.179.1580860195925; Tue, 04 Feb 2020 15:49:55 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:55 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 14/17] media: imx: csi: Lookup upstream endpoint with imx_media_get_pad_fwnode Date: Tue, 4 Feb 2020 15:49:15 -0800 Message-Id: <20200204234918.20425-15-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fix the 1:1 port-id:pad-index assumption for the upstream subdevice, by searching the upstream subdevice's endpoints for one that maps to the pad's index. This is carried out by a new reverse mapping function imx_media_get_pad_fwnode(). Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 22 ++++---------- drivers/staging/media/imx/imx-media-utils.c | 33 +++++++++++++++++++++ drivers/staging/media/imx/imx-media.h | 1 + drivers/staging/media/imx/imx7-media-csi.c | 25 +++++----------- 4 files changed, 47 insertions(+), 34 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 2a8f01375f78..7d4c1c9640dd 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -164,7 +164,7 @@ static inline bool requires_passthrough(struct v4l2_fwnode_endpoint *ep, static int csi_get_upstream_endpoint(struct csi_priv *priv, struct v4l2_fwnode_endpoint *ep) { - struct device_node *endpoint, *port; + struct fwnode_handle *endpoint; struct media_entity *src; struct v4l2_subdev *sd; struct media_pad *pad; @@ -203,23 +203,13 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv, if (!pad) return -ENODEV; - sd = media_entity_to_v4l2_subdev(pad->entity); + endpoint = imx_media_get_pad_fwnode(pad); + if (IS_ERR(endpoint)) + return PTR_ERR(endpoint); - /* - * NOTE: this assumes an OF-graph port id is the same as a - * media pad index. - */ - port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); - if (!port) - return -ENODEV; - - endpoint = of_get_next_child(port, NULL); - of_node_put(port); - if (!endpoint) - return -ENODEV; + v4l2_fwnode_endpoint_parse(endpoint, ep); - v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); - of_node_put(endpoint); + fwnode_handle_put(endpoint); return 0; } diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 87152bd9af22..61752c6b074d 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -1007,6 +1007,39 @@ imx_media_pipeline_video_device(struct media_entity *start_entity, } EXPORT_SYMBOL_GPL(imx_media_pipeline_video_device); +/* + * Find a fwnode endpoint that maps to the given subdevice's pad. + * If there are multiple endpoints that map to the pad, only the + * first endpoint encountered is returned. + * + * On success the refcount of the returned fwnode endpoint is + * incremented. + */ +struct fwnode_handle *imx_media_get_pad_fwnode(struct media_pad *pad) +{ + struct fwnode_handle *endpoint; + struct v4l2_subdev *sd; + + if (!is_media_entity_v4l2_subdev(pad->entity)) + return ERR_PTR(-ENODEV); + + sd = media_entity_to_v4l2_subdev(pad->entity); + + fwnode_graph_for_each_endpoint(dev_fwnode(sd->dev), endpoint) { + int pad_idx = media_entity_get_fwnode_pad(&sd->entity, + endpoint, + pad->flags); + if (pad_idx < 0) + continue; + + if (pad_idx == pad->index) + return endpoint; + } + + return ERR_PTR(-ENODEV); +} +EXPORT_SYMBOL_GPL(imx_media_get_pad_fwnode); + /* * Turn current pipeline streaming on/off starting from entity. */ diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index f90a65ba4ced..5f23d852122f 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -205,6 +205,7 @@ imx_media_pipeline_subdev(struct media_entity *start_entity, u32 grp_id, struct video_device * imx_media_pipeline_video_device(struct media_entity *start_entity, enum v4l2_buf_type buftype, bool upstream); +struct fwnode_handle *imx_media_get_pad_fwnode(struct media_pad *pad); struct imx_media_dma_buf { void *virt; diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index cf9f675c53a3..f2ed13aca2b0 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -439,9 +439,8 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, struct v4l2_fwnode_endpoint *ep, bool skip_mux) { - struct device_node *endpoint, *port; + struct fwnode_handle *endpoint; struct media_entity *src; - struct v4l2_subdev *sd; struct media_pad *pad; if (!csi->src_sd) @@ -463,29 +462,19 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, if (!pad) return -ENODEV; - sd = media_entity_to_v4l2_subdev(pad->entity); - /* To get bus type we may need to skip video mux */ if (skip_mux && src->function == MEDIA_ENT_F_VID_MUX) { - src = &sd->entity; + src = pad->entity; goto skip_video_mux; } - /* - * NOTE: this assumes an OF-graph port id is the same as a - * media pad index. - */ - port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); - if (!port) - return -ENODEV; + endpoint = imx_media_get_pad_fwnode(pad); + if (IS_ERR(endpoint)) + return PTR_ERR(endpoint); - endpoint = of_get_next_child(port, NULL); - of_node_put(port); - if (!endpoint) - return -ENODEV; + v4l2_fwnode_endpoint_parse(endpoint, ep); - v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); - of_node_put(endpoint); + fwnode_handle_put(endpoint); return 0; } From patchwork Tue Feb 4 23:49:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365487 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9880D92A for ; Tue, 4 Feb 2020 23:50:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63ED3222C2 for ; Tue, 4 Feb 2020 23:50:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OnhOeTnL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727619AbgBDXuU (ORCPT ); Tue, 4 Feb 2020 18:50:20 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:32920 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727892AbgBDXt6 (ORCPT ); Tue, 4 Feb 2020 18:49:58 -0500 Received: by mail-pf1-f195.google.com with SMTP id n7so191878pfn.0; Tue, 04 Feb 2020 15:49:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bHkoLoAopDh/1dv+BwgYSSiMTnq6CBi7MdRZKVUgkME=; b=OnhOeTnL8j+tQhl0J2QwQllf0/LcmRUjaAJhn9h31tZDYc+UHsX8PHE0pCYlcYUAfZ pRVCGs+Q+b0WX96fvvKW+Zoi+2UCYMiXWiwSjvWTCrTZv+1RhDnkNsmAO7YJ4MS6eUxb QHhLmiAeN0iiVk4aeMhlBIZsHAAlU5j5AOuhYcBHtpSIO34gm6vSdZd12yUNOZHoWeVR tSez0AO7uHaf2rolk5fDiS1yUJ8L77RGZHGpO0rNi3HxWB4oVG+nhnzo3vjSizNE73wj GUxhVc0wHkQ/Nk2JtbhS2Bt2mGLTIqb8ECgn0BvR67IfqZh5n9svPSg38UdIiyyo5z6M iZow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bHkoLoAopDh/1dv+BwgYSSiMTnq6CBi7MdRZKVUgkME=; b=UjqtUn4ljxJKGtjn0Sp3b+sNJB1o94aclf3RcYcwzDXdFfXpkDpWSv32jtxPTG8wx1 lnarT08UAr1+N+ur5LiqKlx81CooOZ90qNwVQbJS3Evw3a0+w4czUTlykCr2YzfoZwar w1O5zawx84WOx30TYo4HhwRYkPzj0G+VmlfnM3q5W4sQVAo8qrirNuzrQoec23XMCgx2 nVoz9yUVu+JhkHDBkD+xX+58TujKWme3hEfBoMXXrYuqVGVycs/pssqq2brcD+LIrryF 9/6PyApIYjL8ajW64rjBKQ5KD4OqEGs6PpkufptMaqezFK1h7qutsEzxHBSw8vqH6vnr O/rQ== X-Gm-Message-State: APjAAAVBHyBvtjlzI3wkgyAhfgQvuF5++7r94mwBuRII4ZDW7/NdoyDG eFkFWC676TEKpdpcTgXbFh59CFtR X-Google-Smtp-Source: APXvYqzaAZC2PfzKi8U4riquIjtcm+Kd+InTwISM6YhM4lCAk8kgeaUyQEoCzW/Y1bX6/oEqDADZ8Q== X-Received: by 2002:a63:c846:: with SMTP id l6mr10114760pgi.144.1580860197353; Tue, 04 Feb 2020 15:49:57 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:56 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 15/17] media: imx: Create missing links from CSI-2 receiver Date: Tue, 4 Feb 2020 15:49:16 -0800 Message-Id: <20200204234918.20425-16-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The entities external to the i.MX6 IPU and i.MX7 now create the links to their fwnode-endpoint connected entities in their notifier bound callbacks. Which means imx_media_create_of_links() and imx_media_create_csi_of_links() are no longer needed and are removed. However there is still one case in which imx-media needs to create fwnode-endpoint based links at probe completion. The v4l2-async framework does not allow multiple subdevice notifiers to contain a duplicate subdevice in their asd_list. Only the first subdev notifier that discovers and adds that one subdevice to its asd_list will receive a bound callback for it. Other subdevices that also have firmware endpoint connections to this duplicate subdevice will not have it in their asd_list, and thus will never receive a bound callback for it. In the case of imx-media, the one duplicate subdevice in question is the i.MX6 MIPI CSI-2 receiver. Until there is a solution to that problem, rewrite imx_media_create_links() to add the missing links from the CSI-2 receiver to the CSIs and CSI muxes. The function is renamed imx_media_create_csi2_links(). Signed-off-by: Steve Longerbeam --- Changes in v3: - call a local imx-media utility imx_media_create_fwnode_pad_links(). Changes in v2: - this is a rewrite of v1 "media: imx: Use media_create_fwnode_links for external links", which only adds the missing CSI-2 receiver links. --- .../staging/media/imx/imx-media-dev-common.c | 46 +++---- drivers/staging/media/imx/imx-media-of.c | 114 ------------------ drivers/staging/media/imx/imx-media.h | 4 - 3 files changed, 17 insertions(+), 147 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-dev-common.c b/drivers/staging/media/imx/imx-media-dev-common.c index 66b505f7e8df..f7ad3cbbeec2 100644 --- a/drivers/staging/media/imx/imx-media-dev-common.c +++ b/drivers/staging/media/imx/imx-media-dev-common.c @@ -30,41 +30,31 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier, } /* - * Create the media links for all subdevs that registered. + * Create the missing media links from the CSI-2 receiver. * Called after all async subdevs have bound. */ -static int imx_media_create_links(struct v4l2_async_notifier *notifier) +static void imx_media_create_csi2_links(struct imx_media_dev *imxmd) { - struct imx_media_dev *imxmd = notifier2dev(notifier); - struct v4l2_subdev *sd; + struct v4l2_subdev *sd, *csi2 = NULL; list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { - switch (sd->grp_id) { - case IMX_MEDIA_GRP_ID_IPU_VDIC: - case IMX_MEDIA_GRP_ID_IPU_IC_PRP: - case IMX_MEDIA_GRP_ID_IPU_IC_PRPENC: - case IMX_MEDIA_GRP_ID_IPU_IC_PRPVF: - /* - * links have already been created for the - * sync-registered subdevs. - */ - break; - case IMX_MEDIA_GRP_ID_IPU_CSI0: - case IMX_MEDIA_GRP_ID_IPU_CSI1: - case IMX_MEDIA_GRP_ID_CSI: - imx_media_create_csi_of_links(imxmd, sd); - break; - default: - /* - * if this subdev has fwnode links, create media - * links for them. - */ - imx_media_create_of_links(imxmd, sd); + if (sd->grp_id == IMX_MEDIA_GRP_ID_CSI2) { + csi2 = sd; break; } } + if (!csi2) + return; - return 0; + list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { + /* skip if not a CSI or a video mux */ + if (!(sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) && + !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI) && + sd->entity.function != MEDIA_ENT_F_VID_MUX) + continue; + + imx_media_create_fwnode_pad_links(csi2, sd); + } } /* @@ -196,9 +186,7 @@ int imx_media_probe_complete(struct v4l2_async_notifier *notifier) mutex_lock(&imxmd->mutex); - ret = imx_media_create_links(notifier); - if (ret) - goto unlock; + imx_media_create_csi2_links(imxmd); ret = imx_media_create_pad_vdev_lists(imxmd); if (ret) diff --git a/drivers/staging/media/imx/imx-media-of.c b/drivers/staging/media/imx/imx-media-of.c index 2d3efd2a6dde..82e13e972e23 100644 --- a/drivers/staging/media/imx/imx-media-of.c +++ b/drivers/staging/media/imx/imx-media-of.c @@ -74,117 +74,3 @@ int imx_media_add_of_subdevs(struct imx_media_dev *imxmd, return ret; } EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs); - -/* - * Create a single media link to/from sd using a fwnode link. - * - * NOTE: this function assumes an OF port node is equivalent to - * a media pad (port id equal to media pad index), and that an - * OF endpoint node is equivalent to a media link. - */ -static int create_of_link(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd, - struct v4l2_fwnode_link *link) -{ - struct v4l2_subdev *remote, *src, *sink; - int src_pad, sink_pad; - - if (link->local_port >= sd->entity.num_pads) - return -EINVAL; - - remote = imx_media_find_subdev_by_fwnode(imxmd, link->remote_node); - if (!remote) - return 0; - - if (sd->entity.pads[link->local_port].flags & MEDIA_PAD_FL_SINK) { - src = remote; - src_pad = link->remote_port; - sink = sd; - sink_pad = link->local_port; - } else { - src = sd; - src_pad = link->local_port; - sink = remote; - sink_pad = link->remote_port; - } - - /* make sure link doesn't already exist before creating */ - if (media_entity_find_link(&src->entity.pads[src_pad], - &sink->entity.pads[sink_pad])) - return 0; - - v4l2_info(sd->v4l2_dev, "%s:%d -> %s:%d\n", - src->name, src_pad, sink->name, sink_pad); - - return media_create_pad_link(&src->entity, src_pad, - &sink->entity, sink_pad, 0); -} - -/* - * Create media links to/from sd using its device-tree endpoints. - */ -int imx_media_create_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd) -{ - struct v4l2_fwnode_link link; - struct device_node *ep; - int ret; - - for_each_endpoint_of_node(sd->dev->of_node, ep) { - ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); - if (ret) - continue; - - ret = create_of_link(imxmd, sd, &link); - v4l2_fwnode_put_link(&link); - if (ret) - return ret; - } - - return 0; -} -EXPORT_SYMBOL_GPL(imx_media_create_of_links); - -/* - * Create media links to the given CSI subdevice's sink pads, - * using its device-tree endpoints. - */ -int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *csi) -{ - struct device_node *csi_np = csi->dev->of_node; - struct device_node *ep; - - for_each_child_of_node(csi_np, ep) { - struct fwnode_handle *fwnode, *csi_ep; - struct v4l2_fwnode_link link; - int ret; - - memset(&link, 0, sizeof(link)); - - link.local_node = of_fwnode_handle(csi_np); - link.local_port = CSI_SINK_PAD; - - csi_ep = of_fwnode_handle(ep); - - fwnode = fwnode_graph_get_remote_endpoint(csi_ep); - if (!fwnode) - continue; - - fwnode = fwnode_get_parent(fwnode); - fwnode_property_read_u32(fwnode, "reg", &link.remote_port); - fwnode = fwnode_get_next_parent(fwnode); - if (is_of_node(fwnode) && - of_node_name_eq(to_of_node(fwnode), "ports")) - fwnode = fwnode_get_next_parent(fwnode); - link.remote_node = fwnode; - - ret = create_of_link(imxmd, csi, &link); - fwnode_handle_put(link.remote_node); - if (ret) - return ret; - } - - return 0; -} -EXPORT_SYMBOL_GPL(imx_media_create_csi_of_links); diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 5f23d852122f..5271b84bea9a 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -248,10 +248,6 @@ void imx_media_unregister_ipu_internal_subdevs(struct imx_media_dev *imxmd); /* imx-media-of.c */ int imx_media_add_of_subdevs(struct imx_media_dev *dev, struct device_node *np); -int imx_media_create_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd); -int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *csi); int imx_media_of_add_csi(struct imx_media_dev *imxmd, struct device_node *csi_np); From patchwork Tue Feb 4 23:49:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365483 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71FAD92A for ; Tue, 4 Feb 2020 23:50:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F53A21744 for ; Tue, 4 Feb 2020 23:50:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aZ2fMSmB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727906AbgBDXuA (ORCPT ); Tue, 4 Feb 2020 18:50:00 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39189 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727899AbgBDXt7 (ORCPT ); Tue, 4 Feb 2020 18:49:59 -0500 Received: by mail-pf1-f193.google.com with SMTP id 84so173954pfy.6; Tue, 04 Feb 2020 15:49:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xWXrdZ90Rqh6QAAhxL2MMK6jyJVUDs2rWHZG2jR0834=; b=aZ2fMSmBb8INC9ZjdjDJSoO0C6r2ipOGxG5/w6s1OfQxNQPj7y67obTSS3ojlGbFJr vewaFBh4+H8ns/He7PiAh/VUsUH23ucS08bWjKCtyC/nQygZuJWuEWCGqtPjCK4GYN86 /Zv06iqJ4kngXnXIJCWHndx/cG6wn9Q1Wchyl9eTi7Wgc6ssAe6DGjw8zIYWTjygd/qs Q2Tfn9qFmRraWZd1PPhYq0elE7Q6/dO1J9H1nYVTuukq4STOvn6zinW/HYJfDy88Q3R/ t+MP6SXodxP+/ont99CoBkSDnGlCOwrZfXZVg/ys0UJ53j/I2n7Ji/73zWJn5tPeOKkn lsug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xWXrdZ90Rqh6QAAhxL2MMK6jyJVUDs2rWHZG2jR0834=; b=SvQVOUA3q3KFoWKqHM+Kte9pAEb2nTZqzZj+qpU2ImSZ1AzMk+F/5z5oYdUUtvW1WM KT7XumEluE5TdEjZTsQeVgYZv8+U2TKd143R6HeCH9dcFct8Tmpvx2lXICDbv9CGATZC zaC54DxAirpiVA4j5wh4oPINt9V26uUQ9wZKAFEpVzOlLB8xlDtvVIsehoIggoYomLTu T96qeQnnjO1Aj7Tmx8lYFD7mGDOKV2/hrKqBaSvAAAxA4xX8G2+yZa9T/JrsvYuW0Rhw I0HKOc3Nl5A0C1yYCnpwMTVLL56emVJPZHXTvSkhs3CnC7APoN7aw9uh9dcErXnHgodj 8YAQ== X-Gm-Message-State: APjAAAVlHsy9gWdPMeToOVU3xNybsGwLN22LDOq6fHcJcLksj7kswDA0 HsQvyHSFiCoxYFrR78y9yMvQpnjs X-Google-Smtp-Source: APXvYqw62ecVGd2VbnxIC4lzwBiEjvK/Wszd7w+Tuao9OgwOH+0hFr0GKvGsJghM30KoDwQa55wUSA== X-Received: by 2002:a63:7c17:: with SMTP id x23mr14489000pgc.436.1580860198853; Tue, 04 Feb 2020 15:49:58 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:58 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 16/17] media: imx: silence a couple debug messages Date: Tue, 4 Feb 2020 15:49:17 -0800 Message-Id: <20200204234918.20425-17-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Convert to dev_dbg the "subdev bound" and IPU-internal media-link creation messages. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-dev-common.c | 4 +++- drivers/staging/media/imx/imx-media-dev.c | 2 +- drivers/staging/media/imx/imx-media-internal-sd.c | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-dev-common.c b/drivers/staging/media/imx/imx-media-dev-common.c index f7ad3cbbeec2..b23bbfab388a 100644 --- a/drivers/staging/media/imx/imx-media-dev-common.c +++ b/drivers/staging/media/imx/imx-media-dev-common.c @@ -24,7 +24,9 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { - v4l2_info(sd->v4l2_dev, "subdev %s bound\n", sd->name); + struct imx_media_dev *imxmd = notifier2dev(notifier); + + dev_dbg(imxmd->md.dev, "subdev %s bound\n", sd->name); return 0; } diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c index 2c3c2adca683..6d2205461e56 100644 --- a/drivers/staging/media/imx/imx-media-dev.c +++ b/drivers/staging/media/imx/imx-media-dev.c @@ -32,7 +32,7 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier, return ret; } - v4l2_info(&imxmd->v4l2_dev, "subdev %s bound\n", sd->name); + dev_dbg(imxmd->md.dev, "subdev %s bound\n", sd->name); return 0; } diff --git a/drivers/staging/media/imx/imx-media-internal-sd.c b/drivers/staging/media/imx/imx-media-internal-sd.c index d4237e1a4241..da4109b2fd13 100644 --- a/drivers/staging/media/imx/imx-media-internal-sd.c +++ b/drivers/staging/media/imx/imx-media-internal-sd.c @@ -142,9 +142,9 @@ static int create_internal_link(struct imx_media_dev *imxmd, &sink->entity.pads[link->remote_pad])) return 0; - v4l2_info(&imxmd->v4l2_dev, "%s:%d -> %s:%d\n", - src->name, link->local_pad, - sink->name, link->remote_pad); + dev_dbg(imxmd->md.dev, "%s:%d -> %s:%d\n", + src->name, link->local_pad, + sink->name, link->remote_pad); ret = media_create_pad_link(&src->entity, link->local_pad, &sink->entity, link->remote_pad, 0); From patchwork Tue Feb 4 23:49:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11365485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BD6B14D5 for ; Tue, 4 Feb 2020 23:50:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B0C9217F4 for ; Tue, 4 Feb 2020 23:50:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hYh6UQgl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727916AbgBDXuB (ORCPT ); Tue, 4 Feb 2020 18:50:01 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40907 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727910AbgBDXuB (ORCPT ); Tue, 4 Feb 2020 18:50:01 -0500 Received: by mail-pg1-f195.google.com with SMTP id z7so1692404pgk.7; Tue, 04 Feb 2020 15:50:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AS+AHCuMQWIyLmWzD2RHQ/sZnkJFO9p0vLnea6pI0u8=; b=hYh6UQglDyvaKYQeoKHsdmWZDC9Ai1KCxDg3WYXA9VUoIowzCd1/P6UT9SMrmLJ9J6 zmZLaE8LW+fcVnqRkgciwC0EHLKMyKBa62O/YFOfRpFD5vCgBpHzvkxHAMwjOUVIgnXn +cen+/dstiaG4sNS5cmApv/Gx6wAY7OwnfcsrC6Pir6ldHJIq9apbj31QSKJ6KbBlhFa boTTc75UybNSR9VaCqbdiRREHhq0s1gEshNYeWi8W1CG6zZkLHM3rYmQKCkR63OvtH6N ITzHMiADkTEhkwjX73xm3W2sOmqCQi+pgqx0kPpGobHhWbGeU3dXVaqJf/pQtTLGolZu Tm1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AS+AHCuMQWIyLmWzD2RHQ/sZnkJFO9p0vLnea6pI0u8=; b=YP48QzN9ZzeP3W63m0mAMEM8OdvzmvFILi5mVgkSHzKXvXAK1DGtz15NWCdJVfyccY BTQC7Zx7BJHheD3SH8jy8BA3ydO/nm0zaOdTHiK6jvbwWULEPl7vFzftoPOCzuUkJgu5 qfsnK72KB4YEOVpQh/ey56+bEKLCe+pyd2Ui9ZVDKahTHiaBGz7LQ8DkHCpR8RsrJhVd I8CWJBsSJCd/2DBk5XhfTXT+3cUDWgBM1tR4iyLPZ5+6ULByp7LBdZx/iGj1D3sEXN6o Y01b43HEMZvLflFqElHVMEk9PynmtKINxSOGNTtg65n6E04U0i6q0mpVSj8l1XEvvqej Mm/Q== X-Gm-Message-State: APjAAAW09j6Ecyi+5BCbHMa3g96X4HS5F7zle55zR37+vFSqSxj0kTRD gf+a4MZTg8clpoQ+5wZ/tBDP0ETz X-Google-Smtp-Source: APXvYqw+LeZ+qTjjKIp+K4eK8tkRC8y+Os5q6ehTK/O9/49qCRcVeb3fbdOVA6rXi8JN5rFy3XdDeA== X-Received: by 2002:a63:7949:: with SMTP id u70mr33314977pgc.233.1580860200115; Tue, 04 Feb 2020 15:50:00 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id u2sm24607929pgj.7.2020.02.04.15.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Feb 2020 15:49:59 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org, Rui Miguel Silva , Philipp Zabel Cc: Steve Longerbeam , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-arm-kernel@lists.infradead.org (moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 17/17] media: imx: TODO: Remove media link creation todos Date: Tue, 4 Feb 2020 15:49:18 -0800 Message-Id: <20200204234918.20425-18-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200204234918.20425-1-slongerbeam@gmail.com> References: <20200204234918.20425-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Remove the TODO items regarding media link creation, these issues are resolved by moving media link creation to individual entity bound callbacks and the implementation of the get_fwnode_pad operation. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/TODO | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO index 6f29b5ca5324..a371cdedcdb0 100644 --- a/drivers/staging/media/imx/TODO +++ b/drivers/staging/media/imx/TODO @@ -17,35 +17,6 @@ decided whether this feature is useful enough to make it generally available by exporting to v4l2-core. -- After all async subdevices have been bound, v4l2_fwnode_parse_link() - is used to form the media links between the devices discovered in - the OF graph. - - While this approach allows support for arbitrary OF graphs, there - are some assumptions for this to work: - - 1. If a port owned by a device in the graph has endpoint nodes, the - port is treated as a media pad. - - This presents problems for devices that don't make this port = pad - assumption. Examples are SMIAPP compatible cameras which define only - a single output port node, but which define multiple pads owned - by multiple subdevices (pixel-array, binner, scaler). Or video - decoders (entity function MEDIA_ENT_F_ATV_DECODER), which also define - only a single output port node, but define multiple pads for video, - VBI, and audio out. - - A workaround at present is to set the port reg properties to - correspond to the media pad index that the port represents. A - possible long-term solution is to implement a subdev API that - maps a port id to a media pad index. - - 2. Every endpoint of a port owned by a device in the graph is treated - as a media link. - - Which means a port must not contain mixed-use endpoints, they - must all refer to media links between V4L2 subdevices. - - i.MX7: all of the above, since it uses the imx media core - i.MX7: use Frame Interval Monitor