annotate libvo/vo_tdfxfb.c @ 5036:021a0b7bd55f

JPEG_LIB moved to common libs, requires by mencoder too
author arpi
date Mon, 11 Mar 2002 00:13:26 +0000
parents 32e1f5042f65
children 80d8fed6e683
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
1 // uncomment this if you pached mplayer.c with mplayer_our_out_buffer_hack.diff
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
2 //#define VO_TDFXFB_METHOD 2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
3 #define VO_TDFXFB_METHOD 1
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
4 // method: Host-to-Screen bitBLT-ing.
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
5 #define HWACCEL_OSD_M2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
6 //#define YV12_CONV_METH
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
7 #define DONT_USE_FAST_MEMCPY
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
8
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 * video_out_tdfxfb.c
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 * Copyright (C) Zeljko Stevanovic 2001, <zsteva@ptt.yu>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
13 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
14 * 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
15 * add support for YUY2 and BGR16 format, remove all X11 DGA code.
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
16 * - add support for hardware accelerated OSD (buggy for now).
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
17 * work on BGR16 and YUY2 (VO_3DFX_METHOD == 2 only)
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
18 * [oct2001]
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
19 * - added hardware acceleration for OSD (does not look nice, but is faster)
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
20 * (for YV12 don't fork.)
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
21 * - fixed YV12 support for ffdivx, but on my cpu this is sllower of yuv2rgb()
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
22 * try to uncommenting '#define YV12_CONV_METH'
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
23 * - fast_memcpy() is sllower of memcpy() (why, i don't know)
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
24 *
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
25 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
26 * Copyright (C) Colin Cross Apr 2000
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
27 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
28 * 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
29 * mpeg2dec
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 * 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
32 * 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
33 * 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
34 * any later version.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
35 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
36 * 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
37 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
39 * GNU General Public License for more details.
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 * 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
42 * 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
43 * 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
44 *
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
45 */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
46
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
47 #include <stdio.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
48 #include <stdlib.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
49 #include <string.h>
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
50 #include <errno.h>
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
51
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
52 #include "config.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
53 #include "video_out.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
54 #include "video_out_internal.h"
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 LIBVO_EXTERN(tdfxfb)
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 <sys/ioctl.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
59 #include <unistd.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
60 #include <fcntl.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
61 #include <sys/mman.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
62 #include <errno.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
63 #include <wchar.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
64 #include <signal.h>
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 #include <linux/fb.h>
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 extern int verbose;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
69
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
70 //#define LOG(x) syslog(LOG_USER | LOG_DEBUG,x)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
71 #define LOG(x)
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 #include "drivers/3dfx.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
74
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
75 // fast_memcpy() is slower of memcpy(), why? i dont know...
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
76 #ifndef DONT_USE_FAST_MEMCPY
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
77 #include "fastmemcpy.h"
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
78 #endif
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
79
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
80 #ifdef YV12_CONV_METH
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents: 2350
diff changeset
81 #include "../postproc/rgb2rgb.h"
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
82 #endif
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
83
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
84 static vo_info_t vo_info =
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
85 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
86 "tdfxfb (/dev/fb?)",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
87 "tdfxfb",
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
88 "Zeljko Stevanovic <zsteva@ptt.yu>",
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
89 ""
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
92 static char *fb_devname = NULL;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
93 static int fb_fd = -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
94 static struct fb_fix_screeninfo fb_finfo;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
95 static struct fb_var_screeninfo fb_vinfo;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
96
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
97 static uint32_t in_width;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
98 static uint32_t in_height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
99 static uint32_t in_format;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
100 static uint32_t in_bytepp;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
101
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
102 static uint32_t in_banshee_format,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
103 in_banshee_size;
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 static uint32_t screenwidth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
106 static uint32_t screenheight;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
107 static uint32_t screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
108 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
109 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
110
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
111 static uint32_t vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
112 vid_banshee_format,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
113 vid_banshee_size;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
114
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
115 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
116 unsigned char *srca, int stride, unsigned char *dst,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
117 int dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
118
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
119 static uint32_t *vidpage0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
120 static uint32_t *vidpage1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
121 static uint32_t *in_page0;
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 static uint32_t vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
124 static uint32_t vidpage1offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
125 static uint32_t in_page0_offset;
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 // Current pointer into framebuffer where display is located
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
128 static uint32_t targetoffset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
129
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
130 static uint32_t page_space;
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 static uint32_t *tdfx_iobase;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
133
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
134 static voodoo_io_reg *reg_IO;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
135 static voodoo_2d_reg *reg_2d;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
136 static voodoo_yuv_reg *reg_YUV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
137 static voodoo_yuv_fb *fb_YUV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
138
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
139 static uint32_t *memBase0, *memBase1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
140 //static uint32_t baseAddr0, baseAddr1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
141
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
142 //#define BANSHEE_SCREEN_MEMORY (8*1024*1024)
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
143 static uint32_t tdfx_free_offset = 0;
1979
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 /*- ----------------------------------------------------------------- -*/
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
146
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
147 /* code get from linux kernel tdfxfb.c by Hannu Mallat */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
148
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
149 typedef uint32_t u32;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
150
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
151 static inline u32 tdfx_inl(unsigned int reg) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
152 return *((volatile uint32_t *)(tdfx_iobase + reg));
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 static inline void tdfx_outl(unsigned int reg, u32 val) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
156 *((volatile uint32_t *)(tdfx_iobase + reg)) = val;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
157 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
158
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
159 static inline void banshee_make_room(int size) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
160 while((tdfx_inl(STATUS) & 0x1f) < size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
161 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
162
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
163 static inline void banshee_wait_idle(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
164 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
165 int i = 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
166
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
167 banshee_make_room(1);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
168 tdfx_outl(COMMAND_3D, COMMAND_3D_NOP);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
169
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
170 while(1) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
171 i = (tdfx_inl(STATUS) & STATUS_BUSY) ? 0 : i + 1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
172 if(i == 3) break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
173 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
174 }
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
179 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
180 restore_regs(voodoo_2d_reg *regs)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
181 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
182 reg_2d->commandExtra = regs->commandExtra;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
183 reg_2d->clip0Min = regs->clip0Min;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
184 reg_2d->clip0Max = regs->clip0Max;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
185
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
186 reg_2d->srcBaseAddr = regs->srcBaseAddr;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
187 reg_2d->srcXY = regs->srcXY;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
188 reg_2d->srcFormat = regs->srcFormat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
189 reg_2d->srcSize = regs->srcSize;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
190
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
191 reg_2d->dstBaseAddr = regs->dstBaseAddr;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
192 reg_2d->dstXY = regs->dstXY;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
193 reg_2d->dstFormat = regs->dstFormat;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
194 reg_2d->dstSize = regs->dstSize;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
195
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
196 reg_2d->command = 0;
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
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 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
201 restore(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
202 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
203 reg_IO->vidDesktopStartAddr = vidpage0offset;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
204 //XF86DGADirectVideo(display,0,0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
205 }
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 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
208 sighup(int foo)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
209 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
210 reg_IO->vidDesktopStartAddr = vidpage0offset;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
211 //XF86DGADirectVideo(display,0,0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
212 exit(0);
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
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
215 #if 0
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
216 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
217 dump_yuv_planar(void *y, void *u, void *v,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
218 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
219 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
220 uint32_t j;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
221 uint32_t *YUV_U, *YUV_V, *YUV_Y;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
222 uint32_t width2 = width >> 1;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
223 uint32_t height2 = height >> 1;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
224
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
225 reg_YUV->yuvBaseAddr = to + in_width * 2 * py;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
226 reg_YUV->yuvStride = width << 1;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
227
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
228 YUV_U = &fb_YUV->U[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
229 YUV_V = &fb_YUV->V[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
230 YUV_Y = &fb_YUV->Y[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
231 for (j = 0; j < height2; j++)
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
232 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
233 memcpy(YUV_U, u, width2);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
234 memcpy(YUV_V, v, width2);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
235 memcpy(YUV_Y, y, width); YUV_Y += VOODOO_YUV_STRIDE; y += width;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
236 memcpy(YUV_Y, y, width); YUV_Y += VOODOO_YUV_STRIDE; y += width;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
237 YUV_U += VOODOO_YUV_STRIDE; u += width2;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
238 YUV_V += VOODOO_YUV_STRIDE; v += width2;
1979
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 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
241 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
242
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
243 #define S2S_BLT(cmd, to, dXY, dFmt, dSize, from, sXY, sFmt, sSize, extCmd) \
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
244 do { \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
245 voodoo_2d_reg saved_regs = *reg_2d; \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
246 \
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
247 reg_2d->commandExtra = (extCmd); \
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
248 reg_2d->clip0Min = 0; \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
249 reg_2d->clip0Max = 0xffffffff; \
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->srcBaseAddr = (from); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
252 reg_2d->srcXY = (sXY); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
253 reg_2d->srcFormat = (sFmt); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
254 reg_2d->srcSize = (sSize); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
255 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
256 reg_2d->dstBaseAddr = (to); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
257 reg_2d->dstXY = (dXY); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
258 reg_2d->dstFormat = (dFmt); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
259 reg_2d->dstSize = (dSize); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
260 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
261 reg_2d->command = (cmd); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
262 \
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
263 banshee_wait_idle(); \
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
264 restore_regs(&saved_regs); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
265 } while (0)
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
268 /*- ----------------------------------------------------------------- -*/
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 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
271 static uint32_t draw_frame_YV12(uint8_t *src[]);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
272 static void flip_page_YV12(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
273 static void draw_osd_YV12(void);
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_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
276 static uint32_t draw_frame_YUY2_BGR16(uint8_t *src[]);
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
277 static void flip_page_vidpage10(void);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
278 static void draw_osd(void);
1979
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 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
281 unsigned char *srca, int stride);
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
282 #ifdef HWACCEL_OSD_M2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
283 static void my_draw_alpha_accel(int x0, int y0, int w, int h, unsigned char *src,
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
284 unsigned char *srca, int stride);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
285 #endif
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
286
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
287 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
288 update_target(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
289 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
290 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
291
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
292 #ifndef VO_TDFXFB_METHOD
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
293 #define VO_TDFXFB_METHOD 1
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
294 #endif
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
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
297 #if VO_TDFXFB_METHOD == 2
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
298 extern void **our_out_buffer;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
299 #endif
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 static uint32_t
4433
df8e0f71cc3c new info for tuning
nick
parents: 4352
diff changeset
302 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height,
df8e0f71cc3c new info for tuning
nick
parents: 4352
diff changeset
303 uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info)
1979
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
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
306 if (verbose) {
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
307 printf("vo_3dfx->init( width = %d, height = %d, "
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
308 "d_width = %d, d_height = %d, format = %d)\n",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
309 width, height, d_width, d_height, format);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
310 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
311 printf("vo_3dfx: vo_depthonscreen => %d, vo_screenwidth => %d, "
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
312 "vo_screenhight => %d\n", vo_depthonscreen, vo_screenwidth, vo_screenheight);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
313 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
314 vo_dwidth, vo_dheight, vo_dbpp);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
315 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
316
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
317 if (!fb_devname && !(fb_devname = getenv("FRAMEBUFFER")))
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
318 fb_devname = "/dev/fb0";
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
319
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
320 if (verbose)
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
321 printf("vo_3dfx->init(): fbdev ==> %s\n", fb_devname);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
322
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
323 if ((fb_fd = open(fb_devname, O_RDWR)) == -1) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
324 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
325 return -1;
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
328 if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
329 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
330 strerror(errno));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
331 return -1;
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
334 if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
335 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
336 strerror(errno));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
337 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
338 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
339
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
340 if (verbose) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
341 printf("fb_finfo:\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
342 printf(" id: %s\n", fb_finfo.id);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
343 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
344 fb_finfo.smem_len);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
345 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
346
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
347 printf("fb_vinfo:\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
348 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
349 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
350 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
351 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
352
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
353 if (fb_finfo.accel != FB_ACCEL_3DFX_BANSHEE) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
354 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
355 return -1;
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 if (fb_vinfo.bits_per_pixel != 16) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
358 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
359 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
360 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
361 //return -1;
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
364 screenwidth = fb_vinfo.xres;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
365 screenheight = fb_vinfo.yres;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
366 screendepth = 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
367 // Store sizes for later
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
368 in_width = width;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
369 in_height = height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
370 in_format = format;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
371
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
372 if (fullscreen) {
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
373 double exrat;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
374
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
375 if (verbose)
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
376 printf("vo_tdfxfb->init(): fullscreen mode...\n");
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
377
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
378 vidwidth = screenwidth;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
379 vidheight = screenheight;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
380
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
381 exrat = (double)in_width / in_height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
382 if (verbose)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
383 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
384 if (screenwidth / exrat <= screenheight)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
385 vidheight = (double)screenwidth / exrat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
386 else
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
387 vidwidth = (double)screenheight * exrat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
388
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
389 vidx = (screenwidth - vidwidth) / 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
390 vidy = (screenheight - vidheight) / 2;
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 if (verbose) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
393 printf("vo_3dfx->init(): vidwidth => %d\n", vidwidth);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
394 printf("vo_3dfx->init(): vidheight => %d\n", vidheight);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
395 printf("vo_3dfx->init(): vidx => %d\n", vidx);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
396 printf("vo_3dfx->init(): vidy => %d\n", vidy);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
397 }
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
398 } else {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
399 if (in_width > screenwidth || in_height > screenheight) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
400 printf("vo_tdfxfb->init(): your resolution is small for play move...\n");
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
401 return -1;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
402 } else {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
403 vidwidth = in_width;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
404 vidheight = in_height;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
405 vidx = (screenwidth - in_width) / 2;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
406 vidy = (screenheight - in_height) / 2;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
407 }
1979
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 signal(SIGALRM,sighup);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
411 //alarm(120);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
412
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 // access to 3dfx hardware....
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
415 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
416 MAP_SHARED, fb_fd, 0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
417 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
418 MAP_SHARED, fb_fd, fb_finfo.smem_len);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
419
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
420 if (memBase0 == (uint32_t *)0xFFFFFFFF ||
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
421 memBase1 == (uint32_t *)0xFFFFFFFF)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
422 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
423 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
424 memBase0, memBase1, errno);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
425 }
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 tdfx_iobase = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
429
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
430 // Set up global pointers
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
431 reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
432 reg_2d = (void *)memBase0 + VOODOO_2D_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
433 reg_YUV = (void *)memBase0 + VOODOO_YUV_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
434 fb_YUV = (void *)memBase0 + VOODOO_YUV_PLANE_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
435
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
436 vidpage0offset = 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
437 vidpage1offset = screenwidth * screenheight * screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
438 in_page0_offset = vidpage1offset + screenwidth * screenheight * screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
439
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
440 vidpage0 = (void *)memBase1 + (unsigned long int)vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
441 vidpage1 = (void *)memBase1 + (unsigned long int)vidpage1offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
442 in_page0 = (void *)memBase1 + (unsigned long int)in_page0_offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
443
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
444 vid_banshee_xy = XYREG(vidx, vidy);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
445 vid_banshee_format = screenwidth*2 | VOODOO_BLT_FORMAT_16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
446 vid_banshee_size = XYREG(vidwidth, vidheight);
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 in_banshee_size = XYREG(in_width, in_height);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
449
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
450 //video_out_3dfx.flip_page = flip_page_all;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
451 draw_alpha_p = vo_draw_alpha_rgb16;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
452
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
453 switch (in_format) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
454 case IMGFMT_YV12:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
455 video_out_tdfxfb.draw_slice = draw_slice_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
456 video_out_tdfxfb.draw_frame = draw_frame_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
457 video_out_tdfxfb.flip_page = flip_page_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
458 video_out_tdfxfb.draw_osd = draw_osd_YV12;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
459 draw_alpha_p = vo_draw_alpha_yuy2;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
460 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_YUYV;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
461 #ifdef YV12_CONV_METH
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
462 yuv2rgb_init(16, MODE_RGB);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
463 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_16;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
464 draw_alpha_p = vo_draw_alpha_rgb16;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
465 #endif
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
466 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
467 case IMGFMT_YUY2:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
468 video_out_tdfxfb.draw_slice = draw_slice_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
469 video_out_tdfxfb.draw_frame = draw_frame_YUY2_BGR16;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
470 video_out_tdfxfb.flip_page = flip_page_vidpage10;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
471
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
472 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_YUYV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
473 in_bytepp = 2;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
474 #if VO_TDFXFB_METHOD == 2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
475 *our_out_buffer = in_page0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
476 #endif
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
477
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
478 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
479 case IMGFMT_BGR|16:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
480 video_out_tdfxfb.draw_slice = draw_slice_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
481 video_out_tdfxfb.draw_frame = draw_frame_YUY2_BGR16;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
482 video_out_tdfxfb.flip_page = flip_page_vidpage10;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
483
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
484 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
485 in_bytepp = 2;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
486 #if VO_TDFXFB_METHOD == 2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
487 *our_out_buffer = in_page0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
488 #endif
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
489 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
490 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
491
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
492
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
493 // Clear pages 1,2,3
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
494 // leave page 0, that belongs to X.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
495 // So does part of 1. Oops.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
496 memset(vidpage0, 0x00, screenwidth * screenheight * screendepth);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
497 memset(vidpage1, 0x00, screenwidth * screenheight * screendepth);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
498 memset(in_page0, 0x00, in_width * in_height * in_bytepp);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
499
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
500 // Show page 0 (unblanked)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
501 reg_IO->vidDesktopStartAddr = vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
502 //banshee_make_room(1);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
503 //tdfx_outl(VIDDESKSTART, vidpage1offset);
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 /* 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
506
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
507 atexit(restore);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
508
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
509 printf("(display) tdfxfb initialized %p/%p\n",memBase0,memBase1);
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
510 return 0;
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
513 static const vo_info_t*
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
514 get_info(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
515 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
516 return &vo_info;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
517 }
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 // -------------------------------------------------------------------
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
520 // 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
521
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
522 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
523 draw_frame_YV12(uint8_t *src[])
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 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
526 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
527
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
528 #ifndef YV12_CONV_METH
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
529
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
530 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
531 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
532 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
533 void *img_y = image[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
534 void *img_u = image[1];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
535 void *img_v = image[2];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
536 uint32_t j;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
537 uint32_t *YUV_U = &fb_YUV->U[0],
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
538 *YUV_V = &fb_YUV->V[0],
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
539 *YUV_Y = &fb_YUV->Y[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
540 uint32_t height2 = h >> 1;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
541
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
542 #if 0
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
543 printf("stride[0] => %d\n", stride[0]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
544 printf("stride[1] => %d\n", stride[1]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
545 printf("stride[2] => %d\n", stride[2]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
546 printf("w => %d, h => %d, x => %d, y => %d\n", w, h, x, y);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
547 #endif
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
548 #if 0
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
549 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
550 (uint32_t *)image[2], in_page0_offset, x, y, w, h);
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
551 #endif
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
552
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
553 //reg_YUV->yuvBaseAddr = to + mystride * 2 * py;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
554 reg_YUV->yuvBaseAddr = in_page0_offset + w * 2 * y;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
555 reg_YUV->yuvStride = w << 1;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
556
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
557 for (j = 0; j < height2; j++)
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
558 {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
559 memcpy(YUV_U, img_u, stride[1]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
560 memcpy(YUV_V, img_v, stride[2]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
561 memcpy(YUV_Y, img_y, stride[0]); YUV_Y += VOODOO_YUV_STRIDE; img_y += stride[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
562 memcpy(YUV_Y, img_y, stride[0]); YUV_Y += VOODOO_YUV_STRIDE; img_y += stride[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
563 YUV_U += VOODOO_YUV_STRIDE; img_u += stride[1];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
564 YUV_V += VOODOO_YUV_STRIDE; img_v += stride[2];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
565 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
566
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
567 return 0;
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
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
570 #else /* !YV12_CONV_METH */
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
571 // -------------------------------------------------------------------
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
572 // YV12 with converting support
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
573
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
574 static uint32_t
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
575 draw_slice_YV12(uint8_t *image[], int stride[], int w,int h,int x,int y)
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
576 {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
577 uint8_t *dest = (uint8_t *)(in_page0) + (in_width * y + x) * 2;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
578 //dump_yuv_planar((uint32_t *)image[0], (uint32_t *)image[1],
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
579 // (uint32_t *)image[2], in_page0_offset, x, y, w, h);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
580 yuv2rgb(dest, image[0], image[1], image[2], w, h, in_width * 2,
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
581 stride[0], stride[1]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
582 return 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
583 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
584
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
585 #endif /* else ! YV12_CONV_METH */
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
586
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
587 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
588 flip_page_YV12(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
589 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
590 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
591 vidpage0offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
592 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
593 in_page0_offset, 0,
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
594 in_banshee_format, in_banshee_size, 0);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
595
1979
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 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
599 unsigned char *srca, int stride)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
600 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
601 unsigned char *dst = (void *)in_page0 + (in_width * (0+y0) + 0+x0) * 2; // 2 <= bpp
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
602 uint32_t dstride = in_width * 2; // 2 <= bpp
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
603 //printf("draw_alpha: x0,y0 = %d,%d; w,h = %d,%d; stride=%d;\n", x0, y0, w, h, stride);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
604 (*draw_alpha_p)(w, h, src, srca, stride, dst, dstride);
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
605 }
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
608 static void draw_osd_YV12(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
609 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
610 #ifndef HWACCEL_OSD_M2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
611 //vo_draw_text(vidwidth, vidheight, draw_alpha);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
612 #else
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
613 //vo_draw_text(vidwidth, vidheight, my_draw_alpha_accel);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
614 #endif /* else ! HWACCEL_OSD_M2 */
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
615 vo_draw_text(in_width, in_height, draw_alpha_YV12);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
616 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
617
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
618
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
619
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
620 // -------------------------------------------------------------------
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
621 // YUYV & BGR16 support
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 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
624 draw_frame_YUY2_BGR16(uint8_t *src[])
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
625 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
626 #if VO_TDFXFB_METHOD == 1
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
627 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
628 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
629 // blt to offscreen page.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
630 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
631 vidpage1offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
632 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
633 in_page0_offset, 0,
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
634 in_banshee_format, in_banshee_size, 0);
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
635 banshee_wait_idle();
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
636 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
637 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
638
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
639 static uint32_t
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
640 draw_frame_YUY2_BGR16_h2s_bitblt(uint8_t *src[])
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
641 {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
642 uint32_t i, len;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
643 uint32_t *launch = (uint32_t *)&reg_2d->launchArea[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
644 uint32_t *src32 = (uint32_t *)src[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
645 voodoo_2d_reg saved_regs = *reg_2d;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
646
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
647 reg_2d->commandExtra = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
648 reg_2d->clip0Min = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
649 reg_2d->clip0Max = 0xffffffff;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
650
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
651 reg_2d->colorFore = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
652 reg_2d->colorBack = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
653
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
654 reg_2d->srcXY = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
655 //reg_2d->srcBaseAddr = (from);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
656
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
657 // reg_2d->srcFormat = 0x00400000 | BIT(20); // byte allignment + byte swizzle...
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
658 // YUYV + dword packet
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
659 reg_2d->srcFormat = in_width*2 | VOODOO_BLT_FORMAT_YUYV; // | (2 << 22);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
660 reg_2d->dstXY = vid_banshee_xy;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
661 reg_2d->dstSize = vid_banshee_size;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
662 reg_2d->dstBaseAddr = vidpage1offset;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
663 reg_2d->dstFormat = vid_banshee_format;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
664
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
665 // host-to-screen blting + tranpasparent
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
666 //reg_2d->command = 3 | (1 << 16)| (ROP_COPY << 24);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
667 reg_2d->command = 3 | (ROP_COPY << 24);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
668
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
669 i = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
670 len = in_width * in_height * 2; /* 2 => 16 bit */
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
671 len >>= 2; /* / 4 */
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
672 for (;;) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
673 if (i == len) break; launch[0] = src32[i]; i++;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
674 if (i == len) break; launch[1] = src32[i]; i++;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
675 if (i == len) break; launch[2] = src32[i]; i++;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
676 if (i == len) break; launch[3] = src32[i]; i++;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
677 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
678 banshee_wait_idle();
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
679 restore_regs(&saved_regs);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
680 return;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
681 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
682
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
683 static uint32_t
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
684 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
685 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
686 return 0;
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
689 static void
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
690 flip_page_vidpage10(void)
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
691 {
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 void *p;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
694
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
695 // flip screen pages.
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 p = vidpage0; vidpage0 = vidpage1; vidpage1 = p;
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 reg_IO->vidDesktopStartAddr = vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
700 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
701
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
702 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
703 unsigned char *srca, int stride)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
704 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
705 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
706 uint32_t dstride = screenwidth * 2; // 2 <= bpp
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
707 //printf("draw_alpha: x0,y0 = %d,%d; w,h = %d,%d; stride=%d;\n", x0, y0, w, h, stride);
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
708 (*draw_alpha_p)(w, h, src, srca, stride, dst, dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
709 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
710
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
711 static void draw_osd(void)
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
712 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
713 #ifndef HWACCEL_OSD_M2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
714 vo_draw_text(vidwidth, vidheight, draw_alpha);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
715 #else
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
716 vo_draw_text(vidwidth, vidheight, my_draw_alpha_accel);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
717 #endif /* else ! HWACCEL_OSD_M2 */
1979
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
720 // -------------------------------------------------------------------
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
721
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
722 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
723 draw_frame(uint8_t *src[])
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
724 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
725 /* dummy */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
726 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
727 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
728
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
729 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
730 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
731 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
732 /* dummy */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
733 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
734 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
735
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
736 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
737 flip_page(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
738 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
739 /* dummy */
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
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
742 /*- ----------------------------------------------------------------- -*/
1979
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");
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
752 return 4|2; //4|2;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
753 case IMGFMT_BGR|16:
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
754 if (verbose) printf("query_format: IMGFMT_BGR|16\n");
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
755 return 4|2; // 4|2; /* osd + ????? */
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
756 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
757 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
758 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
759
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
760 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
761 uninit(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
762 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
763 reg_IO->vidDesktopStartAddr = vidpage0offset;
1979
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
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
766
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
767 static void check_events(void)
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
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
771 #ifdef HWACCEL_OSD_M2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
772
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
773 static void my_draw_alpha_accel(int x0, int y0, int w, int h, unsigned char *src,
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
774 unsigned char *srca, int stride)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
775 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
776 int y, x;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
777 uint32_t pbuf, pcnt;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
778 uint32_t *launch = (uint32_t *)&reg_2d->launchArea[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
779 voodoo_2d_reg saved_regs = *reg_2d;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
780
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
781 reg_2d->commandExtra = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
782 reg_2d->clip0Min = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
783 reg_2d->clip0Max = 0xffffffff;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
784
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
785 reg_2d->colorFore = 0xffff;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
786 reg_2d->colorBack = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
787
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
788 reg_2d->srcXY = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
789 //reg_2d->srcBaseAddr = (from);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
790
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
791 reg_2d->srcFormat = 0x00400000 | BIT(20); // byte allignment + byte swizzle...
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
792 //reg_2d->srcSize = XYREG(w, h);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
793 reg_2d->dstSize = XYREG(w, h);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
794
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
795 reg_2d->dstBaseAddr = vidpage1offset;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
796 reg_2d->dstXY = XYREG(vidx+x0, vidy+y0);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
797 reg_2d->dstFormat = vid_banshee_format;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
798
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
799 // host-to-screen blting + tranpasparent
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
800 reg_2d->command = 3 | (1 << 16)| (ROP_COPY << 24);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
801
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
802 pcnt = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
803 pbuf = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
804 for (y = 0; y < h; y++) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
805 for (x = 0; x < w; x++) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
806 pbuf = (pbuf << 1) | (((src[x] > 150) ? 1 : 0));
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
807 if (++pcnt == 32) { launch[0] = pbuf; pcnt = 0; pbuf = 0; }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
808 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
809
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
810 if ((pcnt % 8) != 0) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
811 pbuf <<= 8 - (pcnt % 8);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
812 pcnt += 8 - (pcnt % 8);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
813 if (pcnt == 32) { launch[0] = pbuf; pcnt = 0; pbuf = 0; }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
814 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
815
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
816 src += stride;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
817 srca += stride;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
818 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
819 if (pcnt != 0) launch[0] = pbuf;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
820
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
821 banshee_wait_idle();
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
822 restore_regs(&saved_regs);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
823 return;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
824 }
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
825 #endif /* ! HWACCEL_OSD_M2 */
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
826
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
827 static uint32_t preinit(const char *arg)
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
828 {
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
829 if(arg)
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
830 {
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
831 printf("vo_tdfxfb: Unknown subdevice: %s\n",arg);
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
832 return ENOSYS;
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
833 }
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
834 return 0;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
835 }
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
836
4596
c35d7ce151b3 10000hl to Holm... control MUST BE static...
arpi
parents: 4592
diff changeset
837 static uint32_t control(uint32_t request, void *data, ...)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
838 {
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
839 switch (request) {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
840 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
841 return query_format(*((uint32_t*)data));
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
842 }
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
843 return VO_NOTIMPL;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
844 }