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 <sys/mman.h> | 8 #include <sys/mman.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 #include <xf86drm.h> | 10 #include <xf86drm.h> |
11 #include <xf86drmMode.h> | 11 #include <xf86drmMode.h> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
17 #include "base/task_runner.h" | 17 #include "base/task_runner.h" |
18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
19 #include "base/trace_event/trace_event.h" | 19 #include "base/trace_event/trace_event.h" |
20 #include "third_party/skia/include/core/SkImageInfo.h" | 20 #include "third_party/skia/include/core/SkImageInfo.h" |
21 #include "ui/display/types/gamma_ramp_rgb_entry.h" | |
22 #include "ui/ozone/platform/drm/gpu/drm_util.h" | 21 #include "ui/ozone/platform/drm/gpu/drm_util.h" |
23 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h" | 22 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h" |
24 | 23 |
25 #if defined(USE_DRM_ATOMIC) | 24 #if defined(USE_DRM_ATOMIC) |
26 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h" | 25 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h" |
27 #endif | 26 #endif |
28 | 27 |
29 namespace ui { | 28 namespace ui { |
30 | 29 |
31 namespace { | 30 namespace { |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 bool DrmDevice::SetMaster() { | 577 bool DrmDevice::SetMaster() { |
579 DCHECK(file_.IsValid()); | 578 DCHECK(file_.IsValid()); |
580 return (drmSetMaster(file_.GetPlatformFile()) == 0); | 579 return (drmSetMaster(file_.GetPlatformFile()) == 0); |
581 } | 580 } |
582 | 581 |
583 bool DrmDevice::DropMaster() { | 582 bool DrmDevice::DropMaster() { |
584 DCHECK(file_.IsValid()); | 583 DCHECK(file_.IsValid()); |
585 return (drmDropMaster(file_.GetPlatformFile()) == 0); | 584 return (drmDropMaster(file_.GetPlatformFile()) == 0); |
586 } | 585 } |
587 | 586 |
588 bool DrmDevice::SetGammaRamp(uint32_t crtc_id, | |
589 const std::vector<GammaRampRGBEntry>& lut) { | |
590 ScopedDrmCrtcPtr crtc = GetCrtc(crtc_id); | |
591 | |
592 // TODO(robert.bradford) resample the incoming ramp to match what the kernel | |
593 // expects. | |
594 if (static_cast<size_t>(crtc->gamma_size) != lut.size()) { | |
595 LOG(ERROR) << "Gamma table size mismatch: supplied " << lut.size() | |
596 << " expected " << crtc->gamma_size; | |
597 } | |
598 | |
599 std::vector<uint16_t> r, g, b; | |
600 r.reserve(lut.size()); | |
601 g.reserve(lut.size()); | |
602 b.reserve(lut.size()); | |
603 | |
604 for (size_t i = 0; i < lut.size(); ++i) { | |
605 r.push_back(lut[i].r); | |
606 g.push_back(lut[i].g); | |
607 b.push_back(lut[i].b); | |
608 } | |
609 | |
610 DCHECK(file_.IsValid()); | |
611 TRACE_EVENT0("drm", "DrmDevice::SetGamma"); | |
612 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], | |
613 &g[0], &b[0]) == 0); | |
614 } | |
615 | |
616 } // namespace ui | 587 } // namespace ui |
OLD | NEW |