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