Hi,
The following APIs are needed for us to support the legacy Tegra
memory manager for devices("NvMap") with *DMA mapping API*.
New API:
->iova_alloc(): To allocate IOVA area.
->iova_alloc_at(): To allocate IOVA area at specific address.
->iova_free(): To free IOVA area.
->map_page_at(): To map page at specific IOVA.
misc:
->iova_get_free_total(): To return how much IOVA is available totally.
->iova_get_free_max(): To return the size of biggest IOVA area.
Although NvMap itself will be replaced soon, there are cases for the
above API where we need to specify IOVA explicitly.
(1) HWAs may require the address for special purpose, like reset vector.
(2) IOVA linear mapping: ex: [RFC 5/5] ARM: dma-mapping: Introduce
dma_map_linear_attrs() for IOVA linear map
(3) To support different heaps. To have allocation and mapping
independently.
Some of them could be supported with creating different mappings, but
currently a device can have a single contiguous mapping, and we cannot
specifiy any address inside of a map since all IOVA alloction is done
implicitly now.
This is the revised version of:
http://lists.linaro.org/pipermail/linaro-mm-sig/2012-May/001947.htmlhttp://lists.linaro.org/pipermail/linaro-mm-sig/2012-May/001948.htmlhttp://lists.linaro.org/pipermail/linaro-mm-sig/2012-May/001949.html
Any comment would be really appreciated.
Hiroshi Doyu (5):
ARM: dma-mapping: New dma_map_ops->iova_get_free_{total,max}
functions
ARM: dma-mapping: New dma_map_ops->iova_{alloc,free}() functions
ARM: dma-mapping: New dma_map_ops->iova_alloc*_at* function
ARM: dma-mapping: New dma_map_ops->map_page*_at* function
ARM: dma-mapping: Introduce dma_map_linear_attrs() for IOVA linear
map
arch/arm/include/asm/dma-mapping.h | 55 +++++++++++++
arch/arm/mm/dma-mapping.c | 124 ++++++++++++++++++++++++++++++
include/asm-generic/dma-mapping-common.h | 20 +++++
include/linux/dma-mapping.h | 14 ++++
4 files changed, 213 insertions(+), 0 deletions(-)
--
1.7.5.4
Hello everyone,
This patchset adds support for DMABUF [2] importing and exporting to V4L2
stack. The importer and exporter part were merged because DMA mapping
redesign [3] was scheduled for merge to mainline.
v8:
- rebased on 3.6-rc1
- merged importer and exporter patchsets
- fixed missing fields in v4l2_plane32 and v4l2_buffer32 structs
- fixed typos/style in documentation
- significant reduction of warnings from checkpatch.pl
- fixed STREAMOFF issues reported by Dima Zavin [4] by adding
__vb2_dqbuf helper to vb2-core
- DC fails if userptr is not correctly aligned
- add support for DMA attributes in DC
- add support for buffers with no kernel mapping
- add reference counting on device from allocator context
- dummy support for mmap
- use dma_get_sgtable, drop vb2_dc_kaddr_to_pages hack and
vb2_dc_get_base_sgt helper
v7:
- support for V4L2_MEMORY_DMABUF in v4l2-compact-ioctl32.c
- cosmetic fixes to the documentation
- added importing for vmalloc because vmap support in dmabuf for 3.5
was pull-requested
- support for dmabuf importing for VIVI
- resurrect allocation of dma-contig context
- remove reference of alloc_ctx in dma-contig buffer
- use sg_alloc_table_from_pages
- fix DMA scatterlist calls to use orig_nents instead of nents
- fix memleak in vb2_dc_sgt_foreach_page (use orig_nents instead of nents)
v6:
- fixed missing entry in v4l2_memory_names
- fixed a bug occuring after get_user_pages failure
- fixed a bug caused by using invalid vma for get_user_pages
- prepare/finish no longer call dma_sync for dmabuf buffers
v5:
- removed change of importer/exporter behaviour
- fixes vb2_dc_pages_to_sgt basing on Laurent's hints
- changed pin/unpin words to lock/unlock in Doc
v4:
- rebased on mainline 3.4-rc2
- included missing importing support for s5p-fimc and s5p-tv
- added patch for changing map/unmap for importers
- fixes to Documentation part
- coding style fixes
- pairing {map/unmap}_dmabuf in vb2-core
- fixing variable types and semantic of arguments in videobufb2-dma-contig.c
v3:
- rebased on mainline 3.4-rc1
- split 'code refactor' patch to multiple smaller patches
- squashed fixes to Sumit's patches
- patchset is no longer dependant on 'DMA mapping redesign'
- separated path for handling IO and non-IO mappings
- add documentation for DMABUF importing to V4L
- removed all DMABUF exporter related code
- removed usage of dma_get_pages extension
v2:
- extended VIDIOC_EXPBUF argument from integer memoffset to struct
v4l2_exportbuffer
- added patch that breaks DMABUF spec on (un)map_atachment callcacks but allows
to work with existing implementation of DMABUF prime in DRM
- all dma-contig code refactoring patches were squashed
- bugfixes
v1: List of changes since [1].
- support for DMA api extension dma_get_pages, the function is used to retrieve
pages used to create DMA mapping.
- small fixes/code cleanup to videobuf2
- added prepare and finish callbacks to vb2 allocators, it is used keep
consistency between dma-cpu acess to the memory (by Marek Szyprowski)
- support for exporting of DMABUF buffer in V4L2 and Videobuf2, originated from
[3].
- support for dma-buf exporting in vb2-dma-contig allocator
- support for DMABUF for s5p-tv and s5p-fimc (capture interface) drivers,
originated from [3]
- changed handling for userptr buffers (by Marek Szyprowski, Andrzej
Pietrasiewicz)
- let mmap method to use dma_mmap_writecombine call (by Marek Szyprowski)
[1] http://thread.gmane.org/gmane.linux.drivers.video-input-infrastructure/4296…
[2] https://lkml.org/lkml/2011/12/26/29
[3] http://thread.gmane.org/gmane.linux.kernel.cross-arch/12819
[4] http://article.gmane.org/gmane.linux.drivers.video-input-infrastructure/497…
Laurent Pinchart (2):
v4l: vb2-dma-contig: Shorten vb2_dma_contig prefix to vb2_dc
v4l: vb2-dma-contig: Reorder functions
Marek Szyprowski (5):
v4l: vb2: add prepare/finish callbacks to allocators
v4l: vb2-dma-contig: add prepare/finish to dma-contig allocator
v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call
media: vb2: fail if user ptr buffer is not correctly aligned
v4l: vb2: add support for DMA_ATTR_NO_KERNEL_MAPPING
Sumit Semwal (4):
v4l: Add DMABUF as a memory type
v4l: vb2: add support for shared buffer (dma_buf)
v4l: vb: remove warnings about MEMORY_DMABUF
v4l: vb2-dma-contig: add support for dma_buf importing
Tomasz Stanislawski (15):
Documentation: media: description of DMABUF importing in V4L2
v4l: vb2-dma-contig: remove reference of alloc_ctx from a buffer
v4l: vb2-dma-contig: add support for scatterlist in userptr mode
v4l: vb2-vmalloc: add support for dmabuf importing
v4l: vivi: support for dmabuf importing
v4l: s5p-tv: mixer: support for dmabuf importing
v4l: s5p-fimc: support for dmabuf importing
Documentation: media: description of DMABUF exporting in V4L2
v4l: add buffer exporting via dmabuf
v4l: vb2: add buffer exporting via dmabuf
v4l: vb2-dma-contig: add support for DMABUF exporting
v4l: vb2-dma-contig: add reference counting for a device from
allocator context
v4l: s5p-fimc: support for dmabuf exporting
v4l: s5p-tv: mixer: support for dmabuf exporting
v4l: s5p-mfc: support for dmabuf exporting
Documentation/DocBook/media/v4l/compat.xml | 7 +
Documentation/DocBook/media/v4l/io.xml | 183 +++++
Documentation/DocBook/media/v4l/v4l2.xml | 1 +
.../DocBook/media/v4l/vidioc-create-bufs.xml | 3 +-
Documentation/DocBook/media/v4l/vidioc-expbuf.xml | 223 ++++++
Documentation/DocBook/media/v4l/vidioc-qbuf.xml | 15 +
Documentation/DocBook/media/v4l/vidioc-reqbufs.xml | 47 +-
drivers/media/video/Kconfig | 1 +
drivers/media/video/atmel-isi.c | 2 +-
drivers/media/video/blackfin/bfin_capture.c | 2 +-
drivers/media/video/marvell-ccic/mcam-core.c | 3 +-
drivers/media/video/mx2_camera.c | 2 +-
drivers/media/video/mx2_emmaprp.c | 2 +-
drivers/media/video/mx3_camera.c | 2 +-
drivers/media/video/s5p-fimc/Kconfig | 1 +
drivers/media/video/s5p-fimc/fimc-capture.c | 11 +-
drivers/media/video/s5p-fimc/fimc-core.c | 2 +-
drivers/media/video/s5p-fimc/fimc-lite.c | 2 +-
drivers/media/video/s5p-g2d/g2d.c | 2 +-
drivers/media/video/s5p-jpeg/jpeg-core.c | 2 +-
drivers/media/video/s5p-mfc/s5p_mfc.c | 5 +-
drivers/media/video/s5p-mfc/s5p_mfc_dec.c | 18 +
drivers/media/video/s5p-mfc/s5p_mfc_enc.c | 18 +
drivers/media/video/s5p-tv/Kconfig | 1 +
drivers/media/video/s5p-tv/mixer_video.c | 14 +-
drivers/media/video/sh_mobile_ceu_camera.c | 2 +-
drivers/media/video/v4l2-compat-ioctl32.c | 19 +
drivers/media/video/v4l2-dev.c | 1 +
drivers/media/video/v4l2-ioctl.c | 16 +
drivers/media/video/videobuf-core.c | 4 +
drivers/media/video/videobuf2-core.c | 275 +++++++-
drivers/media/video/videobuf2-dma-contig.c | 719 ++++++++++++++++++--
drivers/media/video/videobuf2-memops.c | 40 --
drivers/media/video/videobuf2-vmalloc.c | 56 ++
drivers/media/video/vivi.c | 2 +-
drivers/staging/media/dt3155v4l/dt3155v4l.c | 2 +-
include/linux/videodev2.h | 33 +
include/media/v4l2-ioctl.h | 2 +
include/media/videobuf2-core.h | 36 +
include/media/videobuf2-dma-contig.h | 4 +-
include/media/videobuf2-memops.h | 5 -
41 files changed, 1639 insertions(+), 146 deletions(-)
create mode 100644 Documentation/DocBook/media/v4l/vidioc-expbuf.xml
--
1.7.9.5
So I've been experimenting with support for Dave Airlie's new RandR 1.4 provider
object interface, so that Optimus-based laptops can use our driver to drive the
discrete GPU and display on the integrated GPU. The good news is that I've got
a proof of concept working.
During a review of the current code, we came up with a few concerns:
1. The output source is responsible for allocating the shared memory
Right now, the X server calls CreatePixmap on the output source screen and then
expects the output sink screen to be able to display from whatever memory the
source allocates. Right now, the source has no mechanism for asking the sink
what its requirements are for the surface. I'm using our own internal pitch
alignment requirements and that seems to be good enough for the Intel device to
scan out, but that could be pure luck.
Does it make sense to add a mechanism for drivers to negotiate this with each
other, or is it sufficient to just define a lowest common denominator format and
if your hardware can't deal with that format, you just don't get to share
buffers?
One of my coworkers brought to my attention the fact that Tegra requires a
specific pitch alignment, and cannot accommodate larger pitches. If other SoC
designs have similar restrictions, we might need to add a handshake mechanism.
2. There's no fallback mechanism if sharing can't be negotiated
If RandR fails to share a pixmap with the output sink screen, the whole modeset
fails. This means you'll end up not seeing anything on the screen and you'll
probably think your computer locked up. Should there be some sort of software
copy fallback to ensure that something at least shows up on the display?
3. How should the memory be allocated?
In the prototype I threw together, I'm allocating the shared memory using
shm_open and then exporting that as a dma-buf file descriptor using an ioctl I
added to the kernel, and then importing that memory back into our driver through
dma_buf_attach & dma_buf_map_attachment. Does it make sense for user-space
programs to be able to export shmfs files like that? Should that interface go
in DRM / GEM / PRIME instead? Something else? I'm pretty unfamiliar with this
kernel code so any suggestions would be appreciated.
-- Aaron
P.S. for those unfamiliar with PRIME:
Dave Airlie added new support to the X Resize and Rotate extension version 1.4
to support offloading display and rendering to different drivers. PRIME is the
DRM implementation in the kernel, layered on top of DMA-BUF, that implements the
actual sharing of buffers between drivers.
http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt?id=ra…http://airlied.livejournal.com/75555.html - update on hotplug server
http://airlied.livejournal.com/76078.html - randr 1.5 demo videos
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Base on common.git, android-3.4 branch
Patch 2:
Add support page wised cache flush for carveout_heap
There is only one nents for carveout heap, as well as dirty bit.
As a result, cache flush only takes effect for total carve heap.
Patch 3:
Add oom killer.
Once heap is used off,
SIGKILL is send to all tasks refered the buffer with descending oom_socre_adj
Zhangfei Gao (3):
gpu: ion: update carveout_heap_ops
gpu: ion: carveout_heap page wised cache flush
gpu: ion: oom killer
drivers/gpu/ion/ion.c | 112 ++++++++++++++++++++++++++++++++++-
drivers/gpu/ion/ion_carveout_heap.c | 23 ++++++--
2 files changed, 127 insertions(+), 8 deletions(-)
v0->v1:
1, Change gen_pool_create(12, -1) to gen_pool_create(PAGE_SHIFT, -1), suggested by Haojian
2. move ion_shrink out of mutex, suggested by Nishanth
3. check error flag of ERR_PTR(-ENOMEM)
4. add msleep to allow schedule out.
Base on common.git, android-3.4 branch
Patch 2:
Add support page wised cache flush for carveout_heap
There is only one nents for carveout heap, as well as dirty bit.
As a result, cache flush only takes effect for total carve heap.
Patch 3:
Add oom killer.
Once heap is used off,
SIGKILL is send to all tasks refered the buffer with descending oom_socre_adj
Zhangfei Gao (3):
gpu: ion: update carveout_heap_ops
gpu: ion: carveout_heap page wised cache flush
gpu: ion: oom killer
drivers/gpu/ion/ion.c | 118 +++++++++++++++++++++++++++++++++-
drivers/gpu/ion/ion_carveout_heap.c | 25 ++++++--
2 files changed, 133 insertions(+), 10 deletions(-)
Hi,
I've been observing a high rate of failures with CMA allocations on my
ARM system. I've set up a test case set up with a 56MB CMA region that
essentially does the following:
total_failures = 0;
loop forever:
loop_failure = 0;
for (i = 0; i < 56; i++)
chunk[i] = dma_allocate(&cma_dev, 1MB)
if (!chunk[i])
loop_failure = 0
if (loop_failure)
total_failures++
loop_failure = 0
for (i = 0; i < 56; i++)
dma_free(&cma_dev, chunk[i], 1MB)
In the background, I also have a process doing some amount of filesystem
activity (adb push/pull since this is an android system). During the
course of my investigations I generally get ~8500 loops total and ~450
total failures (i.e. one or more buffers could not be allocated). This
is unacceptably high for our use cases.
In every case the allocation failure was ultimately due to a migration
failure; the pages contained buffers which could not be dropped because
the buffers were busy (move_to_new_page -> fallback_migrate_page ->
try_to_release_page -> try_to_free_buffers -> drop_buffers ->
buffer_busy). In every case, the b_count on the buffer head was always 1.
The problem arises because of the LRU lists for buffer heads:
__getblk
__getblk_slow
grow_buffers
grow_dev_page
find_or_create_page -- create a possibly movable page
__find_get_block
__find_get_block_slow
find_get_page -- return the movable page
bh_lru_install
get_bh -- buffer head now has a reference
The reference taken in bh_lru_install won't be dropped until the bh is
evicted from the lru. This means the page cannot be migrated as long as
the buffer exists on an LRU list. The real issue is that unless the
buffer gets evicted quickly the page can remain non-migratible for long
periods of time. This makes CMA regions unusable for long periods of
time given that we generally don't want to size CMA regions any larger
than necessary ergo any failure will cause a problem.
My quick and dirty workaround for testing is to remove the GFP_MOVABLE
flag from find_or_create_page but this seems significantly less than
optimal. Ideally, it seems like the buffers should be evicted from the
LRU when trying to drop (expand on invalid_bh_lru?) but I'm not familiar
enough with the code path to know if this is a good approach.
Any suggestions/feedback is appreciated. Thanks.
Laura
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Hi,
I see that the lowmemkiller.c is changed to use oom_score_adj instead
of oom_adj.
Does this mean I cannot use an ICS system image with 3.4 kernel?
Or is there a workaround?
- Nishanth Peethambaran
looping-in the linaro-mm-sig ML.
On Thu, Aug 30, 2012 at 4:47 PM, Aubertin, Guillaume <g-aubertin(a)ti.com>wrote:
> hi guys,
>
> I've been working for a few days on getting a proper rmmod with the
> remoteproc/rpmsg modules, and I stumbled upon an interesting issue.
>
> when doing sucessive memory allocation and release in the CMA
> reservation (by loading/unloading the firmware several times), the
> following message shows up :
>
> [ 119.908477] cma: dma_alloc_from_contiguous(cma ed10ad00, count 256,
> align 8)
> [ 119.908843] cma: dma_alloc_from_contiguous(): memory range at c0dfb000
> is busy, retrying
> [ 119.909698] cma: dma_alloc_from_contiguous(): returned c0dfd000
>
> dma_alloc_from_contiguous() tries to allocate the following range,
> 0xc0dfd000, succesfully this time.
>
> In some cases, the allocation fails after trying several ranges :
>
> [ 119.912231] cma: dma_alloc_from_contiguous(cma ed10ad00, count 768,
> align 8)
> [ 119.912719] cma: dma_alloc_from_contiguous(): memory range at c0dff000
> is busy, retrying
> [ 119.913055] cma: dma_alloc_from_contiguous(): memory range at c0e01000
> is busy, retrying
> [ 119.913055] rproc remoteproc0: dma_alloc_coherent failed: 3145728
>
> Here is my understanding so far :
>
> First, even if we made a CMA reservation, the kernel can still allocate
> pages in this area, but these pages must be movable (user process page by
> example).
>
> When dma_alloc_from_contiguous() is called to allocate X pages, it looks
> for the next X contiguous free pages in it's CMA bitmap (with respect to
> the memory alignment). Then, alloc_contig_range() is called to allocate the
> given range of pages. Alloc_contig_range() analyses the pages we want to
> allocate, and if a page is already used, it is migrated to a new page
> outside the page array we want to reserve. this is done using
> isolate_migratepages_range() to list the pages to migrate, and
> migrate_pages() to try to migrate the pages, and that's where it fails.
> Below is a list of next function calls :
>
> fallback_migrate_page() --> migrate_page() --> try_to_release_page()
> --> try_to_free_buffer() --> drop_buffers() --> buffer_busy()
>
> I understand here that the page contains used buffers that can't be
> dropped, and so the page can't be migrated. Well, I must admit that once
> here, I'm feeling a little lost in this ocean of memory management code ;).
> After a few researches, I found the following thread on the
> linux-arm-kernel ML talking about the same issue :
>
> http://lists.infradead.org/pipermail/linux-arm-kernel/2012-June/102844.html with
> the following patch :
>
> * mm/page_alloc.c | 3 ++-*
> * 1 files changed, 2 insertions(+), 1 deletions(-)*
> *
> *
> *diff --git a/mm/page_alloc.c b/mm/page_alloc.c*
> *index 0e1c6f5..c9a6483 100644*
> *--- a/mm/page_alloc.c*
> *+++ b/mm/page_alloc.c*
> *@@ -1310,7 +1310,8 @@ void free_hot_cold_page(struct page *page, int
> cold)*
> * * excessively into the page allocator*
> * */*
> * if (migratetype >= MIGRATE_PCPTYPES) {*
> *- if (unlikely(migratetype == MIGRATE_ISOLATE)) {*
> *+ if (unlikely(migratetype == MIGRATE_ISOLATE)*
> *+ || is_migrate_cma(migratetype)) {*
> * free_one_page(zone, page, 0, migratetype);*
> * goto out;*
> * }*
>
> I tried the patch, and it seems to work (I didn't have any "memory range
> busy" in 5000+ tests), but I'm affraid that this could have some nasty side
> effects.
>
> Any idea ?
>
> Thanks in advance,
> Guillaume
>
>
> --
> Texas Instruments France SA, 821 Avenue Jack Kilby, 06270 Villeneuve
> Loubet. 036 420 040 R.C.S Antibes. Capital de EUR 753.920
>
--
Texas Instruments France SA, 821 Avenue Jack Kilby, 06270 Villeneuve
Loubet. 036 420 040 R.C.S Antibes. Capital de EUR 753.920
Hi All,
Over the last few months I've been working on & off with a few people from
Linaro on a new EGL extension. The extension allows constructing an EGLImage
from a (set of) dma_buf file descriptors, including support for multi-plane
YUV. I envisage the primary use-case of this extension to be importing video
frames from v4l2 into the EGL/GLES graphics driver to texture from.
Originally the intent was to develop this as a Khronos-ratified extension.
However, this is a little too platform-specific to be an officially
sanctioned Khronos extension. It also goes against the general "EGLStream"
direction the EGL working group is going in. As such, the general feeling
was to make this an EXT "multi-vendor" extension with no official stamp of
approval from Khronos. As this is no-longer intended to be a Khronos
extension, I've re-written it to be a lot more Linux & dma_buf specific. It
also allows me to circulate the extension more widely (I.e. To those outside
Khronos membership).
ARM are implementing this extension for at least our Mali-T6xx driver and
likely earlier drivers too. I am sending this e-mail to solicit feedback,
both from other vendors who might implement this extension (Mesa3D?) and
from potential users of the extension. However, any feedback is welcome.
Please find the extension text as it currently stands below. There several
open issues which I've proposed solutions for, but I'm not really happy with
those proposals and hoped others could chip-in with better ideas. There are
likely other issues I've not thought about which also need to be added and
addressed.
Once there's a general consensus or if no-one's interested, I'll update the
spec, move it out of Draft status and get it added to the Khronos registry,
which includes assigning values for the new symbols.
Cheers,
Tom
---------8<---------
Name
EXT_image_dma_buf_import
Name Strings
EGL_EXT_image_dma_buf_import
Contributors
Jesse Barker
Rob Clark
Tom Cooksey
Contacts
Jesse Barker (jesse 'dot' barker 'at' linaro 'dot' org)
Tom Cooksey (tom 'dot' cooksey 'at' arm 'dot' com)
Status
DRAFT
Version
Version 3, August 16, 2012
Number
EGL Extension ???
Dependencies
EGL 1.2 is required.
EGL_KHR_image_base is required.
The EGL implementation must be running on a Linux kernel supporting the
dma_buf buffer sharing mechanism.
This extension is written against the wording of the EGL 1.2
Specification.
Overview
This extension allows creating an EGLImage from a Linux dma_buf file
descriptor or multiple file descriptors in the case of multi-plane YUV
images.
New Types
None
New Procedures and Functions
None
New Tokens
Accepted by the <target> parameter of eglCreateImageKHR:
EGL_LINUX_DMA_BUF_EXT
Accepted as an attribute in the <attrib_list> parameter of
eglCreateImageKHR:
EGL_LINUX_DRM_FOURCC_EXT
EGL_DMA_BUF_PLANE0_FD_EXT
EGL_DMA_BUF_PLANE0_OFFSET_EXT
EGL_DMA_BUF_PLANE0_PITCH_EXT
EGL_DMA_BUF_PLANE1_FD_EXT
EGL_DMA_BUF_PLANE1_OFFSET_EXT
EGL_DMA_BUF_PLANE1_PITCH_EXT
EGL_DMA_BUF_PLANE2_FD_EXT
EGL_DMA_BUF_PLANE2_OFFSET_EXT
EGL_DMA_BUF_PLANE2_PITCH_EXT
Additions to Chapter 2 of the EGL 1.2 Specification (EGL Operation)
Add to section 2.5.1 "EGLImage Specification" (as defined by the
EGL_KHR_image_base specification), in the description of
eglCreateImageKHR:
"Values accepted for <target> are listed in Table aaa, below.
+-------------------------+--------------------------------------------+
| <target> | Notes
|
+-------------------------+--------------------------------------------+
| EGL_LINUX_DMA_BUF_EXT | Used for EGLImages imported from Linux
|
| | dma_buf file descriptors
|
+-------------------------+--------------------------------------------+
Table aaa. Legal values for eglCreateImageKHR <target> parameter
...
If <target> is EGL_LINUX_DMA_BUF_EXT, <dpy> must be a valid display,
<ctx>
must be EGL_NO_CONTEXT, and <buffer> must be NULL, cast into the type
EGLClientBuffer. The details of the image is specified by the attributes
passed into eglCreateImageKHR. Required attributes and their values are
as
follows:
* EGL_WIDTH & EGL_HEIGHT: The logical dimensions of the buffer in
pixels
* EGL_LINUX_DRM_FOURCC_EXT: The pixel format of the buffer, as
specified
by drm_fourcc.h and used as the pixel_format parameter of the
drm_mode_fb_cmd2 ioctl.
* EGL_DMA_BUF_PLANE0_FD_EXT: The dma_buf file descriptor of plane 0
of
the image.
* EGL_DMA_BUF_PLANE0_OFFSET_EXT: The offset from the start of the
dma_buf of the first sample in plane 0, in bytes.
* EGL_DMA_BUF_PLANE0_PITCH_EXT: The number of bytes between the
start of
subsequent rows of samples in plane 0. May have special meaning
for
non-linear formats.
For images in an RGB color-space or those using a single-plane YUV
format,
only the first plane's file descriptor, offset & pitch should be
specified.
For semi-planar YUV formats, the chroma samples are stored in plane 1
and
for fully planar formats, U-samples are stored in plane 1 and V-samples
are
stored in plane 2. Planes 1 & 2 are specified by the following
attributes,
which have the same meanings as defined above for plane 0:
* EGL_DMA_BUF_PLANE1_FD_EXT
* EGL_DMA_BUF_PLANE1_OFFSET_EXT
* EGL_DMA_BUF_PLANE1_PITCH_EXT
* EGL_DMA_BUF_PLANE2_FD_EXT
* EGL_DMA_BUF_PLANE2_OFFSET_EXT
* EGL_DMA_BUF_PLANE2_PITCH_EXT
If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT target,
the
EGL takes ownership of the file descriptor and is responsible for
closing
it, which it may do at any time while the EGLDisplay is initialized."
Add to the list of error conditions for eglCreateImageKHR:
"* If <target> is EGL_LINUX_DMA_BUF_EXT and <buffer> is not NULL, the
error EGL_BAD_PARAMETER is generated.
* If <target> is EGL_LINUX_DMA_BUF_EXT, and the list of attributes is
incomplete, EGL_BAD_PARAMETER is generated.
* If <target> is EGL_LINUX_DMA_BUF_EXT, and the
EGL_LINUX_DRM_FOURCC_EXT
attribute is set to a format not supported by the EGL,
EGL_BAD_MATCH
is generated.
* If <target> is EGL_LINUX_DMA_BUF_EXT, and the
EGL_LINUX_DRM_FOURCC_EXT
attribute indicates a single-plane format, EGL_BAD_ATTRIBUTE is
generated if any of the EGL_DMA_BUF_PLANE1_* or
EGL_DMA_BUF_PLANE2_*
attributes are specified.
Issues
1. Should this be a KHR or EXT extension?
ANSWER: EXT. Khronos EGL working group not keen on this extension as it
is
seen as contradicting the EGLStream direction the specification is going
in.
The working group recommends creating additional specs to allow an
EGLStream
producer/consumer connected to v4l2/DRM or any other Linux interface.
2. Should this be a generic any platform extension, or a Linux-only
extension which explicitly states the handles are dma_buf fds?
ANSWER: There's currently no intention to port this extension to any OS
not
based on the Linux kernel. Consequently, this spec can be explicitly
written
against Linux and the dma_buf API.
3. Does ownership of the file descriptor pass to the EGL library?
PROPOSAL: If eglCreateImageKHR is successful, EGL assumes ownership of
the
file descriptors and is responsible for closing them.
4. How are the different YUV color spaces handled (BT.709/BT.601)?
Open issue, still TBD. Doesn't seem to be specified by either the v4l2
or
DRM APIs. PROPOSAL: Undefined and implementation/format dependent.
5. What chroma-siting is used for sub-sampled YUV formats?
Open issue, still TBD. Doesn't seem to be specified by either the v4l2
or
DRM APIs. PROPOSAL: Undefined and implementation/format dependent.
5. How can an application query which formats the EGL implementation
supports?
PROPOSAL: Don't provide a query mechanism but instead add an error
condition
that EGL_BAD_MATCH is raised if the EGL implementation doesn't support
that
particular format.
5. Which image formats should be supported and how is format specified?
Open issue, still TBD. Seem to be two options 1) specify a new enum in
this
specification and enumerate all possible formats. 2) Use an existing
enum
already in Linux, either v4l2_mbus_pixelcode and/or those formats listed
in drm_fourcc.h?
PROPOSAL: Go for option 2) and just use values defined in drm_fourcc.h.
Revision History
#3 (Tom Cooksey, August 16, 2012)
- Changed name from EGL_EXT_image_external and re-written language to
explicitly state this for use with Linux & dma_buf.
- Added a list of issues, including some still open ones.
#2 (Jesse Barker, May 30, 2012)
- Revision to split eglCreateImageKHR functionality from export
Functionality.
- Update definition of EGLNativeBufferType to be a struct containing a
list
of handles to support multi-buffer/multi-planar formats.
#1 (Jesse Barker, March 20, 2012)
- Initial draft.