From patchwork Sat Feb 15 19:41:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384033 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 38F3A1800 for ; Sat, 15 Feb 2020 19:42:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 19FE4222C2 for ; Sat, 15 Feb 2020 19:42:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p5KiWRSo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726640AbgBOTls (ORCPT ); Sat, 15 Feb 2020 14:41:48 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:43012 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726340AbgBOTlr (ORCPT ); Sat, 15 Feb 2020 14:41:47 -0500 Received: by mail-pl1-f194.google.com with SMTP id p11so5129011plq.10; Sat, 15 Feb 2020 11:41:47 -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=p5KiWRSowO/6u32QdyYfJ5yyQFaKgUISB2YGGY7oCcluRXj+MNEUd4h9e9b3JsCGll NS6XKq9O7lWsE7CECeQLIfHWJt0qYt1AB4+SeDBk9qYX35VfsteWw12J3tUXpCyvujdv QIXSZltmC6ana0ehKkrKWrwkL8/VYp115YluWHwHKWjnIHEJAwc7UZlLFRZZBruDuVAg 1Q0lDNbZvEC4Q3wqTa6qDEDRHi7YnL9ZqgsWfEquUqoOF0lCnP4W8j4QO2QSwx5JNwlY 4gbfDfc8jjifYlC+wT/na2tnV5kdIe5xDUaYV+1vKWUmd6haYCLVJhMe8c4k4+Dsbx2H rsSA== 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=efohZYsrP3K28qfmHjKsCZXpXrFBhDBAhH64pANKZotfc7fN79TtbPFsUxqUMFY7Qt X55Zq0l5Mf+vq+j1umYJ9fqWQpvB8wDQFwNbrkotOvexL2JQVaZkcWY/mBpMcrx0rQQy 8dyiFG1rQwpdE+W2oEN79wy+5srudcpju7h8HqrY4OKrctiETLlWxiOo/ESxiqwVgHPk 4dbrCo0jtEU/Et5DQCk8Hc9Cl837XdJUN6xQcGUuJJsrPVVsHMru8UcjMhcyf8kGaYZw BHQD7jIZInOXrnXLqEqOe2Iwm+54TDdr7HveY5DwqWl2BpLf76eWq28EtX4QLkYvQwmg ga1g== X-Gm-Message-State: APjAAAXq+Td2P1LcWkbEFdcMJ+hjcSF2uOdFWUBrQLnKWZVnXLP3IdRw OQFWFBvIguLHcJmmVjmJAcQVL4xWDk8= X-Google-Smtp-Source: APXvYqx1UNOFEF981/5DjEL2KCCokmkGTRXof8tt88zvZJE6QH8INHw+Aur0m8x1jRinDEn2qTQLrg== X-Received: by 2002:a17:90a:b311:: with SMTP id d17mr11239396pjr.17.1581795706570; Sat, 15 Feb 2020 11:41:46 -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 q4sm11802751pfl.175.2020.02.15.11.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:41:46 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org 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: [RESEND PATCH v3 01/17] media: entity: Pass entity to get_fwnode_pad operation Date: Sat, 15 Feb 2020 11:41:20 -0800 Message-Id: <20200215194136.10131-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384035 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 7357B14E3 for ; Sat, 15 Feb 2020 19:42:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4170A2082F for ; Sat, 15 Feb 2020 19:42:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qLysQWk5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbgBOTmF (ORCPT ); Sat, 15 Feb 2020 14:42:05 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:56213 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726340AbgBOTmE (ORCPT ); Sat, 15 Feb 2020 14:42:04 -0500 Received: by mail-pj1-f67.google.com with SMTP id d5so5441259pjz.5; Sat, 15 Feb 2020 11:42:04 -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=qLysQWk5SYZ55QqddLtEU76Z409wNZHKquXGyoCZpLPuEJPzp/2RbOtagSJVABRksj z+Gs4VaaX8aOCJzT5Tb1fS+Odh+uWmg6PmM47H24DB47abl6lHdzopFVrR28GkK5AigG slashyVT6yPZ8h2WMCrKKgktYLPJAt6VMX2z8EAaf3H0nKG+WiD1te2vxGi4eCl/cl2t XNwCUuUOah75Fjgjz5EAlUGuxlR9tT+OV17gNfGfVBZenTuLTSMnQMyLnePkJt8hNqGS v/jiGNnBHv2xLKdrtSYFmnslBN3iSXfUVSmFdSCi6OS1TczRzGeAQgpEfWAaFXrSisDe N5SQ== 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=sI7LHQ5rJA9Jfaorf0c9NG5K1j+atxBYHqF+2ZnRG4NLUID553xc7bZII2+hRzkK/K AOChBZ2ecquOrwRjHVa8vwWspZAU0rCyrsBw6ci9Jh3TAFQe6wokjoWj1FvUIqy8Pv5K Djnmu9ECzX8U4mKZnlEuNl/kUr4BO7tMxM+aUXhUaL66hF6aNjmyKkoa2Cg9aziDQZjj ShA+PFPUED5/nUXu0qoCbjpIJBqExwkGeZicQa2aVNc1cPgCqAMXrnUY3wiewkUf6L81 iqT57aXYFVc+d6cX0ld0KkMWrx4TLRLx0M7yq1OSn6qJDR/FaAgxvbyrQAHlhPLKi6i4 xJLg== X-Gm-Message-State: APjAAAUW4SsWmNM4I0pFUbLM3z5p5ggZjystOl+gnBq18J+oCzwQyYJg sNhIrz0U5k6aFiQHMUazhuaSxQF4SCA= X-Google-Smtp-Source: APXvYqzurBpRUzzabVGLZS15rHlDxrlzaKiyn3tCFIaKBTM+bjQVEPxEFxKIX96q5RCvg//6Chc3qA== X-Received: by 2002:a17:902:bf49:: with SMTP id u9mr9240587pls.199.1581795723793; Sat, 15 Feb 2020 11:42:03 -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 q4sm11802751pfl.175.2020.02.15.11.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:03 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rui Miguel Silva , Thomas Gleixner , Sakari Ailus , Hans Verkuil , 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: [RESEND PATCH v3 02/17] media: v4l2-fwnode: Pass notifier to v4l2_async_register_fwnode_subdev() Date: Sat, 15 Feb 2020 11:41:21 -0800 Message-Id: <20200215194136.10131-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384037 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 DDBFF14E3 for ; Sat, 15 Feb 2020 19:42:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BED8B2467E for ; Sat, 15 Feb 2020 19:42:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NeCzqZcs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727697AbgBOTmH (ORCPT ); Sat, 15 Feb 2020 14:42:07 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:52361 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726340AbgBOTmH (ORCPT ); Sat, 15 Feb 2020 14:42:07 -0500 Received: by mail-pj1-f65.google.com with SMTP id ep11so5449804pjb.2; Sat, 15 Feb 2020 11:42:07 -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=NeCzqZcsM4ip7J7p8r3xMhsXey+xbtIN2mBvJ1q8bfFgPJcbmjrWbrDeqdjK0DaecD Xn6Hx2DveLYiARrGYdhFJqPFL3phkhmYxwMj/taPdb4kAY/PMyVVCVoUzXc/AAGWMq/9 cmY0pdFaf5/Gk657YOPDH47MNlvWDnyQ67bR/2n8cVvGuUmi16t7Pb3F26FTeQ2RMzdY R7xpokIM8VXtXh8FwXuPRrodGtsPNn06qB+IXrlmU1Kew7168WXEqqo9S0B23ax6rAEj i1yapst7ruP2VALkb6DRCsokK4vdJWKeEjRqugfgQ3+m6bo63ay3YLHulpWfonSQlgzP noDA== 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=gsItkhq2FmKIr2eRI1p25lfPmyVCSHn2HFyvnO830qmJ9+Yg/s5udeipjrJCh9fG69 jwqiU+PzpiAImhjkODbHeaINGbXM8cVih65T7WlQz+zQmphZOFY5CEJ8NpFKZNq61udw 4E/rW0BexIBGq8fyVBPnDt6t7Q61txjAABdI2ekz9Y+cE2A7Nzj/KP3Qjj/ksAS1xfyj iK663bsTZpsVwliUNz16axtVqK/oPoFdb7kNtUo7eK8wgCZLP2jGhFoQaRvUkhUfM20c qcU8eE1uc4rev/Rbpa2iN0SikvCYIqOBYlfRZNdLyxfDKITdYs7keHbMTOBqo94y4ZNe FKfQ== X-Gm-Message-State: APjAAAULWTguaXniWUxteabWHifqYQQVcRYeRQafKVY0Wdnzb95L/lCX G9ignskIhiItQ2fdwIzFkH4Vx85zCpY= X-Google-Smtp-Source: APXvYqx/mg4tIU1tr63Knwf6hjq0RDp8xtlDDNDD8XPHG9TpxACQT79+bFj90QYux56vF+roPlpqSA== X-Received: by 2002:a17:902:7d93:: with SMTP id a19mr9130882plm.283.1581795726696; Sat, 15 Feb 2020 11:42:06 -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 q4sm11802751pfl.175.2020.02.15.11.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:06 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Hans Verkuil , 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: [RESEND PATCH v3 03/17] media: imx: csi: Implement get_fwnode_pad op Date: Sat, 15 Feb 2020 11:41:22 -0800 Message-Id: <20200215194136.10131-4-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384065 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 CCF651800 for ; Sat, 15 Feb 2020 19:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADE6E22314 for ; Sat, 15 Feb 2020 19:43:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TGhkM8Hh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgBOTmL (ORCPT ); Sat, 15 Feb 2020 14:42:11 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45062 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726340AbgBOTmK (ORCPT ); Sat, 15 Feb 2020 14:42:10 -0500 Received: by mail-pf1-f193.google.com with SMTP id 2so6737045pfg.12; Sat, 15 Feb 2020 11:42:10 -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=TGhkM8HhZmjY6DuPQb4msMGHcL2dzou1bD6wb1KGAftp1o3QHahLkCxh3w2vLkJLAW L+KiqIFB35nAHd5eUFpbR9RaqzFZwb8ZAC/atCwwXQM0Tnje/D2Z4++AprA6vSkwa8js 8buim4rd11xf7othSwdH1CR9PwauFkp23Iiwv8R62DtUJ65ngGFaZjyaR0i2I+2r9fkv lHQdo2tWRyANKH8czra1L2U/nMnigwRTlv7vgR/ovAXu4Q3+roMzvJ9aupaOhLpwPizY cO+n85XdHuwByzNr5GPH3/8RZTJYXoLOvvvVoUjCl1A7kix84J9ysgVv04C9X5UiGD3S nUXw== 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=prk0NiyODiQvKhSSpGgYiulqc+RNq4GoH1iYpKDcTbhdIVaT589KhSnumuj1yhZLCy fMkrwloQlUzGbpPD/h2Z4uPwQVUUwi67obLlrarij4ULUWAHLRGTfYZSPeFFI8zr3UkM Ou+5j2rnJzTcgOR4OZOdQzPeu/hyljJ027szG+j0mNr2jTXlMnMNlPeSfxnf+QdHuDJU EU9B1MolIDK1kuIC6d5lMDVmq6gwCsrePvN53G2MM2yar+NX+5y+hgbTGG5+g68GDWjm /e2HHtRQ6caicoTykCXoKIsh6YwSPxwr/xf19YtAPyndZ8X2rRXgfAVj8cv5+xSvw7sA qvOw== X-Gm-Message-State: APjAAAWOasZv2gjuqv4ZdN/nF1X1yq48u2ko/3W7ALJ86Ad4wPkCBSnB KzaLDo6/aSI8Aa5K6rweZ5x0sdo/LAs= X-Google-Smtp-Source: APXvYqykL2GsAy4uDFniQNsQVMLOFN4GwHeH/9K6Btq7YRMenUHjMOgBREWJ9t33xXFT+4LdznuKdw== X-Received: by 2002:aa7:8654:: with SMTP id a20mr9407051pfo.88.1581795729527; Sat, 15 Feb 2020 11:42:09 -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 q4sm11802751pfl.175.2020.02.15.11.42.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:09 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , 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: [RESEND PATCH v3 04/17] media: imx: mipi csi-2: Implement get_fwnode_pad op Date: Sat, 15 Feb 2020 11:41:23 -0800 Message-Id: <20200215194136.10131-5-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384039 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 10C531800 for ; Sat, 15 Feb 2020 19:42:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E62EE217F4 for ; Sat, 15 Feb 2020 19:42:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iJItRTiU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727802AbgBOTmO (ORCPT ); Sat, 15 Feb 2020 14:42:14 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35844 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727799AbgBOTmM (ORCPT ); Sat, 15 Feb 2020 14:42:12 -0500 Received: by mail-pf1-f196.google.com with SMTP id 185so6758686pfv.3; Sat, 15 Feb 2020 11:42:12 -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=iJItRTiU9ZIGuHENK8T4BFJvF8IFQf2Hg5ysXS+3gJw2M6ZFeVmpbB5cVRniPq5bz0 qEety9CoPmmC1QQi6SpusZ6mDuMhaiN3KUBW3nGM7guqRXOzFBB9gHSwFYwmtrXuDswp j+V6TiDR+o6+oHoEH+x2ISzofzsDsd6MEbN/zSRuUcvApxNZqjMYBm6Of9uF0Uco6E4W GVq73Fjz70YrFOswyoz/BfpVeOEeRyhbSounHPJ8EP0OqG+M6IeI1fKZUsXeN82TWRTn q/pDzOlANXNZKVHhMO4Ct67ZTBda4hIj6VTE/7aQ3TTvA20MFpa1PyI1EFNUVEEwTbAI Qudw== 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=YKYNS4lsFCJeAbSj6NUfKOQcxaFhCdUTb+mUBVig/cyW2SSX89oITnQGVt6B8QwxCK 9RSHYO1MdAvj9r+pl68eOZ9+yjVPOjelU62WKu0fABYJGkCIddh78jyL5dP4RLywBmsM lZXDDSzr2tute/EQ3lWrXfQRi9zmQhjEP5IzPaSH7O7QA7DYeNqmh+PeSAzxnouZIJGb 3t+RH4W5CPealDi5abPIoMAqBRwE0wBCCJvuGT1h2ktYPXGhkYu4CIs0qazlJUyy4Dbo yJ6EJN7X+IziPp99EKeOYXAhjz9j6IWjLQbE7M85bv3iesdugcFWnTj1yViczfFg8PyS w1gA== X-Gm-Message-State: APjAAAUvjkpdL4VXz1UoBlBR/BUcf5qWMh6lHuy/Cug/QxQGoXC7y9GI 3odin5eESeAm4gv2x+vK1jN8+Rc8xPw= X-Google-Smtp-Source: APXvYqyA8eKEE1EZxDHRCm+vv/kHU5sceEimjzNg1Q+Nu0UvFglPJz9fmdCempM9IY4kUsbd/0gZKg== X-Received: by 2002:a62:2ad1:: with SMTP id q200mr9748584pfq.123.1581795732019; Sat, 15 Feb 2020 11:42:12 -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 q4sm11802751pfl.175.2020.02.15.11.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:11 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Thomas Gleixner , linux-kernel@vger.kernel.org (open list) Subject: [RESEND PATCH v3 05/17] media: video-mux: Implement get_fwnode_pad op Date: Sat, 15 Feb 2020 11:41:24 -0800 Message-Id: <20200215194136.10131-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384041 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 D0E581395 for ; Sat, 15 Feb 2020 19:42:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9D392187F for ; Sat, 15 Feb 2020 19:42:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oARk1DaO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727845AbgBOTmT (ORCPT ); Sat, 15 Feb 2020 14:42:19 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43742 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727799AbgBOTmS (ORCPT ); Sat, 15 Feb 2020 14:42:18 -0500 Received: by mail-pg1-f193.google.com with SMTP id u12so6547245pgb.10; Sat, 15 Feb 2020 11:42:17 -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=oARk1DaO3noUsR+qW+pygvrVgG/23PEzrIqLPjadMvcQ9Q5g4UabNbOKwPjarZkhzV aqBH5nKan0vW4DQ21C6xvwaS2tB57CuzPbwe1gd+F1wWX1PaLB3mxRVnK8lP7KLdRVGB uFsbStRfOSCKi/fLWY5St+NQKNPTVcQ3eGq96LLAdSbLc/BfFpPzagjKRgN1wwsQ846k eNW7KmUUIoHQaKw+YzpC4B/JbrHqo55V7jZrWvOndVZuIs0MF0Bi6LqmQjrvhCMwaT+5 +vMe/QWdX094PXrVOqYz/PZCTOaV1SN93Rubd1YhFC2DVFbsCeb7+VGPrwRTADMogOJx y2Yg== 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=EY2320eoJgdgJllvMeqbWe2PR+rkomt+AdhtOONm7wL8c8RRVr4B3j/PBykDAtDqjl ty5tvki7Hn/RjsLFPV9mx5hkmWGWoGg/jcnNsooK1vZr6C+Cl/xYv4/HgW+86EARGJSn m6qzfvmze5G68jWA9HgSmFUtivFvTVlu8uMh/yhPbUtn5Qf8XCHvnT+MXe/PYDuMj3no BUYq+3i3BqUAi4xLDy8qQ/cRsN5c8uxXrcUq0tIiKasvNHzlPeap6YLbu9Hm1xfadTXP PxqAnzQVRXHSltSYPG5BMCqvTjSbBC/6/HybbyfJvRC9NFehVhB46hpWux/yvGqbEcIH 0o+Q== X-Gm-Message-State: APjAAAUSxqNVV0AhBI6OqXySgfH2HyrDxikcuzjH/73eLtxKHnlLEsby BnirNy8NElFYRQpbDNciK3jSRTbNGEk= X-Google-Smtp-Source: APXvYqxB+c5KEwcaiWWabRC0Hpows19EuwyJhN0LkZcyzvyObroaOVztlQMSEcc4Sm0hCPvq/m/H5A== X-Received: by 2002:aa7:8755:: with SMTP id g21mr9501097pfo.36.1581795736519; Sat, 15 Feb 2020 11:42:16 -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 q4sm11802751pfl.175.2020.02.15.11.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:16 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Hans Verkuil , 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: [RESEND PATCH v3 06/17] media: imx: Add imx_media_create_fwnode_pad_link() Date: Sat, 15 Feb 2020 11:41:25 -0800 Message-Id: <20200215194136.10131-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384063 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 4FAA21395 for ; Sat, 15 Feb 2020 19:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 310C4222C2 for ; Sat, 15 Feb 2020 19:43:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FLPaTXT+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727868AbgBOTmV (ORCPT ); Sat, 15 Feb 2020 14:42:21 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34141 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbgBOTmU (ORCPT ); Sat, 15 Feb 2020 14:42:20 -0500 Received: by mail-pl1-f194.google.com with SMTP id j7so5156068plt.1; Sat, 15 Feb 2020 11:42:19 -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=FLPaTXT+5fXwsRnzm6pWutS5dn35cQJLM/byRk2a7jjOXFIi/727ypMvJDYDmUzvmU MGYDjaKJZPTuwHqQbeEYjbO0i+djMLSkswvH/7zCfUayqh78R+fdUvrfcV1sb9JDCBnq kpP389t3XWiqBJUutYQ+FvdKnE/7FYIqom4uwsy72ErdzkhER8A6+EKo/Cl0gqo+OISC 7HFd7/XdhTzkV+DslU+duQDGvCSYPlWFbzCv12LxTjkQczDhRQhDbx3DOpBIFo8iLz6p +J9TT+PB9Qxt9jbwtkoZifV2o1xz6acHzUOxEzcMI1dZl698c61Cng2QQ4yk50A9sNuG e6ZQ== 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=DVL7YxQFf25NYCPU1wmKUPQzhEjmJlIsaSDov8y3bI1uCLRB6c9FDOtR4Uiv6/PYf7 AyPzXVLGoMQmVxecf5R5m3IN4vbW1YhR2wmoBarkL5qbYuDiCYT11VdMIZqoRk1aEeeu sqWVmd3prUhmDe4aLJLQSg5mwkuD+3IwOkDMYiHa/JfafnyTB9waJim91/NqlEzoIa2K cNFruJItDROMzrMzwp4qMjSg6XrLBCBGfXG8vHevuJAnwWjmhhD8R5mFHERb1Ws28Ljy O0ymFXraPIxImSSE8zU6rgv5VKyqcp/GRihH1xfl/yJSa1ZoUsK73PzemQ+y6MifcBq8 eOuA== X-Gm-Message-State: APjAAAVbAHWpDmX500jErhVBDeYG+mLATk5DzwUC4aPVjJmGr5TLmX/0 4Kz+Bw7Q4AdGd0mIOoOc2s0zoIPvKLM= X-Google-Smtp-Source: APXvYqzVw6J8XDN5DZSI2aW4QhNFB9oBUYbcgLa7oI0q9/9u6zF7yWQ9KVCdY+aCnbCfN9zmydU4LA== X-Received: by 2002:a17:902:523:: with SMTP id 32mr9281345plf.148.1581795738885; Sat, 15 Feb 2020 11:42:18 -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 q4sm11802751pfl.175.2020.02.15.11.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:18 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Thomas Gleixner , linux-kernel@vger.kernel.org (open list) Subject: [RESEND PATCH v3 07/17] media: video-mux: Create media links in bound notifier Date: Sat, 15 Feb 2020 11:41:26 -0800 Message-Id: <20200215194136.10131-8-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384045 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 8EAA214E3 for ; Sat, 15 Feb 2020 19:42:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6FDC22187F for ; Sat, 15 Feb 2020 19:42:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TlHXKi9U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727887AbgBOTmX (ORCPT ); Sat, 15 Feb 2020 14:42:23 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43037 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbgBOTmW (ORCPT ); Sat, 15 Feb 2020 14:42:22 -0500 Received: by mail-pl1-f196.google.com with SMTP id p11so5129314plq.10; Sat, 15 Feb 2020 11:42:22 -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=TlHXKi9U8uiS2fkx2BPSRGo8YoyUc6hHaVvyRF/ec4V6f3e2pH8hLJC5vKohYdzCWn cmCCKy/flrosl+0iPDsZgqdwIe/WgrsSGa//kLYqxgKrVxMWqWKotlrBSh6orJ7ljBYn oa+Bv5oefAEIME3xifu6PzgaINoMr2vpri9DEznRfFt34Pi5hSTp+5MRTqVP6jnRBHij 4kBrKqeI+8u0bsVvSJ9fNm6YYDR/WwQHpfkQ5Ip57liK8BFvYVQNKb37cX5YxTpcjbY0 B2FZctlpPUNGIrt//nirJ9SqU3qwnHkBersRETRBze0OHHVC4HNmIUbSKxzVnmjpkZGA PnlQ== 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=JYFydN2YuCzOFLIJ+5xabGs2POaW3RosBFwQ1EOr654wWp00rYZGmyFkoy+SIRIboo Yjvi8Y13RP4XR/FyX9gW2JadtrXwUUeaO4ddU3ltD32rnXyWSmgRqkRGygoJejHIjO8Y cwag5v0mbhOLYaD0/MaUKGJQ7NpXBLipMSNfI8tyHWMmeYqrgTEjdO6RQdsgSSNKoJoQ 31p74TaMr83A5DFSebLXLhHmNiLXcyxarbyQy6Aq+2o363u5VaXgmBg25LLT7CiQEZeN yN0DnoAZup05chRgA7FQR/IEVVaprHqvRUsAKRMz0DJ2T4eFg/KCRAtZqVUjfbQwA13f YBLg== X-Gm-Message-State: APjAAAWdyqwPjsbQf25tar3EAsXCGh72NzFqVVmI4SmLBIly8p60z23Q Vmjmi3JD69vEL4naGZCEtLl6rpO4zOE= X-Google-Smtp-Source: APXvYqzMiPby3ABFgdEWNgjVyH0LYRY9+ahPWNR0Ixl7qauNjkEXOJEmC9DbQ6oumPosWwBAam5/vQ== X-Received: by 2002:a17:902:ff11:: with SMTP id f17mr8898260plj.273.1581795741629; Sat, 15 Feb 2020 11:42:21 -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 q4sm11802751pfl.175.2020.02.15.11.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:21 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , 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: [RESEND PATCH v3 08/17] media: imx: mipi csi-2: Create media links in bound notifier Date: Sat, 15 Feb 2020 11:41:27 -0800 Message-Id: <20200215194136.10131-9-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384049 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 D66361395 for ; Sat, 15 Feb 2020 19:42:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B75182082F for ; Sat, 15 Feb 2020 19:42:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cDI2dL7L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727930AbgBOTm3 (ORCPT ); Sat, 15 Feb 2020 14:42:29 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:37410 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727916AbgBOTm2 (ORCPT ); Sat, 15 Feb 2020 14:42:28 -0500 Received: by mail-pj1-f68.google.com with SMTP id m13so5499108pjb.2; Sat, 15 Feb 2020 11:42:28 -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=cDI2dL7L941I9EiBEqWio76ng5wQHc1eCoS2tIQD5FdSipYFf19P+kO/DdGqvns1JD HE1md4Eken3gfmAMPbyb9ZfOsj2CG/iAiseAnugqloC6Dfe0t8i3bw28yitlOy1hHTy1 PiXZEHvHndVAmC/FCCmGIFKuYZPexA5d9CSEpNKT1otpeFJIt+iu3AwkF+ew0wa9OwB6 mk/FWb45B9on2z1xlKgZu2RBKsugZiDyXRrTm9xCOTWtgi4CR3iLvKLWs2Xd7jQxHFBf jsG3ApuD/ufXBMqYddYE2K76cm+CfroMPQsIjn/w+/6uU5m7W/tzKu7rxAmfN8z596P3 hqHw== 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=Zfbm5aChh4YOBuj24Icyvi/tUyVeLu7NwJo16GT+JZqzxLzyDENMKMJ5iJl+/p2ZbN gkpEwxMpAaQu6D5lVuatSYCf9kSoxK20Cr3zxYPGKL5zQ8eGoGkdDP5JifDZ2bekYfk4 D93lxRIb07qsn2QhwMDh1JlvtshjbLVenj9sYUfNXgdtkvKK14UHk6x9uTXvnRctdFO4 oI0//m8WO3df8/sE/Jlhd26B/Am87a+0K8BZVpcYPWiYmJ32flFPHLZnapfr3kMxWDRL l9N6/C5VvimkQe2CQwUF9ZX9Cs/Nd+EN1EPJrlQzb99/ogULzY78EihO0CyTcNakQifj IBPQ== X-Gm-Message-State: APjAAAWn3RbmF8rXXAnerI5GtXKehnGfTubJQ3FQuEg9nA6GaHrRACF3 P4UShmGzrOJsHJivFs32Q/95g8BfKyo= X-Google-Smtp-Source: APXvYqy5FL814cSRx0y6uCQP7K0Wqd4IttStBHjm/I6g0MD5BOw9JE2lyKE1OervxSBUBNXty2JpVw== X-Received: by 2002:a17:90a:1e63:: with SMTP id w90mr10933872pjw.36.1581795747794; Sat, 15 Feb 2020 11:42:27 -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 q4sm11802751pfl.175.2020.02.15.11.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:27 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Rui Miguel Silva , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Hans Verkuil , 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: [RESEND PATCH v3 09/17] media: imx7-mipi-csis: Create media links in bound notifier Date: Sat, 15 Feb 2020 11:41:28 -0800 Message-Id: <20200215194136.10131-10-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384051 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 F2C161395 for ; Sat, 15 Feb 2020 19:42:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D30E12187F for ; Sat, 15 Feb 2020 19:42:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q4REyd3i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbgBOTmg (ORCPT ); Sat, 15 Feb 2020 14:42:36 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:39788 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726411AbgBOTmf (ORCPT ); Sat, 15 Feb 2020 14:42:35 -0500 Received: by mail-pg1-f196.google.com with SMTP id j15so6911126pgm.6; Sat, 15 Feb 2020 11:42:34 -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=Q4REyd3idXsfin5Vl+BX00/YFMs4hCR+L1l4RXoiLz5ZgfQjqJAQ9H/WYlB4kFFuUn 2BeQ8QY0Xbo/AXVK6omCd2e8q2qM3Cf7RyjeCPn8Kp15Om5Loq757kfcG0ONVfrFKoYn X500fw4Ax9F2m4vpO2tnkg/tEeFSBPbInrWJL0siTj/b+oU6a69nJSvRG7wywi5TBf1K pa/1SBon8bHvTHbSxPS0PPHjECAALbiprnh983paW7opRn6p0DBqoDR8kBxgrbVNHI/r jF5I2qiraTuDyDa1lRgQiWVPPJR46f5SuX76CXRRP1tX1TtNNO2RZzCyDMlPpIr8ZX77 4NYg== 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=tVQaXGfRVqm7GdG/2lub7pO1oxhULU3Z4LX22mJQJ4xh9Ku92LyO/BbBSdC6cToVQT m9nXoMuWr0R5wMfhlCVowjiMPi+rn+wke/x7726z9ysiNrkhSM7LLR36msXIwxYVOMcJ kIfGgEIxx5d2QQYA6w2Usty4DUUW8Gh2B05QV9RzBotTdGBsViHFymN625vOfu9lpeW+ R6doeKG0HDqySulOX9wnxuS62G9bh2vMxhYTAuvBW5r21zgKrGdSZ0wMZGQYfNTHWnPn rIq19ljE71vwSNwQ50JyeuAprteAiWQGoOX0uFuPRfyV5ne+QdniX+kZ4cxjXyCTUjdQ vwfg== X-Gm-Message-State: APjAAAW6Wpz7zsJBTfup0rdyf5+JpgxVNwDO3dYtuZhqEmEpShqyeM8M bUjcqS6qjy6nhUWJr7fuovZCFyvAcmg= X-Google-Smtp-Source: APXvYqyqh6I7hOUhflWBDDniEbao7BhGpMR39ofFTVzbTV6SmesNF6l10KxundtimLZ6vZIQ42CIyA== X-Received: by 2002:a63:6383:: with SMTP id x125mr7728780pgb.409.1581795754064; Sat, 15 Feb 2020 11:42:34 -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 q4sm11802751pfl.175.2020.02.15.11.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:33 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Rui Miguel Silva , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Hans Verkuil , 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: [RESEND PATCH v3 10/17] media: imx7-media-csi: Create media links in bound notifier Date: Sat, 15 Feb 2020 11:41:29 -0800 Message-Id: <20200215194136.10131-11-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384059 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 C095F14E3 for ; Sat, 15 Feb 2020 19:42:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0AD624649 for ; Sat, 15 Feb 2020 19:42:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k3GIXKvW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727972AbgBOTmk (ORCPT ); Sat, 15 Feb 2020 14:42:40 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:35596 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727958AbgBOTmh (ORCPT ); Sat, 15 Feb 2020 14:42:37 -0500 Received: by mail-pj1-f67.google.com with SMTP id q39so5500517pjc.0; Sat, 15 Feb 2020 11:42: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=nw6qFQx6S/L6ma/0AlsKxKIDrQ4PZDVJaM1fr3Im7gQ=; b=k3GIXKvWft0N1NbpenDUFg5zblDqcbUwzZDit6j5Lnn/XVvhgo5upPEa6pf+6EAMEz Xt3hbI7ZN7uQ3ZpDboF8dsqWS8SmiaQmTx7VTEHl/ogj+jq5hURSLNGK4VHhyJZj/Qus +bYF9uSPWj7Z8BwAyKR14ry4FKmhnTxJnPRiFZM9Vq4XZLEY9Al273TDUbppvZnGanEN XgsTT3BtOW7qp0sc+wDR8OgJhZGQ16Af0TNYgqSPglzYcYGIUZbTkO3OohkZb/hBFwDh v72JbltSB5enu0WPMOhZW9Ko/dsfsGdL+Qu6goM7QvrgD4+O2up1IqK+TKGYEk2J8ha6 rYcA== 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=l859wukbdJLfS4auFUVmfBk5i7Ge2CcaUtmJxSasK8B2fOT2HhiNF7Xj50nds9rzxt yRUPFffVC3XWIEcxz0NsTi6fWZ5kfT1Jl5l9mOVthBajldgESc+CNuq8aOf8lgEJHVLu khXR3xJw1XFM8BPXs+OqHLtducOz/Ovwx030gkN2O4F5lDDpMLTn8SNTDqZXRRulYC+x MOBo9z/l7dE86BTxpJ+tsO6QrIIKxPC78yL4ske96c8KnLLTG8vllg318kpq73m3lOZi nbcbzvs4zWuD3JWGb72km4JSE0pQYx7JscXGNLSiFRJcTl/M2sp7ZPqFkk6CRN6pdtnG /Pig== X-Gm-Message-State: APjAAAVmV5sufEsyTkqaQSWvoF/zAF6Zw9gAnfuuESGsl/KNsJo/Mb0C CoC/7sIiaKkdLHEwwxyfgPahQcwA8Us= X-Google-Smtp-Source: APXvYqzkUXyKopzlHELwFuMNAOIllbGui1hUS/4slzE0JVfp8tA7A3yD2KKHvzv5nTeYgrIuLTwJ1w== X-Received: by 2002:a17:902:5ace:: with SMTP id g14mr8946961plm.311.1581795756922; Sat, 15 Feb 2020 11:42: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 q4sm11802751pfl.175.2020.02.15.11.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:36 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Hans Verkuil , 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: [RESEND PATCH v3 11/17] media: imx: csi: Embed notifier in struct csi_priv Date: Sat, 15 Feb 2020 11:41:30 -0800 Message-Id: <20200215194136.10131-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384053 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 6E3CD1800 for ; Sat, 15 Feb 2020 19:42:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4FA772082F for ; Sat, 15 Feb 2020 19:42:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jmZpkjWs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727996AbgBOTmo (ORCPT ); Sat, 15 Feb 2020 14:42:44 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:56232 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726411AbgBOTmm (ORCPT ); Sat, 15 Feb 2020 14:42:42 -0500 Received: by mail-pj1-f68.google.com with SMTP id d5so5441650pjz.5; Sat, 15 Feb 2020 11:42: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=WaBGbAVLvbw1Oa8PBijA4rVNFNBvvrFDnIgEYRds3L8=; b=jmZpkjWsbaobRG1GO0fyalos/nZWZE80HVu13ABf0t7B0ahTcSHiWCChAHZuZiBurG b57uODg71jswZRofJSWEa22pIiXiJfsimHlu+cdxpuvye67KXdorOhPsJJKPmK1AIPOD G/K7RLOTsPMM03LJifKz3uhbRvnz45jpuCH19Tlc+9o1b52xj5pFK+qmFxRqn1H3vw8/ 4yL09zC4e1YwJnSezJS/M6CM+kAy/t3/T1BmzVN9SxbGMhY6p26MyzAkq1ruMUE+M5r7 GVT03WQol/jICxoaUmRBiTu2K71nTj3KGgo6z/IBIUZT2CmLoZsZhRhwgbK9WXZyPgiV I9yA== 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=H4kS7QV5MBRMJiXYEDakc/9+KwYWO7vIXwtfTPAlr/xE/T6jnQSyj3aClx3SXzHREa xj97Sm6zwkyL19qXdWVM6qLAtLHora4C37MidKOZo7mJGmj+imFjmqnDVjOtS2gofss5 Roc/9uZyxhh//HXWXB6/XDtwVItI4ezQre5CPCc2cR7Ar2v9EAl+AIiinu6R8xMfqTym LCGa8Io/Hjp1OkWdVE2ZRRXaUWtCTm26+AgehQN2pdJRmJgEQiX/AlE98U8fQmi8keT+ vf0wGOiXerGeABC94eVSpvteOgLXaarKaCBE4WJ3OBh12X8dU+YEJ628btp4ZuXbgcjL gQkg== X-Gm-Message-State: APjAAAWNITLB+BPYOEjQebeHz0ZonphJliwSZhNpwlg9x6taI0IgAacx oRk+aw4hK6zR+qkGgWdbHe731WEdAl4= X-Google-Smtp-Source: APXvYqyieLo6TkLDnsQ1I1ozugLJM2j6uZo5Kq0sitsB01Xv44YmxnyulZiU7C4+ngGeqMUn+Oprtw== X-Received: by 2002:a17:902:b70e:: with SMTP id d14mr9221633pls.295.1581795759976; Sat, 15 Feb 2020 11:42: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 q4sm11802751pfl.175.2020.02.15.11.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:39 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Sakari Ailus , Hans Verkuil , 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: [RESEND PATCH v3 12/17] media: imx: csi: Add missing notifier unregister/cleanup Date: Sat, 15 Feb 2020 11:41:31 -0800 Message-Id: <20200215194136.10131-13-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384057 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 257A11395 for ; Sat, 15 Feb 2020 19:42:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 05EA9217F4 for ; Sat, 15 Feb 2020 19:42:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="o75oGSh6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbgBOTmp (ORCPT ); Sat, 15 Feb 2020 14:42:45 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43057 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbgBOTmn (ORCPT ); Sat, 15 Feb 2020 14:42:43 -0500 Received: by mail-pl1-f195.google.com with SMTP id p11so5129517plq.10; Sat, 15 Feb 2020 11:42: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=J4a12SBTuMD7atLLATUCugE0dEUcvKzeYrZ9OjbRkuY=; b=o75oGSh6E0XVjA4LESDf8tAB+lWr3cpyJkllsXdLva6u+vxUPhSlBWaLo/x/P+coQ0 ziHUMQE9mSHFbUqXNpueAU7rYdwQZcsotuBJ1vGWh5WG0+OKUyH3HHZE2XTSyHuRVfor xH1n+a+FB59ZD/4z0PMtQcKXSESzOsanihg72Dk1h72kmQxvTH3GLSkigEdt12b9D68v TgChzQjAdc/kh8S+v80oM171rQprxqHMoo2vza9Wc44hPW9e3dX/7tSSdmIGl0QT5Q2x FNBoVb77Gp/0iXKR2q2f9O9HcqDOa6eK0Uetm+qJN8pFihgZuow4TQ4O1fmPAf7wdOH/ 6MdQ== 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=g4dZd7DdvwO8v2I9ldP67ASyjDaCGCYkoZ+ZfZgCvN54HvfLULW1fP6JCbVpmj+O0t 2iPc09egTdT8ad4h9h/3wjfb5dLxSqAEEQMohMDXH8FzlJgi/0X/QJ4dNtPGntkr1vTU 1u7s8Jw9GUIGAyW4U8Hv817KLryIYL5YxdmXWXuHLgAvAmZ/6rU2Ft/ogD4ucvp7aPEi iILQyQ048aOsN4SKFxlVIUGyCUC6ZvFWW7dXXH/oNnxvynvX6hh8I/kO8PqjAH0wG6VD HIX/4t3qkXKiJJKxIZar9H/ER/SObqJh1nEQeY6PH3dzKrlh7PiXLXDuugVW9sRPeZpS 7XxQ== X-Gm-Message-State: APjAAAV5rScB6hxv1sRPbN0B1jRxVzGbSVo6W4DoDhxEYGmcYp9IpcVg VjarCT9vodr3YMkysCd5GSRnd2hpSKs= X-Google-Smtp-Source: APXvYqwBQtTLbOCGEG6HDKeQQZqiXvk/KUtfD8Y/2evFbOxbwzS7XJFE9cf5Z4O10CVmJ4jiy5D9aw== X-Received: by 2002:a17:90a:9dc3:: with SMTP id x3mr10971588pjv.45.1581795762862; Sat, 15 Feb 2020 11:42:42 -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 q4sm11802751pfl.175.2020.02.15.11.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:42 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Hans Verkuil , 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: [RESEND PATCH v3 13/17] media: imx: csi: Create media links in bound notifier Date: Sat, 15 Feb 2020 11:41:32 -0800 Message-Id: <20200215194136.10131-14-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384061 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 60AC614E3 for ; Sat, 15 Feb 2020 19:43:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38C74217F4 for ; Sat, 15 Feb 2020 19:43:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nKDR2CfF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728034AbgBOTm5 (ORCPT ); Sat, 15 Feb 2020 14:42:57 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:51784 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbgBOTmy (ORCPT ); Sat, 15 Feb 2020 14:42:54 -0500 Received: by mail-pj1-f67.google.com with SMTP id fa20so5447340pjb.1; Sat, 15 Feb 2020 11:42:54 -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=nKDR2CfF6RrgkcLnn63uYsZxcW77AmH8l4sxM7DwuSPDobUhKmcRG/TGLwFzziD2XJ m0RpfI1jb7nTB2DtiG+2RKuVBeHXgRXEUk0ykiklAN2hjthxfiqa4I5a4RT6nwUxqfmt 3Uaq5pDz8OjKGOfOiWC8L0NHygd/vMzr+WfVZ/yO9lqOFpYp51v6WtVlyHh0cvYOHKK3 Y8bTVhtC690S2fPTR0I0f3KkTn8wY1Kyje0AbpA13T0ETiJ10XP7pM1EOZSbb4Il0dKP uhdvzcPVQ8YTCamR27pyTduRPRdk912YTOo9NMIpKJzkkyuFfcAXlEV9zWTlmRq78hKE TFSQ== 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=iK2Aopz9oT5V893Lpa6uCM+6YGhuxonZ4IG5r7o1zvinbaW5LxBxR3hKsQoBsqpj1J JNgvwrnoee5zLKv50bPGSdQ5SdRZYOr1t5rQW8+0SFDYyyjnrNHGiebOUWRULsEiZt9E evly4f8pQyu/NBYXYBnGqrVvWFZMyuCsqjkKZ9tNdmq5pBwCEkWB758NhFtK3zU4Y7Ic fAlsaoulIFAaHMfCWRtIDZzd0QZ0VTdLZEfALdTzoS0i53MsVMA1wkbRHlvH0aMhyYK+ J0qZdI2jLBxQVnTlmx6ZjRX7PYIagnRR1OHeG64xZ/uUh91BVYLdVVmv/7uc2FcHb/Oq mTkA== X-Gm-Message-State: APjAAAWhLfWLL4vewTfVbVFSZ+PC9O3rlXfGcFYSHNIxuJetzHfmDEp+ JtdMuv1qYKaGpuUK4nf6XyAf/1X4iVo= X-Google-Smtp-Source: APXvYqztop9U0pT2U3t3Oc5/2L3GdOytArOUtcGT+g2w7GTRTohiGs0EUjeIy7TbV+D0iGBfeKUnAA== X-Received: by 2002:a17:902:6948:: with SMTP id k8mr9034740plt.223.1581795773871; Sat, 15 Feb 2020 11:42: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 q4sm11802751pfl.175.2020.02.15.11.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:42:53 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rui Miguel Silva , Hans Verkuil , 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: [RESEND PATCH v3 14/17] media: imx: csi: Lookup upstream endpoint with imx_media_get_pad_fwnode Date: Sat, 15 Feb 2020 11:41:33 -0800 Message-Id: <20200215194136.10131-15-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384067 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 4FFA614E3 for ; Sat, 15 Feb 2020 19:43:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 201B822314 for ; Sat, 15 Feb 2020 19:43:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NcpAoq6E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728059AbgBOTnE (ORCPT ); Sat, 15 Feb 2020 14:43:04 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:39004 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbgBOTnD (ORCPT ); Sat, 15 Feb 2020 14:43:03 -0500 Received: by mail-pj1-f68.google.com with SMTP id e9so5482456pjr.4; Sat, 15 Feb 2020 11:43:01 -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=NcpAoq6EEvviv1o4kDxgs3pSIVyS7GbZVLogxs5nLR5CDykvvXBsBLEUw0+wse3AYS KAfQEXgCXI8qWJrGFBJiz3eQCezYnpAxRE4iewKp5dHLtpxJjXPLsI4bOkyMV4roFHRa jNO0HOIjNgaCd/nQmjeiGnoP/dwTeiH0GH21V0CC8sahskM6b+AxlLocUx32q/b4qlxH 2oA2CWdqn6BL8Korw8gK9V/80Zfz5Kg1LcHi6SmFVFyAxmkcIks47U+cUzY0wTilqXyC QgZkBPTVx+MxK+d2qy36PrNYNKzu8dPRPlbTp4K4FXK5fs/O+6jzm4kyRL/7LgsASRIA W84g== 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=V4wPN5krSP5fK+LCoS6/o+UtjZFvyv/8oBJSiLgcofesbK2i8qP1p38Eg41emR1Jzd ks+vIJFO/lQSzJ/nD8f9B1z+kWRiqzU6ucelxQUVdojvFD35WxVTHd5EDm+o2oIdInQf Yfl2FJuozxVUr3wcxJaw6kvl8nCLa8QXa4b/++ExtU+ySRhnF+KNEED1rZz31mRxN/EL 4SUbRpGSjqT80GhsFqrRAw12ePg0eA43EvPMoheOt/N3xviXuVa/EmEjdGMH9bcbNX2P qBIVLWi9+m5OVpBHMU/7jdSh6gWd1CzYbd2U8hI9md2OdhV2SOOkgAGH8zeRnJ6M31Xl OFsw== X-Gm-Message-State: APjAAAXKIDN90v6WYzMDfm5c9QxOq1jSbkojCby8c97fl/64yhVKUNkb iWJw8CYEi2JMmgrrB0dLQhukffqg8A4= X-Google-Smtp-Source: APXvYqxdvJ/AN9iX95koWHNnICCbr44VZWdSfUoukTDmAsbPpWEUCJTHIrQ8wAbmYqztpjxG9VGkwA== X-Received: by 2002:a17:90a:9311:: with SMTP id p17mr11009393pjo.140.1581795780973; Sat, 15 Feb 2020 11:43: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 q4sm11802751pfl.175.2020.02.15.11.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:43:00 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Hans Verkuil , 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: [RESEND PATCH v3 15/17] media: imx: Create missing links from CSI-2 receiver Date: Sat, 15 Feb 2020 11:41:34 -0800 Message-Id: <20200215194136.10131-16-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384073 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 205CC14E3 for ; Sat, 15 Feb 2020 19:43:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 009B52082F for ; Sat, 15 Feb 2020 19:43:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kkZaNiMC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727800AbgBOTnK (ORCPT ); Sat, 15 Feb 2020 14:43:10 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33158 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728079AbgBOTnJ (ORCPT ); Sat, 15 Feb 2020 14:43:09 -0500 Received: by mail-pl1-f194.google.com with SMTP id ay11so5155503plb.0; Sat, 15 Feb 2020 11:43:09 -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=kkZaNiMCto9qboPG3KkfEyftLRjsCxbl8VSUXkTJe9GEcR1BQGxAyCQUN6xEN28bxj eAmsr9FJEhMlSJNyo1C6i1PTpvt61cE7ChxwwOjF3947YQZiTLOJ+1wwb9aiPJzEBxTU pFvupsyWt271rQ8iAW8UNOfUwaPumWatdBAlFagootQZ/anSpW/tTAaF5HpG24ndm5eR IxxgrUxOC6iMI5wVTVycFocSUEyYwlOWQ3ompnUuNLYx0Su30UfbKoJRox1ot0VS/iYw Z/nmhfIEhgIJX99NkoWppTkbQwjYVLs0uDRApAGBR184SuqxZk0hiY/eL2K3bIBogWiO EufQ== 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=UgwIqscw66tYsNAWitZ1ptsvP3N0kGzo0YoNS5KzXMIyT0nr5v3k5L2vg8n+nbv3Oa 4XCCTHZLKeh9sUIALmdHm05paBmuxzqJfke1zqqLCGUrShZEHUCc/ucccYMJsll9nxPl /65jJhS5+/34LZGS3zGCxZmaJa9cjD4UYCOM0weMuLJafoqIVapVeAt9w5Yz5tJP3VO9 2B3BYSRfM4B1f7/kEOUgFdTHmjLv0X5JvJuFmFIwCgEnZoDYy6bg4PL0vLE35FJ5VVgK b9fhjasaU2EJQi55CXz09PyS+zLcbVg4hQt5pvy5f53F8HvJdWn0MVLccshppYk1U/qV Z0Cg== X-Gm-Message-State: APjAAAUcmS5ySfdkf3lo9/IenRnoh/GbviQcG/ej5hjvjL8mOEwYeBh4 pSPy+Wo6/jcrbVRvIwtj2oPEu6ks1Bo= X-Google-Smtp-Source: APXvYqwzjKJzHTQI7d9t9TLy5kd0/CNhq95OAzyw4PDTakvup3633irweQWCqYwCy5uD7iB0l1GPVw== X-Received: by 2002:a17:90a:608:: with SMTP id j8mr11070072pjj.85.1581795788407; Sat, 15 Feb 2020 11:43:08 -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 q4sm11802751pfl.175.2020.02.15.11.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:43:07 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Hans Verkuil , 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: [RESEND PATCH v3 16/17] media: imx: silence a couple debug messages Date: Sat, 15 Feb 2020 11:41:35 -0800 Message-Id: <20200215194136.10131-17-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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 Sat Feb 15 19:41:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11384071 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 14D8314E3 for ; Sat, 15 Feb 2020 19:43:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA357217F4 for ; Sat, 15 Feb 2020 19:43:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S78uU5EL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728097AbgBOTnO (ORCPT ); Sat, 15 Feb 2020 14:43:14 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42564 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728079AbgBOTnM (ORCPT ); Sat, 15 Feb 2020 14:43:12 -0500 Received: by mail-pg1-f193.google.com with SMTP id w21so6901975pgl.9; Sat, 15 Feb 2020 11:43:11 -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=S78uU5ELv/QGHroNn0uGOcuYzw18JAgX+7W/Y+sH2djZV6Vh7nNYxxoxFE3sHWuBoX 6BBzuJNdmRimqXlI/HqIyTIJ2GfkC7+O8766q44qqEidVEthYlMIYEPl07bL9Wgep32f vjePn3AZeAPDj3Bg+7s/mo4uNYimgtk3dTWYIQMWILZoa0Eee8MqzHDueQapO93VX0Pg 7/DrRSQMZnLMCIWQN5xjQ68AD0KaEoZ8s5xm2BddTE48VERtoFMniIMhANWsX0kwvEuZ J9qtsO35u1pFAxGnFyn6mAmZv0ZRm8/otvzSQIklu4h3EPPvKIrXzya2Xdpnkk3k7xE3 URtQ== 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=iXllR2+P9QBW8+2ubcJgXUlApBqoiS9HDF6FotIfZAzJV5oP3ZENYXoMJwL8XVCROB Z1FxOnCWcd2fSD+zpPtgygIJL1EoDYwk9WmBsdovc3KTqCWnxizMUprBOhdO+esjsmQk iz9u9FI2/o6Xp2RYUMpby5FpYtl6oQYPUPlv+xUNv3sv6IWeNx3E2S1aK70AjocZamb2 oQsmr8bNdUEiiWtonEmzPU1CuAXgGmbgenGmKsDgpKpbVcTwXe4kD7e7YbOO9IXg9a3b e8/OrVgdAFfSRLGm+NGIsRSQcdpSW9eKsqtk7Grx7NTiVUJYDR+Y+1CJZm0OD/InuKTQ 1Ukw== X-Gm-Message-State: APjAAAXFpaqJNty/9Q+SFEacZTisHnG0yPDMKLNCOcZHAUxoIU0GSDc+ aOngbsYe7VDDWn7skKe5Tani1SB8AHQ= X-Google-Smtp-Source: APXvYqwczQn4UX/8KSaTLZ7YHrgD3Ijj7sbqrRkHMXnOMUogEhVvwFylvxV8ataNMmBYV8zmnCZ8yg== X-Received: by 2002:a63:d207:: with SMTP id a7mr10044400pgg.225.1581795791183; Sat, 15 Feb 2020 11:43:11 -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 q4sm11802751pfl.175.2020.02.15.11.43.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:43:10 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Rui Miguel Silva , 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: [RESEND PATCH v3 17/17] media: imx: TODO: Remove media link creation todos Date: Sat, 15 Feb 2020 11:41:36 -0800 Message-Id: <20200215194136.10131-18-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200215194136.10131-1-slongerbeam@gmail.com> References: <20200215194136.10131-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