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