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