aboutsummaryrefslogtreecommitdiffstats
path: root/main/xf86-video-vmware/git_fixes.diff
blob: 85894169e83c9849c71b25596d3960f6baaa980a (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
From 46cdf0ed0ad9df66f36f95e27b209d454f67d526 Mon Sep 17 00:00:00 2001
From: Brian Paul <brianp@vmware.com>
Date: Fri, 20 Apr 2012 20:24:26 +0000
Subject: vmwgfx: set the XA_FLAG_SHARED flag for composite dest surfaces

This fixes a failed assertion in the gallium/svga driver in the
svga_texture_get_handle() function.  The texture resource wasn't
getting created with the PIPE_BIND_SHARED flag so the !cachable
assertion would fail and the X session would abort.  This didn't
happen with release builds.

Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
---
diff --git a/vmwgfx/vmwgfx_xa_surface.c b/vmwgfx/vmwgfx_xa_surface.c
index 2a18762..8b30e45 100644
--- a/vmwgfx/vmwgfx_xa_surface.c
+++ b/vmwgfx/vmwgfx_xa_surface.c
@@ -148,7 +148,7 @@ vmwgfx_hw_composite_dst_stage(PixmapPtr pixmap,
 
     vpix->staging_format = format;
     vpix->staging_remove_flags = 0;
-    vpix->staging_add_flags = XA_FLAG_RENDER_TARGET;
+    vpix->staging_add_flags = XA_FLAG_RENDER_TARGET | XA_FLAG_SHARED;
 
     return TRUE;
 }
--
cgit v0.9.0.2-2-gbebe
From 61df95a86f4997e342d50d7779b00aba2e8849a6 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Wed, 06 Jun 2012 08:58:01 +0000
Subject: vmware: port vmware driver to new compat API

This is a port of the vmware driver to the new compat API.

Tested-by: Jakob Bornecrantz <jakob@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
---
diff --git a/saa/saa.c b/saa/saa.c
index 173c090..f2d68e9 100644
--- a/saa/saa.c
+++ b/saa/saa.c
@@ -594,7 +594,7 @@ saa_set_fallback_debug(ScreenPtr screen, Bool enable)
  * screen private, before calling down to the next CloseScreen.
  */
 Bool
-saa_close_screen(int i, ScreenPtr pScreen)
+saa_close_screen(CLOSE_SCREEN_ARGS_DECL)
 {
     struct saa_screen_priv *sscreen = saa_screen(pScreen);
     struct saa_driver *driver = sscreen->driver;
@@ -624,7 +624,7 @@ saa_close_screen(int i, ScreenPtr pScreen)
 
     free(sscreen);
 
-    return (*pScreen->CloseScreen) (i, pScreen);
+    return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS);
 }
 
 struct saa_driver *
diff --git a/saa/saa.h b/saa/saa.h
index c7aa3b6..4e5ced5 100644
--- a/saa/saa.h
+++ b/saa/saa.h
@@ -44,6 +44,8 @@
 #include <damage.h>
 #include <picturestr.h>
 
+#include "../src/compat-api.h"
+
 #define SAA_VERSION_MAJOR 0
 #define SAA_VERSION_MINOR 1
 
@@ -173,7 +175,7 @@ extern _X_EXPORT RegionPtr
 saa_bitmap_to_region(PixmapPtr pPix);
 
 extern _X_EXPORT Bool
-saa_close_screen(int i, ScreenPtr pScreen);
+saa_close_screen(CLOSE_SCREEN_ARGS_DECL);
 
 extern _X_EXPORT Bool
 saa_gc_reads_destination(DrawablePtr pDrawable, GCPtr pGC);
diff --git a/src/Makefile.am b/src/Makefile.am
index 04c9e0d..b0dd147 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -37,6 +37,7 @@ endif
 vmware_drv_la_SOURCES = \
 	bits2pixels.c \
 	bits2pixels.h \
