summaryrefslogtreecommitdiff
path: root/testing/xf86-video-intel/git-fixes.patch
blob: cbdbf27b50926a9e54eb184cc497558e7bdaa26e (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
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
diff --git a/Makefile.am b/Makefile.am
index f4239de..83948ab 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,6 +18,7 @@
 #  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.
 
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
 SUBDIRS = uxa src man
 MAINTAINERCLEANFILES = ChangeLog INSTALL
diff --git a/configure.ac b/configure.ac
index 529a294..5a1baac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,18 +21,24 @@
 # Process this file with autoconf to produce a configure script
 
 # Initialize Autoconf
-AC_PREREQ([2.60])
+AC_PREREQ([2.63])
 AC_INIT([xf86-video-intel],
         [2.14.0],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-video-intel])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_AUX_DIR(.)
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
 
 # Initialize Automake
-AM_INIT_AUTOMAKE([foreign dist-bzip2])
-AM_MAINTAINER_MODE
+AM_INIT_AUTOMAKE([1.10 foreign dist-bzip2])
+AM_MAINTAINER_MODE([enable])
+
+# Support silent build rules, requires at least automake-1.11. Disable
+# by either passing --disable-silent-rules to configure or passing V=1
+# to make
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 # Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
 m4_ifndef([XORG_MACROS_VERSION],
@@ -50,8 +56,8 @@ m4_ifndef([XORG_DRIVER_CHECK_EXT],
   depending on your distribution, try package 'xserver-xorg-dev' or 'xorg-x11-server-devel'])])
 
 # Initialize libtool
-AC_DISABLE_STATIC
-AC_PROG_LIBTOOL
+LT_PREREQ([2.2])
+LT_INIT([disable-static])
 
 PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.1], [gen4asm=yes], [gen4asm=no])
 AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
