From patchwork Mon Nov 7 14:18:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 16474 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2081740wru; Mon, 7 Nov 2022 06:26:40 -0800 (PST) X-Google-Smtp-Source: AMsMyM76JTN07yTUTf+KooJT7w5KmoT/g3/FZB131XSBkywL249dzoDLNv+XwEbS5eO/uc9ae4kW X-Received: by 2002:aa7:df94:0:b0:461:aff8:d3e1 with SMTP id b20-20020aa7df94000000b00461aff8d3e1mr51403023edy.10.1667831200151; Mon, 07 Nov 2022 06:26:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667831200; cv=none; d=google.com; s=arc-20160816; b=gNzI+jDxhqU0P5wKiB2BveruK9yhDpzfyqkavakKdd/XaQ/ksVnVp+weLzSmitDLIV csd3mCSzdQ7yukLXUx239ncbp8x72u0/+G7SLQValqHszpXq8u29LXvCHKoc+FfmvZus e/0hQHUehbjyiE6D+qQo2c3feogqSPBIf4KUlzPsmAq055qBaaxR/5DlO9IkT8lCrtAC CmqDkK1fv/B50wJow7kMouXnthyIsqiXi5GSq1BgDEDICz1qznlrKmh5qxI/KQbgyKEI iMKUJ62jFSnrlqyKa7//xaGDBKrb57sfZH2J9DxVFRXigGuPozZ47cwwLz/Rk9We2Rsu gZ+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cSn+m4dhkw/qQX6bln9eDcHBgT/dXJxFRWSJNnu7suk=; b=nfw2hys5cGnqV1p/MeoKiECd5u3OE5V6vcvK3tvgPiYJlgILESjWo1mRzeur/WVrYI rnNDz1enykz0M1vEPwjlzK+WD/V6keOD4WGZ/rYUAbGOxsqz4NN0M6iZCr6gnzyj4whZ AH3+l3lm0vOJwhzlSNS5ZUsIxmxQHHhqB84KgfxMFHFnc3ubd5KEQSREy9LTWgMp43lQ h5xgA2nItTuh7uOBvuRynAiaxpS8VZAkTBysF+9I1kwWQA9Nje0PSocZiKJr+EpuyjXS rnyWzJtWmtNEm3a7KowtRbvA3CrGX2GclOPQ7lnP/2HVgHCd6ejSonK1XycEDRo2rhp1 jHkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=mTZ9Wg1W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a50eb0d000000b004588af9ea19si9317463edp.166.2022.11.07.06.26.15; Mon, 07 Nov 2022 06:26:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=mTZ9Wg1W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232458AbiKGOYm (ORCPT + 99 others); Mon, 7 Nov 2022 09:24:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232361AbiKGOYP (ORCPT ); Mon, 7 Nov 2022 09:24:15 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C5123E95; Mon, 7 Nov 2022 06:19:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1667830763; x=1699366763; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/luAN7OA0doORJetnI5tF2uTnMhfUCA9gIxuQ14Fh70=; b=mTZ9Wg1W2OzIk9Zdip1gk4ATiIv2PytebL+mLrCAfZviaxVTRP9R28jA 7W9HuQQEQ/t/x1gTwteuYBSgFb3E3Z1e3xcILcw7DEcspwiu3cpUAGU7q mtbxacwjRIKGoVdtRD2199VkacXmqaleDfCRxzHKsAGNz9n+gG1fbRbF7 ZANbCy9BEUMCyRmjIWWovXrJYtCUhl0fPxc3XAEr3jduwviRW2vzhMq97 YDRV3kVK5D+5grqlgabQQcO6pa4ioDMogS1TZM0SEVA/rvkb2yAw8YVGy ouU3pnzMQI8Pvjxbz35CXWHep+45HyO9+SmnCpu9VmGTGYbfhKaaJrPR8 g==; X-IronPort-AV: E=Sophos;i="5.96,145,1665471600"; d="scan'208";a="198727476" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 07 Nov 2022 07:18:39 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Mon, 7 Nov 2022 07:18:39 -0700 Received: from ROB-ULT-M18282.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Mon, 7 Nov 2022 07:18:37 -0700 From: Eugen Hristev To: , , , CC: , , Eugen Hristev Subject: [PATCH v12 5/6] media: microchip: microchip-isc: move media_pipeline_* to (un)prepare cb Date: Mon, 7 Nov 2022 16:18:17 +0200 Message-ID: <20221107141818.104937-6-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221107141818.104937-1-eugen.hristev@microchip.com> References: <20221107141818.104937-1-eugen.hristev@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748847768243306473?= X-GMAIL-MSGID: =?utf-8?q?1748847768243306473?= Move the media_pipeline_start/stop calls from start/stop streaming to the new prepare_streaming and unprepare_streaming callbacks. Signed-off-by: Eugen Hristev --- .../platform/microchip/microchip-isc-base.c | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c index 28749a09b0c3..e2994d48f10c 100644 --- a/drivers/media/platform/microchip/microchip-isc-base.c +++ b/drivers/media/platform/microchip/microchip-isc-base.c @@ -328,6 +328,13 @@ static int isc_configure(struct isc_device *isc) return isc_update_profile(isc); } +static int isc_prepare_streaming(struct vb2_queue *vq) +{ + struct isc_device *isc = vb2_get_drv_priv(vq); + + return media_pipeline_start(isc->video_dev.entity.pads, &isc->mpipe); +} + static int isc_start_streaming(struct vb2_queue *vq, unsigned int count) { struct isc_device *isc = vb2_get_drv_priv(vq); @@ -336,10 +343,6 @@ static int isc_start_streaming(struct vb2_queue *vq, unsigned int count) unsigned long flags; int ret; - ret = media_pipeline_start(isc->video_dev.entity.pads, &isc->mpipe); - if (ret) - goto err_pipeline_start; - /* Enable stream on the sub device */ ret = v4l2_subdev_call(isc->current_subdev->sd, video, s_stream, 1); if (ret && ret != -ENOIOCTLCMD) { @@ -389,9 +392,6 @@ static int isc_start_streaming(struct vb2_queue *vq, unsigned int count) v4l2_subdev_call(isc->current_subdev->sd, video, s_stream, 0); err_start_stream: - media_pipeline_stop(isc->video_dev.entity.pads); - -err_pipeline_start: spin_lock_irqsave(&isc->dma_queue_lock, flags); list_for_each_entry(buf, &isc->dma_queue, list) vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED); @@ -401,6 +401,14 @@ static int isc_start_streaming(struct vb2_queue *vq, unsigned int count) return ret; } +static void isc_unprepare_streaming(struct vb2_queue *vq) +{ + struct isc_device *isc = vb2_get_drv_priv(vq); + + /* Stop media pipeline */ + media_pipeline_stop(isc->video_dev.entity.pads); +} + static void isc_stop_streaming(struct vb2_queue *vq) { struct isc_device *isc = vb2_get_drv_priv(vq); @@ -430,9 +438,6 @@ static void isc_stop_streaming(struct vb2_queue *vq) if (ret && ret != -ENOIOCTLCMD) v4l2_err(&isc->v4l2_dev, "stream off failed in subdev\n"); - /* Stop media pipeline */ - media_pipeline_stop(isc->video_dev.entity.pads); - /* Release all active buffers */ spin_lock_irqsave(&isc->dma_queue_lock, flags); if (unlikely(isc->cur_frm)) { @@ -472,6 +477,8 @@ static const struct vb2_ops isc_vb2_ops = { .start_streaming = isc_start_streaming, .stop_streaming = isc_stop_streaming, .buf_queue = isc_buffer_queue, + .prepare_streaming = isc_prepare_streaming, + .unprepare_streaming = isc_unprepare_streaming, }; static int isc_querycap(struct file *file, void *priv,