st/xorg: Remove unnecessary headers.
[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.width0 = width;
170 templ.height0 = height;
171 templ.depth0 = 1;
172 templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
173
174 tex = screen->texture_create(screen, &templ);
175
176 return tex;
177 }
178
179 static int
180 check_yuv_textures(struct xorg_xv_port_priv *priv, int width, int height)
181 {
182 struct pipe_texture **dst = priv->yuv[priv->current_set];
183 if (!dst[0] ||
184 dst[0]->width0 != width ||
185 dst[0]->height0 != height) {
186 pipe_texture_reference(&dst[0], NULL);
187 }
188 if (!dst[1] ||
189 dst[1]->width0 != width ||
190 dst[1]->height0 != height) {
191 pipe_texture_reference(&dst[1], NULL);
192 }
193 if (!dst[2] ||
194 dst[2]->width0 != width ||
195 dst[2]->height0 != height) {
196 pipe_texture_reference(&dst[2], NULL);
197 }
198
199 if (!dst[0])
200 dst[0] = create_component_texture(priv->r->pipe, width, height);
201
202 if (!dst[1])
203 dst[1] = create_component_texture(priv->r->pipe, width, height);
204
205 if (!dst[2])
206 dst[2] = create_component_texture(priv->r->pipe, width, height);
207
208 if (!dst[0] || !dst[1] || !dst[2])
209 return BadAlloc;
210
211 return Success;
212 }
213
214 static int
215 query_image_attributes(ScrnInfoPtr pScrn,
216 int id,
217 unsigned short *w, unsigned short *h,
218 int *pitches, int *offsets)
219 {
220 int size, tmp;
221
222 if (*w > IMAGE_MAX_WIDTH)
223 *w = IMAGE_MAX_WIDTH;
224 if (*h > IMAGE_MAX_HEIGHT)
225 *h = IMAGE_MAX_HEIGHT;
226
227 *w = (*w + 1) & ~1;
228 if (offsets)
229 offsets[0] = 0;
230
231 switch (id) {
232 case FOURCC_YV12:
233 *h = (*h + 1) & ~1;
234 size = (*w + 3) & ~3;
235 if (pitches) {
236 pitches[0] = size;
237 }
238 size *= *h;
239 if (offsets) {
240 offsets[1] = size;
241 }
242 tmp = ((*w >> 1) + 3) & ~3;
243 if (pitches) {
244 pitches[1] = pitches[2] = tmp;
245 }
246 tmp *= (*h >> 1);
247 size += tmp;
248 if (offsets) {
249 offsets[2] = size;
250 }
251 size += tmp;
252 break;
253 case FOURCC_UYVY:
254 case FOURCC_YUY2:
255 default:
256 size = *w << 1;
257 if (pitches)
258 pitches[0] = size;
259 size *= *h;
260 break;
261 }
262
263 return size;
264 }
265
266 static void
267 copy_packed_data(ScrnInfoPtr pScrn,
268 struct xorg_xv_port_priv *port,
269 int id,
270 unsigned char *buf,
271 int left,
272 int top,
273 unsigned short w, unsigned short h)
274 {
275 int i, j;
276 struct pipe_texture **dst = port->yuv[port->current_set];
277 struct pipe_transfer *ytrans, *utrans, *vtrans;
278 struct pipe_screen *screen = port->r->pipe->screen;
279 char *ymap, *vmap, *umap;
280 unsigned char y1, y2, u, v;
281 int yidx, uidx, vidx;
282 int y_array_size = w * h;
283
284 ytrans = screen->get_tex_transfer(screen, dst[0],
285 0, 0, 0,
286 PIPE_TRANSFER_WRITE,
287 left, top, w, h);
288 utrans = screen->get_tex_transfer(screen, dst[1],
289 0, 0, 0,
290 PIPE_TRANSFER_WRITE,
291 left, top, w, h);
292 vtrans = screen->get_tex_transfer(screen, dst[2],
293 0, 0, 0,
294 PIPE_TRANSFER_WRITE,
295 left, top, w, h);
296
297 ymap = (char*)screen->transfer_map(screen, ytrans);
298 umap = (char*)screen->transfer_map(screen, utrans);
299 vmap = (char*)screen->transfer_map(screen, vtrans);
300
301 yidx = uidx = vidx = 0;
302
303 switch (id) {
304 case FOURCC_YV12: {
305 int pitches[3], offsets[3];
306 unsigned char *y, *u, *v;
307 query_image_attributes(pScrn, FOURCC_YV12,
308 &w, &h, pitches, offsets);
309
310 y = buf + offsets[0];
311 v = buf + offsets[1];
312 u = buf + offsets[2];
313 for (i = 0; i < h; ++i) {
314 for (j = 0; j < w; ++j) {
315 int yoffset = (w*i+j);
316 int ii = (i|1), jj = (j|1);
317 int vuoffset = (w/2)*(ii/2) + (jj/2);
318 ymap[yidx++] = y[yoffset];
319 umap[uidx++] = u[vuoffset];
320 vmap[vidx++] = v[vuoffset];
321 }
322 }
323 }
324 break;
325 case FOURCC_UYVY:
326 for (i = 0; i < y_array_size; i +=2 ) {
327 /* extracting two pixels */
328 u = buf[0];
329 y1 = buf[1];
330 v = buf[2];
331 y2 = buf[3];
332 buf += 4;
333
334 ymap[yidx++] = y1;
335 ymap[yidx++] = y2;
336 umap[uidx++] = u;
337 umap[uidx++] = u;
338 vmap[vidx++] = v;
339 vmap[vidx++] = v;
340 }
341 break;
342 case FOURCC_YUY2:
343 for (i = 0; i < y_array_size; i +=2 ) {
344 /* extracting two pixels */
345 y1 = buf[0];
346 u = buf[1];
347 y2 = buf[2];
348 v = buf[3];
349
350 buf += 4;
351
352 ymap[yidx++] = y1;
353 ymap[yidx++] = y2;
354 umap[uidx++] = u;
355 umap[uidx++] = u;
356 vmap[vidx++] = v;
357 vmap[vidx++] = v;
358 }
359 break;
360 default:
361 debug_assert(!"Unsupported yuv format!");
362 break;
363 }
364
365 screen->transfer_unmap(screen, ytrans);
366 screen->transfer_unmap(screen, utrans);
367 screen->transfer_unmap(screen, vtrans);
368 screen->tex_transfer_destroy(ytrans);
369 screen->tex_transfer_destroy(utrans);
370 screen->tex_transfer_destroy(vtrans);
371 }
372
373
374 static void
375 setup_fs_video_constants(struct xorg_renderer *r, boolean hdtv)
376 {
377 const int param_bytes = 12 * sizeof(float);
378 const float *video_constants = (hdtv) ? bt_709 : bt_601;
379
380 renderer_set_constants(r, PIPE_SHADER_FRAGMENT,
381 video_constants, param_bytes);
382 }
383
384 static void
385 draw_yuv(struct xorg_xv_port_priv *port,
386 int src_x, int src_y, int src_w, int src_h,
387 int dst_x, int dst_y, int dst_w, int dst_h)
388 {
389 struct pipe_texture **textures = port->yuv[port->current_set];
390
391 renderer_draw_yuv(port->r,
392 src_x, src_y, src_w, src_h,
393 dst_x, dst_y, dst_w, dst_h,
394 textures);
395 }
396
397 static void
398 bind_blend_state(struct xorg_xv_port_priv *port)
399 {
400 struct pipe_blend_state blend;
401
402 memset(&blend, 0, sizeof(struct pipe_blend_state));
403 blend.blend_enable = 1;
404 blend.colormask |= PIPE_MASK_RGBA;
405
406 /* porter&duff src */
407 blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
408 blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
409 blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
410 blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
411
412 cso_set_blend(port->r->cso, &blend);
413 }
414
415
416 static void
417 bind_shaders(struct xorg_xv_port_priv *port)
418 {
419 unsigned vs_traits = 0, fs_traits = 0;
420 struct xorg_shader shader;
421
422 vs_traits |= VS_YUV;
423 fs_traits |= FS_YUV;
424
425 shader = xorg_shaders_get(port->r->shaders, vs_traits, fs_traits);
426 cso_set_vertex_shader_handle(port->r->cso, shader.vs);
427 cso_set_fragment_shader_handle(port->r->cso, shader.fs);
428 }
429
430 static INLINE void
431 conditional_flush(struct pipe_context *pipe, struct pipe_texture **tex,
432 int num)
433 {
434 int i;
435 for (i = 0; i < num; ++i) {
436 if (tex[i] && pipe->is_texture_referenced(pipe, tex[i], 0, 0) &
437 PIPE_REFERENCED_FOR_WRITE) {
438 pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
439 return;
440 }
441 }
442 }
443
444 static void
445 bind_samplers(struct xorg_xv_port_priv *port)
446 {
447 struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
448 struct pipe_sampler_state sampler;
449 struct pipe_texture **dst = port->yuv[port->current_set];
450
451 memset(&sampler, 0, sizeof(struct pipe_sampler_state));
452
453 conditional_flush(port->r->pipe, dst, 3);
454
455 sampler.wrap_s = PIPE_TEX_WRAP_CLAMP;
456 sampler.wrap_t = PIPE_TEX_WRAP_CLAMP;
457 sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
458 sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
459 sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST;
460 sampler.normalized_coords = 1;
461
462 samplers[0] = &sampler;
463 samplers[1] = &sampler;
464 samplers[2] = &sampler;
465
466
467 cso_set_samplers(port->r->cso, 3,
468 (const struct pipe_sampler_state **)samplers);
469 cso_set_sampler_textures(port->r->cso, 3,
470 dst);
471 }
472
473 static int
474 display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
475 RegionPtr dstRegion,
476 int src_x, int src_y, int src_w, int src_h,
477 int dstX, int dstY, int dst_w, int dst_h,
478 PixmapPtr pPixmap)
479 {
480 modesettingPtr ms = modesettingPTR(pScrn);
481 BoxPtr pbox;
482 int nbox;
483 int dxo, dyo;
484 Bool hdtv;
485 int x, y, w, h;
486 struct exa_pixmap_priv *dst;
487 struct pipe_surface *dst_surf = NULL;
488
489 exaMoveInPixmap(pPixmap);
490 dst = exaGetPixmapDriverPrivate(pPixmap);
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 dst_surf = xorg_gpu_surface(pPriv->r->pipe->screen, dst);
501 hdtv = ((src_w >= RES_720P_X) && (src_h >= RES_720P_Y));
502
503 REGION_TRANSLATE(pScrn->pScreen, dstRegion, -pPixmap->screen_x,
504 -pPixmap->screen_y);
505
506 dxo = dstRegion->extents.x1;
507 dyo = dstRegion->extents.y1;
508
509 pbox = REGION_RECTS(dstRegion);
510 nbox = REGION_NUM_RECTS(dstRegion);
511
512 renderer_bind_destination(pPriv->r, dst_surf,
513 dst_surf->width, dst_surf->height);
514
515 bind_blend_state(pPriv);
516 bind_shaders(pPriv);
517 bind_samplers(pPriv);
518 setup_fs_video_constants(pPriv->r, hdtv);
519
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 }