Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1134893imm; Fri, 29 Jun 2018 12:01:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJIRFQsZvFbFCgbZHyToD7au3KtkZmcaUvBVNWQrArRNLnUge3OlC+bYluYikUiOyBfMAfa X-Received: by 2002:a65:40ca:: with SMTP id u10-v6mr13382593pgp.2.1530298886056; Fri, 29 Jun 2018 12:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530298886; cv=none; d=google.com; s=arc-20160816; b=epRAMo2qUuwMWazFvABRtUSS5JJOnICSNEXUcWHTi0R+1IC2k+2Ef+qZyRi6iLSjg2 dseTIEvZeKpoGMm+pyq8jV9Cbz7874B7viiW2IRUfEbxmqPbgAHi07fsfoBbkDjZXjzQ D6Zm+ZIUsU2fzwM2mRexXiRZXNmsbXiG4PT9uOAByOqCuJbX/SPwZ1I6PS1wz8kVPzeA INAc8p+RQP5dcYyuqHMJEWLw/XAIY1C25izgjUAV1NiPTwmnpRfYTuPZoY0sscKBmEEw To2qG1zJd0BoUp/XAzu2OIXbooSoUT4/W3/8YUDuNH8rOUK5ggy7yj+at49MaqBCnvuS 39EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=/jcORsDlJj5odAZjHflLJVmmzfOyQY816PdynHEaDk4=; b=giTWfMP6tnwPMRN9fOaYKmSJETa2g/OpduNL98lU4lr5VUTacElAGZi+xF4lwsu/H9 j9vOBBgZ7VKHB6dDsRtRFyLJXa3Ldun7McCgMRFHuwyveimngmNxBlJG/yaL9wKVuAew KuURc8nXbumQfBV6L+oFRAkTL6VX9wALM8QyQcInyvthehM4JKxfj4ICpPh+2vHJlCnl ypA+/zuTCB2Hfbs2HgKjmKSO0hCrGYvNt4flZPCN3pSTnTVisabSTYUJ0c5eecwcVbyI rMx0cGjuyaFMKXvvQYaa3Pceo761LBfNGeY+vsXSpjKMLcuw9oiLpRDXUAkbxqHPnPIV c6Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ruI40RSt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf13-v6si10994888plb.175.2018.06.29.12.01.11; Fri, 29 Jun 2018 12:01:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ruI40RSt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755044AbeF2Svx (ORCPT + 99 others); Fri, 29 Jun 2018 14:51:53 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35818 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753483AbeF2Svu (ORCPT ); Fri, 29 Jun 2018 14:51:50 -0400 Received: by mail-pf0-f194.google.com with SMTP id a24-v6so962106pfo.2; Fri, 29 Jun 2018 11:51:50 -0700 (PDT) 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=/jcORsDlJj5odAZjHflLJVmmzfOyQY816PdynHEaDk4=; b=ruI40RStaWUcLxn0OIxhbKgxB2a9wbJ5crAlzu72voi1bGTpdRxmf6lfhSEOdNCBVp IaYIMdRRHfA6ExyPNfsoAu8AqAsAabyKWNyxQCvO2fXQfv8i8kbqnrwS1P6AbocuGYPO 32Z4rm1pLXTFBtrU/Fk9JFvzGHtgnh/wydBcGVaCaiO1wX7isWucTo22czXNuwwr/fha 4Z6xAWut69wzTO6VSbDnyVqPt2gH5D4YQWWEaRbWhNPtm1G9rP0+HW1DikqBwG+pzwUz 693FrSYeJUs5u+PE3nU2iIiAgNAvOn5qfGm13pSUYThVhRb4a5wJD9mc28CY2kIYZEd5 LCww== 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=/jcORsDlJj5odAZjHflLJVmmzfOyQY816PdynHEaDk4=; b=keXFpWfx3UTcIsDLiXSSPYhzGZHXliXQZEQF+QxGylqJFwDbsZJf8W1oJe/Rw/3Rm7 2117i6p+fnQQIsMV9WQlQ/fYb+uF29MbpzHuYCiya9m6pA8yio8IYqD3gzhrswXhf5bO UYpu+kqeAkgDJqgzYmodtyKRXvQlvJUEl/yT1EKb2/L+mt08iZ3tqhmLvWmgbooQW2Ud GZQKd8SyBfuwzQ0gxK2spvAzlfWo6p82GgMK6C0EkNsndIr6SoUcIruX4iAdgw895OVA rGk2g+z0jKsf99+BjeIp9i3IpvrasT8SIEQdD3JIGb5xZYl1/LlBo4EYUhCZn4+g9fXq 8B7w== X-Gm-Message-State: APt69E2hYBMCckF3PC4XqgdOMPnSIuzW6LDWfhkzqobvkQZXeTwN8yCZ 4KGKkM42jmndoRzj0OV+pZHtOQ== X-Received: by 2002:a62:9c9c:: with SMTP id u28-v6mr15792449pfk.90.1530298309419; Fri, 29 Jun 2018 11:51:49 -0700 (PDT) Received: from mappy.world.mentorg.com ([2602:306:cc3b:f020:7cd8:9ad7:a375:e853]) by smtp.googlemail.com with ESMTPSA id k13-v6sm27672308pfg.130.2018.06.29.11.51.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jun 2018 11:51:48 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , linux-kernel@vger.kernel.org Subject: [PATCH v5 07/17] media: platform: video-mux: Register a subdev notifier Date: Fri, 29 Jun 2018 11:49:51 -0700 Message-Id: <1530298220-5097-8-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530298220-5097-1-git-send-email-steve_longerbeam@mentor.com> References: <1530298220-5097-1-git-send-email-steve_longerbeam@mentor.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Parse neighbor remote devices on the video muxes input ports, add them to a subdev notifier, and register the subdev notifier for the video mux, by calling v4l2_async_register_fwnode_subdev(). Signed-off-by: Steve Longerbeam --- Changes since v4: - none Changes since v3: - pass num_pads - 1 (num_input_pads) to video_mux_async_register(). Changes since v2: - none Changes since v1: - add #include for kcalloc() declaration. --- drivers/media/platform/video-mux.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index 1fb8872..e54a719 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -21,8 +21,10 @@ #include #include #include +#include #include #include +#include #include struct video_mux { @@ -207,6 +209,38 @@ 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; + 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; + + ret = v4l2_async_register_fwnode_subdev( + &vmux->subdev, sizeof(struct v4l2_async_subdev), + ports, num_input_pads, video_mux_parse_endpoint); + + kfree(ports); + return ret; +} + static int video_mux_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -272,7 +306,7 @@ static int video_mux_probe(struct platform_device *pdev) vmux->subdev.entity.ops = &video_mux_ops; - return v4l2_async_register_subdev(&vmux->subdev); + return video_mux_async_register(vmux, num_pads - 1); } static int video_mux_remove(struct platform_device *pdev) -- 2.7.4