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

Unified 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: rebase to ToT 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 side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/drm/gpu/drm_device_manager.cc
diff --git a/ui/ozone/platform/drm/gpu/drm_device_manager.cc b/ui/ozone/platform/drm/gpu/drm_device_manager.cc
index b01664abb706586b1332aee3d22d82fa6f87a5f0..1a1dc6ecce1b836fe33531019961e7f7230a236f 100644
--- a/ui/ozone/platform/drm/gpu/drm_device_manager.cc
+++ b/ui/ozone/platform/drm/gpu/drm_device_manager.cc
@@ -17,7 +17,7 @@ class FindByDevicePath {
public:
explicit FindByDevicePath(const base::FilePath& path) : path_(path) {}
- bool operator()(const scoped_refptr<DrmDevice>& device) {
+ bool operator()(const scoped_refptr<DrmDeviceBase>& device) {
return device->device_path() == path_;
}
@@ -25,6 +25,31 @@ class FindByDevicePath {
base::FilePath path_;
};
+class FindVgemDevice {
+ public:
+ FindVgemDevice() {}
+
+ bool operator()(const scoped_refptr<DrmDeviceBase>& device) {
+ return device->GetType() == DrmDeviceBase::VGEM;
+ }
+};
+
+class VgemDevice : public DrmDeviceBase {
+ public:
+ VgemDevice(const base::FilePath& device_path, base::File file)
+ : DrmDeviceBase(device_path, file.Pass()) {}
+ void InitializeTaskRunner(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) override {
+ }
+ Type GetType() const override { return VGEM; }
+
+ protected:
+ ~VgemDevice() override {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(VgemDevice);
+};
+
} // namespace
DrmDeviceManager::DrmDeviceManager(
@@ -75,9 +100,24 @@ void DrmDeviceManager::RemoveDrmDevice(const base::FilePath& path) {
}
DCHECK_NE(primary_device_, *it);
+ DCHECK_NE(DrmDeviceBase::VGEM, (*it)->GetType());
devices_.erase(it);
}
+bool DrmDeviceManager::AddVgemDevice(const base::FilePath& path,
+ const base::FileDescriptor& fd) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ base::File file(fd.fd);
+ auto it =
+ std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path));
+ if (it != devices_.end()) {
+ VLOG(2) << "Got request to add existing device: " << path.value();
+ return false;
+ }
+ devices_.push_back(new VgemDevice(path, file.Pass()));
+ return true;
+}
+
void DrmDeviceManager::InitializeIOTaskRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -115,12 +155,28 @@ scoped_refptr<DrmDevice> DrmDeviceManager::GetDrmDevice(
if (!it->second)
return primary_device_;
+ DCHECK_EQ(it->second->GetType(), DrmDeviceBase::DRM);
return it->second;
}
-const DrmDeviceVector& DrmDeviceManager::GetDrmDevices() const {
+DrmDeviceVector DrmDeviceManager::GetDrmDevices() const {
DCHECK(thread_checker_.CalledOnValidThread());
- return devices_;
+ DrmDeviceVector devices;
+ for (const auto& device : devices_) {
+ if (device->GetType() == DrmDeviceBase::DRM)
+ devices.push_back(static_cast<DrmDevice*>(device.get()));
+ }
+ return devices;
+}
+
+scoped_refptr<DrmDeviceBase> DrmDeviceManager::GetVgemDevice() const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ auto it = std::find_if(devices_.begin(), devices_.end(), FindVgemDevice());
+ if (it == devices_.end()) {
+ VLOG(2) << "Don't support VGEM.";
+ return nullptr;
+ }
+ return *it;
}
} // namespace ui
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_device_manager.h ('k') | ui/ozone/platform/drm/gpu/drm_gpu_display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698