Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2120308ybh; Fri, 24 Jul 2020 05:04:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzziDQI/ufiTmUfoLs9QEDPUabKnCOk4sxW06ipxRE3zwDJXZIEhx+aqoh+Z4X9qhtjDOxh X-Received: by 2002:a05:6402:1659:: with SMTP id s25mr1361503edx.153.1595592251039; Fri, 24 Jul 2020 05:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595592251; cv=none; d=google.com; s=arc-20160816; b=Cko9wjpfIPublw61+TpXSGuUzu0u0kfJmGonW0Z9wxTDq7HpLpt9AMYxNx5rTWOB38 /OI5dwO6SKExqroQOE89Qf/J/rSmEmoxvN5YM9GnMq2dXcjawGIbADJMg4VJmhyAJtvI MsNZBu2q67EOIgGzlGg+dL1kNmYRxU7IMa/XDwHj2gbfqJwfleKTHrwXgWfjW/PYOLHi cIFycWUYu53pHdWlXuQx7sPz7/3i/dDTonu9KMIChNwGDZFnQNdvBAqb4QDulHHtqPQi A+nzxvc6ct6prv9jW7iOH2dqils4UN9UTJGYyVeO+QF36xyWLg26labnGg0MsmErLi1x 7ArA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VKngwrDwYgMZRpBa5N9RttIghmCEGJz3vjqXKKgCKYk=; b=Ia7n3ucvcQTh5W2WiCwlxbMXHi/AbuTDEpbAw/o6lEeje5mLQwRHu2Y9YB/wH/whMY aJMcSjDpNnaPKEA56DRgb90PihzHBUZUv6vmF6epUt9R8wumRE6+4CKjJnvfMEXif0V2 ik6PHyya5+pSST0+woLdUvAfn74GBhGuoemyM8P3MZEZykpBjRCdLaHNspGv/aTss18a FgcSItT8fZisRBQnh93x7TjOAE8Wh/SqEvOLAaz/fHZFR8LqQgvb4y5daISPliDkZzUp Im+23bG+2GaWW0F8eiTaKA54LL5f5D63UoV7YEGNd3KlIUB41KAJ+o1+ZlvKUE6cSivp SHhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.s=20150623 header.b=Y9nHFo1t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=iitr.ac.in Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck9si343374edb.560.2020.07.24.05.03.48; Fri, 24 Jul 2020 05:04:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.s=20150623 header.b=Y9nHFo1t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=iitr.ac.in Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727991AbgGXMCn (ORCPT + 99 others); Fri, 24 Jul 2020 08:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727990AbgGXMCk (ORCPT ); Fri, 24 Jul 2020 08:02:40 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87F02C0619D3 for ; Fri, 24 Jul 2020 05:02:40 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id k27so5114941pgm.2 for ; Fri, 24 Jul 2020 05:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VKngwrDwYgMZRpBa5N9RttIghmCEGJz3vjqXKKgCKYk=; b=Y9nHFo1tSKAnjffVi8kwBLAhbHp18RkjpUlSYPHC5SLF6ED+aAi8ub0ltlRPvNOo6m jyRVYf50yN+B368eh0I9OOPp0FGE2rVkkkPe8Dl0zntj2+6UtzM9TT8LnXYpEviCFHnj AO9WiXksWr8YJUBFdDCP05mzFPBm1kVCvZhEtHv6WVMgvxDwG4o0KIb6CTSZTXjfwA32 QTJ1McDzGMLXsUqcr4K/Hc52U/uZzAh0FtwjJfxcmknTx4AfjUNamWAvycYFBFyqWW2f kP05t82lXJJmJCjHWHPoH3FY+lH2DDHsI2quYHe4UVCQ5LZWaRC3UsO+iuPw0c5NqJiV O3Og== 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:mime-version:content-transfer-encoding; bh=VKngwrDwYgMZRpBa5N9RttIghmCEGJz3vjqXKKgCKYk=; b=CyONZ2bvmOxNUfVTXoOFZcHVEOoS9738lGKBSPMV91xjzFJwCAIbHCy7HFuhDANsfs T0qBh53iTnEFI4yk/jprIq7Cc89hR7ivv5KS9LNbwKan3k5lHPyTJsbp7hGsouX0Jxir 7SXScyTxyOf7L20qnOrZR7dFq4nqY+C7gpBqUKmNtE0iB8BXaeexc9GGDvkL6+SWPf65 GccrNHazrCZRBJB3baTIdWUiqdicAR1I5ggOOd4FF3i0v8L03DiSLmDuKCHVv+1i7iQ3 1sn62eBkyr4O213NNmvDI/njLcvRB1wWJgioiEPsWlR0OXJXh5mzDx2cIx/A0hrqhNOU SzWQ== X-Gm-Message-State: AOAM530YCIS5Y5UjFmgaMl/8+a8Fv9VLc4O6ZQ94/hFcWf4WCUh1DhqX eJHWLgq+SwB4Q261MfLJQ/Ugaw== X-Received: by 2002:a62:e217:: with SMTP id a23mr8616963pfi.257.1595592160037; Fri, 24 Jul 2020 05:02:40 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.178]) by smtp.gmail.com with ESMTPSA id w71sm6455658pfd.6.2020.07.24.05.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 05:02:39 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Cc: Kaaira Gupta Subject: [PATCH v2 3/3] media: vimc: Join pipeline if one already exists Date: Fri, 24 Jul 2020 17:32:13 +0530 Message-Id: <20200724120213.17119-4-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200724120213.17119-1-kgupta@es.iitr.ac.in> References: <20200724120213.17119-1-kgupta@es.iitr.ac.in> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An output which is running is already part of a pipeline and trying to start a new pipeline is not possible. This prevents two capture devices from streaming at the same time. Instead of failing to start the second capture device allow it to join the already running pipeline. This allows two (or more) capture devices to independently be started and stopped. [Kaaira: Changed the search for an existing connected sensor, to search for a non-NULL pipe instead, this helps to terminate the search at output itself instead of going till the sensor, changed variable names, commit message and conditions accordingly] Signed-off-by: Niklas Söderlund Signed-off-by: Kaaira Gupta --- .../media/test-drivers/vimc/vimc-capture.c | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c index c63496b17b9a..423d5e5a508d 100644 --- a/drivers/media/test-drivers/vimc/vimc-capture.c +++ b/drivers/media/test-drivers/vimc/vimc-capture.c @@ -237,16 +237,49 @@ static void vimc_cap_return_all_buffers(struct vimc_cap_device *vcap, spin_unlock(&vcap->qlock); } +static struct media_entity *vimc_cap_get_output(struct vimc_cap_device *vcap) +{ + struct media_entity *entity = &vcap->vdev.entity; + struct media_device *mdev = entity->graph_obj.mdev; + struct media_graph graph; + + mutex_lock(&mdev->graph_mutex); + if (media_graph_walk_init(&graph, mdev)) { + mutex_unlock(&mdev->graph_mutex); + return NULL; + } + + media_graph_walk_start(&graph, entity); + + while ((entity = media_graph_walk_next(&graph))) + if (entity->pipe) + break; + + mutex_unlock(&mdev->graph_mutex); + + media_graph_walk_cleanup(&graph); + + return entity; +} + static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count) { struct vimc_cap_device *vcap = vb2_get_drv_priv(vq); struct media_entity *entity = &vcap->vdev.entity; + struct media_pipeline *pipe = NULL; + struct media_entity *oent; int ret; vcap->sequence = 0; /* Start the media pipeline */ - ret = media_pipeline_start(entity, &vcap->stream.pipe); + oent = vimc_cap_get_output(vcap); + if (oent) + pipe = oent->pipe; + else + pipe = &vcap->stream.pipe; + + ret = media_pipeline_start(entity, pipe); if (ret) { vimc_cap_return_all_buffers(vcap, VB2_BUF_STATE_QUEUED); return ret; -- 2.17.1