From patchwork Mon Apr 20 00:39:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210120 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EE42C54F70 for ; Mon, 20 Apr 2020 00:39:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4ABCE2145D for ; Mon, 20 Apr 2020 00:39:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tsR4oDXg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725964AbgDTAjj (ORCPT ); Sun, 19 Apr 2020 20:39:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725949AbgDTAjj (ORCPT ); Sun, 19 Apr 2020 20:39:39 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 270A2C061A0C for ; Sun, 19 Apr 2020 17:39:39 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id f8so3313553plt.2 for ; Sun, 19 Apr 2020 17:39:39 -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=9mTYcYwO3j5DgB6hEjXQEWO63m/OWQAU74YbBUG9mak=; b=tsR4oDXgUacwZqH8ce6tJbIyk4fPDr3Iuaob3YZ5Xd7esxfOBrrdpwuOZCKUOwDnYX oZTU47IDyNkHpEXL3iiKQCdISERxQGgmByIlT+xZm1bwXJXJbI+zslENFcIl2+vlEoUS pA5mRICtNPh4Li3zrW6ib+PkhbI5/XaZe1/Bt73f2bRqLfr5zHC8gqDSwPOar+6HhCUA +hTR2AKf24iEngA+q7HEqCQ162jm4PpOG9oQtxgaVC8wXmdYH7fHL4vy4DB0OC0HtCVg ZrVm5tMdsg5VNQG2/GrGThNSmFuirBIqFDWZXQHfaz7PP6sDunxtrojlIbwCFZ0PBzQn PLDA== 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=9mTYcYwO3j5DgB6hEjXQEWO63m/OWQAU74YbBUG9mak=; b=o6Ywo7wpXUas8p2Vf8Ae98SksJZqKNXpxo49r6C5d6JXVXuELNwz1JcHD+ZFBpqpKC VYu34u99oPF3lHMmhRJVvYqYIxo+07LQR1eqY4Z5f8Cxv8p5UbCg4bjj69RimkaENmGC iQjpVzkc2sV+ucKiHy3um5QMd6AK7abBYQJxgaVzY4k+gVnmJ8HP/4ax5VYhusDvJ0RV pH1obLA4O/v0kfXLN8E4zdyJp15r57PmqDtlL9wg768pLgUqTi6PDH4nTUsOKEkVlN65 GTD1yA/81yAxu16IvXvJ6EZPoKuuzHeFh/cE3+0UrFuaq6ES/A4HhWrXGAJ15JBCEIvM pAsA== X-Gm-Message-State: AGi0PuYcBuGWYX5Ocj8wtBXiCA/Omlr+4IRboYe1a9OHtux5yNjO8DPs uELvhmsdCmwRPpTM0IozGq48UXgzI5o= X-Google-Smtp-Source: APiQypL2bMKRY7kv+MhFAJqxBKrWQeOKeK/RVkGVn8d1WKgu59WhmbuiejMIz4tQsOXKk9u/5o6M7g== X-Received: by 2002:a17:90a:f418:: with SMTP id ch24mr18303110pjb.68.1587343178401; Sun, 19 Apr 2020 17:39:38 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:39:37 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 01/23] media: entity: Pass entity to get_fwnode_pad operation Date: Sun, 19 Apr 2020 17:39:08 -0700 Message-Id: <20200420003930.11463-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-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 Mon Apr 20 00:39:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BA9CC5321D for ; Mon, 20 Apr 2020 00:39:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 085662145D for ; Mon, 20 Apr 2020 00:39:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uIbEvBm7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726050AbgDTAjm (ORCPT ); Sun, 19 Apr 2020 20:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725949AbgDTAjl (ORCPT ); Sun, 19 Apr 2020 20:39:41 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEE1CC061A0C for ; Sun, 19 Apr 2020 17:39:41 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id e6so1265561pjt.4 for ; Sun, 19 Apr 2020 17:39:41 -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=q/D4Oi9U6YWOZjW+n+hLsbyUmbrnB8ZHPL+zrDmH5wo=; b=uIbEvBm7g5QFEKaNJL24wc3tQ3V0IYDKaRcu/U/UYsM4Ld71wKpvaDDIDFPLQdv5JV rS6bCkniZEfMaFynOoBPDn63G2bXx6GG/H/IkFWpatZ0dtLTBZweOE82JQxdt3Idm/WE Bm0G0OoLIbv7iF/VXr+r2F+r0ZGOVF2GIlCiFotb5fdgrFWBb0FtxVJfYJ96bhI2IMoh XYNvgAXmw7env0NnV1bXhGL9yMZN2fAOlYGUKln8PC3jiamFGNAEcxiD2HlgaEnPauMS 933ud8iDFBESkLJXam1MxdEH+MWM2g26ns929R5p5m6eaaRzF/cKHHtDtYsxnKHJVspT k1zw== 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=q/D4Oi9U6YWOZjW+n+hLsbyUmbrnB8ZHPL+zrDmH5wo=; b=Al9EI5j6SxQFkx+S140StXJaaypK1SQgrZyuO46Jash5iAKip8RTTg/urfC9GcnNds fSrFB9up7ZhiTmdXYSJfbs1vX4mXTyznqm0vZklXddc0Vy2zg7ayPZCSZ5Xwm05hQud3 TNQyURBEvO5oJlZ4JyF+ZYLbLSsbDn0ttISc8k3hcnBLZBoLm2kyNq8qVJ9ppUqBeAxg cgiSeaFow8TMrSJdtY8sFf4qZu8QmYFTuTX11XLQoAwI2tkoh7WuLg9uf9t3ZRHw10HG SukdDnYAfR2pmH4mQia102i9HcnbTp9dGaXciD/q+XrNo5SzVQZzgpYRs6phrxsC+ZQL u0UA== X-Gm-Message-State: AGi0PubRlZ1CyZsx/1c+QhhHIDbbt/IrKXioDQ8vPjto5FUttWhOgUbO rTTuUWc8LPGeFFaC71mbMeVc8frlp2I= X-Google-Smtp-Source: APiQypKhE9x81VWijriZ+9Gvb+NjghavjHSRYnIto1uQaKjnI68yraSnNrXj0xuuYEIOEjqUXxaiog== X-Received: by 2002:a17:90a:fc8c:: with SMTP id ci12mr15982579pjb.104.1587343181089; Sun, 19 Apr 2020 17:39:41 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.39.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:39:40 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 03/23] media: v4l2-subdev: add v4l2_subdev_get_fwnode_pad_default Date: Sun, 19 Apr 2020 17:39:10 -0700 Message-Id: <20200420003930.11463-4-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-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 convenience function that can be used as the .get_fwnode_pad operation for subdevices that map port numbers and pad indexes 1:1. The function verifies the endpoint is owned by the subdevice, and if so returns the endpoint port number. Signed-off-by: Steve Longerbeam --- drivers/media/v4l2-core/v4l2-subdev.c | 25 +++++++++++++++++++++++++ include/media/v4l2-subdev.h | 17 +++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index a376b351135f..d5b5cd7a6049 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -696,6 +696,31 @@ const struct v4l2_file_operations v4l2_subdev_fops = { }; #ifdef CONFIG_MEDIA_CONTROLLER + +int v4l2_subdev_get_fwnode_pad_default(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct fwnode_handle *ep; + struct v4l2_subdev *sd; + + if (!is_media_entity_v4l2_subdev(entity)) + return -EINVAL; + + sd = media_entity_to_v4l2_subdev(entity); + + fwnode_graph_for_each_endpoint(dev_fwnode(sd->dev), ep) { + if (ep != endpoint->local_fwnode) + continue; + + fwnode_handle_put(ep); + + return endpoint->port; + } + + return -ENXIO; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_get_fwnode_pad_default); + int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd, struct media_link *link, struct v4l2_subdev_format *source_fmt, diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index a4848de59852..940181323427 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1027,6 +1027,23 @@ static inline void *v4l2_get_subdev_hostdata(const struct v4l2_subdev *sd) #ifdef CONFIG_MEDIA_CONTROLLER +/** + * v4l2_subdev_get_fwnode_pad_default - Get pad number from a subdev fwnode + * endpoint, assuming 1:1 port:pad + * + * @entity - Pointer to the subdev entity + * @endpoint - Pointer to a parsed fwnode endpoint + * + * This function can be used as the .get_fwnode_pad operation for + * subdevices that map port numbers and pad indexes 1:1. If the endpoint + * is owned by the subdevice, the function returns the endpoint port + * number. + * + * Returns the endpoint port number on success or a negative error code. + */ +int v4l2_subdev_get_fwnode_pad_default(struct media_entity *entity, + struct fwnode_endpoint *endpoint); + /** * v4l2_subdev_link_validate_default - validates a media link * From patchwork Mon Apr 20 00:39:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B3A1C54F70 for ; Mon, 20 Apr 2020 00:39:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0ADF221974 for ; Mon, 20 Apr 2020 00:39:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TpZUcxTF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726063AbgDTAjp (ORCPT ); Sun, 19 Apr 2020 20:39:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726054AbgDTAjo (ORCPT ); Sun, 19 Apr 2020 20:39:44 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D552C061A0F for ; Sun, 19 Apr 2020 17:39:44 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id t9so1675787pjw.0 for ; Sun, 19 Apr 2020 17:39:44 -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=da6/kHTa4PmSLjQMbuwmheSk9zUOW8puN02Um2cjqfY=; b=TpZUcxTFyHbT/DrioLzn6Nb2phk0iviW6Pw1bDU0R1oWNSJjKyKA+cRNpoCvPc0mgd cHlZ2mQAK2LpCDr+O18kAa833syQf6wDIitvcVrDFx/HxokdhGQbD4A3KQQ6gsqaRZOU LwlBZmIhUUqdLy2/ZtLFZSmq7l+dCuYdITINuPPdHdIWRZVEpdIi7+aszPFTNC32d5o8 XJLnuX3XAV7M40Cst1vbUlL+f4V0Y4CWKH0GbGmLO20g9KiMMyqjVxSILVMllU7pez0u 3BcmyvFjmjksw6850R7KO58xQi52BQS3WWcu+aDwxYSaVXADBOBZ2iLtXb9MsJVNJdV+ ZbNw== 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=Os/g6CmE+sXn+ASOFN7yjdZeLTnudDhD2WbsBM5gzd1qkBZebWs8+hZbJ/aUPg39xI rCMmN25tGGsHEEDl6ITPZPtOTnEEEVMVtJoK0KfmC9hBKo2DX0vp2p20ChuJoJEOjdIH 8rVdevg/oA4nzPojleGm3B4Au/OJsDTf2/GAARsy7ipn/zkGWalFNOYCGWPn4IfbtDvA LA/Ls2nhLz9bcko0tF36pZNDNheJ2wEtGD6wSVFdIm9+MB5O3psaXjmLKytf+de9Yaw6 9to4RMoHLbNY1/dS7GMZymQ5Z4Jw0leIX3fZ8Bds0RfH69iyhXhFDbQ0WrbUR9gmLXKq xyvw== X-Gm-Message-State: AGi0PuZBx9KwrlWjcwLvVKc5C0GmWbI3O/R02kwJRDWE8inq83VyrPR1 Z4yTVkOdTXuvNzCL1e4ZoUeXF5gQzjc= X-Google-Smtp-Source: APiQypJI2TSWYjAghXZ07v+lRA4aBHgMb3Zlt1Jsi3PO1tyElkUWAf2reEJzeAurMNQXoVFYofsFZQ== X-Received: by 2002:a17:90a:7d16:: with SMTP id g22mr18589163pjl.179.1587343183861; Sun, 19 Apr 2020 17:39:43 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:39:43 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 05/23] media: video-mux: Parse information from firmware without using callbacks Date: Sun, 19 Apr 2020 17:39:12 -0700 Message-Id: <20200420003930.11463-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-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 Mon Apr 20 00:39:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AA3BC5321D for ; Mon, 20 Apr 2020 00:39:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 339452145D for ; Mon, 20 Apr 2020 00:39:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UA+kx+GB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726081AbgDTAjs (ORCPT ); Sun, 19 Apr 2020 20:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726054AbgDTAjr (ORCPT ); Sun, 19 Apr 2020 20:39:47 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A53BCC061A0C for ; Sun, 19 Apr 2020 17:39:47 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id np9so3794112pjb.4 for ; Sun, 19 Apr 2020 17:39:47 -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=pw/KWtB3cpNCCKjjUKy2o/QpPcKDD4Imxdz62soASJ8=; b=UA+kx+GB6fIdUk8Myuuf8gC374VPw+DMgduhOrJr+/bUq1fa+TnFhvjz7wmU2Z6tpH BZ1juovMtf33IqDPJY1ZZ8XviC8gu1S180EfjlyW89yOGKFb91NSPJu20zvgPsWQq0tH 5Cp2zkZM7oMZvk1F2tZP76DRAKMZqYlKubdTXPOL0g/EAgaLsbekUOw41I2yoLpgHZek 2YRPAmlkftfZlYQFqDJcv6LPHwdv1/eWqmTlWfYstEfnlgbKZQixyM44pDCpAwu34MXR vbU8dwOFey3d2/IGB5IiPd8ZMobcwpLoDQTxWyldrQipwydMbZV/wcGeyFueKFVS0KtE Wjvw== 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=pw/KWtB3cpNCCKjjUKy2o/QpPcKDD4Imxdz62soASJ8=; b=VVo0rISqlZwdlOzfqrPpLMhVOe1/yTJ1/NXH7qPsqHZRK/dRJgnSKStLunqyzxqDHV 8BU0OdEkCEinObocNErWmSARTkCz59K4GKpQ2ESz4wrZqV+PB4KjPiX6Q/Tr/UXcuDrK IWqwp/2uF1oA3GnLWxWk1kDWOhzgLvpqngrdmYG/RGyPE4UMl5aJk0mH45ZumTA7BqeB spQTQ41mPa+YMI9SLXpKEajkMpwSE7ERYf4mn8z0+ZiqgPY6ytXkfqAubTa8On2mug4F lKpEYh9PWcUma2RugB9Hepn25BEB5P6DvuI53/f0Jop5d89jxjnsuzz3E1BHS32ezEqT BZmA== X-Gm-Message-State: AGi0PuYH+/8UkedDmrGwzOyiYqiWSiJF5aGVgUdeHf5HPd+6mY6jBp97 8ljpniPNynAxv5PLrxt6o5k7AFfEt3U= X-Google-Smtp-Source: APiQypJfH3SiTGPiTaso4QHooZwZynmm/XAgFnDFebVXtE+qJQ1kYZMBmIOLJzy8v1lGw16B19b2qw== X-Received: by 2002:a17:90b:4c10:: with SMTP id na16mr1357192pjb.30.1587343186739; Sun, 19 Apr 2020 17:39:46 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:39:46 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 07/23] Revert "media: v4l2-fwnode: Add a convenience function for registering subdevs with notifiers" Date: Sun, 19 Apr 2020 17:39:14 -0700 Message-Id: <20200420003930.11463-8-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-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 97f0f8b23b5d..e1f273ae8522 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -1323,68 +1323,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 dd82d6d9764e..fad7a6480bf9 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; @@ -490,43 +489,6 @@ 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); - /* Helper macros to access the connector links. */ /** v4l2_connector_last_link - Helper macro to get the first From patchwork Mon Apr 20 00:39:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB184C5321D for ; Mon, 20 Apr 2020 00:39:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AE2C214D8 for ; Mon, 20 Apr 2020 00:39:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uuOWGvj8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726099AbgDTAjw (ORCPT ); Sun, 19 Apr 2020 20:39:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725991AbgDTAjv (ORCPT ); Sun, 19 Apr 2020 20:39:51 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584CEC061A0C for ; Sun, 19 Apr 2020 17:39:50 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id ms17so3682831pjb.0 for ; Sun, 19 Apr 2020 17:39: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=KL3F8Ry3F3mrrfiEfS5/cHlDdR5sJLqa+9CCe5yF5LU=; b=uuOWGvj8HDjyPEKlaIQtT/FsdQ0nnUzdobEbgxaQ0Xkia1lcIKWNg6DN/UUKhESAMP AA8xJ79tR/eGtv/fS22GlildTnBR+RW5vwNEuKhVTbj5a38AvtbdDc1Qr8nAbApD8fMU HEDT2+T+o/z2eQv2jXxpxuLovNMfVCQ1MAZ4cDJbCVmXAtCCfFGlocWhzMNrYKIktdTZ 9FAUR8Bq6KiqHDTL5I1Dum+sso1swqpkwfuSm3E8iOJB5TjJE1LW85wioDBYOW4O9aEg SGt1ClTfcWo/NKiArHJxsjnoucosJln891o7r3NRt7eJ5QSUq7UStpWcHL8opQN6Q+6G Trig== 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=KL3F8Ry3F3mrrfiEfS5/cHlDdR5sJLqa+9CCe5yF5LU=; b=T+0Vsb7WV43hv1R4ZuE0MsiHF3DI10yeg+O5YZmp+ps+HjKeaeIJmmveImf55RGbas rRTV90z6ABG2KcRz7GW/6EKsy6pxzSANN/hjvX4dKVbZ7AlTHOOytZnobS+NNvGRuD70 HZcwjTkq1WIgUFGa41RzbTRqG/SmusN9GIKr9SMImqnyZBZnPwO1VIVOcdVb2zp8RgBZ 2+NDWbI8OWMhv8mhlzxkd26F/uL8GxgEBkFhSFE4ZMm+A7qmy5ZCfYfyXlt1/+7sEtdk qVIO0SQvaHfjCHu/5AVlFbPUWe4CEdSMZU4zQFLSMSNakTsF0v974tCXFgN1u1F/gwuV MnUA== X-Gm-Message-State: AGi0PuYdLAP9WqdH3SkhDd0Jw7tNkvLPx2/018lBctSDYxiK9WGuaxVo OsFKfgcjfF3qa3QCctA5ElDVJPsgNnM= X-Google-Smtp-Source: APiQypJwxRSPM/Nt/U3QyNKyWz101KHI6RbEfMobBfX9FTVnP9+E7Bfj1lyXbK9fZwSH4h9m8xURNA== X-Received: by 2002:a17:90a:23e2:: with SMTP id g89mr18702757pje.105.1587343189619; Sun, 19 Apr 2020 17:39:49 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:39:49 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 09/23] media: video-mux: Implement get_fwnode_pad op Date: Sun, 19 Apr 2020 17:39:16 -0700 Message-Id: <20200420003930.11463-10-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use v4l2_subdev_get_fwnode_pad_default() as the get_fwnode_pad operation. The video mux maps fwnode port numbers and pad indexes 1:1. Signed-off-by: Steve Longerbeam --- drivers/media/platform/video-mux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index 7b6c96a29aa5..a21b299ce0e7 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -97,6 +97,7 @@ static int video_mux_link_setup(struct media_entity *entity, static const struct media_entity_operations video_mux_ops = { .link_setup = video_mux_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = v4l2_subdev_get_fwnode_pad_default, }; static int video_mux_s_stream(struct v4l2_subdev *sd, int enable) From patchwork Mon Apr 20 00:39:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABAD0C38A29 for ; Mon, 20 Apr 2020 00:39:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88B4D2145D for ; Mon, 20 Apr 2020 00:39:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UXzFqw9v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbgDTAjz (ORCPT ); Sun, 19 Apr 2020 20:39:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726089AbgDTAjy (ORCPT ); Sun, 19 Apr 2020 20:39:54 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36BBEC061A0C for ; Sun, 19 Apr 2020 17:39:53 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id kb16so3802494pjb.1 for ; Sun, 19 Apr 2020 17:39:53 -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=jtajOtLt4o8DXOswYzYCoa3CZyiQQIMpXDBoB7VJNMQ=; b=UXzFqw9vVHBYj7XN31XK3qo8rlLF9OHfEkMFykcuSYOiW+Za2gwEk/9BDZHVVkwWlk ip5aHhYfSyitIBkvCWMMIBqTn5+Rh6h3z4Bol7d83v6WAi9rCqEJ1Cy5vTtNr6A8PVkP +6HOIXKzyRzInqhyKK8a95n6dUv1Wdk/0U3UR4O6WDuJM63NVYOyMEN/UBgUy2XWC5du Wi/o3qJVHCEc6+XCcKpCq2fWwuHRH6FKw3ddS50js8xpyNkohIiFBRp8KcfSVD7WwFNF HkQ2g8q+jhqDsZG0SgDXRiCNyjRaTfHvysaLMGBWnYlTrAQt+EERfPtd5W0u92Dj2YcH TvuA== 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=jtajOtLt4o8DXOswYzYCoa3CZyiQQIMpXDBoB7VJNMQ=; b=MXwj0AYXapAgTGzMfKkceVzox2ixouy/r/UKwGn4E6STwjclB5tmB+E5IwyIDJ9WO4 JXkNSEDPkbmmY5274oBNRvJCiWErTy8PEmbeiAUYH48HR2nnrosYNCSGnsQHAB1G/8ck jRre2Cvs9cN37TYKqONtWWCWCmtYE8hHV5AODfZSV0hKbWqHl1plI1HYqT4ti+K0/bnt qO2dzIZRWiC6IysFYqfeiQP0nYn4SkjBRKEl4fGG4WNwcKJXJ//m2WRmKB/FAZDeyZDL 1q/7JnsI+OrX/fXmzh8/A2hZFY2zR3O0Os8/OSXf2JdZ95qeaiQltWHH8Ls/eu8iGuZM FRVw== X-Gm-Message-State: AGi0PuaQo1sMv5Gg+mbWQcMkpdPO2OKZt6U3wJ0Y4xL22RyzW7yKfxfp IHTl0gib4SdTKq0xMr2eWzfX/egjSUE= X-Google-Smtp-Source: APiQypKxNqx5GNuMmEnjs9So+TwG8pU1qd+hXS6iqa++kUN74AuTRI+lOY7spqF0oiQLAFbaIqMjCQ== X-Received: by 2002:a17:90a:fa17:: with SMTP id cm23mr18802037pjb.121.1587343192463; Sun, 19 Apr 2020 17:39:52 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:39:51 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 11/23] media: imx: imx7-mipi-csis: Implement get_fwnode_pad op Date: Sun, 19 Apr 2020 17:39:18 -0700 Message-Id: <20200420003930.11463-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use v4l2_subdev_get_fwnode_pad_default() as the get_fwnode_pad operation. The imx7-mipi-csis maps port numbers and pad indexes 1:1. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx7-mipi-csis.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index b66299c1136d..1b3af031d136 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -906,6 +906,7 @@ static const struct v4l2_subdev_core_ops mipi_csis_core_ops = { static const struct media_entity_operations mipi_csis_entity_ops = { .link_setup = mipi_csis_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = v4l2_subdev_get_fwnode_pad_default, }; static const struct v4l2_subdev_video_ops mipi_csis_video_ops = { From patchwork Mon Apr 20 00:39:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B316C5321D for ; Mon, 20 Apr 2020 00:39:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 592E6214D8 for ; Mon, 20 Apr 2020 00:39:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cRbmFLm7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726117AbgDTAj5 (ORCPT ); Sun, 19 Apr 2020 20:39:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726105AbgDTAj5 (ORCPT ); Sun, 19 Apr 2020 20:39:57 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EBD1C061A0C for ; Sun, 19 Apr 2020 17:39:56 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id g2so3311404plo.3 for ; Sun, 19 Apr 2020 17:39:56 -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=diBzADfannDdYI1cw4/kwf/YiXFzLk18zW8vS88VTgg=; b=cRbmFLm7HWyET8M2mtdxR1yy54EDrI9cDfTlzDKiHJ/or4k+rIQWlM+4vs+BsbQ9zZ JN9Dm6CD2/Y6wdzw0UN2/lA3u1Du42/FJLPlG3aqzNKKVu/dt2wJfSO/BTVueOpAzl38 P29oV6RrXFZCCEszq4x+v99HQ+qr0+8y+j3gQCiKsaQLD4dKH6WG/q9eViWNeuQGI92P AKZckvjqP3VYqPDa4yluMJO62eM9awibNfbdWbuEON9LxJKKeMe7IXY/6e7rG3/r5K6K uJ6p3W5KfmmfQiDdg9O3QZTqOEUoFFqmbkYWNcEKlUxLYhBzzxfM/qFd62zVyXRUAC3C 83rQ== 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=diBzADfannDdYI1cw4/kwf/YiXFzLk18zW8vS88VTgg=; b=Ft3fFXAs4VIl0U5gzmH0GW23BryQ/ElIcgJ/yg5y+uGvxr/5DBXhriDlg1rIdsluUp 3y7ThGudZ6talH4CmbRJZ0TraMbwOlvVN5BU7bPqyVnzbsK9jfzCWWypImzZ1+HzRyEV F7SFXxH8B0Dr0KJA6F8o7eyA+uaH9H3YKTlEpLd4a0TFmuTZBqG3/F/E+U3MZbrUDFQO j2rZqSs+RzgDVsiol4t5IyA8AICXX8MdkyMX/40M3tEj2ulj+m5fY0YM5UVGKHwzxXty wnm/T0I+k27RFcrFquaBti9zbht4rcbxggWsQMEA7vo3FgeCyxCuI/px8TPXoKpbdT0H 7ieA== X-Gm-Message-State: AGi0PubvmW7k3ahTnFtgJOUoXcUjsN0Pl8/VGBZ3detTtrdJ7tc+gt30 sQshIAqouwn9tSOPfdVb4O5Q/cKWpSQ= X-Google-Smtp-Source: APiQypJlbup7fHotYlAx/xuVClgsdrIXykUUWLkZ84fzozGP3eSLIQRDk0p5b74B9PgMyTUewJlVFw== X-Received: by 2002:a17:902:8485:: with SMTP id c5mr14891219plo.242.1587343195338; Sun, 19 Apr 2020 17:39:55 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:39:54 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 13/23] media: video-mux: Create media links in bound notifier Date: Sun, 19 Apr 2020 17:39:20 -0700 Message-Id: <20200420003930.11463-14-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-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 v5: - went back to something similar to v2. A call is made to helper v4l2_create_fwnode_links(). Changes in v4: - none 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index a21b299ce0e7..4dd6f859450e 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -17,6 +17,7 @@ #include #include #include +#include #include struct video_mux { @@ -36,6 +37,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); @@ -332,6 +339,19 @@ 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); + + return v4l2_create_fwnode_links(sd, &vmux->subdev); +} + +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) { @@ -369,6 +389,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 Mon Apr 20 00:39:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18B9BC54F70 for ; Mon, 20 Apr 2020 00:40:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E713E2145D for ; Mon, 20 Apr 2020 00:39:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CVo2VKUw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726136AbgDTAj7 (ORCPT ); Sun, 19 Apr 2020 20:39:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726121AbgDTAj6 (ORCPT ); Sun, 19 Apr 2020 20:39:58 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0576C061A0C for ; Sun, 19 Apr 2020 17:39:58 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id d24so3301877pll.8 for ; Sun, 19 Apr 2020 17:39:58 -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=zeq7U4bgVi6QRt2+oSb5yHP0cc+C7xZkBs+2BlV9yu0=; b=CVo2VKUwaFM7LPyrdFtvIU7eVPn59p8JVgohZFOLY2mZ9WAcV/T0AY48BpGHU5kzT8 4GoZ8o6rbyRqFEDpGawL7OaMy7zzeffRCnZWIYeccsfKk1CVECJAAlnZYHcTPL2o70Pz KXUl2GOUtUu3Qod3QqF+blEi4rWlWkV8emFxjRglDupFulv06Sr9g6MFzHYeTzMd4Dwa kSVCiBgqq+mhyeEj7eeLb3PCeYbn3ShHDUDvINhX7B5rIAuR6vJVxG7xE4TIU1TeV4Jf fbdjw+t8U5xXtoM/FCIn3AoboRQDc1eyT8yJ8e810Bagwd74Vf8dW/EMbm+MxwSl8ND/ KSww== 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=zeq7U4bgVi6QRt2+oSb5yHP0cc+C7xZkBs+2BlV9yu0=; b=CuhXpLuQJ5xmrLdAO6V1MAq6sp+qGIOSR8yaFKZMh7m+lwkn9GDzDC1vtW7CGRyHTI 1IicNOMNhN8ol8I4FPzfvuMbIUdW803H++0x5nGw7wGRPneEkSR6d9CKQxttFTaC7Flt MmhJacd13sdXkN3WvKFkjx7r/YIziEZzGLd4GgYxB8WMbrh1WP2smwjNcdAdu8Y5KESR 64HD1A8fjXdIzmRAx0Ynxr8qAgnaDhSB1kk73jXnJxAohInDJ7O0L980eEfJ3kRVCQHR iCH62Wyb25ZzDhY8rnlkptrVXLnRTp4x/P2KMx43XcJw4+ndU7k02iBNifeSUiyK/8oO /7EA== X-Gm-Message-State: AGi0PuaJqBGsvkG/k4wZnA0jKM76IoTsG45d+3P4NQl0BtXlr3yb7tED kJgGcaVyToshMUYlLU6Z0YagVm4qum0= X-Google-Smtp-Source: APiQypIKkFIulezgjXHm/ADUWFo5cYbATROwvLrV3boIKohxK90C+75ib3N+xs74GeIV1QRUHr4sMQ== X-Received: by 2002:a17:90a:8a06:: with SMTP id w6mr19560817pjn.191.1587343198018; Sun, 19 Apr 2020 17:39:58 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:39:57 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 15/23] media: imx7: mipi csis: Create media links in bound notifier Date: Sun, 19 Apr 2020 17:39:22 -0700 Message-Id: <20200420003930.11463-16-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-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 v5: - imx_media_create_fwnode_pad_link() has been moved to core as v4l2_create_fwnode_links_to_pad(). Changes in v4: - none 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 | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index 1b3af031d136..6a13dc119c1f 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -26,6 +26,7 @@ #include #include +#include #include #define CSIS_DRIVER_NAME "imx7-mipi-csis" @@ -385,6 +386,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); @@ -948,6 +955,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 v4l2_create_fwnode_links_to_pad(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) @@ -1016,6 +1037,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 Mon Apr 20 00:39:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA788C54F70 for ; Mon, 20 Apr 2020 00:40:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7FD92145D for ; Mon, 20 Apr 2020 00:40:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SdGX7gpF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726147AbgDTAkC (ORCPT ); Sun, 19 Apr 2020 20:40:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726121AbgDTAkB (ORCPT ); Sun, 19 Apr 2020 20:40:01 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FC7EC061A0C for ; Sun, 19 Apr 2020 17:40:01 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id o15so3641542pgi.1 for ; Sun, 19 Apr 2020 17:40:01 -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=XhPOvVCqZ5d3wZcpuBJWgpQLz/1gKin/AejGcxf3OiU=; b=SdGX7gpF8ZGiiJ2SJWfNkvUHNiGvvOPcXnFXe1puAiNfplfMlB8l4Cb6P56km6DDEz WWAc5qkBcsRBt35av2FZuUeGC+8lJEl+XdlO3xIzteq4WRimFLvLcl6eER3TvMlVw3YT BiLqZqt7jcLs9C9eRd3uj87qZDO64E2KFfQ4LNhGV2mFeTGOox9FRhH84Bg+khlfvC5G ps8gIUGeR4ULf7EJSCawSxSTSinG29L3PPjdbO7+2x4ria2rXoXJ7mYtUIcQ9eBNS6LJ XwrqcxsnUjHWFW2IIGQU/zhVtZ0dd+Jc/2tvgMLSg5wgS1yIq4ireH1FOGADs5gZb++x FNAg== 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=XhPOvVCqZ5d3wZcpuBJWgpQLz/1gKin/AejGcxf3OiU=; b=NzOT+qHB70BsS55EZ/nnDsjs8De/DapCfhL0xIqdN4kM9qiHYl6Gc6myaa7tOVUBnV voWrd7V61ileWAqkMnCeukNClJOSAzHTZIeh1JXoWaLyKis1088WM7abH6Vj4Bwzk8cp Dbw6G7wym10xr4Fqtw1EQvkRZ1TC9rM93h4MURLsXgb43dMh+XqMej8KO7p4lm932Gfz z97CPrJOLGExAr2uTOUUaEPoyWDJQHwf4IgXHeoa00ZAOFrJ9pqiDfqGXpG1OKl1Rnqh 3q9l2DO4Yj9Cez6ycv6z4KhRoY01CmlhbA/jNlgPmceylni8pJ7Xg445gCyM4UBcZFLZ ZS+Q== X-Gm-Message-State: AGi0PuZQn4v7asRQLa3X5TDwH9RVzzr2QipUQa7INhZEwY35goVr9wGl gnEMtfAbpzcLSUvFaRPogtnEgqraTKE= X-Google-Smtp-Source: APiQypKliirT5V2/ablTdxa6Qq3bzPsMY9CEGfVrCoLucELZVVcHzTx5tniTPHvC7L+oQfFzNnGM6A== X-Received: by 2002:a62:7656:: with SMTP id r83mr14065752pfc.71.1587343200739; Sun, 19 Apr 2020 17:40:00 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:40:00 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 17/23] media: imx: csi: Create media links in bound notifier Date: Sun, 19 Apr 2020 17:39:24 -0700 Message-Id: <20200420003930.11463-18-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-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 v5: - imx_media_create_fwnode_pad_link() has been moved to core as v4l2_create_fwnode_links_to_pad(). Changes in v4: - none 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 8501efaf9484..8153ae5935cf 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; @@ -1892,6 +1897,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 v4l2_create_fwnode_links_to_pad(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; @@ -1929,6 +1948,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 Mon Apr 20 00:39:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4D9FC54F70 for ; Mon, 20 Apr 2020 00:40:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79AFC2145D for ; Mon, 20 Apr 2020 00:40:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="udzIy9Hb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726161AbgDTAkF (ORCPT ); Sun, 19 Apr 2020 20:40:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726121AbgDTAkE (ORCPT ); Sun, 19 Apr 2020 20:40:04 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E502C061A0C for ; Sun, 19 Apr 2020 17:40:04 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id ms17so3683003pjb.0 for ; Sun, 19 Apr 2020 17:40:04 -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=DQiJWYDZBbUPZ7HiwC9ohaLu2KA+CJB23qe7/YkynpE=; b=udzIy9HbT817NB7ZrBvMCt/YoAjxmLyxDuWavBGGlch1uxEFb5IT2tZn9qMN/9t7DP IGzTPa3Zrrc0c/kreAWVLDjLSbJ7Mo5Q1huvlca2nS00zK97N76BtPUqDd+Umi4sfiAn cmLiJHZeSS30cjGRTYbxUmYLaI4lXfoRGUs+/44SJgI4gM3rcd4DGp7LZtBAu+dQKpE6 9ypGStYs7Tjd1aeBFcJMsRW01pepTp8yWEUNxpby4ZLh+fWnho72Q9d0xDe6B+vzaoXW OxgJw2GPzBYKXer7At8L/eCHVDeA78bXqygyM4IToVRNM9dgZ/JKfuEqhM6LEj1SN5BE EuMg== 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=DQiJWYDZBbUPZ7HiwC9ohaLu2KA+CJB23qe7/YkynpE=; b=QnzzkYdkhsY+GQAZwu4LISsTN7Vw4E1jSRhNTn8HuipOEDKcNUjxRxsiTOszOejuuj vsgUc634wC9p3VMilBQqp+NCiHs7VjZ43sE2j9lBGeH6BDV4Ud+qxnyzzpMwzdk80D/o kq7myQSB8wDhJZWHAg+/h1uHZHBRESL0aOhDE0MSQ5zB11QSaXd5D2hIZllr0uplSo68 i9HszCflaSdiX0A5z+qUtviFCjgMJVp0Ed0DdWD4tV8LX+N2SNEWS7hUDkfeOwXuB/Q8 vKVFhI04aB5jbk6kupTgvQS0xglUv39mYZEbHq5bpFdgBx1hnH3kq1OM8y2AamhNUQhh IyGw== X-Gm-Message-State: AGi0PubEtNwDD1lQcqwQ6QZOP6IDTxRFHxs1MbVgH+g4D7W6tDuZgGU5 70VERBBfudpoAazCB5jmHvQ07UTLWO0= X-Google-Smtp-Source: APiQypIMafuArKUWhOwYh7CleqIEkORQS+Pr/0JvlEpdIg6GPlWaIgJLRJjhXtbqkHkfG+qtrMOFSQ== X-Received: by 2002:a17:902:421:: with SMTP id 30mr13933009ple.271.1587343203757; Sun, 19 Apr 2020 17:40:03 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:40:02 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 19/23] media: imx5/6/7: csi: Mark a bound video mux as a CSI mux Date: Sun, 19 Apr 2020 17:39:26 -0700 Message-Id: <20200420003930.11463-20-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For i.MX5/6, if the bound subdev is a video mux, it must be one of the CSI muxes, and for i.MX7, the bound subdev must always be a CSI mux. So if the bound subdev is a video mux, mark it as a CSI mux with a new group id IMX_MEDIA_GRP_ID_CSI_MUX. In the process use the new group id in csi_get_upstream_endpoint(), and do some cleanup in that function for better readability. Suggested-by: Laurent Pinchart Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 45 +++++++++++++--------- drivers/staging/media/imx/imx-media.h | 1 + drivers/staging/media/imx/imx7-media-csi.c | 7 ++++ 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 8153ae5935cf..303f92ef4d9c 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -165,7 +165,6 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv, struct v4l2_fwnode_endpoint *ep) { struct device_node *endpoint, *port; - struct media_entity *src; struct v4l2_subdev *sd; struct media_pad *pad; @@ -176,30 +175,33 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv, return -EPIPE; sd = priv->src_sd; - src = &sd->entity; - if (src->function == MEDIA_ENT_F_VID_MUX) { + switch (sd->grp_id) { + case IMX_MEDIA_GRP_ID_CSI_MUX: /* - * CSI is connected directly to video mux, skip up to + * CSI is connected directly to CSI mux, skip up to * CSI-2 receiver if it is in the path, otherwise stay - * with video mux. + * with the CSI mux. */ - sd = imx_media_pipeline_subdev(src, IMX_MEDIA_GRP_ID_CSI2, + sd = imx_media_pipeline_subdev(&sd->entity, + IMX_MEDIA_GRP_ID_CSI2, true); - if (!IS_ERR(sd)) - src = &sd->entity; + if (IS_ERR(sd)) + sd = priv->src_sd; + break; + case IMX_MEDIA_GRP_ID_CSI2: + break; + default: + /* + * the source is neither the CSI mux nor the CSI-2 receiver, + * get the source pad directly upstream from CSI itself. + */ + sd = &priv->sd; + break; } - /* - * If the source is neither the video mux nor the CSI-2 receiver, - * get the source pad directly upstream from CSI itself. - */ - if (src->function != MEDIA_ENT_F_VID_MUX && - sd->grp_id != IMX_MEDIA_GRP_ID_CSI2) - src = &priv->sd.entity; - - /* get source pad of entity directly upstream from src */ - pad = imx_media_pipeline_pad(src, 0, 0, true); + /* get source pad of entity directly upstream from sd */ + pad = imx_media_pipeline_pad(&sd->entity, 0, 0, true); if (!pad) return -ENODEV; @@ -1904,6 +1906,13 @@ static int imx_csi_notify_bound(struct v4l2_async_notifier *notifier, struct csi_priv *priv = notifier_to_dev(notifier); struct media_pad *sink = &priv->sd.entity.pads[CSI_SINK_PAD]; + /* + * If the subdev is a video mux, it must be one of the CSI + * muxes. Mark it as such via its group id. + */ + if (sd->entity.function == MEDIA_ENT_F_VID_MUX) + sd->grp_id = IMX_MEDIA_GRP_ID_CSI_MUX; + return v4l2_create_fwnode_links_to_pad(sd, sink); } diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 11861191324a..d89026bb99a8 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -292,5 +292,6 @@ void imx_media_csc_scaler_device_unregister(struct imx_media_video_dev *vdev); #define IMX_MEDIA_GRP_ID_IPU_IC_PRP BIT(13) #define IMX_MEDIA_GRP_ID_IPU_IC_PRPENC BIT(14) #define IMX_MEDIA_GRP_ID_IPU_IC_PRPVF BIT(15) +#define IMX_MEDIA_GRP_ID_CSI_MUX BIT(16) #endif diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 7a9bad7b71d3..7a398e0e56e3 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1163,6 +1163,13 @@ static int imx7_csi_notify_bound(struct v4l2_async_notifier *notifier, struct imx7_csi *csi = imx7_csi_notifier_to_dev(notifier); struct media_pad *sink = &csi->sd.entity.pads[IMX7_CSI_PAD_SINK]; + /* The bound subdev must always be the CSI mux */ + if (WARN_ON(sd->entity.function != MEDIA_ENT_F_VID_MUX)) + return -ENXIO; + + /* Mark it as such via its group id */ + sd->grp_id = IMX_MEDIA_GRP_ID_CSI_MUX; + return v4l2_create_fwnode_links_to_pad(sd, sink); } From patchwork Mon Apr 20 00:39:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEDF2C5321D for ; Mon, 20 Apr 2020 00:40:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88B0B2145D for ; Mon, 20 Apr 2020 00:40:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JDsRVtD3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726168AbgDTAkI (ORCPT ); Sun, 19 Apr 2020 20:40:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726121AbgDTAkH (ORCPT ); Sun, 19 Apr 2020 20:40:07 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1D70C061A0C for ; Sun, 19 Apr 2020 17:40:07 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id ay1so3312536plb.0 for ; Sun, 19 Apr 2020 17:40:07 -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=oN/HNwCrbaMk4efWCxWK/gANgecdnCUQnoso3mWWKm8=; b=JDsRVtD3HrWkOKWlBhrMRpf0wsvVm8Zr/6eQjlv7+46E9acB9SeuPf3XFlNVDA8FXa 5Ic4XgL6PODJYlTXO+gs4Xd+NpS28WAsdtga9QGtZf3I/9uQzONFf2hgb/ApcW3xLjr7 1YqH4/M+2HhqKbZwC3tKy4ejD98uWx91QpYMXHZRbQV0FSwly4AiRVQcgmtMlnBsgiqx LQCbpDmtsN4VxzAlDrspmQJyQgCx9R9sIW+RHCOLb61tfNsMil3EoP7643PkSGgROGak nhYBJgP8WlxX4j8fcZExZ7wx39wgVYvKUywbh7jz8krjDIqCo8uZNKrly0426IyH35b5 xnFw== 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=oN/HNwCrbaMk4efWCxWK/gANgecdnCUQnoso3mWWKm8=; b=BTKGsSHDk1datQg80P7pKs0zlZ9Gs7fvMMlcn6zJdcBsfdHd4EJb0NChocBhCfTEkQ tiMeREhfYIebCYnP5BebgJuX4o7kqJtVUbxZCEjs1a2Rwl6h/kQJ2hGSMO+atcPmJQtt SIjcYrQHGLJuLOurKANgN+m0shiU0KMpeasLaufmJ0ZFuAtYI+fAuca8rbAYLIugXPUu mMayH7DQ03jl1S3UOHiM7RglS1hZBOqzWlWCOP5Q+1lvj2jFcWjJTsvbDdAeLIb1Ypzc SIqdSPB9JeJeUMHIXj7/r0k8Gdc94oykAUPiGEfSHtyYanz/ed0f3dqAWV/tplgYaCrh TGng== X-Gm-Message-State: AGi0PubC0/DgHw09KpF5Ks9rFrFR9YzZieY7ZcB64DVJ2Mrc3lEdoO2Y VYZ1W+ACcMYI7mJ4z+7NubYRU1aJQLU= X-Google-Smtp-Source: APiQypIJ5qBwMgqQe6bC9RH8TDStLS8WqCDAjIkOd1N/nPUc6eJDt9N3SADMltnUPfbroVuvE2bwIg== X-Received: by 2002:a17:90a:1910:: with SMTP id 16mr18638221pjg.119.1587343206525; Sun, 19 Apr 2020 17:40:06 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:40:05 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 21/23] media: imx: Create missing links from CSI-2 receiver Date: Sun, 19 Apr 2020 17:39:28 -0700 Message-Id: <20200420003930.11463-22-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-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 v5: - imx_media_create_fwnode_pad_link() has been moved to core as v4l2_create_fwnode_link(). - use the new group id IMX_MEDIA_GRP_ID_CSI_MUX to look specifically for an imx CSI video mux. Suggested by Laurent. Changes in v4: - none 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..f6ad9631fa0e 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 CSI mux */ + if (!(sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) && + !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI) && + !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI_MUX)) + continue; + + v4l2_create_fwnode_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 058a41e3d941..53bb22feb451 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -244,10 +244,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 Mon Apr 20 00:39:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 210109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ECCEC5321D for ; Mon, 20 Apr 2020 00:40:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E529214D8 for ; Mon, 20 Apr 2020 00:40:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nOIpwk+/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726189AbgDTAkL (ORCPT ); Sun, 19 Apr 2020 20:40:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726121AbgDTAkK (ORCPT ); Sun, 19 Apr 2020 20:40:10 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 980DFC061A0C for ; Sun, 19 Apr 2020 17:40:10 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id h69so4201291pgc.8 for ; Sun, 19 Apr 2020 17:40:10 -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=AS+AHCuMQWIyLmWzD2RHQ/sZnkJFO9p0vLnea6pI0u8=; b=nOIpwk+/SXXpNdXIg0pLKG9+XTHKRZ/7CRt5FSoITv+k0UE5B3QgA9nV+UmogS+X0w ajv+eL35aNu1z4q4bom4mUV1V9LupOHkGh0EJU2zeeZqpcrTtFVhmYoUDnmDnCzuDtfT x9tjHK8lfzIv/KWh9DP79hktZyNFy2YqBk5ufitz/aDkSWuU5ELgeMCjWbkQME08GrVZ ed46kgv4hZiVtZGjBo0T1vRZiF+ow5z5rOpQiRcv3CqnBTvRGDr79Dz6z7SdzC3aJAoW oi6afMh5WYkmkePlm188/oK009WW1EsShflDQtfBXhxifaC2o/2DRi2iv3GY1CfC+4At 8bpA== 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=YRf8/79dbntnKbeFWNbjMfzPHl6vbMrdfXLC5D11QFNKuY/Ot/AJr9VcadKqmrLnb3 JW5L3dadjPQKXum6IG1xrjc5pQ7ImpOb/cjK7PExbmu2mmNgjpTKrs6O8W47kxmo1KME YeH8vbGX/OLXHrOjgzPR8WGxbyVTHM4GvrunzoaDgGidwln55cIaSq131TsncXY6XZtD dq3cbACyBTDid8Afl8qU+5GeSMoJ6kDHQ7sk8vYXk+9ZhhkBO5EnRshtkPKxc9devSGL yyX6lqs8bCx2xnLabKla+z/tzzXW0jlMRVhvuWU06xTXpb/SugB4Ec7urm9I/BwOXFg+ U3zQ== X-Gm-Message-State: AGi0PuYg/R0XiaXFhLVvPapNb3L7jlpeAXWe6RaTV2ZsZmlTmmZixZwg 2Rn59jJVrDTHkZpoonuNObpoipS48EY= X-Google-Smtp-Source: APiQypLxor1zhs1LX2Z1E/dQEUMkYtAjUnF4AglmyLj23pMOu08AU71xmNo/iTEtQIys5rYK82qhjA== X-Received: by 2002:a62:7d11:: with SMTP id y17mr14023458pfc.127.1587343209766; Sun, 19 Apr 2020 17:40:09 -0700 (PDT) Received: from mappy.hsd1.ca.comcast.net (c-107-3-184-99.hsd1.ca.comcast.net. [107.3.184.99]) by smtp.gmail.com with ESMTPSA id f30sm12313701pje.29.2020.04.19.17.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2020 17:40:09 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Rui Miguel Silva , Laurent Pinchart , Philipp Zabel , Steve Longerbeam Subject: [PATCH v5 23/23] media: imx: TODO: Remove media link creation todos Date: Sun, 19 Apr 2020 17:39:30 -0700 Message-Id: <20200420003930.11463-24-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420003930.11463-1-slongerbeam@gmail.com> References: <20200420003930.11463-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