From patchwork Fri Oct 2 09:58:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 7314461 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 73494BEEA4 for ; Fri, 2 Oct 2015 09:59:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 905B120813 for ; Fri, 2 Oct 2015 09:59:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A651E207C5 for ; Fri, 2 Oct 2015 09:59:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751581AbbJBJ7x (ORCPT ); Fri, 2 Oct 2015 05:59:53 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:57843 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbbJBJ7w (ORCPT ); Fri, 2 Oct 2015 05:59:52 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NVL003IC7RPP590@mailout1.w1.samsung.com>; Fri, 02 Oct 2015 10:59:50 +0100 (BST) X-AuditID: cbfec7f4-f79c56d0000012ee-26-560e5595b24b Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id DB.B1.04846.5955E065; Fri, 2 Oct 2015 10:59:49 +0100 (BST) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NVL008CX7RGRI10@eusync4.samsung.com>; Fri, 02 Oct 2015 10:59:49 +0100 (BST) From: Andrzej Hajda To: linux-media@vger.kernel.org (open list:ARM/SAMSUNG S5P SERIES Multi Format Codec (MFC)...) Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Kyungmin Park , Kamil Debski , Jeongtae Park , Mauro Carvalho Chehab , linux-samsung-soc@vger.kernel.org Subject: [PATCH 2/2] s5p-mfc: use MFC_BUF_FLAG_EOS to identify last buffers in decoder capture queue Date: Fri, 02 Oct 2015 11:58:54 +0200 Message-id: <1443779934-30088-2-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1443779934-30088-1-git-send-email-a.hajda@samsung.com> References: <1443779934-30088-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprELMWRmVeSWpSXmKPExsVy+t/xa7pTQ/nCDDp+mVvcWneO1WLjjPWs FkfWXmWy+PH6ApvF2aY37BY9G7ayWsw4v4/JYu2Ru+wWq59VOHB6bOm/y+7Rt2UVo8fnTXIB zFFcNimpOZllqUX6dglcGY0HnrIWTBGqOH3zPFMD42r+LkZODgkBE4lnF3czQ9hiEhfurWcD sYUEljJKXPtVDmE3MUmsO2YNYrMJaEr83XwTrEZEIEGi7dc1xi5GLg5mgQdMEk//9DKCJIQF 0iT6ZhwGK2IRUJV4Pm0SO4jNK+As8bJnIwvEMjmJk8cms4LYnAIuEm+OrmSEWOYscbHrCdsE Rt4FjAyrGEVTS5MLipPScw31ihNzi0vz0vWS83M3MUJC6ssOxsXHrA4xCnAwKvHwRpzmDRNi TSwrrsw9xCjBwawkwuulxBcmxJuSWFmVWpQfX1Sak1p8iFGag0VJnHfurvchQgLpiSWp2amp BalFMFkmDk6pBsYikfVTTErC+2r2iaUdjDLWXbFyz7nbdq/2nZp21+an/8WdUpuf6zZ9Dt4t IeEsG/vzoKOe1OvWN9b8ySqLE4yZ1i/Z/P/JFwmHKwuiTVi7FNqabrAlSixcu24yx9OHfb/E EzZvePY98gvPOokfa19+unGzy2Ua84aO9iOWDlVFPzZM5F8mNzVRiaU4I9FQi7moOBEAELBm WSUCAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP MFC driver never delivered EOS event to apps feeding constantly its capture buffer with fresh buffers. The patch fixes it by marking last buffers returned by MFC with MFC_BUF_FLAG_EOS flag and firing EOS event on de-queuing such buffers. Signed-off-by: Andrzej Hajda --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 1 + drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 21c424e..f1e537e 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -196,6 +196,7 @@ static void s5p_mfc_handle_frame_all_extracted(struct s5p_mfc_ctx *ctx) vb2_set_plane_payload(dst_buf->b, 0, 0); vb2_set_plane_payload(dst_buf->b, 1, 0); list_del(&dst_buf->list); + dst_buf->flags |= MFC_BUF_FLAG_EOS; ctx->dst_queue_cnt--; dst_buf->b->v4l2_buf.sequence = (ctx->sequence++); diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c index aebe4fd..7866eda 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c @@ -645,17 +645,22 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf) mfc_err("Call on DQBUF after unrecoverable error\n"); return -EIO; } - if (buf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) - ret = vb2_dqbuf(&ctx->vq_src, buf, file->f_flags & O_NONBLOCK); - else if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { + + switch (buf->type) { + case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: + return vb2_dqbuf(&ctx->vq_src, buf, file->f_flags & O_NONBLOCK); + case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: ret = vb2_dqbuf(&ctx->vq_dst, buf, file->f_flags & O_NONBLOCK); - if (ret == 0 && ctx->state == MFCINST_FINISHED && - list_empty(&ctx->vq_dst.done_list)) + if (ret) + return ret; + + if (ctx->state == MFCINST_FINISHED && + (ctx->dst_bufs[buf->index].flags & MFC_BUF_FLAG_EOS)) v4l2_event_queue_fh(&ctx->fh, &ev); - } else { - ret = -EINVAL; + return 0; + default: + return -EINVAL; } - return ret; } /* Export DMA buffer */