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/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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 scoped_refptr<DrmDevice::PageFlipManager> page_flip_manager_; | 261 scoped_refptr<DrmDevice::PageFlipManager> page_flip_manager_; |
262 | 262 |
263 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 263 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
264 | 264 |
265 bool paused_; | 265 bool paused_; |
266 int fd_; | 266 int fd_; |
267 | 267 |
268 DISALLOW_COPY_AND_ASSIGN(IOWatcher); | 268 DISALLOW_COPY_AND_ASSIGN(IOWatcher); |
269 }; | 269 }; |
270 | 270 |
271 DrmDevice::DrmDevice(const base::FilePath& device_path) | 271 DrmDeviceBase::DrmDeviceBase(const base::FilePath& device_path, base::File file) |
272 : device_path_(device_path), | 272 : device_path_(device_path), file_(file.Pass()) { |
273 file_(device_path, | 273 } |
274 base::File::FLAG_OPEN | base::File::FLAG_READ | | 274 |
275 base::File::FLAG_WRITE), | 275 DrmDeviceBase::~DrmDeviceBase() { |
276 page_flip_manager_(new PageFlipManager()) { | |
277 LOG_IF(FATAL, !file_.IsValid()) | |
278 << "Failed to open '" << device_path_.value() | |
279 << "': " << base::File::ErrorToString(file_.error_details()); | |
280 } | 276 } |
281 | 277 |
282 DrmDevice::DrmDevice(const base::FilePath& device_path, base::File file) | 278 DrmDevice::DrmDevice(const base::FilePath& device_path, base::File file) |
283 : device_path_(device_path), | 279 : DrmDeviceBase(device_path, file.Pass()), |
284 file_(file.Pass()), | |
285 page_flip_manager_(new PageFlipManager()) { | 280 page_flip_manager_(new PageFlipManager()) { |
286 } | 281 } |
287 | 282 |
288 DrmDevice::~DrmDevice() { | 283 DrmDevice::~DrmDevice() { |
289 if (watcher_) | 284 if (watcher_) |
290 watcher_->Shutdown(); | 285 watcher_->Shutdown(); |
291 } | 286 } |
292 | 287 |
293 bool DrmDevice::Initialize() { | 288 bool DrmDevice::Initialize() { |
294 // Ignore devices that cannot perform modesetting. | 289 // Ignore devices that cannot perform modesetting. |
(...skipping 19 matching lines...) Expand all Loading... |
314 } | 309 } |
315 | 310 |
316 void DrmDevice::InitializeTaskRunner( | 311 void DrmDevice::InitializeTaskRunner( |
317 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 312 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
318 DCHECK(!task_runner_); | 313 DCHECK(!task_runner_); |
319 task_runner_ = task_runner; | 314 task_runner_ = task_runner; |
320 watcher_ = | 315 watcher_ = |
321 new IOWatcher(file_.GetPlatformFile(), task_runner_, page_flip_manager_); | 316 new IOWatcher(file_.GetPlatformFile(), task_runner_, page_flip_manager_); |
322 } | 317 } |
323 | 318 |
| 319 DrmDeviceBase::Type DrmDevice::GetType() const { |
| 320 return DRM; |
| 321 } |
| 322 |
324 ScopedDrmCrtcPtr DrmDevice::GetCrtc(uint32_t crtc_id) { | 323 ScopedDrmCrtcPtr DrmDevice::GetCrtc(uint32_t crtc_id) { |
325 DCHECK(file_.IsValid()); | 324 DCHECK(file_.IsValid()); |
326 return ScopedDrmCrtcPtr(drmModeGetCrtc(file_.GetPlatformFile(), crtc_id)); | 325 return ScopedDrmCrtcPtr(drmModeGetCrtc(file_.GetPlatformFile(), crtc_id)); |
327 } | 326 } |
328 | 327 |
329 bool DrmDevice::SetCrtc(uint32_t crtc_id, | 328 bool DrmDevice::SetCrtc(uint32_t crtc_id, |
330 uint32_t framebuffer, | 329 uint32_t framebuffer, |
331 std::vector<uint32_t> connectors, | 330 std::vector<uint32_t> connectors, |
332 drmModeModeInfo* mode) { | 331 drmModeModeInfo* mode) { |
333 DCHECK(file_.IsValid()); | 332 DCHECK(file_.IsValid()); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 b.push_back(lut[i].b); | 621 b.push_back(lut[i].b); |
623 } | 622 } |
624 | 623 |
625 DCHECK(file_.IsValid()); | 624 DCHECK(file_.IsValid()); |
626 TRACE_EVENT0("drm", "DrmDevice::SetGamma"); | 625 TRACE_EVENT0("drm", "DrmDevice::SetGamma"); |
627 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], | 626 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], |
628 &g[0], &b[0]) == 0); | 627 &g[0], &b[0]) == 0); |
629 } | 628 } |
630 | 629 |
631 } // namespace ui | 630 } // namespace ui |
OLD | NEW |