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