| 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 "base/strings/stringprintf.h" | |
| 6 #include "ui/ozone/platform/dri/dri_util.h" | 5 #include "ui/ozone/platform/dri/dri_util.h" |
| 7 | 6 |
| 8 #include <errno.h> | 7 #include <errno.h> |
| 9 #include <fcntl.h> | 8 #include <fcntl.h> |
| 10 #include <stdint.h> | 9 #include <stdint.h> |
| 11 #include <stdlib.h> | 10 #include <stdlib.h> |
| 12 #include <sys/mman.h> | 11 #include <sys/mman.h> |
| 13 #include <xf86drm.h> | 12 #include <xf86drm.h> |
| 14 #include <xf86drmMode.h> | 13 #include <xf86drmMode.h> |
| 15 | 14 |
| 16 #include "ui/ozone/platform/dri/dri_wrapper.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "ui/ozone/platform/dri/drm_device.h" |
| 17 #include "ui/ozone/platform/dri/screen_manager.h" | 17 #include "ui/ozone/platform/dri/screen_manager.h" |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const char kDefaultGraphicsCardPattern[] = "/dev/dri/card%d"; | 23 const char kDefaultGraphicsCardPattern[] = "/dev/dri/card%d"; |
| 24 | 24 |
| 25 bool IsCrtcInUse(uint32_t crtc, | 25 bool IsCrtcInUse(uint32_t crtc, |
| 26 const ScopedVector<HardwareDisplayControllerInfo>& displays) { | 26 const ScopedVector<HardwareDisplayControllerInfo>& displays) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 fd, | 135 fd, |
| 136 map_request.offset); | 136 map_request.offset); |
| 137 if (*pixels == MAP_FAILED) { | 137 if (*pixels == MAP_FAILED) { |
| 138 VLOG(2) << "Cannot mmap dumb buffer (" << errno << ") " << strerror(errno); | 138 VLOG(2) << "Cannot mmap dumb buffer (" << errno << ") " << strerror(errno); |
| 139 return false; | 139 return false; |
| 140 } | 140 } |
| 141 | 141 |
| 142 return true; | 142 return true; |
| 143 } | 143 } |
| 144 | 144 |
| 145 void ForceInitializationOfPrimaryDisplay(const scoped_refptr<DriWrapper>& drm, | 145 void ForceInitializationOfPrimaryDisplay(const scoped_refptr<DrmDevice>& drm, |
| 146 ScreenManager* screen_manager) { | 146 ScreenManager* screen_manager) { |
| 147 LOG(WARNING) << "Forcing initialization of primary display."; | 147 LOG(WARNING) << "Forcing initialization of primary display."; |
| 148 ScopedVector<HardwareDisplayControllerInfo> displays = | 148 ScopedVector<HardwareDisplayControllerInfo> displays = |
| 149 GetAvailableDisplayControllerInfos(drm->get_fd()); | 149 GetAvailableDisplayControllerInfos(drm->get_fd()); |
| 150 | 150 |
| 151 if (displays.empty()) | 151 if (displays.empty()) |
| 152 return; | 152 return; |
| 153 | 153 |
| 154 ScopedDrmPropertyPtr dpms(drm->GetProperty(displays[0]->connector(), "DPMS")); | 154 ScopedDrmPropertyPtr dpms(drm->GetProperty(displays[0]->connector(), "DPMS")); |
| 155 | 155 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 182 close(fd); | 182 close(fd); |
| 183 if (ret == 0 && res.count_crtcs > 0) { | 183 if (ret == 0 && res.count_crtcs > 0) { |
| 184 return base::FilePath(card_path); | 184 return base::FilePath(card_path); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 return base::FilePath(); | 188 return base::FilePath(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace ui | 191 } // namespace ui |
| OLD | NEW |