| 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> |
| 11 #include <xf86drmMode.h> | 11 #include <xf86drmMode.h> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/stl_util.h" | |
| 16 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
| 17 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 18 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 19 #include "third_party/skia/include/core/SkImageInfo.h" | 18 #include "third_party/skia/include/core/SkImageInfo.h" |
| 20 #include "ui/display/types/gamma_ramp_rgb_entry.h" | 19 #include "ui/display/types/gamma_ramp_rgb_entry.h" |
| 21 #include "ui/ozone/platform/drm/common/drm_util.h" | 20 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 22 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h" | 21 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h" |
| 23 | 22 |
| 24 #if defined(USE_DRM_ATOMIC) | 23 #if defined(USE_DRM_ATOMIC) |
| 25 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h" | 24 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 uint32_t framebuffer, | 259 uint32_t framebuffer, |
| 261 std::vector<uint32_t> connectors, | 260 std::vector<uint32_t> connectors, |
| 262 drmModeModeInfo* mode) { | 261 drmModeModeInfo* mode) { |
| 263 DCHECK(file_.IsValid()); | 262 DCHECK(file_.IsValid()); |
| 264 DCHECK(!connectors.empty()); | 263 DCHECK(!connectors.empty()); |
| 265 DCHECK(mode); | 264 DCHECK(mode); |
| 266 | 265 |
| 267 TRACE_EVENT2("drm", "DrmDevice::SetCrtc", "crtc", crtc_id, "size", | 266 TRACE_EVENT2("drm", "DrmDevice::SetCrtc", "crtc", crtc_id, "size", |
| 268 gfx::Size(mode->hdisplay, mode->vdisplay).ToString()); | 267 gfx::Size(mode->hdisplay, mode->vdisplay).ToString()); |
| 269 return !drmModeSetCrtc(file_.GetPlatformFile(), crtc_id, framebuffer, 0, 0, | 268 return !drmModeSetCrtc(file_.GetPlatformFile(), crtc_id, framebuffer, 0, 0, |
| 270 vector_as_array(&connectors), connectors.size(), mode); | 269 connectors.data(), connectors.size(), mode); |
| 271 } | 270 } |
| 272 | 271 |
| 273 bool DrmDevice::SetCrtc(drmModeCrtc* crtc, std::vector<uint32_t> connectors) { | 272 bool DrmDevice::SetCrtc(drmModeCrtc* crtc, std::vector<uint32_t> connectors) { |
| 274 DCHECK(file_.IsValid()); | 273 DCHECK(file_.IsValid()); |
| 275 // If there's no buffer then the CRTC was disabled. | 274 // If there's no buffer then the CRTC was disabled. |
| 276 if (!crtc->buffer_id) | 275 if (!crtc->buffer_id) |
| 277 return DisableCrtc(crtc->crtc_id); | 276 return DisableCrtc(crtc->crtc_id); |
| 278 | 277 |
| 279 DCHECK(!connectors.empty()); | 278 DCHECK(!connectors.empty()); |
| 280 | 279 |
| 281 TRACE_EVENT1("drm", "DrmDevice::RestoreCrtc", "crtc", crtc->crtc_id); | 280 TRACE_EVENT1("drm", "DrmDevice::RestoreCrtc", "crtc", crtc->crtc_id); |
| 282 return !drmModeSetCrtc(file_.GetPlatformFile(), crtc->crtc_id, | 281 return !drmModeSetCrtc(file_.GetPlatformFile(), crtc->crtc_id, |
| 283 crtc->buffer_id, crtc->x, crtc->y, | 282 crtc->buffer_id, crtc->x, crtc->y, connectors.data(), |
| 284 vector_as_array(&connectors), connectors.size(), | 283 connectors.size(), &crtc->mode); |
| 285 &crtc->mode); | |
| 286 } | 284 } |
| 287 | 285 |
| 288 bool DrmDevice::DisableCrtc(uint32_t crtc_id) { | 286 bool DrmDevice::DisableCrtc(uint32_t crtc_id) { |
| 289 DCHECK(file_.IsValid()); | 287 DCHECK(file_.IsValid()); |
| 290 TRACE_EVENT1("drm", "DrmDevice::DisableCrtc", "crtc", crtc_id); | 288 TRACE_EVENT1("drm", "DrmDevice::DisableCrtc", "crtc", crtc_id); |
| 291 return !drmModeSetCrtc(file_.GetPlatformFile(), crtc_id, 0, 0, 0, NULL, 0, | 289 return !drmModeSetCrtc(file_.GetPlatformFile(), crtc_id, 0, 0, 0, NULL, 0, |
| 292 NULL); | 290 NULL); |
| 293 } | 291 } |
| 294 | 292 |
| 295 ScopedDrmConnectorPtr DrmDevice::GetConnector(uint32_t connector_id) { | 293 ScopedDrmConnectorPtr DrmDevice::GetConnector(uint32_t connector_id) { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 b.push_back(lut[i].b); | 534 b.push_back(lut[i].b); |
| 537 } | 535 } |
| 538 | 536 |
| 539 DCHECK(file_.IsValid()); | 537 DCHECK(file_.IsValid()); |
| 540 TRACE_EVENT0("drm", "DrmDevice::SetGamma"); | 538 TRACE_EVENT0("drm", "DrmDevice::SetGamma"); |
| 541 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], | 539 return (drmModeCrtcSetGamma(file_.GetPlatformFile(), crtc_id, r.size(), &r[0], |
| 542 &g[0], &b[0]) == 0); | 540 &g[0], &b[0]) == 0); |
| 543 } | 541 } |
| 544 | 542 |
| 545 } // namespace ui | 543 } // namespace ui |
| OLD | NEW |