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/common/drm_util.h" | 5 #include "ui/ozone/platform/drm/common/drm_util.h" |
6 | 6 |
7 #include <drm_fourcc.h> | 7 #include <drm_fourcc.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 int GetDrmProperty(int fd, | 101 int GetDrmProperty(int fd, |
102 drmModeConnector* connector, | 102 drmModeConnector* connector, |
103 const std::string& name, | 103 const std::string& name, |
104 ScopedDrmPropertyPtr* property) { | 104 ScopedDrmPropertyPtr* property) { |
105 for (int i = 0; i < connector->count_props; ++i) { | 105 for (int i = 0; i < connector->count_props; ++i) { |
106 ScopedDrmPropertyPtr tmp(drmModeGetProperty(fd, connector->props[i])); | 106 ScopedDrmPropertyPtr tmp(drmModeGetProperty(fd, connector->props[i])); |
107 if (!tmp) | 107 if (!tmp) |
108 continue; | 108 continue; |
109 | 109 |
110 if (name == tmp->name) { | 110 if (name == tmp->name) { |
111 *property = tmp.Pass(); | 111 *property = std::move(tmp); |
112 return i; | 112 return i; |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 return -1; | 116 return -1; |
117 } | 117 } |
118 | 118 |
119 std::string GetNameForEnumValue(drmModePropertyRes* property, uint32_t value) { | 119 std::string GetNameForEnumValue(drmModePropertyRes* property, uint32_t value) { |
120 for (int i = 0; i < property->count_enums; ++i) | 120 for (int i = 0; i < property->count_enums; ++i) |
121 if (property->enums[i].value == value) | 121 if (property->enums[i].value == value) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 DCHECK_LT(display_index, 16); | 155 DCHECK_LT(display_index, 16); |
156 return ((device_index << 4) + display_index) & 0xFF; | 156 return ((device_index << 4) + display_index) & 0xFF; |
157 } | 157 } |
158 | 158 |
159 } // namespace | 159 } // namespace |
160 | 160 |
161 HardwareDisplayControllerInfo::HardwareDisplayControllerInfo( | 161 HardwareDisplayControllerInfo::HardwareDisplayControllerInfo( |
162 ScopedDrmConnectorPtr connector, | 162 ScopedDrmConnectorPtr connector, |
163 ScopedDrmCrtcPtr crtc, | 163 ScopedDrmCrtcPtr crtc, |
164 size_t index) | 164 size_t index) |
165 : connector_(connector.Pass()), crtc_(crtc.Pass()), index_(index) {} | 165 : connector_(std::move(connector)), crtc_(std::move(crtc)), index_(index) {} |
166 | 166 |
167 HardwareDisplayControllerInfo::~HardwareDisplayControllerInfo() { | 167 HardwareDisplayControllerInfo::~HardwareDisplayControllerInfo() { |
168 } | 168 } |
169 | 169 |
170 ScopedVector<HardwareDisplayControllerInfo> GetAvailableDisplayControllerInfos( | 170 ScopedVector<HardwareDisplayControllerInfo> GetAvailableDisplayControllerInfos( |
171 int fd) { | 171 int fd) { |
172 ScopedDrmResourcesPtr resources(drmModeGetResources(fd)); | 172 ScopedDrmResourcesPtr resources(drmModeGetResources(fd)); |
173 DCHECK(resources) << "Failed to get DRM resources"; | 173 DCHECK(resources) << "Failed to get DRM resources"; |
174 ScopedVector<HardwareDisplayControllerInfo> displays; | 174 ScopedVector<HardwareDisplayControllerInfo> displays; |
175 | 175 |
176 for (int i = 0; i < resources->count_connectors; ++i) { | 176 for (int i = 0; i < resources->count_connectors; ++i) { |
177 ScopedDrmConnectorPtr connector( | 177 ScopedDrmConnectorPtr connector( |
178 drmModeGetConnector(fd, resources->connectors[i])); | 178 drmModeGetConnector(fd, resources->connectors[i])); |
179 | 179 |
180 if (!connector || connector->connection != DRM_MODE_CONNECTED || | 180 if (!connector || connector->connection != DRM_MODE_CONNECTED || |
181 connector->count_modes == 0) | 181 connector->count_modes == 0) |
182 continue; | 182 continue; |
183 | 183 |
184 uint32_t crtc_id = GetCrtc(fd, connector.get(), resources.get(), displays); | 184 uint32_t crtc_id = GetCrtc(fd, connector.get(), resources.get(), displays); |
185 if (!crtc_id) | 185 if (!crtc_id) |
186 continue; | 186 continue; |
187 | 187 |
188 ScopedDrmCrtcPtr crtc(drmModeGetCrtc(fd, crtc_id)); | 188 ScopedDrmCrtcPtr crtc(drmModeGetCrtc(fd, crtc_id)); |
189 displays.push_back( | 189 displays.push_back(new HardwareDisplayControllerInfo(std::move(connector), |
190 new HardwareDisplayControllerInfo(connector.Pass(), crtc.Pass(), i)); | 190 std::move(crtc), i)); |
191 } | 191 } |
192 | 192 |
193 return displays.Pass(); | 193 return displays; |
194 } | 194 } |
195 | 195 |
196 bool SameMode(const drmModeModeInfo& lhs, const drmModeModeInfo& rhs) { | 196 bool SameMode(const drmModeModeInfo& lhs, const drmModeModeInfo& rhs) { |
197 return lhs.clock == rhs.clock && lhs.hdisplay == rhs.hdisplay && | 197 return lhs.clock == rhs.clock && lhs.hdisplay == rhs.hdisplay && |
198 lhs.vdisplay == rhs.vdisplay && lhs.vrefresh == rhs.vrefresh && | 198 lhs.vdisplay == rhs.vdisplay && lhs.vrefresh == rhs.vrefresh && |
199 lhs.hsync_start == rhs.hsync_start && lhs.hsync_end == rhs.hsync_end && | 199 lhs.hsync_start == rhs.hsync_start && lhs.hsync_end == rhs.hsync_end && |
200 lhs.htotal == rhs.htotal && lhs.hskew == rhs.hskew && | 200 lhs.htotal == rhs.htotal && lhs.hskew == rhs.hskew && |
201 lhs.vsync_start == rhs.vsync_start && lhs.vsync_end == rhs.vsync_end && | 201 lhs.vsync_start == rhs.vsync_start && lhs.vsync_end == rhs.vsync_end && |
202 lhs.vtotal == rhs.vtotal && lhs.vscan == rhs.vscan && | 202 lhs.vtotal == rhs.vtotal && lhs.vscan == rhs.vscan && |
203 lhs.flags == rhs.flags && strcmp(lhs.name, rhs.name) == 0; | 203 lhs.flags == rhs.flags && strcmp(lhs.name, rhs.name) == 0; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 case DRM_FORMAT_XRGB8888: | 292 case DRM_FORMAT_XRGB8888: |
293 return gfx::BufferFormat::BGRX_8888; | 293 return gfx::BufferFormat::BGRX_8888; |
294 case DRM_FORMAT_UYVY: | 294 case DRM_FORMAT_UYVY: |
295 return gfx::BufferFormat::UYVY_422; | 295 return gfx::BufferFormat::UYVY_422; |
296 default: | 296 default: |
297 NOTREACHED(); | 297 NOTREACHED(); |
298 return gfx::BufferFormat::BGRA_8888; | 298 return gfx::BufferFormat::BGRA_8888; |
299 } | 299 } |
300 } | 300 } |
301 } // namespace ui | 301 } // namespace ui |
OLD | NEW |