From patchwork Wed Oct 25 10:22:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aakarsh Jain X-Patchwork-Id: 738133 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6253DC25B6E for ; Wed, 25 Oct 2023 10:36:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235020AbjJYKgu (ORCPT ); Wed, 25 Oct 2023 06:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344140AbjJYKg3 (ORCPT ); Wed, 25 Oct 2023 06:36:29 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B0931BC1 for ; Wed, 25 Oct 2023 03:35:32 -0700 (PDT) Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20231025103530epoutp04c93695ff0fae7918d8c8dd5c63edba40~RU05vvBdG2401424014epoutp047 for ; Wed, 25 Oct 2023 10:35:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20231025103530epoutp04c93695ff0fae7918d8c8dd5c63edba40~RU05vvBdG2401424014epoutp047 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698230130; bh=yaatIcLSDM4fvogeHxnoEVffNwFt6IcJr5IGOrt3w3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SgE5+UCr5yIQ33peiMncx+dG3uII9hF5xnyoQZTIrOre/0mH2j61Sgsim2Tzy6qSQ Hwwyr+Rv46EFyubPfzQw/LWtq6Pa5KSRh6+mHVN9cCAYK2UX3TmJwQBwB6ZAPp90T+ cxpkgWrCZOc3laFqCqPrUEgIRHf0KKmuakzZmpd4= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20231025103529epcas5p307413dafb1b064ac028126d20179cd1e~RU049YElM2625426254epcas5p3p; Wed, 25 Oct 2023 10:35:29 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.179]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4SFlgh1djJz4x9Q0; Wed, 25 Oct 2023 10:35:28 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id F7.26.09672.F6FE8356; Wed, 25 Oct 2023 19:35:28 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20231025102253epcas5p4e57ce0924392b879d8d296f66613a798~RUp4y2PXJ0069500695epcas5p40; Wed, 25 Oct 2023 10:22:53 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231025102253epsmtrp2980746c585fb109334fa96a5252dc486~RUp4x9yKa0878508785epsmtrp2Z; Wed, 25 Oct 2023 10:22:53 +0000 (GMT) X-AuditID: b6c32a4b-60bfd700000025c8-07-6538ef6f2629 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id AD.C0.08817.D7CE8356; Wed, 25 Oct 2023 19:22:53 +0900 (KST) Received: from cheetah.sa.corp.samsungelectronics.net (unknown [107.109.115.53]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20231025102250epsmtip1bd44c20e67f8666d662736566d7334ab~RUp1t6pHL0054300543epsmtip1E; Wed, 25 Oct 2023 10:22:50 +0000 (GMT) From: Aakarsh Jain To: linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: m.szyprowski@samsung.com, andrzej.hajda@intel.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, krzysztof.kozlowski+dt@linaro.org, dillon.minfei@gmail.com, david.plowman@raspberrypi.com, mark.rutland@arm.com, robh+dt@kernel.org, conor+dt@kernel.org, linux-samsung-soc@vger.kernel.org, andi@etezian.org, gost.dev@samsung.com, alim.akhtar@samsung.com, aswani.reddy@samsung.com, pankaj.dubey@samsung.com, ajaykumar.rs@samsung.com, aakarsh.jain@samsung.com, linux-fsd@tesla.com, Smitha T Murthy Subject: [Patch v4 07/11] media: s5p-mfc: Add support for DMABUF for encoder Date: Wed, 25 Oct 2023 15:52:12 +0530 Message-Id: <20231025102216.50480-8-aakarsh.jain@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231025102216.50480-1-aakarsh.jain@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WTfVDTdRzH+z3s99s84X4B6dcZtFsoDx0Pg7G+GDNSql8HdnTVeWkXLva7 wTG23R4q7VJBhoWpUAjyKAFq8twQQYIaD8axQo/jsZKEIYgOhRhxcyDX5kb99/p8Pu/P9/Pw /X7ZmNcowWWnKrSMWiGR84lN+LWeoIAQ1QJkwot+xuBMWxELGhe6cDhZfo2AVbZ7KLxTZcVh d3MLCes6b6Lwcp+RBS/03mTB1i4zDn83XkfhYNEEDs/MTWHQMD3KglMP9sOh9lICft3UwoLn b/2EwvreCRJeHBtE4SXDGgorW5ZJqO/sJWFWRjUrFtB15XUIPVa9hNHXiydIuqrjPkobar4i 6NujHQTdXH2M1t+w4/SZqzUIvZ5ZRtJWgx9t+sdKJm4+kBaTwkikjJrHKJKV0lSFTMyPfzdp b1KUKFwQIoiGL/N5Ckk6I+bHJSSGvJEqdwzP530ikescrkSJRsMP2x2jVuq0DC9FqdGK+YxK KlcJVaEaSbpG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zzu9jslh75C67xdLrF5kslm36w2SxaOsXdovW vUfYLVoal7A6SHismbeG0eP6kk/MHjtn3WX3WLznJZPHplWdbB53ru1h89i8pN6j9egvFo++ LasYPf41zWX3+LxJzuPU18/sATxRXDYpqTmZZalF+nYJXBn/Tv1mLOiWrHgw5z5LA+MpkS5G Tg4JAROJTZ+vMnYxcnEICexmBHI6WSASMhL/246xQ9jCEiv/PWeHKGpmkmh5OY+ti5GDg01A V+Ls9hyQuIhAK6PE9ZWdTCAOs8B6FokjG5awgxQJC/hITGu3BhnEIqAqcXb2MTYQm1fAVuLz j+WsEAvkJVZvOMAMYnMK2Eks+NYEtlgIqOb+/R+MExj5FjAyrGKUTC0ozk3PLTYsMMpLLdcr TswtLs1L10vOz93ECI4xLa0djHtWfdA7xMjEwXiIUYKDWUmEN9LHIlWINyWxsiq1KD++qDQn tfgQozQHi5I477fXvSlCAumJJanZqakFqUUwWSYOTqkGptq6Hwfr75iXFTRY3Wj/YnrMcgrX 5eqqV+7BJ/eZb36oyM8YvCQ2ecUilu8LP7uVT1jQtXHD8Ur26Zq7OQzrGmVC4/ivLCgSSvRf 6P/Q7lTnm7sdWQl1xrUOZdPcQqU2ndI0yFh/XO3gu8YF0usXsq+a8kuSw+TGWoPdk40ySrcs KFdncr1r1S4hNaEyJ99866JL6w9mHL/Y3niRj51PxjvcI4EzXqR9QsaqBx6zNGasOxcfel6l 4Onem7+V/TtduUzf7Dq0vsb/iiJTlvKHWRMeZi57zPk1/T1D/HG/Q1MmZWwT0vy6Q1PXRyPq yrpF+9a7CaZx7LTwi624xaHHerSgwthBTNnA5fukFD5XJZbijERDLeai4kQAw2qShiADAAA= X-CMS-MailID: 20231025102253epcas5p4e57ce0924392b879d8d296f66613a798 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231025102253epcas5p4e57ce0924392b879d8d296f66613a798 References: <20231025102216.50480-1-aakarsh.jain@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Add dmabuf support for mfc encoder Cc: linux-fsd@tesla.com Signed-off-by: Smitha T Murthy Signed-off-by: Aakarsh Jain --- .../media/platform/samsung/s5p-mfc/s5p_mfc.c | 4 ++-- .../platform/samsung/s5p-mfc/s5p_mfc_enc.c | 21 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c index dee9ef017997..bd055dea827e 100644 --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c @@ -865,7 +865,7 @@ static int s5p_mfc_open(struct file *file) q->io_modes = VB2_MMAP; q->ops = get_dec_queue_ops(); } else if (vdev == dev->vfd_enc) { - q->io_modes = VB2_MMAP | VB2_USERPTR; + q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; q->ops = get_enc_queue_ops(); } else { ret = -ENOENT; @@ -892,7 +892,7 @@ static int s5p_mfc_open(struct file *file) q->io_modes = VB2_MMAP; q->ops = get_dec_queue_ops(); } else if (vdev == dev->vfd_enc) { - q->io_modes = VB2_MMAP | VB2_USERPTR; + q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; q->ops = get_enc_queue_ops(); } else { ret = -ENOENT; diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c index 0afa8426ca4e..80a97b86977e 100644 --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c @@ -1537,9 +1537,10 @@ static int vidioc_reqbufs(struct file *file, void *priv, struct s5p_mfc_ctx *ctx = fh_to_ctx(priv); int ret = 0; - /* if memory is not mmp or userptr return error */ + /* if memory is not mmp or userptr or dmabuf return error */ if ((reqbufs->memory != V4L2_MEMORY_MMAP) && - (reqbufs->memory != V4L2_MEMORY_USERPTR)) + (reqbufs->memory != V4L2_MEMORY_USERPTR) && + (reqbufs->memory != V4L2_MEMORY_DMABUF)) return -EINVAL; if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { if (reqbufs->count == 0) { @@ -1616,9 +1617,10 @@ static int vidioc_querybuf(struct file *file, void *priv, struct s5p_mfc_ctx *ctx = fh_to_ctx(priv); int ret = 0; - /* if memory is not mmp or userptr return error */ + /* if memory is not mmp or userptr or dmabuf return error */ if ((buf->memory != V4L2_MEMORY_MMAP) && - (buf->memory != V4L2_MEMORY_USERPTR)) + (buf->memory != V4L2_MEMORY_USERPTR) && + (buf->memory != V4L2_MEMORY_DMABUF)) return -EINVAL; if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { if (ctx->state != MFCINST_GOT_INST) { @@ -2577,11 +2579,12 @@ static int s5p_mfc_start_streaming(struct vb2_queue *q, unsigned int count) S5P_MFC_R2H_CMD_SEQ_DONE_RET, 0); } - - if (ctx->src_bufs_cnt < ctx->pb_count) { - mfc_err("Need minimum %d OUTPUT buffers\n", - ctx->pb_count); - return -ENOBUFS; + if (q->memory != V4L2_MEMORY_DMABUF) { + if (ctx->src_bufs_cnt < ctx->pb_count) { + mfc_err("Need minimum %d OUTPUT buffers\n", + ctx->pb_count); + return -ENOBUFS; + } } }