From patchwork Sun Nov 24 19:06:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259267 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 5385C17EF for ; Sun, 24 Nov 2019 19:07:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31FA02075E for ; Sun, 24 Nov 2019 19:07:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UV26zfJ2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726926AbfKXTHP (ORCPT ); Sun, 24 Nov 2019 14:07:15 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:35158 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbfKXTHP (ORCPT ); Sun, 24 Nov 2019 14:07:15 -0500 Received: by mail-pj1-f66.google.com with SMTP id s8so5423734pji.2 for ; Sun, 24 Nov 2019 11:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ySxgjAsGLxeO4I//v6isWP1TjOEEKi4r4maQM3cg6UA=; b=UV26zfJ2ALmUcqb0SIl7nsVwQaBVtEKaqEOJ7FOZIU1MXOLTEVrmT0+2Lk3r8X1pBD EWTZZzSCZQ3dvK3T3L1IwIT83RVcXqFHQPxA8iz1i1ShEoOZforSk3vNNWKcNPbvjoIe jQRwQtKa+m+iO0tZawqOfHRA22lhZrGrR54eQiZSHMeD8dnZvGN/UnXjEVVmw/vjq3X/ a6vQ/5IA+OEpy4f5VDNwdh71t7yliRqL1gJ2hKlh2zIy8XCdC2gkAk35CHPPqV8bm06Z WvAeHEZaUeuO+3phumD8ucXsTxf9sK4y3nofbu6fPWVz9U8FRgnPYYQMDJ+amHbva8R7 Y7WA== 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=ySxgjAsGLxeO4I//v6isWP1TjOEEKi4r4maQM3cg6UA=; b=ma3PwsWVszTIfjQHItsc6q5avJj/dR1McjoIpdgcgGB6JlzeeLanOUUW3sdTC3qB0Q 1PwgVjdPxuMDQ1t8MpFcCqzzGyXyL1RYYAtapvwU1P47BYqpcD+MtguGP0ooW7QZvbrj vz3bNDkgg7t6WZM+RwQTckx1vxSoL3JIgbEprgO4duxb4r43EKHMLAxbgnaDz3PJg2Gy tBDuoMrllTYPDXcXjZbNfQcm29EyjvAbhp2rAwi/ieJLNAk/k73GxJQQyFOXnqovBsVb tZnwm+SdMQrYZ05CTiDGCLOKwUQEPfc0h0Vdk8/uKARbNZXaAku05lkBaUm8FQb75mR4 brtQ== X-Gm-Message-State: APjAAAWl+8XRhrB89DT5P1WVmb4yvVj+HI80iJ9OGKstw5UQAgin0zNT BYGFSoij15ln/HLHf0MPun+ZjWhhg6A= X-Google-Smtp-Source: APXvYqxqkhEEcD+njj1uevTtVo+XaMzb7QjwQVtabdzRp6Xp0sfx2N2Kfa6V6tyukmj8zIen6uhLaw== X-Received: by 2002:a17:90a:8a12:: with SMTP id w18mr34447493pjn.51.1574622434690; Sun, 24 Nov 2019 11:07:14 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:14 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 01/23] media: entity: Pass entity to get_fwnode_pad operation Date: Sun, 24 Nov 2019 11:06:41 -0800 Message-Id: <20191124190703.12138-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-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. Fixes: ae45cd5efc120 ("[media] media: entity: Add get_fwnode_pad entity operation") Signed-off-by: Steve Longerbeam --- drivers/media/mc/mc-entity.c | 2 +- include/media/media-entity.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 7c429ce98bae..c333320f790a 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -386,7 +386,7 @@ int media_entity_get_fwnode_pad(struct media_entity *entity, if (ret) return ret; - ret = entity->ops->get_fwnode_pad(&endpoint); + ret = entity->ops->get_fwnode_pad(entity, &endpoint); if (ret < 0) return ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 8cb2c504a05c..cde80ad029b7 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -212,7 +212,8 @@ struct media_pad { * mutex held. */ struct media_entity_operations { - int (*get_fwnode_pad)(struct fwnode_endpoint *endpoint); + int (*get_fwnode_pad)(struct media_entity *entity, + struct fwnode_endpoint *endpoint); int (*link_setup)(struct media_entity *entity, const struct media_pad *local, const struct media_pad *remote, u32 flags); From patchwork Sun Nov 24 19:06:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259269 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 7C80014E5 for ; Sun, 24 Nov 2019 19:07:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BBFA2075E for ; Sun, 24 Nov 2019 19:07:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k59+alcn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbfKXTHR (ORCPT ); Sun, 24 Nov 2019 14:07:17 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42568 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbfKXTHR (ORCPT ); Sun, 24 Nov 2019 14:07:17 -0500 Received: by mail-pg1-f196.google.com with SMTP id q17so5924736pgt.9 for ; Sun, 24 Nov 2019 11:07:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u/PbVO0GF+3G1LmQDJT1XFH8AmJHxoqEkGwCBY/zSdU=; b=k59+alcnR3A0bSusIMmPr6CUlDdeujjQYR7FaJ0HCA97nK5jpX2Js1HzyQtjaMIjCQ fUVSvoDEuetjvd3NJijtCYHC+53tVN2leHbwxltNxDiCaZQXeVKhP/vwtWSj20SJnJpp kQdjxsm6/z3h4xRreJjutLFdHQr9W5zSWI2drYoUB0hnp5FONKi0deTgPWzOL+7ATew7 mx9XiHsWlHEOlPBrrZ6hUmW2bL50KXMzc7Ms/wY/5YbMyl5xG6dVhJ6FRBGox0IlGBAo DIYin1BIMC4RlUAZ7UFZQhtvyVPeOM5asgQc2AAk2IpIjB7K6iqdALXZqv/ZCMKgn6CQ xhjg== 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=u/PbVO0GF+3G1LmQDJT1XFH8AmJHxoqEkGwCBY/zSdU=; b=VWhdG9OR6UOxbE1YHwg41oGdrJ85wTSOm9j5zaDuQCgb6YaWI5dEZ8tKtc9wpyLBKx N5vrMXYfzqkcCP1ILmqrM7PjM0oWtqXBwuk/3oke0Hn3mW2TFUdgHEjXw14KaUYw89Xl oy+2boR19N9MQupDdJ8U/oQJ5bf/DQcexe5dwBRDamMSNL23Dzq2+pzPgMqXAS17Q/F4 4PW9EUgdqM9dNOj9ooP+wXlV1wd9QfpYayOhpM4OmHbtPhA5lb+Sl0BYF7jgBiMKbIzl Vde3m5LRYEBdGOY/70oayfXq4nXoXM+itlJPZKn5CjCbIiSOBlnNPalxLsdoRrgz0vnS 4Qvw== X-Gm-Message-State: APjAAAWYeFz7xquGlXHG9E1xgjOGOHgleChJCw19ZHKhGLUZRyicohs2 LJ9MSOogdt/qjPweBiFhinTm3xTtdI8= X-Google-Smtp-Source: APXvYqwi6Wi1CBGwUwSHFlA54ykiFIlNYvQ7dLROslQuhCze/XZHPcQolfDKDvSZjhR1Ear8KUawOA== X-Received: by 2002:a63:d551:: with SMTP id v17mr28933450pgi.365.1574622435534; Sun, 24 Nov 2019 11:07:15 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:15 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 02/23] media: entity: Modify default behavior of media_entity_get_fwnode_pad Date: Sun, 24 Nov 2019 11:06:42 -0800 Message-Id: <20191124190703.12138-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Modify the default behavior of media_entity_get_fwnode_pad() (when the entity does not provide the get_fwnode_pad op) to first assume the entity implements a 1:1 mapping between fwnode port number and media pad index. If the 1:1 mapping is not valid, e.g. the port number falls outside the entity's pad index range, or the pad at that port number doesn't match the given direction_flags, fall-back to the previous behavior that searches the entity for the first pad that matches the given direction_flags. The previous default behavior can choose the wrong pad for entities with multiple sink or source pads. With this change the function will choose the correct pad index if the entity implements a 1:1 port to pad mapping at that port. Add some comments to the @get_fwnode_pad operation to make it more clear under what conditions entities must implement the operation. Signed-off-by: Steve Longerbeam --- drivers/media/mc/mc-entity.c | 25 ++++++++++++++++++++----- include/media/media-entity.h | 21 +++++++++++++++------ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index c333320f790a..47a39d9383d8 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -370,22 +370,37 @@ int media_entity_get_fwnode_pad(struct media_entity *entity, unsigned long direction_flags) { struct fwnode_endpoint endpoint; - unsigned int i; int ret; + ret = fwnode_graph_parse_endpoint(fwnode, &endpoint); + if (ret) + return ret; + if (!entity->ops || !entity->ops->get_fwnode_pad) { + unsigned int i; + + /* + * for the default case, first try a 1:1 mapping between + * fwnode port number and pad index. + */ + ret = endpoint.port; + if (ret < entity->num_pads && + (entity->pads[ret].flags & direction_flags)) + return ret; + + /* + * if that didn't work search the entity for the first + * pad that matches the @direction_flags. + */ for (i = 0; i < entity->num_pads; i++) { if (entity->pads[i].flags & direction_flags) return i; } + /* else fail */ return -ENXIO; } - ret = fwnode_graph_parse_endpoint(fwnode, &endpoint); - if (ret) - return ret; - 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 cde80ad029b7..ed00adb4313b 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -199,6 +199,12 @@ struct media_pad { * @get_fwnode_pad: Return the pad number based on a fwnode endpoint or * a negative value on error. This operation can be used * to map a fwnode to a media pad number. Optional. + * Entities do not need to implement this operation + * unless two conditions are met: + * - the entity has more than one sink and/or source + * pad, _and_ + * - the entity does not implement a 1:1 mapping of + * fwnode port numbers to pad indexes. * @link_setup: Notify the entity of link changes. The operation can * return an error, in which case link setup will be * cancelled. Optional. @@ -858,21 +864,24 @@ struct media_link *media_entity_find_link(struct media_pad *source, struct media_pad *media_entity_remote_pad(const struct media_pad *pad); /** - * media_entity_get_fwnode_pad - Get pad number from fwnode + * media_entity_get_fwnode_pad - Get pad number from an endpoint fwnode * * @entity: The entity - * @fwnode: Pointer to the fwnode_handle which should be used to find the pad + * @fwnode: Pointer to the endpoint fwnode_handle which should be used to + * find the pad * @direction_flags: Expected direction of the pad, as defined in * :ref:`include/uapi/linux/media.h ` * (seek for ``MEDIA_PAD_FL_*``) * * This function can be used to resolve the media pad number from - * a fwnode. This is useful for devices which use more complex - * mappings of media pads. + * an endpoint fwnode. This is useful for devices which use more + * complex mappings of media pads. * * If the entity does not implement the get_fwnode_pad() operation - * then this function searches the entity for the first pad that - * matches the @direction_flags. + * then this function first assumes the entity implements a 1:1 mapping + * between fwnode port number and media pad index. If the 1:1 mapping + * is not valid, then the function searches the entity for the first pad + * that matches the @direction_flags. * * Return: returns the pad number on success or a negative error code. */ From patchwork Sun Nov 24 19:06:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259271 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 A5EC21805 for ; Sun, 24 Nov 2019 19:07:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 843802075E for ; Sun, 24 Nov 2019 19:07:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b5Pv35uA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726984AbfKXTHT (ORCPT ); Sun, 24 Nov 2019 14:07:19 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:33951 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbfKXTHT (ORCPT ); Sun, 24 Nov 2019 14:07:19 -0500 Received: by mail-pj1-f67.google.com with SMTP id bo14so5424006pjb.1 for ; Sun, 24 Nov 2019 11:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3hiXeQQV1KrdCEAIpSQAk9Ltt3Glhe3/FQmcNgwcF6I=; b=b5Pv35uAPA3KWbjOJyJPjDWKR9bCSOcdEcu2LUdyg2kY4DTkCcmx8VBTrL25IzUAt1 lrYFW1kdaDqXv9oMz9aFVrkxTLKMVtik7d9Hk3ZevGMbqUipzz1r2B0tsyh7E7Hb5tFX 6ut/OcdxHO+XNbNniulHGCmkBbuyq7GsS196UoI+vvxejBQUdh3UtPGdyD2TE/4HGOnM H57BxYhYg7VhY2lmLMl+0+KW4cl08Mw2hV3E/oZUag57M4E4FAqJIF1Ush78sxSc62ye j0At9msN+Ce1/tEmkws0xM2RWdxLzxi8sj8txw9+zedEMqsD+Gxs3J2eoGFLdV9/Xsti au5A== 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=3hiXeQQV1KrdCEAIpSQAk9Ltt3Glhe3/FQmcNgwcF6I=; b=L3mpJ/iNX94Dmu44LKY8JNKmdy7cU6lts34cLbINYCr/8AmIekrofex/z4YSUSs0q6 B60He2YZSGdcZgKwp1kewdE+cqlcNIMcwh3b9Vtm0KJKeXytVP4Fpbt5hMZlCgThczKG Xv0fgkIyUqvlSNTxMLYZ4i6z7tlndiza/4wkzpRp3LW1VRTsnQqcO/AsXRPjw/buVEP9 fB78ZNtTZEvLRAJiGVUOs0n5SOx9FyXtlWY7ey7VBzOfJAnmllCVJlK1afMOyK1qs9Jm 5kp0WMevDeqaVQsYLe67gtVO6iruCc9uHaBK1laAfvE4d6G3D4sLKcQC7cIpaUatt44m HyXw== X-Gm-Message-State: APjAAAVFOvUpzcGTyJvt+S7iB1MYR2vezyRSBSSohGaRkdafybPOJdgG sm4ued6qQXibGTwO15OeoggmKvOMCW8= X-Google-Smtp-Source: APXvYqz98JkzqeHSwwF7zLx18tGdqolFzfnfEhMr1hwNU9QwNu9TODkOVaVlFWUUimUPB8eY6jMN/g== X-Received: by 2002:a17:90b:281:: with SMTP id az1mr34594176pjb.27.1574622436764; Sun, 24 Nov 2019 11:07:16 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:15 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 03/23] media: entity: Convert media_entity_get_fwnode_pad() args to const Date: Sun, 24 Nov 2019 11:06:43 -0800 Message-Id: <20191124190703.12138-4-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-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 media_entity_get_fwnode_pad() can be passed the const local_fwnode member from a struct fwnode_endpoint, so the fwnode argument should be a const pointer. Change the direction_flags argument to const in the process. Signed-off-by: Steve Longerbeam --- drivers/media/mc/mc-entity.c | 4 ++-- include/media/media-entity.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 47a39d9383d8..e9e090244fd4 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -366,8 +366,8 @@ struct media_entity *media_graph_walk_next(struct media_graph *graph) EXPORT_SYMBOL_GPL(media_graph_walk_next); int media_entity_get_fwnode_pad(struct media_entity *entity, - struct fwnode_handle *fwnode, - unsigned long direction_flags) + const struct fwnode_handle *fwnode, + const unsigned long direction_flags) { struct fwnode_endpoint endpoint; int ret; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index ed00adb4313b..de7fc3676b5a 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -886,8 +886,8 @@ struct media_pad *media_entity_remote_pad(const struct media_pad *pad); * Return: returns the pad number on success or a negative error code. */ int media_entity_get_fwnode_pad(struct media_entity *entity, - struct fwnode_handle *fwnode, - unsigned long direction_flags); + const struct fwnode_handle *fwnode, + const unsigned long direction_flags); /** * media_graph_walk_init - Allocate resources used by graph walk. From patchwork Sun Nov 24 19:06:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259279 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 4F17D14E5 for ; Sun, 24 Nov 2019 19:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F15C20835 for ; Sun, 24 Nov 2019 19:07:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ePp1AkyH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbfKXTHV (ORCPT ); Sun, 24 Nov 2019 14:07:21 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40987 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbfKXTHV (ORCPT ); Sun, 24 Nov 2019 14:07:21 -0500 Received: by mail-pf1-f194.google.com with SMTP id p26so6137686pfq.8 for ; Sun, 24 Nov 2019 11:07:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/xV84D2gS7Mwi04w2fDsGDoJh6SY/4m9mQWf3N1HCrs=; b=ePp1AkyHRQ/n/tlMVxl/mYo4urZTkb/kcY6+yHVCw6/w1zOBE+VbwFxI9i51TNe+ho DmB7cCARc8BCMof29VG/bpr86yQq1CKxi2j/hz5VSwjcXA0pl2+mpJ4Dzg07WJp6di9a qztoxs4bSPLZ0ikx1G+fO1kF1M6DxrSs0ibS0a9MkdAja3e8VKvLAapeqImd04eZlyRs NbIbNcRlpiJKO4QBwsdu7d/d0zXojoXRmK2RiZGg+1BGqZXad/YOkOqGjKgs2/E4KCCi J0CzV8cn3geXAXEH8HvlgTZhuvZDtQIKVmfqP2PH8r/MFH/Il8j2ae/qH4tUe33WgSoi W7rQ== 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=/xV84D2gS7Mwi04w2fDsGDoJh6SY/4m9mQWf3N1HCrs=; b=sMrUN/bb+/5OPT8Ga+QizW2P1X0xebSe5/xD45G2KBtS5pJYI5J6nbWajjcNVr58U9 +C5LlS8lUH+vlojFRR+djTERCLGDfIkFs1fHhRiFGlJ1qQULpHxZF0ACkctOVdAv2FJu nvqyHgxHjVYmeKDncvbnurFH411DnI83/ncVsUo5JYhw6dtWwKtwHF2mxQEFfZPRw53B W35YUhoq4e55g0Q52kzREQYq0wThaSu2maECIWTAoDXWRxGWtNTdAJMa+poanI9GWdTj Ta5LI8E9FEx2eGOrgWaRIzoFTOJtgmVgv2snJ8Lui1JAN9sDIRVyVGjmUeLoyzOSzUil BSqQ== X-Gm-Message-State: APjAAAUW2IHifgyH9CqfpH9wwo46KtI9p4iAi29DWuWH6Ecn9advzes/ cW7hQTYW6uZydEpg0yN3rEhHA13uFl0= X-Google-Smtp-Source: APXvYqzkpsCS212wpZJ388vdOAMlsN8ApPzMW9DjNqaxanirOo2fN+UiwL/fhXk72sUgesO6v8wh+g== X-Received: by 2002:a62:180a:: with SMTP id 10mr30684081pfy.40.1574622437646; Sun, 24 Nov 2019 11:07:17 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:17 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 04/23] media: Move v4l2_fwnode_parse_link from v4l2 to driver base Date: Sun, 24 Nov 2019 11:06:44 -0800 Message-Id: <20191124190703.12138-5-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There is nothing v4l2-specific about v4l2_fwnode_{parse|put}_link(). Make these functions more generally available by moving them to driver base, with the appropriate name changes to the functions and struct. In the process embed a 'struct fwnode_endpoint' in 'struct fwnode_link' for both sides of the link, and make use of fwnode_graph_parse_endpoint() to fully parse both endpoints. Rename members local_node and remote_node to more descriptive local_port_parent and remote_port_parent. Signed-off-by: Steve Longerbeam --- drivers/base/property.c | 63 +++++++++++++++++++ drivers/media/platform/xilinx/xilinx-vipp.c | 69 +++++++++++---------- drivers/media/v4l2-core/v4l2-fwnode.c | 39 ------------ drivers/staging/media/imx/imx-media-of.c | 49 +++++++-------- include/linux/fwnode.h | 14 +++++ include/linux/property.h | 5 ++ include/media/v4l2-fwnode.h | 44 ------------- 7 files changed, 141 insertions(+), 142 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 81bd01ed4042..dd82cd150d84 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1100,6 +1100,69 @@ int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, } EXPORT_SYMBOL(fwnode_graph_parse_endpoint); +/** + * fwnode_graph_parse_link() - parse a link between two endpoints + * @local_endpoint: the endpoint's fwnode at the local end of the link + * @link: pointer to the fwnode link data structure + * + * Fill the link structure with the parsed local and remote endpoint info + * and the local and remote port parent nodes. + * + * A reference is taken to both the local and remote port parent nodes, + * the caller must use fwnode_graph_put_link() to drop the references + * when done with the link. + * + * Return: 0 on success, or -ENOLINK if the remote endpoint fwnode + * can't be found. + */ +int fwnode_graph_parse_link(struct fwnode_handle *local_endpoint, + struct fwnode_link *link) +{ + struct fwnode_handle *remote_endpoint; + int ret; + + memset(link, 0, sizeof(*link)); + + ret = fwnode_graph_parse_endpoint(local_endpoint, &link->local); + if (ret < 0) + return ret; + + remote_endpoint = fwnode_graph_get_remote_endpoint(local_endpoint); + if (!remote_endpoint) + return -ENOLINK; + + ret = fwnode_graph_parse_endpoint(remote_endpoint, &link->remote); + if (ret < 0) { + fwnode_handle_put(remote_endpoint); + return ret; + } + + link->local_port_parent = + fwnode_graph_get_port_parent(local_endpoint); + link->remote_port_parent = + fwnode_graph_get_port_parent(remote_endpoint); + + fwnode_handle_put(remote_endpoint); + + return 0; +} +EXPORT_SYMBOL_GPL(fwnode_graph_parse_link); + +/** + * fwnode_graph_put_link() - drop references to port parent nodes in a link + * @link: pointer to the fwnode link data structure + * + * Drop references to the local and remote port parent nodes in the link. + * This function must be called on every link parsed with + * fwnode_graph_parse_link(). + */ +void fwnode_graph_put_link(struct fwnode_link *link) +{ + fwnode_handle_put(link->local_port_parent); + fwnode_handle_put(link->remote_port_parent); +} +EXPORT_SYMBOL_GPL(fwnode_graph_put_link); + const void *device_get_match_data(struct device *dev) { return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev); diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index cc2856efea59..9c0dfc694478 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -74,7 +74,7 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, struct media_pad *local_pad; struct media_pad *remote_pad; struct xvip_graph_entity *ent; - struct v4l2_fwnode_link link; + struct fwnode_link link; struct fwnode_handle *ep = NULL; int ret = 0; @@ -89,7 +89,7 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, dev_dbg(xdev->dev, "processing endpoint %p\n", ep); - ret = v4l2_fwnode_parse_link(ep, &link); + ret = fwnode_graph_parse_link(ep, &link); if (ret < 0) { dev_err(xdev->dev, "failed to parse link for %p\n", ep); @@ -99,54 +99,55 @@ static int xvip_graph_build_one(struct xvip_composite_device *xdev, /* Skip sink ports, they will be processed from the other end of * the link. */ - if (link.local_port >= local->num_pads) { + if (link.local.port >= local->num_pads) { dev_err(xdev->dev, "invalid port number %u for %p\n", - link.local_port, link.local_node); - v4l2_fwnode_put_link(&link); + link.local.port, link.local_port_parent); + fwnode_graph_put_link(&link); ret = -EINVAL; break; } - local_pad = &local->pads[link.local_port]; + local_pad = &local->pads[link.local.port]; if (local_pad->flags & MEDIA_PAD_FL_SINK) { dev_dbg(xdev->dev, "skipping sink port %p:%u\n", - link.local_node, link.local_port); - v4l2_fwnode_put_link(&link); + link.local_port_parent, link.local.port); + fwnode_graph_put_link(&link); continue; } /* Skip DMA engines, they will be processed separately. */ - if (link.remote_node == of_fwnode_handle(xdev->dev->of_node)) { + if (link.remote_port_parent == + of_fwnode_handle(xdev->dev->of_node)) { dev_dbg(xdev->dev, "skipping DMA port %p:%u\n", - link.local_node, link.local_port); - v4l2_fwnode_put_link(&link); + link.local_port_parent, link.local.port); + fwnode_graph_put_link(&link); continue; } /* Find the remote entity. */ - ent = xvip_graph_find_entity(xdev, link.remote_node); + ent = xvip_graph_find_entity(xdev, link.remote_port_parent); if (ent == NULL) { dev_err(xdev->dev, "no entity found for %p\n", - link.remote_node); - v4l2_fwnode_put_link(&link); + link.remote_port_parent); + fwnode_graph_put_link(&link); ret = -ENODEV; break; } remote = ent->entity; - if (link.remote_port >= remote->num_pads) { + if (link.remote.port >= remote->num_pads) { dev_err(xdev->dev, "invalid port number %u on %p\n", - link.remote_port, link.remote_node); - v4l2_fwnode_put_link(&link); + link.remote.port, link.remote_port_parent); + fwnode_graph_put_link(&link); ret = -EINVAL; break; } - remote_pad = &remote->pads[link.remote_port]; + remote_pad = &remote->pads[link.remote.port]; - v4l2_fwnode_put_link(&link); + fwnode_graph_put_link(&link); /* Create the media link. */ dev_dbg(xdev->dev, "creating %s:%u -> %s:%u link\n", @@ -191,7 +192,7 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) struct media_pad *source_pad; struct media_pad *sink_pad; struct xvip_graph_entity *ent; - struct v4l2_fwnode_link link; + struct fwnode_link link; struct device_node *ep = NULL; struct xvip_dma *dma; int ret = 0; @@ -206,7 +207,7 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep); - ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); + ret = fwnode_graph_parse_link(of_fwnode_handle(ep), &link); if (ret < 0) { dev_err(xdev->dev, "failed to parse link for %pOF\n", ep); @@ -214,11 +215,11 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) } /* Find the DMA engine. */ - dma = xvip_graph_find_dma(xdev, link.local_port); + dma = xvip_graph_find_dma(xdev, link.local.port); if (dma == NULL) { dev_err(xdev->dev, "no DMA engine found for port %u\n", - link.local_port); - v4l2_fwnode_put_link(&link); + link.local.port); + fwnode_graph_put_link(&link); ret = -EINVAL; break; } @@ -227,20 +228,20 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) dma->video.name); /* Find the remote entity. */ - ent = xvip_graph_find_entity(xdev, link.remote_node); + ent = xvip_graph_find_entity(xdev, link.remote_port_parent); if (ent == NULL) { dev_err(xdev->dev, "no entity found for %pOF\n", - to_of_node(link.remote_node)); - v4l2_fwnode_put_link(&link); + to_of_node(link.remote_port_parent)); + fwnode_graph_put_link(&link); ret = -ENODEV; break; } - if (link.remote_port >= ent->entity->num_pads) { + if (link.remote.port >= ent->entity->num_pads) { dev_err(xdev->dev, "invalid port number %u on %pOF\n", - link.remote_port, - to_of_node(link.remote_node)); - v4l2_fwnode_put_link(&link); + link.remote.port, + to_of_node(link.remote_port_parent)); + fwnode_graph_put_link(&link); ret = -EINVAL; break; } @@ -249,15 +250,15 @@ static int xvip_graph_build_dma(struct xvip_composite_device *xdev) source = &dma->video.entity; source_pad = &dma->pad; sink = ent->entity; - sink_pad = &sink->pads[link.remote_port]; + sink_pad = &sink->pads[link.remote.port]; } else { source = ent->entity; - source_pad = &source->pads[link.remote_port]; + source_pad = &source->pads[link.remote.port]; sink = &dma->video.entity; sink_pad = &dma->pad; } - v4l2_fwnode_put_link(&link); + fwnode_graph_put_link(&link); /* Create the media link. */ dev_dbg(xdev->dev, "creating %s:%u -> %s:%u link\n", diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 192cac076761..f43f563f9e98 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -557,45 +557,6 @@ int v4l2_fwnode_endpoint_alloc_parse(struct fwnode_handle *fwnode, } EXPORT_SYMBOL_GPL(v4l2_fwnode_endpoint_alloc_parse); -int v4l2_fwnode_parse_link(struct fwnode_handle *__fwnode, - struct v4l2_fwnode_link *link) -{ - const char *port_prop = is_of_node(__fwnode) ? "reg" : "port"; - struct fwnode_handle *fwnode; - - memset(link, 0, sizeof(*link)); - - fwnode = fwnode_get_parent(__fwnode); - fwnode_property_read_u32(fwnode, port_prop, &link->local_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->local_node = fwnode; - - fwnode = fwnode_graph_get_remote_endpoint(__fwnode); - if (!fwnode) { - fwnode_handle_put(fwnode); - return -ENOLINK; - } - - fwnode = fwnode_get_parent(fwnode); - fwnode_property_read_u32(fwnode, port_prop, &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; - - return 0; -} -EXPORT_SYMBOL_GPL(v4l2_fwnode_parse_link); - -void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link) -{ - fwnode_handle_put(link->local_node); - fwnode_handle_put(link->remote_node); -} -EXPORT_SYMBOL_GPL(v4l2_fwnode_put_link); - static int v4l2_async_notifier_fwnode_parse_endpoint(struct device *dev, struct v4l2_async_notifier *notifier, diff --git a/drivers/staging/media/imx/imx-media-of.c b/drivers/staging/media/imx/imx-media-of.c index 2d3efd2a6dde..736c954a8ff5 100644 --- a/drivers/staging/media/imx/imx-media-of.c +++ b/drivers/staging/media/imx/imx-media-of.c @@ -84,28 +84,29 @@ EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs); */ static int create_of_link(struct imx_media_dev *imxmd, struct v4l2_subdev *sd, - struct v4l2_fwnode_link *link) + struct fwnode_link *link) { struct v4l2_subdev *remote, *src, *sink; int src_pad, sink_pad; - if (link->local_port >= sd->entity.num_pads) + if (link->local.port >= sd->entity.num_pads) return -EINVAL; - remote = imx_media_find_subdev_by_fwnode(imxmd, link->remote_node); + remote = imx_media_find_subdev_by_fwnode(imxmd, + link->remote_port_parent); if (!remote) return 0; - if (sd->entity.pads[link->local_port].flags & MEDIA_PAD_FL_SINK) { + if (sd->entity.pads[link->local.port].flags & MEDIA_PAD_FL_SINK) { src = remote; - src_pad = link->remote_port; + src_pad = link->remote.port; sink = sd; - sink_pad = link->local_port; + sink_pad = link->local.port; } else { src = sd; - src_pad = link->local_port; + src_pad = link->local.port; sink = remote; - sink_pad = link->remote_port; + sink_pad = link->remote.port; } /* make sure link doesn't already exist before creating */ @@ -126,17 +127,17 @@ static int create_of_link(struct imx_media_dev *imxmd, int imx_media_create_of_links(struct imx_media_dev *imxmd, struct v4l2_subdev *sd) { - struct v4l2_fwnode_link link; - struct device_node *ep; + struct fwnode_handle *endpoint; + struct fwnode_link link; int ret; - for_each_endpoint_of_node(sd->dev->of_node, ep) { - ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), &link); + fwnode_graph_for_each_endpoint(dev_fwnode(sd->dev), endpoint) { + ret = fwnode_graph_parse_link(endpoint, &link); if (ret) continue; ret = create_of_link(imxmd, sd, &link); - v4l2_fwnode_put_link(&link); + fwnode_graph_put_link(&link); if (ret) return ret; } @@ -152,35 +153,33 @@ EXPORT_SYMBOL_GPL(imx_media_create_of_links); 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; + struct fwnode_handle *csi_np = dev_fwnode(csi->dev); + struct fwnode_handle *csi_ep; - for_each_child_of_node(csi_np, ep) { - struct fwnode_handle *fwnode, *csi_ep; - struct v4l2_fwnode_link link; + fwnode_for_each_child_node(csi_np, csi_ep) { + struct fwnode_handle *fwnode; + struct 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); + link.local_port_parent = csi_np; + link.local.port = CSI_SINK_PAD; 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_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; + link.remote_port_parent = fwnode; ret = create_of_link(imxmd, csi, &link); - fwnode_handle_put(link.remote_node); + fwnode_handle_put(link.remote_port_parent); if (ret) return ret; } diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index ababd6bc82f3..7bafd01b28a4 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -31,6 +31,20 @@ struct fwnode_endpoint { const struct fwnode_handle *local_fwnode; }; +/** + * struct fwnode_link - a link between two fwnode graph endpoints + * @local: parsed local endpoint of the link + * @local_port_parent: port parent fwnode of local endpoint + * @remote: parsed remote endpoint of the link + * @remote_port_parent: port parent fwnode of the remote endpoint + */ +struct fwnode_link { + struct fwnode_endpoint local; + struct fwnode_handle *local_port_parent; + struct fwnode_endpoint remote; + struct fwnode_handle *remote_port_parent; +}; + #define NR_FWNODE_REFERENCE_ARGS 8 /** diff --git a/include/linux/property.h b/include/linux/property.h index 9b3d4ca3a73a..1dd5a939bab7 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -374,6 +374,11 @@ fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode, int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, struct fwnode_endpoint *endpoint); +int fwnode_graph_parse_link(struct fwnode_handle *fwnode, + struct fwnode_link *link); + +void fwnode_graph_put_link(struct fwnode_link *link); + /* -------------------------------------------------------------------------- */ /* Software fwnode support - when HW description is incomplete or missing */ diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index f6a7bcd13197..f81f8bf34526 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -109,20 +109,6 @@ struct v4l2_fwnode_endpoint { unsigned int nr_of_link_frequencies; }; -/** - * struct v4l2_fwnode_link - a link between two endpoints - * @local_node: pointer to device_node of this endpoint - * @local_port: identifier of the port this endpoint belongs to - * @remote_node: pointer to device_node of the remote endpoint - * @remote_port: identifier of the port the remote endpoint belongs to - */ -struct v4l2_fwnode_link { - struct fwnode_handle *local_node; - unsigned int local_port; - struct fwnode_handle *remote_node; - unsigned int remote_port; -}; - /** * v4l2_fwnode_endpoint_parse() - parse all fwnode node properties * @fwnode: pointer to the endpoint's fwnode handle @@ -203,36 +189,6 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); int v4l2_fwnode_endpoint_alloc_parse(struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep); -/** - * v4l2_fwnode_parse_link() - parse a link between two endpoints - * @fwnode: pointer to the endpoint's fwnode at the local end of the link - * @link: pointer to the V4L2 fwnode link data structure - * - * Fill the link structure with the local and remote nodes and port numbers. - * The local_node and remote_node fields are set to point to the local and - * remote port's parent nodes respectively (the port parent node being the - * parent node of the port node if that node isn't a 'ports' node, or the - * grand-parent node of the port node otherwise). - * - * A reference is taken to both the local and remote nodes, the caller must use - * v4l2_fwnode_put_link() to drop the references when done with the - * link. - * - * Return: 0 on success, or -ENOLINK if the remote endpoint fwnode can't be - * found. - */ -int v4l2_fwnode_parse_link(struct fwnode_handle *fwnode, - struct v4l2_fwnode_link *link); - -/** - * v4l2_fwnode_put_link() - drop references to nodes in a link - * @link: pointer to the V4L2 fwnode link data structure - * - * Drop references to the local and remote nodes in the link. This function - * must be called on every link parsed with v4l2_fwnode_parse_link(). - */ -void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link); - /** * typedef parse_endpoint_func - Driver's callback function to be called on * each V4L2 fwnode endpoint. From patchwork Sun Nov 24 19:06:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259275 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 0442118EC for ; Sun, 24 Nov 2019 19:07:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7A392080D for ; Sun, 24 Nov 2019 19:07:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qfl7mpn0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726998AbfKXTHV (ORCPT ); Sun, 24 Nov 2019 14:07:21 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:45926 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726975AbfKXTHU (ORCPT ); Sun, 24 Nov 2019 14:07:20 -0500 Received: by mail-pj1-f66.google.com with SMTP id m71so5405824pjb.12 for ; Sun, 24 Nov 2019 11:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O/5KfUP0LpkEm4DJb+IianL3viLiCU0yRFlJf10usn8=; b=qfl7mpn0dtIN16wpxCG2vs/tl1m0pVxpBvfdTTTkvh62cFmYhpqcRhuuIPEI1+hzfn FbJyss+kn3HcL/My85UetVEOg1fLafvnDsK96MGhhu+dkWH8AycgNQGePWWVC4ywLpfl sDAXb1wdJ8UZShfNXbPKSrEVon6w+0OVTrCav7KplfXtkhbaT8b3vHL0C7iDYITUoyWE UpjL4v+7Cy8gSeV9iZfSj4szsP4IxpFJFG4PI9Wk7uL2MINHwJl+a1sSnoUZ16TQEErk ESqEq6JGBXc13RA9zIJFhNVlUGzz+H/nnh+Pmr8Y6DklPP9yG7XmJSQ1WtSnbpA3qCGo WL/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=O/5KfUP0LpkEm4DJb+IianL3viLiCU0yRFlJf10usn8=; b=AgF+1w/IXffXceXxMY3gnbMwBEtyT3nEUpkDMOAHofGCysgPZCQ1cNaL3RDSw2xkK2 m8s86KvIlqI2Q65AeNqcxruAeocaVLhqSUdLnrhA3OyQpO3BYWhrHYIWO+7D9bU2wuVd m7NH9WEzvpjvhqhz9XdqVZNm+XbrJ0uZ38byLfgLjbnV5Eov1NTK+aeurWDt/dzT8Y8D XokU0P0OxhBtCzPB96qfOWnDxZF27CDleHGIxOG4ShB42jca+ENXSZC+p4Cn6AHjaRor 8/kGcL4/g4ca/f/qXZzvUTIgZGGu84/exHGl4tJ75q8sJOnmHAy2CWGwBYzJxrOnP7V/ OyWQ== X-Gm-Message-State: APjAAAUNY+mLtdskj8MzrKPPbOALSfKSybqKXIKIJAYiB6zNVzoio/Th gJzpJYUN+0NDIOPWPINVfsXLVeR4z+0= X-Google-Smtp-Source: APXvYqziMo5OM1bptcjmxrqJHW7BnUYopgZHmnzFq8lyAck+PC0icOGMKSdSQzpC9Efz9zpLnMrFCQ== X-Received: by 2002:a17:90a:b109:: with SMTP id z9mr33159099pjq.108.1574622438335; Sun, 24 Nov 2019 11:07:18 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:17 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 05/23] media: entity: Add functions to convert fwnode endpoints to media links Date: Sun, 24 Nov 2019 11:06:45 -0800 Message-Id: <20191124190703.12138-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Adds two functions: media_create_fwnode_pad_links(), which converts fwnode endpoints that connect a local pad to all pads on a remote entity into media links. media_create_fwnode_links(), which converts fwnode endpoints that connect all pads from a local entity to all pads on a remote entity into media links. Signed-off-by: Steve Longerbeam --- Changes in v2: - fixed/improved the prototype descriptions. --- drivers/media/mc/mc-entity.c | 178 +++++++++++++++++++++++++++++++++++ include/media/media-entity.h | 71 ++++++++++++++ 2 files changed, 249 insertions(+) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index e9e090244fd4..45bbd6c91019 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -787,6 +787,184 @@ int media_create_pad_links(const struct media_device *mdev, } EXPORT_SYMBOL_GPL(media_create_pad_links); +static int __media_create_fwnode_pad_link(struct media_pad *local_pad, + struct media_entity *remote, + const struct fwnode_handle *remote_ep, + const u32 flags) +{ + struct media_entity *local = local_pad->entity; + unsigned long local_dir = local_pad->flags; + unsigned long remote_dir = (local_dir & MEDIA_PAD_FL_SOURCE) ? + MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; + struct media_entity *src, *sink; + int src_pad, sink_pad; + int remote_pad; + int ret; + + remote_pad = media_entity_get_fwnode_pad(remote, remote_ep, + remote_dir); + if (remote_pad < 0) + return 0; + + if (local_dir & MEDIA_PAD_FL_SOURCE) { + src = local; + src_pad = local_pad->index; + sink = remote; + sink_pad = remote_pad; + } else { + src = remote; + src_pad = remote_pad; + sink = local; + sink_pad = local_pad->index; + } + + /* make sure link doesn't already exist */ + if (media_entity_find_link(&src->pads[src_pad], + &sink->pads[sink_pad])) + return 0; + + ret = media_create_pad_link(src, src_pad, sink, sink_pad, flags); + if (ret) { + dev_dbg(sink->graph_obj.mdev->dev, + "%s:%d -> %s:%d failed with %d\n", + src->name, src_pad, sink->name, sink_pad, + ret); + return ret; + } + + dev_dbg(sink->graph_obj.mdev->dev, "%s:%d -> %s:%d\n", + src->name, src_pad, sink->name, sink_pad); + + return 0; +} + +int __media_create_fwnode_pad_links(struct media_pad *local_pad, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags) +{ + struct fwnode_handle *endpoint; + + fwnode_graph_for_each_endpoint(remote_fwnode, endpoint) { + struct fwnode_link link; + int ret; + + ret = fwnode_graph_parse_link(endpoint, &link); + if (ret) + continue; + + /* + * if this endpoint does not link to the local fwnode + * device, ignore it and continue. + */ + if (link.remote_port_parent != local_fwnode) { + fwnode_graph_put_link(&link); + continue; + } + + ret = __media_create_fwnode_pad_link(local_pad, + remote, endpoint, + link_flags); + + fwnode_graph_put_link(&link); + + if (ret) { + fwnode_handle_put(endpoint); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(__media_create_fwnode_pad_links); + +int media_create_fwnode_pad_links(struct media_pad *local_pad, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags) +{ + struct media_device *mdev = local_pad->entity->graph_obj.mdev; + int ret; + + mutex_lock(&mdev->graph_mutex); + ret = __media_create_fwnode_pad_links(local_pad, local_fwnode, + remote, remote_fwnode, + link_flags); + mutex_unlock(&mdev->graph_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(media_create_fwnode_pad_links); + +int __media_create_fwnode_links(struct media_entity *local, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags) +{ + struct fwnode_handle *endpoint; + + fwnode_graph_for_each_endpoint(local_fwnode, endpoint) { + struct fwnode_link link; + int local_pad; + int ret; + + local_pad = media_entity_get_fwnode_pad(local, endpoint, + MEDIA_PAD_FL_SINK | + MEDIA_PAD_FL_SOURCE); + if (local_pad < 0) + continue; + + ret = fwnode_graph_parse_link(endpoint, &link); + if (ret) + continue; + + /* + * if this endpoint does not link to the remote fwnode + * device, ignore it and continue. + */ + if (link.remote_port_parent != remote_fwnode) { + fwnode_graph_put_link(&link); + continue; + } + + ret = __media_create_fwnode_pad_link(&local->pads[local_pad], + remote, + link.remote.local_fwnode, + link_flags); + + fwnode_graph_put_link(&link); + + if (ret) { + fwnode_handle_put(endpoint); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(__media_create_fwnode_links); + +int media_create_fwnode_links(struct media_entity *local, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags) +{ + struct media_device *mdev = local->graph_obj.mdev; + int ret; + + mutex_lock(&mdev->graph_mutex); + ret = __media_create_fwnode_links(local, local_fwnode, + remote, remote_fwnode, link_flags); + mutex_unlock(&mdev->graph_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(media_create_fwnode_links); + void __media_entity_remove_links(struct media_entity *entity) { struct media_link *link, *tmp; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index de7fc3676b5a..100673ad83c4 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -772,6 +772,77 @@ int media_create_pad_links(const struct media_device *mdev, u32 flags, const bool allow_both_undefined); +/** + * media_create_fwnode_pad_links() - create links between a single local pad + * and a remote entity, using the fwnode endpoints + * between them. + * + * @local_pad: Pointer to &media_pad of the local media pad. + * @local_fwnode: Pointer to the local device's firmware node. + * @remote: Pointer to &media_entity of the remote device. + * @remote_fwnode: Pointer to the remote device's firmware node. + * @link_flags: Link flags, as defined in include/uapi/linux/media.h. + * + * .. note:: + * + * Before calling this function, media_entity_pads_init() and + * media_device_register_entity() should be called previously for + * both entities to be linked. + * + * Locked (via the mdev graph_mutex) and unlocked versions of this + * function are provided. If this function is called from v4l2-async + * notifier bound handlers, the locked version should be used to + * prevent races with other subdevices loading and binding to their + * notifiers in parallel. The unlocked version can for example be + * called from v4l2-async notifier complete handlers, after all + * subdevices have loaded and bound. + */ +int __media_create_fwnode_pad_links(struct media_pad *local_pad, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags); +int media_create_fwnode_pad_links(struct media_pad *local_pad, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags); + +/** + * media_create_fwnode_links() - create links between two entities, using + * the fwnode endpoints between them. + * + * @local: Pointer to &media_entity of the local device. + * @local_fwnode: Pointer to the local device's firmware node. + * @remote: Pointer to &media_entity of the remote device. + * @remote_fwnode: Pointer to the remote device's firmware node. + * @link_flags: Link flags, as defined in include/uapi/linux/media.h. + * + * .. note:: + * + * Before calling this function, media_entity_pads_init() and + * media_device_register_entity() should be called previously for + * both entities to be linked. + * + * Locked (via the mdev graph_mutex) and unlocked versions of this + * function are provided. If this function is called from v4l2-async + * notifier bound handlers, the locked version should be used to + * prevent races with other subdevices loading and binding to their + * notifiers in parallel. The unlocked version can for example be + * called from v4l2-async notifier complete handlers, after all + * subdevices have loaded and bound. + */ +int __media_create_fwnode_links(struct media_entity *local, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags); +int media_create_fwnode_links(struct media_entity *local, + const struct fwnode_handle *local_fwnode, + struct media_entity *remote, + const struct fwnode_handle *remote_fwnode, + const u32 link_flags); + void __media_entity_remove_links(struct media_entity *entity); /** From patchwork Sun Nov 24 19:06:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259273 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 CF99417F0 for ; Sun, 24 Nov 2019 19:07:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE9D72075E for ; Sun, 24 Nov 2019 19:07:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rFeu0exd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726992AbfKXTHU (ORCPT ); Sun, 24 Nov 2019 14:07:20 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41856 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726945AbfKXTHU (ORCPT ); Sun, 24 Nov 2019 14:07:20 -0500 Received: by mail-pg1-f196.google.com with SMTP id 207so5927835pge.8 for ; Sun, 24 Nov 2019 11:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0YKGrpYeoAEn9gUSXzC9FX/K5C81TuWUa0ZyQnxQgg4=; b=rFeu0exdwpuiru+s1mrJspFxEw8QnuQUMtxviibGWDpyd5goH27IHvF5Mpn8MnbEA2 PA0LB08spwQbmZuJocrlIz4lrsbMLcbSC5dZLRgHQ1UFXeR3DPwlVUzMm8Z82OrL8oGb EPWrZ/dKdrmrrSzZ9GZpKTiu3zKzWRZ/pyBqCWjGfEofp24SPCMtWj1+8yRX1FExkB6C FtFJpDLbi44ZyrtKg3/5P7xAjvyoYKC1W+ThxBNg4Jsv+Y2Rmcsd5SB7b6+hxe8FQKue koSqjJOK+sUkDSE0Xt71mIDBaqLxJZiuQ+hccFJsPWcRLi3t308EltNrzm34O+1K3Uvy CUXQ== 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=0YKGrpYeoAEn9gUSXzC9FX/K5C81TuWUa0ZyQnxQgg4=; b=hL2VhwnYgvlCto+sT97HXsG63+geoFMkGZhLhsOAwqyBOPkaib1/x8e5BmipBA4wrV d02oMaCjeG9BCgIHAUkofRtYOi8SRtl/fM16gXe5JvCwD4G4gXyLfYImErNkPHvB3in+ 5iPLcb7pC2pcCoMtOhYJcROklFebeQAC9ub9np710QrXpTkKfSj9XKJD3YHm+l46dlkO cGdUFih9d3iYXCM43vShoyhtHlR2bz+6DQLnjb2h4K3NgY7Ou4vLKdMqbbibAvtKqT9r 2vZEDeeZ2W2Rm/UBqnj25CDf7/QoyrYJaxmSHVFOWVuywCS8vZmtN5W1tLO4jRUcl+pK 1d7Q== X-Gm-Message-State: APjAAAVgh0iqb2tPyhFMbOcOAPVtaPibXVt3HGJMdeKH0wpKCUZS7+tM nqA3eENjy7PV1qu7ITg2K/pZbXqhgbc= X-Google-Smtp-Source: APXvYqxWn8OjPS3zykCnZKKUfg3P+4aBtSEkxUXY24A1dpGY/vfHFoWEQQLbBLPjFKzHhbqk1xtbmQ== X-Received: by 2002:a62:14d0:: with SMTP id 199mr30116729pfu.147.1574622439053; Sun, 24 Nov 2019 11:07:19 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:18 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 06/23] media: adv748x: csi2: Implement get_fwnode_pad Date: Sun, 24 Nov 2019 11:06:46 -0800 Message-Id: <20191124190703.12138-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If the given endpoint fwnode passed to the .get_fwnode_pad() op is the adv748x-csi2 TXA/TXB source endpoint, return the associated media pad index ADV748X_CSI2_SOURCE. The adv748x-csi2 has no other media pads that are associated with fwnode endpoints. Signed-off-by: Steve Longerbeam --- drivers/media/i2c/adv748x/adv748x-csi2.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c index 2091cda50935..810085a1f2f0 100644 --- a/drivers/media/i2c/adv748x/adv748x-csi2.c +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c @@ -228,6 +228,24 @@ static const struct v4l2_subdev_ops adv748x_csi2_ops = { .pad = &adv748x_csi2_pad_ops, }; +/* ----------------------------------------------------------------------------- + * media_entity_operations + */ + +static int adv748x_csi2_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); + + return endpoint->local_fwnode == tx->sd.fwnode ? + ADV748X_CSI2_SOURCE : -ENXIO; +} + +static const struct media_entity_operations adv748x_csi2_entity_ops = { + .get_fwnode_pad = adv748x_csi2_get_fwnode_pad, +}; + /* ----------------------------------------------------------------------------- * Subdev module and controls */ @@ -295,6 +313,9 @@ int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx) /* Register internal ops for incremental subdev registration */ tx->sd.internal_ops = &adv748x_csi2_internal_ops; + /* Register media_entity ops */ + tx->sd.entity.ops = &adv748x_csi2_entity_ops; + tx->pads[ADV748X_CSI2_SINK].flags = MEDIA_PAD_FL_SINK; tx->pads[ADV748X_CSI2_SOURCE].flags = MEDIA_PAD_FL_SOURCE; From patchwork Sun Nov 24 19:06:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259277 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 07C391390 for ; Sun, 24 Nov 2019 19:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D879A20840 for ; Sun, 24 Nov 2019 19:07:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CSBrgqgG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfKXTHV (ORCPT ); Sun, 24 Nov 2019 14:07:21 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34761 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbfKXTHV (ORCPT ); Sun, 24 Nov 2019 14:07:21 -0500 Received: by mail-pg1-f193.google.com with SMTP id z188so5947683pgb.1 for ; Sun, 24 Nov 2019 11:07:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4ph62gNreQJ316vv67Ff1MLtxGjOWFn3EwRPlk4hDDA=; b=CSBrgqgGNrvT5dqtvwVc7cGfUE/uXv87CW7bnbs8+nQbFWbkxcDp/NW49GSySNyAOX gyL8od3VIqtXKOVrFD5SA5kQ23BEf+JwfO6X4Y9fWVWyxbrHzP+e4C/HUFYJ9Y0hhIEN iefKBlcoMrKazgv0u9NzTfBB63ESG3Rs3hV5xfF1oZQtGoZ74Bg4/xKB+yPf+a6xPfMW CEzugMhxT3ltliZ8bzQGJKCIN7NUe0b541gERuBJNsffySWJ0P0Z5IQ4Ht1Rid3leRGZ EfDnRCfcCujkW/NaXX22oKwah1leokad43RjgWq6YqqWupmMBZ+eqXF0GhCTQE4OPPz+ zclQ== 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=4ph62gNreQJ316vv67Ff1MLtxGjOWFn3EwRPlk4hDDA=; b=HBctc5iet4uyJVB4OzHS5BCY8iuVUf/Us6utgTLyBempTVAR6i6gbWM6qzY0j/zfbX XDXGgE2GQFOwoJNxxJSrIRM34Wh2E/UgRrq2O1Xpw9ZAMcCJAlwjqX5deyazqm9AeEot nBvP5huTB0yeW99hsvIVx4MhicHIEGewbhTsuOrLgIcet+Qb7ZV6ERyFWRokJ593u2CN cql84/40onV0mShYYkX3V0oullHjCDWrIWusO5JcPCystu6OGZjRs31mzM9xPKrPcrLM 1mz5TyvhUKqAQkKzaJWhxtrn9WD5hnO0r9RkZzNFTNbIOMJOmJboRxXrV9h59MpagJh8 G3QA== X-Gm-Message-State: APjAAAXx4IGuoFbhNtO2mpxkls355vzOcFgYl/afHEEz9XdAV2gQK1G9 YRD8Uap2MUN03ZrYop5UGWg2OibBpBo= X-Google-Smtp-Source: APXvYqyjrLon9/6TMvbNt4VETLZKYBRpuvL2o67rYr2Wk4VNgQA4fpZiKVgD8KB11fA1MS4TApfH5Q== X-Received: by 2002:a62:7796:: with SMTP id s144mr29061738pfc.37.1574622440188; Sun, 24 Nov 2019 11:07:20 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:19 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 07/23] media: rcar-csi2: Fix fwnode media link creation Date: Sun, 24 Nov 2019 11:06:47 -0800 Message-Id: <20191124190703.12138-8-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org rcsi2_notify_bound() passes the bound subdev's match fwnode to media_entity_get_fwnode_pad() to determine the subdev's source pad for creating the media link to it. When the bound subdev is the adv748x-csi2 transmitter, this is in fact correctly the endpoint fwnode. For other subdevices this likely will not be the case, the asd match fwnode is usually not an endpoint fwnode but rather the port parent fwnode. So rcar-csi2 will fail to get the correct source pad for bound subdev's other than the adv748x. To fix and make rcar-csi2 connect more generally to other subdevices, replace the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: 769afd212b160 ("media: rcar-csi2: add Renesas R-Car MIPI CSI-2 receiver driver") Signed-off-by: Steve Longerbeam --- drivers/media/platform/rcar-vin/rcar-csi2.c | 23 +++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index faa9fb23a2e9..df6cb6d91d7e 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -738,23 +738,20 @@ static int rcsi2_notify_bound(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd) { struct rcar_csi2 *priv = notifier_to_csi2(notifier); - int pad; + int ret; - pad = media_entity_get_fwnode_pad(&subdev->entity, asd->match.fwnode, - MEDIA_PAD_FL_SOURCE); - if (pad < 0) { - dev_err(priv->dev, "Failed to find pad for %s\n", subdev->name); - return pad; - } + ret = media_create_fwnode_pad_links(&priv->subdev.entity.pads[0], + dev_fwnode(priv->dev), + &subdev->entity, + dev_fwnode(subdev->dev), + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); + if (ret) + return ret; priv->remote = subdev; - dev_dbg(priv->dev, "Bound %s pad: %d\n", subdev->name, pad); - - return media_create_pad_link(&subdev->entity, pad, - &priv->subdev.entity, 0, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); + return 0; } static void rcsi2_notify_unbind(struct v4l2_async_notifier *notifier, From patchwork Sun Nov 24 19:06:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259281 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 81F0A913 for ; Sun, 24 Nov 2019 19:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56F072075E for ; Sun, 24 Nov 2019 19:07:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IX4Y9Bz/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727008AbfKXTHW (ORCPT ); Sun, 24 Nov 2019 14:07:22 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:43622 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727007AbfKXTHW (ORCPT ); Sun, 24 Nov 2019 14:07:22 -0500 Received: by mail-pf1-f195.google.com with SMTP id 3so6134596pfb.10 for ; Sun, 24 Nov 2019 11:07:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cuZoH/JLmsjVG1Yg//mGp6FIvC3w8f1MmhjZrWshNBg=; b=IX4Y9Bz/oaP/VAPUGFUyK43T18l1VPj60JTc6pL0zbdvaybJfeifheGeXq4OUAX8ad U4Po6D9ilLnP+P0dbpbJaY4PSyVgzYF6Q2OYIALjVuM6/fVroictl+aJdyq5r2emykwj 4pHyEQIOaqUrinTyNvQdHCjdgKCKCBfza7cq4mYf3UNilIzaIzBXFjvwRjg+Lv3HfjpD hNbnzTclxFHzv9EDOXpN4368pwi/ct4be3Hw4vX78Ineji6i7KmuOAErKsvvcSThesX2 Wx2MTwthNIqm6G76MehseNrO8VvlN0fAAkiML1cExwYdHBVq/lPD0d20hJXS+IFZh5Ay az6A== 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=cuZoH/JLmsjVG1Yg//mGp6FIvC3w8f1MmhjZrWshNBg=; b=W04vlpyfn70k58XC5aKerbuRtgwrmKi5T3uS8KKLoCpU4Iu1s/qzfEeSFBNdAflafl kWrR2e7H1nHlOM+0nEM5Zpyb49zZi22Bnx8EZP9662rS5Lg71gsfu8768CTsiVyb27hr kWHPSOY6cH3b8ZvOB/ymWMBhWwUgAUZXhTbB3qu9KyLBwqNWobWjqtONjSofEoIM2vJQ PlWrt5tcjxnDRzFztS9/8ILpin2rFe4E5gAjn/Y8x0w0ZPCTdRRKlbtw2sMtDo2kzkTC TWKI0syqXdcPMr7f0RqT0BeSkp1M2PQ6LfjJLoj9nnqm/Ap74HXtFKfIl0fs80a2cnKk hITw== X-Gm-Message-State: APjAAAUzeLzipDG7XjWMwTuLFWWvslBOGpRnZHQLBI4fmAJyPOLkN7Tb jTbl/xwlSq2eLiDa7gWcy87air8CMSw= X-Google-Smtp-Source: APXvYqx4H4sE/y5iGINvFwtgb+M0aoC+Ej9aY8Eos8fYhLzhc7CLSmjyZtwqAN5RxKdhhdT/3tHTPQ== X-Received: by 2002:a62:7f93:: with SMTP id a141mr30562612pfd.82.1574622441016; Sun, 24 Nov 2019 11:07:21 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:20 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 08/23] media: cadence: csi2rx: Fix fwnode media link creation Date: Sun, 24 Nov 2019 11:06:48 -0800 Message-Id: <20191124190703.12138-9-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org csi2rx_async_bound() passes the bound subdev's sd->fwnode to media_entity_get_fwnode_pad(). This is likely not an endpoint fwnode as required by media_entity_get_fwnode_pad(), for most subdevices it is the port parent of endpoint fwnode(s). This has only worked before because no entities have implemented the .get_fwnode_pad() op yet, and the default behavior of media_entity_get_fwnode_pad() was to ignore the passed fwnode and return the first pad that matches the given direction flags. Fix this by replacing the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: 1fc3b37f34f69 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver") Signed-off-by: Steve Longerbeam --- drivers/media/platform/cadence/cdns-csi2rx.c | 27 ++++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index be9ec59774d6..d79345820225 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -83,7 +83,6 @@ struct csi2rx_priv { /* Remote source */ struct v4l2_async_subdev asd; struct v4l2_subdev *source_subdev; - int source_pad; }; static inline @@ -251,26 +250,20 @@ static int csi2rx_async_bound(struct v4l2_async_notifier *notifier, { struct v4l2_subdev *subdev = notifier->sd; struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev); + int ret; - csi2rx->source_pad = media_entity_get_fwnode_pad(&s_subdev->entity, - s_subdev->fwnode, - MEDIA_PAD_FL_SOURCE); - if (csi2rx->source_pad < 0) { - dev_err(csi2rx->dev, "Couldn't find output pad for subdev %s\n", - s_subdev->name); - return csi2rx->source_pad; - } + ret = media_create_fwnode_pad_links(&csi2rx->subdev.entity.pads[0], + dev_fwnode(csi2rx->dev), + &s_subdev->entity, + dev_fwnode(s_subdev->dev), + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); + if (ret) + return ret; csi2rx->source_subdev = s_subdev; - dev_dbg(csi2rx->dev, "Bound %s pad: %d\n", s_subdev->name, - csi2rx->source_pad); - - return media_create_pad_link(&csi2rx->source_subdev->entity, - csi2rx->source_pad, - &csi2rx->subdev.entity, 0, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); + return 0; } static const struct v4l2_async_notifier_operations csi2rx_notifier_ops = { From patchwork Sun Nov 24 19:06:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259283 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 B486317EF for ; Sun, 24 Nov 2019 19:07:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A8242075E for ; Sun, 24 Nov 2019 19:07:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hHCjRYPb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727026AbfKXTHY (ORCPT ); Sun, 24 Nov 2019 14:07:24 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42499 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727016AbfKXTHX (ORCPT ); Sun, 24 Nov 2019 14:07:23 -0500 Received: by mail-pl1-f193.google.com with SMTP id j12so5423567plt.9 for ; Sun, 24 Nov 2019 11:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sRRyt6fc5LRoY7i647zUdzX7LInrVBsOqheBLaeBHkk=; b=hHCjRYPbtfMv79iVk9WV/D5EVAhwZOtOmYgxyscvnqd06aeTql4nM7ufCioB1HVLnW gPw6Jbc7sUR3iccJhzWOO9FaQgd1MBuvfwjE52uuL1eWXUcEWFbWeCmeNl8KqYMob9/p w77WV+yp3KbnsbFFsjreiSFedpfNJb6hkVnzUhgRGtNG0D4n7t2WKHgdZs+qDa52pzdd JuJgKwpof6m0yKusxafH0odkXK1c1LT31EXuS6nUSSD2VeHZ2KBvRoHxPRUKaChHa/44 DlC+bXeqVDElOeYEAa7Kb4+HSbiILM6HtgbYFOnFX8dVIQ61YJXlkm5SNjggABn6djId hp6w== 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=sRRyt6fc5LRoY7i647zUdzX7LInrVBsOqheBLaeBHkk=; b=hwVJkC0EDavRoBP5KU1xgiZPie6sGCeRKCRuOIdl/g61xbqJvqWs4KZ+679maqLfhA jIcj8BrvSXhb/t5NmAdBlO0q3ALWuh4tgdsvXiyiFwSgqskQT4L81rUYVLzNn45cunpu fqIZ0wEGHS0i0NmrV6JUGr8mKrhVm6xB0g3D3n81HdgWgCAoMjMmVna3GWuZtfyw6YJz dW2MO97Wac2b2vuPy3oE517nFuOgCYzo6DUNhn6N72EMPD/aEKuySwzLbrFha1h+sjHV bNsaskgqUJo9TEusFewNF37ssYMyInEDevxOkRzGIwmUNDuopfYL87V7kqsFB+oIGa5d BYFA== X-Gm-Message-State: APjAAAXsjDSqHk6LN7FZtQ0vhGRRS3xrudlwV1iYqlMammEY8cOIIeMC H92Zd3TrEPJ5UzIH0wORfBGBTYFRBtk= X-Google-Smtp-Source: APXvYqzbITRSkAAmspfJ5jYvcmr2++QY2ZLZvfvs8ByPiU/Q5Em2I+J7MQjbW+fGydkovuUfvB7aJg== X-Received: by 2002:a17:902:760b:: with SMTP id k11mr15152099pll.272.1574622442156; Sun, 24 Nov 2019 11:07:22 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:21 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 09/23] media: sun6i: Fix fwnode media link creation Date: Sun, 24 Nov 2019 11:06:49 -0800 Message-Id: <20191124190703.12138-10-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org sun6i_csi_link_entity() passes the bound subdev's sd->fwnode to media_entity_get_fwnode_pad(). This is likely not an endpoint fwnode as required by media_entity_get_fwnode_pad(), for most subdevices it is the port parent of endpoint fwnode(s). This has only worked before because no entities have implemented the .get_fwnode_pad() op yet, and the default behavior of media_entity_get_fwnode_pad() was to ignore the passed fwnode and return the first pad that matches the given direction flags. Fix this by replacing the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: 5cc7522d89655 ("media: sun6i: Add support for Allwinner CSI V3s") Signed-off-by: Steve Longerbeam --- .../platform/sunxi/sun6i-csi/sun6i_csi.c | 36 +++---------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index 055eb0b8e396..c6f51554ef67 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -630,37 +630,11 @@ static int sun6i_csi_link_entity(struct sun6i_csi *csi, struct media_entity *entity, struct fwnode_handle *fwnode) { - struct media_entity *sink; - struct media_pad *sink_pad; - int src_pad_index; - int ret; - - ret = media_entity_get_fwnode_pad(entity, fwnode, MEDIA_PAD_FL_SOURCE); - if (ret < 0) { - dev_err(csi->dev, "%s: no source pad in external entity %s\n", - __func__, entity->name); - return -EINVAL; - } - - src_pad_index = ret; - - sink = &csi->video.vdev.entity; - sink_pad = &csi->video.pad; - - dev_dbg(csi->dev, "creating %s:%u -> %s:%u link\n", - entity->name, src_pad_index, sink->name, sink_pad->index); - ret = media_create_pad_link(entity, src_pad_index, sink, - sink_pad->index, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); - if (ret < 0) { - dev_err(csi->dev, "failed to create %s:%u -> %s:%u link\n", - entity->name, src_pad_index, - sink->name, sink_pad->index); - return ret; - } - - return 0; + return media_create_fwnode_pad_links(&csi->video.pad, + dev_fwnode(csi->dev), + entity, fwnode, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); } static int sun6i_subdev_notify_complete(struct v4l2_async_notifier *notifier) From patchwork Sun Nov 24 19:06:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259285 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 16C5914E5 for ; Sun, 24 Nov 2019 19:07:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF41020830 for ; Sun, 24 Nov 2019 19:07:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XQ3l0hYb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727029AbfKXTHY (ORCPT ); Sun, 24 Nov 2019 14:07:24 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37200 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbfKXTHY (ORCPT ); Sun, 24 Nov 2019 14:07:24 -0500 Received: by mail-pg1-f196.google.com with SMTP id b10so5941337pgd.4 for ; Sun, 24 Nov 2019 11:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5ZpPo4clcR+upeFZkPjixFe7+7EzxZsDajulwhkI/xc=; b=XQ3l0hYba8b79t+2nLw6jXYVGFbCYC2hNugvlMy20V7SJ5QnDrSx4LXsjgsIFYrhTP 1n1Fvh2Cn37rL/fG6GC4PVOmk0mg4yTn6x8p8ahoPSzd+jLpaDDiYy8bH07eh3lsNgIB 7XZRq/LL9SSVtG2mskPmuVBoEUPAUXid/eH2oar+I/47vO/Nc4BrQg5dun11ZT1ITVR6 2XQczWHlE4G3B69p3qSUBOgEf6nFbBxTdZN/Y6VwAAeX5f+9RWnglOiBYCBddNB/r/fh 1kGhgDZybL5kGBsRQjimpjMuGtGNs6xSrhukmX7F5HSK3ExnX5edRYQiHHG6XISHVj65 e4RQ== 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=5ZpPo4clcR+upeFZkPjixFe7+7EzxZsDajulwhkI/xc=; b=oHFMIfd2kjmxl5ga/m3v8j+AQM3z7AHZ51gm261mlfa9h46gAmizurr901tvfnmpOL HlDH0NKcW7BnvYjSo0ekvJCRiaoE1DRUV8ebn/sojUdBjfjr7rdyoIGODpc+9Txh2cow MX3/I3/rE8/KTcB01iYgO5q7aT3Oub8gPV9CKHIVlmSh+obd7JKl6VqJaeinFAC8RhW1 wVBsLR55gpi12rEwfN5R4iuT8V40GYmtDTyoFtRFw9Mf0MBoc67wymbpcvqzklBHvbai Hoz2qnP+rkhasbMdHfpUWSF4LtsUIwBB5I85/R0bRoabiiBGC+bBpvrdDBVHX2NVI49G Dnsw== X-Gm-Message-State: APjAAAVnKAE4fomrqYUpD5NUYmDGAH6WVcbsSGVNdHj56Jezo1Bqz6g+ 7zpy+xBRwSzunCq/uxOrowKsyYnxX4s= X-Google-Smtp-Source: APXvYqxxW8m5mIxRqvf/SQOTUWAM8Pf7R+3mfxN+2ZgVfXFY9usW+e3ozt8k9gJDmrfYoRM1cHrqwg== X-Received: by 2002:a63:e4a:: with SMTP id 10mr25910143pgo.121.1574622442910; Sun, 24 Nov 2019 11:07:22 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:22 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 10/23] media: st-mipid02: Fix fwnode media link creation Date: Sun, 24 Nov 2019 11:06:50 -0800 Message-Id: <20191124190703.12138-11-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org mipid02_async_bound() passes the bound subdev's sd->fwnode to media_entity_get_fwnode_pad(). This is likely not an endpoint fwnode as required by media_entity_get_fwnode_pad(), for most subdevices it is the port parent of endpoint fwnode(s). This has only worked before because no entities have implemented the .get_fwnode_pad() op yet, and the default behavior of media_entity_get_fwnode_pad() was to ignore the passed fwnode and return the first pad that matches the given direction flags. Fix this by replacing the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: 642bb5e88fed8 ("media: st-mipid02: MIPID02 CSI-2 to PARALLEL bridge driver") Signed-off-by: Steve Longerbeam --- drivers/media/i2c/st-mipid02.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c index 003ba22334cd..bd487082d677 100644 --- a/drivers/media/i2c/st-mipid02.c +++ b/drivers/media/i2c/st-mipid02.c @@ -798,24 +798,16 @@ static int mipid02_async_bound(struct v4l2_async_notifier *notifier, { struct mipid02_dev *bridge = to_mipid02_dev(notifier->sd); struct i2c_client *client = bridge->i2c_client; - int source_pad; int ret; dev_dbg(&client->dev, "sensor_async_bound call %p", s_subdev); - source_pad = media_entity_get_fwnode_pad(&s_subdev->entity, - s_subdev->fwnode, - MEDIA_PAD_FL_SOURCE); - if (source_pad < 0) { - dev_err(&client->dev, "Couldn't find output pad for subdev %s\n", - s_subdev->name); - return source_pad; - } - - ret = media_create_pad_link(&s_subdev->entity, source_pad, - &bridge->sd.entity, 0, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); + ret = media_create_fwnode_pad_links(&bridge->sd.entity.pads[0], + dev_fwnode(&client->dev), + &s_subdev->entity, + dev_fwnode(s_subdev->dev), + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); if (ret) { dev_err(&client->dev, "Couldn't create media link %d", ret); return ret; From patchwork Sun Nov 24 19:06:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259287 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 CFE50913 for ; Sun, 24 Nov 2019 19:07:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD19C2075E for ; Sun, 24 Nov 2019 19:07:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QxeagG8e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbfKXTHZ (ORCPT ); Sun, 24 Nov 2019 14:07:25 -0500 Received: from mail-pf1-f171.google.com ([209.85.210.171]:33329 "EHLO mail-pf1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727016AbfKXTHY (ORCPT ); Sun, 24 Nov 2019 14:07:24 -0500 Received: by mail-pf1-f171.google.com with SMTP id c184so6167580pfb.0 for ; Sun, 24 Nov 2019 11:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d6CoAtic4/E6VgKaXDd72737mg84I8iU+YKVh93R/0c=; b=QxeagG8eIBcsO5X+bbY/WaHen60GSSR3CjODAGw2V2ZSy7cPHYDwX3eQkVmtYCcU9g KTVPJptMLp57koow6dTUYgytTn66OCJ/bHTyWcVIgNT89lEOoYbHJ3judulrZ8kCPeI6 kh3hzEA5zn9irT8V0mr54aL1Z66E+g8NYg6HrjoBKlF/+Ignm+1qVJmItr2PPTiS+oh8 UkDs/CAwATl9NgFiKuWwMvvwuuzcPeoMG0zubgshUZyUuyYL4NhrcxO6xcGEKfO9C1Bp hMStHjnaAo82JxlGdcrPVCN+3pv+Qc7y2q6LfUZviMxlqC1w0drhtBE5gp+RwM6sHVxc m/tA== 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=d6CoAtic4/E6VgKaXDd72737mg84I8iU+YKVh93R/0c=; b=Lo/LkST9hfnmBD+zJPk84taMUbZrNVOBQN9bCllvCrFHyMw5QZ9VmoBsIjSMMtb9rx D/ov0EsFNjMBXcIdSpbv59XxU02zcwr00hHBEn4x7GGfWkACirVBRL8YmR8nOZrnqVoT Z0TiISM0tkFFNE3m0HTul7nGVLhwoLYAJjcFjPfJH4MgrAZAx0QUf5pPrGMnhDmAcQ5d JhpiXR++DPBC/v6Vgu2C4gNLbQ8yKHFTV8omz9KLHnrHHkyxx81g4G3Lf+G8gNX4rJBa My6P8UON0d8nBoZK1Sd8eDVJqRR3ZH8IXdrjhx6VKV0kl16jiyhpXpkaNlY0ULeTaRqA YT4w== X-Gm-Message-State: APjAAAV1T2uoS9f6yyPeiQ1gzUW3uAmK7uT95/bIP/VT1nF9sHLFRmfa lk4tOmFnsj4dHhc67pru6b6VFiXeMzo= X-Google-Smtp-Source: APXvYqxuAh73gMzDA5ve+GjMlHwoUUFt2aWSZVsgjPaCCrheyN4lvZVsiFhn1qUlK/OCXSloXVOQNg== X-Received: by 2002:a62:ce41:: with SMTP id y62mr30350806pfg.34.1574622443847; Sun, 24 Nov 2019 11:07:23 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:23 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 11/23] media: stm32-dcmi: Fix fwnode media link creation Date: Sun, 24 Nov 2019 11:06:51 -0800 Message-Id: <20191124190703.12138-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org dcmi_graph_notify_bound() passes the bound subdev's sd->fwnode to media_entity_get_fwnode_pad(). This is likely not an endpoint fwnode as required by media_entity_get_fwnode_pad(), for most subdevices it is the port parent of endpoint fwnode(s). This has only worked before because no entities have implemented the .get_fwnode_pad() op yet, and the default behavior of media_entity_get_fwnode_pad() was to ignore the passed fwnode and return the first pad that matches the given direction flags. Fix this by replacing the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: f4378baf07a2 ("media: stm32-dcmi: add support of several sub-devices") Signed-off-by: Steve Longerbeam --- drivers/media/platform/stm32/stm32-dcmi.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index 9392e3409fba..bfb7794c43a1 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -1743,7 +1743,6 @@ static int dcmi_graph_notify_bound(struct v4l2_async_notifier *notifier, { struct stm32_dcmi *dcmi = notifier_to_dcmi(notifier); unsigned int ret; - int src_pad; dev_dbg(dcmi->dev, "Subdev \"%s\" bound\n", subdev->name); @@ -1751,14 +1750,12 @@ static int dcmi_graph_notify_bound(struct v4l2_async_notifier *notifier, * Link this sub-device to DCMI, it could be * a parallel camera sensor or a bridge */ - src_pad = media_entity_get_fwnode_pad(&subdev->entity, - subdev->fwnode, - MEDIA_PAD_FL_SOURCE); - - ret = media_create_pad_link(&subdev->entity, src_pad, - &dcmi->vdev->entity, 0, - MEDIA_LNK_FL_IMMUTABLE | - MEDIA_LNK_FL_ENABLED); + ret = media_create_fwnode_pad_links(&dcmi->vdev->entity.pads[0], + dev_fwnode(dcmi->dev), + &subdev->entity, + dev_fwnode(subdev->dev), + MEDIA_LNK_FL_IMMUTABLE | + MEDIA_LNK_FL_ENABLED); if (ret) dev_err(dcmi->dev, "Failed to create media pad link with subdev \"%s\"\n", subdev->name); From patchwork Sun Nov 24 19:06:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259289 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 894FD913 for ; Sun, 24 Nov 2019 19:07:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67A682075E for ; Sun, 24 Nov 2019 19:07:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R0vk/BHG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727047AbfKXTH0 (ORCPT ); Sun, 24 Nov 2019 14:07:26 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40991 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727031AbfKXTHZ (ORCPT ); Sun, 24 Nov 2019 14:07:25 -0500 Received: by mail-pf1-f195.google.com with SMTP id p26so6137768pfq.8 for ; Sun, 24 Nov 2019 11:07:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=M6vbKNlAe4oVXAzBpbMwq3/kIC7rorbSwG5kJs/7+zs=; b=R0vk/BHG/ZhjQHcVV53A70DNGDLblSriO8nUY1ykttAClZYQny54zY9F0oWQ9ywUtc gjSR9xZyl6ir5eNy35Myjfpe0aErhF5b/vrQ+PTnss9B7M00+ZiZsrX3pczzuqRC7i6i 7xYEmUIMJWXU3cXJf7d2oPBaW9ccR6aeu8UUFsKiXTTQNtmey1BtS7ZOmClvLqVXSneD E8amFWaA9bucnb8OSlmxwL19Rj1kWzo98N2sFyrh3rWM9VEliXrCoMJqUQQuGp8bk650 /cie1Jq1srOyxTVT+mSzwXuOF0l6niWpsRvPIRPifU/6EQv82TREsZJDrbqTp5dOi8jU eupA== 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=M6vbKNlAe4oVXAzBpbMwq3/kIC7rorbSwG5kJs/7+zs=; b=R1BLkVDpvmvAGJr4IJZL/LrKUyV9OMbekmBGCNG0jVY1WXAlStquq5x+esRq6YDumU nzEVHwdrlwwz4AkDdxegNu+Hd5gmVQt6KScUYrq10KT2YGuwnwODYfQhcGBHTymaGrXr ADsXTaA+z0bGeT1m/HB7FOJUftVQMoEI6ufcOHe22ukTXjsBidTd+B1YhCCdLHg51rIr a5Dd3qwTWuiFqZBORObcoSKr8YAkAogTUbV1RdHaDrteJLoitjoEPJQOy0jvdGQVILmv T8QClxwZyMMsE+xLbKi9Oy3Shwxx3iDeSiU57abZJlIQ8qDq7933zSAwHeeCWPwBWJ8J yXdw== X-Gm-Message-State: APjAAAVFQlJf9azAqkp0O9LgJMnm1Q1VSjYkDYs9gLNtexDQ2xKRw+1T c/H5qS2HErjGShmdTH1x8TjA5+bpTZg= X-Google-Smtp-Source: APXvYqz/o3Dh45ONDaf4iHpn7yOdVxKTnVylZYyk8nPT7F/52mr5NxPG9EgX2DPHls7DRgtLF+yGjA== X-Received: by 2002:a63:fa0e:: with SMTP id y14mr27463991pgh.174.1574622444689; Sun, 24 Nov 2019 11:07:24 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:24 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 12/23] media: sunxi: Fix fwnode media link creation Date: Sun, 24 Nov 2019 11:06:52 -0800 Message-Id: <20191124190703.12138-13-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org sun4i_csi_notify_bound() passes the bound subdev's sd->fwnode to media_entity_get_fwnode_pad(). This is likely not an endpoint fwnode as required by media_entity_get_fwnode_pad(), for most subdevices it is the port parent of endpoint fwnode(s). This has only worked before because no entities have implemented the .get_fwnode_pad() op yet, and the default behavior of media_entity_get_fwnode_pad() was to ignore the passed fwnode and return the first pad that matches the given direction flags. Fix this by replacing the calls to media_entity_get_fwnode_pad() and media_create_pad_link() with a call to media_create_fwnode_pad_links(). Fixes: 577bbf23b758 ("media: sunxi: Add A10 CSI driver") Signed-off-by: Steve Longerbeam --- .../platform/sunxi/sun4i-csi/sun4i_csi.c | 27 ++++++++----------- .../platform/sunxi/sun4i-csi/sun4i_csi.h | 1 - 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c index f36dc6258900..0f117d41a19b 100644 --- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c +++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c @@ -38,19 +38,21 @@ static int sun4i_csi_notify_bound(struct v4l2_async_notifier *notifier, { struct sun4i_csi *csi = container_of(notifier, struct sun4i_csi, notifier); + struct media_pad *sink = &csi->subdev.entity.pads[CSI_SUBDEV_SINK]; + int ret; csi->src_subdev = subdev; - csi->src_pad = media_entity_get_fwnode_pad(&subdev->entity, - subdev->fwnode, - MEDIA_PAD_FL_SOURCE); - if (csi->src_pad < 0) { - dev_err(csi->dev, "Couldn't find output pad for subdev %s\n", + + ret = media_create_fwnode_pad_links(sink, dev_fwnode(csi->dev), + &subdev->entity, + dev_fwnode(subdev->dev), + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); + if (ret) + dev_err(csi->dev, "Couldn't create media links to subdev %s\n", subdev->name); - return csi->src_pad; - } - dev_dbg(csi->dev, "Bound %s pad: %d\n", subdev->name, csi->src_pad); - return 0; + return ret; } static int sun4i_csi_notify_complete(struct v4l2_async_notifier *notifier) @@ -81,13 +83,6 @@ static int sun4i_csi_notify_complete(struct v4l2_async_notifier *notifier) if (ret) goto err_clean_media; - ret = media_create_pad_link(&csi->src_subdev->entity, csi->src_pad, - &subdev->entity, CSI_SUBDEV_SINK, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); - if (ret) - goto err_clean_media; - ret = v4l2_device_register_subdev_nodes(&csi->v4l); if (ret < 0) goto err_clean_media; diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h index 001c8bde006c..1d403f9cef1a 100644 --- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h +++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.h @@ -140,7 +140,6 @@ struct sun4i_csi { struct v4l2_async_subdev asd; struct v4l2_async_notifier notifier; struct v4l2_subdev *src_subdev; - int src_pad; /* V4L2 variables */ struct mutex lock; From patchwork Sun Nov 24 19:06:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259291 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 19852913 for ; Sun, 24 Nov 2019 19:07:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2EA420823 for ; Sun, 24 Nov 2019 19:07:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bPcHZ6KN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727051AbfKXTH2 (ORCPT ); Sun, 24 Nov 2019 14:07:28 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46206 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbfKXTH0 (ORCPT ); Sun, 24 Nov 2019 14:07:26 -0500 Received: by mail-pg1-f194.google.com with SMTP id r18so5909923pgu.13 for ; Sun, 24 Nov 2019 11:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ttEfZsY6dic0+OiNMThzYQrbSNb+Yy78L0Oc8DJv0uY=; b=bPcHZ6KNjAJglZr+/RWPxdQod7grx5/2VvfXkbJa1y066M05KSSWGJpKBxIn925wyw nnoj9gYIMHDfqnSR22bC0QxrorJ7q2TPV9WFL0eZWYUy2jqdM/2qqv8wEI3D3ryvEuxn vzYuxDWVupSpKSdB4QYoxE9++CIfa56Vs10A8/HTAx5rlnyhBOrRXsPmQyh9rHNTO7in XTfOuW2Ua0uj9OOYLUkvEcd3fhgnXF01PfWnddiux8DdM+BUFFyaBuLM6iKWasqCqzZ5 uPY6MSJRE9wLcC7QQKQq8lCltXsEbuQgnKUUlQj9JmEip5iCxE10Ev0ws0j/Ma6Lq01v Qihg== 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=ttEfZsY6dic0+OiNMThzYQrbSNb+Yy78L0Oc8DJv0uY=; b=cjmpjJkaDWhYQLIqGn7CogN2lG1QM38M7UuouePa9Mt9DYZivtvpgkNstJ8BlF/zSQ ZGT62HpKi03D/v5HHzGhaXj8njUiUc78ODOb3pyaNbS5SvsgDUNa2sQHS6TFyAp+9QxH XO59jR5hy1RWhlml1QizLWHHyRiKxktSqbMccFBTQdJuWUGYFzLlm3EGyEi1g9YlmZm2 nNiR5gNUFqFGZCCpmRmLT814O+g8KO9hNBglLlTs9lPTWm4syrU178VJSTMqrf6ZmYxQ h++kcvPW+wLFqNhmhvl0aq/ffrzbkfogIM/M4ePU5yT/fP2n3Lx8jPd6JUHWANUseUUn WZlQ== X-Gm-Message-State: APjAAAXOerDRMnfiUxXb3HwiGcd1n1s156GH546YfwkwJRh/5Gbm1PMq x0QKFAAN3aEIkwDjYvhsYyjS7/sP4CM= X-Google-Smtp-Source: APXvYqw5bvOuQMHNLc1DGScsuUHOEf4JqodR8M51Z1FgAk9KLiwgNe3946RpJqXBd7lm14K5y15OWA== X-Received: by 2002:aa7:9314:: with SMTP id 20mr29625167pfj.231.1574622445605; Sun, 24 Nov 2019 11:07:25 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:25 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 13/23] media: v4l2-fwnode: Pass notifier to v4l2_async_register_fwnode_subdev() Date: Sun, 24 Nov 2019 11:06:53 -0800 Message-Id: <20191124190703.12138-14-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Instead of allocating a notifier in v4l2_async_register_fwnode_subdev(), have the caller provide one. This allows the caller to implement notifier ops (bind, unbind). The caller is now responsible for first initializing its notifier with a call to v4l2_async_notifier_init(). Signed-off-by: Steve Longerbeam --- drivers/media/platform/video-mux.c | 6 +++++- drivers/media/v4l2-core/v4l2-fwnode.c | 11 +---------- drivers/staging/media/imx/imx6-mipi-csi2.c | 5 ++++- drivers/staging/media/imx/imx7-media-csi.c | 5 ++++- drivers/staging/media/imx/imx7-mipi-csis.c | 5 ++++- include/media/v4l2-fwnode.h | 12 ++++++++---- 6 files changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index ddd0e338f9e4..ca1cef783646 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -21,6 +21,7 @@ struct video_mux { struct v4l2_subdev subdev; + struct v4l2_async_notifier notifier; struct media_pad *pads; struct v4l2_mbus_framefmt *format_mbus; struct mux_control *mux; @@ -354,8 +355,11 @@ static int video_mux_async_register(struct video_mux *vmux, for (i = 0; i < num_input_pads; i++) ports[i] = i; + v4l2_async_notifier_init(&vmux->notifier); + ret = v4l2_async_register_fwnode_subdev( - &vmux->subdev, sizeof(struct v4l2_async_subdev), + &vmux->subdev, &vmux->notifier, + sizeof(struct v4l2_async_subdev), ports, num_input_pads, video_mux_parse_endpoint); kfree(ports); diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index f43f563f9e98..d2f134caa0cf 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -1125,12 +1125,12 @@ int v4l2_async_register_subdev_sensor_common(struct v4l2_subdev *sd) EXPORT_SYMBOL_GPL(v4l2_async_register_subdev_sensor_common); int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, + struct v4l2_async_notifier *notifier, size_t asd_struct_size, unsigned int *ports, unsigned int num_ports, parse_endpoint_func parse_endpoint) { - struct v4l2_async_notifier *notifier; struct device *dev = sd->dev; struct fwnode_handle *fwnode; int ret; @@ -1142,12 +1142,6 @@ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, if (!fwnode_device_is_available(fwnode)) return -ENODEV; - notifier = kzalloc(sizeof(*notifier), GFP_KERNEL); - if (!notifier) - return -ENOMEM; - - v4l2_async_notifier_init(notifier); - if (!ports) { ret = v4l2_async_notifier_parse_fwnode_endpoints(dev, notifier, asd_struct_size, @@ -1172,15 +1166,12 @@ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, if (ret < 0) goto out_unregister; - sd->subdev_notifier = notifier; - return 0; out_unregister: v4l2_async_notifier_unregister(notifier); out_cleanup: v4l2_async_notifier_cleanup(notifier); - kfree(notifier); return ret; } diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index cd3dd6e33ef0..06ed4057b426 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -35,6 +35,7 @@ struct csi2_dev { struct device *dev; struct v4l2_subdev sd; + struct v4l2_async_notifier notifier; struct media_pad pad[CSI2_NUM_PADS]; struct clk *dphy_clk; struct clk *pllref_clk; @@ -636,8 +637,10 @@ static int csi2_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &csi2->sd); + v4l2_async_notifier_init(&csi2->notifier); + ret = v4l2_async_register_fwnode_subdev( - &csi2->sd, sizeof(struct v4l2_async_subdev), + &csi2->sd, &csi2->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, csi2_parse_endpoint); if (ret) goto dphy_off; diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index db30e2c70f2f..15b08bfb5aa7 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -155,6 +155,7 @@ struct imx7_csi { struct device *dev; struct v4l2_subdev sd; + struct v4l2_async_notifier notifier; struct imx_media_video_dev *vdev; struct imx_media_dev *imxmd; struct media_pad pad[IMX7_CSI_PADS_NUM]; @@ -1266,7 +1267,9 @@ static int imx7_csi_probe(struct platform_device *pdev) if (ret < 0) goto free; - ret = v4l2_async_register_fwnode_subdev(&csi->sd, + v4l2_async_notifier_init(&csi->notifier); + + ret = v4l2_async_register_fwnode_subdev(&csi->sd, &csi->notifier, sizeof(struct v4l2_async_subdev), NULL, 0, imx7_csi_parse_endpoint); diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index 99166afca071..bbbc4d55fa9e 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -223,6 +223,7 @@ struct csi_state { struct device *dev; struct media_pad pads[CSIS_PADS_NUM]; struct v4l2_subdev mipi_sd; + struct v4l2_async_notifier notifier; struct v4l2_subdev *src_sd; u8 index; @@ -885,7 +886,9 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, if (ret) return ret; - ret = v4l2_async_register_fwnode_subdev(mipi_sd, + v4l2_async_notifier_init(&state->notifier); + + ret = v4l2_async_register_fwnode_subdev(mipi_sd, &state->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, mipi_csis_parse_endpoint); diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index f81f8bf34526..27a7b78149c2 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -331,6 +331,7 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, * and parses fwnode endpoints * * @sd: pointer to struct &v4l2_subdev + * @notifier: the sub-device's notifier. * @asd_struct_size: size of the driver's async sub-device struct, including * sizeof(struct v4l2_async_subdev). The &struct * v4l2_async_subdev shall be the first member of @@ -343,13 +344,15 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, * endpoint. Optional. * * This function is just like v4l2_async_register_subdev() with the - * exception that calling it will also allocate a notifier for the - * sub-device, parse the sub-device's firmware node endpoints using - * v4l2_async_notifier_parse_fwnode_endpoints() or + * exception that calling it will also parse the sub-device's firmware + * node endpoints using v4l2_async_notifier_parse_fwnode_endpoints() or * v4l2_async_notifier_parse_fwnode_endpoints_by_port(), and - * registers the sub-device notifier. The sub-device is similarly + * registers the sub-device's notifier. The sub-device is similarly * unregistered by calling v4l2_async_unregister_subdev(). * + * The caller must first initialize the notifier with a call to + * v4l2_async_notifier_init(). + * * While registered, the subdev module is marked as in-use. * * An error is returned if the module is no longer loaded on any attempts @@ -357,6 +360,7 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, */ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, + struct v4l2_async_notifier *notifier, size_t asd_struct_size, unsigned int *ports, unsigned int num_ports, From patchwork Sun Nov 24 19:06:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259293 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 9B99F1390 for ; Sun, 24 Nov 2019 19:07:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78B7620823 for ; Sun, 24 Nov 2019 19:07:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Dofu17Lz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbfKXTH2 (ORCPT ); Sun, 24 Nov 2019 14:07:28 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:43987 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727031AbfKXTH1 (ORCPT ); Sun, 24 Nov 2019 14:07:27 -0500 Received: by mail-pj1-f68.google.com with SMTP id a10so5412260pju.10 for ; Sun, 24 Nov 2019 11:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y+3BTNqSaca7NC83BwvFX9hsocsd054ub84DKx6q1XE=; b=Dofu17LzGuSXiaHHruDlmYUGjrDSnY9WRhZSKfz2itAURgVQn16MkDQjhM2gxKGQQg 254OvPZTk3uKwsPNEB0cfE4aQE7aBbIwnNRmtOcuxmmz1wSsWkbramjbYLTfsNLFW+OE jjRbTcmGaupEDoOhs78njdUw6N18EsvowKuj9c1rbyq3ytgfuGcyU7q0mV0bHdMg28XQ zZM3bHVSMCo1QcIdrkWFdnanKc8EwLdZceyQbXt7BwQrJT/Hy3WrsW51DNt3QyqpWBuU E++kyLa2y8VLO5HIsYGjTkKMTpgBOAkLVCy4EW6HMnrqC/8ensG9XEBdzzQBIEMEmrX+ Xugg== 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=y+3BTNqSaca7NC83BwvFX9hsocsd054ub84DKx6q1XE=; b=RcWjI0z6AncOzw9l7Fk3xSwlgdDuijc8zbkzFQgDbhNcWD3iuz/p8EhlfFV7LHBQHl r/J1ldlkxixOaCcBenCPRZNcqDqlt6rtz2VZqUe8ZKtvyDZJZ2WjI75c1nUjx/fua+l5 KhFmMiG6wod4JWCB9K1qJhG/GpX7IHN46milzQRkfAPrtALnVCY/jRon1y51midaG6xv hMS5hfXtMzS85vwvJ7gc9pb98cI25/tIgA5/0UH8t/hn3tTITBF5rpcBbW0vKMLY7kcu eFa/NBYcMfoIeOurFcdWKNNyddORICopxLUhTpAuAE1KTmtUTm8IU4W+wk16xpPZXY5r 1fJQ== X-Gm-Message-State: APjAAAVlT6zwQI48zNWs4ABcj3DywxNTbUvZ6m1YSuLJW3+s77IbWbyf n+VrLLt40rz+ouax8ZldWXqVyl9Rsqo= X-Google-Smtp-Source: APXvYqxc9kfZR4O98X1U/sM6uQlAWgs4j8WLOAIRutZq3gVZygIoahnr4QdxFHcFK0N3Ae7S+YMEvw== X-Received: by 2002:a17:90a:7188:: with SMTP id i8mr32788304pjk.6.1574622446562; Sun, 24 Nov 2019 11:07:26 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:25 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 14/23] media: video-mux: Create media links in bound notifier Date: Sun, 24 Nov 2019 11:06:54 -0800 Message-Id: <20191124190703.12138-15-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-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 pads to all of the video-mux sink pads. Signed-off-by: Steve Longerbeam --- drivers/media/platform/video-mux.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c index ca1cef783646..de5b0698fc1d 100644 --- a/drivers/media/platform/video-mux.c +++ b/drivers/media/platform/video-mux.c @@ -36,6 +36,12 @@ static const struct v4l2_mbus_framefmt video_mux_format_mbus_default = { .field = V4L2_FIELD_NONE, }; +static inline struct video_mux * +notifier_to_video_mux(struct v4l2_async_notifier *n) +{ + return container_of(n, struct video_mux, notifier); +} + static inline struct video_mux *v4l2_subdev_to_video_mux(struct v4l2_subdev *sd) { return container_of(sd, struct video_mux, subdev); @@ -343,6 +349,22 @@ static int video_mux_parse_endpoint(struct device *dev, return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN; } +static int video_mux_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct video_mux *vmux = notifier_to_video_mux(notifier); + + return media_create_fwnode_links(&vmux->subdev.entity, + dev_fwnode(vmux->subdev.dev), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +static const struct v4l2_async_notifier_operations video_mux_notify_ops = { + .bound = video_mux_notify_bound, +}; + static int video_mux_async_register(struct video_mux *vmux, unsigned int num_input_pads) { @@ -357,6 +379,8 @@ static int video_mux_async_register(struct video_mux *vmux, v4l2_async_notifier_init(&vmux->notifier); + vmux->notifier.ops = &video_mux_notify_ops; + ret = v4l2_async_register_fwnode_subdev( &vmux->subdev, &vmux->notifier, sizeof(struct v4l2_async_subdev), From patchwork Sun Nov 24 19:06:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259295 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 CD4EE913 for ; Sun, 24 Nov 2019 19:07:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ACFFF2080D for ; Sun, 24 Nov 2019 19:07:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VnVtZALE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbfKXTHb (ORCPT ); Sun, 24 Nov 2019 14:07:31 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35641 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727060AbfKXTHa (ORCPT ); Sun, 24 Nov 2019 14:07:30 -0500 Received: by mail-pg1-f194.google.com with SMTP id k32so5947031pgl.2 for ; Sun, 24 Nov 2019 11:07:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GZ+ndbbNSOuinmxZ+Pqw9olU2lkbVgSJQGTQgul1b80=; b=VnVtZALE4HwaKYx96+9w6/bbHDsONBZds5JD8JaIpGoRG+XhxkKHX5MxFbtlh284KM 97BVLGnPD1ym39j1+TobGya26OdvkGKK254ZZSeozgt4/vc7LRVu/XoeHDnzEj4sEV6l b9ZiIg8IGBShhGnJcUHnPqJuc5+8wZLxKB+4GZd6Kyyq2eaHcd0qcEano31D1cfeEwd1 g/nCTVM+NDAi23MonDynukbJ0vH1PAqosGnqrhuuoufBs4q59T4HEGf7f71hCypOCIvl ytMGPrAUtd0XuBbyX4m9bJaEgjlyTfn7G7poW4MmsxaneCe8ZKEWy96e/Z6q2EVSDe9+ MsdA== 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=GZ+ndbbNSOuinmxZ+Pqw9olU2lkbVgSJQGTQgul1b80=; b=nR7agxiysZFCgXfLSW09LFOGwpkTJoElEd7mxN6xeSxof0VsQ85I6p97aFv/dDbCZu sz3tSt8YbpJEDwwa3capTJ/YxwXo6Pr9WK640h2mgm3EjuEkAEVCuoboI5kG/PDhufO3 lS1z6DTOQpuS+bTF16Cxu3P6NdbhEwYJHS8EffPmI9EqWBw5YUVSN7z9pAFaIbS9aany 3jTl5qUodUQFBC+XluDhMR7V03EmobaACT/yHAVEIJAsShXpjwNqbC8lu/p/v6pd2iVF lte2RftdQ49/gdnLAY+aHyNac1m024DOaS39xVHPdhGG1Lv0f56TK1rXdGxUCqyoHd74 cbGg== X-Gm-Message-State: APjAAAXa6a7hR69JpfHEVHLbTwL8z11xh+ZzqqBO8P9dVqTkcgiNrYf0 eSN/4wpwF1DxfSiunyo/yOwGu8LRixI= X-Google-Smtp-Source: APXvYqw53MiqXmBr9MA+coO3twXtIiu7UUoFj6kJHq/EqzUHzieK1drPDPr02P2yzrqc0RuT3aks5A== X-Received: by 2002:a63:1e16:: with SMTP id e22mr8387794pge.87.1574622447599; Sun, 24 Nov 2019 11:07:27 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:26 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 15/23] media: imx: mipi csi-2: Create media links in bound notifier Date: Sun, 24 Nov 2019 11:06:55 -0800 Message-Id: <20191124190703.12138-16-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-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 --- drivers/staging/media/imx/imx6-mipi-csi2.c | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c b/drivers/staging/media/imx/imx6-mipi-csi2.c index 06ed4057b426..19275a310033 100644 --- a/drivers/staging/media/imx/imx6-mipi-csi2.c +++ b/drivers/staging/media/imx/imx6-mipi-csi2.c @@ -91,6 +91,11 @@ static inline struct csi2_dev *sd_to_dev(struct v4l2_subdev *sdev) return container_of(sdev, struct csi2_dev, sd); } +static inline struct csi2_dev *notifier_to_dev(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi2_dev, notifier); +} + /* * The required sequence of MIPI CSI-2 startup as specified in the i.MX6 * reference manual is as follows: @@ -556,6 +561,23 @@ static int csi2_parse_endpoint(struct device *dev, return 0; } +static int csi2_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi2_dev *csi2 = notifier_to_dev(notifier); + struct media_pad *sink = &csi2->sd.entity.pads[CSI2_SINK_PAD]; + + return media_create_fwnode_pad_links(sink, + dev_fwnode(csi2->dev), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +static const struct v4l2_async_notifier_operations csi2_notify_ops = { + .bound = csi2_notify_bound, +}; + static int csi2_probe(struct platform_device *pdev) { unsigned int sink_port = 0; @@ -639,6 +661,8 @@ static int csi2_probe(struct platform_device *pdev) v4l2_async_notifier_init(&csi2->notifier); + csi2->notifier.ops = &csi2_notify_ops; + ret = v4l2_async_register_fwnode_subdev( &csi2->sd, &csi2->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, csi2_parse_endpoint); From patchwork Sun Nov 24 19:06:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259297 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 990C4913 for ; Sun, 24 Nov 2019 19:07:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78EE020823 for ; Sun, 24 Nov 2019 19:07:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Gyu9En7H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbfKXTHb (ORCPT ); Sun, 24 Nov 2019 14:07:31 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:40215 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727059AbfKXTHa (ORCPT ); Sun, 24 Nov 2019 14:07:30 -0500 Received: by mail-pj1-f67.google.com with SMTP id ep1so5422237pjb.7 for ; Sun, 24 Nov 2019 11:07:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qKzW5+s6KI4myxqad8J3Vr1gc4mjcMaiSiZAkdUBak0=; b=Gyu9En7H9SL54wFBU9+u6daVm7zL4pX493gkvapEwNBvBKb8TBPDNup50udV/PKtdX dZi1OR4mgweOknwFKVYa1EGoeGDu481GM6jm9ljqHxZFJ1ByTGK6mUeWV6L5qDZ7IRLM v+z8zBv7/63RUFEe9M57wPzkG6sPgWxdco0i9mNpSZpW8r+7Ij93jQw9Dzrrm5ONLC58 w4NwrxB+qMXLa4KobuDox7buNWc6I7bBtTzPweElGco1G1SxSLZD4bl63FbaKhLxjDGv ycWJFLL/p8DlOXEUEoUUQRb8pmVoOYBqfdCtrBpds0VZXswfIJ7Ye29eLtt3g1GnZbcj fgSA== 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=qKzW5+s6KI4myxqad8J3Vr1gc4mjcMaiSiZAkdUBak0=; b=EeoTO3Uy9r1X2NqZ7ywyCrYFfBb7J4CCSLJvb8SrSXgd8YJ5fHybXxWsx62i9Q/4zQ xtgeDc03X3pKLQ7ZUurqRKox5sJlCuyCcZx+gA2DQuZULB514o2n/W8Yb8Us5wzr8lEi gMJJuPlnVT/CBlUncweW6U0II0lAhHB1gczflBNHbpgyCy9Dt/atxIffAUOZRvs8c9PI Jr0Qqw9jZxT+p/LL9VBtDmMy/XB03PMltRAttmGzIxqrwwd653rWy+iXaGvwxMQ+Nw4U Da5hSOiz1nmUZbzs3O/rNzFeK6i5+Av1ArlM7dLFzHHZ2cVmwkiNX1nqCLQtsy084X6Q 0exA== X-Gm-Message-State: APjAAAWNQxLyAeMjqkrA1x4Rkpbf0jzMWK7slzdRfNEYnXQJYLP7ZWTH nx7BmidYl0hT+bvjw6y5KdNg7WoljFU= X-Google-Smtp-Source: APXvYqyHKtF9kjOLoDbMs0ghqGMMF6iZkVrIq0dpo8qZhusJk2LclZPkaM8ip7RSLKwtLT7QIdJE3Q== X-Received: by 2002:a17:90a:2223:: with SMTP id c32mr11401710pje.15.1574622448772; Sun, 24 Nov 2019 11:07:28 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:27 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 16/23] media: imx7-mipi-csis: Create media links in bound notifier Date: Sun, 24 Nov 2019 11:06:56 -0800 Message-Id: <20191124190703.12138-17-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Implement a notifier bound op to register media links from the remote sub-device's source pad(s) to the mipi csi-2 receiver sink pad. Signed-off-by: Steve Longerbeam --- Changes in 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 Miguel Silva --- drivers/staging/media/imx/imx7-mipi-csis.c | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index bbbc4d55fa9e..0ea6a48c2274 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -319,6 +319,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); @@ -850,6 +856,23 @@ static int mipi_csis_parse_endpoint(struct device *dev, return 0; } +static int mipi_csis_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi_state *state = mipi_notifier_to_csis_state(notifier); + struct media_pad *sink = &state->mipi_sd.entity.pads[CSIS_PAD_SINK]; + + return media_create_fwnode_pad_links(sink, + dev_fwnode(state->mipi_sd.dev), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +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) @@ -888,6 +911,8 @@ static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd, v4l2_async_notifier_init(&state->notifier); + state->notifier.ops = &mipi_csis_notify_ops; + ret = v4l2_async_register_fwnode_subdev(mipi_sd, &state->notifier, sizeof(struct v4l2_async_subdev), &sink_port, 1, From patchwork Sun Nov 24 19:06:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259299 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 07E961390 for ; Sun, 24 Nov 2019 19:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBF7C20823 for ; Sun, 24 Nov 2019 19:07:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="orRDshB7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727091AbfKXTHd (ORCPT ); Sun, 24 Nov 2019 14:07:33 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36285 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727059AbfKXTHc (ORCPT ); Sun, 24 Nov 2019 14:07:32 -0500 Received: by mail-pg1-f196.google.com with SMTP id k13so5953445pgh.3 for ; Sun, 24 Nov 2019 11:07:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yySuFpmjwOQiPlCOH/hIkjrkYS//RfWjr8qhFINVqLQ=; b=orRDshB7cgZ0W/uUPEn+Z2B9D8GBODr6lGevXU71e5NaQHBp3pO4mTdb7M4/U/LWwf LOsM+GoOXpPAkfxTZhRxfEkU8XfKVkx7H8te/m1KKYXHObcO7MrM3tixcgZHYlzdF1UQ rCOyZg3mKSZ8eYjLPLOmbXyaMTCrDX9blTZdCTwvahUB3VvAgmQX4dzkYZDogSdclLAn nPNsip/RtcXcHpGk0JWB+tY0UG+swoTgfWPF+pmYHiQDQ4xIX1ohLQeK1knxXD9mZMp7 9399tGtMCL+465wDE13muhDHQyEoc5iBxMbMcP6GuG0x8uUl/1ik9DPfIML48zz1LVoc IKIA== 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=yySuFpmjwOQiPlCOH/hIkjrkYS//RfWjr8qhFINVqLQ=; b=DZfR1Fzjd3tRsysE5YdLtzBkCY/+mc/3/DKaYgEFt9Z3CAlACmM6Sd2xeeVoB1dzCL sqBiPPaZoH+w9BTx7jym5AhCdMt97MW08CbIlBRVQ+Tfyf9QHiYm0xUqhM0aB0qUf+2b IzZTc6n/2rVphamz/M4kitReMONImFF3D3VMONIgQICo1oC5GrEPDICVXJ/lfvo8lC1X Uif19N5i/qY0u3D0L81Xk7Uy2l+zARNJM2o60VxbCIZVC0GR06EhZADpIco8RrDWxBxe KA1eNtAJqouqMauV88nsOzF9VXu4VwpijS60t8srKrgNR1uN43WQSyDmCTh9keWQMn85 kQGg== X-Gm-Message-State: APjAAAVNEMhdxrjcHYtlTlUv6CVw1CzCUktBSmLv7BRDJR3jBEDKngGP x/sddwY7hTn1zmWcXYf2ilKb4uisKhQ= X-Google-Smtp-Source: APXvYqwuk5DUR/yM01Cani7CTDPCXt1X5AklZDKuzH4mQIVd6tFY7HK1ONcWlQMa0BlHq/dqQ5ZctQ== X-Received: by 2002:a63:6f01:: with SMTP id k1mr11363344pgc.214.1574622449649; Sun, 24 Nov 2019 11:07:29 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:29 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 17/23] media: imx7-media-csi: Create media links in bound notifier Date: Sun, 24 Nov 2019 11:06:57 -0800 Message-Id: <20191124190703.12138-18-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-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 v2: Rename notifier_to_dev() to imx7_csi_notifier_to_dev() and remove unnecessary inline. Suggested-by: Rui Miguel Silva --- drivers/staging/media/imx/imx7-media-csi.c | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 15b08bfb5aa7..848d1286fbeb 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -196,6 +196,12 @@ struct imx7_csi { struct completion last_eof_completion; }; +static struct imx7_csi * +imx7_csi_notifier_to_dev(struct v4l2_async_notifier *n) +{ + return container_of(n, struct imx7_csi, notifier); +} + static u32 imx7_csi_reg_read(struct imx7_csi *csi, unsigned int offset) { return readl(csi->regbase + offset); @@ -1187,6 +1193,23 @@ static int imx7_csi_parse_endpoint(struct device *dev, return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL; } +static int imx7_csi_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct imx7_csi *csi = imx7_csi_notifier_to_dev(notifier); + struct media_pad *sink = &csi->sd.entity.pads[IMX7_CSI_PAD_SINK]; + + return media_create_fwnode_pad_links(sink, + dev_fwnode(csi->sd.dev), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = { + .bound = imx7_csi_notify_bound, +}; + static int imx7_csi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1269,6 +1292,8 @@ static int imx7_csi_probe(struct platform_device *pdev) v4l2_async_notifier_init(&csi->notifier); + csi->notifier.ops = &imx7_csi_notify_ops; + ret = v4l2_async_register_fwnode_subdev(&csi->sd, &csi->notifier, sizeof(struct v4l2_async_subdev), NULL, 0, From patchwork Sun Nov 24 19:06:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259301 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 B16DD1390 for ; Sun, 24 Nov 2019 19:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EE852080D for ; Sun, 24 Nov 2019 19:07:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B88IjOh9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727104AbfKXTHd (ORCPT ); Sun, 24 Nov 2019 14:07:33 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36489 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727060AbfKXTHb (ORCPT ); Sun, 24 Nov 2019 14:07:31 -0500 Received: by mail-pl1-f196.google.com with SMTP id d7so5439883pls.3 for ; Sun, 24 Nov 2019 11:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tEFP9EfjLyBSm2GDbhHW2vsbKN5BJT5FKVyhRHQNMY8=; b=B88IjOh997RjEzZHRef+LU6pcPdmsGPGPMI2gOZJFRtuN6Pe7sXujXbmZ+4SN6rm4k vluL1xdL/y/oqjF8EHPG4sLVc9mjyunGLK77RR6WcWuG7Ce3Ghe4QMiyh/4pfT9HkAAj cXhC63FNHZ1EbZWrroIxGie7RvNndAQw8tNy1R7gAWr5lFzTFgoeD7Tay75fVe6KL0kc NCmdP4eKStGKE6LLr9KLTcxKomBdx8ocwRVZe9Uo9lODmyQMCIzDPaFSIcHm1SE5E+ou y81Ydk89/9oIa54s7JOcadsb05xxMPhlX0Q7VCmHS8hRHECYGNJO8M/zKcHOTHUOnByo F6hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tEFP9EfjLyBSm2GDbhHW2vsbKN5BJT5FKVyhRHQNMY8=; b=nhPkJ8HYxTBuAzPuRVbshhNbJqOyT6HA4H5Iwla6pN/iZMKh2ZD0Gl30P6QSsVjaJ9 2S17CAzWoGDkathsReYwknyuR5sWXiaKIik2ec3d4uTyJIBkPlT0zdOZne8xnDuFUMEG jJiolCPLt7wwijtXIU5VjPuNEma+5mb6S7DbWbPCltel7YESqmW9nfmF0WJV541gLtBD +VVmtNnKIqDVmXH4Lh2XqBdXCyb+fnkMxRs4C+ebYc67qrIIuRr8a+Ky7DQ7cNTjcq5Q 3uxexruX2HdIyq8MOa+xyk8cv2ZAiys5bLtGKK9PBDO/cxFlYUD+ZnVcIGB/r3iNgRL0 uUGA== X-Gm-Message-State: APjAAAWPyFu+fQXh9NgJbIOPejQp0gw7ab6CHT+qNfUBo0xBWJu8XaXS ekcCBgSRlKwRjqfB8Gl4QxzjZroPHAI= X-Google-Smtp-Source: APXvYqxZtqOa9ZbCa4yGN9FvLcxy35OT7zk3TIpQt2Y3+cN/Qout3S8alCWmv8O0/nlM7MFbNi9LjQ== X-Received: by 2002:a17:90a:a63:: with SMTP id o90mr33582830pjo.81.1574622450683; Sun, 24 Nov 2019 11:07:30 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:30 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 18/23] media: imx: csi: Implement get_fwnode_pad Date: Sun, 24 Nov 2019 11:06:58 -0800 Message-Id: <20191124190703.12138-19-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The CSI does not have a 1:1 relationship between fwnode port numbers and pad indexes. In fact the CSI fwnode device is itself a port which is the sink, containing only a single fwnode endpoint. Implement media_entity operation get_fwnode_pad to first verify the given endpoint is the CSI's sink endpoint, and if so return the CSI sink pad index. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index b60ed4f22f6d..dc5fe25fe7b8 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1825,9 +1825,32 @@ static void csi_unregistered(struct v4l2_subdev *sd) ipu_csi_put(priv->csi); } +/* + * The CSI has only one fwnode endpoint, at the sink pad. Verify the + * endpoint belongs to us, and return CSI_SINK_PAD. + */ +static int csi_get_fwnode_pad(struct media_entity *entity, + struct fwnode_endpoint *endpoint) +{ + struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); + struct csi_priv *priv = v4l2_get_subdevdata(sd); + struct fwnode_handle *csi_port = dev_fwnode(priv->dev); + struct fwnode_handle *csi_ep; + int ret; + + csi_ep = fwnode_get_next_child_node(csi_port, NULL); + + ret = endpoint->local_fwnode == csi_ep ? CSI_SINK_PAD : -ENXIO; + + fwnode_handle_put(csi_ep); + + return ret; +} + static const struct media_entity_operations csi_entity_ops = { .link_setup = csi_link_setup, .link_validate = v4l2_subdev_link_validate, + .get_fwnode_pad = csi_get_fwnode_pad, }; static const struct v4l2_subdev_core_ops csi_core_ops = { From patchwork Sun Nov 24 19:06:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259305 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 ADDFF1390 for ; Sun, 24 Nov 2019 19:07:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C02B2082F for ; Sun, 24 Nov 2019 19:07:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U2MezOHP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727109AbfKXTHe (ORCPT ); Sun, 24 Nov 2019 14:07:34 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46722 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727080AbfKXTHc (ORCPT ); Sun, 24 Nov 2019 14:07:32 -0500 Received: by mail-pl1-f196.google.com with SMTP id k20so964178pll.13 for ; Sun, 24 Nov 2019 11:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nw6qFQx6S/L6ma/0AlsKxKIDrQ4PZDVJaM1fr3Im7gQ=; b=U2MezOHPJhlXIpIZfS7PEXG3iMfNJxWJI2aEME50rey1eZLQv4gQi3Kex0Xragapaf 7XnQ+1nMZJFbCARscIKYeIgTzw36a1e3LGyKbPZu3AMEmfxSNHu/5E7d2Q95KkGyBDHH xahr9/rNTTS5Tfl/14qBSGen4NzFdF9eljHKfta4ZGebVVV1ZqZTeYY+DrCXZeIdJBRA eH1BHLhhee5CycsJeV2GygQ/dD6SkruE6CjgzgzdtaX/Q4zbNrHFBFtxb5OCfuWpES7z 04EvYcUkj73PUBZSSbxOGCxR09DWdBNWx9KksIMJK/WYgCtYixXz9lsK/y202LBmjaTJ IYMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nw6qFQx6S/L6ma/0AlsKxKIDrQ4PZDVJaM1fr3Im7gQ=; b=VSti/mupEdlHrpo9cyw6smmj2E2v4/MI3xjXjwEV1qayVj7XiNUpsgNsiej7/+HkY2 SoucYyrljW4y59JqOgRtaCNSwwdZaxbS+LsCBPF1gVoj7A8GBMLVWGnWCLLw0MKmxL71 tvMm2EbEmYZWpEtxfQrxBeUl719M9vlQxNmqmlRklp+KDABJKRsndKeK/PwUfWHrMHr4 kWlW1DOpA3G7Anib6cE6h75OHSTV5/LZ4Brp4blSaETG/9f+IYuwqSev3BtgYFO0bgDQ L//gDwLd2UeWCaxCTcAbhKdfQWbDl1iG0OyPc571c0MpoP1YXjbzV9NYfpMV0EcEWIvq 0NKQ== X-Gm-Message-State: APjAAAU4ePmniicRK7aMBYxrWNF2PRbHS2smKdgY3bLSIRsjG7nI6lQa VjT4gZ5h2JASfi6+2X+QMsQ5uj1m7mg= X-Google-Smtp-Source: APXvYqxkV/vJTfmI9pPZGK0M8+q8xT1guwvcfzS/N0eHl5AJod0byvFdIwjmgJ9eozKQzv89JxjDtg== X-Received: by 2002:a17:90a:610:: with SMTP id j16mr34191037pjj.85.1574622451699; Sun, 24 Nov 2019 11:07:31 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:31 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 19/23] media: imx: csi: Embed notifier in struct csi_priv Date: Sun, 24 Nov 2019 11:06:59 -0800 Message-Id: <20191124190703.12138-20-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Embed the notifier in 'struct csi_priv', instead of dynamically allocating it, to make it possible to retrieve csi_priv in a notifier callback op. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 25 +++++++++-------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index dc5fe25fe7b8..3e2afdd59276 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -58,6 +58,8 @@ struct csi_priv { struct ipu_soc *ipu; struct v4l2_subdev sd; struct media_pad pad[CSI_NUM_PADS]; + struct v4l2_async_notifier notifier; + /* the video device at IDMAC output pad */ struct imx_media_video_dev *vdev; struct imx_media_fim *fim; @@ -1896,31 +1898,28 @@ static int imx_csi_parse_endpoint(struct device *dev, static int imx_csi_async_register(struct csi_priv *priv) { - struct v4l2_async_notifier *notifier; struct fwnode_handle *fwnode; unsigned int port; int ret; - notifier = kzalloc(sizeof(*notifier), GFP_KERNEL); - if (!notifier) - return -ENOMEM; - - v4l2_async_notifier_init(notifier); + v4l2_async_notifier_init(&priv->notifier); fwnode = dev_fwnode(priv->dev); /* get this CSI's port id */ ret = fwnode_property_read_u32(fwnode, "reg", &port); if (ret < 0) - goto out_free; + return ret; ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port( - priv->dev->parent, notifier, sizeof(struct v4l2_async_subdev), + priv->dev->parent, &priv->notifier, + sizeof(struct v4l2_async_subdev), port, imx_csi_parse_endpoint); if (ret < 0) goto out_cleanup; - ret = v4l2_async_subdev_notifier_register(&priv->sd, notifier); + ret = v4l2_async_subdev_notifier_register(&priv->sd, + &priv->notifier); if (ret < 0) goto out_cleanup; @@ -1928,16 +1927,12 @@ static int imx_csi_async_register(struct csi_priv *priv) if (ret < 0) goto out_unregister; - priv->sd.subdev_notifier = notifier; - return 0; out_unregister: - v4l2_async_notifier_unregister(notifier); + v4l2_async_notifier_unregister(&priv->notifier); out_cleanup: - v4l2_async_notifier_cleanup(notifier); -out_free: - kfree(notifier); + v4l2_async_notifier_cleanup(&priv->notifier); return ret; } From patchwork Sun Nov 24 19:07:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259303 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 03C95913 for ; Sun, 24 Nov 2019 19:07:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D68ED2080D for ; Sun, 24 Nov 2019 19:07:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AxYIUyp/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727080AbfKXTHe (ORCPT ); Sun, 24 Nov 2019 14:07:34 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:39441 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727099AbfKXTHd (ORCPT ); Sun, 24 Nov 2019 14:07:33 -0500 Received: by mail-pj1-f67.google.com with SMTP id v93so2156662pjb.6 for ; Sun, 24 Nov 2019 11:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=w9UD0KbOuv61h2E5uokL4oDGzhRyPV6pq2zfaUlyAZQ=; b=AxYIUyp/A/MeY+NtzyfgasJiaT1stD4J8vLxU5G18+aFQFdY/T3OEIPCrf9eFI/BRv 76pUCk8JguJjBQ/yb8P89V2MiJZ036GgvEQ3Y6L2JeJEKmmcn6KQ3CoBEdJZF6g4UjT4 A+mquv/Nxj0dcTmkmBG85IycGOTMtekByXLuG/x3gmPDyAx8ydhSymBXubuLWNo75gvl HW1lafD/Hz38QvsrRvtFRKzbWlJ6FYYQcOETuYgbKMkHreqKPQx1VOxXwXWSYagcb0X1 0EUb+a3UUGf9zraFKorqvXUjr4MmOCMljljsfHYS/1VFExjd+Jdi72mQ7Y5ETrvzweyl hNTg== 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=w9UD0KbOuv61h2E5uokL4oDGzhRyPV6pq2zfaUlyAZQ=; b=dp7jwLKUMlfBO612pbf7ENp9xvPV68QBCTV1bkFZaOjs2B9OFTM2SObWSxJahB7dPk OCIemw4oHAJ7wpevAoTNpu9wFNuNjsswJ2TeITtazikne3tOhffglnMvZC4HB3r0VyE6 LcAcaKAjrUY7DzvRwEeNNEP/iYxvAkvBQC2mnPeIfjYZekMEIdI73sqA9zA7jPSBbobg qy/ukXy6mN3tleR2BPwPvIPfzSHwEtrePuiJadmR9kIeax8G1Br465TG0DGCq55ulERu iWZOOgMn5Q6qyKxPkMQU1rXdDFeao37Z8LoovdHE3o2hFkqchbyiAhHWbDYnxtnZkNtH 1ZYA== X-Gm-Message-State: APjAAAUeeIaBejrzZvTWhRgDIhrbgbPQTZsWRlAM4cLYlKIPepOk0Nox 6R0dcegpF0wX4kXSLKOlXK6rcrWvUBY= X-Google-Smtp-Source: APXvYqyX6jguSfkaFpU41a3jlGIfgIzGln1MBuauspNqXkbJkxoXdQ2v9MEd3oZvv1N58Ztb3zEfcg== X-Received: by 2002:a17:90a:9915:: with SMTP id b21mr11132179pjp.104.1574622452851; Sun, 24 Nov 2019 11:07:32 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:32 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 20/23] media: imx: csi: Create media links in bound notifier Date: Sun, 24 Nov 2019 11:07:00 -0800 Message-Id: <20191124190703.12138-21-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-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 --- drivers/staging/media/imx/imx-media-csi.c | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 3e2afdd59276..e162f8aee164 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -120,6 +120,11 @@ static inline struct csi_priv *sd_to_dev(struct v4l2_subdev *sdev) return container_of(sdev, struct csi_priv, sd); } +static inline struct csi_priv *notifier_to_dev(struct v4l2_async_notifier *n) +{ + return container_of(n, struct csi_priv, notifier); +} + static inline bool is_parallel_bus(struct v4l2_fwnode_endpoint *ep) { return ep->bus_type != V4L2_MBUS_CSI2_DPHY; @@ -1896,6 +1901,23 @@ static int imx_csi_parse_endpoint(struct device *dev, return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN; } +static int imx_csi_notify_bound(struct v4l2_async_notifier *notifier, + struct v4l2_subdev *sd, + struct v4l2_async_subdev *asd) +{ + struct csi_priv *priv = notifier_to_dev(notifier); + struct media_pad *sink = &priv->sd.entity.pads[CSI_SINK_PAD]; + + return media_create_fwnode_pad_links(sink, + dev_fwnode(priv->dev->parent), + &sd->entity, + dev_fwnode(sd->dev), 0); +} + +static const struct v4l2_async_notifier_operations csi_notify_ops = { + .bound = imx_csi_notify_bound, +}; + static int imx_csi_async_register(struct csi_priv *priv) { struct fwnode_handle *fwnode; @@ -1904,6 +1926,8 @@ static int imx_csi_async_register(struct csi_priv *priv) v4l2_async_notifier_init(&priv->notifier); + priv->notifier.ops = &csi_notify_ops; + fwnode = dev_fwnode(priv->dev); /* get this CSI's port id */ From patchwork Sun Nov 24 19:07:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259307 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 D94B514E5 for ; Sun, 24 Nov 2019 19:07:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B829720836 for ; Sun, 24 Nov 2019 19:07:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ipJTdZm/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727112AbfKXTHf (ORCPT ); Sun, 24 Nov 2019 14:07:35 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45394 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbfKXTHe (ORCPT ); Sun, 24 Nov 2019 14:07:34 -0500 Received: by mail-pg1-f196.google.com with SMTP id k1so5919206pgg.12 for ; Sun, 24 Nov 2019 11:07:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yQ8IO0w/KyBx6rbYxSq5zR22FDlZzSw4KuUBAaZfku8=; b=ipJTdZm/MV494uC0AA091MzgirUy1MFb4JpD02o1+dLfMJRofpuH2AK4GNs+0mkYMb +WPNZ2gvSGYDe54jpmDRuSKVmzVtoFyt0z/wdDvhPzOfGB1+wMWhSqOexysuEqfN469Q KbkWPLvrzbnKmDHCYbtNWUTtdrC1lbtbKKjDBgcp6OyBiLhHRXdd672BIoCnpnwP4gBi tneohWNYHJ/wUv+H97KBqgjBZMAOZ/2KpTAzFn41sQwVRZMgVMFEn6DOZOIvkkOo5n8c ZAap+pNXG12CQ0ILBx7WkuunSXXnXRg1hgw77VmX/OmpfqhcICEZuBghUSwO2I38Fzce EzrQ== 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=yQ8IO0w/KyBx6rbYxSq5zR22FDlZzSw4KuUBAaZfku8=; b=d9G8B7BZZEbeTwtxGPFM3LIBqjBHJQBJs1NWnSHbUXNjBlrHBPBfAMGv8ZMURK1YEn mFZF0WP7aF6xQnCa/uKZfnLTNVfVwS6zOVCjngMa2GrN/ZmNeJjQya8L7EZ38XC0h5x3 UcIXtoNJzQjpX4Xsedj4yOF9P7ND20sJxmcxrtgzCFrGgvXSaaQEEODSjZ2LbZSmINZ4 O0FbfJpIpJrDtdsSK2PcWDD8/zZFkYZq4B321SHi+uDLza49L/xKZfOjrCbsk1Utid0S QnFsYGg8o6Po3p3uVeiqn3KazsW+kFi99U7WWtSIZ28GeVDJleEcCqUi3ROVhjE6uY5g LElg== X-Gm-Message-State: APjAAAUBCfOW+9e9dGT//wed7r+chE+3nd8YiDBJoe903HoV343PIPqp jsJttayNhJDf3swWgacqQbpDVKVgiHw= X-Google-Smtp-Source: APXvYqwScleusIU25xqHxLGHfvThL6pNHaQgwZ8LxUOwcWfBBsLuXkXMx16xvOgFG/CHYxqRlLOi7g== X-Received: by 2002:a63:e0a:: with SMTP id d10mr15349416pgl.124.1574622453726; Sun, 24 Nov 2019 11:07:33 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:33 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 21/23] media: imx: csi: Lookup upstream endpoint with imx_media_get_pad_fwnode Date: Sun, 24 Nov 2019 11:07:01 -0800 Message-Id: <20191124190703.12138-22-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fix the 1:1 port-id:pad-index assumption for the upstream subdevice, by searching the upstream subdevice's endpoints for one that maps to the pad's index. This is carried out by a new reverse mapping function imx_media_get_pad_fwnode(). Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 22 ++++---------- drivers/staging/media/imx/imx-media-utils.c | 33 +++++++++++++++++++++ drivers/staging/media/imx/imx-media.h | 1 + drivers/staging/media/imx/imx7-media-csi.c | 25 +++++----------- 4 files changed, 47 insertions(+), 34 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index e162f8aee164..022472f0a657 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -164,7 +164,7 @@ static inline bool requires_passthrough(struct v4l2_fwnode_endpoint *ep, static int csi_get_upstream_endpoint(struct csi_priv *priv, struct v4l2_fwnode_endpoint *ep) { - struct device_node *endpoint, *port; + struct fwnode_handle *endpoint; struct media_entity *src; struct v4l2_subdev *sd; struct media_pad *pad; @@ -203,23 +203,13 @@ static int csi_get_upstream_endpoint(struct csi_priv *priv, if (!pad) return -ENODEV; - sd = media_entity_to_v4l2_subdev(pad->entity); + endpoint = imx_media_get_pad_fwnode(pad); + if (IS_ERR(endpoint)) + return PTR_ERR(endpoint); - /* - * NOTE: this assumes an OF-graph port id is the same as a - * media pad index. - */ - port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); - if (!port) - return -ENODEV; - - endpoint = of_get_next_child(port, NULL); - of_node_put(port); - if (!endpoint) - return -ENODEV; + v4l2_fwnode_endpoint_parse(endpoint, ep); - v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); - of_node_put(endpoint); + fwnode_handle_put(endpoint); return 0; } diff --git a/drivers/staging/media/imx/imx-media-utils.c b/drivers/staging/media/imx/imx-media-utils.c index 0788a1874557..547805f9379e 100644 --- a/drivers/staging/media/imx/imx-media-utils.c +++ b/drivers/staging/media/imx/imx-media-utils.c @@ -916,6 +916,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 11861191324a..3363af07a5ca 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -201,6 +201,7 @@ imx_media_pipeline_subdev(struct media_entity *start_entity, u32 grp_id, struct video_device * imx_media_pipeline_video_device(struct media_entity *start_entity, enum v4l2_buf_type buftype, bool upstream); +struct fwnode_handle *imx_media_get_pad_fwnode(struct media_pad *pad); struct imx_media_dma_buf { void *virt; diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 848d1286fbeb..103447cb5e01 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -439,9 +439,8 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, struct v4l2_fwnode_endpoint *ep, bool skip_mux) { - struct device_node *endpoint, *port; + struct fwnode_handle *endpoint; struct media_entity *src; - struct v4l2_subdev *sd; struct media_pad *pad; if (!csi->src_sd) @@ -463,29 +462,19 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi *csi, if (!pad) return -ENODEV; - sd = media_entity_to_v4l2_subdev(pad->entity); - /* To get bus type we may need to skip video mux */ if (skip_mux && src->function == MEDIA_ENT_F_VID_MUX) { - src = &sd->entity; + src = pad->entity; goto skip_video_mux; } - /* - * NOTE: this assumes an OF-graph port id is the same as a - * media pad index. - */ - port = of_graph_get_port_by_id(sd->dev->of_node, pad->index); - if (!port) - return -ENODEV; + endpoint = imx_media_get_pad_fwnode(pad); + if (IS_ERR(endpoint)) + return PTR_ERR(endpoint); - endpoint = of_get_next_child(port, NULL); - of_node_put(port); - if (!endpoint) - return -ENODEV; + v4l2_fwnode_endpoint_parse(endpoint, ep); - v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep); - of_node_put(endpoint); + fwnode_handle_put(endpoint); return 0; } From patchwork Sun Nov 24 19:07:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259309 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 59099913 for ; Sun, 24 Nov 2019 19:07:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26EF620828 for ; Sun, 24 Nov 2019 19:07:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fgfZcyFL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbfKXTHg (ORCPT ); Sun, 24 Nov 2019 14:07:36 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46722 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbfKXTHg (ORCPT ); Sun, 24 Nov 2019 14:07:36 -0500 Received: by mail-pl1-f194.google.com with SMTP id k20so964197pll.13 for ; Sun, 24 Nov 2019 11:07:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OkkbpuVrsDEczJ8S9HRvlV+n1naGN5QgjJsGUUqNzOk=; b=fgfZcyFL3uipWXkBO8JghY/CKId/gwY+d6iePJ5hNPbdKyemOpChbFJ/lo/WNqIi10 pG+7e14hiernRjfKxeCgCc4e9hStpxM2bnVcPSP4ESYHjWOW0RG76eSZc0BFDSg8Vu09 lDZ0wWeKlZodXT3vB/QwnsYnDGjncC4fiZELoNJH4Uh3QVqOsZlfMvad7K+CmBH3LO4F 4tXVt5Qbm7CjBRiQjsCbzlRhFRGE5WkqjJGxDsUuph9eAm9BBO13xD1QZV0ew4CWjbPc B51wFrhMGuCNJcxb5tB6OV4MVn1m/MONHsBrdmZ2rX+74AlteF9JAXpeURhVoiCvhfKY N1/A== 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=OkkbpuVrsDEczJ8S9HRvlV+n1naGN5QgjJsGUUqNzOk=; b=PiXvOIJrCHYi7TfGVR1WjRg5SKwGAEjHCOc4YH6swVJn+FLyAaNpCc1FSfB/zNZ8EC n/jTZZL/iJLNn/vL25Z6PLF53Crt7gdj8wFcnCaRlml1CUQRXl3Ki6++gdte2ot/U5Ib ItAPka3J0FUnK4cxnYz8kzQoZZEZx1P4ObhtM3NvViV6xN8P+A2NSvl+qSsAU64u9pqX sTkbclMhu11zOSU4xaALBw1v4WrrD+/I4y7l8Pi1fySSVgOaLpf8KzGim967QHd1zPMe vxMtvXElXm0Ot4XF6WhvAsBeg764I959V61kqpD1787t0FyxrU0qEoEO8tVdo/T8tvYO t7NA== X-Gm-Message-State: APjAAAUd3ZsJQtNax5kQB/WgkVqNTP6NXBQG8b5H0ccJOqEcX9b5c7Yv AT3sXVdPbAshZlycIVpb8pR3/g0DDeU= X-Google-Smtp-Source: APXvYqw98Z1WgneXjQEmuSaQpPAIr+gdx9DKjuQ3bS0t70vA20CACn2BDFM7QV45PgOVOWmREvmZlw== X-Received: by 2002:a17:90a:230b:: with SMTP id f11mr3786367pje.124.1574622454952; Sun, 24 Nov 2019 11:07:34 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:34 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 22/23] media: imx: Create missing links from CSI-2 receiver Date: Sun, 24 Nov 2019 11:07:02 -0800 Message-Id: <20191124190703.12138-23-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The entities external to the i.MX6 IPU and i.MX7 now create the links to their fwnode-endpoint connected entities in their notifier bound callbacks. Which means imx_media_create_of_links() and imx_media_create_csi_of_links() are no longer needed and are removed. However there is still one case in which imx-media needs to create fwnode-endpoint based links at probe completion. The v4l2-async framework does not allow multiple subdevice notifiers to contain a duplicate subdevice in their asd_list. Only the first subdev notifier that discovers and adds that one subdevice to its asd_list will receive a bound callback for it. Other subdevices that also have firmware endpoint connections to this duplicate subdevice will not have it in their asd_list, and thus will never receive a bound callback for it. In the case of imx-media, the one duplicate subdevice in question is the i.MX6 MIPI CSI-2 receiver. Until there is a solution to that problem, rewrite imx_media_create_links() to add the missing links from the CSI-2 receiver to the CSIs and CSI muxes. The function is renamed imx_media_create_csi2_links(). Signed-off-by: Steve Longerbeam --- Changes in 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 | 60 +++++----- drivers/staging/media/imx/imx-media-of.c | 113 ------------------ drivers/staging/media/imx/imx-media.h | 4 - 3 files changed, 31 insertions(+), 146 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..8acf2f2e28c6 100644 --- a/drivers/staging/media/imx/imx-media-dev-common.c +++ b/drivers/staging/media/imx/imx-media-dev-common.c @@ -30,41 +30,45 @@ 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; } } - return 0; + if (!csi2) + return; + + list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { + struct fwnode_handle *fwnode; + + /* skip if not a CSI or a video mux */ + if (!(sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) && + !(sd->grp_id & IMX_MEDIA_GRP_ID_CSI) && + sd->entity.function != MEDIA_ENT_F_VID_MUX) + continue; + + fwnode = (sd->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) ? + dev_fwnode(sd->dev->parent) : + dev_fwnode(sd->dev); + + /* + * if there are fwnode endpoint connections between + * the CSI-2 receiver and this CSI or video-mux, + * create media links for them. + */ + __media_create_fwnode_links(&csi2->entity, + dev_fwnode(csi2->dev), + &sd->entity, fwnode, 0); + } } /* @@ -196,9 +200,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 736c954a8ff5..82e13e972e23 100644 --- a/drivers/staging/media/imx/imx-media-of.c +++ b/drivers/staging/media/imx/imx-media-of.c @@ -74,116 +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 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_port_parent); - 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 fwnode_handle *endpoint; - struct fwnode_link link; - int ret; - - fwnode_graph_for_each_endpoint(dev_fwnode(sd->dev), endpoint) { - ret = fwnode_graph_parse_link(endpoint, &link); - if (ret) - continue; - - ret = create_of_link(imxmd, sd, &link); - fwnode_graph_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 fwnode_handle *csi_np = dev_fwnode(csi->dev); - struct fwnode_handle *csi_ep; - - fwnode_for_each_child_node(csi_np, csi_ep) { - struct fwnode_handle *fwnode; - struct fwnode_link link; - int ret; - - memset(&link, 0, sizeof(link)); - - link.local_port_parent = csi_np; - link.local.port = CSI_SINK_PAD; - - 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_port_parent = fwnode; - - ret = create_of_link(imxmd, csi, &link); - fwnode_handle_put(link.remote_port_parent); - 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 3363af07a5ca..d462759f583c 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -244,10 +244,6 @@ void imx_media_unregister_ipu_internal_subdevs(struct imx_media_dev *imxmd); /* imx-media-of.c */ int imx_media_add_of_subdevs(struct imx_media_dev *dev, struct device_node *np); -int imx_media_create_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *sd); -int imx_media_create_csi_of_links(struct imx_media_dev *imxmd, - struct v4l2_subdev *csi); int imx_media_of_add_csi(struct imx_media_dev *imxmd, struct device_node *csi_np); From patchwork Sun Nov 24 19:07:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 11259311 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 B6FC7913 for ; Sun, 24 Nov 2019 19:07:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 93F972080D for ; Sun, 24 Nov 2019 19:07:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tktmlwzJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbfKXTHi (ORCPT ); Sun, 24 Nov 2019 14:07:38 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40943 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727111AbfKXTHg (ORCPT ); Sun, 24 Nov 2019 14:07:36 -0500 Received: by mail-pg1-f196.google.com with SMTP id e17so5929346pgd.7 for ; Sun, 24 Nov 2019 11:07:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2TmLGvTN3FaWVeRsZPV3e4KNsmV2AReP7cWUVSqpqFQ=; b=tktmlwzJ0mriS6Fthqk2MprPTXldRFIfdl97oh1ZiZtDZTz0+pR3d7y6AVWt+4WN91 r1PrkKL8CqAVqbya/+e0CQAiypndn60iMCyhOeV77Bj3PI6sWT2p1aLD13+ZMq48tZsb b5Xm9ksK9eR/p0K9GrFkS7oj20MS0uSt2AdcOab3vcdJc1GwQ6VX63YytmVN832+NPhc tN0HAOJlEPQiaEfeArtL8lFPKtsOrqNXyhB4SNu0N2NfsXRtBCIM5OVMk/zZUngnteHE hcvrCr8rm2VY68pPBqJ9Vt3nypqno7XsiPCmKcnL2DHMrOOD36eOkKT7w1hTCM8Oqy0j vE4Q== 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=2TmLGvTN3FaWVeRsZPV3e4KNsmV2AReP7cWUVSqpqFQ=; b=qbdw7hZvxzW8d+/TlsDNrq13VJuZwLt5b/pZ3oKGFdakRj0+QX/Vr10bh0n2YSTEWW 4dGDFZrkYCgj+CE4c+v1ozYwwKQ8l4xiEmQN+L30Zta+arZWCA9Z0DIluUBvK5eSEHt9 HfvPZM2YCQ5ndUh0sXWXWbrnN5/vjtxrm3t42j6vWcstQ54Y7kiJ/YOX9/LzLUX8Zmxn 3uTgqpAy2V38UVldGZo38gDy+4bfGXW7gqDqrklMPuZWp2nSfkM/lgvdlFO81LTURwUk cj2CrbLMf7lN1WJ/3jtZc4RTheKbGSXlJiSoVbhtSQ2Z4rNjJ8/E3EaRYb2O6ayKkguA IYOw== X-Gm-Message-State: APjAAAXLEIMpRVuMWKZF7r9WrllJFIo8g2pRNoUi/EgHfOnd++AHSB7H RiYIw9EqGixsa/lB6c9fGfKXOKTic1k= X-Google-Smtp-Source: APXvYqzHWXvlukGyVa9OsAemjiAdrkEBX3SPUU79avByGJme8RFnzve+PdOb/4EnGSwWKudLvGPF2g== X-Received: by 2002:a63:1013:: with SMTP id f19mr13200361pgl.289.1574622455623; Sun, 24 Nov 2019 11:07:35 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r20sm5367801pgo.74.2019.11.24.11.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Nov 2019 11:07:35 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH v2 23/23] media: imx: TODO: Remove media link creation todos Date: Sun, 24 Nov 2019 11:07:03 -0800 Message-Id: <20191124190703.12138-24-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191124190703.12138-1-slongerbeam@gmail.com> References: <20191124190703.12138-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 after exporting media link creation to individual entity bound callbacks and the use of media_create_fwnode_links(), media_create_fwnode_pad_links(), and media_entity_get_fwnode_pad(). 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