summaryrefslogtreecommitdiffstats
path: root/drivers/hacking.ati
blob: 20c9bfa8ea90eae4062b6e2a5de93e1b7f7a26f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
                       ATI chips hacking
                       =================
                                                Dedicated to ATI's hackers.

Preface
~~~~~~~
This document will compare ATI chips only from point of DAC and video overlay.
There are lots of difference from 3D point, dual-head support, tv-out support
and many other things but it's already perfectly different story.
This document doesn't include information about ATI AIW (All In Wonder) chips.

What are units on modern ATI chips:
DAC   - (Digital to Analog Convertor) controls CRTC, LCD, DFP monitor's output
        Consists from:
                PLL  - (Programable line length) registers
                CRTC - CRT controller
                LCD/DFP scaler
                surface control
DAC2  - controls CRTC, LCD, DFP monitor's output on second head
TVDAC - controls Composite Video and Super Video output ports
        Consists from:
                TV_PLL
                TV scaler & sync unit
                TV format convertor (PAL/NTSC)
TVCAP - controls Video-In port
MPP   - Miscellaneous peripheral port. (includes macrovision's filter - copy
        protection mechanism)
OV    - Video overlay (YUV BES) (include subpictures, gamma correction and
        adaptive deinterlacing)
CAP0  - Video capturing
CAP1  - Video capturing (second unit)
RT    - Rage theatre: video encoding and mixing
MUX   - video muxer
MEM   - PCI/AGP bus mastering
2D    - GUI engine
3D    - 3D-OpenGL engine (There are lots of stuff)
I2C   - I2C Bus control

This document is mainly related only with OV unit ;)
Video decoding diagram:

RAM memory:   [ App ]    Copies YUV image to overlay memory
                 |       <-- (It's possible to program DMA here)
overlay memory:[ OV ]    performs scaling and YUVtoRGB convertion
                /\
RGB memory:   /    \
            /  [ macrovision ]  performs copy protection filtering
          /            \        (unneeded but presented by default thing;)
 [ CRTC/LCD/DFP DAC ] [ TV DAC ] convert RGB memory to CRTC and NTSC/PAL signals
          |                |
 [CRTC/LCD/DFP Monitor] [TV-screen]

History
~~~~~~~
  What is history of ATI's chips? I can be wrong but below is my vision
of this question:

0. I don't know any earlied chips :(
1. Mach8
2. Mach16
3. Mach32

4. Mach64.
        It's first chip which has support from side of open
        source drivers. Set of mach64 chips is:
                mach64GX (ATI888GX00)
                mach64CX (ATI888CX00)
                mach64CT (ATI264CT)
                mach64ET (ATI264ET)
                mach64VTA3 (ATI264VT)
                mach64VTA4 (ATI264VT)
                mach64VTB (ATI264VTB)
                mach64VT4 (ATI264VT4)

5. 3D rage chips.
        It seems that these chips have fully compatible by GPU with Mach64
        which is extended by 3D possibilities. Set of 3D rage chips is:
                3D RAGE (GT)
                3D RAGE II+ (GTB)
                3D RAGE IIC (PCI)
                3D RAGE IIC (AGP)
                3D RAGE LT
                3D RAGE LT-G
                3D RAGE PRO (BGA, AGP)
                3D RAGE PRO (BGA, AGP, 1x only)
                3D RAGE PRO (BGA, PCI)
                3D RAGE PRO (PQFP, PCI)
                3D RAGE PRO (PQFP, PCI, limited 3D)
                3D RAGE (XL)
                3D RAGE LT PRO (AGP)
                3D RAGE LT PRO (PCI)
                3D RAGE Mobility (PCI)
                3D RAGE Mobility (AGP)

6. Rage128 chips.
        These chips have perfectly new GPU which supports memory mapped IO
        space for accelerating port access (It's main cause of incompatibility
        with mach64). Set of Rage128 chips is:
                Rage128 GL RE
                Rage128 GL RF
                Rage128 GL RG
                Rage128 GL RH
                Rage128 GL RI
                Rage128 VR RK
                Rage128 VR RL
                Rage128 VR RM
                Rage128 VR RN
                Rage128 VR RO
                Rage128 Mobility M3 LE
                Rage128 Mobility M3 LF
7. Rage128Pro chips.
        These chips are successors of Rage128 ones.
                Rage128Pro GL PA
                Rage128Pro GL PB
                Rage128Pro GL PC
                Rage128Pro GL PD
                Rage128Pro GL PE
                Rage128Pro GL PF
                Rage128Pro VR PG
                Rage128Pro VR PH
                Rage128Pro VR PI
                Rage128Pro VR PJ
                Rage128Pro VR PK
                Rage128Pro VR PL
                Rage128Pro VR PM
                Rage128Pro VR PN
                Rage128Pro VR PO
                Rage128Pro VR PP
                Rage128Pro VR PQ
                Rage128Pro VR PR
                Rage128Pro VR TR
                Rage128Pro VR PS
                Rage128Pro VR PT
                Rage128Pro VR PU
                Rage128Pro VR PV
                Rage128Pro VR PW
                Rage128Pro VR PX
                Rage128Pro Ultra U1
                Rage128Pro Ultra U2
                Rage128Pro Ultra U3

8. Radeon chips.
        Indeed they could be named Rage256 Pro. (With minor changes is fully
        compatible with Rage128 chips).
                Radeon QD
                Radeon QE
                Radeon QF
                Radeon QG
                Radeon VE QY
                Radeon VE QZ
                Radeon M6 LY
                Radeon M6 LZ
                Radeon M7 LW
9. Radeon2 chips.
        Indeed they could be named Rage512 Pro.
                Radeon2 8500 QL
                Radeon2 7500 QW

10. Radeon3 and newest are cooming soon, but I hope that they will be fully
    compatible with Radeon1 chips.

In Radeon famility there were introduced also FX chips: Radeon FX and
Radeon2 8700 FX. Probably they have the same possibility as other Radeon
but currently it's unknown for me.

What about video overlay and DAC?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Currently it's known that there is only difference between
Mach64 and Rage128 compatible chips:
- They have different logic of io ports programming!
- They are incompatible by port numbers!
But:
- They use the same program logic from register's name point.
(Indeed exists slight difference even between Radeon and Rage128
chips. AFAIK only Radeon has OV0_SLICE_CNTL register which currently
is not used by driver. But I know only its name ;). Also there
is difference in slight adjust of BES position but it's configured
by #ifdef blocks).

Please compare:

(The piece of Back-End Scaler programming)

 Sample for Mach64 compatible chips:
 ***********************************

#define SPARSE_IO_BASE          0x03fcu
#define SPARSE_IO_SELECT        0xfc00u

#define BLOCK_IO_BASE           0xff00u
#define BLOCK_IO_SELECT         0x00fcu

#define MM_IO_SELECT            0x03fcu
#define BLOCK_SELECT            0x0400u
#define DWORD_SELECT            (BLOCK_SELECT | MM_IO_SELECT)

#define IO_BYTE_SELECT          0x0003u

#define SPARSE_IO_PORT          (SPARSE_IO_BASE | IO_BYTE_SELECT)
#define BLOCK_IO_PORT           (BLOCK_IO_BASE | IO_BYTE_SELECT)

#define IOPortTag(_SparseIOSelect, _BlockIOSelect)      \
        (SetBits(_SparseIOSelect, SPARSE_IO_SELECT) |   \
         SetBits(_BlockIOSelect, BLOCK_SELECT | MM_IO_SELECT))
#define SparseIOTag(_IOSelect)  IOPortTag(_IOSelect, 0)
#define BlockIOTag(_IOSelect)   IOPortTag(0, _IOSelect)

...

#define OVERLAY_Y_X_START       BlockIOTag(0x100u)
#define OVERLAY_Y_X_END         BlockIOTag(0x101u)

...

#define OUTREG(_Register, _Value)                              \
    MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \
               (_Register) & MM_IO_SELECT, _Value)

