comparison libvo/vo_svga.c @ 28649:7ec20a2f2067

Cosmetics. Reindent to 4 spaces. Checked for equality with diff -w.
author iive
date Sat, 21 Feb 2009 08:33:43 +0000
parents c8e199e21100
children f01023c524c3
comparison
equal deleted inserted replaced
28648:c8e199e21100 28649:7ec20a2f2067
101 101
102 static int image_width,image_height; // used by OSD 102 static int image_width,image_height; // used by OSD
103 static int x_pos, y_pos; 103 static int x_pos, y_pos;
104 104
105 static struct { 105 static struct {
106 int yoffset;//y position of the page 106 int yoffset;//y position of the page
107 int doffset;//display start of the page 107 int doffset;//display start of the page
108 uint8_t * vbase;//memory start address of the page 108 uint8_t * vbase;//memory start address of the page
109 int locks; 109 int locks;
110 }PageStore[MAXPAGES]; 110 }PageStore[MAXPAGES];
111 111
112 static const vo_info_t info = { 112 static const vo_info_t info = {
113 "SVGAlib", 113 "SVGAlib",
114 "svga", 114 "svga",
124 LIBVO_EXTERN(svga) 124 LIBVO_EXTERN(svga)
125 125
126 126
127 //return number of 1'st free page or -1 if no free one 127 //return number of 1'st free page or -1 if no free one
128 static inline int page_find_free(void){ 128 static inline int page_find_free(void){
129 int i; 129 int i;
130 for(i=0;i<max_pages;i++) 130 for(i=0;i<max_pages;i++)
131 if(PageStore[i].locks == PAGE_EMPTY) return i; 131 if(PageStore[i].locks == PAGE_EMPTY) return i;
132 return -1; 132 return -1;
133 } 133 }
134 134
135 static int preinit(const char *arg) 135 static int preinit(const char *arg)
136 { 136 {
137 int i,rez; 137 int i,rez;
138 char s[64]; 138 char s[64];
139 139
140 getch2_disable(); 140 getch2_disable();
141 memset(zerobuf,0,sizeof(zerobuf)); 141 memset(zerobuf,0,sizeof(zerobuf));
142 force_vm=force_native=squarepix=0; 142 force_vm=force_native=squarepix=0;
143 sync_flip=vo_vsync; 143 sync_flip=vo_vsync;
144 blackbar_osd=0; 144 blackbar_osd=0;
145 145
146 if(arg)while(*arg) { 146 if(arg)while(*arg) {
147 #ifdef CONFIG_VIDIX 147 #ifdef CONFIG_VIDIX
148 if(memcmp(arg,"vidix",5)==0) { 148 if(memcmp(arg,"vidix",5)==0) {
149 i=6; 149 i=6;
150 while(arg[i] && arg[i]!=':') i++; 150 while(arg[i] && arg[i]!=':') i++;
151 strncpy(vidix_name, arg+6, i-6); 151 strncpy(vidix_name, arg+6, i-6);
152 vidix_name[i-5]=0; 152 vidix_name[i-5]=0;
153 if(arg[i]==':')i++; 153 if(arg[i]==':')i++;
154 arg+=i; 154 arg+=i;
155 vidix_preinit(vidix_name, &video_out_svga); 155 vidix_preinit(vidix_name, &video_out_svga);
156 } 156 }
157 #endif 157 #endif
158 if(!strncmp(arg,"sq",2)) { 158 if(!strncmp(arg,"sq",2)) {
159 squarepix=1; 159 squarepix=1;
160 arg+=2; 160 arg+=2;
161 if( *arg == ':' ) arg++; 161 if( *arg == ':' ) arg++;
162 } 162 }
163 163
164 if(!strncmp(arg,"native",6)) { 164 if(!strncmp(arg,"native",6)) {
165 force_native=1; 165 force_native=1;
166 arg+=6; 166 arg+=6;
167 if( *arg == ':' ) arg++; 167 if( *arg == ':' ) arg++;
168 } 168 }
169 169
170 if(!strncmp(arg,"bbosd",5)) { 170 if(!strncmp(arg,"bbosd",5)) {
171 blackbar_osd=1; 171 blackbar_osd=1;
172 arg+=5; 172 arg+=5;
173 if( *arg == ':' ) arg++; 173 if( *arg == ':' ) arg++;
174 } 174 }
175 175
176 if(!strncmp(arg,"retrace",7)) { 176 if(!strncmp(arg,"retrace",7)) {
177 sync_flip=1; 177 sync_flip=1;
178 arg+=7; 178 arg+=7;
179 if( *arg == ':' ) arg++; 179 if( *arg == ':' ) arg++;
180 } 180 }
181 181
182 if(*arg) { 182 if(*arg) {
183 i=0; 183 i=0;
184 while(arg[i] && arg[i]!=':')i++; 184 while(arg[i] && arg[i]!=':')i++;
185 if(i<64){ 185 if(i<64){
186 strncpy(s, arg, i); 186 strncpy(s, arg, i);
187 s[i]=0; 187 s[i]=0;
188 188
189 force_vm=vga_getmodenumber(s); 189 force_vm=vga_getmodenumber(s);
190 if(force_vm>0) { 190 if(force_vm>0) {
191 mp_msg(MSGT_VO,MSGL_V, "vo_svga: Forcing mode %i\n",force_vm); 191 mp_msg(MSGT_VO,MSGL_V, "vo_svga: Forcing mode %i\n",force_vm);
192 }else{ 192 }else{
193 force_vm = 0; 193 force_vm = 0;
194 } 194 }
195 } 195 }
196 arg+=i; 196 arg+=i;
197 if(*arg==':')arg++; 197 if(*arg==':')arg++;
198 } 198 }
199 } 199 }
200 200
201 rez = vga_init(); 201 rez = vga_init();
202 if(rez != 0){ 202 if(rez != 0){
203 mp_msg(MSGT_VO,MSGL_ERR, "vo_svga: vga_init() returned error=%d\n",rez); 203 mp_msg(MSGT_VO,MSGL_ERR, "vo_svga: vga_init() returned error=%d\n",rez);
204 } 204 }
205 return !!rez; 205 return !!rez;
206 } 206 }
207 207
208 static void svga_clear_box(int x,int y,int w,int h){ 208 static void svga_clear_box(int x,int y,int w,int h){
209 uint8_t * rgbplane; 209 uint8_t * rgbplane;
210 int i; 210 int i;
211 211
212 if (mode_capabilities&CAP_ACCEL_CLEAR){ 212 if (mode_capabilities&CAP_ACCEL_CLEAR){
213 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with HW acceleration\n", 213 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with HW acceleration\n",
214 x,y,w,h); 214 x,y,w,h);
215 if(mode_capabilities&CAP_ACCEL_BACKGR) 215 if(mode_capabilities&CAP_ACCEL_BACKGR)
216 vga_accel(ACCEL_SYNC); 216 vga_accel(ACCEL_SYNC);
217 vga_accel(ACCEL_SETFGCOLOR,0);//black 217 vga_accel(ACCEL_SETFGCOLOR,0);//black
218 vga_accel(ACCEL_FILLBOX,x,y,w,h); 218 vga_accel(ACCEL_FILLBOX,x,y,w,h);
219 return; 219 return;
220 } 220 }
221 if (mode_capabilities & CAP_LINEAR){ 221 if (mode_capabilities & CAP_LINEAR){
222 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with memset\n",x,y,w,h); 222 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with memset\n",x,y,w,h);
223 rgbplane=PageStore[0].vbase + (y*mode_stride) + (x*modeinfo->bytesperpixel); 223 rgbplane=PageStore[0].vbase + (y*mode_stride) + (x*modeinfo->bytesperpixel);
224 for(i=0;i<h;i++){
225 //i'm afraid that memcpy is better optimized than memset;)
226 fast_memcpy(rgbplane,zerobuf,w*modeinfo->bytesperpixel);
227 // memset(rgbplane,0,w*modeinfo->bytesperpixel);
228 rgbplane+=mode_stride;
229 }
230 return;
231 }
232 //native
233 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with native draw \n",x,y,w,h);
234 if(modeinfo->bytesperpixel!=0) w*=modeinfo->bytesperpixel;
224 for(i=0;i<h;i++){ 235 for(i=0;i<h;i++){
225 //i'm afraid that memcpy is better optimized than memset;) 236 vga_drawscansegment(zerobuf,x,y+i,w);
226 fast_memcpy(rgbplane,zerobuf,w*modeinfo->bytesperpixel); 237 }
227 // memset(rgbplane,0,w*modeinfo->bytesperpixel);
228 rgbplane+=mode_stride;
229 }
230 return;
231 }
232 //native
233 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with native draw \n",x,y,w,h);
234 if(modeinfo->bytesperpixel!=0) w*=modeinfo->bytesperpixel;
235 for(i=0;i<h;i++){
236 vga_drawscansegment(zerobuf,x,y+i,w);
237 }
238 }; 238 };
239 239
240 static uint32_t svga_draw_image(mp_image_t *mpi){ 240 static uint32_t svga_draw_image(mp_image_t *mpi){
241 int i,x,y,w,h; 241 int i,x,y,w,h;
242 int stride; 242 int stride;
243 uint8_t *rgbplane, *base; 243 uint8_t *rgbplane, *base;
244 int bytesperline; 244 int bytesperline;
245 int page; 245 int page;
246 246
247 if(mpi->flags & MP_IMGFLAG_DIRECT){ 247 if(mpi->flags & MP_IMGFLAG_DIRECT){
248 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: drawing direct rendered surface\n"); 248 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: drawing direct rendered surface\n");
249 cpage=(uint32_t)mpi->priv; 249 cpage=(uint32_t)mpi->priv;
250 assert((cpage>=0)&&(cpage<max_pages)); 250 assert((cpage>=0)&&(cpage<max_pages));
251 return VO_TRUE; //it's already done 251 return VO_TRUE; //it's already done
252 } 252 }
253 // if (mpi->flags&MP_IMGFLAGS_DRAWBACK) 253 // if (mpi->flags&MP_IMGFLAGS_DRAWBACK)
254 // return VO_TRUE;//direct render method 2 254 // return VO_TRUE;//direct render method 2
255 255
256 //find a free page to draw into 256 //find a free page to draw into
257 //if there is no one then use the current one 257 //if there is no one then use the current one
258 page = page_find_free(); 258 page = page_find_free();
259 if(page>=0) cpage=page; 259 if(page>=0) cpage=page;
260 PageStore[cpage].locks=PAGE_BUSY; 260 PageStore[cpage].locks=PAGE_BUSY;
261 261
262 // these variables are used in loops 262 // these variables are used in loops
263 x = mpi->x; 263 x = mpi->x;
264 y = mpi->y; 264 y = mpi->y;
265 w = mpi->w; 265 w = mpi->w;
266 h = mpi->h; 266 h = mpi->h;
267 stride = mpi->stride[0]; 267 stride = mpi->stride[0];
268 rgbplane = mpi->planes[0] + y*stride + (x*mpi->bpp)/8; 268 rgbplane = mpi->planes[0] + y*stride + (x*mpi->bpp)/8;
269 x+=x_pos;//center 269 x+=x_pos;//center
270 y+=y_pos; 270 y+=y_pos;
271 271
272 if(mpi->bpp >= 8){//for modes<8 use only native 272 if(mpi->bpp >= 8){//for modes<8 use only native
273 if( (mode_capabilities&CAP_ACCEL_PUTIMAGE) && (x==0) && (w==mpi->width) && 273 if( (mode_capabilities&CAP_ACCEL_PUTIMAGE) && (x==0) && (w==mpi->width) &&
274 (stride == mode_stride) ){ //only monolite image can be accelerated 274 (stride == mode_stride) ){ //only monolite image can be accelerated
275 w=(stride*8)/mpi->bpp;//we transfer pixels in the stride so the source 275 w=(stride*8)/mpi->bpp;//we transfer pixels in the stride so the source
276 //ACCELERATE 276 //ACCELERATE
277 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using HW PutImage (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); 277 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using HW PutImage (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
278 if(mode_capabilities & CAP_ACCEL_BACKGR) 278 if(mode_capabilities & CAP_ACCEL_BACKGR)
279 vga_accel(ACCEL_SYNC); 279 vga_accel(ACCEL_SYNC);
280 280
281 vga_accel(ACCEL_PUTIMAGE,x,y+PageStore[cpage].yoffset,w,h,rgbplane); 281 vga_accel(ACCEL_PUTIMAGE,x,y+PageStore[cpage].yoffset,w,h,rgbplane);
282 return VO_TRUE; 282 return VO_TRUE;
283 } 283 }
284 284
285 if( mode_capabilities&CAP_LINEAR){ 285 if( mode_capabilities&CAP_LINEAR){
286 //DIRECT 286 //DIRECT
287 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); 287 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
288 bytesperline=(w*mpi->bpp)/8; 288 bytesperline=(w*mpi->bpp)/8;
289 base=PageStore[cpage].vbase + (y*mode_stride) + (x*mpi->bpp)/8; 289 base=PageStore[cpage].vbase + (y*mode_stride) + (x*mpi->bpp)/8;
290 290
291 for(i=0;i<h;i++){ 291 for(i=0;i<h;i++){
292 mem2agpcpy(base,rgbplane,bytesperline); 292 mem2agpcpy(base,rgbplane,bytesperline);
293 base+=mode_stride; 293 base+=mode_stride;
294 rgbplane+=stride; 294 rgbplane+=stride;
295 } 295 }
296 return VO_TRUE; 296 return VO_TRUE;
297 } 297 }
298 }//(modebpp>=8 298 }//(modebpp>=8
299 299
300 300
301 //NATIVE 301 //NATIVE
302 { 302 {
303 int length; 303 int length;
304 length=(w*mpi->bpp)/8; 304 length=(w*mpi->bpp)/8;
305 //one byte per pixel! svgalib innovation 305 //one byte per pixel! svgalib innovation
306 if(mpi->imgfmt==IMGFMT_RG4B || mpi->imgfmt==IMGFMT_BG4B) length=w; 306 if(mpi->imgfmt==IMGFMT_RG4B || mpi->imgfmt==IMGFMT_BG4B) length=w;
307 307
308 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); 308 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
309 y+=PageStore[cpage].yoffset;//y position of the page beggining 309 y+=PageStore[cpage].yoffset;//y position of the page beggining
310 for(i=0;i<h;i++){ 310 for(i=0;i<h;i++){
311 vga_drawscansegment(rgbplane,x,y+i,length); 311 vga_drawscansegment(rgbplane,x,y+i,length);
312 rgbplane+=stride; 312 rgbplane+=stride;
313 } 313 }
314 } 314 }
315 return VO_TRUE; 315 return VO_TRUE;
316 } 316 }
317 317
318 static int bpp_from_vminfo(vga_modeinfo *vminfo){ 318 static int bpp_from_vminfo(vga_modeinfo *vminfo){
319 switch(vminfo->colors){ 319 switch(vminfo->colors){
320 case 2: return 1; 320 case 2: return 1;
321 case 16: return 4; 321 case 16: return 4;
322 case 256: return 8; 322 case 256: return 8;
323 case 32768: return 15; 323 case 32768: return 15;
324 case 65536: return 16; 324 case 65536: return 16;
325 case 1<<24: return 8*vminfo->bytesperpixel; 325 case 1<<24: return 8*vminfo->bytesperpixel;
326 } 326 }
327 return 0; 327 return 0;
328 } 328 }
329 329
330 static int find_best_svga_mode(int req_w,int req_h, int req_bpp){ 330 static int find_best_svga_mode(int req_w,int req_h, int req_bpp){
331 int badness,prev_badness; 331 int badness,prev_badness;
332 int bestmode,lastmode; 332 int bestmode,lastmode;
333 int i; 333 int i;
334 vga_modeinfo *vminfo; 334 vga_modeinfo *vminfo;
335 //int best aspect mode // best linear mode // best normal mode (no modeX) 335 //int best aspect mode // best linear mode // best normal mode (no modeX)
336 336
337 prev_badness = 0;//take care of special case below 337 prev_badness = 0;//take care of special case below
338 bestmode = 0; //0 is the TEXT mode 338 bestmode = 0; //0 is the TEXT mode
339 lastmode = vga_lastmodenumber(); 339 lastmode = vga_lastmodenumber();
340 for(i=1;i<=lastmode;i++){ 340 for(i=1;i<=lastmode;i++){
341 vminfo = vga_getmodeinfo(i); 341 vminfo = vga_getmodeinfo(i);
342 if( vminfo == NULL ) continue; 342 if( vminfo == NULL ) continue;
343 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: testing mode %d (%s)\n",i,vga_getmodename(i)); 343 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: testing mode %d (%s)\n",i,vga_getmodename(i));
344 if( vga_hasmode(i) == 0 ) continue; 344 if( vga_hasmode(i) == 0 ) continue;
345 if( req_bpp != bpp_from_vminfo(vminfo) )continue; 345 if( req_bpp != bpp_from_vminfo(vminfo) )continue;
346 if( (vminfo->width < req_w) || (vminfo->height < req_h) ) continue; 346 if( (vminfo->width < req_w) || (vminfo->height < req_h) ) continue;
347 badness=(vminfo->width * vminfo->height) - (req_h * req_w); 347 badness=(vminfo->width * vminfo->height) - (req_h * req_w);
348 //put here aspect calculations 348 //put here aspect calculations
349 if(squarepix) 349 if(squarepix)
350 if( vminfo->width*3 != vminfo->height*4 ) continue; 350 if( vminfo->width*3 != vminfo->height*4 ) continue;
351 351
352 if( bestmode==0 || prev_badness >= badness ){//modeX etc... 352 if( bestmode==0 || prev_badness >= badness ){//modeX etc...
353 prev_badness=badness; 353 prev_badness=badness;
354 bestmode=i; 354 bestmode=i;
355 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: found good mode %d with badness %d\n",i,badness); 355 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: found good mode %d with badness %d\n",i,badness);
356 } 356 }
357 } 357 }
358 return bestmode; 358 return bestmode;
359 } 359 }
360 360
361 static int control(uint32_t request, void *data, ...) 361 static int control(uint32_t request, void *data, ...)
362 { 362 {
363 switch (request) { 363 switch (request) {
364 case VOCTRL_QUERY_FORMAT: 364 case VOCTRL_QUERY_FORMAT:
365 return query_format(*((uint32_t*)data)); 365 return query_format(*((uint32_t*)data));
366 case VOCTRL_DRAW_IMAGE: 366 case VOCTRL_DRAW_IMAGE:
367 return svga_draw_image( (mp_image_t *)data); 367 return svga_draw_image( (mp_image_t *)data);
368 case VOCTRL_GET_IMAGE: 368 case VOCTRL_GET_IMAGE:
369 return get_image(data); 369 return get_image(data);
370 } 370 }
371 371
372 #ifdef CONFIG_VIDIX 372 #ifdef CONFIG_VIDIX
373 if (vidix_name[0]) { 373 if (vidix_name[0]) {
374 switch (request) { 374 switch (request) {
375 case VOCTRL_SET_EQUALIZER: 375 case VOCTRL_SET_EQUALIZER:
376 { 376 {
377 va_list ap; 377 va_list ap;
378 int value; 378 int value;
379 379
380 va_start(ap, data); 380 va_start(ap, data);
381 value = va_arg(ap, int); 381 value = va_arg(ap, int);
382 va_end(ap); 382 va_end(ap);
383 383
384 return vidix_control(request, data, value); 384 return vidix_control(request, data, value);
385 } 385 }
386 case VOCTRL_GET_EQUALIZER: 386 case VOCTRL_GET_EQUALIZER:
387 { 387 {
388 va_list ap; 388 va_list ap;
389 int *value; 389 int *value;
390 390
391 va_start(ap, data); 391 va_start(ap, data);
392 value = va_arg(ap, int*); 392 value = va_arg(ap, int*);
393 va_end(ap); 393 va_end(ap);
394 394
395 return vidix_control(request, data, value); 395 return vidix_control(request, data, value);
396 } 396 }
397 } 397 }
398 return vidix_control(request, data); 398 return vidix_control(request, data);
399 } 399 }
400 #endif 400 #endif
401 401
402 return VO_NOTIMPL; 402 return VO_NOTIMPL;
403 } 403 }
404 404
405 // 405 //
406 // This function is called to init the video driver for specific mode 406 // This function is called to init the video driver for specific mode
407 // 407 //
408 static int config(uint32_t width, uint32_t height, uint32_t d_width, 408 static int config(uint32_t width, uint32_t height, uint32_t d_width,
409 uint32_t d_height, uint32_t flags, char *title, 409 uint32_t d_height, uint32_t flags, char *title,
410 uint32_t format) { 410 uint32_t format) {
411 int32_t req_w = width;// (d_width > 0 ? d_width : width); 411 int32_t req_w = width;// (d_width > 0 ? d_width : width);
412 int32_t req_h = height;// (d_height > 0 ? d_height : height); 412 int32_t req_h = height;// (d_height > 0 ? d_height : height);
413 uint16_t vid_mode = 0; 413 uint16_t vid_mode = 0;
414 int32_t req_bpp; 414 int32_t req_bpp;
415 415
416 uint32_t accflags; 416 uint32_t accflags;
417 mp_msg(MSGT_VO,MSGL_V, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height, 417 mp_msg(MSGT_VO,MSGL_V, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height,
418 d_width, d_height, flags, title, format); 418 d_width, d_height, flags, title, format);
419 //Only RGB modes supported 419 //Only RGB modes supported
420 if (!IMGFMT_IS_RGB(format) && !IMGFMT_IS_BGR(format)) {assert(0);return -1;} 420 if (!IMGFMT_IS_RGB(format) && !IMGFMT_IS_BGR(format)) {assert(0);return -1;}
421 req_bpp = IMGFMT_BGR_DEPTH(format); 421 req_bpp = IMGFMT_BGR_DEPTH(format);
422 422
423 if( vo_dbpp!=0 && vo_dbpp!=req_bpp) {assert(0);return-1;} 423 if( vo_dbpp!=0 && vo_dbpp!=req_bpp) {assert(0);return-1;}
424 424
425 if(!force_vm) { 425 if(!force_vm) {
426 mp_msg(MSGT_VO,MSGL_V, "vo_svga: Looking for the best resolution...\n"); 426 mp_msg(MSGT_VO,MSGL_V, "vo_svga: Looking for the best resolution...\n");
427 mp_msg(MSGT_VO,MSGL_V, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp); 427 mp_msg(MSGT_VO,MSGL_V, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp);
428 vid_mode=find_best_svga_mode(req_w,req_h,req_bpp); 428 vid_mode=find_best_svga_mode(req_w,req_h,req_bpp);
429 if(vid_mode==0) 429 if(vid_mode==0)
430 return 1; 430 return 1;
431 modeinfo=vga_getmodeinfo(vid_mode); 431 modeinfo=vga_getmodeinfo(vid_mode);
432 }else{//force_vm 432 }else{//force_vm
433 vid_mode=force_vm; 433 vid_mode=force_vm;
434 if(vga_hasmode(vid_mode) == 0){ 434 if(vga_hasmode(vid_mode) == 0){
435 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeNotAvailable, 435 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeNotAvailable,
436 vid_mode,vga_getmodename(vid_mode)); 436 vid_mode,vga_getmodename(vid_mode));
437 return 1; //error; 437 return 1; //error;
438 } 438 }
439 modeinfo=vga_getmodeinfo(vid_mode); 439 modeinfo=vga_getmodeinfo(vid_mode);
440 if( (modeinfo->width < req_w) || (modeinfo->height < req_h) ){ 440 if( (modeinfo->width < req_w) || (modeinfo->height < req_h) ){
441 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeTooSmall, 441 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeTooSmall,
442 vid_mode,vga_getmodename(vid_mode)); 442 vid_mode,vga_getmodename(vid_mode));
443 return 1; 443 return 1;
444 } 444 }
445 } 445 }
446 mode_bpp=bpp_from_vminfo(modeinfo); 446 mode_bpp=bpp_from_vminfo(modeinfo);
447 447
448 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode, 448 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode,
449 vid_mode,modeinfo->width,modeinfo->height,mode_bpp); 449 vid_mode,modeinfo->width,modeinfo->height,mode_bpp);
450 450
451 if (vga_setmode(vid_mode) == -1) { 451 if (vga_setmode(vid_mode) == -1) {
452 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode); 452 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode);
453 uninit(); 453 uninit();
454 return 1; // error 454 return 1; // error
455 } 455 }
456 /* set 332 palette for 8 bpp */ 456 /* set 332 palette for 8 bpp */
457 if(mode_bpp==8){ 457 if(mode_bpp==8){
458 int i; 458 int i;
459 for(i=0; i<256; i++) 459 for(i=0; i<256; i++)
460 vga_setpalette(i, ((i>>5)&7)*9, ((i>>2)&7)*9, (i&3)*21); 460 vga_setpalette(i, ((i>>5)&7)*9, ((i>>2)&7)*9, (i&3)*21);
461 } 461 }
462 /* set 121 palette for 4 bpp */ 462 /* set 121 palette for 4 bpp */
463 else if(mode_bpp==4){ 463 else if(mode_bpp==4){
464 int i; 464 int i;
465 for(i=0; i<16; i++) 465 for(i=0; i<16; i++)
466 vga_setpalette(i, ((i>>3)&1)*63, ((i>>1)&3)*21, (i&1)*63); 466 vga_setpalette(i, ((i>>3)&1)*63, ((i>>1)&3)*21, (i&1)*63);
467 } 467 }
468 //if we change the logical width, we should know the granularity 468 //if we change the logical width, we should know the granularity
469 stride_granularity=8;//according to man vga_logicalwidth 469 stride_granularity=8;//according to man vga_logicalwidth
470 if(modeinfo->flags & EXT_INFO_AVAILABLE){ 470 if(modeinfo->flags & EXT_INFO_AVAILABLE){
471 stride_granularity=modeinfo->linewidth_unit; 471 stride_granularity=modeinfo->linewidth_unit;
472 } 472 }
473 //look for hardware acceleration 473 //look for hardware acceleration
474 mode_capabilities=0;//NATIVE; 474 mode_capabilities=0;//NATIVE;
475 if(!force_native){//if we want to use only native drawers 475 if(!force_native){//if we want to use only native drawers
476 if(modeinfo->flags & HAVE_EXT_SET){//support for hwaccel interface 476 if(modeinfo->flags & HAVE_EXT_SET){//support for hwaccel interface
477 accflags=vga_ext_set(VGA_EXT_AVAILABLE,VGA_AVAIL_ACCEL); 477 accflags=vga_ext_set(VGA_EXT_AVAILABLE,VGA_AVAIL_ACCEL);
478 if(accflags & ACCELFLAG_FILLBOX) // clear screen 478 if(accflags & ACCELFLAG_FILLBOX) // clear screen
479 mode_capabilities|=CAP_ACCEL_CLEAR; 479 mode_capabilities|=CAP_ACCEL_CLEAR;
480 if(accflags & ACCELFLAG_PUTIMAGE)//support for mem->vid transfer 480 if(accflags & ACCELFLAG_PUTIMAGE)//support for mem->vid transfer
481 mode_capabilities|=CAP_ACCEL_PUTIMAGE; 481 mode_capabilities|=CAP_ACCEL_PUTIMAGE;
482 if((accflags & ACCELFLAG_SETMODE) && (accflags & ACCELFLAG_SYNC)){ 482 if((accflags & ACCELFLAG_SETMODE) && (accflags & ACCELFLAG_SYNC)){
483 vga_accel(ACCEL_SETMODE,BLITS_IN_BACKGROUND); 483 vga_accel(ACCEL_SETMODE,BLITS_IN_BACKGROUND);
484 mode_capabilities|=CAP_ACCEL_BACKGR;//can draw in backgraund 484 mode_capabilities|=CAP_ACCEL_BACKGR;//can draw in backgraund
485 } 485 }
486 } 486 }
487 if(modeinfo->flags & IS_LINEAR){ 487 if(modeinfo->flags & IS_LINEAR){
488 mode_capabilities|=CAP_LINEAR; //don't use bank & vga_draw 488 mode_capabilities|=CAP_LINEAR; //don't use bank & vga_draw
489 } 489 }
490 else{ 490 else{
491 if(modeinfo->flags & CAPABLE_LINEAR){ 491 if(modeinfo->flags & CAPABLE_LINEAR){
492 int vid_mem_size; 492 int vid_mem_size;
493 vid_mem_size = vga_setlinearaddressing(); 493 vid_mem_size = vga_setlinearaddressing();
494 if(vid_mem_size != -1){ 494 if(vid_mem_size != -1){
495 modeinfo=vga_getmodeinfo(vid_mode);//sometimes they change parameters 495 modeinfo=vga_getmodeinfo(vid_mode);//sometimes they change parameters
496 mode_capabilities|=CAP_LINEAR; 496 mode_capabilities|=CAP_LINEAR;
497 } 497 }
498 } 498 }
499 } 499 }
500 }//fi force native 500 }//fi force native
501 if(mode_capabilities&CAP_LINEAR){ 501 if(mode_capabilities&CAP_LINEAR){
502 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeIsLinearAndMemcpyCouldBeUsed); 502 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeIsLinearAndMemcpyCouldBeUsed);
503 } 503 }
504 if(mode_capabilities&CAP_ACCEL_PUTIMAGE){ 504 if(mode_capabilities&CAP_ACCEL_PUTIMAGE){
505 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHasHardwareAcceleration); 505 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHasHardwareAcceleration);
506 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_IfItWorksForYouIWouldLikeToKnow); 506 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_IfItWorksForYouIWouldLikeToKnow);
507 } 507 }
508 508
509 //here is the place to handle strides for accel_ modes; 509 //here is the place to handle strides for accel_ modes;
510 mode_stride=modeinfo->linewidth; 510 mode_stride=modeinfo->linewidth;
511 //we may try to set a bigger stride for video mode that will match the mpi->stride, 511 //we may try to set a bigger stride for video mode that will match the mpi->stride,
512 //this way we will transfer more data, but HW put_image can do it in backgraund! 512 //this way we will transfer more data, but HW put_image can do it in backgraund!
513 513
514 //now let's see how many pages we can use 514 //now let's see how many pages we can use
515 max_pages = modeinfo->maxpixels/(modeinfo->height * modeinfo->width); 515 max_pages = modeinfo->maxpixels/(modeinfo->height * modeinfo->width);
516 if(max_pages > MAXPAGES) max_pages = MAXPAGES; 516 if(max_pages > MAXPAGES) max_pages = MAXPAGES;
517 if(!vo_doublebuffering) max_pages=1; 517 if(!vo_doublebuffering) max_pages=1;
518 //fill PageStore structs 518 //fill PageStore structs
519 { 519 {
520 int i; 520 int i;
521 uint8_t * GRAPH_MEM; 521 uint8_t * GRAPH_MEM;
522 int dof; 522 int dof;
523 GRAPH_MEM=vga_getgraphmem(); 523 GRAPH_MEM=vga_getgraphmem();
524 for(i=0;i<max_pages;i++){ 524 for(i=0;i<max_pages;i++){
525 //calculate display offset 525 //calculate display offset
526 dof = i * modeinfo->height * modeinfo->width; 526 dof = i * modeinfo->height * modeinfo->width;
527 if(modeinfo->bytesperpixel != 0) dof*=modeinfo->bytesperpixel; 527 if(modeinfo->bytesperpixel != 0) dof*=modeinfo->bytesperpixel;
528 //check video chip limitations 528 //check video chip limitations
529 if( dof != (dof & modeinfo->startaddressrange) ){ 529 if( dof != (dof & modeinfo->startaddressrange) ){
530 max_pages=i;//page 0 will never come here 530 max_pages=i;//page 0 will never come here
531 break; 531 break;
532 } 532 }
533 PageStore[i].yoffset = i * modeinfo->height;//starting y offset 533 PageStore[i].yoffset = i * modeinfo->height;//starting y offset
534 PageStore[i].vbase = GRAPH_MEM + i*modeinfo->height*mode_stride; //memory base address 534 PageStore[i].vbase = GRAPH_MEM + i*modeinfo->height*mode_stride; //memory base address
535 PageStore[i].doffset = dof; //display offset 535 PageStore[i].doffset = dof; //display offset
536 PageStore[i].locks = PAGE_EMPTY; 536 PageStore[i].locks = PAGE_EMPTY;
537 } 537 }
538 } 538 }
539 assert(max_pages>0); 539 assert(max_pages>0);
540 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHas,max_pages); 540 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHas,max_pages);
541 //15bpp 541 //15bpp
542 if(modeinfo->bytesperpixel!=0) 542 if(modeinfo->bytesperpixel!=0)
543 vga_claimvideomemory(max_pages * modeinfo->height * modeinfo->width * modeinfo->bytesperpixel); 543 vga_claimvideomemory(max_pages * modeinfo->height * modeinfo->width * modeinfo->bytesperpixel);
544 else 544 else
545 vga_claimvideomemory(max_pages * modeinfo->height * modeinfo->width * mode_bpp / 8); 545 vga_claimvideomemory(max_pages * modeinfo->height * modeinfo->width * mode_bpp / 8);
546 546
547 cpage=old_page=0; 547 cpage=old_page=0;
548 svga_clear_box(0,0,modeinfo->width,modeinfo->height * max_pages); 548 svga_clear_box(0,0,modeinfo->width,modeinfo->height * max_pages);
549 549
550 image_height=req_h; 550 image_height=req_h;
551 image_width=req_w; 551 image_width=req_w;
552 x_pos = (modeinfo->width - req_w) / 2; 552 x_pos = (modeinfo->width - req_w) / 2;
553 y_pos = (modeinfo->height - req_h) / 2; 553 y_pos = (modeinfo->height - req_h) / 2;
554 x_pos &= ~(15); //align x offset position to 16 pixels 554 x_pos &= ~(15); //align x offset position to 16 pixels
555 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_CenteringImageStartAt,x_pos,y_pos); 555 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_CenteringImageStartAt,x_pos,y_pos);
556 556
557 #ifdef CONFIG_VIDIX 557 #ifdef CONFIG_VIDIX
558 558
559 if(vidix_name[0]){ 559 if(vidix_name[0]){
560 vidix_init(width, height, x_pos, y_pos, modeinfo->width, modeinfo->height, 560 vidix_init(width, height, x_pos, y_pos, modeinfo->width, modeinfo->height,
561 format, mode_bpp, modeinfo->width,modeinfo->height); 561 format, mode_bpp, modeinfo->width,modeinfo->height);
562 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_UsingVidix,width,height, 562 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_UsingVidix,width,height,
563 modeinfo->width,modeinfo->height); 563 modeinfo->width,modeinfo->height);
564 vidix_start(); 564 vidix_start();
565 /*set colorkey*/ 565 /*set colorkey*/
566 if(vidix_grkey_support()){ 566 if(vidix_grkey_support()){
567 vidix_grkey_get(&gr_key); 567 vidix_grkey_get(&gr_key);
568 gr_key.key_op = KEYS_PUT; 568 gr_key.key_op = KEYS_PUT;
569 if (!(vo_colorkey & 0xFF000000)) { 569 if (!(vo_colorkey & 0xFF000000)) {
570 gr_key.ckey.op = CKEY_TRUE; 570 gr_key.ckey.op = CKEY_TRUE;
571 gr_key.ckey.red = (vo_colorkey & 0x00FF0000) >> 16; 571 gr_key.ckey.red = (vo_colorkey & 0x00FF0000) >> 16;
572 gr_key.ckey.green = (vo_colorkey & 0x0000FF00) >> 8; 572 gr_key.ckey.green = (vo_colorkey & 0x0000FF00) >> 8;
573 gr_key.ckey.blue = vo_colorkey & 0x000000FF; 573 gr_key.ckey.blue = vo_colorkey & 0x000000FF;
574 } else 574 } else
575 gr_key.ckey.op = CKEY_FALSE; 575 gr_key.ckey.op = CKEY_FALSE;
576 vidix_grkey_set(&gr_key); 576 vidix_grkey_set(&gr_key);
577 } 577 }
578 } 578 }
579 #endif 579 #endif
580 580
581 vga_setdisplaystart(0); 581 vga_setdisplaystart(0);
582 return 0; 582 return 0;
583 } 583 }
584 584
585 static int draw_slice(uint8_t *image[],int stride[], 585 static int draw_slice(uint8_t *image[],int stride[],
586 int w, int h, int x, int y) { 586 int w, int h, int x, int y) {
587 assert(0); 587 assert(0);
588 UNUSED(image);UNUSED(stride); 588 UNUSED(image);UNUSED(stride);
589 UNUSED(w);UNUSED(h); 589 UNUSED(w);UNUSED(h);
590 UNUSED(x);UNUSED(y); 590 UNUSED(x);UNUSED(y);
591 591
592 return VO_ERROR;//this is yv12 only -> vf_scale should do all transforms 592 return VO_ERROR;//this is yv12 only -> vf_scale should do all transforms
593 } 593 }
594 594
595 static int draw_frame(uint8_t *src[]) { 595 static int draw_frame(uint8_t *src[]) {
596 assert(0); 596 assert(0);
597 UNUSED(src); 597 UNUSED(src);
598 return VO_ERROR;//this one should not be called 598 return VO_ERROR;//this one should not be called
599 } 599 }
600 600
601 static void draw_osd(void) 601 static void draw_osd(void)
602 { 602 {
603 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: draw_osd()\n"); 603 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: draw_osd()\n");
604 //only modes with bytesperpixel>0 can draw OSD 604 //only modes with bytesperpixel>0 can draw OSD
605 if(modeinfo->bytesperpixel==0) return; 605 if(modeinfo->bytesperpixel==0) return;
606 if(!(mode_capabilities&CAP_LINEAR)) return;//force_native will remove OSD 606 if(!(mode_capabilities&CAP_LINEAR)) return;//force_native will remove OSD
607 607
608 if(blackbar_osd){ 608 if(blackbar_osd){
609 //111 609 //111
610 //3 4 610 //3 4
611 //222 611 //222
612 svga_clear_box(0,0 + PageStore[cpage].yoffset, 612 svga_clear_box(0,0 + PageStore[cpage].yoffset,
613 modeinfo->width, y_pos); 613 modeinfo->width, y_pos);
614 svga_clear_box(0, image_height + y_pos + PageStore[cpage].yoffset, 614 svga_clear_box(0, image_height + y_pos + PageStore[cpage].yoffset,
615 modeinfo->width, modeinfo->height-(image_height+ y_pos)); 615 modeinfo->width, modeinfo->height-(image_height+ y_pos));
616 svga_clear_box(0, y_pos + PageStore[cpage].yoffset, 616 svga_clear_box(0, y_pos + PageStore[cpage].yoffset,
617 x_pos, image_height); 617 x_pos, image_height);
618 svga_clear_box(image_width + x_pos, y_pos + PageStore[cpage].yoffset, 618 svga_clear_box(image_width + x_pos, y_pos + PageStore[cpage].yoffset,
619 modeinfo->width-(x_pos+image_width), image_height); 619 modeinfo->width-(x_pos+image_width), image_height);
620 // vo_remove_text(modeinfo->width, modeinfo->height, clear_alpha); 620 // vo_remove_text(modeinfo->width, modeinfo->height, clear_alpha);
621 vo_draw_text(modeinfo->width, modeinfo->height, draw_alpha); 621 vo_draw_text(modeinfo->width, modeinfo->height, draw_alpha);
622 }else{ 622 }else{
623 vo_draw_text(image_width, image_height, draw_alpha); 623 vo_draw_text(image_width, image_height, draw_alpha);
624 } 624 }
625 } 625 }
626 626
627 static void flip_page(void) { 627 static void flip_page(void) {
628 PageStore[old_page].locks=PAGE_EMPTY; 628 PageStore[old_page].locks=PAGE_EMPTY;
629 PageStore[cpage].locks=PAGE_BUSY; 629 PageStore[cpage].locks=PAGE_BUSY;
630 630
631 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: viewing page %d\n",cpage); 631 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: viewing page %d\n",cpage);
632 if(sync_flip && old_page!=cpage){ 632 if(sync_flip && old_page!=cpage){
633 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga:vga_waitretrace\n"); 633 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga:vga_waitretrace\n");
634 vga_waitretrace(); 634 vga_waitretrace();
635 } 635 }
636 vga_setdisplaystart(PageStore[cpage].doffset); 636 vga_setdisplaystart(PageStore[cpage].doffset);
637 637
638 old_page=cpage;//cpage will be overwriten on next draw_image 638 old_page=cpage;//cpage will be overwriten on next draw_image
639 } 639 }
640 640
641 static void check_events(void) { 641 static void check_events(void) {
642 } 642 }
643 643
644 static void uninit(void) { 644 static void uninit(void) {
645 645
646 #ifdef CONFIG_VIDIX 646 #ifdef CONFIG_VIDIX
647 if(vidix_name[0])vidix_term(); 647 if(vidix_name[0])vidix_term();
648 #endif 648 #endif
649 vga_setmode(TEXT); 649 vga_setmode(TEXT);
650 } 650 }
651 651
652 /* --------------------------------------------------------------------- */ 652 /* --------------------------------------------------------------------- */
653 static int query_format(uint32_t format) { 653 static int query_format(uint32_t format) {
654 int32_t req_bpp,flags; 654 int32_t req_bpp,flags;
655 int i,lastmode; 655 int i,lastmode;
656 vga_modeinfo * vminfo; 656 vga_modeinfo * vminfo;
657 657
658 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: query_format=%X \n",format); 658 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: query_format=%X \n",format);
659 //only RGB modes supported 659 //only RGB modes supported
660 if( (!IMGFMT_IS_RGB(format)) && (!IMGFMT_IS_BGR(format)) ) return 0; 660 if( (!IMGFMT_IS_RGB(format)) && (!IMGFMT_IS_BGR(format)) ) return 0;
661 661
662 // Reject different endian 662 // Reject different endian
663 #ifdef WORDS_BIGENDIAN 663 #ifdef WORDS_BIGENDIAN
664 if (IMGFMT_IS_BGR(format)) return 0; 664 if (IMGFMT_IS_BGR(format)) return 0;
665 #else 665 #else
666 if (IMGFMT_IS_RGB(format)) return 0; 666 if (IMGFMT_IS_RGB(format)) return 0;
667 #endif 667 #endif
668 668
669 //svgalib supports only BG4B! if we want BGR4 we have to emulate it (sw) 669 //svgalib supports only BG4B! if we want BGR4 we have to emulate it (sw)
670 if( format==IMGFMT_BGR4 || format==IMGFMT_RGB4) return 0; 670 if( format==IMGFMT_BGR4 || format==IMGFMT_RGB4) return 0;
671 req_bpp = IMGFMT_RGB_DEPTH(format); 671 req_bpp = IMGFMT_RGB_DEPTH(format);
672 if( vo_dbpp>0 && vo_dbpp!=req_bpp ) return 0; //support -bpp options 672 if( vo_dbpp>0 && vo_dbpp!=req_bpp ) return 0; //support -bpp options
673 //scan all modes 673 //scan all modes
674 lastmode = vga_lastmodenumber(); 674 lastmode = vga_lastmodenumber();
675 for(i=1;i<=lastmode;i++){ 675 for(i=1;i<=lastmode;i++){
676 vminfo = vga_getmodeinfo(i); 676 vminfo = vga_getmodeinfo(i);
677 if( vminfo == NULL ) continue; 677 if( vminfo == NULL ) continue;
678 if( vga_hasmode(i) == 0 ) continue; 678 if( vga_hasmode(i) == 0 ) continue;
679 if( req_bpp != bpp_from_vminfo(vminfo) ) continue; 679 if( req_bpp != bpp_from_vminfo(vminfo) ) continue;
680 if( (force_vm > 0) && (force_vm != i) ) continue;//quick hack 680 if( (force_vm > 0) && (force_vm != i) ) continue;//quick hack
681 flags = VFCAP_CSP_SUPPORTED| 681 flags = VFCAP_CSP_SUPPORTED|
682 VFCAP_CSP_SUPPORTED_BY_HW| 682 VFCAP_CSP_SUPPORTED_BY_HW|
683 VFCAP_ACCEPT_STRIDE| 683 VFCAP_ACCEPT_STRIDE|
684 0; 684 0;
685 if(req_bpp>8) flags|=VFCAP_OSD; 685 if(req_bpp>8) flags|=VFCAP_OSD;
686 return flags; 686 return flags;
687 } 687 }
688 return 0; 688 return 0;
689 } 689 }
690 690
691 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, 691 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
692 unsigned char *srca, int stride) { 692 unsigned char *srca, int stride) {
693 char* base; 693 char* base;
694 694
695 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: draw_alpha(x0=%d,y0=%d,w=%d,h=%d,src=%p,srca=%p,stride=%d\n", 695 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: draw_alpha(x0=%d,y0=%d,w=%d,h=%d,src=%p,srca=%p,stride=%d\n",
696 x0,y0,w,h,src,srca,stride); 696 x0,y0,w,h,src,srca,stride);
697 if(!blackbar_osd) { 697 if(!blackbar_osd) {
698 //drawing in the image, so place the stuff there 698 //drawing in the image, so place the stuff there
699 x0+=x_pos; 699 x0+=x_pos;
700 y0+=y_pos; 700 y0+=y_pos;
701 } 701 }
702 702
703 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: OSD draw in page %d\n",cpage); 703 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: OSD draw in page %d\n",cpage);
704 base=PageStore[cpage].vbase + y0*mode_stride + x0*modeinfo->bytesperpixel; 704 base=PageStore[cpage].vbase + y0*mode_stride + x0*modeinfo->bytesperpixel;
705 switch (mode_bpp) { 705 switch (mode_bpp) {
706 case 32: 706 case 32:
707 vo_draw_alpha_rgb32(w, h, src, srca, stride, base, mode_stride); 707 vo_draw_alpha_rgb32(w, h, src, srca, stride, base, mode_stride);
708 break; 708 break;
709 case 24: 709 case 24:
710 vo_draw_alpha_rgb24(w, h, src, srca, stride, base, mode_stride); 710 vo_draw_alpha_rgb24(w, h, src, srca, stride, base, mode_stride);
711 break; 711 break;
712 case 16: 712 case 16:
713 vo_draw_alpha_rgb16(w, h, src, srca, stride, base, mode_stride); 713 vo_draw_alpha_rgb16(w, h, src, srca, stride, base, mode_stride);
714 break; 714 break;
715 case 15: 715 case 15:
716 vo_draw_alpha_rgb15(w, h, src, srca, stride, base, mode_stride); 716 vo_draw_alpha_rgb15(w, h, src, srca, stride, base, mode_stride);
717 break; 717 break;
718 } 718 }
719 } 719 }
720 720
721 static uint32_t get_image(mp_image_t *mpi){ 721 static uint32_t get_image(mp_image_t *mpi){
722 int page; 722 int page;
723 723
724 if(!IMGFMT_IS_BGR(mpi->imgfmt) && !IMGFMT_IS_RGB(mpi->imgfmt) ){ 724 if(!IMGFMT_IS_BGR(mpi->imgfmt) && !IMGFMT_IS_RGB(mpi->imgfmt) ){
725 assert(0);//should never happen 725 assert(0);//should never happen
726 return VO_FALSE;
727 }
728
729 if (
730 ( (mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) ||
731 (mpi->flags & MP_IMGFLAG_PLANAR) ||
732 (mpi->flags & MP_IMGFLAG_YUV)
733 )
726 return VO_FALSE; 734 return VO_FALSE;
727 } 735
728 736 //reading from video memory is horribly slow
729 if ( 737 if( !(mpi->flags & MP_IMGFLAG_READABLE) && vo_directrendering &&
730 ( (mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) || 738 (mode_capabilities & CAP_LINEAR) ){
731 (mpi->flags & MP_IMGFLAG_PLANAR) || 739
732 (mpi->flags & MP_IMGFLAG_YUV) 740 //find free page and reserve it
733 ) 741 page=page_find_free();
742 if(page >= 0){
743 PageStore[page].locks=PAGE_BUSY;
744
745 mpi->flags |= MP_IMGFLAG_DIRECT;
746 mpi->stride[0] = mode_stride;
747 mpi->planes[0] = PageStore[page].vbase +
748 y_pos*mode_stride + (x_pos*mpi->bpp)/8;
749 mpi->priv=(void *)page;
750 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: direct render allocated! page=%d\n",page);
751 return VO_TRUE;
752 }
753 }
754
734 return VO_FALSE; 755 return VO_FALSE;
735 756 }
736 //reading from video memory is horribly slow
737 if( !(mpi->flags & MP_IMGFLAG_READABLE) && vo_directrendering &&
738 (mode_capabilities & CAP_LINEAR) ){
739
740 //find free page and reserve it
741 page=page_find_free();
742 if(page >= 0){
743 PageStore[page].locks=PAGE_BUSY;
744
745 mpi->flags |= MP_IMGFLAG_DIRECT;
746 mpi->stride[0] = mode_stride;
747 mpi->planes[0] = PageStore[page].vbase +
748 y_pos*mode_stride + (x_pos*mpi->bpp)/8;
749 mpi->priv=(void *)page;
750 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: direct render allocated! page=%d\n",page);
751 return VO_TRUE;
752 }
753 }
754
755 return VO_FALSE;
756 }