1 #include "xorg_tracker.h"
4 #include <X11/extensions/Xv.h>
7 /*XXX get these from pipe's texture limits */
8 #define IMAGE_MAX_WIDTH 2048
9 #define IMAGE_MAX_HEIGHT 2048
11 #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
13 static Atom xvBrightness
, xvContrast
;
15 #define NUM_TEXTURED_ATTRIBUTES 2
16 static XF86AttributeRec TexturedAttributes
[NUM_TEXTURED_ATTRIBUTES
] = {
17 {XvSettable
| XvGettable
, -128, 127, "XV_BRIGHTNESS"},
18 {XvSettable
| XvGettable
, 0, 255, "XV_CONTRAST"}
22 static XF86VideoFormatRec Formats
[NUM_FORMATS
] = {
23 {15, TrueColor
}, {16, TrueColor
}, {24, TrueColor
}
26 static XF86VideoEncodingRec DummyEncoding
[1] = {
30 IMAGE_MAX_WIDTH
, IMAGE_MAX_HEIGHT
,
36 static XF86ImageRec Images
[NUM_IMAGES
] = {
41 struct xorg_xv_port_priv
{
47 stop_video(ScrnInfoPtr pScrn
, pointer data
, Bool shutdown
)
52 set_port_attribute(ScrnInfoPtr pScrn
,
53 Atom attribute
, INT32 value
, pointer data
)
59 get_port_attribute(ScrnInfoPtr pScrn
,
60 Atom attribute
, INT32
* value
, pointer data
)
66 query_best_size(ScrnInfoPtr pScrn
,
68 short vid_w
, short vid_h
,
69 short drw_w
, short drw_h
,
70 unsigned int *p_w
, unsigned int *p_h
, pointer data
)
75 put_image(ScrnInfoPtr pScrn
,
76 short src_x
, short src_y
,
77 short drw_x
, short drw_y
,
78 short src_w
, short src_h
,
79 short drw_w
, short drw_h
,
80 int id
, unsigned char *buf
,
81 short width
, short height
,
82 Bool sync
, RegionPtr clipBoxes
, pointer data
,
89 query_image_attributes(ScrnInfoPtr pScrn
,
91 unsigned short *w
, unsigned short *h
,
92 int *pitches
, int *offsets
)
97 static struct xorg_xv_port_priv
*
98 port_priv_create(ScreenPtr pScreen
)
100 /*ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];*/
101 /*modesettingPtr ms = modesettingPTR(pScrn);*/
102 struct xorg_xv_port_priv
*priv
= NULL
;
104 priv
= calloc(1, sizeof(struct xorg_xv_port_priv
));
109 REGION_NULL(pScreen
, &priv
->clip
);
114 static XF86VideoAdaptorPtr
115 xorg_setup_textured_adapter(ScreenPtr pScreen
)
117 /*ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];*/
118 /*modesettingPtr ms = modesettingPTR(pScrn);*/
119 XF86VideoAdaptorPtr adapt
;
120 XF86AttributePtr attrs
;
121 DevUnion
*dev_unions
;
125 nattributes
= NUM_TEXTURED_ATTRIBUTES
;
127 adapt
= calloc(1, sizeof(XF86VideoAdaptorRec
));
128 dev_unions
= calloc(nports
, sizeof(DevUnion
));
129 attrs
= calloc(nattributes
, sizeof(XF86AttributeRec
));
130 if (adapt
== NULL
|| dev_unions
== NULL
|| attrs
== NULL
) {
137 adapt
->type
= XvWindowMask
| XvInputMask
| XvImageMask
;
139 adapt
->name
= "Gallium3D Textured Video";
140 adapt
->nEncodings
= 1;
141 adapt
->pEncodings
= DummyEncoding
;
142 adapt
->nFormats
= NUM_FORMATS
;
143 adapt
->pFormats
= Formats
;
145 adapt
->pPortPrivates
= dev_unions
;
146 adapt
->nAttributes
= nattributes
;
147 adapt
->pAttributes
= attrs
;
148 memcpy(attrs
, TexturedAttributes
, nattributes
* sizeof(XF86AttributeRec
));
149 adapt
->nImages
= NUM_IMAGES
;
150 adapt
->pImages
= Images
;
151 adapt
->PutVideo
= NULL
;
152 adapt
->PutStill
= NULL
;
153 adapt
->GetVideo
= NULL
;
154 adapt
->GetStill
= NULL
;
155 adapt
->StopVideo
= stop_video
;
156 adapt
->SetPortAttribute
= set_port_attribute
;
157 adapt
->GetPortAttribute
= get_port_attribute
;
158 adapt
->QueryBestSize
= query_best_size
;
159 adapt
->PutImage
= put_image
;
160 adapt
->QueryImageAttributes
= query_image_attributes
;
162 for (i
= 0; i
< nports
; i
++) {
163 struct xorg_xv_port_priv
*priv
=
164 port_priv_create(pScreen
);
166 adapt
->pPortPrivates
[i
].ptr
= (pointer
) (priv
);
174 xorg_init_video(ScreenPtr pScreen
)
176 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
177 /*modesettingPtr ms = modesettingPTR(pScrn);*/
178 XF86VideoAdaptorPtr
*adaptors
, *new_adaptors
= NULL
;
179 XF86VideoAdaptorPtr textured_adapter
;
182 num_adaptors
= xf86XVListGenericAdaptors(pScrn
, &adaptors
);
183 new_adaptors
= malloc((num_adaptors
+ 1) * sizeof(XF86VideoAdaptorPtr
*));
184 if (new_adaptors
== NULL
)
187 memcpy(new_adaptors
, adaptors
, num_adaptors
* sizeof(XF86VideoAdaptorPtr
));
188 adaptors
= new_adaptors
;
190 /* Add the adaptors supported by our hardware. First, set up the atoms
191 * that will be used by both output adaptors.
193 xvBrightness
= MAKE_ATOM("XV_BRIGHTNESS");
194 xvContrast
= MAKE_ATOM("XV_CONTRAST");
196 textured_adapter
= xorg_setup_textured_adapter(pScreen
);
198 debug_assert(textured_adapter
);
200 if (textured_adapter
) {
201 adaptors
[num_adaptors
++] = textured_adapter
;
205 xf86XVScreenInit(pScreen
, adaptors
, num_adaptors
);
207 xf86DrvMsg(pScrn
->scrnIndex
, X_WARNING
,
208 "Disabling Xv because no adaptors could be initialized.\n");