Chromium Code Reviews| Index: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc |
| diff --git a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc |
| index 26d123a2a452209637a928aa78f7b07d1d1dd3a9..cb1561e99c5e92d64848926ae8966f9f54c63ea0 100644 |
| --- a/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc |
| +++ b/ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc |
| @@ -4,7 +4,9 @@ |
| #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" |
| +#include <errno.h> |
| #include <fcntl.h> |
| +#include <linux/dma-buf.h> |
| #include <stddef.h> |
| #include <sys/mman.h> |
| #include <xf86drm.h> |
| @@ -14,6 +16,25 @@ |
| namespace ui { |
| +namespace { |
| + |
| +void PrimeSyncStart(int dmabuf_fd) { |
| + struct dma_buf_sync sync_start = {0}; |
| + |
| + sync_start.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_READ; |
| + if (drmIoctl(dmabuf_fd, DMA_BUF_IOCTL_SYNC, &sync_start)) |
| + LOG(ERROR) << "fail to sync start dma buf fd, errno: " << errno; |
|
spang
2016/03/30 00:19:00
PLOG(ERROR)
vignatti (out of this project)
2016/03/30 20:04:23
Done.
|
| +} |
| + |
| +void PrimeSyncEnd(int dmabuf_fd) { |
| + struct dma_buf_sync sync_end = {0}; |
| + |
| + sync_end.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_WRITE; |
| + if (drmIoctl(dmabuf_fd, DMA_BUF_IOCTL_SYNC, &sync_end)) |
| + LOG(ERROR) << "fail to sync end dma buf fd, errno " << errno; |
|
spang
2016/03/30 00:19:00
PLOG(ERROR)
vignatti (out of this project)
2016/03/30 20:04:23
Done.
|
| +} |
| +} |
|
spang
2016/03/30 00:19:00
Add a newline between the braces and say
} // na
vignatti (out of this project)
2016/03/30 20:04:23
Done.
|
| + |
| // static |
| scoped_ptr<ClientNativePixmap> ClientNativePixmapDmaBuf::ImportFromDmabuf( |
| int dmabuf_fd, |
| @@ -26,7 +47,7 @@ scoped_ptr<ClientNativePixmap> ClientNativePixmapDmaBuf::ImportFromDmabuf( |
| ClientNativePixmapDmaBuf::ClientNativePixmapDmaBuf(int dmabuf_fd, |
| const gfx::Size& size, |
| int stride) |
| - : size_(size), stride_(stride) { |
| + : dmabuf_fd_(dmabuf_fd), size_(size), stride_(stride) { |
| TRACE_EVENT0("drm", "ClientNativePixmapDmaBuf"); |
| size_t map_size = stride_ * size_.height(); |
| data_ = mmap(nullptr, map_size, (PROT_READ | PROT_WRITE), MAP_SHARED, |
| @@ -36,16 +57,22 @@ ClientNativePixmapDmaBuf::ClientNativePixmapDmaBuf(int dmabuf_fd, |
| ClientNativePixmapDmaBuf::~ClientNativePixmapDmaBuf() { |
| TRACE_EVENT0("drm", "~ClientNativePixmapDmaBuf"); |
| + |
| size_t size = stride_ * size_.height(); |
| int ret = munmap(data_, size); |
| DCHECK(!ret); |
| } |
| void* ClientNativePixmapDmaBuf::Map() { |
| + TRACE_EVENT0("nativepixmap", "DmaBuf:Map"); |
|
spang
2016/03/30 00:19:00
Please, use "drm". This doesn't warrant its own tr
vignatti (out of this project)
2016/03/30 20:04:23
Done.
|
| + PrimeSyncStart(dmabuf_fd_.get()); |
| return data_; |
| } |
| -void ClientNativePixmapDmaBuf::Unmap() {} |
| +void ClientNativePixmapDmaBuf::Unmap() { |
| + TRACE_EVENT0("nativepixmap", "DmaBuf:Unmap"); |
| + PrimeSyncEnd(dmabuf_fd_.get()); |
| +} |
| void ClientNativePixmapDmaBuf::GetStride(int* stride) const { |
| *stride = stride_; |