From patchwork Tue Mar 3 23:42:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418953 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 33EB11395 for ; Tue, 3 Mar 2020 23:43:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 11DB820842 for ; Tue, 3 Mar 2020 23:43:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rK+ilurY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728367AbgCCXnJ (ORCPT ); Tue, 3 Mar 2020 18:43:09 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:34422 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbgCCXnJ (ORCPT ); Tue, 3 Mar 2020 18:43:09 -0500 Received: by mail-pj1-f65.google.com with SMTP id f2so1741949pjq.1 for ; Tue, 03 Mar 2020 15:43:08 -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=WldNcB0ZUA0C59QCiXBTJolDLh/hIPr21BH76I/kQ7w=; b=rK+ilurYTS4QXIMl2Auhh3YRLUyZuHvy2RJp4hDUJ7tFNlr7rVcvnPY2M5VTw3oFlI m+glKgc4RNh1xMq+4Au06SSInC7Azs/qparoYonPaqmgnEMzcAiygKkKwcnWCRYtHSH7 UFu6y3jifftx1IhrsBH0ysmIyf0jUlhe4ii3JWxxwRe1KI+dF5yMecn9QdWLmRK8dVW9 bT2uv0PyCy61rmlZ96ecnH+xPCruJpXKJI5WC22TqY3LX7r81AEY8nWt7gX5LbPWFRWP KPsnpfVQqBsWz5X+zu1hNPpjBcyUrWSC08bQtAIHkcdJHWr98F38BRXN51MJ/8V30W2h 8dQg== 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=WldNcB0ZUA0C59QCiXBTJolDLh/hIPr21BH76I/kQ7w=; b=cdDpWj4rOb8SIVm1Agq346VXzDxKeknto0hTw/KZIpxVev5IQJtXjCjCchWbyxDP7s TrBwpI8ioGmHJC8zmobiFryvN4muhMPwui/Zg/JRoWbr2n777sJh8bB2cHBdlyuX+1I5 shdbFl2FPz8eQlTCiiL50RexMCAy+Z5OPE3pE2HthACUoZrBhIxG3Y3Il57HG7RxEwHU A8BSh0fFD3mjcWRlVYA9h+NTCL4XcHpzqwG9Vrpr4uZeRm0WvwV0R1l9XFDh3PNmR0tl ZL4pS5GQALNy7XmXKNkzsXVKz4cWjHHdJjonom8+rMjEt0ImL/F66ba3tM1Hb5RrvXOg YPUA== X-Gm-Message-State: ANhLgQ3wcFXiWYLGq9z1FOLdxjNQeWSfgcLkolevYk5SaVKw7nHeuvI4 WiyVOf5LrX7W2m34R0oTy3NVWLMtV/A= X-Google-Smtp-Source: ADFU+vsnhd0rxsOU4JcKZRKdtpxxMNk6q8qNC6NWUKfhvmo8KqSKiQvbs3PpJdaiQRHJn0Kjiw2+hQ== X-Received: by 2002:a17:90a:d103:: with SMTP id l3mr17666pju.91.1583278988125; Tue, 03 Mar 2020 15:43:08 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:07 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 01/17] media: entity: Pass entity to get_fwnode_pad operation Date: Tue, 3 Mar 2020 15:42:40 -0800 Message-Id: <20200303234256.8928-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 Reviewed-by: Laurent Pinchart --- 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 211279c5fd77..12b45e669bcc 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -386,7 +386,7 @@ int media_entity_get_fwnode_pad(struct media_entity *entity, if (ret) return ret; - ret = entity->ops->get_fwnode_pad(&endpoint); + ret = entity->ops->get_fwnode_pad(entity, &endpoint); if (ret < 0) return ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 8cb2c504a05c..cde80ad029b7 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -212,7 +212,8 @@ struct media_pad { * mutex held. */ struct media_entity_operations { - int (*get_fwnode_pad)(struct fwnode_endpoint *endpoint); + int (*get_fwnode_pad)(struct media_entity *entity, + struct fwnode_endpoint *endpoint); int (*link_setup)(struct media_entity *entity, const struct media_pad *local, const struct media_pad *remote, u32 flags); From patchwork Tue Mar 3 23:42:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418955 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 522471395 for ; Tue, 3 Mar 2020 23:43:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 30AE02072D for ; Tue, 3 Mar 2020 23:43:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aCq1K/12" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728380AbgCCXnL (ORCPT ); Tue, 3 Mar 2020 18:43:11 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34204 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbgCCXnL (ORCPT ); Tue, 3 Mar 2020 18:43:11 -0500 Received: by mail-pg1-f195.google.com with SMTP id t3so70173pgn.1 for ; Tue, 03 Mar 2020 15:43: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=da6/kHTa4PmSLjQMbuwmheSk9zUOW8puN02Um2cjqfY=; b=aCq1K/12PXEkM8yC3VgArgoUYGauSVUmUkL+HjXkGfMVdkBO+NGB3SMNNzsuBepora eGkdxS2dl6rvLgaCe6rF95nhyRJQ1lpbFrYqvM6dWB7tX9F/e6IW8OK3xH3rCWDxRzLG T3bih4hRYhWmDOhi4WU8IxGUvWAoGA62U7QhU6FxHIIheW1mtUOtdvwx4RDIwi+HgMzF RI84Pusr3oQ1jTEGVUwedUCRDBrQK1zKH9WcLuaOWxX2oNaf/gZna1+8FsxMmaqJNw29 90sVuUlQzMWTxd65hWFJasYULkGq9mhilVkqtG21pdEhaI/wyEEauoBpMTPp2qpJcdBA b5VQ== 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=da6/kHTa4PmSLjQMbuwmheSk9zUOW8puN02Um2cjqfY=; b=B3n30OTaqSyYMZ3+5gnQnLC+ZjErP+UeQHoYyFnTgJj3KBk4DIZcAvkk0QMPVV+cXA 9BBY333w9RDYZd2hJDnKw/9jE4uHcStapkUJHYuTib0Lb7e+DKjb/wBsTo1LOQBwhAXc 8oIRFlgihsydHqCxXNQygu7ePJjk9ApyVTiUgSjM9zN1xaN0DvBit/P9JddBxrDgio9R dekCGBggykBA0xRpJz2ujF/w3olDZV+lRq50UQuo9qBQc3Rt5HLykog+7cLiuoOScWRq uAwt7e+sI6Vb1Unfqeh/W1lI3Pt09kbVBbWqdvw28i9SyDdUwDp48MkErtgXHQyp/SDH adqg== X-Gm-Message-State: ANhLgQ28P6ZvBBOvkMflU7pXkNTSCIOItT11iKLg5v/tOKMWoc1RK5wU bGy+O5IZHFs+8vYnHHzAOhQM/fTW+pc= X-Google-Smtp-Source: ADFU+vvsLgpZ+HCRuKVE4YovNzsTULV3ubxG/a4KFsRfViFqVpqisGf+XHTlM6g98lwuVnfGAU4f7w== X-Received: by 2002:aa7:96f6:: with SMTP id i22mr184044pfq.61.1583278989750; Tue, 03 Mar 2020 15:43:09 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:09 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 02/17] media: video-mux: Parse information from firmware without using callbacks Date: Tue, 3 Mar 2020 15:42:41 -0800 Message-Id: <20200303234256.8928-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 using the convenience function v4l2_async_register_fwnode_subdev(), parse the video-mux input endpoints and set up the async sub-devices without using callbacks. The video-mux knows which ports it must parse (the input ports) and how to handle unconnected remotes, so it makes the code simpler to transfer control of endpoint parsing to the driver. Signed-off-by: Steve Longerbeam --- drivers/media/platform/video-mux.c | 70 ++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index ddd0e338f9e4..7b6c96a29aa5 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; @@ -330,36 +331,49 @@ static const struct v4l2_subdev_ops video_mux_subdev_ops = { .video = &video_mux_subdev_video_ops, }; -static int video_mux_parse_endpoint(struct device *dev, - struct v4l2_fwnode_endpoint *vep, - struct v4l2_async_subdev *asd) -{ - /* - * it's not an error if remote is missing on a video-mux - * input port, return -ENOTCONN to skip this endpoint with - * no error. - */ - return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN; -} - static int video_mux_async_register(struct video_mux *vmux, unsigned int num_input_pads) { - unsigned int i, *ports; + unsigned int i; int ret; - ports = kcalloc(num_input_pads, sizeof(*ports), GFP_KERNEL); - if (!ports) - return -ENOMEM; - 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), - ports, num_input_pads, video_mux_parse_endpoint); + for (i = 0; i < num_input_pads; i++) { + struct v4l2_async_subdev *asd; + struct fwnode_handle *ep; - kfree(ports); - return ret; + ep = fwnode_graph_get_endpoint_by_id( + dev_fwnode(vmux->subdev.dev), i, 0, + FWNODE_GRAPH_ENDPOINT_NEXT); + if (!ep) + continue; + + asd = kzalloc(sizeof(*asd), GFP_KERNEL); + if (!asd) { + fwnode_handle_put(ep); + return -ENOMEM; + } + + ret = v4l2_async_notifier_add_fwnode_remote_subdev( + &vmux->notifier, ep, asd); + + fwnode_handle_put(ep); + + if (ret) { + kfree(asd); + /* OK if asd already exists */ + if (ret != -EEXIST) + return ret; + } + } + + ret = v4l2_async_subdev_notifier_register(&vmux->subdev, + &vmux->notifier); + if (ret) + return ret; + + return v4l2_async_register_subdev(&vmux->subdev); } static int video_mux_probe(struct platform_device *pdev) @@ -434,7 +448,13 @@ static int video_mux_probe(struct platform_device *pdev) vmux->subdev.entity.ops = &video_mux_ops; - return video_mux_async_register(vmux, num_pads - 1); + ret = video_mux_async_register(vmux, num_pads - 1); + if (ret) { + v4l2_async_notifier_unregister(&vmux->notifier); + v4l2_async_notifier_cleanup(&vmux->notifier); + } + + return ret; } static int video_mux_remove(struct platform_device *pdev) @@ -442,6 +462,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); From patchwork Tue Mar 3 23:42:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418957 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 B354414B7 for ; Tue, 3 Mar 2020 23:43:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FFDB20848 for ; Tue, 3 Mar 2020 23:43:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OOBOylkb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728389AbgCCXnO (ORCPT ); Tue, 3 Mar 2020 18:43:14 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40398 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbgCCXnN (ORCPT ); Tue, 3 Mar 2020 18:43:13 -0500 Received: by mail-pg1-f194.google.com with SMTP id t24so57035pgj.7 for ; Tue, 03 Mar 2020 15:43: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=ayKqejKOnrvGn3Gt6KUwE9Eg6tbKPqBovfizospOrd0=; b=OOBOylkbTY76ulbBqhazf07EkfIFRkMiFdCxWzSBqvcxpI/vQ+Nbkwzov7mqeuLZXd emMoZQo7+NiWQJsGxu8jl6Oim2MAo2kGrPb6L70A7b58IctqZKMCnNhMOXMX3c5070J4 L9Vo4OUSWjMJGqkCw0dzozVmgZ6w7Z+M1OFX9yfPYfFPp1Bd4KnvgIdLnrNp5j8CHHNj sYL6NfPWo+f9eNR2BPV/6F1ZsrSRLi4HrUJx65b4VyMgTXlrnYIctCdpX18KOfaY/LKp E4bMEhkgo0bx2S60pKc/VSlWhOUAHS0/Xip+6EzTM8ebqtdzOn9KBWb6I4UWoG3mpl4C QuXA== 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=ayKqejKOnrvGn3Gt6KUwE9Eg6tbKPqBovfizospOrd0=; b=t6hs0JRcYWxsqQV2hDCxhtVv8/wx63ManquyQG5omhL5hxu8FoRadCCkSKsZPhwpjq bqBpD1q+IJrH9BNs63VPYig+VbDv2W7CpAl07V4kB3+bIEyUBeOii1IPmOyWsjFPDzyp 8pXg0SL4AH/O2nV0GlJgvg8t4hopBpAPQKb8Y5hdkcZFxb7pqS/+MuOGOER0VYHyI0dW o2sxV3HUJ/x82mW6VrwTb6zlwTQpRzG7hjTzj6nF3KyVO2f1taISNnYPBhJk3VgaPsui ZrJBn2t8oHK6g5q6q2vqQ9f9KHtTyE++dyG6VOMSIgscRpbXmTtsrtIUGLBMvRxYErZ5 yCag== X-Gm-Message-State: ANhLgQ3CqZQcUse49y0jt1P58AYPlXlKL7JjcN2SEbXAbdapUiTv8OA1 vIp/jbuzIGDe0yA3YUEMFoIItPre9fQ= X-Google-Smtp-Source: ADFU+vu1IFdWOhwJZwGNrZW7TpR6lqcWisNnwMk8kU/NVMCNFg8IQr7kBkIuAf1OZF+3OEdz0S2+Dw== X-Received: by 2002:aa7:8755:: with SMTP id g21mr221318pfo.36.1583278991742; Tue, 03 Mar 2020 15:43:11 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:11 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 03/17] media: imx: Parse information from firmware without using callbacks Date: Tue, 3 Mar 2020 15:42:42 -0800 Message-Id: <20200303234256.8928-4-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 using the convenience functions v4l2_async_notifier_parse_fwnode_endpoints*() or v4l2_async_register_fwnode_subdev(), parse the input endpoints and set up the async sub-devices without using callbacks. The drivers know which ports it must parse and how to handle unconnected remotes, so it makes the code simpler to transfer control of endpoint parsing to the driver. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 78 +++++++++---------- drivers/staging/media/imx/imx6-mipi-csi2.c | 70 ++++++++++++----- drivers/staging/media/imx/imx7-media-csi.c | 53 ++++++++++--- drivers/staging/media/imx/imx7-mipi-csis.c | 91 +++++++++++++++------- 4 files changed, 192 insertions(+), 100 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index b60ed4f22f6d..f409fca88dcf 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; @@ -1864,59 +1866,49 @@ static const struct v4l2_subdev_internal_ops csi_internal_ops = { .unregistered = csi_unregistered, }; -static int imx_csi_parse_endpoint(struct device *dev, - struct v4l2_fwnode_endpoint *vep, - struct v4l2_async_subdev *asd) -{ - return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN; -} - static int imx_csi_async_register(struct csi_priv *priv) { - struct v4l2_async_notifier *notifier; - struct fwnode_handle *fwnode; + struct v4l2_async_subdev *asd = NULL; + struct fwnode_handle *ep; unsigned int port; int ret; - notifier = kzalloc(sizeof(*notifier), GFP_KERNEL); - if (!notifier) - return -ENOMEM; - - v4l2_async_notifier_init(notifier); - - fwnode = dev_fwnode(priv->dev); + v4l2_async_notifier_init(&priv->notifier); /* get this CSI's port id */ - ret = fwnode_property_read_u32(fwnode, "reg", &port); - if (ret < 0) - goto out_free; - - ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port( - priv->dev->parent, notifier, sizeof(struct v4l2_async_subdev), - port, imx_csi_parse_endpoint); + ret = fwnode_property_read_u32(dev_fwnode(priv->dev), "reg", &port); if (ret < 0) - goto out_cleanup; + return ret; - ret = v4l2_async_subdev_notifier_register(&priv->sd, notifier); - if (ret < 0) - goto out_cleanup; + ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(priv->dev->parent), + port, 0, + FWNODE_GRAPH_ENDPOINT_NEXT); + if (ep) { + asd = kzalloc(sizeof(*asd), GFP_KERNEL); + if (!asd) { + fwnode_handle_put(ep); + return -ENOMEM; + } - ret = v4l2_async_register_subdev(&priv->sd); - if (ret < 0) - goto out_unregister; + ret = v4l2_async_notifier_add_fwnode_remote_subdev( + &priv->notifier, ep, asd); - priv->sd.subdev_notifier = notifier; + fwnode_handle_put(ep); - return 0; + if (ret) { + kfree(asd); + /* OK if asd already exists */ + if (ret != -EEXIST) + return ret; + } + } -out_unregister: - v4l2_async_notifier_unregister(notifier); -out_cleanup: - v4l2_async_notifier_cleanup(notifier); -out_free: - kfree(notifier); + ret = v4l2_async_subdev_notifier_register(&priv->sd, + &priv->notifier); + if (ret) + return ret; - return ret; + return v4l2_async_register_subdev(&priv->sd); } static int imx_csi_probe(struct platform_device *pdev) @@ -1996,9 +1988,13 @@ static int imx_csi_probe(struct platform_device *pdev) ret = imx_csi_async_register(priv); if (ret) - goto free; + goto cleanup; return 0; + +cleanup: + v4l2_async_notifier_unregister(&priv->notifier); + v4l2_async_notifier_cleanup(&priv->notifier); free: v4l2_ctrl_handler_free(&priv->ctrl_hdlr); mutex_destroy(&priv->lock); @@ -2012,6 +2008,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); diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index cd3dd6e33ef0..fdd763587e6c 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; @@ -530,34 +531,59 @@ static const struct v4l2_subdev_internal_ops csi2_internal_ops = { .registered = csi2_registered, }; -static int csi2_parse_endpoint(struct device *dev, - struct v4l2_fwnode_endpoint *vep, - struct v4l2_async_subdev *asd) +static int csi2_async_register(struct csi2_dev *csi2) { - struct v4l2_subdev *sd = dev_get_drvdata(dev); - struct csi2_dev *csi2 = sd_to_dev(sd); + struct v4l2_fwnode_endpoint vep = { + .bus_type = V4L2_MBUS_CSI2_DPHY, + }; + struct v4l2_async_subdev *asd = NULL; + struct fwnode_handle *ep; + int ret; - if (!fwnode_device_is_available(asd->match.fwnode)) { - v4l2_err(&csi2->sd, "remote is not available\n"); - return -EINVAL; - } + v4l2_async_notifier_init(&csi2->notifier); - if (vep->bus_type != V4L2_MBUS_CSI2_DPHY) { - v4l2_err(&csi2->sd, "invalid bus type, must be MIPI CSI2\n"); - return -EINVAL; - } + ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(csi2->dev), 0, 0, + FWNODE_GRAPH_ENDPOINT_NEXT); + if (!ep) + return -ENOTCONN; + + ret = v4l2_fwnode_endpoint_parse(ep, &vep); + if (ret) + goto err_parse; - csi2->bus = vep->bus.mipi_csi2; + csi2->bus = vep.bus.mipi_csi2; dev_dbg(csi2->dev, "data lanes: %d\n", csi2->bus.num_data_lanes); dev_dbg(csi2->dev, "flags: 0x%08x\n", csi2->bus.flags); - return 0; + asd = kzalloc(sizeof(*asd), GFP_KERNEL); + if (!asd) { + ret = -ENOMEM; + goto err_parse; + } + + ret = v4l2_async_notifier_add_fwnode_remote_subdev( + &csi2->notifier, ep, asd); + if (ret) + goto err_parse; + + fwnode_handle_put(ep); + + ret = v4l2_async_subdev_notifier_register(&csi2->sd, + &csi2->notifier); + if (ret) + return ret; + + return v4l2_async_register_subdev(&csi2->sd); + +err_parse: + fwnode_handle_put(ep); + kfree(asd); + return ret; } static int csi2_probe(struct platform_device *pdev) { - unsigned int sink_port = 0; struct csi2_dev *csi2; struct resource *res; int i, ret; @@ -636,15 +662,15 @@ static int csi2_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &csi2->sd); - ret = v4l2_async_register_fwnode_subdev( - &csi2->sd, sizeof(struct v4l2_async_subdev), - &sink_port, 1, csi2_parse_endpoint); + ret = csi2_async_register(csi2); if (ret) - goto dphy_off; + goto clean_notifier; return 0; -dphy_off: +clean_notifier: + v4l2_async_notifier_unregister(&csi2->notifier); + v4l2_async_notifier_cleanup(&csi2->notifier); clk_disable_unprepare(csi2->dphy_clk); pllref_off: clk_disable_unprepare(csi2->pllref_clk); @@ -658,6 +684,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..776eb42ae5c8 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]; @@ -1179,11 +1180,41 @@ static const struct v4l2_subdev_internal_ops imx7_csi_internal_ops = { .unregistered = imx7_csi_unregistered, }; -static int imx7_csi_parse_endpoint(struct device *dev, - struct v4l2_fwnode_endpoint *vep, - struct v4l2_async_subdev *asd) +static int imx7_csi_async_register(struct imx7_csi *csi) { - return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL; + struct v4l2_async_subdev *asd = NULL; + struct fwnode_handle *ep; + int ret; + + v4l2_async_notifier_init(&csi->notifier); + + ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(csi->dev), 0, 0, + FWNODE_GRAPH_ENDPOINT_NEXT); + if (ep) { + asd = kzalloc(sizeof(*asd), GFP_KERNEL); + if (!asd) { + fwnode_handle_put(ep); + return -ENOMEM; + } + + ret = v4l2_async_notifier_add_fwnode_remote_subdev( + &csi->notifier, ep, asd); + + fwnode_handle_put(ep); + + if (ret) { + kfree(asd); + /* OK if asd already exists */ + if (ret != -EEXIST) + return ret; + } + } + + ret = v4l2_async_subdev_notifier_register(&csi->sd, &csi->notifier); + if (ret) + return ret; + + return v4l2_async_register_subdev(&csi->sd); } static int imx7_csi_probe(struct platform_device *pdev) @@ -1266,19 +1297,21 @@ static int imx7_csi_probe(struct platform_device *pdev) if (ret < 0) goto free; - ret = v4l2_async_register_fwnode_subdev(&csi->sd, - sizeof(struct v4l2_async_subdev), - NULL, 0, - imx7_csi_parse_endpoint); + ret = imx7_csi_async_register(csi); if (ret) - goto free; + goto subdev_notifier_cleanup; return 0; +subdev_notifier_cleanup: + v4l2_async_notifier_unregister(&csi->notifier); + v4l2_async_notifier_cleanup(&csi->notifier); + free: v4l2_ctrl_handler_free(&csi->ctrl_hdlr); cleanup: + v4l2_async_notifier_unregister(&imxmd->notifier); v4l2_async_notifier_cleanup(&imxmd->notifier); v4l2_device_unregister(&imxmd->v4l2_dev); media_device_unregister(&imxmd->md); @@ -1303,6 +1336,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..7e872d8f51e0 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; @@ -827,33 +828,11 @@ static int mipi_csis_parse_dt(struct platform_device *pdev, static int mipi_csis_pm_resume(struct device *dev, bool runtime); -static int mipi_csis_parse_endpoint(struct device *dev, - struct v4l2_fwnode_endpoint *ep, - struct v4l2_async_subdev *asd) -{ - struct v4l2_subdev *mipi_sd = dev_get_drvdata(dev); - struct csi_state *state = mipi_sd_to_csis_state(mipi_sd); - - if (ep->bus_type != V4L2_MBUS_CSI2_DPHY) { - dev_err(dev, "invalid bus type, must be MIPI CSI2\n"); - return -EINVAL; - } - - state->bus = ep->bus.mipi_csi2; - - dev_dbg(state->dev, "data lanes: %d\n", state->bus.num_data_lanes); - dev_dbg(state->dev, "flags: 0x%08x\n", state->bus.flags); - - return 0; -} - static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, struct platform_device *pdev, const struct v4l2_subdev_ops *ops) { struct csi_state *state = mipi_sd_to_csis_state(mipi_sd); - unsigned int sink_port = 0; - int ret; v4l2_subdev_init(mipi_sd, ops); mipi_sd->owner = THIS_MODULE; @@ -878,17 +857,58 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, state->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK; state->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_pads_init(&mipi_sd->entity, CSIS_PADS_NUM, - state->pads); + return media_entity_pads_init(&mipi_sd->entity, CSIS_PADS_NUM, + state->pads); +} + +static int mipi_csis_async_register(struct csi_state *state) +{ + struct v4l2_fwnode_endpoint vep = { + .bus_type = V4L2_MBUS_CSI2_DPHY, + }; + struct v4l2_async_subdev *asd = NULL; + struct fwnode_handle *ep; + int ret; + + v4l2_async_notifier_init(&state->notifier); + + ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(state->dev), 0, 0, + FWNODE_GRAPH_ENDPOINT_NEXT); + if (!ep) + return -ENOTCONN; + + ret = v4l2_fwnode_endpoint_parse(ep, &vep); + if (ret) + goto err_parse; + + state->bus = vep.bus.mipi_csi2; + + dev_dbg(state->dev, "data lanes: %d\n", state->bus.num_data_lanes); + dev_dbg(state->dev, "flags: 0x%08x\n", state->bus.flags); + + asd = kzalloc(sizeof(*asd), GFP_KERNEL); + if (!asd) { + ret = -ENOMEM; + goto err_parse; + } + + ret = v4l2_async_notifier_add_fwnode_remote_subdev( + &state->notifier, ep, asd); + if (ret) + goto err_parse; + + fwnode_handle_put(ep); + + ret = v4l2_async_subdev_notifier_register(&state->mipi_sd, + &state->notifier); if (ret) return ret; - ret = v4l2_async_register_fwnode_subdev(mipi_sd, - sizeof(struct v4l2_async_subdev), - &sink_port, 1, - mipi_csis_parse_endpoint); - if (ret < 0) - dev_err(&pdev->dev, "async fwnode register failed: %d\n", ret); + return v4l2_async_register_subdev(&state->mipi_sd); + +err_parse: + fwnode_handle_put(ep); + kfree(asd); return ret; } @@ -995,6 +1015,12 @@ static int mipi_csis_probe(struct platform_device *pdev) if (ret < 0) goto disable_clock; + ret = mipi_csis_async_register(state); + if (ret < 0) { + dev_err(&pdev->dev, "async register failed: %d\n", ret); + goto cleanup; + } + memcpy(state->events, mipi_csis_events, sizeof(state->events)); mipi_csis_debugfs_init(state); @@ -1013,7 +1039,10 @@ static int mipi_csis_probe(struct platform_device *pdev) unregister_all: mipi_csis_debugfs_exit(state); +cleanup: 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 +1130,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); From patchwork Tue Mar 3 23:42:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418959 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 CBB5C14B7 for ; Tue, 3 Mar 2020 23:43:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A094D20848 for ; Tue, 3 Mar 2020 23:43:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DM7/C7NH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728390AbgCCXnP (ORCPT ); Tue, 3 Mar 2020 18:43:15 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40408 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbgCCXnP (ORCPT ); Tue, 3 Mar 2020 18:43:15 -0500 Received: by mail-pf1-f195.google.com with SMTP id l184so2315602pfl.7 for ; Tue, 03 Mar 2020 15:43:14 -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=pThP6NC8TXqIZgF+q2FNoYaQrWxsRa/xWyaf2zAr4/Y=; b=DM7/C7NHAwc0ymSi77dnPLbuef6d4Q9Mfx2OidTlosfRkhBjAvAHo0oCkLrkwf8Be5 FpCXPpVfFQPxuWLblpKUwNhWYwkUxSVYvL0rk9tnvfgCZcrdLuPrcMMGu6ViTeZyuPUv taExSTu8dWOJaPWK3apKJq/FfRbB/zkDKlqbKgnTvTAEAeIKwtMuEP/EoljPsvNA2nPR YpGlt1AP3LuIWKLVS/eo64PYtMj8qd4XAJU9pYN3nJy6Wrl8KnGFnk16tuSpSPljDY0G tyNK1nm3Y9zBMMMkFtjYh/w5AHfTXEF6r5Y3crlEkMjOtdARGqBe0QP3tsbnWjhxEgs2 XOdw== 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=pThP6NC8TXqIZgF+q2FNoYaQrWxsRa/xWyaf2zAr4/Y=; b=rPDtxHtvt+DZT4KG9kXUUy5ApGOhpFWLIyL5nJkYrdr3ILrQIeW4qQBJaDiZEly4Vp Lq66OpKIWtByvL3JTtSKfl6uBy/7hwHwGe51adm8rd0kaSW44pUoQymR0zAwJ/t+ICU7 //UmJ/EyVhV3kF8NX4puMsq/M6sFvMovlXqcjHBSs/5i+WDk2cFH0k+LYGE05pkIPRhg vMPni3Ffb8qdkdIwHua/RXPhpahFyaYRoHITuVaxVu2i2Q83+qF6+7UHq5lFnAQiDw6n ytV/hs3UPhT1+l+T9aHWekY1dRgeRfJLpvBLOxmsWzCcimF3VIXTBFebht2CwADTBwPS dJGA== X-Gm-Message-State: ANhLgQ1rvHdmY6DJaukJ+bHRuE+EKOO9lO5tewRx84doxEooTmH8FSmS 7nZ+vVKRNnnNPs9j6/9pshZ3dlBIlHQ= X-Google-Smtp-Source: ADFU+vvsNtuGZEfb5Uonpd9epsW6LzcgfBAaHj1Kusm7rsG6WGqSKkw1Jlr9wxtqqrOJvx8NqQTf1g== X-Received: by 2002:aa7:934a:: with SMTP id 10mr168281pfn.233.1583278993653; Tue, 03 Mar 2020 15:43:13 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:13 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 04/17] Revert "media: v4l2-fwnode: Add a convenience function for registering subdevs with notifiers" Date: Tue, 3 Mar 2020 15:42:43 -0800 Message-Id: <20200303234256.8928-5-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The users of v4l2_async_register_fwnode_subdev() have switched to parsing their endpoints and setting up async sub-device lists in their notifiers locally, without using the endpoint parsing callbacks. There are no more users of v4l2_async_register_fwnode_subdev() so this convenience function can be removed. This reverts commit 1634f0eded87d1f150e823fa56cd782ea0775eb2. Signed-off-by: Steve Longerbeam --- drivers/media/v4l2-core/v4l2-fwnode.c | 62 --------------------------- include/media/v4l2-fwnode.h | 38 ---------------- 2 files changed, 100 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 6ece4320e1d2..1dc18940ac0e 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -1163,68 +1163,6 @@ 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, - 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; - - if (WARN_ON(!dev)) - return -ENODEV; - - fwnode = dev_fwnode(dev); - 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, - parse_endpoint); - if (ret < 0) - goto out_cleanup; - } else { - unsigned int i; - - for (i = 0; i < num_ports; i++) { - ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port(dev, notifier, asd_struct_size, ports[i], parse_endpoint); - if (ret < 0) - goto out_cleanup; - } - } - - ret = v4l2_async_subdev_notifier_register(sd, notifier); - if (ret < 0) - goto out_cleanup; - - ret = v4l2_async_register_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; -} -EXPORT_SYMBOL_GPL(v4l2_async_register_fwnode_subdev); - MODULE_LICENSE("GPL"); MODULE_AUTHOR("Sakari Ailus "); MODULE_AUTHOR("Sylwester Nawrocki "); diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index f6a7bcd13197..caa854d2a867 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -20,7 +20,6 @@ #include #include -#include struct fwnode_handle; struct v4l2_async_notifier; @@ -369,41 +368,4 @@ v4l2_async_notifier_parse_fwnode_endpoints_by_port(struct device *dev, int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, struct v4l2_async_notifier *notifier); -/** - * v4l2_async_register_fwnode_subdev - registers a sub-device to the - * asynchronous sub-device framework - * and parses fwnode endpoints - * - * @sd: pointer to struct &v4l2_subdev - * @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 - * the driver's async sub-device struct, i.e. both - * begin at the same memory address. - * @ports: array of port id's to parse for fwnode endpoints. If NULL, will - * parse all ports owned by the sub-device. - * @num_ports: number of ports in @ports array. Ignored if @ports is NULL. - * @parse_endpoint: Driver's callback function called on each V4L2 fwnode - * 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 - * v4l2_async_notifier_parse_fwnode_endpoints_by_port(), and - * registers the sub-device notifier. The sub-device is similarly - * unregistered by calling v4l2_async_unregister_subdev(). - * - * While registered, the subdev module is marked as in-use. - * - * An error is returned if the module is no longer loaded on any attempts - * to register it. - */ -int -v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, - size_t asd_struct_size, - unsigned int *ports, - unsigned int num_ports, - parse_endpoint_func parse_endpoint); - #endif /* _V4L2_FWNODE_H */ From patchwork Tue Mar 3 23:42:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418961 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 289DF1395 for ; Tue, 3 Mar 2020 23:43:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08A9B20828 for ; Tue, 3 Mar 2020 23:43:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YWcJKSqM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728397AbgCCXnR (ORCPT ); Tue, 3 Mar 2020 18:43:17 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:43932 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbgCCXnR (ORCPT ); Tue, 3 Mar 2020 18:43:17 -0500 Received: by mail-pf1-f193.google.com with SMTP id c144so81061pfb.10 for ; Tue, 03 Mar 2020 15:43:16 -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=8uhfqYqnydZFe8c9SbO7P/6+8io27mcAmYqcApQItKE=; b=YWcJKSqMuR5iSKKeX5rX0zHZbWyopfB+tKQZi9Qw2mm36NKZiaxS3xyzVxPZJGnSFa o80uWzcMGRXyOoShIiFNE3UiewfTsxzD7AV5TBPS+TsyvDrBoTXJHdkpz49cr5V0HWet X+vT58P0teBmi6TSGrVYVzD4XxkXD+822yKAIJJZc/kihX96KAFdKZb3tVG2vpG13yh+ Vp57oCwkQ6MvnfFIP9c/weoHXrn207rGVJTTBInfl6VXPUA2ZnKLNMTTstaWFxHi06qJ Q2CV6nOEN+ajaGdHOmiyq8YfrdeccM1mtCkwiiskNpn8dg+nAmtEQfjwZ17S0lWY2nKJ Nosg== 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=8uhfqYqnydZFe8c9SbO7P/6+8io27mcAmYqcApQItKE=; b=QuzQZ1UBgZatM4pVMxkLQ+ckIEi5TjYN04ikfMNEpVD1qszSjNzckYyHyLkBDd//D5 yd1o2piuRMcAHpxOBFE3oLn7ns1dNkD4UxBNusoFuQT+8Q6UuDFcNCvgraapnSCQbkrW JboziQJVwNK2h0gkqmpAyGsYK5kvnhhxyGdYKM+Wvr/DhLGD01dm0D52S3t/hY8oCTfv Yle8cnUpMz3tpDDKW9UT65Wz392A1bGNKFX8NXacu4nw5fIxIW0liaghhshaBavH4Eae E6cru6nQF/WaqyqrzUm9vN7YHnb2NRd2TXuM+V3EPB7oLeQ+uOV/xRCyD8L+2xckDie0 Mtew== X-Gm-Message-State: ANhLgQ2tccKoBUxuFv/dJ4gAjS/rXrbD0LY+y9wNGo01g9NxlMfJvVbl GFpPmQ8jC9dK6c0oySp2akAYM4YlBKs= X-Google-Smtp-Source: ADFU+vvZYT+0vD48JPOzvXHS9JKakN2x81mCVEkguqA9F+dhZEglwW7piTABrFI0VFBAqPwUIfgTWA== X-Received: by 2002:a62:ae13:: with SMTP id q19mr201439pff.244.1583278995510; Tue, 03 Mar 2020 15:43:15 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:15 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 05/17] media: imx: csi: Implement get_fwnode_pad op Date: Tue, 3 Mar 2020 15:42:44 -0800 Message-Id: <20200303234256.8928-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 Reviewed-by: Laurent Pinchart --- 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 f409fca88dcf..35f2512ed2a9 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1827,9 +1827,32 @@ static void csi_unregistered(struct v4l2_subdev *sd) ipu_csi_put(priv->csi); } +/* + * The CSI has only one fwnode endpoint, at the sink pad. Verify the + * endpoint belongs to us, and return CSI_SINK_PAD. + */ +static int csi_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct fwnode_handle *csi_port = dev_fwnode(priv->dev); + struct fwnode_handle *csi_ep; + int ret; + + csi_ep = fwnode_get_next_child_node(csi_port, NULL); + + ret = endpoint->local_fwnode == csi_ep ? CSI_SINK_PAD : -ENXIO; + + fwnode_handle_put(csi_ep); + + return ret; +} + static const struct media_entity_operations csi_entity_ops = { .link_setup = csi_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = csi_get_fwnode_pad, }; static const struct v4l2_subdev_core_ops csi_core_ops = { From patchwork Tue Mar 3 23:42:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418963 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 A0E4C1395 for ; Tue, 3 Mar 2020 23:43:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80F7E20828 for ; Tue, 3 Mar 2020 23:43:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fq03c8XK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728399AbgCCXnT (ORCPT ); Tue, 3 Mar 2020 18:43:19 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34215 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbgCCXnS (ORCPT ); Tue, 3 Mar 2020 18:43:18 -0500 Received: by mail-pg1-f196.google.com with SMTP id t3so70296pgn.1 for ; Tue, 03 Mar 2020 15:43:18 -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=MRgADrHFv+sxso8bqXCcm68L6/PWS1nV1T4ZXE1mTTA=; b=fq03c8XKW3KkoA3u9y2Q5waI34oSosnG305qdoK/oK0hjCHa387ePGCV2BSpxYHv8Q f6OU5iRFlG0MJXCLR3QOgTaMxitwZi/jnFk/vZDJscTjn9hyRS3ELWdbOvNBYG3RwCBo cFXxwuGZdHBKTd87P/AMzzA4h/jCPyhZTx0f0CtYlFZJ0X7Rh0VYMDn8LAvWCfaG9zpX wQ6uWo3MWmjEbujGkgNd3KYmCoOqxgDP76W0sfmmnWe9rKbeD//dQ2YFz3BGFrIb5KBF jG3a+Wry/K8uUil3v3LRbEYfHeRpIgH3A/kfUD7qjQda54TNuL4rF0UrooPWcf4aV8zB wTjQ== 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=MRgADrHFv+sxso8bqXCcm68L6/PWS1nV1T4ZXE1mTTA=; b=lnJlC6i4NG0VjyrlOCWlmrPJa1/mLIFJtDiB1qIX03CAbXk4gffx74PUAbkXzYVbsJ CyrLI7ZuNpLPSJ2GBxzj8ZpsoWBKDXsURnszpMmzIv5WKNXiYwnr2NVVwTBweQVMxlrN osvJntAP0v8UKtvVVc+9Z9fwYYAnp55ue/MFCcM0tPfMFmzDb9cxCWTywK6aWrU+y6OL zhom7DXi5ASBzR37aZ+fhvzNeLaPZi6gjr/N2LLxzmPUN9hJIKsqxDjyeDMJ1qqZzAu8 ydL0rRJAsdhji03yhjN22dWzLrraI1hyZaVHROGLr1mc3TwrjYBN2m+XREmPtCh63p6q NT3A== X-Gm-Message-State: ANhLgQ33AfUkWKW42/NZyXDPC3Zr2XV1pwuM72HxTj11l0tw/MazS20H jLahtAULJe2I+wutgNJc3eBnOXnbWO0= X-Google-Smtp-Source: ADFU+vt3+kKoaC+hxfXd5r4vHfXPo3OSVpRGdS7dDX0wef1TTSOu3Xx5CG39ZOjerp+mPQHMdxi4/g== X-Received: by 2002:aa7:85c8:: with SMTP id z8mr210972pfn.66.1583278997545; Tue, 03 Mar 2020 15:43:17 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:17 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 06/17] media: imx: mipi csi-2: Implement get_fwnode_pad op Date: Tue, 3 Mar 2020 15:42:45 -0800 Message-Id: <20200303234256.8928-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 fdd763587e6c..8500207e5ea9 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -507,9 +507,37 @@ static int csi2_registered(struct v4l2_subdev *sd) 640, 480, 0, V4L2_FIELD_NONE, NULL); } +static int csi2_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct csi2_dev *csi2 = sd_to_dev(sd); + struct fwnode_handle *csi2_ep; + + /* + * If the endpoint is one of ours, return the endpoint's port + * number. This device maps port numbers and pad indexes 1:1. + */ + fwnode_graph_for_each_endpoint(dev_fwnode(csi2->dev), csi2_ep) { + if (endpoint->local_fwnode == csi2_ep) { + struct fwnode_endpoint fwep; + int ret; + + ret = fwnode_graph_parse_endpoint(csi2_ep, &fwep); + + fwnode_handle_put(csi2_ep); + + return ret ? ret : fwep.port; + } + } + + return -ENXIO; +} + static const struct media_entity_operations csi2_entity_ops = { .link_setup = csi2_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = csi2_get_fwnode_pad, }; static const struct v4l2_subdev_video_ops csi2_video_ops = { From patchwork Tue Mar 3 23:42:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418965 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 DA59814B7 for ; Tue, 3 Mar 2020 23:43:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B964D20842 for ; Tue, 3 Mar 2020 23:43:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FbUt9xm1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728433AbgCCXnW (ORCPT ); Tue, 3 Mar 2020 18:43:22 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:42211 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728415AbgCCXnW (ORCPT ); Tue, 3 Mar 2020 18:43:22 -0500 Received: by mail-pl1-f196.google.com with SMTP id u3so128503plr.9 for ; Tue, 03 Mar 2020 15:43:20 -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=UmulW+gVzwrZmHWvKjh1tlSb5HuC+mxLHVPgwHlIe0I=; b=FbUt9xm1rkh1RyWcoAnoZqbdnmx7j4FohzExpZm30pdljQLLX6BzuiwiYrlKQLd3En ZRaAxL4JZzNGE405RxJWSWlM+vtUUzrs8Jdid0LeZFEnbBMRFo2GtkjsLYGweieP5Rcv hkJCl1bNkGpI1aq4WlUHE6iTc3L6J9qgQdkrR9qnXUkbLs7RfUrxT/UtN0Ct2+OaCoWH x9W6KVr8AmtsPebrKeJa9jiM7twqWu8pZR/dG0xQn8MNRYIz0yDYzBhpaz7ez9wguoI+ WX634bZ8oxXmGKGkQB8I2K3m8c/swxIfjDEKTAFcuN7+zYLvuiUY8ZcEokKeLFlTzwOJ dsmA== 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=UmulW+gVzwrZmHWvKjh1tlSb5HuC+mxLHVPgwHlIe0I=; b=LA+qByGAyq7WEuM5gipYgDO+f7TvtBcVAHZVdoKPd/EE7hgd8qw5lVEzmPGuHw7Wir p9NuM4993wEm+cuWM+ajYT5v+/zLy4lsLRakUVN0WxQ4rwML085pVF6Pdkzo3b8c71zp EKQ8Op2R9KGajAWl/P0QT9j/TX3FxDx2f4UJfzK7wuEkMopMW/okH58X96DTDievojfN 1Kv7R0RUPFBROFciYsg8s0GL5zsjYLsmUiiQIL90yjIPRHgJZ2pDH31yKlllqLQ8PXZ9 SHxmthGbIRN3Kio746izQlmwCMdktW+3BYuLe2pptVsdv/9dAWQhD7wP4xsoOcCAYwtZ 6XbA== X-Gm-Message-State: ANhLgQ3OdKA9D/iQvoaRhzMffm2JjxJyaAosetKYBcY+nL3uPnvRUDFo 1aHRyIG3MveQHZbU6FGA/iS3D5kM/Bw= X-Google-Smtp-Source: ADFU+vuB8/nxsVHa1juMm7SqRFBY9fZmTHCnMaxkVQIVyY6jUMLGmMo6bxF60Nd94sqRrBAUvL2eGw== X-Received: by 2002:a17:902:123:: with SMTP id 32mr381607plb.38.1583278999571; Tue, 03 Mar 2020 15:43:19 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:19 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 07/17] media: video-mux: Implement get_fwnode_pad op Date: Tue, 3 Mar 2020 15:42:46 -0800 Message-Id: <20200303234256.8928-8-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 7b6c96a29aa5..f446ada82176 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -94,9 +94,38 @@ static int video_mux_link_setup(struct media_entity *entity, return ret; } +static int video_mux_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct video_mux *vmux = v4l2_subdev_to_video_mux(sd); + struct fwnode_handle *vmux_fwnode = dev_fwnode(vmux->subdev.dev); + struct fwnode_handle *vmux_ep; + + /* + * If the endpoint is one of ours, return the endpoint's port + * number. This device maps port numbers and pad indexes 1:1. + */ + fwnode_graph_for_each_endpoint(vmux_fwnode, vmux_ep) { + if (endpoint->local_fwnode == vmux_ep) { + struct fwnode_endpoint fwep; + int ret; + + ret = fwnode_graph_parse_endpoint(vmux_ep, &fwep); + + fwnode_handle_put(vmux_ep); + + return ret ? ret : fwep.port; + } + } + + return -ENXIO; +} + static const struct media_entity_operations video_mux_ops = { .link_setup = video_mux_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = video_mux_get_fwnode_pad, }; static int video_mux_s_stream(struct v4l2_subdev *sd, int enable) From patchwork Tue Mar 3 23:42:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418967 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 D8D4414B7 for ; Tue, 3 Mar 2020 23:43:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8A702072D for ; Tue, 3 Mar 2020 23:43:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sR4O67PF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728442AbgCCXnX (ORCPT ); Tue, 3 Mar 2020 18:43:23 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33745 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbgCCXnW (ORCPT ); Tue, 3 Mar 2020 18:43:22 -0500 Received: by mail-pf1-f195.google.com with SMTP id n7so2329296pfn.0 for ; Tue, 03 Mar 2020 15:43:21 -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=sR4O67PFDK1J5aO2SMM4YjzLIcIh4TnlSItBFn5CmIZXE4wrefACazjfvRM1QBbZgA Y6+3K4VDTO7nutklK/brQokcbq+RSP3zEN0hBnaeLoVPOQBRG1s6cDW3V4/iL90Agh7x 1DFwEioCwFqYtGm1oVSfb+HfbeDr08/wA9T8BQlfLEVy3c9PCr9HZO041KX1Ir9FyPMy szINe8pTUdk9eLuvnrMzfZqYo8/apzbveYxbTiIMkMsg/ESsqeubprXyqTyo1qa7NimE TkRABaIY79FTRFJng5Lod2vlhKiWUhC/vP66sziTeErqiBF1J0BeSVenSH1TBcYDjmAC 1KNg== 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=Vo2EfeBmbcEhO2pdp1U9DDtmGbcS/HPLV+ZFTYmH5JnhrDCMXh3eUwWn4d0Kh2LqwW ra/XYI9Xd0eSYGBC8PflAlVKSymM/r9Qc7gww2f8FqtoZUrPXeOHojn43DWGoDvVIOap djDBYx0obPtbvlPB5alPLJo/88qkH2y/gJ+n8wyijATpai2yA0vuwhHaZNPp4ftqqP/6 qvKhjK1M1d0N/8b/bDer0olhh5qhCozf0rKU1MmbYbOyD6j3pZpNeik1dsHw1TyJQdnF gCProHnzT8Y4FfYt6tMG2jOSZI2xOhYBdreZqUQqc3bseHygEIqXLzZ5QFqG4/gZ+KHL sLJg== X-Gm-Message-State: ANhLgQ39HjeDvduWa0iQe33eiPmPZ9KATsf6fJ/e7i5DnTDFjkMBs152 kNOEV0kDy0wMi2DQtm9ZtsPbE2GwRK0= X-Google-Smtp-Source: ADFU+vtkSmiPqq/y/3o/3gpQvWHB8YCbRzN/ibyA7FHz9Teq5V8WdcHLJHrTPQoDfbhv6Wy0aTi3ng== X-Received: by 2002:a63:e053:: with SMTP id n19mr4926976pgj.64.1583279001042; Tue, 03 Mar 2020 15:43:21 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:20 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 08/17] media: imx: Add imx_media_create_fwnode_pad_link() Date: Tue, 3 Mar 2020 15:42:47 -0800 Message-Id: <20200303234256.8928-9-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add functions to create media links between a source and sink subdevice based on fwnode endpoint connections between them. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-utils.c | 91 +++++++++++++++++++++ drivers/staging/media/imx/imx-media.h | 4 + 2 files changed, 95 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 0788a1874557..87152bd9af22 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -729,6 +729,97 @@ void imx_media_grp_id_to_sd_name(char *sd_name, int sz, u32 grp_id, int ipu_id) } EXPORT_SYMBOL_GPL(imx_media_grp_id_to_sd_name); +/* + * Look for and create a single fwnode link that connects a source + * subdevice to a sink pad. + */ +int imx_media_create_fwnode_pad_link(struct v4l2_subdev *src_sd, + struct media_pad *sink) +{ + struct fwnode_handle *endpoint; + + /* loop thru the source's fwnode endpoints */ + fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) { + struct fwnode_handle *remote_ep; + int src_idx, sink_idx, ret; + struct media_pad *src; + + remote_ep = fwnode_graph_get_remote_endpoint(endpoint); + if (!remote_ep) + continue; + + /* + * ask the sink entity to verify that this fwnode link + * actually does connect with the entity, and if so that + * it connects to its requested sink pad. + */ + sink_idx = media_entity_get_fwnode_pad(sink->entity, + remote_ep, + MEDIA_PAD_FL_SINK); + fwnode_handle_put(remote_ep); + + if (sink_idx < 0 || sink_idx != sink->index) + continue; + + src_idx = media_entity_get_fwnode_pad(&src_sd->entity, + endpoint, + MEDIA_PAD_FL_SOURCE); + if (src_idx < 0) + continue; + + /* + * found the fwnode link that works, create the media + * link for it. + */ + + fwnode_handle_put(endpoint); + + src = &src_sd->entity.pads[src_idx]; + + /* success if it already exists */ + if (media_entity_find_link(src, sink)) + return 0; + + dev_dbg(src_sd->dev, "%s:%d -> %s:%d\n", + src_sd->entity.name, src_idx, + sink->entity->name, sink_idx); + + ret = media_create_pad_link(&src_sd->entity, src_idx, + sink->entity, sink_idx, 0); + if (ret) + dev_err(src_sd->dev, + "%s:%d -> %s:%d failed with %d\n", + src_sd->entity.name, src_idx, + sink->entity->name, sink_idx, ret); + + return ret; + } + + return -ENXIO; +} +EXPORT_SYMBOL_GPL(imx_media_create_fwnode_pad_link); + +int imx_media_create_fwnode_pad_links(struct v4l2_subdev *src_sd, + struct v4l2_subdev *sink_sd) +{ + int i; + + for (i = 0; i < sink_sd->entity.num_pads; i++) { + struct media_pad *pad = &sink_sd->entity.pads[i]; + int ret; + + if (!(pad->flags & MEDIA_PAD_FL_SINK)) + continue; + + ret = imx_media_create_fwnode_pad_link(src_sd, pad); + if (ret) + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(imx_media_create_fwnode_pad_links); + struct v4l2_subdev * imx_media_find_subdev_by_fwnode(struct imx_media_dev *imxmd, struct fwnode_handle *fwnode) diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 11861191324a..f90a65ba4ced 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -183,6 +183,10 @@ int imx_media_ipu_image_to_mbus_fmt(struct v4l2_mbus_framefmt *mbus, struct ipu_image *image); void imx_media_grp_id_to_sd_name(char *sd_name, int sz, u32 grp_id, int ipu_id); +int imx_media_create_fwnode_pad_link(struct v4l2_subdev *src_sd, + struct media_pad *sink); +int imx_media_create_fwnode_pad_links(struct v4l2_subdev *src_sd, + struct v4l2_subdev *sink_sd); struct v4l2_subdev * imx_media_find_subdev_by_fwnode(struct imx_media_dev *imxmd, struct fwnode_handle *fwnode); From patchwork Tue Mar 3 23:42:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418969 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 1501D1395 for ; Tue, 3 Mar 2020 23:43:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E668520828 for ; Tue, 3 Mar 2020 23:43:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RQnyTS1G" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728445AbgCCXnY (ORCPT ); Tue, 3 Mar 2020 18:43:24 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44653 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbgCCXnY (ORCPT ); Tue, 3 Mar 2020 18:43:24 -0500 Received: by mail-pg1-f194.google.com with SMTP id a14so48116pgb.11 for ; Tue, 03 Mar 2020 15:43:23 -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=k6owUehipygcgAwE4Me8A8yJ7y3IgmI/s2YT+RYiWrU=; b=RQnyTS1GVHyM/wqenjZEcEphz5ki44UCxuB7xvFLnSSlm+E+CCKGBPXXPSuqyJMSgp cbdyE3YnZsbXfdpAez13hXgLKilYuMnWnfaffHhwvDaFeP+5H/x1cmpDCHM8G4QDr6xS ZbFw7i0P3PS+nMgeKbSwTJqWY/0emSLf+tBdGbqrNIVjL20B02j8DXhZ1x54GQYVYQ07 ROYmcrCDc2jWwSiBgE+qvn5DoXtgkMwbCUW56mlOmot7ez0NqEVGIk518TSZFqDNkRm5 0fzS5KYwwaUL0lNvcSQ4PFMXpuqixBU2WNX8zngHRsHyEIJJJ1QU/xIcziBHRqAI4FaF IFgA== 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=k6owUehipygcgAwE4Me8A8yJ7y3IgmI/s2YT+RYiWrU=; b=ZILmavwulaWLPsbvgNTVGx5H5QuztN3gd9E5/si7Q0LRNn325F7EbwX4b3iS5iDj+k 2hBvfwR3E+9/pAnqVIsYTyHyOqLCSvF8nZPrsAzE9JOX1JNEHZDm2EHyWs2Jj1DgZ4KP uHhJnB1SFni9qbfmoPmUhZz7vfD5L0tHI9Zw4L79rvp3+EireBvDqj6YW79l3IMv1DjZ WpLLjgwM10MTgD4jYqnItxt5odQHGcdqiPTcBawOnyF3+QV5lxfNTFSo33IucOI2G57G DX3tVEW3Ye+Lvi9CaBxlcgHWLKWZl8M0uPb5HZdhKHToDnARpi7HH/FKjyJj9pWCStTw A/tQ== X-Gm-Message-State: ANhLgQ2hVpjno1JOpVnehIimxmSLMr65aNxYN4wdG3ewKTg7YZMg/ju9 T3y85ICACnQoxkw87dsBAY41z2ApEgc= X-Google-Smtp-Source: ADFU+vuRm0jjviy7TdxZFlUv1X1b4torFfy4MgusLE8b9kJcAEs1+hORa8zIReIgnlMwtoLFOHDgwQ== X-Received: by 2002:a63:a741:: with SMTP id w1mr6386585pgo.131.1583279002573; Tue, 03 Mar 2020 15:43:22 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:22 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 09/17] media: video-mux: Create media links in bound notifier Date: Tue, 3 Mar 2020 15:42:48 -0800 Message-Id: <20200303234256.8928-10-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 f446ada82176..3991b1ea671c 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); @@ -360,6 +366,90 @@ static const struct v4l2_subdev_ops video_mux_subdev_ops = { .video = &video_mux_subdev_video_ops, }; +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) { @@ -397,6 +487,8 @@ static int video_mux_async_register(struct video_mux *vmux, } } + vmux->notifier.ops = &video_mux_notify_ops; + ret = v4l2_async_subdev_notifier_register(&vmux->subdev, &vmux->notifier); if (ret) From patchwork Tue Mar 3 23:42:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418971 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 54C9914B7 for ; Tue, 3 Mar 2020 23:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35C8820842 for ; Tue, 3 Mar 2020 23:43:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A0bJ/Sr8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728451AbgCCXn0 (ORCPT ); Tue, 3 Mar 2020 18:43:26 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:35834 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbgCCXn0 (ORCPT ); Tue, 3 Mar 2020 18:43:26 -0500 Received: by mail-pj1-f65.google.com with SMTP id s8so46946pjq.0 for ; Tue, 03 Mar 2020 15:43:24 -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=1tZkatKoDWfM8xQlN+YOV09B4S9XGa85i1t4wiiwXPM=; b=A0bJ/Sr826VvVDedd+k+B2P457U3N1QgyYnkOWEcOTDxhS5OjUywGBf0e/1ZfXfTzB 1Zt+poGNgB1RGOQU0A9azGFJlCELUjBHiJqmIZbCSHy5Q/w2oGuNpGKvNGPKJH+18GzF uhPt2M+BgJUuCCkIjP9FoZHQi7HuMBtwLvmSHHkOv1KL78znN80TYtCp8Uc3YGNtY1ce f0g9op8KvFzLo2la08QbLqxdZPkj00Z6/uHEaONOl/3xZMju35HAEGOIy5n/iavlBT52 HdhPWMYjjrz0rhL/Tj4viWXNBfDI0hlV/f/WS96G8GIn1kAq3JDWRgbCS22qcNAhThvJ 52dQ== 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=1tZkatKoDWfM8xQlN+YOV09B4S9XGa85i1t4wiiwXPM=; b=JS/OzRn03BRPnny+J6icShbOnQICRlvOqoaw2+o+iRJfGlTEM+Um/qWdF9qQvnw364 82kPshjceisCOAa76WAdb8SiMf2lkv2toV2Ra81APavb0FkbrhCphXAL9XinwVueR0hQ bYRJqFNo/nxHt+NI01S6deiaMin1RYoRg1KLYG/P6TUivhS4RKUslyYk4jYimfuZ0fdg t/aUn/8RupNcNJ8xF8HihCI1+LpLKqzM4nY3ZmwD2Nh+WZknMySeOZHOP/McGm2K+z0C 7WMA0xtDVhC7p8rKKxu6YH5T8xzXJGTrcTpTt0ec8InAQX8ybPKSIs4bf4brhSRMGYQv v8qg== X-Gm-Message-State: ANhLgQ0X44lRh6vpc0jBgcM3YZNGD6wjYNQpz1jF25L7zAtRvgfvbmDK x5mha8WakHQW46UdsM2ivpMkQiZ1aA0= X-Google-Smtp-Source: ADFU+vubyQ1hhBKgHV3jjgKeA7S5/pkLy77VvS9iW/lYmbdJWLY3qKn8QQfVCRpN08YGYRdexnzDHA== X-Received: by 2002:a17:902:8a89:: with SMTP id p9mr344665plo.286.1583279004119; Tue, 03 Mar 2020 15:43:24 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:23 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 10/17] media: imx: mipi csi-2: Create media links in bound notifier Date: Tue, 3 Mar 2020 15:42:49 -0800 Message-Id: <20200303234256.8928-11-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 8500207e5ea9..26c0b579e6ae 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: @@ -559,6 +564,20 @@ static const struct v4l2_subdev_internal_ops csi2_internal_ops = { .registered = csi2_registered, }; +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_async_register(struct csi2_dev *csi2) { struct v4l2_fwnode_endpoint vep = { @@ -597,6 +616,8 @@ static int csi2_async_register(struct csi2_dev *csi2) fwnode_handle_put(ep); + csi2->notifier.ops = &csi2_notify_ops; + ret = v4l2_async_subdev_notifier_register(&csi2->sd, &csi2->notifier); if (ret) From patchwork Tue Mar 3 23:42:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418973 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 5FE0D14B7 for ; Tue, 3 Mar 2020 23:43:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F95C2072D for ; Tue, 3 Mar 2020 23:43:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QwZeBa7U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728457AbgCCXn2 (ORCPT ); Tue, 3 Mar 2020 18:43:28 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40422 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728427AbgCCXn2 (ORCPT ); Tue, 3 Mar 2020 18:43:28 -0500 Received: by mail-pf1-f193.google.com with SMTP id l184so2315817pfl.7 for ; Tue, 03 Mar 2020 15:43:26 -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=u90FNeV7YRWX/ZiCG1LHsUcgglvWvd+1ge0hhU/zuqo=; b=QwZeBa7UMT7kP3/NkVSjucIxMf50WJupqQZpfxysjlOU2DKp1BeZrfkqONBpmtrqPo H649RLXAGAgbbsNDSgpjTG3h+wTRj+jlFYShxPr5LJyh74Xna3Wi8meHFsHq0ewlJXMY gnmM6rjOJ4Q4riHJRGvqItvnolx/g2L/8C4k6dgO2Bl3+JvhjAtIDi6Vpf8VOUJN93+b mSRgnDNKptQBHWP1Tc+PfQzdYW+6H7JVcJccUqaeXBDGvJHvJf3+2IILi/e8Nj3Lfe32 iP1xk7w4j7AR7zjMdgNzu6yTkfyuADMJPcO4jC+UafvHEoYs6FxeaY7Vu1JrDFzlXKKd ZDZg== 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=u90FNeV7YRWX/ZiCG1LHsUcgglvWvd+1ge0hhU/zuqo=; b=kXdw1gW/x+kDRHkuWRHL2JSx3OfkfJdDJVYqJ3DrmUIfzcLn7XKUgzPC6T3S5PE9cq N9y13KVISr5yfYiV29htW0lWo4/dxA5E56yGiImiM8gtk4KWv5n1Vu71DWlmcv5ih5/j JWQdW3vb3s87aPCrYop7VNIOYAJ1dnpIU2SXVPz0/gOWYA8nURSf23tTbU2Q/KxQs851 aiboa5MAV27kFgCCKBazc4X1SIfOUzegD1XrW/gBzFOOBKdtq5oJLzT9YuXghRLdQbzM 91wXVf+4yz5mSsFtOWL3//uEoTwyHdM1iH2uodYX54t8awnccn6z1yJWRu0ocnRY4dxK GQTg== X-Gm-Message-State: ANhLgQ2WQAecLnOOgTeFhIOtCE+ywgsVRoxBHa9OHnzhiAKn+yHXuoys WctLiqNIhcpT2FiKdyFYhT8q/DDpGUk= X-Google-Smtp-Source: ADFU+vudvLnY6xwduNuIVNM9PHoO9dNADomuWMN8mF+xcws1psN1qZUhz/q4DnZyHwwihe6Fy2exKg== X-Received: by 2002:a63:445:: with SMTP id 66mr950644pge.351.1583279006027; Tue, 03 Mar 2020 15:43:26 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:25 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 11/17] media: imx7: mipi csis: Create media links in bound notifier Date: Tue, 3 Mar 2020 15:42:50 -0800 Message-Id: <20200303234256.8928-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 7e872d8f51e0..363545127047 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); @@ -828,6 +834,20 @@ static int mipi_csis_parse_dt(struct platform_device *pdev, static int mipi_csis_pm_resume(struct device *dev, bool runtime); +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) @@ -899,6 +919,8 @@ static int mipi_csis_async_register(struct csi_state *state) fwnode_handle_put(ep); + state->notifier.ops = &mipi_csis_notify_ops; + ret = v4l2_async_subdev_notifier_register(&state->mipi_sd, &state->notifier); if (ret) From patchwork Tue Mar 3 23:42:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418975 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 E726C1395 for ; Tue, 3 Mar 2020 23:43:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C638720828 for ; Tue, 3 Mar 2020 23:43:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zy+hGwUv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728458AbgCCXn3 (ORCPT ); Tue, 3 Mar 2020 18:43:29 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45881 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728107AbgCCXn3 (ORCPT ); Tue, 3 Mar 2020 18:43:29 -0500 Received: by mail-pg1-f196.google.com with SMTP id m15so45792pgv.12 for ; Tue, 03 Mar 2020 15:43: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=0YReqWAumc7c9udJV52FSM86eqqC/L7jXq4w/Lscg1I=; b=Zy+hGwUvC++U4n5J4hvXkMd7LH7Hze1DZtHbkV8niYOaBF5MNIodnxF+97Iaw4f4Cv TJEMaYl+2o1GRJ4T7JwoN+VICb5FEi4X73tzjDJ98zShawxhxKgsJms8v0+d3UnGpCOh sBQI85s5betAl0n2+A1vL5OawwozBX7osZjyHHEnlqJnKemODIZl2pmFBG0GFTx4hwiZ 7q5045UozLLlOQNDFFL/agPjK4SAvtBskoYv3aurEY91iKZcn0xynJKz/BRCoGEjnOA/ 0q7oZObCuSNK08M5DLoysvDvRT+SsV670ohHJxO7JyqvPh53gHL4qToWJ1niO5l2e+Yp k99A== 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=0YReqWAumc7c9udJV52FSM86eqqC/L7jXq4w/Lscg1I=; b=O2+udC7jNG456EgO/QTPjQdcIHjmGjTHUJigTQO9STeZttcKhWB6nSKYBXNh/4uoMT lEOI/b7VP+bFw7OuZBIELGnAeZBXJHezH5EQ+EVG6zEEQSzrOwlfvwPoHy+/bXk3uoqZ cB2vuwmTroEdCJWkE8hY8kA+RNI3X62ojSUE+oohC1CY/CgmmVNBS/3izc9v5hOe8RoL p6Aey5q1Kinx2QlMytdvwGd5K5UDPiEfl9KRWW3a02IcUFFj7ikRTZ0G3u6wqtF3/ZHR IAtBMAJeBtPIRIbk3kzjmp6V2rSCr3CmN4ZKDKyG6/wDSGb2fmoZtjwSnnBafl+nRD7i oZPg== X-Gm-Message-State: ANhLgQ21R/mLPsDbLf7YJOO/RM/65mrpdTKNLbOfex6ucQPggYUoEBGH Hqt5sXISbGGp9bVR6FEMlJLqXQh8ZUM= X-Google-Smtp-Source: ADFU+vs/QBpgmPPG2UY9VpWTEEvTPnhSk0Nlzqmr286/QfFDiTclrv9AkXcmrEBaTrznQibKZk3YMg== X-Received: by 2002:a63:6841:: with SMTP id d62mr6014971pgc.86.1583279007663; Tue, 03 Mar 2020 15:43:27 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:27 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 12/17] media: imx7: csi: Create media links in bound notifier Date: Tue, 3 Mar 2020 15:42:51 -0800 Message-Id: <20200303234256.8928-13-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 776eb42ae5c8..88e21c13e420 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); @@ -1180,6 +1186,20 @@ static const struct v4l2_subdev_internal_ops imx7_csi_internal_ops = { .unregistered = imx7_csi_unregistered, }; +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_async_register(struct imx7_csi *csi) { struct v4l2_async_subdev *asd = NULL; @@ -1210,6 +1230,8 @@ static int imx7_csi_async_register(struct imx7_csi *csi) } } + csi->notifier.ops = &imx7_csi_notify_ops; + ret = v4l2_async_subdev_notifier_register(&csi->sd, &csi->notifier); if (ret) return ret; From patchwork Tue Mar 3 23:42:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418977 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 6BDF214B7 for ; Tue, 3 Mar 2020 23:43:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48FE620828 for ; Tue, 3 Mar 2020 23:43:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KolG0wp/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728467AbgCCXna (ORCPT ); Tue, 3 Mar 2020 18:43:30 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33757 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728107AbgCCXna (ORCPT ); Tue, 3 Mar 2020 18:43:30 -0500 Received: by mail-pf1-f195.google.com with SMTP id n7so2329450pfn.0 for ; Tue, 03 Mar 2020 15:43:30 -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=I/weKw8gqSMHerG7+ZtB0jaPIbMs+J6LkbgWE8zyS2o=; b=KolG0wp/nlZeZAto3wnTI8CtRNn86MNCy+CseiHgX+F39EPJue519oEz+MN/43A8+N RWVWIvrZlmA5Xtu6104ZweJnz2bQuXzTlsunDUTsFxCzrj8OWwZjy4yUomTiLCv1Nn8x Xk9RZyKjAJZ3pdckHpsTtpGSPZsxyc1djdS54B1jc9to0aDZn5ZgHQjQDvU+3Svajj2J d1dml8HLr/TBUbuC4kjpftXwiWXroR/qTlKvaqD8VLoTsQfJhLcBG3OTIA1+4CFMpSS+ JCFOahxdRafVKdXzUUG1cTH1lm5pJ5R53rIT0BZSMKjFIK27TPGxyVqgP61O/rFVHKmc cLQg== 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=I/weKw8gqSMHerG7+ZtB0jaPIbMs+J6LkbgWE8zyS2o=; b=D1FKead7HQAgN4+BH8xNoNl301tydh2VfNBmi9F98ygMBOrxy9aSDN8HS6L3X7xK5T Y7F1RevG3okoqWOAn/G2q/roQAIh9sifUyglA4phY0+j0MEzG6mCJRVP3bQO5WsuyyZQ ParRlrRZ6KhOIW23eUFSCGnS452JuWLyhlZE012GagAvX98q2/9OEaGV5/37Oj7QqUKZ wkWepDohNhYZyi4wOniEeoJDzPbS4b8HoiOfr7VZAE68e1EZ/XX038ZxsE9Pl4byUiLh xZ6OshaK50J1bvgDGQmcfAy5tqB0sqJ+B6jTum+5FHadl5/nj6JPju8E0Uqpg+ikLlKD XQLA== X-Gm-Message-State: ANhLgQ23J8iOFmslKbilX8/W0ADWYjKJ1yRKWIPK3iUEJHNyt2BCtPMz +3YtUv0kJVMhcA58gfdD3RE9CO2apOY= X-Google-Smtp-Source: ADFU+vuqMzyPVjNJsQntTY/2xt5idxopQleSvlethhNFKbopw1FGQ6D7e91X7dIyVyM/mKwAQ0DdJg== X-Received: by 2002:a63:d18:: with SMTP id c24mr6306470pgl.218.1583279009437; Tue, 03 Mar 2020 15:43:29 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:29 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 13/17] media: imx: csi: Create media links in bound notifier Date: Tue, 3 Mar 2020 15:42:52 -0800 Message-Id: <20200303234256.8928-14-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 35f2512ed2a9..59ab1cf72841 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; @@ -1889,6 +1894,20 @@ static const struct v4l2_subdev_internal_ops csi_internal_ops = { .unregistered = csi_unregistered, }; +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 v4l2_async_subdev *asd = NULL; @@ -1926,6 +1945,8 @@ static int imx_csi_async_register(struct csi_priv *priv) } } + priv->notifier.ops = &csi_notify_ops; + ret = v4l2_async_subdev_notifier_register(&priv->sd, &priv->notifier); if (ret) From patchwork Tue Mar 3 23:42:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418979 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 46FB314B7 for ; Tue, 3 Mar 2020 23:43:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 272D020866 for ; Tue, 3 Mar 2020 23:43:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nk4HT+Rk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728475AbgCCXnc (ORCPT ); Tue, 3 Mar 2020 18:43:32 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:56169 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728107AbgCCXnc (ORCPT ); Tue, 3 Mar 2020 18:43:32 -0500 Received: by mail-pj1-f65.google.com with SMTP id a18so34693pjs.5 for ; Tue, 03 Mar 2020 15:43:31 -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=dRqJL2C3GC4fAf71WIWo2Omz+fN++LTYE3PdtWw52Eo=; b=nk4HT+Rke6LljjPVPR8nTWLbUnjHgZ9el1cwccffqPsWqUAd6t9yv8ZPBJFJqrFQBJ BxRWqcPt8zYkOvMpyRp1DdlqpIFkaFYD9boIronIIAckFsQCiQXrUwW5hvac7cnBJsWL v/luY8iWfdYwYfJLtkIh3hCKlw0AGthCV8KZAwqzu3rWtuOjHX/cLBpkUIQi2cVjmuvm 6Q2Vli3jzX1DlR59bvHOqjGWa0MTA5YLbww77gtziAnlZhQMXyJLXLmgwAGoSG72COpL YXPnfkXSEbdlZPeNZDFPPFYuXMCNxYz6IzMeBdjcCX8gpXTC+E+jsNPK9NfOm6RJU7Ie 1iug== 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=dRqJL2C3GC4fAf71WIWo2Omz+fN++LTYE3PdtWw52Eo=; b=sxs6fGjR4w/sr7xv40J5BQM5q8A2Ik5DzxRobfT6COdQKjDO8TCAAH9JLHzvdFccDm ZlOyWUbaFvxi7iB2Zs52ROglc1/RwcPWzWQpVKJOJxXcqP5/fg4xsit78HrIF1T92feM yzXkS2AzDXh+aob4Yg8xNvJbGFzLh9a6/bc/4qlwMRlM6tq5geRNPmjWvUmdbV56zCg8 uiP7B8nvEYY1voWSihhnq0KKqyAFFXqoSofSB8R1INRkPnwOP3xtWTu+ZAgUxRBGRWkW 2QK0/NZ0F533Eb31Es6tclAVzwMUiBRK3TOKJ3Yr+PxXyjfluXd1mE8tLSEG/d/62fjE bGlw== X-Gm-Message-State: ANhLgQ3NIHfMa37iKopkvLPT7tNs0Zh29GMUPMbRqeYSBV+LxpZK1o9B 5BFoy7XZt53iQI++LlgNdEQqO7tvxAg= X-Google-Smtp-Source: ADFU+vswq1p/dVipgUiYcboT7+3+5k0VZANXa22gict4ykJTW6ny+cZggY9X0rLiHbKkMCBqSI2d5w== X-Received: by 2002:a17:902:9a85:: with SMTP id w5mr327724plp.323.1583279011047; Tue, 03 Mar 2020 15:43:31 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:30 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 14/17] media: imx: csi: Lookup upstream endpoint with imx_media_get_pad_fwnode Date: Tue, 3 Mar 2020 15:42:53 -0800 Message-Id: <20200303234256.8928-15-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 59ab1cf72841..0388d73e916c 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 88e21c13e420..9b31379611ac 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -439,9 +439,8 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, struct v4l2_fwnode_endpoint *ep, bool skip_mux) { - struct device_node *endpoint, *port; + struct fwnode_handle *endpoint; struct media_entity *src; - struct v4l2_subdev *sd; struct media_pad *pad; if (!csi->src_sd) @@ -463,29 +462,19 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, if (!pad) return -ENODEV; - sd = media_entity_to_v4l2_subdev(pad->entity); - /* To get bus type we may need to skip video mux */ if (skip_mux && src->function == MEDIA_ENT_F_VID_MUX) { - src = &sd->entity; + src = pad->entity; goto skip_video_mux; } - /* - * NOTE: this assumes an OF-graph port id is the same as a - * media pad index. - */ - port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); - if (!port) - return -ENODEV; + endpoint = imx_media_get_pad_fwnode(pad); + if (IS_ERR(endpoint)) + return PTR_ERR(endpoint); - endpoint = of_get_next_child(port, NULL); - of_node_put(port); - if (!endpoint) - return -ENODEV; + v4l2_fwnode_endpoint_parse(endpoint, ep); - v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); - of_node_put(endpoint); + fwnode_handle_put(endpoint); return 0; } From patchwork Tue Mar 3 23:42:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418981 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 163881395 for ; Tue, 3 Mar 2020 23:43:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEF2020828 for ; Tue, 3 Mar 2020 23:43:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VLyyd0kl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728483AbgCCXne (ORCPT ); Tue, 3 Mar 2020 18:43:34 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:34372 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728107AbgCCXne (ORCPT ); Tue, 3 Mar 2020 18:43:34 -0500 Received: by mail-pl1-f195.google.com with SMTP id j7so145837plt.1 for ; Tue, 03 Mar 2020 15:43:33 -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=VLyyd0kltz8/fc8No5wm7uzRRNrmuW1r+LIzH/OFX0K5JU16Cbf5B93EJYquAyVsSJ X4ccJ7ntuPQ0LAkFGpjh5PZhCvAMnoTmW7GHrxd4d/7HP5fWrv0hLA+0MlNpSF5VRAFG qxixjroFhUFH+p92qjm9OkppDR0/BPX3moo7OGsDExkVNYZhEU9kYnj91AC8KyFrMTKh ax3ueRDhjLkVx39709cncNn5wsoqH6Evbr3wcK0JFmuKwmm67ekW55V+eua9icv/CTLn IsszwxFRzdVpcLJfzaon5JMui5MoCZUFD8AteK0QbpFsw2GoKPX5skHfGNoH9yEEghjf kcDA== 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=oGj5e1OwJuiKz8kok8orCKPdfEDNF6sVSkqC8BdH8ZdGHidXr3zQ83NVLeWh5WD5ZU sQYAfN8kePoks5AMFZ++Hcmm1bQNlgjsMO3Oi331og2b/wMu2vZGLdxFqXnqs3NaO+kp XlEzz35o3wxT50AWJHtN0XDpP/zSBkUXbWCGTKXn7lnQg0TGPWcaSOE4/ucT3X5N21ut cAM9nnQiARxj6rjDWiKq/4X/nW6eMR7obtMOtxGsa7rUMkQ5OxNDDpVyL03E4RJTVv+p I6lErOXkHfITnA6ze6NlJvrEf4BxTzfOBDMmloWf5VY9TGz6fxwOEbfgoXxWqj+2iEka 9N2g== X-Gm-Message-State: ANhLgQ1KdF114Wo+4m+F7cnTST4nMwHhuIhYz7fv3CsahCcv15zmDm+3 KdkSLxuTMU3kApj6iMkHHgqI9Q95V0Y= X-Google-Smtp-Source: ADFU+vva5TJRM298r9Ngg/vKz7OuF4kS+gb8YGZy2V1PcEwnZV6MlZOK1wBX+O/bMHDwfPuupEQwCw== X-Received: by 2002:a17:902:bf08:: with SMTP id bi8mr312864plb.305.1583279012653; Tue, 03 Mar 2020 15:43:32 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:32 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 15/17] media: imx: Create missing links from CSI-2 receiver Date: Tue, 3 Mar 2020 15:42:54 -0800 Message-Id: <20200303234256.8928-16-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 Reviewed-by: Laurent Pinchart --- Changes in v3: - call a local imx-media utility imx_media_create_fwnode_pad_links(). Changes in v2: - this is a rewrite of v1 "media: imx: Use media_create_fwnode_links for external links", which only adds the missing CSI-2 receiver links. --- .../staging/media/imx/imx-media-dev-common.c | 46 +++---- drivers/staging/media/imx/imx-media-of.c | 114 ------------------ drivers/staging/media/imx/imx-media.h | 4 - 3 files changed, 17 insertions(+), 147 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-dev-common.c b/drivers/staging/media/imx/imx-media-dev-common.c index 66b505f7e8df..f7ad3cbbeec2 100644 --- a/drivers/staging/media/imx/imx-media-dev-common.c +++ b/drivers/staging/media/imx/imx-media-dev-common.c @@ -30,41 +30,31 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier, } /* - * Create the media links for all subdevs that registered. + * Create the missing media links from the CSI-2 receiver. * Called after all async subdevs have bound. */ -static int imx_media_create_links(struct v4l2_async_notifier *notifier) +static void imx_media_create_csi2_links(struct imx_media_dev *imxmd) { - struct imx_media_dev *imxmd = notifier2dev(notifier); - struct v4l2_subdev *sd; + struct v4l2_subdev *sd, *csi2 = NULL; list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { - switch (sd->grp_id) { - case IMX_MEDIA_GRP_ID_IPU_VDIC: - case IMX_MEDIA_GRP_ID_IPU_IC_PRP: - case IMX_MEDIA_GRP_ID_IPU_IC_PRPENC: - case IMX_MEDIA_GRP_ID_IPU_IC_PRPVF: - /* - * links have already been created for the - * sync-registered subdevs. - */ - break; - case IMX_MEDIA_GRP_ID_IPU_CSI0: - case IMX_MEDIA_GRP_ID_IPU_CSI1: - case IMX_MEDIA_GRP_ID_CSI: - imx_media_create_csi_of_links(imxmd, sd); - break; - default: - /* - * if this subdev has fwnode links, create media - * links for them. - */ - imx_media_create_of_links(imxmd, sd); + if (sd->grp_id == IMX_MEDIA_GRP_ID_CSI2) { + csi2 = sd; break; } } + if (!csi2) + return; - return 0; + list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { + /* skip if not a CSI or a video mux */ + if (!(sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) && + !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI) && + sd->entity.function != MEDIA_ENT_F_VID_MUX) + continue; + + imx_media_create_fwnode_pad_links(csi2, sd); + } } /* @@ -196,9 +186,7 @@ int imx_media_probe_complete(struct v4l2_async_notifier *notifier) mutex_lock(&imxmd->mutex); - ret = imx_media_create_links(notifier); - if (ret) - goto unlock; + imx_media_create_csi2_links(imxmd); ret = imx_media_create_pad_vdev_lists(imxmd); if (ret) diff --git a/drivers/staging/media/imx/imx-media-of.c b/drivers/staging/media/imx/imx-media-of.c index 2d3efd2a6dde..82e13e972e23 100644 --- a/drivers/staging/media/imx/imx-media-of.c +++ b/drivers/staging/media/imx/imx-media-of.c @@ -74,117 +74,3 @@ int imx_media_add_of_subdevs(struct imx_media_dev *imxmd, return ret; } EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs); - -/* - * Create a single media link to/from sd using a fwnode link. - * - * NOTE: this function assumes an OF port node is equivalent to - * a media pad (port id equal to media pad index), and that an - * OF endpoint node is equivalent to a media link. - */ -static int create_of_link(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd, - struct v4l2_fwnode_link *link) -{ - struct v4l2_subdev *remote, *src, *sink; - int src_pad, sink_pad; - - if (link->local_port >= sd->entity.num_pads) - return -EINVAL; - - remote = imx_media_find_subdev_by_fwnode(imxmd, link->remote_node); - if (!remote) - return 0; - - if (sd->entity.pads[link->local_port].flags & MEDIA_PAD_FL_SINK) { - src = remote; - src_pad = link->remote_port; - sink = sd; - sink_pad = link->local_port; - } else { - src = sd; - src_pad = link->local_port; - sink = remote; - sink_pad = link->remote_port; - } - - /* make sure link doesn't already exist before creating */ - if (media_entity_find_link(&src->entity.pads[src_pad], - &sink->entity.pads[sink_pad])) - return 0; - - v4l2_info(sd->v4l2_dev, "%s:%d -> %s:%d\n", - src->name, src_pad, sink->name, sink_pad); - - return media_create_pad_link(&src->entity, src_pad, - &sink->entity, sink_pad, 0); -} - -/* - * Create media links to/from sd using its device-tree endpoints. - */ -int imx_media_create_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd) -{ - struct v4l2_fwnode_link link; - struct device_node *ep; - int ret; - - for_each_endpoint_of_node(sd->dev->of_node, ep) { - ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); - if (ret) - continue; - - ret = create_of_link(imxmd, sd, &link); - v4l2_fwnode_put_link(&link); - if (ret) - return ret; - } - - return 0; -} -EXPORT_SYMBOL_GPL(imx_media_create_of_links); - -/* - * Create media links to the given CSI subdevice's sink pads, - * using its device-tree endpoints. - */ -int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *csi) -{ - struct device_node *csi_np = csi->dev->of_node; - struct device_node *ep; - - for_each_child_of_node(csi_np, ep) { - struct fwnode_handle *fwnode, *csi_ep; - struct v4l2_fwnode_link link; - int ret; - - memset(&link, 0, sizeof(link)); - - link.local_node = of_fwnode_handle(csi_np); - link.local_port = CSI_SINK_PAD; - - csi_ep = of_fwnode_handle(ep); - - fwnode = fwnode_graph_get_remote_endpoint(csi_ep); - if (!fwnode) - continue; - - fwnode = fwnode_get_parent(fwnode); - fwnode_property_read_u32(fwnode, "reg", &link.remote_port); - fwnode = fwnode_get_next_parent(fwnode); - if (is_of_node(fwnode) && - of_node_name_eq(to_of_node(fwnode), "ports")) - fwnode = fwnode_get_next_parent(fwnode); - link.remote_node = fwnode; - - ret = create_of_link(imxmd, csi, &link); - fwnode_handle_put(link.remote_node); - if (ret) - return ret; - } - - return 0; -} -EXPORT_SYMBOL_GPL(imx_media_create_csi_of_links); diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 5f23d852122f..5271b84bea9a 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -248,10 +248,6 @@ void imx_media_unregister_ipu_internal_subdevs(struct imx_media_dev *imxmd); /* imx-media-of.c */ int imx_media_add_of_subdevs(struct imx_media_dev *dev, struct device_node *np); -int imx_media_create_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd); -int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *csi); int imx_media_of_add_csi(struct imx_media_dev *imxmd, struct device_node *csi_np); From patchwork Tue Mar 3 23:42:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418983 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 A03911395 for ; Tue, 3 Mar 2020 23:43:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80BCD20842 for ; Tue, 3 Mar 2020 23:43:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TOZWuriA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728499AbgCCXnh (ORCPT ); Tue, 3 Mar 2020 18:43:37 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45065 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728107AbgCCXng (ORCPT ); Tue, 3 Mar 2020 18:43:36 -0500 Received: by mail-pf1-f194.google.com with SMTP id 2so2301211pfg.12 for ; Tue, 03 Mar 2020 15:43: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=xWXrdZ90Rqh6QAAhxL2MMK6jyJVUDs2rWHZG2jR0834=; b=TOZWuriAMFf5smnHuDqY31JDv3zdpwmGYPM9OwkX2cZ8S2D9n9256Pr0Pn+IcG8R0i AJQ1AUvmujr2w2Tr0pTYNYw8AU3fYe4Ml0vwQ4heLNDdPyvuwUj08Ce3mqSBUpHkISIj W06J2u4Cfhki2Vu1bltTU5d0HVvS6JbMQaOZybHHRbFm0TptHLSPQxX4IvR0aZgW8ns2 1f3D40oS63ieL9dFN6h0jt2CdXpTp9Uv5ED7rVAcjSAY+f4UOp3hu/stgKNJnUhkSaTa 4VKwgI6wqhurHC6aG+UJLa1JB6SYdWj2p6hjuEidhcICOTDhk0kV+PNaGIHNva1NZf3Y wrVA== 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=Vp9bX1LhIn1v23BF9qKZbeQKEiQmroaJi3+BDMwf8DkoOfA2W+UkofbEspLFDR7idw q6cj0RmGixBJzfpIRaIBG5IRxECUyjKeZV1EwRIV/uMX8tYPOk9GNhla3+EdyFln4C7W TOzeduh1RuTpXSOQPqtI28fw78fYsG1iufnGnlbiXEV7Hq+opnrVehKk0TC/JaWBQ8P2 ZiT+aDiV6cwzW0PSuq+yFcMWsFZGPMA1Aa5ySPNg501EKB3zgE6Gk2q0MHlmM0CJy0/y BemWdcBljOksRLNV/8HKFQSTA75WK/YMQ3s7vcaeJMGas0+3A5zuhT0uO8X2rPPa/S7E Oaqw== X-Gm-Message-State: ANhLgQ0om734sVY7PG4f/QAWLTSTHQvAkg65wmAizqvOFGIwKS52dw3Y wRKiblpm75vC7vU7ka0U357Xl90yxE4= X-Google-Smtp-Source: ADFU+vvQOqac3XdrocdKJXwPQmo9rGvJ2DYakKwrchRmep68KFR1we0hUCUL5Jj2+H0gVZkJl0Rz7A== X-Received: by 2002:a62:7c09:: with SMTP id x9mr217492pfc.80.1583279014153; Tue, 03 Mar 2020 15:43:34 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:33 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 16/17] media: imx: silence a couple debug messages Date: Tue, 3 Mar 2020 15:42:55 -0800 Message-Id: <20200303234256.8928-17-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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 Reviewed-by: Laurent Pinchart --- drivers/staging/media/imx/imx-media-dev-common.c | 4 +++- drivers/staging/media/imx/imx-media-dev.c | 2 +- drivers/staging/media/imx/imx-media-internal-sd.c | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-dev-common.c b/drivers/staging/media/imx/imx-media-dev-common.c index f7ad3cbbeec2..b23bbfab388a 100644 --- a/drivers/staging/media/imx/imx-media-dev-common.c +++ b/drivers/staging/media/imx/imx-media-dev-common.c @@ -24,7 +24,9 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { - v4l2_info(sd->v4l2_dev, "subdev %s bound\n", sd->name); + struct imx_media_dev *imxmd = notifier2dev(notifier); + + dev_dbg(imxmd->md.dev, "subdev %s bound\n", sd->name); return 0; } diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c index 2c3c2adca683..6d2205461e56 100644 --- a/drivers/staging/media/imx/imx-media-dev.c +++ b/drivers/staging/media/imx/imx-media-dev.c @@ -32,7 +32,7 @@ static int imx_media_subdev_bound(struct v4l2_async_notifier *notifier, return ret; } - v4l2_info(&imxmd->v4l2_dev, "subdev %s bound\n", sd->name); + dev_dbg(imxmd->md.dev, "subdev %s bound\n", sd->name); return 0; } diff --git a/drivers/staging/media/imx/imx-media-internal-sd.c b/drivers/staging/media/imx/imx-media-internal-sd.c index d4237e1a4241..da4109b2fd13 100644 --- a/drivers/staging/media/imx/imx-media-internal-sd.c +++ b/drivers/staging/media/imx/imx-media-internal-sd.c @@ -142,9 +142,9 @@ static int create_internal_link(struct imx_media_dev *imxmd, &sink->entity.pads[link->remote_pad])) return 0; - v4l2_info(&imxmd->v4l2_dev, "%s:%d -> %s:%d\n", - src->name, link->local_pad, - sink->name, link->remote_pad); + dev_dbg(imxmd->md.dev, "%s:%d -> %s:%d\n", + src->name, link->local_pad, + sink->name, link->remote_pad); ret = media_create_pad_link(&src->entity, link->local_pad, &sink->entity, link->remote_pad, 0); From patchwork Tue Mar 3 23:42:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11418985 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 5F62817E0 for ; Tue, 3 Mar 2020 23:43:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D62120828 for ; Tue, 3 Mar 2020 23:43:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nx+iRQ9r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728500AbgCCXnh (ORCPT ); Tue, 3 Mar 2020 18:43:37 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36202 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728494AbgCCXnh (ORCPT ); Tue, 3 Mar 2020 18:43:37 -0500 Received: by mail-pf1-f194.google.com with SMTP id i13so2325186pfe.3 for ; Tue, 03 Mar 2020 15:43: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=AS+AHCuMQWIyLmWzD2RHQ/sZnkJFO9p0vLnea6pI0u8=; b=nx+iRQ9rlI/UN8xYS4H2lgIfb7SwrIUVzaIj6QFmCJ44w5wVtFapFsZYhvHhnjQS4L Q+IENjrnYfJUs8Ue1Szh1hQDSksOngWvI+jgTEz+ztT/So0aY9EBJe7GxC+bbyAP1nv2 BhIrS6tGLC5WVXRkYsmdCxHGcEF88C/hffNTyUy4I5DALDvSdweC3yvdxxgUUuA6UU1Y KK84k8flEhs2iHekB90IwCw6QgMwSsQvvQqxKdf3I9kt2GxqofPs7XAjNgLGUW6/ygf2 ncmY90srO+Rwud1c4/nNtOBTIAYtfaFvyK51xYT5let7aQ/cati0WqWlYLgk+x7Namhb FuRw== 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=E8kiyk+azbztIOPEL+k5mtApXWxMKgRH9i+uTWBMQtGPrAhSzkQENI5CcYd/PeE8/Y ct3ojzxNp37Huy+Jexyao4QOdecsWpGaByKvMBR2GzYtMomXww+z5vCIYRXWUKA5/7KD aeNEnHIGiRsTa+T0T8x1QQXu34BPgsqw9VjD67ZW47fNTVFwYWvSNlsYXyHiRuoEwWiW MXMaLQOb0Ao0Gw8vZm6vMlu7R9hm1LsjAWoZxFPbn8JAEQfSsCIoz7RxS8sHYzq22v6l krKD/+lt1BYkO36JjbYKPKFpFR5MoVHkWZ3E5D3RQiUmtFV9+xHCpnWX5msuojnE3hVa rf+w== X-Gm-Message-State: ANhLgQ3/wuSP496s1U/cxZ1lZdmRiwPI3dmyM2MkFYwksN8h6mGRr26Y w1lNGO8qsqw41XGEWlJixvIoaopzAMg= X-Google-Smtp-Source: ADFU+vt8YPvn85p+KvVGysds4MYZkP2OT0DYvBlkIydwUd2Ki9GXRwVyLjW/7MsdRJ+I2F40y3b7rA== X-Received: by 2002:aa7:947b:: with SMTP id t27mr201118pfq.212.1583279016089; Tue, 03 Mar 2020 15:43:36 -0800 (PST) Received: from mappy.sklembedded.com ([2605:e000:d445:6a00:8145:3904:f092:dd35]) by smtp.gmail.com with ESMTPSA id q66sm23540009pgq.50.2020.03.03.15.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 15:43:35 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Subject: [PATCH v4 17/17] media: imx: TODO: Remove media link creation todos Date: Tue, 3 Mar 2020 15:42:56 -0800 Message-Id: <20200303234256.8928-18-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200303234256.8928-1-slongerbeam@gmail.com> References: <20200303234256.8928-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