Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong
GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/packages/extras-buildpkgs/xf86-video-armsoc/debian/patches/0001-Add-sun4i-drmmode-driver.patch
8629 views
1
From 85545c7b30bfb53a6329d6e41447e52b6e5512c2 Mon Sep 17 00:00:00 2001
2
From: Maxime Ripard <[email protected]>
3
Date: Tue, 8 Dec 2015 15:09:48 +0100
4
Subject: [PATCH] Add sun4i drmmode driver
5
6
Originally-created-by: Maxime Ripard <[email protected]>
7
[Icenowy: changed commit message and change README]
8
Signed-off-by: Icenowy Zheng <[email protected]>
9
---
10
README | 1 +
11
src/Makefile.am | 3 +-
12
src/armsoc_driver.c | 1 +
13
src/drmmode_driver.h | 1 +
14
src/drmmode_sun4i/drmmode_sun4i.c | 88 +++++++++++++++++++++++++++++++++++++++
15
5 files changed, 93 insertions(+), 1 deletion(-)
16
create mode 100644 src/drmmode_sun4i/drmmode_sun4i.c
17
18
diff --git a/README b/README
19
index 707356a..d2ff0de 100644
20
--- a/README
21
+++ b/README
22
@@ -13,6 +13,7 @@ The currently supported DRM drivers are:
23
- exynos
24
- kirin
25
- sti
26
+- sun4i
27
28
For other drivers, you will need to implement this support yourself. A template implementation is
29
provided in src/drmmode_template.
30
diff --git a/src/Makefile.am b/src/Makefile.am
31
index 3b26019..ae39d1e 100644
32
--- a/src/Makefile.am
33
+++ b/src/Makefile.am
34
@@ -43,7 +43,8 @@ armsoc_drv_ladir = @moduledir@/drivers
35
DRMMODE_SRCS = drmmode_exynos/drmmode_exynos.c \
36
drmmode_pl111/drmmode_pl111.c \
37
drmmode_kirin/drmmode_kirin.c \
38
- drmmode_sti/drmmode_sti.c
39
+ drmmode_sti/drmmode_sti.c \
40
+ drmmode_sun4i/drmmode_sun4i.c
41
42
43
armsoc_drv_la_SOURCES = \
44
diff --git a/src/armsoc_driver.c b/src/armsoc_driver.c
45
index 83e74a7..abae36c 100644
46
--- a/src/armsoc_driver.c
47
+++ b/src/armsoc_driver.c
48
@@ -737,6 +737,7 @@ static struct drmmode_interface *get_drmmode_implementation(int drm_fd)
49
&pl111_interface,
50
&kirin_interface,
51
&sti_interface,
52
+ &sun4i_interface,
53
};
54
int i;
55
56
diff --git a/src/drmmode_driver.h b/src/drmmode_driver.h
57
index 879fc60..1a75cde 100644
58
--- a/src/drmmode_driver.h
59
+++ b/src/drmmode_driver.h
60
@@ -106,6 +106,7 @@ extern struct drmmode_interface exynos_interface;
61
extern struct drmmode_interface pl111_interface;
62
extern struct drmmode_interface kirin_interface;
63
extern struct drmmode_interface sti_interface;
64
+extern struct drmmode_interface sun4i_interface;
65
66
67
#endif
68
diff --git a/src/drmmode_sun4i/drmmode_sun4i.c b/src/drmmode_sun4i/drmmode_sun4i.c
69
new file mode 100644
70
index 0000000..5513d80
71
--- /dev/null
72
+++ b/src/drmmode_sun4i/drmmode_sun4i.c
73
@@ -0,0 +1,88 @@
74
+/*
75
+ * Copyright © 2013 ARM Limited.
76
+ *
77
+ * Permission is hereby granted, free of charge, to any person obtaining a
78
+ * copy of this software and associated documentation files (the "Software"),
79
+ * to deal in the Software without restriction, including without limitation
80
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
81
+ * and/or sell copies of the Software, and to permit persons to whom the
82
+ * Software is furnished to do so, subject to the following conditions:
83
+ *
84
+ * The above copyright notice and this permission notice (including the next
85
+ * paragraph) shall be included in all copies or substantial portions of the
86
+ * Software.
87
+ *
88
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
89
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
90
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
91
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
92
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
93
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
94
+ * SOFTWARE.
95
+ *
96
+ */
97
+
98
+#include <xf86drm.h>
99
+
100
+#include "../drmmode_driver.h"
101
+
102
+#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
103
+
104
+#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
105
+#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
106
+#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
107
+
108
+/* This should be included from uapi headers once the driver is
109
+ * mainlined
110
+ */
111
+struct drm_sun4i_gem_create {
112
+ uint64_t size;
113
+ uint32_t flags;
114
+ uint32_t handle;
115
+};
116
+
117
+#define DRM_SUN4I_GEM_CREATE 0x00
118
+
119
+#define DRM_IOCTL_SUN4I_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_SUN4I_GEM_CREATE, \
120
+ struct drm_sun4i_gem_create)
121
+
122
+static int create_custom_gem(int fd, struct armsoc_create_gem *create_gem)
123
+{
124
+ struct drm_sun4i_gem_create create_sun4i;
125
+ int ret;
126
+ unsigned int pitch;
127
+
128
+ assert((create_gem->buf_type == ARMSOC_BO_SCANOUT) ||
129
+ (create_gem->buf_type == ARMSOC_BO_NON_SCANOUT));
130
+
131
+ /* make pitch a multiple of 64 bytes for best performance */
132
+ pitch = DIV_ROUND_UP(create_gem->width * create_gem->bpp, 8);
133
+ pitch = ALIGN(pitch, 64);
134
+
135
+ memset(&create_sun4i, 0, sizeof(create_sun4i));
136
+ create_sun4i.size = create_gem->height * pitch;
137
+
138
+ ret = drmIoctl(fd, DRM_IOCTL_SUN4I_GEM_CREATE, &create_sun4i);
139
+ if (ret)
140
+ return ret;
141
+
142
+ /* Convert custom create_sun4i to generic create_gem */
143
+ create_gem->handle = create_sun4i.handle;
144
+ create_gem->pitch = pitch;
145
+ create_gem->size = create_sun4i.size;
146
+
147
+ return 0;
148
+}
149
+
150
+struct drmmode_interface sun4i_interface = {
151
+ "sun4i-drm" /* name of drm driver*/,
152
+ 1 /* use_page_flip_events */,
153
+ 1 /* use_early_display */,
154
+ 0 /* cursor width */,
155
+ 0 /* cursor_height */,
156
+ 0 /* cursor padding */,
157
+ HWCURSOR_API_NONE /* cursor_api */,
158
+ NULL /* init_plane_for_cursor */,
159
+ 0 /* vblank_query_supported */,
160
+ create_custom_gem /* create_custom_gem */,
161
+};
162
--
163
2.12.2
164
165
166