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: 13435952 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 64589C0032E for ; Wed, 25 Oct 2023 10:36:02 +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:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=qlIFSgHjWzmDLQOeimZt/rOFD1SA+kBacdXNcrzS/Vk=; b=4lg1PTXMkwXO0x 79r+uOW13HxOB2XkNnW5PzK4y4+qYFZKOQ1p3yQwrFMLwWG6LApoeOWq4MDj69OG0jjR7yb6sg1rv CZGEkvDh2WAWnzG/tyEby3hDjyNe/D4P3UQL8ObaQsfVPGhhHJ+5kgbchc/WJ78e/m468DevNZREo RI0kls2EG6Gg8ai9tMHw2pPT3l1cUr5lie8ZxoQ+tW7LMu3kieA4oTvOigcoAyv7j+CylIcAApBOo M2vRzVq2MeY5TS+MfPdk3e8eusXl8R/NQJLm3pcjau+rgZ0V/jyCZ5DGr6Pzq7Lb3/Sfz7Bjc5LNf 6YtQR2xRQe2XULZEs9pQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvbEf-00C4Wr-0O; Wed, 25 Oct 2023 10:35:37 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qvbEa-00C4UK-1n for linux-arm-kernel@lists.infradead.org; Wed, 25 Oct 2023 10:35:35 +0000 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20231025103530epoutp02d27c4c99c0193bf019aaad0d4fa93c70~RU05pUhKY0149201492epoutp02i for ; Wed, 25 Oct 2023 10:35:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20231025103530epoutp02d27c4c99c0193bf019aaad0d4fa93c70~RU05pUhKY0149201492epoutp02i 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 KlcJVaEaSbpGp5CFKhjtLkF4eESUQ3goLWXdtIqoTm37bLL0Dn4cMfnkIBw2oISgv68Zy0E2 sb2oHxHww3AF6jKWEDBUtYq4jBUEZH6rxzZSDNYRd6ATAY/XLrgNPQqW9RaHis0mqBAw0Cp3 JvhQGQiY/lLr1GBUIQ6mG6ykU+NNJYCCk684NTi1AwyU/EI42YMSA6vtMstV7AVQ22R8WphD 7QYVK5mk8xxA2dhgtbXALYoDa6M9iIu9wYO+q6SLucD6qJNwcTKYrrzvnkAOGjvycRe/CozD pbizH4wKAo3tYS63LzhnakCdjFGe4PTqXdTl9wBt5Ru8E5TetrlbeB701F50t0CDR4Xz7p3k IaBvZZzMRfyK/y9RgSA1yDZGpUmXMZooVaSC+fS/W0tWphuQpw88OL4NMU8uhnYjKBvpRgAb 4/t4fJAAGS8Pqe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LHIlWINyWxsiq1KD++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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231025_033532_936466_E826AFE1 X-CRM114-Status: GOOD ( 19.30 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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; + } } }