+	compat-api.h \
 	guest_os.h \
 	includeCheck.h \
 	svga_escape.h \
diff --git a/src/compat-api.h b/src/compat-api.h
new file mode 100644
index 0000000..6bc946f
--- a/dev/null
+++ b/src/compat-api.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * 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.
+ *
+ * Author: Dave Airlie <airlied@redhat.com>
+ */
+
+/* this file provides API compat between server post 1.13 and pre it,
+   it should be reused inside as many drivers as possible */
+#ifndef COMPAT_API_H
+#define COMPAT_API_H
+
+#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
+#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
+#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
+#endif
+
+#ifndef XF86_HAS_SCRN_CONV
+#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
+#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
+#endif
+
+#ifndef XF86_SCRN_INTERFACE
+
+#define SCRN_ARG_TYPE int
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)]
+
+#define SCREEN_ARG_TYPE int
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
+
+#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
+
+#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS scrnIndex, pScreen
+
+#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
+#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0
+
+#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
+#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0
+
+#define FREE_SCREEN_ARGS_DECL int arg, int flags
+
+#define VT_FUNC_ARGS_DECL int arg, int flags
+#define VT_FUNC_ARGS pScrn->scrnIndex, 0
+
+#define XF86_SCRN_ARG(x) ((x)->scrnIndex)
+#else
+#define SCRN_ARG_TYPE ScrnInfoPtr
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1)
+
+#define SCREEN_ARG_TYPE ScreenPtr
+#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1)
+
+#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask
+#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask
+
+#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
+#define CLOSE_SCREEN_ARGS pScreen
+
+#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
+#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
+
+#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
+#define SWITCH_MODE_ARGS(arg, m) arg, m
+
+#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
+
+#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
+#define VT_FUNC_ARGS pScrn
+
+#define XF86_SCRN_ARG(x) (x)
+
+#endif
+
+#endif
diff --git a/src/vmware.c b/src/vmware.c
index e3892f1..41201f1 100644
--- a/src/vmware.c
+++ b/src/vmware.c
@@ -901,8 +901,8 @@ VMWAREModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool rebuildPixmap)
                                                          pScrn->pScreen->rootDepth),
                                            (pointer)(pVMWARE->FbBase + pScrn->fbOffset));
 
-        (*pScrn->EnableDisableFBAccess)(pScrn->pScreen->myNum, FALSE);
-        (*pScrn->EnableDisableFBAccess)(pScrn->pScreen->myNum, TRUE);
+        (*pScrn->EnableDisableFBAccess)(XF86_SCRN_ARG(pScrn), FALSE);
+        (*pScrn->EnableDisableFBAccess)(XF86_SCRN_ARG(pScrn), TRUE);
     }
 
     vgaHWProtect(pScrn, FALSE);
@@ -1018,7 +1018,7 @@ vmwareNextXineramaState(VMWAREPtr pVMWARE)
 }
 
 static void
-VMWAREAdjustFrame(int scrnIndex, int x, int y, int flags)
+VMWAREAdjustFrame(ADJUST_FRAME_ARGS_DECL)
 {
     /* FIXME */
 }
@@ -1089,9 +1089,9 @@ VMWAREStopFIFO(ScrnInfoPtr pScrn)
 }
 
 static Bool
-VMWARECloseScreen(int scrnIndex, ScreenPtr pScreen)
+VMWARECloseScreen(CLOSE_SCREEN_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
     ScreenPtr save = &pVMWARE->ScrnFuncs;
 
@@ -1119,7 +1119,7 @@ VMWARECloseScreen(int scrnIndex, ScreenPtr pScreen)
     pScrn->DriverFunc = NULL;
 #endif
 
-    return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+    return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
 }
 
 static Bool
@@ -1296,16 +1296,14 @@ vmwareIsRegionEqual(const RegionPtr reg1,
 }
 
 static Bool
-VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+VMWAREScreenInit(SCREEN_INIT_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn;
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     vgaHWPtr hwp;
     VMWAREPtr pVMWARE;
     OptionInfoPtr options;
     Bool useXinerama = TRUE;
 
-    /* Get the ScrnInfoRec */
-    pScrn = xf86Screens[pScreen->myNum];
     pVMWARE = VMWAREPTR(pScrn);
 
 
@@ -1381,7 +1379,7 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
     VMWAREModeInit(pScrn, pScrn->currentMode, FALSE);
 
     /* Set the viewport if supported */
-    VMWAREAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+    VMWAREAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
 
     /*
      * Setup the screen's visuals, and initialise the framebuffer
@@ -1582,10 +1580,9 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 }
 
 static Bool
-VMWARESwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
-
+VMWARESwitchMode(SWITCH_MODE_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     ScreenPtr pScreen = pScrn->pScreen;
 
     pScreen->mmWidth = (pScreen->width * VMWARE_INCHTOMM +
@@ -1597,9 +1594,9 @@ VMWARESwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
 }
 
 static Bool
-VMWAREEnterVT(int scrnIndex, int flags)
+VMWAREEnterVT(VT_FUNC_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
 
     /*
@@ -1616,9 +1613,9 @@ VMWAREEnterVT(int scrnIndex, int flags)
 }
 
 static void
-VMWARELeaveVT(int scrnIndex, int flags)
+VMWARELeaveVT(VT_FUNC_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
 
     /*
@@ -1631,17 +1628,18 @@ VMWARELeaveVT(int scrnIndex, int flags)
 }
 
 static void
-VMWAREFreeScreen(int scrnIndex, int flags)
+VMWAREFreeScreen(FREE_SCREEN_ARGS_DECL)
 {
+    SCRN_INFO_PTR(arg);
     /*
      * If the vgahw module is used vgaHWFreeHWRec() would be called
      * here.
      */
-   VMWAREFreeRec(xf86Screens[scrnIndex]);
+   VMWAREFreeRec(pScrn);
 }
 
 static ModeStatus
-VMWAREValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+VMWAREValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
 {
     return MODE_OK;
 }
