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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_device.cc

Issue 1147553003: ozone: Add atomic initialization path (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove flag for now 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 unified diff | Download patch
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/drm/gpu/drm_device.h" 5 #include "ui/ozone/platform/drm/gpu/drm_device.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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 : device_path_(device_path), 283 : device_path_(device_path),
284 file_(file.Pass()), 284 file_(file.Pass()),
285 page_flip_manager_(new PageFlipManager()) { 285 page_flip_manager_(new PageFlipManager()) {
286 } 286 }
287 287
288 DrmDevice::~DrmDevice() { 288 DrmDevice::~DrmDevice() {
289 if (watcher_) 289 if (watcher_)
290 watcher_->Shutdown(); 290 watcher_->Shutdown();
291 } 291 }
292 292
293 bool DrmDevice::Initialize() { 293 bool DrmDevice::Initialize(bool use_atomic) {
294 // Ignore devices that cannot perform modesetting. 294 // Ignore devices that cannot perform modesetting.
295 if (!CanQueryForResources(file_.GetPlatformFile())) { 295 if (!CanQueryForResources(file_.GetPlatformFile())) {
296 VLOG(2) << "Cannot query for resources for '" << device_path_.value() 296 VLOG(2) << "Cannot query for resources for '" << device_path_.value()
297 << "'"; 297 << "'";
298 return false; 298 return false;
299 } 299 }
300 300
301 #if defined(USE_DRM_ATOMIC) 301 #if defined(USE_DRM_ATOMIC)
302 plane_manager_.reset(new HardwareDisplayPlaneManagerAtomic()); 302 // Use atomic only if the build, kernel & flags all allow it.
303 #else 303 if (use_atomic && SetCapability(DRM_CLIENT_CAP_ATOMIC, 1))
304 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy()); 304 plane_manager_.reset(new HardwareDisplayPlaneManagerAtomic());
305 #endif // defined(USE_DRM_ATOMIC) 305 #endif // defined(USE_DRM_ATOMIC)
306
307 if (!plane_manager_)
308 plane_manager_.reset(new HardwareDisplayPlaneManagerLegacy());
306 if (!plane_manager_->Initialize(this)) { 309 if (!plane_manager_->Initialize(this)) {
307 LOG(ERROR) << "Failed to initialize the plane manager for " 310 LOG(ERROR) << "Failed to initialize the plane manager for "
308 << device_path_.value(); 311 << device_path_.value();
309 plane_manager_.reset(); 312 plane_manager_.reset();
310 return false; 313 return false;
311 } 314 }
312 315
313 return true; 316 return true;
314 } 317 }
315 318
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 return !drmIoctl(file_.GetPlatformFile(), DRM_IOCTL_GEM_CLOSE, 559 return !drmIoctl(file_.GetPlatformFile(), DRM_IOCTL_GEM_CLOSE,
557 &close_request); 560 &close_request);
558 } 561 }
559 562
560 bool DrmDevice::CommitProperties(drmModePropertySet* properties, 563 bool DrmDevice::CommitProperties(drmModePropertySet* properties,
561 uint32_t flags, 564 uint32_t flags,
562 bool is_sync, 565 bool is_sync,
563 const PageFlipCallback& callback) { 566 const PageFlipCallback& callback) {
564 #if defined(USE_DRM_ATOMIC) 567 #if defined(USE_DRM_ATOMIC)
565 flags |= DRM_MODE_PAGE_FLIP_EVENT; 568 flags |= DRM_MODE_PAGE_FLIP_EVENT;
566 scoped_ptr<PageFlipPayload> payload(
567 new PageFlipPayload(base::ThreadTaskRunnerHandle::Get(), callback));
568 uint64_t id = page_flip_manager_->GetNextId(); 569 uint64_t id = page_flip_manager_->GetNextId();
569 if (!drmModePropertySetCommit(file_.GetPlatformFile(), flags, payload.get(), 570 if (!drmModePropertySetCommit(file_.GetPlatformFile(), flags,
570 properties)) { 571 reinterpret_cast<void*>(id), properties)) {
571 page_flip_manager_->RegisterCallback(id, callback); 572 page_flip_manager_->RegisterCallback(id, callback);
572 573
573 // If the flip was requested synchronous or if no watcher has been installed 574 // If the flip was requested synchronous or if no watcher has been installed
574 // yet, then synchronously handle the page flip events. 575 // yet, then synchronously handle the page flip events.
575 if (is_sync || !watcher_) { 576 if (is_sync || !watcher_) {
576 TRACE_EVENT1("drm", "OnDrmEvent", "socket", file_.GetPlatformFile()); 577 TRACE_EVENT1("drm", "OnDrmEvent", "socket", file_.GetPlatformFile());
577 578
578 ProcessDrmEvent( 579 ProcessDrmEvent(
579 file_.GetPlatformFile(), 580 file_.GetPlatformFile(),
580 base::Bind(&PageFlipManager::OnPageFlip, page_flip_manager_)); 581 base::Bind(&PageFlipManager::OnPageFlip, page_flip_manager_));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 b.push_back(lut[i].b); 623 b.push_back(lut[i].b);
623 } 624 }
624 625
625 DCHECK(file_.IsValid()); 626 DCHECK(file_.IsValid());
626 TRACE_EVENT0("drm", "DrmDevice::SetGamma"); 627 TRACE_EVENT0("drm", "DrmDevice::SetGamma");
627 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], 628 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0],
628 &g[0], &b[0]) == 0); 629 &g[0], &b[0]) == 0);
629 } 630 }
630 631
631 } // namespace ui 632 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698