annotate libvo/vo_tdfxfb.c @ 4481:b8ec9cc1b2c5

MMX(2) optimized YUY2 input avoid duplicate checks for formats by changeing them (Y8->Y800, IYUV->I420)
author michael
date Sat, 02 Feb 2002 18:18:58 +0000
parents df8e0f71cc3c
children 5fbfd8545c3b
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>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
50
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
51 #include "config.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
52 #include "video_out.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
53 #include "video_out_internal.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
54
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
55 LIBVO_EXTERN(tdfxfb)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
56
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
57 #include <sys/ioctl.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
58 #include <unistd.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
59 #include <fcntl.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
60 #include <sys/mman.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
61 #include <errno.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
62 #include <wchar.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
63 #include <signal.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
64
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
65 #include <linux/fb.h>
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
66
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
67 extern int verbose;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
68
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
69 //#define LOG(x) syslog(LOG_USER | LOG_DEBUG,x)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
70 #define LOG(x)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
71
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
72 #include "drivers/3dfx.h"
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
73
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
74 // fast_memcpy() is slower of memcpy(), why? i dont know...
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
75 #ifndef DONT_USE_FAST_MEMCPY
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
76 #include "fastmemcpy.h"
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
77 #endif
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
78
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
79 #ifdef YV12_CONV_METH
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents: 2350
diff changeset
80 #include "../postproc/rgb2rgb.h"
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
81 #endif
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
82
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
83 static vo_info_t vo_info =
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
84 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
85 "tdfxfb (/dev/fb?)",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
86 "tdfxfb",
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
87 "Zeljko Stevanovic <zsteva@ptt.yu>",
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
88 ""
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 static char *fb_devname = NULL;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
92 static int fb_fd = -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
93 static struct fb_fix_screeninfo fb_finfo;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
94 static struct fb_var_screeninfo fb_vinfo;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
95
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
96 static uint32_t in_width;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
97 static uint32_t in_height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
98 static uint32_t in_format;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
99 static uint32_t in_bytepp;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
100
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
101 static uint32_t in_banshee_format,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
102 in_banshee_size;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
103
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
104 static uint32_t screenwidth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
105 static uint32_t screenheight;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
106 static uint32_t screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
107 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
108 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
109
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
110 static uint32_t vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
111 vid_banshee_format,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
112 vid_banshee_size;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
113
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
114 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
115 unsigned char *srca, int stride, unsigned char *dst,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
116 int dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
117
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
118 static uint32_t *vidpage0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
119 static uint32_t *vidpage1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
120 static uint32_t *in_page0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
121
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
122 static uint32_t vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
123 static uint32_t vidpage1offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
124 static uint32_t in_page0_offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
125
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
126 // Current pointer into framebuffer where display is located
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
127 static uint32_t targetoffset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
128
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
129 static uint32_t page_space;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
130
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
131 static uint32_t *tdfx_iobase;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
132
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
133 static voodoo_io_reg *reg_IO;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
134 static voodoo_2d_reg *reg_2d;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
135 static voodoo_yuv_reg *reg_YUV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
136 static voodoo_yuv_fb *fb_YUV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
137
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
138 static uint32_t *memBase0, *memBase1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
139 //static uint32_t baseAddr0, baseAddr1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
140
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
141 //#define BANSHEE_SCREEN_MEMORY (8*1024*1024)
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
142 static uint32_t tdfx_free_offset = 0;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
143
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 /* code get from linux kernel tdfxfb.c by Hannu Mallat */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
147
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
148 typedef uint32_t u32;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
149
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
150 static inline u32 tdfx_inl(unsigned int reg) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
151 return *((volatile uint32_t *)(tdfx_iobase + reg));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
152 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
153
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
154 static inline void tdfx_outl(unsigned int reg, u32 val) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
155 *((volatile uint32_t *)(tdfx_iobase + reg)) = val;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
156 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
157
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
158 static inline void banshee_make_room(int size) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
159 while((tdfx_inl(STATUS) & 0x1f) < size);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
160 }
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 static inline void banshee_wait_idle(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
163 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
164 int i = 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
165
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
166 banshee_make_room(1);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
167 tdfx_outl(COMMAND_3D, COMMAND_3D_NOP);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
168
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
169 while(1) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
170 i = (tdfx_inl(STATUS) & STATUS_BUSY) ? 0 : i + 1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
171 if(i == 3) break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
172 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
173 }
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 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
179 restore_regs(voodoo_2d_reg *regs)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
180 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
181 reg_2d->commandExtra = regs->commandExtra;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
182 reg_2d->clip0Min = regs->clip0Min;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
183 reg_2d->clip0Max = regs->clip0Max;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
184
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
185 reg_2d->srcBaseAddr = regs->srcBaseAddr;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
186 reg_2d->srcXY = regs->srcXY;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
187 reg_2d->srcFormat = regs->srcFormat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
188 reg_2d->srcSize = regs->srcSize;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
189
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
190 reg_2d->dstBaseAddr = regs->dstBaseAddr;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
191 reg_2d->dstXY = regs->dstXY;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
192 reg_2d->dstFormat = regs->dstFormat;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
193 reg_2d->dstSize = regs->dstSize;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
194
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
195 reg_2d->command = 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
196 }
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 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
200 restore(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
201 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
202 reg_IO->vidDesktopStartAddr = vidpage0offset;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
203 //XF86DGADirectVideo(display,0,0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
204 }
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 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
207 sighup(int foo)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
208 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
209 reg_IO->vidDesktopStartAddr = vidpage0offset;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
210 //XF86DGADirectVideo(display,0,0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
211 exit(0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
212 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
213
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
214 #if 0
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
215 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
216 dump_yuv_planar(void *y, void *u, void *v,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
217 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
218 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
219 uint32_t j;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
220 uint32_t *YUV_U, *YUV_V, *YUV_Y;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
221 uint32_t width2 = width >> 1;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
222 uint32_t height2 = height >> 1;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
223
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
224 reg_YUV->yuvBaseAddr = to + in_width * 2 * py;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
225 reg_YUV->yuvStride = width << 1;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
226
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
227 YUV_U = &fb_YUV->U[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
228 YUV_V = &fb_YUV->V[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
229 YUV_Y = &fb_YUV->Y[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
230 for (j = 0; j < height2; j++)
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
231 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
232 memcpy(YUV_U, u, width2);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
233 memcpy(YUV_V, v, width2);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
234 memcpy(YUV_Y, y, width); YUV_Y += VOODOO_YUV_STRIDE; y += width;
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 YUV_U += VOODOO_YUV_STRIDE; u += width2;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
237 YUV_V += VOODOO_YUV_STRIDE; v += width2;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
238 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
239 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
240 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
241
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
242 #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
243 do { \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
244 voodoo_2d_reg saved_regs = *reg_2d; \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
245 \
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
246 reg_2d->commandExtra = (extCmd); \
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
247 reg_2d->clip0Min = 0; \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
248 reg_2d->clip0Max = 0xffffffff; \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
249 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
250 reg_2d->srcBaseAddr = (from); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
251 reg_2d->srcXY = (sXY); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
252 reg_2d->srcFormat = (sFmt); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
253 reg_2d->srcSize = (sSize); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
254 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
255 reg_2d->dstBaseAddr = (to); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
256 reg_2d->dstXY = (dXY); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
257 reg_2d->dstFormat = (dFmt); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
258 reg_2d->dstSize = (dSize); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
259 \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
260 reg_2d->command = (cmd); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
261 \
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
262 banshee_wait_idle(); \
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
263 restore_regs(&saved_regs); \
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
264 } while (0)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
265
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 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
270 static uint32_t draw_frame_YV12(uint8_t *src[]);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
271 static void flip_page_YV12(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
272 static void draw_osd_YV12(void);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
273
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
274 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
275 static uint32_t draw_frame_YUY2_BGR16(uint8_t *src[]);
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
276 static void flip_page_vidpage10(void);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
277 static void draw_osd(void);
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
278
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
279 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
280 unsigned char *srca, int stride);
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
281 #ifdef HWACCEL_OSD_M2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
282 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
283 unsigned char *srca, int stride);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
284 #endif
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
285
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
286 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
287 update_target(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
288 {
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
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
291 #ifndef VO_TDFXFB_METHOD
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
292 #define VO_TDFXFB_METHOD 1
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
293 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
294
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
295
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
296 #if VO_TDFXFB_METHOD == 2
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
297 extern void **our_out_buffer;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
298 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
299
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
300 static uint32_t
4433
df8e0f71cc3c new info for tuning
nick
parents: 4352
diff changeset
301 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
302 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
303 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
304
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
305 if (verbose) {
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
306 printf("vo_3dfx->init( width = %d, height = %d, "
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
307 "d_width = %d, d_height = %d, format = %d)\n",
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
308 width, height, d_width, d_height, format);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
309 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
310 printf("vo_3dfx: vo_depthonscreen => %d, vo_screenwidth => %d, "
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
311 "vo_screenhight => %d\n", vo_depthonscreen, vo_screenwidth, vo_screenheight);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
312 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
313 vo_dwidth, vo_dheight, vo_dbpp);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
314 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
315
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
316 if (!fb_devname && !(fb_devname = getenv("FRAMEBUFFER")))
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
317 fb_devname = "/dev/fb0";
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
318
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
319 if (verbose)
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
320 printf("vo_3dfx->init(): fbdev ==> %s\n", fb_devname);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
321
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
322 if ((fb_fd = open(fb_devname, O_RDWR)) == -1) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
323 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
324 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
325 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
326
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
327 if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
328 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
329 strerror(errno));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
330 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
331 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
332
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
333 if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
334 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
335 strerror(errno));
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
336 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
337 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
338
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
339 if (verbose) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
340 printf("fb_finfo:\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
341 printf(" id: %s\n", fb_finfo.id);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
342 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
343 fb_finfo.smem_len);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
344 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
345
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
346 printf("fb_vinfo:\n");
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
347 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
348 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
349 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
350 }
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 if (fb_finfo.accel != FB_ACCEL_3DFX_BANSHEE) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
353 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
354 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
355 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
356 if (fb_vinfo.bits_per_pixel != 16) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
357 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
358 return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
359 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
360 //return -1;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
361
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
362
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
363 screenwidth = fb_vinfo.xres;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
364 screenheight = fb_vinfo.yres;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
365 screendepth = 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
366 // Store sizes for later
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
367 in_width = width;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
368 in_height = height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
369 in_format = format;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
370
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
371 if (fullscreen) {
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
372 double exrat;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
373
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
374 if (verbose)
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
375 printf("vo_tdfxfb->init(): fullscreen mode...\n");
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
376
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
377 vidwidth = screenwidth;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
378 vidheight = screenheight;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
379
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
380 exrat = (double)in_width / in_height;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
381 if (verbose)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
382 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
383 if (screenwidth / exrat <= screenheight)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
384 vidheight = (double)screenwidth / exrat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
385 else
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
386 vidwidth = (double)screenheight * exrat;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
387
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
388 vidx = (screenwidth - vidwidth) / 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
389 vidy = (screenheight - vidheight) / 2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
390
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
391 if (verbose) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
392 printf("vo_3dfx->init(): vidwidth => %d\n", vidwidth);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
393 printf("vo_3dfx->init(): vidheight => %d\n", vidheight);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
394 printf("vo_3dfx->init(): vidx => %d\n", vidx);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
395 printf("vo_3dfx->init(): vidy => %d\n", vidy);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
396 }
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
397 } else {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
398 if (in_width > screenwidth || in_height > screenheight) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
399 printf("vo_tdfxfb->init(): your resolution is small for play move...\n");
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
400 return -1;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
401 } else {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
402 vidwidth = in_width;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
403 vidheight = in_height;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
404 vidx = (screenwidth - in_width) / 2;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
405 vidy = (screenheight - in_height) / 2;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
406 }
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
407 }
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 signal(SIGALRM,sighup);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
410 //alarm(120);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
411
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 // access to 3dfx hardware....
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
414 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
415 MAP_SHARED, fb_fd, 0);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
416 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
417 MAP_SHARED, fb_fd, fb_finfo.smem_len);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
418
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
419 if (memBase0 == (uint32_t *)0xFFFFFFFF ||
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
420 memBase1 == (uint32_t *)0xFFFFFFFF)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
421 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
422 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
423 memBase0, memBase1, errno);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
424 }
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 tdfx_iobase = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
428
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
429 // Set up global pointers
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
430 reg_IO = (void *)memBase0 + VOODOO_IO_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
431 reg_2d = (void *)memBase0 + VOODOO_2D_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
432 reg_YUV = (void *)memBase0 + VOODOO_YUV_REG_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
433 fb_YUV = (void *)memBase0 + VOODOO_YUV_PLANE_OFFSET;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
434
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
435 vidpage0offset = 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
436 vidpage1offset = screenwidth * screenheight * screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
437 in_page0_offset = vidpage1offset + screenwidth * screenheight * screendepth;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
438
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
439 vidpage0 = (void *)memBase1 + (unsigned long int)vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
440 vidpage1 = (void *)memBase1 + (unsigned long int)vidpage1offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
441 in_page0 = (void *)memBase1 + (unsigned long int)in_page0_offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
442
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
443 vid_banshee_xy = XYREG(vidx, vidy);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
444 vid_banshee_format = screenwidth*2 | VOODOO_BLT_FORMAT_16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
445 vid_banshee_size = XYREG(vidwidth, vidheight);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
446
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
447 in_banshee_size = XYREG(in_width, in_height);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
448
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
449 //video_out_3dfx.flip_page = flip_page_all;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
450 draw_alpha_p = vo_draw_alpha_rgb16;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
451
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
452 switch (in_format) {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
453 case IMGFMT_YV12:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
454 video_out_tdfxfb.draw_slice = draw_slice_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
455 video_out_tdfxfb.draw_frame = draw_frame_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
456 video_out_tdfxfb.flip_page = flip_page_YV12;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
457 video_out_tdfxfb.draw_osd = draw_osd_YV12;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
458 draw_alpha_p = vo_draw_alpha_yuy2;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
459 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_YUYV;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
460 #ifdef YV12_CONV_METH
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
461 yuv2rgb_init(16, MODE_RGB);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
462 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_16;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
463 draw_alpha_p = vo_draw_alpha_rgb16;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
464 #endif
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
465 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
466 case IMGFMT_YUY2:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
467 video_out_tdfxfb.draw_slice = draw_slice_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
468 video_out_tdfxfb.draw_frame = draw_frame_YUY2_BGR16;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
469 video_out_tdfxfb.flip_page = flip_page_vidpage10;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
470
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
471 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_YUYV;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
472 in_bytepp = 2;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
473 #if VO_TDFXFB_METHOD == 2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
474 *our_out_buffer = in_page0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
475 #endif
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
476
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
477 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
478 case IMGFMT_BGR|16:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
479 video_out_tdfxfb.draw_slice = draw_slice_YUY2_BGR16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
480 video_out_tdfxfb.draw_frame = draw_frame_YUY2_BGR16;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
481 video_out_tdfxfb.flip_page = flip_page_vidpage10;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
482
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
483 in_banshee_format = in_width * 2 | VOODOO_BLT_FORMAT_16;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
484 in_bytepp = 2;
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
485 #if VO_TDFXFB_METHOD == 2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
486 *our_out_buffer = in_page0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
487 #endif
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
488 break;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
489 }
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 // Clear pages 1,2,3
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
493 // leave page 0, that belongs to X.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
494 // So does part of 1. Oops.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
495 memset(vidpage0, 0x00, screenwidth * screenheight * screendepth);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
496 memset(vidpage1, 0x00, screenwidth * screenheight * screendepth);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
497 memset(in_page0, 0x00, in_width * in_height * in_bytepp);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
498
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
499 // Show page 0 (unblanked)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
500 reg_IO->vidDesktopStartAddr = vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
501 //banshee_make_room(1);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
502 //tdfx_outl(VIDDESKSTART, vidpage1offset);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
503
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
504 /* 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
505
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
506 atexit(restore);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
507
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
508 printf("(display) tdfxfb initialized %p/%p\n",memBase0,memBase1);
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
509 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
510 }
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 static const vo_info_t*
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
513 get_info(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
514 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
515 return &vo_info;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
516 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
517
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 // 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
520
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
521 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
522 draw_frame_YV12(uint8_t *src[])
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
523 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
524 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
525 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
526
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
527 #ifndef YV12_CONV_METH
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
528
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
529 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
530 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
531 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
532 void *img_y = image[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
533 void *img_u = image[1];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
534 void *img_v = image[2];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
535 uint32_t j;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
536 uint32_t *YUV_U = &fb_YUV->U[0],
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
537 *YUV_V = &fb_YUV->V[0],
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
538 *YUV_Y = &fb_YUV->Y[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
539 uint32_t height2 = h >> 1;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
540
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
541 #if 0
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
542 printf("stride[0] => %d\n", stride[0]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
543 printf("stride[1] => %d\n", stride[1]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
544 printf("stride[2] => %d\n", stride[2]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
545 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
546 #endif
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
547 #if 0
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
548 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
549 (uint32_t *)image[2], in_page0_offset, x, y, w, h);
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
550 #endif
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
551
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
552 //reg_YUV->yuvBaseAddr = to + mystride * 2 * py;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
553 reg_YUV->yuvBaseAddr = in_page0_offset + w * 2 * y;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
554 reg_YUV->yuvStride = w << 1;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
555
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
556 for (j = 0; j < height2; j++)
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
557 {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
558 memcpy(YUV_U, img_u, stride[1]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
559 memcpy(YUV_V, img_v, stride[2]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
560 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
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 YUV_U += VOODOO_YUV_STRIDE; img_u += stride[1];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
563 YUV_V += VOODOO_YUV_STRIDE; img_v += stride[2];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
564 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
565
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
566 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
567 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
568
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
569 #else /* !YV12_CONV_METH */
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
570 // -------------------------------------------------------------------
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
571 // YV12 with converting support
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
572
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
573 static uint32_t
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
574 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
575 {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
576 uint8_t *dest = (uint8_t *)(in_page0) + (in_width * y + x) * 2;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
577 //dump_yuv_planar((uint32_t *)image[0], (uint32_t *)image[1],
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
578 // (uint32_t *)image[2], in_page0_offset, x, y, w, h);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
579 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
580 stride[0], stride[1]);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
581 return 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
582 }
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 #endif /* else ! YV12_CONV_METH */
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
585
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
586 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
587 flip_page_YV12(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
588 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
589 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
590 vidpage0offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
591 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
592 in_page0_offset, 0,
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
593 in_banshee_format, in_banshee_size, 0);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
594
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
595 }
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 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
598 unsigned char *srca, int stride)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
599 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
600 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
601 uint32_t dstride = in_width * 2; // 2 <= bpp
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
602 //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
603 (*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
604 }
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 static void draw_osd_YV12(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
608 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
609 #ifndef HWACCEL_OSD_M2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
610 //vo_draw_text(vidwidth, vidheight, draw_alpha);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
611 #else
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
612 //vo_draw_text(vidwidth, vidheight, my_draw_alpha_accel);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
613 #endif /* else ! HWACCEL_OSD_M2 */
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
614 vo_draw_text(in_width, in_height, draw_alpha_YV12);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
615 }
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
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
618
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
619 // -------------------------------------------------------------------
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
620 // YUYV & BGR16 support
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
621
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
622 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
623 draw_frame_YUY2_BGR16(uint8_t *src[])
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
624 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
625 #if VO_TDFXFB_METHOD == 1
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
626 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
627 #endif
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
628 // blt to offscreen page.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
629 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
630 vidpage1offset, vid_banshee_xy,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
631 vid_banshee_format, vid_banshee_size,
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
632 in_page0_offset, 0,
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
633 in_banshee_format, in_banshee_size, 0);
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
634 banshee_wait_idle();
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
635 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
636 }
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 static uint32_t
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
639 draw_frame_YUY2_BGR16_h2s_bitblt(uint8_t *src[])
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
640 {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
641 uint32_t i, len;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
642 uint32_t *launch = (uint32_t *)&reg_2d->launchArea[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
643 uint32_t *src32 = (uint32_t *)src[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
644 voodoo_2d_reg saved_regs = *reg_2d;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
645
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
646 reg_2d->commandExtra = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
647 reg_2d->clip0Min = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
648 reg_2d->clip0Max = 0xffffffff;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
649
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
650 reg_2d->colorFore = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
651 reg_2d->colorBack = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
652
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
653 reg_2d->srcXY = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
654 //reg_2d->srcBaseAddr = (from);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
655
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
656 // reg_2d->srcFormat = 0x00400000 | BIT(20); // byte allignment + byte swizzle...
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
657 // YUYV + dword packet
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
658 reg_2d->srcFormat = in_width*2 | VOODOO_BLT_FORMAT_YUYV; // | (2 << 22);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
659 reg_2d->dstXY = vid_banshee_xy;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
660 reg_2d->dstSize = vid_banshee_size;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
661 reg_2d->dstBaseAddr = vidpage1offset;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
662 reg_2d->dstFormat = vid_banshee_format;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
663
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
664 // host-to-screen blting + tranpasparent
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
665 //reg_2d->command = 3 | (1 << 16)| (ROP_COPY << 24);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
666 reg_2d->command = 3 | (ROP_COPY << 24);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
667
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
668 i = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
669 len = in_width * in_height * 2; /* 2 => 16 bit */
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
670 len >>= 2; /* / 4 */
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
671 for (;;) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
672 if (i == len) break; launch[0] = src32[i]; i++;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
673 if (i == len) break; launch[1] = src32[i]; i++;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
674 if (i == len) break; launch[2] = src32[i]; i++;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
675 if (i == len) break; launch[3] = src32[i]; i++;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
676 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
677 banshee_wait_idle();
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
678 restore_regs(&saved_regs);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
679 return;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
680 }
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 static uint32_t
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
683 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
684 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
685 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
686 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
687
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
688 static void
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
689 flip_page_vidpage10(void)
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
690 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
691 uint32_t o;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
692 void *p;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
693
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
694 // flip screen pages.
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
695 o = vidpage0offset; vidpage0offset = vidpage1offset; vidpage1offset = o;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
696 p = vidpage0; vidpage0 = vidpage1; vidpage1 = p;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
697
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
698 reg_IO->vidDesktopStartAddr = vidpage0offset;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
699 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
700
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
701 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
702 unsigned char *srca, int stride)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
703 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
704 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
705 uint32_t dstride = screenwidth * 2; // 2 <= bpp
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
706 //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
707 (*draw_alpha_p)(w, h, src, srca, stride, dst, dstride);
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
708 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
709
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
710 static void draw_osd(void)
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
711 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
712 #ifndef HWACCEL_OSD_M2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
713 vo_draw_text(vidwidth, vidheight, draw_alpha);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
714 #else
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
715 vo_draw_text(vidwidth, vidheight, my_draw_alpha_accel);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
716 #endif /* else ! HWACCEL_OSD_M2 */
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
717 }
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 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
722 draw_frame(uint8_t *src[])
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
723 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
724 /* dummy */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
725 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
726 }
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 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
729 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
730 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
731 /* dummy */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
732 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
733 }
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 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
736 flip_page(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
737 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
738 /* dummy */
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
739 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
740
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
741 /*- ----------------------------------------------------------------- -*/
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
742
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
743 static uint32_t
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
744 query_format(uint32_t format)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
745 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
746 switch(format){
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
747 case IMGFMT_YV12:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
748 return 4|2; // 4|2;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
749 case IMGFMT_YUY2:
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
750 if (verbose) printf("query_format: IMGFMT_YUY2\n");
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
751 return 4|2; //4|2;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
752 case IMGFMT_BGR|16:
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
753 if (verbose) printf("query_format: IMGFMT_BGR|16\n");
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
754 return 4|2; // 4|2; /* osd + ????? */
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
755 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
756 return 0;
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
757 }
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 static void
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
760 uninit(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
761 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
762 reg_IO->vidDesktopStartAddr = vidpage0offset;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
763 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
764
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
765
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
766 static void check_events(void)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
767 {
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
768 }
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
769
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
770 #ifdef HWACCEL_OSD_M2
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
771
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
772 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
773 unsigned char *srca, int stride)
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
774 {
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
775 int y, x;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
776 uint32_t pbuf, pcnt;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
777 uint32_t *launch = (uint32_t *)&reg_2d->launchArea[0];
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
778 voodoo_2d_reg saved_regs = *reg_2d;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
779
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
780 reg_2d->commandExtra = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
781 reg_2d->clip0Min = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
782 reg_2d->clip0Max = 0xffffffff;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
783
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
784 reg_2d->colorFore = 0xffff;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
785 reg_2d->colorBack = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
786
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
787 reg_2d->srcXY = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
788 //reg_2d->srcBaseAddr = (from);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
789
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
790 reg_2d->srcFormat = 0x00400000 | BIT(20); // byte allignment + byte swizzle...
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
791 //reg_2d->srcSize = XYREG(w, h);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
792 reg_2d->dstSize = XYREG(w, h);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
793
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
794 reg_2d->dstBaseAddr = vidpage1offset;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
795 reg_2d->dstXY = XYREG(vidx+x0, vidy+y0);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
796 reg_2d->dstFormat = vid_banshee_format;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
797
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
798 // host-to-screen blting + tranpasparent
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
799 reg_2d->command = 3 | (1 << 16)| (ROP_COPY << 24);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
800
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
801 pcnt = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
802 pbuf = 0;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
803 for (y = 0; y < h; y++) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
804 for (x = 0; x < w; x++) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
805 pbuf = (pbuf << 1) | (((src[x] > 150) ? 1 : 0));
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
806 if (++pcnt == 32) { launch[0] = pbuf; pcnt = 0; pbuf = 0; }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
807 }
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 if ((pcnt % 8) != 0) {
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
810 pbuf <<= 8 - (pcnt % 8);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
811 pcnt += 8 - (pcnt % 8);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
812 if (pcnt == 32) { launch[0] = pbuf; pcnt = 0; pbuf = 0; }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
813 }
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 src += stride;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
816 srca += stride;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
817 }
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
818 if (pcnt != 0) launch[0] = pbuf;
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
819
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
820 banshee_wait_idle();
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
821 restore_regs(&saved_regs);
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
822 return;
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
823 }
2350
d3a67a417352 new version by zsteva@ptt.yu
arpi
parents: 1979
diff changeset
824 #endif /* ! HWACCEL_OSD_M2 */
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
825
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
826 static uint32_t preinit(const char *arg)
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
827 {
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
828 return 0;
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
829 }
1979
6278f566cd91 tdfxfb yuv driver by Zeljko Stevanovic <zsteva@ptt.yu>
arpi
parents:
diff changeset
830
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
831 static void query_vaa(vo_vaa_t *vaa)
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
832 {
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
833 memset(vaa,0,sizeof(vo_vaa_t));
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 2732
diff changeset
834 }