Mercurial > mplayer.hg
annotate libvo/vo_vesa.c @ 7703:386e76d9c0cc
argh 100l
author | nexus |
---|---|
date | Thu, 10 Oct 2002 09:14:53 +0000 |
parents | d8ce19f6b1fe |
children | 5b39e79af5fe |
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 */ |
2775 | 17 #include "config.h" |
7069 | 18 #include "gtf.h" |
2244 | 19 #include <stdio.h> |
2775 | 20 #ifdef HAVE_MALLOC_H |
21 #include <malloc.h> | |
22 #endif | |
2446 | 23 #include <stdlib.h> |
2244 | 24 #include <string.h> |
25 #include <stddef.h> | |
26 #include <limits.h> | |
4739 | 27 #include <unistd.h> |
28 #include <pwd.h> | |
29 #include <sys/types.h> | |
30 #include <sys/stat.h> | |
31 | |
2244 | 32 |
33 #include "video_out.h" | |
34 #include "video_out_internal.h" | |
35 | |
36 #include "fastmemcpy.h" | |
2337 | 37 #include "sub.h" |
2244 | 38 #include "linux/vbelib.h" |
39 #include "bswap.h" | |
2689 | 40 #include "aspect.h" |
3202 | 41 #include "vesa_lvo.h" |
4089 | 42 #ifdef CONFIG_VIDIX |
4030 | 43 #include "vosub_vidix.h" |
4089 | 44 #endif |
2244 | 45 |
2298 | 46 #include "../postproc/swscale.h" |
47 | |
2244 | 48 LIBVO_EXTERN(vesa) |
4739 | 49 |
50 #ifdef HAVE_PNG | |
51 extern vo_functions_t video_out_png; | |
52 #endif | |
53 | |
2244 | 54 extern int verbose; |
55 | |
7069 | 56 extern char *monitor_hfreq_str; |
57 extern char *monitor_vfreq_str; | |
58 extern char *monitor_dotclock_str; | |
59 | |
2649 | 60 #define MAX_BUFFERS 3 |
61 | |
2244 | 62 #ifndef max |
63 #define max(a,b) ((a)>(b)?(a):(b)) | |
64 #endif | |
65 #ifndef min | |
66 #define min(a,b) ((a)<(b)?(a):(b)) | |
67 #endif | |
68 | |
2688 | 69 #define UNUSED(x) ((void)(x)) /**< Removes warning about unused arguments */ |
2244 | 70 |
71 static vo_info_t vo_info = | |
72 { | |
73 "VESA VBE 2.0 video output", | |
74 "vesa", | |
75 "Nick Kurshev <nickols_k@mail.ru>", | |
76 "Requires ROOT privileges" | |
77 }; | |
78 | |
79 /* driver data */ | |
80 | |
81 struct win_frame | |
82 { | |
83 uint8_t *ptr; /* pointer to window's frame memory */ | |
84 uint32_t low; /* lowest boundary of frame */ | |
85 uint32_t high; /* highest boundary of frame */ | |
2610 | 86 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
|
87 special case for DGA: idx=-1 |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
88 idx=-2 indicates invalid frame, exists only in init() */ |
2244 | 89 }; |
90 | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
91 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
|
92 |
4537 | 93 static uint32_t srcW=0,srcH=0,srcBpp,srcFourcc; /* source image description */ |
94 static uint32_t dstBpp,dstW, dstH,dstFourcc; /* destinition image description */ | |
2298 | 95 |
4537 | 96 static SwsContext * sws = NULL; |
97 | |
2329 | 98 static int32_t x_offset,y_offset; /* to center image on screen */ |
2244 | 99 static unsigned init_mode; /* mode before run of mplayer */ |
100 static void *init_state = NULL; /* state before run of mplayer */ | |
101 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
|
102 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */ |
2244 | 103 static unsigned video_mode; /* selected video mode for playback */ |
104 static struct VesaModeInfoBlock video_mode_info; | |
2331 | 105 static int flip_trigger = 0; |
2337 | 106 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); |
2244 | 107 |
2649 | 108 /* multibuffering */ |
109 uint8_t* video_base; /* should be never changed */ | |
110 uint32_t multi_buff[MAX_BUFFERS]; /* contains offsets of buffers */ | |
111 uint8_t multi_size=0; /* total number of buffers */ | |
112 uint8_t multi_idx=0; /* active buffer */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
113 |
2869 | 114 /* Linux Video Overlay */ |
115 static const char *lvo_name = NULL; | |
4089 | 116 #ifdef CONFIG_VIDIX |
4030 | 117 static const char *vidix_name = NULL; |
4089 | 118 #endif |
2869 | 119 |
2649 | 120 #define HAS_DGA() (win.idx == -1) |
2244 | 121 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS) |
2649 | 122 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_WRITEABLE) |
123 | |
2244 | 124 static char * vbeErrToStr(int err) |
125 { | |
126 char *retval; | |
127 static char sbuff[80]; | |
128 if((err & VBE_VESA_ERROR_MASK) == VBE_VESA_ERROR_MASK) | |
129 { | |
4667 | 130 sprintf(sbuff,"VESA failed = 0x4f%02x",(err & VBE_VESA_ERRCODE_MASK)>>8); |
2244 | 131 retval = sbuff; |
132 } | |
133 else | |
134 switch(err) | |
135 { | |
136 case VBE_OK: retval = "No error"; break; | |
137 case VBE_VM86_FAIL: retval = "vm86() syscall failed"; break; | |
138 case VBE_OUT_OF_DOS_MEM: retval = "Out of DOS memory"; break; | |
139 case VBE_OUT_OF_MEM: retval = "Out of memory"; break; | |
2360 | 140 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
|
141 default: sprintf(sbuff,"Unknown or internal error: %i",err); retval=sbuff; break; |
2244 | 142 } |
143 return retval; | |
144 } | |
145 | |
146 #define PRINT_VBE_ERR(name,err) { printf("vo_vesa: %s returns: %s\n",name,vbeErrToStr(err)); fflush(stdout); } | |
147 | |
148 static void vesa_term( void ) | |
149 { | |
150 int err; | |
2869 | 151 if(lvo_name) vlvo_term(); |
4089 | 152 #ifdef CONFIG_VIDIX |
4030 | 153 else if(vidix_name) vidix_term(); |
4089 | 154 #endif |
2244 | 155 if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err); |
156 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
|
157 if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
158 if(dga_buffer && !HAS_DGA()) free(dga_buffer); |
2244 | 159 vbeDestroy(); |
4537 | 160 if(sws) freeSwsContext(sws); |
2244 | 161 } |
162 | |
163 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high) | |
164 #define VIDEO_PTR(offset) (win.ptr + offset - win.low) | |
165 | |
166 static inline void __vbeSwitchBank(unsigned long offset) | |
167 { | |
168 unsigned long gran; | |
169 unsigned new_offset; | |
170 int err; | |
171 gran = video_mode_info.WinGranularity*1024; | |
172 new_offset = offset / gran; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
173 if(HAS_DGA()) { err = -1; goto show_err; } |
2244 | 174 if((err=vbeSetWindow(win.idx,new_offset)) != VBE_OK) |
175 { | |
2610 | 176 show_err: |
2686 | 177 vesa_term(); |
2244 | 178 PRINT_VBE_ERR("vbeSetWindow",err); |
179 printf("vo_vesa: Fatal error occured! Can't continue\n"); | |
180 exit(-1); | |
181 } | |
182 win.low = new_offset * gran; | |
183 win.high = win.low + video_mode_info.WinSize*1024; | |
184 } | |
185 | |
186 static void __vbeSetPixel(int x, int y, int r, int g, int b) | |
187 { | |
188 int x_res = video_mode_info.XResolution; | |
189 int y_res = video_mode_info.YResolution; | |
190 int shift_r = video_mode_info.RedFieldPosition; | |
191 int shift_g = video_mode_info.GreenFieldPosition; | |
192 int shift_b = video_mode_info.BlueFieldPosition; | |
4537 | 193 int pixel_size = (dstBpp+7)/8; |
2244 | 194 int bpl = video_mode_info.BytesPerScanLine; |
2676 | 195 int color; |
196 unsigned offset; | |
2244 | 197 |
198 if (x < 0 || x >= x_res || y < 0 || y >= y_res) return; | |
199 r >>= 8 - video_mode_info.RedMaskSize; | |
200 g >>= 8 - video_mode_info.GreenMaskSize; | |
201 b >>= 8 - video_mode_info.BlueMaskSize; | |
202 color = (r << shift_r) | (g << shift_g) | (b << shift_b); | |
203 offset = y * bpl + (x * pixel_size); | |
204 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); | |
205 memcpy(VIDEO_PTR(offset), &color, pixel_size); | |
206 } | |
207 | |
208 /* | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
209 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
|
210 as video memory. |
2244 | 211 */ |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
212 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
|
213 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
214 memcpy(&win.ptr[offset],image,size); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
215 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
216 |
2244 | 217 static void __vbeCopyBlock(unsigned long offset,uint8_t *image,unsigned long size) |
218 { | |
219 unsigned long delta,src_idx = 0; | |
220 while(size) | |
221 { | |
4537 | 222 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); |
223 delta = min(size,win.high - offset); | |
224 memcpy(VIDEO_PTR(offset),&image[src_idx],delta); | |
225 src_idx += delta; | |
226 offset += delta; | |
227 size -= delta; | |
2244 | 228 } |
229 } | |
230 | |
231 /* | |
232 Copies frame to video memory. Data should be in the same format as video | |
233 memory. | |
234 */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
235 |
4537 | 236 #define PIXEL_SIZE() ((dstBpp+7)/8) |
2676 | 237 #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) ) |
4537 | 238 #define IMAGE_LINE_SIZE(pixel_size) (dstW*(pixel_size)) |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
239 |
2244 | 240 static void __vbeCopyData(uint8_t *image) |
241 { | |
2308 | 242 unsigned long i,j,image_offset,offset; |
2244 | 243 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
|
244 pixel_size = PIXEL_SIZE(); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
245 screen_line_size = SCREEN_LINE_SIZE(pixel_size); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
246 image_line_size = IMAGE_LINE_SIZE(pixel_size); |
4537 | 247 if(dstW == video_mode_info.XResolution) |
2306 | 248 { |
249 /* Special case for zooming */ | |
4537 | 250 (*cpy_blk_fnc)(y_offset*screen_line_size,image,image_line_size*dstH); |
2306 | 251 } |
252 else | |
2244 | 253 { |
2306 | 254 x_shift = x_offset*pixel_size; |
4537 | 255 for(j=0,i=y_offset;j<dstH;i++,j++) |
2306 | 256 { |
257 offset = i*screen_line_size+x_shift; | |
258 image_offset = j*image_line_size; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
259 (*cpy_blk_fnc)(offset,&image[image_offset],image_line_size); |
2306 | 260 } |
2244 | 261 } |
262 } | |
2328 | 263 |
2244 | 264 /* is called for yuv only */ |
265 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
266 { | |
4537 | 267 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
268 uint8_t *dst[3]= {dga_buffer, NULL, NULL}; | |
269 int dstStride[3]; | |
2504 | 270 if(verbose > 2) |
271 printf("vo_vesa: draw_slice was called: w=%u h=%u x=%u y=%u\n",w,h,x,y); | |
4537 | 272 dstStride[0]=dstride*((dstBpp+7)/8); |
273 dstStride[1]= | |
274 dstStride[2]=dstStride[0]>>1; | |
275 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); | |
4554 | 276 sws->swScale(sws,image,stride,y,h,dst,dstStride); |
2331 | 277 flip_trigger = 1; |
2298 | 278 return 0; |
2244 | 279 } |
280 | |
4572 | 281 /* Please comment it out if you want have OSD within movie */ |
6825
2cbf7d447bb2
Disable OSD outside movie, because it's not redrawn currently, user can use -vop expand to get osd outisde movie.
atmos4
parents:
6203
diff
changeset
|
282 /*#define OSD_OUTSIDE_MOVIE 1*/ |
4572 | 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 { | |
4537 | 286 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
4572 | 287 #ifndef OSD_OUTSIDE_MOVIE |
288 if(HAS_DGA()) | |
289 { | |
290 x0 += x_offset; | |
291 y0 += y_offset; | |
292 } | |
293 #endif | |
2649 | 294 vo_draw_alpha_rgb32(w,h,src,srca,stride,dga_buffer+4*(y0*dstride+x0),4*dstride); |
2337 | 295 } |
296 | |
2649 | 297 static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
298 { | |
4537 | 299 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
4572 | 300 #ifndef OSD_OUTSIDE_MOVIE |
301 if(HAS_DGA()) | |
302 { | |
303 x0 += x_offset; | |
304 y0 += y_offset; | |
305 } | |
306 #endif | |
2649 | 307 vo_draw_alpha_rgb24(w,h,src,srca,stride,dga_buffer+3*(y0*dstride+x0),3*dstride); |
2337 | 308 } |
309 | |
2649 | 310 static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
311 { | |
4537 | 312 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
4572 | 313 #ifndef OSD_OUTSIDE_MOVIE |
314 if(HAS_DGA()) | |
315 { | |
316 x0 += x_offset; | |
317 y0 += y_offset; | |
318 } | |
319 #endif | |
2649 | 320 vo_draw_alpha_rgb16(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); |
2337 | 321 } |
322 | |
2649 | 323 static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
324 { | |
4537 | 325 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
4572 | 326 #ifndef OSD_OUTSIDE_MOVIE |
327 if(HAS_DGA()) | |
328 { | |
329 x0 += x_offset; | |
330 y0 += y_offset; | |
331 } | |
332 #endif | |
2649 | 333 vo_draw_alpha_rgb15(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); |
2337 | 334 } |
335 | |
2649 | 336 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
337 { | |
2688 | 338 UNUSED(x0); |
339 UNUSED(y0); | |
340 UNUSED(w); | |
341 UNUSED(h); | |
342 UNUSED(src); | |
343 UNUSED(srca); | |
344 UNUSED(stride); | |
2337 | 345 } |
346 | |
347 | |
2244 | 348 static void draw_osd(void) |
349 { | |
2649 | 350 uint32_t w,h; |
2504 | 351 if(verbose > 2) |
352 printf("vo_vesa: draw_osd was called\n"); | |
2869 | 353 { |
4572 | 354 #ifdef OSD_OUTSIDE_MOVIE |
4537 | 355 w = HAS_DGA()?video_mode_info.XResolution:dstW; |
356 h = HAS_DGA()?video_mode_info.YResolution:dstH; | |
4572 | 357 #else |
358 w = dstW; | |
359 h = dstH; | |
360 #endif | |
2869 | 361 if(dga_buffer) vo_draw_text(w,h,draw_alpha_fnc); |
362 } | |
2244 | 363 } |
364 | |
365 static void flip_page(void) | |
366 { | |
2504 | 367 if(verbose > 2) |
368 printf("vo_vesa: flip_page was called\n"); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
369 if(flip_trigger) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
370 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
371 if(!HAS_DGA()) __vbeCopyData(dga_buffer); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
372 flip_trigger = 0; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
373 } |
4493 | 374 if(vo_doublebuffering && multi_size > 1) |
2649 | 375 { |
2686 | 376 int err; |
4667 | 377 if((err=vbeSetDisplayStart(multi_buff[multi_idx],vo_vsync)) != VBE_OK) |
2686 | 378 { |
379 vesa_term(); | |
2692 | 380 PRINT_VBE_ERR("vbeSetDisplayStart",err); |
2686 | 381 printf("vo_vesa: Fatal error occured! Can't continue\n"); |
382 exit(EXIT_FAILURE); | |
383 } | |
384 multi_idx = multi_idx ? 0 : 1; | |
385 win.ptr = dga_buffer = video_base + multi_buff[multi_idx]; | |
2649 | 386 } |
387 /* | |
388 else | |
389 if(tripple_buffering) | |
390 { | |
4667 | 391 vbeSetScheduledDisplayStart(multi_buff[multi_idx],vo_vsync); |
2649 | 392 multi_idx++; |
393 if(multi_idx > 2) multi_idx = 0; | |
4667 | 394 win.ptr = dga_buffer = video_base + multi_buff[multi_idx]; |
2649 | 395 } |
396 */ | |
2244 | 397 } |
398 | |
399 /* is called for rgb only */ | |
400 static uint32_t draw_frame(uint8_t *src[]) | |
401 { | |
2504 | 402 if(verbose > 2) |
403 printf("vo_vesa: draw_frame was called\n"); | |
4537 | 404 if(sws) |
2504 | 405 { |
4537 | 406 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:dstW; |
407 int srcStride[1]; | |
408 uint8_t *dst[3]= {dga_buffer, NULL, NULL}; | |
409 int dstStride[3]; | |
410 dstStride[0]=dstride*((dstBpp+7)/8); | |
411 dstStride[1]= | |
412 dstStride[2]=dstStride[0]>>1; | |
413 if(srcFourcc == IMGFMT_RGB32 || srcFourcc == IMGFMT_BGR32) | |
414 srcStride[0] = srcW*4; | |
415 else | |
416 if(srcFourcc == IMGFMT_RGB24 || srcFourcc == IMGFMT_BGR24) | |
417 srcStride[0] = srcW*3; | |
418 else | |
419 srcStride[0] = srcW*2; | |
420 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); | |
4554 | 421 sws->swScale(sws,src,srcStride,0,srcH,dst,dstStride); |
4537 | 422 flip_trigger=1; |
423 } | |
2504 | 424 return 0; |
2244 | 425 } |
426 | |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
427 #define SUBDEV_NODGA 0x00000001UL |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
428 #define SUBDEV_FORCEDGA 0x00000002UL |
4362 | 429 static uint32_t subdev_flags = 0xFFFFFFFEUL; |
2953
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
430 static uint32_t parseSubDevice(const char *sd) |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
431 { |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
432 uint32_t flags; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
433 flags = 0; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
434 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
|
435 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
436 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
|
437 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
438 if(memcmp(sd,"lvo:",4) == 0) lvo_name = &sd[4]; /* lvo_name will be valid within init() */ |
4089 | 439 #ifdef CONFIG_VIDIX |
4030 | 440 else |
441 if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */ | |
4089 | 442 #endif |
4537 | 443 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
|
444 return flags; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
445 } |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
446 |
2244 | 447 static uint32_t query_format(uint32_t format) |
448 { | |
2504 | 449 if(verbose > 2) |
450 printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
7690 | 451 return 1 | VFCAP_OSD | VFCAP_SWSCALE | VFCAP_ACCEPT_STRIDE; /* due new SwScale code */ |
2244 | 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; | |
4537 | 515 screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((dstBpp+7)/8); |
2649 | 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 | |
7360 | 529 |
7069 | 530 static int set_refresh(unsigned x, unsigned y, unsigned mode,struct VesaCRTCInfoBlock *crtc_pass) |
531 { | |
532 unsigned pixclk; | |
533 float H_freq; | |
534 | |
535 range_t *monitor_hfreq = NULL; | |
536 range_t *monitor_vfreq = NULL; | |
537 range_t *monitor_dotclock = NULL; | |
2649 | 538 |
7069 | 539 monitor_hfreq = str2range(monitor_hfreq_str); |
540 monitor_vfreq = str2range(monitor_vfreq_str); | |
541 monitor_dotclock = str2range(monitor_dotclock_str); | |
542 | |
543 if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) { | |
544 printf("vo_vesa: you have to specify the capabilities of" | |
545 " the monitor. Not changing refresh rate.\n"); | |
546 return 0; | |
547 } | |
548 | |
549 H_freq = range_max(monitor_hfreq)/1000; | |
550 | |
551 // printf("H_freq MAX %f\n",H_freq); | |
552 | |
553 do | |
554 { | |
7360 | 555 H_freq -= 0.01; |
7069 | 556 GTF_calcTimings(x,y,H_freq,GTF_HF,0, 0,crtc_pass); |
557 // printf("PixelCLK %d\n",(unsigned)crtc_pass->PixelClock); | |
558 } | |
7360 | 559 while ( (!in_range(monitor_vfreq,crtc_pass->RefreshRate/100)|| |
560 !in_range(monitor_hfreq,H_freq*1000))&&(H_freq>0)); | |
7069 | 561 |
562 pixclk = crtc_pass->PixelClock; | |
563 // printf("PIXclk before %d\n",pixclk); | |
564 vbeGetPixelClock(&mode,&pixclk); | |
565 // printf("PIXclk after %d\n",pixclk); | |
566 GTF_calcTimings(x,y,pixclk/1000000,GTF_PF,0,0,crtc_pass); | |
567 // printf("Flags: %x\n",(unsigned) crtc_pass->Flags); | |
568 /* | |
569 printf("hTotal %d\n",crtc_pass->hTotal); | |
570 printf("hSyncStart %d\n",crtc_pass->hSyncStart); | |
571 printf("hSyncEnd %d\n",crtc_pass->hSyncEnd); | |
572 | |
573 printf("vTotal %d\n",crtc_pass->vTotal); | |
574 printf("vSyncStart %d\n",crtc_pass->vSyncStart); | |
575 printf("vSyncEnd %d\n",crtc_pass->vSyncEnd); | |
576 | |
577 printf("RR %d\n",crtc_pass->RefreshRate); | |
578 printf("PixelCLK %d\n",(unsigned)crtc_pass->PixelClock);*/ | |
7360 | 579 |
580 if (!in_range(monitor_vfreq,crtc_pass->RefreshRate/100)|| | |
581 !in_range(monitor_hfreq,H_freq*1000)) { | |
582 printf( "vo_vesa: Unable to fit the mode into monitor's limitation." | |
583 " Not changing refresh rate.\n"); | |
584 return 0; | |
585 } | |
586 | |
7069 | 587 return 1; |
588 } | |
7360 | 589 |
2244 | 590 /* fullscreen: |
591 * bit 0 (0x01) means fullscreen (-fs) | |
592 * bit 1 (0x02) means mode switching (-vm) | |
593 * bit 2 (0x04) enables software scaling (-zoom) | |
2335 | 594 * bit 3 (0x08) enables flipping (-flip) (NK: and for what?) |
2244 | 595 */ |
7069 | 596 |
2244 | 597 static uint32_t |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
7069
diff
changeset
|
598 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
2244 | 599 { |
7069 | 600 struct VbeInfoBlock vib; |
2244 | 601 struct VesaModeInfoBlock vmib; |
7069 | 602 struct VesaCRTCInfoBlock crtc_pass; |
2244 | 603 size_t i,num_modes; |
4362 | 604 uint32_t w,h; |
2244 | 605 unsigned short *mode_ptr,win_seg; |
606 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; | |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
607 int err,fs_mode,use_scaler=0; |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
608 srcW = dstW = width; |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
609 srcH = dstH = height; |
2336 | 610 fs_mode = 0; |
4362 | 611 if(subdev_flags == 0xFFFFFFFEUL) |
2971 | 612 { |
4362 | 613 printf("vo_vesa: detected internal fatal error: init is called before preinit\n"); |
2971 | 614 return -1; |
4362 | 615 } |
4537 | 616 if(subdev_flags == 0xFFFFFFFFUL) return -1; |
2329 | 617 if(flags & 0x8) |
2244 | 618 { |
2329 | 619 printf("vo_vesa: switch -flip is not supported\n"); |
2244 | 620 } |
4537 | 621 if(flags & 0x04) use_scaler = 1; |
2336 | 622 if(flags & 0x01) |
623 { | |
4537 | 624 if(use_scaler) use_scaler = 2; |
2336 | 625 else fs_mode = 1; |
626 } | |
2244 | 627 if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; } |
628 memcpy(vib.VESASignature,"VBE2",4); | |
629 if((err=vbeGetControllerInfo(&vib)) != VBE_OK) | |
630 { | |
631 PRINT_VBE_ERR("vbeGetControllerInfo",err); | |
632 printf("vo_vesa: possible reason: No VBE2 BIOS found\n"); | |
633 return -1; | |
634 } | |
635 /* Print general info here */ | |
636 printf("vo_vesa: Found VESA VBE BIOS Version %x.%x Revision: %x\n", | |
637 (int)(vib.VESAVersion >> 8) & 0xff, | |
638 (int)(vib.VESAVersion & 0xff), | |
639 (int)(vib.OemSoftwareRev & 0xffff)); | |
2255 | 640 printf("vo_vesa: Video memory: %u Kb\n",vib.TotalMemory*64); |
641 printf("vo_vesa: VESA Capabilities: %s %s %s %s %s\n" | |
642 ,vib.Capabilities & VBE_DAC_8BIT ? "8-bit DAC," : "6-bit DAC," | |
643 ,vib.Capabilities & VBE_NONVGA_CRTC ? "non-VGA CRTC,":"VGA CRTC," | |
644 ,vib.Capabilities & VBE_SNOWED_RAMDAC ? "snowed RAMDAC,":"normal RAMDAC," | |
645 ,vib.Capabilities & VBE_STEREOSCOPIC ? "stereoscopic,":"no stereoscopic," | |
646 ,vib.Capabilities & VBE_STEREO_EVC ? "Stereo EVC":"no stereo"); | |
647 printf("vo_vesa: !!! Below will be printed OEM info. !!!\n"); | |
648 printf("vo_vesa: You should watch 5 OEM related lines below else you've broken vm86\n"); | |
2244 | 649 printf("vo_vesa: OEM info: %s\n",vib.OemStringPtr); |
2255 | 650 printf("vo_vesa: OEM Revision: %x\n",vib.OemSoftwareRev); |
651 printf("vo_vesa: OEM vendor: %s\n",vib.OemVendorNamePtr); | |
652 printf("vo_vesa: OEM Product Name: %s\n",vib.OemProductNamePtr); | |
653 printf("vo_vesa: OEM Product Rev: %s\n",vib.OemProductRevPtr); | |
654 printf("vo_vesa: Hint: To get workable TV-Out you should have plugged tv-connector in\n" | |
655 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n"); | |
2244 | 656 /* Find best mode here */ |
657 num_modes = 0; | |
658 mode_ptr = vib.VideoModePtr; | |
659 while(*mode_ptr++ != 0xffff) num_modes++; | |
660 switch(format) | |
661 { | |
662 case IMGFMT_BGR8: | |
663 case IMGFMT_RGB8: bpp = 8; break; | |
664 case IMGFMT_BGR15: | |
665 case IMGFMT_RGB15: bpp = 15; break; | |
666 case IMGFMT_BGR16: | |
667 case IMGFMT_RGB16: bpp = 16; break; | |
668 case IMGFMT_BGR24: | |
669 case IMGFMT_RGB24: bpp = 24; break; | |
670 case IMGFMT_BGR32: | |
671 case IMGFMT_RGB32: bpp = 32; break; | |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
672 default: bpp = 16; break; |
2244 | 673 } |
4537 | 674 srcBpp = bpp; |
675 srcFourcc = format; | |
2504 | 676 if(vo_dbpp) bpp = vo_dbpp; |
2337 | 677 switch(bpp) |
678 { | |
4537 | 679 case 15: draw_alpha_fnc = draw_alpha_15; |
680 dstFourcc = IMGFMT_BGR15; | |
681 break; | |
682 case 16: draw_alpha_fnc = draw_alpha_16; | |
683 dstFourcc = IMGFMT_BGR16; | |
684 break; | |
685 case 24: draw_alpha_fnc = draw_alpha_24; | |
686 dstFourcc = IMGFMT_BGR24; | |
687 break; | |
688 case 32: draw_alpha_fnc = draw_alpha_32; | |
689 dstFourcc = IMGFMT_BGR32; | |
690 break; | |
691 default: draw_alpha_fnc = draw_alpha_null; | |
692 dstFourcc = IMGFMT_BGR16; | |
693 break; | |
2337 | 694 } |
2244 | 695 if(verbose) |
696 { | |
2304 | 697 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); |
2244 | 698 printf("vo_vesa: Total modes found: %u\n",num_modes); |
699 mode_ptr = vib.VideoModePtr; | |
700 printf("vo_vesa: Mode list:"); | |
701 for(i = 0;i < num_modes;i++) | |
702 { | |
703 printf(" %04X",mode_ptr[i]); | |
704 } | |
705 printf("\nvo_vesa: Modes in detail:\n"); | |
706 } | |
707 mode_ptr = vib.VideoModePtr; | |
4537 | 708 if(use_scaler) |
2335 | 709 { |
4537 | 710 dstW = d_width; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
711 dstH = d_height; |
2335 | 712 } |
713 if(vo_screenwidth) w = vo_screenwidth; | |
4537 | 714 else w = max(dstW,width); |
2335 | 715 if(vo_screenheight) h = vo_screenheight; |
4537 | 716 else h = max(dstH,height); |
2244 | 717 for(i=0;i < num_modes;i++) |
718 { | |
719 if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK) | |
720 { | |
721 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
722 return -1; | |
723 } | |
2329 | 724 if(vmib.XResolution >= w && |
725 vmib.YResolution >= h && | |
2244 | 726 (vmib.ModeAttributes & MOVIE_MODE) == MOVIE_MODE && |
727 vmib.BitsPerPixel == bpp && | |
728 vmib.MemoryModel == memRGB) | |
729 { | |
2293 | 730 if(vmib.XResolution <= best_x && |
731 vmib.YResolution <= best_y) | |
2244 | 732 { |
733 best_x = vmib.XResolution; | |
734 best_y = vmib.YResolution; | |
735 best_mode_idx = i; | |
736 } | |
737 } | |
738 if(verbose) | |
739 { | |
2298 | 740 printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%04X\n" |
2293 | 741 "vo_vesa: #planes=%u model=%u(%s) #pages=%u\n" |
742 "vo_vesa: winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n" | |
2446 | 743 "vo_vesa: direct_color=%u DGA_phys_addr=%08lX\n" |
2244 | 744 ,i,mode_ptr[i],vmib.XResolution,vmib.YResolution,vmib.BitsPerPixel,vmib.ModeAttributes |
2293 | 745 ,vmib.NumberOfPlanes,vmib.MemoryModel,model2str(vmib.MemoryModel),vmib.NumberOfImagePages |
2244 | 746 ,vmib.WinASegment,vmib.WinAAttributes,vmib.WinBSegment,vmib.WinBAttributes,vmib.WinSize,vmib.WinGranularity |
747 ,vmib.DirectColorModeInfo,vmib.PhysBasePtr); | |
748 if(vmib.MemoryModel == 6 || vmib.MemoryModel == 7) | |
749 printf("vo_vesa: direct_color_info = %u:%u:%u:%u\n" | |
750 ,vmib.RedMaskSize,vmib.GreenMaskSize,vmib.BlueMaskSize,vmib.RsvdMaskSize); | |
751 fflush(stdout); | |
752 } | |
753 } | |
754 if(best_mode_idx != UINT_MAX) | |
755 { | |
756 video_mode = vib.VideoModePtr[best_mode_idx]; | |
757 fflush(stdout); | |
758 if((err=vbeGetMode(&init_mode)) != VBE_OK) | |
759 { | |
760 PRINT_VBE_ERR("vbeGetMode",err); | |
761 return -1; | |
762 } | |
763 if(verbose) printf("vo_vesa: Initial video mode: %x\n",init_mode); | |
764 if((err=vbeGetModeInfo(video_mode,&video_mode_info)) != VBE_OK) | |
765 { | |
766 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
767 return -1; | |
768 } | |
7025
3bc8ff93d64e
10l bug - noticed by Emiel Neggers <emiel@neggers.net>
arpi
parents:
6825
diff
changeset
|
769 dstBpp = video_mode_info.BitsPerPixel; |
2329 | 770 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n" |
771 ,best_mode_idx,video_mode,video_mode_info.XResolution | |
4537 | 772 ,video_mode_info.YResolution,dstBpp); |
4362 | 773 if(subdev_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
774 if(use_scaler || fs_mode) |
2298 | 775 { |
2304 | 776 /* software scale */ |
4537 | 777 if(use_scaler > 1) |
2689 | 778 { |
779 aspect_save_orig(width,height); | |
780 aspect_save_prescale(d_width,d_height); | |
781 aspect_save_screenres(video_mode_info.XResolution,video_mode_info.YResolution); | |
4537 | 782 aspect(&dstW,&dstH,A_ZOOM); |
2689 | 783 } |
2336 | 784 else |
785 if(fs_mode) | |
786 { | |
4537 | 787 dstW = video_mode_info.XResolution; |
788 dstH = video_mode_info.YResolution; | |
2336 | 789 } |
4537 | 790 use_scaler = 1; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
791 } |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
792 if(!lvo_name |
4089 | 793 #ifdef CONFIG_VIDIX |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
794 && !vidix_name |
4089 | 795 #endif |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
796 ) |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
797 { |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
798 sws = getSwsContextFromCmdLine(srcW,srcH,srcFourcc,dstW,dstH,dstFourcc); |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
799 if(!sws) |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
800 { |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
801 printf("vo_vesa: Can't initialize SwScaler\n"); |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
802 return -1; |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
803 } |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
804 else if(verbose) printf("vo_vesa: Using SW BES emulator\n"); |
2298 | 805 } |
2244 | 806 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE) |
807 win.idx = 0; /* frame A */ | |
808 else | |
809 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE) | |
810 win.idx = 1; /* frame B */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
811 else win.idx = -2; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
812 /* Try use DGA instead */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
813 if(video_mode_info.PhysBasePtr && vib.TotalMemory && (video_mode_info.ModeAttributes & MODE_ATTR_LINEAR)) |
2244 | 814 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
815 void *lfb; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
816 unsigned long vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
817 vsize = vib.TotalMemory*64*1024; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
818 lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vsize); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
819 if(lfb == NULL) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
820 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
|
821 else |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
822 { |
2649 | 823 video_base = win.ptr = lfb; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
824 win.low = 0UL; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
825 win.high = vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
826 win.idx = -1; /* HAS_DGA() is on */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
827 video_mode |= VESA_MODE_USE_LINEAR; |
2649 | 828 printf("vo_vesa: Using DGA (physical resources: %08lXh, %08lXh)" |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
829 ,video_mode_info.PhysBasePtr |
2649 | 830 ,vsize); |
831 if(verbose) printf(" at %08lXh",(unsigned long)lfb); | |
832 printf("\n"); | |
833 if(!(multi_size = fillMultiBuffer(vsize,2))) return -1; | |
834 if(vo_doublebuffering && multi_size < 2) | |
835 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
|
836 } |
2244 | 837 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
838 if(win.idx == -2) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
839 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
840 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
|
841 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
842 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
843 if(!HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
844 { |
4362 | 845 if(subdev_flags & SUBDEV_FORCEDGA) |
2649 | 846 { |
847 printf("vo_vesa: you've forced DGA. Exiting\n"); | |
848 return -1; | |
849 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
850 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
|
851 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
852 printf("vo_vesa: Can't find valid window address\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
853 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
854 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
855 win.ptr = PhysToVirtSO(win_seg,0); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
856 win.low = 0L; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
857 win.high= video_mode_info.WinSize*1024; |
2649 | 858 printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n" |
859 ,(unsigned long)win.ptr,(unsigned long)win.high); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
860 } |
4537 | 861 if(video_mode_info.XResolution > dstW) |
862 x_offset = (video_mode_info.XResolution - dstW) / 2; | |
2329 | 863 else x_offset = 0; |
4537 | 864 if(video_mode_info.YResolution > dstH) |
865 y_offset = (video_mode_info.YResolution - dstH) / 2; | |
2329 | 866 else y_offset = 0; |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
867 if(verbose) |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
868 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n" |
4537 | 869 ,dstW,dstH |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
870 ,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
|
871 ,x_offset,y_offset); |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
872 if(HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
873 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
874 dga_buffer = win.ptr; /* Trickly ;) */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
875 cpy_blk_fnc = __vbeCopyBlockFast; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
876 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
877 else |
2610 | 878 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
879 cpy_blk_fnc = __vbeCopyBlock; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
880 if(!lvo_name |
4089 | 881 #ifdef CONFIG_VIDIX |
882 && !vidix_name | |
883 #endif | |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
884 ) |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
885 { |
4537 | 886 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*dstBpp))) |
2610 | 887 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
888 printf("vo_vesa: Can't allocate temporary buffer\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
889 return -1; |
2610 | 890 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
891 if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer); |
2337 | 892 } |
2504 | 893 } |
2244 | 894 if((err=vbeSaveState(&init_state)) != VBE_OK) |
895 { | |
896 PRINT_VBE_ERR("vbeSaveState",err); | |
897 return -1; | |
898 } | |
7360 | 899 |
900 /* TODO: | |
901 user might pass refresh value, | |
7069 | 902 GTF constants might be read from monitor |
7360 | 903 for best results, I don't have a spec (RM) |
7069 | 904 */ |
7360 | 905 |
7069 | 906 if (((int)(vib.VESAVersion >> 8) & 0xff) > 2) { |
907 | |
7650
7e8193475ddf
a small fix for vo_vesa, when calling set_refresh, when -nofs used.
arpi
parents:
7360
diff
changeset
|
908 if (set_refresh(video_mode_info.XResolution,video_mode_info.YResolution,video_mode,&crtc_pass)) |
7069 | 909 video_mode = video_mode | 0x800; |
910 | |
911 } | |
912 | |
913 ; | |
914 | |
915 if ((err=vbeSetMode(video_mode,&crtc_pass)) != VBE_OK) | |
2244 | 916 { |
917 PRINT_VBE_ERR("vbeSetMode",err); | |
918 return -1; | |
919 } | |
7069 | 920 |
2244 | 921 /* Now we are in video mode!!!*/ |
2337 | 922 /* Below 'return -1' is impossible */ |
2244 | 923 if(verbose) |
924 { | |
925 printf("vo_vesa: Graphics mode was activated\n"); | |
926 fflush(stdout); | |
927 } | |
2869 | 928 if(lvo_name) |
929 { | |
4537 | 930 if(vlvo_init(width,height,x_offset,y_offset,dstW,dstH,format,dstBpp) != 0) |
2869 | 931 { |
932 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
|
933 lvo_name = NULL; |
2869 | 934 vesa_term(); |
935 return -1; | |
936 } | |
937 else printf("vo_vesa: Using video overlay: %s\n",lvo_name); | |
938 } | |
4089 | 939 #ifdef CONFIG_VIDIX |
4030 | 940 else |
941 if(vidix_name) | |
942 { | |
4537 | 943 if(vidix_init(width,height,x_offset,y_offset,dstW, |
944 dstH,format,dstBpp, | |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
7069
diff
changeset
|
945 video_mode_info.XResolution,video_mode_info.YResolution) != 0) |
4030 | 946 { |
947 printf("vo_vesa: Can't initialize VIDIX driver\n"); | |
948 vidix_name = NULL; | |
4548 | 949 vesa_term(); |
4030 | 950 return -1; |
951 } | |
4083 | 952 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
|
953 vidix_start(); |
4030 | 954 } |
4089 | 955 #endif |
2244 | 956 } |
957 else | |
958 { | |
2255 | 959 printf("vo_vesa: Can't find mode for: %ux%u@%u\n",width,height,bpp); |
2244 | 960 return -1; |
961 } | |
962 if(verbose) | |
963 { | |
964 printf("vo_vesa: VESA initialization complete\n"); | |
965 fflush(stdout); | |
966 } | |
2914 | 967 /* Clear screen for stupid BIOSes */ |
968 clear_screen(); | |
2688 | 969 if(HAS_DGA() && vo_doublebuffering) |
2244 | 970 { |
2686 | 971 for(i=0;i<MAX_BUFFERS;i++) |
972 { | |
973 win.ptr = dga_buffer = video_base + multi_buff[i]; | |
4002 | 974 if(verbose>1) paintBkGnd(); |
2686 | 975 } |
2244 | 976 } |
2686 | 977 else |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
978 { |
4002 | 979 if(verbose>1) paintBkGnd(); |
2686 | 980 { |
981 int x; | |
982 x = (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2; | |
983 if(x < 0) x = 0; | |
984 vbeWriteString(x,0,7,title); | |
985 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
986 } |
2244 | 987 return 0; |
988 } | |
989 | |
990 static const vo_info_t* | |
991 get_info(void) | |
992 { | |
2504 | 993 if(verbose > 2) |
994 printf("vo_vesa: get_info was called\n"); | |
2244 | 995 return &vo_info; |
996 } | |
997 | |
998 static void | |
999 uninit(void) | |
1000 { | |
2686 | 1001 vesa_term(); |
2504 | 1002 if(verbose > 2) |
1003 printf("vo_vesa: uninit was called\n"); | |
2244 | 1004 } |
1005 | |
1006 | |
1007 static void check_events(void) | |
1008 { | |
2504 | 1009 if(verbose > 2) |
1010 printf("vo_vesa: check_events was called\n"); | |
2244 | 1011 /* Nothing to do */ |
1012 } | |
4352 | 1013 |
1014 static uint32_t preinit(const char *arg) | |
1015 { | |
4362 | 1016 int pre_init_err = 0; |
1017 if(verbose>1) printf("vo_vesa: preinit(%s) was called\n",arg); | |
1018 if(verbose > 2) | |
1019 printf("vo_vesa: subdevice %s is being initialized\n",arg); | |
1020 subdev_flags = 0; | |
1021 if(arg) subdev_flags = parseSubDevice(arg); | |
1022 if(lvo_name) pre_init_err = vlvo_preinit(lvo_name); | |
1023 #ifdef CONFIG_VIDIX | |
1024 else if(vidix_name) pre_init_err = vidix_preinit(vidix_name,&video_out_vesa); | |
1025 #endif | |
1026 if(verbose > 2) | |
1027 printf("vo_subdevice: initialization returns: %i\n",pre_init_err); | |
1028 return pre_init_err; | |
4352 | 1029 } |
1030 | |
4596 | 1031 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 1032 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1033 switch (request) { |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1034 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1035 return query_format(*((uint32_t*)data)); |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1036 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4572
diff
changeset
|
1037 return VO_NOTIMPL; |
4352 | 1038 } |