@@ -85,6 +91,12 @@ AC_ARG_ENABLE(kms-only, AS_HELP_STRING([--enable-kms-only],
               [KMS_ONLY="$enableval"],
               [KMS_ONLY=no])
 
+AC_ARG_ENABLE(debug,
+	      AS_HELP_STRING([--enable-debug],
+			     [Enables internal debugging [[default=yes]]]),
+              [DEBUG="$enableval"],
+              [DEBUG=yes])
+
 # Store the list of server defined optional extensions in REQUIRED_MODULES
 XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
 XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
@@ -138,15 +150,19 @@ fi
 AC_MSG_CHECKING([whether to include XvMC support])
 AC_MSG_RESULT([$XVMC])
 AM_CONDITIONAL(XVMC, test x$XVMC = xyes)
-if test "$XVMC" = yes; then
+if test "x$XVMC" = xyes; then
 	AC_DEFINE(ENABLE_XVMC,1,[Enable XvMC support])
 fi
 
 AM_CONDITIONAL(KMS_ONLY, test x$KMS_ONLY = xyes)
-if test "$KMS_ONLY" = yes; then
+if test "x$KMS_ONLY" = xyes; then
 	AC_DEFINE(KMS_ONLY,1,[Assume KMS support])
 fi
 
+if test "x$DEBUG" = xno; then
+	AC_DEFINE(NDEBUG,1,[Disable internal debugging])
+fi
+
 DRIVER_NAME=intel
 AC_SUBST([DRIVER_NAME])
 AC_SUBST([moduledir])
diff --git a/src/i915_render.c b/src/i915_render.c
index 6d844e5..d04e8e1 100644
--- a/src/i915_render.c
+++ b/src/i915_render.c
@@ -302,12 +302,10 @@ static Bool i915_texture_setup(PicturePtr picture, PixmapPtr pixmap, int unit)
 	ScrnInfoPtr scrn = xf86Screens[picture->pDrawable->pScreen->myNum];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	uint32_t format, pitch, filter;
-	int w, h, i;
 	uint32_t wrap_mode, tiling_bits;
+	int i;
 
 	pitch = intel_pixmap_pitch(pixmap);
-	w = picture->pDrawable->width;
-	h = picture->pDrawable->height;
 	intel->scale_units[unit][0] = 1. / pixmap->drawable.width;
 	intel->scale_units[unit][1] = 1. / pixmap->drawable.height;
 
@@ -546,8 +544,8 @@ i915_emit_composite_primitive(PixmapPtr dest,
 {
 	ScrnInfoPtr scrn = xf86Screens[dest->drawable.pScreen->myNum];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	Bool is_affine_src, is_affine_mask = TRUE;
-	int per_vertex, num_floats;
+	Bool is_affine_src = TRUE, is_affine_mask = TRUE;
+	int per_vertex;
 	int tex_unit = 0;
 	int src_unit = -1, mask_unit = -1;
 	float src_x[3], src_y[3], src_w[3], mask_x[3], mask_y[3], mask_w[3];
@@ -666,8 +664,6 @@ i915_emit_composite_primitive(PixmapPtr dest,
 		}
 	}
 
-	num_floats = 3 * per_vertex;
-
 	OUT_VERTEX(dstX + w);
 	OUT_VERTEX(dstY + h);
 	if (! intel->render_source_is_solid) {
diff --git a/src/i965_video.c b/src/i965_video.c
index 235dfb9..e16a575 100644
--- a/src/i965_video.c
+++ b/src/i965_video.c
@@ -414,8 +414,8 @@ static void i965_create_dst_surface_state(ScrnInfoPtr scrn,
 	    intel_emit_reloc(surf_bo, offset + offsetof(struct brw_surface_state, ss1),
 			     pixmap_bo, 0, I915_GEM_DOMAIN_SAMPLER, 0);
 
-	dest_surf_state->ss2.height = scrn->virtualY - 1;
-	dest_surf_state->ss2.width = scrn->virtualX - 1;
+	dest_surf_state->ss2.height = pixmap->drawable.height - 1;
+	dest_surf_state->ss2.width = pixmap->drawable.width - 1;
 	dest_surf_state->ss2.mip_count = 0;
 	dest_surf_state->ss2.render_target_rotation = 0;
 	dest_surf_state->ss3.pitch = intel_pixmap_pitch(pixmap) - 1;
@@ -770,7 +770,7 @@ static drm_intel_bo *i965_create_cc_state(ScrnInfoPtr scrn)
 }
 
 static void
-i965_emit_video_setup(ScrnInfoPtr scrn, drm_intel_bo * surface_state_binding_table_bo, int n_src_surf)
+i965_emit_video_setup(ScrnInfoPtr scrn, drm_intel_bo * surface_state_binding_table_bo, int n_src_surf, PixmapPtr pixmap)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	int urb_vs_start, urb_vs_size;
@@ -821,20 +821,20 @@ i965_emit_video_setup(ScrnInfoPtr scrn, drm_intel_bo * surface_state_binding_tab
 		OUT_BATCH(0 | BASE_ADDRESS_MODIFY);	/* media base addr, don't care */
 		OUT_BATCH(0 | BASE_ADDRESS_MODIFY);	/* Instruction base address */
 		/* general state max addr, disabled */
-		OUT_BATCH(0x10000000 | BASE_ADDRESS_MODIFY);
+		OUT_BATCH(0 | BASE_ADDRESS_MODIFY);
 		/* media object state max addr, disabled */
-		OUT_BATCH(0x10000000 | BASE_ADDRESS_MODIFY);
+		OUT_BATCH(0 | BASE_ADDRESS_MODIFY);
 		/* Instruction max addr, disabled */
-		OUT_BATCH(0x10000000 | BASE_ADDRESS_MODIFY);
+		OUT_BATCH(0 | BASE_ADDRESS_MODIFY);
 	} else {
 		OUT_BATCH(BRW_STATE_BASE_ADDRESS | 4);
 		OUT_BATCH(0 | BASE_ADDRESS_MODIFY);	/* Generate state base address */
 		OUT_RELOC(surface_state_binding_table_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY); /* Surface state base address */
 		OUT_BATCH(0 | BASE_ADDRESS_MODIFY);	/* media base addr, don't care */
 		/* general state max addr, disabled */
-		OUT_BATCH(0x10000000 | BASE_ADDRESS_MODIFY);
+		OUT_BATCH(0 | BASE_ADDRESS_MODIFY);
 		/* media object state max addr, disabled */
-		OUT_BATCH(0x10000000 | BASE_ADDRESS_MODIFY);
+		OUT_BATCH(0 | BASE_ADDRESS_MODIFY);
 	}
 
 	/* Set system instruction pointer */
@@ -877,7 +877,7 @@ i965_emit_video_setup(ScrnInfoPtr scrn, drm_intel_bo * surface_state_binding_tab
 	 */
 	OUT_BATCH(BRW_3DSTATE_DRAWING_RECTANGLE | 2);	/* XXX 3 for BLC or CTG */
 	OUT_BATCH(0x00000000);	/* ymin, xmin */
-	OUT_BATCH((scrn->virtualX - 1) | (scrn->virtualY - 1) << 16);	/* ymax, xmax */
+	OUT_BATCH((pixmap->drawable.width - 1) | (pixmap->drawable.height - 1) << 16);	/* ymax, xmax */
 	OUT_BATCH(0x00000000);	/* yorigin, xorigin */
 
 	/* skip the depth buffer */
@@ -1212,7 +1212,7 @@ I965DisplayVideoTextured(ScrnInfoPtr scrn,
 
 		intel_batch_start_atomic(scrn, 100);
 
-		i965_emit_video_setup(scrn, surface_state_binding_table_bo, n_src_surf);
+		i965_emit_video_setup(scrn, surface_state_binding_table_bo, n_src_surf, pixmap);
 
 		/* Set up the pointer to our vertex buffer */
 		OUT_BATCH(BRW_3DSTATE_VERTEX_BUFFERS | 3);
@@ -1517,13 +1517,13 @@ gen6_upload_depth_buffer_state(ScrnInfoPtr scrn)
 }
 
 static void
-gen6_upload_drawing_rectangle(ScrnInfoPtr scrn)
+gen6_upload_drawing_rectangle(ScrnInfoPtr scrn, PixmapPtr pixmap)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
 	OUT_BATCH(BRW_3DSTATE_DRAWING_RECTANGLE | 2);
 	OUT_BATCH(0x00000000);	/* ymin, xmin */
-	OUT_BATCH((scrn->virtualX - 1) | (scrn->virtualY - 1) << 16);	/* ymax, xmax */
+	OUT_BATCH((pixmap->drawable.width - 1) | (pixmap->drawable.height - 1) << 16);	/* ymax, xmax */
 	OUT_BATCH(0x00000000);	/* yorigin, xorigin */
 }
 
@@ -1673,7 +1673,7 @@ gen6_upload_vertex_element_state(ScrnInfoPtr scrn)
 }
 
 static void
-gen6_emit_video_setup(ScrnInfoPtr scrn, drm_intel_bo *surface_state_binding_table_bo, int n_src_surf)
+gen6_emit_video_setup(ScrnInfoPtr scrn, drm_intel_bo *surface_state_binding_table_bo, int n_src_surf, PixmapPtr pixmap)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
@@ -1694,7 +1694,7 @@ gen6_emit_video_setup(ScrnInfoPtr scrn, drm_intel_bo *surface_state_binding_tabl
 	gen6_upload_wm_state(scrn, n_src_surf == 1 ? TRUE : FALSE);
 	gen6_upload_binding_table(scrn, (n_src_surf + 1) * ALIGN(sizeof(struct brw_surface_state), 32));;
 	gen6_upload_depth_buffer_state(scrn);
-	gen6_upload_drawing_rectangle(scrn);
+	gen6_upload_drawing_rectangle(scrn, pixmap);
 	gen6_upload_vertex_element_state(scrn);
 }
 
@@ -1853,7 +1853,7 @@ void Gen6DisplayVideoTextured(ScrnInfoPtr scrn,
 			intel_batch_submit(scrn, FALSE);
 
 		intel_batch_start_atomic(scrn, 200);
-		gen6_emit_video_setup(scrn, surface_state_binding_table_bo, n_src_surf);
+		gen6_emit_video_setup(scrn, surface_state_binding_table_bo, n_src_surf, pixmap);
 
 		/* Set up the pointer to our vertex buffer */
 		OUT_BATCH(BRW_3DSTATE_VERTEX_BUFFERS | (5 - 2));
diff --git a/src/intel.h b/src/intel.h
index 9063328..4c755fc 100644
--- a/src/intel.h
+++ b/src/intel.h
@@ -227,8 +227,6 @@ static inline Bool intel_pixmap_tiled(PixmapPtr pixmap)
 dri_bo *intel_get_pixmap_bo(PixmapPtr pixmap);
 void intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo);
 
-typedef struct _I830OutputRec I830OutputRec, *I830OutputPtr;
-
 #include "common.h"
 
 #ifdef XvMCExtension
@@ -239,39 +237,6 @@ typedef struct _I830OutputRec I830OutputRec, *I830OutputPtr;
 
 #define PITCH_NONE 0
 
-/** Record of a linear allocation in the aperture. */
-typedef struct _intel_memory intel_memory;
-struct _intel_memory {
-	/** Description of the allocation, for logging */
-	char *name;
-
-	/** @{
-	 * Memory allocator linked list pointers
-	 */
-	intel_memory *next;
-	intel_memory *prev;
-	/** @} */
-
-	drm_intel_bo *bo;
-	uint32_t gem_name;
-};
-
-typedef struct _I830CrtcPrivateRec {
-	int pipe;
-	int plane;
-
-	Bool enabled;
-
-	int dpms_mode;
-
-	int x, y;
-
-	/* Lookup table values to be set when the CRTC is enabled */
-	uint8_t lut_r[256], lut_g[256], lut_b[256];
-} I830CrtcPrivateRec, *I830CrtcPrivatePtr;
-
-#define I830CrtcPrivate(c) ((I830CrtcPrivatePtr) (c)->driver_private)
-
 /** enumeration of 3d consumers so some can maintain invariant state. */
 enum last_3d {
 	LAST_3D_OTHER,
@@ -288,19 +253,12 @@ enum dri_type {
 
 typedef struct intel_screen_private {
 	ScrnInfoPtr scrn;
-	unsigned char *MMIOBase;
 	int cpp;
 
 #define RENDER_BATCH			I915_EXEC_RENDER
 #define BLT_BATCH			I915_EXEC_BLT
 	unsigned int current_batch;
 
-	unsigned int bufferOffset;	/* for I830SelectBuffer */
-
-	/* These are set in PreInit and never changed. */
-	long FbMapSize;
-	long GTTMapSize;
-
 	void *modes;
 	drm_intel_bo *front_buffer;
 	long front_pitch, front_tiling;
@@ -344,7 +302,6 @@ typedef struct intel_screen_private {
 	Bool has_relaxed_fencing;
 
 	int Chipset;
-	unsigned long LinearAddr;
 	EntityInfoPtr pEnt;
 	struct pci_device *PciInfo;
 	struct intel_chipset chipset;
@@ -535,8 +492,6 @@ extern void I830InitVideo(ScreenPtr pScreen);
 extern xf86CrtcPtr intel_covering_crtc(ScrnInfoPtr scrn, BoxPtr box,
 				      xf86CrtcPtr desired, BoxPtr crtc_box_ret);
 
-extern xf86CrtcPtr intel_pipe_to_crtc(ScrnInfoPtr scrn, int pipe);
-
 Bool I830DRI2ScreenInit(ScreenPtr pScreen);
 void I830DRI2CloseScreen(ScreenPtr pScreen);
 void I830DRI2FrameEventHandler(unsigned int frame, unsigned int tv_sec,
@@ -545,11 +500,7 @@ void I830DRI2FlipEventHandler(unsigned int frame, unsigned int tv_sec,
 			      unsigned int tv_usec, void *user_data);
 
 extern Bool intel_crtc_on(xf86CrtcPtr crtc);
-static inline int intel_crtc_to_pipe(xf86CrtcPtr crtc)
-{
-	intel_screen_private *intel = intel_get_screen_private(crtc->scrn);
-	return intel_get_pipe_from_crtc_id(intel->bufmgr, crtc);
-}
+int intel_crtc_to_pipe(xf86CrtcPtr crtc);
 
 /* intel_memory.c */
 unsigned long intel_get_fence_size(intel_screen_private *intel, unsigned long size);
@@ -688,11 +639,6 @@ static inline drm_intel_bo *intel_bo_alloc_for_data(ScrnInfoPtr scrn,
 	return bo;
 }
 
-/* Flags for memory allocation function */
-#define NEED_PHYSICAL_ADDR		0x00000001
-#define ALLOW_SHARING			0x00000010
-#define DISABLE_REUSE			0x00000020
-
 void intel_debug_flush(ScrnInfoPtr scrn);
 
 static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
@@ -715,7 +661,7 @@ static inline Bool pixmap_is_scanout(PixmapPtr pixmap)
 const OptionInfoRec *intel_uxa_available_options(int chipid, int busid);
 
 Bool intel_uxa_init(ScreenPtr pScreen);
-void intel_uxa_create_screen_resources(ScreenPtr pScreen);
+Bool intel_uxa_create_screen_resources(ScreenPtr pScreen);
 void intel_uxa_block_handler(intel_screen_private *intel);
 Bool intel_get_aperture_space(ScrnInfoPtr scrn, drm_intel_bo ** bo_table,
 			      int num_bos);
diff --git a/src/intel_display.c b/src/intel_display.c
index 1198013..f487a6e 100644
--- a/src/intel_display.c
+++ b/src/intel_display.c
@@ -70,6 +70,7 @@ struct intel_crtc {
 	struct intel_mode *mode;
 	drmModeModeInfo kmode;
 	drmModeCrtcPtr mode_crtc;
+	int pipe;
 	dri_bo *cursor;
 	dri_bo *rotate_bo;
 	uint32_t rotate_pitch;
@@ -118,7 +119,6 @@ intel_output_dpms_backlight(xf86OutputPtr output, int oldmode, int mode);
  * List of available kernel interfaces in priority order
  */
 static const char *backlight_interfaces[] = {
-	"intel", /* prefer our own native backlight driver */
 	"asus-laptop",
 	"eeepc",
 	"thinkpad_screen",
@@ -128,6 +128,7 @@ static const char *backlight_interfaces[] = {
 	"samsung",
 	"acpi_video1", /* finally fallback to the generic acpi drivers */
 	"acpi_video0",
+	"intel_backlight",
 	NULL,
 };
 /*
@@ -678,6 +679,9 @@ intel_crtc_init(ScrnInfoPtr scrn, struct intel_mode *mode, int num)
 	intel_crtc->mode = mode;
 	crtc->driver_private = intel_crtc;
 
+	intel_crtc->pipe = drm_intel_get_pipe_from_crtc_id(intel->bufmgr,
+							   crtc_id(intel_crtc));
+
 	intel_crtc->cursor = drm_intel_bo_alloc(intel->bufmgr, "ARGB cursor",
 						HWCURSOR_SIZE_ARGB,
 						GTT_PAGE_SIZE);
@@ -1671,16 +1675,15 @@ intel_mode_fini(intel_screen_private *intel)
 	intel->modes = NULL;
 }
 
-int
-intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, xf86CrtcPtr crtc)
-{
-	return drm_intel_get_pipe_from_crtc_id(bufmgr,
-					      	crtc_id(crtc->driver_private));
-}
-
 /* for the mode overlay */
 int
 intel_crtc_id(xf86CrtcPtr crtc)
 {
 	return crtc_id(crtc->driver_private);
 }
+
+int intel_crtc_to_pipe(xf86CrtcPtr crtc)
+{
+	struct intel_crtc *intel_crtc = crtc->driver_private;
+	return intel_crtc->pipe;
+}
diff --git a/src/intel_driver.c b/src/intel_driver.c
index 1275e4b..ebed258 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -37,10 +37,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "config.h"
 #endif
 
-#ifndef PRINT_MODE_INFO
-#define PRINT_MODE_INFO 0
-#endif
-
 #include <assert.h>
 #include <string.h>
 #include <stdio.h>
@@ -80,10 +76,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "i915_drm.h"
 #include <xf86drmMode.h>
 
-#define BIT(x) (1 << (x))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#define NB_OF(x) (sizeof (x) / sizeof (*x))
-
 /* *INDENT-OFF* */
 /*
  * Note: "ColorKey" is provided for compatibility with the i810 driver.
@@ -174,14 +166,6 @@ I830LoadPalette(ScrnInfoPtr scrn, int numColors, int *indices,
 
 	for (p = 0; p < xf86_config->num_crtc; p++) {
 		xf86CrtcPtr crtc = xf86_config->crtc[p];
-		I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
-
-		/* Initialize to the old lookup table values. */
-		for (i = 0; i < 256; i++) {
-			lut_r[i] = intel_crtc->lut_r[i] << 8;
-			lut_g[i] = intel_crtc->lut_g[i] << 8;
-			lut_b[i] = intel_crtc->lut_b[i] << 8;
-		}
 
 		switch (scrn->depth) {
 		case 15:
@@ -250,9 +234,7 @@ static Bool i830CreateScreenResources(ScreenPtr screen)
 	if (!(*screen->CreateScreenResources) (screen))
 		return FALSE;
 
-	intel_uxa_create_screen_resources(screen);
-
-	return TRUE;
+	return intel_uxa_create_screen_resources(screen);
 }
 
 static void PreInitCleanup(ScrnInfoPtr scrn)
@@ -607,12 +589,9 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 	intel->tiling = TRUE;
 
 	/* Allow user override if they set a value */
-	if (!ALWAYS_TILING(intel) && xf86IsOptionSet(intel->Options, OPTION_TILING)) {
-		if (xf86ReturnOptValBool(intel->Options, OPTION_TILING, FALSE))
-			intel->tiling = TRUE;
-		else
-			intel->tiling = FALSE;
-	}
+	if (!ALWAYS_TILING(intel))
+		intel->tiling = xf86ReturnOptValBool(intel->Options,
+						     OPTION_TILING, TRUE);
 
 	intel->can_blt = can_accelerate_blt(intel);
 	intel->use_shadow = !intel->can_blt;
@@ -631,19 +610,11 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 	}
 
 	/* SwapBuffers delays to avoid tearing */
-	intel->swapbuffers_wait = TRUE;
-
-	/* Allow user override if they set a value */
-	if (xf86IsOptionSet(intel->Options, OPTION_SWAPBUFFERS_WAIT)) {
-		if (xf86ReturnOptValBool
-		    (intel->Options, OPTION_SWAPBUFFERS_WAIT, FALSE))
-			intel->swapbuffers_wait = TRUE;
-		else
-			intel->swapbuffers_wait = FALSE;
-	}
-
+	intel->swapbuffers_wait = xf86ReturnOptValBool(intel->Options,
+						       OPTION_SWAPBUFFERS_WAIT,
+						       TRUE);
 	if (IS_GEN6(intel))
-	    intel->swapbuffers_wait = FALSE;
+		intel->swapbuffers_wait = FALSE;
 
 	xf86DrvMsg(scrn->scrnIndex, X_CONFIG, "Tiling %sabled\n",
 		   intel->tiling ? "en" : "dis");
@@ -679,19 +650,12 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 	}
 
 	/* Load the dri2 module if requested. */
-	if (xf86ReturnOptValBool(intel->Options, OPTION_DRI, FALSE) &&
-	    intel->directRenderingType != DRI_DISABLED) {
+	if (intel->directRenderingType != DRI_DISABLED)
 		xf86LoadSubModule(scrn, "dri2");
-	}
 
 	return TRUE;
 }
 
-enum pipe {
-	PIPE_A = 0,
-	PIPE_B,
-};
-
 /**
  * Intialiazes the hardware for the 3D pipeline use in the 2D driver.
  *
@@ -733,50 +697,6 @@ I830BlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadmask)
 	intel_video_block_handler(intel);
 }
 
-static void intel_fixup_mtrrs(ScrnInfoPtr scrn)
-{
-#ifdef HAS_MTRR_SUPPORT
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	int fd;
-	struct mtrr_gentry gentry;
-	struct mtrr_sentry sentry;
-
-	if ((fd = open("/proc/mtrr", O_RDONLY, 0)) != -1) {
-		for (gentry.regnum = 0;
-		     ioctl(fd, MTRRIOC_GET_ENTRY, &gentry) == 0;
-		     ++gentry.regnum) {
-
-			if (gentry.size < 1) {
-				/* DISABLED */
-				continue;
-			}
-
-			/* Check the MTRR range is one we like and if not - remove it.
-			 * The Xserver common layer will then setup the right range
-			 * for us.
-			 */
-			if (gentry.base == intel->LinearAddr &&
-			    gentry.size < intel->FbMapSize) {
-
-				xf86DrvMsg(scrn->scrnIndex, X_INFO,
-					   "Removing bad MTRR range (base 0x%lx, size 0x%x)\n",
-					   gentry.base, gentry.size);
-
-				sentry.base = gentry.base;
-				sentry.size = gentry.size;
-				sentry.type = gentry.type;
-
-				if (ioctl(fd, MTRRIOC_DEL_ENTRY, &sentry) == -1) {
-					xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-						   "Failed to remove bad MTRR range\n");
-				}
-			}
-		}
-		close(fd);
-	}
-#endif
-}
-
 static Bool
 intel_init_initial_framebuffer(ScrnInfoPtr scrn)
 {
@@ -809,7 +729,7 @@ Bool intel_crtc_on(xf86CrtcPtr crtc)
 {
 	ScrnInfoPtr scrn = crtc->scrn;
 	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-	int i, active_outputs = 0;
+	int i;
 
 	if (!crtc->enabled)
 		return FALSE;
@@ -819,11 +739,9 @@ Bool intel_crtc_on(xf86CrtcPtr crtc)
 		xf86OutputPtr output = xf86_config->output[i];
 		if (output->crtc == crtc &&
 		    intel_output_dpms_status(output) == DPMSModeOn)
-			active_outputs++;
+			return TRUE;
 	}
 
-	if (active_outputs)
-		return TRUE;
 	return FALSE;
 }
 
@@ -849,103 +767,102 @@ intel_flush_callback(CallbackListPtr *list,
 static void
 I830HandleUEvents(int fd, void *closure)
 {
-    ScrnInfoPtr scrn = closure;
+	ScrnInfoPtr scrn = closure;
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-    struct udev_device *dev;
-    const char *hotplug;
-    struct stat s;
-    dev_t udev_devnum;
-
-    dev = udev_monitor_receive_device(intel->uevent_monitor);
-    if (!dev)
-	return;
-
-    udev_devnum = udev_device_get_devnum(dev);
-    fstat(intel->drmSubFD, &s);
-    /*
-     * Check to make sure this event is directed at our
-     * device (by comparing dev_t values), then make
-     * sure it's a hotplug event (HOTPLUG=1)
-     */
-
-    hotplug = udev_device_get_property_value(dev, "HOTPLUG");
-
-    if (memcmp(&s.st_rdev, &udev_devnum, sizeof (dev_t)) == 0 &&
-	hotplug && atoi(hotplug) == 1)
-	RRGetInfo(screenInfo.screens[scrn->scrnIndex], TRUE);
-
-    udev_device_unref(dev);
+	struct udev_device *dev;
+	const char *hotplug;
+	struct stat s;
+	dev_t udev_devnum;
+
+	dev = udev_monitor_receive_device(intel->uevent_monitor);
+	if (!dev)
+		return;
+
+	udev_devnum = udev_device_get_devnum(dev);
+	fstat(intel->drmSubFD, &s);
+	/*
+	 * Check to make sure this event is directed at our
+	 * device (by comparing dev_t values), then make
+	 * sure it's a hotplug event (HOTPLUG=1)
+	 */
+
+	hotplug = udev_device_get_property_value(dev, "HOTPLUG");
+
+	if (memcmp(&s.st_rdev, &udev_devnum, sizeof (dev_t)) == 0 &&
+			hotplug && atoi(hotplug) == 1)
+		RRGetInfo(screenInfo.screens[scrn->scrnIndex], TRUE);
+
+	udev_device_unref(dev);
 }
 
 static void
 I830UeventInit(ScrnInfoPtr scrn)
 {
-    intel_screen_private *intel = intel_get_screen_private(scrn);
-    struct udev *u;
-    struct udev_monitor *mon;
-    Bool hotplug;
-    MessageType from = X_CONFIG;
-
-    if (!xf86GetOptValBool(intel->Options, OPTION_HOTPLUG, &hotplug)) {
-	from = X_DEFAULT;
-	hotplug = TRUE;
-    }
-
-    xf86DrvMsg(scrn->scrnIndex, from, "hotplug detection: \"%s\"\n",
-	       hotplug ? "enabled" : "disabled");
-    if (!hotplug)
-	return;
-
-    u = udev_new();
-    if (!u)
-	return;
-
-    mon = udev_monitor_new_from_netlink(u, "udev");
-
-    if (!mon) {
-	udev_unref(u);
-	return;
-    }
-
-    if (udev_monitor_filter_add_match_subsystem_devtype(mon,
-							"drm",
-							"drm_minor") < 0 ||
-	udev_monitor_enable_receiving(mon) < 0)
-    {
-	udev_monitor_unref(mon);
-	udev_unref(u);
-	return;
-    }
-
-    intel->uevent_handler =
-	xf86AddGeneralHandler(udev_monitor_get_fd(mon),
-			      I830HandleUEvents,
-			      scrn);
-    if (!intel->uevent_handler) {
-	udev_monitor_unref(mon);
-	udev_unref(u);
-	return;
-    }
-
-    intel->uevent_monitor = mon;
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	struct udev *u;
+	struct udev_monitor *mon;
+	Bool hotplug;
+	MessageType from = X_CONFIG;
+
+	if (!xf86GetOptValBool(intel->Options, OPTION_HOTPLUG, &hotplug)) {
+		from = X_DEFAULT;
+		hotplug = TRUE;
+	}
+
+	xf86DrvMsg(scrn->scrnIndex, from, "hotplug detection: \"%s\"\n",
+			hotplug ? "enabled" : "disabled");
+	if (!hotplug)
+		return;
+
+	u = udev_new();
+	if (!u)
+		return;
+
+	mon = udev_monitor_new_from_netlink(u, "udev");
+
+	if (!mon) {
+		udev_unref(u);
+		return;
+	}
+
+	if (udev_monitor_filter_add_match_subsystem_devtype(mon,
+				"drm",
+				"drm_minor") < 0 ||
+			udev_monitor_enable_receiving(mon) < 0)
+	{
+		udev_monitor_unref(mon);
+		udev_unref(u);
+		return;
+	}
+
+	intel->uevent_handler =
+		xf86AddGeneralHandler(udev_monitor_get_fd(mon),
+				I830HandleUEvents,
+				scrn);
+	if (!intel->uevent_handler) {
+		udev_monitor_unref(mon);
+		udev_unref(u);
+		return;
+	}
+
+	intel->uevent_monitor = mon;
 }
 
 static void
 I830UeventFini(ScrnInfoPtr scrn)
 {
-    intel_screen_private *intel = intel_get_screen_private(scrn);
+	intel_screen_private *intel = intel_get_screen_private(scrn);
 
-    if (intel->uevent_handler)
-    {
-	struct udev *u = udev_monitor_get_udev(intel->uevent_monitor);
+	if (intel->uevent_handler) {
+		struct udev *u = udev_monitor_get_udev(intel->uevent_monitor);
 
-	xf86RemoveGeneralHandler(intel->uevent_handler);
+		xf86RemoveGeneralHandler(intel->uevent_handler);
 
-	udev_monitor_unref(intel->uevent_monitor);
-	udev_unref(u);
-	intel->uevent_handler = NULL;
-	intel->uevent_monitor = NULL;
-    }
+		udev_monitor_unref(intel->uevent_monitor);
+		udev_unref(u);
+		intel->uevent_handler = NULL;
+		intel->uevent_monitor = NULL;
+	}
 }
 #endif /* HAVE_UDEV */
 
@@ -961,32 +878,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr screen, int argc, char **argv)
 	struct pci_device *const device = intel->PciInfo;
 	int fb_bar = IS_GEN2(intel) ? 0 : 2;
 
-	/*
-	 * The "VideoRam" config file parameter specifies the maximum amount of
-	 * memory that will be used/allocated.  When not present, we allow the
-	 * driver to allocate as much memory as it wishes to satisfy its
-	 * allocations, but if agpgart support isn't available, it gets limited
-	 * to the amount of pre-allocated ("stolen") memory.
-	 *
-	 * Note that in using this value for allocator initialization, we're
-	 * limiting aperture allocation to the VideoRam option, rather than limiting
-	 * actual memory allocation, so alignment and things will cause less than
-	 * VideoRam to be actually used.
-	 */
-	scrn->videoRam = intel->FbMapSize / KB(1);
-	if (intel->pEnt->device->videoRam != 0) {
-		if (scrn->videoRam != intel->pEnt->device->videoRam) {
-			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-				   "VideoRam configuration found, which is no "
-				   "longer used.\n");
-			xf86DrvMsg(scrn->scrnIndex, X_INFO,
-				   "Continuing with (ignored) %dkB VideoRam "
-				   "instead of %d kB.\n",
-				   scrn->videoRam,
-				   intel->pEnt->device->videoRam);
-		}
-	}
-
 	scrn->videoRam = device->regions[fb_bar].size / 1024;
 
 	intel->last_3d = LAST_3D_OTHER;
