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

Side by Side Diff: ui/gfx/linux/client_native_pixmap_dmabuf.cc

Issue 2794183002: ui: dmabuf: match linux header define names
Patch Set: Created 3 years, 8 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/gfx/linux/client_native_pixmap_dmabuf.h" 5 #include "ui/gfx/linux/client_native_pixmap_dmabuf.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/version.h> 8 #include <linux/version.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <sys/mman.h> 10 #include <sys/mman.h>
11 #include <xf86drm.h> 11 #include <xf86drm.h>
12 12
13 #include "base/debug/crash_logging.h" 13 #include "base/debug/crash_logging.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/process/memory.h" 15 #include "base/process/memory.h"
16 #include "base/process/process_metrics.h" 16 #include "base/process/process_metrics.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 19
20 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) 20 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
21 #include <linux/types.h> 21 #include <linux/types.h>
22 22
23 struct local_dma_buf_sync { 23 struct dma_buf_sync {
24 __u64 flags; 24 __u64 flags;
25 }; 25 };
26 26
27 #define LOCAL_DMA_BUF_SYNC_READ (1 << 0) 27 #define DMA_BUF_SYNC_READ (1 << 0)
28 #define LOCAL_DMA_BUF_SYNC_WRITE (2 << 0) 28 #define DMA_BUF_SYNC_WRITE (2 << 0)
29 #define LOCAL_DMA_BUF_SYNC_RW \ 29 #define DMA_BUF_SYNC_RW (DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE)
30 (LOCAL_DMA_BUF_SYNC_READ | LOCAL_DMA_BUF_SYNC_WRITE) 30 #define DMA_BUF_SYNC_START (0 << 2)
31 #define LOCAL_DMA_BUF_SYNC_START (0 << 2) 31 #define DMA_BUF_SYNC_END (1 << 2)
32 #define LOCAL_DMA_BUF_SYNC_END (1 << 2)
33 32
34 #define LOCAL_DMA_BUF_BASE 'b' 33 #define DMA_BUF_BASE 'b'
35 #define LOCAL_DMA_BUF_IOCTL_SYNC \ 34 #define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
36 _IOW(LOCAL_DMA_BUF_BASE, 0, struct local_dma_buf_sync)
37 35
38 #else 36 #else
39 #include <linux/dma-buf.h> 37 #include <linux/dma-buf.h>
40 #endif 38 #endif
41 39
42 namespace gfx { 40 namespace gfx {
43 41
44 namespace { 42 namespace {
45 43
46 void PrimeSyncStart(int dmabuf_fd) { 44 void PrimeSyncStart(int dmabuf_fd) {
47 struct local_dma_buf_sync sync_start = {0}; 45 struct dma_buf_sync sync_start = {0};
danakj 2017/04/04 15:46:22 I'm confused, how did this work before with kernel
48 46
49 sync_start.flags = LOCAL_DMA_BUF_SYNC_START | LOCAL_DMA_BUF_SYNC_RW; 47 sync_start.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_RW;
50 #if DCHECK_IS_ON() 48 #if DCHECK_IS_ON()
51 int rv = 49 int rv =
52 #endif 50 #endif
53 drmIoctl(dmabuf_fd, LOCAL_DMA_BUF_IOCTL_SYNC, &sync_start); 51 drmIoctl(dmabuf_fd, DMA_BUF_IOCTL_SYNC, &sync_start);
54 DPLOG_IF(ERROR, rv) << "Failed DMA_BUF_SYNC_START"; 52 DPLOG_IF(ERROR, rv) << "Failed DMA_BUF_SYNC_START";
55 } 53 }
56 54
57 void PrimeSyncEnd(int dmabuf_fd) { 55 void PrimeSyncEnd(int dmabuf_fd) {
58 struct local_dma_buf_sync sync_end = {0}; 56 struct dma_buf_sync sync_end = {0};
59 57
60 sync_end.flags = LOCAL_DMA_BUF_SYNC_END | LOCAL_DMA_BUF_SYNC_RW; 58 sync_end.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_RW;
61 #if DCHECK_IS_ON() 59 #if DCHECK_IS_ON()
62 int rv = 60 int rv =
63 #endif 61 #endif
64 drmIoctl(dmabuf_fd, LOCAL_DMA_BUF_IOCTL_SYNC, &sync_end); 62 drmIoctl(dmabuf_fd, DMA_BUF_IOCTL_SYNC, &sync_end);
65 DPLOG_IF(ERROR, rv) << "Failed DMA_BUF_SYNC_END"; 63 DPLOG_IF(ERROR, rv) << "Failed DMA_BUF_SYNC_END";
66 } 64 }
67 65
68 } // namespace 66 } // namespace
69 67
70 // static 68 // static
71 std::unique_ptr<gfx::ClientNativePixmap> 69 std::unique_ptr<gfx::ClientNativePixmap>
72 ClientNativePixmapDmaBuf::ImportFromDmabuf( 70 ClientNativePixmapDmaBuf::ImportFromDmabuf(
73 const gfx::NativePixmapHandle& handle, 71 const gfx::NativePixmapHandle& handle,
74 const gfx::Size& size) { 72 const gfx::Size& size) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 uint8_t* address = reinterpret_cast<uint8_t*>(data_); 145 uint8_t* address = reinterpret_cast<uint8_t*>(data_);
148 return address + pixmap_handle_.planes[plane].offset; 146 return address + pixmap_handle_.planes[plane].offset;
149 } 147 }
150 148
151 int ClientNativePixmapDmaBuf::GetStride(size_t plane) const { 149 int ClientNativePixmapDmaBuf::GetStride(size_t plane) const {
152 DCHECK_LT(plane, pixmap_handle_.planes.size()); 150 DCHECK_LT(plane, pixmap_handle_.planes.size());
153 return pixmap_handle_.planes[plane].stride; 151 return pixmap_handle_.planes[plane].stride;
154 } 152 }
155 153
156 } // namespace gfx 154 } // namespace gfx
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