From patchwork Wed Jun 10 23:05:37 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: 11599001 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 B884F13B1 for ; Wed, 10 Jun 2020 23:06:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0651206F4 for ; Wed, 10 Jun 2020 23:06:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbgFJXGA (ORCPT ); Wed, 10 Jun 2020 19:06:00 -0400 Received: from bin-mail-out-06.binero.net ([195.74.38.229]:13267 "EHLO bin-mail-out-06.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726453AbgFJXGA (ORCPT ); Wed, 10 Jun 2020 19:06:00 -0400 X-Halon-ID: eed6ab18-ab6e-11ea-933e-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id eed6ab18-ab6e-11ea-933e-005056917a89; Thu, 11 Jun 2020 01:05:53 +0200 (CEST) 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: [PATCH 1/5] uapi/linux/media.h: add flags field to struct media_v2_topology Date: Thu, 11 Jun 2020 01:05:37 +0200 Message-Id: <20200610230541.1603067-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> References: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a flags field to the media_v2_topology structure by taking one of the reserved u32 fields. Also define a flag to carry information about if the graph is complete. The use-case is to have a way to report to user-space if the media graph contains all subdevices. 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 --- drivers/media/mc/mc-device.c | 2 +- include/uapi/linux/media.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c index da8088351135298a..c2ef5bb512a5fba0 100644 --- a/drivers/media/mc/mc-device.c +++ b/drivers/media/mc/mc-device.c @@ -242,6 +242,7 @@ static long media_device_get_topology(struct media_device *mdev, void *arg) int ret = 0; topo->topology_version = mdev->topology_version; + topo->flags = 0; /* Get entities and number of entities */ i = 0; @@ -269,7 +270,6 @@ static long media_device_get_topology(struct media_device *mdev, void *arg) uentity++; } topo->num_entities = i; - topo->reserved1 = 0; /* Get interfaces and number of interfaces */ i = 0; diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index 383ac7b7d8f07eca..7c07b9939252c768 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -351,7 +351,7 @@ struct media_v2_topology { __u64 topology_version; __u32 num_entities; - __u32 reserved1; + __u32 flags; __u64 ptr_entities; __u32 num_interfaces; @@ -367,6 +367,8 @@ struct media_v2_topology { __u64 ptr_links; } __attribute__ ((packed)); +#define MEDIA_TOPOLOGY_FLAG_COMPLETE (1 << 0) + /* ioctls */ #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info) From patchwork Wed Jun 10 23:05:38 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: 11599003 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 D44B417EE for ; Wed, 10 Jun 2020 23:06:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC69D206F4 for ; Wed, 10 Jun 2020 23:06:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726471AbgFJXGA (ORCPT ); Wed, 10 Jun 2020 19:06:00 -0400 Received: from bin-mail-out-06.binero.net ([195.74.38.229]:8091 "EHLO bin-mail-out-06.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726553AbgFJXGA (ORCPT ); Wed, 10 Jun 2020 19:06:00 -0400 X-Halon-ID: ef3e8b75-ab6e-11ea-933e-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id ef3e8b75-ab6e-11ea-933e-005056917a89; Thu, 11 Jun 2020 01:05:54 +0200 (CEST) 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: [PATCH 2/5] media-device: Add a complete flag to struct media_device Date: Thu, 11 Jun 2020 01:05:38 +0200 Message-Id: <20200610230541.1603067-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> References: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a complete flag to indicate if the media graph is complete or not. The use-case is for v4l2-async to set the flag when all subdevices are bound and that the flag be reported to user-space so it can learn when a graph is completely populated. Signed-off-by: Niklas Söderlund --- include/media/media-device.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/media/media-device.h b/include/media/media-device.h index fa089543072052cf..cd685c3a791c6c04 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -83,6 +83,7 @@ struct media_device_ops { * @serial: Device serial number (optional) * @bus_info: Unique and stable device location identifier * @hw_revision: Hardware device revision + * @complete: Graph completed flag * @topology_version: Monotonic counter for storing the version of the graph * topology. Should be incremented each time the topology changes. * @id: Unique ID used on the last registered graph object @@ -151,6 +152,7 @@ struct media_device { char serial[40]; char bus_info[32]; u32 hw_revision; + bool complete; u64 topology_version; From patchwork Wed Jun 10 23:05:39 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: 11599011 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 43D16159A for ; Wed, 10 Jun 2020 23:06:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 351FD2078D for ; Wed, 10 Jun 2020 23:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726768AbgFJXGC (ORCPT ); Wed, 10 Jun 2020 19:06:02 -0400 Received: from bin-mail-out-06.binero.net ([195.74.38.229]:7175 "EHLO bin-mail-out-06.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726453AbgFJXGC (ORCPT ); Wed, 10 Jun 2020 19:06:02 -0400 X-Halon-ID: ef9f9575-ab6e-11ea-933e-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id ef9f9575-ab6e-11ea-933e-005056917a89; Thu, 11 Jun 2020 01:05:54 +0200 (CEST) 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: [PATCH 3/5] v4l2-async: Flag when media graph is complete Date: Thu, 11 Jun 2020 01:05:39 +0200 Message-Id: <20200610230541.1603067-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> References: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When the notifier completes set the complete flag in the struct media_device. This flag can can then be reported to user-space to let it know the graph is complete. Signed-off-by: Niklas Söderlund --- drivers/media/v4l2-core/v4l2-async.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 8bde33c21ce45f98..331594ca5b3bb723 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -217,6 +217,11 @@ v4l2_async_notifier_try_complete(struct v4l2_async_notifier *notifier) if (!v4l2_async_notifier_can_complete(notifier)) return 0; +#if defined(CONFIG_MEDIA_CONTROLLER) + if (notifier->v4l2_dev->mdev) + notifier->v4l2_dev->mdev->complete = true; +#endif + return v4l2_async_notifier_call_complete(notifier); } From patchwork Wed Jun 10 23:05:40 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: 11599013 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 5629C175A for ; Wed, 10 Jun 2020 23:06:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 482A42078D for ; Wed, 10 Jun 2020 23:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbgFJXGD (ORCPT ); Wed, 10 Jun 2020 19:06:03 -0400 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:26526 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726553AbgFJXGC (ORCPT ); Wed, 10 Jun 2020 19:06:02 -0400 X-Halon-ID: effdd561-ab6e-11ea-933e-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id effdd561-ab6e-11ea-933e-005056917a89; Thu, 11 Jun 2020 01:05:55 +0200 (CEST) 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: [PATCH 4/5] mc-device.c: Report graph complete to user-space Date: Thu, 11 Jun 2020 01:05:40 +0200 Message-Id: <20200610230541.1603067-5-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> References: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If the graph in the media device is complete report it to userspace by setting the MEDIA_TOPOLOGY_FLAG_COMPLETE flag. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- drivers/media/mc/mc-device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c index c2ef5bb512a5fba0..d63792cc014279fc 100644 --- a/drivers/media/mc/mc-device.c +++ b/drivers/media/mc/mc-device.c @@ -242,7 +242,7 @@ static long media_device_get_topology(struct media_device *mdev, void *arg) int ret = 0; topo->topology_version = mdev->topology_version; - topo->flags = 0; + topo->flags = mdev->complete ? MEDIA_TOPOLOGY_FLAG_COMPLETE : 0; /* Get entities and number of entities */ i = 0; From patchwork Wed Jun 10 23:05:41 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: 11599017 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 8E9DC17EE for ; Wed, 10 Jun 2020 23:06:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76A40206F4 for ; Wed, 10 Jun 2020 23:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726777AbgFJXGD (ORCPT ); Wed, 10 Jun 2020 19:06:03 -0400 Received: from vsp-unauthed02.binero.net ([195.74.38.227]:8720 "EHLO vsp-unauthed02.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726753AbgFJXGC (ORCPT ); Wed, 10 Jun 2020 19:06:02 -0400 X-Halon-ID: f05f6433-ab6e-11ea-933e-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id f05f6433-ab6e-11ea-933e-005056917a89; Thu, 11 Jun 2020 01:05:55 +0200 (CEST) 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: [PATCH 5/5] rcar-vin: Do not unregister video device when a subdevice is unbound Date: Thu, 11 Jun 2020 01:05:41 +0200 Message-Id: <20200610230541.1603067-6-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> References: <20200610230541.1603067-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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 7440c8965d27e64f..6b0f13618556cac4 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -525,7 +525,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) { @@ -747,10 +746,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++) {