@@ -998,10 +889,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr screen, int argc, char **argv)
 	 */
 	intel->XvEnabled = TRUE;
 
-	xf86DrvMsg(scrn->scrnIndex,
-		   intel->pEnt->device->videoRam ? X_CONFIG : X_DEFAULT,
-		   "VideoRam: %d KB\n", scrn->videoRam);
-
 #ifdef DRI2
 	if (intel->directRenderingType == DRI_NONE
 	    && I830DRI2ScreenInit(screen))
@@ -1011,8 +898,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr screen, int argc, char **argv)
 	if (!intel_init_initial_framebuffer(scrn))
 		return FALSE;
 
-	intel_fixup_mtrrs(scrn);
-
 	intel_batch_init(scrn);
 
 	if (INTEL_INFO(intel)->gen >= 40)
@@ -1159,7 +1044,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr screen, int argc, char **argv)
 	I830UeventInit(scrn);
 #endif
 
-	return uxa_resources_init(screen);
+	return TRUE;
 }
 
 static void i830AdjustFrame(int scrnIndex, int x, int y, int flags)
@@ -1382,22 +1267,6 @@ static Bool I830PMEvent(int scrnIndex, pmEvent event, Bool undo)
 	return TRUE;
 }
 
-xf86CrtcPtr intel_pipe_to_crtc(ScrnInfoPtr scrn, int pipe)
-{
-	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
-	int c;
-
-	for (c = 0; c < config->num_crtc; c++) {
-		xf86CrtcPtr crtc = config->crtc[c];
-		I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
-
-		if (intel_crtc->pipe == pipe)
-			return crtc;
-	}
-
-	return NULL;
-}
-
 void intel_init_scrn(ScrnInfoPtr scrn)
 {
 	scrn->PreInit = I830PreInit;
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index 1a591f1..9341b91 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -1089,12 +1089,15 @@ static Bool intel_uxa_destroy_pixmap(PixmapPtr pixmap)
 	return TRUE;
 }
 
