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