From patchwork Fri May 30 07:45:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrie Wu X-Patchwork-Id: 893476 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30B8621170D; Fri, 30 May 2025 07:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748591157; cv=none; b=tbF0hwLwPqiEgviErZp0bKk0emdrXieMeZqct/ns1PboIqfjQk8SbWnstxfcW4UJnHPociyCiiVXygED3qvWspYuRah5MbQRtiF+YjauCGf0zzFni92eTOJGSznu6rsyWibkcRGi+OCfmOOWqVLBEvm4NVB2Tq9OOnKtbE/07xs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748591157; c=relaxed/simple; bh=WbuLiynWujGvmB8DLZCSZXSoK4mcPAGIbfDFH/YsvXs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TPKmTyT1BjZlfexogZF+wEcYOO/IjC/seJ1Mivli9uu9cgXc2sTtfNZyy2Wbp6Pl8qyVhraldn1CLJZ7zEIdUWDtViv9sr03DbTkVI+CjtwdwW93+FEJ8VUsKM1I6nhsUKs2t+9b/iDVx3u/TaRUCRNP2K2ixPLyVj4VMxluUcI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=Cd0RsXmj; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Cd0RsXmj" X-UUID: 1b934de63d2a11f082f7f7ac98dee637-20250530 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=N0tPegYoongyaCY6bs5X+PjA8xXy8hsIicZmNQUSMw8=; b=Cd0RsXmjZx8naoG2lcsLyQJO2NHGqWGzCF0tIS6h3F3J2oGp8nQhVGkBTMWKG6yLBtNQJ+wHl9P2sJ0Ps5uZqNic4P3NNnT3V4PbojQRB1NAys4p5NgxsyHVO32sMsjOPZFZ6Ja4s2HbztFwACsRcIHXg+z9584XCsbIsN6xDfU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.2.1, REQID:bd6ac303-9956-4854-b8e1-648c8ebca034, IP:0, UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:0ef645f, CLOUDID:93b3e547-ee4f-4716-aedb-66601021a588, 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: 1b934de63d2a11f082f7f7ac98dee637-20250530 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 588569593; Fri, 30 May 2025 15:45:50 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.39; Fri, 30 May 2025 15:45:49 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1258.39 via Frontend Transport; Fri, 30 May 2025 15:45:48 +0800 From: Kyrie Wu To: Hans Verkuil , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Kyrie Wu , , , , , CC: Subject: [PATCH v5 11/12] media: mediatek: jpeg: refactor decoding resolution change operation Date: Fri, 30 May 2025 15:45:36 +0800 Message-ID: <20250530074537.26338-12-kyrie.wu@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250530074537.26338-1-kyrie.wu@mediatek.com> References: <20250530074537.26338-1-kyrie.wu@mediatek.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MTK: N 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 795916206c7c..eba9f58b9198 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -891,7 +891,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; @@ -1785,11 +1786,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) {