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

Unified Diff: ui/ozone/platform/drm/host/drm_display_host_manager.cc

Issue 1124063003: drm: GPU process manages VGEM fd. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/host/drm_display_host_manager.cc
diff --git a/ui/ozone/platform/drm/host/drm_display_host_manager.cc b/ui/ozone/platform/drm/host/drm_display_host_manager.cc
index 93d43e2467de430ae2cec6ce1655f6eb33dd403d..05aeb2d2a7e8c7cbdb7e28be0cbd50d7ddb59777 100644
--- a/ui/ozone/platform/drm/host/drm_display_host_manager.cc
+++ b/ui/ozone/platform/drm/host/drm_display_host_manager.cc
@@ -31,6 +31,7 @@ typedef base::Callback<void(const base::FilePath&, scoped_ptr<DrmDeviceHandle>)>
OnOpenDeviceReplyCallback;
const char kDefaultGraphicsCardPattern[] = "/dev/dri/card%d";
+const char kVGEMCardPattern[] = "/sys/bus/platform/devices/vgem/drm/card%d";
const char* kDisplayActionString[] = {
"ADD",
@@ -40,10 +41,11 @@ const char* kDisplayActionString[] = {
void OpenDeviceOnWorkerThread(
const base::FilePath& path,
+ bool is_vgem,
const scoped_refptr<base::TaskRunner>& reply_runner,
const OnOpenDeviceReplyCallback& callback) {
scoped_ptr<DrmDeviceHandle> handle(new DrmDeviceHandle());
- handle->Initialize(path);
+ handle->Initialize(path, is_vgem);
reply_runner->PostTask(
FROM_HERE, base::Bind(callback, path, base::Passed(handle.Pass())));
}
@@ -112,7 +114,7 @@ DrmDisplayHostManager::DrmDisplayHostManager(DrmGpuPlatformSupportHost* proxy,
// graphics state.
base::ThreadRestrictions::ScopedAllowIO allow_io;
scoped_ptr<DrmDeviceHandle> handle(new DrmDeviceHandle());
- if (!handle->Initialize(primary_graphics_card_path_)) {
+ if (!handle->Initialize(primary_graphics_card_path_, false)) {
LOG(FATAL) << "Failed to open primary graphics card";
return;
}
@@ -249,7 +251,20 @@ void DrmDisplayHostManager::OnDeviceEvent(const DeviceEvent& event) {
if (event.device_type() != DeviceEvent::DISPLAY)
return;
- event_queue_.push(DisplayEvent(event.action_type(), event.path()));
+ bool is_vgem = false;
+ for (int i = 0; i < 16; i++) {
+ struct stat vgem_stat;
+ std::string vgem_path = base::StringPrintf(kVGEMCardPattern, i);
+ if (stat(vgem_path.c_str(), &vgem_stat) == -1)
+ continue;
+
+ std::string card_path = base::StringPrintf(kDefaultGraphicsCardPattern, i);
+ if (card_path == event.path().value())
+ is_vgem = true;
+ break;
+ }
+
+ event_queue_.push(DisplayEvent(event.action_type(), event.path(), is_vgem));
ProcessEvent();
}
@@ -264,7 +279,7 @@ void DrmDisplayHostManager::ProcessEvent() {
if (drm_devices_.find(event.path) == drm_devices_.end()) {
task_pending_ = base::WorkerPool::PostTask(
FROM_HERE,
- base::Bind(&OpenDeviceOnWorkerThread, event.path,
+ base::Bind(&OpenDeviceOnWorkerThread, event.path, event.is_vgem,
base::ThreadTaskRunnerHandle::Get(),
base::Bind(&DrmDisplayHostManager::OnAddGraphicsDevice,
weak_ptr_factory_.GetWeakPtr())),
@@ -305,7 +320,7 @@ void DrmDisplayHostManager::OnAddGraphicsDevice(
base::ScopedFD file = handle->Duplicate();
drm_devices_.add(path, handle.Pass());
proxy_->Send(new OzoneGpuMsg_AddGraphicsDevice(
- path, base::FileDescriptor(file.Pass())));
+ path, base::FileDescriptor(file.Pass()), handle->IsVgem()));
NotifyDisplayDelegate();
}
@@ -335,12 +350,14 @@ void DrmDisplayHostManager::OnChannelEstablished(
// Send the primary device first since this is used to initialize graphics
// state.
proxy_->Send(new OzoneGpuMsg_AddGraphicsDevice(
- it->first, base::FileDescriptor(it->second->Duplicate())));
+ it->first, base::FileDescriptor(it->second->Duplicate()),
+ it->second->IsVgem()));
for (auto pair : drm_devices_) {
if (pair.second->IsValid() && pair.first != primary_graphics_card_path_) {
proxy_->Send(new OzoneGpuMsg_AddGraphicsDevice(
- pair.first, base::FileDescriptor(pair.second->Duplicate())));
+ pair.first, base::FileDescriptor(pair.second->Duplicate()),
+ it->second->IsVgem()));
}
}

Powered by Google App Engine
This is Rietveld 408576698