From patchwork Thu Apr 14 09:00:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 12813204 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 EA6C1C433FE for ; Thu, 14 Apr 2022 09:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=vSrVu5KmJD9vYkI+azuEhDHvDORsFy8jJY8NlyX7T6I=; b=TWEcTACfsa0+iR 8PLjBLpmxFvaTY9gKR6H3S5veKGn5elTSfzm8iFoe5gUuwsn6qlTShTdIQjigzOxMXyytDSntZY63 MrnzYovjM7rtrTYypaO61T82WWlWRDXda+bLfDftvzEU0TmQEXwNdfeoMTkVhqtmc+cN8RxhonvBx mEJjoWnZzNB6FQOpB2MIeN9UjbWOQTzy/zmZsPWt4gat88XGeLLsKMADMuC5oym/bAKXhqgn1ZxIf 2slnTOmXMH+VGojhQ50frmkQfr3d0UWVKwbhQKzjxk8kSvNZjmohTJzG6tWjb5zCXCfJIQtmM9gpT ThAJU/X3pBejkK8ySz/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nevb5-004plr-2f; Thu, 14 Apr 2022 09:17:04 +0000 Received: from mail-vi1eur04on060f.outbound.protection.outlook.com ([2a01:111:f400:fe0e::60f] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nevaw-004phU-Ez for linux-arm-kernel@lists.infradead.org; Thu, 14 Apr 2022 09:16:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZWMKuSKcpoZirL/K4UgQ3Tp9ehFwqN2ZlV3wbct/VeCaSjcbgAxJRyMuXwKpNULjib+7ajZkuvYht6KXYMbgmjPaNSqIOsZdyjbuSz+1iA3XOHMexUNcch7c3cDbmgPpj0F6xiMvTxN8drGsBHHDeOnKvtVEiIbrNpT/qBF75Nqi/pEB9+A8es6U2vPnTQv38K+6OzcRMV3OiCrj1z+TD7tZijlcZVy/1vsyER+sxR8h4YqiNL6ooMdZ2wCTvyMaY2PPJ39o2xT69t22HOkcS5YyuZgIipXN9aryRtp/T7Rkg4ZmehST+WSnlfnavwg4aZQZ8h6YeBiU4NwJuNJLaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7Bekbt61buxMplQ5Q0eevV5Ix/Ch+zmQox+vaxzEZks=; b=FdX2U+6DbWh8A1BZXFalWtYTSD99XQwC1oBLTfF5jtc7PPaJjFLFHVnMSPhC4xn8oDLgaAaN40WHogclOIMP02sCxl2thzF6TJFJEIb63gSTitEp7cRdGs4lXlJj6RAJHsjPy/uV6CRIPFeWYFMkYwASvlw7y1q856qMS4to+EeVU7Zjgv/sb9lrvueH00Ozh2y4G1mQwKFOAcvj47xLjiHABDnXA6kgRvlJgZ1u38jrSjYRZ7vu8p0l5IaAQsPb6y/G5jdEx3wyc/vUeEkNpTzHkjUyYd1sA619e5P00sJgUsgNwOD91Y5hh8VcgBq0PkrC5l9JGcj7vJAQjTiEFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7Bekbt61buxMplQ5Q0eevV5Ix/Ch+zmQox+vaxzEZks=; b=Wqby0vNNkLhhQg3Fg3dYykVO+Q8FJ/e7MJsbWfD2ixvSOaf3kqSYAOYaR95gb7zENrY4AAvpk0Pdj6GVRSichYYo7pNexAVzL3Krcm3sZHYhBSTr10s+lkKVwzf98VS7h3mB0IO8FjlJxj/LgnwuaTkHDGS0I/gY4ob1DCAd7Uc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM7PR04MB6885.eurprd04.prod.outlook.com (2603:10a6:20b:10d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.30; Thu, 14 Apr 2022 09:01:11 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::d8b5:5914:5189:ffa5]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::d8b5:5914:5189:ffa5%6]) with mapi id 15.20.5164.020; Thu, 14 Apr 2022 09:01:11 +0000 From: Ming Qian To: mchehab@kernel.org, shawnguo@kernel.org Cc: hverkuil-cisco@xs4all.nl, robh+dt@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, aisheng.dong@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 1/2] media: amphion: decoder copy timestamp from output to capture Date: Thu, 14 Apr 2022 17:00:29 +0800 Message-Id: <1fd290193c6c49cee4911abb2ebc22e41817528c.1649753693.git.ming.qian@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: X-ClientProxiedBy: SG2P153CA0011.APCP153.PROD.OUTLOOK.COM (2603:1096::21) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8746e8ab-a440-478c-1863-08da1df55277 X-MS-TrafficTypeDiagnostic: AM7PR04MB6885:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eAd5jIIadRbKhv7II/O0xqg3cNXLbhDCWETBl8wwRy+maHxfBH0kbIqJLuwSFNkMItHxoMVIw1EreLFZcmUIwY6YAWUgQOtPIbnoeXdHclCoig1Q7DNK6IxCRGU7EsZcEN1oTY29OKmaljeFU21yV5JVVlFghL1tRlVRApTrLvItzGFw+MHNbq651IOs+8qGkp5o2U/D+WNU7kPfL29gKrfH5q7MHsI0zuQCed6nDeKbULCdleH4XVq2waR0NKdUuNCEW30xTm2HA8imb8dbWP1cfbhTZ/gFtfC9zyZKLNsZiK+JKBr5tP4F3qvSIV3OvHjq0bE8p9RgQjHEPV5eSUT2+v5fs5rTFPgl+g8qluQnOayIL2d8hV4km3FIsDDnqvCCMkFaHpFKengWsI7SbC/g0ucLixyHFeJFsaLz10ZAyEg99dgYhdLeoMYfTY9KCywAIuPDp7H1zrFMMeu5EAPduVirfopZ8PvpRPu/btKjoAu9pFWI7DUizYjLNR+d0PqF6moYFnQs4gddIgKBT2czxa4U2LlOhfRIR5EEaseTkaio7O+KU5hJ/0RKXWcvLdGsYFXQtPzCYo3W3UNkURDQf2uCfXh3MxdQzZUbWHSogxT1FBbT3g+oh1W0bWJxmGbBsD2NXUAlL7JTSoZHZ9mSH0ZiFSCU9ECPoVct8e4agwOf3Ba4h6hrNxuBliY0bZZH9uoPhBQSLIa3BT6G2g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(38100700002)(38350700002)(2616005)(83380400001)(5660300002)(66556008)(8676002)(52116002)(86362001)(186003)(26005)(7416002)(66946007)(4326008)(36756003)(2906002)(8936002)(44832011)(6486002)(6666004)(508600001)(6506007)(6512007)(316002)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B4kIqaX6fzObOug4nZVQ4GcqbA+bHSrK3BiZXR4rMNg6TqOOewq5LpPKREYcaP1+ohquAWNBywmgPx78+oPYv+DeAs4I1L/u3zHavhi8e7aeYyi95gja1m5ltAiEd+OD6FxMe03IWvDjD91kW+8+jXrCuIK+Zvb/HTOcUlePa6mKJ1kSrq0RmYwXUMynMFmYWfmI4gJS37E+X8exAflu7qhVLjBdLkIVVWMR/dxXdgUmitoyO2Xn7FQIVePl7ENfmmyfII3MQmA35DayE9Y3VrG9cE6tBqp4LVXNQX4lHlJcW3ShbyDuHAQFBKevsfcbzbqHrsImpTaBFDPZj42D14+kiE7j7eA/A8da/p5pFdguk84CUvd1lq7Gnf6ICmMtHm3X1qOo1abSfy74+nEhPpM9gPvT+Vu4ukEAf88ZTJnOSgVVbW6dqGmPI6kWvm/CcbcQHZnUrfmFUeOgjTP2jTRr+IjUx2F8kM0areoAONT3SUMHCw7kIb7EPMoMmLJcyXdx0OuIzmcCzwL0IQ6Opm+MBYVlpVM53zAd/tHk+S/zHej+knkdXMVXDuFUvI15Z/VnOo6VhgVd2SDX1g6J79NxQdiDL7NghbhCaHruHKFa/T0ndZXV5i7FtlXeFpOXBJmHFzxpqkvqGcfOCuIs1TfCUZ9VDFLmlT7Oq4vRoO4YlFxEl2I4AzYta4dRZfN5B8p/WK74Z5dyfppK/8DW3qmQbNfWHvjpOVtSExUxxWKG6VNPpM47g0YG3zPfjkKsjx9GVT15Tp/7babxUgJQ1klCly/K4vtO9JxlXa2ZtLWNCSJ1gheT48xieEqBL+CJYuXDFdv11u268azILnzZCY4QBc2VAhjwblKJ5NpTUfxySzlfDb9kpC5PtZzCw+4ofOU1tFi8vU0nG6XZpybvZcS9JBMDkA/+xe1bTxOVdwW0Rh7JEAAipphYKM+Dv5zD8NIgVu06MvHdgLEGscJSPeNguOGBvvRYpXzDIxiU4+dLo/P9FTLbySrJwWzj6WrMwNl290NJzgn+4IYpISrALgg8f8RsgH/Ci1ql9qSgy+rAJK+Ycxh1MDIaR4/eoB+3Ykwmcm2w+INT6VkhdXDr+uONImkiWDiErmeTkoBxWxL+JEopLZy7u+Pd9/n3wDob9ELgozlGdjfdZ9Wu/Z8fCor7hJ8BHesY9Sp8LM7HhfFR9opvrSvEp57pk0ZlvjcQb/Ir7tHzjZsJulYOlk7Lw8D+2ttJKABTolWzp/h2YOXphDiACndHWnFauI4Qc87r9ResESXltznQKERdSsJv6Leva+s7QcaBvqCQObpgEoChG3nlLzAdo4y/T8yAkIXE+wnqWO0JRfr6qAcDrJDusta8TDpwrjJ3wSpWMgLdcffk5BpNGWBbmwPIZJHaNrKAyz0bkoihQOyCU9pMdU1lRom80lGkYFFmqMKiJ/DFjsIRbzq2q+5YbpKmFRLMUwRoyiDwxlLhOc4owuuoU5jY8KEjFdDuUxsnIBkXi4pe01StO7UpStTRhj/1CBDxJ+50xsvjX73UduklWde3n8cpikX4gCetzd9Zuq6EAtAYSiB93r+UtxljwmRn3+9yOA5+P9DRKoGj+AEkH3NiSSElKsagz+1ku0WEB7OQcdM9IlMOvN83sJkPbfo4KxO8UZB5vcYDGOUFdKt3pHG9FkKIY/lDv7Zhw3aiiINp4bME4+sQXLwMU+z1QIbTQWh1Bu7k94L4vudsNz3n99uoi7niDA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8746e8ab-a440-478c-1863-08da1df55277 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2022 09:01:11.7044 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: d5q2+uhleAsmA2OI3wS5vn4ISNfTFM2dyCmquLvk28NPwS458tGy1rGLemEcg0mIicCOubf7ABu0l8FoP3BTuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6885 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220414_021654_722152_60CCC051 X-CRM114-Status: GOOD ( 22.36 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org copy the timestamp using the helper function V4L2_BUF_FLAG_TIMESTAMP_COPY To implement this, driver will keep the output buffer until it's decoded, in previous, driver will return the output buffer immediately after copying data to stream buffer. After that, there is no need to make a workaround for poll function. driver can use v4l2_m2m_fop_poll directly. Also, driver don't need to keep a input threshold as the buffer count is up to only 32. Signed-off-by: Ming Qian --- drivers/media/platform/amphion/vdec.c | 89 ++++++++++------------- drivers/media/platform/amphion/vpu_v4l2.c | 13 ++++ drivers/media/platform/amphion/vpu_v4l2.h | 1 + 3 files changed, 54 insertions(+), 49 deletions(-) diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c index 8f8dfd6ce2c6..09628dd0c855 100644 --- a/drivers/media/platform/amphion/vdec.c +++ b/drivers/media/platform/amphion/vdec.c @@ -26,8 +26,8 @@ #include "vpu_cmds.h" #include "vpu_rpc.h" -#define VDEC_FRAME_DEPTH 256 #define VDEC_MIN_BUFFER_CAP 8 +#define VDEC_MIN_BUFFER_OUT 8 struct vdec_fs_info { char name[8]; @@ -63,8 +63,6 @@ struct vdec_t { bool is_source_changed; u32 source_change; u32 drain; - u32 ts_pre_count; - u32 frame_depth; }; static const struct vpu_format vdec_formats[] = { @@ -470,7 +468,7 @@ static int vdec_drain(struct vpu_inst *inst) if (!vdec->drain) return 0; - if (v4l2_m2m_num_src_bufs_ready(inst->fh.m2m_ctx)) + if (!vpu_is_source_empty(inst)) return 0; if (!vdec->params.frame_count) { @@ -589,11 +587,8 @@ static bool vdec_check_ready(struct vpu_inst *inst, unsigned int type) { struct vdec_t *vdec = inst->priv; - if (V4L2_TYPE_IS_OUTPUT(type)) { - if (vdec->ts_pre_count >= vdec->frame_depth) - return false; + if (V4L2_TYPE_IS_OUTPUT(type)) return true; - } if (vdec->req_frame_count) return true; @@ -601,12 +596,34 @@ static bool vdec_check_ready(struct vpu_inst *inst, unsigned int type) return false; } +static struct vb2_v4l2_buffer *vdec_get_src_buffer(struct vpu_inst *inst, u32 count) +{ + struct vb2_v4l2_buffer *src_buf; + enum vb2_buffer_state state; + u32 i; + + for (i = 1; i < count; i++) { + src_buf = v4l2_m2m_src_buf_remove(inst->fh.m2m_ctx); + if (!src_buf || vpu_get_buffer_state(src_buf) == VPU_BUF_STATE_IDLE) + return NULL; + if (vpu_get_buffer_state(src_buf) == VPU_BUF_STATE_DECODED) + state = VB2_BUF_STATE_DONE; + else + state = VB2_BUF_STATE_ERROR; + vpu_set_buffer_state(src_buf, VPU_BUF_STATE_IDLE); + v4l2_m2m_buf_done(src_buf, state); + } + + return v4l2_m2m_next_src_buf(inst->fh.m2m_ctx); +} + static int vdec_frame_decoded(struct vpu_inst *inst, void *arg) { struct vdec_t *vdec = inst->priv; struct vpu_dec_pic_info *info = arg; struct vpu_vb2_buffer *vpu_buf; struct vb2_v4l2_buffer *vbuf; + struct vb2_v4l2_buffer *src_buf; int ret = 0; if (!info || info->id >= ARRAY_SIZE(vdec->slots)) @@ -620,14 +637,21 @@ static int vdec_frame_decoded(struct vpu_inst *inst, void *arg) goto exit; } vbuf = &vpu_buf->m2m_buf.vb; + src_buf = vdec_get_src_buffer(inst, info->consumed_count); + if (src_buf) { + v4l2_m2m_buf_copy_metadata(src_buf, vbuf, true); + if (info->consumed_count) { + v4l2_m2m_src_buf_remove(inst->fh.m2m_ctx); + vpu_set_buffer_state(src_buf, VPU_BUF_STATE_IDLE); + v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE); + } else { + vpu_set_buffer_state(src_buf, VPU_BUF_STATE_DECODED); + } + } if (vpu_get_buffer_state(vbuf) == VPU_BUF_STATE_DECODED) dev_info(inst->dev, "[%d] buf[%d] has been decoded\n", inst->id, info->id); vpu_set_buffer_state(vbuf, VPU_BUF_STATE_DECODED); vdec->decoded_frame_count++; - if (vdec->ts_pre_count >= info->consumed_count) - vdec->ts_pre_count -= info->consumed_count; - else - vdec->ts_pre_count = 0; exit: vpu_inst_unlock(inst); @@ -683,10 +707,9 @@ static void vdec_buf_done(struct vpu_inst *inst, struct vpu_frame_info *frame) vpu_set_buffer_state(vbuf, VPU_BUF_STATE_READY); vb2_set_plane_payload(&vbuf->vb2_buf, 0, inst->cap_format.sizeimage[0]); vb2_set_plane_payload(&vbuf->vb2_buf, 1, inst->cap_format.sizeimage[1]); - vbuf->vb2_buf.timestamp = frame->timestamp; vbuf->field = inst->cap_format.field; vbuf->sequence = sequence; - dev_dbg(inst->dev, "[%d][OUTPUT TS]%32lld\n", inst->id, frame->timestamp); + dev_dbg(inst->dev, "[%d][OUTPUT TS]%32lld\n", inst->id, vbuf->vb2_buf.timestamp); v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_DONE); vpu_inst_lock(inst); @@ -708,7 +731,6 @@ static void vdec_stop_done(struct vpu_inst *inst) vdec->fixed_fmt = false; vdec->params.end_flag = 0; vdec->drain = 0; - vdec->ts_pre_count = 0; vdec->params.frame_count = 0; vdec->decoded_frame_count = 0; vdec->display_frame_count = 0; @@ -1244,18 +1266,14 @@ static int vdec_process_output(struct vpu_inst *inst, struct vb2_buffer *vb) if (free_space < vb2_get_plane_payload(vb, 0) + 0x40000) return -ENOMEM; + vpu_set_buffer_state(vbuf, VPU_BUF_STATE_INUSE); ret = vpu_iface_input_frame(inst, vb); if (ret < 0) return -ENOMEM; dev_dbg(inst->dev, "[%d][INPUT TS]%32lld\n", inst->id, vb->timestamp); - vdec->ts_pre_count++; vdec->params.frame_count++; - v4l2_m2m_src_buf_remove_by_buf(inst->fh.m2m_ctx, vbuf); - vpu_set_buffer_state(vbuf, VPU_BUF_STATE_IDLE); - v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_DONE); - if (vdec->drain) vdec_drain(inst); @@ -1318,7 +1336,6 @@ static void vdec_abort(struct vpu_inst *inst) vdec->sequence); vdec->params.end_flag = 0; vdec->drain = 0; - vdec->ts_pre_count = 0; vdec->params.frame_count = 0; vdec->decoded_frame_count = 0; vdec->display_frame_count = 0; @@ -1525,10 +1542,6 @@ static int vdec_get_debug_info(struct vpu_inst *inst, char *str, u32 size, u32 i vdec->drain, vdec->eos_received, vdec->source_change); break; case 8: - num = scnprintf(str, size, "ts_pre_count = %d, frame_depth = %d\n", - vdec->ts_pre_count, vdec->frame_depth); - break; - case 9: num = scnprintf(str, size, "fps = %d/%d\n", vdec->codec_info.frame_rate.numerator, vdec->codec_info.frame_rate.denominator); @@ -1562,12 +1575,8 @@ static struct vpu_inst_ops vdec_inst_ops = { static void vdec_init(struct file *file) { struct vpu_inst *inst = to_inst(file); - struct vdec_t *vdec; struct v4l2_format f; - vdec = inst->priv; - vdec->frame_depth = VDEC_FRAME_DEPTH; - memset(&f, 0, sizeof(f)); f.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; f.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_H264; @@ -1612,36 +1621,18 @@ static int vdec_open(struct file *file) vdec->fixed_fmt = false; inst->min_buffer_cap = VDEC_MIN_BUFFER_CAP; + inst->min_buffer_out = VDEC_MIN_BUFFER_OUT; vdec_init(file); return 0; } -static __poll_t vdec_poll(struct file *file, poll_table *wait) -{ - struct vpu_inst *inst = to_inst(file); - struct vb2_queue *src_q, *dst_q; - __poll_t ret; - - ret = v4l2_m2m_fop_poll(file, wait); - src_q = v4l2_m2m_get_src_vq(inst->fh.m2m_ctx); - dst_q = v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx); - if (vb2_is_streaming(src_q) && !vb2_is_streaming(dst_q)) - ret &= (~EPOLLERR); - if (!src_q->error && !dst_q->error && - (vb2_is_streaming(src_q) && list_empty(&src_q->queued_list)) && - (vb2_is_streaming(dst_q) && list_empty(&dst_q->queued_list))) - ret &= (~EPOLLERR); - - return ret; -} - static const struct v4l2_file_operations vdec_fops = { .owner = THIS_MODULE, .open = vdec_open, .release = vpu_v4l2_close, .unlocked_ioctl = video_ioctl2, - .poll = vdec_poll, + .poll = v4l2_m2m_fop_poll, .mmap = v4l2_m2m_fop_mmap, }; diff --git a/drivers/media/platform/amphion/vpu_v4l2.c b/drivers/media/platform/amphion/vpu_v4l2.c index 9c0704cd5766..cbf3315605a9 100644 --- a/drivers/media/platform/amphion/vpu_v4l2.c +++ b/drivers/media/platform/amphion/vpu_v4l2.c @@ -127,6 +127,19 @@ int vpu_set_last_buffer_dequeued(struct vpu_inst *inst) return 0; } +bool vpu_is_source_empty(struct vpu_inst *inst) +{ + struct v4l2_m2m_buffer *buf = NULL; + + if (!inst->fh.m2m_ctx) + return true; + v4l2_m2m_for_each_src_buf(inst->fh.m2m_ctx, buf) { + if (vpu_get_buffer_state(&buf->vb) == VPU_BUF_STATE_IDLE) + return false; + } + return true; +} + const struct vpu_format *vpu_try_fmt_common(struct vpu_inst *inst, struct v4l2_format *f) { struct v4l2_pix_format_mplane *pixmp = &f->fmt.pix_mp; diff --git a/drivers/media/platform/amphion/vpu_v4l2.h b/drivers/media/platform/amphion/vpu_v4l2.h index 90fa7ea67495..ad114734a017 100644 --- a/drivers/media/platform/amphion/vpu_v4l2.h +++ b/drivers/media/platform/amphion/vpu_v4l2.h @@ -27,6 +27,7 @@ int vpu_notify_source_change(struct vpu_inst *inst); int vpu_set_last_buffer_dequeued(struct vpu_inst *inst); void vpu_vb2_buffers_return(struct vpu_inst *inst, unsigned int type, enum vb2_buffer_state state); int vpu_get_num_buffers(struct vpu_inst *inst, u32 type); +bool vpu_is_source_empty(struct vpu_inst *inst); dma_addr_t vpu_get_vb_phy_addr(struct vb2_buffer *vb, u32 plane_no); unsigned int vpu_get_vb_length(struct vb2_buffer *vb, u32 plane_no); From patchwork Thu Apr 14 09:00:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 12813198 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 9AE5AC433F5 for ; Thu, 14 Apr 2022 09:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=wIAH7OMGvy7+FXo19Jftd21JiefneNN3lf2YvLJqDao=; b=pYRNhvi+CQZpj8 7JWy3zF7uktCB5C0PwCMw4BPrGyQaW5/xNe4gchgcxZ3JwA6+toHd2y/DphEwCP1oWf8RTflSZpHd T9Wlb+qaUatGenUnrAcx3vViDlKuIPlciKgrbKbIDvjrAtMtFxI5Nchc20l1zK/Gnzpgvf1JsGOeX gOcl7O2B3FHz9CdN4dU3HM+9P3AEQTCJujJ+K+ElXje0qd7NVDSfrfoCyL/jnfbOT8O5i2SgSUGR5 snH8rHq6lFX/3A6Ss5k+krl3BVa8n5q5GP3VuuHFTkqAoQ2ocDXyw53WxPWcfXHe3lk4CA5En4Ocg oKD7mjKA7D1ytZvXLwwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nevaP-004pVh-F3; Thu, 14 Apr 2022 09:16:21 +0000 Received: from mail-vi1eur05on20604.outbound.protection.outlook.com ([2a01:111:f400:7d00::604] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nevaM-004pTi-0F for linux-arm-kernel@lists.infradead.org; Thu, 14 Apr 2022 09:16:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ay3MvD3WxQbcabzkWpmAhVrzV9MuSuW8rFepHNfuVpowsbsjEOWgS+ntR1P/HGUxN4ruUAHPJZD+f4CJRn3adDvyaXIB5fvAdgpraZoKd1AHAwZ4WFoiwIvkNZOsWYDN94MUYMy6NCDG2mVDh4nKCdFHB8V9qfANlqAQs6MaM05/sqrD2ieAs0xExroPg/xMwMXUZfx8iQ9qGWYdBZlrDvce3RP+U62SIaVxYRucGvLuVYXGhzDvrqnUVQkRUA9VLCaAlrvfthZx+nwldtt5IJCKunjErIvqYuWfX/o6aFS8rhG/joDpG4RPJB4oSN42wL5Wjir6bJ6L8jVMF7IerA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ip04xNVrv+sidpa8RKsKWVqM2Fn1Czr/5ybq24opo0I=; b=OtTAaHXJypdZ0q8VtQcM4O2ra8v+gGPfs5BZb55CVWPsLkjZdYP6UYaUoXwRWhVfdu7/v9I55Kk5sFSeDv5kXh9tzl2jGXW2o6E/o4z8ZegzjN6qgcfUIZgHuR9Kqv3cuqW2w40tlqDG+Iivbw6ezzLdHFEoCtl7O/Qjp4BS0QDnuYLwhEhVHByWoYXdGoBzQfRRfiWEQve4c+al6dTEFoEf3LwOkt0Q2AEKtn2075AoDeb4qLdL2rwaXWUk/l7SftZNU1phm0Esx9MrPsQ+a/qExucXOAKEvKjhYmbh0xT877ZnUgtPxGkTbKKXIEpZ/e8AsJUVUtydctnIju3QpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ip04xNVrv+sidpa8RKsKWVqM2Fn1Czr/5ybq24opo0I=; b=MCOhrECSjHc2kPFFaDXe0g+zqgVSgIsSPtVF8NU9YQ3h75GPphBBDc6zJdxNYxG4QEHfKA7PYrZ9CTe0l8Zl7TgXBmYim6GFhsm1cxso0ZVcX2g+L6OzHNHLFCttqzLONeaMJZpdmMdWmKPUGwv/usboIlOW2Et0x7h0z6oXwxI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by PAXPR04MB8800.eurprd04.prod.outlook.com (2603:10a6:102:20f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Thu, 14 Apr 2022 09:01:15 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::d8b5:5914:5189:ffa5]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::d8b5:5914:5189:ffa5%6]) with mapi id 15.20.5164.020; Thu, 14 Apr 2022 09:01:15 +0000 From: Ming Qian To: mchehab@kernel.org, shawnguo@kernel.org Cc: hverkuil-cisco@xs4all.nl, robh+dt@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, aisheng.dong@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/2] media: amphion: encoder copy timestamp from output to capture Date: Thu, 14 Apr 2022 17:00:30 +0800 Message-Id: <483845f7b902ebb29c791ce251e09eb93fed97ff.1649753693.git.ming.qian@nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: X-ClientProxiedBy: SG2P153CA0011.APCP153.PROD.OUTLOOK.COM (2603:1096::21) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a57da67-2b2e-45d4-e06c-08da1df554cf X-MS-TrafficTypeDiagnostic: PAXPR04MB8800:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7hgU49Ws/vdQRVyTbtlLecrhoNb8O8fVeiqRgYx7NRhaBhDlStdnbJyulTTlV3qBDhorRKNsZteKzyzfKcb+VM0H652+oaag9kuO0pAUtPq5GIg9TdFc2J6R7JD8yjYfr680rdL20H5myDlYvuS2ANOZRK8BN4X6WVnbpjzPwslNHdD/7X0pYnet5zcmGGpGKoyV3PPoafDu01Luz6jW1o4avpBC8vkX7r36YdK7IEuFSed8/rT0kmrouPmd6/56T3shPU0ie5LqSkhJI4KlLX0kRpaXGIjx3JGhz4NnZM21+xbDAruS6Ca9JnB+7OEBnjddDDbr/hOGtuZ8iDnI9ml+0EYJKrn+TYEHWkHzdR1UH2tzfWp/B+HuX2JHmj0zz7pSF5wwi088hrUzQSn+Vhd1tAipstZb58UlyEiIvqdR38dxf6WN53EyHhaFA4fGrSzieyYeDSOiA23X4Oc8X3xTQYddaShkf1W9GXG9foNXF+Esj4O83BRCXhbea/cQKsCQ7ubdUmNUO6Q04wfs5ySNMNi3KqvjmiCK99JIFmc8cIpCZBbOyTNotdfxDnOu8CwjJa6OCXyN02jTBRlDwsPy2lFvzrZblqbk2xK21H+Lv+yFEytfKXB4rXhkk8dED27iGuoB4RKzU7uSQ2PyQNdXF0/gudmk42cpQ+A9ay7B5HVfbqbZFkkMdI3VjkFhKzgS60hwD/Me9V1p2SjdTA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(66476007)(36756003)(86362001)(8676002)(4326008)(38350700002)(508600001)(5660300002)(66556008)(2906002)(8936002)(316002)(66946007)(38100700002)(6486002)(7416002)(2616005)(186003)(26005)(44832011)(6666004)(52116002)(6506007)(6512007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JEokU32dVcvgPCfiPXP6+REm88LHhDwuxGPLd5VygiGHq1m0jRXYQjVe/RcBLLgwl/KIzzdCAWzLvOjrUAj2UHs7iG4vrB/2HrBTAZC5u61u6JtX4aKCkbRLRIs8LhbxX/0Ac+gdYDnLqMUEVjom4SYNRJYWEa0s5GebLVxH/93sK5NwHxoVwr0d70KUTGNKuvWMVzB3KyigZUqw3QdLtUSN3jhZlvuq0ZcF+2zBhxxpjxle+eVcvY4qdkAieE9bFL91kMlL/oWzuuAzdHdzHO8iYOMKfSAXIKQ9EnHRK3CttTsuTkh5hzJ1xUwbT2DlGEwW3zE/Zzd4rDI3XfSHoz9hSn4mmlnPJC4A+c0uq3FOnYENXV/lwTUAKsce6aDFJncwa+B1a0zuJOZyC8Imi1rphY8m1gzH73pm1l88vdlG5ZJXpOjSdOTbBNWRLpPgl9oh+K8T9rw1kwzOrh68TpOh5Pfjznm3g1Sau8A2JJbPdFF3gb7ZfyQVsNJZrUB6PB70RLgg2ZBZOqVcyW5FvNZFbp8e8zEQXwfMvVG2ECRI43YSM/svkWD+BjshqEpVQenTuPGSZjJ0gNGBrmmuLfMv2cmGDWvH4F9HuiK9NNdZ5ODXz9vsPbep4X7y0dl9PpJomPPXnfmILlIVzQYnwa+0sc5Dij2lnBUSHGa+vhEMjxQgRrlzCP9lCTsC8GhqLwHa7aGCkvUe1tv5inAveiL6YhhAco5h358GKb6qdrcdJJL803wXBTE5S/cYA7ioCCBuCeSM6CDtHECSIpd9QbdWVlAKbTM2v1Vm8+RQ3v2licbHf+Aypc3bzV9L+8BlrkGTiwNohvjmwtoVq8alOzrb9nJm1f9uucT9XQm4Q5ZRJZmgfgr38xRpS6Z5Qe5melPTQZqmb+e+bSFDROO5swGDLJ+AhN9X3t9MkIvu1SdU/LLAsEwrTOYPPw2ZsFK0cti86NPZn/nYFDXWAqzGKrP3OX0tRf/PiDxOe1PRCmoQ/SGhs0dHYByyHjqCkAcoCFt6QHMgKbM8srQ7HRSPX0G6d8IaWqlnnuoJY1Jcgsvf/0SgTfHeRjLeTJUpEDYNlIxmLpK0Uwqn7Z9PFc+AlJembaRQ1SkPRJGcwJtfHW/VirP+txtxERqFQ5lD4uXdLRvfAsucR8Tp3eDHJGmsXk94ZqDFllYpc4PU8I9bAElhg6NUO6M8ia46RsIuaiQx3BhkJoHK+69aCr26lXemjP3I1xp8PnqNovCGFjx2t/XFZ2hxEJAyrOa54hzwJHWMHi16SRjEl2R7PjWe3bVs4UdtujwB8xE2Q7ZqT26zjC/VjazD/z6yqfkQbSs7yZVEE4e6FJpNVVLgFL6ovJtIv6YAmB6f4K08AuopWJUqdc9nPQyUOSEOqo05E4sTQc7Ts4HWJ+buzKa7U87Ph7cXZGFvTv15t/DDKKMKy+w4x7imgDgZMp8Fxr5yWrECP5YMJ0nE5e+fDDhEqumz2ckNvAQaQYnVAeF5SP9OSoWLYfKegYb1iHSDFlSENVuLc03/a8+YvXS+oxep/YFvIoHbwE+TbieAJXVnOrcK68y2AfO6QDQsdKDy23G96eHbG2jk3pjrRJKlFf7BdJBF2efOD/TJrmij9SHx3EHpEgu75MwQabXO86ma366tikAIVorelshurGIzYIpwczpEOdXabmFpGLJ2aJXUjzkcOe9/drCU4uBNOZZXNhI2sIx6QwUEJRadFIJKEyQjGLtwYiJUJg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a57da67-2b2e-45d4-e06c-08da1df554cf X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2022 09:01:15.5480 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xNr7FsRU7GD1G3ETwbQIF+K1bOtgcpQSAs1FvG4wO4WPmhKqDi1UzSatzZhasxl2KJG/jL2rtLUBxY5ms1s7sw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8800 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220414_021618_056589_8A230278 X-CRM114-Status: GOOD ( 15.05 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org copy the timestamp using the helper function V4L2_BUF_FLAG_TIMESTAMP_COPY To implement this, driver will keep the output buffer until it's encoded, in previous, driver will return the output buffer immediately after firmware return it Signed-off-by: Ming Qian --- drivers/media/platform/amphion/venc.c | 47 +++++++++------------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/drivers/media/platform/amphion/venc.c b/drivers/media/platform/amphion/venc.c index d33c2748e4b7..06c873fd0031 100644 --- a/drivers/media/platform/amphion/venc.c +++ b/drivers/media/platform/amphion/venc.c @@ -33,6 +33,8 @@ #define VENC_CAPTURE_ENABLE BIT(1) #define VENC_ENABLE_MASK (VENC_OUTPUT_ENABLE | VENC_CAPTURE_ENABLE) #define VENC_MAX_BUF_CNT 8 +#define VENC_MIN_BUFFER_OUT 6 +#define VENC_MIN_BUFFER_CAP 6 struct venc_t { struct vpu_encode_params params; @@ -423,7 +425,7 @@ static int venc_drain(struct vpu_inst *inst) if (inst->state != VPU_CODEC_STATE_DRAIN) return 0; - if (v4l2_m2m_num_src_bufs_ready(inst->fh.m2m_ctx)) + if (!vpu_is_source_empty(inst)) return 0; if (!venc->input_ready) @@ -775,10 +777,20 @@ static int venc_get_one_encoded_frame(struct vpu_inst *inst, struct vb2_v4l2_buffer *vbuf) { struct venc_t *venc = inst->priv; + struct vb2_v4l2_buffer *src_buf; if (!vbuf) return -EAGAIN; + src_buf = vpu_find_buf_by_sequence(inst, inst->out_format.type, frame->info.frame_id); + if (src_buf) { + v4l2_m2m_buf_copy_metadata(src_buf, vbuf, true); + vpu_set_buffer_state(src_buf, VPU_BUF_STATE_IDLE); + v4l2_m2m_src_buf_remove_by_buf(inst->fh.m2m_ctx, src_buf); + v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE); + } else { + vbuf->vb2_buf.timestamp = frame->info.timestamp; + } if (!venc_get_enable(inst->priv, vbuf->vb2_buf.type)) { v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR); return 0; @@ -800,11 +812,10 @@ static int venc_get_one_encoded_frame(struct vpu_inst *inst, } vb2_set_plane_payload(&vbuf->vb2_buf, 0, frame->bytesused); vbuf->sequence = frame->info.frame_id; - vbuf->vb2_buf.timestamp = frame->info.timestamp; vbuf->field = inst->cap_format.field; vbuf->flags |= frame->info.pic_type; vpu_set_buffer_state(vbuf, VPU_BUF_STATE_IDLE); - dev_dbg(inst->dev, "[%d][OUTPUT TS]%32lld\n", inst->id, frame->info.timestamp); + dev_dbg(inst->dev, "[%d][OUTPUT TS]%32lld\n", inst->id, vbuf->vb2_buf.timestamp); v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_DONE); venc->ready_count++; @@ -860,33 +871,6 @@ static int venc_frame_encoded(struct vpu_inst *inst, void *arg) return ret; } -static void venc_buf_done(struct vpu_inst *inst, struct vpu_frame_info *frame) -{ - struct vb2_v4l2_buffer *vbuf; - - if (!inst->fh.m2m_ctx) - return; - - vpu_inst_lock(inst); - if (!venc_get_enable(inst->priv, frame->type)) - goto exit; - vbuf = vpu_find_buf_by_sequence(inst, frame->type, frame->sequence); - if (!vbuf) { - dev_err(inst->dev, "[%d] can't find buf: type %d, sequence %d\n", - inst->id, frame->type, frame->sequence); - goto exit; - } - - vpu_set_buffer_state(vbuf, VPU_BUF_STATE_IDLE); - if (V4L2_TYPE_IS_OUTPUT(frame->type)) - v4l2_m2m_src_buf_remove_by_buf(inst->fh.m2m_ctx, vbuf); - else - v4l2_m2m_dst_buf_remove_by_buf(inst->fh.m2m_ctx, vbuf); - v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_DONE); -exit: - vpu_inst_unlock(inst); -} - static void venc_set_last_buffer_dequeued(struct vpu_inst *inst) { struct venc_t *venc = inst->priv; @@ -1252,7 +1236,6 @@ static struct vpu_inst_ops venc_inst_ops = { .check_ready = venc_check_ready, .input_done = venc_input_done, .get_one_frame = venc_frame_encoded, - .buf_done = venc_buf_done, .stop_done = venc_stop_done, .event_notify = venc_event_notify, .release = venc_release, @@ -1333,6 +1316,8 @@ static int venc_open(struct file *file) if (ret) return ret; + inst->min_buffer_out = VENC_MIN_BUFFER_OUT; + inst->min_buffer_cap = VENC_MIN_BUFFER_CAP; venc_init(file); return 0;