Merge branch 'pipe-format-simplify'
[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 #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
29 static 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 };*/
34 static 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
43 static 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 };*/
48 static 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
56 static Atom xvBrightness, xvContrast;
57
58 #define NUM_TEXTURED_ATTRIBUTES 2
59 static 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
65 static XF86VideoFormatRec Formats[NUM_FORMATS] = {
66 {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
67 };
68
69 static 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
79 static XF86ImageRec Images[NUM_IMAGES] = {
80 XVIMAGE_UYVY,
81 XVIMAGE_YUY2,
82 XVIMAGE_YV12,
83 };
84
85 struct 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
100 static void
101 stop_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
108 static int
109 set_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
128 static int
129 get_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
144 static void
145 query_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
160 static INLINE struct pipe_texture *
161 create_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
182 static int
183 check_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
217 static int
218 query_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
269 static void
270 copy_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
377 static void
378 setup_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
387 static void
388 draw_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
400 static void
401 bind_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.blend_enable = 1;
407 blend.colormask |= PIPE_MASK_RGBA;
408
409 /* porter&duff src */
410 blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
411 blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
412 blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
413 blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
414
415 cso_set_blend(port->r->cso, &blend);
416 }
417
418
419 static void
420 bind_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
433 static INLINE void
434 conditional_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
447 static void
448 bind_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
476 static int
477 display_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 = exaGetPixmapDriverPrivate(pPixmap);
490 struct pipe_surface *dst_surf = xorg_gpu_surface(pPriv->r->pipe->screen, dst);
491
492 if (dst && !dst->tex) {
493 xorg_exa_set_shared_usage(pPixmap);
494 pScrn->pScreen->ModifyPixmapHeader(pPixmap, 0, 0, 0, 0, 0, NULL);
495 }
496
497 if (!dst || !dst->tex)
498 XORG_FALLBACK("Xv destination %s", !dst ? "!dst" : "!dst->tex");
499
500 hdtv = ((src_w >= RES_720P_X) && (src_h >= RES_720P_Y));
501
502 REGION_TRANSLATE(pScrn->pScreen, dstRegion, -pPixmap->screen_x,
503 -pPixmap->screen_y);
504
505 dxo = dstRegion->extents.x1;
506 dyo = dstRegion->extents.y1;
507
508 pbox = REGION_RECTS(dstRegion);
509 nbox = REGION_NUM_RECTS(dstRegion);
510
511 renderer_bind_destination(pPriv->r, dst_surf,
512 dst_surf->width, dst_surf->height);
513
514 bind_blend_state(pPriv);
515 bind_shaders(pPriv);
516 bind_samplers(pPriv);
517 setup_fs_video_constants(pPriv->r, hdtv);
518
519 exaMoveInPixmap(pPixmap);
520 DamageDamageRegion(&pPixmap->drawable, dstRegion);
521
522 while (nbox--) {
523 int box_x1 = pbox->x1;
524 int box_y1 = pbox->y1;
525 int box_x2 = pbox->x2;
526 int box_y2 = pbox->y2;
527 float diff_x = (float)src_w / (float)dst_w;
528 float diff_y = (float)src_h / (float)dst_h;
529 int offset_x = box_x1 - dstX + pPixmap->screen_x;
530 int offset_y = box_y1 - dstY + pPixmap->screen_y;
531 int offset_w;
532 int offset_h;
533
534 x = box_x1;
535 y = box_y1;
536 w = box_x2 - box_x1;
537 h = box_y2 - box_y1;
538
539 offset_w = dst_w - w;
540 offset_h = dst_h - h;
541
542 draw_yuv(pPriv, src_x + offset_x*diff_x, src_y + offset_y*diff_y,
543 src_w - offset_w*diff_x, src_h - offset_h*diff_x,
544 x, y, w, h);
545
546 pbox++;
547 }
548 DamageRegionProcessPending(&pPixmap->drawable);
549
550 pipe_surface_reference(&dst_surf, NULL);
551
552 return TRUE;
553 }
554
555 static int
556 put_image(ScrnInfoPtr pScrn,
557 short src_x, short src_y,
558 short drw_x, short drw_y,
559 short src_w, short src_h,
560 short drw_w, short drw_h,
561 int id, unsigned char *buf,
562 short width, short height,
563 Bool sync, RegionPtr clipBoxes, pointer data,
564 DrawablePtr pDraw)
565 {
566 struct xorg_xv_port_priv *pPriv = (struct xorg_xv_port_priv *) data;
567 ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
568 PixmapPtr pPixmap;
569 INT32 x1, x2, y1, y2;
570 BoxRec dstBox;
571 int ret;
572
573 /* Clip */
574 x1 = src_x;
575 x2 = src_x + src_w;
576 y1 = src_y;
577 y2 = src_y + src_h;
578
579 dstBox.x1 = drw_x;
580 dstBox.x2 = drw_x + drw_w;
581 dstBox.y1 = drw_y;
582 dstBox.y2 = drw_y + drw_h;
583
584 if (!xf86XVClipVideoHelper(&dstBox, &x1, &x2, &y1, &y2, clipBoxes,
585 width, height))
586 return Success;
587
588 ret = check_yuv_textures(pPriv, width, height);
589
590 if (ret)
591 return ret;
592
593 copy_packed_data(pScrn, pPriv, id, buf,
594 src_x, src_y, width, height);
595
596 if (pDraw->type == DRAWABLE_WINDOW) {
597 pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
598 } else {
599 pPixmap = (PixmapPtr)pDraw;
600 }
601
602 display_video(pScrn, pPriv, id, clipBoxes,
603 src_x, src_y, src_w, src_h,
604 drw_x, drw_y,
605 drw_w, drw_h, pPixmap);
606
607 pPriv->current_set = (pPriv->current_set + 1) & 1;
608 return Success;
609 }
610
611 static struct xorg_xv_port_priv *
612 port_priv_create(struct xorg_renderer *r)
613 {
614 struct xorg_xv_port_priv *priv = NULL;
615
616 priv = calloc(1, sizeof(struct xorg_xv_port_priv));
617
618 if (!priv)
619 return NULL;
620
621 priv->r = r;
622
623 REGION_NULL(pScreen, &priv->clip);
624
625 debug_assert(priv && priv->r);
626
627 return priv;
628 }
629
630 static XF86VideoAdaptorPtr
631 xorg_setup_textured_adapter(ScreenPtr pScreen)
632 {
633 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
634 modesettingPtr ms = modesettingPTR(pScrn);
635 XF86VideoAdaptorPtr adapt;
636 XF86AttributePtr attrs;
637 DevUnion *dev_unions;
638 int nports = 16, i;
639 int nattributes;
640
641 nattributes = NUM_TEXTURED_ATTRIBUTES;
642
643 debug_assert(ms->exa);
644 debug_assert(ms->exa->renderer);
645
646 adapt = calloc(1, sizeof(XF86VideoAdaptorRec));
647 dev_unions = calloc(nports, sizeof(DevUnion));
648 attrs = calloc(nattributes, sizeof(XF86AttributeRec));
649 if (adapt == NULL || dev_unions == NULL || attrs == NULL) {
650 free(adapt);
651 free(dev_unions);
652 free(attrs);
653 return NULL;
654 }
655
656 adapt->type = XvWindowMask | XvInputMask | XvImageMask;
657 adapt->flags = 0;
658 adapt->name = "Gallium3D Textured Video";
659 adapt->nEncodings = 1;
660 adapt->pEncodings = DummyEncoding;
661 adapt->nFormats = NUM_FORMATS;
662 adapt->pFormats = Formats;
663 adapt->nPorts = 0;
664 adapt->pPortPrivates = dev_unions;
665 adapt->nAttributes = nattributes;
666 adapt->pAttributes = attrs;
667 memcpy(attrs, TexturedAttributes, nattributes * sizeof(XF86AttributeRec));
668 adapt->nImages = NUM_IMAGES;
669 adapt->pImages = Images;
670 adapt->PutVideo = NULL;
671 adapt->PutStill = NULL;
672 adapt->GetVideo = NULL;
673 adapt->GetStill = NULL;
674 adapt->StopVideo = stop_video;
675 adapt->SetPortAttribute = set_port_attribute;
676 adapt->GetPortAttribute = get_port_attribute;
677 adapt->QueryBestSize = query_best_size;
678 adapt->PutImage = put_image;
679 adapt->QueryImageAttributes = query_image_attributes;
680
681 for (i = 0; i < nports; i++) {
682 struct xorg_xv_port_priv *priv =
683 port_priv_create(ms->exa->renderer);
684
685 adapt->pPortPrivates[i].ptr = (pointer) (priv);
686 adapt->nPorts++;
687 }
688
689 return adapt;
690 }
691
692 void
693 xorg_xv_init(ScreenPtr pScreen)
694 {
695 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
696 /*modesettingPtr ms = modesettingPTR(pScrn);*/
697 XF86VideoAdaptorPtr *adaptors, *new_adaptors = NULL;
698 XF86VideoAdaptorPtr textured_adapter;
699 int num_adaptors;
700
701 num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
702 new_adaptors = malloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr *));
703 if (new_adaptors == NULL)
704 return;
705
706 memcpy(new_adaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr));
707 adaptors = new_adaptors;
708
709 /* Add the adaptors supported by our hardware. First, set up the atoms
710 * that will be used by both output adaptors.
711 */
712 xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
713 xvContrast = MAKE_ATOM("XV_CONTRAST");
714
715 textured_adapter = xorg_setup_textured_adapter(pScreen);
716
717 debug_assert(textured_adapter);
718
719 if (textured_adapter) {
720 adaptors[num_adaptors++] = textured_adapter;
721 }
722
723 if (num_adaptors) {
724 xf86XVScreenInit(pScreen, adaptors, num_adaptors);
725 } else {
726 xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
727 "Disabling Xv because no adaptors could be initialized.\n");
728 }
729
730 free(adaptors);
731 }