xorg_xv.c revision 690d888416909f0449e6ebbfa46f18079b68b1bd
1#include "xorg_tracker.h"
2
3#include <xf86xv.h>
4#include <X11/extensions/Xv.h>
5#include <fourcc.h>
6
7#include "xorg_exa.h"
8#include "xorg_renderer.h"
9#include "xorg_exa_tgsi.h"
10
11#include "cso_cache/cso_context.h"
12
13#include "pipe/p_screen.h"
14#include "pipe/p_inlines.h"
15
16/*XXX get these from pipe's texture limits */
17#define IMAGE_MAX_WIDTH		2048
18#define IMAGE_MAX_HEIGHT	2048
19
20#define RES_720P_X 1280
21#define RES_720P_Y 720
22
23
24/* The ITU-R BT.601 conversion matrix for SDTV. */
25/* original, matrix, but we transpose it to
26 * make the shader easier
27static const float bt_601[] = {
28    1.0, 0.0, 1.4075,   ,
29    1.0, -0.3455, -0.7169, 0,
30    1.0, 1.7790, 0., 0,
31};*/
32static const float bt_601[] = {
33    1.0, 1.0, 1.0,        0.5,
34    0.0, -0.3455, 1.7790, 0,
35    1.4075, -0.7169, 0.,  0,
36};
37
38/* The ITU-R BT.709 conversion matrix for HDTV. */
39/* original, but we transpose to make the conversion
40 * in the shader easier
41static const float bt_709[] = {
42    1.0, 0.0, 1.581, 0,
43    1.0, -0.1881, -0.47, 0,
44    1.0, 1.8629, 0., 0,
45};*/
46static const float bt_709[] = {
47    1.0,   1.0,     1.0,     0.5,
48    0.0,  -0.1881,  1.8629,  0,
49    1.581,-0.47   , 0.0,     0,
50};
51
52#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
53
54static Atom xvBrightness, xvContrast;
55
56#define NUM_TEXTURED_ATTRIBUTES 2
57static XF86AttributeRec TexturedAttributes[NUM_TEXTURED_ATTRIBUTES] = {
58   {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
59   {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
60};
61
62#define NUM_FORMATS 3
63static XF86VideoFormatRec Formats[NUM_FORMATS] = {
64   {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
65};
66
67static XF86VideoEncodingRec DummyEncoding[1] = {
68   {
69      0,
70      "XV_IMAGE",
71      IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
72      {1, 1}
73   }
74};
75
76#define NUM_IMAGES 3
77static XF86ImageRec Images[NUM_IMAGES] = {
78   XVIMAGE_UYVY,
79   XVIMAGE_YUY2,
80   XVIMAGE_YV12,
81};
82
83struct xorg_xv_port_priv {
84   struct xorg_renderer *r;
85
86   RegionRec clip;
87
88   int brightness;
89   int contrast;
90
91   int current_set;
92   /* juggle two sets of seperate Y, U and V
93    * textures */
94   struct pipe_texture *yuv[2][3];
95};
96
97
98static void
99stop_video(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
100{
101   struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data;
102
103   REGION_EMPTY(pScrn->pScreen, &priv->clip);
104}
105
106static int
107set_port_attribute(ScrnInfoPtr pScrn,
108                   Atom attribute, INT32 value, pointer data)
109{
110   struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data;
111
112   if (attribute == xvBrightness) {
113      if ((value < -128) || (value > 127))
114         return BadValue;
115      priv->brightness = value;
116   } else if (attribute == xvContrast) {
117      if ((value < 0) || (value > 255))
118         return BadValue;
119      priv->contrast = value;
120   } else
121      return BadMatch;
122
123   return Success;
124}
125
126static int
127get_port_attribute(ScrnInfoPtr pScrn,
128                   Atom attribute, INT32 * value, pointer data)
129{
130   struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data;
131
132   if (attribute == xvBrightness)
133      *value = priv->brightness;
134   else if (attribute == xvContrast)
135      *value = priv->contrast;
136   else
137      return BadMatch;
138
139   return Success;
140}
141
142static void
143query_best_size(ScrnInfoPtr pScrn,
144                Bool motion,
145                short vid_w, short vid_h,
146                short drw_w, short drw_h,
147                unsigned int *p_w, unsigned int *p_h, pointer data)
148{
149   if (vid_w > (drw_w << 1))
150      drw_w = vid_w >> 1;
151   if (vid_h > (drw_h << 1))
152      drw_h = vid_h >> 1;
153
154   *p_w = drw_w;
155   *p_h = drw_h;
156}
157
158static INLINE struct pipe_texture *
159create_component_texture(struct pipe_context *pipe,
160                         int width, int height)
161{
162   struct pipe_screen *screen = pipe->screen;
163   struct pipe_texture *tex = 0;
164   struct pipe_texture templ;
165
166   memset(&templ, 0, sizeof(templ));
167   templ.target = PIPE_TEXTURE_2D;
168   templ.format = PIPE_FORMAT_L8_UNORM;
169   templ.last_level = 0;
170   templ.width[0] = width;
171   templ.height[0] = height;
172   templ.depth[0] = 1;
173   pf_get_block(PIPE_FORMAT_L8_UNORM, &templ.block);
174   templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
175
176   tex = screen->texture_create(screen, &templ);
177
178   return tex;
179}
180
181static int
182check_yuv_textures(struct xorg_xv_port_priv *priv,  int width, int height)
183{
184   struct pipe_texture **dst = priv->yuv[priv->current_set];
185   if (!dst[0] ||
186       dst[0]->width[0] != width ||
187       dst[0]->height[0] != height) {
188      pipe_texture_reference(&dst[0], NULL);
189   }
190   if (!dst[1] ||
191       dst[1]->width[0] != width ||
192       dst[1]->height[0] != height) {
193      pipe_texture_reference(&dst[1], NULL);
194   }
195   if (!dst[2] ||
196       dst[2]->width[0] != width ||
197       dst[2]->height[0] != height) {
198      pipe_texture_reference(&dst[2], NULL);
199   }
200
201   if (!dst[0])
202      dst[0] = create_component_texture(priv->r->pipe, width, height);
203
204   if (!dst[1])
205      dst[1] = create_component_texture(priv->r->pipe, width, height);
206
207   if (!dst[2])
208      dst[2] = create_component_texture(priv->r->pipe, width, height);
209
210   if (!dst[0] || !dst[1] || !dst[2])
211      return BadAlloc;
212
213   return Success;
214}
215
216static void
217copy_packed_data(ScrnInfoPtr pScrn,
218                 struct xorg_xv_port_priv *port,
219                 int id,
220                 unsigned char *buf,
221                 int srcPitch,
222                 int left,
223                 int top,
224                 int w, int h)
225{
226   unsigned char *src;
227   int i, j;
228   struct pipe_texture **dst = port->yuv[port->current_set];
229   struct pipe_transfer *ytrans, *utrans, *vtrans;
230   struct pipe_screen *screen = port->r->pipe->screen;
231   char *ymap, *vmap, *umap;
232   unsigned char y1, y2, u, v;
233   int yidx, uidx, vidx;
234   int y_array_size = w * h;
235
236   src = buf + (top * srcPitch) + (left << 1);
237
238   ytrans = screen->get_tex_transfer(screen, dst[0],
239                                     0, 0, 0,
240                                     PIPE_TRANSFER_WRITE,
241                                     left, top, w, h);
242   utrans = screen->get_tex_transfer(screen, dst[1],
243                                     0, 0, 0,
244                                     PIPE_TRANSFER_WRITE,
245                                     left, top, w, h);
246   vtrans = screen->get_tex_transfer(screen, dst[2],
247                                     0, 0, 0,
248                                     PIPE_TRANSFER_WRITE,
249                                     left, top, w, h);
250
251   ymap = (char*)screen->transfer_map(screen, ytrans);
252   umap = (char*)screen->transfer_map(screen, utrans);
253   vmap = (char*)screen->transfer_map(screen, vtrans);
254
255   yidx = uidx = vidx = 0;
256
257   switch (id) {
258   case FOURCC_YV12: {
259      for (i = 0; i < w; ++i) {
260         for (j = 0; j < h; ++j) {
261            /*XXX use src? */
262            y1  = buf[j*w + i];
263            u   = buf[(j/2) * (w/2) + i/2 + y_array_size];
264            v   = buf[(j/2) * (w/2) + i/2 + y_array_size + y_array_size/4];
265            ymap[yidx++] = y1;
266            umap[uidx++] = u;
267            vmap[vidx++] = v;
268         }
269      }
270   }
271      break;
272   case FOURCC_UYVY:
273      for (i = 0; i < y_array_size; i +=2 ) {
274         /* extracting two pixels */
275         u  = buf[0];
276         y1 = buf[1];
277         v  = buf[2];
278         y2 = buf[3];
279         buf += 4;
280
281         ymap[yidx++] = y1;
282         ymap[yidx++] = y2;
283         umap[uidx++] = u;
284         umap[uidx++] = u;
285         vmap[vidx++] = v;
286         vmap[vidx++] = v;
287      }
288      break;
289   case FOURCC_YUY2:
290      for (i = 0; i < y_array_size; i +=2 ) {
291         /* extracting two pixels */
292         y1 = buf[0];
293         u  = buf[1];
294         y2 = buf[2];
295         v  = buf[3];
296
297         buf += 4;
298
299         ymap[yidx++] = y1;
300         ymap[yidx++] = y2;
301         umap[uidx++] = u;
302         umap[uidx++] = u;
303         vmap[vidx++] = v;
304         vmap[vidx++] = v;
305      }
306      break;
307   default:
308      debug_assert(!"Unsupported yuv format!");
309      break;
310   }
311
312   screen->transfer_unmap(screen, ytrans);
313   screen->transfer_unmap(screen, utrans);
314   screen->transfer_unmap(screen, vtrans);
315   screen->tex_transfer_destroy(ytrans);
316   screen->tex_transfer_destroy(utrans);
317   screen->tex_transfer_destroy(vtrans);
318}
319
320
321static void
322setup_fs_video_constants(struct xorg_renderer *r, boolean hdtv)
323{
324   const int param_bytes = 12 * sizeof(float);
325   const float *video_constants = (hdtv) ? bt_709 : bt_601;
326
327   renderer_set_constants(r, PIPE_SHADER_FRAGMENT,
328                          video_constants, param_bytes);
329}
330
331static void
332draw_yuv(struct xorg_xv_port_priv *port,
333         int src_x, int src_y, int src_w, int src_h,
334         int dst_x, int dst_y, int dst_w, int dst_h)
335{
336   struct pipe_texture **textures = port->yuv[port->current_set];
337
338   renderer_draw_yuv(port->r,
339                     src_x, src_y, src_w, src_h,
340                     dst_x, dst_y, dst_w, dst_h,
341                     textures);
342}
343
344static void
345bind_blend_state(struct xorg_xv_port_priv *port)
346{
347   struct pipe_blend_state blend;
348
349   memset(&blend, 0, sizeof(struct pipe_blend_state));
350   blend.blend_enable = 1;
351   blend.colormask |= PIPE_MASK_RGBA;
352
353   /* porter&duff src */
354   blend.rgb_src_factor   = PIPE_BLENDFACTOR_ONE;
355   blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
356   blend.rgb_dst_factor   = PIPE_BLENDFACTOR_ZERO;
357   blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
358
359   cso_set_blend(port->r->cso, &blend);
360}
361
362
363static void
364bind_shaders(struct xorg_xv_port_priv *port)
365{
366   unsigned vs_traits = 0, fs_traits = 0;
367   struct xorg_shader shader;
368
369   vs_traits |= VS_YUV;
370   fs_traits |= FS_YUV;
371
372   shader = xorg_shaders_get(port->r->shaders, vs_traits, fs_traits);
373   cso_set_vertex_shader_handle(port->r->cso, shader.vs);
374   cso_set_fragment_shader_handle(port->r->cso, shader.fs);
375}
376
377static INLINE void
378conditional_flush(struct pipe_context *pipe, struct pipe_texture **tex,
379                  int num)
380{
381   int i;
382   for (i = 0; i < num; ++i) {
383      if (tex[i] && pipe->is_texture_referenced(pipe, tex[i], 0, 0) &
384          PIPE_REFERENCED_FOR_WRITE) {
385         pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
386         return;
387      }
388   }
389}
390
391static void
392bind_samplers(struct xorg_xv_port_priv *port)
393{
394   struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
395   struct pipe_sampler_state sampler;
396   struct pipe_texture **dst = port->yuv[port->current_set];
397
398   memset(&sampler, 0, sizeof(struct pipe_sampler_state));
399
400   conditional_flush(port->r->pipe, dst, 3);
401
402   sampler.wrap_s = PIPE_TEX_WRAP_CLAMP;
403   sampler.wrap_t = PIPE_TEX_WRAP_CLAMP;
404   sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
405   sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
406   sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
407   sampler.normalized_coords = 1;
408
409   samplers[0] = &sampler;
410   samplers[1] = &sampler;
411   samplers[2] = &sampler;
412
413
414   cso_set_samplers(port->r->cso, 3,
415                    (const struct pipe_sampler_state **)samplers);
416   cso_set_sampler_textures(port->r->cso, 3,
417                            dst);
418}
419
420static int
421display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
422              RegionPtr dstRegion,
423              int src_x, int src_y, int src_w, int src_h,
424              int dstX, int dstY, int dst_w, int dst_h,
425              PixmapPtr pPixmap)
426{
427   modesettingPtr ms = modesettingPTR(pScrn);
428   BoxPtr pbox;
429   int nbox;
430   int dxo, dyo;
431   Bool hdtv;
432   int x, y, w, h;
433   struct exa_pixmap_priv *dst = exaGetPixmapDriverPrivate(pPixmap);
434   struct pipe_surface *dst_surf = xorg_gpu_surface(pPriv->r->pipe->screen, dst);
435
436   if (dst && !dst->tex) {
437	xorg_exa_set_shared_usage(pPixmap);
438	pScrn->pScreen->ModifyPixmapHeader(pPixmap, 0, 0, 0, 0, 0, NULL);
439   }
440
441   if (!dst || !dst->tex)
442      XORG_FALLBACK("Xv destination %s", !dst ? "!dst" : "!dst->tex");
443
444   hdtv = ((src_w >= RES_720P_X) && (src_h >= RES_720P_Y));
445
446   REGION_TRANSLATE(pScrn->pScreen, dstRegion, -pPixmap->screen_x,
447                    -pPixmap->screen_y);
448
449   dxo = dstRegion->extents.x1;
450   dyo = dstRegion->extents.y1;
451
452   pbox = REGION_RECTS(dstRegion);
453   nbox = REGION_NUM_RECTS(dstRegion);
454
455   renderer_bind_destination(pPriv->r, dst_surf,
456                             dst_surf->width, dst_surf->height);
457
458   bind_blend_state(pPriv);
459   bind_shaders(pPriv);
460   bind_samplers(pPriv);
461   setup_fs_video_constants(pPriv->r, hdtv);
462
463   exaMoveInPixmap(pPixmap);
464   DamageDamageRegion(&pPixmap->drawable, dstRegion);
465
466   while (nbox--) {
467      int box_x1 = pbox->x1;
468      int box_y1 = pbox->y1;
469      int box_x2 = pbox->x2;
470      int box_y2 = pbox->y2;
471      float diff_x = (float)src_w / (float)dst_w;
472      float diff_y = (float)src_h / (float)dst_h;
473      int offset_x = box_x1 - dstX + pPixmap->screen_x;
474      int offset_y = box_y1 - dstY + pPixmap->screen_y;
475      int offset_w;
476      int offset_h;
477
478      x = box_x1;
479      y = box_y1;
480      w = box_x2 - box_x1;
481      h = box_y2 - box_y1;
482
483      offset_w = dst_w - w;
484      offset_h = dst_h - h;
485
486      draw_yuv(pPriv, src_x + offset_x*diff_x, src_y + offset_y*diff_y,
487               src_w - offset_w*diff_x, src_h - offset_h*diff_x,
488               x, y, w, h);
489
490      pbox++;
491   }
492   DamageRegionProcessPending(&pPixmap->drawable);
493
494   pipe_surface_reference(&dst_surf, NULL);
495
496   return TRUE;
497}
498
499static int
500put_image(ScrnInfoPtr pScrn,
501          short src_x, short src_y,
502          short drw_x, short drw_y,
503          short src_w, short src_h,
504          short drw_w, short drw_h,
505          int id, unsigned char *buf,
506          short width, short height,
507          Bool sync, RegionPtr clipBoxes, pointer data,
508          DrawablePtr pDraw)
509{
510   struct xorg_xv_port_priv *pPriv = (struct xorg_xv_port_priv *) data;
511   ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
512   PixmapPtr pPixmap;
513   INT32 x1, x2, y1, y2;
514   int srcPitch;
515   BoxRec dstBox;
516   int ret;
517
518   /* Clip */
519   x1 = src_x;
520   x2 = src_x + src_w;
521   y1 = src_y;
522   y2 = src_y + src_h;
523
524   dstBox.x1 = drw_x;
525   dstBox.x2 = drw_x + drw_w;
526   dstBox.y1 = drw_y;
527   dstBox.y2 = drw_y + drw_h;
528
529   if (!xf86XVClipVideoHelper(&dstBox, &x1, &x2, &y1, &y2, clipBoxes,
530			      width, height))
531      return Success;
532
533   switch (id) {
534   case FOURCC_UYVY:
535   case FOURCC_YUY2:
536   case FOURCC_YV12:
537   default:
538      srcPitch = width << 1;
539      break;
540   }
541
542   ret = check_yuv_textures(pPriv, width, height);
543
544   if (ret)
545      return ret;
546
547   copy_packed_data(pScrn, pPriv, id, buf, srcPitch,
548                    src_x, src_y, width, height);
549
550   if (pDraw->type == DRAWABLE_WINDOW) {
551      pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
552   } else {
553      pPixmap = (PixmapPtr)pDraw;
554   }
555
556   display_video(pScrn, pPriv, id, clipBoxes,
557                 src_x, src_y, src_w, src_h,
558                 drw_x, drw_y,
559                 drw_w, drw_h, pPixmap);
560
561   pPriv->current_set = (pPriv->current_set + 1) & 1;
562   return Success;
563}
564
565static int
566query_image_attributes(ScrnInfoPtr pScrn,
567                       int id,
568                       unsigned short *w, unsigned short *h,
569                       int *pitches, int *offsets)
570{
571   int size;
572
573   if (*w > IMAGE_MAX_WIDTH)
574      *w = IMAGE_MAX_WIDTH;
575   if (*h > IMAGE_MAX_HEIGHT)
576      *h = IMAGE_MAX_HEIGHT;
577
578   *w = (*w + 1) & ~1;
579   if (offsets)
580      offsets[0] = 0;
581
582   switch (id) {
583   case FOURCC_UYVY:
584   case FOURCC_YUY2:
585   case FOURCC_YV12:
586   default:
587      size = *w << 1;
588      if (pitches)
589	 pitches[0] = size;
590      size *= *h;
591      break;
592   }
593
594   return size;
595}
596
597static struct xorg_xv_port_priv *
598port_priv_create(struct xorg_renderer *r)
599{
600   struct xorg_xv_port_priv *priv = NULL;
601
602   priv = calloc(1, sizeof(struct xorg_xv_port_priv));
603
604   if (!priv)
605      return NULL;
606
607   priv->r = r;
608
609   REGION_NULL(pScreen, &priv->clip);
610
611   debug_assert(priv && priv->r);
612
613   return priv;
614}
615
616static XF86VideoAdaptorPtr
617xorg_setup_textured_adapter(ScreenPtr pScreen)
618{
619   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
620   modesettingPtr ms = modesettingPTR(pScrn);
621   XF86VideoAdaptorPtr adapt;
622   XF86AttributePtr attrs;
623   DevUnion *dev_unions;
624   int nports = 16, i;
625   int nattributes;
626
627   nattributes = NUM_TEXTURED_ATTRIBUTES;
628
629   debug_assert(ms->exa);
630   debug_assert(ms->exa->renderer);
631
632   adapt = calloc(1, sizeof(XF86VideoAdaptorRec));
633   dev_unions = calloc(nports, sizeof(DevUnion));
634   attrs = calloc(nattributes, sizeof(XF86AttributeRec));
635   if (adapt == NULL || dev_unions == NULL || attrs == NULL) {
636      free(adapt);
637      free(dev_unions);
638      free(attrs);
639      return NULL;
640   }
641
642   adapt->type = XvWindowMask | XvInputMask | XvImageMask;
643   adapt->flags = 0;
644   adapt->name = "Gallium3D Textured Video";
645   adapt->nEncodings = 1;
646   adapt->pEncodings = DummyEncoding;
647   adapt->nFormats = NUM_FORMATS;
648   adapt->pFormats = Formats;
649   adapt->nPorts = 0;
650   adapt->pPortPrivates = dev_unions;
651   adapt->nAttributes = nattributes;
652   adapt->pAttributes = attrs;
653   memcpy(attrs, TexturedAttributes, nattributes * sizeof(XF86AttributeRec));
654   adapt->nImages = NUM_IMAGES;
655   adapt->pImages = Images;
656   adapt->PutVideo = NULL;
657   adapt->PutStill = NULL;
658   adapt->GetVideo = NULL;
659   adapt->GetStill = NULL;
660   adapt->StopVideo = stop_video;
661   adapt->SetPortAttribute = set_port_attribute;
662   adapt->GetPortAttribute = get_port_attribute;
663   adapt->QueryBestSize = query_best_size;
664   adapt->PutImage = put_image;
665   adapt->QueryImageAttributes = query_image_attributes;
666
667   for (i = 0; i < nports; i++) {
668      struct xorg_xv_port_priv *priv =
669         port_priv_create(ms->exa->renderer);
670
671      adapt->pPortPrivates[i].ptr = (pointer) (priv);
672      adapt->nPorts++;
673   }
674
675   return adapt;
676}
677
678void
679xorg_xv_init(ScreenPtr pScreen)
680{
681   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
682   /*modesettingPtr ms = modesettingPTR(pScrn);*/
683   XF86VideoAdaptorPtr *adaptors, *new_adaptors = NULL;
684   XF86VideoAdaptorPtr textured_adapter;
685   int num_adaptors;
686
687   num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
688   new_adaptors = malloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr *));
689   if (new_adaptors == NULL)
690      return;
691
692   memcpy(new_adaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr));
693   adaptors = new_adaptors;
694
695   /* Add the adaptors supported by our hardware.  First, set up the atoms
696    * that will be used by both output adaptors.
697    */
698   xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
699   xvContrast = MAKE_ATOM("XV_CONTRAST");
700
701   textured_adapter = xorg_setup_textured_adapter(pScreen);
702
703   debug_assert(textured_adapter);
704
705   if (textured_adapter) {
706      adaptors[num_adaptors++] = textured_adapter;
707   }
708
709   if (num_adaptors) {
710      xf86XVScreenInit(pScreen, adaptors, num_adaptors);
711   } else {
712      xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
713                 "Disabling Xv because no adaptors could be initialized.\n");
714   }
715
716   free(adaptors);
717}
718