...

OUTREG(OVERLAY_Y_X_START,((drw_x)<<16)|(drw_y)|(1<<31));
OUTREG(OVERLAY_Y_X_END,((drw_x+drw_w)<<16)|(drw_y+drw_h));


 Sample for Rage128 compatible chips:
 ************************************

#define OV0_Y_X_START                          0x0400
#define OV0_Y_X_END                            0x0404

...

#define INREG(addr)             readl((rage_mmio_base)+addr)
#define OUTREG(addr,val)        writel(val, (rage_mmio_base)+addr)

...

rage_mmio_base = ioremap_nocache(pci_resource_start (dev, 2),RAGE_REGSIZE);

...

#ifdef RADEON
#define X_ADJUST 8
#else /* rage128 */
#define X_ADJUST 0
#endif

OUTREG(OV0_Y_X_START,(drw_x+X_ADJUST)|(drw_y<<16));
OUTREG(OV0_Y_X_END,(drw_x+drw_w+X_ADJUST)|(drw_y+drw_h)<<16));

Thus - these chips have almost the same logic from register's name point.
(except the fact that they have swapped 16-bit halfs).
Yes - programming of Rage128 is much simpler of Mach64.


What about other ATI's chips?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I suggest you have latest copy of GATOS-CVS:
http://www.linuxvideo.org
GATOS was designed and introduced as General ATI TV and Overlay Sowfware.
You will be able to find out there a lots of useful hacking utilities
(at location gatos-ati/gatos):
gfxdump - Program for dumping graphics chips registers on Linux and Windows 9X.
          (it's more useful for Win9x to hack their values).
xatitv  - For working with tv-in (currently is under hard development)
atitvout- For working with tv-out
and lot of other stuff.
BUT: After studing of Gatos and X11 stuffs I've found that they are bad
optimized for movie playback.
Please compare:
 radeon_vid - configures video overlay only once and provides DGA to it.
              (doesn't require to be MMX optimized)
 gatos and X11 - configures video overlay at every slice of frame, then
              performs unoptimized copying of source stuff to video memory
              often with using CopyMungedData (it's C-analog of YV12_to_YUY2)
              since there are lacks in yv12 support.
              (is not MMX optimized that's gladly accepted, but probably
               will be never optimized due portability).

hardware IDCT support diagram:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                      |
[ Video parser ] <---------- [ Transport demuxing ] --> [ Audio ]
       |                                |       |
[ Variable length decoder]              |D      |
       |                                |V      |
[ Inverse quantization ]                |D      |
       |                                |       |
-------|---[ video card ]---------+     |s      |
       |                          |     |u      |
[ Run level decode & de-zigzag ]  |     |b      |
       |                          |     |p      |
[    IDCT   ]                     |     |i      |
       |                          |     |c      |
[  Motion compensation  ]         |     |t      |
       |                          |     |u      |
[ Advanced deinterlacing ]        |     |r      |
       |                          |     |e      |
[ Filtered X-Y scaling ] [SUBPIC]-|-----+s   [ OSD ]
       |                     |    |     |       |
[ 4-bit alpha blending ] <---+    |     +-------+
       |                          |
[ YUV to RGB conversion ]         |
-------|--------------------------+
TV-screen or CRT-display


Conslusion:
~~~~~~~~~~~

That's all folk!