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