From patchwork Wed Aug 7 08:24:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13755953 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 CC19C1C9DE1; Wed, 7 Aug 2024 08:25:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723019107; cv=none; b=Tt6gnhZ59szF1JG7U0iC62HdLoES+B1bX6sOL2i8Mw4bTpw0A0gzZzwgHK59423ufILS9dKfeoZKjQZnL3Q7xfUF/qYCKPlhbWWBIjZ3tMRMzHtr72nodVvQLhKf78Y/Wzi2wCO/rRU4rGIhRj+CtTL0b4gD/fNVI4Wo4IkhlgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723019107; c=relaxed/simple; bh=trvx6jaFW75AON9rV+PaB3RuMLHq5M6NaMGGSTOG5b0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KJNyw1pvbGKoTX/b7Gew8VjdW1JHQhx3m7ZfdOXRv8ttJlJUbYC9wDWUQhm8AECRa35KiDkfEZAgli3lxMTNn9pgGiJoYEc9BJa7MkTvhz8cghmaAx5mJ3a5+YO3nqweQDq89QJLLmnw574zV1fjUNKT9sQxqWdSizbwLdr1SJg= 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=hchdrL6x; arc=none smtp.client-ip=60.244.123.138 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="hchdrL6x" X-UUID: 8626ca2a549611ef9a4e6796c666300c-20240807 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=5i0uIbVdvEKDwjGgpSGBLRCEjpPon9Aw/m+cLooxtlA=; b=hchdrL6x0yqTG57uePaozPCuyfPq0F8H3LgFSdyi0nlMRB9kKgbEuKpTwuS0qlYV6suHGgjFbswanrNqD80kMKDzMqHm/5jnRO4DWlo8S4a1+9IrO4g3YjbyW6twG07deBdIBcKKcWcSFi6DaHkGsCFG07y9xUHla6WabZjZ180=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:05a359b5-5874-4dfb-a065-a6d4b1be29d6,IP:0,U RL:0,TC:0,Content:0,EDM:-30,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-30 X-CID-META: VersionHash:6dc6a47,CLOUDID:8d8e46fe-77bb-433c-b174-ffb8012693b0,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:2,IP:nil,UR L:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,S PR: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: 8626ca2a549611ef9a4e6796c666300c-20240807 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1257363713; Wed, 07 Aug 2024 16:24:54 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 7 Aug 2024 16:24:51 +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.1118.26 via Frontend Transport; Wed, 7 Aug 2024 16:24:51 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , "Yunfei Dong" , , , , , , Subject: [PATCH v4 5/7] media: mediatek: vcodec: store source vb2 buffer Date: Wed, 7 Aug 2024 16:24:35 +0800 Message-ID: <20240807082444.21280-6-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240807082444.21280-1-yunfei.dong@mediatek.com> References: <20240807082444.21280-1-yunfei.dong@mediatek.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--8.493400-8.000000 X-TMASE-MatchedRID: WY68sLfT96+SDoYDmYjzLAPZZctd3P4BSjyMfjCRfaMdbuyvB6mjXBa5 2myIWiom6akcHd5iadlNEOwtHhbbvlIMRaTXK1BM4RtSDjG+z7Dt/okBLaEo+MA0eOJZYj7thL9 xNXVrt1S5sKf/odud/uztdCjtxnSM4vZjlIwkBi8SEYfcJF0pRZYcYQ11P5U/myiLZetSf8mfop 0ytGwvXiq2rl3dzGQ1wqlxFFNgYzXo0jGXNiJLafAnx8F8tZmaKJywXlyBY9FYi5vGM9MT8sC+k sT6a9fy X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.493400-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 54638FC186E42D7A37EA7B591EBFA8021FE6499DA4B60AFF12273B38CAE3C4672000:8 X-MTK: N Store the current vb2 buffer when lat need to decode again. Then lat work can get the same vb2 buffer directly next time. Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h | 2 ++ .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h index 1fabe8c5b7a4..0817be73f8e0 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h @@ -155,6 +155,7 @@ struct mtk_vcodec_dec_pdata { * @last_decoded_picinfo: pic information get from latest decode * @empty_flush_buf: a fake size-0 capture buffer that indicates flush. Used * for stateful decoder. + * @last_vb2_v4l2_src: the backup of current source buffer. * @is_flushing: set to true if flushing is in progress. * * @current_codec: current set input codec, in V4L2 pixel format @@ -201,6 +202,7 @@ struct mtk_vcodec_dec_ctx { struct work_struct decode_work; struct vdec_pic_info last_decoded_picinfo; struct v4l2_m2m_buffer empty_flush_buf; + struct vb2_v4l2_buffer *last_vb2_v4l2_src; bool is_flushing; u32 current_codec; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c index 2a7e4fe24ed3..8aa379872ddc 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c @@ -320,7 +320,7 @@ static void mtk_vdec_worker(struct work_struct *work) struct mtk_vcodec_dec_ctx *ctx = container_of(work, struct mtk_vcodec_dec_ctx, decode_work); struct mtk_vcodec_dec_dev *dev = ctx->dev; - struct vb2_v4l2_buffer *vb2_v4l2_src; + struct vb2_v4l2_buffer *vb2_v4l2_src = ctx->last_vb2_v4l2_src; struct vb2_buffer *vb2_src; struct mtk_vcodec_mem *bs_src; struct mtk_video_dec_buf *dec_buf_src; @@ -329,7 +329,7 @@ static void mtk_vdec_worker(struct work_struct *work) bool res_chg = false; int ret; - vb2_v4l2_src = v4l2_m2m_next_src_buf(ctx->m2m_ctx); + vb2_v4l2_src = vb2_v4l2_src ? vb2_v4l2_src : v4l2_m2m_next_src_buf(ctx->m2m_ctx); if (!vb2_v4l2_src) { v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); mtk_v4l2_vdec_dbg(1, ctx, "[%d] no available source buffer", ctx->id); @@ -383,8 +383,13 @@ static void mtk_vdec_worker(struct work_struct *work) v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl); v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx, state); } else { - if (ret != -EAGAIN) + if (ret != -EAGAIN) { v4l2_m2m_src_buf_remove(ctx->m2m_ctx); + ctx->last_vb2_v4l2_src = NULL; + } else { + ctx->last_vb2_v4l2_src = vb2_v4l2_src; + } + v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); } }