Mercurial > mplayer.hg
annotate libvo/vo_tdfxfb.c @ 7854:d6c29d863f15
dvd chapter detect function from Gregory Kovriga
author | pontscho |
---|---|
date | Tue, 22 Oct 2002 22:45:30 +0000 |
parents | c1e8287f9574 |
children | 732a8bfc7681 |
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. |
1979 | 18 * |
5567 | 19 * Hints and tricks: |
20 * - Use -dr to get direct rendering | |
21 * - 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
|
22 * - 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
|
23 * - 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
|
24 * - The driver supports both scaling and shrinking the image using the -x and |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
25 * -y options on the mplayer commandline. |
1979 | 26 */ |
27 | |
28 #include <stdio.h> | |
29 #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
|
30 #include <errno.h> |
7708 | 31 #include <string.h> |
32 #include <unistd.h> | |
5567 | 33 #include <sys/ioctl.h> |
34 #include <fcntl.h> | |
35 #include <sys/mman.h> | |
36 #include <linux/fb.h> | |
1979 | 37 |
38 #include "config.h" | |
5567 | 39 #include "fastmemcpy.h" |
1979 | 40 #include "video_out.h" |
41 #include "video_out_internal.h" | |
5567 | 42 #include "drivers/3dfx.h" |
7708 | 43 #include "aspect.h" |
1979 | 44 |
45 LIBVO_EXTERN(tdfxfb) | |
46 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
47 static vo_info_t vo_info = |
1979 | 48 { |
5567 | 49 "3Dfx Banshee/Voodoo3/Voodoo5", |
1979 | 50 "tdfxfb", |
7708 | 51 "Mark Zealey <mark@zealos.org>", |
1979 | 52 "" |
53 }; | |
54 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
55 /* Some registers on the card */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
56 #define S2S_STRECH_BLT 2 // BLT + Strech |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
57 #define S2S_IMMED (1 << 8) // Do it immediatly |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
58 #define S2S_ROP (0xCC << 24) // ??? |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
59 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
60 /* Stepping between the different YUV plane registers */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
61 #define YUV_STRIDE 1024 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
62 struct YUV_plane { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
63 char Y[0x0100000]; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
64 char U[0x0100000]; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
65 char V[0x0100000]; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
66 }; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
67 |
7708 | 68 static int fd = -1; |
1979 | 69 static struct fb_fix_screeninfo fb_finfo; |
70 static struct fb_var_screeninfo fb_vinfo; | |
5567 | 71 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
|
72 screenwidth, screenheight, screendepth, vidwidth, vidheight, vidx, vidy, |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
73 vid_voodoo_format, *vidpage, *hidpage, *inpage, vidpageoffset, |
7708 | 74 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
|
75 static volatile voodoo_io_reg *reg_IO; |
1979 | 76 static voodoo_2d_reg *reg_2d; |
77 static voodoo_yuv_reg *reg_YUV; | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
78 static struct YUV_plane *YUV; |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
79 static void (*alpha_func)(), (*alpha_func_double)(); |
1979 | 80 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
81 static uint32_t preinit(const char *arg) |
1979 | 82 { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
83 char *name; |
1979 | 84 |
7708 | 85 if(arg) |
86 name = (char*)arg; | |
87 else if(!(name = getenv("FRAMEBUFFER"))) | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
88 name = "/dev/fb0"; |
1979 | 89 |
5567 | 90 if((fd = open(name, O_RDWR)) == -1) { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
91 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
|
92 return -1; |
1979 | 93 } |
94 | |
5567 | 95 if(ioctl(fd, FBIOGET_FSCREENINFO, &fb_finfo)) { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
96 printf("tdfxfb: problem with FBITGET_FSCREENINFO ioctl: %s\n", |
1979 | 97 strerror(errno)); |
7708 | 98 close(fd); |
99 fd = -1; | |
1979 | 100 return -1; |
101 } | |
102 | |
5567 | 103 if(ioctl(fd, FBIOGET_VSCREENINFO, &fb_vinfo)) { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
104 printf("tdfxfb: problem with FBITGET_VSCREENINFO ioctl: %s\n", |
1979 | 105 strerror(errno)); |
7708 | 106 close(fd); |
107 fd = -1; | |
1979 | 108 return -1; |
109 } | |
110 | |
5567 | 111 /* BANSHEE means any of the series aparently */ |
112 if (fb_finfo.accel != FB_ACCEL_3DFX_BANSHEE) { | |
113 printf("tdfxfb: This driver is only supports the 3Dfx Banshee," | |
114 " Voodoo3 and Voodoo 5\n"); | |
7708 | 115 close(fd); |
116 fd = -1; | |
5567 | 117 return -1; |
1979 | 118 } |
119 | |
7708 | 120 // Check the depth now as config() musn't fail |
121 switch(fb_vinfo.bits_per_pixel) { | |
122 case 16: | |
123 case 24: | |
124 case 32: | |
125 break; // Ok | |
126 default: | |
127 printf("tdfxfb: %d bpp output is not supported\n", fb_vinfo.bits_per_pixel); | |
128 close(fd); | |
129 fd = -1; | |
130 return -1; | |
131 } | |
132 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
133 /* Open up a window to the hardware */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
134 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
|
135 MAP_SHARED, fd, 0); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
136 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
|
137 MAP_SHARED, fd, fb_finfo.smem_len); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
138 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
139 if((long)memBase0 == -1 || (long)memBase1 == -1) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
140 printf("tdfxfb: Couldn't map memory areas: %s\n", strerror(errno)); |
7708 | 141 if((long)memBase0 != -1) |
142 munmap(memBase0, fb_finfo.smem_len); | |
143 if((long)memBase1 != -1) | |
144 munmap(memBase1, fb_finfo.smem_len); | |
145 memBase0 = memBase1 = NULL; | |
1979 | 146 return -1; |
147 } | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
148 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
149 /* Set up global pointers to the voodoo's regs */ |
5567 | 150 reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET; |
151 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
|
152 reg_YUV = (void *)memBase0 + VOODOO_YUV_REG_OFFSET; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
153 YUV = (void *)memBase0 + VOODOO_YUV_PLANE_OFFSET; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
154 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
155 return 0; |
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 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
158 static void uninit(void) |
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 if(reg_IO) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
161 /* Restore the screen (Linux lives at 0) */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
162 reg_IO->vidDesktopStartAddr = 0; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
163 reg_IO = NULL; |
1979 | 164 } |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
165 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
166 /* And close our mess */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
167 if(memBase1) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
168 munmap(memBase1, fb_finfo.smem_len); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
169 memBase1 = NULL; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
170 } |
1979 | 171 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
172 if(memBase0) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
173 munmap(memBase0, fb_finfo.mmio_len); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
174 memBase0 = NULL; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
175 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
176 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
177 if(fd != -1) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
178 close(fd); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
179 fd = -1; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
180 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
181 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
182 |
5567 | 183 static void clear_screen() |
184 { | |
7137
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
185 /* 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
|
186 * 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
|
187 * 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
|
188 * 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
|
189 * the card. |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
190 */ |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
191 if(vo_doublebuffering) { |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
192 /* 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
|
193 * every time - alex */ |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
194 do {} while((reg_IO->status & 0x1f) < 1); |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
195 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
|
196 memset(hidpage, 0, screenwidth * screenheight * screendepth); |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
197 } |
5567 | 198 } |
199 | |
200 /* Setup output screen dimensions etc */ | |
5590 | 201 static void setup_screen(uint32_t full) |
5567 | 202 { |
7708 | 203 vo_fs = full; |
7137
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
204 |
7708 | 205 aspect(&vidwidth,&vidheight, vo_fs ? A_ZOOM : A_NOZOOM); |
206 if(vo_fs) { | |
207 vidx = (screenwidth - vidwidth) / 2; | |
208 vidy = (screenheight - vidheight) / 2; | |
209 } else | |
210 vidx = vidy = 0; | |
7137
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
211 |
5567 | 212 clear_screen(); |
213 } | |
214 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
215 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
|
216 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
|
217 { |
1979 | 218 screenwidth = fb_vinfo.xres; |
219 screenheight = fb_vinfo.yres; | |
7708 | 220 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
|
221 |
1979 | 222 in_width = width; |
223 in_height = height; | |
224 in_format = format; | |
7708 | 225 aspect_save_orig(width,height); |
1979 | 226 |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
227 r_width = d_width; |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
228 r_height = d_height; |
7708 | 229 aspect_save_prescale(d_width,d_height); |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
230 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
231 /* Setup the screen for rendering to */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
232 switch(fb_vinfo.bits_per_pixel) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
233 case 16: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
234 screendepth = 2; |
5567 | 235 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
|
236 alpha_func_double = vo_draw_alpha_rgb16; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
237 break; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
238 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
239 case 24: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
240 screendepth = 3; |
5567 | 241 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
|
242 alpha_func_double = vo_draw_alpha_rgb24; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
243 break; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
244 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
245 case 32: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
246 screendepth = 4; |
5567 | 247 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
|
248 alpha_func_double = vo_draw_alpha_rgb32; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
249 break; |
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 default: |
7708 | 252 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
|
253 return -1; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
254 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
255 |
5567 | 256 vid_voodoo_format |= screenwidth * screendepth; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
257 |
5567 | 258 /* Some defaults here */ |
259 in_voodoo_format = VOODOO_BLT_FORMAT_YUYV; | |
260 in_depth = 2; | |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
261 alpha_func = vo_draw_alpha_yuy2; |
5567 | 262 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
263 switch(in_format) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
264 case IMGFMT_YV12: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
265 case IMGFMT_I420: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
266 case IMGFMT_IYUV: |
5567 | 267 case IMGFMT_YUY2: |
268 break; | |
7708 | 269 case IMGFMT_UYVY: |
270 in_voodoo_format = VOODOO_BLT_FORMAT_UYVY; | |
271 break; | |
5567 | 272 case IMGFMT_BGR16: |
273 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
|
274 alpha_func = vo_draw_alpha_rgb16; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
275 break; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
276 |
5567 | 277 case IMGFMT_BGR24: |
278 in_depth = 3; | |
279 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
|
280 alpha_func = vo_draw_alpha_rgb24; |
5567 | 281 break; |
282 | |
283 case IMGFMT_BGR32: | |
284 in_depth = 4; | |
285 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
|
286 alpha_func = vo_draw_alpha_rgb32; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
287 break; |
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 default: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
290 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
|
291 return -1; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
292 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
293 |
5567 | 294 in_voodoo_format |= in_width * in_depth; |
1979 | 295 |
7137
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
296 /* Linux lives in the first frame */ |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
297 if(vo_doublebuffering) { |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
298 vidpageoffset = screenwidth * screenheight * screendepth; |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
299 hidpageoffset = vidpageoffset + screenwidth * screenheight * screendepth; |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
300 } else |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
301 vidpageoffset = hidpageoffset = 0; /* Console background */ |
9a44c38d388c
Fixed some breakages of single-buffer rendering of tdfx
mark
parents:
7124
diff
changeset
|
302 |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
303 |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
304 inpageoffset = hidpageoffset + screenwidth * screenheight * screendepth; |
1979 | 305 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
306 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
|
307 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
|
308 return -1; |
1979 | 309 } |
310 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
311 vidpage = (void *)memBase1 + (unsigned long)vidpageoffset; |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
312 hidpage = (void *)memBase1 + (unsigned long)hidpageoffset; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
313 inpage = (void *)memBase1 + (unsigned long)inpageoffset; |
1979 | 314 |
5590 | 315 setup_screen(flags & VOFLAG_FULLSCREEN); |
5567 | 316 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
317 memset(inpage, 0, in_width * in_height * in_depth); |
1979 | 318 |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
319 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
|
320 screenwidth, screenheight, screendepth * 8, |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
321 in_width, in_height, in_depth * 8, |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
322 d_width, d_height); |
1979 | 323 |
324 return 0; | |
325 } | |
326 | |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
327 /* Double-buffering draw_alpha */ |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
328 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
|
329 unsigned char *srca, int stride) |
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 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
|
332 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
|
333 } |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
334 |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
335 /* Single-buffering draw_alpha */ |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
336 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
|
337 unsigned char *srca, int stride) |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
338 { |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
339 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
|
340 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
|
341 } |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
342 |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
343 static void draw_osd(void) |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
344 { |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
345 if(!vo_doublebuffering) |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
346 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
|
347 } |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
348 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
349 /* Render onto the screen */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
350 static void flip_page(void) |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
351 { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
352 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
|
353 int i = 0; |
7113
3c84ee5e7da1
clear screen and tiny image bug patch by Burton Samograd <kruhft@kruhft.dyndns.org>
alex
parents:
5607
diff
changeset
|
354 /* 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
|
355 /* 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
|
356 int tempvidheight = vidheight; |
3c84ee5e7da1
clear screen and tiny image bug patch by Burton Samograd <kruhft@kruhft.dyndns.org>
alex
parents:
5607
diff
changeset
|
357 int tempvidwidth = vidwidth; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
358 |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
359 if(vo_doublebuffering) { |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
360 /* 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
|
361 uint32_t t = vidpageoffset; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
362 void *j = vidpage; |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
363 |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
364 vidpage = hidpage; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
365 hidpage = j; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
366 vidpageoffset = hidpageoffset; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
367 hidpageoffset = t; |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
368 } |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
369 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
370 reg_2d->commandExtra = 0; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
371 reg_2d->clip0Min = 0; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
372 reg_2d->clip0Max = 0xffffffff; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
373 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
374 reg_2d->srcBaseAddr = inpageoffset; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
375 reg_2d->srcXY = 0; |
5567 | 376 reg_2d->srcFormat = in_voodoo_format; |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
377 reg_2d->srcSize = XYREG(in_width, in_height); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
378 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
379 reg_2d->dstBaseAddr = vidpageoffset; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
380 reg_2d->dstXY = XYREG(vidx, vidy); |
5567 | 381 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
|
382 /* 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
|
383 reg_2d->dstSize = XYREG(vidwidth, vidheight); |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
384 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
|
385 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
386 /* 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
|
387 * sound corruption... */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
388 while((reg_IO->status & 0x1f) < 1) |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
389 /* Wait */; |
1979 | 390 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
391 *((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
|
392 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
393 while(i < 3) |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
394 if(!(reg_IO->status & STATUS_BUSY)) |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
395 i++; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
396 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
397 /* Restore the old regs now */ |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
398 reg_2d->commandExtra = regs.commandExtra; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
399 reg_2d->clip0Min = regs.clip0Min; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
400 reg_2d->clip0Max = regs.clip0Max; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
401 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
402 reg_2d->srcBaseAddr = regs.srcBaseAddr; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
403 reg_2d->srcXY = regs.srcXY; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
404 reg_2d->srcFormat = regs.srcFormat; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
405 reg_2d->srcSize = regs.srcSize; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
406 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
407 reg_2d->dstBaseAddr = regs.dstBaseAddr; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
408 reg_2d->dstXY = regs.dstXY; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
409 reg_2d->dstFormat = regs.dstFormat; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
410 reg_2d->dstSize = regs.dstSize; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
411 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
412 reg_2d->command = 0; |
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 /* 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
|
415 if(vo_doublebuffering) |
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
416 vo_draw_text(vidwidth, vidheight, draw_alpha_double); |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
417 |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
418 /* And flip to the new buffer! */ |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
419 reg_IO->vidDesktopStartAddr = vidpageoffset; |
1979 | 420 } |
421 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
422 static uint32_t draw_frame(uint8_t *src[]) |
1979 | 423 { |
5567 | 424 mem2agpcpy(inpage, src[0], in_width * in_depth * in_height); |
1979 | 425 return 0; |
426 } | |
427 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
428 static uint32_t draw_slice(uint8_t *i[], int s[], int w, int h, int x, int y) |
1979 | 429 { |
5567 | 430 /* We want to render to the YUV to the input page + the location |
431 * of the stripes we're doing */ | |
432 reg_YUV->yuvBaseAddr = inpageoffset + in_width * in_depth * y + x; | |
433 reg_YUV->yuvStride = in_width * in_depth; | |
1979 | 434 |
5567 | 435 /* Put the YUV channels into the voodoos internal combiner unit |
436 * thingie */ | |
437 mem2agpcpy_pic(YUV->Y, i[0], s[0], h , YUV_STRIDE, s[0]); | |
438 mem2agpcpy_pic(YUV->U, i[1], s[1], h / 2, YUV_STRIDE, s[1]); | |
439 mem2agpcpy_pic(YUV->V, i[2], s[2], h / 2, YUV_STRIDE, s[2]); | |
1979 | 440 return 0; |
441 } | |
442 | |
5590 | 443 /* Attempt to start doing DR */ |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
444 static uint32_t get_image(mp_image_t *mpi) |
1979 | 445 { |
2350 | 446 |
7708 | 447 if(mpi->flags & MP_IMGFLAG_READABLE) |
448 return VO_FALSE; | |
449 if(mpi->type == MP_IMGTYPE_STATIC && vo_doublebuffering) | |
450 return VO_FALSE; | |
451 if(mpi->type > MP_IMGTYPE_TEMP) | |
452 return VO_FALSE; // TODO ?? | |
2350 | 453 |
5567 | 454 switch(in_format) { |
455 case IMGFMT_YUY2: | |
456 case IMGFMT_BGR16: | |
457 case IMGFMT_BGR24: | |
458 case IMGFMT_BGR32: | |
7708 | 459 case IMGFMT_UYVY: |
5567 | 460 mpi->planes[0] = (char *)inpage; |
461 mpi->stride[0] = in_width * in_depth; | |
462 break; | |
463 | |
464 case IMGFMT_YV12: | |
465 case IMGFMT_I420: | |
466 case IMGFMT_IYUV: | |
7708 | 467 if(!(mpi->flags & MP_IMGFLAG_ACCEPT_STRIDE) && mpi->w != YUV_STRIDE) |
468 return VO_FALSE; | |
5567 | 469 mpi->planes[0] = YUV->Y; |
470 mpi->planes[1] = YUV->U; | |
471 mpi->planes[2] = YUV->V; | |
472 mpi->stride[0] = mpi->stride[1] = mpi->stride[2] = YUV_STRIDE; | |
7708 | 473 reg_YUV->yuvBaseAddr = inpageoffset; |
474 reg_YUV->yuvStride = in_width * in_depth; | |
5567 | 475 break; |
2350 | 476 |
5567 | 477 default: |
478 return VO_FALSE; | |
479 } | |
480 | |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
481 mpi->width = in_width; |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
482 mpi->flags |= MP_IMGFLAG_DIRECT; |
1979 | 483 |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
484 return VO_TRUE; |
4352 | 485 } |
1979 | 486 |
4596 | 487 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 488 { |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
489 switch(request) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
490 case VOCTRL_GET_IMAGE: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
491 return get_image(data); |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
492 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
493 case VOCTRL_QUERY_FORMAT: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
494 switch(*((uint32_t*)data)) { |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
495 case IMGFMT_YV12: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
496 case IMGFMT_I420: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
497 case IMGFMT_IYUV: |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
498 case IMGFMT_YUY2: |
7708 | 499 case IMGFMT_UYVY: |
5567 | 500 case IMGFMT_BGR16: |
501 case IMGFMT_BGR24: | |
502 case IMGFMT_BGR32: | |
5579
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
503 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | |
2250b6ad5ad9
Some OSD and other random fixes. Added double buffering
mark
parents:
5567
diff
changeset
|
504 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
|
505 } |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
506 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
507 return 0; /* Not supported */ |
5567 | 508 |
509 case VOCTRL_FULLSCREEN: | |
7708 | 510 setup_screen(!vo_fs); |
5590 | 511 return 0; |
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 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
514 return VO_NOTIMPL; |
4352 | 515 } |
5540
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
516 |
80d8fed6e683
new tdfxfb yuv driver by Mark Zealey <mark@zealos.org>
arpi
parents:
4737
diff
changeset
|
517 /* Dummy funcs */ |
5580
6366586083bb
Added support for choosing weather to use double-buffering or single buffering
mark
parents:
5579
diff
changeset
|
518 static void check_events(void) {} |
5567 | 519 static const vo_info_t* get_info(void) { return &vo_info; } |