OSDN Git Service

minigbm: remove GBM_BO_USE_WRITE from the drivers.
[android-x86/external-minigbm.git] / mediatek.c
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
7 #ifdef GBM_MEDIATEK
8
9 #include <stdio.h>
10 #include <string.h>
11 #include <xf86drm.h>
12 #include <mediatek_drm.h>
13 #include <stdio.h>
14 #include "gbm_priv.h"
15 #include "helpers.h"
16
17 static int gbm_mediatek_bo_create(struct gbm_bo *bo,
18                                   uint32_t width, uint32_t height,
19                                   uint32_t format, uint32_t flags)
20 {
21         size_t size;
22         struct drm_mtk_gem_create gem_create;
23         int ret;
24
25         bo->strides[0] = gbm_stride_from_format(format, width);
26         size = height * bo->strides[0];
27
28         memset(&gem_create, 0, sizeof(gem_create));
29         gem_create.size = size;
30
31         ret = drmIoctl(bo->gbm->fd, DRM_IOCTL_MTK_GEM_CREATE, &gem_create);
32         if (ret) {
33                 fprintf(stderr, "minigbm: DRM_IOCTL_MTK_GEM_CREATE failed "
34                                 "(size=%zu)\n", size);
35                 return ret;
36         }
37
38         bo->handles[0].u32 = gem_create.handle;
39         bo->sizes[0] = size;
40         bo->offsets[0] = 0;
41
42         return 0;
43 }
44
45 const struct gbm_driver gbm_driver_mediatek =
46 {
47         .name = "mediatek",
48         .bo_create = gbm_mediatek_bo_create,
49         .bo_destroy = gbm_gem_bo_destroy,
50         .format_list = {
51                 {GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING},
52                 {GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_LINEAR},
53                 {GBM_FORMAT_ARGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING},
54                 {GBM_FORMAT_ARGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_LINEAR},
55         }
56 };
57
58 #endif