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> |
11 #include <xf86drm.h> | 11 #include <xf86drm.h> |
12 #include <xf86drmMode.h> | 12 #include <xf86drmMode.h> |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "ui/display/util/edid_parser.h" | 15 #include "ui/display/util/edid_parser.h" |
16 | 16 |
17 #if !defined(DRM_MODE_CONNECTOR_DSI) | 17 #if !defined(DRM_MODE_CONNECTOR_DSI) |
18 #define DRM_MODE_CONNECTOR_DSI 16 | 18 #define DRM_MODE_CONNECTOR_DSI 16 |
19 #endif | 19 #endif |
20 | 20 |
21 #if !defined(DRM_CAP_CURSOR_WIDTH) | 21 #if !defined(DRM_CAP_CURSOR_WIDTH) |
22 #define DRM_CAP_CURSOR_WIDTH 0x8 | 22 #define DRM_CAP_CURSOR_WIDTH 0x8 |
23 #endif | 23 #endif |
24 | 24 |
25 #if !defined(DRM_CAP_CURSOR_HEIGHT) | 25 #if !defined(DRM_CAP_CURSOR_HEIGHT) |
26 #define DRM_CAP_CURSOR_HEIGHT 0x9 | 26 #define DRM_CAP_CURSOR_HEIGHT 0x9 |
27 #endif | 27 #endif |
28 | 28 |
| 29 #if !defined(DRM_FORMAT_R8) |
| 30 // TODO(dshwang): after most linux and libdrm has this definition, remove it. |
| 31 #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') |
| 32 #endif |
| 33 |
29 namespace ui { | 34 namespace ui { |
30 | 35 |
31 namespace { | 36 namespace { |
32 | 37 |
33 static const size_t kDefaultCursorWidth = 64; | 38 static const size_t kDefaultCursorWidth = 64; |
34 static const size_t kDefaultCursorHeight = 64; | 39 static const size_t kDefaultCursorHeight = 64; |
35 | 40 |
36 bool IsCrtcInUse(uint32_t crtc, | 41 bool IsCrtcInUse(uint32_t crtc, |
37 const ScopedVector<HardwareDisplayControllerInfo>& displays) { | 42 const ScopedVector<HardwareDisplayControllerInfo>& displays) { |
38 for (size_t i = 0; i < displays.size(); ++i) { | 43 for (size_t i = 0; i < displays.size(); ++i) { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 if (!params.has_native_mode && !params.modes.empty()) { | 316 if (!params.has_native_mode && !params.modes.empty()) { |
312 params.has_native_mode = true; | 317 params.has_native_mode = true; |
313 params.native_mode = params.modes.front(); | 318 params.native_mode = params.modes.front(); |
314 } | 319 } |
315 | 320 |
316 return params; | 321 return params; |
317 } | 322 } |
318 | 323 |
319 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) { | 324 int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) { |
320 switch (format) { | 325 switch (format) { |
| 326 case gfx::BufferFormat::R_8: |
| 327 return DRM_FORMAT_R8; |
321 case gfx::BufferFormat::RGBA_8888: | 328 case gfx::BufferFormat::RGBA_8888: |
322 return DRM_FORMAT_ABGR8888; | 329 return DRM_FORMAT_ABGR8888; |
323 case gfx::BufferFormat::RGBX_8888: | 330 case gfx::BufferFormat::RGBX_8888: |
324 return DRM_FORMAT_XBGR8888; | 331 return DRM_FORMAT_XBGR8888; |
325 case gfx::BufferFormat::BGRA_8888: | 332 case gfx::BufferFormat::BGRA_8888: |
326 return DRM_FORMAT_ARGB8888; | 333 return DRM_FORMAT_ARGB8888; |
327 case gfx::BufferFormat::BGRX_8888: | 334 case gfx::BufferFormat::BGRX_8888: |
328 return DRM_FORMAT_XRGB8888; | 335 return DRM_FORMAT_XRGB8888; |
329 case gfx::BufferFormat::UYVY_422: | 336 case gfx::BufferFormat::UYVY_422: |
330 return DRM_FORMAT_UYVY; | 337 return DRM_FORMAT_UYVY; |
331 default: | 338 default: |
332 NOTREACHED(); | 339 NOTREACHED(); |
333 return 0; | 340 return 0; |
334 } | 341 } |
335 } | 342 } |
336 | 343 |
337 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { | 344 gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { |
338 switch (format) { | 345 switch (format) { |
| 346 case DRM_FORMAT_R8: |
| 347 return gfx::BufferFormat::R_8; |
339 case DRM_FORMAT_ABGR8888: | 348 case DRM_FORMAT_ABGR8888: |
340 return gfx::BufferFormat::RGBA_8888; | 349 return gfx::BufferFormat::RGBA_8888; |
341 case DRM_FORMAT_XBGR8888: | 350 case DRM_FORMAT_XBGR8888: |
342 return gfx::BufferFormat::RGBX_8888; | 351 return gfx::BufferFormat::RGBX_8888; |
343 case DRM_FORMAT_ARGB8888: | 352 case DRM_FORMAT_ARGB8888: |
344 return gfx::BufferFormat::BGRA_8888; | 353 return gfx::BufferFormat::BGRA_8888; |
345 case DRM_FORMAT_XRGB8888: | 354 case DRM_FORMAT_XRGB8888: |
346 return gfx::BufferFormat::BGRX_8888; | 355 return gfx::BufferFormat::BGRX_8888; |
347 case DRM_FORMAT_UYVY: | 356 case DRM_FORMAT_UYVY: |
348 return gfx::BufferFormat::UYVY_422; | 357 return gfx::BufferFormat::UYVY_422; |
(...skipping 13 matching lines...) Expand all Loading... |
362 case gfx::BufferFormat::BGRX_8888: | 371 case gfx::BufferFormat::BGRX_8888: |
363 return DRM_FORMAT_XRGB8888; | 372 return DRM_FORMAT_XRGB8888; |
364 case gfx::BufferFormat::UYVY_422: | 373 case gfx::BufferFormat::UYVY_422: |
365 return DRM_FORMAT_UYVY; | 374 return DRM_FORMAT_UYVY; |
366 default: | 375 default: |
367 NOTREACHED(); | 376 NOTREACHED(); |
368 return 0; | 377 return 0; |
369 } | 378 } |
370 } | 379 } |
371 } // namespace ui | 380 } // namespace ui |
OLD | NEW |