-void intel_uxa_create_screen_resources(ScreenPtr screen)
+Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	dri_bo *bo = intel->front_buffer;
 
+	if (!uxa_resources_init(screen))
+		return FALSE;
+
 	drm_intel_gem_bo_map_gtt(bo);
 
 	if (intel->use_shadow) {
@@ -1111,6 +1114,8 @@ void intel_uxa_create_screen_resources(ScreenPtr screen)
 					   NULL);
 		scrn->displayWidth = intel->front_pitch / intel->cpp;
 	}
+
+	return TRUE;
 }
 
 static void
@@ -1185,7 +1190,6 @@ Bool intel_uxa_init(ScreenPtr screen)
 
 	memset(intel->uxa_driver, 0, sizeof(*intel->uxa_driver));
 
-	intel->bufferOffset = 0;
 	intel->uxa_driver->uxa_major = 1;
 	intel->uxa_driver->uxa_minor = 0;
 
diff --git a/src/intel_video.c b/src/intel_video.c
index 2786201..5294f73 100644
--- a/src/intel_video.c
+++ b/src/intel_video.c
@@ -996,7 +996,7 @@ I830CopyPlanarData(intel_adaptor_private *adaptor_priv,
 	/* Copy V data for YV12, or U data for I420 */
 	src2 = buf +		/* start of YUV data */
 	    (srcH * srcPitch) +	/* move over Luma plane */
-	    ((top * srcPitch) >> 2) +	/* move down from by top lines */
+	    ((top >> 1) * srcPitch2) +	/* move down from by top lines */
 	    (left >> 1);	/* move left by left pixels */
 
 #if 0
@@ -1015,7 +1015,7 @@ I830CopyPlanarData(intel_adaptor_private *adaptor_priv,
 	src3 = buf +		/* start of YUV data */
 	    (srcH * srcPitch) +	/* move over Luma plane */
 	    ((srcH >> 1) * srcPitch2) +	/* move over Chroma plane */
-	    ((top * srcPitch) >> 2) +	/* move down from by top lines */
+	    ((top >> 1) * srcPitch2) +	/* move down from by top lines */
 	    (left >> 1);	/* move left by left pixels */
 #if 0
 	ErrorF("src3 is %p, offset is %ld\n", src3,
diff --git a/src/xvmc/i915_xvmc.c b/src/xvmc/i915_xvmc.c
index 21a1149..fbd4555 100644
--- a/src/xvmc/i915_xvmc.c
+++ b/src/xvmc/i915_xvmc.c
@@ -391,7 +391,6 @@ static void i915_mc_static_indirect_state_set(XvMCContext * context,
 	i915XvMCContext *pI915XvMC = (i915XvMCContext *) context->privData;
 	struct intel_xvmc_surface *intel_surf = dest->privData;
 	struct i915_mc_static_indirect_state_buffer *buffer_info;
-	unsigned int w = dest->width;
 
 	drm_intel_gem_bo_map_gtt(pI915XvMC->sis_bo);
 	buffer_info = pI915XvMC->sis_bo->virtual;
@@ -688,7 +687,7 @@ static void i915_mc_load_indirect_render_emit(XvMCContext * context)
 {
 	i915XvMCContext *pI915XvMC = (i915XvMCContext *) context->privData;
 	int mem_select;
-	uint32_t load_indirect, buffer_address;
+	uint32_t load_indirect;
 	BATCH_LOCALS;
 
 	BEGIN_BATCH(5);
diff --git a/src/xvmc/intel_batchbuffer.c b/src/xvmc/intel_batchbuffer.c
index 337b2ce..2b5526c 100644
--- a/src/xvmc/intel_batchbuffer.c
+++ b/src/xvmc/intel_batchbuffer.c
@@ -64,8 +64,6 @@ static void i965_end_batch(void)
 
 Bool intelInitBatchBuffer(void)
 {
-	int i;
-
 	if ((xvmc_driver->batch.buf =
 	     drm_intel_bo_alloc(xvmc_driver->bufmgr,
 				"batch buffer", BATCH_SIZE, 0x1000)) == NULL) {
diff --git a/src/xvmc/intel_batchbuffer.h b/src/xvmc/intel_batchbuffer.h
index 6fa1c05..888abeb 100644
--- a/src/xvmc/intel_batchbuffer.h
+++ b/src/xvmc/intel_batchbuffer.h
@@ -24,7 +24,7 @@ extern int VERBOSE;
 
 #define OUT_RELOC(bo,read_domains,write_domains,delta)  \
     do { \
-        *(unsigned int *)batch_ptr = delta + bo->offset; \
+        *(unsigned int *)batch_ptr = (delta) + bo->offset; \
         intel_batch_emit_reloc(bo, read_domains, write_domains, delta, batch_ptr); \
         batch_ptr += 4;                                                 \
     } while (0)
diff --git a/src/xvmc/intel_xvmc.c b/src/xvmc/intel_xvmc.c
index 6cbec80..1b96945 100644
--- a/src/xvmc/intel_xvmc.c
+++ b/src/xvmc/intel_xvmc.c
@@ -105,8 +105,6 @@ unsigned int mb_bytes_420[] = {
 
 void LOCK_HARDWARE(drm_context_t ctx)
 {
-	char __ret = 0;
-
 	PPTHREAD_MUTEX_LOCK();
 	assert(!xvmc_driver->locked);
 
@@ -218,11 +216,6 @@ _X_EXPORT Status XvMCCreateContext(Display * display, XvPortID port,
 	int error_base;
 	int event_base;
 	int priv_count;
-	int isCapable;
-	int screen = DefaultScreen(display);
-	intel_xvmc_context_ptr intel_ctx;
-	int fd;
-	char *driverName = NULL, *deviceName = NULL;
 
 	/* Verify Obvious things first */
 	if (!display || !context)
@@ -482,7 +475,6 @@ _X_EXPORT Status XvMCCreateBlocks(Display * display, XvMCContext * context,
 				  unsigned int num_blocks,
 				  XvMCBlockArray * block)
 {
-	Status ret;
 	if (!display || !context || !num_blocks || !block)
 		return BadValue;
 
@@ -505,7 +497,6 @@ _X_EXPORT Status XvMCCreateBlocks(Display * display, XvMCContext * context,
  */
 _X_EXPORT Status XvMCDestroyBlocks(Display * display, XvMCBlockArray * block)
 {
-	Status ret;
 	if (!display || !block)
 		return BadValue;
 
@@ -678,13 +669,10 @@ _X_EXPORT Status XvMCPutSurface(Display * display, XvMCSurface * surface,
  */
 _X_EXPORT Status XvMCSyncSurface(Display * display, XvMCSurface * surface)
 {
-	Status ret;
-	int stat = 0;
-
 	if (!display || !surface)
 		return XvMCBadSurface;
 
-	return ret;
+	return Success;
 }
 
 /*
@@ -739,9 +727,6 @@ _X_EXPORT Status XvMCGetSurfaceStatus(Display * display, XvMCSurface * surface,
  */
 _X_EXPORT Status XvMCHideSurface(Display * display, XvMCSurface * surface)
 {
-	int stat = 0;
-	Status ret;
-
 	if (!display || !surface)
 		return XvMCBadSurface;
 
@@ -1071,7 +1056,7 @@ _X_EXPORT Status XvMCLoadQMatrix(Display * display, XvMCContext * context,
 _X_EXPORT Status XvMCPutSlice(Display * display, XvMCContext * context,
 			      char *slice, int nbytes)
 {
-	if (xvmc_driver->put_slice(display, context, slice, nbytes)) {
+	if (xvmc_driver->put_slice(display, context, (unsigned char *) slice, nbytes)) {
 		XVMC_ERR("PutSlice fail\n");
 		return BadValue;
 	}
@@ -1082,7 +1067,7 @@ _X_EXPORT Status XvMCPutSlice2(Display * display, XvMCContext * context,
 			       char *slice, int nbytes, int slice_code)
 {
 	if (xvmc_driver->put_slice2
-	    (display, context, slice, nbytes, slice_code)) {
+	    (display, context, (unsigned char *) slice, nbytes, slice_code)) {
 		XVMC_ERR("PutSlice2 fail\n");
 		return BadValue;
 	}
diff --git a/src/xvmc/intel_xvmc_dump.c b/src/xvmc/intel_xvmc_dump.c
index 974bcbb..d22d311 100644
--- a/src/xvmc/intel_xvmc_dump.c
+++ b/src/xvmc/intel_xvmc_dump.c
@@ -38,7 +38,7 @@ void intel_xvmc_dump_open(void)
 	if (xvmc_dump)
 		return;
 
-	if (d = getenv("INTEL_XVMC_DUMP"))
+	if ((d = getenv("INTEL_XVMC_DUMP")))
 		xvmc_dump = 1;
 
 	if (xvmc_dump) {
diff --git a/src/xvmc/xvmc_vld.c b/src/xvmc/xvmc_vld.c
index addc7c9..d72e105 100644
--- a/src/xvmc/xvmc_vld.c
+++ b/src/xvmc/xvmc_vld.c
@@ -785,7 +785,6 @@ static Status begin_surface(Display * display, XvMCContext * context,
 			    XvMCSurface * future,
 			    const XvMCMpegControl * control)
 {
-	struct i965_xvmc_contex *i965_ctx;
 	struct intel_xvmc_surface *priv_target, *priv_past, *priv_future;
 	intel_xvmc_context_ptr intel_ctx = context->privData;
 	Status ret;
diff --git a/uxa/uxa-accel.c b/uxa/uxa-accel.c
index a5066c8..0650ac2 100644
--- a/uxa/uxa-accel.c
+++ b/uxa/uxa-accel.c
@@ -120,6 +120,10 @@ uxa_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int n,
 
 		solid = uxa_acquire_solid(screen, src->pSourcePict);
 		FreePicture(src, 0);
+		if (!solid) {
+			FreePicture(dst, 0);
+			goto solid;
+		}
 
 		src = solid;
 		src_pixmap = uxa_get_offscreen_pixmap(src->pDrawable,
@@ -1110,6 +1114,10 @@ try_solid:
 
 			solid = uxa_acquire_solid(screen, src->pSourcePict);
 			FreePicture(src, 0);
+			if (!solid) {
+				FreePicture(dst, 0);
+				goto err;
+			}
 
 			src = solid;
 			src_pixmap = uxa_get_offscreen_pixmap(src->pDrawable,
diff --git a/uxa/uxa-glyphs.c b/uxa/uxa-glyphs.c
index 420e891..0f5ddda 100644
--- a/uxa/uxa-glyphs.c
+++ b/uxa/uxa-glyphs.c
@@ -111,6 +111,9 @@ static void uxa_unrealize_glyph_caches(ScreenPtr pScreen)
 	uxa_screen_t *uxa_screen = uxa_get_screen(pScreen);
 	int i;
 
+	if (!uxa_screen->glyph_cache_initialized)
+		return;
+
 	for (i = 0; i < UXA_NUM_GLYPH_CACHE_FORMATS; i++) {
 		uxa_glyph_cache_t *cache = &uxa_screen->glyphCaches[i];
 
@@ -120,6 +123,7 @@ static void uxa_unrealize_glyph_caches(ScreenPtr pScreen)
 		if (cache->glyphs)
 			free(cache->glyphs);
 	}
+	uxa_screen->glyph_cache_initialized = FALSE;
 }
 
 void uxa_glyphs_fini(ScreenPtr pScreen)
@@ -145,6 +149,10 @@ static Bool uxa_realize_glyph_caches(ScreenPtr pScreen)
 	};
 	int i;
 
+	if (uxa_screen->glyph_cache_initialized)
+		return TRUE;
+
+	uxa_screen->glyph_cache_initialized = TRUE;
 	memset(uxa_screen->glyphCaches, 0, sizeof(uxa_screen->glyphCaches));
 
 	for (i = 0; i < sizeof(formats)/sizeof(formats[0]); i++) {
@@ -214,17 +222,7 @@ Bool uxa_glyphs_init(ScreenPtr pScreen)
 	if (uxa_get_screen(pScreen)->force_fallback)
 		return TRUE;
 
-	/* We are trying to initialise per screen resources prior to the
-	 * complete initialisation of the screen. So ensure the components
-	 * that we depend upon are initialsed prior to our use.
-	 */
-	if (!CreateScratchPixmapsForScreen(pScreen->myNum))
-		return FALSE;
-
-	if (!uxa_realize_glyph_caches(pScreen))
-		return FALSE;
-
-	return TRUE;
+	return uxa_realize_glyph_caches(pScreen);
 }
 
 /* The most efficient thing to way to upload the glyph to the screen
diff --git a/uxa/uxa-priv.h b/uxa/uxa-priv.h
index 92536cc..ac206af 100644
--- a/uxa/uxa-priv.h
+++ b/uxa/uxa-priv.h
@@ -139,6 +139,7 @@ typedef struct {
 	unsigned offScreenCounter;
 
 	uxa_glyph_cache_t glyphCaches[UXA_NUM_GLYPH_CACHE_FORMATS];
+	Bool glyph_cache_initialized;
 
 	PicturePtr solid_clear, solid_black, solid_white;
 	uxa_solid_cache_t solid_cache[UXA_NUM_SOLID_CACHE];
diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c
index cf8b8ea..0f06e82 100644
--- a/uxa/uxa-render.c
+++ b/uxa/uxa-render.c
@@ -1061,6 +1061,8 @@ try_solid:
 			int src_off_x, src_off_y;
 
 			solid = uxa_acquire_solid(screen, src->pSourcePict);
+			if (!solid)
+				goto err_src;
 			FreePicture(src, 0);
 
 			src = solid;
@@ -1090,6 +1092,7 @@ try_solid:
 	/* XXX xserver-1.8: CompositeRects is not tracked by Damage, so we must
 	 * manually append the damaged regions ourselves.
 	 */
+	pixman_region_translate(&region, -dst_x, -dst_y);
 	DamageRegionAppend(dst->pDrawable, &region);
 
 	pixman_region_fini(&region);