From patchwork Fri Jan 10 01:27:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?S3lyaWUgV3UgKOWQtOaZlyk=?= X-Patchwork-Id: 13933440 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7ADF7E7719A for ; Fri, 10 Jan 2025 01:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7XxeDT1yqk0joCSBlrR1vdvJ1IoLGgbPPLdPXNw3S7Y=; b=MeLLGIBKc1QKnlWNMnSnrxnV/f eh2lmEHc/7ZJvj6wCGKL6i6nHD3HbLGY2qNZAXx6c+EHEgcvPkj/Uiov73eESUKw1xV+NQbTOvRK5 mmoSlG5OxmJySXLTDP3ZpXx9ovhdj4BaOkNZhmLD2JWShjOcnudkHMwvYAihFjFIBZKxOecTY5cp6 xrDIkFCXc1PDMNaQJrB0azRC0xN25mdad4WmKjJkB6bzS1b57XK+HAyJHvoSICChN6p/eJpQaiH9R Lrs1Uy+qBm4aoYiTX0Bxk23VuwMDyb1BqYZ1qT46HmBqEPMjTdKbzOnLT8vDkg5ecoBVlFJ1yWwyU BhdgBl/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tW43F-0000000Dmhy-2Xgr; Fri, 10 Jan 2025 01:43:05 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tW3or-0000000DkSb-2AzC; Fri, 10 Jan 2025 01:28:14 +0000 X-UUID: 23fcc972cef211ef9048ed6ed365623b-20250109 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=7XxeDT1yqk0joCSBlrR1vdvJ1IoLGgbPPLdPXNw3S7Y=; b=GqqD0F/rRt/KcPxEaruCTAnNuvrgZHdhWzMrI81ZlqJULmlbq/97OGWwHFrCyDqpPS30SHtkOV8ABHfpIt+0LAE/KheDQSSFcrifbyvr+WnBAhrtv5DZiD/fxfF3/8qGCF2YZnT47AKZAk293ToHrHFmnYFypfp/1S1Z+J6LQW8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.46,REQID:54c7889f-9e1a-4d5a-ab55-c2e237b53271,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:60aa074,CLOUDID:2fcea637-e11c-4c1a-89f7-e7a032832c40,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV :0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 23fcc972cef211ef9048ed6ed365623b-20250109 Received: from mtkmbs09n2.mediatek.inc [(172.21.101.94)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 303212743; Thu, 09 Jan 2025 18:28:05 -0700 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 10 Jan 2025 09:28:02 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 10 Jan 2025 09:28:01 +0800 From: kyrie.wu To: Hans Verkuil , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tzung-Bi Shih CC: Rob Herring , Krzysztof Kozlowski , Conor Dooley , AngeloGioacchino Del Regno , kyrie wu , , , , , , kyrie.wu Subject: [RESEND,V1,11/12] media: mediatek: jpeg: refactor decoding resolution change operation Date: Fri, 10 Jan 2025 09:27:48 +0800 Message-ID: <20250110012749.30072-12-kyrie.wu@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250110012749.30072-1-kyrie.wu@mediatek.com> References: <20250110012749.30072-1-kyrie.wu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250109_172813_557516_898B3AC5 X-CRM114-Status: GOOD ( 14.57 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org For multi-core: 1.if there are only two src buffers, hw0 and hw1 are decoding at the same time. When resolution change occurred on one hw, the src buffer cannot be got in the stop streaming function, which will cause a crash. 2.When a resolution change occurs, immediately set the new resolution parameter to save the new resolution; 3.After a resolution change occurred, decoding should not continue, needs to wait until new buffers are ready and the state machine changed. Signed-off-by: kyrie.wu --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index 791fc064bc0a..2919fdd92d45 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -886,7 +886,8 @@ static void mtk_jpeg_dec_stop_streaming(struct vb2_queue *q) vb = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); src_buf = mtk_jpeg_vb2_to_srcbuf(&vb->vb2_buf); - mtk_jpeg_set_queue_data(ctx, &src_buf->dec_param); + if (!IS_ERR_OR_NULL(src_buf)) + mtk_jpeg_set_queue_data(ctx, &src_buf->dec_param); ctx->state = MTK_JPEG_RUNNING; } else if (V4L2_TYPE_IS_OUTPUT(q->type)) { ctx->state = MTK_JPEG_INIT; @@ -1752,11 +1753,15 @@ static void mtk_jpegdec_worker(struct work_struct *work) if (mtk_jpeg_check_resolution_change(ctx, &jpeg_src_buf->dec_param)) { - mtk_jpeg_queue_src_chg_event(ctx); + mtk_jpeg_set_queue_data(ctx, &jpeg_src_buf->dec_param); ctx->state = MTK_JPEG_SOURCE_CHANGE; + mtk_jpeg_queue_src_chg_event(ctx); goto getbuf_fail; } + if (ctx->state == MTK_JPEG_SOURCE_CHANGE) + goto getbuf_fail; + mtk_jpegdec_set_hw_param(ctx, hw_id, src_buf, dst_buf); ret = pm_runtime_resume_and_get(comp_jpeg[hw_id]->dev); if (ret < 0) {