diff --git a/src/vmware.h b/src/vmware.h
index 458390a..4818e16 100644
--- a/src/vmware.h
+++ b/src/vmware.h
@@ -177,7 +177,7 @@ typedef struct {
 #define VMWAREPTR(p) ((VMWAREPtr)((p)->driverPrivate))
 
 static __inline ScrnInfoPtr infoFromScreen(ScreenPtr s) {
-    return xf86Screens[s->myNum];
+    return xf86ScreenToScrn(s);
 }
 
 #define MIN(a,b) ((a)<(b)?(a):(b))
diff --git a/src/vmware_common.h b/src/vmware_common.h
index 9cd7194..5629c10 100644
--- a/src/vmware_common.h
+++ b/src/vmware_common.h
@@ -32,6 +32,8 @@
 #include <X11/extensions/panoramiXproto.h>
 #include <xf86.h>
 
+#include "compat-api.h"
+
 xXineramaScreenInfo *
 VMWAREParseTopologyString(ScrnInfoPtr pScrn,
                           const char *topology,
diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c
index 1b82ac4..7de0772 100644
--- a/vmwgfx/vmwgfx_dri2.c
+++ b/vmwgfx/vmwgfx_dri2.c
@@ -83,7 +83,7 @@ static Bool
 dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int format)
 {
     ScreenPtr pScreen = pDraw->pScreen;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
     BufferPrivatePtr private = buffer->driverPrivate;
     PixmapPtr pPixmap;
@@ -371,7 +371,7 @@ dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
 Bool
 xorg_dri2_init(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
     DRI2InfoRec dri2info;
     int major, minor;
diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
index ed1eb8c..9959ffb 100644
--- a/vmwgfx/vmwgfx_driver.c
+++ b/vmwgfx/vmwgfx_driver.c
@@ -107,14 +107,13 @@ typedef uint8_t uint8;
  */
 
 static Bool drv_pre_init(ScrnInfoPtr pScrn, int flags);
-static Bool drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc,
-			    char **argv);
-static Bool drv_switch_mode(int scrnIndex, DisplayModePtr mode, int flags);
-static void drv_adjust_frame(int scrnIndex, int x, int y, int flags);
-static Bool drv_enter_vt(int scrnIndex, int flags);
-static void drv_leave_vt(int scrnIndex, int flags);
-static void drv_free_screen(int scrnIndex, int flags);
-static ModeStatus drv_valid_mode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+static Bool drv_screen_init(SCREEN_INIT_ARGS_DECL);
+static Bool drv_switch_mode(SWITCH_MODE_ARGS_DECL);
+static void drv_adjust_frame(ADJUST_FRAME_ARGS_DECL);
+static Bool drv_enter_vt(VT_FUNC_ARGS_DECL);
+static void drv_leave_vt(VT_FUNC_ARGS_DECL);
+static void drv_free_screen(FREE_SCREEN_ARGS_DECL);
+static ModeStatus drv_valid_mode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose,
 			         int flags);
 
 extern void xorg_tracker_set_functions(ScrnInfoPtr scrn);
@@ -133,7 +132,7 @@ vmwgfx_hookup(ScrnInfoPtr pScrn)
  * Internal function definitions
  */
 
-static Bool drv_close_screen(int scrnIndex, ScreenPtr pScreen);
+static Bool drv_close_screen(CLOSE_SCREEN_ARGS_DECL);
 
 /*
  * Internal functions
@@ -633,7 +632,7 @@ vmwgfx_scanout_present(ScreenPtr pScreen, int drm_fd,
 
 void xorg_flush(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     PixmapPtr pixmap = NULL;
@@ -708,14 +707,13 @@ void xorg_flush(ScreenPtr pScreen)
     free(pixmaps);
 }
 
-static void drv_block_handler(int i, pointer blockData, pointer pTimeout,
-                              pointer pReadmask)
+static void drv_block_handler(BLOCKHANDLER_ARGS_DECL)
 {
-    ScreenPtr pScreen = screenInfo.screens[i];
-    modesettingPtr ms = modesettingPTR(xf86Screens[pScreen->myNum]);
+    SCREEN_PTR(arg);
+    modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(pScreen));
 
     vmwgfx_swap(ms, pScreen, BlockHandler);
-    pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
+    pScreen->BlockHandler(BLOCKHANDLER_ARGS);
     vmwgfx_swap(ms, pScreen, BlockHandler);
 
     vmwgfx_flush_dri2(pScreen);
@@ -725,7 +723,7 @@ static void drv_block_handler(int i, pointer blockData, pointer pTimeout,
 static Bool
 drv_create_screen_resources(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
     Bool ret;
 
@@ -735,9 +733,9 @@ drv_create_screen_resources(ScreenPtr pScreen)
     if (!ret)
 	return ret;
 
-    drv_adjust_frame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+    drv_adjust_frame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
 
-    return drv_enter_vt(pScreen->myNum, 1);
+    return drv_enter_vt(VT_FUNC_ARGS);
 }
 
 static Bool
@@ -773,7 +771,7 @@ drv_set_master(ScrnInfoPtr pScrn)
 static Bool
 vmwgfx_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
 {
-    ScrnInfoPtr pScrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
     modesettingPtr ms = modesettingPTR(pScrn);
@@ -804,7 +802,7 @@ vmwgfx_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
 static Bool
 vmwgfx_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
 {
-    ScrnInfoPtr pScrn = xf86Screens[screen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
     modesettingPtr ms = modesettingPTR(pScrn);
@@ -902,9 +900,9 @@ static void drv_load_palette(ScrnInfoPtr pScrn, int numColors,
 
 
 static Bool
-drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+drv_screen_init(SCREEN_INIT_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
     VisualPtr visual;
 
@@ -1088,9 +1086,9 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 }
 
 static void
-drv_adjust_frame(int scrnIndex, int x, int y, int flags)
+drv_adjust_frame(ADJUST_FRAME_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
     xf86OutputPtr output = config->output[config->compat_output];
     xf86CrtcPtr crtc = output->crtc;
@@ -1104,15 +1102,16 @@ drv_adjust_frame(int scrnIndex, int x, int y, int flags)
 }
 
 static void
-drv_free_screen(int scrnIndex, int flags)
+drv_free_screen(FREE_SCREEN_ARGS_DECL)
 {
-    drv_free_rec(xf86Screens[scrnIndex]);
+    SCRN_INFO_PTR(arg);
+    drv_free_rec(pScrn);
 }
 
 static void
-drv_leave_vt(int scrnIndex, int flags)
+drv_leave_vt(VT_FUNC_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
     modesettingPtr ms = modesettingPTR(pScrn);
 
     vmwgfx_cursor_bypass(ms->fd, 0, 0);
@@ -1130,9 +1129,9 @@ drv_leave_vt(int scrnIndex, int flags)
  * This gets called when gaining control of the VT, and from ScreenInit().
  */
 static Bool
-drv_enter_vt(int scrnIndex, int flags)
+drv_enter_vt(VT_FUNC_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
 
     if (!drv_set_master(pScrn))
 	return FALSE;
@@ -1144,17 +1143,17 @@ drv_enter_vt(int scrnIndex, int flags)
 }
 
 static Bool
-drv_switch_mode(int scrnIndex, DisplayModePtr mode, int flags)
+drv_switch_mode(SWITCH_MODE_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    SCRN_INFO_PTR(arg);
 
     return xf86SetSingleMode(pScrn, mode, RR_Rotate_0);
 }
 
 static Bool
-drv_close_screen(int scrnIndex, ScreenPtr pScreen)
+drv_close_screen(CLOSE_SCREEN_ARGS_DECL)
 {
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
 
     if (ms->cursor) {
@@ -1166,7 +1165,7 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
 	xorg_dri2_close(pScreen);
 
     if (pScrn->vtSema)
-	pScrn->LeaveVT(scrnIndex, 0);
+        pScrn->LeaveVT(VT_FUNC_ARGS);
 
     pScrn->vtSema = FALSE;
 
@@ -1180,11 +1179,11 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
     if (ms->xat)
 	xa_tracker_destroy(ms->xat);
 
-    return (*pScreen->CloseScreen) (scrnIndex, pScreen);
+    return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS);
 }
 
 static ModeStatus
-drv_valid_mode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+drv_valid_mode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
 {
     return MODE_OK;
 }
diff --git a/vmwgfx/vmwgfx_driver.h b/vmwgfx/vmwgfx_driver.h
index 4fcfed6..f78a85f 100644
--- a/vmwgfx/vmwgfx_driver.h
+++ b/vmwgfx/vmwgfx_driver.h
@@ -46,6 +46,7 @@
 #include <xa_tracker.h>
 #include <xf86Module.h>
 
+#include "../src/compat-api.h"
 #ifdef DRI2
 #include <dri2.h>
 #if (!defined(DRI2INFOREC_VERSION) || (DRI2INFOREC_VERSION < 3))
@@ -118,9 +119,9 @@ typedef struct _modesettingRec
     ScreenBlockHandlerProcPtr saved_BlockHandler;
     CreateScreenResourcesProcPtr saved_CreateScreenResources;
     CloseScreenProcPtr saved_CloseScreen;
-    Bool (*saved_EnterVT)(int, int);
-    void (*saved_LeaveVT)(int, int);
-    void (*saved_AdjustFrame)(int, int, int, int);
+    Bool (*saved_EnterVT)(VT_FUNC_ARGS_DECL);
+    void (*saved_LeaveVT)(VT_FUNC_ARGS_DECL);
+    void (*saved_AdjustFrame)(ADJUST_FRAME_ARGS_DECL);
     Bool (*saved_UseHWCursor)(ScreenPtr, CursorPtr);
     Bool (*saved_UseHWCursorARGB)(ScreenPtr, CursorPtr);
 
diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
index 469598a..63df3a1 100644
--- a/vmwgfx/vmwgfx_saa.c
+++ b/vmwgfx/vmwgfx_saa.c
@@ -460,7 +460,7 @@ vmwgfx_flush_dri2(ScreenPtr pScreen)
     struct vmwgfx_saa *vsaa =
 	to_vmwgfx_saa(saa_get_driver(pScreen));
     struct _WsbmListHead *list, *next;
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 
     if (!pScrn->vtSema)
 	return;
@@ -1199,7 +1199,7 @@ vmwgfx_operation_complete(struct saa_driver *driver,
     struct vmwgfx_saa *vsaa = to_vmwgfx_saa(driver);
     struct saa_pixmap *spix = saa_get_saa_pixmap(pixmap);
     struct vmwgfx_saa_pixmap *vpix = to_vmwgfx_saa_pixmap(spix);
-    ScrnInfoPtr pScrn = xf86Screens[vsaa->pScreen->myNum];
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(vsaa->pScreen);
 
     /*
      * Make dri2 drawables up to date, or add them to the flush list
diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c
index af53379..449266b 100644
--- a/vmwgfx/vmwgfx_tex_video.c
+++ b/vmwgfx/vmwgfx_tex_video.c
@@ -638,7 +638,7 @@ put_image(ScrnInfoPtr pScrn,
           DrawablePtr pDraw)
 {
    struct xorg_xv_port_priv *pPriv = (struct xorg_xv_port_priv *) data;
-   ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+   ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
    PixmapPtr pPixmap;
    INT32 x1, x2, y1, y2;
    BoxRec dstBox;
@@ -732,7 +732,7 @@ vmwgfx_free_textured_adaptor(XF86VideoAdaptorPtr adaptor, Bool free_ports)
 static XF86VideoAdaptorPtr
 xorg_setup_textured_adapter(ScreenPtr pScreen)
 {
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+   ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
    modesettingPtr ms = modesettingPTR(pScrn);
    XF86VideoAdaptorPtr adapt;
    XF86AttributePtr attrs;
@@ -799,7 +799,7 @@ xorg_setup_textured_adapter(ScreenPtr pScreen)
 void
 xorg_xv_init(ScreenPtr pScreen)
 {
-   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+   ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
    modesettingPtr ms = modesettingPTR(pScrn);
    XF86VideoAdaptorPtr *adaptors, *new_adaptors = NULL;
    XF86VideoAdaptorPtr textured_adapter = NULL, overlay_adaptor = NULL;
--
cgit v0.9.0.2-2-gbebe
From 50c01998c7800bc02fd6656cc14efa715bf63e08 Mon Sep 17 00:00:00 2001
From: Robert Hooker <sarvatt@ubuntu.com>
Date: Fri, 15 Jun 2012 15:56:59 +0000
Subject: vmware: Fix up some warnings after new compat API change.

Fixes multiple instances of these warnings on x86_64:
../../src/vmware.h:180:5: warning: implicit declaration of function 'xf86ScreenToScrn' [-Wimplicit-function-declaration]
../../src/vmware.h:180:5: warning: nested extern declaration of 'xf86ScreenToScrn' [-Wnested-externs]
../../src/vmware.h:180:5: warning: return makes pointer from integer without a cast [enabled by default]
Function `xf86ScreenToScrn' implicitly converted to pointer at ../../src/vmware.h:180

Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
Signed-off-by: Robert Hooker <sarvatt@ubuntu.com>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
---
diff --git a/src/vmware.h b/src/vmware.h
index 4818e16..be113bb 100644
--- a/src/vmware.h
+++ b/src/vmware.h
@@ -18,6 +18,7 @@
 #include "xf86.h"
 #include "xf86_OSproc.h"
 
+#include "compat-api.h"
 
 #include <X11/extensions/panoramiXproto.h>
 
--
cgit v0.9.0.2-2-gbebe
From 46c0862d205eefa985e36a74391ca392640cb898 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Sat, 16 Jun 2012 13:43:52 +0000
Subject: vmware: drop infoFromScreen inline in favour of new interface

This also should fix the build regression introduced with the fix
for this macro.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
diff --git a/src/vmware.h b/src/vmware.h
index be113bb..028dff3 100644
--- a/src/vmware.h
+++ b/src/vmware.h
@@ -18,8 +18,6 @@
 #include "xf86.h"
 #include "xf86_OSproc.h"
 
-#include "compat-api.h"
-
 #include <X11/extensions/panoramiXproto.h>
 
 #ifdef XSERVER_LIBPCIACCESS
@@ -177,10 +175,6 @@ typedef struct {
 
 #define VMWAREPTR(p) ((VMWAREPtr)((p)->driverPrivate))
 
-static __inline ScrnInfoPtr infoFromScreen(ScreenPtr s) {
-    return xf86ScreenToScrn(s);
-}
-
 #define MIN(a,b) ((a)<(b)?(a):(b))
 #define MAX(a,b) ((a)>(b)?(a):(b))
 #define ABS(x) (((x) >= 0) ? (x) : -(x))
diff --git a/src/vmwarecurs.c b/src/vmwarecurs.c
index 2e2effb..93dacc0 100644
--- a/src/vmwarecurs.c
+++ b/src/vmwarecurs.c
@@ -12,6 +12,7 @@ char rcsId_vmwarecurs[] =
 #endif
 
 #include "vmware.h"
+#include "vmware_common.h"
 #include "bits2pixels.h"
 
 static void VMWAREGetImage(DrawablePtr src, int x, int y, int w, int h,
@@ -110,7 +111,7 @@ vmwareSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
 static Bool
 vmwareUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
 {
-    ScrnInfoPtr pScrn = infoFromScreen(pScreen);
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
     VmwareLog(("UseHWCursor new cursor %p refcnt %i old cursor %p refcnt %i\n",
               pCurs, pCurs->refcnt, pVMWARE->oldCurs, pVMWARE->oldCurs ? pVMWARE->oldCurs->refcnt : 0));
@@ -145,7 +146,7 @@ vmwareLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src )
 static Bool
 vmwareUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs)
 {
-    ScrnInfoPtr pScrn = infoFromScreen(pScreen);
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
     VmwareLog(("UseHWCursorARGB new cursor %p refcnt %i old cursor %p refcnt %i\n",
               pCurs, pCurs->refcnt, pVMWARE->oldCurs, pVMWARE->oldCurs ? pVMWARE->oldCurs->refcnt : 0));
@@ -283,7 +284,7 @@ Bool
 vmwareCursorInit(ScreenPtr pScreen)
 {
     xf86CursorInfoPtr infoPtr;
-    VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pScreen));
+    VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(pScreen));
     Bool ret;
 
     TRACEPOINT
@@ -330,7 +331,7 @@ vmwareCursorInit(ScreenPtr pScreen)
 void
 vmwareCursorCloseScreen(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = infoFromScreen(pScreen);
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
 #ifdef RENDER
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
@@ -356,7 +357,7 @@ vmwareCursorCloseScreen(ScreenPtr pScreen)
 void
 vmwareCursorHookWrappers(ScreenPtr pScreen)
 {
-    VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pScreen));
+    VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(pScreen));
 #ifdef RENDER
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
 #endif
@@ -382,7 +383,7 @@ VMWAREGetImage(DrawablePtr src, int x, int y, int w, int h,
                unsigned int format, unsigned long planeMask, char *pBinImage)
 {
     ScreenPtr pScreen = src->pScreen;
-    VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(src->pScreen));
+    VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(src->pScreen));
     BoxRec box;
     Bool hidden = FALSE;
     
@@ -412,7 +413,7 @@ static void
 VMWARECopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 {
     ScreenPtr pScreen = pWin->drawable.pScreen;
-    VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pWin->drawable.pScreen));
+    VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(pWin->drawable.pScreen));
     BoxPtr pBB;
     Bool hidden = FALSE;
     
@@ -448,7 +449,7 @@ VMWAREComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
 		CARD16 width, CARD16 height)
 {
     ScreenPtr pScreen = pDst->pDrawable->pScreen;
-    VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pScreen));
+    VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(pScreen));
     PictureScreenPtr ps = GetPictureScreen(pScreen);
     BoxRec box;
     Bool hidden = FALSE;
diff --git a/src/vmwarevideo.c b/src/vmwarevideo.c
index 71f21fe..745c71f 100644
--- a/src/vmwarevideo.c
+++ b/src/vmwarevideo.c
@@ -39,6 +39,7 @@
 #endif
 
 #include "vmware.h"
+#include "vmware_common.h"
 #include "xf86xv.h"
 #include "fourcc.h"
 #include "svga_escape.h"
@@ -435,7 +436,7 @@ vmwareVideoEnabled(VMWAREPtr pVMWARE)
 Bool
 vmwareVideoInit(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = infoFromScreen(pScreen);
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL;
     XF86VideoAdaptorPtr newAdaptor = NULL;
     int numAdaptors;
@@ -504,7 +505,7 @@ vmwareVideoInit(ScreenPtr pScreen)
 void
 vmwareVideoEnd(ScreenPtr pScreen)
 {
-    ScrnInfoPtr pScrn = infoFromScreen(pScreen);
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
     VMWAREVideoPtr pVid;
     int i;
--
cgit v0.9.0.2-2-gbebe
From e5ac80d8f72963313358e31cfb1ab98583e26f23 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Tue, 03 Jul 2012 12:50:30 +0000
Subject: vmware: avoid warnings about shadowing 'i'

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
diff --git a/src/compat-api.h b/src/compat-api.h
index 6bc946f..205ac59 100644
--- a/src/compat-api.h
+++ b/src/compat-api.h
@@ -46,7 +46,7 @@
 #define SCREEN_ARG_TYPE int
 #define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
 
-#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv
+#define SCREEN_INIT_ARGS_DECL int scrnIndex, ScreenPtr pScreen, int argc, char **argv
 
 #define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
 #define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
--
cgit v0.9.0.2-2-gbebe
From 007bed30270ca9548dfe6e359972b56cbb8e2f13 Mon Sep 17 00:00:00 2001
From: Jakob Bornecrantz <jakob@vmware.com>
Date: Tue, 29 May 2012 21:01:14 +0000
Subject: vmwgfx: Guard against null rotate pixmap in shadow destroy

Reviewed-by: Thomas Hellström <thellstrom@vmware.com>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
---
diff --git a/vmwgfx/vmwgfx_crtc.c b/vmwgfx/vmwgfx_crtc.c
index eaf87b2..fec04c0 100644
--- a/vmwgfx/vmwgfx_crtc.c
+++ b/vmwgfx/vmwgfx_crtc.c
@@ -250,8 +250,12 @@ crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 static void
 crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
 {
-    ScreenPtr pScreen = rotate_pixmap->drawable.pScreen;
+    ScreenPtr pScreen;
 
+    if (rotate_pixmap == NULL)
+        return;
+
+    pScreen = rotate_pixmap->drawable.pScreen;
     pScreen->DestroyPixmap(rotate_pixmap);
 }
 
--
cgit v0.9.0.2-2-gbebe