OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ozone/impl/drm_wrapper_ozone.h" | 5 #include "ui/gfx/ozone/impl/dri_wrapper.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 #include <xf86drmMode.h> | 9 #include <xf86drmMode.h> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 | 14 |
15 DrmWrapperOzone::DrmWrapperOzone(const char* device_path) { | 15 DriWrapper::DriWrapper(const char* device_path) { |
16 fd_ = open(device_path, O_RDWR | O_CLOEXEC); | 16 fd_ = open(device_path, O_RDWR | O_CLOEXEC); |
17 } | 17 } |
18 | 18 |
19 DrmWrapperOzone::~DrmWrapperOzone() { | 19 DriWrapper::~DriWrapper() { |
20 if (fd_ >= 0) | 20 if (fd_ >= 0) |
21 close(fd_); | 21 close(fd_); |
22 } | 22 } |
23 | 23 |
24 drmModeCrtc* DrmWrapperOzone::GetCrtc(uint32_t crtc_id) { | 24 drmModeCrtc* DriWrapper::GetCrtc(uint32_t crtc_id) { |
25 CHECK(fd_ >= 0); | 25 CHECK(fd_ >= 0); |
26 return drmModeGetCrtc(fd_, crtc_id); | 26 return drmModeGetCrtc(fd_, crtc_id); |
27 } | 27 } |
28 | 28 |
29 void DrmWrapperOzone::FreeCrtc(drmModeCrtc* crtc) { | 29 void DriWrapper::FreeCrtc(drmModeCrtc* crtc) { |
30 drmModeFreeCrtc(crtc); | 30 drmModeFreeCrtc(crtc); |
31 } | 31 } |
32 | 32 |
33 bool DrmWrapperOzone::SetCrtc(uint32_t crtc_id, | 33 bool DriWrapper::SetCrtc(uint32_t crtc_id, |
34 uint32_t framebuffer, | 34 uint32_t framebuffer, |
35 uint32_t* connectors, | 35 uint32_t* connectors, |
36 drmModeModeInfo* mode) { | 36 drmModeModeInfo* mode) { |
37 CHECK(fd_ >= 0); | 37 CHECK(fd_ >= 0); |
38 return !drmModeSetCrtc(fd_, crtc_id, framebuffer, 0, 0, connectors, 1, mode); | 38 return !drmModeSetCrtc(fd_, crtc_id, framebuffer, 0, 0, connectors, 1, mode); |
39 } | 39 } |
40 | 40 |
41 bool DrmWrapperOzone::SetCrtc(drmModeCrtc* crtc, uint32_t* connectors) { | 41 bool DriWrapper::SetCrtc(drmModeCrtc* crtc, uint32_t* connectors) { |
42 CHECK(fd_ >= 0); | 42 CHECK(fd_ >= 0); |
43 return !drmModeSetCrtc(fd_, | 43 return !drmModeSetCrtc(fd_, |
44 crtc->crtc_id, | 44 crtc->crtc_id, |
45 crtc->buffer_id, | 45 crtc->buffer_id, |
46 crtc->x, | 46 crtc->x, |
47 crtc->y, | 47 crtc->y, |
48 connectors, | 48 connectors, |
49 1, | 49 1, |
50 &crtc->mode); | 50 &crtc->mode); |
51 } | 51 } |
52 | 52 |
53 bool DrmWrapperOzone::AddFramebuffer(const drmModeModeInfo& mode, | 53 bool DriWrapper::AddFramebuffer(const drmModeModeInfo& mode, |
54 uint8_t depth, | 54 uint8_t depth, |
55 uint8_t bpp, | 55 uint8_t bpp, |
56 uint32_t stride, | 56 uint32_t stride, |
57 uint32_t handle, | 57 uint32_t handle, |
58 uint32_t* framebuffer) { | 58 uint32_t* framebuffer) { |
59 CHECK(fd_ >= 0); | 59 CHECK(fd_ >= 0); |
60 return !drmModeAddFB(fd_, | 60 return !drmModeAddFB(fd_, |
61 mode.hdisplay, | 61 mode.hdisplay, |
62 mode.vdisplay, | 62 mode.vdisplay, |
63 depth, | 63 depth, |
64 bpp, | 64 bpp, |
65 stride, | 65 stride, |
66 handle, | 66 handle, |
67 framebuffer); | 67 framebuffer); |
68 } | 68 } |
69 | 69 |
70 bool DrmWrapperOzone::RemoveFramebuffer(uint32_t framebuffer) { | 70 bool DriWrapper::RemoveFramebuffer(uint32_t framebuffer) { |
71 CHECK(fd_ >= 0); | 71 CHECK(fd_ >= 0); |
72 return !drmModeRmFB(fd_, framebuffer); | 72 return !drmModeRmFB(fd_, framebuffer); |
73 } | 73 } |
74 | 74 |
75 bool DrmWrapperOzone::PageFlip(uint32_t crtc_id, | 75 bool DriWrapper::PageFlip(uint32_t crtc_id, |
76 uint32_t framebuffer, | 76 uint32_t framebuffer, |
77 void* data) { | 77 void* data) { |
78 CHECK(fd_ >= 0); | 78 CHECK(fd_ >= 0); |
79 return !drmModePageFlip(fd_, | 79 return !drmModePageFlip(fd_, |
80 crtc_id, | 80 crtc_id, |
81 framebuffer, | 81 framebuffer, |
82 DRM_MODE_PAGE_FLIP_EVENT, | 82 DRM_MODE_PAGE_FLIP_EVENT, |
83 data); | 83 data); |
84 } | 84 } |
85 | 85 |
86 bool DrmWrapperOzone::ConnectorSetProperty(uint32_t connector_id, | 86 bool DriWrapper::ConnectorSetProperty(uint32_t connector_id, |
87 uint32_t property_id, | 87 uint32_t property_id, |
88 uint64_t value) { | 88 uint64_t value) { |
89 CHECK(fd_ >= 0); | 89 CHECK(fd_ >= 0); |
90 return !drmModeConnectorSetProperty(fd_, connector_id, property_id, value); | 90 return !drmModeConnectorSetProperty(fd_, connector_id, property_id, value); |
91 } | 91 } |
92 | 92 |
93 } // namespace gfx | 93 } // namespace gfx |
OLD | NEW |