OSDN Git Service

Populate the stride field when creating gbm_bos
[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 * gbm_bytes_from_format(format);
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         bo->stride = width * gbm_bytes_from_format(format);
31
32         return 0;
33 }
34
35 struct gbm_driver gbm_driver_rockchip =
36 {
37         .name = "rockchip",
38         .bo_create = gbm_rockchip_bo_create,
39         .bo_destroy = gbm_gem_bo_destroy,
40         .format_list = {
41                 {GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING | GBM_BO_USE_WRITE},
42                 {GBM_FORMAT_ARGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING | GBM_BO_USE_WRITE},
43         }
44 };
45
46 #endif