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