]> git.pld-linux.org Git - packages/xorg-driver-video-vmware.git/blob - git.patch
- added updates from upstream git
[packages/xorg-driver-video-vmware.git] / git.patch
1 diff --git a/configure.ac b/configure.ac
2 index 0631bcc..123356c 100644
3 --- a/configure.ac
4 +++ b/configure.ac
5 @@ -118,7 +118,15 @@ if test x$BUILD_VMWGFX = xyes; then
6         PKG_CHECK_MODULES([LIBDRM], [libdrm],[],[BUILD_VMWGFX=no])
7  fi
8  if test x$BUILD_VMWGFX = xyes; then
9 -       PKG_CHECK_MODULES([XATRACKER], [xatracker >= 0.4.0],[],[BUILD_VMWGFX=no])
10 +#
11 +# Early versions of mesa 10 forgot to bump the XA major version number in
12 +# the xa_tracker.h header
13 +#
14 +       PKG_CHECK_MODULES([XATRACKER], [xatracker >= 0.4.0],
15 +                         [PKG_CHECK_EXISTS([xatracker = 2.0.0],
16 +                         [AC_DEFINE([HAVE_XA_2], 1,
17 +                                 [Has version 2 of XA])])],
18 +                         [],[BUILD_VMWGFX=no])
19  fi
20  
21  DRIVER_NAME=vmware
22 diff --git a/src/vmware_bootstrap.c b/src/vmware_bootstrap.c
23 index ea5be19..bb58325 100644
24 --- a/src/vmware_bootstrap.c
25 +++ b/src/vmware_bootstrap.c
26 @@ -256,7 +256,6 @@ VMwarePciProbe (DriverPtr           drv,
27                  intptr_t            match_data)
28  {
29      ScrnInfoPtr     scrn = NULL;
30 -    EntityInfoPtr   entity;
31  
32      scrn = xf86ConfigPciEntity(scrn, 0, entity_num, VMWAREPciChipsets,
33                                 NULL, NULL, NULL, NULL, NULL);
34 @@ -267,7 +266,6 @@ VMwarePciProbe (DriverPtr           drv,
35          scrn->Probe = NULL;
36      }
37  
38 -    entity = xf86GetEntityInfo(entity_num);
39      switch (DEVICE_ID(device)) {
40      case PCI_DEVICE_ID_VMWARE_SVGA2:
41      case PCI_DEVICE_ID_VMWARE_SVGA:
42 diff --git a/src/vmwarevideo.c b/src/vmwarevideo.c
43 index 745c71f..8d7d171 100644
44 --- a/src/vmwarevideo.c
45 +++ b/src/vmwarevideo.c
46 @@ -82,7 +82,7 @@
47  #define VMWARE_VID_MAX_HEIGHT   2048
48  
49  #define VMWARE_VID_NUM_ENCODINGS 1
50 -static XF86VideoEncodingRec vmwareVideoEncodings[] =
51 +static const XF86VideoEncodingRec vmwareVideoEncodings[] =
52  {
53      {
54         0,
55 @@ -108,7 +108,7 @@ static XF86ImageRec vmwareVideoImages[] =
56  };
57  
58  #define VMWARE_VID_NUM_ATTRIBUTES 2
59 -static XF86AttributeRec vmwareVideoAttributes[] =
60 +static const XF86AttributeRec vmwareVideoAttributes[] =
61  {
62      {
63          XvGettable | XvSettable,
64 diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c
65 index 7de0772..4c74a6b 100644
66 --- a/vmwgfx/vmwgfx_dri2.c
67 +++ b/vmwgfx/vmwgfx_dri2.c
68 @@ -138,6 +138,8 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for
69        return TRUE;
70      case DRI2BufferStencil:
71      case DRI2BufferDepthStencil:
72 +       if (!pScrn->vtSema)
73 +           return FALSE;
74  
75         depth = (format) ? vmwgfx_zs_format_to_depth(format) : 32;
76  
77 @@ -155,6 +157,9 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for
78  
79         break;
80      case DRI2BufferDepth:
81 +       if (!pScrn->vtSema)
82 +           return FALSE;
83 +
84         depth = (format) ? vmwgfx_z_format_to_depth(format) :
85             pDraw->bitsPerPixel;
86  
87 @@ -201,7 +206,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for
88      }
89  
90      private->srf = srf;
91 -    if (xa_surface_handle(srf, &buffer->name, &buffer->pitch) != 0)
92 +    if (_xa_surface_handle(srf, &buffer->name, &buffer->pitch) != 0)
93         return FALSE;
94  
95      buffer->cpp = xa_format_depth(xa_surface_format(srf)) / 8;
96 @@ -290,6 +295,14 @@ dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
97      DrawablePtr dst_draw;
98      RegionPtr myClip;
99      GCPtr gc;
100 +    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
101 +
102 +    /*
103 +     * This is a fragile protection against HW operations when not master.
104 +     * Needs to be blocked higher up in the dri2 code.
105 +     */
106 +    if (!pScrn->vtSema)
107 +       return;
108  
109      /*
110       * In driCreateBuffers we dewrap windows into the
111 diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
112 index 7863ba2..4e28097 100644
113 --- a/vmwgfx/vmwgfx_driver.c
114 +++ b/vmwgfx/vmwgfx_driver.c
115 @@ -79,7 +79,7 @@ typedef uint8_t uint8;
116  
117  #define XA_VERSION_MINOR_REQUIRED 0
118  #define XA_VERSION_MAJOR_REQUIRED 1
119 -#define XA_VERSION_MAJOR_COMPAT 1
120 +#define XA_VERSION_MAJOR_COMPAT 2
121  
122  #define DRM_VERSION_MAJOR_REQUIRED 2
123  #define DRM_VERSION_MINOR_REQUIRED 3
124 @@ -617,7 +617,7 @@ vmwgfx_scanout_present(ScreenPtr pScreen, int drm_fd,
125         return FALSE;
126      }
127  
128 -    if (xa_surface_handle(vpix->hw, &handle, &dummy) != 0) {
129 +    if (_xa_surface_handle(vpix->hw, &handle, &dummy) != 0) {
130         LogMessage(X_ERROR, "Could not get present surface handle.\n");
131         return FALSE;
132      }
133 @@ -657,7 +657,6 @@ void xorg_flush(ScreenPtr pScreen)
134         if (crtc->enabled) {
135             pixmap = crtc_get_scanout(crtc);
136             if (pixmap) {
137 -               unsigned int j;
138  
139                 /*
140                  * Remove duplicates.
141 @@ -1115,6 +1114,7 @@ drv_leave_vt(VT_FUNC_ARGS_DECL)
142  
143      vmwgfx_cursor_bypass(ms->fd, 0, 0);
144      vmwgfx_disable_scanout(pScrn);
145 +    vmwgfx_saa_drop_master(pScrn->pScreen);
146  
147      if (drmDropMaster(ms->fd))
148         xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
149 @@ -1135,6 +1135,8 @@ drv_enter_vt(VT_FUNC_ARGS_DECL)
150      if (!drv_set_master(pScrn))
151         return FALSE;
152  
153 +    vmwgfx_saa_set_master(pScrn->pScreen);
154 +
155      if (!xf86SetDesiredModes(pScrn))
156         return FALSE;
157  
158 diff --git a/vmwgfx/vmwgfx_output.c b/vmwgfx/vmwgfx_output.c
159 index 4f52f1d..f9e4263 100644
160 --- a/vmwgfx/vmwgfx_output.c
161 +++ b/vmwgfx/vmwgfx_output.c
162 @@ -60,7 +60,7 @@ struct output_private
163      Bool is_implicit;
164  };
165  
166 -static char *output_enum_list[] = {
167 +static const char *output_enum_list[] = {
168      "Unknown",
169      "VGA",
170      "DVI",
171 diff --git a/vmwgfx/vmwgfx_overlay.c b/vmwgfx/vmwgfx_overlay.c
172 index 6624a10..986dd06 100644
173 --- a/vmwgfx/vmwgfx_overlay.c
174 +++ b/vmwgfx/vmwgfx_overlay.c
175 @@ -84,7 +84,7 @@ typedef uint8_t uint8;
176  #define VMWARE_VID_MAX_HEIGHT   2048
177  
178  #define VMWARE_VID_NUM_ENCODINGS 1
179 -static XF86VideoEncodingRec vmwareVideoEncodings[] =
180 +static const XF86VideoEncodingRec vmwareVideoEncodings[] =
181  {
182      {
183         0,
184 @@ -110,7 +110,7 @@ static XF86ImageRec vmwareVideoImages[] =
185  };
186  
187  #define VMWARE_VID_NUM_ATTRIBUTES 2
188 -static XF86AttributeRec vmwareVideoAttributes[] =
189 +static const XF86AttributeRec vmwareVideoAttributes[] =
190  {
191      {
192          XvGettable | XvSettable,
193 diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
194 index 63df3a1..e76bd09 100644
195 --- a/vmwgfx/vmwgfx_saa.c
196 +++ b/vmwgfx/vmwgfx_saa.c
197 @@ -26,6 +26,7 @@
198   */
199  
200  #include <xorg-server.h>
201 +#include <xorgVersion.h>
202  #include <mi.h>
203  #include <fb.h>
204  #include <xf86drmMode.h>
205 @@ -76,7 +77,12 @@ vmwgfx_pixmap_remove_damage(PixmapPtr pixmap)
206      if (!spix->damage || vpix->hw || vpix->gmr || vpix->malloc)
207         return;
208  
209 +#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,14,99,2,0)
210 +    DamageUnregister(spix->damage);
211 +#else
212      DamageUnregister(&pixmap->drawable, spix->damage);
213 +#endif
214 +
215      DamageDestroy(spix->damage);
216      spix->damage = NULL;
217  }
218 @@ -286,7 +292,7 @@ vmwgfx_saa_dma(struct vmwgfx_saa *vsaa,
219      if (vpix->gmr && vsaa->can_optimize_dma) {
220         uint32_t handle, dummy;
221  
222 -       if (xa_surface_handle(vpix->hw, &handle, &dummy) != 0)
223 +       if (_xa_surface_handle(vpix->hw, &handle, &dummy) != 0)
224             goto out_err;
225         if (vmwgfx_dma(0, 0, reg, vpix->gmr, pixmap->devKind, handle,
226                        to_hw) != 0)
227 @@ -305,6 +311,8 @@ vmwgfx_saa_dma(struct vmwgfx_saa *vsaa,
228                              (int) to_hw,
229                              (struct xa_box *) REGION_RECTS(reg),
230                              REGION_NUM_RECTS(reg));
231 +       if (to_hw)
232 +           xa_context_flush(vsaa->xa_ctx);
233         if (vpix->gmr)
234             vmwgfx_dmabuf_unmap(vpix->gmr);
235         if (ret)
236 @@ -420,6 +428,7 @@ vmwgfx_create_pixmap(struct saa_driver *driver, struct saa_pixmap *spix,
237  
238      WSBMINITLISTHEAD(&vpix->sync_x_head);
239      WSBMINITLISTHEAD(&vpix->scanout_list);
240 +    WSBMINITLISTHEAD(&vpix->pixmap_list);
241  
242      return TRUE;
243  }
244 @@ -496,6 +505,7 @@ vmwgfx_destroy_pixmap(struct saa_driver *driver, PixmapPtr pixmap)
245       */
246  
247      vmwgfx_pixmap_remove_present(vpix);
248 +    WSBMLISTDELINIT(&vpix->pixmap_list);
249      WSBMLISTDELINIT(&vpix->sync_x_head);
250  
251      if (vpix->hw_is_dri2_fronts)
252 @@ -624,6 +634,8 @@ vmwgfx_modify_pixmap_header (PixmapPtr pixmap, int w, int h, int depth,
253                              int bpp, int devkind, void *pixdata)
254  {
255      struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(pixmap);
256 +    ScreenPtr pScreen = pixmap->drawable.pScreen;
257 +    struct vmwgfx_saa *vsaa = to_vmwgfx_saa(saa_get_driver(pScreen));
258      unsigned int old_height;
259      unsigned int old_width;
260      unsigned int old_pitch;
261 @@ -667,6 +679,8 @@ vmwgfx_modify_pixmap_header (PixmapPtr pixmap, int w, int h, int depth,
262  
263      vmwgfx_pix_resize(pixmap, old_pitch, old_height, old_width);
264      vmwgfx_pixmap_free_storage(vpix);
265 +    WSBMLISTADDTAIL(&vpix->pixmap_list, &vsaa->pixmaps);
266 +
267      return TRUE;
268  
269    out_no_modify:
270 @@ -683,7 +697,7 @@ vmwgfx_present_prepare(struct vmwgfx_saa *vsaa,
271  
272      (void) pScreen;
273      if (src_vpix == dst_vpix || !src_vpix->hw ||
274 -       xa_surface_handle(src_vpix->hw, &vsaa->src_handle, &dummy) != 0)
275 +       _xa_surface_handle(src_vpix->hw, &vsaa->src_handle, &dummy) != 0)
276         return FALSE;
277  
278      REGION_NULL(pScreen, &vsaa->present_region);
279 @@ -856,7 +870,7 @@ vmwgfx_copy_prepare(struct saa_driver *driver,
280      Bool has_valid_hw;
281  
282      if (!vsaa->xat || !SAA_PM_IS_SOLID(&dst_pixmap->drawable, plane_mask) ||
283 -       alu != GXcopy)
284 +       alu != GXcopy || !vsaa->is_master)
285         return FALSE;
286  
287      src_vpix = vmwgfx_saa_pixmap(src_pixmap);
288 @@ -929,6 +943,7 @@ vmwgfx_copy_prepare(struct saa_driver *driver,
289  
290         if (!vmwgfx_hw_validate(src_pixmap, src_reg)) {
291             xa_copy_done(vsaa->xa_ctx);
292 +           xa_context_flush(vsaa->xa_ctx);
293             return FALSE;
294         }
295  
296 @@ -1029,6 +1044,7 @@ vmwgfx_copy_done(struct saa_driver *driver)
297         return;
298      }
299      xa_copy_done(vsaa->xa_ctx);
300 +    xa_context_flush(vsaa->xa_ctx);
301  }
302  
303  static Bool
304 @@ -1051,6 +1067,9 @@ vmwgfx_composite_prepare(struct saa_driver *driver, CARD8 op,
305      RegionRec empty;
306      struct xa_composite *xa_comp;
307  
308 +    if (!vsaa->is_master)
309 +       return FALSE;
310 +
311      REGION_NULL(pScreen, &empty);
312  
313      /*
314 @@ -1175,6 +1194,7 @@ vmwgfx_composite_done(struct saa_driver *driver)
315     struct vmwgfx_saa *vsaa = to_vmwgfx_saa(driver);
316  
317     xa_composite_done(vsaa->xa_ctx);
318 +   xa_context_flush(vsaa->xa_ctx);
319  }
320  
321  static void
322 @@ -1209,7 +1229,7 @@ vmwgfx_operation_complete(struct saa_driver *driver,
323       */
324  
325      if (vpix->hw && vpix->hw_is_dri2_fronts) {
326 -       if (1 && pScrn->vtSema &&
327 +       if (pScrn->vtSema &&
328             vmwgfx_upload_to_hw(driver, pixmap, &spix->dirty_shadow)) {
329  
330             REGION_EMPTY(vsaa->pScreen, &spix->dirty_shadow);
331 @@ -1360,7 +1380,9 @@ vmwgfx_saa_init(ScreenPtr pScreen, int drm_fd, struct xa_tracker *xat,
332      vsaa->use_present_opt = direct_presents;
333      vsaa->only_hw_presents = only_hw_presents;
334      vsaa->rendercheck = rendercheck;
335 +    vsaa->is_master = TRUE;
336      WSBMINITLISTHEAD(&vsaa->sync_x_list);
337 +    WSBMINITLISTHEAD(&vsaa->pixmaps);
338  
339      vsaa->driver = vmwgfx_saa_driver;
340      vsaa->vcomp = vmwgfx_alloc_composite();
341 @@ -1436,7 +1458,7 @@ vmwgfx_scanout_ref(struct vmwgfx_screen_entry  *entry)
342              */
343             if (!vmwgfx_hw_accel_validate(pixmap, 0, XA_FLAG_SCANOUT, 0, NULL))
344                 goto out_err;
345 -           if (xa_surface_handle(vpix->hw, &handle, &dummy) != 0)
346 +           if (_xa_surface_handle(vpix->hw, &handle, &dummy) != 0)
347                 goto out_err;
348             depth = xa_format_depth(xa_surface_format(vpix->hw));
349  
350 @@ -1510,3 +1532,34 @@ vmwgfx_scanout_unref(struct vmwgfx_screen_entry *entry)
351      entry->pixmap = NULL;
352      pixmap->drawable.pScreen->DestroyPixmap(pixmap);
353  }
354 +
355 +void
356 +vmwgfx_saa_set_master(ScreenPtr pScreen)
357 +{
358 +    struct vmwgfx_saa *vsaa = to_vmwgfx_saa(saa_get_driver(pScreen));
359 +
360 +    vsaa->is_master = TRUE;
361 +}
362 +
363 +void
364 +vmwgfx_saa_drop_master(ScreenPtr pScreen)
365 +{
366 +    struct vmwgfx_saa *vsaa = to_vmwgfx_saa(saa_get_driver(pScreen));
367 +    struct _WsbmListHead *list;
368 +    struct vmwgfx_saa_pixmap *vpix;
369 +    struct saa_pixmap *spix;
370 +
371 +    WSBMLISTFOREACH(list, &vsaa->pixmaps) {
372 +       vpix = WSBMLISTENTRY(list, struct vmwgfx_saa_pixmap, pixmap_list);
373 +       spix = &vpix->base;
374 +
375 +       if (!vpix->hw)
376 +           continue;
377 +
378 +       (void) vmwgfx_download_from_hw(&vsaa->driver, spix->pixmap,
379 +                                      &spix->dirty_hw);
380 +       REGION_EMPTY(draw->pScreen, &spix->dirty_hw);
381 +    }
382 +
383 +    vsaa->is_master = FALSE;
384 +}
385 diff --git a/vmwgfx/vmwgfx_saa.h b/vmwgfx/vmwgfx_saa.h
386 index bb8ec96..5e1f40c 100644
387 --- a/vmwgfx/vmwgfx_saa.h
388 +++ b/vmwgfx/vmwgfx_saa.h
389 @@ -54,6 +54,7 @@ struct vmwgfx_saa_pixmap {
390      int hw_is_dri2_fronts;
391      struct _WsbmListHead sync_x_head;
392      struct _WsbmListHead scanout_list;
393 +    struct _WsbmListHead pixmap_list;
394  
395      uint32_t xa_flags;
396      uint32_t staging_add_flags;
397 @@ -107,4 +108,23 @@ Bool
398  vmwgfx_hw_accel_validate(PixmapPtr pixmap, unsigned int depth,
399                          uint32_t add_flags, uint32_t remove_flags,
400                          RegionPtr region);
401 +
402 +void
403 +vmwgfx_saa_set_master(ScreenPtr pScreen);
404 +
405 +void
406 +vmwgfx_saa_drop_master(ScreenPtr pScreen);
407 +
408 +#if (XA_TRACKER_VERSION_MAJOR <= 1) && !defined(HAVE_XA_2)
409 +
410 +#define _xa_surface_handle(_a, _b, _c) xa_surface_handle(_a, _b, _c)
411 +#define xa_context_flush(_a)
412 +
413 +#else
414 +
415 +#define xa_surface_destroy(_a) xa_surface_unref(_a)
416 +#define _xa_surface_handle(_a, _b, _c)         \
417 +    xa_surface_handle(_a, xa_handle_type_shared, _b, _c)
418 +
419 +#endif /*  (XA_TRACKER_VERSION_MAJOR <= 1) */
420  #endif
421 diff --git a/vmwgfx/vmwgfx_saa_priv.h b/vmwgfx/vmwgfx_saa_priv.h
422 index 5f46dee..16583b0 100644
423 --- a/vmwgfx/vmwgfx_saa_priv.h
424 +++ b/vmwgfx/vmwgfx_saa_priv.h
425 @@ -54,8 +54,10 @@ struct vmwgfx_saa {
426      Bool use_present_opt;
427      Bool only_hw_presents;
428      Bool rendercheck;
429 +    Bool is_master;
430      void (*present_flush) (ScreenPtr pScreen);
431      struct _WsbmListHead sync_x_list;
432 +    struct _WsbmListHead pixmaps;
433      struct vmwgfx_composite *vcomp;
434  };
435  
436 diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c
437 index 449266b..9fd8f22 100644
438 --- a/vmwgfx/vmwgfx_tex_video.c
439 +++ b/vmwgfx/vmwgfx_tex_video.c
440 @@ -70,11 +70,11 @@ static const float bt_709[] = {
441  static Atom xvBrightness, xvContrast, xvSaturation, xvHue;
442  
443  #define NUM_TEXTURED_ATTRIBUTES 4
444 -static XF86AttributeRec TexturedAttributes[NUM_TEXTURED_ATTRIBUTES] = {
445 -   {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
446 -   {XvSettable | XvGettable, -1000, 1000, "XV_CONTRAST"},
447 -   {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"},
448 -   {XvSettable | XvGettable, -1000, 1000, "XV_HUE"}
449 +static const XF86AttributeRec TexturedAttributes[NUM_TEXTURED_ATTRIBUTES] = {
450 +    {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
451 +    {XvSettable | XvGettable, -1000, 1000, "XV_CONTRAST"},
452 +    {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"},
453 +    {XvSettable | XvGettable, -1000, 1000, "XV_HUE"}
454  };
455  
456  #define NUM_FORMATS 3
457 @@ -82,7 +82,7 @@ static XF86VideoFormatRec Formats[NUM_FORMATS] = {
458     {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
459  };
460  
461 -static XF86VideoEncodingRec DummyEncoding[1] = {
462 +static const XF86VideoEncodingRec DummyEncoding[1] = {
463     {
464        0,
465        "XV_IMAGE",
466 @@ -111,8 +111,7 @@ struct xorg_xv_port_priv {
467      int hue;
468  
469      int current_set;
470 -    struct vmwgfx_dmabuf *bounce[2][3];
471 -    struct xa_surface *yuv[3];
472 +    struct xa_surface *yuv[2][3];
473  
474      int drm_fd;
475  
476 @@ -198,14 +197,10 @@ stop_video(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
477         priv->fence = NULL;
478  
479         for (i=0; i<3; ++i) {
480 -          if (priv->yuv[i]) {
481 -              xa_surface_destroy(priv->yuv[i]);
482 -              priv->yuv[i] = NULL;
483 -          }
484            for (j=0; j<2; ++j) {
485 -              if (priv->bounce[j][i]) {
486 -                  vmwgfx_dmabuf_destroy(priv->bounce[j][i]);
487 -                  priv->bounce[0][i] = NULL;
488 +              if (priv->yuv[i]) {
489 +                  xa_surface_destroy(priv->yuv[j][i]);
490 +                  priv->yuv[j][i] = NULL;
491                }
492            }
493         }
494 @@ -297,11 +292,9 @@ static int
495  check_yuv_surfaces(struct xorg_xv_port_priv *priv,  int id,
496                    int width, int height)
497  {
498 -    struct xa_surface **yuv = priv->yuv;
499 -    struct vmwgfx_dmabuf **bounce = priv->bounce[priv->current_set];
500 +    struct xa_surface **yuv = priv->yuv[priv->current_set];
501      int ret = 0;
502      int i;
503 -    size_t size;
504  
505      for (i=0; i<3; ++i) {
506  
507 @@ -334,19 +327,6 @@ check_yuv_surfaces(struct xorg_xv_port_priv *priv,  int id,
508         if (ret || !yuv[i])
509             return BadAlloc;
510  
511 -       size = width * height;
512 -
513 -       if (bounce[i] && (bounce[i]->size < size ||
514 -                         bounce[i]->size > 2*size)) {
515 -           vmwgfx_dmabuf_destroy(bounce[i]);
516 -           bounce[i] = NULL;
517 -       }
518 -
519 -       if (!bounce[i]) {
520 -           bounce[i] = vmwgfx_dmabuf_alloc(priv->drm_fd, size);
521 -           if (!bounce[i])
522 -               return BadAlloc;
523 -       }
524      }
525      return Success;
526  }
527 @@ -413,28 +393,20 @@ copy_packed_data(ScrnInfoPtr pScrn,
528                   unsigned short w, unsigned short h)
529  {
530      int i;
531 -   struct vmwgfx_dmabuf **bounce = port->bounce[port->current_set];
532 +   struct xa_surface **yuv = port->yuv[port->current_set];
533     char *ymap, *vmap, *umap;
534     unsigned char y1, y2, u, v;
535     int yidx, uidx, vidx;
536     int y_array_size = w * h;
537     int ret = BadAlloc;
538  
539 -   /*
540 -    * Here, we could use xa_surface_[map|unmap], but given the size of
541 -    * the yuv textures, that could stress the xa tracker dma buffer pool,
542 -    * particularaly with multiple videos rendering simultaneously.
543 -    *
544 -    * Instead, cheat and allocate vmwgfx dma buffers directly.
545 -    */
546 -
547 -   ymap = (char *)vmwgfx_dmabuf_map(bounce[0]);
548 +   ymap = xa_surface_map(port->r, yuv[0], XA_MAP_WRITE);
549     if (!ymap)
550         return BadAlloc;
551 -   umap = (char *)vmwgfx_dmabuf_map(bounce[1]);
552 +   umap = xa_surface_map(port->r, yuv[1], XA_MAP_WRITE);
553     if (!umap)
554         goto out_no_umap;
555 -   vmap = (char *)vmwgfx_dmabuf_map(bounce[2]);
556 +   vmap = xa_surface_map(port->r, yuv[2], XA_MAP_WRITE);
557     if (!vmap)
558         goto out_no_vmap;
559  
560 @@ -444,16 +416,16 @@ copy_packed_data(ScrnInfoPtr pScrn,
561     switch (id) {
562     case FOURCC_YV12: {
563        int pitches[3], offsets[3];
564 -      unsigned char *y, *u, *v;
565 +      unsigned char *yp, *up, *vp;
566        query_image_attributes(pScrn, FOURCC_YV12,
567                               &w, &h, pitches, offsets);
568  
569 -      y = buf + offsets[0];
570 -      v = buf + offsets[1];
571 -      u = buf + offsets[2];
572 -      memcpy(ymap, y, w*h);
573 -      memcpy(vmap, v, w*h/4);
574 -      memcpy(umap, u, w*h/4);
575 +      yp = buf + offsets[0];
576 +      vp = buf + offsets[1];
577 +      up = buf + offsets[2];
578 +      memcpy(ymap, yp, w*h);
579 +      memcpy(vmap, vp, w*h/4);
580 +      memcpy(umap, up, w*h/4);
581        break;
582     }
583     case FOURCC_UYVY:
584 @@ -493,64 +465,11 @@ copy_packed_data(ScrnInfoPtr pScrn,
585     }
586  
587     ret = Success;
588 -   vmwgfx_dmabuf_unmap(bounce[2]);
589 +   xa_surface_unmap(yuv[2]);
590    out_no_vmap:
591 -   vmwgfx_dmabuf_unmap(bounce[1]);
592 +   xa_surface_unmap(yuv[1]);
593    out_no_umap:
594 -   vmwgfx_dmabuf_unmap(bounce[0]);
595 -
596 -   if (ret == Success) {
597 -       struct xa_surface *srf;
598 -       struct vmwgfx_dmabuf *buf;
599 -       uint32_t handle;
600 -       unsigned int stride;
601 -       BoxRec box;
602 -       RegionRec reg;
603 -
604 -       box.x1 = 0;
605 -       box.x2 = w;
606 -       box.y1 = 0;
607 -       box.y2 = h;
608 -
609 -       REGION_INIT(pScrn->pScreen, &reg, &box, 1);
610 -
611 -       for (i=0; i<3; ++i) {
612 -          srf = port->yuv[i];
613 -          buf = bounce[i];
614 -
615 -          if (i == 1) {
616 -              switch(id) {
617 -              case FOURCC_YV12:
618 -                  h /= 2;
619 -                  /* Fall through */
620 -              case FOURCC_YUY2:
621 -              case FOURCC_UYVY:
622 -                  w /= 2;
623 -                  break;
624 -              default:
625 -                  break;
626 -              }
627 -
628 -              box.x1 = 0;
629 -              box.x2 = w;
630 -              box.y1 = 0;
631 -              box.y2 = h;
632 -
633 -              REGION_RESET(pScrn->pScreen, &reg, &box);
634 -          }
635 -
636 -          if (xa_surface_handle(srf, &handle, &stride) != 0) {
637 -              ret = BadAlloc;
638 -              break;
639 -          }
640 -
641 -          if (vmwgfx_dma(0, 0, &reg, buf, w, handle, 1) != 0) {
642 -              ret = BadAlloc;
643 -              break;
644 -          }
645 -       }
646 -       REGION_UNINIT(pScrn->pScreen, &reg);
647 -   }
648 +   xa_surface_unmap(yuv[0]);
649  
650     return ret;
651  }
652 @@ -609,7 +528,8 @@ display_video(ScreenPtr pScreen, struct xorg_xv_port_priv *pPriv, int id,
653                                  (struct xa_box *)REGION_RECTS(dstRegion),
654                                  REGION_NUM_RECTS(dstRegion),
655                                  pPriv->cm,
656 -                                vpix->hw, pPriv->yuv);
657 +                                vpix->hw,
658 +                                pPriv->yuv[pPriv->current_set ]);
659  
660     saa_pixmap_dirty(pPixmap, TRUE, dstRegion);
661     DamageRegionProcessPending(&pPixmap->drawable);
662 diff --git a/vmwgfx/vmwgfx_xa_surface.c b/vmwgfx/vmwgfx_xa_surface.c
663 index 8b30e45..2f23c57 100644
664 --- a/vmwgfx/vmwgfx_xa_surface.c
665 +++ b/vmwgfx/vmwgfx_xa_surface.c
666 @@ -362,6 +362,12 @@ vmwgfx_hw_accel_validate(PixmapPtr pixmap, unsigned int depth,
667  Bool
668  vmwgfx_hw_dri2_validate(PixmapPtr pixmap, unsigned int depth)
669  {
670 +    struct vmwgfx_saa *vsaa =
671 +       to_vmwgfx_saa(saa_get_driver(pixmap->drawable.pScreen));
672 +
673 +    if (!vsaa->is_master)
674 +           return FALSE;
675 +
676      return (vmwgfx_hw_dri2_stage(pixmap, depth) &&
677             vmwgfx_hw_commit(pixmap) &&
678             vmwgfx_hw_validate(pixmap, NULL));
This page took 0.208171 seconds and 3 git commands to generate.