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