From patchwork Fri May 1 17:15:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11522945 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 BD87192C for ; Fri, 1 May 2020 17:16:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2D3F24956 for ; Fri, 1 May 2020 17:16:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cMYNJxm6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729046AbgEARQG (ORCPT ); Fri, 1 May 2020 13:16:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728495AbgEARQF (ORCPT ); Fri, 1 May 2020 13:16:05 -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 5CC61C061A0C for ; Fri, 1 May 2020 10:16:04 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id hi11so143743pjb.3 for ; Fri, 01 May 2020 10:16: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=9mTYcYwO3j5DgB6hEjXQEWO63m/OWQAU74YbBUG9mak=; b=cMYNJxm6hkL/YRxGLK7PHDXEtSyeFk/U/hbGZY9MbKvvpVZ4xziBSPFdr0hyMWkAa/ p4nlEKAxDbdHURFWcGl7Olyf25mSbtDxJwxVTqdGyCFsWJDUK+jtZxQgW77i9Cm5bKtc U5OFij8Zt2t8jlqFyQ8joNiwKUPyEYqb5JxvGWdGiVQSQ52a2yPr3aW2v7qpCOg7WiJI j4BCV0Q6TZTJcRWJutfa/TabWaviK1Efst6Tmg8BeXCErC8Wg82xRB8BboY/lG920/95 oxoMA+yfYXbzjh8vaiJuAItMpXKGvE+rblbWyqXygdpyfNIQFbaCbuE6TrYAGqY7VwD5 L++Q== 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=qjxj6hQ1rhK2/3XIYrhXDu5iuKM577lnhu4UyF9AWMR2KBkVigy61nb54/KFs4IQth v6vpTgvzUft/RZvXcpA9xeX4sUlRVIqGlaXlJriZoR8kWINFSkDnu6p6tcfCHsrK5v6z QMmZrUvAjxvmrsnBz12Uj4C6BKt1MaHZyIxfw6KBRKWPEGy/0h3Yl81097CTC5GnpDp2 1E71+kAHiZH3933NS5nQfmCiRySqDFxTUr4/86uTsolwH9dPEKOnVUq+VrsnaRBTi0oI 8FZATNHa8U7UasrCyxrJdMwIUwJ4lIkSpeU7+tsjJviIiGRInCR7+1qOdYNb9m7AkSE0 3Bfg== X-Gm-Message-State: AGi0PuZjZZh2OvzKBIbdjzPV9wdk+13AK3gulRcQURHmFFPx0N+EbHtv FlEvKJnSRmIBccFQsn++EYeCymL8 X-Google-Smtp-Source: APiQypK95o/GFLBWMNScioewRPXJbYTOz4ifDeGbIl3VGcz4Tx8YBYXqliHYOfriwlMbU0wLQ/qR8g== X-Received: by 2002:a17:902:9682:: with SMTP id n2mr5458335plp.44.1588353363625; Fri, 01 May 2020 10:16: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 g14sm2733966pfh.49.2020.05.01.10.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16: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 v6 01/22] media: entity: Pass entity to get_fwnode_pad operation Date: Fri, 1 May 2020 10:15:35 -0700 Message-Id: <20200501171556.14731-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 Fri May 1 17:15:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11522947 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 F2B0114B4 for ; Fri, 1 May 2020 17:16:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DADA624955 for ; Fri, 1 May 2020 17:16:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JiD72NVj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729061AbgEARQG (ORCPT ); Fri, 1 May 2020 13:16:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729037AbgEARQF (ORCPT ); Fri, 1 May 2020 13:16:05 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFE9AC061A0E for ; Fri, 1 May 2020 10:16:05 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id v2so3842945plp.9 for ; Fri, 01 May 2020 10:16:05 -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=/RVoX7yT7iGvoW/qYzoH+jpIAMj0AtP9LvPCJFybw1A=; b=JiD72NVjDtz3enhXc7RGkxBL+K1uTheOlPVTi9xueyKWRcDLMAATycu9ppnGl20NyT +a1oDIawnsYaZiM1whtrJMGzgKRUi1dcbtdJyTXPvBYnFJnsmUkVvg4SegU9n7q4H/47 H3F77Ia/pGac8/Hjm1rkSNivInEg49FOeezUfK7o4j1gFhC5/GOUAO8Yx2IFmWVQxu2W cro9zV/O6zB8q4HgTCWIeoHC/k5qb0oYoPAvnbRvcfXaqwQP3NabKbq/8DjjNCkOmnB0 Pbs5/1wlkgQQW5OB4RLKcEM8rXIq6pFZLf8IoVs44hSw8BnzaTzpdkNfsxbUWbKwPIWX P+wQ== 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=/RVoX7yT7iGvoW/qYzoH+jpIAMj0AtP9LvPCJFybw1A=; b=n9sssEOHqaya22/QpkR2izaThQN8QvMQlXaEx7MZWRTJ3UUsrlUETaIhwWp8oKE6uI u0D4NDg5rBQVbDkk4WwJNPu3F5Z/wP8GSdT5ADMYaJ0/0rgUvmDAWEQpb4Mf7xoxBlQI ltARGYpOoiipZkbavU7CLki28so4aB1C08TAPltYp19iycXtOqgSlMaV6HvyHeOJ5N2S B3ZPSXGvhPd4hGy2KhH9FAK5Rshy/RzzEO+3VrDWRGRrVMhv//s/pXZgAi0McJCgvOU8 pRSGgh+KP7Gj/fafp743hODVxgxZgIZCFzCqqgtXiWfRQ0dQhTgZ3Br3Q41hEgrs2cWI ml0A== X-Gm-Message-State: AGi0PubHLxvlVc82UexrGDnnmMnInEEu6NApTnFz9dufyWBEiCK94b8V BTWWmwfx0R/m1msQ1iHtjnJUXK3K X-Google-Smtp-Source: APiQypIGQLRj5b3HPqLRhGAA9gLVcvDelGhiVn0VbK0+DaLDTDHWcsg9UEcZpiyw7Jh9WL2HZEu8lg== X-Received: by 2002:a17:90a:a40e:: with SMTP id y14mr680710pjp.101.1588353364997; Fri, 01 May 2020 10:16:04 -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 g14sm2733966pfh.49.2020.05.01.10.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:04 -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 v6 02/22] media: v4l2-subdev: add v4l2_subdev_get_fwnode_pad_1_to_1 Date: Fri, 1 May 2020 10:15:36 -0700 Message-Id: <20200501171556.14731-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 | 22 ++++++++++++++++++++++ include/media/v4l2-subdev.h | 17 +++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index a376b351135f..3bdda686341f 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -696,6 +696,28 @@ const struct v4l2_file_operations v4l2_subdev_fops = { }; #ifdef CONFIG_MEDIA_CONTROLLER + +int v4l2_subdev_get_fwnode_pad_1_to_1(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct fwnode_handle *fwnode; + struct v4l2_subdev *sd; + + if (!is_media_entity_v4l2_subdev(entity)) + return -EINVAL; + + sd = media_entity_to_v4l2_subdev(entity); + + fwnode = fwnode_graph_get_port_parent(endpoint->local_fwnode); + fwnode_handle_put(fwnode); + + if (dev_fwnode(sd->dev) == fwnode) + return endpoint->port; + + return -ENXIO; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_get_fwnode_pad_1_to_1); + 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..f7fe78a6f65a 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_1_to_1 - 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_1_to_1(struct media_entity *entity, + struct fwnode_endpoint *endpoint); + /** * v4l2_subdev_link_validate_default - validates a media link * From patchwork Fri May 1 17:15:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11522949 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 B9C5892C for ; Fri, 1 May 2020 17:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E3B82137B for ; Fri, 1 May 2020 17:16:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uquU//Bo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729037AbgEARQI (ORCPT ); Fri, 1 May 2020 13:16:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728933AbgEARQH (ORCPT ); Fri, 1 May 2020 13:16:07 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37E10C061A0C for ; Fri, 1 May 2020 10:16:07 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id a31so149202pje.1 for ; Fri, 01 May 2020 10:16: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=xqvf4AG0d588UR2GuJsbJfkppVg9/Oc7aooELImZjbU=; b=uquU//BogVT0nU0tS4uIPqkl9/OVN6rQkiGCeQAbmQAA6L09W4UWD3qrugnZ6M87pN OKDC4RZc/XMOV+nV3JwzsTIH+Zoq4kfub/BcXiC256MYsLqSvO8a4jfj/6fQ12j6OT25 CmpsvGt/UFjH9IzgDfqHYQocDHssnoqNOe0BBiCIZcqQ7HWuGFi4AQrH9682xv8Yh7SO TDm42Qes3VXL5O/YBFww/bD7BOyxqOESfGgLhf/yRJ+cDopaOCoIyb6xwTUNZQ5ohtVF l9lxGR48kSg+lWsA23cLExhYWeJNJ/uWZaOnxpj+XxNMZICAcY8NrDZc0FA337j99usK 4jqw== 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=xqvf4AG0d588UR2GuJsbJfkppVg9/Oc7aooELImZjbU=; b=c8MyYOStwpmg/+8Q9d8VPH+fZWmgXQCRbZJdEjhERO5rySf9z8tsdObGhHiUQzlCZO Fwp7klIbF+894SKmS5CM8HYu2ZU8cJm1y40cUZmjVFhXINl+bisnZrUmVXNuS3CL2tyC ep+uztnNxLDeTsB2wj3FG2AMykg8loOGZwYKPfe+tGoQvoYTRonRSURDsOPWoUC84jT/ Q4n6mlv9IjnV4kIwSSg55FMel7VB1gZJsUdpQuucxbvIaCeHEmnfey1uXS+w0lAI5KME y8grINr28YUV8Act5oxZlEFvcb5YOI0IrbuqPMSXPQF+723m9Zavv11uLFDRRVLMXZw7 8mIw== X-Gm-Message-State: AGi0Pua6DYK+JgiFLVq9xOa+WWLSOTCL0oM17+8SDBizI0WVsBS9oRbG Kn1/t8gmPYVnXLZUzrdocZqlbK4y X-Google-Smtp-Source: APiQypIqpbYTSWTACXVDOXk191yY0HXzwIuDncNAnf/GN+y1mpSvC9orqhzQZIoGlPM2TWe/S4s+gQ== X-Received: by 2002:a17:902:b20e:: with SMTP id t14mr5329434plr.223.1588353366353; Fri, 01 May 2020 10:16: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 g14sm2733966pfh.49.2020.05.01.10.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16: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 v6 03/22] media: v4l2-mc: add v4l2_create_fwnode_links helpers Date: Fri, 1 May 2020 10:15:37 -0700 Message-Id: <20200501171556.14731-4-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 source and sink subdevices, based on the fwnode endpoint connections between them: v4l2_create_fwnode_links_to_pad() - create links from a source subdev to a single sink pad based on fwnode endpoint connections. v4l2_create_fwnode_links() - create all links from a source to sink subdev based on fwnode endpoint connections. These functions can be used in a sink's v4l2-async notifier subdev bound callback to make the links from the bound subdev. Signed-off-by: Steve Longerbeam --- drivers/media/v4l2-core/v4l2-mc.c | 95 +++++++++++++++++++++++++++++++ include/media/v4l2-mc.h | 48 ++++++++++++++++ 2 files changed, 143 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index 0fffdd3ce6a4..ba2f2b8dcc8c 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -309,6 +309,101 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q) } EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source); +int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd, + struct media_pad *sink) +{ + struct fwnode_handle *endpoint; + struct v4l2_subdev *sink_sd; + + if (!(sink->flags & MEDIA_PAD_FL_SINK) || + !is_media_entity_v4l2_subdev(sink->entity)) + return -EINVAL; + + sink_sd = media_entity_to_v4l2_subdev(sink->entity); + + 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; + + src_idx = media_entity_get_fwnode_pad(&src_sd->entity, + endpoint, + MEDIA_PAD_FL_SOURCE); + if (src_idx < 0) + continue; + + remote_ep = fwnode_graph_get_remote_endpoint(endpoint); + if (!remote_ep) + continue; + + /* + * ask the sink to verify it owns the remote endpoint, + * and translate to a sink pad. + */ + sink_idx = media_entity_get_fwnode_pad(&sink_sd->entity, + remote_ep, + MEDIA_PAD_FL_SINK); + fwnode_handle_put(remote_ep); + + if (sink_idx < 0 || sink_idx != sink->index) + continue; + + /* + * the source endpoint corresponds to one of its source pads, + * the source endpoint connects to an endpoint at the sink + * entity, and the sink endpoint corresponds to the sink + * pad requested, so we have found an endpoint connection + * that works, create the media link for it. + */ + + src = &src_sd->entity.pads[src_idx]; + + /* skip if link already exists */ + if (media_entity_find_link(src, sink)) + continue; + + dev_dbg(sink_sd->dev, "creating link %s:%d -> %s:%d\n", + src_sd->entity.name, src_idx, + sink_sd->entity.name, sink_idx); + + ret = media_create_pad_link(&src_sd->entity, src_idx, + &sink_sd->entity, sink_idx, 0); + if (ret) { + dev_err(sink_sd->dev, + "link %s:%d -> %s:%d failed with %d\n", + src_sd->entity.name, src_idx, + sink_sd->entity.name, sink_idx, ret); + + fwnode_handle_put(endpoint); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_create_fwnode_links_to_pad); + +int v4l2_create_fwnode_links(struct v4l2_subdev *src_sd, + struct v4l2_subdev *sink_sd) +{ + unsigned 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 = v4l2_create_fwnode_links_to_pad(src_sd, pad); + if (ret) + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_create_fwnode_links); + /* ----------------------------------------------------------------------------- * Pipeline power management * diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h index 5e73eb8e28f6..246eed398648 100644 --- a/include/media/v4l2-mc.h +++ b/include/media/v4l2-mc.h @@ -12,6 +12,7 @@ #include #include +#include #include /* We don't need to include pci.h or usb.h here */ @@ -84,6 +85,53 @@ void v4l_disable_media_source(struct video_device *vdev); */ int v4l_vb2q_enable_media_source(struct vb2_queue *q); +/** + * v4l2_create_fwnode_links_to_pad - Create fwnode-based links from a + * source subdev to a sink subdev pad. + * + * @src_sd - pointer to a source subdev + * @sink - pointer to a subdev sink pad + * + * This function searches for fwnode endpoint connections from a source + * subdevice to a single sink pad, and if suitable connections are found, + * translates them into media links to that pad. The function can be + * called by the sink subdevice, in its v4l2-async notifier subdev bound + * callback, to create links from a bound source subdevice. + * + * .. note:: + * + * Any sink subdevice that calls this function must implement the + * .get_fwnode_pad media operation in order to verify endpoints passed + * to the sink are owned by the sink. + * + * Return 0 on success or a negative error code on failure. + */ +int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd, + struct media_pad *sink); + +/** + * v4l2_create_fwnode_links - Create fwnode-based links from a source + * subdev to a sink subdev. + * + * @src_sd - pointer to a source subdevice + * @sink_sd - pointer to a sink subdevice + * + * This function searches for any and all fwnode endpoint connections + * between source and sink subdevices, and translates them into media + * links. The function can be called by the sink subdevice, in its + * v4l2-async notifier subdev bound callback, to create all links from + * a bound source subdevice. + * + * .. note:: + * + * Any sink subdevice that calls this function must implement the + * .get_fwnode_pad media operation in order to verify endpoints passed + * to the sink are owned by the sink. + * + * Return 0 on success or a negative error code on failure. + */ +int v4l2_create_fwnode_links(struct v4l2_subdev *src_sd, + struct v4l2_subdev *sink_sd); /** * v4l2_pipeline_pm_get - Increase the use count of a pipeline From patchwork Fri May 1 17:15:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11522951 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 2E83292C for ; Fri, 1 May 2020 17:16:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1783024954 for ; Fri, 1 May 2020 17:16:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DBpS263Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729112AbgEARQK (ORCPT ); Fri, 1 May 2020 13:16:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728933AbgEARQJ (ORCPT ); Fri, 1 May 2020 13:16:09 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E63EC061A0C for ; Fri, 1 May 2020 10:16:08 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id w3so3847705plz.5 for ; Fri, 01 May 2020 10:16:08 -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=DBpS263QMw5+MtOoiLyAmY6fQZOYrYNAGwCi0tNjVcbT6AqH3gpz6A9dWFGm4mgnEp bkd/3rFxMxpUTZUBIfRkEFAswfnECV223JcYZbMgp2PgtZRTN4Q4/UOQUGeNxCqN0+Xj I7MQrpMEHqVdghyv3p7sCep0nGhNgU1gfyokLhkJHAp/FqUyeWaPy+YpSAlqaAo1azKV 8iKcjitszyn5f8H/oG22o2tZ7Qm5o25Ui19Od8cgrHqpwTLXYFoR9878LvGiUSpl0nkN lpiyzH993iNG52/4LMXWtV55X03tWJJ/qsRV16CVaxSFEP9FqRi6GX/WSKSuGjJWGtYg bCBQ== 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=neMaXt3WWzEu9Rlv/p1rI2DUZSm/9vtlKUd9Xdeo/lEHHZ8iF+ghvzv8U5Bla2bJ/w AQi4F2LDwkSvdvrO6+jh/rZvoOAzpAa8NNmIbg6E9nLZ19icbfa7WatJlKckjPP3FwfV kK92oTs22I1FmeoRyNVnMJ+pnKDEwfumNSZaMcVNW4+5inn+aGuo/QtBRpBGBUClCot2 a0D/lkpool/fnPzAgH/PUTdJg52BYQv1knbU9IgNjHwAJELJVWDU2gPiDlYYXbMcSfLg pD2qvinelN/RgZrJS7AO6klcmOSoLYBfp2tBj/WoWUYnKr2CsL7iCXU645F/XL3w72hf h/Vg== X-Gm-Message-State: AGi0PubCqsyadFEiNfAvclVwvwvkZzscUSS+6x5gVCIlrL6nk0YGujST Zci7BoxEpN5ZL0WzNQ4ltnq0VilH X-Google-Smtp-Source: APiQypLEHLY7P5/rVu4uifih+nyf4vN5dlGCEhLuaXE/lzWAriDGJUwU7da6JEPbHRKY6txWdgkp2A== X-Received: by 2002:a17:90a:6343:: with SMTP id v3mr646254pjs.127.1588353367674; Fri, 01 May 2020 10:16:07 -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 g14sm2733966pfh.49.2020.05.01.10.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:07 -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 v6 04/22] media: video-mux: Parse information from firmware without using callbacks Date: Fri, 1 May 2020 10:15:38 -0700 Message-Id: <20200501171556.14731-5-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 Fri May 1 17:15:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11522953 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 B44AF14B4 for ; Fri, 1 May 2020 17:16:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9380124954 for ; Fri, 1 May 2020 17:16:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rQZRS80f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729135AbgEARQK (ORCPT ); Fri, 1 May 2020 13:16:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQK (ORCPT ); Fri, 1 May 2020 13:16:10 -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 EF874C061A0E for ; Fri, 1 May 2020 10:16:09 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a5so146252pjh.2 for ; Fri, 01 May 2020 10:16:09 -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=lMJO/HEuAKBb3REdiDxDlVu8OygfZHZORsB9lQ5SZSo=; b=rQZRS80fuZQunmi+L+JCD0GDabvkBshskq0vkqzdVgL2qb/uPKoltU3UmzrfjAFOFb Yr3ju5g9WTMFBCVwwmA7UYMOVEm6IMUIYboFH5xo3JBdrsS7AXSMwDSMB8+GxYZb5oRY AwAOVclNbP7GO1QG1TJDGQniPPuJ3L7sZBFpaJxJDdfpL2b1yy/quUDXEGITgoAOqztU QJg5EtiNDFv/W1riMQP7FNTffYxkt7NpVY09YUwPT2W82o4SQfW5HsTdGfqpkuEIiLUw JypKrv2M8rABCJeewLFb8KtQFYml5fVwODQLNT4hYMMdGENNWcrHpiTFpMhDa0BvYPrg G/0A== 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=lMJO/HEuAKBb3REdiDxDlVu8OygfZHZORsB9lQ5SZSo=; b=ASzicAlkksNsmlfnCOx3gwZUuNIcZ1jQbAcXEpf8MN2OdIti8JxtGPIu9a4YnUi1mh WXectihX2axnR/h5e91nj6dyfEsDg7xGP/9tHt6SxPlU4qoAICAHyvW9IVjBP5u5rRAQ Okq+Nam+eUpwVHVMIbAiyIQ/KiHgDgzsrfCUoEc1Xbqntvr4puYIlNBjy6FVMP1uaLlw Yd1YwRjw1mn2it/do2WZ3WZ7y8UZhqaVBMXAj9fVkmo2JmMKtBV9HAhe9zOZdFoTdGxw MLyUZeyju+9OHllCJSXkmfaUhmT5U+khQ5APaSUIFtpKrSYJ49pKl9qpHDBtVtbzsAZc FXAQ== X-Gm-Message-State: AGi0Pub7NHRjVGs8EhbCmZiSL1pQV3/FgkhxUXBRuxzzWjbHWqdYG61+ zDyUg95RzsJTiulQOX3pnrqg1vwF X-Google-Smtp-Source: APiQypK47Lgp/oeC8Q3DJDa5fBDvUSqMcwkF/CIyzG8H5uZ/DKHFzgwF8rg1O2WZXL3Ev8loCGCPUQ== X-Received: by 2002:a17:902:8d95:: with SMTP id v21mr2263739plo.322.1588353369009; Fri, 01 May 2020 10:16: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 g14sm2733966pfh.49.2020.05.01.10.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:08 -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 v6 05/22] media: imx: Parse information from firmware without using callbacks Date: Fri, 1 May 2020 10:15:39 -0700 Message-Id: <20200501171556.14731-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 66468326bcbc..905b1ee27db6 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; @@ -1869,59 +1871,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) @@ -2001,9 +1993,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); @@ -2017,6 +2013,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 8ab823042c09..332d77aec8aa 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; @@ -633,15 +659,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); @@ -655,6 +681,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 1ac10f807ac0..abef59dc22b6 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]; @@ -1202,11 +1203,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) @@ -1289,19 +1320,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); @@ -1326,6 +1359,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 e2403b448b6d..b66299c1136d 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -221,6 +221,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; @@ -946,33 +947,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; @@ -994,17 +973,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; } @@ -1111,6 +1131,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); @@ -1129,7 +1155,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); @@ -1217,6 +1246,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 Fri May 1 17:15: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: 11522955 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 AEFEF92C for ; Fri, 1 May 2020 17:16:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93B9824955 for ; Fri, 1 May 2020 17:16:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eQgYazT0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729182AbgEARQM (ORCPT ); Fri, 1 May 2020 13:16:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQL (ORCPT ); Fri, 1 May 2020 13:16:11 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F30C061A0C for ; Fri, 1 May 2020 10:16:11 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id y25so1837140pfn.5 for ; Fri, 01 May 2020 10:16:11 -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=eQgYazT0syAKPkzd3IwUdSu6HnNkPO+JEmCibV8D6LfY3aBs+JLljAxz7HsKGRAPUh EpLZrphVns1wfoMaRIsuG+B9wTwiwfRiPTqL+Lf8ho7ZSKtTurTY5u9toFh1MgWk1OzR KhTbySO2jk5KqIny0tUgGHdJy+31PlEG8IJq/3+yfTQ8H29ADMMZwosm6ZXslw3GjSIx FDrukisVCUXLql1lTqcVcoj6stScWIBtdTLOYvSx5/0bw2shH++wpjt/SN+YEc0yz+Yq 6ajaAuINery7B/u6ZXVGMypJKO2eZN0vLjGqfrCQ6+wL9yvDaTPS7M+PRas6rzo5zzt3 zmjQ== 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=dlRzFazDaKSHiNp8MzMP/sdLaxQfkF/0mSqKA5pyeDboo8i3sq7hnc3OdAMheHI1Dz WDByEHwpzjwLucPsYfTk9DZUX5rEUkinF1CORxCa4vSGhYFD3JxYLzbINcjvQ7oZtkrE sLw9nazQ+iF6uW+ow0IPEVuTYdF2Hx0ZDLdqzh6YmTkcgv78QrtpJntpt1sqlkJV3aaE sgis19hwZQ8hxa2srqIOiSnHjO/x9kFlpnUJZP21MdZMkbfSzaFfKC6UK773zsjfdtN1 /MOZvSTXV1d0L6w1UzEwMqBm+7l+QjzznYZY2r3xBweX70lbIBi1kSuyf0YJNQTPxrSX pMpQ== X-Gm-Message-State: AGi0PuYgfDo1GOdOy+Srf7RoyJ4K1J/ipqfz4nmNN9e6Dyyz+dN4tMmG U4F5z6sw1LnzqmEIu1I9TbokV1Yh X-Google-Smtp-Source: APiQypJ7AX0j0MUPsyJlh5TTDApKzh3UZIOL8CHcnPY9JYTZAdfVjyZUGvYz2vM49x9AoNBwxKxhRg== X-Received: by 2002:a62:144c:: with SMTP id 73mr5147723pfu.37.1588353370344; Fri, 01 May 2020 10:16:10 -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 g14sm2733966pfh.49.2020.05.01.10.16.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16: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 v6 06/22] Revert "media: v4l2-fwnode: Add a convenience function for registering subdevs with notifiers" Date: Fri, 1 May 2020 10:15:40 -0700 Message-Id: <20200501171556.14731-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 Fri May 1 17:15: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: 11522957 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 E649792C for ; Fri, 1 May 2020 17:16:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFA7F24956 for ; Fri, 1 May 2020 17:16:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dhgtSVhG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729312AbgEARQN (ORCPT ); Fri, 1 May 2020 13:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQM (ORCPT ); Fri, 1 May 2020 13:16:12 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CF7BC061A0C for ; Fri, 1 May 2020 10:16:12 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id r4so4820223pgg.4 for ; Fri, 01 May 2020 10:16:12 -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=amjt0D7pRAoNOQO2ul5J9FAiqMKYe4q4mNXCQU5qr60=; b=dhgtSVhGsqT3dd2K3cp09aW3o6kqpzWy6OPC08r65D9JU1Z1+DJTQlZ5AbmrFAflLX TABwMSyy4xwebCw2v3g4kx+LDoK7MeIPbk3L46LdiDCIVODNEu5IkCtSnScUAAN5s+aj +Izgt6cvfPYDQYV5qY1BrHV4TPokCwxqz2zvJUKUPWkT94e29SZrjCjfcCVjrHNjWPzt KSMcwJ5opSGvkmOHVSqsNRgcferkQYv+BtXevqys47ReIUt9HMdTo3ZlXV35F9mg+uIE 0h8YcYgbKKSUe/oz+xytaqhr7cWsmKcKTNIsYiUP3eJovNLd8JD6O/3oLGuSKmU8K9TS SSUg== 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=amjt0D7pRAoNOQO2ul5J9FAiqMKYe4q4mNXCQU5qr60=; b=gILAYqO+Wb2KhAYDkO7EzO9L+29tAzm+takB+fIIgduP8f7UJFYfu4SClf5U3oIUYj 3Arj6Wz6eKfXz67k8WX5m4/WhON4lMgVp8wOV705TcGj3hBwt2mkIy1KpQ9sWb6Og+rK Qskb0mPmit53DeZiNgWkwTdXnXIR0qd96sBO/qKVxg+57GJfcxrJwZTVZER4FwmcAjnX aERnPZu68cEVroIR0vEgT71tBN44T+eSdGRCt58IrrEY0+4zaSu1k3drg6u9uA1bj3bU t87oOQh1jHCohDHiD69wBwbepRV546UaKbaaU0VsvsULyI7bKID4IwS8HijUsFx1DoLj JJCg== X-Gm-Message-State: AGi0PubhQHB0x/tUoX/AsdmOSTJq1GdNw2aHABNK7YddOMmWD6zxFbwy lVgUrVlS9C2UvHlHCUkrBGL1SG0J X-Google-Smtp-Source: APiQypI4Nxz5XaLOsdfjgBCZzpUHMk7AF+E532rIrDcRy8Qb5yT7hVT6+0U+JXPjHBw2STvcO+NWzw== X-Received: by 2002:a63:eb15:: with SMTP id t21mr4961320pgh.279.1588353371738; Fri, 01 May 2020 10:16:11 -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 g14sm2733966pfh.49.2020.05.01.10.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:11 -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 v6 07/22] media: imx: csi: Implement get_fwnode_pad op Date: Fri, 1 May 2020 10:15:41 -0700 Message-Id: <20200501171556.14731-8-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 905b1ee27db6..08f698af4797 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1832,9 +1832,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 Fri May 1 17:15: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: 11522959 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 5A88E92C for ; Fri, 1 May 2020 17:16:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42C4424954 for ; Fri, 1 May 2020 17:16:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MZAqA2Cj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729391AbgEARQO (ORCPT ); Fri, 1 May 2020 13:16:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQO (ORCPT ); Fri, 1 May 2020 13:16:14 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 401F6C061A0C for ; Fri, 1 May 2020 10:16:14 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id s18so4801743pgl.12 for ; Fri, 01 May 2020 10:16:14 -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=Dg8KbWlDnXHLMKnZ1WrAv3cvcCZ02gA3fmDwwT1MLdE=; b=MZAqA2CjwAT26XTGJdTdHWTS8QFPG66KdQsvoxIaMfUcb9SW1nhNkk0FbcyQ7rDWzT pKPp6q0cVV8bn+jP2V/ayKAsw0T1mj3/2Bv+vuD2YOLTcewnbRK8R76y+bX4z8s7ldsr cRiYQkCAHE3S2NDrnrj6hbJnG3WNeDp09SDNyNoJxbC3NLjS8XUgzdxnFDH1AnmGyCOc rnSlAgolEWfcBUXYUUXh0BdTKFsayXO1pAcBCrO6WnPWE2wxOLuSUtEmBz9DUn0++6Al uLvR4c8IX1zZPcj3wmz92H2HR4NTK5BTK6qN3IXDcjRdKimfXhNSSz1hUP//XdD07g80 EhOg== 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=Dg8KbWlDnXHLMKnZ1WrAv3cvcCZ02gA3fmDwwT1MLdE=; b=ORGzeu+TL4d6ygC4eopodgFkF5a37tq1GuZDvvcCSQ1q06JovLhZY/JyhC2FbDWWIm TN58YX8wPzq+AaNq0PVM6nDQJTaX/ycdsRJZe4+iXLN4xl4EibqGK9ef3bn2lWhyBZhm 2OHijGQ2HBbfeoBHpIUVgUNQCKdi9m2rZ2h0vifzc9QaptpX/OjFkVAEgPcNj8Voo+70 e+qXPBKgV+2uMzQXpcIo1P/083lkM+yVwwtGKnE7U8aCk0hPeYdiWHA0UdW1QGeh3DAm F40/AITE8+QfmWbPJkTplnwKinSLg5388B+iSR2tEU+Dan8sd4jQ98ay8P58yT2et9Z8 3muQ== X-Gm-Message-State: AGi0PuZsbHdI1yTFTR/s1f/wQIy+odd9ZZugiCv712iNMniD+eQoqNBk fscmRPmNBmnaKH+0wwV8itm7aVli X-Google-Smtp-Source: APiQypKjpyvPjhTSlYMGrs9b6jk6kWM/eW7i7uxdOlWjbDnawVoR6fGbEE6rJxmf7NrQdvEpRmk6og== X-Received: by 2002:a62:7ece:: with SMTP id z197mr5309425pfc.244.1588353373272; Fri, 01 May 2020 10:16:13 -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 g14sm2733966pfh.49.2020.05.01.10.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:12 -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 v6 08/22] media: video-mux: Implement get_fwnode_pad op Date: Fri, 1 May 2020 10:15:42 -0700 Message-Id: <20200501171556.14731-9-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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_1_to_1() 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..9f148f403603 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_1_to_1, }; static int video_mux_s_stream(struct v4l2_subdev *sd, int enable) From patchwork Fri May 1 17:15: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: 11522961 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 A2DF614B4 for ; Fri, 1 May 2020 17:16:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C0FB24953 for ; Fri, 1 May 2020 17:16:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RB2ttOVm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729432AbgEARQQ (ORCPT ); Fri, 1 May 2020 13:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQP (ORCPT ); Fri, 1 May 2020 13:16:15 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A400C061A0C for ; Fri, 1 May 2020 10:16:15 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id f7so1830168pfa.9 for ; Fri, 01 May 2020 10:16:15 -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=uHr5JKoQoDtH72JlNFLgtURjWLo3YGj8deaBxUTPJOg=; b=RB2ttOVmnRoYuZd2k3MUsWHmkfany7VaXoCqXth77Bql4a9xZZlfWStCPJDIy3JcFB ViD5AKgg9LSv7wGfD1LksPDEGVKS1slXQzv/Jv4sa5q4Y2+4kY4GAvtEGsweYDV9kkJo uvYNd//TQJHBiDB+G6oVkLO4rUpMKtZKKf69hdsedJ/W4F5jkMguk1OK2jSLClriatYB +YaGnkD4snAawCY4dB/p/b6ydi+ktFDE4RA3YmtwiR2BR+6+U0boTNJHcNDW9q0AsAro zzlxIbPIDCmmItg3vnQStGxG/HXy4aWHKTf14x3gKO7VAydSIgYml77y8EVnf63eyCOX eGUQ== 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=uHr5JKoQoDtH72JlNFLgtURjWLo3YGj8deaBxUTPJOg=; b=ZTNOdZSndDeHYQYzOwkwCa2X54N2pdC5OJohkd7Um3Z2YIWlOLHr6ILmB33jutF6IF 8xl3YvD1c/G1UgieJOT4Bg9bXpUEe1bt3HypX3nHQgk036JgRZTfuIT41185MfjpUN2q IDCoPIcE1MS+Tajr1PEQLLxXZdwfSU5IM9TFrZQFvn7eElTp/0k2VrfG+Lhk+X/DQcN/ fS7kMEqllVURHpvh1pTjjh6yDOjJB3U36CYJ8I4Y/Qbbs4Rvvk4SYO/pZqI7mA82oWnJ dmQLPwGX+7r4Igl7xEd80AipU3G8pRUPp0uexhkaW0Cf4cwQOvmup/yeIQNlq2pjeR0I 8D+g== X-Gm-Message-State: AGi0PuZd7l8yzFTgT/8i3KDa75iyOlCtrTbzzbjLsua/XaQPorxWUAEg XWkdM8ZtFeK9UsMdoYFuGoMSbqTJ X-Google-Smtp-Source: APiQypJHqewNXyH53HtsQhxFejQqBdIP8Y8W+dh4xDf0y1hK1FfqWobpZyGNrO6B+6C2o7Ibo68mqg== X-Received: by 2002:a63:e242:: with SMTP id y2mr4610812pgj.205.1588353374587; Fri, 01 May 2020 10:16:14 -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 g14sm2733966pfh.49.2020.05.01.10.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:13 -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 v6 09/22] media: imx: mipi csi-2: Implement get_fwnode_pad op Date: Fri, 1 May 2020 10:15:43 -0700 Message-Id: <20200501171556.14731-10-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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_1_to_1() as the get_fwnode_pad operation. 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index 332d77aec8aa..23823c8c6c3d 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -510,6 +510,7 @@ static int csi2_registered(struct v4l2_subdev *sd) static const struct media_entity_operations csi2_entity_ops = { .link_setup = csi2_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = v4l2_subdev_get_fwnode_pad_1_to_1, }; static const struct v4l2_subdev_video_ops csi2_video_ops = { From patchwork Fri May 1 17:15: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: 11522963 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 F09A614B4 for ; Fri, 1 May 2020 17:16:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8A6D24956 for ; Fri, 1 May 2020 17:16:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ekX8ni4H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729447AbgEARQR (ORCPT ); Fri, 1 May 2020 13:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQQ (ORCPT ); Fri, 1 May 2020 13:16:16 -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 BEDA0C061A0C for ; Fri, 1 May 2020 10:16:16 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id b6so570674plz.13 for ; Fri, 01 May 2020 10:16:16 -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=Ew8ODtHZB2v9klvRNnpmtFZWxf7EehbfPJw388DD5Ig=; b=ekX8ni4HBJWGQDnPDSV7REbK9E4efv3nRbPgv5AmoAnbGZ2OTcXKXFUNvwODKDyU2d GA4xn0hS8SBXp8W7paEmlPkNw/cXmdoPfxrXD0RdD0XTP1nNaeV3JOWlp7yWjdNZLvmC 19JLExz6aumQguIHcDet0E6aKNrphau6cayf9JKb9i2TW549SHBcwRmVx1Lm+F7TXAQ4 dyCdOxGR9VcI9M0PNXh0mC+d84t1Z6O/iLkExwSkYg/Zf0Qo0JXPpkk+WEhUY/Y7FjiR rIcoPdjzlQrf/AnJ9UpzrtRTD8evoS41AT1piQxDHSoXxEpntPZ8k7ZjiYZF8TnKnAle 25gA== 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=Ew8ODtHZB2v9klvRNnpmtFZWxf7EehbfPJw388DD5Ig=; b=UWcvY4O+iQ2fe9IY+Dwj/aDHtE9YPBkWkXVkryPuuc5LbRfGAhg2w6TJeTi4Evw9lN rGNaTWXFLn79jkiIQlAs9/J0nqnC/fSqX/fjm/+6gqM2u5jieBEBlySXNOIvBKMzLcJY 26rAQYtQR5oJ49pK7a9PbInsAjMgM/LQmdAkKttDxc781qALTpIOlhmjPQGo0mAu0IaY g/U2FwpA+xgLV3O5kr0n0O66IR0hRgub1b005po9ayg+SDlNmMMNM4ngR0Owqe9agFl3 gGXnDRU0r/i8sHB6STYsVYBYIbCgwW9LOr1/IAAjFbR2oDfKf6aOUs99DYrD9FCiTooH RQ+A== X-Gm-Message-State: AGi0Pubg/j/fowzrRKOJOLaQZ7SMyWVb9kkIScH+EW1Ugs3siDgfP3U5 cBSbSA3fbhPXw+8q7dnAVPFxmh/I X-Google-Smtp-Source: APiQypLqH8lJLySrWVJnqsD50s4VKr2/Ls881t2bEXV+tGt2rFdammAF85urgRVhuI31yBmqD9wxzw== X-Received: by 2002:a17:90a:3343:: with SMTP id m61mr758801pjb.112.1588353375930; Fri, 01 May 2020 10:16:15 -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 g14sm2733966pfh.49.2020.05.01.10.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:15 -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 v6 10/22] media: imx: imx7-mipi-csis: Implement get_fwnode_pad op Date: Fri, 1 May 2020 10:15:44 -0700 Message-Id: <20200501171556.14731-11-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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_1_to_1() as the get_fwnode_pad operation. The imx7-mipi-csis maps port numbers and pad indexes 1:1. Signed-off-by: Steve Longerbeam Acked-by: Rui Miguel Silva --- 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..7b5c3e662d0d 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_1_to_1, }; static const struct v4l2_subdev_video_ops mipi_csis_video_ops = { From patchwork Fri May 1 17:15: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: 11522965 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 A236392C for ; Fri, 1 May 2020 17:16:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BA8E24953 for ; Fri, 1 May 2020 17:16:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rrf4Z4PU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729513AbgEARQT (ORCPT ); Fri, 1 May 2020 13:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQS (ORCPT ); Fri, 1 May 2020 13:16:18 -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 156CCC061A0C for ; Fri, 1 May 2020 10:16:18 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id z6so3838343plk.10 for ; Fri, 01 May 2020 10:16:18 -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=FVAjkuoo2ThSpOR4ie/eTODzC5Quk6g8w++NYCnSb4o=; b=Rrf4Z4PUWafdLiSKuzKm61CT8hoMw1RETl7sTcQ85T2LZhT/1UDP2Us1oPt/1VD+xN mPzKuzUQso6D1/zAv+9Yrk9hIovRQp8Vhu3x6KtCLTNSXZaP0OcUF+pSl1moePSSmw1D 6VnvnvBO9eqqvZFFxyB7XSKzfBPQgE9rLlAsmFxZBPfR78d4zx8yGr2vpiWDzcWiP+8V K0+sAcqyZyZhuF/NFZ9J7nrU4QAsvibug/JJNzMuHsizU5rb6fAqnea74/oRu0l52K2B U3WypAPxJb64CU7qHmOWSWY22yObjgNLFe2iJ/W41v/QBOIS/UBJ6MJnTIM2kbLpUE3C JRPQ== 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=FVAjkuoo2ThSpOR4ie/eTODzC5Quk6g8w++NYCnSb4o=; b=ar06+v+9o65Nnh6ayhKQdJzUUVfkloqLdGe7oyw8mTDV7yXXt1rHfNLOSDj7xIwIHK r1Bs5TUR7G1QEpOGDKZIbHk2OWjJbf8GBn3+9Q/qHgbFA5IOQ0Gz9jeY58u+JS+g/SKO Fmrj2rnaKBfBSrG7/gijWTogV+0OBw1Fp0fJfU+ek4TmqIEOa+ymPLusENe5xtOlp8sY tE7lKiFeLtNQJHS/lE4fd+w/QsEthjXRM4ukkoCH+pWowdG/9Lt4hBvlFhv8/hk0hq40 4d3Z5Y2/O5ZodcXzFPVokK8OaFUEFeHzSieX3YfjMFXCKSdsSC/B22PUDV6NEe/msG81 3/CQ== X-Gm-Message-State: AGi0PuY10XCYyAj+QVNxtLbgqb8VzxeMQqSbTVVZ9AOCaB2ML6KxRfW5 HJVh55aFpjk1TpviX09h1f3ihR2q X-Google-Smtp-Source: APiQypKs+BjLihNlS5Hg16b8Sb3jWaed8CTi/j7UBhIApnyn9d+71fYIaHpjvSvrEOuqV2IdejkUSw== X-Received: by 2002:a17:90b:4d10:: with SMTP id mw16mr663054pjb.19.1588353377356; Fri, 01 May 2020 10:16:17 -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 g14sm2733966pfh.49.2020.05.01.10.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:16 -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 v6 11/22] media: imx: imx7-media-csi: Implement get_fwnode_pad op Date: Fri, 1 May 2020 10:15:45 -0700 Message-Id: <20200501171556.14731-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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_1_to_1() as the get_fwnode_pad operation. The i.MX7 CSI maps port numbers and pad indexes 1:1. Signed-off-by: Steve Longerbeam Acked-by: Rui Miguel Silva --- drivers/staging/media/imx/imx7-media-csi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index abef59dc22b6..c74455f65b3e 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1179,6 +1179,7 @@ static int imx7_csi_init_cfg(struct v4l2_subdev *sd, static const struct media_entity_operations imx7_csi_entity_ops = { .link_setup = imx7_csi_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = v4l2_subdev_get_fwnode_pad_1_to_1, }; static const struct v4l2_subdev_video_ops imx7_csi_video_ops = { From patchwork Fri May 1 17:15: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: 11522967 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 C8B1E14B4 for ; Fri, 1 May 2020 17:16:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B08AD2137B for ; Fri, 1 May 2020 17:16:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="das/IGQR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729535AbgEARQU (ORCPT ); Fri, 1 May 2020 13:16:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQT (ORCPT ); Fri, 1 May 2020 13:16:19 -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 7F5A3C061A0C for ; Fri, 1 May 2020 10:16:19 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a5so146433pjh.2 for ; Fri, 01 May 2020 10:16:19 -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=BnMGjNnDbs7knQNG08RhDP1eWnGEoczFnCi38jnuKiY=; b=das/IGQR7zyQOTvEceNfRO9GvX26AdyGcY0THN9bP6n3FsnSbtVFXp42pmyf/xhmGW CWF1dv9xtUOWq+hQ53RPeYAbp2i8Gjyr2kTLGtILug4KoNdPPW5+nbk3a2oZWYMWRE2r byS5/pewuzpzg/rycpO+nMKsuhPMS3kGCCw7/UV2ox0nYK6x6lZjPnp0Z/yTRRbS/BMs Bs2UblLGAQ7EqykvGJrupbwe9eIF9S3kpq/H4OTtXMsk7hC4R1+cPPoKSMDGxPUyyGSV AAJ+ZEdUt53DWp4XMWmMjLzh2WcY4g02OGMZa2vJ68F3Upsj9vew8IiKqd93fzxgxhja qDDQ== 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=BnMGjNnDbs7knQNG08RhDP1eWnGEoczFnCi38jnuKiY=; b=fv3a04RUuDln0wCkBpvgBhGDTo8VDq9CHT3ThjvqsGuNyz6acZYrocEIfjZqpGi3pt YC10yIy5w3NxVMVD6EN2OlYcdMQ+3CscGC4dAeWVv8bAecQMiw4UpjFKEi/Jli2TRKx2 OlidpBYbaPiypKxpgL5ni9PsDEMxvf+wGC+t+07lbMm2q02J62giW6jAjSkSCCNx4Vqt bBSzJzmG1XyRS7wJpjvks0Fz0FeN5Zrtu3TH5XX4B1tSI7cKdazY+zbA40LsGmKwEVOb w1ZpEdxAJE7Dqal2tegXTuiExHfQiT7+lOYMqcGTxFAEOZs3Z8JUCIIKajFneDmXTc3o CrbA== X-Gm-Message-State: AGi0PubcxLAnYx4ot4dVKyFjsL0oouE81Vw7tHjoMe0Yy5dojqLs6Rjv KVSElfS9istUgR2jmCPEJiISAiuZ X-Google-Smtp-Source: APiQypJGrGmH0EYP1tEyCcspnlrATc+MAyOfXZE0KiBc8uDCPyPyyXDLlT3PcksKjpkb7Pb8DSj9ug== X-Received: by 2002:a17:90a:2943:: with SMTP id x3mr666937pjf.63.1588353378703; Fri, 01 May 2020 10:16:18 -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 g14sm2733966pfh.49.2020.05.01.10.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:18 -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 v6 12/22] media: video-mux: Create media links in bound notifier Date: Fri, 1 May 2020 10:15:46 -0700 Message-Id: <20200501171556.14731-13-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 9f148f403603..53570250a25d 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 Fri May 1 17:15: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: 11522969 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 34BE014B4 for ; Fri, 1 May 2020 17:16:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E83824953 for ; Fri, 1 May 2020 17:16:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BmxUYWWW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729634AbgEARQV (ORCPT ); Fri, 1 May 2020 13:16:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQU (ORCPT ); Fri, 1 May 2020 13:16:20 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA989C061A0C for ; Fri, 1 May 2020 10:16:20 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id o185so4818046pgo.3 for ; Fri, 01 May 2020 10:16:20 -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=NDcuwhR6BjNJeJU0nAbykERqerCKLETI+zIr/z5d1lU=; b=BmxUYWWWp4biiIhDSaHqr2BaLw7p5EUGP2yky9iHxwrNtAWQL7Dep9tgF4ljwDO+fg auQi4lkJJfkTQpKt5noapcZpIAshbgV0oty73vGx7VLh91YBkxdjWFC0NP/ifCH+InUb TGTYnKRgQgVdUQayWV0g07IX6w+y0yc7RF23x60sBNTCJpWl7sO197DKFJ8tG9YSzfPO FrDy4ZUCg9UFGi/r5xci1iGvRr03jnxIM7r5qJZ/hiB5CwNkj5JZEw/ehONtsEm2a0j5 CRN9YkwrJ5iwd6PbSp76oppF12XW/wWVn4y/g7BtFWZkoT26CoBqj4gn381a8kqMH6zO gZ3g== 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=NDcuwhR6BjNJeJU0nAbykERqerCKLETI+zIr/z5d1lU=; b=POSLX+kW9L9eTEx8Pc/fxRz7EMkyRmESFQaNvoUpuBytjyzud2F01wA9jv3YW6vPao go7oSfZ/CJdGCs2AerJ8icAoiS0v/WJ6IYUOdaSjWi41waAfX2g5EzLRwKV05RemxuMh y9dJ/Q0/jvARyZ3tAOOAZ7TTGWxjZlb+N6qMQmi/9AeVDoAMZ+OaLwdkPSaweosVe8iZ 2BHcWSJ6ZwyUBsup0UxJqTbYYEbTjLOr884K6RTJ+BQRMyxwdpLPLjTPNtbVIWV3AiFy LSlZsilmxHFa3TdzJ7NvWBxXGTuiKpAsYy9kn63vzbOhtmyWrvqvhCOvv9OR+PYXjV70 hurg== X-Gm-Message-State: AGi0PuZ1yps/Snf5S53qJkk96BPNLPlz7dpmsKuQXtUY+WfSdTbuNkDU k0C5PhggMopZIG+SZjE2g2PjrBwc X-Google-Smtp-Source: APiQypIYkhipQCvmMkyPn/b20KAbAhWY0Ylvf6HGLfb4YqsVRDboSPY2mybsJ++wlrHyG1HLAxKQdw== X-Received: by 2002:a62:2544:: with SMTP id l65mr5146020pfl.288.1588353380129; Fri, 01 May 2020 10:16:20 -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 g14sm2733966pfh.49.2020.05.01.10.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:19 -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 v6 13/22] media: imx: mipi csi-2: Create media links in bound notifier Date: Fri, 1 May 2020 10:15:47 -0700 Message-Id: <20200501171556.14731-14-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 --- Chnges 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() that creates a single link. --- drivers/staging/media/imx/imx6-mipi-csi2.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index 23823c8c6c3d..94d87d27d389 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "imx-media.h" @@ -91,6 +92,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: @@ -532,6 +538,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 v4l2_create_fwnode_links_to_pad(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 = { @@ -570,6 +590,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 Fri May 1 17:15: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: 11522971 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 6F6C492C for ; Fri, 1 May 2020 17:16:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58C5E2173E for ; Fri, 1 May 2020 17:16:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Cqia4m0l" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729686AbgEARQW (ORCPT ); Fri, 1 May 2020 13:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQW (ORCPT ); Fri, 1 May 2020 13:16:22 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E866C061A0C for ; Fri, 1 May 2020 10:16:22 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id p25so1819712pfn.11 for ; Fri, 01 May 2020 10:16:22 -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=cvFFu/w/Sqd1CjEtVEg3CHkjbOlulSOPdqVl8s8dGaI=; b=Cqia4m0ldgnKSrzy62lTb8j3aY85o+cpyVKOjBunkw5WCAloV7HKA/KhDUmuoK2PPJ 6LUwK9CQR7Bq7ujIR5CLPPOOndYmTEjotw3gr/kkEaLk4q1aMBLHvyGBkaEqpt++WjpL cvY+j+tbymS453VN568HEbL5nG0q9BHa84Y3P/Svtl4wj2doEE0mcbjPbJ/26DHanVCw vaxsoLLIdEUCsoje1s9Dx8FSYGt7oVq6zuNGlkEbbFGT43Zm5Q2rYgHlrZXU/iR9wypJ zFslpGoH4n+2S0tsMLVY7JUZ7tkDkQ6/CxK+ll20NN/W4BQTUCi5Ni4D93dGE+nLdmeK Ey4g== 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=cvFFu/w/Sqd1CjEtVEg3CHkjbOlulSOPdqVl8s8dGaI=; b=qMK7hL1hatnAoDptJV8a0XA60WeuowTZ13Nrnno8wuG6N0xVO51GKVHdvjwNgd0VXT qQX8oHydz6yZD4Ej4ntIWTtSrv8VKJbcueVYImAurh8LO6kWG5YAGmajXJhKGVjLInKV dAmL3UsJNt7V0kehqd4p6xIWF+6tSh1ojDvkdxgPg9iUtpo7FIbgozOvTi1QRrQPjyFl N8oqYyo9GuCEU95sML6/wMlsY+2Z/d3Tdn/jNSh/p9tx8v65zIOHg2M7eG+0C1ojmWlm 27Yp/vRgPGKU1MALQyRjr8Rzmf21riq5SxItBubZDHgUaIXYv3fFN7BLuTEivTXzXftm ZrLw== X-Gm-Message-State: AGi0PuajjcHEo4dsGImxFX8qSQ6V7//4sQZYwyS3KLVxJmPTXb5BW0Y1 +v9aa8An3sCqnd2OlYh3YBasgzTH X-Google-Smtp-Source: APiQypILAL97XnNE/TTeRW5PvBMLjOWPrP5SmvyHwT8HZiDhsRDvnXB7N5YuJcWlyDyF/XYNLBqi7w== X-Received: by 2002:a63:513:: with SMTP id 19mr5258582pgf.48.1588353381359; Fri, 01 May 2020 10:16:21 -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 g14sm2733966pfh.49.2020.05.01.10.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:20 -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 v6 14/22] media: imx7: mipi csis: Create media links in bound notifier Date: Fri, 1 May 2020 10:15:48 -0700 Message-Id: <20200501171556.14731-15-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 Acked-by: Rui Miguel Silva --- 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 7b5c3e662d0d..1025e42740f1 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 Fri May 1 17:15: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: 11522973 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 B9A8814B4 for ; Fri, 1 May 2020 17:16:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1DAE24953 for ; Fri, 1 May 2020 17:16:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W0VLtuVW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729701AbgEARQY (ORCPT ); Fri, 1 May 2020 13:16:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQX (ORCPT ); Fri, 1 May 2020 13:16:23 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80DD5C061A0C for ; Fri, 1 May 2020 10:16:23 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id y25so1837381pfn.5 for ; Fri, 01 May 2020 10:16:23 -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=GEyFXh4vSWfigdSzRW/AG6YVXwt0cYiVSCi8tI0IZg8=; b=W0VLtuVWzjgXs5lT0xK3lY9i3osxxaGJB+tZAjaYaOE2S24x0wlzr3yLYjbHcrVTXC 1AJQDQ6nmb5BMYcjAaFlL56oh7Jl0yrzztWjIdZaUdYHccNS4eLlbW4y9SvGrsrDpZAc GKDOM36OCfmNn7G/kSJi87zq6KVpyVvwkEQ4TFHHxcrAiLOvaOjltBKGjKqRRXaNZtDz 1HdqwQv64QxDakpeJ561J6K+AbM0WZJG7r2f/iga+mn7OuzyimKxS4G0PTbMyfxfWFnI cOI77bW+PmaDN33UBSYBanDGQ99dg4en1b8JUPYDrt7E5ltTabZGQPtuLQWMymavzUrV a7Ew== 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=GEyFXh4vSWfigdSzRW/AG6YVXwt0cYiVSCi8tI0IZg8=; b=Mfi3r3+rCqGgTKVCBJJYxhKDXdsCeIfGMCQsJ4c7rQBhrfmroj7Zy/vvqg/f4cRcAk LInkd1RpBnVbEMs1euv94CbZaHpmz5c/zWe57rivYhE52QAuCpCh/y2cAQ985/OzX2He Dr9TyfRlLIOblqwmiBSVX/BFWo+ULPsrwjFIk3UtXmNAI7EuFLIHUx2TEYLzYZ+d/9FG PD52G/edEcPFzMK8F7xy1r1B4uaj+Z3RTVcKTJNYfLrewaXfMDg0eW6gKVXZ7fmWSwIZ 5RItJh1J0GX7Ns0TQTdoea8hbrfi91bygVcgUcXlnJZlvJgfLwELVl79CVuZYrBzxER+ EgKQ== X-Gm-Message-State: AGi0PuZKM842tTKgxaLdR9ZQ2P+8TzCs7/BLiriaocM9Xt3b+bo9z5xp ZPhooGLawqIXD0n+bgk+EFPK3Q30 X-Google-Smtp-Source: APiQypLfeDOVUNSuRxvD/jPeHEuDVYdFs6aDcbhsSPOgPlWFUajJjdNiTSoEhS8+2RQJsqnXE4FloQ== X-Received: by 2002:a62:3287:: with SMTP id y129mr5284860pfy.167.1588353382732; Fri, 01 May 2020 10:16:22 -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 g14sm2733966pfh.49.2020.05.01.10.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:22 -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 v6 15/22] media: imx7: csi: Create media links in bound notifier Date: Fri, 1 May 2020 10:15:49 -0700 Message-Id: <20200501171556.14731-16-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 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: - 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 c74455f65b3e..21a86fa3d89b 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); @@ -1204,6 +1210,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 v4l2_create_fwnode_links_to_pad(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; @@ -1234,6 +1254,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 Fri May 1 17:15: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: 11522975 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 22F7214B4 for ; Fri, 1 May 2020 17:16:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BEDF24956 for ; Fri, 1 May 2020 17:16:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HKk0pN0P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729801AbgEARQZ (ORCPT ); Fri, 1 May 2020 13:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQY (ORCPT ); Fri, 1 May 2020 13:16:24 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2485C061A0C for ; Fri, 1 May 2020 10:16:24 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id 18so1831737pfx.6 for ; Fri, 01 May 2020 10:16:24 -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=g7H6Ri9yWcJp790asZwo8Gkl5sN2mkHYDZM5qgRTUO8=; b=HKk0pN0P9R0udEGF97Q8GdCXalVJISAOlTxj5t+4BeTRDQTKDeia/GR7e1V/BT2qGd JSgiyzl8M3Ng58REBps3wZ7dFLq8lC5gTzV4VPRCjViUGqQzG4IF9PcBFi3o5101UR5n 2JneKdiEbq6EdKy3Jx3clqu7avMM16NygX40EjgoECe1EShuG6slybJTt+7nmtgf7Bjj RH0OEIkJxlYysqrbXiKIOtYLjGXtMFbRdOKn5khsh5Y+NTJT5XRwfMIp/ttqFOrCYrM9 8cx+Kb6iOiPQWreq8rwuywhiDilRformQxGuGEwvR7DMOXafa/Regdei0wp+Ee8Q+4ev 8NBA== 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=g7H6Ri9yWcJp790asZwo8Gkl5sN2mkHYDZM5qgRTUO8=; b=j3AaXnwEb18B0fx2f8RjKlMgAEw6LMqkgcUfrXDvrTxz/jjkKW9KiDxkZtCNpO5N48 XHIvPF6vIY3z0bUr5lLElcjaWesFXk+tM2qotTAmuLIfNK1fp6putfALXbD0D+wvdtMj RCg60Cx47JUONVNbHhcQP6WVOLBqZf2YSE6viyzlkzifX8tFuBWKjYlW//GXrHMo+WDT 8oUpNGKjDcTXRLs4Hnqqx70ue0ddH8io5ceTQL/ycgfN2+qArRoG2Qkh3EyYSHvCcJdY roRvDLvPT7Z2rVvQrgRqqDn/HvyoBiLx6ZEagEf4TADHSCpiyYoVti+Sim9xpQ/wF5pi VSgA== X-Gm-Message-State: AGi0PuYhCmb3+kaO9e+DJ756nKg1e96OvwhC8GlPKfJFKK6FLX/DBDw+ s7O61Gu/LEc0ebtQzweBDk2HQ6ZF X-Google-Smtp-Source: APiQypKCr3ktUWmpW+i+BLkDvjUg3N0FL72RK2+PsJGuu7/ovNnUMMWPJQNTZdwMbcwS91P2ckRbkA== X-Received: by 2002:a63:130c:: with SMTP id i12mr4920149pgl.122.1588353384057; Fri, 01 May 2020 10:16:24 -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 g14sm2733966pfh.49.2020.05.01.10.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:23 -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 v6 16/22] media: imx: csi: Create media links in bound notifier Date: Fri, 1 May 2020 10:15:50 -0700 Message-Id: <20200501171556.14731-17-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 08f698af4797..a051a063a2db 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; @@ -1894,6 +1899,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; @@ -1931,6 +1950,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 Fri May 1 17:15: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: 11522977 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 2092F92C for ; Fri, 1 May 2020 17:16:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0822024955 for ; Fri, 1 May 2020 17:16:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dDDWKN1L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729847AbgEARQ2 (ORCPT ); Fri, 1 May 2020 13:16:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729827AbgEARQ1 (ORCPT ); Fri, 1 May 2020 13:16:27 -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 42880C061A0C for ; Fri, 1 May 2020 10:16:26 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id t40so146464pjb.3 for ; Fri, 01 May 2020 10:16:26 -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=G/XXGIuGgcwbyVpd/73oRJYypIhJKFb7odYO+w6RndI=; b=dDDWKN1LIrO/L9p3B0VJN5nmEj5uvr0VEXLZtjYv54xb5TK4DMcKdj4m+BdT43+oQg Pq6QNXmGbOxnx+vyPoEh5zwUpmskEemkjur5/DHHdhtlfbMNITCFgYWpcWJrcT7djwlt K271eamq3KjBL+L5KgUoKo0ksv6zy0Wd/Lv5FBh5I8wc2UWv9ABfQm0Q/eVt9jzGcYPh 7huIMG4Mjo+2yUXnwv0fm87zMzTpBjG5hnGmBtwr4i6zPmtQ8dDu1nNBOOUVs04YNR6R JNPWMIcXtXyVg69oYy88IqROChbPUI5hxqSMs+7R75OctkjiB8qGvs4QXcoo5gOCfqcO 6naw== 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=G/XXGIuGgcwbyVpd/73oRJYypIhJKFb7odYO+w6RndI=; b=TvM+JpBtR05xmSGu+xun5QnNyMuxIV+BQHEFWDwJvz28Ej6d+FLVENXEhej0PVc3gZ nOcAneZT2xZYTzzkX6g63Tn7HDPo6ZqzgHXRvzfW0RvlitXpmWWbjbd755MFEEAK8cNC rzUz2W2FoAhNSWWUINcY38VLm/wiY99t/QsUfPCZh1q+ATMGS9uaHjQdM1urK3xGS+qB WQKFRHPovZiHCe2YNO1kbEtcmeH516kEpL41xOjpx2uGqJzRMaYkSuScBeKSNghXAiR6 9ZRloh9gwmm7U19KZLay76gOHgzA2aBSVvNrC+xSlemR/XAfm5whL8movbhNQBG7IE45 96qg== X-Gm-Message-State: AGi0Pua2wQBgWgzArrgi6uKSvGuk8tAJocXgmkY3sZFBLCEp+kzwrfo3 9OVnEZ+DJzr9bwqUNjqfKtSjOKdk X-Google-Smtp-Source: APiQypLBokWMBCKG1MmFUNKLKlEYuONr44JSDjHxvxronpFf9Kbhpfebn+RUObLtLlSfWgqCBGOG0A== X-Received: by 2002:a17:90a:a796:: with SMTP id f22mr760949pjq.42.1588353385443; Fri, 01 May 2020 10:16:25 -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 g14sm2733966pfh.49.2020.05.01.10.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:24 -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 v6 17/22] media: imx7: csi: Remove imx7_csi_get_upstream_endpoint() Date: Fri, 1 May 2020 10:15:51 -0700 Message-Id: <20200501171556.14731-18-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The function imx7_csi_get_upstream_endpoint() is not necessary for imx7. First, the imx7 CSI only receives from the CSI mux, so much of the code in there is pointless. Second, it is only used to determine whether the CSI mux has selected the CSI-2 input or the parallel input. This can be accomplished much more simply by getting the function type of selected input entity to the CSI mux. Signed-off-by: Steve Longerbeam Acked-by: Rui Miguel Silva --- drivers/staging/media/imx/imx7-media-csi.c | 77 ++++------------------ 1 file changed, 12 insertions(+), 65 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 21a86fa3d89b..69f7abb32ae1 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -169,8 +169,6 @@ struct imx7_csi { struct media_entity *sink; - struct v4l2_fwnode_endpoint upstream_ep; - struct v4l2_mbus_framefmt format_mbus[IMX7_CSI_PADS_NUM]; const struct imx_media_pixfmt *cc[IMX7_CSI_PADS_NUM]; struct v4l2_fract frame_interval[IMX7_CSI_PADS_NUM]; @@ -435,61 +433,6 @@ static void imx7_csi_deinit(struct imx7_csi *csi) csi->is_init = false; } -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 media_entity *src; - struct v4l2_subdev *sd; - struct media_pad *pad; - - if (!csi->src_sd) - return -EPIPE; - - src = &csi->src_sd->entity; - - /* - * if the source is neither a mux or csi2 get the one directly upstream - * from this csi - */ - if (src->function != MEDIA_ENT_F_VID_IF_BRIDGE && - src->function != MEDIA_ENT_F_VID_MUX) - src = &csi->sd.entity; - -skip_video_mux: - /* get source pad of entity directly upstream from src */ - pad = imx_media_pipeline_pad(src, 0, 0, true); - 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; - 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 = of_get_next_child(port, NULL); - of_node_put(port); - if (!endpoint) - return -ENODEV; - - v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); - of_node_put(endpoint); - - return 0; -} - static int imx7_csi_link_setup(struct media_entity *entity, const struct media_pad *local, const struct media_pad *remote, u32 flags) @@ -556,23 +499,27 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd, struct v4l2_subdev_format *sink_fmt) { struct imx7_csi *csi = v4l2_get_subdevdata(sd); - struct v4l2_fwnode_endpoint upstream_ep = {}; + struct media_pad *pad; int ret; ret = v4l2_subdev_link_validate_default(sd, link, source_fmt, sink_fmt); if (ret) return ret; - ret = imx7_csi_get_upstream_endpoint(csi, &upstream_ep, true); - if (ret) { - v4l2_err(&csi->sd, "failed to find upstream endpoint\n"); - return ret; - } + if (!csi->src_sd) + return -EPIPE; + + /* + * find the entity that is selected by the CSI mux. This is needed + * to distinguish between a parallel or CSI-2 pipeline. + */ + pad = imx_media_pipeline_pad(&csi->src_sd->entity, 0, 0, true); + if (!pad) + return -ENODEV; mutex_lock(&csi->lock); - csi->upstream_ep = upstream_ep; - csi->is_csi2 = (upstream_ep.bus_type == V4L2_MBUS_CSI2_DPHY); + csi->is_csi2 = (pad->entity->function == MEDIA_ENT_F_VID_IF_BRIDGE); mutex_unlock(&csi->lock); From patchwork Fri May 1 17:15: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: 11522979 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 E38BD92C for ; Fri, 1 May 2020 17:16:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD89C24955 for ; Fri, 1 May 2020 17:16:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="edc3A13C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729885AbgEARQ3 (ORCPT ); Fri, 1 May 2020 13:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729792AbgEARQ1 (ORCPT ); Fri, 1 May 2020 13:16:27 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98EDBC061A0E for ; Fri, 1 May 2020 10:16:27 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id a21so280364pls.4 for ; Fri, 01 May 2020 10:16:27 -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=iR1mKkkmKIZESgEF8BbzgebbENJGwFXvt3bpadflBeo=; b=edc3A13CnaJYaOprnVfOHCkqYgRm7iLAmR2LyO34CUt5jwHga9B39+x1eYl/q6qEm/ AkQqD9dGXJUvRrzTP1fgp7At4IFvqJD2zeCgxY3QQwgAgvK0i/Dcs9Q3SV4dbD1KhhNW Wrq2zHwUW4JLSy7Rvom5vuOKUqzHON/2Gf43GsHK8NIVwksktaQZgLj37abDhTrVudEn PsgxPlf4r0CvJlCIugshSs3DunKxEh9lKAWqSP+rjG5OIk8NnVS9l9ya6JefddNq5DF4 u1qmP3RdYLdLB2FNL+lUV4cYEyTqwL8c/NLtC6cnTttL2Ge436HM1cEjRi/+dMDicj5P Hx6w== 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=iR1mKkkmKIZESgEF8BbzgebbENJGwFXvt3bpadflBeo=; b=Qmfy5YoVONs2EOwygQCmtOW7IlNOUFl03JNE08KSW9Vl5oMsJU10dQmeqWH/+nv0/x XwMx893eyfJiyG0sZikY6D49dMBbx+sv53fifWMdNmyXrYjjSNBrSLnw+tDgghtKai5W sjsBCYuPrArsT0JPbLn2uNuoExpAz7s9MQDT3/2mPfzkbMbEJl7wqWFeXVnU3sgoFbKE NjxhnhW5y4t5JjMAF10bd6cpO+nAaEkv5Ru8DDtlzI5jQZlezGrsdzQiphVAKthkRgIN kP/GpFgDtJqI6hWtHboZtHp2wKG8SyrGCNzS23aPd9+dP0jq0+ecJacjOseMt3rCptgm ZQHQ== X-Gm-Message-State: AGi0PuZk9Xsv0qVI9KBR1n6Xx7/shq83IMBGt4A9j7eMHI1AL9f3vHAx D1dZzTRO9Jw2iz/Hzbmf8CUgTS20 X-Google-Smtp-Source: APiQypIYuKiFBHNTkSqPILyXYmNY4ZFkUStvm/1xe5xdTzTPk4jwmU+nqXCRD6osL4lke2kRBEhvgg== X-Received: by 2002:a17:90b:30cb:: with SMTP id hi11mr679774pjb.103.1588353386774; Fri, 01 May 2020 10:16:26 -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 g14sm2733966pfh.49.2020.05.01.10.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:26 -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 v6 18/22] media: imx5/6/7: csi: Mark a bound video mux as a CSI mux Date: Fri, 1 May 2020 10:15:52 -0700 Message-Id: <20200501171556.14731-19-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 Acked-by: Rui Miguel Silva --- 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 a051a063a2db..6cfbe67c43d1 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; @@ -1906,6 +1908,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 ca36beca16de..b5b7d3245727 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -311,5 +311,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 69f7abb32ae1..a3f3df901704 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1164,6 +1164,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 Fri May 1 17:15: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: 11522981 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 B979414B4 for ; Fri, 1 May 2020 17:16:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A23EC24956 for ; Fri, 1 May 2020 17:16:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q9HiZtAL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729792AbgEARQb (ORCPT ); Fri, 1 May 2020 13:16:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729865AbgEARQ3 (ORCPT ); Fri, 1 May 2020 13:16:29 -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 009E5C061A0C for ; Fri, 1 May 2020 10:16:29 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id u22so3840147plq.12 for ; Fri, 01 May 2020 10:16:28 -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=R/JI0aS56V9pQ1I8WLqOQx9B/h2i55Iy3v4YpaXKhJk=; b=Q9HiZtALbPgIu6T8W0xXlfBFTUcIM2rpnLaNjCZ7QQmiQFGQQnegLFbM0RFB2dBS0g 4+dUuv7RVR6dIECR+oF1kjE2TjcZQLe46ssHw5DzWvmT3rHg9GA7deV9NbTLa2yIf3YQ wkBcN0BipxLHNToOJYXu75dSfKIN+5tWcmtNKFJLSCvqrm8tTNJJ9mzFAgqQAw+4JboT jYwDaiiK6XTHGeBoXCqnfXn8D8n7X4qz3ZQ7wV8JDikEvjp9A8W1A2L+FeR6PQfeHvGX dKHvOqZe+QuM5B0F3RY7PCxWG7FM0isF+MoTx5sULcOfC/RTElPVLkWv6nX4Ra9gf1Jx ludw== 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=R/JI0aS56V9pQ1I8WLqOQx9B/h2i55Iy3v4YpaXKhJk=; b=ouJvMS83CkpTCQXmdmA6bqJeOj7EWlAFHA1F7m0jMP8RObKoHF+V1InovnrTSpfdTH LQMl2ZlnpxqeYpcDxtpSSrRm58vaQBqFQk6P57J6ITEG/3I0RuoP9fvua3D3vOErpq/y U92RqRDocyO8pQzIHvvgYgjzLWwaChpL4xfvuK08Opa86Ke8FKj61C4eQudRhOYvFeEQ ZSqe1jbgzdTq1lzwU+VDhn0ISCWbZ/iCRmqCvexo9Lh3FPEFMziG8mjakPenAMV7Ub82 /aUurwm+6zCK+RcyFOthMPVTRarrArp7oWU9Ni2DRKIIMcOqriyJD8n1S/vI1OyV/cMZ z7cA== X-Gm-Message-State: AGi0PuZva5cuTlb0KZ9BYHIzXwXK/kOC9JuafQJzZdfZPRysSnm+FKOm /7Lmf368QIvvS+gW116XiKg5whzV X-Google-Smtp-Source: APiQypKmWvyCmJV3/n3Qnl9iBJwxnN4ueVT5JkZY8grcAss0ulRLJxgBBiBcFkcjUjRprtd5Gj6MpA== X-Received: by 2002:a17:90a:210b:: with SMTP id a11mr719243pje.31.1588353388175; Fri, 01 May 2020 10:16:28 -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 g14sm2733966pfh.49.2020.05.01.10.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:27 -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 v6 19/22] media: imx: csi: Lookup upstream endpoint with imx_media_get_pad_fwnode Date: Fri, 1 May 2020 10:15:53 -0700 Message-Id: <20200501171556.14731-20-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 + 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 6cfbe67c43d1..d7e5b9ed27b8 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 v4l2_subdev *sd; struct media_pad *pad; @@ -205,23 +205,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 42e64b618a61..7c058db41f7c 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -835,6 +835,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 b5b7d3245727..c5f2aa2f0e98 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -220,6 +220,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; From patchwork Fri May 1 17:15: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: 11522983 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 5A1B217EF for ; Fri, 1 May 2020 17:16:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C58D24953 for ; Fri, 1 May 2020 17:16:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qejat9+K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729955AbgEARQb (ORCPT ); Fri, 1 May 2020 13:16:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728970AbgEARQa (ORCPT ); Fri, 1 May 2020 13:16:30 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50F64C061A0E for ; Fri, 1 May 2020 10:16:30 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id a32so140773pje.5 for ; Fri, 01 May 2020 10:16:30 -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=7nDsABg1OEiBsUmQMmNToGbTWaiUH5u7uhY2MzTbsLk=; b=qejat9+KbVys97XNtCdWHUTSOOpS7yDnXM+sqGPR+fcQliDl83JU+0RzHj1lURqhsQ /fRv87cIFgeUK8e4h2SYWWybpT6zLy7IR6X2/aZpTZVdpQJv4vC7pt5yHl1tdFBqhKUN h+t2mqdmoYxpY55D15tcIcuE0wcXISjy4cct8SRIsnXt5LoCKwz/bpWKGI4MyopDtm1I 9814exbmQCL60/QnYSIGS38bRj0pKPFncKYgYemK3bFmBOEK7ZL7kRWwAz3MHwnL7zIg cpFCvsFgcYbjMW3DtQfjNSx1PhGQY7VRpX7x4IPXip6R/3WYtfekWTluDoMhEwD6BWjK tlzQ== 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=7nDsABg1OEiBsUmQMmNToGbTWaiUH5u7uhY2MzTbsLk=; b=i7OhhzaNZ4jqbcx4yFSp0mWUI7fss643Wq3NJFPSd1O/XSAEuWWs7TOZ/hBR+Tuyeg Z3TjZD3qYeuJl8cOpC/JW8ngISlGRO1B4sekSvBJBElXjTA00+yHJChACkoUrtYO7rBU DgBv1qTVfW4zTNKgc3/vb48s/SAF8kP1IfaIGEyTrEt3VCoijowke2i1Wue1DZv/bk8G rfahVdz7N/DxRd9HXVORnP7HWhAT2B+6ABIAAgB8RW4Nso+Ct1Z/kFq8Ukqg5HUow/0l Nrv8Sp5jp80A+19aeoD4hHlD5/UKPDKZXvOr/MghgdNP/ONejrA0+jj3x8h7YorX0K+7 1eCQ== X-Gm-Message-State: AGi0Puat4HzRjuW+OLBF4Gds+JQfx5Y1O8JPBTlUtQjhg7F1cQ/0vSEj z1BKWGLUFKZbyTkNRcCESJ134jmC X-Google-Smtp-Source: APiQypL7jlgQTp0V3CRUjUj+uiyJ+GOE5XgaAL1/UeXkbLjIpolf3jZmPsunOFDW7cbjx2SIQJfgaQ== X-Received: by 2002:a17:902:74cb:: with SMTP id f11mr5634181plt.171.1588353389412; Fri, 01 May 2020 10:16:29 -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 g14sm2733966pfh.49.2020.05.01.10.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:28 -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 v6 20/22] media: imx: Create missing links from CSI-2 receiver Date: Fri, 1 May 2020 10:15:54 -0700 Message-Id: <20200501171556.14731-21-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 c5f2aa2f0e98..f17135158029 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -263,10 +263,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 Fri May 1 17:15: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: 11522985 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 E97BA92C for ; Fri, 1 May 2020 17:16:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D359724954 for ; Fri, 1 May 2020 17:16:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bLBHpG6M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729963AbgEARQc (ORCPT ); Fri, 1 May 2020 13:16:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729951AbgEARQb (ORCPT ); Fri, 1 May 2020 13:16:31 -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 6FE7EC061A0C for ; Fri, 1 May 2020 10:16:31 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id z6so3838510plk.10 for ; Fri, 01 May 2020 10:16:31 -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=aulrQ6oHsIqioAIw97gNvp4/kCTJRc3i88m+9ebFRaM=; b=bLBHpG6M0dca4W9s4ixDuPHJu40MtnCkjhbN88og0aBxS2IVatu5zDyK9o1w84x0bz wemPs7bqkKv1WU9CUE1xfXyFx2RwlIGSkcbsLo2ej46VSVLFAqTakPqqj3d7uUR3wH+X y8JGSbwJvMbQODiO0TMYo17V4kq99x8VrxT0x6iem8O7OEbxJyQnqlWTj0SqWUvCt6u+ C51p2cBcFEG1X4ln2sGNbRaaa2WctESJ9SMjKjj0hRdMlvYtuXyNdA3gKyKpPqLUozh4 o/KGsO84rxoKLKma6utCojzjg3ye8bwQd6XFTGVLSixY7P5jjNTvmCoGgTeal2ZwgyBf mdcQ== 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=aulrQ6oHsIqioAIw97gNvp4/kCTJRc3i88m+9ebFRaM=; b=lrWZCPQEI6KAx/6COt7krL5vjSEZldGLluDT/MdgY2Jg+EGtVdmoMlq2kN78Xc3LsH xGNR3hUn/TGJjPUJjerl41HAYNd8ZG+//isLrj9yr+bCrLroaO+KP9a+7fL8pNgJ2Bo0 oIJzr0so3MRTfGXat8X4tIrcGBHoeyyrD4ZGBO5/U7nOIl5fABRZzPSS/ELt2bTp8Q+p M5ag0bMM10pscYQgFN6YGOLbTBp4Q10QaZ7u3kPK+XyKK/mkkWoxfe5w0mJNOwo+DmV4 i8Jia8oPIpdhgi25M+wivb04NfBn4jNHcXUgtp5zwxXSj95crT99LuL2pV8MKZijsUAM zDbw== X-Gm-Message-State: AGi0PuaELa8tBdVM5hxLaV5EZhrihagkB1ewEYWjHlshj8RyCtN63zNM bwwf69QP3nizi9WBPKgaT3wdOLZe X-Google-Smtp-Source: APiQypLc0664anz1R4W5JCyePgHv7Mvzc0jusQhzN6oUIkNxP/VEtj9lr0pNRmE5yAQYsuY7k9sxsg== X-Received: by 2002:a17:902:9042:: with SMTP id w2mr5517649plz.127.1588353390684; Fri, 01 May 2020 10:16:30 -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 g14sm2733966pfh.49.2020.05.01.10.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:30 -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 v6 21/22] media: imx: silence a couple debug messages Date: Fri, 1 May 2020 10:15:55 -0700 Message-Id: <20200501171556.14731-22-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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 f6ad9631fa0e..5fe4b22ab847 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 Fri May 1 17:15: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: 11522987 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 8229714B4 for ; Fri, 1 May 2020 17:16:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B03B24953 for ; Fri, 1 May 2020 17:16:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oh6/4+lT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729998AbgEARQd (ORCPT ); Fri, 1 May 2020 13:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729951AbgEARQd (ORCPT ); Fri, 1 May 2020 13:16:33 -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 E7951C061A0C for ; Fri, 1 May 2020 10:16:32 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d24so3846058pll.8 for ; Fri, 01 May 2020 10:16:32 -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=oh6/4+lTRtxuDurfROSG0h4tUeTfPfdAf2Z8+ixz3dSaZAr1nlT/B+PYRMD5Pq95Fn VvOYxziFwdvP89uJEW6eDcpYSZoigiKCt5SfbusDQEBnjQ2V6LDvlFlPyJgJvtvNhe+d uNn3tl9KOf8Q/wzLIZd/ErB+hmr477uKZkIcB+DDSmsK+5Cuu80WoWbfQh8pDGtur2E3 DU56Xc4vCGPTJowoJ0fC41A2Sr2y1+sOzS4vXj/Cni+UxQiOQF06bLiuVeGm1c129Mn0 l+sNuokS+PxFMKZKZCKV8jrupfuGYbkY7qirG588MuU22ZrLmNw8VDMg4vWReiWSdobX CjjA== 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=YVTHFojZ7HkrkYu1OBhrzJMhD4K9Ih9cURZurvqZWSJ6mePRoLdJWU63bTOxcwhvRr NeYojGGcL70gzntnbdsqXs27EKVT0th+vBewtOSrdwt3UeKK+o2yMQJtl71LJADWwUqX PmwjEfLLSBtbJDYW+T9N5e2SdRxHQ1DV366l3ttvnyu7HSHH2mwD8jbKIRVWJtX0Cpzc qb2Khh3ylJLRKeKRPPgw6LnNtDnsPxxe6hJCVAA+F4cMob+qSau05aMZsdLFrxsLBgSQ 7NkoFHm4fAulCfMEula7/ab3/0g6KwMWWW0KJtDFSSdwE9lolBf68/th93Prv4GYD8gb 9ujQ== X-Gm-Message-State: AGi0PuYEwbB2rIEp36PWGpX20efFOiyy+EbmF3wBQHONXbC1VYTShAf7 BPnXXGAS/IGN88nSnVob73wtnLkU X-Google-Smtp-Source: APiQypK5sQOd8+H9jVCejE9rccsY6gZ/S+UPB10u4HlY97ANFt8A3tphUI4Jv0pCXCtbOqx29yX2hg== X-Received: by 2002:a17:90a:80c2:: with SMTP id k2mr749889pjw.6.1588353392120; Fri, 01 May 2020 10:16:32 -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 g14sm2733966pfh.49.2020.05.01.10.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2020 10:16:31 -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 v6 22/22] media: imx: TODO: Remove media link creation todos Date: Fri, 1 May 2020 10:15:56 -0700 Message-Id: <20200501171556.14731-23-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200501171556.14731-1-slongerbeam@gmail.com> References: <20200501171556.14731-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