JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The Chromium OS Authors. All rights reserved. |
| 3 | * Use of this source code is governed by a BSD-style license that can be |
| 4 | * found in the LICENSE file. |
| 5 | */ |
| 6 | |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame^] | 7 | #ifdef DRV_MEDIATEK |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 8 | |
Ilja H. Friedel | f9d2ab7 | 2015-04-09 14:08:36 -0700 | [diff] [blame] | 9 | #include <stdio.h> |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 10 | #include <string.h> |
| 11 | #include <xf86drm.h> |
| 12 | #include <mediatek_drm.h> |
| 13 | #include <stdio.h> |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame^] | 14 | #include "drv_priv.h" |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 15 | #include "helpers.h" |
| 16 | |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame^] | 17 | static int drv_mediatek_bo_create(struct bo *bo, |
Stéphane Marchesin | ed475b4 | 2016-02-26 13:36:22 -0800 | [diff] [blame] | 18 | uint32_t width, uint32_t height, |
| 19 | uint32_t format, uint32_t flags) |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 20 | { |
Yuly Novikov | 96c7a3b | 2015-12-08 22:48:29 -0500 | [diff] [blame] | 21 | size_t size; |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 22 | struct drm_mtk_gem_create gem_create; |
| 23 | int ret; |
| 24 | |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame^] | 25 | bo->strides[0] = drv_stride_from_format(format, width); |
Yuly Novikov | 96c7a3b | 2015-12-08 22:48:29 -0500 | [diff] [blame] | 26 | size = height * bo->strides[0]; |
| 27 | |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 28 | memset(&gem_create, 0, sizeof(gem_create)); |
| 29 | gem_create.size = size; |
| 30 | |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame^] | 31 | ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MTK_GEM_CREATE, &gem_create); |
Ilja H. Friedel | f9d2ab7 | 2015-04-09 14:08:36 -0700 | [diff] [blame] | 32 | if (ret) { |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame^] | 33 | fprintf(stderr, "drv: DRM_IOCTL_MTK_GEM_CREATE failed " |
Ilja H. Friedel | f9d2ab7 | 2015-04-09 14:08:36 -0700 | [diff] [blame] | 34 | "(size=%zu)\n", size); |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 35 | return ret; |
Ilja H. Friedel | f9d2ab7 | 2015-04-09 14:08:36 -0700 | [diff] [blame] | 36 | } |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 37 | |
Yuly Novikov | 96c7a3b | 2015-12-08 22:48:29 -0500 | [diff] [blame] | 38 | bo->handles[0].u32 = gem_create.handle; |
| 39 | bo->sizes[0] = size; |
| 40 | bo->offsets[0] = 0; |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame^] | 45 | const struct backend backend_mediatek = |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 46 | { |
| 47 | .name = "mediatek", |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame^] | 48 | .bo_create = drv_mediatek_bo_create, |
| 49 | .bo_destroy = drv_gem_bo_destroy, |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 50 | .format_list = { |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame^] | 51 | {DRV_FORMAT_XRGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_CURSOR | DRV_BO_USE_RENDERING}, |
| 52 | {DRV_FORMAT_XRGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_CURSOR | DRV_BO_USE_LINEAR}, |
| 53 | {DRV_FORMAT_ARGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_CURSOR | DRV_BO_USE_RENDERING}, |
| 54 | {DRV_FORMAT_ARGB8888, DRV_BO_USE_SCANOUT | DRV_BO_USE_CURSOR | DRV_BO_USE_LINEAR}, |
JB Tsai | 0c16a0f | 2015-03-19 14:30:31 +0800 | [diff] [blame] | 55 | } |
| 56 | }; |
| 57 | |
| 58 | #endif |