From patchwork Wed Oct 10 14:46:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 12126 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 1BF0723EFB for ; Wed, 10 Oct 2012 14:59:11 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id AE16FA18F35 for ; Wed, 10 Oct 2012 14:59:10 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so1016235iej.11 for ; Wed, 10 Oct 2012 07:59:10 -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: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=+q6Ei1Bg6fE92WMI/i9Wopi5CA7hxuWr3wd0eFQSm5w=; b=PoKb9GknB8dPbhHQt2qpSOdmqT3ktD3Chl0XoN69VMKPpPtlATtPJoqU2CZI/zIwG4 I8rdYc9GjmS0sI7ehs3FwNpf24YD0rYs0zDWfyvjXrjOWcioJdAbu1Wd8qdUsY0n1sXY HGGhjwf/J8949qeIVz+Xl5l8Zkm4QINgq1Jwc2rvM4bJYkKvkaKe9krsdnt8N/LOI8u/ dSrj1iLxvr3Yu1UwFQR9op9IFxzaTIcKcSXjz0OhlcYXhbS6n1EeB0GBfriCfllRUjVF lIreLnU6Q8a8F+Ozt35g0bEUr0VbvTPdMQ/yWJskDikbzYXpE6gF8AZCf8qKAgHjNYeA IwUQ== Received: by 10.50.152.137 with SMTP id uy9mr5459009igb.62.1349881150121; Wed, 10 Oct 2012 07:59:10 -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.67.148 with SMTP id n20csp236949igt; Wed, 10 Oct 2012 07:59:08 -0700 (PDT) Received: by 10.204.129.213 with SMTP id p21mr8118894bks.115.1349881146519; Wed, 10 Oct 2012 07:59:06 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id is5si2868610bkc.43.2012.10.10.07.59.05; Wed, 10 Oct 2012 07:59:06 -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 1TLxkW-0002Lj-B3; Wed, 10 Oct 2012 14:59:04 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TLxkU-0002LU-9E for linaro-mm-sig@lists.linaro.org; Wed, 10 Oct 2012 14:59:02 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MBO00AGJMY9Q580@mailout4.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 10 Oct 2012 23:59:00 +0900 (KST) X-AuditID: cbfee61a-b7f726d000000ec7-97-50758d34fae2 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id EA.6A.03783.43D85705; Wed, 10 Oct 2012 23:59:00 +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 <0MBO002YDME0EC70@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 10 Oct 2012 23:59:00 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Wed, 10 Oct 2012 16:46:36 +0200 Message-id: <1349880405-26049-18-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1349880405-26049-1-git-send-email-t.stanislaws@samsung.com> References: <1349880405-26049-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCJMWRmVeSWpSXmKPExsVy+t9jAV2T3tIAg80ztSy+XHnI5MDocfvf Y+YAxigum5TUnMyy1CJ9uwSujEOnLrEWbPOpuPfxNFMD40a7LkZODgkBE4lJP34wQdhiEhfu rWfrYuTiEBJYxCjx+vgGJghnLZPE/rntYFVsQB3HlnxmBLFFBBwkTt+dxQxSxCxwklniyfVX YAlhgUiJZQ+OsYLYLAKqEh3d59lAbF4BT4l/7R/ZIdbJSzy93wcW5wSKX5g3nRnEFhLwkPi/ fjPTBEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNzNzGC/f5MagfjygaLQ4wCHIxKPLwZ USUBQqyJZcWVuYcYJTiYlUR4TX1KA4R4UxIrq1KL8uOLSnNSiw8xSnOwKInzNnukBAgJpCeW pGanphakFsFkmTg4pRoYTQ5+N5j5fcusYtUtncnVH1iZD/7JesNSG9r2zN2cOSRSKaiK50O9 wf5pj7/qzMmIn73iWnDQ77Atr94cW5RxPrVz4k8DhWcBR79lN5ixls46YHWZmf3Vxr1TiqS3 MV94nrtDqPzBIgUv1v6O9FvOgZGau93Sc3QWrnj4xmwGm4Oss8M1XuN2JZbijERDLeai4kQA a+uixPcBAAA= Cc: k.debski@samsung.com, s.nawrocki@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, laurent.pinchart@ideasonboard.com, airlied@redhat.com, remi@remlab.net Subject: [Linaro-mm-sig] [PATCHv10 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: ALoCoQlD4Koa7HAMAo86bOfOlyCGnYS3jgN+caVWR/1qKNUaUoO/yZZFFUyeQrysytc7TYUmh55B 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 Acked-by: Hans Verkuil --- 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 | 212 +++++++++++++++++++++ 4 files changed, 219 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 50eb630..3dd9e78 100644 --- a/Documentation/DocBook/media/v4l/compat.xml +++ b/Documentation/DocBook/media/v4l/compat.xml @@ -2590,6 +2590,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 0abb5cb..81d0ed4 100644 --- a/Documentation/DocBook/media/v4l/io.xml +++ b/Documentation/DocBook/media/v4l/io.xml @@ -488,6 +488,9 @@ DMA 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 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 10ccde9..4d110b1 100644 --- a/Documentation/DocBook/media/v4l/v4l2.xml +++ b/Documentation/DocBook/media/v4l/v4l2.xml @@ -543,6 +543,7 @@ and discussions on the V4L mailing list. &sub-enuminput; &sub-enumoutput; &sub-enumstd; + &sub-expbuf; &sub-g-audio; &sub-g-audioout; &sub-g-crop; diff --git a/Documentation/DocBook/media/v4l/vidioc-expbuf.xml b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml new file mode 100644 index 0000000..72dfbd2 --- /dev/null +++ b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml @@ -0,0 +1,212 @@ + + + + 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 a DMABUF file at any time after buffers have been allocated with the +&VIDIOC-REQBUFS; ioctl. + + To export a buffer, applications fill &v4l2-exportbuffer;. The + type field is set to the same buffer type as was +previously used with &v4l2-requestbuffers; type . +Applications must also set the index field. Valid +index numbers range from zero to the number of buffers allocated with +&VIDIOC-REQBUFS; (&v4l2-requestbuffers; count ) +minus one. For the multi-planar API, applications set the plane + field to the index of the plane to be exported. Valid planes +range from zero to the maximal number of valid planes for the currently active +format. For the single-planar API, applications must set plane + to zero. Additional flags may be posted in the +flags field. Refer to a manual for open() for details. +Currently only O_CLOEXEC is supported. All other fields must be set to zero. +In the 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 DMABUF-aware devices. Refer to +DMABUF importing for details about importing +DMABUF files into V4L2 nodes. It is recommended to close a DMABUF file when it +is no longer used to allow the associated memory to be reclaimed. + + + +
+ Examples + + + Exporting a buffer. + +int buffer_export(int v4lfd, &v4l2-buf-type; bt, int index, int *dmafd) +{ + &v4l2-exportbuffer; expbuf; + + memset(&expbuf, 0, sizeof(expbuf)); + expbuf.type = bt; + expbuf.index = index; + if (ioctl(v4lfd, &VIDIOC-EXPBUF;, &expbuf) == -1) { + perror("VIDIOC_EXPBUF"); + return -1; + } + + *dmafd = expbuf.fd; + + return 0; +} + + + + + Exporting a buffer using the multi-planar API. + +int buffer_export_mp(int v4lfd, &v4l2-buf-type; bt, int index, + int dmafd[], int n_planes) +{ + int i; + + for (i = 0; i < n_planes; ++i) { + &v4l2-exportbuffer; expbuf; + + memset(&expbuf, 0, sizeof(expbuf)); + expbuf.type = bt; + expbuf.index = index; + expbuf.plane = i; + 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 + type + Type of the buffer, same as &v4l2-format; +type or &v4l2-requestbuffers; +type, set by the application. See + + + __u32 + index + Number of the buffer, set by the application. This field is +only used for memory mapping I/O and can range from +zero to the number of buffers allocated with the &VIDIOC-REQBUFS; and/or +&VIDIOC-CREATE-BUFS; ioctls. + + + __u32 + plane + Index of the plane to be exported when using the +multi-planar API. Otherwise this value must be set to zero. + + + __u32 + flags + Flags for the newly created file, currently only +O_CLOEXEC is supported, refer to the manual of open() for more +details. + + + __s32 + fd + The DMABUF file descriptor associated with a buffer. Set by + the driver. + + + __u32 + reserved[11] + 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 flags or type + or index or plane + fields are invalid. + + + + + +