Mercurial > mplayer.hg
annotate libvo/vo_vesa.c @ 4494:382a3c60629e
Allows to users control direct rendering
author | nick |
---|---|
date | Sun, 03 Feb 2002 09:28:58 +0000 |
parents | be41ab8c8918 |
children | bc5b78f1df77 |
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 } |
4493 | 341 if(vo_doublebuffering && multi_size > 1) |
2649 | 342 { |
2686 | 343 int err; |
344 if((err=vbeSetDisplayStart(multi_buff[multi_idx],1)) != VBE_OK) | |
345 { | |
346 vesa_term(); | |
2692 | 347 PRINT_VBE_ERR("vbeSetDisplayStart",err); |
2686 | 348 printf("vo_vesa: Fatal error occured! Can't continue\n"); |
349 exit(EXIT_FAILURE); | |
350 } | |
351 multi_idx = multi_idx ? 0 : 1; | |
352 win.ptr = dga_buffer = video_base + multi_buff[multi_idx]; | |
2649 | 353 } |
354 /* | |
355 else | |
356 if(tripple_buffering) | |
357 { | |
358 vbeSetScheduledDisplayStart(multi_buffer[multi_idx],1); | |
359 multi_idx++; | |
360 if(multi_idx > 2) multi_idx = 0; | |
361 win.ptr = dga_buffer = video_base + multi_buffer[multi_idx]; | |
362 } | |
363 */ | |
2244 | 364 } |
365 | |
366 /* is called for rgb only */ | |
367 static uint32_t draw_frame(uint8_t *src[]) | |
368 { | |
2649 | 369 uint8_t *data = src[0]; |
2504 | 370 if(verbose > 2) |
371 printf("vo_vesa: draw_frame was called\n"); | |
372 if(rgb2rgb_fnc) | |
373 { | |
2649 | 374 if(HAS_DGA()) |
375 { | |
376 size_t i, psize, ssize, dsize; | |
2676 | 377 uint8_t *dest; |
378 const uint8_t *sptr; | |
2649 | 379 psize = PIXEL_SIZE(); |
380 dsize = SCREEN_LINE_SIZE(psize); | |
2676 | 381 ssize = IMAGE_LINE_SIZE((image_bpp+7)/8); |
382 dest = dga_buffer + y_offset*dsize + x_offset*psize; | |
2649 | 383 sptr = src[0]; |
384 for(i=0;i<image_height;i++) | |
385 { | |
386 (*rgb2rgb_fnc)(sptr,dest,ssize); | |
387 sptr += ssize; | |
388 dest += dsize; | |
389 } | |
390 } | |
391 else | |
392 { | |
393 (*rgb2rgb_fnc)(src[0],dga_buffer,image_width*image_height*image_bpp); | |
394 data = dga_buffer; | |
395 } | |
2504 | 396 if(verbose > 2) |
397 printf("vo_vesa: rgb2rgb_fnc was called\n"); | |
398 } | |
4493 | 399 if(!rgb2rgb_fnc || !HAS_DGA()) __vbeCopyData(data); |
2504 | 400 return 0; |
2244 | 401 } |
402 | |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
403 #define SUBDEV_NODGA 0x00000001UL |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
404 #define SUBDEV_FORCEDGA 0x00000002UL |
4362 | 405 static uint32_t subdev_flags = 0xFFFFFFFEUL; |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
406 static uint32_t parseSubDevice(const char *sd) |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
407 { |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
408 uint32_t flags; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
409 flags = 0; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
410 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
|
411 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
412 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
|
413 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
414 if(memcmp(sd,"lvo:",4) == 0) lvo_name = &sd[4]; /* lvo_name will be valid within init() */ |
4089 | 415 #ifdef CONFIG_VIDIX |
4030 | 416 else |
417 if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */ | |
4089 | 418 #endif |
4030 | 419 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
|
420 return flags; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
421 } |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
422 |
2244 | 423 static uint32_t query_format(uint32_t format) |
424 { | |
425 uint32_t retval; | |
2504 | 426 if(verbose > 2) |
427 printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
2244 | 428 switch(format) |
429 { | |
430 case IMGFMT_YV12: | |
2637 | 431 #if 0 /* Should be tested better */ |
2244 | 432 case IMGFMT_I420: |
433 case IMGFMT_IYUV: | |
434 #endif | |
435 case IMGFMT_RGB8: | |
436 case IMGFMT_RGB15: | |
437 case IMGFMT_RGB16: | |
438 case IMGFMT_RGB24: | |
439 case IMGFMT_RGB32: | |
440 case IMGFMT_BGR8: | |
441 case IMGFMT_BGR15: | |
442 case IMGFMT_BGR16: | |
443 case IMGFMT_BGR24: | |
444 case IMGFMT_BGR32: | |
445 retval = 1; break; | |
446 default: | |
447 if(verbose) | |
448 printf("vo_vesa: unknown format: %x = %s\n",format,vo_format_name(format)); | |
449 retval = 0; | |
450 } | |
451 return retval; | |
452 } | |
453 | |
2686 | 454 static void paintBkGnd( void ) |
455 { | |
456 int x_res = video_mode_info.XResolution; | |
457 int y_res = video_mode_info.YResolution; | |
458 int x, y; | |
459 | |
460 for (y = 0; y < y_res; ++y) | |
461 { | |
462 for (x = 0; x < x_res; ++x) | |
463 { | |
464 int r, g, b; | |
465 if ((x & 16) ^ (y & 16)) | |
466 { | |
467 r = x * 255 / x_res; | |
468 g = y * 255 / y_res; | |
469 b = 255 - x * 255 / x_res; | |
470 } | |
471 else | |
472 { | |
473 r = 255 - x * 255 / x_res; | |
474 g = y * 255 / y_res; | |
475 b = 255 - y * 255 / y_res; | |
476 } | |
477 __vbeSetPixel(x, y, r, g, b); | |
478 } | |
479 } | |
480 } | |
481 | |
2914 | 482 static void clear_screen( void ) |
483 { | |
484 int x_res = video_mode_info.XResolution; | |
485 int y_res = video_mode_info.YResolution; | |
486 int x, y; | |
487 | |
488 for (y = 0; y < y_res; ++y) | |
489 for (x = 0; x < x_res; ++x) | |
490 __vbeSetPixel(x, y, 0, 0, 0); | |
491 } | |
492 | |
2293 | 493 static char *model2str(unsigned char type) |
494 { | |
495 char *retval; | |
496 switch(type) | |
497 { | |
498 case memText: retval = "Text"; break; | |
499 case memCGA: retval="CGA"; break; | |
500 case memHercules: retval="Hercules"; break; | |
501 case memPL: retval="Planar"; break; | |
502 case memPK: retval="Packed pixel"; break; | |
503 case mem256: retval="256"; break; | |
504 case memRGB: retval="Direct color RGB"; break; | |
505 case memYUV: retval="Direct color YUV"; break; | |
506 default: retval="Unknown"; break; | |
507 } | |
508 return retval; | |
509 } | |
510 | |
2649 | 511 unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs ) |
512 { | |
513 unsigned long screen_size, offset; | |
514 unsigned total,i; | |
515 screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((video_mode_info.BitsPerPixel+7)/8); | |
516 if(screen_size%64) screen_size=((screen_size/64)*64)+64; | |
517 total = vsize / screen_size; | |
2918 | 518 if(verbose) printf("vo_vesa: Can use up to %u video buffers\n",total); |
2649 | 519 i = 0; |
520 offset = 0; | |
521 total = min(total,nbuffs); | |
522 while(i < total) { multi_buff[i++] = offset; offset += screen_size; } | |
523 if(!i) | |
524 printf("vo_vesa: Your have too small size of video memory for this mode:\n" | |
525 "vo_vesa: Requires: %08lX exists: %08lX\n", screen_size, vsize); | |
526 return i; | |
527 } | |
528 | |
529 | |
2244 | 530 /* fullscreen: |
531 * bit 0 (0x01) means fullscreen (-fs) | |
532 * bit 1 (0x02) means mode switching (-vm) | |
533 * bit 2 (0x04) enables software scaling (-zoom) | |
2335 | 534 * bit 3 (0x08) enables flipping (-flip) (NK: and for what?) |
2244 | 535 */ |
536 static uint32_t | |
4433 | 537 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format,const vo_tune_info_t *info) |
2244 | 538 { |
539 struct VbeInfoBlock vib; | |
540 struct VesaModeInfoBlock vmib; | |
541 size_t i,num_modes; | |
4362 | 542 uint32_t w,h; |
2244 | 543 unsigned short *mode_ptr,win_seg; |
544 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; | |
2337 | 545 int err,fs_mode,yuv_fmt; |
2244 | 546 image_width = width; |
547 image_height = height; | |
2336 | 548 fs_mode = 0; |
2504 | 549 rgb2rgb_fnc = NULL; |
4362 | 550 if(subdev_flags == 0xFFFFFFFEUL) |
2971 | 551 { |
4362 | 552 printf("vo_vesa: detected internal fatal error: init is called before preinit\n"); |
2971 | 553 return -1; |
4362 | 554 } |
555 if(subdev_flags == -1) return -1; | |
2329 | 556 if(flags & 0x8) |
2244 | 557 { |
2329 | 558 printf("vo_vesa: switch -flip is not supported\n"); |
2244 | 559 } |
2329 | 560 if(flags & 0x04) vesa_zoom = 1; |
2336 | 561 if(flags & 0x01) |
562 { | |
563 if(vesa_zoom) vesa_zoom = 2; | |
564 else fs_mode = 1; | |
565 } | |
2244 | 566 if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; } |
567 memcpy(vib.VESASignature,"VBE2",4); | |
568 if((err=vbeGetControllerInfo(&vib)) != VBE_OK) | |
569 { | |
570 PRINT_VBE_ERR("vbeGetControllerInfo",err); | |
571 printf("vo_vesa: possible reason: No VBE2 BIOS found\n"); | |
572 return -1; | |
573 } | |
574 /* Print general info here */ | |
575 printf("vo_vesa: Found VESA VBE BIOS Version %x.%x Revision: %x\n", | |
576 (int)(vib.VESAVersion >> 8) & 0xff, | |
577 (int)(vib.VESAVersion & 0xff), | |
578 (int)(vib.OemSoftwareRev & 0xffff)); | |
2255 | 579 printf("vo_vesa: Video memory: %u Kb\n",vib.TotalMemory*64); |
580 printf("vo_vesa: VESA Capabilities: %s %s %s %s %s\n" | |
581 ,vib.Capabilities & VBE_DAC_8BIT ? "8-bit DAC," : "6-bit DAC," | |
582 ,vib.Capabilities & VBE_NONVGA_CRTC ? "non-VGA CRTC,":"VGA CRTC," | |
583 ,vib.Capabilities & VBE_SNOWED_RAMDAC ? "snowed RAMDAC,":"normal RAMDAC," | |
584 ,vib.Capabilities & VBE_STEREOSCOPIC ? "stereoscopic,":"no stereoscopic," | |
585 ,vib.Capabilities & VBE_STEREO_EVC ? "Stereo EVC":"no stereo"); | |
586 printf("vo_vesa: !!! Below will be printed OEM info. !!!\n"); | |
587 printf("vo_vesa: You should watch 5 OEM related lines below else you've broken vm86\n"); | |
2244 | 588 printf("vo_vesa: OEM info: %s\n",vib.OemStringPtr); |
2255 | 589 printf("vo_vesa: OEM Revision: %x\n",vib.OemSoftwareRev); |
590 printf("vo_vesa: OEM vendor: %s\n",vib.OemVendorNamePtr); | |
591 printf("vo_vesa: OEM Product Name: %s\n",vib.OemProductNamePtr); | |
592 printf("vo_vesa: OEM Product Rev: %s\n",vib.OemProductRevPtr); | |
593 printf("vo_vesa: Hint: To get workable TV-Out you should have plugged tv-connector in\n" | |
594 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n"); | |
2244 | 595 /* Find best mode here */ |
596 num_modes = 0; | |
597 mode_ptr = vib.VideoModePtr; | |
598 while(*mode_ptr++ != 0xffff) num_modes++; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
599 yuv_fmt = 0; |
2244 | 600 switch(format) |
601 { | |
602 case IMGFMT_BGR8: | |
603 case IMGFMT_RGB8: bpp = 8; break; | |
604 case IMGFMT_BGR15: | |
605 case IMGFMT_RGB15: bpp = 15; break; | |
606 case IMGFMT_YV12: | |
607 case IMGFMT_I420: | |
2553 | 608 case IMGFMT_IYUV: yuv_fmt = 1; |
609 default: | |
2244 | 610 case IMGFMT_BGR16: |
611 case IMGFMT_RGB16: bpp = 16; break; | |
612 case IMGFMT_BGR24: | |
613 case IMGFMT_RGB24: bpp = 24; break; | |
614 case IMGFMT_BGR32: | |
615 case IMGFMT_RGB32: bpp = 32; break; | |
616 } | |
2504 | 617 image_bpp = bpp; |
618 if(vo_dbpp) bpp = vo_dbpp; | |
619 if(yuv_fmt) yuv2rgb_init(bpp, MODE_RGB); | |
2337 | 620 switch(bpp) |
621 { | |
622 case 15: draw_alpha_fnc = draw_alpha_15; break; | |
623 case 16: draw_alpha_fnc = draw_alpha_16; break; | |
624 case 24: draw_alpha_fnc = draw_alpha_24; break; | |
625 case 32: draw_alpha_fnc = draw_alpha_32; break; | |
626 default: draw_alpha_fnc = draw_alpha_null; break; | |
627 } | |
2244 | 628 if(verbose) |
629 { | |
2304 | 630 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); |
2244 | 631 printf("vo_vesa: Total modes found: %u\n",num_modes); |
632 mode_ptr = vib.VideoModePtr; | |
633 printf("vo_vesa: Mode list:"); | |
634 for(i = 0;i < num_modes;i++) | |
635 { | |
636 printf(" %04X",mode_ptr[i]); | |
637 } | |
638 printf("\nvo_vesa: Modes in detail:\n"); | |
639 } | |
640 mode_ptr = vib.VideoModePtr; | |
2335 | 641 if(vesa_zoom) |
642 { | |
643 image_width = d_width; | |
644 image_height= d_height; | |
645 } | |
646 if(vo_screenwidth) w = vo_screenwidth; | |
647 else w = max(image_width,width); | |
648 if(vo_screenheight) h = vo_screenheight; | |
649 else h = max(image_height,height); | |
2244 | 650 for(i=0;i < num_modes;i++) |
651 { | |
652 if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK) | |
653 { | |
654 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
655 return -1; | |
656 } | |
2329 | 657 if(vmib.XResolution >= w && |
658 vmib.YResolution >= h && | |
2244 | 659 (vmib.ModeAttributes & MOVIE_MODE) == MOVIE_MODE && |
660 vmib.BitsPerPixel == bpp && | |
661 vmib.MemoryModel == memRGB) | |
662 { | |
2293 | 663 if(vmib.XResolution <= best_x && |
664 vmib.YResolution <= best_y) | |
2244 | 665 { |
666 best_x = vmib.XResolution; | |
667 best_y = vmib.YResolution; | |
668 best_mode_idx = i; | |
669 } | |
670 } | |
671 if(verbose) | |
672 { | |
2298 | 673 printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%04X\n" |
2293 | 674 "vo_vesa: #planes=%u model=%u(%s) #pages=%u\n" |
675 "vo_vesa: winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n" | |
2446 | 676 "vo_vesa: direct_color=%u DGA_phys_addr=%08lX\n" |
2244 | 677 ,i,mode_ptr[i],vmib.XResolution,vmib.YResolution,vmib.BitsPerPixel,vmib.ModeAttributes |
2293 | 678 ,vmib.NumberOfPlanes,vmib.MemoryModel,model2str(vmib.MemoryModel),vmib.NumberOfImagePages |
2244 | 679 ,vmib.WinASegment,vmib.WinAAttributes,vmib.WinBSegment,vmib.WinBAttributes,vmib.WinSize,vmib.WinGranularity |
680 ,vmib.DirectColorModeInfo,vmib.PhysBasePtr); | |
681 if(vmib.MemoryModel == 6 || vmib.MemoryModel == 7) | |
682 printf("vo_vesa: direct_color_info = %u:%u:%u:%u\n" | |
683 ,vmib.RedMaskSize,vmib.GreenMaskSize,vmib.BlueMaskSize,vmib.RsvdMaskSize); | |
684 fflush(stdout); | |
685 } | |
686 } | |
687 if(best_mode_idx != UINT_MAX) | |
688 { | |
689 video_mode = vib.VideoModePtr[best_mode_idx]; | |
690 fflush(stdout); | |
691 if((err=vbeGetMode(&init_mode)) != VBE_OK) | |
692 { | |
693 PRINT_VBE_ERR("vbeGetMode",err); | |
694 return -1; | |
695 } | |
696 if(verbose) printf("vo_vesa: Initial video mode: %x\n",init_mode); | |
697 if((err=vbeGetModeInfo(video_mode,&video_mode_info)) != VBE_OK) | |
698 { | |
699 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
700 return -1; | |
701 } | |
2329 | 702 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n" |
703 ,best_mode_idx,video_mode,video_mode_info.XResolution | |
704 ,video_mode_info.YResolution,video_mode_info.BitsPerPixel); | |
4362 | 705 if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0; |
2336 | 706 if( vesa_zoom || fs_mode ) |
2298 | 707 { |
4089 | 708 if(format==IMGFMT_YV12 || lvo_name |
709 #ifdef CONFIG_VIDIX | |
710 || vidix_name | |
711 #endif | |
712 ) | |
2304 | 713 { |
714 /* software scale */ | |
2329 | 715 if(vesa_zoom > 1) |
2689 | 716 { |
717 aspect_save_orig(width,height); | |
718 aspect_save_prescale(d_width,d_height); | |
719 aspect_save_screenres(video_mode_info.XResolution,video_mode_info.YResolution); | |
720 aspect(&image_width,&image_height,A_ZOOM); | |
721 } | |
2336 | 722 else |
723 if(fs_mode) | |
724 { | |
725 image_width = video_mode_info.XResolution; | |
726 image_height = video_mode_info.YResolution; | |
727 vesa_zoom = 1; | |
728 } | |
3209 | 729 scale_srcW=width; |
730 scale_srcH=height; | |
4089 | 731 if(!lvo_name |
732 #ifdef CONFIG_VIDIX | |
733 && !vidix_name | |
734 #endif | |
735 ) SwScale_Init(); | |
2304 | 736 if(verbose) printf("vo_vesa: Using SCALE\n"); |
737 } | |
738 else | |
739 { | |
740 printf("vo_vesa: Can't apply zooming to non YV12 formats\n"); | |
741 return -1; | |
742 } | |
2298 | 743 } |
4089 | 744 if(format != IMGFMT_YV12 && image_bpp != video_mode_info.BitsPerPixel && !lvo_name |
745 #ifdef CONFIG_VIDIX | |
746 && !vidix_name | |
747 #endif | |
748 ) | |
2504 | 749 { |
750 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 32) rgb2rgb_fnc = rgb24to32; | |
751 else | |
2505 | 752 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 24) rgb2rgb_fnc = rgb32to24; |
753 else | |
2712 | 754 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb32to16; |
755 else | |
756 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 15) rgb2rgb_fnc = rgb32to15; | |
757 else | |
2718 | 758 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb24to16; |
759 else | |
760 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 15) rgb2rgb_fnc = rgb24to15; | |
761 else | |
2506 | 762 if(image_bpp == 15 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb15to16; |
763 else | |
2504 | 764 { |
765 printf("vo_vesa: Can't convert %u to %u\n",image_bpp,video_mode_info.BitsPerPixel); | |
766 return -1; | |
767 } | |
2554 | 768 printf("vo_vesa: using %u-bpp to %u-bpp sw convertor\n",image_bpp,video_mode_info.BitsPerPixel); |
2504 | 769 } |
2244 | 770 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE) |
771 win.idx = 0; /* frame A */ | |
772 else | |
773 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE) | |
774 win.idx = 1; /* frame B */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
775 else win.idx = -2; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
776 /* Try use DGA instead */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
777 if(video_mode_info.PhysBasePtr && vib.TotalMemory && (video_mode_info.ModeAttributes & MODE_ATTR_LINEAR)) |
2244 | 778 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
779 void *lfb; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
780 unsigned long vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
781 vsize = vib.TotalMemory*64*1024; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
782 lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vsize); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
783 if(lfb == NULL) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
784 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
|
785 else |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
786 { |
2649 | 787 video_base = win.ptr = lfb; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
788 win.low = 0UL; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
789 win.high = vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
790 win.idx = -1; /* HAS_DGA() is on */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
791 video_mode |= VESA_MODE_USE_LINEAR; |
2649 | 792 printf("vo_vesa: Using DGA (physical resources: %08lXh, %08lXh)" |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
793 ,video_mode_info.PhysBasePtr |
2649 | 794 ,vsize); |
795 if(verbose) printf(" at %08lXh",(unsigned long)lfb); | |
796 printf("\n"); | |
797 if(!(multi_size = fillMultiBuffer(vsize,2))) return -1; | |
798 if(vo_doublebuffering && multi_size < 2) | |
799 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
|
800 } |
2244 | 801 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
802 if(win.idx == -2) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
803 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
804 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
|
805 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
806 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
807 if(!HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
808 { |
4362 | 809 if(subdev_flags & SUBDEV_FORCEDGA) |
2649 | 810 { |
811 printf("vo_vesa: you've forced DGA. Exiting\n"); | |
812 return -1; | |
813 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
814 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
|
815 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
816 printf("vo_vesa: Can't find valid window address\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
817 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
818 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
819 win.ptr = PhysToVirtSO(win_seg,0); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
820 win.low = 0L; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
821 win.high= video_mode_info.WinSize*1024; |
2649 | 822 printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n" |
823 ,(unsigned long)win.ptr,(unsigned long)win.high); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
824 } |
2329 | 825 if(video_mode_info.XResolution > image_width) |
826 x_offset = (video_mode_info.XResolution - image_width) / 2; | |
827 else x_offset = 0; | |
828 if(video_mode_info.YResolution > image_height) | |
829 y_offset = (video_mode_info.YResolution - image_height) / 2; | |
830 else y_offset = 0; | |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
831 if(verbose) |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
832 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
|
833 ,image_width,image_height |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
834 ,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
|
835 ,x_offset,y_offset); |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
836 if(HAS_DGA()) |
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 dga_buffer = win.ptr; /* Trickly ;) */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
839 cpy_blk_fnc = __vbeCopyBlockFast; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
840 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
841 else |
2610 | 842 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
843 cpy_blk_fnc = __vbeCopyBlock; |
4089 | 844 if((yuv_fmt || rgb2rgb_fnc) && !lvo_name |
845 #ifdef CONFIG_VIDIX | |
846 && !vidix_name | |
847 #endif | |
848 ) | |
2633
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 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*video_mode_info.BitsPerPixel))) |
2610 | 851 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
852 printf("vo_vesa: Can't allocate temporary buffer\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
853 return -1; |
2610 | 854 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
855 if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer); |
2337 | 856 } |
2504 | 857 } |
2244 | 858 if((err=vbeSaveState(&init_state)) != VBE_OK) |
859 { | |
860 PRINT_VBE_ERR("vbeSaveState",err); | |
861 return -1; | |
862 } | |
863 if((err=vbeSetMode(video_mode,NULL)) != VBE_OK) | |
864 { | |
865 PRINT_VBE_ERR("vbeSetMode",err); | |
866 return -1; | |
867 } | |
868 /* Now we are in video mode!!!*/ | |
2337 | 869 /* Below 'return -1' is impossible */ |
2244 | 870 if(verbose) |
871 { | |
872 printf("vo_vesa: Graphics mode was activated\n"); | |
873 fflush(stdout); | |
874 } | |
2869 | 875 if(lvo_name) |
876 { | |
2971 | 877 if(vlvo_init(width,height,x_offset,y_offset,image_width,image_height,format,video_mode_info.BitsPerPixel) != 0) |
2869 | 878 { |
879 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
|
880 lvo_name = NULL; |
2869 | 881 vesa_term(); |
882 return -1; | |
883 } | |
884 else printf("vo_vesa: Using video overlay: %s\n",lvo_name); | |
885 } | |
4089 | 886 #ifdef CONFIG_VIDIX |
4030 | 887 else |
888 if(vidix_name) | |
889 { | |
890 if(vidix_init(width,height,x_offset,y_offset,image_width, | |
891 image_height,format,video_mode_info.BitsPerPixel, | |
4434 | 892 video_mode_info.XResolution,video_mode_info.YResolution,info) != 0) |
4030 | 893 { |
894 printf("vo_vesa: Can't initialize VIDIX driver\n"); | |
895 vidix_name = NULL; | |
4083 | 896 vidix_term(); |
4030 | 897 return -1; |
898 } | |
4083 | 899 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
|
900 vidix_start(); |
4030 | 901 } |
4089 | 902 #endif |
2244 | 903 } |
904 else | |
905 { | |
2255 | 906 printf("vo_vesa: Can't find mode for: %ux%u@%u\n",width,height,bpp); |
2244 | 907 return -1; |
908 } | |
909 if(verbose) | |
910 { | |
911 printf("vo_vesa: VESA initialization complete\n"); | |
912 fflush(stdout); | |
913 } | |
2914 | 914 /* Clear screen for stupid BIOSes */ |
915 clear_screen(); | |
2688 | 916 if(HAS_DGA() && vo_doublebuffering) |
2244 | 917 { |
2686 | 918 for(i=0;i<MAX_BUFFERS;i++) |
919 { | |
920 win.ptr = dga_buffer = video_base + multi_buff[i]; | |
4002 | 921 if(verbose>1) paintBkGnd(); |
2686 | 922 } |
2244 | 923 } |
2686 | 924 else |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
925 { |
4002 | 926 if(verbose>1) paintBkGnd(); |
2686 | 927 { |
928 int x; | |
929 x = (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2; | |
930 if(x < 0) x = 0; | |
931 vbeWriteString(x,0,7,title); | |
932 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
933 } |
2244 | 934 return 0; |
935 } | |
936 | |
937 static const vo_info_t* | |
938 get_info(void) | |
939 { | |
2504 | 940 if(verbose > 2) |
941 printf("vo_vesa: get_info was called\n"); | |
2244 | 942 return &vo_info; |
943 } | |
944 | |
945 static void | |
946 uninit(void) | |
947 { | |
2686 | 948 vesa_term(); |
2504 | 949 if(verbose > 2) |
950 printf("vo_vesa: uninit was called\n"); | |
2244 | 951 } |
952 | |
953 | |
954 static void check_events(void) | |
955 { | |
2504 | 956 if(verbose > 2) |
957 printf("vo_vesa: check_events was called\n"); | |
2244 | 958 /* Nothing to do */ |
959 } | |
4352 | 960 |
961 static uint32_t preinit(const char *arg) | |
962 { | |
4362 | 963 int pre_init_err = 0; |
964 if(verbose>1) printf("vo_vesa: preinit(%s) was called\n",arg); | |
965 if(verbose > 2) | |
966 printf("vo_vesa: subdevice %s is being initialized\n",arg); | |
967 subdev_flags = 0; | |
968 if(arg) subdev_flags = parseSubDevice(arg); | |
969 if(lvo_name) pre_init_err = vlvo_preinit(lvo_name); | |
970 #ifdef CONFIG_VIDIX | |
971 else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_vesa); | |
972 #endif | |
973 if(verbose > 2) | |
974 printf("vo_subdevice: initialization returns: %i\n",pre_init_err); | |
975 return pre_init_err; | |
4352 | 976 } |
977 | |
978 static void query_vaa(vo_vaa_t *vaa) | |
979 { | |
980 memset(vaa,0,sizeof(vo_vaa_t)); | |
981 } |