diff options
author | JB Tsai <jb.tsai@mediatek.com> | 2015-03-19 14:30:31 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-03-25 12:49:25 +0000 |
commit | 0c16a0f731c1e901a364724beba2577b90e60da5 (patch) | |
tree | c0af6c1254f3384bac8cacffdfc2a7a1507f1829 /mediatek.c | |
parent | de93efd0efdb76808a7a53f3cfb629e61de87149 (diff) |
minigbm: Add mediatek drm to minigbm
Add gbm_driver_mediatek function in gbm_get_driver to support
mediatek drm
BUG=None
TEST=Use gbmtest with minigbm to verify
Change-Id: Ieaccdbf5a2bde94f70addb8ac5192fbbcecf321e
Signed-off-by: JB Tsai <jb.tsai@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/261503
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Diffstat (limited to 'mediatek.c')
-rw-r--r-- | mediatek.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/mediatek.c b/mediatek.c new file mode 100644 index 0000000..01eec63 --- /dev/null +++ b/mediatek.c @@ -0,0 +1,47 @@ +/* + * Copyright 2015 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifdef GBM_MEDIATEK + +#include <string.h> +#include <xf86drm.h> +#include <mediatek_drm.h> +#include <stdio.h> +#include "gbm_priv.h" +#include "helpers.h" + +int gbm_mediatek_bo_create(struct gbm_bo *bo, uint32_t width, uint32_t height, uint32_t format, uint32_t flags) +{ + size_t size = width * height * gbm_bytes_from_format(format); + struct drm_mtk_gem_create gem_create; + int ret; + + memset(&gem_create, 0, sizeof(gem_create)); + gem_create.size = size; + + ret = drmIoctl(bo->gbm->fd, DRM_IOCTL_MTK_GEM_CREATE, &gem_create); + if (ret) + return ret; + + bo->handle.u32 = gem_create.handle; + bo->size = size; + bo->stride = width * gbm_bytes_from_format(format); + + return 0; +} + +struct gbm_driver gbm_driver_mediatek = +{ + .name = "mediatek", + .bo_create = gbm_mediatek_bo_create, + .bo_destroy = gbm_gem_bo_destroy, + .format_list = { + {GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING | GBM_BO_USE_WRITE}, + {GBM_FORMAT_ARGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_CURSOR | GBM_BO_USE_RENDERING | GBM_BO_USE_WRITE}, + } +}; + +#endif |