summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJB Tsai <jb.tsai@mediatek.com>2015-03-19 14:30:31 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-25 12:49:25 +0000
commit0c16a0f731c1e901a364724beba2577b90e60da5 (patch)
treec0af6c1254f3384bac8cacffdfc2a7a1507f1829
parentde93efd0efdb76808a7a53f3cfb629e61de87149 (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>
-rw-r--r--gbm.c6
-rw-r--r--mediatek.c47
2 files changed, 53 insertions, 0 deletions
diff --git a/gbm.c b/gbm.c
index b9f08f2..b96faf0 100644
--- a/gbm.c
+++ b/gbm.c
@@ -41,6 +41,9 @@ extern struct gbm_driver gbm_driver_gma500;
#ifdef GBM_I915
extern struct gbm_driver gbm_driver_i915;
#endif
+#ifdef GBM_MEDIATEK
+extern struct gbm_driver gbm_driver_mediatek;
+#endif
#ifdef GBM_ROCKCHIP
extern struct gbm_driver gbm_driver_rockchip;
#endif
@@ -68,6 +71,9 @@ static struct gbm_driver *gbm_get_driver(int fd)
#ifdef GBM_I915
&gbm_driver_i915,
#endif
+#ifdef GBM_MEDIATEK
+ &gbm_driver_mediatek,
+#endif
#ifdef GBM_ROCKCHIP
&gbm_driver_rockchip,
#endif
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