From patchwork Tue Aug 14 15:34:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 10747 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DD73223E00 for ; Tue, 14 Aug 2012 15:37:49 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 978C4A18A3F for ; Tue, 14 Aug 2012 15:37:49 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so617166yhp.11 for ; Tue, 14 Aug 2012 08:37:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:x-auditid :from:to:date:message-id:x-mailer:in-reply-to:references :x-brightmail-tracker:x-tm-as-mml:cc:subject:x-beenthere :x-mailman-version:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-gm-message-state; bh=UvwkZH96B7YqD3G1S1aaDFuRgWBiPZeMBMMuZ3WZKz8=; b=ayZx8TFiwyOncpEy65pWEsV05m1aI2PxutiBgGSSNu6Xyewn3eMPRA4i/f0Yu25ie3 SUmTBw/pFg/2iJw5Xs48l1f1mxk04sSvjjyh7MWQYAwH2T4pyZhm7a/NjVmXxju0D2/3 0L6usctHajv0OSa/N19Ug/rw4/VIPEZWR54VzhCphaJOcJk20L4S5GMWOQAC6yrbbATw 42ibYJsTZ8zLkKcCKNugHFed8tC8vreh4jzWL5i1yMudCdI5xz/TE2ddl83mYE/YHtv9 F1ScOPWIogvorG9kAmOVZ54116kggSeZT2cbeHb92OBrcLyR9GMXkR06lJPoTrLKK+Qn 131A== Received: by 10.42.75.73 with SMTP id z9mr13115719icj.46.1344958668688; Tue, 14 Aug 2012 08:37:48 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.200 with SMTP id ew8csp20668igc; Tue, 14 Aug 2012 08:37:47 -0700 (PDT) Received: by 10.204.128.213 with SMTP id l21mr6424157bks.84.1344958667207; Tue, 14 Aug 2012 08:37:47 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id fy11si3983578bkc.134.2012.08.14.08.37.45; Tue, 14 Aug 2012 08:37:47 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T1JBg-0008Sk-LS; Tue, 14 Aug 2012 15:37:44 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T1JBf-0008Rq-2O for linaro-mm-sig@lists.linaro.org; Tue, 14 Aug 2012 15:37:43 +0000 Received: from epcpsbgm1.samsung.com (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M8R00J6Z4Q4DVJ0@mailout2.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 15 Aug 2012 00:37:24 +0900 (KST) X-AuditID: cbfee61a-b7fc66d0000043b7-aa-502a70b49a1b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 46.8D.17335.4B07A205; Wed, 15 Aug 2012 00:37:24 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M8R004J44MBC810@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 15 Aug 2012 00:37:24 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Tue, 14 Aug 2012 17:34:47 +0200 Message-id: <1344958496-9373-18-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1344958496-9373-1-git-send-email-t.stanislaws@samsung.com> References: <1344958496-9373-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIJMWRmVeSWpSXmKPExsVy+t9jAd0tBVoBBufvClt8ufKQyYHR4/a/ x8wBjFFcNimpOZllqUX6dglcGU/f2BSs8Kr4NOUCcwPjGZsuRk4OCQETiVsrFjBD2GISF+6t ZwOxhQQWMUpMfS/SxcgFZK9lkri7p4MFJMEG1HBsyWdGEFtEwEHi9N1ZzCBFzAJ3mSUW/VsE ViQsECHx8dN8dhCbRUBV4seO+WAbeAU8JF79nA61TV7i6f0+sG2cQPGXm7qBhnIAbXOXWPjT fwIj7wJGhlWMoqkFyQXFSem5hnrFibnFpXnpesn5uZsYwR5/JrWDcWWDxSFGAQ5GJR5ehTTN ACHWxLLiytxDjBIczEoivEVBWgFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeY29v/oLCaQnlqRm p6YWpBbBZJk4OKUaGEs0oiZzOcxW3HbzZV2C059J2V3xy6ybzVW85Y4KTJmTuHf524X+ws// +tgULmu/pr+Vz9k2aFMrR0li3I7KLdN/8N5n38Zh0/FbwOr5vSSD/vJT3gdare+L3dW02/K2 cqVP3+ZetlaNbQnz1Tb3zFI6c6D+4bPLnKo7Vtf+cY93Yyws1BcUUWIpzkg01GIuKk4EAHDl f0H0AQAA X-TM-AS-MML: No Cc: k.debski@samsung.com, pawel@osciak.com, sumit.semwal@ti.com, linux-doc@vger.kernel.org, mchehab@redhat.com, robdclark@gmail.com, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, dmitriyz@google.com, laurent.pinchart@ideasonboard.com, s.nawrocki@samsung.com, airlied@redhat.com, remi@remlab.net, g.liakhovetski@gmx.de Subject: [Linaro-mm-sig] [PATCHv8 17/26] Documentation: media: description of DMABUF exporting in V4L2 X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQn0gNuLptMqAGwWH25IKO3bPuHmwnMu4LcBqf0zFGc3XeWU7DWMes8p3LZjclOXvUIyQ7CR This patch adds description and usage examples for exporting DMABUF file descriptor in V4L2. Signed-off-by: Tomasz Stanislawski Signed-off-by: Kyungmin Park CC: linux-doc@vger.kernel.org --- Documentation/DocBook/media/v4l/compat.xml | 3 + Documentation/DocBook/media/v4l/io.xml | 3 + Documentation/DocBook/media/v4l/v4l2.xml | 1 + Documentation/DocBook/media/v4l/vidioc-expbuf.xml | 223 +++++++++++++++++++++ 4 files changed, 230 insertions(+) create mode 100644 Documentation/DocBook/media/v4l/vidioc-expbuf.xml diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml index ff45330..802c1ab 100644 --- a/Documentation/DocBook/media/v4l/compat.xml +++ b/Documentation/DocBook/media/v4l/compat.xml @@ -2609,6 +2609,9 @@ ioctls. Importing DMABUF file descriptors as a new IO method described in . + + Exporting DMABUF files using &VIDIOC-EXPBUF; ioctl. + diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml index 98253ee..c27e59b 100644 --- a/Documentation/DocBook/media/v4l/io.xml +++ b/Documentation/DocBook/media/v4l/io.xml @@ -488,6 +488,9 @@ buffer from userspace using a file descriptor previously exported for a different or the same device (known as the importer role), or both. This section describes the DMABUF importer role API in V4L2. + Refer to DMABUF exporting for +details about exporting a V4L2 buffers as DMABUF file descriptors. + Input and output devices support the streaming I/O method when the V4L2_CAP_STREAMING flag in the capabilities field of &v4l2-capability; returned by diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml index 0292ed1..874c085 100644 --- a/Documentation/DocBook/media/v4l/v4l2.xml +++ b/Documentation/DocBook/media/v4l/v4l2.xml @@ -568,6 +568,7 @@ and discussions on the V4L mailing list. &sub-overlay; &sub-prepare-buf; &sub-qbuf; + &sub-expbuf; &sub-querybuf; &sub-querycap; &sub-queryctrl; diff --git a/Documentation/DocBook/media/v4l/vidioc-expbuf.xml b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml new file mode 100644 index 0000000..30ebf67 --- /dev/null +++ b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml @@ -0,0 +1,223 @@ + + + + ioctl VIDIOC_EXPBUF + &manvol; + + + + VIDIOC_EXPBUF + Export a buffer as a DMABUF file descriptor. + + + + + + int ioctl + int fd + int request + struct v4l2_exportbuffer *argp + + + + + + Arguments + + + + fd + + &fd; + + + + request + + VIDIOC_EXPBUF + + + + argp + + + + + + + + + Description + + + Experimental + This is an experimental + interface and may change in the future. + + +This ioctl is an extension to the memory +mapping I/O method therefore it is available only for +V4L2_MEMORY_MMAP buffers. It can be used to export a +buffer as DMABUF file at any time after buffers have been allocated with the +&VIDIOC-REQBUFS; ioctl. + +Prior to exporting an application calls VIDIOC_QUERYBUF to obtain memory offsets. When +using the multi-planar API every plane has +own offset. + +To export a buffer, the application fills &v4l2-exportbuffer;. The + mem_offset field is set to the offset obtained +from VIDIOC_QUERYBUF . Additional flags may be posted in +the flags field. Refer to manual for open syscall +for details. Currently only O_CLOEXEC is guaranteed to be supported. All other +fields must be set to zero. In a case of multi-planar API, every plane is +exported separately using multiple VIDIOC_EXPBUF +calls. + + After calling VIDIOC_EXPBUF the fd + field will be set by a driver. This is a DMABUF file +descriptor. The application may pass it to other API. Refer to DMABUF importing for details about importing DMABUF +files into V4L2 nodes. A developer is encouraged to close a DMABUF file when it +is no longer used. + + + +
+ Examples + + + Exporting a buffer. + +int buffer_export(int v4lfd, &v4l2-buf-type; bt, int index, int *dmafd) +{ + &v4l2-buffer; buf; + &v4l2-exportbuffer; expbuf; + + memset(&buf, 0, sizeof buf); + buf.type = bt; + buf.memory = V4L2_MEMORY_MMAP; + buf.index = index; + + if (ioctl (v4lfd, &VIDIOC-QUERYBUF;, &buf) == -1) { + perror ("VIDIOC_QUERYBUF"); + return -1; + } + + memset(&expbuf, 0, sizeof expbuf); + expbuf.mem_offset = buf.m.offset; + if (ioctl (v4lfd, &VIDIOC-EXPBUF;, &expbuf) == -1) { + perror ("VIDIOC_EXPBUF"); + return -1; + } + + *dmafd = expbuf.fd; + + return 0; +} + + + + + Exporting a buffer using multi plane API. + +int buffer_export_mp(int v4lfd, &v4l2-buf-type; bt, int index, + int dmafd[], int n_planes) +{ + &v4l2-buffer; buf; + &v4l2-plane; planes[VIDEO_MAX_PLANES]; + int i; + + memset(&buf, 0, sizeof buf); + buf.type = bt; + buf.memory = V4L2_MEMORY_MMAP; + buf.index = index; + buf.m.planes = planes; + buf.length = n_planes; + memset(&planes, 0, sizeof planes); + + if (ioctl (v4lfd, &VIDIOC-QUERYBUF;, &buf) == -1) { + perror ("VIDIOC_QUERYBUF"); + return -1; + } + + for (i = 0; i < n_planes; ++i) { + &v4l2-exportbuffer; expbuf; + + memset(&expbuf, 0, sizeof expbuf); + expbuf.mem_offset = plane[i].m.offset; + if (ioctl (v4lfd, &VIDIOC-EXPBUF;, &expbuf) == -1) { + perror ("VIDIOC_EXPBUF"); + while (i) + close(dmafd[--i]); + return -1; + } + dmafd[i] = expbuf.fd; + } + + return 0; +} + + +
+
+ + + + struct <structname>v4l2_exportbuffer</structname> + + &cs-str; + + + __u32 + fd + The DMABUF file descriptor associated with a buffer. Set by + a driver. + + + __u32 + reserved0 + Reserved field for future use. Must be set to zero. + + + __u32 + mem_offset + Buffer memory offset as returned by +VIDIOC_QUERYBUF in &v4l2-buffer; ::m.offset + (for single-plane formats) or &v4l2-plane; +::m.offset (for multi-planar formats) + + + __u32 + flags + Flags for newly created file, currently only +O_CLOEXEC is supported, refer to manual of open syscall for more +details. + + + __u32 + reserved[12] + Reserved field for future use. Must be set to zero. + + + +
+ +
+ + + &return-value; + + + EINVAL + + A queue is not in MMAP mode or DMABUF exporting is not +supported or flag or mem_offset + fields are invalid. + + + + + +