annotate libvo/vo_tdfxfb.c @ 2216:9da2a0515184

software yv12->rgb scaler - separated from fsdga
author arpi
date Mon, 15 Oct 2001 18:59:44 +0000
parents 6278f566cd91
children d3a67a417352
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
1
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
2 /*
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
3 * video_out_tdfxfb.c
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
4 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
5 * Copyright (C) Zeljko Stevanovic 2001, <zsteva@ptt.yu>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
6 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
7 * Most code rewrited, move from /dev/3dfx to /dev/fb0 (kernel 2.4.?)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
8 * add support for YUY2 and BGR16 format, remove all X11 DGA code.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
9 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
10 * Copyright (C) Colin Cross Apr 2000
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
11 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
12 * This file heavily based off of video_out_mga.c of Aaron Holtzman's
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
13 * mpeg2dec
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
14 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
15 * mpeg2dec is free software; you can redistribute it and/or modify
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
16 * it under the terms of the GNU General Public License as published by
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
17 * the Free Software Foundation; either version 2, or (at your option)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
18 * any later version.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
19 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
20 * mpeg2dec is distributed in the hope that it will be useful,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
23 * GNU General Public License for more details.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
24 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
25 * You should have received a copy of the GNU General Public License
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
26 * along with GNU Make; see the file COPYING. If not, write to
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
27 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
28 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
29 */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
30
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
31 #include <stdio.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
32 #include <stdlib.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
33 #include <string.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
34
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
35 #include "config.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
36 #include "video_out.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
37 #include "video_out_internal.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
38
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
39 LIBVO_EXTERN(tdfxfb)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
40
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
41 #include <sys/ioctl.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
42 #include <unistd.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
43 #include <fcntl.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
44 #include <sys/mman.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
45 #include <errno.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
46 #include <wchar.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
47 #include <signal.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
48
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
49 #include <linux/fb.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
50
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
51 extern int verbose;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
52
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
53 //#define LOG(x) syslog(LOG_USER | LOG_DEBUG,x)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
54 #define LOG(x)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
55
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
56 #include "drivers/3dfx.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
57
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
58 #include "fastmemcpy.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
59
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
60 static vo_info_t vo_info =
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
61 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
62 "tdfxfb (/dev/fb?)",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
63 "tdfxfb",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
64 "Zeljko Stevanovic <zsteva@ptt.yu>, bassed on vo_3dfx of Colin Cross <colin@MIT.EDU>",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
65 ""
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
66 };
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
67
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
68 static char *fb_devname = NULL;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
69 static int fb_fd = -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
70 static struct fb_fix_screeninfo fb_finfo;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
71 static struct fb_var_screeninfo fb_vinfo;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
72
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
73 static uint32_t in_width;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
74 static uint32_t in_height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
75 static uint32_t in_format;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
76 static uint32_t in_bytepp;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
77
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
78 static uint32_t in_banshee_format,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
79 in_banshee_size;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
80
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
81 static uint32_t screenwidth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
82 static uint32_t screenheight;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
83 static uint32_t screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
84 static uint32_t vidwidth, vidheight; // resize on screen to ... for ration expect...
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
85 static uint32_t vidx=0, vidy=0; // for centring on screen.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
86
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
87 static uint32_t vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
88 vid_banshee_format,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
89 vid_banshee_size;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
90
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
91 static void (*draw_alpha_p)(int w, int h, unsigned char *src,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
92 unsigned char *srca, int stride, unsigned char *dst,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
93 int dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
94
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
95 static uint32_t *vidpage0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
96 static uint32_t *vidpage1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
97 static uint32_t *osd_page;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
98 static uint32_t *in_page0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
99
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
100 static uint32_t vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
101 static uint32_t vidpage1offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
102 static uint32_t osd_page_offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
103 static uint32_t in_page0_offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
104
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
105 // Current pointer into framebuffer where display is located
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
106 static uint32_t targetoffset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
107
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
108 static uint32_t page_space;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
109
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
110 static uint32_t *tdfx_iobase;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
111
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
112 static voodoo_io_reg *reg_IO;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
113 static voodoo_2d_reg *reg_2d;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
114 static voodoo_yuv_reg *reg_YUV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
115 static voodoo_yuv_fb *fb_YUV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
116
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
117 static uint32_t *memBase0, *memBase1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
118 //static uint32_t baseAddr0, baseAddr1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
119
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
120 //#define BANSHEE_SCREEN_MEMORY (8*1024*1024)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
121 //static uint32_t tdfx_free_scrmem = 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
122
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
123 /*- ----------------------------------------------------------------- -*/
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
124
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
125 /* code get from linux kernel tdfxfb.c by Hannu Mallat */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
126
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
127 typedef uint32_t u32;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
128
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
129 static inline u32 tdfx_inl(unsigned int reg) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
130 return *((volatile uint32_t *)(tdfx_iobase + reg));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
131 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
132
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
133 static inline void tdfx_outl(unsigned int reg, u32 val) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
134 *((volatile uint32_t *)(tdfx_iobase + reg)) = val;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
135 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
136
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
137 static inline void banshee_make_room(int size) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
138 while((tdfx_inl(STATUS) & 0x1f) < size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
139 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
140
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
141 static inline void banshee_wait_idle(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
142 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
143 int i = 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
144
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
145 banshee_make_room(1);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
146 tdfx_outl(COMMAND_3D, COMMAND_3D_NOP);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
147
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
148 while(1) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
149 i = (tdfx_inl(STATUS) & STATUS_BUSY) ? 0 : i + 1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
150 if(i == 3) break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
151 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
152 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
153
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
154
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
155 /*- ----------------------------------------------------------------- -*/
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
156
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
157 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
158 restore_regs(voodoo_2d_reg *regs)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
159 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
160 reg_2d->commandExtra = regs->commandExtra;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
161 reg_2d->clip0Min = regs->clip0Min;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
162 reg_2d->clip0Max = regs->clip0Max;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
163
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
164 reg_2d->srcBaseAddr = regs->srcBaseAddr;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
165 reg_2d->srcXY = regs->srcXY;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
166 reg_2d->srcFormat = regs->srcFormat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
167 reg_2d->srcSize = regs->srcSize;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
168
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
169 reg_2d->dstBaseAddr = regs->dstBaseAddr;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
170 reg_2d->dstXY = regs->dstXY;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
171 reg_2d->dstFormat = regs->dstFormat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
172
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
173 reg_2d->dstSize = regs->dstSize;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
174 reg_2d->command = 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
175 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
176
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
177
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
178 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
179 restore(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
180 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
181 //reg_IO->vidDesktopStartAddr = vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
182 //XF86DGADirectVideo(display,0,0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
183 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
184
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
185 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
186 sighup(int foo)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
187 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
188 //reg_IO->vidDesktopStartAddr = vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
189 //XF86DGADirectVideo(display,0,0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
190 exit(0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
191 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
192
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
193 #if 1
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
194 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
195 dump_yuv_planar(void *y, void *u, void *v,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
196 uint32_t to, uint32_t px, uint32_t py, uint32_t width, uint32_t height)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
197 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
198 // YUV conversion works like this:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
199 //
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
200 // We write the Y, U, and V planes separately into 3dfx YUV Planar memory
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
201 // region. The nice chip then takes these and packs them into the YUYV
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
202 // format in the regular frame buffer, starting at yuvBaseAddr, page 2 here.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
203 // Then we tell the 3dfx to do a Screen to Screen Stretch BLT to copy all
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
204 // of the data on page 2 onto page 1, converting it to 16 bpp RGB as
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
205 // it goes. The result is a nice image on page 1 ready for display.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
206
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
207 uint32_t j;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
208 uint32_t y_imax, uv_imax, jmax;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
209
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
210
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
211 //printf("dump_yuv_planar(..., px=%d, py=%d, w=%d, h=%d\n",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
212 // px, py, width, height);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
213
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
214 reg_YUV->yuvBaseAddr = to + in_width * 2 * py;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
215 reg_YUV->yuvStride = width*2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
216
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
217 jmax = height >> 1; // vidheight/2, height of U and V planes
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
218 y_imax = width; // Y plane is twice as wide as U and V planes
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
219 uv_imax = width >> 1; // in_width/2/4, width of U and V planes in 32-bit words
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
220
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
221 for (j = 0; j < jmax; j++)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
222 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
223 #if 0
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
224 //XXX this should be hand-rolled 32 bit memcpy for safeness.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
225 memcpy(fb_YUV->U (uint32_t) VOODOO_YUV_STRIDE * j,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
226 ((uint8_t*)u) + uv_imax * j , uv_imax);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
227
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
228 memcpy(fb_YUV->V + (uint32_t) VOODOO_YUV_STRIDE * j,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
229 ((uint8_t*)v) + uv_imax * j , uv_imax);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
230
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
231 memcpy(fb_YUV->Y + (uint32_t) VOODOO_YUV_STRIDE* (j<<1),
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
232 ((uint8_t*)y) + y_imax * (j<<1) , y_imax);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
233 memcpy(fb_YUV->Y + (uint32_t) VOODOO_YUV_STRIDE*((j<<1)+1),
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
234 ((uint8_t*)y) + y_imax *((j<<1)+1), y_imax);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
235 #else
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
236 memcpy(&fb_YUV->U[VOODOO_YUV_STRIDE * j], u + uv_imax * j , uv_imax);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
237 memcpy(&fb_YUV->V[VOODOO_YUV_STRIDE * j], v + uv_imax * j , uv_imax);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
238
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
239
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
240 memcpy(&fb_YUV->Y[VOODOO_YUV_STRIDE* (j<<1)], y + y_imax * (j<<1) , y_imax);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
241 memcpy(&fb_YUV->Y[VOODOO_YUV_STRIDE*((j<<1)+1)], y + y_imax *((j<<1)+1), y_imax);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
242 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
243 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
244 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
245 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
246
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
247 #define S2S_BLT(cmd, to, dXY, dFmt, dSize, from, sXY, sFmt, sSize) \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
248 do { \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
249 voodoo_2d_reg saved_regs = *reg_2d; \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
250 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
251 reg_2d->commandExtra = 0; \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
252 reg_2d->clip0Min = 0; \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
253 reg_2d->clip0Max = 0xffffffff; \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
254 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
255 reg_2d->srcBaseAddr = (from); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
256 reg_2d->srcXY = (sXY); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
257 reg_2d->srcFormat = (sFmt); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
258 reg_2d->srcSize = (sSize); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
259 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
260 reg_2d->dstBaseAddr = (to); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
261 reg_2d->dstXY = (dXY); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
262 reg_2d->dstFormat = (dFmt); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
263 reg_2d->dstSize = (dSize); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
264 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
265 reg_2d->command = (cmd); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
266 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
267 restore_regs(&saved_regs); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
268 } while (0)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
269
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
270
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
271 #define VOODOO_BLT_FORMAT_24 (4 << 16)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
272
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
273 /*- ----------------------------------------------------------------- -*/
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
274
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
275 static uint32_t draw_slice_YV12(uint8_t *image[], int stride[], int w,int h,int x,int y);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
276 static uint32_t draw_frame_YV12(uint8_t *src[]);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
277 static void flip_page_YV12(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
278 static void draw_osd_YV12(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
279
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
280 static uint32_t draw_slice_YUY2_BGR16(uint8_t *image[], int stride[], int w,int h,int x,int y);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
281 static uint32_t draw_frame_YUY2_BGR16(uint8_t *src[]);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
282 static void flip_page_YUY2_BGR16(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
283 static void draw_osd_YUY2_BGR16(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
284
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
285 #if 0
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
286 static uint32_t draw_frame_YUY2_2(uint8_t *src[]);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
287 static uint32_t draw_slice_YUY2(uint8_t *image[], int stride[], int w,int h,int x,int y);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
288 static void flip_page_all(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
289 static void flip_page_YUY2(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
290 static void flip_page_YUY2_2(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
291 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
292
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
293 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
294 unsigned char *srca, int stride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
295
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
296 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
297 update_target(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
298 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
299 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
300
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
301 #ifndef VO_3DFX_METHOD
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
302 #define VO_3DFX_METHOD 1
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
303 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
304
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
305
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
306 #if VO_3DFX_METHOD == 2
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
307 extern void **our_out_buffer;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
308 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
309
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
310 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
311 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
312 uint32_t fullscreen, char *title, uint32_t format)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
313 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
314
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
315 if (!fullscreen) return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
316 if (1 || verbose) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
317 printf("vo_3dfx->init( width = %d, height = %d, "
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
318 "d_width = %d, d_height = %d, format = %d)\n",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
319 width, height, d_width, d_height, format);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
320 printf("vo_3dfx->init( format => %s )\n", vo_format_name(format));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
321 printf("vo_3dfx: vo_depthonscreen => %d, vo_screenwidth => %d, "
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
322 "vo_screenhight => %d\n", vo_depthonscreen, vo_screenwidth, vo_screenheight);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
323 printf("vo_3dfx->init() vo_dwidth => %d, vo_dheight => %d, vo_dbpp => %d\n",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
324 vo_dwidth, vo_dheight, vo_dbpp);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
325 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
326
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
327 if (!fb_devname && !(fb_devname = getenv("FRAMEBUFFER")))
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
328 fb_devname = "/dev/fb0";
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
329
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
330 if (1 || verbose)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
331 printf("vo_3dfx->init(): fbdev ==> %s\n", fb_devname);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
332
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
333 if ((fb_fd = open(fb_devname, O_RDWR)) == -1) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
334 printf("vo_3dfx->init(): can't open %s, %s\n", fb_devname, strerror(errno));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
335 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
336 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
337
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
338 if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
339 printf("vo_3dfx->init(): problem with ioctl(fb_fd, FBITGET_FSCREENINFO.., %s\n",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
340 strerror(errno));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
341 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
342 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
343
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
344 if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
345 printf("vo_3dfx->init(): problem with ioctl(fb_fd, FBITGET_VSCREENINFO.., %s\n",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
346 strerror(errno));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
347 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
348 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
349
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
350 if (verbose) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
351 printf("fb_finfo:\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
352 printf(" id: %s\n", fb_finfo.id);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
353 printf(" frame bufer at %x len %x (%d)\n", fb_finfo.smem_start, fb_finfo.smem_len,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
354 fb_finfo.smem_len);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
355 printf(" mem io at %x len %x\n", fb_finfo.mmio_start, fb_finfo.mmio_len);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
356
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
357 printf("fb_vinfo:\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
358 printf(" resolution: %dx%d\n", fb_vinfo.xres, fb_vinfo.yres);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
359 printf(" virtual res: %dx%d\n", fb_vinfo.xres_virtual, fb_vinfo.yres_virtual);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
360 printf(" virt offset: %dx%d\n", fb_vinfo.xoffset, fb_vinfo.yoffset);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
361 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
362
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
363 if (fb_finfo.accel != FB_ACCEL_3DFX_BANSHEE) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
364 printf("vo_3dfx->init(): this driver made only for 3dfx banshee... sorry...\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
365 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
366 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
367 if (fb_vinfo.bits_per_pixel != 16) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
368 printf("vo_3dfx->init(): for now fork only in 16 bits mode. use fbset -depth 16 <mode>\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
369 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
370 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
371 //return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
372
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
373
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
374 //screenwidth = 800;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
375 //screenheight = 600;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
376 //screendepth = 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
377 screenwidth = fb_vinfo.xres;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
378 screenheight = fb_vinfo.yres;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
379 screendepth = 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
380 // Store sizes for later
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
381 in_width = width;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
382 in_height = height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
383 in_format = format;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
384
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
385 vidwidth = screenwidth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
386 vidheight = screenheight;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
387 //vidwidth = in_width;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
388 //vidheight = in_height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
389 if (1) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
390 double exrat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
391
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
392 exrat = (double)in_width / in_height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
393 if (verbose)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
394 printf("vo_3dfx->init(): in_width / in_height => %f\n", exrat);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
395 if (screenwidth / exrat <= screenheight)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
396 vidheight = (double)screenwidth / exrat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
397 else
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
398 vidwidth = (double)screenheight * exrat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
399
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
400 vidx = (screenwidth - vidwidth) / 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
401 vidy = (screenheight - vidheight) / 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
402
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
403 if (verbose) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
404 printf("vo_3dfx->init(): vidwidth => %d\n", vidwidth);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
405 printf("vo_3dfx->init(): vidheight => %d\n", vidheight);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
406 printf("vo_3dfx->init(): vidx => %d\n", vidx);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
407 printf("vo_3dfx->init(): vidy => %d\n", vidy);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
408 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
409 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
410
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
411 signal(SIGALRM,sighup);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
412 //alarm(120);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
413
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
414
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
415 // access to 3dfx hardware....
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
416 memBase1 = mmap(0, fb_finfo.smem_len, PROT_READ | PROT_WRITE,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
417 MAP_SHARED, fb_fd, 0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
418 memBase0 = mmap(0, fb_finfo.mmio_len, PROT_READ | PROT_WRITE,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
419 MAP_SHARED, fb_fd, fb_finfo.smem_len);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
420
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
421 if (memBase0 == (uint32_t *)0xFFFFFFFF ||
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
422 memBase1 == (uint32_t *)0xFFFFFFFF)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
423 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
424 printf("Couldn't map 3dfx memory areas: %p, %p, %d\n",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
425 memBase0, memBase1, errno);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
426 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
427
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
428
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
429 tdfx_iobase = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
430
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
431 // Set up global pointers
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
432 reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
433 reg_2d = (void *)memBase0 + VOODOO_2D_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
434 reg_YUV = (void *)memBase0 + VOODOO_YUV_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
435 fb_YUV = (void *)memBase0 + VOODOO_YUV_PLANE_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
436
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
437 vidpage0offset = 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
438 vidpage1offset = screenwidth * screenheight * screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
439 //osd_page_offset = vidpage1offset + screenwidth * screenheight * screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
440 //in_page0_offset = osd_page_offset + screenwidth * screenheight * screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
441 in_page0_offset = vidpage1offset + screenwidth * screenheight * screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
442
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
443 vidpage0 = (void *)memBase1 + (unsigned long int)vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
444 vidpage1 = (void *)memBase1 + (unsigned long int)vidpage1offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
445 //osd_page = (void *)memBase1 + (unsigned long int)osd_page_offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
446 in_page0 = (void *)memBase1 + (unsigned long int)in_page0_offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
447
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
448 vid_banshee_xy = XYREG(vidx, vidy);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
449 vid_banshee_format = screenwidth*2 | VOODOO_BLT_FORMAT_16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
450 vid_banshee_size = XYREG(vidwidth, vidheight);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
451
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
452 in_banshee_size = XYREG(in_width, in_height);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
453
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
454 //video_out_tdfxfb.flip_page = flip_page_all;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
455 draw_alpha_p = NULL;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
456
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
457 switch (in_format) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
458 case IMGFMT_YV12:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
459 video_out_tdfxfb.draw_slice = draw_slice_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
460 video_out_tdfxfb.draw_frame = draw_frame_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
461 video_out_tdfxfb.flip_page = flip_page_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
462 video_out_tdfxfb.draw_osd = draw_osd_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
463 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_YUYV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
464 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
465 case IMGFMT_YUY2:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
466 video_out_tdfxfb.draw_slice = draw_slice_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
467 video_out_tdfxfb.draw_frame = draw_frame_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
468 video_out_tdfxfb.flip_page = flip_page_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
469 video_out_tdfxfb.draw_osd = draw_osd_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
470
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
471 #if VO_3DFX_METHOD == 1
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
472 draw_alpha_p = vo_draw_alpha_yuy2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
473 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
474 #if VO_3DFX_METHOD == 2
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
475 *our_out_buffer = in_page0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
476 draw_alpha_p = vo_draw_alpha_rgb16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
477 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
478 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_YUYV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
479 in_bytepp = 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
480 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
481 case IMGFMT_BGR|16:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
482 video_out_tdfxfb.draw_slice = draw_slice_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
483 video_out_tdfxfb.draw_frame = draw_frame_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
484 video_out_tdfxfb.flip_page = flip_page_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
485 video_out_tdfxfb.draw_osd = draw_osd_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
486 #if VO_3DFX_METHOD == 2
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
487 *our_out_buffer = in_page0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
488 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
489 draw_alpha_p = vo_draw_alpha_rgb16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
490 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
491 in_bytepp = 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
492 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
493 case IMGFMT_BGR|24:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
494 // FIXME: !!!!
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
495 //video_out_tdfxfb.draw_frame = draw_frame_BGR24;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
496 video_out_tdfxfb.draw_frame = draw_frame; // draw_frame_BGR24;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
497 //*our_out_buffer = vidpage1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
498
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
499 in_banshee_format = in_width * 3 | VOODOO_BLT_FORMAT_24;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
500 in_bytepp = 3;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
501 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
502 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
503
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
504
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
505 // Clear pages 1,2,3
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
506 // leave page 0, that belongs to X.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
507 // So does part of 1. Oops.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
508 memset(vidpage0, 0x00, screenwidth * screenheight * screendepth);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
509 memset(vidpage1, 0x00, screenwidth * screenheight * screendepth);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
510 memset(in_page0, 0x00, in_width * in_height * in_bytepp);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
511
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
512 // Show page 0 (unblanked)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
513 reg_IO->vidDesktopStartAddr = vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
514 //banshee_make_room(1);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
515 //tdfx_outl(VIDDESKSTART, vidpage1offset);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
516
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
517 /* fd is deliberately not closed - if it were, mmaps might be released??? */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
518
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
519 atexit(restore);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
520
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
521 printf("(display) 3dfx initialized %p/%p\n",memBase0,memBase1);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
522 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
523 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
524
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
525 static const vo_info_t*
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
526 get_info(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
527 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
528 return &vo_info;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
529 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
530
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
531 // -------------------------------------------------------------------
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
532 // YV12 fork fine. but only on vcd, with ffmpeg codec for DivX don't given corect picture.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
533
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
534 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
535 draw_frame_YV12(uint8_t *src[])
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
536 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
537 //printf("vo_3dfx->draw_frame_YV12\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
538 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
539 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
540
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
541 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
542 draw_slice_YV12(uint8_t *image[], int stride[], int w,int h,int x,int y)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
543 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
544 dump_yuv_planar((uint32_t *)image[0], (uint32_t *)image[1],
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
545 (uint32_t *)image[2], in_page0_offset, x, y, w, h);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
546 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
547 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
548
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
549 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
550 flip_page_YV12(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
551 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
552 S2S_BLT(2 | 1 << 8 | 0xcc << 24, // 2 | 1<<8 | 0xcc<<24,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
553 vidpage0offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
554 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
555 in_page0_offset, 0,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
556 in_banshee_format, in_banshee_size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
557 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
558
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
559 static void draw_alpha_YV12(int x0, int y0, int w, int h, unsigned char *src,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
560 unsigned char *srca, int stride)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
561 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
562 unsigned char *dst = (void *)in_page0 + (in_width * y0 + x0) * 2; // 2 <= bpp
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
563 uint32_t dstride = in_width * 2; // 2 <= bpp
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
564
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
565 //printf("draw_alpha: x0,y0 = %d,%d; w,h = %d,%d;\n", x0, y0, w, h);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
566 //(*draw_alpha_p)(w, h, src, srca, stride, dst, dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
567 vo_draw_alpha_yuy2(w, h, src, srca, stride, dst, dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
568 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
569
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
570
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
571 static void draw_osd_YV12(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
572 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
573 vo_draw_text(in_width, in_height, draw_alpha_YV12);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
574 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
575
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
576
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
577 // -------------------------------------------------------------------
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
578 // YUYV & BGR16 support
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
579
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
580 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
581 draw_frame_YUY2_BGR16(uint8_t *src[])
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
582 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
583 #if VO_3DFX_METHOD == 1
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
584 memcpy(in_page0, src[0], in_width * in_height * in_bytepp);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
585 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
586 #if VO_3DFX_METHOD == 2
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
587 // blt to offscreen page.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
588 S2S_BLT(2 | 1 << 8 | 0xcc << 24, // 2 | 1<<8 | 0xcc<<24,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
589 vidpage1offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
590 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
591 in_page0_offset, 0,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
592 in_banshee_format, in_banshee_size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
593 banshee_wait_idle();
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
594 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
595 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
596 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
597
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
598 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
599 draw_slice_YUY2_BGR16(uint8_t *image[], int stride[], int w,int h,int x,int y)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
600 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
601 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
602 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
603
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
604 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
605 flip_page_YUY2_BGR16(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
606 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
607 #if VO_3DFX_METHOD == 1
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
608 S2S_BLT(2 | 1 << 8 | 0xcc << 24, // 2 | 1<<8 | 0xcc<<24,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
609 vidpage0offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
610 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
611 in_page0_offset, 0,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
612 in_banshee_format, in_banshee_size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
613 banshee_wait_idle();
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
614 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
615 #if VO_3DFX_METHOD == 2
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
616 uint32_t o;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
617 void *p;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
618
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
619 // flip screen pages.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
620 o = vidpage0offset; vidpage0offset = vidpage1offset; vidpage1offset = o;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
621 p = vidpage0; vidpage0 = vidpage1; vidpage1 = p;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
622
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
623 reg_IO->vidDesktopStartAddr = vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
624 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
625 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
626
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
627 static void draw_alpha_YUY2_BGR16(int x0, int y0, int w, int h, unsigned char *src,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
628 unsigned char *srca, int stride)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
629 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
630 #if VO_3DFX_METHOD == 1
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
631 unsigned char *dst = (void *)in_page0 + (in_width * y0 + x0) * 2; // 2 <= bpp
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
632 uint32_t dstride = in_width * 2; // 2 <= bpp
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
633 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
634 #if VO_3DFX_METHOD == 2
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
635 unsigned char *dst = (void *)vidpage1 + (screenwidth * (vidy+y0) + vidx+x0) * 2; // 2 <= bpp
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
636 uint32_t dstride = screenwidth * 2; // 2 <= bpp
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
637 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
638 //printf("draw_alpha: x0,y0 = %d,%d; w,h = %d,%d;\n", x0, y0, w, h);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
639 (*draw_alpha_p)(w, h, src, srca, stride, dst, dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
640 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
641
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
642 static void draw_osd_YUY2_BGR16(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
643 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
644 #if VO_3DFX_METHOD == 1
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
645 vo_draw_text(in_width, in_height, draw_alpha_YUY2_BGR16);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
646 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
647 #if VO_3DFX_METHOD == 2
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
648 //vo_draw_text(screenwidth, screenheight, draw_alpha_YUY2_BGR16);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
649 //vo_draw_text(vidwidth, vidheight, draw_alpha_YUY2_BGR16);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
650 vo_draw_text(vidwidth, vidheight, draw_alpha_YUY2_BGR16);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
651 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
652 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
653
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
654 // -------------------------------------------------------------------
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
655
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
656 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
657 draw_frame(uint8_t *src[])
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
658 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
659 /* dummy */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
660 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
661 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
662
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
663 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
664 draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
665 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
666 /* dummy */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
667 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
668 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
669
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
670 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
671 flip_page(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
672 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
673 /* dummy */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
674 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
675
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
676 #if 0
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
677 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
678 flip_page_all(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
679 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
680 S2S_BLT(2 | 1 << 8 | 0xcc << 24, // 2 | 1<<8 | 0xcc<<24,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
681 vidpage0offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
682 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
683 in_page0_offset, 0,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
684 in_banshee_format, in_banshee_size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
685 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
686
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
687
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
688 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
689 flip_page_YUY2_2(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
690 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
691 void *p;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
692 uint32_t o;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
693
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
694 /* flip screen buffer */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
695 p = vidpage0; vidpage0 = vidpage1; vidpage1 = p;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
696 o = vidpage0offset; vidpage0offset = vidpage1offset; vidpage1offset = o;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
697 reg_IO->vidDesktopStartAddr = vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
698
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
699
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
700 //banshee_make_room(1);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
701 //tdfx_outl(VIDDESKSTART, vidpage0offset);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
702 //banshee_wait_idle();
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
703
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
704 #if 0
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
705 S2S_BLT(2 | 1 << 8 | 0xCC << 24,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
706 vidpage0offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
707 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
708 in_page1_offset, 0,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
709 in_banshee_format, in_banshee_size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
710 banshee_wait_idle();
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
711 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
712 #if 0
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
713 S2S_BLT(2 | 1 << 8 | 0xCC << 24,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
714 vidpage0offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
715 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
716 vidpage1offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
717 vid_banshee_format, vid_banshee_size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
718
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
719 banshee_wait_idle();
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
720 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
721 #if 0
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
722 banshee_make_room(3+9);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
723
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
724 tdfx_outl(COMMANDEXTRA_2D, 4);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
725 tdfx_outl(CLIP0MIN, 0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
726 tdfx_outl(CLIP0MAX, 0xffffffff);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
727 tdfx_outl(SRCBASE, page_0_offset);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
728 tdfx_outl(SRCXY, 0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
729 tdfx_outl(SRCFORMAT, in_banshee_format);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
730 tdfx_outl(SRCSIZE, in_banshee_size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
731
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
732 tdfx_outl(DSTBASE, vidpage0offset);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
733 tdfx_outl(DSTXY, vid_banshee_xy);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
734 tdfx_outl(DSTFORMAT, vid_banshee_format);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
735 tdfx_outl(DSTSIZE, vid_banshee_size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
736
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
737 tdfx_outl(COMMAND_2D, 2 | 1<<8 | 0xcc << 24);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
738 banshee_wait_idle();
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
739 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
740 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
741 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
742
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
743
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
744 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
745 query_format(uint32_t format)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
746 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
747 switch(format){
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
748 case IMGFMT_YV12:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
749 return 4|2; // 4|2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
750 case IMGFMT_YUY2:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
751 if (verbose) printf("query_format: IMGFMT_YUY2\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
752 return 0; //4|2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
753 case IMGFMT_RGB|24:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
754 if (verbose) printf("query_format: IMGFMT_RGB|24\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
755 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
756 case IMGFMT_BGR|24:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
757 if (verbose) printf("query_format: IMGFMT_BGR|24\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
758 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
759 case IMGFMT_BGR|16:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
760 return 4|2; // 4|1; /* osd + ????? */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
761 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
762 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
763 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
764
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
765 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
766 uninit(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
767 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
768 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
769
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
770
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
771 static void check_events(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
772 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
773 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
774
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
775 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
776 unsigned char *srca, int stride)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
777 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
778 unsigned char *dst = (void *)vidpage1 + (in_width * y0 + x0) * 2; // 2 <= bpp
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
779 uint32_t dstride = in_width * 2; // 2 <= bpp
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
780
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
781 //printf("draw_alpha: x0,y0 = %d,%d; w,h = %d,%d;\n", x0, y0, w, h);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
782 //(*draw_alpha_p)(w, h, src, srca, stride, dst, dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
783 vo_draw_alpha_rgb16(w, h, src, srca, stride, dst, dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
784 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
785
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
786 static void draw_osd(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
787 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
788 #if 1
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
789 vo_draw_text(vidwidth, vidheight, draw_alpha);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
790 #else
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
791 zz_draw_text(in_width, in_height, draw_alpha);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
792 S2S_BLT(2 | 1 << 8 | 0xCC << 24,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
793 in_page1_offset, in_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
794 in_banshee_format, in_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
795 in_pageT_offset, 0,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
796 in_banshee_format, in_banshee_size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
797 banshee_wait_idle();
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
798 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
799 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
800
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
801