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