| 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/ozone/platform/drm/gpu/drm_util.h" | 21 #include "ui/ozone/platform/drm/gpu/drm_util.h" |
| 22 #if defined(OZONE_USE_ATOMIC) |
| 23 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h" |
| 24 #endif |
| 22 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h" | 25 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h" |
| 23 | 26 |
| 24 namespace ui { | 27 namespace ui { |
| 25 | 28 |
| 26 namespace { | 29 namespace { |
| 27 | 30 |
| 28 struct PageFlipPayload { | 31 struct PageFlipPayload { |
| 29 PageFlipPayload(const scoped_refptr<base::TaskRunner>& task_runner, | 32 PageFlipPayload(const scoped_refptr<base::TaskRunner>& task_runner, |
| 30 const DrmDevice::PageFlipCallback& callback) | 33 const DrmDevice::PageFlipCallback& callback) |
| 31 : task_runner(task_runner), callback(callback) {} | 34 : task_runner(task_runner), callback(callback) {} |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 195 } |
| 193 | 196 |
| 194 bool DrmDevice::Initialize() { | 197 bool DrmDevice::Initialize() { |
| 195 // Ignore devices that cannot perform modesetting. | 198 // Ignore devices that cannot perform modesetting. |
| 196 if (!CanQueryForResources(file_.GetPlatformFile())) { | 199 if (!CanQueryForResources(file_.GetPlatformFile())) { |
| 197 VLOG(2) << "Cannot query for resources for '" << device_path_.value() | 200 VLOG(2) << "Cannot query for resources for '" << device_path_.value() |
| 198 << "'"; | 201 << "'"; |
| 199 return false; | 202 return false; |
| 200 } | 203 } |
| 201 | 204 |
| 205 #if defined(OZONE_USE_ATOMIC) |
| 206 plane_manager_.reset(new HardwareDisplayPlaneManagerAtomic()); |
| 207 #else |
| 202 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy()); | 208 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy()); |
| 209 #endif |
| 203 if (!plane_manager_->Initialize(this)) { | 210 if (!plane_manager_->Initialize(this)) { |
| 204 LOG(ERROR) << "Failed to initialize the plane manager for " | 211 LOG(ERROR) << "Failed to initialize the plane manager for " |
| 205 << device_path_.value(); | 212 << device_path_.value(); |
| 206 plane_manager_.reset(); | 213 plane_manager_.reset(); |
| 207 return false; | 214 return false; |
| 208 } | 215 } |
| 209 | 216 |
| 210 return true; | 217 return true; |
| 211 } | 218 } |
| 212 | 219 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 void DrmDevice::DestroyDumbBuffer(const SkImageInfo& info, | 439 void DrmDevice::DestroyDumbBuffer(const SkImageInfo& info, |
| 433 uint32_t handle, | 440 uint32_t handle, |
| 434 uint32_t stride, | 441 uint32_t stride, |
| 435 void* pixels) { | 442 void* pixels) { |
| 436 DCHECK(file_.IsValid()); | 443 DCHECK(file_.IsValid()); |
| 437 TRACE_EVENT1("drm", "DrmDevice::DestroyDumbBuffer", "handle", handle); | 444 TRACE_EVENT1("drm", "DrmDevice::DestroyDumbBuffer", "handle", handle); |
| 438 munmap(pixels, info.getSafeSize(stride)); | 445 munmap(pixels, info.getSafeSize(stride)); |
| 439 DrmDestroyDumbBuffer(file_.GetPlatformFile(), handle); | 446 DrmDestroyDumbBuffer(file_.GetPlatformFile(), handle); |
| 440 } | 447 } |
| 441 | 448 |
| 449 bool DrmDevice::CommitProperties(drmModePropertySet* properties, |
| 450 uint32_t flags, |
| 451 void* user_ptr) { |
| 452 #if defined(OZONE_USE_ATOMIC) |
| 453 return drmModePropertySetCommit(file_.GetPlatformFile(), flags, user_ptr, |
| 454 properties) == 0; |
| 455 #else |
| 456 return false; |
| 457 #endif |
| 458 } |
| 459 |
| 442 bool DrmDevice::SetMaster() { | 460 bool DrmDevice::SetMaster() { |
| 443 DCHECK(file_.IsValid()); | 461 DCHECK(file_.IsValid()); |
| 444 return (drmSetMaster(file_.GetPlatformFile()) == 0); | 462 return (drmSetMaster(file_.GetPlatformFile()) == 0); |
| 445 } | 463 } |
| 446 | 464 |
| 447 bool DrmDevice::DropMaster() { | 465 bool DrmDevice::DropMaster() { |
| 448 DCHECK(file_.IsValid()); | 466 DCHECK(file_.IsValid()); |
| 449 return (drmDropMaster(file_.GetPlatformFile()) == 0); | 467 return (drmDropMaster(file_.GetPlatformFile()) == 0); |
| 450 } | 468 } |
| 451 | 469 |
| 452 } // namespace ui | 470 } // namespace ui |
| OLD | NEW |