summaryrefslogtreecommitdiff
path: root/packages/qte/qte-2.3.10/c7x0-w100-accel.patch
blob: 5cff74623af1ea240ea8fdc4b35f24dc442f36a4 (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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
ATI IMAGEON (W100) Accelerated support
Manuel Teira <manuel.teira@telefonica.net>

#
# Patch managed by http://www.holgerschurig.de/patcher.html
#

--- qt-2.3.10/configure~w100
+++ qt-2.3.10/configure
@@ -325,6 +325,9 @@
    -accel-matrox)
 	QWS_ACCEL_MATROX=y
 	;;
+   -accel-w100)
+	QWS_ACCEL_W100=y
+	;;
    -qvfb)
 	QWS_QVFB=y
 	;;
@@ -726,6 +729,10 @@
 then
     QT_CXX="$QT_CXX -DQT_NO_QWS_MATROX"
 fi
+if [ -z "$QWS_ACCEL_W100" -a -n "$EMB" ]
+then
+    QT_CXX="$QT_CXX -DQT_NO_QWS_W100"
+fi
 if [ -z "$QWS_VNC" -a -n "$EMB" ]
 then
     QT_CXX="$QT_CXX -DQT_NO_QWS_VNC"
@@ -1338,6 +1345,7 @@
     -accel-voodoo3 ..... Enable Voodoo3 acceleration.
     -accel-mach64 ...... Enable Mach64 acceleration.
     -accel-matrox ...... Enable Matrox MGA acceleration.
+    -accel-w100 ........ Enable ATI Imageon w100 acceleration (experimental).
     -qvfb .............. Enable X11-based Qt Virtual Frame Buffer.
     -vnc ............... Enable VNC server (requires network module).
 
@@ -1462,6 +1470,7 @@
 [ "x$JPEG" = "xyes" ] && QT_LIBS="${QT_LIBS} -ljpeg"
 [ "x$MNG" = "xyes" ] && QT_LIBS="${QT_LIBS} -lmng -ljpeg" # assume JNG support
 [ "x$NAS_SOUND" = "xyes" ] && QT_LIBS="${QT_LIBS} -laudio -lXt" # Xt junk in audio library
+[ "x$QWS_ACCEL_W100" = "xy" ] && QT_LIBS="${QT_LIBS} -laticore" # Aticore W100 support
 QT_LIBS="$L_FLAGS $R_FLAGS $QT_LIBS $l_FLAGS"
 
 
--- qt-2.3.10/src/kernel/qgfxraster_qws.cpp~w100
+++ qt-2.3.10/src/kernel/qgfxraster_qws.cpp
@@ -5945,6 +5945,10 @@
 # include "qgfxmatrox_qws.cpp"
 #endif
 
+#if !defined(QT_NO_QWS_W100)
+# include "qgfxw100_qws.cpp"
+#endif
+
 #if !defined(QT_NO_QWS_VFB)
 # include "qgfxvfb_qws.cpp"
 #endif
@@ -5999,6 +6003,9 @@
 #if !defined(QT_NO_QWS_MATROX)
     { "Matrox", qt_get_screen_matrox, 1 },
 #endif
+#if !defined(QT_NO_QWS_W100)
+    { "W100", qt_get_screen_w100, 1 },
+#endif
 #if !defined(QT_NO_QWS_TRANSFORMED)
     { "Transformed", qt_get_screen_transformed, 0 },
 #endif
