st/xorg: Advertise support for XvMC
[mesa/nouveau-pmpeg.git] / src / gallium / state_trackers / xorg / xorg_xvmc.c
blob0f3f3f00907ec3f39ba46029d990c04b014c4f09
1 #include "xorg_tracker.h"
3 #include <xf86.h>
4 #include <xf86xv.h>
5 #include <xf86xvmc.h>
6 #include <X11/extensions/Xv.h>
7 #include <X11/extensions/XvMC.h>
8 #include <fourcc.h>
10 #define FOURCC_RGB 0x0000003
11 #define XVIMAGE_RGB \
12 { \
13 FOURCC_RGB, \
14 XvRGB, \
15 LSBFirst, \
16 { \
17 'R', 'G', 'B', 0x00, \
18 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71 \
19 }, \
20 32, \
21 XvPacked, \
22 1, \
23 24, 0x00FF0000, 0x0000FF00, 0x000000FF, \
24 0, 0, 0, \
25 0, 0, 0, \
26 0, 0, 0, \
27 { \
28 'B','G','R','X', \
29 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 \
30 }, \
31 XvTopToBottom \
34 static int subpicture_index_list[] = {
35 FOURCC_RGB,
36 FOURCC_IA44,
37 FOURCC_AI44
40 static XF86MCImageIDList subpicture_list =
42 sizeof(subpicture_index_list)/sizeof(*subpicture_index_list),
43 subpicture_index_list
46 static XF86MCSurfaceInfoRec yv12_mpeg2_surface =
48 FOURCC_I420,
49 XVMC_CHROMA_FORMAT_420,
51 2048, 2048, 2048, 2048,
52 XVMC_IDCT | XVMC_MPEG_2,
53 XVMC_SUBPICTURE_INDEPENDENT_SCALING | XVMC_BACKEND_SUBPICTURE,
54 &subpicture_list
57 static const XF86MCSurfaceInfoRec uyvy_mpeg2_surface =
59 FOURCC_UYVY,
60 XVMC_CHROMA_FORMAT_422,
62 2048, 2048, 2048, 2048,
63 XVMC_IDCT | XVMC_MPEG_2,
64 XVMC_SUBPICTURE_INDEPENDENT_SCALING | XVMC_BACKEND_SUBPICTURE,
65 &subpicture_list
68 static XF86MCSurfaceInfoPtr surfaces[] =
70 (XF86MCSurfaceInfoPtr)&yv12_mpeg2_surface,
71 (XF86MCSurfaceInfoPtr)&uyvy_mpeg2_surface
74 static const XF86ImageRec rgb_subpicture = XVIMAGE_RGB;
75 static const XF86ImageRec ia44_subpicture = XVIMAGE_IA44;
76 static const XF86ImageRec ai44_subpicture = XVIMAGE_AI44;
78 static XF86ImagePtr subpictures[] =
80 (XF86ImagePtr)&rgb_subpicture,
81 (XF86ImagePtr)&ia44_subpicture,
82 (XF86ImagePtr)&ai44_subpicture
85 static const XF86MCAdaptorRec adaptor_template =
87 "",
88 sizeof(surfaces)/sizeof(*surfaces),
89 surfaces,
90 sizeof(subpictures)/sizeof(*subpictures),
91 subpictures,
92 (xf86XvMCCreateContextProcPtr)NULL,
93 (xf86XvMCDestroyContextProcPtr)NULL,
94 (xf86XvMCCreateSurfaceProcPtr)NULL,
95 (xf86XvMCDestroySurfaceProcPtr)NULL,
96 (xf86XvMCCreateSubpictureProcPtr)NULL,
97 (xf86XvMCDestroySubpictureProcPtr)NULL
100 void
101 xorg_xvmc_init(ScreenPtr pScreen, char *name)
103 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
104 XF86MCAdaptorPtr adaptorXvMC = xf86XvMCCreateAdaptorRec();
105 if (!adaptorXvMC)
106 return;
108 *adaptorXvMC = adaptor_template;
109 adaptorXvMC->name = name;
110 xf86DrvMsg(pScrn->scrnIndex, X_INFO,
111 "[XvMC] Associated with %s.\n", name);
112 if (!xf86XvMCScreenInit(pScreen, 1, &adaptorXvMC))
113 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
114 "[XvMC] Failed to initialize extension.\n");
115 else
116 xf86DrvMsg(pScrn->scrnIndex, X_INFO,
117 "[XvMC] Extension initialized.\n");
118 xf86XvMCDestroyAdaptorRec(adaptorXvMC);