| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gpu/drm_device.h" | 5 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <i915_drm.h> |
| 8 #include <sys/mman.h> | 9 #include <sys/mman.h> |
| 9 #include <unistd.h> | 10 #include <unistd.h> |
| 10 #include <xf86drm.h> | 11 #include <xf86drm.h> |
| 11 #include <xf86drmMode.h> | 12 #include <xf86drmMode.h> |
| 12 | 13 |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 16 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/task_runner.h" | 18 #include "base/task_runner.h" |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 g.push_back(lut[i].g); | 609 g.push_back(lut[i].g); |
| 609 b.push_back(lut[i].b); | 610 b.push_back(lut[i].b); |
| 610 } | 611 } |
| 611 | 612 |
| 612 DCHECK(file_.IsValid()); | 613 DCHECK(file_.IsValid()); |
| 613 TRACE_EVENT0("drm", "DrmDevice::SetGamma"); | 614 TRACE_EVENT0("drm", "DrmDevice::SetGamma"); |
| 614 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], | 615 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], |
| 615 &g[0], &b[0]) == 0); | 616 &g[0], &b[0]) == 0); |
| 616 } | 617 } |
| 617 | 618 |
| 619 bool DrmDevice::BufferHandleToFd(uint32_t handle, int* fd) { |
| 620 int ret; |
| 621 |
| 622 ret = drmPrimeHandleToFD(file_.GetPlatformFile(), handle, DRM_CLOEXEC, fd); |
| 623 if (ret == -1) |
| 624 return false; |
| 625 |
| 626 return true; |
| 627 } |
| 628 |
| 629 bool DrmDevice::BufferFdToHandle(int fd, uint32_t* handle) { |
| 630 int ret; |
| 631 |
| 632 ret = drmPrimeFDToHandle(file_.GetPlatformFile(), fd, handle); |
| 633 if (ret == -1) |
| 634 return false; |
| 635 |
| 636 return true; |
| 637 } |
| 638 |
| 639 bool DrmDevice::BufferHandleSetTiling(uint32_t handle, |
| 640 uint32_t stride, |
| 641 uint32_t tiling_mode) { |
| 642 struct drm_i915_gem_set_tiling set_tiling; |
| 643 int ret; |
| 644 |
| 645 do { |
| 646 set_tiling.handle = handle; |
| 647 set_tiling.tiling_mode = tiling_mode; |
| 648 set_tiling.stride = stride; |
| 649 |
| 650 ret = drmIoctl(file_.GetPlatformFile(), DRM_IOCTL_I915_GEM_SET_TILING, |
| 651 &set_tiling); |
| 652 } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); |
| 653 |
| 654 return ret != -1; |
| 655 } |
| 656 |
| 618 } // namespace ui | 657 } // namespace ui |
| OLD | NEW |