Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.cc

Issue 2297783006: ui: ozone: drm: synchronize mapped dmabuf with read&write (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h" 5 #include "ui/ozone/platform/drm/common/client_native_pixmap_dmabuf.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <sys/mman.h> 9 #include <sys/mman.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
11 11
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/process/memory.h" 13 #include "base/process/memory.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 15
16 #if defined(OS_CHROMEOS) 16 #if defined(OS_CHROMEOS)
17 // TODO(vignatti): replace the local definitions below with #include 17 // TODO(vignatti): replace the local definitions below with #include
18 // <linux/dma-buf.h> once kernel version 4.6 becomes widely used. 18 // <linux/dma-buf.h> once kernel version 4.6 becomes widely used.
19 #include <linux/types.h> 19 #include <linux/types.h>
20 20
21 struct local_dma_buf_sync { 21 struct local_dma_buf_sync {
22 __u64 flags; 22 __u64 flags;
23 }; 23 };
24 24
25 #define LOCAL_DMA_BUF_SYNC_READ (1 << 0) 25 #define LOCAL_DMA_BUF_SYNC_READ (1 << 0)
26 #define LOCAL_DMA_BUF_SYNC_WRITE (2 << 0) 26 #define LOCAL_DMA_BUF_SYNC_WRITE (2 << 0)
27 #define LOCAL_DMA_BUF_SYNC_RW \
28 (LOCAL_DMA_BUF_SYNC_READ | LOCAL_DMA_BUF_SYNC_WRITE)
27 #define LOCAL_DMA_BUF_SYNC_START (0 << 2) 29 #define LOCAL_DMA_BUF_SYNC_START (0 << 2)
28 #define LOCAL_DMA_BUF_SYNC_END (1 << 2) 30 #define LOCAL_DMA_BUF_SYNC_END (1 << 2)
29 31
30 #define LOCAL_DMA_BUF_BASE 'b' 32 #define LOCAL_DMA_BUF_BASE 'b'
31 #define LOCAL_DMA_BUF_IOCTL_SYNC \ 33 #define LOCAL_DMA_BUF_IOCTL_SYNC \
32 _IOW(LOCAL_DMA_BUF_BASE, 0, struct local_dma_buf_sync) 34 _IOW(LOCAL_DMA_BUF_BASE, 0, struct local_dma_buf_sync)
33 #endif 35 #endif
34 36
35 namespace ui { 37 namespace ui {
36 38
37 namespace { 39 namespace {
38 40
39 void PrimeSyncStart(int dmabuf_fd) { 41 void PrimeSyncStart(int dmabuf_fd) {
40 struct local_dma_buf_sync sync_start = {0}; 42 struct local_dma_buf_sync sync_start = {0};
41 43
42 sync_start.flags = LOCAL_DMA_BUF_SYNC_START | LOCAL_DMA_BUF_SYNC_READ; 44 sync_start.flags = LOCAL_DMA_BUF_SYNC_START | LOCAL_DMA_BUF_SYNC_RW;
43 if (drmIoctl(dmabuf_fd, LOCAL_DMA_BUF_IOCTL_SYNC, &sync_start)) 45 if (drmIoctl(dmabuf_fd, LOCAL_DMA_BUF_IOCTL_SYNC, &sync_start))
44 PLOG(ERROR) << "Failed DMA_BUF_SYNC_START"; 46 PLOG(ERROR) << "Failed DMA_BUF_SYNC_START";
45 } 47 }
46 48
47 void PrimeSyncEnd(int dmabuf_fd) { 49 void PrimeSyncEnd(int dmabuf_fd) {
48 struct local_dma_buf_sync sync_end = {0}; 50 struct local_dma_buf_sync sync_end = {0};
49 51
50 sync_end.flags = LOCAL_DMA_BUF_SYNC_END | LOCAL_DMA_BUF_SYNC_WRITE; 52 sync_end.flags = LOCAL_DMA_BUF_SYNC_END | LOCAL_DMA_BUF_SYNC_RW;
51 if (drmIoctl(dmabuf_fd, LOCAL_DMA_BUF_IOCTL_SYNC, &sync_end)) 53 if (drmIoctl(dmabuf_fd, LOCAL_DMA_BUF_IOCTL_SYNC, &sync_end))
52 PLOG(ERROR) << "Failed DMA_BUF_SYNC_END"; 54 PLOG(ERROR) << "Failed DMA_BUF_SYNC_END";
53 } 55 }
54 56
55 } // namespace 57 } // namespace
56 58
57 // static 59 // static
58 std::unique_ptr<ClientNativePixmap> ClientNativePixmapDmaBuf::ImportFromDmabuf( 60 std::unique_ptr<ClientNativePixmap> ClientNativePixmapDmaBuf::ImportFromDmabuf(
59 int dmabuf_fd, 61 int dmabuf_fd,
60 const gfx::Size& size, 62 const gfx::Size& size,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 void ClientNativePixmapDmaBuf::Unmap() { 96 void ClientNativePixmapDmaBuf::Unmap() {
95 TRACE_EVENT0("drm", "DmaBuf:Unmap"); 97 TRACE_EVENT0("drm", "DmaBuf:Unmap");
96 PrimeSyncEnd(dmabuf_fd_.get()); 98 PrimeSyncEnd(dmabuf_fd_.get());
97 } 99 }
98 100
99 void ClientNativePixmapDmaBuf::GetStride(int* stride) const { 101 void ClientNativePixmapDmaBuf::GetStride(int* stride) const {
100 *stride = stride_; 102 *stride = stride_;
101 } 103 }
102 104
103 } // namespace ui 105 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698