OLD | NEW |
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 DriWrapper::~DriWrapper() { | 152 DriWrapper::~DriWrapper() { |
153 if (fd_ >= 0) | 153 if (fd_ >= 0) |
154 close(fd_); | 154 close(fd_); |
155 | 155 |
156 if (watcher_) | 156 if (watcher_) |
157 watcher_->Shutdown(); | 157 watcher_->Shutdown(); |
158 } | 158 } |
159 | 159 |
160 void DriWrapper::Initialize() { | 160 void DriWrapper::Initialize() { |
161 fd_ = open(device_path_, O_RDWR | O_CLOEXEC); | 161 if (device_path_ == NULL) |
| 162 fd_ = OpenFirstDisplayCard(); |
| 163 else |
| 164 fd_ = open(device_path_, O_RDWR | O_CLOEXEC); |
162 if (fd_ < 0) | 165 if (fd_ < 0) |
163 PLOG(FATAL) << "open: " << device_path_; | 166 PLOG(FATAL) << "open: " << device_path_; |
164 if (!plane_manager_->Initialize(this)) | 167 if (!plane_manager_->Initialize(this)) |
165 LOG(ERROR) << "Failed to initialize the plane manager"; | 168 LOG(ERROR) << "Failed to initialize the plane manager"; |
166 } | 169 } |
167 | 170 |
168 void DriWrapper::InitializeTaskRunner( | 171 void DriWrapper::InitializeTaskRunner( |
169 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 172 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
170 DCHECK(!task_runner_); | 173 DCHECK(!task_runner_); |
171 task_runner_ = task_runner; | 174 task_runner_ = task_runner; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 DCHECK(fd_ >= 0); | 411 DCHECK(fd_ >= 0); |
409 return (drmSetMaster(fd_) == 0); | 412 return (drmSetMaster(fd_) == 0); |
410 } | 413 } |
411 | 414 |
412 bool DriWrapper::DropMaster() { | 415 bool DriWrapper::DropMaster() { |
413 DCHECK(fd_ >= 0); | 416 DCHECK(fd_ >= 0); |
414 return (drmDropMaster(fd_) == 0); | 417 return (drmDropMaster(fd_) == 0); |
415 } | 418 } |
416 | 419 |
417 } // namespace ui | 420 } // namespace ui |
OLD | NEW |