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 bef88fbb0f1467ba1664cd8d976fa052d7113bf2..d383ed279f953e059436475c573a539c28f75af8 100644 |
--- a/ui/ozone/platform/drm/host/drm_display_host_manager.cc |
+++ b/ui/ozone/platform/drm/host/drm_display_host_manager.cc |
@@ -8,6 +8,7 @@ |
#include <stdio.h> |
#include <xf86drm.h> |
+#include "base/files/file_enumerator.h" |
#include "base/logging.h" |
#include "base/strings/stringprintf.h" |
#include "base/thread_task_runner_handle.h" |
@@ -32,6 +33,8 @@ typedef base::Callback<void(const base::FilePath&, scoped_ptr<DrmDeviceHandle>)> |
OnOpenDeviceReplyCallback; |
const char kDefaultGraphicsCardPattern[] = "/dev/dri/card%d"; |
+const char kVgemDevDriCardPath[] = "/dev/dri/"; |
+const char kVgemSysCardPath[] = "/sys/bus/platform/devices/vgem/drm/"; |
const char* kDisplayActionString[] = { |
"ADD", |
@@ -76,6 +79,23 @@ base::FilePath GetPrimaryDisplayCardPath() { |
return base::FilePath(); |
} |
+base::FilePath GetVgemCardPath() { |
+ base::FileEnumerator file_iter( |
+ base::FilePath::FromUTF8Unsafe(kVgemSysCardPath), false, |
spang
2015/06/03 19:03:21
I don't think you need the FromUTF8Unsafe(). Does
|
+ base::FileEnumerator::DIRECTORIES, FILE_PATH_LITERAL("card*")); |
+ |
+ while (!file_iter.Next().empty()) { |
+ // Inspect the card%d directories in the directory and extract the filename. |
+ std::string vgem_card_path = |
+ kVgemDevDriCardPath + |
+ file_iter.GetInfo().GetName().BaseName().MaybeAsASCII(); |
spang
2015/06/03 19:03:21
Use value() instead of MaybeAsASCII().
dshwang
2015/06/04 08:32:07
Done.
|
+ DVLOG(1) << "VGEM card path is " << vgem_card_path; |
+ return base::FilePath(vgem_card_path); |
+ } |
+ DVLOG(1) << "Don't support VGEM"; |
+ return base::FilePath(); |
+} |
+ |
class FindDrmDisplayHostById { |
public: |
explicit FindDrmDisplayHostById(int64_t display_id) |
@@ -111,6 +131,13 @@ DrmDisplayHostManager::DrmDisplayHostManager(DrmGpuPlatformSupportHost* proxy, |
return; |
} |
drm_devices_.insert(primary_graphics_card_path_); |
+ |
+ vgem_card_path_ = GetVgemCardPath(); |
+ if (!vgem_card_path_.empty()) { |
dshwang
2015/06/03 10:07:35
handle the platform which doesn't have vgem.
spang
2015/06/03 19:03:21
Can you just use open() and store it in a ScopedFD
dshwang
2015/06/04 08:32:07
Done.
|
+ vgem_card_device_file_ = base::File( |
+ vgem_card_path_, base::File::FLAG_OPEN | base::File::FLAG_READ | |
+ base::File::FLAG_WRITE); |
+ } |
} |
device_manager_->AddObserver(this); |
@@ -187,6 +214,8 @@ void DrmDisplayHostManager::ProcessEvent() { |
<< " for " << event.path.value(); |
switch (event.action_type) { |
case DeviceEvent::ADD: |
+ if (event.path == vgem_card_path_) |
+ continue; |
if (drm_devices_.find(event.path) == drm_devices_.end()) { |
task_pending_ = base::WorkerPool::PostTask( |
FROM_HERE, |
@@ -206,6 +235,7 @@ void DrmDisplayHostManager::ProcessEvent() { |
case DeviceEvent::REMOVE: |
DCHECK(event.path != primary_graphics_card_path_) |
<< "Removing primary graphics card"; |
+ DCHECK(event.path != vgem_card_path_) << "Removing VGEM device"; |
auto it = drm_devices_.find(event.path); |
if (it != drm_devices_.end()) { |
task_pending_ = base::ThreadTaskRunnerHandle::Get()->PostTask( |