From patchwork Wed Mar 18 21:30:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 11446089 X-Patchwork-Delegate: kieran@bingham.xyz 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 977251893 for ; Wed, 18 Mar 2020 21:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77EB120772 for ; Wed, 18 Mar 2020 21:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726733AbgCRVbH (ORCPT ); Wed, 18 Mar 2020 17:31:07 -0400 Received: from vsp-unauthed02.binero.net ([195.74.38.227]:49598 "EHLO vsp-unauthed02.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbgCRVbG (ORCPT ); Wed, 18 Mar 2020 17:31:06 -0400 X-Halon-ID: b19d55db-695f-11ea-9f40-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id b19d55db-695f-11ea-9f40-0050569116f7; Wed, 18 Mar 2020 22:30:31 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [RFC 1/5] uapi/linux/media.h: add flag field to struct media_device_info Date: Wed, 18 Mar 2020 22:30:47 +0100 Message-Id: <20200318213051.3200981-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> References: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Add a flags field to the media_device_info structure by taking one of the reserved u32 fields. The use-case is to have a way to (optionally) report to user-space if the media graph is complete or not. Also define two flags to carry information about if the graph is complete or not. If neither of the two flags are set the media device does not support reporting its graph status. The other bits in the flags field are unused for now, but could be claimed to carry other type of information in the future. Signed-off-by: Niklas Söderlund --- include/uapi/linux/media.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 383ac7b7d8f07eca..9b37ed8b41d0d866 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -34,9 +34,16 @@ struct media_device_info { __u32 media_version; __u32 hw_revision; __u32 driver_version; - __u32 reserved[31]; + __u32 flags; + __u32 reserved[30]; }; +/* + * Graph flags + */ +#define MEDIA_INFO_FLAG_INCOMPLETE (1 << 0) +#define MEDIA_INFO_FLAG_COMPLETE (1 << 1) + /* * Base number ranges for entity functions * From patchwork Wed Mar 18 21:30:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 11446091 X-Patchwork-Delegate: kieran@bingham.xyz 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 0AB68913 for ; Wed, 18 Mar 2020 21:31:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEA6820772 for ; Wed, 18 Mar 2020 21:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbgCRVbH (ORCPT ); Wed, 18 Mar 2020 17:31:07 -0400 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:19178 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbgCRVbH (ORCPT ); Wed, 18 Mar 2020 17:31:07 -0400 X-Halon-ID: b206bf1e-695f-11ea-9f40-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id b206bf1e-695f-11ea-9f40-0050569116f7; Wed, 18 Mar 2020 22:30:32 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [RFC 2/5] media-device: Add a graph_complete callback to struct media_device_ops Date: Wed, 18 Mar 2020 22:30:48 +0100 Message-Id: <20200318213051.3200981-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> References: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Add a new graph_complete operation to struct media_device_ops. The callback is optional to implement. If it's implemented it shall return the status about the media graphs completes. If all entities that the media device could contain is registered in the graph it shall return true, otherwise false. Signed-off-by: Niklas Söderlund --- include/media/media-device.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/media/media-device.h b/include/media/media-device.h index fa089543072052cf..f637ad2eee38f456 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -61,6 +61,8 @@ struct media_entity_notify { * request (and thus the buffer) must be available to the driver. * And once a buffer is queued, then the driver can complete * or delete objects from the request before req_queue exits. + * @graph_complete: Check if the media device graph is complete and all entries + * have been added to the graph. */ struct media_device_ops { int (*link_notify)(struct media_link *link, u32 flags, @@ -69,6 +71,7 @@ struct media_device_ops { void (*req_free)(struct media_request *req); int (*req_validate)(struct media_request *req); void (*req_queue)(struct media_request *req); + bool (*graph_complete)(struct media_device *mdev); }; /** From patchwork Wed Mar 18 21:30:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 11446099 X-Patchwork-Delegate: kieran@bingham.xyz 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 59DD41874 for ; Wed, 18 Mar 2020 21:31:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 388A720772 for ; Wed, 18 Mar 2020 21:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726840AbgCRVbJ (ORCPT ); Wed, 18 Mar 2020 17:31:09 -0400 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:1048 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbgCRVbI (ORCPT ); Wed, 18 Mar 2020 17:31:08 -0400 X-Halon-ID: b279901d-695f-11ea-9f40-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id b279901d-695f-11ea-9f40-0050569116f7; Wed, 18 Mar 2020 22:30:32 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [RFC 3/5] mc-device.c: If graph completes status is available report it to user-space Date: Wed, 18 Mar 2020 22:30:49 +0100 Message-Id: <20200318213051.3200981-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> References: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org If the media device implements the graph_complete callback utilise it and fill in the completes of the graph in the struct media_device_info. Signed-off-by: Niklas Söderlund Signed-off-by: Niklas Söderlund --- drivers/media/mc/mc-device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c index da8088351135298a..64c786570b6df129 100644 --- a/drivers/media/mc/mc-device.c +++ b/drivers/media/mc/mc-device.c @@ -75,6 +75,10 @@ static long media_device_get_info(struct media_device *dev, void *arg) info->driver_version = info->media_version; info->hw_revision = dev->hw_revision; + if (dev->ops && dev->ops->graph_complete) + info->flags |= dev->ops->graph_complete(dev) ? + MEDIA_INFO_FLAG_COMPLETE : MEDIA_INFO_FLAG_INCOMPLETE; + return 0; } From patchwork Wed Mar 18 21:30:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 11446097 X-Patchwork-Delegate: kieran@bingham.xyz 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 0649516C1 for ; Wed, 18 Mar 2020 21:31:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E475D20752 for ; Wed, 18 Mar 2020 21:31:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726894AbgCRVbJ (ORCPT ); Wed, 18 Mar 2020 17:31:09 -0400 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:25967 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726747AbgCRVbJ (ORCPT ); Wed, 18 Mar 2020 17:31:09 -0400 X-Halon-ID: b2e1d9bc-695f-11ea-9f40-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id b2e1d9bc-695f-11ea-9f40-0050569116f7; Wed, 18 Mar 2020 22:30:33 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [RFC 4/5] rcar-vin: Report the completeness of the media graph Date: Wed, 18 Mar 2020 22:30:50 +0100 Message-Id: <20200318213051.3200981-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> References: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Implement the graph_complete callback and report if the media graph is complete or not. Signed-off-by: Niklas Söderlund --- drivers/media/platform/rcar-vin/rcar-core.c | 13 +++++++++++++ drivers/media/platform/rcar-vin/rcar-vin.h | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c index 7440c8965d27e64f..21ce3de8168c3224 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -221,8 +221,16 @@ static int rvin_group_link_notify(struct media_link *link, u32 flags, return ret; } +static bool rvin_group_graph_complete(struct media_device *mdev) +{ + struct rvin_group *group = container_of(mdev, struct rvin_group, mdev); + + return group->complete; +} + static const struct media_device_ops rvin_media_ops = { .link_notify = rvin_group_link_notify, + .graph_complete = rvin_group_graph_complete, }; /* ----------------------------------------------------------------------------- @@ -735,6 +743,9 @@ static int rvin_group_notify_complete(struct v4l2_async_notifier *notifier) break; } } + + vin->group->complete = true; + mutex_unlock(&vin->group->lock); return ret; @@ -761,6 +772,8 @@ static void rvin_group_notify_unbind(struct v4l2_async_notifier *notifier, break; } + vin->group->complete = false; + mutex_unlock(&vin->group->lock); } diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h b/drivers/media/platform/rcar-vin/rcar-vin.h index c19d077ce1cb4f4b..ff04adbb969b07de 100644 --- a/drivers/media/platform/rcar-vin/rcar-vin.h +++ b/drivers/media/platform/rcar-vin/rcar-vin.h @@ -263,6 +263,8 @@ struct rvin_dev { * @vin: VIN instances which are part of the group * @csi: array of pairs of fwnode and subdev pointers * to all CSI-2 subdevices. + * @complete: True if all devices of the group are in the media graph, + * false otherwise. */ struct rvin_group { struct kref refcount; @@ -278,6 +280,8 @@ struct rvin_group { struct fwnode_handle *fwnode; struct v4l2_subdev *subdev; } csi[RVIN_CSI_MAX]; + + bool complete; }; int rvin_dma_register(struct rvin_dev *vin, int irq); From patchwork Wed Mar 18 21:30:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 11446101 X-Patchwork-Delegate: kieran@bingham.xyz 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 E2243913 for ; Wed, 18 Mar 2020 21:31:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C262C20772 for ; Wed, 18 Mar 2020 21:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727175AbgCRVbK (ORCPT ); Wed, 18 Mar 2020 17:31:10 -0400 Received: from vsp-unauthed02.binero.net ([195.74.38.227]:56586 "EHLO vsp-unauthed02.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727138AbgCRVbJ (ORCPT ); Wed, 18 Mar 2020 17:31:09 -0400 X-Halon-ID: b354f972-695f-11ea-9f40-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de [79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id b354f972-695f-11ea-9f40-0050569116f7; Wed, 18 Mar 2020 22:30:34 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [RFC 5/5] rcar-vin: Do not unregister video device when a subdevice is unbound Date: Wed, 18 Mar 2020 22:30:51 +0100 Message-Id: <20200318213051.3200981-6-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> References: <20200318213051.3200981-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org If the v4l2-async notifier have once been complete and the video device(s) have been register, do not unregister them if one subdevice is unbound. Depending on which subdevice is unbound other parts of the pipeline could still be functional. For example if one of multiple sensors connected to a CSI-2 transmitter is unbound other sensors in that pipeline are still useable. This problem is extra critical for R-Car VIN which registers two independent CSI-2 receivers in the same media graph as they can both be used by the same dma-engines. If one of the CSI-2 receivers are unbound the other CSI-2 receiver pipeline is still fully functional. Signed-off-by: Niklas Söderlund --- drivers/media/platform/rcar-vin/rcar-core.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c index 21ce3de8168c3224..d51ffe75c34c97c5 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -533,7 +533,6 @@ static int rvin_parallel_subdevice_attach(struct rvin_dev *vin, static void rvin_parallel_subdevice_detach(struct rvin_dev *vin) { - rvin_v4l2_unregister(vin); vin->parallel->subdev = NULL; if (!vin->info->use_mc) { @@ -758,10 +757,6 @@ static void rvin_group_notify_unbind(struct v4l2_async_notifier *notifier, struct rvin_dev *vin = v4l2_dev_to_vin(notifier->v4l2_dev); unsigned int i; - for (i = 0; i < RCAR_VIN_NUM; i++) - if (vin->group->vin[i]) - rvin_v4l2_unregister(vin->group->vin[i]); - mutex_lock(&vin->group->lock); for (i = 0; i < RVIN_CSI_MAX; i++) {