Mercurial > mplayer.hg
annotate libvo/vo_vesa.c @ 10082:1c95e3d5888a
fixed alignment bug
author | michael |
---|---|
date | Wed, 07 May 2003 23:25:25 +0000 |
parents | fe733da8e8b9 |
children | 35f52ad860a0 |
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; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
441 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
|
442 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
443 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
|
444 else |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
445 if(memcmp(sd,"lvo:",4) == 0) lvo_name = &sd[4]; /* lvo_name will be valid within init() */ |
4089 | 446 #ifdef CONFIG_VIDIX |
4030 | 447 else |
448 if(memcmp(sd,"vidix",5) == 0) vidix_name = &sd[5]; /* vidix_name will be valid within init() */ | |
4089 | 449 #endif |
4537 | 450 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
|
451 return flags; |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
452 } |
b0cf2b649d3c
Fixed incorretc terminating of lvo stuff and improving of query_format
nick
parents:
2918
diff
changeset
|
453 |
2244 | 454 static uint32_t query_format(uint32_t format) |
455 { | |
2504 | 456 if(verbose > 2) |
457 printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
7690 | 458 return 1 | VFCAP_OSD | VFCAP_SWSCALE | VFCAP_ACCEPT_STRIDE; /* due new SwScale code */ |
2244 | 459 } |
460 | |
2686 | 461 static void paintBkGnd( void ) |
462 { | |
463 int x_res = video_mode_info.XResolution; | |
464 int y_res = video_mode_info.YResolution; | |
465 int x, y; | |
466 | |
467 for (y = 0; y < y_res; ++y) | |
468 { | |
469 for (x = 0; x < x_res; ++x) | |
470 { | |
471 int r, g, b; | |
472 if ((x & 16) ^ (y & 16)) | |
473 { | |
474 r = x * 255 / x_res; | |
475 g = y * 255 / y_res; | |
476 b = 255 - x * 255 / x_res; | |
477 } | |
478 else | |
479 { | |
480 r = 255 - x * 255 / x_res; | |
481 g = y * 255 / y_res; | |
482 b = 255 - y * 255 / y_res; | |
483 } | |
484 __vbeSetPixel(x, y, r, g, b); | |
485 } | |
486 } | |
487 } | |
488 | |
2914 | 489 static void clear_screen( void ) |
490 { | |
491 int x_res = video_mode_info.XResolution; | |
492 int y_res = video_mode_info.YResolution; | |
493 int x, y; | |
494 | |
495 for (y = 0; y < y_res; ++y) | |
496 for (x = 0; x < x_res; ++x) | |
497 __vbeSetPixel(x, y, 0, 0, 0); | |
498 } | |
499 | |
2293 | 500 static char *model2str(unsigned char type) |
501 { | |
502 char *retval; | |
503 switch(type) | |
504 { | |
505 case memText: retval = "Text"; break; | |
506 case memCGA: retval="CGA"; break; | |
507 case memHercules: retval="Hercules"; break; | |
508 case memPL: retval="Planar"; break; | |
509 case memPK: retval="Packed pixel"; break; | |
510 case mem256: retval="256"; break; | |
511 case memRGB: retval="Direct color RGB"; break; | |
512 case memYUV: retval="Direct color YUV"; break; | |
513 default: retval="Unknown"; break; | |
514 } | |
515 return retval; | |
516 } | |
517 | |
2649 | 518 unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs ) |
519 { | |
520 unsigned long screen_size, offset; | |
521 unsigned total,i; | |
4537 | 522 screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((dstBpp+7)/8); |
2649 | 523 if(screen_size%64) screen_size=((screen_size/64)*64)+64; |
524 total = vsize / screen_size; | |
2918 | 525 if(verbose) printf("vo_vesa: Can use up to %u video buffers\n",total); |
2649 | 526 i = 0; |
527 offset = 0; | |
528 total = min(total,nbuffs); | |
529 while(i < total) { multi_buff[i++] = offset; offset += screen_size; } | |
530 if(!i) | |
531 printf("vo_vesa: Your have too small size of video memory for this mode:\n" | |
532 "vo_vesa: Requires: %08lX exists: %08lX\n", screen_size, vsize); | |
533 return i; | |
534 } | |
535 | |
7360 | 536 |
7069 | 537 static int set_refresh(unsigned x, unsigned y, unsigned mode,struct VesaCRTCInfoBlock *crtc_pass) |
538 { | |
539 unsigned pixclk; | |
540 float H_freq; | |
541 | |
542 range_t *monitor_hfreq = NULL; | |
543 range_t *monitor_vfreq = NULL; | |
544 range_t *monitor_dotclock = NULL; | |
2649 | 545 |
7069 | 546 monitor_hfreq = str2range(monitor_hfreq_str); |
547 monitor_vfreq = str2range(monitor_vfreq_str); | |
548 monitor_dotclock = str2range(monitor_dotclock_str); | |
549 | |
550 if (!monitor_hfreq || !monitor_vfreq || !monitor_dotclock) { | |
551 printf("vo_vesa: you have to specify the capabilities of" | |
552 " the monitor. Not changing refresh rate.\n"); | |
553 return 0; | |
554 } | |
555 | |
556 H_freq = range_max(monitor_hfreq)/1000; | |
557 | |
558 // printf("H_freq MAX %f\n",H_freq); | |
559 | |
560 do | |
561 { | |
7360 | 562 H_freq -= 0.01; |
7069 | 563 GTF_calcTimings(x,y,H_freq,GTF_HF,0, 0,crtc_pass); |
564 // printf("PixelCLK %d\n",(unsigned)crtc_pass->PixelClock); | |
565 } | |
7360 | 566 while ( (!in_range(monitor_vfreq,crtc_pass->RefreshRate/100)|| |
567 !in_range(monitor_hfreq,H_freq*1000))&&(H_freq>0)); | |
7069 | 568 |
569 pixclk = crtc_pass->PixelClock; | |
570 // printf("PIXclk before %d\n",pixclk); | |
571 vbeGetPixelClock(&mode,&pixclk); | |
572 // printf("PIXclk after %d\n",pixclk); | |
573 GTF_calcTimings(x,y,pixclk/1000000,GTF_PF,0,0,crtc_pass); | |
574 // printf("Flags: %x\n",(unsigned) crtc_pass->Flags); | |
575 /* | |
576 printf("hTotal %d\n",crtc_pass->hTotal); | |
577 printf("hSyncStart %d\n",crtc_pass->hSyncStart); | |
578 printf("hSyncEnd %d\n",crtc_pass->hSyncEnd); | |
579 | |
580 printf("vTotal %d\n",crtc_pass->vTotal); | |
581 printf("vSyncStart %d\n",crtc_pass->vSyncStart); | |
582 printf("vSyncEnd %d\n",crtc_pass->vSyncEnd); | |
583 | |
584 printf("RR %d\n",crtc_pass->RefreshRate); | |
585 printf("PixelCLK %d\n",(unsigned)crtc_pass->PixelClock);*/ | |
7360 | 586 |
587 if (!in_range(monitor_vfreq,crtc_pass->RefreshRate/100)|| | |
588 !in_range(monitor_hfreq,H_freq*1000)) { | |
589 printf( "vo_vesa: Unable to fit the mode into monitor's limitation." | |
590 " Not changing refresh rate.\n"); | |
591 return 0; | |
592 } | |
593 | |
7069 | 594 return 1; |
595 } | |
7360 | 596 |
2244 | 597 /* fullscreen: |
598 * bit 0 (0x01) means fullscreen (-fs) | |
599 * bit 1 (0x02) means mode switching (-vm) | |
600 * bit 2 (0x04) enables software scaling (-zoom) | |
2335 | 601 * bit 3 (0x08) enables flipping (-flip) (NK: and for what?) |
2244 | 602 */ |
7069 | 603 |
2244 | 604 static uint32_t |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
7069
diff
changeset
|
605 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
2244 | 606 { |
7069 | 607 struct VbeInfoBlock vib; |
2244 | 608 struct VesaModeInfoBlock vmib; |
7069 | 609 struct VesaCRTCInfoBlock crtc_pass; |
2244 | 610 size_t i,num_modes; |
4362 | 611 uint32_t w,h; |
2244 | 612 unsigned short *mode_ptr,win_seg; |
613 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
|
614 int err,fs_mode,use_scaler=0; |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
615 srcW = dstW = width; |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
616 srcH = dstH = height; |
2336 | 617 fs_mode = 0; |
4362 | 618 if(subdev_flags == 0xFFFFFFFEUL) |
2971 | 619 { |
4362 | 620 printf("vo_vesa: detected internal fatal error: init is called before preinit\n"); |
2971 | 621 return -1; |
4362 | 622 } |
4537 | 623 if(subdev_flags == 0xFFFFFFFFUL) return -1; |
2329 | 624 if(flags & 0x8) |
2244 | 625 { |
2329 | 626 printf("vo_vesa: switch -flip is not supported\n"); |
2244 | 627 } |
4537 | 628 if(flags & 0x04) use_scaler = 1; |
2336 | 629 if(flags & 0x01) |
630 { | |
4537 | 631 if(use_scaler) use_scaler = 2; |
2336 | 632 else fs_mode = 1; |
633 } | |
2244 | 634 if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; } |
635 memcpy(vib.VESASignature,"VBE2",4); | |
636 if((err=vbeGetControllerInfo(&vib)) != VBE_OK) | |
637 { | |
638 PRINT_VBE_ERR("vbeGetControllerInfo",err); | |
639 printf("vo_vesa: possible reason: No VBE2 BIOS found\n"); | |
640 return -1; | |
641 } | |
642 /* Print general info here */ | |
643 printf("vo_vesa: Found VESA VBE BIOS Version %x.%x Revision: %x\n", | |
644 (int)(vib.VESAVersion >> 8) & 0xff, | |
645 (int)(vib.VESAVersion & 0xff), | |
646 (int)(vib.OemSoftwareRev & 0xffff)); | |
2255 | 647 printf("vo_vesa: Video memory: %u Kb\n",vib.TotalMemory*64); |
648 printf("vo_vesa: VESA Capabilities: %s %s %s %s %s\n" | |
649 ,vib.Capabilities & VBE_DAC_8BIT ? "8-bit DAC," : "6-bit DAC," | |
650 ,vib.Capabilities & VBE_NONVGA_CRTC ? "non-VGA CRTC,":"VGA CRTC," | |
651 ,vib.Capabilities & VBE_SNOWED_RAMDAC ? "snowed RAMDAC,":"normal RAMDAC," | |
652 ,vib.Capabilities & VBE_STEREOSCOPIC ? "stereoscopic,":"no stereoscopic," | |
653 ,vib.Capabilities & VBE_STEREO_EVC ? "Stereo EVC":"no stereo"); | |
654 printf("vo_vesa: !!! Below will be printed OEM info. !!!\n"); | |
655 printf("vo_vesa: You should watch 5 OEM related lines below else you've broken vm86\n"); | |
2244 | 656 printf("vo_vesa: OEM info: %s\n",vib.OemStringPtr); |
2255 | 657 printf("vo_vesa: OEM Revision: %x\n",vib.OemSoftwareRev); |
658 printf("vo_vesa: OEM vendor: %s\n",vib.OemVendorNamePtr); | |
659 printf("vo_vesa: OEM Product Name: %s\n",vib.OemProductNamePtr); | |
660 printf("vo_vesa: OEM Product Rev: %s\n",vib.OemProductRevPtr); | |
661 printf("vo_vesa: Hint: To get workable TV-Out you should have plugged tv-connector in\n" | |
662 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n"); | |
2244 | 663 /* Find best mode here */ |
664 num_modes = 0; | |
665 mode_ptr = vib.VideoModePtr; | |
666 while(*mode_ptr++ != 0xffff) num_modes++; | |
667 switch(format) | |
668 { | |
669 case IMGFMT_BGR8: | |
670 case IMGFMT_RGB8: bpp = 8; break; | |
671 case IMGFMT_BGR15: | |
672 case IMGFMT_RGB15: bpp = 15; break; | |
673 case IMGFMT_BGR16: | |
674 case IMGFMT_RGB16: bpp = 16; break; | |
675 case IMGFMT_BGR24: | |
676 case IMGFMT_RGB24: bpp = 24; break; | |
677 case IMGFMT_BGR32: | |
678 case IMGFMT_RGB32: bpp = 32; break; | |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
679 default: bpp = 16; break; |
2244 | 680 } |
4537 | 681 srcBpp = bpp; |
682 srcFourcc = format; | |
2504 | 683 if(vo_dbpp) bpp = vo_dbpp; |
2337 | 684 switch(bpp) |
685 { | |
4537 | 686 case 15: draw_alpha_fnc = draw_alpha_15; |
687 dstFourcc = IMGFMT_BGR15; | |
688 break; | |
689 case 16: draw_alpha_fnc = draw_alpha_16; | |
690 dstFourcc = IMGFMT_BGR16; | |
691 break; | |
692 case 24: draw_alpha_fnc = draw_alpha_24; | |
693 dstFourcc = IMGFMT_BGR24; | |
694 break; | |
695 case 32: draw_alpha_fnc = draw_alpha_32; | |
696 dstFourcc = IMGFMT_BGR32; | |
697 break; | |
698 default: draw_alpha_fnc = draw_alpha_null; | |
699 dstFourcc = IMGFMT_BGR16; | |
700 break; | |
2337 | 701 } |
2244 | 702 if(verbose) |
703 { | |
2304 | 704 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); |
2244 | 705 printf("vo_vesa: Total modes found: %u\n",num_modes); |
706 mode_ptr = vib.VideoModePtr; | |
707 printf("vo_vesa: Mode list:"); | |
708 for(i = 0;i < num_modes;i++) | |
709 { | |
710 printf(" %04X",mode_ptr[i]); | |
711 } | |
712 printf("\nvo_vesa: Modes in detail:\n"); | |
713 } | |
714 mode_ptr = vib.VideoModePtr; | |
4537 | 715 if(use_scaler) |
2335 | 716 { |
4537 | 717 dstW = d_width; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
718 dstH = d_height; |
2335 | 719 } |
720 if(vo_screenwidth) w = vo_screenwidth; | |
4537 | 721 else w = max(dstW,width); |
2335 | 722 if(vo_screenheight) h = vo_screenheight; |
4537 | 723 else h = max(dstH,height); |
2244 | 724 for(i=0;i < num_modes;i++) |
725 { | |
726 if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK) | |
727 { | |
728 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
729 return -1; | |
730 } | |
2329 | 731 if(vmib.XResolution >= w && |
732 vmib.YResolution >= h && | |
2244 | 733 (vmib.ModeAttributes & MOVIE_MODE) == MOVIE_MODE && |
734 vmib.BitsPerPixel == bpp && | |
735 vmib.MemoryModel == memRGB) | |
736 { | |
2293 | 737 if(vmib.XResolution <= best_x && |
738 vmib.YResolution <= best_y) | |
2244 | 739 { |
740 best_x = vmib.XResolution; | |
741 best_y = vmib.YResolution; | |
742 best_mode_idx = i; | |
743 } | |
744 } | |
745 if(verbose) | |
746 { | |
2298 | 747 printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%04X\n" |
2293 | 748 "vo_vesa: #planes=%u model=%u(%s) #pages=%u\n" |
749 "vo_vesa: winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n" | |
2446 | 750 "vo_vesa: direct_color=%u DGA_phys_addr=%08lX\n" |
2244 | 751 ,i,mode_ptr[i],vmib.XResolution,vmib.YResolution,vmib.BitsPerPixel,vmib.ModeAttributes |
2293 | 752 ,vmib.NumberOfPlanes,vmib.MemoryModel,model2str(vmib.MemoryModel),vmib.NumberOfImagePages |
2244 | 753 ,vmib.WinASegment,vmib.WinAAttributes,vmib.WinBSegment,vmib.WinBAttributes,vmib.WinSize,vmib.WinGranularity |
754 ,vmib.DirectColorModeInfo,vmib.PhysBasePtr); | |
755 if(vmib.MemoryModel == 6 || vmib.MemoryModel == 7) | |
756 printf("vo_vesa: direct_color_info = %u:%u:%u:%u\n" | |
757 ,vmib.RedMaskSize,vmib.GreenMaskSize,vmib.BlueMaskSize,vmib.RsvdMaskSize); | |
758 fflush(stdout); | |
759 } | |
760 } | |
761 if(best_mode_idx != UINT_MAX) | |
762 { | |
763 video_mode = vib.VideoModePtr[best_mode_idx]; | |
764 fflush(stdout); | |
765 if((err=vbeGetMode(&init_mode)) != VBE_OK) | |
766 { | |
767 PRINT_VBE_ERR("vbeGetMode",err); | |
768 return -1; | |
769 } | |
770 if(verbose) printf("vo_vesa: Initial video mode: %x\n",init_mode); | |
771 if((err=vbeGetModeInfo(video_mode,&video_mode_info)) != VBE_OK) | |
772 { | |
773 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
774 return -1; | |
775 } | |
7025
3bc8ff93d64e
10l bug - noticed by Emiel Neggers <emiel@neggers.net>
arpi
parents:
6825
diff
changeset
|
776 dstBpp = video_mode_info.BitsPerPixel; |
2329 | 777 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n" |
778 ,best_mode_idx,video_mode,video_mode_info.XResolution | |
4537 | 779 ,video_mode_info.YResolution,dstBpp); |
4362 | 780 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
|
781 if(use_scaler || fs_mode) |
2298 | 782 { |
2304 | 783 /* software scale */ |
4537 | 784 if(use_scaler > 1) |
2689 | 785 { |
786 aspect_save_orig(width,height); | |
787 aspect_save_prescale(d_width,d_height); | |
788 aspect_save_screenres(video_mode_info.XResolution,video_mode_info.YResolution); | |
4537 | 789 aspect(&dstW,&dstH,A_ZOOM); |
2689 | 790 } |
2336 | 791 else |
792 if(fs_mode) | |
793 { | |
4537 | 794 dstW = video_mode_info.XResolution; |
795 dstH = video_mode_info.YResolution; | |
2336 | 796 } |
4537 | 797 use_scaler = 1; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
798 } |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
799 if(!lvo_name |
4089 | 800 #ifdef CONFIG_VIDIX |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
801 && !vidix_name |
4089 | 802 #endif |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
803 ) |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
804 { |
9494
543ab3909b78
sws_ prefix, more seperation between internal & external swscaler API
michael
parents:
9380
diff
changeset
|
805 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
|
806 if(!sws) |
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 printf("vo_vesa: Can't initialize SwScaler\n"); |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
809 return -1; |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
810 } |
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
811 else if(verbose) printf("vo_vesa: Using SW BES emulator\n"); |
2298 | 812 } |
2244 | 813 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE) |
814 win.idx = 0; /* frame A */ | |
815 else | |
816 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE) | |
817 win.idx = 1; /* frame B */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
818 else win.idx = -2; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
819 /* Try use DGA instead */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
820 if(video_mode_info.PhysBasePtr && vib.TotalMemory && (video_mode_info.ModeAttributes & MODE_ATTR_LINEAR)) |
2244 | 821 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
822 void *lfb; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
823 unsigned long vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
824 vsize = vib.TotalMemory*64*1024; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
825 lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vsize); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
826 if(lfb == NULL) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
827 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
|
828 else |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
829 { |
2649 | 830 video_base = win.ptr = lfb; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
831 win.low = 0UL; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
832 win.high = vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
833 win.idx = -1; /* HAS_DGA() is on */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
834 video_mode |= VESA_MODE_USE_LINEAR; |
2649 | 835 printf("vo_vesa: Using DGA (physical resources: %08lXh, %08lXh)" |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
836 ,video_mode_info.PhysBasePtr |
2649 | 837 ,vsize); |
838 if(verbose) printf(" at %08lXh",(unsigned long)lfb); | |
839 printf("\n"); | |
840 if(!(multi_size = fillMultiBuffer(vsize,2))) return -1; | |
841 if(vo_doublebuffering && multi_size < 2) | |
842 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
|
843 } |
2244 | 844 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
845 if(win.idx == -2) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
846 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
847 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
|
848 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
849 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
850 if(!HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
851 { |
4362 | 852 if(subdev_flags & SUBDEV_FORCEDGA) |
2649 | 853 { |
854 printf("vo_vesa: you've forced DGA. Exiting\n"); | |
855 return -1; | |
856 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
857 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
|
858 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
859 printf("vo_vesa: Can't find valid window address\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
860 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
861 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
862 win.ptr = PhysToVirtSO(win_seg,0); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
863 win.low = 0L; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
864 win.high= video_mode_info.WinSize*1024; |
2649 | 865 printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n" |
866 ,(unsigned long)win.ptr,(unsigned long)win.high); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
867 } |
4537 | 868 if(video_mode_info.XResolution > dstW) |
869 x_offset = (video_mode_info.XResolution - dstW) / 2; | |
2329 | 870 else x_offset = 0; |
4537 | 871 if(video_mode_info.YResolution > dstH) |
872 y_offset = (video_mode_info.YResolution - dstH) / 2; | |
2329 | 873 else y_offset = 0; |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
874 if(verbose) |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
875 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n" |
4537 | 876 ,dstW,dstH |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
877 ,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
|
878 ,x_offset,y_offset); |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
879 if(HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
880 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
881 dga_buffer = win.ptr; /* Trickly ;) */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
882 cpy_blk_fnc = __vbeCopyBlockFast; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
883 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
884 else |
2610 | 885 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
886 cpy_blk_fnc = __vbeCopyBlock; |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
887 if(!lvo_name |
4089 | 888 #ifdef CONFIG_VIDIX |
889 && !vidix_name | |
890 #endif | |
4601
8cda24d7f074
Make code simple. Use swScaler even for fastmemcpy purposes :)
nick
parents:
4596
diff
changeset
|
891 ) |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
892 { |
4537 | 893 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*dstBpp))) |
2610 | 894 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
895 printf("vo_vesa: Can't allocate temporary buffer\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
896 return -1; |
2610 | 897 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
898 if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer); |
2337 | 899 } |
2504 | 900 } |
2244 | 901 if((err=vbeSaveState(&init_state)) != VBE_OK) |
902 { | |
903 PRINT_VBE_ERR("vbeSaveState",err); | |
904 return -1; | |
905 } | |
7360 | 906 |
907 /* TODO: | |
908 user might pass refresh value, | |
7069 | 909 GTF constants might be read from monitor |
7360 | 910 for best results, I don't have a spec (RM) |
7069 | 911 */ |
7360 | 912 |
7069 | 913 if (((int)(vib.VESAVersion >> 8) & 0xff) > 2) { |
914 | |
7650
7e8193475ddf
a small fix for vo_vesa, when calling set_refresh, when -nofs used.
arpi
parents:
7360
diff
changeset
|
915 if (set_refresh(video_mode_info.XResolution,video_mode_info.YResolution,video_mode,&crtc_pass)) |
7069 | 916 video_mode = video_mode | 0x800; |
917 | |
918 } | |
919 | |
920 ; | |
921 | |
922 if ((err=vbeSetMode(video_mode,&crtc_pass)) != VBE_OK) | |
2244 | 923 { |
924 PRINT_VBE_ERR("vbeSetMode",err); | |
925 return -1; | |
926 } | |
7069 | 927 |
2244 | 928 /* Now we are in video mode!!!*/ |
2337 | 929 /* Below 'return -1' is impossible */ |
2244 | 930 if(verbose) |
931 { | |
932 printf("vo_vesa: Graphics mode was activated\n"); | |
933 fflush(stdout); | |
934 } | |
2869 | 935 if(lvo_name) |
936 { | |
4537 | 937 if(vlvo_init(width,height,x_offset,y_offset,dstW,dstH,format,dstBpp) != 0) |
2869 | 938 { |
939 printf("vo_vesa: Can't initialize Linux Video Overlay\n"); | |
940 vesa_term(); | |
941 return -1; | |
942 } | |
943 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
|
944 lvo_opened = 1; |
2869 | 945 } |
4089 | 946 #ifdef CONFIG_VIDIX |
4030 | 947 else |
948 if(vidix_name) | |
949 { | |
4537 | 950 if(vidix_init(width,height,x_offset,y_offset,dstW, |
951 dstH,format,dstBpp, | |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
7069
diff
changeset
|
952 video_mode_info.XResolution,video_mode_info.YResolution) != 0) |
4030 | 953 { |
954 printf("vo_vesa: Can't initialize VIDIX driver\n"); | |
4548 | 955 vesa_term(); |
4030 | 956 return -1; |
957 } | |
4083 | 958 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
|
959 vidix_start(); |
9883
3a407acefec5
multiple init fix by Aurelien JACOBS <aurel@gnuage.org>
alex
parents:
9714
diff
changeset
|
960 vidix_opened = 1; |
4030 | 961 } |
4089 | 962 #endif |
2244 | 963 } |
964 else | |
965 { | |
2255 | 966 printf("vo_vesa: Can't find mode for: %ux%u@%u\n",width,height,bpp); |
2244 | 967 return -1; |
968 } | |
969 if(verbose) | |
970 { | |
971 printf("vo_vesa: VESA initialization complete\n"); | |
972 fflush(stdout); | |
973 } | |
2688 | 974 if(HAS_DGA() && vo_doublebuffering) |
2244 | 975 { |
2686 | 976 for(i=0;i<MAX_BUFFERS;i++) |
977 { | |
978 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
|
979 clear_screen(); /* Clear screen for stupid BIOSes */ |
4002 | 980 if(verbose>1) paintBkGnd(); |
2686 | 981 } |
2244 | 982 } |
2686 | 983 else |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
984 { |
8652
edfe94b9d578
Juste a trivial patch for vesa output. The screen were cleaned at init
arpi
parents:
8148
diff
changeset
|
985 clear_screen(); /* Clear screen for stupid BIOSes */ |
9714 | 986 if(verbose>1) |
2686 | 987 { |
988 int x; | |
989 x = (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2; | |
990 if(x < 0) x = 0; | |
9714 | 991 paintBkGnd(); |
2686 | 992 vbeWriteString(x,0,7,title); |
993 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
994 } |
2244 | 995 return 0; |
996 } | |
997 | |
998 static void | |
999 uninit(void) | |
1000 { | |
8786
605c85c27e68
Not checking it caused SIGSEV when uninitning after vesa init failed.
filon
parents:
8652
diff
changeset
|
1001 // not inited |
2686 | 1002 vesa_term(); |
2504 | 1003 if(verbose > 2) |
1004 printf("vo_vesa: uninit was called\n"); | |
2244 | 1005 } |
1006 | |
1007 | |
1008 static void check_events(void) | |
1009 { | |
2504 | 1010 if(verbose > 2) |
1011 printf("vo_vesa: check_events was called\n"); | |
2244 | 1012 /* Nothing to do */ |
1013 } | |
4352 | 1014 |
1015 static uint32_t preinit(const char *arg) | |
1016 { | |
4362 | 1017 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
|
1018 int fd; |
4362 | 1019 if(verbose>1) printf("vo_vesa: preinit(%s) was called\n",arg); |
1020 if(verbose > 2) | |
1021 printf("vo_vesa: subdevice %s is being initialized\n",arg); | |
1022 subdev_flags = 0; | |
9958 | 1023 lvo_name = NULL; |
1024 #ifdef CONFIG_VIDIX | |
1025 vidix_name = NULL; | |
1026 #endif | |
4362 | 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 } |