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

Side by Side Diff: ui/ozone/platform/dri/dri_wrapper.cc

Issue 956563004: [Ozone-Dri] Gracefully handle DRM devices with no resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 years, 9 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
« no previous file with comments | « ui/ozone/platform/dri/dri_wrapper.h ('k') | ui/ozone/platform/dri/drm_device_generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/dri/dri_wrapper.h" 5 #include "ui/ozone/platform/dri/dri_wrapper.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 void HandlePageFlipEventOnUI(int fd, 82 void HandlePageFlipEventOnUI(int fd,
83 unsigned int frame, 83 unsigned int frame,
84 unsigned int seconds, 84 unsigned int seconds,
85 unsigned int useconds, 85 unsigned int useconds,
86 void* data) { 86 void* data) {
87 scoped_ptr<PageFlipPayload> payload(static_cast<PageFlipPayload*>(data)); 87 scoped_ptr<PageFlipPayload> payload(static_cast<PageFlipPayload*>(data));
88 payload->callback.Run(frame, seconds, useconds); 88 payload->callback.Run(frame, seconds, useconds);
89 } 89 }
90 90
91 bool CanQueryForResources(int fd) {
92 drm_mode_card_res resources;
93 memset(&resources, 0, sizeof(resources));
94 // If there is no error getting DRM resources then assume this is a
95 // modesetting device.
96 return !drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &resources);
97 }
98
91 } // namespace 99 } // namespace
92 100
93 class DriWrapper::IOWatcher 101 class DriWrapper::IOWatcher
94 : public base::RefCountedThreadSafe<DriWrapper::IOWatcher>, 102 : public base::RefCountedThreadSafe<DriWrapper::IOWatcher>,
95 public base::MessagePumpLibevent::Watcher { 103 public base::MessagePumpLibevent::Watcher {
96 public: 104 public:
97 IOWatcher(int fd, 105 IOWatcher(int fd,
98 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) 106 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
99 : io_task_runner_(io_task_runner) { 107 : io_task_runner_(io_task_runner) {
100 io_task_runner_->PostTask(FROM_HERE, 108 io_task_runner_->PostTask(FROM_HERE,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 164
157 DriWrapper::DriWrapper(const base::FilePath& device_path, base::File file) 165 DriWrapper::DriWrapper(const base::FilePath& device_path, base::File file)
158 : device_path_(device_path), file_(file.Pass()) { 166 : device_path_(device_path), file_(file.Pass()) {
159 } 167 }
160 168
161 DriWrapper::~DriWrapper() { 169 DriWrapper::~DriWrapper() {
162 if (watcher_) 170 if (watcher_)
163 watcher_->Shutdown(); 171 watcher_->Shutdown();
164 } 172 }
165 173
166 void DriWrapper::Initialize() { 174 bool DriWrapper::Initialize() {
175 // Ignore devices that cannot perform modesetting.
176 if (!CanQueryForResources(file_.GetPlatformFile())) {
177 VLOG(2) << "Cannot query for resources for '" << device_path_.value()
178 << "'";
179 return false;
180 }
181
167 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy()); 182 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy());
168 if (!plane_manager_->Initialize(this)) 183 if (!plane_manager_->Initialize(this)) {
169 LOG(ERROR) << "Failed to initialize the plane manager"; 184 LOG(ERROR) << "Failed to initialize the plane manager for "
185 << device_path_.value();
186 plane_manager_.reset();
187 return false;
188 }
189
190 return true;
170 } 191 }
171 192
172 void DriWrapper::InitializeTaskRunner( 193 void DriWrapper::InitializeTaskRunner(
173 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { 194 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
174 DCHECK(!task_runner_); 195 DCHECK(!task_runner_);
175 task_runner_ = task_runner; 196 task_runner_ = task_runner;
176 watcher_ = new IOWatcher(file_.GetPlatformFile(), task_runner_); 197 watcher_ = new IOWatcher(file_.GetPlatformFile(), task_runner_);
177 } 198 }
178 199
179 ScopedDrmCrtcPtr DriWrapper::GetCrtc(uint32_t crtc_id) { 200 ScopedDrmCrtcPtr DriWrapper::GetCrtc(uint32_t crtc_id) {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 DCHECK(file_.IsValid()); 427 DCHECK(file_.IsValid());
407 return (drmSetMaster(file_.GetPlatformFile()) == 0); 428 return (drmSetMaster(file_.GetPlatformFile()) == 0);
408 } 429 }
409 430
410 bool DriWrapper::DropMaster() { 431 bool DriWrapper::DropMaster() {
411 DCHECK(file_.IsValid()); 432 DCHECK(file_.IsValid());
412 return (drmDropMaster(file_.GetPlatformFile()) == 0); 433 return (drmDropMaster(file_.GetPlatformFile()) == 0);
413 } 434 }
414 435
415 } // namespace ui 436 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/dri_wrapper.h ('k') | ui/ozone/platform/dri/drm_device_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698