Mercurial > mplayer.hg
annotate libvo/vo_vesa.c @ 2957:72229b5bd370
yeah, true.
TODO: place links all over ATI TVout stuff and vice versa and etcetc :)
author | gabucino |
---|---|
date | Sat, 17 Nov 2001 18:53:09 +0000 |
parents | b0cf2b649d3c |
children | 8cd493fd5db7 |
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> | |
28 | |
29 #include "video_out.h" | |
30 #include "video_out_internal.h" | |
31 | |
32 #include "fastmemcpy.h" | |
2337 | 33 #include "sub.h" |
2244 | 34 #include "linux/vbelib.h" |
35 #include "bswap.h" | |
2689 | 36 #include "aspect.h" |
2244 | 37 |
2298 | 38 #include "../postproc/swscale.h" |
2504 | 39 #include "../postproc/rgb2rgb.h" |
2298 | 40 |
2244 | 41 LIBVO_EXTERN(vesa) |
42 extern int verbose; | |
43 | |
2649 | 44 #define MAX_BUFFERS 3 |
45 | |
2244 | 46 #ifndef max |
47 #define max(a,b) ((a)>(b)?(a):(b)) | |
48 #endif | |
49 #ifndef min | |
50 #define min(a,b) ((a)<(b)?(a):(b)) | |
51 #endif | |
52 | |
2688 | 53 #define UNUSED(x) ((void)(x)) /**< Removes warning about unused arguments */ |
2244 | 54 |
55 static vo_info_t vo_info = | |
56 { | |
57 "VESA VBE 2.0 video output", | |
58 "vesa", | |
59 "Nick Kurshev <nickols_k@mail.ru>", | |
60 "Requires ROOT privileges" | |
61 }; | |
62 | |
63 /* driver data */ | |
64 | |
65 struct win_frame | |
66 { | |
67 uint8_t *ptr; /* pointer to window's frame memory */ | |
68 uint32_t low; /* lowest boundary of frame */ | |
69 uint32_t high; /* highest boundary of frame */ | |
2610 | 70 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
|
71 special case for DGA: idx=-1 |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
72 idx=-2 indicates invalid frame, exists only in init() */ |
2244 | 73 }; |
74 | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
75 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
|
76 |
2298 | 77 static int vesa_zoom=0; /* software scaling */ |
78 static unsigned int scale_xinc=0; | |
79 static unsigned int scale_yinc=0; | |
80 | |
2504 | 81 static uint32_t image_bpp,image_width, image_height; /* source image dimension */ |
2329 | 82 static int32_t x_offset,y_offset; /* to center image on screen */ |
2244 | 83 static unsigned init_mode; /* mode before run of mplayer */ |
84 static void *init_state = NULL; /* state before run of mplayer */ | |
85 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
|
86 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */ |
2244 | 87 static unsigned video_mode; /* selected video mode for playback */ |
88 static struct VesaModeInfoBlock video_mode_info; | |
2331 | 89 static int flip_trigger = 0; |
2337 | 90 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); |
2676 | 91 static void (*rgb2rgb_fnc)(const uint8_t *src,uint8_t *dst,uint32_t src_size); |
2244 | 92 |
2649 | 93 /* multibuffering */ |
94 uint8_t* video_base; /* should be never changed */ | |
95 uint32_t multi_buff[MAX_BUFFERS]; /* contains offsets of buffers */ | |
96 uint8_t multi_size=0; /* total number of buffers */ | |
97 uint8_t multi_idx=0; /* active buffer */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
98 |
2869 | 99 /* Linux Video Overlay */ |
100 static const char *lvo_name = NULL; | |
101 | |
2649 | 102 #define HAS_DGA() (win.idx == -1) |
2244 | 103 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS) |
2649 | 104 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_WRITEABLE) |
105 | |
2244 | 106 static char * vbeErrToStr(int err) |
107 { | |
108 char *retval; | |
109 static char sbuff[80]; | |
110 if((err & VBE_VESA_ERROR_MASK) == VBE_VESA_ERROR_MASK) | |
111 { | |
2255 | 112 sprintf(sbuff,"VESA failed = 0x4f%x",(err & VBE_VESA_ERRCODE_MASK)>>8); |
2244 | 113 retval = sbuff; |
114 } | |
115 else | |
116 switch(err) | |
117 { | |
118 case VBE_OK: retval = "No error"; break; | |
119 case VBE_VM86_FAIL: retval = "vm86() syscall failed"; break; | |
120 case VBE_OUT_OF_DOS_MEM: retval = "Out of DOS memory"; break; | |
121 case VBE_OUT_OF_MEM: retval = "Out of memory"; break; | |
2360 | 122 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
|
123 default: sprintf(sbuff,"Unknown or internal error: %i",err); retval=sbuff; break; |
2244 | 124 } |
125 return retval; | |
126 } | |
127 | |
128 #define PRINT_VBE_ERR(name,err) { printf("vo_vesa: %s returns: %s\n",name,vbeErrToStr(err)); fflush(stdout); } | |
129 | |
130 static void vesa_term( void ) | |
131 { | |
132 int err; | |
2869 | 133 if(lvo_name) vlvo_term(); |
2244 | 134 if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err); |
135 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
|
136 if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
137 if(dga_buffer && !HAS_DGA()) free(dga_buffer); |
2244 | 138 vbeDestroy(); |
139 } | |
140 | |
141 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high) | |
142 #define VIDEO_PTR(offset) (win.ptr + offset - win.low) | |
143 | |
144 static inline void __vbeSwitchBank(unsigned long offset) | |
145 { | |
146 unsigned long gran; | |
147 unsigned new_offset; | |
148 int err; | |
149 gran = video_mode_info.WinGranularity*1024; | |
150 new_offset = offset / gran; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
151 if(HAS_DGA()) { err = -1; goto show_err; } |
2244 | 152 if((err=vbeSetWindow(win.idx,new_offset)) != VBE_OK) |
153 { | |
2610 | 154 show_err: |
2686 | 155 vesa_term(); |
2244 | 156 PRINT_VBE_ERR("vbeSetWindow",err); |
157 printf("vo_vesa: Fatal error occured! Can't continue\n"); | |
158 exit(-1); | |
159 } | |
160 win.low = new_offset * gran; | |
161 win.high = win.low + video_mode_info.WinSize*1024; | |
162 } | |
163 | |
164 static void __vbeSetPixel(int x, int y, int r, int g, int b) | |
165 { | |
166 int x_res = video_mode_info.XResolution; | |
167 int y_res = video_mode_info.YResolution; | |
168 int shift_r = video_mode_info.RedFieldPosition; | |
169 int shift_g = video_mode_info.GreenFieldPosition; | |
170 int shift_b = video_mode_info.BlueFieldPosition; | |
171 int pixel_size = (video_mode_info.BitsPerPixel+7)/8; | |
172 int bpl = video_mode_info.BytesPerScanLine; | |
2676 | 173 int color; |
174 unsigned offset; | |
2244 | 175 |
176 if (x < 0 || x >= x_res || y < 0 || y >= y_res) return; | |
177 r >>= 8 - video_mode_info.RedMaskSize; | |
178 g >>= 8 - video_mode_info.GreenMaskSize; | |
179 b >>= 8 - video_mode_info.BlueMaskSize; | |
180 color = (r << shift_r) | (g << shift_g) | (b << shift_b); | |
181 offset = y * bpl + (x * pixel_size); | |
182 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); | |
183 memcpy(VIDEO_PTR(offset), &color, pixel_size); | |
184 } | |
185 | |
186 /* | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
187 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
|
188 as video memory. |
2244 | 189 */ |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
190 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
|
191 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
192 memcpy(&win.ptr[offset],image,size); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
193 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
194 |
2244 | 195 static void __vbeCopyBlock(unsigned long offset,uint8_t *image,unsigned long size) |
196 { | |
197 unsigned long delta,src_idx = 0; | |
198 while(size) | |
199 { | |
200 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); | |
201 delta = min(size,win.high - offset); | |
202 memcpy(VIDEO_PTR(offset),&image[src_idx],delta); | |
203 src_idx += delta; | |
204 offset += delta; | |
205 size -= delta; | |
206 } | |
207 } | |
208 | |
209 /* | |
210 Copies frame to video memory. Data should be in the same format as video | |
211 memory. | |
212 */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
213 |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
214 #define PIXEL_SIZE() ((video_mode_info.BitsPerPixel+7)/8) |
2676 | 215 #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) ) |
216 #define IMAGE_LINE_SIZE(pixel_size) (image_width*(pixel_size)) | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
217 |
2244 | 218 static void __vbeCopyData(uint8_t *image) |
219 { | |
2308 | 220 unsigned long i,j,image_offset,offset; |
2244 | 221 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
|
222 pixel_size = PIXEL_SIZE(); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
223 screen_line_size = SCREEN_LINE_SIZE(pixel_size); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
224 image_line_size = IMAGE_LINE_SIZE(pixel_size); |
2306 | 225 if(image_width == video_mode_info.XResolution) |
226 { | |
227 /* Special case for zooming */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
228 (*cpy_blk_fnc)(y_offset*screen_line_size,image,image_line_size*image_height); |
2306 | 229 } |
230 else | |
2244 | 231 { |
2306 | 232 x_shift = x_offset*pixel_size; |
2308 | 233 for(j=0,i=y_offset;j<image_height;i++,j++) |
2306 | 234 { |
235 offset = i*screen_line_size+x_shift; | |
236 image_offset = j*image_line_size; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
237 (*cpy_blk_fnc)(offset,&image[image_offset],image_line_size); |
2306 | 238 } |
2244 | 239 } |
240 } | |
2328 | 241 |
2244 | 242 /* is called for yuv only */ |
243 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
244 { | |
2504 | 245 if(verbose > 2) |
246 printf("vo_vesa: draw_slice was called: w=%u h=%u x=%u y=%u\n",w,h,x,y); | |
2869 | 247 if(lvo_name) return vlvo_draw_slice(image,stride,w,h,x,y); |
248 else | |
2298 | 249 if(vesa_zoom) |
250 { | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
251 uint8_t *dst[3]= {dga_buffer, NULL, NULL}; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
252 int dst_stride; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
253 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
254 dst_stride = PIXEL_SIZE()*(HAS_DGA()?video_mode_info.XResolution:image_width); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
255 SwScale_YV12slice(image,stride,y,h,dst,dst_stride, |
2298 | 256 image_width, video_mode_info.BitsPerPixel, |
257 scale_xinc, scale_yinc); | |
258 } | |
259 else | |
260 { | |
2331 | 261 uint8_t *yuv_slice; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
262 int rgb_stride; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
263 yuv_slice=dga_buffer; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
264 if(HAS_DGA()) yuv_slice += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); |
2636 | 265 rgb_stride = HAS_DGA()?video_mode_info.XResolution:image_width; |
266 yuv_slice+=(rgb_stride*y+x)*PIXEL_SIZE(); | |
267 rgb_stride *= PIXEL_SIZE(); | |
2331 | 268 yuv2rgb(yuv_slice, image[0], image[1], image[2], w, h, |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
269 rgb_stride, stride[0], stride[1]); |
2298 | 270 } |
2331 | 271 flip_trigger = 1; |
2298 | 272 return 0; |
2244 | 273 } |
274 | |
2649 | 275 static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
276 { | |
277 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | |
278 vo_draw_alpha_rgb32(w,h,src,srca,stride,dga_buffer+4*(y0*dstride+x0),4*dstride); | |
2337 | 279 } |
280 | |
2649 | 281 static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
282 { | |
283 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | |
284 vo_draw_alpha_rgb24(w,h,src,srca,stride,dga_buffer+3*(y0*dstride+x0),3*dstride); | |
2337 | 285 } |
286 | |
2649 | 287 static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
288 { | |
289 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | |
290 vo_draw_alpha_rgb16(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); | |
2337 | 291 } |
292 | |
2649 | 293 static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
294 { | |
295 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | |
296 vo_draw_alpha_rgb15(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); | |
2337 | 297 } |
298 | |
2649 | 299 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
300 { | |
2688 | 301 UNUSED(x0); |
302 UNUSED(y0); | |
303 UNUSED(w); | |
304 UNUSED(h); | |
305 UNUSED(src); | |
306 UNUSED(srca); | |
307 UNUSED(stride); | |
2337 | 308 } |
309 | |
310 | |
2244 | 311 static void draw_osd(void) |
312 { | |
2649 | 313 uint32_t w,h; |
2504 | 314 if(verbose > 2) |
315 printf("vo_vesa: draw_osd was called\n"); | |
2869 | 316 if(lvo_name) vlvo_draw_osd(); |
317 else | |
318 { | |
319 w = HAS_DGA()?video_mode_info.XResolution:image_width; | |
320 h = HAS_DGA()?video_mode_info.YResolution:image_height; | |
321 if(dga_buffer) vo_draw_text(w,h,draw_alpha_fnc); | |
322 } | |
2244 | 323 } |
324 | |
325 static void flip_page(void) | |
326 { | |
2504 | 327 if(verbose > 2) |
328 printf("vo_vesa: flip_page was called\n"); | |
2869 | 329 if(lvo_name) vlvo_flip_page(); |
330 else | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
331 if(flip_trigger) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
332 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
333 if(!HAS_DGA()) __vbeCopyData(dga_buffer); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
334 flip_trigger = 0; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
335 } |
2869 | 336 if(vo_doublebuffering && multi_size > 1 && !lvo_name) |
2649 | 337 { |
2686 | 338 int err; |
339 if((err=vbeSetDisplayStart(multi_buff[multi_idx],1)) != VBE_OK) | |
340 { | |
341 vesa_term(); | |
2692 | 342 PRINT_VBE_ERR("vbeSetDisplayStart",err); |
2686 | 343 printf("vo_vesa: Fatal error occured! Can't continue\n"); |
344 exit(EXIT_FAILURE); | |
345 } | |
346 multi_idx = multi_idx ? 0 : 1; | |
347 win.ptr = dga_buffer = video_base + multi_buff[multi_idx]; | |
2649 | 348 } |
349 /* | |
350 else | |
351 if(tripple_buffering) | |
352 { | |
353 vbeSetScheduledDisplayStart(multi_buffer[multi_idx],1); | |
354 multi_idx++; | |
355 if(multi_idx > 2) multi_idx = 0; | |
356 win.ptr = dga_buffer = video_base + multi_buffer[multi_idx]; | |
357 } | |
358 */ | |
2244 | 359 } |
360 | |
361 /* is called for rgb only */ | |
362 static uint32_t draw_frame(uint8_t *src[]) | |
363 { | |
2649 | 364 uint8_t *data = src[0]; |
2504 | 365 if(verbose > 2) |
366 printf("vo_vesa: draw_frame was called\n"); | |
2869 | 367 if(lvo_name) return vlvo_draw_frame(src); |
368 else | |
2504 | 369 if(rgb2rgb_fnc) |
370 { | |
2649 | 371 if(HAS_DGA()) |
372 { | |
373 size_t i, psize, ssize, dsize; | |
2676 | 374 uint8_t *dest; |
375 const uint8_t *sptr; | |
2649 | 376 psize = PIXEL_SIZE(); |
377 dsize = SCREEN_LINE_SIZE(psize); | |
2676 | 378 ssize = IMAGE_LINE_SIZE((image_bpp+7)/8); |
379 dest = dga_buffer + y_offset*dsize + x_offset*psize; | |
2649 | 380 sptr = src[0]; |
381 for(i=0;i<image_height;i++) | |
382 { | |
383 (*rgb2rgb_fnc)(sptr,dest,ssize); | |
384 sptr += ssize; | |
385 dest += dsize; | |
386 } | |
387 } | |
388 else | |
389 { | |
390 (*rgb2rgb_fnc)(src[0],dga_buffer,image_width*image_height*image_bpp); | |
391 data = dga_buffer; | |
392 } | |
2504 | 393 if(verbose > 2) |
394 printf("vo_vesa: rgb2rgb_fnc was called\n"); | |
395 } | |
2869 | 396 if((!rgb2rgb_fnc || !HAS_DGA()) && !lvo_name) __vbeCopyData(data); |
2504 | 397 return 0; |
2244 | 398 } |
399 | |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
400 #define SUBDEV_NODGA 0x00000001UL |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
401 #define SUBDEV_FORCEDGA 0x00000002UL |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
402 static uint32_t parseSubDevice(const char *sd) |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
403 { |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
404 uint32_t flags; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
405 flags = 0; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
406 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
|
407 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
408 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
|
409 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
410 if(memcmp(sd,"lvo:",4) == 0) lvo_name = &sd[4]; /* lvo_name will be valid within init() */ |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
411 else if(verbose) printf("vo_vesa: Unknown subcommand: %s\n", sd); |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
412 return flags; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
413 } |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
414 |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
415 |
2244 | 416 static uint32_t query_format(uint32_t format) |
417 { | |
418 uint32_t retval; | |
2504 | 419 if(verbose > 2) |
420 printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
421 if(vo_subdevice) parseSubDevice(vo_subdevice); |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
422 if(lvo_name) return 1; |
2244 | 423 switch(format) |
424 { | |
425 case IMGFMT_YV12: | |
2637 | 426 #if 0 /* Should be tested better */ |
2244 | 427 case IMGFMT_I420: |
428 case IMGFMT_IYUV: | |
429 #endif | |
430 case IMGFMT_RGB8: | |
431 case IMGFMT_RGB15: | |
432 case IMGFMT_RGB16: | |
433 case IMGFMT_RGB24: | |
434 case IMGFMT_RGB32: | |
435 case IMGFMT_BGR8: | |
436 case IMGFMT_BGR15: | |
437 case IMGFMT_BGR16: | |
438 case IMGFMT_BGR24: | |
439 case IMGFMT_BGR32: | |
440 retval = 1; break; | |
441 default: | |
442 if(verbose) | |
443 printf("vo_vesa: unknown format: %x = %s\n",format,vo_format_name(format)); | |
444 retval = 0; | |
445 } | |
446 return retval; | |
447 } | |
448 | |
2686 | 449 static void paintBkGnd( void ) |
450 { | |
451 int x_res = video_mode_info.XResolution; | |
452 int y_res = video_mode_info.YResolution; | |
453 int x, y; | |
454 | |
455 for (y = 0; y < y_res; ++y) | |
456 { | |
457 for (x = 0; x < x_res; ++x) | |
458 { | |
459 int r, g, b; | |
460 if ((x & 16) ^ (y & 16)) | |
461 { | |
462 r = x * 255 / x_res; | |
463 g = y * 255 / y_res; | |
464 b = 255 - x * 255 / x_res; | |
465 } | |
466 else | |
467 { | |
468 r = 255 - x * 255 / x_res; | |
469 g = y * 255 / y_res; | |
470 b = 255 - y * 255 / y_res; | |
471 } | |
472 __vbeSetPixel(x, y, r, g, b); | |
473 } | |
474 } | |
475 } | |
476 | |
2914 | 477 static void clear_screen( void ) |
478 { | |
479 int x_res = video_mode_info.XResolution; | |
480 int y_res = video_mode_info.YResolution; | |
481 int x, y; | |
482 | |
483 for (y = 0; y < y_res; ++y) | |
484 for (x = 0; x < x_res; ++x) | |
485 __vbeSetPixel(x, y, 0, 0, 0); | |
486 } | |
487 | |
2293 | 488 static char *model2str(unsigned char type) |
489 { | |
490 char *retval; | |
491 switch(type) | |
492 { | |
493 case memText: retval = "Text"; break; | |
494 case memCGA: retval="CGA"; break; | |
495 case memHercules: retval="Hercules"; break; | |
496 case memPL: retval="Planar"; break; | |
497 case memPK: retval="Packed pixel"; break; | |
498 case mem256: retval="256"; break; | |
499 case memRGB: retval="Direct color RGB"; break; | |
500 case memYUV: retval="Direct color YUV"; break; | |
501 default: retval="Unknown"; break; | |
502 } | |
503 return retval; | |
504 } | |
505 | |
2649 | 506 unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs ) |
507 { | |
508 unsigned long screen_size, offset; | |
509 unsigned total,i; | |
510 screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((video_mode_info.BitsPerPixel+7)/8); | |
511 if(screen_size%64) screen_size=((screen_size/64)*64)+64; | |
512 total = vsize / screen_size; | |
2918 | 513 if(verbose) printf("vo_vesa: Can use up to %u video buffers\n",total); |
2649 | 514 i = 0; |
515 offset = 0; | |
516 total = min(total,nbuffs); | |
517 while(i < total) { multi_buff[i++] = offset; offset += screen_size; } | |
518 if(!i) | |
519 printf("vo_vesa: Your have too small size of video memory for this mode:\n" | |
520 "vo_vesa: Requires: %08lX exists: %08lX\n", screen_size, vsize); | |
521 return i; | |
522 } | |
523 | |
524 | |
2244 | 525 /* fullscreen: |
526 * bit 0 (0x01) means fullscreen (-fs) | |
527 * bit 1 (0x02) means mode switching (-vm) | |
528 * bit 2 (0x04) enables software scaling (-zoom) | |
2335 | 529 * bit 3 (0x08) enables flipping (-flip) (NK: and for what?) |
2244 | 530 */ |
531 static uint32_t | |
2329 | 532 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
2244 | 533 { |
534 struct VbeInfoBlock vib; | |
535 struct VesaModeInfoBlock vmib; | |
536 size_t i,num_modes; | |
2649 | 537 uint32_t w,h, sd_flags; |
2244 | 538 unsigned short *mode_ptr,win_seg; |
539 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; | |
2337 | 540 int err,fs_mode,yuv_fmt; |
2244 | 541 image_width = width; |
542 image_height = height; | |
2336 | 543 fs_mode = 0; |
2504 | 544 rgb2rgb_fnc = NULL; |
2649 | 545 sd_flags = 0; |
546 if(vo_subdevice) sd_flags = parseSubDevice(vo_subdevice); | |
2329 | 547 if(flags & 0x8) |
2244 | 548 { |
2329 | 549 printf("vo_vesa: switch -flip is not supported\n"); |
2244 | 550 } |
2329 | 551 if(flags & 0x04) vesa_zoom = 1; |
2336 | 552 if(flags & 0x01) |
553 { | |
554 if(vesa_zoom) vesa_zoom = 2; | |
555 else fs_mode = 1; | |
556 } | |
2244 | 557 if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; } |
558 memcpy(vib.VESASignature,"VBE2",4); | |
559 if((err=vbeGetControllerInfo(&vib)) != VBE_OK) | |
560 { | |
561 PRINT_VBE_ERR("vbeGetControllerInfo",err); | |
562 printf("vo_vesa: possible reason: No VBE2 BIOS found\n"); | |
563 return -1; | |
564 } | |
565 /* Print general info here */ | |
566 printf("vo_vesa: Found VESA VBE BIOS Version %x.%x Revision: %x\n", | |
567 (int)(vib.VESAVersion >> 8) & 0xff, | |
568 (int)(vib.VESAVersion & 0xff), | |
569 (int)(vib.OemSoftwareRev & 0xffff)); | |
2255 | 570 printf("vo_vesa: Video memory: %u Kb\n",vib.TotalMemory*64); |
571 printf("vo_vesa: VESA Capabilities: %s %s %s %s %s\n" | |
572 ,vib.Capabilities & VBE_DAC_8BIT ? "8-bit DAC," : "6-bit DAC," | |
573 ,vib.Capabilities & VBE_NONVGA_CRTC ? "non-VGA CRTC,":"VGA CRTC," | |
574 ,vib.Capabilities & VBE_SNOWED_RAMDAC ? "snowed RAMDAC,":"normal RAMDAC," | |
575 ,vib.Capabilities & VBE_STEREOSCOPIC ? "stereoscopic,":"no stereoscopic," | |
576 ,vib.Capabilities & VBE_STEREO_EVC ? "Stereo EVC":"no stereo"); | |
577 printf("vo_vesa: !!! Below will be printed OEM info. !!!\n"); | |
578 printf("vo_vesa: You should watch 5 OEM related lines below else you've broken vm86\n"); | |
2244 | 579 printf("vo_vesa: OEM info: %s\n",vib.OemStringPtr); |
2255 | 580 printf("vo_vesa: OEM Revision: %x\n",vib.OemSoftwareRev); |
581 printf("vo_vesa: OEM vendor: %s\n",vib.OemVendorNamePtr); | |
582 printf("vo_vesa: OEM Product Name: %s\n",vib.OemProductNamePtr); | |
583 printf("vo_vesa: OEM Product Rev: %s\n",vib.OemProductRevPtr); | |
584 printf("vo_vesa: Hint: To get workable TV-Out you should have plugged tv-connector in\n" | |
585 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n"); | |
2244 | 586 /* Find best mode here */ |
587 num_modes = 0; | |
588 mode_ptr = vib.VideoModePtr; | |
589 while(*mode_ptr++ != 0xffff) num_modes++; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
590 yuv_fmt = 0; |
2244 | 591 switch(format) |
592 { | |
593 case IMGFMT_BGR8: | |
594 case IMGFMT_RGB8: bpp = 8; break; | |
595 case IMGFMT_BGR15: | |
596 case IMGFMT_RGB15: bpp = 15; break; | |
597 case IMGFMT_YV12: | |
598 case IMGFMT_I420: | |
2553 | 599 case IMGFMT_IYUV: yuv_fmt = 1; |
600 default: | |
2244 | 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; | |
607 } | |
2504 | 608 image_bpp = bpp; |
609 if(vo_dbpp) bpp = vo_dbpp; | |
610 if(yuv_fmt) yuv2rgb_init(bpp, MODE_RGB); | |
2337 | 611 switch(bpp) |
612 { | |
613 case 15: draw_alpha_fnc = draw_alpha_15; break; | |
614 case 16: draw_alpha_fnc = draw_alpha_16; break; | |
615 case 24: draw_alpha_fnc = draw_alpha_24; break; | |
616 case 32: draw_alpha_fnc = draw_alpha_32; break; | |
617 default: draw_alpha_fnc = draw_alpha_null; break; | |
618 } | |
2244 | 619 if(verbose) |
620 { | |
2304 | 621 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); |
2244 | 622 printf("vo_vesa: Total modes found: %u\n",num_modes); |
623 mode_ptr = vib.VideoModePtr; | |
624 printf("vo_vesa: Mode list:"); | |
625 for(i = 0;i < num_modes;i++) | |
626 { | |
627 printf(" %04X",mode_ptr[i]); | |
628 } | |
629 printf("\nvo_vesa: Modes in detail:\n"); | |
630 } | |
631 mode_ptr = vib.VideoModePtr; | |
2335 | 632 if(vesa_zoom) |
633 { | |
634 image_width = d_width; | |
635 image_height= d_height; | |
636 } | |
637 if(vo_screenwidth) w = vo_screenwidth; | |
638 else w = max(image_width,width); | |
639 if(vo_screenheight) h = vo_screenheight; | |
640 else h = max(image_height,height); | |
2244 | 641 for(i=0;i < num_modes;i++) |
642 { | |
643 if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK) | |
644 { | |
645 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
646 return -1; | |
647 } | |
2329 | 648 if(vmib.XResolution >= w && |
649 vmib.YResolution >= h && | |
2244 | 650 (vmib.ModeAttributes & MOVIE_MODE) == MOVIE_MODE && |
651 vmib.BitsPerPixel == bpp && | |
652 vmib.MemoryModel == memRGB) | |
653 { | |
2293 | 654 if(vmib.XResolution <= best_x && |
655 vmib.YResolution <= best_y) | |
2244 | 656 { |
657 best_x = vmib.XResolution; | |
658 best_y = vmib.YResolution; | |
659 best_mode_idx = i; | |
660 } | |
661 } | |
662 if(verbose) | |
663 { | |
2298 | 664 printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%04X\n" |
2293 | 665 "vo_vesa: #planes=%u model=%u(%s) #pages=%u\n" |
666 "vo_vesa: winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n" | |
2446 | 667 "vo_vesa: direct_color=%u DGA_phys_addr=%08lX\n" |
2244 | 668 ,i,mode_ptr[i],vmib.XResolution,vmib.YResolution,vmib.BitsPerPixel,vmib.ModeAttributes |
2293 | 669 ,vmib.NumberOfPlanes,vmib.MemoryModel,model2str(vmib.MemoryModel),vmib.NumberOfImagePages |
2244 | 670 ,vmib.WinASegment,vmib.WinAAttributes,vmib.WinBSegment,vmib.WinBAttributes,vmib.WinSize,vmib.WinGranularity |
671 ,vmib.DirectColorModeInfo,vmib.PhysBasePtr); | |
672 if(vmib.MemoryModel == 6 || vmib.MemoryModel == 7) | |
673 printf("vo_vesa: direct_color_info = %u:%u:%u:%u\n" | |
674 ,vmib.RedMaskSize,vmib.GreenMaskSize,vmib.BlueMaskSize,vmib.RsvdMaskSize); | |
675 fflush(stdout); | |
676 } | |
677 } | |
678 if(best_mode_idx != UINT_MAX) | |
679 { | |
680 video_mode = vib.VideoModePtr[best_mode_idx]; | |
681 fflush(stdout); | |
682 if((err=vbeGetMode(&init_mode)) != VBE_OK) | |
683 { | |
684 PRINT_VBE_ERR("vbeGetMode",err); | |
685 return -1; | |
686 } | |
687 if(verbose) printf("vo_vesa: Initial video mode: %x\n",init_mode); | |
688 if((err=vbeGetModeInfo(video_mode,&video_mode_info)) != VBE_OK) | |
689 { | |
690 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
691 return -1; | |
692 } | |
2329 | 693 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n" |
694 ,best_mode_idx,video_mode,video_mode_info.XResolution | |
695 ,video_mode_info.YResolution,video_mode_info.BitsPerPixel); | |
2649 | 696 if(sd_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0; |
2336 | 697 if( vesa_zoom || fs_mode ) |
2298 | 698 { |
2872 | 699 if( format==IMGFMT_YV12 || lvo_name ) |
2304 | 700 { |
701 /* software scale */ | |
2329 | 702 if(vesa_zoom > 1) |
2689 | 703 { |
704 aspect_save_orig(width,height); | |
705 aspect_save_prescale(d_width,d_height); | |
706 aspect_save_screenres(video_mode_info.XResolution,video_mode_info.YResolution); | |
707 aspect(&image_width,&image_height,A_ZOOM); | |
708 } | |
2336 | 709 else |
710 if(fs_mode) | |
711 { | |
712 image_width = video_mode_info.XResolution; | |
713 image_height = video_mode_info.YResolution; | |
714 vesa_zoom = 1; | |
715 } | |
2304 | 716 scale_xinc=(width << 16) / image_width - 2; /* needed for proper rounding */ |
717 scale_yinc=(height << 16) / image_height + 2; | |
2869 | 718 if(!lvo_name) SwScale_Init(); |
2304 | 719 if(verbose) printf("vo_vesa: Using SCALE\n"); |
720 } | |
721 else | |
722 { | |
723 printf("vo_vesa: Can't apply zooming to non YV12 formats\n"); | |
724 return -1; | |
725 } | |
2298 | 726 } |
2869 | 727 if(format != IMGFMT_YV12 && image_bpp != video_mode_info.BitsPerPixel && !lvo_name) |
2504 | 728 { |
729 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 32) rgb2rgb_fnc = rgb24to32; | |
730 else | |
2505 | 731 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 24) rgb2rgb_fnc = rgb32to24; |
732 else | |
2712 | 733 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb32to16; |
734 else | |
735 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 15) rgb2rgb_fnc = rgb32to15; | |
736 else | |
2718 | 737 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb24to16; |
738 else | |
739 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 15) rgb2rgb_fnc = rgb24to15; | |
740 else | |
2506 | 741 if(image_bpp == 15 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb15to16; |
742 else | |
2504 | 743 { |
744 printf("vo_vesa: Can't convert %u to %u\n",image_bpp,video_mode_info.BitsPerPixel); | |
745 return -1; | |
746 } | |
2554 | 747 printf("vo_vesa: using %u-bpp to %u-bpp sw convertor\n",image_bpp,video_mode_info.BitsPerPixel); |
2504 | 748 } |
2244 | 749 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE) |
750 win.idx = 0; /* frame A */ | |
751 else | |
752 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE) | |
753 win.idx = 1; /* frame B */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
754 else win.idx = -2; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
755 /* Try use DGA instead */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
756 if(video_mode_info.PhysBasePtr && vib.TotalMemory && (video_mode_info.ModeAttributes & MODE_ATTR_LINEAR)) |
2244 | 757 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
758 void *lfb; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
759 unsigned long vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
760 vsize = vib.TotalMemory*64*1024; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
761 lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vsize); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
762 if(lfb == NULL) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
763 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
|
764 else |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
765 { |
2649 | 766 video_base = win.ptr = lfb; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
767 win.low = 0UL; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
768 win.high = vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
769 win.idx = -1; /* HAS_DGA() is on */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
770 video_mode |= VESA_MODE_USE_LINEAR; |
2649 | 771 printf("vo_vesa: Using DGA (physical resources: %08lXh, %08lXh)" |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
772 ,video_mode_info.PhysBasePtr |
2649 | 773 ,vsize); |
774 if(verbose) printf(" at %08lXh",(unsigned long)lfb); | |
775 printf("\n"); | |
776 if(!(multi_size = fillMultiBuffer(vsize,2))) return -1; | |
777 if(vo_doublebuffering && multi_size < 2) | |
778 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
|
779 } |
2244 | 780 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
781 if(win.idx == -2) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
782 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
783 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
|
784 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
785 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
786 if(!HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
787 { |
2649 | 788 if(sd_flags & SUBDEV_FORCEDGA) |
789 { | |
790 printf("vo_vesa: you've forced DGA. Exiting\n"); | |
791 return -1; | |
792 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
793 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
|
794 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
795 printf("vo_vesa: Can't find valid window address\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
796 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
797 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
798 win.ptr = PhysToVirtSO(win_seg,0); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
799 win.low = 0L; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
800 win.high= video_mode_info.WinSize*1024; |
2649 | 801 printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n" |
802 ,(unsigned long)win.ptr,(unsigned long)win.high); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
803 } |
2329 | 804 if(video_mode_info.XResolution > image_width) |
805 x_offset = (video_mode_info.XResolution - image_width) / 2; | |
806 else x_offset = 0; | |
807 if(video_mode_info.YResolution > image_height) | |
808 y_offset = (video_mode_info.YResolution - image_height) / 2; | |
809 else y_offset = 0; | |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
810 if(verbose) |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
811 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n" |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
812 ,image_width,image_height |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
813 ,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
|
814 ,x_offset,y_offset); |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
815 if(HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
816 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
817 dga_buffer = win.ptr; /* Trickly ;) */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
818 cpy_blk_fnc = __vbeCopyBlockFast; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
819 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
820 else |
2610 | 821 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
822 cpy_blk_fnc = __vbeCopyBlock; |
2869 | 823 if((yuv_fmt || rgb2rgb_fnc) && !lvo_name) |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
824 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
825 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*video_mode_info.BitsPerPixel))) |
2610 | 826 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
827 printf("vo_vesa: Can't allocate temporary buffer\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
828 return -1; |
2610 | 829 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
830 if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer); |
2337 | 831 } |
2504 | 832 } |
2244 | 833 if((err=vbeSaveState(&init_state)) != VBE_OK) |
834 { | |
835 PRINT_VBE_ERR("vbeSaveState",err); | |
836 return -1; | |
837 } | |
838 if((err=vbeSetMode(video_mode,NULL)) != VBE_OK) | |
839 { | |
840 PRINT_VBE_ERR("vbeSetMode",err); | |
841 return -1; | |
842 } | |
843 /* Now we are in video mode!!!*/ | |
2337 | 844 /* Below 'return -1' is impossible */ |
2244 | 845 if(verbose) |
846 { | |
847 printf("vo_vesa: Graphics mode was activated\n"); | |
848 fflush(stdout); | |
849 } | |
2869 | 850 if(lvo_name) |
851 { | |
852 if(vlvo_init(lvo_name,width,height,x_offset,y_offset,image_width,image_height,format,video_mode_info.BitsPerPixel) != 0) | |
853 { | |
854 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
|
855 lvo_name = NULL; |
2869 | 856 vesa_term(); |
857 return -1; | |
858 } | |
859 else printf("vo_vesa: Using video overlay: %s\n",lvo_name); | |
860 } | |
2244 | 861 } |
862 else | |
863 { | |
2255 | 864 printf("vo_vesa: Can't find mode for: %ux%u@%u\n",width,height,bpp); |
2244 | 865 return -1; |
866 } | |
867 if(verbose) | |
868 { | |
869 printf("vo_vesa: VESA initialization complete\n"); | |
870 fflush(stdout); | |
871 } | |
2914 | 872 /* Clear screen for stupid BIOSes */ |
873 clear_screen(); | |
2688 | 874 if(HAS_DGA() && vo_doublebuffering) |
2244 | 875 { |
2686 | 876 for(i=0;i<MAX_BUFFERS;i++) |
877 { | |
878 win.ptr = dga_buffer = video_base + multi_buff[i]; | |
879 if(verbose) paintBkGnd(); | |
880 } | |
2244 | 881 } |
2686 | 882 else |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
883 { |
2686 | 884 if(verbose) paintBkGnd(); |
885 { | |
886 int x; | |
887 x = (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2; | |
888 if(x < 0) x = 0; | |
889 vbeWriteString(x,0,7,title); | |
890 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
891 } |
2244 | 892 return 0; |
893 } | |
894 | |
895 static const vo_info_t* | |
896 get_info(void) | |
897 { | |
2504 | 898 if(verbose > 2) |
899 printf("vo_vesa: get_info was called\n"); | |
2244 | 900 return &vo_info; |
901 } | |
902 | |
903 static void | |
904 uninit(void) | |
905 { | |
2686 | 906 vesa_term(); |
2504 | 907 if(verbose > 2) |
908 printf("vo_vesa: uninit was called\n"); | |
2244 | 909 } |
910 | |
911 | |
912 static void check_events(void) | |
913 { | |
2504 | 914 if(verbose > 2) |
915 printf("vo_vesa: check_events was called\n"); | |
2244 | 916 /* Nothing to do */ |
917 } |