--- /dev/null
+++ qt-2.3.10/src/3rdparty/kernel/aticore/aticore.h
@@ -0,0 +1,567 @@
+/*
+ * AtiCore 2D acceleration API
+ *
+ */
+
+#include <inttypes.h>
+#include <sys/types.h>
+
+#ifndef __W100API_H__
+#define __W100API_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SolidRop_GXclear	0x00	/* 0 */
+#define SolidRop_GXand		0xa0	/* src AND dst */
+#define	SolidRop_GXandReverse	0x50	/* src AND NOT dst */
+#define	SolidRop_GXcopy		0xf0	/* src */
+#define SolidRop_GXandInverted	0x0a	/* NOT src AND dst */
+#define	SolidRop_GXnoop		0xaa	/* dst */
+#define	SolidRop_GXxor		0x5a	/* src XOR dst */
+#define	SolidRop_GXor		0xfa	/* src OR dst */
+#define	SolidRop_GXnor		0x05	/* NOT src AND NOT dst */
+#define	SolidRop_GXequiv	0xa5	/* NOT src XOR dst */
+#define	SolidRop_GXinvert	0x55	/* NOT dst */
+#define	SolidRop_GXorReverse	0xf5	/* src OR NOT dst */
+#define	SolidRop_GXcopyInverted	0x0f	/* NOT src */
+#define	SolidRop_GXorInverted	0xaf	/* NOT src OR dst */
+#define	SolidRop_GXnand		0x5f	/* NOT src OR NOT dst */
+#define	SolidRop_GXset		0xff	/* 1 */
+
+#define	BltRop_GXclear		0x00	/* 0 */
+#define	BltRop_GXand		0x88	/* src AND dst */
+#define	BltRop_GXandReverse	0x44	/* src AND NOT dst */
+#define	BltRop_GXcopy		0xcc	/* src */
+#define	BltRop_GXandInverted	0x22	/* NOT src AND dst */
+#define	BltRop_GXnoop		0xaa	/* dst */
+#define	BltRop_GXxor		0x66	/* src XOR dst */
+#define	BltRop_GXor		0xee	/* src OR dst */
+#define	BltRop_GXnor		0x11	/* NOT src AND NOT dst */
+#define	BltRop_GXequiv		0x99	/* NOT src XOR dst */
+#define	BltRop_GXinvert		0x55	/* NOT dst */
+#define	BltRop_GXorReverse	0xdd	/* src OR NOT dst */
+#define	BltRop_GXcopyInverted	0x33	/* NOT src */
+#define	BltRop_GXorInverted	0xbb	/* NOT src OR dst */
+#define	BltRop_GXnand		0x77	/* NOT src OR NOT dst */
+#define	BltRop_GXset		0xff	/* 1 */
+
+#define DSTTYPE_8BPP            2   //8bpp
+#define DSTTYPE_16BPP_1555	3   //16 bpp aRGB 1555
+#define DSTTYPE_16BPP_444	5   //16 bpp aRGB 4444
+
+#define SRCTYPE_1BPP_OPA        0       //mono (expanded to frgd, bkgd)
+#define SRCTYPE_1BPP_TRA        1       //mono (expanded to frgd, leave_alone)
+#define SRCTYPE_EQU_DST         3       //color (same as DST)
+#define SRCTYPE_SOLID_COLOR_BLT 4       //solid color for Blt (use frgd)
+#define SRCTYPE_4BPP            5       //4 bpp
+#define SRCTYPE_12BPP_PACKED    6       //12 bpp packed
+  
+#define ROP3_SRCCOPY		0xcc
+#define ROP3_PATCOPY		0xf0
+  
+#define OVLTYPE_YUV420          7
+#define OVLTYPE_RGB565          8
+
+#define DP_BRUSH_8x8MONOOPA     0 //8x8 mono pattern (expanded to frgd, bkgd )
+#define DP_BRUSH_8x8MONOTRA     1 //8x8 mono pattern (expanded to frgd, leave alone )
+#define DP_PEN_32x1MONOOPA      6 //32x1 mono pattern (expanded to frgd, bkgd)
+#define DP_PEN_32x1MONOTRA      7 //32x1 mono pattern (expanded to frgd, leave alone)
+#define DP_BRUSH_8x8COLOR       10 //8x8 color pattern
+#define DP_BRUSH_SOLIDCOLOR     13 //solid color pattern (frgd)
+#define DB_BRUSH_NONE           15 //No brush used
+
+  typedef struct {
+    int16_t XCoord;
+    int16_t YCoord;
+  } ATI_POINT;
+  
+  typedef struct {
+    int16_t XCoord;
+    int16_t YCoord;
+    int16_t Width;
+    int16_t Height;
+  } ATI_RECT;
+  
+  typedef struct {
+    int16_t X_Top_Left;                  // x coordinate of top left corner
+    int16_t Y_Top_Left;                  // y coordinate of top left corner
+    int16_t X_Bottom_Right;              // x coordinate of bottom right corner
+    int16_t Y_Bottom_Right;              // y coordinate of bottom right corner
+  } ATI_CLIPRECT;
+  
+  typedef struct {
+    uint32_t Count; 
+    uint8_t ScaleXFactor;
+    uint8_t ScaleYFactor;
+    uint8_t BlendOn;
+    uint8_t dummy1;
+  } ATI_STRETCH;
+  
+  typedef struct {
+    uint32_t *lpSrcBitmap;                /* サーフェスのオフセット */
+    uint16_t XCoord;                      /* +4  確定:サーフェス内のx座標 */
+    uint16_t YCoord;                      /* +6  確定:サーフェス内のy座標 */
+    uint16_t SrcPitch;                    /* +8  確定: */
+    uint16_t SrcHeight;                   /* +10 確定: */
+    uint16_t OverlayWidth;                /* オーバレイの幅(Srcと違う値にしても、動的に拡大縮小されたりはしない、意味あんの?) */
+    uint16_t OverlayHeight;
+    uint32_t lpOverlayKey;                /* +16 確定:謎(カラーキー?) */
+    uint8_t OverlayFormat;               /* +20 確定 */
+    uint8_t dummy1;
+    uint16_t dummy2;
+  } ATI_OVERLAYPROP;                      /* 24bytes? */
+  
+  typedef struct {
+    int HInvert;
+    int VInvert;
+  } ATI_EXTVIDEOPROP;
+  
+  typedef struct {
+    ATI_EXTVIDEOPROP ExtVideoProp;
+  } ATI_UNKNOWN1;
+  
+  typedef struct {
+    unsigned long clr_cmp_fcn_src   :3;
+    unsigned long                   :5;
+    unsigned long clr_cmp_fcn_dst   :3;
+    unsigned long                   :13;
+    unsigned long clr_cmp_src       :2;
+    unsigned long                   :6;
+  } clr_cmp_cntl_t;
+
+  typedef struct {
+    uint16_t x;
+    uint16_t y;
+    uint16_t w;
+    uint16_t h;
+    clr_cmp_cntl_t cmp_cntl;
+    unsigned long tcolour;
+  } transbitblt_t;
+
+  typedef struct {
+    uint32_t dummy1;
+    uint32_t dummy2;
+    uint8_t HExpansion;                   /* +8  確定 */
+    uint8_t VExpansion;                   /* +9  確定 */
+    uint8_t dummy3;
+    uint8_t dummy4;
+    uint8_t RConversion;                  /* +12 確定 */
+    uint8_t dummy5;
+    uint8_t dummy6;
+    uint8_t dummy7;
+    ATI_UNKNOWN1 x;
+  } ATI_EXTENDEDOVERLAYPROP;              /* 16byte? */
+  
+  /**
+   * AtiCore initialization.
+   * Sets up the shared memory area
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_ProcessAttach( void );
+  
+  /**
+   * AtiCore finish.
+   *
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_ProcessDetach( void );
+  
+  /**
+   * Allocates a surface on the internal RAM.
+   * Perhaps there's a way to indicate to allocate on the 
+   * internal RAM?
+   * @arg handle Reference to the returned surface handle
+   * @arg offset Returned offset of this surface on the video memory
+   * @arg size   Size (bytes) to be reserved (16 multiple)
+   * @arg direction 
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_AllocateSurface( uint16_t *handle, uint32_t *offset,
+			       uint32_t size, uint32_t direction );
+  
+  /**
+   * Deallocates a given surface.
+   * @arg handle Handle to the allocated surface 
+   * (As returned by AllocateSurface)
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_DestroySurface( uint16_t handle );
+
+  /**
+   * Sets the kind of Raster Operation.
+   * @param rop Raster operation to be performed
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetRopOperation( uint32_t rop );
+  
+  /**
+   * Sets the destination type for raster operation.
+   * @param dsttype
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetDstType( uint32_t dsttype );
+  
+  /**
+   * Sets the source type for raster operation.
+   * @param srctype
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetSrcType( uint32_t srctype );
+  
+  /**
+   * Sets Source clipping rectangle.
+   * @param cliprect Rectangle to perform clipping.
+   * @return 1:success, 0:fail
+   */ 
+  int AtiCore_SetSrcClippingRect( ATI_CLIPRECT *cliprect );
+  
+  /**
+   * Sets Destination clipping rectangle.
+   * @param cliprect Rectangle to perform clipping.
+   * @return 1:success, 0:fail
+   */ 
+  int AtiCore_SetDstClippingRect(ATI_CLIPRECT *cliprect);
+  
+  /**
+   * Sets pitch and offset for source in a raster operation.
+   * @param pitch Pitch (line width) of source
+   * @param offset Offset of source
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetSrcPitchOffset( int pitch, int offset );
+  
+  /**
+   * Sets pitch and offset destination source in a raster operation.
+   * @param pitch Pitch (line width) of destination
+   * @param offset Offset of destination (memory offset)
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetDstPitchOffset( int pitch, int offset );
+  
+  /**
+   * Performs a BitBlt with source rotation.
+   * @param flags Rotation degree
+   * @param dstRect Rectangle for destination Bitblitting
+   * @param srcRect Rectangle for origin bitblitting
+   * @test Tested with specified flags parameter
+   */
+  int AtiCore_BitBltFilpRotate( int flags,
+				ATI_RECT *dstRect, 
+				ATI_RECT *srcRect);
+  
+  /**
+   * Performs a BitBlt with source stretching.
+   * @param option Unknown
+   * @param point Unknown
+   * @param srcRect Source blitting surface
+   * @test Untested
+   */
+  int AtiCore_StretchBlt( ATI_STRETCH *option,
+			  ATI_POINT *point, 
+			  ATI_RECT *srcRect);
+  
+  /**
+   * Waits for the FIFO to be idle at least msecs.
+   * @param msecs Maximum time to wait for FIFO to idle
+   * @return 1:success, 0:fail
+   * @test Untested
+   */
+  int AtiCore_WaitComplete( int msec );
+
+  /**
+   * Allocates a new overlay handle.
+   * @param   handle overlay
+   * @return  1:success, 0:fail
+   * @test Yes
+   */
+  int AtiCore_AllocOverlay( uint16_t *handle );
+
+  /**
+   * Deallocates a overlay handle.
+   * @param  handle overlay
+   * @return 1:success, 0:fail
+   * @test Yes
+   */
+  int AtiCore_ReleaseOverlay( uint16_t handle );
+
+  /**
+   * Sets up an overlay given a handle an a set of properties.
+   * @param handle Allocated handle to setup the overlay.
+   * @param props Overlay properties struct
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetupOverlay( uint16_t handle, ATI_OVERLAYPROP *props );
+
+  /**
+   * Sets up extended overlay features.
+   * @param handle Allocated handle to an overlay
+   * @param props Extended overlay properties
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetupOverlayExtended( uint16_t handle, 
+				    ATI_EXTENDEDOVERLAYPROP *props );
+
+  /**
+   * Enable/Disable an overlayed surface.
+   * @param   handle Overlay to be enabled/disabled
+   * @param   enable 1: Enable, 0: Disable
+   * @return  1:success, 0:fail
+   * @test Tested
+   */
+  int AtiCore_SetOverlayOnOff( uint16_t handle, int enable );
+
+  /**
+   * Sets up the overlay position for a given handle.
+   * @param handle Overlay Handle
+   * @param x X Coordinate (Seems to be a bug with x < 4 )
+   * @param y Y Coordinate
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetOverlayPos( uint16_t handle, 
+			     uint16_t x, 
+			     uint16_t y );
+
+  /**
+   * Translates between physical/virtual addresses.
+   * @param offset VRAM offset to be translated
+   * @param viraddr Virtual address for VRAM
+   * @return 1:success,0:fail
+   */
+  int AtiCore_SetupMemoryTransfer( uint32_t offset, 
+				   uint32_t *viraddr );
+
+  /**
+   * Related with the previous one. It seems to be necesary to be called
+   * but I'm not sure of its function.
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_TerminateMemoryTransfer( void );
+
+  /**
+   * Returns the frontbuffer pitch and offset.
+   * @param pitch Return value for the frontbuffer pitch (width)
+   * @param offset Return value for the frontbuffer offset
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_GetFrontBufferPitchOffset( uint32_t *pitch, 
+					 uint32_t *offset );
+
+  /**
+   * Changes display brighness ?
+   * @param  brightness  -64...63
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetDisplayBrightness( int brightness );
+
+  /**
+   * Returns the amount of available internal/external memory.
+   * @param  internal Pointer to return internal memory size
+   * @param  external Pointer to return external memory size
+   * @return 1:success, 0:fail
+   */
+  int GetAvailableVideoMem( uint32_t *internal, 
+			    uint32_t *external );
+
+/**
+ *
+ * 
+ *
+ 
+ {
+    (uint32_t) 0
+    (uint32_t) 0
+    (uint16_t) 480
+    (uint16_t) 640
+    (uint16_t) 480
+    (uint16_t) 640
+    (uint32_t) 5
+ */
+
+  typedef struct {
+    uint32_t	dummy1;
+    ATI_RECT	Size;
+    uint16_t	Width;
+    uint16_t	Height;
+    uint32_t	Flag;
+  } ATI_GRAPHICWINDOW;
+ 
+ int AtiCore_SetupGraphicWindow(void* );
+
+  /**
+   * It seems to be necessary after AtiCore_ProcessAttach
+   * @param mode: 0xaaab for portrait, 0xaaaa for landscape
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_ProcessAttachSpecialMode( int mode );
+
+  /**
+   * Sets up the position of the Graphic viewport ?
+   * @param x X coordinate
+   * @param y Y coordinate
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetGraphicWindowPos( int x, int y );
+
+  /**
+   * Get the graphic viewport position.
+   * @param x Pointer to xcoord placeholder
+   * @param y Pointer to ycoord placeholder
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_GetGraphicWindowPos( int *x, int *y );
+
+  /**
+   * Sets up the frontbuffer position.
+   * @param offset VRAM offset to be used.
+   * @param x X Coordinate?
+   * @param y Y Coordinate?
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetFrontBuffer( int offset, int x, int y );
+
+  /**
+   * Enable/Disable the frontbuffer?
+   * @param enable 1 enables/ 0 disables
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetGraphicWindowOnOff( int enable );
+
+  /*
+   * Sets the foreground color.
+   * @param colour Color in 565 format (perhaps depends on the source format)
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetFrgColour( int colour );
+
+  /*
+   * Sets the background colour.
+   * @param colour Colour in 565 format (perhaps depends on the source format)
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_SetBkgColour( int colour );
+  
+  /**
+   * Changes the painting brush
+   * @param btype Type of brush to use
+   *        4: Uses the pattern
+   *        6: SolidLine
+   * @param pattern Pointer to a 32 bit pattern
+   * @return 1:success, 0:fail
+   * @test Some values for btype produces a kind of antialiasing line
+   */
+  int AtiCore_BrushType( int btype, unsigned int *pattern );
+
+  /**
+   * Performs a rectangle paint.
+   * @param nrects Number of rectangles to be painted
+   * @param rects Array of rectangles to be painted
+   * @return 1:success, 0:fail
+   * @test Tested with nrects==1
+   */
+  int AtiCore_PaintRect( int nrects , 
+			 ATI_RECT rects[] );
+
+  /**
+   * Draws a set of lines.
+   * @param npoints Number of points in the polyline set
+   * @param points  Pointer to an array of ATI_POINT
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_Polyline( int npoints, ATI_POINT points[] );
+
+  int AtiCore_GetPitchOffsetProperty( void *, void *);
+
+  int AtiCore_CursorOnOff( int, int );
+
+  /**
+   * Performs a BitBlt ROP operation.
+   * @param unk Unknown (Always set to 1)
+   * @param dstrect Bounding destination rect
+   * @param srcrect Bounding source rect
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_BitBlt( int unk, 
+		      ATI_RECT *dstrect, 
+		      ATI_RECT *srcrect );
+
+  /**
+   * Performs a Transparent BitBlt ROP operation.
+   * @param dstrect Transparent DstRect bitblt argument
+   * @param srcrect Transparent SrcRect bitblt argument
+   * @return 1:success, 0:fail
+   * @test Doesn't work. It sets to zero CLR_CMP_CNTL and CLR_CMP_MSK
+   */
+  int AtiCore_TransBitBlt( transbitblt_t *dstrect,
+			   transbitblt_t *srcrect );
+
+  int AtiCore_WakeUpCall( void );
+
+  /**
+   * Draws a set of pixels
+   * @param npoints Number of points to draw
+   * @param points Pointer to an array of ATI_POINT
+   * @return 1:success, 0:fail
+   */
+  int AtiCore_DrawPixel( int npoints, ATI_POINT *points );
+
+  int AtiCore_SetSysClk( unsigned short in0 );
+  int AtiCore_SetFastSysClk( unsigned short in0 );
+  int AtiCore_SetSlowSysClk( unsigned short in0 );
+
+  int AtiCore_GetCursorPos( unsigned long in0,
+			    unsigned short *x,
+			    unsigned short *y );
+  
+
+
+/* ================================================================ */
+/* from libqte.so.2.3.2 */
+/*
+AtiCore_AlphaBlend
+
+AtiCore_Flush
+AtiCore_GammaCorrection
+AtiCore_GetCRC
+AtiCore_GetCursorPos
+AtiCore_GetDeviceInfo
+AtiCore_GetGPIO_Data
+AtiCore_GetGraphicExtended
+AtiCore_GetGraphicWindowPos
+AtiCore_GetLargestVideoMemBlock
+AtiCore_GetLastError
+AtiCore_GetMultiCRC
+AtiCore_GetOverlayPos
+AtiCore_Host
+AtiCore_LoadCursorBitMap
+AtiCore_PolyScanline
+AtiCore_ProcessAttachMinimal(void)?
+AtiCore_ProcessDetachMinimal(void)?
+AtiCore_ProcessDetachSpecialMode
+AtiCore_ReadCfgReg
+AtiCore_ReadMem(int, int)?
+AtiCore_ReadReg(int, int)?
+AtiCore_ScanlineShading
+AtiCore_SetApertures
+AtiCore_SetBytePixelOrder
+AtiCore_SetCursorPos
+AtiCore_SetDisplayParameters
+AtiCore_SetDriverBehaviour
+AtiCore_SetGPIO_Data
+AtiCore_SetOverlayPosUsingGraphicWindowXY
+AtiCore_SetPartialCursor
+AtiCore_SetupGraphicExtended
+AtiCore_SetupPM4
+AtiCore_SmallText
+AtiCore_SubmitPM4Packet
+AtiCore_WriteCfgReg
+AtiCore_WriteMem
+AtiCore_WriteReg
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+++ qt-2.3.10/src/kernel/qgfxw100_qws.cpp
@@ -0,0 +1,1466 @@
+/***************************************************************************
+
+** Imageon driver for qte using libAticore
+** Manuel Teira( 2005 )
+** BUGS
+*  - Enable again internal memory surfaces.
+****************************************************************************/
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <time.h>
+
+#include <qapplication.h>
+
+#ifndef __sparc__
+#include <sys/io.h>
+#endif
+
+#include "qgfxraster_qws.h"
+#include "qgfxlinuxfb_qws.h"
+#include <aticore/aticore.h>
+
+#include <stdarg.h>
+
+class W100Control {
+public:
+
+  typedef enum Loglevel {
+    ERROR = 0,
+    WARNING,
+    INFO
+  };
+
+  typedef enum Opcodes {
+    DRAWLINE = 1,
+    DRAWPOINT,
+    DRAWPOINTS,
+    FILLRECT,
+    SCROLL,
+    BITBLT,
+    POLYLINE,
+    EOO
+  };
+
+  typedef struct Opcode {
+    QString str;
+    int index;
+    bool accelerated;
+    int hits;
+    int misses;
+  };
+
+  static Opcode lOpcodes[];
+
+  static QString level2str( int level )
+  {
+    switch( level ) {
+    case ERROR:
+      return QString( "ERROR" );
+      break;
+    case WARNING:
+      return QString( "WARNING" );
+      break;
+    case INFO:
+      return QString( "INFO" );
+      break;
+    default:
+      return QString( "UNKNOWN" );
+      break;
+    }
+  }
+
+  W100Control():
+    m_loglevel( 0 ),
+    m_enabled( 0 )
+  {
+    m_loglevel = 0;
+    char *var;
+    if ( var = getenv( "W100_DEBUG" ) ) {
+      if ( strtol( var, 0, 0 ) == 1 ) {
+	m_enabled = 1;
+      }
+    }
+
+    if ( m_enabled ) {
+      if ( var = getenv( "W100_DEBUGLEVEL" ) ) {
+	if ( ( m_loglevel = strtol( var, 0, 0 ) ) < 0 ) {
+	  m_loglevel = 0;
+	}
+      }
+
+      QString path( "/mnt/card/w100/w100debug.log" );
+      if ( var = getenv( "W100_DEBUGPATH" ) ) {
+	path = QString( var ) + "/w100debug.log";
+      } 
+      m_logfile = fopen( path.latin1(), "w" );
+      if ( m_logfile == NULL ) m_enabled = 0;
+    }
+
+    Opcode *opcodePtr = lOpcodes;
+    int i = 1;
+    while ( opcodePtr->index != EOO ) {
+      if ( opcodePtr->index != i ) {
+	fprintf( stderr, "Opcode list is not ordered!!\n" );
+	abort();
+      }
+
+      QString varName = "W100_ACCEL_" + opcodePtr->str;
+      char *varPtr;
+      if ( ( varPtr = getenv( varName.latin1() ) )  ) {
+	if ( ( strtol( varPtr, NULL, 0 ) == 0 ) ||
+	     ( strcmp( varPtr, "false" ) == 0 ) )  {
+	  opcodePtr->accelerated = false;
+	}
+      }
+      opcodePtr++;
+      i++;
+    }
+  }
+
+  ~W100Control()
+  {
+    //Dump statistics about any opcode
+    Opcode *opcodePtr = lOpcodes;
+    while ( opcodePtr->index != EOO ) {
+      log( WARNING, "Opcode %s. Accelerated=%s. Hits=%d. Misses=%d",
+	   opcodePtr->str.latin1(),
+	   opcodePtr->accelerated ? "true" : "false",
+	   opcodePtr->hits,
+	   opcodePtr->misses );
+      opcodePtr++;
+    }
+    if ( m_enabled && m_logfile ) {
+      fclose( m_logfile );
+    }
+  }
+
+  bool accelerated( int opcode )
+  {
+    if ( opcode < EOO ) {
+      return lOpcodes[opcode].accelerated;
+    }
+    return false;
+  }
+
+  void addHit( int opcode )
+  {
+    lOpcodes[opcode].hits++;
+    ( *lastop ) = opcode;
+  }
+
+  int lastOp( void ) const
+  {
+    return ( *lastop );
+  }
+
+  void addMiss( int opcode )
+  {
+    lOpcodes[opcode].misses++;
+  }
+
+  void log( int level, const char *fmt, ... )
+  {
+    if ( m_enabled && ( level <= m_loglevel ) ) {
+      char buffer[1024];
+      va_list ap;
+      va_start( ap, fmt );
+      vsnprintf( buffer, 1023, fmt, ap );
+      va_end( ap );
+      fprintf( m_logfile, "%d:%s:%s\n", getpid(),
+	       level2str( level ).latin1(), 
+	       buffer );
+    }
+  }
+
+private:
+  FILE *m_logfile;
+  int m_loglevel;
+  bool m_enabled;
+};
+
+W100Control::Opcode W100Control::lOpcodes[] = {
+  { "DRAWLINE",   W100Control::DRAWLINE,   true, 0, 0 },
+  { "DRAWPOINT",  W100Control::DRAWPOINT,  true, 0, 0 },
+  { "DRAWPOINTS", W100Control::DRAWPOINTS, true, 0, 0 },
+  { "FILLRECT",   W100Control::FILLRECT,   true, 0, 0 },
+  { "SCROLL",     W100Control::SCROLL,     true, 0, 0 },
+  { "BITBLT",     W100Control::BITBLT,     true, 0, 0 },
+  { "POLYLINE",   W100Control::POLYLINE,   true, 0, 0 },
+  { ""      ,     W100Control::EOO,        false, 0, 0 }
+};
+
+W100Control control;
+
+static int W100_ProcessAttach( void )
+{
+  return( AtiCore_ProcessAttach() );
+}
+
+static int W100_ProcessDetach( void )
+{
+  return( AtiCore_ProcessDetach() );
+}
+
+static int W100_AllocateSurface( uint16_t *handle, uint32_t *offset,
+				 uint32_t size, uint32_t direction )
+{
+  int retcode = AtiCore_AllocateSurface( handle, offset, size, direction );
+  return( retcode );
+}
+
+static int W100_DestroySurface( uint16_t handle )
+{
+  int retcode = AtiCore_DestroySurface( handle );
+  return( retcode );
+}
+
+static int W100_DrawPixel( int npoints, ATI_POINT *points )
+{
+  return( AtiCore_DrawPixel( npoints, points ) );
+}
+
+static int W100_SetRopOperation( uint32_t rop )
+{
+  return( AtiCore_SetRopOperation( rop ) );
+}
+
+static int W100_SetDstType( uint32_t dtype )
+{
+  return( AtiCore_SetDstType( dtype ) );
+}
+
+static int W100_SetSrcType( uint32_t stype )
+{
+  return( AtiCore_SetSrcType( stype ) );
+}
+
+static int W100_SetSrcClippingRect( ATI_CLIPRECT *cliprect )
+{
+  return( AtiCore_SetSrcClippingRect( cliprect ) );
+}
+
+
+static int W100_SetDstClippingRect( ATI_CLIPRECT *cliprect )
+{
+  return( AtiCore_SetDstClippingRect( cliprect ) );
+}
+
+static int W100_SetSrcPitchOffset( int pitch, int offset )
+{
+  return( AtiCore_SetSrcPitchOffset( pitch, offset ) );
+}
+
+static int W100_SetDstPitchOffset( int pitch, int offset )
+{
+  return( AtiCore_SetDstPitchOffset( pitch, offset ) );
+}
+
+static int W100_BitBltFilpRotate( int flags, 
+				  ATI_RECT *dstRect,
+				  ATI_RECT *srcRect )
+{
+  return( AtiCore_BitBltFilpRotate( flags, dstRect, srcRect ) );
+}
+
+static int W100_StretchBlt( ATI_STRETCH *option,
+			    ATI_POINT *point,
+			    ATI_RECT *srcRect )
+{
+  return( AtiCore_StretchBlt( option, point, srcRect ) );
+}
+
+static int W100_WaitComplete( int msec )
+{
+  return( AtiCore_WaitComplete( msec ) );
+}
+
+static int W100_AllocOverlay( uint16_t *handle ) 
+{
+  return( AtiCore_AllocOverlay( handle ) );
+}
+
+static int W100_ReleaseOverlay( uint16_t handle )
+{
+  return( AtiCore_ReleaseOverlay( handle ) );
+}
+
+static int W100_SetupOverlay( uint16_t handle, ATI_OVERLAYPROP *prop )
+{
+  return( AtiCore_SetupOverlay( handle, prop ) );
+}
+
+static int W100_SetupOverlayExtended( uint16_t handle, ATI_EXTENDEDOVERLAYPROP *prop )
+{
+  return( AtiCore_SetupOverlayExtended( handle, prop ) );
+}
+
+static int W100_SetOverlayOnOff( uint16_t handle, int isShow )
+{
+  return( AtiCore_SetOverlayOnOff( handle, isShow ) );
+}
+
+static int W100_SetOverlayPos( uint16_t handle, uint16_t x, uint16_t y )
+{
+  return( AtiCore_SetOverlayPos( handle, x, y ) );
+}
+
+static int W100_SetupMemoryTransfer( uint32_t offset, uint32_t *regdata )
+{
+  return( AtiCore_SetupMemoryTransfer( offset, regdata ) );
+}
+
+static int W100_TerminateMemoryTransfer( void )
+{
+  return( AtiCore_TerminateMemoryTransfer() );
+}
+
+static int W100_GetFrontBufferPitchOffset( uint32_t *pitch, uint32_t *offset )
+{
+  return( AtiCore_GetFrontBufferPitchOffset( pitch, offset ) );
+}
+
+static int W100_SetDisplayBrightness( int bri )
+{
+  return( AtiCore_SetDisplayBrightness( bri ) );
+}
+
+static int W100_GetAvailableVideoMem( uint32_t *internal, uint32_t *external )
+{
+  return( GetAvailableVideoMem( internal, external ) );
+}
+
+static int W100_SetupGraphicWindow( ATI_GRAPHICWINDOW *win )
+{
+  return( AtiCore_SetupGraphicWindow( ( void * ) win ) );
+}
+
+static int W100_ProcessAttachSpecialMode( int mode )
+{
+  return( AtiCore_ProcessAttachSpecialMode( mode ) );
+}
+
+static int W100_SetGraphicWindowPos( int x, int y )
+{
+  return( AtiCore_SetGraphicWindowPos( x, y ) );
+}
+
+static int W100_SetFrontBuffer( int offset, int a, int b )
+{
+  return( AtiCore_SetFrontBuffer( offset, a, b ) );
+}
+
+static int W100_SetGraphicWindowOnOff( int val )
+{
+  return( AtiCore_SetGraphicWindowOnOff( val ) );
+}
+
+static unsigned long ccolor( unsigned int rgb )
+{
+  unsigned char r = ( rgb & 0xff0000 ) >> 19;
+  unsigned char g = ( rgb & 0xff00 ) >> 10;
+  unsigned char b = ( rgb & 0xff ) >> 3;
+  return ( ( ( ( unsigned short )0x1f & r ) << 11 ) |
+	   ( ( ( unsigned short )0x3f & g ) << 5 ) |
+	   ( ( ( unsigned short )0x1f & b ) )  ); 
+}
+
+static int W100_SetFrgColour( int val )
+{
+  return( AtiCore_SetFrgColour( ccolor( val ) ) );
+}
+
+static int W100_BrushType( int type, unsigned int pattern )
+{
+  return( AtiCore_BrushType( type, &pattern ) );
+}
+
+static int W100_PaintRect( int flags, ATI_RECT *rect )
+{
+  return( AtiCore_PaintRect( flags, rect ) );
+}
+
+static int W100_Polyline( int npoints, ATI_POINT *points )
+{
+  return( AtiCore_Polyline( npoints, points ) );
+}
+
+static int W100_GetPitchOffsetProperty( void *pitch, void *offset )
+{
+  return( AtiCore_GetPitchOffsetProperty( pitch, offset ) );
+}
+
+static int W100_CursorOnOff( int a, int b )
+{
+  return( AtiCore_CursorOnOff( a, b ) );
+}
+
+static int W100_BitBlt( int flags, ATI_RECT *dst, ATI_RECT *src )
+{
+  return( AtiCore_BitBlt( flags, dst, src ) );
+}
+
+static int W100_WakeUpCall( void )
+{
+  return( AtiCore_WakeUpCall() );
+}
+
+
+template <const int depth, const int type>
+class QGfxW100 : public QGfxRaster<depth,type> {
+
+public:
+  QGfxW100( unsigned char *b, int w, int h );
+  virtual void drawLine( int, int, int, int);
+  virtual void fillRect( int, int, int, int);
+  virtual void blt( int, int, int, int, int, int );
+  virtual void sync();
+  virtual void setOffset( int x, int y );
+  virtual void setPen( const QPen & p );
+  
+  virtual void drawPolyline( const QPointArray &, int, int );
+  virtual void drawPolygon( const QPointArray &, bool, int, int );
+  virtual void drawPoint( int, int );
+  virtual void drawPoints( const QPointArray &, int, int );
+  virtual void scroll( int, int, int, int, int, int );
+  
+
+private:
+  bool checkDest( bool setsrc = false );
+  bool checkSourceDest();
+};
+
+template<const int depth,const int type>
+QGfxW100<depth,type>::QGfxW100( unsigned char * b, int w, int h )
+  : QGfxRaster<depth,type>(b, w, h)
+{
+}
+
+
+template<const int depth,const int type>
+inline void QGfxW100<depth,type>::setOffset( int x, int y )
+{
+  QGfxRaster<depth,type>::setOffset( x, y );
+}
+
+static QString penStyleStr( const QPen &pen ) 
+{
+  QString res;
+  switch( pen.style() ) {
+  case Qt::NoPen:
+    res = "NoPen";
+    break;
+  case Qt::SolidLine:
+    res = "SolidLine";
+    break;
+  case Qt::DashLine:
+    res = "DashLine";
+    break;
+  case Qt::DotLine:
+    res = "DotLine";
+    break;
+  case Qt::DashDotLine:
+    res = "DashDotLine";
+    break;
+  case Qt::DashDotDotLine:
+    res = "DashDotDotLine";
+    break;
+  default:
+    res = "Unknown";
+  }
+  return res;
+}
+
+template<const int depth, const int type>
+inline void QGfxW100<depth,type>::setPen( const QPen &p )
+{
+  QGfxRaster<depth,type>::setPen( p );
+}
+
+template<const int depth,const int type>
+inline bool QGfxW100<depth,type>::checkSourceDest()
+{
+  if ( !checkDest() ) {
+    return FALSE;
+  }
+
+  int sourcepixelpitch;
+  ulong src_buffer_offset;
+  if ( this->srctype == this->SourcePen ) {
+    src_buffer_offset = -1;
+    return FALSE;
+  } else {
+    if ( !qt_screen->onCard( this->srcbits, src_buffer_offset ) ) {
+      return FALSE;
+    }
+    sourcepixelpitch = ( this->srclinestep * 8 ) / this->srcdepth;
+    W100_SetSrcPitchOffset( sourcepixelpitch,
+			    src_buffer_offset );
+  }
+  return TRUE;
+}
+
+template< const int depth, const int type>
+inline bool QGfxW100<depth, type>::checkDest( bool setsrc )
+{
+  //Main framebuffer should be registered as a hardware surface
+  ulong buffer_offset;
+  if ( !qt_screen->onCard( this->buffer, buffer_offset ) ) {
+    return FALSE;
+  }
+  int pixelstep = ( this->linestep() * 8 ) / depth;
+  W100_SetDstPitchOffset( pixelstep, buffer_offset );
+  if ( setsrc ) {
+    W100_SetSrcPitchOffset( pixelstep, buffer_offset );
+  }
+  return TRUE;
+}
+
+template<const int depth,const int type>
+void QGfxW100<depth,type>::drawLine( int x1, int y1, int x2, int y2 )
+{
+  // No point going any further if the window isn't visible
+  if( this->ncliprect < 1 ) {
+    return;
+  }
+
+  if ( !control.accelerated( W100Control::DRAWLINE ) ) {
+    control.addMiss( W100Control::DRAWLINE );
+    QGfxRaster<depth,type>::drawLine( x1, y1, x2, y2 );
+    return;
+  }
+
+  // Only handle 'normal' lines
+  if ( ( this->cpen.style() != this->SolidLine ) || 
+       ( this->myrop != this->CopyROP ) ||
+       ( this->cpen.width() > 1 ) ||
+       ( this->dashedLines ) ) {
+    control.addMiss( W100Control::DRAWLINE );
+    QGfxRaster<depth,type>::drawLine(x1,y1,x2,y2);
+    return;
+  }
+
+  // Stop anyone else trying to access optype/lastop/the graphics engine
+  // to avoid synchronization problems with other processes
+  QWSDisplay::grab( TRUE );
+  if ( !checkDest() ) {
+    QWSDisplay::ungrab();
+    control.addMiss( W100Control::DRAWLINE );
+    QGfxRaster<depth,type>::drawLine( x1, y1, x2, y2);
+    return;
+  }
+
+  // Note that the last operation used the 2d engine
+  ( *optype ) = 1;
+
+
+
+  // Add the offset of the gfx - used to make the origin the right
+  // place for windows
+  x1 = x1 + this->xoffs;
+  y1 = y1 + this->yoffs;
+  x2 = x2 + this->xoffs;
+  y2 = y2 + this->yoffs;
+
+  // Only cope with lines going from left to right
+  // - swap them round if this isn't TRUE
+  if ( x1 > x2 ) {
+    int x3 = x2;
+    int y3 = y2;
+    x2 = x1;
+    y2 = y1;
+    x1 = x3;
+    y1 = y3;
+  }
+
+  GFX_START( QRect( x1, 
+		    y1 < y2 ? y1 : y2, 
+		    ( x2 - x1  + 1 ), 
+		    QABS( y2 - y1 ) + 1 ) );
+
+  // The clip region is defined as a series of rectangles
+  // We repeatedly set up the hardware clip rectangle to one of
+  // these rectangles and re-draw the line - an alternative approach
+  // would be to clip to the rectangle in software
+    
+
+
+  /*
+   * Just a dirty hack. Comment it out for now
+   if ( this->dashedLines ) {
+   W100_BrushType( 4, 0xaaaaaaaa );
+   } else {
+   W100_BrushType( 6, 0 );
+   }
+   switch( this->cpen.style() ) {
+   case Qt::NoPen:
+   //W100DEBUG( "Using pen style NoPen" );
+   break;
+   case Qt::SolidLine:
+   //W100DEBUG( "Using pen style SolidLine" );
+   break;
+   case Qt::DashLine:
+   //W100DEBUG( "Using pen style DashLine" );
+   break;
+   case Qt::DotLine:
+   //W100DEBUG( "Using pen style DotLine" );
+   break;
+   case Qt::DashDotLine:
+   //W100DEBUG( "Using pen style DashDotLine" );
+   break;
+   case Qt::DashDotDotLine:
+   //W100DEBUG( "Using pen style DashDotDotLine" );
+   break;
+   default:
+   //W100DEBUG( "Using unknown type of pen" );
+   }
+  */
+
+  //if ( control.lastOp() != W100Control::DRAWLINE &&
+  //control.lastOp() != W100Control::POLYLINE ) {
+  W100_SetDstType( DSTTYPE_16BPP_1555 );
+  W100_SetSrcType( SRCTYPE_EQU_DST );
+  W100_SetRopOperation( ROP3_PATCOPY );
+  W100_BrushType( 6, 0 );
+  //}
+  W100_SetFrgColour( this->cpen.color().rgb() );
+  control.addHit( W100Control::DRAWLINE );
+
+  //The imageon seems not to write on the edge of the clip
+  //for the polyline op. 
+  //We are using a three points array repeating the last point
+  //to get the last single point painted.
+  ATI_POINT points[3];
+  points[0].XCoord = x1;
+  points[0].YCoord = y1;
+  points[1].XCoord = x2;
+  points[1].YCoord = y2;
+  points[2].XCoord = x2;
+  points[2].YCoord = y2;
+  for ( int loopc = 0 ; loopc < this->ncliprect; loopc++ ) {
+    ATI_CLIPRECT clip;
+    clip.X_Top_Left = this->cliprect[loopc].x();
+    clip.Y_Top_Left = this->cliprect[loopc].y();
+    clip.X_Bottom_Right = this->cliprect[loopc].right() + 1;
+    clip.Y_Bottom_Right = this->cliprect[loopc].bottom() + 1;
+    W100_SetDstClippingRect( &clip );
+
+    W100_Polyline( 3, points );
+  }
+
+  // Software mouse cursor stuff
+  GFX_END;
+
+  // Release display again - not doing so will cause Qt/Embedded applications
+  // to deadlock
+  QWSDisplay::ungrab();
+
+}
+
+
+template< const int depth, const int type >
+void QGfxW100< depth, type>::drawPolyline( const QPointArray &a, 
+					   int index, 
+					   int npoints )
+{
+
+  if ( ( this->ncliprect < 1 ) || ( npoints < 1 ) ) {
+    return;
+  }
+
+  if ( !control.accelerated( W100Control::POLYLINE ) ) {
+    control.addMiss( W100Control::POLYLINE );
+    QGfxRaster<depth,type>::drawPolyline( a, index, npoints );
+    return;
+  }
+
+  if ( this->cpen.style() != this->SolidLine ||
+       this->myrop != this->CopyROP ) {
+    control.addMiss( W100Control::POLYLINE );
+    QGfxRaster<depth,type>::drawPolyline( a, index, npoints );
+    return;
+  }
+
+  QWSDisplay::grab( TRUE );
+  if ( !checkDest() ) {
+    QWSDisplay::ungrab();
+    control.addMiss( W100Control::POLYLINE );
+    QGfxRaster<depth,type>::drawPolyline( a, index, npoints );
+    return;
+  }
+
+  ( *optype ) = 1;
+
+  //if ( control.lastOp() != W100Control::POLYLINE &&
+  //control.lastOp() != W100Control::DRAWLINE ) {
+
+  W100_SetDstType( DSTTYPE_16BPP_1555 );
+  W100_SetSrcType( SRCTYPE_EQU_DST );
+  W100_SetRopOperation( ROP3_PATCOPY );
+  W100_BrushType( 6, 0 );
+  
+  //}
+
+  W100_SetFrgColour( this->cpen.color().rgb() );
+
+  control.addHit( W100Control::POLYLINE );
+
+  ATI_POINT *points = new ATI_POINT[ npoints + 1 ];
+
+  for ( int i = 0; i < npoints; i++ ) {
+    points[i].XCoord = a[ i + index ].x() + this->xoffs;
+    points[i].YCoord = a[ i + index ].y() + this->yoffs;
+  }
+  //Hack to get the last point of the last line painted
+  points[ npoints ] = points[ npoints - 1 ];
+
+
+  GFX_START( clipbounds );
+  W100_SetFrgColour( this->cpen.color().rgb() );
+  W100_SetRopOperation( ROP3_PATCOPY );
+  for ( int loopc = 0; loopc < this->ncliprect; loopc++ ) {
+    ATI_CLIPRECT clip;
+    clip.X_Top_Left = this->cliprect[loopc].x();
+    clip.Y_Top_Left = this->cliprect[loopc].y();
+    clip.X_Bottom_Right = this->cliprect[loopc].right() + 1;
+    clip.Y_Bottom_Right = this->cliprect[loopc].bottom() + 1;
+    W100_SetDstClippingRect( &clip );
+    W100_Polyline( npoints + 1, points );
+  }
+  GFX_END;
+
+  delete [] points;
+    
+  QWSDisplay::ungrab();
+}
+
+template< const int depth, const int type >
+void QGfxW100< depth, type>::drawPolygon( const QPointArray &a, bool b, int c, int d )
+{
+  QGfxRaster<depth,type>::drawPolygon( a, b, c, d );
+}
+
+template< const int depth, const int type >
+void QGfxW100< depth, type>::drawPoint( int a, int b )
+{
+
+  if ( this->ncliprect < 1 ) {
+    //W100DEBUG( "ncliprect=%d", this->ncliprect );
+    return;
+  }
+
+  if ( !control.accelerated( W100Control::DRAWPOINT) ) {
+    control.addMiss( W100Control::DRAWPOINT );
+    QGfxRaster<depth,type>::drawPoint( a, b );
+    return;
+  }
+
+  if ( this->cpen.style() != this->SolidLine ||
+       this->myrop != this->CopyROP ) {
+    control.addMiss( W100Control::DRAWPOINT );
+    QGfxRaster<depth,type>::drawPoint( a, b );
+    return;
+  }
+
+  QWSDisplay::grab( TRUE );
+  if ( !checkDest() ) {
+    QWSDisplay::ungrab();
+    control.addMiss( W100Control::DRAWPOINT );
+    QGfxRaster<depth,type>::drawPoint( a, b );
+    return;
+  }
+
+  control.addHit( W100Control::DRAWPOINT );
+  ( *optype ) = 1;
+  
+  ATI_POINT point;
+  point.XCoord = a + this->xoffs;
+  point.YCoord = b + this->yoffs;
+
+  GFX_START( clipbounds );
+  W100_SetFrgColour( this->cpen.color().rgb() );
+  W100_SetRopOperation( ROP3_PATCOPY );
+  for ( int loopc = 0; loopc < this->ncliprect; loopc++ ) {
+    ATI_CLIPRECT clip;
+    clip.X_Top_Left = this->cliprect[loopc].x();
+    clip.Y_Top_Left = this->cliprect[loopc].y();
+    clip.X_Bottom_Right = this->cliprect[loopc].right() + 1;
+    clip.Y_Bottom_Right = this->cliprect[loopc].bottom() + 1;
+    W100_SetDstClippingRect( &clip );
+    W100_DrawPixel( 1, &point );
+  }
+  GFX_END;
+  QWSDisplay::ungrab();
+}
+
+template< const int depth, const int type >
+void QGfxW100< depth, type>::drawPoints( const QPointArray &a, 
+					 int index, 
+					 int npoints )
+{
+  if ( ( this->ncliprect < 1 ) || ( npoints < 1 ) ) {
+    return;
+  }
+
+  if ( !control.accelerated( W100Control::DRAWPOINTS ) ) {
+    control.addMiss( W100Control::DRAWPOINTS );
+    QGfxRaster<depth,type>::drawPoints( a, index, npoints );
+    return;
+  }
+
+  if ( this->cpen.style() != this->SolidLine ||
+       this->myrop != this->CopyROP ) {
+    control.addMiss( W100Control::DRAWPOINTS );
+    QGfxRaster<depth,type>::drawPoints( a, index, npoints );
+    return;
+  }
+
+  QWSDisplay::grab( TRUE );
+  if ( !checkDest() ) {
+    QWSDisplay::ungrab();
+    control.addMiss( W100Control::DRAWPOINTS );
+    QGfxRaster<depth,type>::drawPoints( a, index, npoints );
+    return;
+  }
+
+  control.addHit( W100Control::DRAWPOINTS );
+  ( *optype ) = 1;
+  
+  ATI_POINT *points = new ATI_POINT[ npoints ];
+  for ( int i = 0; i < npoints; i++ ) {
+    points[i].XCoord = a[ i + index ].x() + this->xoffs;
+    points[i].YCoord = a[ i + index ].y() + this->yoffs;
+  }
+
+  GFX_START( clipbounds );
+  W100_SetFrgColour( this->cpen.color().rgb() );
+  W100_SetRopOperation( ROP3_PATCOPY );
+  for ( int loopc = 0; loopc < this->ncliprect; loopc++ ) {
+    ATI_CLIPRECT clip;
+    clip.X_Top_Left = this->cliprect[loopc].x();
+    clip.Y_Top_Left = this->cliprect[loopc].y();
+    clip.X_Bottom_Right = this->cliprect[loopc].right() + 1;
+    clip.Y_Bottom_Right = this->cliprect[loopc].bottom() + 1;
+    W100_SetDstClippingRect( &clip );
+    W100_DrawPixel( npoints, points );
+  }
+  GFX_END;
+
+  delete [] points;
+  QWSDisplay::ungrab();
+}
+
+
+template< const int depth, const int type >
+void QGfxW100< depth, type>::scroll( int rx, int ry,
+				     int w, int h, 
+				     int sx, int sy )
+{
+  if ( !control.accelerated( W100Control::SCROLL ) ) {
+    control.addMiss( W100Control::SCROLL );
+    QGfxRaster<depth,type>::scroll( rx, ry, w, h, sx, sy );
+    return;
+  }
+
+  if ( this->ncliprect < 1 ) return;
+
+  if ( ( w < 1 )  || ( h < 1 ) ) return;
+
+  int dy = sy - ry;
+  int dx = sx - rx;
+
+  if ( dx == 0 && dy == 0 ) return;
+
+
+  QWSDisplay::grab( TRUE );
+
+  if ( checkDest( true ) ) {
+
+
+    rx += this->xoffs;
+    sx += this->xoffs;
+    ry += this->yoffs;
+    sy += this->yoffs;
+
+    GFX_START( QRect( QMIN( rx , sx  ),
+		      QMIN( ry , sy  ),
+		      w + QABS( dx ) + 1,
+		      h + QABS( dy ) + 1 ) );
+    ( *optype ) = 1;
+
+
+    //if ( control.lastOp() != W100Control::SCROLL ) {
+    W100_SetRopOperation( ROP3_SRCCOPY );
+    W100_SetDstType( DSTTYPE_16BPP_1555 );
+    W100_SetSrcType( SRCTYPE_EQU_DST );
+    //}
+
+    control.addHit( W100Control::SCROLL );
+
+    ATI_RECT srcrect, dstrect;
+
+    srcrect.XCoord = sx;
+    srcrect.YCoord = sy;
+    srcrect.Width = w;
+    srcrect.Height = h;
+    dstrect.XCoord = rx;
+    dstrect.YCoord = ry;
+    dstrect.Width = w;
+    dstrect.Height = h;
+
+    for ( int loopc = 0; loopc < this->ncliprect; loopc++ ) {
+      ATI_CLIPRECT clip;
+      clip.X_Top_Left     = this->cliprect[ loopc ].x();
+      clip.Y_Top_Left     = this->cliprect[ loopc ].y();
+      clip.X_Bottom_Right = this->cliprect[ loopc ].right() + 1;
+      clip.Y_Bottom_Right = this->cliprect[ loopc ].bottom() + 1;
+      W100_SetDstClippingRect( &clip );
+      W100_BitBlt( 1, &dstrect, &srcrect );
+    }
+    GFX_END;
+    QWSDisplay::ungrab();
+
+  } else {
+    QWSDisplay::ungrab();
+    // software fallback
+    control.addMiss( W100Control::SCROLL );
+    QGfxRaster<depth,type>::scroll( rx, ry, w, h, sx, sy );
+  }
+}
+
+
+  
+template< const int depth, const int type >
+void QGfxW100< depth, type>::fillRect( int rx, int ry, int w, int h )
+{
+
+  if ( w <= 0 || h <= 0 || this->ncliprect < 1 ) return;
+
+  if ( !control.accelerated( W100Control::FILLRECT ) ) {
+    control.addMiss( W100Control::FILLRECT );
+    QGfxRaster<depth,type>::fillRect( rx, ry, w, h );
+    return;
+  }
+
+  if ( ( this->cbrush.style() != this->NoBrush ) && 
+       ( this->cbrush.style() != this->SolidPattern ) ) {
+    control.addMiss( W100Control::FILLRECT );
+    QGfxRaster<depth,type>::fillRect( rx, ry, w, h );
+    return;
+  }
+
+  if ( !checkDest() || ( this->myrop != this->CopyROP ) ) {
+    control.addMiss( W100Control::FILLRECT );
+    QGfxRaster<depth,type>::fillRect(rx,ry,w,h);
+    return;
+  }
+
+  QWSDisplay::grab( TRUE );
+  rx += this->xoffs;
+  ry += this->yoffs;
+
+  GFX_START( QRect( rx, ry, w+1, h+1 ) );
+
+  ( *optype ) = 1;
+  control.log( W100Control::INFO, "QGfxW100::fillRect( +%d+%d %dx%d )",
+	       rx, ry, w, h );
+
+
+  //if ( control.lastOp() != W100Control::FILLRECT ) {
+  W100_SetDstType( DSTTYPE_16BPP_1555 );
+  W100_SetSrcType( SRCTYPE_EQU_DST );
+  W100_SetRopOperation( ROP3_PATCOPY );
+  W100_BrushType( 6, 0 );
+  //}
+  W100_SetFrgColour( this->cbrush.color().rgb() );
+
+  control.addHit( W100Control::FILLRECT );
+
+  if ( this->cbrush.style() != this->NoBrush ) {
+    //Using all the cliprects
+    for ( int loopc = 0; loopc < this->ncliprect; loopc++ ) {
+      ATI_CLIPRECT clip;
+      ATI_RECT rect;
+
+      clip.X_Top_Left     = this->cliprect[ loopc ].x();
+      clip.Y_Top_Left     = this->cliprect[ loopc ].y();
+      clip.X_Bottom_Right = this->cliprect[ loopc ].right() + 1;
+      clip.Y_Bottom_Right = this->cliprect[ loopc ].bottom() + 1;
+
+      W100_SetDstClippingRect( &clip );
+      rect.XCoord = rx;
+      rect.YCoord = ry;
+      rect.Width  = w;
+      rect.Height = h;
+      W100_PaintRect( 1, &rect );
+    }
+  }
+  GFX_END;
+      
+  QWSDisplay::ungrab();
+}
+
+template< const int depth, const int type >
+inline void QGfxW100< depth, type>::blt( int rx, int ry, 
+					 int w, int h,
+					 int sx, int sy )
+{
+  control.log( W100Control::INFO, "QGfxW100::blt( +%d+%d %dx%d )",
+	       rx, ry, w, h );
+  if ( !w || !h || this->ncliprect < 1 ) {
+    return;
+  }
+
+  if ( !control.accelerated( W100Control::BITBLT ) ) {
+    control.addMiss( W100Control::BITBLT );
+    QGfxRaster<depth,type>::blt(rx,ry,w,h,sx,sy);
+    return;
+  }
+
+  if ( this->alphatype == this->BigEndianMask ||
+       this->alphatype == this->LittleEndianMask ||
+       this->alphatype == this->SeparateAlpha ||
+       this->srctype == this->SourcePen ||
+       ( this->myrop != this->CopyROP ) ) {
+    control.addMiss( W100Control::BITBLT );
+    QGfxRaster<depth,type>::blt(rx,ry,w,h,sx,sy);
+    return;
+  }
+
+  if( ( this->srcdepth != 16 ) || this->alphatype != this->IgnoreAlpha ) {
+    control.addMiss( W100Control::BITBLT );
+    QGfxRaster<depth,type>::blt(rx,ry,w,h,sx,sy);
+    return;
+  }
+
+  QWSDisplay::grab( TRUE );
+
+  if( checkSourceDest() ) {
+    GFX_START( QRect( rx + xoffs, ry + yoffs , w+1, h+1 ) );
+    ( *optype ) = 1;
+
+    //if ( control.lastOp() != W100Control::BITBLT ) {
+    W100_SetRopOperation( ROP3_SRCCOPY );
+    W100_SetDstType( DSTTYPE_16BPP_1555 );
+    W100_SetSrcType( SRCTYPE_EQU_DST );
+    //}
+
+    control.addHit( W100Control::BITBLT );
+
+    ATI_RECT rect1;
+    ATI_RECT rect2;
+	
+    rect1.XCoord = this->srcwidgetoffs.x() + sx;
+    rect1.YCoord = this->srcwidgetoffs.y() + sy;
+    rect1.Width  = w;
+    rect1.Height = h;
+    rect2.XCoord = this->xoffs + rx;
+    rect2.YCoord = this->yoffs + ry;
+    rect2.Width = w;
+    rect2.Height = h;
+    for(int loopc = 0; loopc < this->ncliprect; loopc++ ) {
+      ATI_CLIPRECT clip;
+      clip.X_Top_Left     = this->cliprect[ loopc ].x();
+      clip.Y_Top_Left     = this->cliprect[ loopc ].y();
+      clip.X_Bottom_Right = this->cliprect[ loopc ].right() + 1;
+      clip.Y_Bottom_Right = this->cliprect[ loopc ].bottom() + 1;
+      W100_SetDstClippingRect( &clip );
+      W100_BitBlt( 1, &rect2, &rect1 );
+    }
+    GFX_END;
+      
+    QWSDisplay::ungrab();
+    return;
+  } else {
+    QWSDisplay::ungrab();
+    // software fallback
+    control.addMiss( W100Control::BITBLT );
+    QGfxRaster<depth,type>::blt( rx, ry, w, h, sx, sy );
+  }
+}
+
+
+template<const int depth,const int type>
+void QGfxW100<depth,type>::sync()
+{
+  W100_WaitComplete( -1 );
+}
+
+class QW100Screen : public QLinuxFbScreen {
+
+public:
+  class HWSurface {
+  public:
+    HWSurface( void ):
+      m_handle( 0 ),
+      m_offset( 0 ),
+      m_addr( 0 ),
+      m_size( 0 ),
+      m_internal( false ),
+      m_clientid( -1 ) {};
+    HWSurface( unsigned short handle,
+	       uint32_t sOffset,
+	       unsigned char *localAddr, 
+	       int amount,
+	       bool internal,
+	       int clientid ):
+      m_handle( handle ),
+      m_offset( sOffset ),
+      m_addr( localAddr ),
+      m_size( amount ),
+      m_internal( internal ),
+      m_clientid( clientid ) {};
+    HWSurface( uint32_t sOffset, 
+	       unsigned char *localAddr,
+	       bool internal,
+	       int amount ):
+      m_handle( 0 ),
+      m_offset( sOffset ),
+      m_addr( localAddr ),
+      m_size( amount ),
+      m_internal( internal ),
+      m_clientid( -1 ) {};
+    bool operator!=( HWSurface &other ) {
+      return( m_offset == other.getSOffset() );
+    };
+    HWSurface &operator=( const HWSurface &c ) {
+      m_handle = c.getHandle();
+      m_offset = c.getSOffset();
+      m_addr = c.getAddr();
+      m_size = c.getSize();
+      m_clientid= c.getCId();
+      m_internal = c.internal();
+      return( *this );
+    };
+    unsigned short getHandle( void ) const { return m_handle; };
+    uint32_t getSOffset( void ) const { return m_offset; };
+    unsigned char *getAddr( void ) const { return m_addr; };
+    unsigned int getSize( void ) const { return m_size; };
+    int getCId( void ) const { return m_clientid; };
+    bool internal( void ) const { return m_internal; };
+
+  private:
+    unsigned short m_handle;
+    uint32_t m_offset;
+    unsigned char *m_addr;
+    int m_size;
+    bool m_internal;
+    int m_clientid;
+  };
+    
+  QW100Screen( int display_id );
+  virtual ~QW100Screen();
+  virtual bool connect( const QString &spec );
+  virtual void disconnect( void );
+  virtual bool initDevice();
+  virtual void shutdownDevice();
+  virtual bool useOffscreen() { return TRUE; }
+  virtual QGfx * createGfx( unsigned char *, int, int, int, int);
+  virtual uchar *cache( int amount, int optim );
+  virtual void uncache( uchar *c );
+  virtual bool onCard( unsigned char *p ) const;
+  virtual bool onCard( unsigned char *p, ulong& offset ) const;
+  QMap< uchar*, HWSurface > *getPSurfaceMap( void ) const;
+  void clearCache( int clientId );
+protected:
+  static void clearCache( QScreen *instance, int clientId );
+  QMap< uchar*, HWSurface > surfaceMap;
+  int vramoffset;
+  virtual int pixmapLinestepAlignment() { return 128; }
+};
+
+QW100Screen::QW100Screen( int display_id )
+  :QLinuxFbScreen( display_id )
+{
+  vramoffset = ( w == 320 ) ? 0: 0x0f000000;
+  clearCacheFunc = &clearCache;
+}
+
+bool QW100Screen::connect( const QString &displaySpec )
+{
+
+  if ( QLinuxFbScreen::connect( displaySpec ) ) {
+    if ( W100_ProcessAttach() ) {
+      W100_ProcessAttachSpecialMode( ( w == 480 ) ? 0xaaab:0xaaaa );
+      surfaceMap.insert( 0, HWSurface( vramoffset, 
+				       data , false, 
+				       w*h*d/8 ) );
+      canaccel = TRUE;
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
+
+void QW100Screen::disconnect( void )
+{
+  QLinuxFbScreen::disconnect();
+  W100_ProcessDetach();
+}
+
+QW100Screen::~QW100Screen()
+{
+}
+
+bool QW100Screen::initDevice()
+{
+  ATI_GRAPHICWINDOW win;
+  ATI_CLIPRECT      clip;
+  uint16_t overlay;
+  int ret;
+  uint32_t extm, intm;
+  W100_GetAvailableVideoMem( &intm, &extm );
+  ret = W100_CursorOnOff( 1, 0 );
+  ret = W100_CursorOnOff( 2, 0 );
+  ret = W100_CursorOnOff( 3, 0 );
+  win.dummy1 = 0;
+  win.Size.XCoord = 0;
+  win.Size.YCoord = 0;
+  win.Size.Width = w;
+  win.Size.Height = h;
+  win.Width = w > h ? h : w;
+  win.Height = w > h ? w : h;
+  win.Flag = DSTTYPE_16BPP_444; //(5)
+    
+  ret = W100_SetupGraphicWindow( &win );
+  if ( !ret ) {
+    return FALSE;
+  }
+  ret = W100_SetGraphicWindowPos( 0, 0 );
+
+  ret = W100_SetFrontBuffer( vramoffset, 0, 0 );
+  ret = W100_SetDstPitchOffset( w, vramoffset );
+  ret = W100_SetDstType( DSTTYPE_16BPP_444 );
+  ret = W100_SetSrcPitchOffset( w, vramoffset );
+  ret = W100_SetSrcType( SRCTYPE_SOLID_COLOR_BLT );
+  clip.X_Top_Left = 0;
+  clip.Y_Top_Left = 0;
+  clip.X_Bottom_Right = w;
+  clip.Y_Bottom_Right = h;
+  ret = W100_SetDstClippingRect( &clip );
+    
+  clip.X_Top_Left = 0xE000;
+  clip.Y_Top_Left = 0xE000;
+  clip.X_Bottom_Right = 0x1FFF;
+  clip.Y_Bottom_Right = 0x1FFF;
+    
+  ret = W100_SetSrcClippingRect( &clip );
+  ret = W100_SetRopOperation( ROP3_SRCCOPY );
+  ret = W100_SetGraphicWindowOnOff( 1 );
+    
+  ret = W100_AllocOverlay( &overlay );
+  ret = W100_SetOverlayOnOff( overlay, 0 );
+  ret = W100_ReleaseOverlay( overlay );
+  ret = W100_SetDstPitchOffset( w, vramoffset );
+  ret = W100_SetDstClippingRect( NULL );
+  
+  if ( QLinuxFbScreen::initDevice() ) {
+    //HACK
+    //Some sprite corruption seems to be avoided
+    //reserving some upper memory on the offscreen framebuffer memory
+    QLinuxFbScreen::cache( 65535 * 2, 0 );
+    return true;
+  }
+  return false;
+}
+
+void QW100Screen::shutdownDevice()
+{
+  QLinuxFbScreen::shutdownDevice();
+  W100_ProcessDetach();
+}
+
+QGfx *QW100Screen::createGfx( unsigned char *b,
+			      int w, int h, int d, int linestep )
+{
+  //We need ALL the gfx created to be QGfxW100 to allow software
+  //drawing syncing after hardware operations
+  QGfx * ret=0;
+  if ( false ) {
+#ifndef QT_NO_QWS_DEPTH_1
+  } else if ( d == 1 ) {
+    ret = new QGfxW100<1,0>( b, w, h );
+#endif
+#ifndef QT_NO_QWS_DEPTH_4
+  } else if ( d == 4 ) {
+    ret = new QGfxW100<4,0>( b, w, h );
+#endif
+#ifndef QT_NO_QWS_DEPTH_8
+  } else if ( d == 8 ) {
+    ret = new QGfxW100<8,0>( b, w, h );
+#endif
+#ifndef QT_NO_QWS_DEPTH_16    
+  } else if  ( d == 16 ) {
+    ret = new QGfxW100<16,0>( b, w, h );
+#endif
+#ifndef QT_NO_QWS_DEPTH_24
+  } else if ( d == 24 ) {
+    ret = new QGfxW100<24,0>( b, w, h );
+#endif
+#ifndef QT_NO_QWS_DEPTH_32
+  } else if ( d == 32 ) {
+    ret = new QGfxW100<32,0>( b, w, h );
+#endif
+  } else {
+    qFatal( "Unsupported depth %d\n", d );
+    ret = 0;
+  }
+
+  ret->setLineStep( linestep );
+  return ret;    
+}
+
+static int sinternal = 0;
+static int sexternal = 0;
+
+uchar *QW100Screen::cache( int amount, int optim )
+{
+  unsigned short hSurface = 0;
+  uint32_t surfaceOffset = 0;
+  uchar* localAddr = 0;
+  bool internal = false;
+
+  /* The size must have 0xF bit zeroed (16 multiple)*/
+  /* Perhaps this is not needed anymore, after setting
+   * QW100Screen::pixmapLinestepAlignment to 128
+   */
+  amount = ( amount & 0x0F ) ? ( amount | 0x10 ) & ~0x0F : amount;
+
+  /* Experimenting memory corruption with the
+   * internal AtiCore memory allocation routines
+   * disabled for now
+   */
+#if 1
+  if ( !( localAddr = QLinuxFbScreen::cache( amount, optim ) ) ) {
+    return( 0 );
+  }
+  surfaceOffset = vramoffset + ( uint32_t ) localAddr - ( uint32_t )data;
+
+#else
+  int retcode = 0;
+  qt_fbdpy->grab();
+  retcode = W100_AllocateSurface( &hSurface,
+				  &surfaceOffset,
+				  amount, 1 );
+  qt_fbdpy->ungrab();
+  if ( retcode ) {
+    internal = true;
+    W100_SetupMemoryTransfer( surfaceOffset, (uint32_t*) &localAddr );
+    W100_TerminateMemoryTransfer();
+  } else {
+    // Try to use the offscreen framebuffer memory
+    // to allocate the surface. Use the qgfxlinuxfb routines
+    if ( !( localAddr = QLinuxFbScreen::cache( amount, optim ) ) ) {
+      return( 0 );
+    }
+    //Distance between physical vram start and surface should be
+    //the same than distance between logical addresses
+    surfaceOffset = vramoffset + ( uint32_t ) localAddr - ( uint32_t ) data;
+  }
+#endif
+    
+  HWSurface surface( hSurface, surfaceOffset,
+		     localAddr, amount, 
+		     internal,
+		     qws_client_id );
+#if 0
+  if ( internal ) {
+    sinternal++;
+  } else {
+    sexternal++;
+  }
+#endif
+  surfaceMap.insert( surface.getAddr(), surface );
+  return( ( uchar* ) localAddr );
+}
+
+void QW100Screen::uncache( uchar *c )
+{
+  QMap< uchar*, HWSurface >::Iterator itr;
+  if ( ( itr = surfaceMap.find( c ) ) != surfaceMap.end() ) {
+    if ( itr.data().internal() ) {
+      qt_fbdpy->grab();
+      W100_DestroySurface( itr.data().getHandle() );
+      qt_fbdpy->ungrab();
+      --sinternal;
+    } else {
+      --sexternal;
+      QLinuxFbScreen::uncache( c );
+    }
+    surfaceMap.remove( itr );
+  } 
+}
+
+bool QW100Screen::onCard( uchar *p ) const
+{
+  QMap< uchar*, HWSurface >::ConstIterator itr = surfaceMap.begin();
+  for ( ; itr != surfaceMap.end(); itr++ ) {
+    uchar *begin;
+    if ( ( begin = itr.data().getAddr() ) <= p ) {
+      if ( ( itr.data().getSize() + begin ) >= p ) {
+	return TRUE;
+      }
+    }
+  }
+  return FALSE;
+}
+
+bool QW100Screen::onCard( unsigned char *p, ulong& offset ) const
+{
+  QMap< uchar*, HWSurface >::ConstIterator itr;
+  for ( itr = surfaceMap.begin(); itr != surfaceMap.end(); itr++ ) {
+    uchar *begin;
+    if ( ( begin = itr.data().getAddr() ) <= p ) {
+      if ( ( itr.data().getSize() + begin ) >= p ) {
+	offset = itr.data().getSOffset() + ( p - begin );
+	return TRUE;
+      }
+    }
+  }
+  return FALSE;
+}
+
+QMap< uchar*, QW100Screen::HWSurface > 
+*QW100Screen::getPSurfaceMap( void ) const
+{
+  return ( QMap<uchar*,HWSurface> *) &surfaceMap;
+}
+
+void QW100Screen::clearCache( int clientId )
+{
+  QMap< uchar*, HWSurface >::Iterator itr = surfaceMap.begin();
+  while ( itr != surfaceMap.end() ) {
+    if ( itr.data().getCId() == clientId ) {
+      if ( itr.data().internal() ) {
+	qt_fbdpy->grab();
+	W100_DestroySurface( itr.data().getHandle() );
+	qt_fbdpy->ungrab();
+	--sinternal;
+      } else {
+	QLinuxFbScreen::uncache( itr.data().getAddr() );
+	--sexternal;
+      }
+      surfaceMap.remove( itr );
+    }
+    itr++;
+  }
+}
+
+void QW100Screen::clearCache( QScreen *instance, int clientId )
+{
+  QW100Screen *screen = ( QW100Screen * )instance;
+  screen->clearCache( clientId );
+}
+
+extern bool qws_accel;
+
+extern "C" QScreen * qt_get_screen_w100( int display_id )
+{
+    return( new QW100Screen( display_id ) );
+}