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