From patchwork Tue Sep 20 14:33:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Milen Mitkov \(Consultant\)" X-Patchwork-Id: 608133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 334F9ECAAD8 for ; Tue, 20 Sep 2022 14:35:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbiITOfc (ORCPT ); Tue, 20 Sep 2022 10:35:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231625AbiITOf2 (ORCPT ); Tue, 20 Sep 2022 10:35:28 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01FDA2A723 for ; Tue, 20 Sep 2022 07:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1663684526; x=1695220526; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GrTtXyw3LwMpYy+O6xjoKOXG8mtQt9xYXSfxY5dD+M4=; b=UfwezilN9NiZUWuG3XRUEgRsqoTGkR7hRoMij5e81f7fIALWQTR2ekrr qmiGP9o+wvqEDop1EPbbOxYqwaIztF/KXs53LfqrJ+VFYT3Oq91kcLOz1 XxeOjLkArbNzX0TQIkXUiwaz9ISCwGwhzWVUY/IR4dXy5+cKuObQmfj4c 4=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 20 Sep 2022 07:33:24 -0700 X-QCInternal: smtphost Received: from unknown (HELO nasanex01a.na.qualcomm.com) ([10.52.223.231]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2022 07:33:24 -0700 Received: from mmitkov.eu.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 20 Sep 2022 07:33:22 -0700 From: To: CC: , , Milen Mitkov Subject: [PATCH 4/4] media: camss: sm8250: Pipeline starting and stopping for multiple virtual channels Date: Tue, 20 Sep 2022 17:33:00 +0300 Message-ID: <20220920143300.1633-5-quic_mmitkov@quicinc.com> X-Mailer: git-send-email 2.37.3.windows.1 In-Reply-To: <20220920143300.1633-1-quic_mmitkov@quicinc.com> References: <20220920143300.1633-1-quic_mmitkov@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Milen Mitkov Use the multistream series function video_device_pipeline_alloc_start to allows multiple clients of the same pipeline. If any of the entities in the pipeline doesn't return success at stop (e.g. if a VFE line remains running), the full pipeline won't be stopped. This allows for stopping and starting streams at any point without disrupting the other running streams. Signed-off-by: Milen Mitkov --- .../media/platform/qcom/camss/camss-video.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c index 81fb3a5bc1d5..b042faf3dcda 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -353,6 +353,7 @@ static int video_get_subdev_format(struct camss_video *video, fmt.pad = pad; fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; + fmt.stream = 0; ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt); if (ret) @@ -493,9 +494,11 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count) struct v4l2_subdev *subdev; int ret; - ret = video_device_pipeline_start(vdev, &video->pipe); - if (ret < 0) + ret = video_device_pipeline_alloc_start(vdev); + if (ret < 0) { + dev_err(video->camss->dev, "Failed to start media pipeline: %d\n", ret); return ret; + } ret = video_check_format(video); if (ret < 0) @@ -536,6 +539,7 @@ static void video_stop_streaming(struct vb2_queue *q) struct media_entity *entity; struct media_pad *pad; struct v4l2_subdev *subdev; + int ret; entity = &vdev->entity; while (1) { @@ -550,7 +554,18 @@ static void video_stop_streaming(struct vb2_queue *q) entity = pad->entity; subdev = media_entity_to_v4l2_subdev(entity); - v4l2_subdev_call(subdev, video, s_stream, 0); + ret = v4l2_subdev_call(subdev, video, s_stream, 0); + + if (ret == -EBUSY) { + /* Don't stop if other instances of the pipeline are still running */ + dev_dbg(video->camss->dev, "Video pipeline still used, don't stop streaming.\n"); + return; + } + + if (ret) { + dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret); + return; + } } video_device_pipeline_stop(vdev);