| 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/host/drm_display_host_manager.h" | 5 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <xf86drm.h> | 8 #include <xf86drm.h> |
| 9 | 9 |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| 11 #include "base/posix/eintr_wrapper.h" | 11 #include "base/posix/eintr_wrapper.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
| 14 #include "base/threading/worker_pool.h" | 14 #include "base/threading/worker_pool.h" |
| 15 #include "ui/display/types/display_snapshot.h" | 15 #include "ui/display/types/display_snapshot.h" |
| 16 #include "ui/events/ozone/device/device_event.h" | 16 #include "ui/events/ozone/device/device_event.h" |
| 17 #include "ui/events/ozone/device/device_manager.h" | 17 #include "ui/events/ozone/device/device_manager.h" |
| 18 #include "ui/ozone/common/display_util.h" | 18 #include "ui/ozone/common/display_util.h" |
| 19 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" | 19 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" |
| 20 #include "ui/ozone/platform/drm/common/drm_util.h" | 20 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 21 #include "ui/ozone/platform/drm/host/drm_device_handle.h" | 21 #include "ui/ozone/platform/drm/host/drm_device_handle.h" |
| 22 #include "ui/ozone/platform/drm/host/drm_display_host.h" | 22 #include "ui/ozone/platform/drm/host/drm_display_host.h" |
| 23 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" | 23 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h" |
| 24 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" | 24 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" |
| 25 | 25 |
| 26 #include "base/command_line.h" |
| 27 #include "ui/ozone/public/ozone_switches.h" |
| 28 |
| 26 namespace ui { | 29 namespace ui { |
| 27 | 30 |
| 28 namespace { | 31 namespace { |
| 29 | 32 |
| 30 typedef base::Callback<void(const base::FilePath&, scoped_ptr<DrmDeviceHandle>)> | 33 typedef base::Callback<void(const base::FilePath&, scoped_ptr<DrmDeviceHandle>)> |
| 31 OnOpenDeviceReplyCallback; | 34 OnOpenDeviceReplyCallback; |
| 32 | 35 |
| 33 const char kDefaultGraphicsCardPattern[] = "/dev/dri/card%d"; | 36 const char kDefaultGraphicsCardPattern[] = "/dev/dri/card%d"; |
| 37 const char kDefaultRenderNodePattern[] = "/dev/dri/renderD128"; |
| 34 const char kVgemDevDriCardPath[] = "/dev/dri/"; | 38 const char kVgemDevDriCardPath[] = "/dev/dri/"; |
| 35 const char kVgemSysCardPath[] = "/sys/bus/platform/devices/vgem/drm/"; | 39 const char kVgemSysCardPath[] = "/sys/bus/platform/devices/vgem/drm/"; |
| 36 | 40 |
| 37 const char* kDisplayActionString[] = { | 41 const char* kDisplayActionString[] = { |
| 38 "ADD", | 42 "ADD", |
| 39 "REMOVE", | 43 "REMOVE", |
| 40 "CHANGE", | 44 "CHANGE", |
| 41 }; | 45 }; |
| 42 | 46 |
| 43 void OpenDeviceOnWorkerThread( | 47 void OpenDeviceOnWorkerThread( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // synchronously since the GPU process will need it to initialize the | 126 // synchronously since the GPU process will need it to initialize the |
| 123 // graphics state. | 127 // graphics state. |
| 124 base::ThreadRestrictions::ScopedAllowIO allow_io; | 128 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 125 primary_drm_device_handle_.reset(new DrmDeviceHandle()); | 129 primary_drm_device_handle_.reset(new DrmDeviceHandle()); |
| 126 if (!primary_drm_device_handle_->Initialize(primary_graphics_card_path_)) { | 130 if (!primary_drm_device_handle_->Initialize(primary_graphics_card_path_)) { |
| 127 LOG(FATAL) << "Failed to open primary graphics card"; | 131 LOG(FATAL) << "Failed to open primary graphics card"; |
| 128 return; | 132 return; |
| 129 } | 133 } |
| 130 drm_devices_.insert(primary_graphics_card_path_); | 134 drm_devices_.insert(primary_graphics_card_path_); |
| 131 | 135 |
| 136 int fd = HANDLE_EINTR(open(kDefaultRenderNodePattern, O_RDWR | O_CLOEXEC)); |
| 137 if (fd < 0) { |
| 138 PLOG(ERROR) << "Failed to open primary render node: " |
| 139 << kDefaultRenderNodePattern; |
| 140 } |
| 141 primary_render_node_file_.reset(fd); |
| 142 |
| 132 vgem_card_path_ = GetVgemCardPath(); | 143 vgem_card_path_ = GetVgemCardPath(); |
| 133 if (!vgem_card_path_.empty()) { | 144 if (!vgem_card_path_.empty()) { |
| 134 int fd = HANDLE_EINTR( | 145 int fd = HANDLE_EINTR( |
| 135 open(vgem_card_path_.value().c_str(), O_RDWR | O_CLOEXEC)); | 146 open(vgem_card_path_.value().c_str(), O_RDWR | O_CLOEXEC)); |
| 136 if (fd < 0) { | 147 if (fd < 0) { |
| 137 PLOG(ERROR) << "Failed to open vgem: " << vgem_card_path_.value(); | 148 PLOG(ERROR) << "Failed to open vgem: " << vgem_card_path_.value(); |
| 138 } | 149 } |
| 139 vgem_card_device_file_.reset(fd); | 150 vgem_card_device_file_.reset(fd); |
| 140 } | 151 } |
| 141 } | 152 } |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 485 |
| 475 callback.Run(snapshots); | 486 callback.Run(snapshots); |
| 476 } | 487 } |
| 477 | 488 |
| 478 void DrmDisplayHostManager::NotifyDisplayDelegate() const { | 489 void DrmDisplayHostManager::NotifyDisplayDelegate() const { |
| 479 if (delegate_) | 490 if (delegate_) |
| 480 delegate_->OnConfigurationChanged(); | 491 delegate_->OnConfigurationChanged(); |
| 481 } | 492 } |
| 482 | 493 |
| 483 } // namespace ui | 494 } // namespace ui |
| OLD | NEW |