OSDN Git Service

Populate the stride field when creating gbm_bos
[android-x86/external-minigbm.git] / tegra.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_TEGRA
8
9 #include <string.h>
10 #include <xf86drm.h>
11 #include <tegra_drm.h>
12
13 #include "gbm_priv.h"
14 #include "helpers.h"
15
16 int gbm_tegra_bo_create(struct gbm_bo *bo, uint32_t width, uint32_t height, uint32_t format, uint32_t flags)
17 {
18         size_t size = width * height * gbm_bytes_from_format(format);
19         struct drm_tegra_gem_create gem_create;
20         int ret;
21
22         memset(&gem_create, 0, sizeof(gem_create));
23         gem_create.size = size;
24         gem_create.flags = 0;
25
26         ret = drmIoctl(bo->gbm->fd, DRM_IOCTL_TEGRA_GEM_CREATE, &gem_create);
27         if (ret)
28                 return ret;
29
30         bo->handle.u32 = gem_create.handle;
31         bo->size = size;
32         bo->stride = width * gbm_bytes_from_format(format);
33
34         return 0;
35 }
36
37 struct gbm_driver gbm_driver_tegra =
38 {
39         .name = "tegra",
40         .bo_create = gbm_tegra_bo_create,
41         .bo_destroy = gbm_gem_bo_destroy,
42         .format_list = {
43                 {GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING | GBM_BO_USE_WRITE},
44                 {GBM_FORMAT_ARGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING | GBM_BO_USE_WRITE},
45         }
46 };
47
48 #endif