aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-graphics/drm/libdrm-2.4.24/glamo.patch
blob: b397ded5809c7984b8444a3d9fd33d366901f9b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
diff --git a/Makefile.am b/Makefile.am
index 25d1747..f384228 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,7 +41,11 @@ if HAVE_RADEON
 RADEON_SUBDIR = radeon
 endif
 
-SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) $(RADEON_SUBDIR) tests include
+if HAVE_GLAMO
+GLAMO_SUBDIR = glamo
+endif
+
+SUBDIRS = . $(LIBKMS_SUBDIR) $(INTEL_SUBDIR) $(NOUVEAU_SUBDIR) $(RADEON_SUBDIR) $(GLAMO_SUBDIR) tests include
 
 libdrm_la_LTLIBRARIES = libdrm.la
 libdrm_ladir = $(libdir)
diff --git a/configure.ac b/configure.ac
index 62db817..0b2a33e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,11 @@ AC_ARG_ENABLE(nouveau-experimental-api,
 	      [NOUVEAU=$enableval], [NOUVEAU=no])
 
 
+AC_ARG_ENABLE(glamo-experimental-api,
+	      AS_HELP_STRING([--enable-glamo-experimental-api],
+	      [Enable support for Glamo's KMS API (default: disabled)]),
+	      [GLAMO=$enableval], [GLAMO=no])
+
 dnl ===========================================================================
 dnl check compiler flags
 AC_DEFUN([LIBDRM_CC_TRY_FLAG], [
@@ -169,6 +174,11 @@ if test "x$NOUVEAU" = xyes; then
 	AC_DEFINE(HAVE_NOUVEAU, 1, [Have nouveau (nvidia) support])
 fi
 
+AM_CONDITIONAL(HAVE_GLAMO, [test "x$GLAMO" = xyes])
+if test "x$GLAMO" = xyes; then
+	AC_DEFINE(HAVE_GLAMO, 1, [Have glamo support])
+fi
+
 PKG_CHECK_MODULES(CAIRO, cairo, [HAVE_CAIRO=yes], [HAVE_CAIRO=no])
 if test "x$HAVE_CAIRO" = xyes; then
 	AC_DEFINE(HAVE_CAIRO, 1, [Have cairo support])
@@ -262,6 +272,8 @@ AC_OUTPUT([
 	radeon/libdrm_radeon.pc
 	nouveau/Makefile
 	nouveau/libdrm_nouveau.pc
+	glamo/Makefile
+	glamo/libdrm_glamo.pc
 	tests/Makefile
 	tests/modeprint/Makefile
 	tests/modetest/Makefile
diff --git a/glamo/Makefile.am b/glamo/Makefile.am
new file mode 100644
index 0000000..1f17aa3
--- /dev/null
+++ b/glamo/Makefile.am
@@ -0,0 +1,52 @@
+# Copyright (c) 2009 Thomas Whtie <taw@bitwiz.org.uk>
+# Based on libdrm-glamo Copyright © 2008 Jérôme Glisse
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+#
+# Authors:
+#    Jérôme Glisse <glisse@freedesktop.org>
+#    Thomas White <taw@bitwiz.org.uk>
+
+AM_CFLAGS = \
+	$(WARN_CFLAGS) \
+	-I$(top_srcdir) \
+	-I$(top_srcdir)/glamo \
+	$(PTHREADSTUBS_CFLAGS) \
+	-I$(top_srcdir)/include/drm
+
+libdrm_glamo_la_LTLIBRARIES = libdrm_glamo.la
+libdrm_glamo_ladir = $(libdir)
+libdrm_glamo_la_LDFLAGS = -version-number 1:0:0 -no-undefined
+libdrm_glamo_la_LIBADD = ../libdrm.la @PTHREADSTUBS_LIBS@
+
+libdrm_glamo_la_SOURCES = \
+	glamo_bo_gem.c \
+	glamo_track.c
+
+libdrm_glamoincludedir = ${includedir}/libdrm
+libdrm_glamoinclude_HEADERS = \
+	glamo_bo.h \
+	glamo_bo_gem.h \
+	glamo_track.h
+
+pkgconfigdir = @pkgconfigdir@
+pkgconfig_DATA = libdrm_glamo.pc
+
+EXTRA_DIST = libdrm_glamo.pc.in
diff --git a/glamo/glamo_bo.h b/glamo/glamo_bo.h
new file mode 100644
index 0000000..8ef2a18
--- /dev/null
+++ b/glamo/glamo_bo.h
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2009 Thomas White
+ *
+ * Heavily based on radeon_bo.h
+ * Copyright © 2008 Jérôme Glisse
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ *	Thomas White <taw@bitwiz.org.uk>
+ */
+#ifndef GLAMO_BO_H
+#define GLAMO_BO_H
+
+#include <stdio.h>
+#include <stdint.h>
+#include "glamo_track.h"
+
+/* bo object */
+#define GLAMO_BO_FLAGS_MACRO_TILE  1
+#define GLAMO_BO_FLAGS_MICRO_TILE  2
+
+struct glamo_bo_manager;
+
+struct glamo_bo {
+    uint32_t                    alignment;
+    uint32_t                    handle;
+    uint32_t                    size;
+    uint32_t                    domains;
+    uint32_t                    flags;
+    unsigned                    cref;
+#ifdef GLAMO_BO_TRACK
+    struct glamo_track		*track;
+#endif
+    struct glamo_bo_manager	*bom;
+    void			*virtual;
+    uint32_t			space_accounted;
+};
+
+/* bo functions */
+struct glamo_bo_funcs {
+    struct glamo_bo *(*bo_open)(struct glamo_bo_manager *bom,
+                                 uint32_t handle,
+                                 uint32_t size,
+                                 uint32_t alignment,
+                                 uint32_t domains,
+                                 uint32_t flags);
+    void (*bo_ref)(struct glamo_bo *bo);
+    struct glamo_bo *(*bo_unref)(struct glamo_bo *bo);
+    int (*bo_map)(struct glamo_bo *bo, int write);
+    int (*bo_unmap)(struct glamo_bo *bo);
+    int (*bo_wait)(struct glamo_bo *bo);
+};
+
+struct glamo_bo_manager {
+    struct glamo_bo_funcs  *funcs;
+    int                     fd;
+    struct glamo_tracker   tracker;
+};
+
+static inline void _glamo_bo_debug(struct glamo_bo *bo,
+                                    const char *op,
+                                    const char *file,
+                                    const char *func,
+                                    int line)
+{
+    fprintf(stderr, "%s %p 0x%08X 0x%08X 0x%08X [%s %s %d]\n",
+            op, (void *)bo, bo->handle, bo->size, bo->cref, file, func, line);
+}
+
+static inline struct glamo_bo *_glamo_bo_open(struct glamo_bo_manager *bom,
+                                                uint32_t handle,
+                                                uint32_t size,
+                                                uint32_t alignment,
+                                                uint32_t domains,
+                                                uint32_t flags,
+                                                const char *file,
+                                                const char *func,
+                                                int line)
+{
+    struct glamo_bo *bo;
+
+    bo = bom->funcs->bo_open(bom, handle, size, alignment, domains, flags);
+#ifdef GLAMO_BO_TRACK
+    if (bo) {
+        bo->track = glamo_tracker_add_track(&bom->tracker, bo->handle);
+        glamo_track_add_event(bo->track, file, func, "open", line);
+    }
+#endif
+    return bo;
+}
+
+static inline void _glamo_bo_ref(struct glamo_bo *bo,
+                                  const char *file,
+                                  const char *func,
+                                  int line)
+{
+    bo->cref++;
+#ifdef GLAMO_BO_TRACK
+    glamo_track_add_event(bo->track, file, func, "ref", line);
+#endif
+    bo->bom->funcs->bo_ref(bo);
+}
+
+static inline struct glamo_bo *_glamo_bo_unref(struct glamo_bo *bo,
+                                                 const char *file,
+                                                 const char *func,
+                                                 int line)
+{
+    bo->cref--;
+#ifdef GLAMO_BO_TRACK
+    glamo_track_add_event(bo->track, file, func, "unref", line);
+    if (bo->cref <= 0) {
+        glamo_tracker_remove_track(&bo->bom->tracker, bo->track);
+        bo->track = NULL;
+    }
+#endif
+    return bo->bom->funcs->bo_unref(bo);
+}
+
+static inline int _glamo_bo_map(struct glamo_bo *bo,
+                                 int write,
+                                 const char *file,
+                                 const char *func,
+                                 int line)
+{
+    return bo->bom->funcs->bo_map(bo, write);
+}
+
+static inline int _glamo_bo_unmap(struct glamo_bo *bo,
+                                   const char *file,
+                                   const char *func,
+                                   int line)
+{
+    return bo->bom->funcs->bo_unmap(bo);
+}
+
+static inline int _glamo_bo_wait(struct glamo_bo *bo,
+                                  const char *file,
+                                  const char *func,
+                                  int line)
+{
+    return bo->bom->funcs->bo_wait(bo);
+}
+
+#define glamo_bo_open(bom, h, s, a, d, f)\
+    _glamo_bo_open(bom, h, s, a, d, f, __FILE__, __FUNCTION__, __LINE__)
+#define glamo_bo_ref(bo)\
+    _glamo_bo_ref(bo, __FILE__, __FUNCTION__, __LINE__)
+#define glamo_bo_unref(bo)\
+    _glamo_bo_unref(bo, __FILE__, __FUNCTION__, __LINE__)
+#define glamo_bo_map(bo, w)\
+    _glamo_bo_map(bo, w, __FILE__, __FUNCTION__, __LINE__)
+#define glamo_bo_unmap(bo)\
+    _glamo_bo_unmap(bo, __FILE__, __FUNCTION__, __LINE__)
+#define glamo_bo_debug(bo, opcode)\
+    _glamo_bo_debug(bo, opcode, __FILE__, __FUNCTION__, __LINE__)
+#define glamo_bo_wait(bo) \
+    _glamo_bo_wait(bo, __FILE__, __func__, __LINE__)
+
+#endif
diff --git a/glamo/glamo_bo_gem.c b/glamo/glamo_bo_gem.c
new file mode 100644
index 0000000..38a4436
--- /dev/null
+++ b/glamo/glamo_bo_gem.c
@@ -0,0 +1,336 @@
+/*
+ * Copyright © 2009 Thomas White
+ *
+ * Based on radeon_bo_gem.c, to which the following notice applies:
+ *
+ * Copyright © 2008 Dave Airlie
+ * Copyright © 2008 Jérôme Glisse
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ *      Dave Airlie
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ *
+ *
+ * Memory mapping functions are based on intel_bufmgr_gem.c, to which the
+ * following notice applies:
+ *
+ * Copyright © 2007 Red Hat Inc.
+ * Copyright © 2007 Intel Corporation
+ * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ *
+ **************************************************************************/
+/*
+ * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
+ *          Keith Whitwell <keithw-at-tungstengraphics-dot-com>
+ *	    Eric Anholt <eric@anholt.net>
+ *	    Dave Airlie <airlied@linux.ie>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "glamo_drm.h"
+#include "glamo_bo.h"
+#include "glamo_bo_gem.h"
+
+struct glamo_bo_gem {
+	struct glamo_bo   base;
+	uint32_t          name;
+	int               map_count;
+};
+
+struct bo_manager_gem {
+	struct glamo_bo_manager    base;
+};
+
+static struct glamo_bo *bo_open(struct glamo_bo_manager *bom,
+                                 uint32_t handle,
+                                 uint32_t size,
+                                 uint32_t alignment,
+                                 uint32_t domains,
+                                 uint32_t flags)
+{
+	struct glamo_bo_gem *bo;
+	int r;
+
+	bo = (struct glamo_bo_gem*)calloc(1, sizeof(struct glamo_bo_gem));
+	if (bo == NULL) {
+		return NULL;
+	}
+
+	bo->base.bom = bom;
+	bo->base.handle = 0;
+	bo->base.size = size;
+	bo->base.alignment = alignment;
+	bo->base.domains = domains;
+	bo->base.flags = flags;
+	bo->base.cref = 0;
+	bo->map_count = 0;
+	bo->base.virtual = NULL;
+	if (handle) {
+		struct drm_gem_open open_arg;
+
+		memset(&open_arg, 0, sizeof(open_arg));
+		open_arg.name = handle;
+		r = ioctl(bom->fd, DRM_IOCTL_GEM_OPEN, &open_arg);
+		if (r != 0) {
+			free(bo);
+			return NULL;
+		}
+		bo->base.handle = open_arg.handle;
+		bo->base.size = open_arg.size;
+		bo->name = handle;
+	} else {
+		struct drm_glamo_gem_create args;
+
+		args.size = size;
+		args.alignment = alignment;
+		args.initial_domain = bo->base.domains;
+		args.no_backing_store = 0;
+		args.handle = 0;
+		r = drmCommandWriteRead(bom->fd, DRM_GLAMO_GEM_CREATE,
+		                        &args, sizeof(args));
+		bo->base.handle = args.handle;
+		if (r) {
+			fprintf(stderr, "Failed to allocate :\n");
+			fprintf(stderr, "   size      : %d bytes\n", size);
+			fprintf(stderr, "   alignment : %d bytes\n", alignment);
+			free(bo);
+			return NULL;
+		}
+	}
+	glamo_bo_ref((struct glamo_bo*)bo);
+	return (struct glamo_bo*)bo;
+}
+
+static void bo_ref(struct glamo_bo *bo)
+{
+}
+
+static struct glamo_bo *bo_unref(struct glamo_bo *bo)
+{
+	struct glamo_bo_gem *bo_gem = (struct glamo_bo_gem*)bo;
+	struct drm_gem_close args;
+
+	if (bo == NULL) {
+		return NULL;
+	}
+	if (bo->cref) {
+		return bo;
+	}
+	if (bo_gem->map_count) {
+		munmap(bo->virtual, bo->size);
+	}
+
+	/* close object */
+	args.handle = bo->handle;
+	ioctl(bo->bom->fd, DRM_IOCTL_GEM_CLOSE, &args);
+	memset(bo_gem, 0, sizeof(struct glamo_bo_gem));
+	free(bo_gem);
+	return NULL;
+}
+
+static int bo_map(struct glamo_bo *bo, int write)
+{
+	struct glamo_bo_gem *bo_gem;
+	struct glamo_bo_manager *bufmgr;
+	int ret;
+
+	bo_gem = (struct glamo_bo_gem *)bo;
+	bufmgr = (struct glamo_bo_manager*)bo->bom;
+
+	/* Get a mapping of the buffer if we haven't before. */
+	if (bo->virtual == NULL) {
+
+		struct drm_glamo_gem_mmap mmap_arg;
+
+		memset(&mmap_arg, 0, sizeof(mmap_arg));
+		mmap_arg.handle = bo->handle;
+
+		/* Get the fake offset back... */
+		ret = ioctl(bufmgr->fd, DRM_IOCTL_GLAMO_GEM_MMAP, &mmap_arg);
+		if (ret != 0) {
+			fprintf(stderr,
+			        "%s:%d: Error preparing BO map %d (%d): %s .\n",
+			        __FILE__, __LINE__,
+			        bo->handle, bo_gem->name,
+			        strerror(errno));
+			return ret;
+		}
+		/* and mmap it */
+		bo->virtual = mmap(0, bo->size, PROT_READ | PROT_WRITE,
+		                       MAP_SHARED, bufmgr->fd,
+		                       mmap_arg.offset);
+		if (bo->virtual == MAP_FAILED) {
+			fprintf(stderr,
+			        "%s:%d: Error mapping buffer %d (%d): %s .\n",
+			        __FILE__, __LINE__,
+			        bo->handle, bo_gem->name,
+			        strerror(errno));
+			return errno;
+		}
+	}
+	bo_gem->map_count++;
+
+	return 0;
+}
+
+static int bo_unmap(struct glamo_bo *bo)
+{
+	struct glamo_bo_gem *bo_gem = (struct glamo_bo_gem*)bo;
+
+	if ( bo_gem->map_count == 0 ) {
+		fprintf(stderr, "Not unmapping %p, because its map count"
+		                " is already zero.\n", bo_gem);
+		return 0;
+	}
+
+	if (--bo_gem->map_count > 0) {
+		return 0;
+	}
+	munmap(bo->virtual, bo->size);
+	bo->virtual = NULL;
+	return 0;
+}
+
+static int bo_wait(struct glamo_bo *bo)
+{
+	struct drm_glamo_gem_wait_rendering args;
+	int ret;
+
+	args.handle = bo->handle;
+	args.have_handle = 1;
+	do {
+		ret = drmCommandWriteRead(bo->bom->fd,
+		                          DRM_GLAMO_GEM_WAIT_RENDERING,
+		                          &args, sizeof(args));
+	} while (ret == -EAGAIN);
+	return ret;
+}
+
+static struct glamo_bo_funcs bo_gem_funcs = {
+	bo_open,
+	bo_ref,
+	bo_unref,
+	bo_map,
+	bo_unmap,
+	bo_wait
+};
+
+struct glamo_bo_manager *glamo_bo_manager_gem_ctor(int fd)
+{
+	struct bo_manager_gem *bomg;
+
+	bomg = (struct bo_manager_gem*)calloc(1, sizeof(struct bo_manager_gem));
+	if (bomg == NULL) return NULL;
+
+	bomg->base.funcs = &bo_gem_funcs;
+	bomg->base.fd = fd;
+	return (struct glamo_bo_manager*)bomg;
+}
+
+void glamo_bo_manager_gem_dtor(struct glamo_bo_manager *bom)
+{
+	struct bo_manager_gem *bomg = (struct bo_manager_gem*)bom;
+
+	if (bom == NULL) return;
+	free(bomg);
+}
+
+uint32_t glamo_gem_get_name(struct glamo_bo *bo)
+{
+	struct glamo_bo_gem *bo_gem = (struct glamo_bo_gem*)bo;
+	return bo_gem->name;
+}
+
+int glamo_gem_name_buffer(struct glamo_bo *bo, uint32_t *name)
+{
+	struct drm_gem_flink flink;
+	int r;
+
+	if ( !bo ) {
+		fprintf(stderr, "No buffer object!\n");
+		return -1;
+	}
+
+	flink.handle = bo->handle;
+	r = ioctl(bo->bom->fd, DRM_IOCTL_GEM_FLINK, &flink);
+	if (r) return r;
+
+	*name = flink.name;
+	return 0;
+}
+
+int glamo_bo_subdata(struct glamo_bo *bo, unsigned long offset,
+                     unsigned long size, const void *data)
+{
+	int ret;
+
+	if (size == 0 || data == NULL)
+		return 0;
+
+	ret = bo_map(bo, 1);
+	if ( ret ) return ret;
+
+	memcpy((unsigned char *)bo->virtual + offset, data, size);
+
+	bo_unmap(bo);
+
+	return 0;
+}
diff --git a/glamo/glamo_bo_gem.h b/glamo/glamo_bo_gem.h
new file mode 100644
index 0000000..05b5fb9
--- /dev/null
+++ b/glamo/glamo_bo_gem.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2008 Dave Airlie
+ * Copyright © 2008 Jérôme Glisse
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ *      Dave Airlie
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#ifndef GLAMO_BO_GEM_H
+#define GLAMO_BO_GEM_H
+
+#include "glamo_bo.h"
+
+struct glamo_bo_manager *glamo_bo_manager_gem_ctor(int fd);
+void glamo_bo_manager_gem_dtor(struct glamo_bo_manager *bom);
+int glamo_gem_name_buffer(struct glamo_bo *bo, uint32_t *name);
+uint32_t glamo_gem_get_name(struct glamo_bo *bo);
+extern int glamo_bo_subdata(struct glamo_bo *bo, unsigned long offset,
+                            unsigned long size, const void *data);
+#endif
diff --git a/glamo/glamo_track.c b/glamo/glamo_track.c
new file mode 100644
index 0000000..27ffe41
--- /dev/null
+++ b/glamo/glamo_track.c
@@ -0,0 +1,140 @@
+/* 
+ * Copyright © 2008 Jérôme Glisse
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "glamo_track.h"
+
+void glamo_track_add_event(struct glamo_track *track,
+                            const char *file,
+                            const char *func,
+                            const char *op,
+                            unsigned line)
+{
+    struct glamo_track_event *event;
+
+    if (track == NULL) {
+        return;
+    }
+    event = (void*)calloc(1,sizeof(struct glamo_track_event));
+    if (event == NULL) {
+        return;
+    }
+    event->line = line;
+    event->file = strdup(file);
+    event->func = strdup(func);
+    event->op = strdup(op);
+    if (event->file == NULL || event->func == NULL || event->op == NULL) {
+        free(event->file);
+        free(event->func);
+        free(event->op);
+        free(event);
+        return;
+    }
+    event->next = track->events;
+    track->events = event;
+}
+
+struct glamo_track *glamo_tracker_add_track(struct glamo_tracker *tracker,
+                                              unsigned key)
+{
+    struct glamo_track *track;
+
+    track = (struct glamo_track*)calloc(1, sizeof(struct glamo_track));
+    if (track) {
+        track->next = tracker->tracks.next;
+        track->prev = &tracker->tracks;
+        tracker->tracks.next = track;
+        if (track->next) {
+            track->next->prev = track;
+        }
+        track->key = key;
+        track->events = NULL;
+    }
+    return track;
+}
+
+void glamo_tracker_remove_track(struct glamo_tracker *tracker,
+                                 struct glamo_track *track)
+{
+    struct glamo_track_event *event;
+    void *tmp;
+
+    if (track == NULL) {
+        return;
+    }
+    track->prev->next = track->next;
+    if (track->next) {
+        track->next->prev = track->prev;
+    }
+    track->next = track->prev = NULL;
+    event = track->events;
+    while (event) {
+        tmp = event;
+        free(event->file);
+        free(event->func);
+        free(event->op);
+        event = event->next;
+        free(tmp);
+    }
+    track->events = NULL;
+    free(track);
+}
+
+void glamo_tracker_print(struct glamo_tracker *tracker, FILE *file)
+{
+    struct glamo_track *track;
+    struct glamo_track_event *event;
+    void *tmp;
+
+    track = tracker->tracks.next;
+    while (track) {
+        event = track->events;
+        fprintf(file, "[0x%08X] :\n", track->key);
+        while (event) {
+            tmp = event;
+            fprintf(file, "  [0x%08X:%s](%s:%s:%d)\n",
+                    track->key, event->op,  event->file,
+                    event->func, event->line);
+            free(event->file);
+            free(event->func);
+            free(event->op);
+            event->file = NULL;
+            event->func = NULL;
+            event->op = NULL;
+            event = event->next;
+            free(tmp);
+        }
+        track->events = NULL;
+        tmp = track;
+        track = track->next;
+        free(tmp);
+    }
+}
diff --git a/glamo/glamo_track.h b/glamo/glamo_track.h
new file mode 100644
index 0000000..fedead7
--- /dev/null
+++ b/glamo/glamo_track.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2008 Jérôme Glisse
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ *      Jérôme Glisse <glisse@freedesktop.org>
+ */
+#ifndef GLAMO_TRACK_H
+#define GLAMO_TRACK_H
+
+struct glamo_track_event {
+    struct glamo_track_event   *next;
+    char                        *file;
+    char                        *func;
+    char                        *op;
+    unsigned                    line;
+};
+
+struct glamo_track {
+    struct glamo_track         *next;
+    struct glamo_track         *prev;
+    unsigned                    key;
+    struct glamo_track_event   *events;
+};
+
+struct glamo_tracker {
+    struct glamo_track         tracks;
+};
+
+void glamo_track_add_event(struct glamo_track *track,
+                            const char *file,
+                            const char *func,
+                            const char *op,
+                            unsigned line);
+struct glamo_track *glamo_tracker_add_track(struct glamo_tracker *tracker,
+                                              unsigned key);
+void glamo_tracker_remove_track(struct glamo_tracker *tracker,
+                                 struct glamo_track *track);
+void glamo_tracker_print(struct glamo_tracker *tracker,
+                          FILE *file);
+
+#endif
diff --git a/glamo/libdrm_glamo.pc.in b/glamo/libdrm_glamo.pc.in
new file mode 100644
index 0000000..d4d8e70
--- /dev/null
+++ b/glamo/libdrm_glamo.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libdrm_glamo
+Description: Userspace interface to kernel DRM services for Glamo
+Version: 1.0.1
+Libs: -L${libdir} -ldrm_glamo
+Cflags: -I${includedir} -I${includedir}/libdrm
diff --git a/include/drm/Makefile.am b/include/drm/Makefile.am
index 43695bd..f3f7edf 100644
--- a/include/drm/Makefile.am
+++ b/include/drm/Makefile.am
@@ -35,6 +35,7 @@ klibdrminclude_HEADERS = \
 	savage_drm.h \
 	sis_drm.h \
 	via_drm.h \
+	glamo_drm.h \
 	mach64_drm.h
 
 
diff --git a/include/drm/glamo_drm.h b/include/drm/glamo_drm.h
new file mode 100644
index 0000000..7629ebc
--- /dev/null
+++ b/include/drm/glamo_drm.h
@@ -0,0 +1,153 @@
+/* glamo_drm.h -- Public header for the Glamo driver
+ *
+ * Copyright 2009 Thomas White
+ * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
+ * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Thomas White <taw@bitwiz.org.uk>
+ *    Kevin E. Martin <martin@valinux.com>
+ *    Gareth Hughes <gareth@valinux.com>
+ *    Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef __GLAMO_DRM_H__
+#define __GLAMO_DRM_H__
+
+#include "drm.h"
+
+#define GLAMO_GEM_DOMAIN_VRAM (0x1)
+
+/* Glamo specific ioctls */
+#define DRM_GLAMO_CMDBUF     0x01
+#define DRM_GLAMO_SWAP       0x02
+#define DRM_GLAMO_CMDBURST   0x03
+
+#define DRM_GLAMO_GEM_INFO     0x1c
+#define DRM_GLAMO_GEM_CREATE   0x1d
+#define DRM_GLAMO_GEM_MMAP     0x1e
+#define DRM_GLAMO_GEM_PIN      0x1f
+#define DRM_GLAMO_GEM_UNPIN    0x20
+#define DRM_GLAMO_GEM_PREAD    0x21
+#define DRM_GLAMO_GEM_PWRITE   0x22
+#define DRM_GLAMO_GEM_WAIT_RENDERING 0x24
+
+#define DRM_IOCTL_GLAMO_CMDBUF     DRM_IOW(DRM_COMMAND_BASE + DRM_GLAMO_CMDBUF, drm_glamo_cmd_buffer_t)
+#define DRM_IOCTL_GLAMO_SWAP       DRM_IO(DRM_COMMAND_BASE + DRM_GLAMO_SWAP)
+#define DRM_IOCTL_GLAMO_CMDBURST     DRM_IOW(DRM_COMMAND_BASE + DRM_GLAMO_CMDBURST, drm_glamo_cmd_burst_t)
+
+#define DRM_IOCTL_GLAMO_GEM_INFO   DRM_IOWR(DRM_COMMAND_BASE + DRM_GLAMO_GEM_INFO, struct drm_glamo_gem_info)
+#define DRM_IOCTL_GLAMO_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_GLAMO_GEM_CREATE, struct drm_glamo_gem_create)
+#define DRM_IOCTL_GLAMO_GEM_MMAP   DRM_IOWR(DRM_COMMAND_BASE + DRM_GLAMO_GEM_MMAP, struct drm_glamo_gem_mmap)
+#define DRM_IOCTL_GLAMO_GEM_PIN    DRM_IOWR(DRM_COMMAND_BASE + DRM_GLAMO_GEM_PIN, struct drm_glamo_gem_pin)
+#define DRM_IOCTL_GLAMO_GEM_UNPIN  DRM_IOWR(DRM_COMMAND_BASE + DRM_GLAMO_GEM_UNPIN, struct drm_glamo_gem_unpin)
+#define DRM_IOCTL_GLAMO_GEM_PREAD  DRM_IOWR(DRM_COMMAND_BASE + DRM_GLAMO_GEM_PREAD, struct drm_glamo_gem_pread)
+#define DRM_IOCTL_GLAMO_GEM_PWRITE DRM_IOWR(DRM_COMMAND_BASE + DRM_GLAMO_GEM_PWRITE, struct drm_glamo_gem_pwrite)
+#define DRM_IOCTL_GLAMO_GEM_WAIT_RENDERING DRM_IOW(DRM_COMMAND_BASE + DRM_GLAMO_GEM_WAIT_RENDERING, struct drm_glamo_gem_wait_rendering)
+
+
+/* Simple command submission - a list of 16-bit address-data pairs */
+typedef struct drm_glamo_cmd_buffer {
+	unsigned int bufsz;	/* Size of buffer, in bytes */
+	char *buf;		/* Buffer of stuff to go onto the ring buffer */
+	unsigned int *obj_pos;	/* Offsets (in bytes) at which to put objs */
+	uint32_t *objs;		/* List of buffer object (handles) to use */
+	unsigned int nobjs;	/* Number of objects referenced */
+	int nbox;
+	struct drm_clip_rect *boxes;
+} drm_glamo_cmd_buffer_t;
+
+
+/* Burst command submission - base address and data:
+ *  - Data can be 32-bit (more easily)
+ *  - Easier for the kernel to validate */
+typedef struct drm_glamo_cmd_burst {
+	uint16_t base;		/* Base address (command) */
+	int bufsz;		/* Size of data, in bytes */
+	uint16_t *data;		/* Pointer to data */
+	unsigned int *obj_pos;	/* Offsets (in bytes) at which to put objs */
+	uint32_t *objs;		/* List of buffer object (handles) to use */
+	unsigned int nobjs;	/* Number of objects referenced */
+} drm_glamo_cmd_burst_t;
+
+struct drm_glamo_gem_info {
+	uint64_t vram_start;
+	uint64_t vram_size;
+};
+
+struct drm_glamo_gem_create {
+	uint64_t size;
+	uint64_t alignment;
+	uint32_t handle;
+	uint32_t initial_domain; // to allow VRAM to be created
+	uint32_t no_backing_store;
+};
+
+struct drm_glamo_gem_mmap {
+	uint32_t handle;	/* Handle goes in... */
+	uint64_t offset;	/* ...offset comes out */
+};
+
+struct drm_glamo_gem_wait_rendering {
+	uint32_t handle;
+	int have_handle;
+};
+
+struct drm_glamo_gem_pin {
+	uint32_t handle;
+	uint32_t pin_domain;
+	uint64_t alignment;
+	uint64_t offset;
+};
+
+struct drm_glamo_gem_unpin {
+	uint32_t handle;
+	uint32_t pad;
+};
+
+struct drm_glamo_gem_pread {
+	/** Handle for the object being read. */
+	uint32_t handle;
+	uint32_t pad;
+	/** Offset into the object to read from */
+	uint64_t offset;
+	/** Length of data to read */
+	uint64_t size;
+	/** Pointer to write the data into. */
+	uint64_t data_ptr;	/* void *, but pointers are not 32/64 compatible */
+};
+
+struct drm_glamo_gem_pwrite {
+	/** Handle for the object being written to. */
+	uint32_t handle;
+	uint32_t pad;
+	/** Offset into the object to write to */
+	uint64_t offset;
+	/** Length of data to write */
+	uint64_t size;
+	/** Pointer to read the data from. */
+	uint64_t data_ptr;	/* void *, but pointers are not 32/64 compatible */
+};
+
+#endif