aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/xorg/xorg_xvmc.c
blob: ea9a74150d8720b36291069f900ab49b75c82911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "xorg_tracker.h"

#include <xf86.h>
#include <xf86xv.h>
#include <xf86xvmc.h>
#include <X11/extensions/Xv.h>
#include <X11/extensions/XvMC.h>
#include <fourcc.h>

#define FOURCC_RGB 0x0000003
#define XVIMAGE_RGB								\
{										\
	FOURCC_RGB,								\
	XvRGB,									\
	LSBFirst,								\
	{									\
		'R', 'G', 'B', 0x00,						\
		0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71	\
	},									\
	32,									\
	XvPacked,								\
	1,									\
	24, 0x00FF0000, 0x0000FF00, 0x000000FF,					\
	0, 0, 0,								\
	0, 0, 0,								\
	0, 0, 0,								\
	{									\
		'B','G','R','X',						\
		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		\
	},									\
	XvTopToBottom								\
}

static int subpicture_index_list[] = {
   FOURCC_RGB,
   FOURCC_IA44,
   FOURCC_AI44
};

static XF86MCImageIDList subpicture_list =
{
   sizeof(subpicture_index_list)/sizeof(*subpicture_index_list),
   subpicture_index_list
};

static XF86MCSurfaceInfoRec yv12_mpeg2_surface =
{
   FOURCC_I420,
   XVMC_CHROMA_FORMAT_420,
   0,
   2048, 2048, 2048, 2048,
   XVMC_IDCT | XVMC_MPEG_2,
   XVMC_SUBPICTURE_INDEPENDENT_SCALING | XVMC_BACKEND_SUBPICTURE,
   &subpicture_list
};

static const XF86MCSurfaceInfoRec uyvy_mpeg2_surface =
{
   FOURCC_UYVY,
   XVMC_CHROMA_FORMAT_422,
   0,
   2048, 2048, 2048, 2048,
   XVMC_IDCT | XVMC_MPEG_2,
   XVMC_SUBPICTURE_INDEPENDENT_SCALING | XVMC_BACKEND_SUBPICTURE,
   &subpicture_list
};

static XF86MCSurfaceInfoPtr surfaces[] =
{
   (XF86MCSurfaceInfoPtr)&yv12_mpeg2_surface,
   (XF86MCSurfaceInfoPtr)&uyvy_mpeg2_surface
};

static const XF86ImageRec rgb_subpicture = XVIMAGE_RGB;
static const XF86ImageRec ia44_subpicture = XVIMAGE_IA44;
static const XF86ImageRec ai44_subpicture = XVIMAGE_AI44;

static XF86ImagePtr subpictures[] =
{
   (XF86ImagePtr)&rgb_subpicture,
   (XF86ImagePtr)&ia44_subpicture,
   (XF86ImagePtr)&ai44_subpicture
};

static const XF86MCAdaptorRec adaptor_template =
{
   "",
   sizeof(surfaces)/sizeof(*surfaces),
   surfaces,
   sizeof(subpictures)/sizeof(*subpictures),
   subpictures,
   (xf86XvMCCreateContextProcPtr)NULL,
   (xf86XvMCDestroyContextProcPtr)NULL,
   (xf86XvMCCreateSurfaceProcPtr)NULL,
   (xf86XvMCDestroySurfaceProcPtr)NULL,
   (xf86XvMCCreateSubpictureProcPtr)NULL,
   (xf86XvMCDestroySubpictureProcPtr)NULL
};

void
xorg_xvmc_init(ScreenPtr pScreen, char *name)
{
   ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
   XF86MCAdaptorPtr adaptorXvMC = xf86XvMCCreateAdaptorRec();
   if (!adaptorXvMC)
      return;

   *adaptorXvMC = adaptor_template;
   adaptorXvMC->name = name;
   xf86DrvMsg(pScrn->scrnIndex, X_INFO,
              "[XvMC] Associated with %s.\n", name);
   if (!xf86XvMCScreenInit(pScreen, 1, &adaptorXvMC))
      xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                 "[XvMC] Failed to initialize extension.\n");
   else
      xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                 "[XvMC] Extension initialized.\n");
   xf86XvMCDestroyAdaptorRec(adaptorXvMC);
}