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