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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_device_manager.cc

Issue 1124063003: drm: GPU process manages VGEM fd. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use LazyInstance Created 5 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_manager.h" 5 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
6 6
7 #include "base/file_descriptor_posix.h" 7 #include "base/file_descriptor_posix.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "ui/ozone/platform/drm/gpu/drm_device.h" 9 #include "ui/ozone/platform/drm/gpu/drm_device.h"
10 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" 10 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
(...skipping 20 matching lines...) Expand all
31 scoped_ptr<DrmDeviceGenerator> drm_device_generator) 31 scoped_ptr<DrmDeviceGenerator> drm_device_generator)
32 : drm_device_generator_(drm_device_generator.Pass()) { 32 : drm_device_generator_(drm_device_generator.Pass()) {
33 } 33 }
34 34
35 DrmDeviceManager::~DrmDeviceManager() { 35 DrmDeviceManager::~DrmDeviceManager() {
36 DCHECK(thread_checker_.CalledOnValidThread()); 36 DCHECK(thread_checker_.CalledOnValidThread());
37 DCHECK(drm_device_map_.empty()); 37 DCHECK(drm_device_map_.empty());
38 } 38 }
39 39
40 bool DrmDeviceManager::AddDrmDevice(const base::FilePath& path, 40 bool DrmDeviceManager::AddDrmDevice(const base::FilePath& path,
41 const base::FileDescriptor& fd) { 41 const base::FileDescriptor& fd,
42 bool is_vgem) {
42 DCHECK(thread_checker_.CalledOnValidThread()); 43 DCHECK(thread_checker_.CalledOnValidThread());
44
45 if (is_vgem) {
46 vgem_device_.reset(fd.fd);
47 vgem_path_ = path;
48 return true;
49 }
50
43 base::File file(fd.fd); 51 base::File file(fd.fd);
44 auto it = 52 auto it =
45 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path)); 53 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path));
46 if (it != devices_.end()) { 54 if (it != devices_.end()) {
47 VLOG(2) << "Got request to add existing device: " << path.value(); 55 VLOG(2) << "Got request to add existing device: " << path.value();
48 return false; 56 return false;
49 } 57 }
50 58
51 scoped_refptr<DrmDevice> device = 59 scoped_refptr<DrmDevice> device =
52 drm_device_generator_->CreateDevice(path, file.Pass()); 60 drm_device_generator_->CreateDevice(path, file.Pass());
53 if (!device) { 61 if (!device) {
54 LOG(ERROR) << "Could not initialize DRM device for " << path.value(); 62 LOG(ERROR) << "Could not initialize DRM device for " << path.value();
55 return false; 63 return false;
56 } 64 }
57 65
58 if (io_task_runner_) 66 if (io_task_runner_)
59 device->InitializeTaskRunner(io_task_runner_); 67 device->InitializeTaskRunner(io_task_runner_);
60 68
61 if (!primary_device_) 69 if (!primary_device_)
62 primary_device_ = device; 70 primary_device_ = device;
63 71
64 devices_.push_back(device); 72 devices_.push_back(device);
65 return true; 73 return true;
66 } 74 }
67 75
68 void DrmDeviceManager::RemoveDrmDevice(const base::FilePath& path) { 76 void DrmDeviceManager::RemoveDrmDevice(const base::FilePath& path) {
69 DCHECK(thread_checker_.CalledOnValidThread()); 77 DCHECK(thread_checker_.CalledOnValidThread());
78 if (vgem_path_ == path) {
dnicoara 2015/05/12 15:41:22 Should it be possible to remove the VGEM device? I
dshwang 2015/05/12 16:18:57 What's mean? IMO it's impossible for chromium to d
79 vgem_device_.reset();
80 vgem_path_ = base::FilePath();
81 return;
82 }
83
70 auto it = 84 auto it =
71 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path)); 85 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path));
72 if (it == devices_.end()) { 86 if (it == devices_.end()) {
73 VLOG(2) << "Got request to remove non-existent device: " << path.value(); 87 VLOG(2) << "Got request to remove non-existent device: " << path.value();
74 return; 88 return;
75 } 89 }
76 90
77 DCHECK_NE(primary_device_, *it); 91 DCHECK_NE(primary_device_, *it);
78 devices_.erase(it); 92 devices_.erase(it);
79 } 93 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return primary_device_; 130 return primary_device_;
117 131
118 return it->second; 132 return it->second;
119 } 133 }
120 134
121 const DrmDeviceVector& DrmDeviceManager::GetDrmDevices() const { 135 const DrmDeviceVector& DrmDeviceManager::GetDrmDevices() const {
122 DCHECK(thread_checker_.CalledOnValidThread()); 136 DCHECK(thread_checker_.CalledOnValidThread());
123 return devices_; 137 return devices_;
124 } 138 }
125 139
140 int DrmDeviceManager::GetVgemDevice() const {
141 DCHECK(thread_checker_.CalledOnValidThread());
142 return vgem_device_.get();
143 }
144
126 } // namespace ui 145 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698