From patchwork Fri Oct 2 12:09:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 7315091 Return-Path: X-Original-To: patchwork-linux-media@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 A6238BEEA4 for ; Fri, 2 Oct 2015 12:10:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB36F2089B for ; Fri, 2 Oct 2015 12:10:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D1BF2208A2 for ; Fri, 2 Oct 2015 12:10:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751795AbbJBMKf (ORCPT ); Fri, 2 Oct 2015 08:10:35 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:59355 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbbJBMKe (ORCPT ); Fri, 2 Oct 2015 08:10:34 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NVL00KQNDTJXF70@mailout2.w1.samsung.com>; Fri, 02 Oct 2015 13:10:31 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-63-560e74370dfd Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id A5.34.05269.7347E065; Fri, 2 Oct 2015 13:10:31 +0100 (BST) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NVL00C78DTALL20@eusync3.samsung.com>; Fri, 02 Oct 2015 13:10:31 +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 v2 2/2] s5p-mfc: use MFC_BUF_FLAG_EOS to identify last buffers in decoder capture queue Date: Fri, 02 Oct 2015 14:09:39 +0200 Message-id: <1443787779-18458-2-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1443787779-18458-1-git-send-email-a.hajda@samsung.com> References: <1443787779-18458-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprELMWRmVeSWpSXmKPExsVy+t/xq7rmJXxhBp+eSFvcWneO1WLjjPWs FkfWXmWy+PH6ApvF2aY37BY9G7ayWsw4v4/JYu2Ru+wWq59VOHB6bOm/y+7Rt2UVo8fnTXIB zFFcNimpOZllqUX6dglcGcfPXWUt+CpUMW3HNpYGxu/8XYycHBICJhLNW08wQ9hiEhfurWfr YuTiEBJYyijxZ+1adginiUlixqT3rCBVbAKaEn8332QDsUUEEiTafl1jBCliFnjAJPH0Ty8j SEJYIFNi49ulQA0cHCwCqhI7H7qCmLwCzhKzL2tCLJOTOHlsMthITgEXiVdvnoN1CgGVPPl/ i20CI+8CRoZVjKKppckFxUnpuUZ6xYm5xaV56XrJ+bmbGCEh9XUH49JjVocYBTgYlXh4N5zl DRNiTSwrrsw9xCjBwawkwuubyhcmxJuSWFmVWpQfX1Sak1p8iFGag0VJnHfmrvchQgLpiSWp 2ampBalFMFkmDk6pBsakPWflGFX7ZR1s2FYzq/r3chtscnly2mC9AXPKdCFHnfyswP83/Wdt in2Uu1jl7dGX9zcpfIrvCVUtYNnPonBpooBwW9vEkIXCasnTQ+/lbfvca8iZ7jlXdPkciWOy x/m354mJOSnePVK5+kKC6KTlk31+B8nO4HuddK5Zvf6sG7/gu0XcrUosxRmJhlrMRcWJAEb+ H1IlAgAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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 --- Hi, This version is rebased on latest media_tree branch. Regards Andrzej --- 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 05a31ee..3ffe2ec 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->vb2_buf, 0, 0); vb2_set_plane_payload(&dst_buf->b->vb2_buf, 1, 0); list_del(&dst_buf->list); + dst_buf->flags |= MFC_BUF_FLAG_EOS; ctx->dst_queue_cnt--; dst_buf->b->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 1734775..8d3d40c 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 */