Path: blob/next/external/packages/extras-buildpkgs/xf86-video-armsoc/debian/patches/0001-Add-sun4i-drmmode-driver.patch
8629 views
From 85545c7b30bfb53a6329d6e41447e52b6e5512c2 Mon Sep 17 00:00:00 20011From: Maxime Ripard <[email protected]>2Date: Tue, 8 Dec 2015 15:09:48 +01003Subject: [PATCH] Add sun4i drmmode driver45Originally-created-by: Maxime Ripard <[email protected]>6[Icenowy: changed commit message and change README]7Signed-off-by: Icenowy Zheng <[email protected]>8---9README | 1 +10src/Makefile.am | 3 +-11src/armsoc_driver.c | 1 +12src/drmmode_driver.h | 1 +13src/drmmode_sun4i/drmmode_sun4i.c | 88 +++++++++++++++++++++++++++++++++++++++145 files changed, 93 insertions(+), 1 deletion(-)15create mode 100644 src/drmmode_sun4i/drmmode_sun4i.c1617diff --git a/README b/README18index 707356a..d2ff0de 10064419--- a/README20+++ b/README21@@ -13,6 +13,7 @@ The currently supported DRM drivers are:22- exynos23- kirin24- sti25+- sun4i2627For other drivers, you will need to implement this support yourself. A template implementation is28provided in src/drmmode_template.29diff --git a/src/Makefile.am b/src/Makefile.am30index 3b26019..ae39d1e 10064431--- a/src/Makefile.am32+++ b/src/Makefile.am33@@ -43,7 +43,8 @@ armsoc_drv_ladir = @moduledir@/drivers34DRMMODE_SRCS = drmmode_exynos/drmmode_exynos.c \35drmmode_pl111/drmmode_pl111.c \36drmmode_kirin/drmmode_kirin.c \37- drmmode_sti/drmmode_sti.c38+ drmmode_sti/drmmode_sti.c \39+ drmmode_sun4i/drmmode_sun4i.c404142armsoc_drv_la_SOURCES = \43diff --git a/src/armsoc_driver.c b/src/armsoc_driver.c44index 83e74a7..abae36c 10064445--- a/src/armsoc_driver.c46+++ b/src/armsoc_driver.c47@@ -737,6 +737,7 @@ static struct drmmode_interface *get_drmmode_implementation(int drm_fd)48&pl111_interface,49&kirin_interface,50&sti_interface,51+ &sun4i_interface,52};53int i;5455diff --git a/src/drmmode_driver.h b/src/drmmode_driver.h56index 879fc60..1a75cde 10064457--- a/src/drmmode_driver.h58+++ b/src/drmmode_driver.h59@@ -106,6 +106,7 @@ extern struct drmmode_interface exynos_interface;60extern struct drmmode_interface pl111_interface;61extern struct drmmode_interface kirin_interface;62extern struct drmmode_interface sti_interface;63+extern struct drmmode_interface sun4i_interface;646566#endif67diff --git a/src/drmmode_sun4i/drmmode_sun4i.c b/src/drmmode_sun4i/drmmode_sun4i.c68new file mode 10064469index 0000000..5513d8070--- /dev/null71+++ b/src/drmmode_sun4i/drmmode_sun4i.c72@@ -0,0 +1,88 @@73+/*74+ * Copyright © 2013 ARM Limited.75+ *76+ * Permission is hereby granted, free of charge, to any person obtaining a77+ * copy of this software and associated documentation files (the "Software"),78+ * to deal in the Software without restriction, including without limitation79+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,80+ * and/or sell copies of the Software, and to permit persons to whom the81+ * Software is furnished to do so, subject to the following conditions:82+ *83+ * The above copyright notice and this permission notice (including the next84+ * paragraph) shall be included in all copies or substantial portions of the85+ * Software.86+ *87+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR88+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,89+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL90+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER91+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,92+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE93+ * SOFTWARE.94+ *95+ */96+97+#include <xf86drm.h>98+99+#include "../drmmode_driver.h"100+101+#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))102+103+#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))104+#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)105+#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))106+107+/* This should be included from uapi headers once the driver is108+ * mainlined109+ */110+struct drm_sun4i_gem_create {111+ uint64_t size;112+ uint32_t flags;113+ uint32_t handle;114+};115+116+#define DRM_SUN4I_GEM_CREATE 0x00117+118+#define DRM_IOCTL_SUN4I_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_SUN4I_GEM_CREATE, \119+ struct drm_sun4i_gem_create)120+121+static int create_custom_gem(int fd, struct armsoc_create_gem *create_gem)122+{123+ struct drm_sun4i_gem_create create_sun4i;124+ int ret;125+ unsigned int pitch;126+127+ assert((create_gem->buf_type == ARMSOC_BO_SCANOUT) ||128+ (create_gem->buf_type == ARMSOC_BO_NON_SCANOUT));129+130+ /* make pitch a multiple of 64 bytes for best performance */131+ pitch = DIV_ROUND_UP(create_gem->width * create_gem->bpp, 8);132+ pitch = ALIGN(pitch, 64);133+134+ memset(&create_sun4i, 0, sizeof(create_sun4i));135+ create_sun4i.size = create_gem->height * pitch;136+137+ ret = drmIoctl(fd, DRM_IOCTL_SUN4I_GEM_CREATE, &create_sun4i);138+ if (ret)139+ return ret;140+141+ /* Convert custom create_sun4i to generic create_gem */142+ create_gem->handle = create_sun4i.handle;143+ create_gem->pitch = pitch;144+ create_gem->size = create_sun4i.size;145+146+ return 0;147+}148+149+struct drmmode_interface sun4i_interface = {150+ "sun4i-drm" /* name of drm driver*/,151+ 1 /* use_page_flip_events */,152+ 1 /* use_early_display */,153+ 0 /* cursor width */,154+ 0 /* cursor_height */,155+ 0 /* cursor padding */,156+ HWCURSOR_API_NONE /* cursor_api */,157+ NULL /* init_plane_for_cursor */,158+ 0 /* vblank_query_supported */,159+ create_custom_gem /* create_custom_gem */,160+};161--1622.12.2163164165166