savage_streams.h revision ab47cfaa
1#ifndef __SAVAGE_STREAMS_H__
2
3# define __SAVAGE_STREAMS_H__
4
5/**************************************
6   S3 streams processor
7**************************************/
8
9#define EXT_MISC_CTRL2              0x67
10
11/* New streams */
12
13/* CR67[2] = 1 : enable secondary stream 1 */
14#define ENABLE_STREAM1              0x04
15/* CR67[1] = 1 : enable secondary stream 2 */
16#define ENABLE_STREAM2              0x02
17/* mask to clear CR67[2,1] */
18#define NO_STREAMS                  0xF9
19/* CR67[3] = 1 : Mem-mapped regs */
20#define USE_MM_FOR_PRI_STREAM       0x08
21
22#define HDM_SHIFT	16
23#define HDSCALE_4	(2 << HDM_SHIFT)
24#define HDSCALE_8	(3 << HDM_SHIFT)
25#define HDSCALE_16	(4 << HDM_SHIFT)
26#define HDSCALE_32	(5 << HDM_SHIFT)
27#define HDSCALE_64	(6 << HDM_SHIFT)
28
29/* Old Streams */
30
31#define ENABLE_STREAMS_OLD	    0x0c
32#define NO_STREAMS_OLD		    0xf3
33/* CR69[0] = 1 : Mem-mapped regs */
34#define USE_MM_FOR_PRI_STREAM_OLD   0x01
35
36
37/*
38 * There are two different streams engines used in the Savage line.
39 * The old engine is in the 3D, 4, Pro, and Twister.
40 * The new engine is in the 2000, MX, IX, and Super.
41 */
42
43
44/* streams registers for old engine */
45#define PSTREAM_CONTROL_REG		0x8180
46#define COL_CHROMA_KEY_CONTROL_REG	0x8184
47#define SSTREAM_CONTROL_REG		0x8190
48#define CHROMA_KEY_UPPER_BOUND_REG	0x8194
49#define SSTREAM_STRETCH_REG		0x8198
50#define COLOR_ADJUSTMENT_REG		0x819C
51#define BLEND_CONTROL_REG		0x81A0
52#define PSTREAM_FBADDR0_REG		0x81C0
53#define PSTREAM_FBADDR1_REG		0x81C4
54#define PSTREAM_STRIDE_REG		0x81C8
55#define DOUBLE_BUFFER_REG		0x81CC
56/* updated by peterzhu,original define is DOUBLE_BUFFER_REG*/
57#define MULTIPLE_BUFFER_REG             0x81CC
58#define SSTREAM_FBADDR0_REG		0x81D0
59#define SSTREAM_FBADDR1_REG		0x81D4
60#define SSTREAM_STRIDE_REG		0x81D8
61#define SSTREAM_VSCALE_REG		0x81E0
62#define SSTREAM_VINITIAL_REG		0x81E4
63#define SSTREAM_LINES_REG		0x81E8
64#define STREAMS_FIFO_REG		0x81EC
65#define PSTREAM_WINDOW_START_REG	0x81F0
66#define PSTREAM_WINDOW_SIZE_REG		0x81F4
67#define SSTREAM_WINDOW_START_REG	0x81F8
68#define SSTREAM_WINDOW_SIZE_REG		0x81FC
69#define FIFO_CONTROL			0x8200
70#define PSTREAM_FBSIZE_REG		0x8300
71#define SSTREAM_FBSIZE_REG		0x8304
72#define SSTREAM_FBADDR2_REG		0x8308
73
74#define OS_XY(x,y)	(((x)<<16)|(y+1)) /*(((x+1)<<16)|(y+1))*/
75#define OS_WH(x,y)	(((x-1)<<16)|(y))
76
77/* Streams Processor macros */
78#define H_Shift                 0
79#define H_Mask                  (((1L << 11) - 1) << H_Shift)
80#define W_Shift                 16
81#define W_Mask                  (((1L << 11) - 1) << W_Shift)
82
83#define Y_Shift                 0
84#define Y_Mask                  (((1L << 11) - 1) << Y_Shift)
85#define X_Shift                 16
86#define X_Mask                  (((1L << 11) - 1) << X_Shift)
87
88#define XY(x,y)      ((((x+1)<<X_Shift)&X_Mask) | (((y+1)<<Y_Shift)&Y_Mask))
89#define WH(w,h)      ((((w-1)<<W_Shift)&W_Mask) | (((h)<<H_Shift)&H_Mask))
90
91#define HSCALING_Shift    0
92#define HSCALING_Mask     (((1L << 16)-1) << HSCALING_Shift)
93#define HSCALING(w0,w1)   ((((unsigned int)(((double)w0/(double)w1) * (1 << 15))) \
94                               << HSCALING_Shift) \
95                           & HSCALING_Mask)
96
97#define VSCALING_Shift    0
98#define VSCALING_Mask     (((1L << 20)-1) << VSCALING_Shift)
99#define VSCALING(h0,h1)   ((((unsigned int) (((double)h0/(double)h1) * (1 << 15))) \
100                               << VSCALING_Shift) \
101                           & VSCALING_Mask)
102
103/* New Streams Processor */
104/* Stream Processor 1 */
105
106/* Primary Stream 1 Frame Buffer Address 0 */
107#define PRI_STREAM_FBUF_ADDR0           0x81c0
108/* Primary Stream 1 Frame Buffer Address 0 */
109#define PRI_STREAM_FBUF_ADDR1           0x81c4
110/* Primary Stream 1 Stride */
111#define PRI_STREAM_STRIDE               0x81c8
112/* Primary Stream 1 Frame Buffer Size */
113#define PRI_STREAM_BUFFERSIZE           0x8214
114
115/* Secondary stream 1 Color/Chroma Key Control */
116#define SEC_STREAM_CKEY_LOW             0x8184
117/* Secondary stream 1 Chroma Key Upper Bound */
118#define SEC_STREAM_CKEY_UPPER           0x8194
119/* Blend Control of Secondary Stream 1 & 2 */
120#define BLEND_CONTROL                   0x8190
121/* Secondary Stream 1 Color conversion/Adjustment 1 */
122#define SEC_STREAM_COLOR_CONVERT1       0x8198
123/* Secondary Stream 1 Color conversion/Adjustment 2 */
124#define SEC_STREAM_COLOR_CONVERT2       0x819c
125/* Secondary Stream 1 Color conversion/Adjustment 3 */
126#define SEC_STREAM_COLOR_CONVERT3       0x81e4
127/* Secondary Stream 1 Horizontal Scaling */
128#define SEC_STREAM_HSCALING             0x81a0
129/* Secondary Stream 1 Frame Buffer Size */
130#define SEC_STREAM_BUFFERSIZE           0x81a8
131/* Secondary Stream 1 Horizontal Scaling Normalization (2K only) */
132#define SEC_STREAM_HSCALE_NORMALIZE	0x81ac
133/* Secondary Stream 1 Horizontal Scaling */
134#define SEC_STREAM_VSCALING             0x81e8
135/* Secondary Stream 1 Frame Buffer Address 0 */
136#define SEC_STREAM_FBUF_ADDR0           0x81d0
137/* Secondary Stream 1 Frame Buffer Address 1 */
138#define SEC_STREAM_FBUF_ADDR1           0x81d4
139/* Secondary Stream 1 Frame Buffer Address 2 */
140#define SEC_STREAM_FBUF_ADDR2           0x81ec
141/* Secondary Stream 1 Stride */
142#define SEC_STREAM_STRIDE               0x81d8
143/* Secondary Stream 1 Window Start Coordinates */
144#define SEC_STREAM_WINDOW_START         0x81f8
145/* Secondary Stream 1 Window Size */
146#define SEC_STREAM_WINDOW_SZ            0x81fc
147/* Secondary Streams Tile Offset */
148#define SEC_STREAM_TILE_OFF             0x821c
149/* Secondary Stream 1 Opaque Overlay Control */
150#define SEC_STREAM_OPAQUE_OVERLAY       0x81dc
151
152
153/* Stream Processor 2 */
154
155/* Primary Stream 2 Frame Buffer Address 0 */
156#define PRI_STREAM2_FBUF_ADDR0          0x81b0
157/* Primary Stream 2 Frame Buffer Address 1 */
158#define PRI_STREAM2_FBUF_ADDR1          0x81b4
159/* Primary Stream 2 Stride */
160#define PRI_STREAM2_STRIDE              0x81b8
161/* Primary Stream 2 Frame Buffer Size */
162#define PRI_STREAM2_BUFFERSIZE          0x8218
163
164/* Secondary Stream 2 Color/Chroma Key Control */
165#define SEC_STREAM2_CKEY_LOW            0x8188
166/* Secondary Stream 2 Chroma Key Upper Bound */
167#define SEC_STREAM2_CKEY_UPPER          0x818c
168/* Secondary Stream 2 Horizontal Scaling */
169#define SEC_STREAM2_HSCALING            0x81a4
170/* Secondary Stream 2 Horizontal Scaling */
171#define SEC_STREAM2_VSCALING            0x8204
172/* Secondary Stream 2 Frame Buffer Size */
173#define SEC_STREAM2_BUFFERSIZE          0x81ac
174/* Secondary Stream 2 Frame Buffer Address 0 */
175#define SEC_STREAM2_FBUF_ADDR0          0x81bc
176/* Secondary Stream 2 Frame Buffer Address 1 */
177#define SEC_STREAM2_FBUF_ADDR1          0x81e0
178/* Secondary Stream 2 Frame Buffer Address 2 */
179#define SEC_STREAM2_FBUF_ADDR2          0x8208
180/* Multiple Buffer/LPB and Secondary Stream 2 Stride */
181#define SEC_STREAM2_STRIDE_LPB          0x81cc
182/* Secondary Stream 2 Color conversion/Adjustment 1 */
183#define SEC_STREAM2_COLOR_CONVERT1      0x81f0
184/* Secondary Stream 2 Color conversion/Adjustment 2 */
185#define SEC_STREAM2_COLOR_CONVERT2      0x81f4
186/* Secondary Stream 2 Color conversion/Adjustment 3 */
187#define SEC_STREAM2_COLOR_CONVERT3      0x8200
188/* Secondary Stream 2 Window Start Coordinates */
189#define SEC_STREAM2_WINDOW_START        0x820c
190/* Secondary Stream 2 Window Size */
191#define SEC_STREAM2_WINDOW_SZ           0x8210
192/* Secondary Stream 2 Opaque Overlay Control */
193#define SEC_STREAM2_OPAQUE_OVERLAY      0x8180
194
195/* savage 2000 */
196#define SEC_STREAM_COLOR_CONVERT0_2000       0x8198
197#define SEC_STREAM_COLOR_CONVERT1_2000       0x819c
198#define SEC_STREAM_COLOR_CONVERT2_2000       0x81e0
199#define SEC_STREAM_COLOR_CONVERT3_2000       0x81e4
200#define SEC_STREAM_SRC_START_2000            0x818c
201#define SEC_STREAM_SRC_SIZE_2000             0x81a8
202#define SEC_STREAM_BUFFERSIZE_2000           0x81a4
203#define S_SRC_H_Mask            0x00000fff
204#define S_SRC_W_Shift           16
205#define S_SRC_W_Mask            0x0fff0000
206#define SRCSIZE(w,h)   (((w <<S_SRC_W_Shift) & S_SRC_W_Mask) | (h & S_SRC_H_Mask))
207#define SRCSTART(x,y)  (((x <<S_SRC_W_Shift) & 0x7ff0000) | (y & 0x000007ff))
208#define VSCALING_2000(h0,h1)   ((unsigned int) (((float)h0/(float)h1) * (float)(65536.0) ))
209#define HSCALING_NORMALIZE(h0,h1)  ((unsigned int) ((float)2048.0 * ((float)h0/ (float)h1))) << 16
210#define HSCALING_2000(w0,w1)   ((unsigned int) (((float)w0/ (float)w1) * (float)(65536.0)))
211#define XY_2000(x,y)      ((((x)<<X_Shift)&X_Mask) | (((y)<<Y_Shift)&Y_Mask))
212#define WH_2000(w,h)      ((((w)<<W_Shift)&W_Mask) | (((h)<<H_Shift)&H_Mask))
213
214#define BASE_PAD 0xf
215
216#define  STREAMS_MODE32 0x7
217#define  STREAMS_MODE24 0x6
218#define  STREAMS_MODE16 0x5 /* @@@ */
219
220#define SSTREAMS_MODE(bpp) (bpp > 16 ? (bpp > 24 ? STREAMS_MODE32 :\
221				       STREAMS_MODE24) : STREAMS_MODE16)
222
223#endif /*__SAVAGE_STREAMS_H__*/
224