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

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

Issue 1100973002: [2/4]Allow hotplugging of primary DRM device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-hotplug
Patch Set: unittests Created 5 years, 8 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
« no previous file with comments | « ui/ozone/platform/drm/gpu/screen_manager_unittest.cc ('k') | ui/ozone/platform/drm/ozone_platform_drm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/drm/host/drm_native_display_delegate.cc
diff --git a/ui/ozone/platform/drm/host/drm_native_display_delegate.cc b/ui/ozone/platform/drm/host/drm_native_display_delegate.cc
index dc57045af3ea8f6974963f34e81dc9dbe8f81d68..ca13a19f02630107337e01c3cdca558cb60fcede 100644
--- a/ui/ozone/platform/drm/host/drm_native_display_delegate.cc
+++ b/ui/ozone/platform/drm/host/drm_native_display_delegate.cc
@@ -5,6 +5,7 @@
#include "ui/ozone/platform/drm/host/drm_native_display_delegate.h"
#include <stdio.h>
+#include <xf86drm.h>
#include "base/logging.h"
#include "base/thread_task_runner_handle.h"
@@ -33,21 +34,42 @@ const char* kDisplayActionString[] = {
"CHANGE",
};
+bool Authenticate(int fd) {
+ drm_magic_t magic = 0;
+ // We need to make sure the DRM device has enough privilege. Use the DRM
+ // authentication logic to figure out if the device has enough permissions.
+ return !drmGetMagic(fd, &magic) && !drmAuthMagic(fd, magic);
+}
+
base::File OpenDrmDevice(const base::FilePath& path) {
- base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ |
- base::File::FLAG_WRITE);
+ base::File file;
+ bool print_warning = true;
+ while (true) {
+ file = base::File(path, base::File::FLAG_OPEN | base::File::FLAG_READ |
+ base::File::FLAG_WRITE);
+
+ base::File::Info info;
+ file.GetInfo(&info);
+
+ CHECK(!info.is_directory);
+ CHECK(path.DirName() == base::FilePath("/dev/dri"));
+
+ if (!file.IsValid()) {
+ LOG(ERROR) << "Failed to open " << path.value() << ": "
+ << base::File::ErrorToString(file.error_details());
+ return file.Pass();
+ }
- base::File::Info info;
- file.GetInfo(&info);
+ if (Authenticate(file.GetPlatformFile()))
+ break;
- CHECK(!info.is_directory);
- CHECK(path.DirName() == base::FilePath("/dev/dri"));
+ LOG_IF(WARNING, print_warning) << "Failed to authenticate " << path.value();
- if (!file.IsValid()) {
- LOG(ERROR) << "Failed to open " << path.value() << ": "
- << base::File::ErrorToString(file.error_details());
+ print_warning = false;
+ usleep(100000);
}
+ VLOG(1) << "Succeeded authenticating " << path.value();
return file.Pass();
}
@@ -323,6 +345,20 @@ void DrmNativeDisplayDelegate::OnChannelEstablished(
const base::Callback<void(IPC::Message*)>& send_callback) {
drm_devices_.clear();
drm_devices_.insert(primary_graphics_card_path_);
+ {
+ // First device needs to be treated specially. We need to open this
+ // synchronously since the GPU process will need it to initialize the
+ // graphics state.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ base::File file = OpenDrmDevice(primary_graphics_card_path_);
+ if (!file.IsValid()) {
+ LOG(FATAL) << "Failed to open primary graphics card";
+ return;
+ }
+ proxy_->Send(new OzoneGpuMsg_AddGraphicsDevice(
+ primary_graphics_card_path_, base::FileDescriptor(file.Pass())));
+ }
+
device_manager_->ScanDevices(this);
FOR_EACH_OBSERVER(NativeDisplayObserver, observers_,
OnConfigurationChanged());
« no previous file with comments | « ui/ozone/platform/drm/gpu/screen_manager_unittest.cc ('k') | ui/ozone/platform/drm/ozone_platform_drm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698