From patchwork Thu Aug 22 19:44:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 11110033 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2791B1395 for ; Thu, 22 Aug 2019 19:47:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 05855233FC for ; Thu, 22 Aug 2019 19:47:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ce+27sj+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05855233FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=siol.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PDi2ONnc0dj58WAiFfuxC9l4v2irL7Q+ZOPjN8wH3JA=; b=Ce+27sj+SS9xov yirmVBsDgZCoetYyWiW7D8qxN5jMQ7WqEj6zpiONX2lTWTVsqhSN8HVuXhA/hp1TrusOj0llpuV9l SI3vICuKBkSiYtlwYjXVHfj9ZXsHpxJ4AIvqkwT5x8WWtrrP1KcIgGkHdKrfSmjNVaHXQP0T9ndKW mogR+XUwJ2LdCjaJpSwAVxjZT4CnzxxOBTFzfP6V3jLY2kqgi6j6qQTXHAPGADQv9deoIlfuCGPLz llfYgtJcQPybejD5KiAEMXoq2oU7gjQLDX361SaQi/wpk4jgwbLsyQDk3EbnFQUePfXwWd7eES7df YB2RBr9qw1gIfChtU3ug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i0t2y-00011D-4P; Thu, 22 Aug 2019 19:47:00 +0000 Received: from mailoutvs54.siol.net ([185.57.226.245] helo=mail.siol.net) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i0t1V-0007r0-6y for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2019 19:45:31 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id E0B52524922; Thu, 22 Aug 2019 21:45:26 +0200 (CEST) X-Virus-Scanned: amavisd-new at psrvmta11.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta11.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id GUgxcelfQGCl; Thu, 22 Aug 2019 21:45:26 +0200 (CEST) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id 84BC452481F; Thu, 22 Aug 2019 21:45:26 +0200 (CEST) Received: from localhost.localdomain (cpe-86-58-59-25.static.triera.net [86.58.59.25]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPSA id 20948524922; Thu, 22 Aug 2019 21:45:24 +0200 (CEST) From: Jernej Skrabec To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, paul.kocialkowski@bootlin.com, mripard@kernel.org Subject: [PATCH 7/8] media: cedrus: Add support for holding capture buffer Date: Thu, 22 Aug 2019 21:44:59 +0200 Message-Id: <20190822194500.2071-8-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20190822194500.2071-1-jernej.skrabec@siol.net> References: <20190822194500.2071-1-jernej.skrabec@siol.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190822_124529_742221_FBB8512E X-CRM114-Status: GOOD ( 10.51 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [185.57.226.245 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, jernej.skrabec@siol.net, pawel@osciak.com, acourbot@chromium.org, jonas@kwiboo.se, gregkh@linuxfoundation.org, wens@csie.org, tfiga@chromium.org, kyungmin.park@samsung.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, ezequiel@collabora.com, linux-kernel@vger.kernel.org, m.szyprowski@samsung.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When frame contains multiple slices and driver works in slice mode, it's more efficient to hold capture buffer in queue until all slices of a same frame are decoded. Add support for that to Cedrus driver by exposing and implementing V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF capability. Signed-off-by: Jernej Skrabec Reviewed-by: Boris Brezillon --- drivers/staging/media/sunxi/cedrus/cedrus_dec.c | 9 +++++++++ drivers/staging/media/sunxi/cedrus/cedrus_hw.c | 8 +++++--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c index d7b54accfe83..68462b99750e 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c @@ -31,6 +31,14 @@ void cedrus_device_run(void *priv) run.src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); run.dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); + + if (v4l2_m2m_release_capture_buf(run.src, run.dst)) { + v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + v4l2_m2m_buf_done(run.dst, VB2_BUF_STATE_DONE); + run.dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); + } + run.dst->is_held = run.src->flags & V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF; + run.first_slice = run.src->vb2_buf.timestamp != run.dst->vb2_buf.timestamp; @@ -46,6 +54,7 @@ void cedrus_device_run(void *priv) V4L2_CID_MPEG_VIDEO_MPEG2_SLICE_PARAMS); run.mpeg2.quantization = cedrus_find_control_data(ctx, V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION); + run.dst->is_held = false; break; case V4L2_PIX_FMT_H264_SLICE: diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c index a942cd9bed57..99fedec80224 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_hw.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_hw.c @@ -122,7 +122,7 @@ static irqreturn_t cedrus_irq(int irq, void *data) dev->dec_ops[ctx->current_codec]->irq_clear(ctx); src_buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); - dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); if (!src_buf || !dst_buf) { v4l2_err(&dev->v4l2_dev, @@ -136,8 +136,10 @@ static irqreturn_t cedrus_irq(int irq, void *data) state = VB2_BUF_STATE_DONE; v4l2_m2m_buf_done(src_buf, state); - v4l2_m2m_buf_done(dst_buf, state); - + if (!dst_buf->is_held) { + v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + v4l2_m2m_buf_done(dst_buf, state); + } v4l2_m2m_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx); return IRQ_HANDLED; diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c index eeee3efd247b..5153b2bba21e 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c @@ -515,6 +515,7 @@ int cedrus_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; src_vq->io_modes = VB2_MMAP | VB2_DMABUF; src_vq->drv_priv = ctx; + src_vq->subsystem_flags = VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF; src_vq->buf_struct_size = sizeof(struct cedrus_buffer); src_vq->min_buffers_needed = 1; src_vq->ops = &cedrus_qops;