Created
April 22, 2016 16:47
-
-
Save carlocaione/1cdaf1c2259ff166563789865021abb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/configure.ac b/configure.ac | |
index b5f70d5..e33b209 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -80,7 +80,7 @@ AM_CONDITIONAL(HAVE_XEXTPROTO_71, [ test "$HAVE_XEXTPROTO_71" = "yes"]) | |
# Checks for header files. | |
AC_HEADER_STDC | |
- | |
+AC_SYS_LARGEFILE | |
DRIVER_NAME=armsoc | |
AC_SUBST([DRIVER_NAME]) | |
diff --git a/src/Makefile.am b/src/Makefile.am | |
index 07cd626..ef67512 100644 | |
--- a/src/Makefile.am | |
+++ b/src/Makefile.am | |
@@ -42,7 +42,8 @@ armsoc_drv_la_LIBADD = @XORG_LIBS@ | |
armsoc_drv_ladir = @moduledir@/drivers | |
DRMMODE_SRCS = drmmode_exynos/drmmode_exynos.c \ | |
drmmode_pl111/drmmode_pl111.c \ | |
- drmmode_kirin/drmmode_kirin.c | |
+ drmmode_kirin/drmmode_kirin.c \ | |
+ drmmode_meson/drmmode_meson.c | |
armsoc_drv_la_SOURCES = \ | |
diff --git a/src/armsoc_driver.c b/src/armsoc_driver.c | |
index 0bf2b21..0c74573 100644 | |
--- a/src/armsoc_driver.c | |
+++ b/src/armsoc_driver.c | |
@@ -736,6 +736,7 @@ static struct drmmode_interface *get_drmmode_implementation(int drm_fd) | |
&exynos_interface, | |
&pl111_interface, | |
&kirin_interface, | |
+ &meson_interface, | |
}; | |
int i; | |
diff --git a/src/drmmode_driver.h b/src/drmmode_driver.h | |
index edc87c7..98b398d 100644 | |
--- a/src/drmmode_driver.h | |
+++ b/src/drmmode_driver.h | |
@@ -104,6 +104,7 @@ struct drmmode_interface { | |
extern struct drmmode_interface exynos_interface; | |
extern struct drmmode_interface pl111_interface; | |
+extern struct drmmode_interface meson_interface; | |
extern struct drmmode_interface kirin_interface; | |
diff --git a/src/drmmode_meson/drmmode_meson.c b/src/drmmode_meson/drmmode_meson.c | |
new file mode 100644 | |
index 0000000..727ffe4 | |
--- /dev/null | |
+++ b/src/drmmode_meson/drmmode_meson.c | |
@@ -0,0 +1,85 @@ | |
+/* | |
+ * Copyright (C) 2014 Endless Mobile | |
+ * | |
+ * This program is free software; you can redistribute it and/or | |
+ * modify it under the terms of the GNU General Public License as | |
+ * published by the Free Software Foundation; either version 2 of the | |
+ * License, or (at your option) any later version. | |
+ * | |
+ * This program is distributed in the hope that it will be useful, but | |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of | |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
+ * General Public License for more details. | |
+ * | |
+ * You should have received a copy of the GNU General Public License | |
+ * along with this program; if not, write to the Free Software | |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
+ * 02111-1307, USA. | |
+ * | |
+ * Written by: | |
+ * Jasper St. Pierre <[email protected]> | |
+ */ | |
+ | |
+#include "../drmmode_driver.h" | |
+ | |
+#include "meson_drm.h" | |
+#include <errno.h> | |
+#include <xf86drm.h> | |
+#include <xf86drmMode.h> | |
+ | |
+/* Cursor dimensions | |
+ * Technically we probably don't have any size limit.. since we | |
+ * are just using an overlay... but xserver will always create | |
+ * cursor images in the max size, so don't use width/height values | |
+ * that are too big | |
+ */ | |
+#define CURSORW (64) | |
+#define CURSORH (64) | |
+ | |
+#define CURSORPAD (0) | |
+ | |
+#define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1)) | |
+ | |
+static int create_custom_gem(int fd, struct armsoc_create_gem *create_gem) | |
+{ | |
+ struct drm_meson_gem_create_with_ump create_meson; | |
+ size_t pitch; | |
+ int ret; | |
+ | |
+ assert((create_gem->buf_type == ARMSOC_BO_SCANOUT) || | |
+ (create_gem->buf_type == ARMSOC_BO_NON_SCANOUT)); | |
+ | |
+ /* make pitch a multiple of 64 bytes for best performance */ | |
+ pitch = ALIGN(create_gem->width * ((create_gem->bpp + 7) / 8), 64); | |
+ create_meson.size = create_gem->height * pitch; | |
+ create_meson.flags = 0; | |
+ | |
+ if (create_gem->buf_type == ARMSOC_BO_SCANOUT) | |
+ create_meson.flags |= DRM_MESON_GEM_CREATE_WITH_UMP_FLAG_SCANOUT; | |
+ else | |
+ create_meson.flags |= DRM_MESON_GEM_CREATE_WITH_UMP_FLAG_TEXTURE; | |
+ | |
+ ret = drmIoctl(fd, DRM_IOCTL_MESON_GEM_CREATE_WITH_UMP, &create_meson); | |
+ if (ret) | |
+ return ret; | |
+ | |
+ /* Convert custom meson ioctl to generic create_gem */ | |
+ create_gem->handle = create_meson.handle; | |
+ create_gem->pitch = pitch; | |
+ create_gem->size = create_meson.size; | |
+ | |
+ return 0; | |
+} | |
+ | |
+struct drmmode_interface meson_interface = { | |
+ "meson", | |
+ 1 /* use_page_flip_events */, | |
+ 1, | |
+ CURSORW /* cursor width */, | |
+ CURSORH /* cursor_height */, | |
+ CURSORPAD /* cursor padding */, | |
+ HWCURSOR_API_STANDARD /* cursor_api */, | |
+ NULL /* init_plane_for_cursor */, | |
+ 0 /* vblank_query_supported */, | |
+ create_custom_gem /* create_custom_gem */, | |
+}; | |
diff --git a/src/drmmode_meson/meson_drm.h b/src/drmmode_meson/meson_drm.h | |
new file mode 100644 | |
index 0000000..297015d | |
--- /dev/null | |
+++ b/src/drmmode_meson/meson_drm.h | |
@@ -0,0 +1,86 @@ | |
+/* | |
+ * Copyright (C) 2014 Endless Mobile | |
+ * | |
+ * This program is free software; you can redistribute it and/or | |
+ * modify it under the terms of the GNU General Public License as | |
+ * published by the Free Software Foundation; either version 2 of the | |
+ * License, or (at your option) any later version. | |
+ * | |
+ * This program is distributed in the hope that it will be useful, but | |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of | |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
+ * General Public License for more details. | |
+ * | |
+ * You should have received a copy of the GNU General Public License | |
+ * along with this program; if not, write to the Free Software | |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
+ * 02111-1307, USA. | |
+ * | |
+ * Written by: | |
+ * Jasper St. Pierre <[email protected]> | |
+ */ | |
+ | |
+#ifndef __MESON_DRM_H__ | |
+#define __MESON_DRM_H__ | |
+ | |
+#include <stddef.h> | |
+#include <drm.h> | |
+ | |
+struct drm_meson_gem_create_with_ump { | |
+ uint64_t size; | |
+ unsigned int flags; | |
+ unsigned int handle; | |
+ uint32_t ump_secure_id; | |
+}; | |
+ | |
+enum drm_meson_msync_op { | |
+ DRM_MESON_MSYNC_CLEAN = 0, | |
+ DRM_MESON_MSYNC_CLEAN_AND_INVALIDATE = 1, | |
+ DRM_MESON_MSYNC_INVALIDATE = 2, | |
+ DRM_MESON_MSYNC_FLUSH_L1 = 3, | |
+ DRM_MESON_MSYNC_READOUT_CACHE_ENABLED = 128, | |
+}; | |
+ | |
+struct drm_meson_msync { | |
+ uint32_t handle; | |
+ enum drm_meson_msync_op op; | |
+ void *mapping; | |
+ void *address; | |
+ uint32_t size; | |
+ uint32_t is_cached; | |
+}; | |
+ | |
+#define DRM_MESON_GEM_DOMAIN_CPU 0x01 | |
+#define DRM_MESON_GEM_DOMAIN_MALI 0x02 | |
+ | |
+struct drm_meson_gem_set_domain { | |
+ uint32_t handle; | |
+ uint32_t write_domain; | |
+}; | |
+ | |
+enum drm_meson_cache_op_control { | |
+ DRM_MESON_CACHE_OP_START, | |
+ DRM_MESON_CACHE_OP_FINISH, | |
+ DRM_MESON_CACHE_OP_COUNT, | |
+}; | |
+ | |
+struct drm_meson_cache_operations_control { | |
+ enum drm_meson_cache_op_control op; | |
+}; | |
+ | |
+#define DRM_MESON_GEM_CREATE_WITH_UMP 0x00 | |
+#define DRM_MESON_MSYNC 0x01 | |
+#define DRM_MESON_GEM_SET_DOMAIN 0x02 | |
+#define DRM_MESON_CACHE_OPERATIONS_CONTROL 0x03 | |
+#define DRM_MESON_NUM_IOCTLS 0x04 | |
+ | |
+/* Use flags */ | |
+#define DRM_MESON_GEM_CREATE_WITH_UMP_FLAG_SCANOUT 0x01 | |
+#define DRM_MESON_GEM_CREATE_WITH_UMP_FLAG_TEXTURE 0x02 | |
+ | |
+#define DRM_IOCTL_MESON_GEM_CREATE_WITH_UMP DRM_IOWR(DRM_COMMAND_BASE + DRM_MESON_GEM_CREATE_WITH_UMP, struct drm_meson_gem_create_with_ump) | |
+#define DRM_IOCTL_MESON_MSYNC DRM_IOWR(DRM_COMMAND_BASE + DRM_MESON_MSYNC, struct drm_meson_msync) | |
+#define DRM_IOCTL_MESON_GEM_SET_DOMAIN DRM_IOWR(DRM_COMMAND_BASE + DRM_MESON_GEM_SET_DOMAIN, struct drm_meson_gem_set_domain) | |
+#define DRM_IOCTL_MESON_CACHE_OPERATIONS_CONTROL DRM_IOWR(DRM_COMMAND_BASE + DRM_MESON_CACHE_OPERATIONS_CONTROL, struct drm_meson_cache_operations_control) | |
+ | |
+#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment