Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: ui/ozone/platform/dri/native_display_delegate_dri.cc

Issue 905873003: [8/8][Ozone-Dri] Pass DRM FD to GPU process on hotplug event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@udl2.9-allow-ndd-to-handle-multiple-drm-devices
Patch Set: . Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/dri/native_display_delegate_dri.h" 5 #include "ui/ozone/platform/dri/native_display_delegate_dri.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_descriptor_posix.h"
10 #include "base/files/file.h"
9 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
10 #include "ui/display/types/native_display_observer.h" 12 #include "ui/display/types/native_display_observer.h"
11 #include "ui/events/ozone/device/device_event.h" 13 #include "ui/events/ozone/device/device_event.h"
12 #include "ui/ozone/common/display_util.h" 14 #include "ui/ozone/common/display_util.h"
13 #include "ui/ozone/platform/dri/display_mode_dri.h" 15 #include "ui/ozone/platform/dri/display_mode_dri.h"
14 #include "ui/ozone/platform/dri/display_snapshot_dri.h" 16 #include "ui/ozone/platform/dri/display_snapshot_dri.h"
15 #include "ui/ozone/platform/dri/dri_util.h" 17 #include "ui/ozone/platform/dri/dri_util.h"
16 #include "ui/ozone/platform/dri/dri_wrapper.h" 18 #include "ui/ozone/platform/dri/dri_wrapper.h"
19 #include "ui/ozone/platform/dri/drm_device_generator.h"
17 #include "ui/ozone/platform/dri/screen_manager.h" 20 #include "ui/ozone/platform/dri/screen_manager.h"
18 #include "ui/ozone/public/ozone_switches.h" 21 #include "ui/ozone/public/ozone_switches.h"
19 22
20 namespace ui { 23 namespace ui {
21 24
22 namespace { 25 namespace {
23 26
24 const char kContentProtection[] = "Content Protection"; 27 const char kContentProtection[] = "Content Protection";
25 28
26 struct ContentProtectionMapping { 29 struct ContentProtectionMapping {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return drm_ == other->drm() && connector_ == other->connector() && 70 return drm_ == other->drm() && connector_ == other->connector() &&
68 crtc_ == other->crtc(); 71 crtc_ == other->crtc();
69 } 72 }
70 73
71 private: 74 private:
72 scoped_refptr<DriWrapper> drm_; 75 scoped_refptr<DriWrapper> drm_;
73 uint32_t crtc_; 76 uint32_t crtc_;
74 uint32_t connector_; 77 uint32_t connector_;
75 }; 78 };
76 79
80 class FindByDevicePath {
81 public:
82 explicit FindByDevicePath(const base::FilePath& path) : path_(path) {}
83
84 bool operator()(const scoped_refptr<DriWrapper>& device) {
85 return device->device_path() == path_;
86 }
87
88 private:
89 base::FilePath path_;
90 };
91
77 } // namespace 92 } // namespace
78 93
79 NativeDisplayDelegateDri::NativeDisplayDelegateDri( 94 NativeDisplayDelegateDri::NativeDisplayDelegateDri(
80 ScreenManager* screen_manager, 95 ScreenManager* screen_manager,
81 const scoped_refptr<DriWrapper>& primary_device) 96 const scoped_refptr<DriWrapper>& primary_device,
82 : screen_manager_(screen_manager) { 97 scoped_ptr<DrmDeviceGenerator> drm_device_generator)
98 : screen_manager_(screen_manager),
99 drm_device_generator_(drm_device_generator.Pass()) {
83 devices_.push_back(primary_device); 100 devices_.push_back(primary_device);
84 } 101 }
85 102
86 NativeDisplayDelegateDri::~NativeDisplayDelegateDri() { 103 NativeDisplayDelegateDri::~NativeDisplayDelegateDri() {
87 } 104 }
88 105
89 void NativeDisplayDelegateDri::ForceDPMSOn() { 106 void NativeDisplayDelegateDri::ForceDPMSOn() {
90 for (size_t i = 0; i < cached_displays_.size(); ++i) { 107 for (size_t i = 0; i < cached_displays_.size(); ++i) {
91 DisplaySnapshotDri* dri_output = cached_displays_[i]; 108 DisplaySnapshotDri* dri_output = cached_displays_[i];
92 if (dri_output->dpms_property()) 109 if (dri_output->dpms_property())
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 bool NativeDisplayDelegateDri::RelinquishDisplayControl() { 205 bool NativeDisplayDelegateDri::RelinquishDisplayControl() {
189 for (const auto& drm : devices_) { 206 for (const auto& drm : devices_) {
190 if (!drm->DropMaster()) { 207 if (!drm->DropMaster()) {
191 LOG(ERROR) << "Failed to relinquish control of the display"; 208 LOG(ERROR) << "Failed to relinquish control of the display";
192 return false; 209 return false;
193 } 210 }
194 } 211 }
195 return true; 212 return true;
196 } 213 }
197 214
198 void NativeDisplayDelegateDri::AddGraphicsDevice(const base::FilePath& path) { 215 void NativeDisplayDelegateDri::AddGraphicsDevice(
199 NOTIMPLEMENTED(); 216 const base::FilePath& path,
217 const base::FileDescriptor& fd) {
218 base::File file(fd.fd);
219 auto it =
220 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path));
221 if (it != devices_.end())
spang 2015/02/12 18:02:46 maybe warn?
dnicoara 2015/02/12 18:11:19 Done.
222 return;
223
224 scoped_refptr<DriWrapper> device =
225 drm_device_generator_->CreateDevice(path, file.Pass());
226 devices_.push_back(device);
227 if (io_task_runner_)
228 device->InitializeTaskRunner(io_task_runner_);
200 } 229 }
201 230
202 void NativeDisplayDelegateDri::RemoveGraphicsDevice( 231 void NativeDisplayDelegateDri::RemoveGraphicsDevice(
203 const base::FilePath& path) { 232 const base::FilePath& path) {
204 NOTIMPLEMENTED(); 233 auto it =
234 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path));
235 if (it == devices_.end()) {
236 LOG(ERROR) << "Got request to remove non-existent device '" << path.value()
237 << "'";
238 return;
239 }
240
241 devices_.erase(it);
205 } 242 }
206 243
207 DisplaySnapshotDri* NativeDisplayDelegateDri::FindDisplaySnapshot(int64_t id) { 244 DisplaySnapshotDri* NativeDisplayDelegateDri::FindDisplaySnapshot(int64_t id) {
208 for (size_t i = 0; i < cached_displays_.size(); ++i) 245 for (size_t i = 0; i < cached_displays_.size(); ++i)
209 if (cached_displays_[i]->display_id() == id) 246 if (cached_displays_[i]->display_id() == id)
210 return cached_displays_[i]; 247 return cached_displays_[i];
211 248
212 return NULL; 249 return NULL;
213 } 250 }
214 251
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 405
369 if (it == old_displays.end()) { 406 if (it == old_displays.end()) {
370 screen_manager_->AddDisplayController(new_displays[i]->drm(), 407 screen_manager_->AddDisplayController(new_displays[i]->drm(),
371 new_displays[i]->crtc(), 408 new_displays[i]->crtc(),
372 new_displays[i]->connector()); 409 new_displays[i]->connector());
373 } 410 }
374 } 411 }
375 } 412 }
376 413
377 } // namespace ui 414 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/native_display_delegate_dri.h ('k') | ui/ozone/platform/dri/native_display_delegate_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698