OSDN Git Service

Import minigbm
[android-x86/external-minigbm.git] / rockchip.c
1 /*
2  * Copyright (c) 2014 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_ROCKCHIP
8
9 #include <string.h>
10 #include <xf86drm.h>
11 #include <rockchip_drm.h>
12
13 #include "gbm_priv.h"
14
15 int gbm_rockchip_bo_create(struct gbm_bo *bo, uint32_t width, uint32_t height, uint32_t format, uint32_t flags)
16 {
17         size_t size = width * height * ;
18         struct drm_rockchip_gem_create gem_create;
19         int ret;
20
21         memset(&gem_create, 0, sizeof(gem_create));
22         gem_create.size = size;
23
24         ret = drmIoctl(bo->gbm->fd, DRM_IOCTL_ROCKCHIP_GEM_CREATE, &gem_create);
25         if (ret)
26                 return ret;
27
28         bo->handle.u32 = gem_create.handle;
29         bo->size = size;
30
31         return 0;
32 }
33
34 struct gbm_driver gbm_driver_rockchip =
35 {
36         .name = "rockchip",
37         .bo_create = gbm_rockchip_bo_create,
38         .bo_destroy = gbm_gem_bo_destroy,
39         .format_list = {
40                 {GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING | GBM_BO_USE_WRITE},
41                 {GBM_FORMAT_ARGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING | GBM_BO_USE_WRITE},
42         }
43 };
44
45 #endif