Mercurial > mplayer.hg
annotate libvo/vo_tdfxfb.c @ 8028:c06fa0b05c1c
-really-quiet
author | arpi |
---|---|
date | Fri, 01 Nov 2002 18:22:46 +0000 |
parents | 732a8bfc7681 |
children | 9fc45fe0d444 |
rev | line source |
---|---|
5567 | 1 /* Copyright (C) Mark Zealey, 2002, <mark@zealos.org>. Released under the terms |
2 * and conditions of the GPL. | |
1979 | 3 * |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
4 * 30/03/02: An almost total rewrite, added DR support and support for modes |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
5 * other than 16bpp. Fixed the crash when playing multiple files |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
6 * 07/04/02: Fixed DR support, added YUY2 support, fixed OSD stuff. |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
7 * 08/04/02: Fixed a wierd sound corruption problem caused by some optomizations |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
8 * I made. |
5567 | 9 * 09/04/02: Fixed a problem with changing the variables passed to draw_slice(). |
10 * Fixed DR support for YV12 et al. Added BGR support. Removed lots of dud code. | |
11 * 10/04/02: Changed the memcpy functions to mem2agpcpy.. should be a tad | |
12 * faster. | |
13 * 11/04/02: Added a compile option so you can watch the film with the console | |
14 * as the background, or not. | |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
15 * 13/04/02: Fix rough OSD stuff by rendering it straight onto the output |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
16 * buffer. Added double-buffering. Supports hardware zoom/reduce zoom modes. |
5590 | 17 * 13/04/02: Misc cleanups of the code. |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7708
diff
changeset
|
18 * 22/10/02: Added geometry support to it |
1979 | 19 * |
5567 | 20 * Hints and tricks: |
21 * - Use -dr to get direct rendering | |
22 * - Use -vop yuy2 to get yuy2 rendering, *MUCH* faster than yv12 | |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
23 * - To get a black background and nice smooth OSD, use -double |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
24 * - To get the console as a background, but with scaled OSD, use -nodouble |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
25 * - The driver supports both scaling and shrinking the image using the -x and |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7708
diff
changeset
|
26 * -y options on the mplayer commandline. Also repositioning via the -geometry |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7708
diff
changeset
|
27 * option. |
1979 | 28 */ |
29 | |
30 #include <stdio.h> | |
31 #include <stdlib.h> | |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4596
diff
changeset
|
32 #include <errno.h> |
7708 | 33 #include <string.h> |
34 #include <unistd.h> | |
5567 | 35 #include <sys/ioctl.h> |
36 #include <fcntl.h> | |
37 #include <sys/mman.h> | |
38 #include <linux/fb.h> | |
1979 | 39 |
40 #include "config.h" | |
5567 | 41 #include "fastmemcpy.h" |
1979 | 42 #include "video_out.h" |
43 #include "video_out_internal.h" | |
5567 | 44 #include "drivers/3dfx.h" |
7708 | 45 #include "aspect.h" |
1979 | 46 |
47 LIBVO_EXTERN(tdfxfb) | |
48 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
49 static vo_info_t vo_info = |
1979 | 50 { |
5567 | 51 "3Dfx Banshee/Voodoo3/Voodoo5", |
1979 | 52 "tdfxfb", |
7708 | 53 "Mark Zealey <mark@zealos.org>", |
1979 | 54 "" |
55 }; | |
56 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
57 /* Some registers on the card */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
58 #define S2S_STRECH_BLT 2 // BLT + Strech |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
59 #define S2S_IMMED (1 << 8) // Do it immediatly |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
60 #define S2S_ROP (0xCC << 24) // ??? |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
61 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
62 /* Stepping between the different YUV plane registers */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
63 #define YUV_STRIDE 1024 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
64 struct YUV_plane { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
65 char Y[0x0100000]; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
66 char U[0x0100000]; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
67 char V[0x0100000]; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
68 }; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
69 |
7708 | 70 static int fd = -1; |
1979 | 71 static struct fb_fix_screeninfo fb_finfo; |
72 static struct fb_var_screeninfo fb_vinfo; | |
5567 | 73 static uint32_t in_width, in_height, in_format, in_depth, in_voodoo_format, |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
74 screenwidth, screenheight, screendepth, vidwidth, vidheight, vidx, vidy, |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
75 vid_voodoo_format, *vidpage, *hidpage, *inpage, vidpageoffset, |
7708 | 76 hidpageoffset, inpageoffset, *memBase0 = NULL, *memBase1 = NULL, r_width, r_height; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
77 static volatile voodoo_io_reg *reg_IO; |
1979 | 78 static voodoo_2d_reg *reg_2d; |
79 static voodoo_yuv_reg *reg_YUV; | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
80 static struct YUV_plane *YUV; |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
81 static void (*alpha_func)(), (*alpha_func_double)(); |
1979 | 82 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
83 static uint32_t preinit(const char *arg) |
1979 | 84 { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
85 char *name; |
1979 | 86 |
7708 | 87 if(arg) |
88 name = (char*)arg; | |
89 else if(!(name = getenv("FRAMEBUFFER"))) | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
90 name = "/dev/fb0"; |
1979 | 91 |
5567 | 92 if((fd = open(name, O_RDWR)) == -1) { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
93 printf("tdfxfb: can't open %s: %s\n", name, strerror(errno)); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
94 return -1; |
1979 | 95 } |
96 | |
5567 | 97 if(ioctl(fd, FBIOGET_FSCREENINFO, &fb_finfo)) { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
98 printf("tdfxfb: problem with FBITGET_FSCREENINFO ioctl: %s\n", |
1979 | 99 strerror(errno)); |
7708 | 100 close(fd); |
101 fd = -1; | |
1979 | 102 return -1; |
103 } | |
104 | |
5567 | 105 if(ioctl(fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
106 printf("tdfxfb: problem with FBITGET_VSCREENINFO ioctl: %s\n", |
1979 | 107 strerror(errno)); |
7708 | 108 close(fd); |
109 fd = -1; | |
1979 | 110 return -1; |
111 } | |
112 | |
5567 | 113 /* BANSHEE means any of the series aparently */ |
114 if (fb_finfo.accel != FB_ACCEL_3DFX_BANSHEE) { | |
115 printf("tdfxfb: This driver is only supports the 3Dfx Banshee," | |
116 " Voodoo3 and Voodoo 5\n"); | |
7708 | 117 close(fd); |
118 fd = -1; | |
5567 | 119 return -1; |
1979 | 120 } |
121 | |
7708 | 122 // Check the depth now as config() musn't fail |
123 switch(fb_vinfo.bits_per_pixel) { | |
124 case 16: | |
125 case 24: | |
126 case 32: | |
127 break; // Ok | |
128 default: | |
129 printf("tdfxfb: %d bpp output is not supported\n", fb_vinfo.bits_per_pixel); | |
130 close(fd); | |
131 fd = -1; | |
132 return -1; | |
133 } | |
134 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
135 /* Open up a window to the hardware */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
136 memBase1 = mmap(0, fb_finfo.smem_len, PROT_READ | PROT_WRITE, |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
137 MAP_SHARED, fd, 0); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
138 memBase0 = mmap(0, fb_finfo.mmio_len, PROT_READ | PROT_WRITE, |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
139 MAP_SHARED, fd, fb_finfo.smem_len); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
140 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
141 if((long)memBase0 == -1 || (long)memBase1 == -1) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
142 printf("tdfxfb: Couldn't map memory areas: %s\n", strerror(errno)); |
7708 | 143 if((long)memBase0 != -1) |
144 munmap(memBase0, fb_finfo.smem_len); | |
145 if((long)memBase1 != -1) | |
146 munmap(memBase1, fb_finfo.smem_len); | |
147 memBase0 = memBase1 = NULL; | |
1979 | 148 return -1; |
149 } | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
150 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
151 /* Set up global pointers to the voodoo's regs */ |
5567 | 152 reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET; |
153 reg_2d = (void *)memBase0 + VOODOO_2D_REG_OFFSET; | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
154 reg_YUV = (void *)memBase0 + VOODOO_YUV_REG_OFFSET; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
155 YUV = (void *)memBase0 + VOODOO_YUV_PLANE_OFFSET; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
156 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
157 return 0; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
158 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
159 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
160 static void uninit(void) |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
161 { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
162 if(reg_IO) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
163 /* Restore the screen (Linux lives at 0) */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
164 reg_IO->vidDesktopStartAddr = 0; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
165 reg_IO = NULL; |
1979 | 166 } |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
167 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
168 /* And close our mess */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
169 if(memBase1) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
170 munmap(memBase1, fb_finfo.smem_len); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
171 memBase1 = NULL; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
172 } |
1979 | 173 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
174 if(memBase0) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
175 munmap(memBase0, fb_finfo.mmio_len); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
176 memBase0 = NULL; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
177 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
178 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
179 if(fd != -1) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
180 close(fd); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
181 fd = -1; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
182 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
183 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
184 |
5567 | 185 static void clear_screen() |
186 { | |
7137
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
187 /* There needs to be some sort of delay here or else things seriously |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
188 * screw up. Causes the image to not be the right size on screen if |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
189 * this isn't like this. A printf before the memset call also seems to |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
190 * work, but this made more sense since it actually checks the status of |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
191 * the card. |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
192 */ |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
193 if(vo_doublebuffering) { |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
194 /* first wait for the card to be ready, do not try to write |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
195 * every time - alex */ |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
196 do {} while((reg_IO->status & 0x1f) < 1); |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
197 memset(vidpage, 0, screenwidth * screenheight * screendepth); |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
198 memset(hidpage, 0, screenwidth * screenheight * screendepth); |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
199 } |
5567 | 200 } |
201 | |
202 /* Setup output screen dimensions etc */ | |
5590 | 203 static void setup_screen(uint32_t full) |
5567 | 204 { |
7866
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7708
diff
changeset
|
205 aspect(&vidwidth, &vidheight, full ? A_ZOOM : A_NOZOOM); |
732a8bfc7681
Added the -geometry option (supports fbdev and tdfxfb drivers)
mark
parents:
7708
diff
changeset
|
206 geometry(&vidx, &vidy, screenwidth, screenheight, vidwidth, vidheight, full); |
7708 | 207 vo_fs = full; |
5567 | 208 clear_screen(); |
209 } | |
210 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
211 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
7117
diff
changeset
|
212 uint32_t flags, char *title, uint32_t format) |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
213 { |
1979 | 214 screenwidth = fb_vinfo.xres; |
215 screenheight = fb_vinfo.yres; | |
7708 | 216 aspect_save_screenres(fb_vinfo.xres,fb_vinfo.yres); |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
217 |
1979 | 218 in_width = width; |
219 in_height = height; | |
220 in_format = format; | |
7708 | 221 aspect_save_orig(width,height); |
1979 | 222 |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
223 r_width = d_width; |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
224 r_height = d_height; |
7708 | 225 aspect_save_prescale(d_width,d_height); |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
226 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
227 /* Setup the screen for rendering to */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
228 switch(fb_vinfo.bits_per_pixel) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
229 case 16: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
230 screendepth = 2; |
5567 | 231 vid_voodoo_format = VOODOO_BLT_FORMAT_16; |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
232 alpha_func_double = vo_draw_alpha_rgb16; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
233 break; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
234 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
235 case 24: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
236 screendepth = 3; |
5567 | 237 vid_voodoo_format = VOODOO_BLT_FORMAT_24; |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
238 alpha_func_double = vo_draw_alpha_rgb24; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
239 break; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
240 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
241 case 32: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
242 screendepth = 4; |
5567 | 243 vid_voodoo_format = VOODOO_BLT_FORMAT_32; |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
244 alpha_func_double = vo_draw_alpha_rgb32; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
245 break; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
246 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
247 default: |
7708 | 248 printf("tdfxfb: %d bpp output is not supported (This should never happend)\n", fb_vinfo.bits_per_pixel); |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
249 return -1; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
250 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
251 |
5567 | 252 vid_voodoo_format |= screenwidth * screendepth; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
253 |
5567 | 254 /* Some defaults here */ |
255 in_voodoo_format = VOODOO_BLT_FORMAT_YUYV; | |
256 in_depth = 2; | |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
257 alpha_func = vo_draw_alpha_yuy2; |
5567 | 258 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
259 switch(in_format) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
260 case IMGFMT_YV12: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
261 case IMGFMT_I420: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
262 case IMGFMT_IYUV: |
5567 | 263 case IMGFMT_YUY2: |
264 break; | |
7708 | 265 case IMGFMT_UYVY: |
266 in_voodoo_format = VOODOO_BLT_FORMAT_UYVY; | |
267 break; | |
5567 | 268 case IMGFMT_BGR16: |
269 in_voodoo_format = VOODOO_BLT_FORMAT_16; | |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
270 alpha_func = vo_draw_alpha_rgb16; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
271 break; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
272 |
5567 | 273 case IMGFMT_BGR24: |
274 in_depth = 3; | |
275 in_voodoo_format = VOODOO_BLT_FORMAT_24; | |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
276 alpha_func = vo_draw_alpha_rgb24; |
5567 | 277 break; |
278 | |
279 case IMGFMT_BGR32: | |
280 in_depth = 4; | |
281 in_voodoo_format = VOODOO_BLT_FORMAT_32; | |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
282 alpha_func = vo_draw_alpha_rgb32; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
283 break; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
284 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
285 default: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
286 printf("tdfxfb: Eik! Something's wrong with control().\n"); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
287 return -1; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
288 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
289 |
5567 | 290 in_voodoo_format |= in_width * in_depth; |
1979 | 291 |
7137
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
292 /* Linux lives in the first frame */ |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
293 if(vo_doublebuffering) { |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
294 vidpageoffset = screenwidth * screenheight * screendepth; |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
295 hidpageoffset = vidpageoffset + screenwidth * screenheight * screendepth; |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
296 } else |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
297 vidpageoffset = hidpageoffset = 0; /* Console background */ |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
298 |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
299 |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
300 inpageoffset = hidpageoffset + screenwidth * screenheight * screendepth; |
1979 | 301 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
302 if(inpageoffset + in_width * in_depth * in_height > fb_finfo.smem_len) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
303 printf("tdfxfb: Not enough video memory to play this movie. Try at a lower resolution\n"); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
304 return -1; |
1979 | 305 } |
306 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
307 vidpage = (void *)memBase1 + (unsigned long)vidpageoffset; |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
308 hidpage = (void *)memBase1 + (unsigned long)hidpageoffset; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
309 inpage = (void *)memBase1 + (unsigned long)inpageoffset; |
1979 | 310 |
5590 | 311 setup_screen(flags & VOFLAG_FULLSCREEN); |
5567 | 312 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
313 memset(inpage, 0, in_width * in_height * in_depth); |
1979 | 314 |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
315 printf("tdfxfb: screen is %dx%d at %d bpp, in is %dx%d at %d bpp, norm is %dx%d\n", |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
316 screenwidth, screenheight, screendepth * 8, |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
317 in_width, in_height, in_depth * 8, |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
318 d_width, d_height); |
1979 | 319 |
320 return 0; | |
321 } | |
322 | |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
323 /* Double-buffering draw_alpha */ |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
324 static void draw_alpha_double(int x, int y, int w, int h, unsigned char *src, |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
325 unsigned char *srca, int stride) |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
326 { |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
327 char *dst = (char *)vidpage + ((y + vidy) * screenwidth + x + vidx) * screendepth; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
328 alpha_func_double(w, h, src, srca, stride, dst, screenwidth * screendepth); |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
329 } |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
330 |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
331 /* Single-buffering draw_alpha */ |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
332 static void draw_alpha(int x, int y, int w, int h, unsigned char *src, |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
333 unsigned char *srca, int stride) |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
334 { |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
335 char *dst = (char *)inpage + (y * in_width + x) * in_depth; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
336 alpha_func(w, h, src, srca, stride, dst, in_width * in_depth); |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
337 } |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
338 |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
339 static void draw_osd(void) |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
340 { |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
341 if(!vo_doublebuffering) |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
342 vo_draw_text(in_width, in_height, draw_alpha); |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
343 } |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
344 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
345 /* Render onto the screen */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
346 static void flip_page(void) |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
347 { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
348 voodoo_2d_reg regs = *reg_2d; /* Copy the regs */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
349 int i = 0; |
7113
3c84ee5e7da1
clear screen and tiny image bug patch by Burton Samograd <kruhft@kruhft.dyndns.org>
alex
parents:
5607
diff
changeset
|
350 /* This has to be done of else setting dstSize doesn't work */ |
3c84ee5e7da1
clear screen and tiny image bug patch by Burton Samograd <kruhft@kruhft.dyndns.org>
alex
parents:
5607
diff
changeset
|
351 /* Must be a gcc 3.0+ bug */ |
3c84ee5e7da1
clear screen and tiny image bug patch by Burton Samograd <kruhft@kruhft.dyndns.org>
alex
parents:
5607
diff
changeset
|
352 int tempvidheight = vidheight; |
3c84ee5e7da1
clear screen and tiny image bug patch by Burton Samograd <kruhft@kruhft.dyndns.org>
alex
parents:
5607
diff
changeset
|
353 int tempvidwidth = vidwidth; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
354 |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
355 if(vo_doublebuffering) { |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
356 /* Flip to an offscreen buffer for rendering */ |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
357 uint32_t t = vidpageoffset; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
358 void *j = vidpage; |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
359 |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
360 vidpage = hidpage; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
361 hidpage = j; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
362 vidpageoffset = hidpageoffset; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
363 hidpageoffset = t; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
364 } |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
365 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
366 reg_2d->commandExtra = 0; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
367 reg_2d->clip0Min = 0; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
368 reg_2d->clip0Max = 0xffffffff; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
369 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
370 reg_2d->srcBaseAddr = inpageoffset; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
371 reg_2d->srcXY = 0; |
5567 | 372 reg_2d->srcFormat = in_voodoo_format; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
373 reg_2d->srcSize = XYREG(in_width, in_height); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
374 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
375 reg_2d->dstBaseAddr = vidpageoffset; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
376 reg_2d->dstXY = XYREG(vidx, vidy); |
5567 | 377 reg_2d->dstFormat = vid_voodoo_format; |
7113
3c84ee5e7da1
clear screen and tiny image bug patch by Burton Samograd <kruhft@kruhft.dyndns.org>
alex
parents:
5607
diff
changeset
|
378 /* The XYREG macro doesn't seem to work for this line so build the register contents very explicitly */ |
7137
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
379 reg_2d->dstSize = XYREG(vidwidth, vidheight); |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
380 reg_2d->command = S2S_STRECH_BLT | S2S_IMMED | S2S_ROP; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
381 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
382 /* Wait for the command to finish (If we don't do this, we get wierd |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
383 * sound corruption... */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
384 while((reg_IO->status & 0x1f) < 1) |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
385 /* Wait */; |
1979 | 386 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
387 *((volatile uint32_t *)((uint32_t *)reg_IO + COMMAND_3D)) = COMMAND_3D_NOP; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
388 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
389 while(i < 3) |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
390 if(!(reg_IO->status & STATUS_BUSY)) |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
391 i++; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
392 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
393 /* Restore the old regs now */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
394 reg_2d->commandExtra = regs.commandExtra; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
395 reg_2d->clip0Min = regs.clip0Min; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
396 reg_2d->clip0Max = regs.clip0Max; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
397 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
398 reg_2d->srcBaseAddr = regs.srcBaseAddr; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
399 reg_2d->srcXY = regs.srcXY; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
400 reg_2d->srcFormat = regs.srcFormat; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
401 reg_2d->srcSize = regs.srcSize; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
402 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
403 reg_2d->dstBaseAddr = regs.dstBaseAddr; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
404 reg_2d->dstXY = regs.dstXY; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
405 reg_2d->dstFormat = regs.dstFormat; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
406 reg_2d->dstSize = regs.dstSize; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
407 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
408 reg_2d->command = 0; |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
409 |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
410 /* Render any text onto this buffer */ |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
411 if(vo_doublebuffering) |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
412 vo_draw_text(vidwidth, vidheight, draw_alpha_double); |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
413 |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
414 /* And flip to the new buffer! */ |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
415 reg_IO->vidDesktopStartAddr = vidpageoffset; |
1979 | 416 } |
417 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
418 static uint32_t draw_frame(uint8_t *src[]) |
1979 | 419 { |
5567 | 420 mem2agpcpy(inpage, src[0], in_width * in_depth * in_height); |
1979 | 421 return 0; |
422 } | |
423 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
424 static uint32_t draw_slice(uint8_t *i[], int s[], int w, int h, int x, int y) |
1979 | 425 { |
5567 | 426 /* We want to render to the YUV to the input page + the location |
427 * of the stripes we're doing */ | |
428 reg_YUV->yuvBaseAddr = inpageoffset + in_width * in_depth * y + x; | |
429 reg_YUV->yuvStride = in_width * in_depth; | |
1979 | 430 |
5567 | 431 /* Put the YUV channels into the voodoos internal combiner unit |
432 * thingie */ | |
433 mem2agpcpy_pic(YUV->Y, i[0], s[0], h , YUV_STRIDE, s[0]); | |
434 mem2agpcpy_pic(YUV->U, i[1], s[1], h / 2, YUV_STRIDE, s[1]); | |
435 mem2agpcpy_pic(YUV->V, i[2], s[2], h / 2, YUV_STRIDE, s[2]); | |
1979 | 436 return 0; |
437 } | |
438 | |
5590 | 439 /* Attempt to start doing DR */ |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
440 static uint32_t get_image(mp_image_t *mpi) |
1979 | 441 { |
2350 | 442 |
7708 | 443 if(mpi->flags & MP_IMGFLAG_READABLE) |
444 return VO_FALSE; | |
445 if(mpi->type == MP_IMGTYPE_STATIC && vo_doublebuffering) | |
446 return VO_FALSE; | |
447 if(mpi->type > MP_IMGTYPE_TEMP) | |
448 return VO_FALSE; // TODO ?? | |
2350 | 449 |
5567 | 450 switch(in_format) { |
451 case IMGFMT_YUY2: | |
452 case IMGFMT_BGR16: | |
453 case IMGFMT_BGR24: | |
454 case IMGFMT_BGR32: | |
7708 | 455 case IMGFMT_UYVY: |
5567 | 456 mpi->planes[0] = (char *)inpage; |
457 mpi->stride[0] = in_width * in_depth; | |
458 break; | |
459 | |
460 case IMGFMT_YV12: | |
461 case IMGFMT_I420: | |
462 case IMGFMT_IYUV: | |
7708 | 463 if(!(mpi->flags & MP_IMGFLAG_ACCEPT_STRIDE) && mpi->w != YUV_STRIDE) |
464 return VO_FALSE; | |
5567 | 465 mpi->planes[0] = YUV->Y; |
466 mpi->planes[1] = YUV->U; | |
467 mpi->planes[2] = YUV->V; | |
468 mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = YUV_STRIDE; | |
7708 | 469 reg_YUV->yuvBaseAddr = inpageoffset; |
470 reg_YUV->yuvStride = in_width * in_depth; | |
5567 | 471 break; |
2350 | 472 |
5567 | 473 default: |
474 return VO_FALSE; | |
475 } | |
476 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
477 mpi->width = in_width; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
478 mpi->flags |= MP_IMGFLAG_DIRECT; |
1979 | 479 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
480 return VO_TRUE; |
4352 | 481 } |
1979 | 482 |
4596 | 483 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 484 { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
485 switch(request) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
486 case VOCTRL_GET_IMAGE: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
487 return get_image(data); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
488 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
489 case VOCTRL_QUERY_FORMAT: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
490 switch(*((uint32_t*)data)) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
491 case IMGFMT_YV12: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
492 case IMGFMT_I420: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
493 case IMGFMT_IYUV: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
494 case IMGFMT_YUY2: |
7708 | 495 case IMGFMT_UYVY: |
5567 | 496 case IMGFMT_BGR16: |
497 case IMGFMT_BGR24: | |
498 case IMGFMT_BGR32: | |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
499 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
500 VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
501 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
502 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
503 return 0; /* Not supported */ |
5567 | 504 |
505 case VOCTRL_FULLSCREEN: | |
7708 | 506 setup_screen(!vo_fs); |
5590 | 507 return 0; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
508 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
509 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
510 return VO_NOTIMPL; |
4352 | 511 } |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
512 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
513 /* Dummy funcs */ |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
514 static void check_events(void) {} |
5567 | 515 static const vo_info_t* get_info(void) { return &vo_info; } |