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