Mercurial > mplayer.hg
annotate libvo/vo_svga.c @ 33086:1b9f989855f3
Remove needless variable.
Use passed parameter directly instead.
author | ib |
---|---|
date | Fri, 01 Apr 2011 10:58:04 +0000 |
parents | fbe5c829c69b |
children | 899d817e56fc |
rev | line source |
---|---|
285 | 1 /* |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
2 * video driver for SVGAlib |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
3 * by Zoltan Mark Vician <se7en@sch.bme.hu> |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
4 * Code started: Mon Apr 1 23:25:47 2001 |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
5 * Some changes by Matan Ziv-Av <matan@svgalib.org> |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
6 * complete rewrite by Ivan Kalvachev 19 Mar 2003 |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
7 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
8 * This file is part of MPlayer. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
9 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
10 * MPlayer is free software; you can redistribute it and/or modify |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
13 * (at your option) any later version. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
14 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
15 * MPlayer is distributed in the hope that it will be useful, |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
18 * GNU General Public License for more details. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
19 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
20 * You should have received a copy of the GNU General Public License along |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
21 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
23 */ |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
24 |
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
26755
diff
changeset
|
25 /* |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
26 Wrangings: |
28646 | 27 - 1bpp doesn't work right for me with '-double' and svgalib 1.4.3, |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
28 but works OK with svgalib 1.9.17 |
28646 | 29 - The HW acceleration is not tested - svgalibs supports few chipsets, |
30 and i don't have any of them. If it works for you then let me know. | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
31 I will remove this warning after confirm its status. |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
32 - retrace sync works only in doublebuffer mode. |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
33 - the retrace sync may slow down decoding a lot - mplayer is blocked while |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
34 waiting for retrace |
9659 | 35 - denoise3d fails to find common colorspace, use -vf denoise3d,scale |
28646 | 36 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
37 TODO: |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
38 - let choose_best_mode take aspect into account |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
39 - set palette from mpi->palette or mpi->plane[1] |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
40 - make faster OSD black bars clear - need some OSD changes |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
41 - Make nicer CONFIG parsing |
28646 | 42 - change video mode logical width to match img->stride[0] - for HW only |
285 | 43 */ |
44 | |
45 #include <stdio.h> | |
46 #include <stdlib.h> | |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7124
diff
changeset
|
47 #include <string.h> |
285 | 48 |
49 #include <vga.h> | |
50 | |
485 | 51 #include <limits.h> |
52 | |
285 | 53 #include "config.h" |
54 #include "video_out.h" | |
55 #include "video_out_internal.h" | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
56 #include "fastmemcpy.h" |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
57 #include "osdep/getch2.h" |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
58 #include "vosub_vidix.h" |
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
59 |
32467 | 60 #include "sub/sub.h" |
616 | 61 |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
11565
diff
changeset
|
62 #include "mp_msg.h" |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
63 #include "help_mp.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
11565
diff
changeset
|
64 //#include "mp_image.h" |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
65 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
66 #include <assert.h> |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
67 |
407 | 68 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
69 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
70 unsigned char *srca, int stride); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
71 static uint32_t get_image(mp_image_t *mpi); |
285 | 72 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
73 #define MAXPAGES 16 |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
74 #define PAGE_EMPTY 0 |
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
75 #define PAGE_BUSY 1 |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
76 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
77 #define CAP_ACCEL_CLEAR 8 |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
78 #define CAP_ACCEL_PUTIMAGE 4 |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
79 #define CAP_ACCEL_BACKGR 2 |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
80 #define CAP_LINEAR 1 |
285 | 81 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
82 static uint8_t zerobuf[8192];//used when clear screen with vga_draw |
285 | 83 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
84 static int squarepix; |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
85 static int force_vm=0; |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
86 static int force_native=0; |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
87 static int sync_flip=0; |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
88 static int blackbar_osd=0; |
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
89 static int cpage,max_pages,old_page; |
447 | 90 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
91 static vga_modeinfo * modeinfo; |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
92 static int mode_stride; //keep it in case of vga_setlogicalwidth |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
93 static int stride_granularity; //not yet used |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
94 static int mode_bpp; |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
95 static int mode_capabilities; |
483 | 96 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
97 static int image_width,image_height; // used by OSD |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
98 static int x_pos, y_pos; |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
99 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
100 static struct { |
28649 | 101 int yoffset;//y position of the page |
102 int doffset;//display start of the page | |
103 uint8_t * vbase;//memory start address of the page | |
104 int locks; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
105 }PageStore[MAXPAGES]; |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
106 |
25216 | 107 static const vo_info_t info = { |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
108 "SVGAlib", |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
109 "svga", |
10940 | 110 "Ivan Kalvachev <iive@users.sf.net>", |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
111 "" |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
112 }; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
113 |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
114 #ifdef CONFIG_VIDIX |
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
115 static char vidix_name[32] = ""; |
11158
85f4534d1edb
Colorkeying can be disabled. Fbdev, svga and vesa vidix colorkeying support
alex
parents:
11000
diff
changeset
|
116 static vidix_grkey_t gr_key; |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
117 #endif |
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
118 |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7691
diff
changeset
|
119 LIBVO_EXTERN(svga) |
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
7691
diff
changeset
|
120 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
121 |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
122 //return number of 1'st free page or -1 if no free one |
22886 | 123 static inline int page_find_free(void){ |
28649 | 124 int i; |
125 for(i=0;i<max_pages;i++) | |
126 if(PageStore[i].locks == PAGE_EMPTY) return i; | |
127 return -1; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
128 } |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
129 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
130 static int preinit(const char *arg) |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
131 { |
28649 | 132 int i,rez; |
133 char s[64]; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
134 |
28649 | 135 getch2_disable(); |
136 memset(zerobuf,0,sizeof(zerobuf)); | |
137 force_vm=force_native=squarepix=0; | |
138 sync_flip=vo_vsync; | |
139 blackbar_osd=0; | |
28646 | 140 |
28649 | 141 if(arg)while(*arg) { |
28646 | 142 #ifdef CONFIG_VIDIX |
28649 | 143 if(memcmp(arg,"vidix",5)==0) { |
144 i=6; | |
145 while(arg[i] && arg[i]!=':') i++; | |
146 strncpy(vidix_name, arg+6, i-6); | |
147 vidix_name[i-5]=0; | |
148 if(arg[i]==':')i++; | |
149 arg+=i; | |
150 vidix_preinit(vidix_name, &video_out_svga); | |
151 } | |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
152 #endif |
28649 | 153 if(!strncmp(arg,"sq",2)) { |
154 squarepix=1; | |
155 arg+=2; | |
156 if( *arg == ':' ) arg++; | |
157 } | |
158 | |
159 if(!strncmp(arg,"native",6)) { | |
160 force_native=1; | |
161 arg+=6; | |
162 if( *arg == ':' ) arg++; | |
163 } | |
164 | |
165 if(!strncmp(arg,"bbosd",5)) { | |
166 blackbar_osd=1; | |
167 arg+=5; | |
168 if( *arg == ':' ) arg++; | |
169 } | |
28646 | 170 |
28649 | 171 if(!strncmp(arg,"retrace",7)) { |
172 sync_flip=1; | |
173 arg+=7; | |
174 if( *arg == ':' ) arg++; | |
175 } | |
176 | |
177 if(*arg) { | |
178 i=0; | |
179 while(arg[i] && arg[i]!=':')i++; | |
180 if(i<64){ | |
181 strncpy(s, arg, i); | |
182 s[i]=0; | |
183 | |
184 force_vm=vga_getmodenumber(s); | |
185 if(force_vm>0) { | |
186 mp_msg(MSGT_VO,MSGL_V, "vo_svga: Forcing mode %i\n",force_vm); | |
187 }else{ | |
188 force_vm = 0; | |
189 } | |
190 } | |
191 arg+=i; | |
192 if(*arg==':')arg++; | |
193 } | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
194 } |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
195 |
28649 | 196 rez = vga_init(); |
197 if(rez != 0){ | |
198 mp_msg(MSGT_VO,MSGL_ERR, "vo_svga: vga_init() returned error=%d\n",rez); | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
199 } |
28649 | 200 return !!rez; |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
201 } |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
202 |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
203 static void svga_clear_box(int x,int y,int w,int h){ |
28649 | 204 uint8_t * rgbplane; |
205 int i; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
206 |
28649 | 207 if (mode_capabilities&CAP_ACCEL_CLEAR){ |
208 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with HW acceleration\n", | |
209 x,y,w,h); | |
210 if(mode_capabilities&CAP_ACCEL_BACKGR) | |
211 vga_accel(ACCEL_SYNC); | |
212 vga_accel(ACCEL_SETFGCOLOR,0);//black | |
213 vga_accel(ACCEL_FILLBOX,x,y,w,h); | |
214 return; | |
215 } | |
216 if (mode_capabilities & CAP_LINEAR){ | |
217 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with memset\n",x,y,w,h); | |
218 rgbplane=PageStore[0].vbase + (y*mode_stride) + (x*modeinfo->bytesperpixel); | |
219 for(i=0;i<h;i++){ | |
220 //i'm afraid that memcpy is better optimized than memset;) | |
221 fast_memcpy(rgbplane,zerobuf,w*modeinfo->bytesperpixel); | |
222 // memset(rgbplane,0,w*modeinfo->bytesperpixel); | |
223 rgbplane+=mode_stride; | |
224 } | |
225 return; | |
226 } | |
227 //native | |
228 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with native draw \n",x,y,w,h); | |
229 if(modeinfo->bytesperpixel!=0) w*=modeinfo->bytesperpixel; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
230 for(i=0;i<h;i++){ |
28649 | 231 vga_drawscansegment(zerobuf,x,y+i,w); |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
232 } |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
233 }; |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
234 |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
235 static uint32_t svga_draw_image(mp_image_t *mpi){ |
28649 | 236 int i,x,y,w,h; |
237 int stride; | |
238 uint8_t *rgbplane, *base; | |
239 int bytesperline; | |
240 int page; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
241 |
28649 | 242 if(mpi->flags & MP_IMGFLAG_DIRECT){ |
243 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: drawing direct rendered surface\n"); | |
244 cpage=(uint32_t)mpi->priv; | |
245 assert((cpage>=0)&&(cpage<max_pages)); | |
246 return VO_TRUE; //it's already done | |
247 } | |
28646 | 248 // if (mpi->flags&MP_IMGFLAGS_DRAWBACK) |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
249 // return VO_TRUE;//direct render method 2 |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
250 |
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
251 //find a free page to draw into |
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
252 //if there is no one then use the current one |
28649 | 253 page = page_find_free(); |
254 if(page>=0) cpage=page; | |
255 PageStore[cpage].locks=PAGE_BUSY; | |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
256 |
28646 | 257 // these variables are used in loops |
28649 | 258 x = mpi->x; |
259 y = mpi->y; | |
260 w = mpi->w; | |
261 h = mpi->h; | |
262 stride = mpi->stride[0]; | |
263 rgbplane = mpi->planes[0] + y*stride + (x*mpi->bpp)/8; | |
264 x+=x_pos;//center | |
265 y+=y_pos; | |
28646 | 266 |
28649 | 267 if(mpi->bpp >= 8){//for modes<8 use only native |
268 if( (mode_capabilities&CAP_ACCEL_PUTIMAGE) && (x==0) && (w==mpi->width) && | |
269 (stride == mode_stride) ){ //only monolite image can be accelerated | |
270 w=(stride*8)/mpi->bpp;//we transfer pixels in the stride so the source | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
271 //ACCELERATE |
28649 | 272 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using HW PutImage (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); |
273 if(mode_capabilities & CAP_ACCEL_BACKGR) | |
274 vga_accel(ACCEL_SYNC); | |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
275 |
28649 | 276 vga_accel(ACCEL_PUTIMAGE,x,y+PageStore[cpage].yoffset,w,h,rgbplane); |
277 return VO_TRUE; | |
278 } | |
28646 | 279 |
28649 | 280 if( mode_capabilities&CAP_LINEAR){ |
28646 | 281 //DIRECT |
28649 | 282 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); |
283 bytesperline=(w*mpi->bpp)/8; | |
284 base=PageStore[cpage].vbase + (y*mode_stride) + (x*mpi->bpp)/8; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
285 |
28649 | 286 for(i=0;i<h;i++){ |
287 mem2agpcpy(base,rgbplane,bytesperline); | |
288 base+=mode_stride; | |
289 rgbplane+=stride; | |
290 } | |
291 return VO_TRUE; | |
292 } | |
293 }//(modebpp>=8 | |
28646 | 294 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
295 |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
296 //NATIVE |
28649 | 297 { |
298 int length; | |
299 length=(w*mpi->bpp)/8; | |
300 //one byte per pixel! svgalib innovation | |
301 if(mpi->imgfmt==IMGFMT_RG4B || mpi->imgfmt==IMGFMT_BG4B) length=w; | |
28646 | 302 |
28649 | 303 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); |
304 y+=PageStore[cpage].yoffset;//y position of the page beggining | |
305 for(i=0;i<h;i++){ | |
306 vga_drawscansegment(rgbplane,x,y+i,length); | |
307 rgbplane+=stride; | |
308 } | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
309 } |
28649 | 310 return VO_TRUE; |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
311 } |
7675 | 312 |
18950 | 313 static int bpp_from_vminfo(vga_modeinfo *vminfo){ |
28649 | 314 switch(vminfo->colors){ |
315 case 2: return 1; | |
316 case 16: return 4; | |
317 case 256: return 8; | |
318 case 32768: return 15; | |
319 case 65536: return 16; | |
320 case 1<<24: return 8*vminfo->bytesperpixel; | |
321 } | |
322 return 0; | |
483 | 323 } |
324 | |
18950 | 325 static int find_best_svga_mode(int req_w,int req_h, int req_bpp){ |
28649 | 326 int badness,prev_badness; |
327 int bestmode,lastmode; | |
328 int i; | |
329 vga_modeinfo *vminfo; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
330 //int best aspect mode // best linear mode // best normal mode (no modeX) |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
331 |
28649 | 332 prev_badness = 0;//take care of special case below |
333 bestmode = 0; //0 is the TEXT mode | |
334 lastmode = vga_lastmodenumber(); | |
335 for(i=1;i<=lastmode;i++){ | |
336 vminfo = vga_getmodeinfo(i); | |
337 if( vminfo == NULL ) continue; | |
338 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: testing mode %d (%s)\n",i,vga_getmodename(i)); | |
339 if( vga_hasmode(i) == 0 ) continue; | |
340 if( req_bpp != bpp_from_vminfo(vminfo) )continue; | |
341 if( (vminfo->width < req_w) || (vminfo->height < req_h) ) continue; | |
342 badness=(vminfo->width * vminfo->height) - (req_h * req_w); | |
343 //put here aspect calculations | |
344 if(squarepix) | |
345 if( vminfo->width*3 != vminfo->height*4 ) continue; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
346 |
28649 | 347 if( bestmode==0 || prev_badness >= badness ){//modeX etc... |
348 prev_badness=badness; | |
349 bestmode=i; | |
350 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: found good mode %d with badness %d\n",i,badness); | |
351 } | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
352 } |
28649 | 353 return bestmode; |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
354 } |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
355 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
356 static int control(uint32_t request, void *data, ...) |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
357 { |
28649 | 358 switch (request) { |
359 case VOCTRL_QUERY_FORMAT: | |
360 return query_format(*((uint32_t*)data)); | |
361 case VOCTRL_DRAW_IMAGE: | |
362 return svga_draw_image( (mp_image_t *)data); | |
363 case VOCTRL_GET_IMAGE: | |
364 return get_image(data); | |
365 } | |
11565
0d24c99199e2
Some more vidix crap - vidix equalizer passthrough. Patch by Oleg I. Vdovikin <vdovikin@jscc.ru>
alex
parents:
11216
diff
changeset
|
366 |
0d24c99199e2
Some more vidix crap - vidix equalizer passthrough. Patch by Oleg I. Vdovikin <vdovikin@jscc.ru>
alex
parents:
11216
diff
changeset
|
367 #ifdef CONFIG_VIDIX |
28649 | 368 if (vidix_name[0]) { |
369 switch (request) { | |
370 case VOCTRL_SET_EQUALIZER: | |
371 { | |
372 va_list ap; | |
373 int value; | |
374 | |
375 va_start(ap, data); | |
376 value = va_arg(ap, int); | |
377 va_end(ap); | |
28646 | 378 |
28649 | 379 return vidix_control(request, data, value); |
380 } | |
381 case VOCTRL_GET_EQUALIZER: | |
382 { | |
383 va_list ap; | |
384 int *value; | |
11565
0d24c99199e2
Some more vidix crap - vidix equalizer passthrough. Patch by Oleg I. Vdovikin <vdovikin@jscc.ru>
alex
parents:
11216
diff
changeset
|
385 |
28649 | 386 va_start(ap, data); |
387 value = va_arg(ap, int*); | |
388 va_end(ap); | |
389 | |
390 return vidix_control(request, data, value); | |
391 } | |
392 } | |
393 return vidix_control(request, data); | |
11565
0d24c99199e2
Some more vidix crap - vidix equalizer passthrough. Patch by Oleg I. Vdovikin <vdovikin@jscc.ru>
alex
parents:
11216
diff
changeset
|
394 } |
0d24c99199e2
Some more vidix crap - vidix equalizer passthrough. Patch by Oleg I. Vdovikin <vdovikin@jscc.ru>
alex
parents:
11216
diff
changeset
|
395 #endif |
0d24c99199e2
Some more vidix crap - vidix equalizer passthrough. Patch by Oleg I. Vdovikin <vdovikin@jscc.ru>
alex
parents:
11216
diff
changeset
|
396 |
28649 | 397 return VO_NOTIMPL; |
285 | 398 } |
399 | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
400 // |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
401 // This function is called to init the video driver for specific mode |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
402 // |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
403 static int config(uint32_t width, uint32_t height, uint32_t d_width, |
15212
05aa13cdf92f
replace VO and VF numeric flags with #defined identifiers
henry
parents:
13865
diff
changeset
|
404 uint32_t d_height, uint32_t flags, char *title, |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
405 uint32_t format) { |
28649 | 406 int32_t req_w = width;// (d_width > 0 ? d_width : width); |
407 int32_t req_h = height;// (d_height > 0 ? d_height : height); | |
408 uint16_t vid_mode = 0; | |
409 int32_t req_bpp; | |
28646 | 410 |
28649 | 411 uint32_t accflags; |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
412 mp_msg(MSGT_VO,MSGL_V, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height, |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
413 d_width, d_height, flags, title, format); |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
414 //Only RGB modes supported |
28649 | 415 if (!IMGFMT_IS_RGB(format) && !IMGFMT_IS_BGR(format)) {assert(0);return -1;} |
416 req_bpp = IMGFMT_BGR_DEPTH(format); | |
28646 | 417 |
28649 | 418 if( vo_dbpp!=0 && vo_dbpp!=req_bpp) {assert(0);return-1;} |
28646 | 419 |
28649 | 420 if(!force_vm) { |
421 mp_msg(MSGT_VO,MSGL_V, "vo_svga: Looking for the best resolution...\n"); | |
422 mp_msg(MSGT_VO,MSGL_V, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp); | |
423 vid_mode=find_best_svga_mode(req_w,req_h,req_bpp); | |
424 if(vid_mode==0) | |
425 return 1; | |
426 modeinfo=vga_getmodeinfo(vid_mode); | |
427 }else{//force_vm | |
428 vid_mode=force_vm; | |
429 if(vga_hasmode(vid_mode) == 0){ | |
430 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeNotAvailable, | |
431 vid_mode,vga_getmodename(vid_mode)); | |
432 return 1; //error; | |
433 } | |
434 modeinfo=vga_getmodeinfo(vid_mode); | |
435 if( (modeinfo->width < req_w) || (modeinfo->height < req_h) ){ | |
436 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_ForcedVidmodeTooSmall, | |
437 vid_mode,vga_getmodename(vid_mode)); | |
438 return 1; | |
439 } | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
440 } |
28649 | 441 mode_bpp=bpp_from_vminfo(modeinfo); |
28646 | 442 |
28649 | 443 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode, |
444 vid_mode,modeinfo->width,modeinfo->height,mode_bpp); | |
28646 | 445 |
28649 | 446 if (vga_setmode(vid_mode) == -1) { |
447 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode); | |
448 uninit(); | |
449 return 1; // error | |
450 } | |
451 /* set 332 palette for 8 bpp */ | |
452 if(mode_bpp==8){ | |
453 int i; | |
454 for(i=0; i<256; i++) | |
455 vga_setpalette(i, ((i>>5)&7)*9, ((i>>2)&7)*9, (i&3)*21); | |
456 } | |
457 /* set 121 palette for 4 bpp */ | |
458 else if(mode_bpp==4){ | |
459 int i; | |
460 for(i=0; i<16; i++) | |
461 vga_setpalette(i, ((i>>3)&1)*63, ((i>>1)&3)*21, (i&1)*63); | |
462 } | |
463 //if we change the logical width, we should know the granularity | |
464 stride_granularity=8;//according to man vga_logicalwidth | |
465 if(modeinfo->flags & EXT_INFO_AVAILABLE){ | |
466 stride_granularity=modeinfo->linewidth_unit; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
467 } |
28649 | 468 //look for hardware acceleration |
469 mode_capabilities=0;//NATIVE; | |
470 if(!force_native){//if we want to use only native drawers | |
471 if(modeinfo->flags & HAVE_EXT_SET){//support for hwaccel interface | |
472 accflags=vga_ext_set(VGA_EXT_AVAILABLE,VGA_AVAIL_ACCEL); | |
473 if(accflags & ACCELFLAG_FILLBOX) // clear screen | |
474 mode_capabilities|=CAP_ACCEL_CLEAR; | |
475 if(accflags & ACCELFLAG_PUTIMAGE)//support for mem->vid transfer | |
476 mode_capabilities|=CAP_ACCEL_PUTIMAGE; | |
477 if((accflags & ACCELFLAG_SETMODE) && (accflags & ACCELFLAG_SYNC)){ | |
478 vga_accel(ACCEL_SETMODE,BLITS_IN_BACKGROUND); | |
479 mode_capabilities|=CAP_ACCEL_BACKGR;//can draw in backgraund | |
480 } | |
481 } | |
482 if(modeinfo->flags & IS_LINEAR){ | |
483 mode_capabilities|=CAP_LINEAR; //don't use bank & vga_draw | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
484 } |
28649 | 485 else{ |
486 if(modeinfo->flags & CAPABLE_LINEAR){ | |
487 int vid_mem_size; | |
488 vid_mem_size = vga_setlinearaddressing(); | |
489 if(vid_mem_size != -1){ | |
490 modeinfo=vga_getmodeinfo(vid_mode);//sometimes they change parameters | |
491 mode_capabilities|=CAP_LINEAR; | |
492 } | |
493 } | |
494 } | |
495 }//fi force native | |
496 if(mode_capabilities&CAP_LINEAR){ | |
497 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeIsLinearAndMemcpyCouldBeUsed); | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
498 } |
28649 | 499 if(mode_capabilities&CAP_ACCEL_PUTIMAGE){ |
500 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHasHardwareAcceleration); | |
501 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_IfItWorksForYouIWouldLikeToKnow); | |
502 } | |
28646 | 503 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
504 //here is the place to handle strides for accel_ modes; |
28649 | 505 mode_stride=modeinfo->linewidth; |
28646 | 506 //we may try to set a bigger stride for video mode that will match the mpi->stride, |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
507 //this way we will transfer more data, but HW put_image can do it in backgraund! |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
508 |
28646 | 509 //now let's see how many pages we can use |
28649 | 510 max_pages = modeinfo->maxpixels/(modeinfo->height * modeinfo->width); |
511 if(max_pages > MAXPAGES) max_pages = MAXPAGES; | |
512 if(!vo_doublebuffering) max_pages=1; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
513 //fill PageStore structs |
28649 | 514 { |
515 int i; | |
516 uint8_t * GRAPH_MEM; | |
517 int dof; | |
518 GRAPH_MEM=vga_getgraphmem(); | |
519 for(i=0;i<max_pages;i++){ | |
520 //calculate display offset | |
521 dof = i * modeinfo->height * modeinfo->width; | |
522 if(modeinfo->bytesperpixel != 0) dof*=modeinfo->bytesperpixel; | |
523 //check video chip limitations | |
524 if( dof != (dof & modeinfo->startaddressrange) ){ | |
525 max_pages=i;//page 0 will never come here | |
526 break; | |
527 } | |
528 PageStore[i].yoffset = i * modeinfo->height;//starting y offset | |
529 PageStore[i].vbase = GRAPH_MEM + i*modeinfo->height*mode_stride; //memory base address | |
530 PageStore[i].doffset = dof; //display offset | |
531 PageStore[i].locks = PAGE_EMPTY; | |
532 } | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
533 } |
28649 | 534 assert(max_pages>0); |
535 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHas,max_pages); | |
536 //15bpp | |
537 if(modeinfo->bytesperpixel!=0) | |
538 vga_claimvideomemory(max_pages * modeinfo->height * modeinfo->width * modeinfo->bytesperpixel); | |
539 else | |
540 vga_claimvideomemory(max_pages * modeinfo->height * modeinfo->width * mode_bpp / 8); | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
541 |
28649 | 542 cpage=old_page=0; |
543 svga_clear_box(0,0,modeinfo->width,modeinfo->height * max_pages); | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
544 |
28649 | 545 image_height=req_h; |
546 image_width=req_w; | |
547 x_pos = (modeinfo->width - req_w) / 2; | |
548 y_pos = (modeinfo->height - req_h) / 2; | |
549 x_pos &= ~(15); //align x offset position to 16 pixels | |
550 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_CenteringImageStartAt,x_pos,y_pos); | |
8520 | 551 |
552 #ifdef CONFIG_VIDIX | |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
553 |
28649 | 554 if(vidix_name[0]){ |
555 vidix_init(width, height, x_pos, y_pos, modeinfo->width, modeinfo->height, | |
556 format, mode_bpp, modeinfo->width,modeinfo->height); | |
557 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_UsingVidix,width,height, | |
558 modeinfo->width,modeinfo->height); | |
559 vidix_start(); | |
560 /*set colorkey*/ | |
561 if(vidix_grkey_support()){ | |
562 vidix_grkey_get(&gr_key); | |
563 gr_key.key_op = KEYS_PUT; | |
564 if (!(vo_colorkey & 0xFF000000)) { | |
565 gr_key.ckey.op = CKEY_TRUE; | |
566 gr_key.ckey.red = (vo_colorkey & 0x00FF0000) >> 16; | |
567 gr_key.ckey.green = (vo_colorkey & 0x0000FF00) >> 8; | |
568 gr_key.ckey.blue = vo_colorkey & 0x000000FF; | |
569 } else | |
570 gr_key.ckey.op = CKEY_FALSE; | |
571 vidix_grkey_set(&gr_key); | |
572 } | |
28646 | 573 } |
574 #endif | |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
575 |
28649 | 576 vga_setdisplaystart(0); |
577 return 0; | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
578 } |
6456 | 579 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
580 static int draw_slice(uint8_t *image[],int stride[], |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
581 int w, int h, int x, int y) { |
28649 | 582 assert(0); |
583 return VO_ERROR;//this is yv12 only -> vf_scale should do all transforms | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
584 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
585 |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
586 static int draw_frame(uint8_t *src[]) { |
28649 | 587 assert(0); |
588 return VO_ERROR;//this one should not be called | |
285 | 589 } |
590 | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
591 static void draw_osd(void) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
592 { |
28649 | 593 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: draw_osd()\n"); |
594 //only modes with bytesperpixel>0 can draw OSD | |
595 if(modeinfo->bytesperpixel==0) return; | |
596 if(!(mode_capabilities&CAP_LINEAR)) return;//force_native will remove OSD | |
28646 | 597 |
28649 | 598 if(blackbar_osd){ |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
599 //111 |
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
600 //3 4 |
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
601 //222 |
28649 | 602 svga_clear_box(0,0 + PageStore[cpage].yoffset, |
603 modeinfo->width, y_pos); | |
604 svga_clear_box(0, image_height + y_pos + PageStore[cpage].yoffset, | |
605 modeinfo->width, modeinfo->height-(image_height+ y_pos)); | |
606 svga_clear_box(0, y_pos + PageStore[cpage].yoffset, | |
607 x_pos, image_height); | |
608 svga_clear_box(image_width + x_pos, y_pos + PageStore[cpage].yoffset, | |
609 modeinfo->width-(x_pos+image_width), image_height); | |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
610 // vo_remove_text(modeinfo->width, modeinfo->height, clear_alpha); |
28649 | 611 vo_draw_text(modeinfo->width, modeinfo->height, draw_alpha); |
612 }else{ | |
613 vo_draw_text(image_width, image_height, draw_alpha); | |
614 } | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
615 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
616 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
617 static void flip_page(void) { |
28649 | 618 PageStore[old_page].locks=PAGE_EMPTY; |
619 PageStore[cpage].locks=PAGE_BUSY; | |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
620 |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
621 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: viewing page %d\n",cpage); |
28649 | 622 if(sync_flip && old_page!=cpage){ |
623 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga:vga_waitretrace\n"); | |
624 vga_waitretrace(); | |
625 } | |
626 vga_setdisplaystart(PageStore[cpage].doffset); | |
28646 | 627 |
28649 | 628 old_page=cpage;//cpage will be overwriten on next draw_image |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
629 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
630 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
631 static void check_events(void) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
632 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
633 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
634 static void uninit(void) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
635 |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
636 #ifdef CONFIG_VIDIX |
28649 | 637 if(vidix_name[0])vidix_term(); |
8515
b4e5d87b878b
vidix support and better device options handler by Matan Ziv-Av <matan@svgalib.org>
alex
parents:
8148
diff
changeset
|
638 #endif |
28649 | 639 vga_setmode(TEXT); |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
640 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
641 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
642 /* --------------------------------------------------------------------- */ |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
15212
diff
changeset
|
643 static int query_format(uint32_t format) { |
28649 | 644 int32_t req_bpp,flags; |
645 int i,lastmode; | |
646 vga_modeinfo * vminfo; | |
407 | 647 |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
648 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: query_format=%X \n",format); |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
649 //only RGB modes supported |
28649 | 650 if( (!IMGFMT_IS_RGB(format)) && (!IMGFMT_IS_BGR(format)) ) return 0; |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
651 |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
652 // Reject different endian |
29401
f01023c524c3
Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents:
28649
diff
changeset
|
653 #if HAVE_BIGENDIAN |
28649 | 654 if (IMGFMT_IS_BGR(format)) return 0; |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
655 #else |
28649 | 656 if (IMGFMT_IS_RGB(format)) return 0; |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
657 #endif |
485 | 658 |
28649 | 659 //svgalib supports only BG4B! if we want BGR4 we have to emulate it (sw) |
660 if( format==IMGFMT_BGR4 || format==IMGFMT_RGB4) return 0; | |
661 req_bpp = IMGFMT_RGB_DEPTH(format); | |
662 if( vo_dbpp>0 && vo_dbpp!=req_bpp ) return 0; //support -bpp options | |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
663 //scan all modes |
28649 | 664 lastmode = vga_lastmodenumber(); |
665 for(i=1;i<=lastmode;i++){ | |
666 vminfo = vga_getmodeinfo(i); | |
667 if( vminfo == NULL ) continue; | |
668 if( vga_hasmode(i) == 0 ) continue; | |
669 if( req_bpp != bpp_from_vminfo(vminfo) ) continue; | |
670 if( (force_vm > 0) && (force_vm != i) ) continue;//quick hack | |
671 flags = VFCAP_CSP_SUPPORTED| | |
672 VFCAP_CSP_SUPPORTED_BY_HW| | |
673 VFCAP_ACCEPT_STRIDE| | |
674 0; | |
675 if(req_bpp>8) flags|=VFCAP_OSD; | |
676 return flags; | |
677 } | |
678 return 0; | |
285 | 679 } |
680 | |
681 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
682 unsigned char *srca, int stride) { | |
28649 | 683 char* base; |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
684 |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
685 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: draw_alpha(x0=%d,y0=%d,w=%d,h=%d,src=%p,srca=%p,stride=%d\n", |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
686 x0,y0,w,h,src,srca,stride); |
28649 | 687 if(!blackbar_osd) { |
688 //drawing in the image, so place the stuff there | |
689 x0+=x_pos; | |
690 y0+=y_pos; | |
691 } | |
28646 | 692 |
18234
a107276371a8
Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
reynaldo
parents:
17932
diff
changeset
|
693 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: OSD draw in page %d\n",cpage); |
28649 | 694 base=PageStore[cpage].vbase + y0*mode_stride + x0*modeinfo->bytesperpixel; |
695 switch (mode_bpp) { | |
696 case 32: | |
697 vo_draw_alpha_rgb32(w, h, src, srca, stride, base, mode_stride); | |
698 break; | |
699 case 24: | |
700 vo_draw_alpha_rgb24(w, h, src, srca, stride, base, mode_stride); | |
701 break; | |
702 case 16: | |
703 vo_draw_alpha_rgb16(w, h, src, srca, stride, base, mode_stride); | |
704 break; | |
705 case 15: | |
706 vo_draw_alpha_rgb15(w, h, src, srca, stride, base, mode_stride); | |
707 break; | |
708 } | |
285 | 709 } |
4352 | 710 |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
711 static uint32_t get_image(mp_image_t *mpi){ |
28649 | 712 int page; |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
713 |
28649 | 714 if(!IMGFMT_IS_BGR(mpi->imgfmt) && !IMGFMT_IS_RGB(mpi->imgfmt) ){ |
715 assert(0);//should never happen | |
716 return VO_FALSE; | |
717 } | |
28646 | 718 |
28649 | 719 if ( |
720 ( (mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) || | |
721 (mpi->flags & MP_IMGFLAG_PLANAR) || | |
722 (mpi->flags & MP_IMGFLAG_YUV) | |
723 ) | |
26755
46f0b4d34fa1
cosmetics: Remove useless parentheses from from return statements.
diego
parents:
26174
diff
changeset
|
724 return VO_FALSE; |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
725 |
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
726 //reading from video memory is horribly slow |
28649 | 727 if( !(mpi->flags & MP_IMGFLAG_READABLE) && vo_directrendering && |
728 (mode_capabilities & CAP_LINEAR) ){ | |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
729 |
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
730 //find free page and reserve it |
28649 | 731 page=page_find_free(); |
732 if(page >= 0){ | |
733 PageStore[page].locks=PAGE_BUSY; | |
10924
f531971e44cf
blackbar osd support based on patch send by Dimitar Zhekov <jimmy@is-vn.bg>, page code removed/merged, small updates
iive
parents:
9788
diff
changeset
|
734 |
28649 | 735 mpi->flags |= MP_IMGFLAG_DIRECT; |
736 mpi->stride[0] = mode_stride; | |
737 mpi->planes[0] = PageStore[page].vbase + | |
738 y_pos*mode_stride + (x_pos*mpi->bpp)/8; | |
739 mpi->priv=(void *)page; | |
740 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: direct render allocated! page=%d\n",page); | |
741 return VO_TRUE; | |
742 } | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
743 } |
9621
3ef467aac4a1
new svga driver - support double buffering, fast_memcpy, direct render and HW acceleration
iive
parents:
9237
diff
changeset
|
744 |
28649 | 745 return VO_FALSE; |
4352 | 746 } |