Mercurial > mplayer.hg
annotate libvo/vo_vesa.c @ 5161:b9ba9cefcd7d
Mp4S fixed
author | arpi |
---|---|
date | Sun, 17 Mar 2002 14:21:07 +0000 |
parents | cbce019d2d94 |
children | e01c664def74 |
rev | line source |
---|---|
2519 | 1 /* |
2244 | 2 * video_out_vesa.c |
3 * | |
4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - Oct 2001 | |
5 * | |
6 * You can redistribute this file under terms and conditions | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
7 * of GNU General Public licence v2. |
2244 | 8 * This file is partly based on vbetest.c from lrmi distributive. |
9 */ | |
10 | |
11 /* | |
12 TODO: | |
13 - hw YUV support (need volunteers who have corresponding hardware) | |
2649 | 14 - triple buffering (if it will really speedup playback). |
2692 | 15 note: triple buffering requires VBE 3.0 - need volunteers. |
2244 | 16 - refresh rate support (need additional info from mplayer) |
17 */ | |
2775 | 18 #include "config.h" |
19 | |
2244 | 20 #include <stdio.h> |
2775 | 21 #ifdef HAVE_MALLOC_H |
22 #include <malloc.h> | |
23 #endif | |
2446 | 24 #include <stdlib.h> |
2244 | 25 #include <string.h> |
26 #include <stddef.h> | |
27 #include <limits.h> | |
4739 | 28 #include <unistd.h> |
29 #include <pwd.h> | |
30 #include <sys/types.h> | |
31 #include <sys/stat.h> | |
32 | |
2244 | 33 |
34 #include "video_out.h" | |
35 #include "video_out_internal.h" | |
36 | |
37 #include "fastmemcpy.h" | |
2337 | 38 #include "sub.h" |
2244 | 39 #include "linux/vbelib.h" |
40 #include "bswap.h" | |
2689 | 41 #include "aspect.h" |
3202 | 42 #include "vesa_lvo.h" |
4089 | 43 #ifdef CONFIG_VIDIX |
4030 | 44 #include "vosub_vidix.h" |
4089 | 45 #endif |
2244 | 46 |
2298 | 47 #include "../postproc/swscale.h" |
48 | |
2244 | 49 LIBVO_EXTERN(vesa) |
4739 | 50 |
51 #ifdef HAVE_PNG | |
52 extern vo_functions_t video_out_png; | |
53 #endif | |
54 | |
2244 | 55 extern int verbose; |
56 | |
2649 | 57 #define MAX_BUFFERS 3 |
58 | |
2244 | 59 #ifndef max |
60 #define max(a,b) ((a)>(b)?(a):(b)) | |
61 #endif | |
62 #ifndef min | |
63 #define min(a,b) ((a)<(b)?(a):(b)) | |
64 #endif | |
65 | |
2688 | 66 #define UNUSED(x) ((void)(x)) /**< Removes warning about unused arguments */ |
2244 | 67 |
68 static vo_info_t vo_info = | |
69 { | |
70 "VESA VBE 2.0 video output", | |
71 "vesa", | |
72 "Nick Kurshev <nickols_k@mail.ru>", | |
73 "Requires ROOT privileges" | |
74 }; | |
75 | |
76 /* driver data */ | |
77 | |
78 struct win_frame | |
79 { | |
80 uint8_t *ptr; /* pointer to window's frame memory */ | |
81 uint32_t low; /* lowest boundary of frame */ | |
82 uint32_t high; /* highest boundary of frame */ | |
2610 | 83 char idx; /* indicates index of relocatable frame (A=0 or B=1) |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
84 special case for DGA: idx=-1 |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
85 idx=-2 indicates invalid frame, exists only in init() */ |
2244 | 86 }; |
87 | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
88 static void (*cpy_blk_fnc)(unsigned long,uint8_t *,unsigned long) = NULL; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
89 |
4537 | 90 static uint32_t srcW=0,srcH=0,srcBpp,srcFourcc; /* source image description */ |
91 static uint32_t dstBpp,dstW, dstH,dstFourcc; /* destinition image description */ | |
2298 | 92 |
4537 | 93 static SwsContext * sws = NULL; |
94 | |
2329 | 95 static int32_t x_offset,y_offset; /* to center image on screen */ |
2244 | 96 static unsigned init_mode; /* mode before run of mplayer */ |
97 static void *init_state = NULL; /* state before run of mplayer */ | |
98 static struct win_frame win; /* real-mode window to video memory */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
99 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */ |
2244 | 100 static unsigned video_mode; /* selected video mode for playback */ |
101 static struct VesaModeInfoBlock video_mode_info; | |
2331 | 102 static int flip_trigger = 0; |
2337 | 103 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); |
2244 | 104 |
2649 | 105 /* multibuffering */ |
106 uint8_t* video_base; /* should be never changed */ | |
107 uint32_t multi_buff[MAX_BUFFERS]; /* contains offsets of buffers */ | |
108 uint8_t multi_size=0; /* total number of buffers */ | |
109 uint8_t multi_idx=0; /* active buffer */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
110 |
2869 | 111 /* Linux Video Overlay */ |
112 static const char *lvo_name = NULL; | |
4089 | 113 #ifdef CONFIG_VIDIX |
4030 | 114 static const char *vidix_name = NULL; |
4089 | 115 #endif |
2869 | 116 |
2649 | 117 #define HAS_DGA() (win.idx == -1) |
2244 | 118 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS) |
2649 | 119 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_WRITEABLE) |
120 | |
2244 | 121 static char * vbeErrToStr(int err) |
122 { | |
123 char *retval; | |
124 static char sbuff[80]; | |
125 if((err & VBE_VESA_ERROR_MASK) == VBE_VESA_ERROR_MASK) | |
126 { | |
4667 | 127 sprintf(sbuff,"VESA failed = 0x4f%02x",(err & VBE_VESA_ERRCODE_MASK)>>8); |
2244 | 128 retval = sbuff; |
129 } | |
130 else | |
131 switch(err) | |
132 { | |
133 case VBE_OK: retval = "No error"; break; | |
134 case VBE_VM86_FAIL: retval = "vm86() syscall failed"; break; | |
135 case VBE_OUT_OF_DOS_MEM: retval = "Out of DOS memory"; break; | |
136 case VBE_OUT_OF_MEM: retval = "Out of memory"; break; | |
2360 | 137 case VBE_BROKEN_BIOS: retval = "Broken BIOS or DOS TSR"; break; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
138 default: sprintf(sbuff,"Unknown or internal error: %i",err); retval=sbuff; break; |
2244 | 139 } |
140 return retval; | |
141 } | |
142 | |
143 #define PRINT_VBE_ERR(name,err) { printf("vo_vesa: %s returns: %s\n",name,vbeErrToStr(err)); fflush(stdout); } | |
144 | |
145 static void vesa_term( void ) | |
146 { | |
147 int err; | |
2869 | 148 if(lvo_name) vlvo_term(); |
4089 | 149 #ifdef CONFIG_VIDIX |
4030 | 150 else if(vidix_name) vidix_term(); |
4089 | 151 #endif |
2244 | 152 if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err); |
153 if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
154 if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
155 if(dga_buffer && !HAS_DGA()) free(dga_buffer); |
2244 | 156 vbeDestroy(); |
4537 | 157 if(sws) freeSwsContext(sws); |
2244 | 158 } |
159 | |
160 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high) | |
161 #define VIDEO_PTR(offset) (win.ptr + offset - win.low) | |
162 | |
163 static inline void __vbeSwitchBank(unsigned long offset) | |
164 { | |
165 unsigned long gran; | |
166 unsigned new_offset; | |
167 int err; | |
168 gran = video_mode_info.WinGranularity*1024; | |
169 new_offset = offset / gran; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
170 if(HAS_DGA()) { err = -1; goto show_err; } |
2244 | 171 if((err=vbeSetWindow(win.idx,new_offset)) != VBE_OK) |
172 { | |
2610 | 173 show_err: |
2686 | 174 vesa_term(); |
2244 | 175 PRINT_VBE_ERR("vbeSetWindow",err); |
176 printf("vo_vesa: Fatal error occured! Can't continue\n"); | |
177 exit(-1); | |
178 } | |
179 win.low = new_offset * gran; | |
180 win.high = win.low + video_mode_info.WinSize*1024; | |
181 } | |
182 | |
183 static void __vbeSetPixel(int x, int y, int r, int g, int b) | |
184 { | |
185 int x_res = video_mode_info.XResolution; | |
186 int y_res = video_mode_info.YResolution; | |
187 int shift_r = video_mode_info.RedFieldPosition; | |
188 int shift_g = video_mode_info.GreenFieldPosition; | |
189 int shift_b = video_mode_info.BlueFieldPosition; | |
4537 | 190 int pixel_size = (dstBpp+7)/8; |
2244 | 191 int bpl = video_mode_info.BytesPerScanLine; |
2676 | 192 int color; |
193 unsigned offset; | |
2244 | 194 |
195 if (x < 0 || x >= x_res || y < 0 || y >= y_res) return; | |
196 r >>= 8 - video_mode_info.RedMaskSize; | |
197 g >>= 8 - video_mode_info.GreenMaskSize; | |
198 b >>= 8 - video_mode_info.BlueMaskSize; | |
199 color = (r << shift_r) | (g << shift_g) | (b << shift_b); | |
200 offset = y * bpl + (x * pixel_size); | |
201 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); | |
202 memcpy(VIDEO_PTR(offset), &color, pixel_size); | |
203 } | |
204 | |
205 /* | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
206 Copies part of frame to video memory. Data should be in the same format |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
207 as video memory. |
2244 | 208 */ |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
209 static void __vbeCopyBlockFast(unsigned long offset,uint8_t *image,unsigned long size) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
210 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
211 memcpy(&win.ptr[offset],image,size); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
212 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
213 |
2244 | 214 static void __vbeCopyBlock(unsigned long offset,uint8_t *image,unsigned long size) |
215 { | |
216 unsigned long delta,src_idx = 0; | |
217 while(size) | |
218 { | |
4537 | 219 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); |
220 delta = min(size,win.high - offset); | |
221 memcpy(VIDEO_PTR(offset),&image[src_idx],delta); | |
222 src_idx += delta; | |
223 offset += delta; | |
224 size -= delta; | |
2244 | 225 } |
226 } | |
227 | |
228 /* | |
229 Copies frame to video memory. Data should be in the same format as video | |
230 memory. | |
231 */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
232 |
4537 | 233 #define PIXEL_SIZE() ((dstBpp+7)/8) |
2676 | 234 #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) ) |
4537 | 235 #define IMAGE_LINE_SIZE(pixel_size) (dstW*(pixel_size)) |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
236 |
2244 | 237 static void __vbeCopyData(uint8_t *image) |
238 { | |
2308 | 239 unsigned long i,j,image_offset,offset; |
2244 | 240 unsigned pixel_size,image_line_size,screen_line_size,x_shift; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
241 pixel_size = PIXEL_SIZE(); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
242 screen_line_size = SCREEN_LINE_SIZE(pixel_size); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
243 image_line_size = IMAGE_LINE_SIZE(pixel_size); |
4537 | 244 if(dstW == video_mode_info.XResolution) |
2306 | 245 { |
246 /* Special case for zooming */ | |
4537 | 247 (*cpy_blk_fnc)(y_offset*screen_line_size,image,image_line_size*dstH); |
2306 | 248 } |
249 else | |
2244 | 250 { |
2306 | 251 x_shift = x_offset*pixel_size; |
4537 | 252 for(j=0,i=y_offset;j<dstH;i++,j++) |
2306 | 253 { |
254 offset = i*screen_line_size+x_shift; | |
255 image_offset = j*image_line_size; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
256 (*cpy_blk_fnc)(offset,&image[image_offset],image_line_size); |
2306 | 257 } |
2244 | 258 } |
259 } | |
2328 | 260 |
2244 | 261 /* is called for yuv only */ |
262 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
263 { | |
4537 | 264 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
265 uint8_t *dst[3]= {dga_buffer, NULL, NULL}; | |
266 int dstStride[3]; | |
2504 | 267 if(verbose > 2) |
268 printf("vo_vesa: draw_slice was called: w=%u h=%u x=%u y=%u\n",w,h,x,y); | |
4537 | 269 dstStride[0]=dstride*((dstBpp+7)/8); |
270 dstStride[1]= | |
271 dstStride[2]=dstStride[0]>>1; | |
272 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); | |
4554 | 273 sws->swScale(sws,image,stride,y,h,dst,dstStride); |
2331 | 274 flip_trigger = 1; |
2298 | 275 return 0; |
2244 | 276 } |
277 | |
4572 | 278 /* Please comment it out if you want have OSD within movie */ |
279 #define OSD_OUTSIDE_MOVIE 1 | |
280 | |
2649 | 281 static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
282 { | |
4537 | 283 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
4572 | 284 #ifndef OSD_OUTSIDE_MOVIE |
285 if(HAS_DGA()) | |
286 { | |
287 x0 += x_offset; | |
288 y0 += y_offset; | |
289 } | |
290 #endif | |
2649 | 291 vo_draw_alpha_rgb32(w,h,src,srca,stride,dga_buffer+4*(y0*dstride+x0),4*dstride); |
2337 | 292 } |
293 | |
2649 | 294 static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
295 { | |
4537 | 296 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
4572 | 297 #ifndef OSD_OUTSIDE_MOVIE |
298 if(HAS_DGA()) | |
299 { | |
300 x0 += x_offset; | |
301 y0 += y_offset; | |
302 } | |
303 #endif | |
2649 | 304 vo_draw_alpha_rgb24(w,h,src,srca,stride,dga_buffer+3*(y0*dstride+x0),3*dstride); |
2337 | 305 } |
306 | |
2649 | 307 static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
308 { | |
4537 | 309 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
4572 | 310 #ifndef OSD_OUTSIDE_MOVIE |
311 if(HAS_DGA()) | |
312 { | |
313 x0 += x_offset; | |
314 y0 += y_offset; | |
315 } | |
316 #endif | |
2649 | 317 vo_draw_alpha_rgb16(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); |
2337 | 318 } |
319 | |
2649 | 320 static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
321 { | |
4537 | 322 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
4572 | 323 #ifndef OSD_OUTSIDE_MOVIE |
324 if(HAS_DGA()) | |
325 { | |
326 x0 += x_offset; | |
327 y0 += y_offset; | |
328 } | |
329 #endif | |
2649 | 330 vo_draw_alpha_rgb15(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); |
2337 | 331 } |
332 | |
2649 | 333 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
334 { | |
2688 | 335 UNUSED(x0); |
336 UNUSED(y0); | |
337 UNUSED(w); | |
338 UNUSED(h); | |
339 UNUSED(src); | |
340 UNUSED(srca); | |
341 UNUSED(stride); | |
2337 | 342 } |
343 | |
344 | |
2244 | 345 static void draw_osd(void) |
346 { | |
2649 | 347 uint32_t w,h; |
2504 | 348 if(verbose > 2) |
349 printf("vo_vesa: draw_osd was called\n"); | |
2869 | 350 { |
4572 | 351 #ifdef OSD_OUTSIDE_MOVIE |
4537 | 352 w = HAS_DGA()?video_mode_info.XResolution:dstW; |
353 h = HAS_DGA()?video_mode_info.YResolution:dstH; | |
4572 | 354 #else |
355 w = dstW; | |
356 h = dstH; | |
357 #endif | |
2869 | 358 if(dga_buffer) vo_draw_text(w,h,draw_alpha_fnc); |
359 } | |
2244 | 360 } |
361 | |
362 static void flip_page(void) | |
363 { | |
2504 | 364 if(verbose > 2) |
365 printf("vo_vesa: flip_page was called\n"); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
366 if(flip_trigger) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
367 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
368 if(!HAS_DGA()) __vbeCopyData(dga_buffer); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
369 flip_trigger = 0; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
370 } |
4493 | 371 if(vo_doublebuffering && multi_size > 1) |
2649 | 372 { |
2686 | 373 int err; |
4667 | 374 if((err=vbeSetDisplayStart(multi_buff[multi_idx],vo_vsync)) != VBE_OK) |
2686 | 375 { |
376 vesa_term(); | |
2692 | 377 PRINT_VBE_ERR("vbeSetDisplayStart",err); |
2686 | 378 printf("vo_vesa: Fatal error occured! Can't continue\n"); |
379 exit(EXIT_FAILURE); | |
380 } | |
381 multi_idx = multi_idx ? 0 : 1; | |
382 win.ptr = dga_buffer = video_base + multi_buff[multi_idx]; | |
2649 | 383 } |
384 /* | |
385 else | |
386 if(tripple_buffering) | |
387 { | |
4667 | 388 vbeSetScheduledDisplayStart(multi_buff[multi_idx],vo_vsync); |
2649 | 389 multi_idx++; |
390 if(multi_idx > 2) multi_idx = 0; | |
4667 | 391 win.ptr = dga_buffer = video_base + multi_buff[multi_idx]; |
2649 | 392 } |
393 */ | |
2244 | 394 } |
395 | |
396 /* is called for rgb only */ | |
397 static uint32_t draw_frame(uint8_t *src[]) | |
398 { | |
2504 | 399 if(verbose > 2) |
400 printf("vo_vesa: draw_frame was called\n"); | |
4537 | 401 if(sws) |
2504 | 402 { |
4537 | 403 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
404 int srcStride[1]; | |
405 uint8_t *dst[3]= {dga_buffer, NULL, NULL}; | |
406 int dstStride[3]; | |
407 dstStride[0]=dstride*((dstBpp+7)/8); | |
408 dstStride[1]= | |
409 dstStride[2]=dstStride[0]>>1; | |
410 if(srcFourcc == IMGFMT_RGB32 || srcFourcc == IMGFMT_BGR32) | |
411 srcStride[0] = srcW*4; | |
412 else | |
413 if(srcFourcc == IMGFMT_RGB24 || srcFourcc == IMGFMT_BGR24) | |
414 srcStride[0] = srcW*3; | |
415 else | |
416 srcStride[0] = srcW*2; | |
417 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); | |
4554 | 418 sws->swScale(sws,src,srcStride,0,srcH,dst,dstStride); |
4537 | 419 flip_trigger=1; |
420 } | |
2504 | 421 return 0; |
2244 | 422 } |
423 | |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
424 #define SUBDEV_NODGA 0x00000001UL |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
425 #define SUBDEV_FORCEDGA 0x00000002UL |
4362 | 426 static uint32_t subdev_flags = 0xFFFFFFFEUL; |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
427 static uint32_t parseSubDevice(const char *sd) |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
428 { |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
429 uint32_t flags; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
430 flags = 0; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
431 if(strcmp(sd,"nodga") == 0) { flags |= SUBDEV_NODGA; flags &= ~(SUBDEV_FORCEDGA); } |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
432 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
433 if(strcmp(sd,"dga") == 0) { flags &= ~(SUBDEV_NODGA); flags |= SUBDEV_FORCEDGA; } |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
434 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
435 if(memcmp(sd,"lvo:",4) == 0) lvo_name = &sd[4]; /* lvo_name will be valid within init() */ |
4089 | 436 #ifdef CONFIG_VIDIX |
4030 | 437 else |
438 if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */ | |
4089 | 439 #endif |
4537 | 440 else { printf("vo_vesa: Unknown subdevice: '%s'\n", sd); return 0xFFFFFFFFUL; } |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
441 return flags; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
442 } |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
443 |
2244 | 444 static uint32_t query_format(uint32_t format) |
445 { | |
2504 | 446 if(verbose > 2) |
447 printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
4537 | 448 return 1; /* due new SwScale code */ |
2244 | 449 } |
450 | |
2686 | 451 static void paintBkGnd( void ) |
452 { | |
453 int x_res = video_mode_info.XResolution; | |
454 int y_res = video_mode_info.YResolution; | |
455 int x, y; | |
456 | |
457 for (y = 0; y < y_res; ++y) | |
458 { | |
459 for (x = 0; x < x_res; ++x) | |
460 { | |
461 int r, g, b; | |
462 if ((x & 16) ^ (y & 16)) | |
463 { | |
464 r = x * 255 / x_res; | |
465 g = y * 255 / y_res; | |
466 b = 255 - x * 255 / x_res; | |
467 } | |
468 else | |
469 { | |
470 r = 255 - x * 255 / x_res; | |
471 g = y * 255 / y_res; | |
472 b = 255 - y * 255 / y_res; | |
473 } | |
474 __vbeSetPixel(x, y, r, g, b); | |
475 } | |
476 } | |
477 } | |
478 | |
2914 | 479 static void clear_screen( void ) |
480 { | |
481 int x_res = video_mode_info.XResolution; | |
482 int y_res = video_mode_info.YResolution; | |
483 int x, y; | |
484 | |
485 for (y = 0; y < y_res; ++y) | |
486 for (x = 0; x < x_res; ++x) | |
487 __vbeSetPixel(x, y, 0, 0, 0); | |
488 } | |
489 | |
2293 | 490 static char *model2str(unsigned char type) |
491 { | |
492 char *retval; | |
493 switch(type) | |
494 { | |
495 case memText: retval = "Text"; break; | |
496 case memCGA: retval="CGA"; break; | |
497 case memHercules: retval="Hercules"; break; | |
498 case memPL: retval="Planar"; break; | |
499 case memPK: retval="Packed pixel"; break; | |
500 case mem256: retval="256"; break; | |
501 case memRGB: retval="Direct color RGB"; break; | |
502 case memYUV: retval="Direct color YUV"; break; | |
503 default: retval="Unknown"; break; | |
504 } | |
505 return retval; | |
506 } | |
507 | |
2649 | 508 unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs ) |
509 { | |
510 unsigned long screen_size, offset; | |
511 unsigned total,i; | |
4537 | 512 screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((dstBpp+7)/8); |
2649 | 513 if(screen_size%64) screen_size=((screen_size/64)*64)+64; |
514 total = vsize / screen_size; | |
2918 | 515 if(verbose) printf("vo_vesa: Can use up to %u video buffers\n",total); |
2649 | 516 i = 0; |
517 offset = 0; | |
518 total = min(total,nbuffs); | |
519 while(i < total) { multi_buff[i++] = offset; offset += screen_size; } | |
520 if(!i) | |
521 printf("vo_vesa: Your have too small size of video memory for this mode:\n" | |
522 "vo_vesa: Requires: %08lX exists: %08lX\n", screen_size, vsize); | |
523 return i; | |
524 } | |
525 | |
526 | |
2244 | 527 /* fullscreen: |
528 * bit 0 (0x01) means fullscreen (-fs) | |
529 * bit 1 (0x02) means mode switching (-vm) | |
530 * bit 2 (0x04) enables software scaling (-zoom) | |
2335 | 531 * bit 3 (0x08) enables flipping (-flip) (NK: and for what?) |
2244 | 532 */ |
533 static uint32_t | |
4433 | 534 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format,const vo_tune_info_t *info) |
2244 | 535 { |
536 struct VbeInfoBlock vib; | |
537 struct VesaModeInfoBlock vmib; | |
538 size_t i,num_modes; | |
4362 | 539 uint32_t w,h; |
2244 | 540 unsigned short *mode_ptr,win_seg; |
541 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; | |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
542 int err,fs_mode,use_scaler=0; |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
543 srcW = dstW = width; |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
544 srcH = dstH = height; |
2336 | 545 fs_mode = 0; |
4362 | 546 if(subdev_flags == 0xFFFFFFFEUL) |
2971 | 547 { |
4362 | 548 printf("vo_vesa: detected internal fatal error: init is called before preinit\n"); |
2971 | 549 return -1; |
4362 | 550 } |
4537 | 551 if(subdev_flags == 0xFFFFFFFFUL) return -1; |
2329 | 552 if(flags & 0x8) |
2244 | 553 { |
2329 | 554 printf("vo_vesa: switch -flip is not supported\n"); |
2244 | 555 } |
4537 | 556 if(flags & 0x04) use_scaler = 1; |
2336 | 557 if(flags & 0x01) |
558 { | |
4537 | 559 if(use_scaler) use_scaler = 2; |
2336 | 560 else fs_mode = 1; |
561 } | |
2244 | 562 if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; } |
563 memcpy(vib.VESASignature,"VBE2",4); | |
564 if((err=vbeGetControllerInfo(&vib)) != VBE_OK) | |
565 { | |
566 PRINT_VBE_ERR("vbeGetControllerInfo",err); | |
567 printf("vo_vesa: possible reason: No VBE2 BIOS found\n"); | |
568 return -1; | |
569 } | |
570 /* Print general info here */ | |
571 printf("vo_vesa: Found VESA VBE BIOS Version %x.%x Revision: %x\n", | |
572 (int)(vib.VESAVersion >> 8) & 0xff, | |
573 (int)(vib.VESAVersion & 0xff), | |
574 (int)(vib.OemSoftwareRev & 0xffff)); | |
2255 | 575 printf("vo_vesa: Video memory: %u Kb\n",vib.TotalMemory*64); |
576 printf("vo_vesa: VESA Capabilities: %s %s %s %s %s\n" | |
577 ,vib.Capabilities & VBE_DAC_8BIT ? "8-bit DAC," : "6-bit DAC," | |
578 ,vib.Capabilities & VBE_NONVGA_CRTC ? "non-VGA CRTC,":"VGA CRTC," | |
579 ,vib.Capabilities & VBE_SNOWED_RAMDAC ? "snowed RAMDAC,":"normal RAMDAC," | |
580 ,vib.Capabilities & VBE_STEREOSCOPIC ? "stereoscopic,":"no stereoscopic," | |
581 ,vib.Capabilities & VBE_STEREO_EVC ? "Stereo EVC":"no stereo"); | |
582 printf("vo_vesa: !!! Below will be printed OEM info. !!!\n"); | |
583 printf("vo_vesa: You should watch 5 OEM related lines below else you've broken vm86\n"); | |
2244 | 584 printf("vo_vesa: OEM info: %s\n",vib.OemStringPtr); |
2255 | 585 printf("vo_vesa: OEM Revision: %x\n",vib.OemSoftwareRev); |
586 printf("vo_vesa: OEM vendor: %s\n",vib.OemVendorNamePtr); | |
587 printf("vo_vesa: OEM Product Name: %s\n",vib.OemProductNamePtr); | |
588 printf("vo_vesa: OEM Product Rev: %s\n",vib.OemProductRevPtr); | |
589 printf("vo_vesa: Hint: To get workable TV-Out you should have plugged tv-connector in\n" | |
590 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n"); | |
2244 | 591 /* Find best mode here */ |
592 num_modes = 0; | |
593 mode_ptr = vib.VideoModePtr; | |
594 while(*mode_ptr++ != 0xffff) num_modes++; | |
595 switch(format) | |
596 { | |
597 case IMGFMT_BGR8: | |
598 case IMGFMT_RGB8: bpp = 8; break; | |
599 case IMGFMT_BGR15: | |
600 case IMGFMT_RGB15: bpp = 15; break; | |
601 case IMGFMT_BGR16: | |
602 case IMGFMT_RGB16: bpp = 16; break; | |
603 case IMGFMT_BGR24: | |
604 case IMGFMT_RGB24: bpp = 24; break; | |
605 case IMGFMT_BGR32: | |
606 case IMGFMT_RGB32: bpp = 32; break; | |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
607 default: bpp = 16; break; |
2244 | 608 } |
4537 | 609 srcBpp = bpp; |
610 srcFourcc = format; | |
2504 | 611 if(vo_dbpp) bpp = vo_dbpp; |
2337 | 612 switch(bpp) |
613 { | |
4537 | 614 case 15: draw_alpha_fnc = draw_alpha_15; |
615 dstFourcc = IMGFMT_BGR15; | |
616 break; | |
617 case 16: draw_alpha_fnc = draw_alpha_16; | |
618 dstFourcc = IMGFMT_BGR16; | |
619 break; | |
620 case 24: draw_alpha_fnc = draw_alpha_24; | |
621 dstFourcc = IMGFMT_BGR24; | |
622 break; | |
623 case 32: draw_alpha_fnc = draw_alpha_32; | |
624 dstFourcc = IMGFMT_BGR32; | |
625 break; | |
626 default: draw_alpha_fnc = draw_alpha_null; | |
627 dstFourcc = IMGFMT_BGR16; | |
628 break; | |
2337 | 629 } |
2244 | 630 if(verbose) |
631 { | |
2304 | 632 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); |
2244 | 633 printf("vo_vesa: Total modes found: %u\n",num_modes); |
634 mode_ptr = vib.VideoModePtr; | |
635 printf("vo_vesa: Mode list:"); | |
636 for(i = 0;i < num_modes;i++) | |
637 { | |
638 printf(" %04X",mode_ptr[i]); | |
639 } | |
640 printf("\nvo_vesa: Modes in detail:\n"); | |
641 } | |
642 mode_ptr = vib.VideoModePtr; | |
4537 | 643 if(use_scaler) |
2335 | 644 { |
4537 | 645 dstW = d_width; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
646 dstH = d_height; |
2335 | 647 } |
648 if(vo_screenwidth) w = vo_screenwidth; | |
4537 | 649 else w = max(dstW,width); |
2335 | 650 if(vo_screenheight) h = vo_screenheight; |
4537 | 651 else h = max(dstH,height); |
2244 | 652 for(i=0;i < num_modes;i++) |
653 { | |
654 if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK) | |
655 { | |
656 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
657 return -1; | |
658 } | |
2329 | 659 if(vmib.XResolution >= w && |
660 vmib.YResolution >= h && | |
2244 | 661 (vmib.ModeAttributes & MOVIE_MODE) == MOVIE_MODE && |
662 vmib.BitsPerPixel == bpp && | |
663 vmib.MemoryModel == memRGB) | |
664 { | |
2293 | 665 if(vmib.XResolution <= best_x && |
666 vmib.YResolution <= best_y) | |
2244 | 667 { |
668 best_x = vmib.XResolution; | |
669 best_y = vmib.YResolution; | |
670 best_mode_idx = i; | |
671 } | |
672 } | |
673 if(verbose) | |
674 { | |
2298 | 675 printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%04X\n" |
2293 | 676 "vo_vesa: #planes=%u model=%u(%s) #pages=%u\n" |
677 "vo_vesa: winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n" | |
2446 | 678 "vo_vesa: direct_color=%u DGA_phys_addr=%08lX\n" |
2244 | 679 ,i,mode_ptr[i],vmib.XResolution,vmib.YResolution,vmib.BitsPerPixel,vmib.ModeAttributes |
2293 | 680 ,vmib.NumberOfPlanes,vmib.MemoryModel,model2str(vmib.MemoryModel),vmib.NumberOfImagePages |
2244 | 681 ,vmib.WinASegment,vmib.WinAAttributes,vmib.WinBSegment,vmib.WinBAttributes,vmib.WinSize,vmib.WinGranularity |
682 ,vmib.DirectColorModeInfo,vmib.PhysBasePtr); | |
683 if(vmib.MemoryModel == 6 || vmib.MemoryModel == 7) | |
684 printf("vo_vesa: direct_color_info = %u:%u:%u:%u\n" | |
685 ,vmib.RedMaskSize,vmib.GreenMaskSize,vmib.BlueMaskSize,vmib.RsvdMaskSize); | |
686 fflush(stdout); | |
687 } | |
688 } | |
689 if(best_mode_idx != UINT_MAX) | |
690 { | |
691 video_mode = vib.VideoModePtr[best_mode_idx]; | |
692 fflush(stdout); | |
693 if((err=vbeGetMode(&init_mode)) != VBE_OK) | |
694 { | |
695 PRINT_VBE_ERR("vbeGetMode",err); | |
696 return -1; | |
697 } | |
698 if(verbose) printf("vo_vesa: Initial video mode: %x\n",init_mode); | |
699 if((err=vbeGetModeInfo(video_mode,&video_mode_info)) != VBE_OK) | |
700 { | |
701 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
702 return -1; | |
703 } | |
2329 | 704 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n" |
705 ,best_mode_idx,video_mode,video_mode_info.XResolution | |
4537 | 706 ,video_mode_info.YResolution,dstBpp); |
707 dstBpp = video_mode_info.BitsPerPixel; | |
4362 | 708 if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
709 if(use_scaler || fs_mode) |
2298 | 710 { |
2304 | 711 /* software scale */ |
4537 | 712 if(use_scaler > 1) |
2689 | 713 { |
714 aspect_save_orig(width,height); | |
715 aspect_save_prescale(d_width,d_height); | |
716 aspect_save_screenres(video_mode_info.XResolution,video_mode_info.YResolution); | |
4537 | 717 aspect(&dstW,&dstH,A_ZOOM); |
2689 | 718 } |
2336 | 719 else |
720 if(fs_mode) | |
721 { | |
4537 | 722 dstW = video_mode_info.XResolution; |
723 dstH = video_mode_info.YResolution; | |
2336 | 724 } |
4537 | 725 use_scaler = 1; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
726 } |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
727 if(!lvo_name |
4089 | 728 #ifdef CONFIG_VIDIX |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
729 && !vidix_name |
4089 | 730 #endif |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
731 ) |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
732 { |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
733 sws = getSwsContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc); |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
734 if(!sws) |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
735 { |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
736 printf("vo_vesa: Can't initialize SwScaler\n"); |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
737 return -1; |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
738 } |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
739 else if(verbose) printf("vo_vesa: Using SW BES emulator\n"); |
2298 | 740 } |
2244 | 741 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE) |
742 win.idx = 0; /* frame A */ | |
743 else | |
744 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE) | |
745 win.idx = 1; /* frame B */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
746 else win.idx = -2; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
747 /* Try use DGA instead */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
748 if(video_mode_info.PhysBasePtr && vib.TotalMemory && (video_mode_info.ModeAttributes & MODE_ATTR_LINEAR)) |
2244 | 749 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
750 void *lfb; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
751 unsigned long vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
752 vsize = vib.TotalMemory*64*1024; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
753 lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vsize); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
754 if(lfb == NULL) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
755 printf("vo_vesa: Can't use DGA. Force bank switching mode. :(\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
756 else |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
757 { |
2649 | 758 video_base = win.ptr = lfb; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
759 win.low = 0UL; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
760 win.high = vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
761 win.idx = -1; /* HAS_DGA() is on */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
762 video_mode |= VESA_MODE_USE_LINEAR; |
2649 | 763 printf("vo_vesa: Using DGA (physical resources: %08lXh, %08lXh)" |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
764 ,video_mode_info.PhysBasePtr |
2649 | 765 ,vsize); |
766 if(verbose) printf(" at %08lXh",(unsigned long)lfb); | |
767 printf("\n"); | |
768 if(!(multi_size = fillMultiBuffer(vsize,2))) return -1; | |
769 if(vo_doublebuffering && multi_size < 2) | |
770 printf("vo_vesa: Can't use double buffering: not enough video memory\n"); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
771 } |
2244 | 772 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
773 if(win.idx == -2) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
774 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
775 printf("vo_vesa: Can't find neither DGA nor relocatable window's frame.\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
776 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
777 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
778 if(!HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
779 { |
4362 | 780 if(subdev_flags & SUBDEV_FORCEDGA) |
2649 | 781 { |
782 printf("vo_vesa: you've forced DGA. Exiting\n"); | |
783 return -1; | |
784 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
785 if(!(win_seg = win.idx == 0 ? video_mode_info.WinASegment:video_mode_info.WinBSegment)) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
786 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
787 printf("vo_vesa: Can't find valid window address\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
788 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
789 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
790 win.ptr = PhysToVirtSO(win_seg,0); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
791 win.low = 0L; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
792 win.high= video_mode_info.WinSize*1024; |
2649 | 793 printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n" |
794 ,(unsigned long)win.ptr,(unsigned long)win.high); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
795 } |
4537 | 796 if(video_mode_info.XResolution > dstW) |
797 x_offset = (video_mode_info.XResolution - dstW) / 2; | |
2329 | 798 else x_offset = 0; |
4537 | 799 if(video_mode_info.YResolution > dstH) |
800 y_offset = (video_mode_info.YResolution - dstH) / 2; | |
2329 | 801 else y_offset = 0; |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
802 if(verbose) |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
803 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n" |
4537 | 804 ,dstW,dstH |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
805 ,video_mode_info.XResolution,video_mode_info.YResolution |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
806 ,x_offset,y_offset); |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
807 if(HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
808 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
809 dga_buffer = win.ptr; /* Trickly ;) */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
810 cpy_blk_fnc = __vbeCopyBlockFast; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
811 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
812 else |
2610 | 813 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
814 cpy_blk_fnc = __vbeCopyBlock; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
815 if(!lvo_name |
4089 | 816 #ifdef CONFIG_VIDIX |
817 && !vidix_name | |
818 #endif | |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
819 ) |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
820 { |
4537 | 821 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*dstBpp))) |
2610 | 822 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
823 printf("vo_vesa: Can't allocate temporary buffer\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
824 return -1; |
2610 | 825 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
826 if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer); |
2337 | 827 } |
2504 | 828 } |
2244 | 829 if((err=vbeSaveState(&init_state)) != VBE_OK) |
830 { | |
831 PRINT_VBE_ERR("vbeSaveState",err); | |
832 return -1; | |
833 } | |
834 if((err=vbeSetMode(video_mode,NULL)) != VBE_OK) | |
835 { | |
836 PRINT_VBE_ERR("vbeSetMode",err); | |
837 return -1; | |
838 } | |
839 /* Now we are in video mode!!!*/ | |
2337 | 840 /* Below 'return -1' is impossible */ |
2244 | 841 if(verbose) |
842 { | |
843 printf("vo_vesa: Graphics mode was activated\n"); | |
844 fflush(stdout); | |
845 } | |
2869 | 846 if(lvo_name) |
847 { | |
4537 | 848 if(vlvo_init(width,height,x_offset,y_offset,dstW,dstH,format,dstBpp) != 0) |
2869 | 849 { |
850 printf("vo_vesa: Can't initialize Linux Video Overlay\n"); | |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
851 lvo_name = NULL; |
2869 | 852 vesa_term(); |
853 return -1; | |
854 } | |
855 else printf("vo_vesa: Using video overlay: %s\n",lvo_name); | |
856 } | |
4089 | 857 #ifdef CONFIG_VIDIX |
4030 | 858 else |
859 if(vidix_name) | |
860 { | |
4537 | 861 if(vidix_init(width,height,x_offset,y_offset,dstW, |
862 dstH,format,dstBpp, | |
4434 | 863 video_mode_info.XResolution,video_mode_info.YResolution,info) != 0) |
4030 | 864 { |
865 printf("vo_vesa: Can't initialize VIDIX driver\n"); | |
866 vidix_name = NULL; | |
4548 | 867 vesa_term(); |
4030 | 868 return -1; |
869 } | |
4083 | 870 else printf("vo_vesa: Using VIDIX\n"); |
4198
7e2bf04c9a7c
added vidix_start() and vidix_stop() for better runtime-resize support ;)
alex
parents:
4089
diff
changeset
|
871 vidix_start(); |
4030 | 872 } |
4089 | 873 #endif |
2244 | 874 } |
875 else | |
876 { | |
2255 | 877 printf("vo_vesa: Can't find mode for: %ux%u@%u\n",width,height,bpp); |
2244 | 878 return -1; |
879 } | |
880 if(verbose) | |
881 { | |
882 printf("vo_vesa: VESA initialization complete\n"); | |
883 fflush(stdout); | |
884 } | |
2914 | 885 /* Clear screen for stupid BIOSes */ |
886 clear_screen(); | |
2688 | 887 if(HAS_DGA() && vo_doublebuffering) |
2244 | 888 { |
2686 | 889 for(i=0;i<MAX_BUFFERS;i++) |
890 { | |
891 win.ptr = dga_buffer = video_base + multi_buff[i]; | |
4002 | 892 if(verbose>1) paintBkGnd(); |
2686 | 893 } |
2244 | 894 } |
2686 | 895 else |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
896 { |
4002 | 897 if(verbose>1) paintBkGnd(); |
2686 | 898 { |
899 int x; | |
900 x = (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2; | |
901 if(x < 0) x = 0; | |
902 vbeWriteString(x,0,7,title); | |
903 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
904 } |
2244 | 905 return 0; |
906 } | |
907 | |
908 static const vo_info_t* | |
909 get_info(void) | |
910 { | |
2504 | 911 if(verbose > 2) |
912 printf("vo_vesa: get_info was called\n"); | |
2244 | 913 return &vo_info; |
914 } | |
915 | |
916 static void | |
917 uninit(void) | |
918 { | |
2686 | 919 vesa_term(); |
2504 | 920 if(verbose > 2) |
921 printf("vo_vesa: uninit was called\n"); | |
2244 | 922 } |
923 | |
924 | |
925 static void check_events(void) | |
926 { | |
2504 | 927 if(verbose > 2) |
928 printf("vo_vesa: check_events was called\n"); | |
2244 | 929 /* Nothing to do */ |
930 } | |
4352 | 931 |
932 static uint32_t preinit(const char *arg) | |
933 { | |
4362 | 934 int pre_init_err = 0; |
935 if(verbose>1) printf("vo_vesa: preinit(%s) was called\n",arg); | |
936 if(verbose > 2) | |
937 printf("vo_vesa: subdevice %s is being initialized\n",arg); | |
938 subdev_flags = 0; | |
939 if(arg) subdev_flags = parseSubDevice(arg); | |
940 if(lvo_name) pre_init_err = vlvo_preinit(lvo_name); | |
941 #ifdef CONFIG_VIDIX | |
942 else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_vesa); | |
943 #endif | |
944 if(verbose > 2) | |
945 printf("vo_subdevice: initialization returns: %i\n",pre_init_err); | |
946 return pre_init_err; | |
4352 | 947 } |
948 | |
4739 | 949 #ifdef HAVE_PNG |
950 static int vesa_screenshot(const char *fname) | |
951 { | |
952 uint32_t i,n; | |
953 uint8_t *ptrs[video_mode_info.YResolution]; | |
4746
cbce019d2d94
Change order of vo_function calls (Although it doesn't matter for now).
nick
parents:
4739
diff
changeset
|
954 if(video_out_png.preinit(NULL)) |
cbce019d2d94
Change order of vo_function calls (Although it doesn't matter for now).
nick
parents:
4739
diff
changeset
|
955 { |
cbce019d2d94
Change order of vo_function calls (Although it doesn't matter for now).
nick
parents:
4739
diff
changeset
|
956 printf("\nvo_vesa: can't preinit vo_png\n"); |
cbce019d2d94
Change order of vo_function calls (Although it doesn't matter for now).
nick
parents:
4739
diff
changeset
|
957 return 1; |
cbce019d2d94
Change order of vo_function calls (Although it doesn't matter for now).
nick
parents:
4739
diff
changeset
|
958 } |
4739 | 959 if(!video_out_png.control(VOCTRL_QUERY_FORMAT, &dstFourcc)) |
960 { | |
961 printf("\nvo_vesa: vo_png doesn't support: %s fourcc\n",vo_format_name(dstFourcc)); | |
962 return 1; | |
963 } | |
964 if(video_out_png.config(HAS_DGA()?video_mode_info.XResolution:dstW, | |
965 HAS_DGA()?video_mode_info.YResolution:dstH, | |
966 HAS_DGA()?video_mode_info.XResolution:dstW, | |
967 HAS_DGA()?video_mode_info.YResolution:dstH, | |
968 0,NULL,dstFourcc,NULL)) | |
969 { | |
970 printf("\nvo_vesa: can't configure vo_png\n"); | |
971 return 1; | |
972 } | |
973 n = HAS_DGA()?video_mode_info.YResolution:dstH; | |
974 for(i=0;i<n;i++) | |
975 ptrs[i] = &dga_buffer[(HAS_DGA()?video_mode_info.XResolution:dstW)*i*PIXEL_SIZE()]; | |
976 if(video_out_png.draw_frame(ptrs)) | |
977 { | |
978 printf("\nvo_vesa: vo_png: error during dumping\n"); | |
979 return 1; | |
980 } | |
981 | |
982 video_out_png.uninit(); | |
983 if(verbose) printf("\nvo_vesa: png output has been created\n"); | |
984 return 0; | |
985 } | |
986 | |
987 | |
988 static char _home_name[FILENAME_MAX + 1]; | |
989 static char * __get_home_filename(const char *progname) | |
990 { | |
991 char *p = getenv("HOME"); | |
992 | |
993 if (p == NULL || strlen(p) < 2) { | |
994 struct passwd *psw = getpwuid(getuid()); | |
995 if (psw != NULL) p = psw->pw_dir; | |
996 } | |
997 | |
998 if (p == NULL || strlen(p) > FILENAME_MAX - (strlen(progname) + 4)) | |
999 p = "/tmp"; | |
1000 | |
1001 strcpy(_home_name, p); | |
1002 strcat(_home_name, "/."); | |
1003 return strcat(_home_name, progname); | |
1004 } | |
1005 #endif | |
1006 | |
4596 | 1007 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 1008 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1009 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1010 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1011 return query_format(*((uint32_t*)data)); |
4739 | 1012 #ifdef HAVE_PNG |
1013 case VOCTRL_SCREENSHOT: | |
1014 return vesa_screenshot(__get_home_filename("mplayer_vesa_dump.png")); | |
1015 break; | |
1016 #endif | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1017 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1018 return VO_NOTIMPL; |
4352 | 1019 } |