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
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
|
/*
* Copyright (c) 2006 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Neither the name of the Advanced Micro Devices, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*/
/*
* Cimarron display controller routines. These routines program the display
* mode and configure the hardware cursor and video buffers.
*/
/*---------------------*/
/* CIMARRON VG GLOBALS */
/*---------------------*/
CIMARRON_STATIC unsigned long vg3_x_hotspot = 0;
CIMARRON_STATIC unsigned long vg3_y_hotspot = 0;
CIMARRON_STATIC unsigned long vg3_cursor_offset = 0;
CIMARRON_STATIC unsigned long vg3_mode_width = 0;
CIMARRON_STATIC unsigned long vg3_mode_height = 0;
CIMARRON_STATIC unsigned long vg3_panel_width = 0;
CIMARRON_STATIC unsigned long vg3_panel_height = 0;
CIMARRON_STATIC unsigned long vg3_delta_x = 0;
CIMARRON_STATIC unsigned long vg3_delta_y = 0;
CIMARRON_STATIC unsigned long vg3_bpp = 0;
CIMARRON_STATIC unsigned long vg3_color_cursor = 0;
CIMARRON_STATIC unsigned long vg3_panel_enable = 0;
/*---------------------------------------------------------------------------
* vg_delay_milliseconds
*
* This routine delays for a number of milliseconds based on a crude
* delay loop.
*--------------------------------------------------------------------------*/
int
vg_delay_milliseconds(unsigned long ms)
{
/* ASSUME 500 MHZ 20 CLOCKS PER READ */
unsigned long loop = ms * 25000;
while (loop-- > 0) {
READ_REG32(DC3_UNLOCK);
}
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_display_mode
*
* This routine sets a CRT display mode using predefined Cimarron timings.
* The source width and height are specified to allow scaling.
*--------------------------------------------------------------------------*/
int
vg_set_display_mode(unsigned long src_width, unsigned long src_height,
unsigned long dst_width, unsigned long dst_height,
int bpp, int hz, unsigned long flags)
{
VG_QUERY_MODE crt_query;
VG_DISPLAY_MODE crt_mode;
int mode;
crt_query.active_width = dst_width;
crt_query.active_height = dst_height;
crt_query.bpp = bpp;
crt_query.hz = hz;
crt_query.query_flags = VG_QUERYFLAG_ACTIVEWIDTH |
VG_QUERYFLAG_ACTIVEHEIGHT | VG_QUERYFLAG_BPP | VG_QUERYFLAG_REFRESH;
mode = vg_get_display_mode_index(&crt_query);
if (mode >= 0) {
crt_mode = CimarronDisplayModes[mode];
crt_mode.src_width = src_width;
crt_mode.src_height = src_height;
/* ADD USER-REQUESTED FLAGS */
crt_mode.flags |= (flags & VG_MODEFLAG_VALIDUSERFLAGS);
if (flags & VG_MODEFLAG_OVERRIDE_BAND) {
crt_mode.flags &= ~VG_MODEFLAG_BANDWIDTHMASK;
crt_mode.flags |= (flags & VG_MODEFLAG_BANDWIDTHMASK);
}
if (flags & VG_MODEFLAG_INT_OVERRIDE) {
crt_mode.flags &= ~VG_MODEFLAG_INT_MASK;
crt_mode.flags |= (flags & VG_MODEFLAG_INT_MASK);
}
return vg_set_custom_mode(&crt_mode, bpp);
}
return CIM_STATUS_ERROR;
}
/*---------------------------------------------------------------------------
* vg_set_panel_mode
*
* This routine sets a panel mode using predefined Cimarron fixed timings.
* The source width and height specify the width and height of the data in
* the frame buffer. The destination width and height specify the width and
* height of the active data to be displayed. The panel width and height
* specify the dimensions of the panel. This interface allows the user to
* scale or center graphics data or both. To perform scaling, the src width
* or height should be different than the destination width or height. To
* perform centering or panning, the destination width and height should be
* different than the panel resolution.
*--------------------------------------------------------------------------*/
int
vg_set_panel_mode(unsigned long src_width, unsigned long src_height,
unsigned long dst_width, unsigned long dst_height,
unsigned long panel_width, unsigned long panel_height,
int bpp, unsigned long flags)
{
unsigned long sync_width;
unsigned long sync_offset;
VG_QUERY_MODE panel_query;
VG_DISPLAY_MODE panel_mode;
int mode;
/* SEARCH CIMARRON'S TABLE OF PREDEFINED PANEL MODES */
/* If the destination resolution is larger than the panel resolution, */
/* panning will be performed. However, the timings for a panned mode */
/* are identical to the timings without panning. To save space in the */
/* mode tables, there are no additional table entries for modes with */
/* panning. Instead, we read the timings for a mode without panning */
/* and override the structure entries that specify the width and */
/* height of the mode. We perform a similar procedure for centered */
/* modes, except that certain timing parameters are dynamically */
/* calculated. */
panel_query.active_width = panel_width;
panel_query.active_height = panel_height;
panel_query.panel_width = panel_width;
panel_query.panel_height = panel_height;
panel_query.bpp = bpp;
panel_query.query_flags = VG_QUERYFLAG_ACTIVEWIDTH |
VG_QUERYFLAG_ACTIVEHEIGHT |
VG_QUERYFLAG_PANELWIDTH |
VG_QUERYFLAG_PANELHEIGHT | VG_QUERYFLAG_PANEL | VG_QUERYFLAG_BPP;
mode = vg_get_display_mode_index(&panel_query);
/* COPY THE DATA FROM THE MODE TABLE TO A TEMPORARY STRUCTURE */
if (mode >= 0) {
panel_mode = CimarronDisplayModes[mode];
panel_mode.mode_width = dst_width;
panel_mode.mode_height = dst_height;
panel_mode.src_width = src_width;
panel_mode.src_height = src_height;
/* ADD USER-REQUESTED FLAGS */
panel_mode.flags |= (flags & VG_MODEFLAG_VALIDUSERFLAGS);
if (flags & VG_MODEFLAG_OVERRIDE_BAND) {
panel_mode.flags &= ~VG_MODEFLAG_BANDWIDTHMASK;
panel_mode.flags |= (flags & VG_MODEFLAG_BANDWIDTHMASK);
}
if (flags & VG_MODEFLAG_INT_OVERRIDE) {
panel_mode.flags &= ~VG_MODEFLAG_INT_MASK;
panel_mode.flags |= (flags & VG_MODEFLAG_INT_MASK);
}
/* DYNAMICALLY CALCULATE CENTERED TIMINGS */
/* For centered timings the blank start and blank end are set to */
/* half the difference between the mode dimension and the panel */
/* dimension. The sync pulse preserves the width and offset from */
/* blanking whenever possible. */
if (dst_width < panel_width) {
sync_width = panel_mode.hsyncend - panel_mode.hsyncstart;
sync_offset = panel_mode.hsyncstart - panel_mode.hblankstart;
panel_mode.hactive = dst_width;
panel_mode.hblankstart =
panel_mode.hactive + ((panel_width - dst_width) >> 1);
panel_mode.hblankend =
panel_mode.htotal - ((panel_width - dst_width) >> 1);
panel_mode.hsyncstart = panel_mode.hblankstart + sync_offset;
panel_mode.hsyncend = panel_mode.hsyncstart + sync_width;
panel_mode.flags |= VG_MODEFLAG_CENTERED;
}
if (dst_height < panel_height) {
sync_width = panel_mode.vsyncend - panel_mode.vsyncstart;
sync_offset = panel_mode.vsyncstart - panel_mode.vblankstart;
panel_mode.vactive = dst_height;
panel_mode.vblankstart =
panel_mode.vactive + ((panel_height - dst_height) >> 1);
panel_mode.vblankend =
panel_mode.vtotal - ((panel_height - dst_height) >> 1);
panel_mode.vsyncstart = panel_mode.vblankstart + sync_offset;
panel_mode.vsyncend = panel_mode.vsyncstart + sync_width;
panel_mode.flags |= VG_MODEFLAG_CENTERED;
}
return vg_set_custom_mode(&panel_mode, bpp);
}
return CIM_STATUS_ERROR;
}
/*---------------------------------------------------------------------------
* vg_set_tv_mode
*
* This routine sets a TV display mode using predefined Cimarron timings. The
* source width and height are specified to allow scaling.
*--------------------------------------------------------------------------*/
int
vg_set_tv_mode(unsigned long *src_width, unsigned long *src_height,
unsigned long encoder, unsigned long tvres, int bpp,
unsigned long flags, unsigned long h_overscan,
unsigned long v_overscan)
{
unsigned long sync_width;
unsigned long sync_offset;
VG_QUERY_MODE tv_query;
VG_DISPLAY_MODE tv_mode;
int mode;
if (!src_width || !src_height)
return CIM_STATUS_INVALIDPARAMS;
tv_query.bpp = bpp;
tv_query.encoder = encoder;
tv_query.tvmode = tvres;
tv_query.query_flags = VG_QUERYFLAG_BPP | VG_QUERYFLAG_TVOUT |
VG_QUERYFLAG_ENCODER | VG_QUERYFLAG_TVMODE;
mode = vg_get_display_mode_index(&tv_query);
if (mode >= 0) {
/* RETRIEVE THE UNSCALED RESOLUTION
* As we are indexing here simply by a mode and encoder, the actual
* timings may vary. A 0 value for source or height will thus query
* the unscaled resolution.
*/
if (!(*src_width) || !(*src_height)) {
*src_width = CimarronDisplayModes[mode].hactive - (h_overscan << 1);
*src_height = CimarronDisplayModes[mode].vactive;
if (CimarronDisplayModes[mode].flags & VG_MODEFLAG_INTERLACED) {
if (((flags & VG_MODEFLAG_INT_OVERRIDE) &&
(flags & VG_MODEFLAG_INT_MASK) ==
VG_MODEFLAG_INT_LINEDOUBLE)
|| (!(flags & VG_MODEFLAG_INT_OVERRIDE)
&& (CimarronDisplayModes[mode].flags &
VG_MODEFLAG_INT_MASK) ==
VG_MODEFLAG_INT_LINEDOUBLE)) {
if (CimarronDisplayModes[mode].vactive_even >
CimarronDisplayModes[mode].vactive)
*src_height = CimarronDisplayModes[mode].vactive_even;
/* ONLY 1/2 THE OVERSCAN FOR LINE DOUBLED MODES */
*src_height -= v_overscan;
}
else {
*src_height += CimarronDisplayModes[mode].vactive_even;
*src_height -= v_overscan << 1;
}
}
else {
*src_height -= v_overscan << 1;
}
return CIM_STATUS_OK;
}
tv_mode = CimarronDisplayModes[mode];
tv_mode.src_width = *src_width;
tv_mode.src_height = *src_height;
/* ADD USER-REQUESTED FLAGS */
tv_mode.flags |= (flags & VG_MODEFLAG_VALIDUSERFLAGS);
if (flags & VG_MODEFLAG_OVERRIDE_BAND) {
tv_mode.flags &= ~VG_MODEFLAG_BANDWIDTHMASK;
tv_mode.flags |= (flags & VG_MODEFLAG_BANDWIDTHMASK);
}
if (flags & VG_MODEFLAG_INT_OVERRIDE) {
tv_mode.flags &= ~VG_MODEFLAG_INT_MASK;
tv_mode.flags |= (flags & VG_MODEFLAG_INT_MASK);
}
/* ADJUST FOR OVERSCAN */
if (h_overscan) {
sync_width = tv_mode.hsyncend - tv_mode.hsyncstart;
sync_offset = tv_mode.hsyncstart - tv_mode.hblankstart;
tv_mode.hactive -= h_overscan << 1;
tv_mode.hblankstart = tv_mode.hactive + h_overscan;
tv_mode.hblankend = tv_mode.htotal - h_overscan;
tv_mode.hsyncstart = tv_mode.hblankstart + sync_offset;
tv_mode.hsyncend = tv_mode.hsyncstart + sync_width;
tv_mode.flags |= VG_MODEFLAG_CENTERED;
}
if (v_overscan) {
sync_width = tv_mode.vsyncend - tv_mode.vsyncstart;
sync_offset = tv_mode.vsyncstart - tv_mode.vblankstart;
if (tv_mode.flags & VG_MODEFLAG_INTERLACED) {
tv_mode.vactive -= v_overscan;
tv_mode.vblankstart = tv_mode.vactive + (v_overscan >> 1);
tv_mode.vblankend = tv_mode.vtotal - (v_overscan >> 1);
tv_mode.vsyncstart = tv_mode.vblankstart + sync_offset;
tv_mode.vsyncend = tv_mode.vsyncstart + sync_width;
sync_width = tv_mode.vsyncend_even - tv_mode.vsyncstart_even;
sync_offset = tv_mode.vsyncstart_even -
tv_mode.vblankstart_even;
tv_mode.vactive_even -= v_overscan;
tv_mode.vblankstart_even =
tv_mode.vactive_even + (v_overscan >> 1);
tv_mode.vblankend_even =
tv_mode.vtotal_even - (v_overscan >> 1);
tv_mode.vsyncstart_even =
tv_mode.vblankstart_even + sync_offset;
tv_mode.vsyncend_even = tv_mode.vsyncstart_even + sync_width;
}
else {
tv_mode.vactive -= v_overscan << 1;
tv_mode.vblankstart = tv_mode.vactive + v_overscan;
tv_mode.vblankend = tv_mode.vtotal - v_overscan;
tv_mode.vsyncstart = tv_mode.vblankstart + sync_offset;
tv_mode.vsyncend = tv_mode.vsyncstart + sync_width;
}
tv_mode.flags |= VG_MODEFLAG_CENTERED;
}
/* TV MODES WILL NEVER ALLOW PANNING */
tv_mode.panel_width = tv_mode.hactive;
tv_mode.panel_height = tv_mode.vactive;
tv_mode.mode_width = tv_mode.hactive;
tv_mode.mode_height = tv_mode.vactive;
return vg_set_custom_mode(&tv_mode, bpp);
}
return CIM_STATUS_ERROR;
}
/*---------------------------------------------------------------------------
* vg_set_custom_mode
*
* This routine sets a display mode. The API is structured such that this
* routine can be called from four sources:
* - vg_set_display_mode
* - vg_set_panel_mode
* - vg_set_tv_mode
* - directly by the user for a custom mode.
*--------------------------------------------------------------------------*/
int
vg_set_custom_mode(VG_DISPLAY_MODE * mode_params, int bpp)
{
unsigned long config, misc, temp;
unsigned long irq_ctl, genlk_ctl;
unsigned long unlock, flags;
unsigned long acfg, gcfg, dcfg;
unsigned long size, line_size, pitch;
unsigned long bpp_mask, dv_size;
unsigned long hscale, vscale, starting_width;
unsigned long starting_height, output_height;
Q_WORD msr_value;
/* DETERMINE DIMENSIONS FOR SCALING */
/* Scaling is performed before flicker filtering and interlacing */
output_height = mode_params->vactive;
if (mode_params->flags & VG_MODEFLAG_INTERLACED) {
/* EVEN AND ODD FIELDS ARE SEPARATE
* The composite image height is the sum of the height of both
* fields
*/
if ((mode_params->flags & VG_MODEFLAG_INT_MASK) ==
VG_MODEFLAG_INT_FLICKER
|| (mode_params->flags & VG_MODEFLAG_INT_MASK) ==
VG_MODEFLAG_INT_ADDRESS) {
output_height += mode_params->vactive_even;
}
/* LINE DOUBLING
* The composite image height is the greater of the two field
* heights.
*/
else if (mode_params->vactive_even > output_height)
output_height = mode_params->vactive_even;
}
/* CHECK FOR VALID SCALING FACTOR
* GeodeLX supports only 2:1 vertical downscale (before interlacing) and
* 2:1 horizontal downscale. The source width when scaling must be
* less than or equal to 1024 pixels. The destination can be any size,
* except when flicker filtering is enabled.
*/
irq_ctl = 0;
if (mode_params->flags & VG_MODEFLAG_PANELOUT) {
if (mode_params->src_width != mode_params->mode_width) {
starting_width = (mode_params->hactive * mode_params->src_width) /
mode_params->mode_width;
hscale = (mode_params->src_width << 14) /
(mode_params->mode_width - 1);
irq_ctl |= (DC3_IRQFILT_ALPHA_FILT_EN | DC3_IRQFILT_GFX_FILT_EN);
}
else {
starting_width = mode_params->hactive;
hscale = 0x4000;
}
if (mode_params->src_height != mode_params->mode_height) {
starting_height = (output_height * mode_params->src_height) /
mode_params->mode_height;
vscale = (mode_params->src_height << 14) /
(mode_params->mode_height - 1);
irq_ctl |= (DC3_IRQFILT_ALPHA_FILT_EN | DC3_IRQFILT_GFX_FILT_EN);
}
else {
starting_height = output_height;
vscale = 0x4000;
}
}
else {
starting_width = mode_params->src_width;
starting_height = mode_params->src_height;
if (mode_params->src_width != mode_params->hactive) {
hscale = (mode_params->src_width << 14) /
(mode_params->hactive - 1);
irq_ctl |= (DC3_IRQFILT_ALPHA_FILT_EN | DC3_IRQFILT_GFX_FILT_EN);
}
else {
hscale = 0x4000;
}
if (mode_params->src_height != output_height) {
vscale = (mode_params->src_height << 14) / (output_height - 1);
irq_ctl |= (DC3_IRQFILT_ALPHA_FILT_EN | DC3_IRQFILT_GFX_FILT_EN);
}
else {
vscale = 0x4000;
}
}
starting_width = (starting_width + 7) & 0xFFFF8;
if (mode_params->hactive < (starting_width >> 1) ||
output_height < (starting_height >> 1) ||
(irq_ctl && (starting_width > 1024))) {
return CIM_STATUS_INVALIDSCALE;
}
/* VERIFY INTERLACED SCALING */
/* The output width must be less than or equal to 1024 pixels when the */
/* flicker filter is enabled. Also, scaling should be disabled when */
/* the interlacing mode is set to interlaced addressing. */
if (mode_params->flags & VG_MODEFLAG_INTERLACED) {
if ((((mode_params->flags & VG_MODEFLAG_INT_MASK) ==
VG_MODEFLAG_INT_FLICKER) && (mode_params->hactive > 1024))
|| (((mode_params->flags & VG_MODEFLAG_INT_MASK) ==
VG_MODEFLAG_INT_ADDRESS) && irq_ctl)) {
return CIM_STATUS_INVALIDSCALE;
}
}
/* CHECK FOR VALID BPP */
switch (bpp) {
case 8:
bpp_mask = DC3_DCFG_DISP_MODE_8BPP;
break;
case 24:
bpp_mask = DC3_DCFG_DISP_MODE_24BPP;
break;
case 32:
bpp_mask = DC3_DCFG_DISP_MODE_32BPP;
break;
case 12:
bpp_mask = DC3_DCFG_DISP_MODE_16BPP | DC3_DCFG_12BPP;
break;
case 15:
bpp_mask = DC3_DCFG_DISP_MODE_16BPP | DC3_DCFG_15BPP;
break;
case 16:
bpp_mask = DC3_DCFG_DISP_MODE_16BPP | DC3_DCFG_16BPP;
break;
default:
return CIM_STATUS_INVALIDPARAMS;
}
vg3_bpp = bpp;
/* CLEAR PANNING OFFSETS */
vg3_delta_x = 0;
vg3_delta_y = 0;
/* SAVE PANEL PARAMETERS */
if (mode_params->flags & VG_MODEFLAG_PANELOUT) {
vg3_panel_enable = 1;
vg3_panel_width = mode_params->panel_width;
vg3_panel_height = mode_params->panel_height;
vg3_mode_width = mode_params->mode_width;
vg3_mode_height = mode_params->mode_height;
/* INVERT THE SHIFT CLOCK IF REQUESTED */
/* Note that we avoid writing the power management register if */
/* we can help it. */
temp = READ_VID32(DF_POWER_MANAGEMENT);
if ((mode_params->flags & VG_MODEFLAG_INVERT_SHFCLK) &&
!(temp & DF_PM_INVERT_SHFCLK)) {
WRITE_VID32(DF_POWER_MANAGEMENT, (temp | DF_PM_INVERT_SHFCLK));
}
else if (!(mode_params->flags & VG_MODEFLAG_INVERT_SHFCLK) &&
(temp & DF_PM_INVERT_SHFCLK)) {
WRITE_VID32(DF_POWER_MANAGEMENT, (temp & ~DF_PM_INVERT_SHFCLK));
}
/* SET PANEL TIMING VALUES */
if (!(mode_params->flags & VG_MODEFLAG_NOPANELTIMINGS)) {
unsigned long pmtim1, pmtim2, dith_ctl;
if (mode_params->flags & VG_MODEFLAG_XVGA_TFT) {
pmtim1 = DF_DEFAULT_XVGA_PMTIM1;
pmtim2 = DF_DEFAULT_XVGA_PMTIM2;
dith_ctl = DF_DEFAULT_DITHCTL;
msr_value.low = DF_DEFAULT_XVGA_PAD_SEL_LOW;
msr_value.high = DF_DEFAULT_XVGA_PAD_SEL_HIGH;
}
else if (mode_params->flags & VG_MODEFLAG_CUSTOM_PANEL) {
pmtim1 = mode_params->panel_tim1;
pmtim2 = mode_params->panel_tim2;
dith_ctl = mode_params->panel_dither_ctl;
msr_value.low = mode_params->panel_pad_sel_low;
msr_value.high = mode_params->panel_pad_sel_high;
}
else {
pmtim1 = DF_DEFAULT_TFT_PMTIM1;
pmtim2 = DF_DEFAULT_TFT_PMTIM2;
dith_ctl = DF_DEFAULT_DITHCTL;
msr_value.low = DF_DEFAULT_TFT_PAD_SEL_LOW;
msr_value.high = DF_DEFAULT_TFT_PAD_SEL_HIGH;
}
WRITE_VID32(DF_VIDEO_PANEL_TIM1, pmtim1);
WRITE_VID32(DF_VIDEO_PANEL_TIM2, pmtim2);
WRITE_VID32(DF_DITHER_CONTROL, dith_ctl);
msr_write64(MSR_DEVICE_GEODELX_DF, DF_MSR_PAD_SEL, &msr_value);
}
/* SET APPROPRIATE PANEL OUTPUT MODE */
msr_read64(MSR_DEVICE_GEODELX_DF, MSR_GEODELINK_CONFIG, &msr_value);
msr_value.low &= ~DF_CONFIG_OUTPUT_MASK;
msr_value.low |= DF_OUTPUT_PANEL;
if (mode_params->flags & VG_MODEFLAG_CRT_AND_FP)
msr_value.low |= DF_SIMULTANEOUS_CRT_FP;
else
msr_value.low &= ~DF_SIMULTANEOUS_CRT_FP;
msr_write64(MSR_DEVICE_GEODELX_DF, MSR_GEODELINK_CONFIG, &msr_value);
}
else if (mode_params->flags & VG_MODEFLAG_TVOUT) {
vg3_panel_enable = 0;
/* SET APPROPRIATE TV OUTPUT MODE */
msr_read64(MSR_DEVICE_GEODELX_DF, MSR_GEODELINK_CONFIG, &msr_value);
msr_value.low &= ~DF_CONFIG_OUTPUT_MASK;
msr_value.low |= DF_OUTPUT_PANEL;
if (mode_params->flags & VG_MODEFLAG_CRT_AND_FP)
msr_value.low |= DF_SIMULTANEOUS_CRT_FP;
else
msr_value.low &= ~DF_SIMULTANEOUS_CRT_FP;
msr_write64(MSR_DEVICE_GEODELX_DF, MSR_GEODELINK_CONFIG, &msr_value);
/* CONFIGURE PADS FOR VOP OUTPUT */
/* Note that the VOP clock is currently always inverted. */
msr_value.low = DF_DEFAULT_TV_PAD_SEL_LOW;
msr_value.high = DF_DEFAULT_TV_PAD_SEL_HIGH;
msr_write64(MSR_DEVICE_GEODELX_DF, DF_MSR_PAD_SEL, &msr_value);
}
else {
vg3_panel_enable = 0;
/* SET OUTPUT TO CRT ONLY */
msr_read64(MSR_DEVICE_GEODELX_DF, MSR_GEODELINK_CONFIG, &msr_value);
msr_value.low &= ~DF_CONFIG_OUTPUT_MASK;
msr_value.low |= DF_OUTPUT_CRT;
msr_write64(MSR_DEVICE_GEODELX_DF, MSR_GEODELINK_CONFIG, &msr_value);
}
/* SET UNLOCK VALUE */
unlock = READ_REG32(DC3_UNLOCK);
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
/*-------------------------------------------------------------------*/
/* MAKE THE SYSTEM "SAFE" */
/* Before setting a mode, we first ensure that the system is in a */
/* benign quiescent state. This involves disabling compression and */
/* all interrupt sources. It also involves terminating all accesses */
/* to memory, including video, FIFO load, VIP and the GP. */
/*-------------------------------------------------------------------*/
/* DISABLE VGA
* VGA *MUST* be turned off before TGEN is enabled. If not, a condition
* will result where VGA Enable is waiting for a VSync to be latched but
* a VSync will not be generated until VGA is disabled.
*/
temp = READ_REG32(DC3_GENERAL_CFG) & ~DC3_GCFG_VGAE;
/* DISABLE VIDEO (INCLUDING ALPHA WINDOWS) */
WRITE_VID32(DF_ALPHA_CONTROL_1, 0);
WRITE_VID32(DF_ALPHA_CONTROL_1 + 32, 0);
WRITE_VID32(DF_ALPHA_CONTROL_1 + 64, 0);
WRITE_REG32(DC3_GENERAL_CFG, (temp & ~DC3_GCFG_VIDE));
temp = READ_VID32(DF_VIDEO_CONFIG);
WRITE_VID32(DF_VIDEO_CONFIG, (temp & ~DF_VCFG_VID_EN));
/* DISABLE VG INTERRUPTS */
WRITE_REG32(DC3_IRQ, DC3_IRQ_MASK | DC3_VSYNC_IRQ_MASK |
DC3_IRQ_STATUS | DC3_VSYNC_IRQ_STATUS);
/* DISABLE GENLOCK */
genlk_ctl = READ_REG32(DC3_GENLK_CTL);
WRITE_REG32(DC3_GENLK_CTL, (genlk_ctl & ~DC3_GC_GENLOCK_ENABLE));
/* DISABLE VIP CAPTURE AND VIP INTERRUPTS */
WRITE_VIP32(VIP_CONTROL1, 0);
WRITE_VIP32(VIP_CONTROL2, 0);
WRITE_VIP32(VIP_INTERRUPT, VIP_ALL_INTERRUPTS | (VIP_ALL_INTERRUPTS >> 16));
/* DISABLE COLOR KEYING
* The color key mechanism should be disabled whenever a mode switch
* occurs.
*/
temp = READ_REG32(DC3_COLOR_KEY);
WRITE_REG32(DC3_COLOR_KEY, (temp & ~DC3_CLR_KEY_ENABLE));
/* BLANK THE DISPLAY
* Note that we never blank the panel. Most flat panels have very long
* latency requirements when setting their power low. Some panels require
* upwards of 500ms before VDD goes high again. Needless to say, we are
* not planning to take over one half a second inside this routine.
*/
misc = READ_VID32(DF_VID_MISC);
config = READ_VID32(DF_DISPLAY_CONFIG);
WRITE_VID32(DF_VID_MISC, (misc | DF_DAC_POWER_DOWN));
WRITE_VID32(DF_DISPLAY_CONFIG,
(config & ~(DF_DCFG_DIS_EN | DF_DCFG_HSYNC_EN |
DF_DCFG_VSYNC_EN | DF_DCFG_DAC_BL_EN)));
/* DISABLE COMPRESSION */
gcfg = READ_REG32(DC3_GENERAL_CFG);
gcfg &= ~(DC3_GCFG_CMPE | DC3_GCFG_DECE);
WRITE_REG32(DC3_GENERAL_CFG, gcfg);
/* DISABLE THE TIMING GENERATOR */
dcfg = READ_REG32(DC3_DISPLAY_CFG);
dcfg &= ~DC3_DCFG_TGEN;
WRITE_REG32(DC3_DISPLAY_CFG, dcfg);
/* WAIT FOR PENDING MEMORY REQUESTS */
vg_delay_milliseconds(1);
/* DISABLE DISPLAY FIFO LOAD */
gcfg &= ~DC3_GCFG_DFLE;
WRITE_REG32(DC3_GENERAL_CFG, gcfg);
gcfg = 0;
dcfg = 0;
/* WAIT FOR THE GP TO BE IDLE (JUST IN CASE) */
while (((temp = READ_GP32(GP3_BLT_STATUS)) & GP3_BS_BLT_BUSY) ||
!(temp & GP3_BS_CB_EMPTY)) {
;
}
/* SET THE DOT CLOCK FREQUENCY */
if (!(mode_params->flags & VG_MODEFLAG_EXCLUDEPLL)) {
if (mode_params->flags & VG_MODEFLAG_HALFCLOCK)
flags = VG_PLL_DIVIDE_BY_2;
else if (mode_params->flags & VG_MODEFLAG_QVGA)
flags = VG_PLL_DIVIDE_BY_4;
else
flags = 0;
/* ALLOW DOTREF TO BE USED AS THE PLL */
/* This is useful for some external TV encoders. */
if (mode_params->flags & VG_MODEFLAG_PLL_BYPASS)
flags |= VG_PLL_BYPASS;
/* ALLOW THE USER TO MANUALLY ENTER THE MSR VALUE */
if (mode_params->flags & VG_MODEFLAG_MANUAL_FREQUENCY)
flags |= VG_PLL_MANUAL;
if (mode_params->flags & VG_MODEFLAG_VIP_TO_DOT_CLOCK)
flags |= VG_PLL_VIP_CLOCK;
vg_set_clock_frequency(mode_params->frequency, flags);
}
/* CLEAR ALL BUFFER OFFSETS */
WRITE_REG32(DC3_FB_ST_OFFSET, 0);
WRITE_REG32(DC3_CB_ST_OFFSET, 0);
WRITE_REG32(DC3_CURS_ST_OFFSET, 0);
genlk_ctl = READ_REG32(DC3_GENLK_CTL) & ~(DC3_GC_ALPHA_FLICK_ENABLE |
DC3_GC_FLICKER_FILTER_ENABLE |
DC3_GC_FLICKER_FILTER_MASK);
/* ENABLE INTERLACING */
if (mode_params->flags & VG_MODEFLAG_INTERLACED) {
irq_ctl |= DC3_IRQFILT_INTL_EN;
if ((mode_params->flags & VG_MODEFLAG_INT_MASK) ==
VG_MODEFLAG_INT_ADDRESS)
irq_ctl |= DC3_IRQFILT_INTL_ADDR;
else if ((mode_params->flags & VG_MODEFLAG_INT_MASK) ==
VG_MODEFLAG_INT_FLICKER) {
genlk_ctl |= DC3_GC_FLICKER_FILTER_1_8 |
DC3_GC_FLICKER_FILTER_ENABLE | DC3_GC_ALPHA_FLICK_ENABLE;
}
}
WRITE_REG32(DC3_GFX_SCALE, (vscale << 16) | (hscale & 0xFFFF));
WRITE_REG32(DC3_IRQ_FILT_CTL, irq_ctl);
WRITE_REG32(DC3_GENLK_CTL, genlk_ctl);
/* SET LINE SIZE AND PITCH
* The line size and pitch are calculated from the src_width parameter
* passed in to this routine. All other parameters are ignored.
* The pitch is set either to a power of 2 to allow efficient
* compression or to a linear value to allow efficient memory management.
*/
switch (bpp) {
case 8:
size = mode_params->src_width;
line_size = starting_width;
break;
case 12:
case 15:
case 16:
size = mode_params->src_width << 1;
line_size = starting_width << 1;
break;
case 24:
case 32:
default:
size = mode_params->src_width << 2;
line_size = starting_width << 2;
break;
}
/* CALCULATE DV RAM SETTINGS AND POWER OF 2 PITCH */
pitch = 1024;
dv_size = DC3_DV_LINE_SIZE_1024;
if (size > 1024) {
pitch = 2048;
dv_size = DC3_DV_LINE_SIZE_2048;
}
if (size > 2048) {
pitch = 4096;
dv_size = DC3_DV_LINE_SIZE_4096;
}
if (size > 4096) {
pitch = 8192;
dv_size = DC3_DV_LINE_SIZE_8192;
}
/* OVERRIDE SETTINGS FOR LINEAR PITCH */
if (mode_params->flags & VG_MODEFLAG_LINEARPITCH) {
unsigned long max;
if (pitch != size) {
/* CALCULATE MAXIMUM ADDRESS (1K ALIGNED) */
max = size * output_height;
max = (max + 0x3FF) & 0xFFFFFC00;
WRITE_REG32(DC3_DV_TOP, max | DC3_DVTOP_ENABLE);
gcfg |= DC3_GCFG_FDTY;
pitch = size;
}
else {
WRITE_REG32(DC3_DV_TOP, 0);
}
}
/* WRITE PITCH AND DV RAM SETTINGS */
/* The DV RAM line length is programmed at a power of 2 boundary */
/* in case the user wants to toggle back to a power of 2 pitch */
/* later. It could happen... */
temp = READ_REG32(DC3_DV_CTL);
WRITE_REG32(DC3_GFX_PITCH, pitch >> 3);
WRITE_REG32(DC3_DV_CTL, (temp & ~DC3_DV_LINE_SIZE_MASK) | dv_size);
/* SET THE LINE SIZE */
WRITE_REG32(DC3_LINE_SIZE, (line_size + 7) >> 3);
/* ALWAYS ENABLE VIDEO AND GRAPHICS DATA */
/* These bits are relics from a previous design and */
/* should always be enabled. */
dcfg |= (DC3_DCFG_VDEN | DC3_DCFG_GDEN);
/* SET PIXEL FORMAT */
dcfg |= bpp_mask;
/* ENABLE TIMING GENERATOR, TIM. REG. UPDATES, PALETTE BYPASS */
/* AND VERT. INT. SELECT */
dcfg |= (unsigned long) (DC3_DCFG_TGEN | DC3_DCFG_TRUP | DC3_DCFG_PALB |
DC3_DCFG_VISL);
/* SET FIFO PRIORITIES AND DISPLAY FIFO LOAD ENABLE
* Note that the bandwidth setting gets upgraded when scaling or flicker
* filtering are enabled, as they require more data throughput.
*/
msr_read64(MSR_DEVICE_GEODELX_VG, DC3_SPARE_MSR, &msr_value);
msr_value.low &= ~(DC3_SPARE_DISABLE_CFIFO_HGO |
DC3_SPARE_VFIFO_ARB_SELECT |
DC3_SPARE_LOAD_WM_LPEN_MASK | DC3_SPARE_WM_LPEN_OVRD |
DC3_SPARE_DISABLE_INIT_VID_PRI |
DC3_SPARE_DISABLE_VFIFO_WM);
if ((mode_params->flags & VG_MODEFLAG_BANDWIDTHMASK) ==
VG_MODEFLAG_HIGH_BAND || ((mode_params->flags & VG_MODEFLAG_INTERLACED)
&& (mode_params->flags & VG_MODEFLAG_INT_MASK)
== VG_MODEFLAG_INT_FLICKER) ||
(irq_ctl & DC3_IRQFILT_GFX_FILT_EN)) {
/* HIGH BANDWIDTH */
/* Set aggressive watermarks and disallow forced low priority */
gcfg |= 0x0000BA01;
dcfg |= 0x000EA000;
acfg = 0x001A0201;
msr_value.low |= DC3_SPARE_DISABLE_CFIFO_HGO |
DC3_SPARE_VFIFO_ARB_SELECT | DC3_SPARE_WM_LPEN_OVRD;
}
else if ((mode_params->flags & VG_MODEFLAG_BANDWIDTHMASK) ==
VG_MODEFLAG_AVG_BAND) {
/* AVERAGE BANDWIDTH
* Set average watermarks and allow small regions of forced low
* priority.
*/
gcfg |= 0x0000B601;
dcfg |= 0x00009000;
acfg = 0x00160001;
msr_value.low |= DC3_SPARE_DISABLE_CFIFO_HGO |
DC3_SPARE_VFIFO_ARB_SELECT | DC3_SPARE_WM_LPEN_OVRD;
/* SET THE NUMBER OF LOW PRIORITY LINES TO 1/2 THE TOTAL AVAILABLE */
temp = ((READ_REG32(DC3_V_ACTIVE_TIMING) >> 16) & 0x7FF) + 1;
temp -= (READ_REG32(DC3_V_SYNC_TIMING) & 0x7FF) + 1;
temp >>= 1;
if (temp > 127)
temp = 127;
acfg |= temp << 9;
}
else if ((mode_params->flags & VG_MODEFLAG_BANDWIDTHMASK) ==
VG_MODEFLAG_LOW_BAND) {
/* LOW BANDWIDTH
* Set low watermarks and allow larger regions of forced low priority
*/
gcfg |= 0x00009501;
dcfg |= 0x00008000;
acfg = 0x00150001;
msr_value.low |= DC3_SPARE_DISABLE_CFIFO_HGO |
DC3_SPARE_VFIFO_ARB_SELECT | DC3_SPARE_WM_LPEN_OVRD;
/* SET THE NUMBER OF LOW PRIORITY LINES TO 3/4 THE TOTAL AVAILABLE */
temp = ((READ_REG32(DC3_V_ACTIVE_TIMING) >> 16) & 0x7FF) + 1;
temp -= (READ_REG32(DC3_V_SYNC_TIMING) & 0x7FF) + 1;
temp = (temp * 3) >> 2;
if (temp > 127)
temp = 127;
acfg |= temp << 9;
}
else {
/* LEGACY CHARACTERISTICS */
/* Arbitration from a single set of watermarks. */
gcfg |= 0x0000B601;
msr_value.low |= DC3_SPARE_DISABLE_VFIFO_WM |
DC3_SPARE_DISABLE_INIT_VID_PRI;
acfg = 0;
}
msr_write64(MSR_DEVICE_GEODELX_VG, DC3_SPARE_MSR, &msr_value);
/* ENABLE FLAT PANEL CENTERING */
/* For panel modes having a resolution smaller than the */
/* panel resolution, turn on data centering. */
if (mode_params->flags & VG_MODEFLAG_CENTERED)
dcfg |= DC3_DCFG_DCEN;
/* COMBINE AND SET TIMING VALUES */
temp = (mode_params->hactive - 1) | ((mode_params->htotal - 1) << 16);
WRITE_REG32(DC3_H_ACTIVE_TIMING, temp);
temp = (mode_params->hblankstart - 1) |
((mode_params->hblankend - 1) << 16);
WRITE_REG32(DC3_H_BLANK_TIMING, temp);
temp = (mode_params->hsyncstart - 1) | ((mode_params->hsyncend - 1) << 16);
WRITE_REG32(DC3_H_SYNC_TIMING, temp);
temp = (mode_params->vactive - 1) | ((mode_params->vtotal - 1) << 16);
WRITE_REG32(DC3_V_ACTIVE_TIMING, temp);
temp = (mode_params->vblankstart - 1) |
((mode_params->vblankend - 1) << 16);
WRITE_REG32(DC3_V_BLANK_TIMING, temp);
temp = (mode_params->vsyncstart - 1) | ((mode_params->vsyncend - 1) << 16);
WRITE_REG32(DC3_V_SYNC_TIMING, temp);
temp = (mode_params->vactive_even - 1) | ((mode_params->vtotal_even -
1) << 16);
WRITE_REG32(DC3_V_ACTIVE_EVEN, temp);
temp = (mode_params->vblankstart_even - 1) |
((mode_params->vblankend_even - 1) << 16);
WRITE_REG32(DC3_V_BLANK_EVEN, temp);
temp = (mode_params->vsyncstart_even - 1) |
((mode_params->vsyncend_even - 1) << 16);
WRITE_REG32(DC3_V_SYNC_EVEN, temp);
/* SET THE VIDEO REQUEST REGISTER */
WRITE_VID32(DF_VIDEO_REQUEST, 0);
/* SET SOURCE DIMENSIONS */
WRITE_REG32(DC3_FB_ACTIVE, ((starting_width - 1) << 16) |
(starting_height - 1));
/* SET SYNC POLARITIES */
temp = READ_VID32(DF_DISPLAY_CONFIG);
temp &= ~(DF_DCFG_CRT_SYNC_SKW_MASK | DF_DCFG_PWR_SEQ_DLY_MASK |
DF_DCFG_CRT_HSYNC_POL | DF_DCFG_CRT_VSYNC_POL);
temp |= DF_DCFG_CRT_SYNC_SKW_INIT | DF_DCFG_PWR_SEQ_DLY_INIT;
if (mode_params->flags & VG_MODEFLAG_NEG_HSYNC)
temp |= DF_DCFG_CRT_HSYNC_POL;
if (mode_params->flags & VG_MODEFLAG_NEG_VSYNC)
temp |= DF_DCFG_CRT_VSYNC_POL;
WRITE_VID32(DF_DISPLAY_CONFIG, temp);
WRITE_REG32(DC3_DISPLAY_CFG, dcfg);
WRITE_REG32(DC3_ARB_CFG, acfg);
WRITE_REG32(DC3_GENERAL_CFG, gcfg);
/* RESTORE VALUE OF DC3_UNLOCK */
WRITE_REG32(DC3_UNLOCK, unlock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_bpp
*
* This routine changes the display BPP on the fly. It is intended only to
* switch between pixel depths of the same pixel size 24<->32 or 15<->16, NOT
* between pixel depths of differing sizes 16<->32
*--------------------------------------------------------------------------*/
int
vg_set_display_bpp(int bpp)
{
unsigned long unlock, dcfg, bpp_mask;
switch (bpp) {
case 8:
bpp_mask = DC3_DCFG_DISP_MODE_8BPP;
break;
case 24:
bpp_mask = DC3_DCFG_DISP_MODE_24BPP;
break;
case 32:
bpp_mask = DC3_DCFG_DISP_MODE_32BPP;
break;
case 12:
bpp_mask = DC3_DCFG_DISP_MODE_16BPP | DC3_DCFG_12BPP;
break;
case 15:
bpp_mask = DC3_DCFG_DISP_MODE_16BPP | DC3_DCFG_15BPP;
break;
case 16:
bpp_mask = DC3_DCFG_DISP_MODE_16BPP | DC3_DCFG_16BPP;
break;
default:
return CIM_STATUS_INVALIDPARAMS;
}
unlock = READ_REG32(DC3_UNLOCK);
dcfg = READ_REG32(DC3_DISPLAY_CFG) & ~(DC3_DCFG_DISP_MODE_MASK |
DC3_DCFG_16BPP_MODE_MASK);
dcfg |= bpp_mask;
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_DISPLAY_CFG, dcfg);
WRITE_REG32(DC3_UNLOCK, unlock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_get_display_mode_index
*
* This routine searches the Cimarron mode table for a mode that matches the
* input parameters. If a match is found, the return value is the index into
* the mode table. If no match is found, the return value is -1.
*--------------------------------------------------------------------------*/
int
vg_get_display_mode_index(VG_QUERY_MODE * query)
{
unsigned int mode;
unsigned long hz_flag = 0xFFFFFFFF;
unsigned long bpp_flag = 0xFFFFFFFF;
unsigned long enc_flag = 0xFFFFFFFF;
unsigned long tv_flag = 0;
unsigned long interlaced = 0;
unsigned long halfclock = 0;
long minimum = 0x7FFFFFFF;
long diff;
int match = -1;
if (!query || !query->query_flags)
return -1;
if (query->query_flags & VG_QUERYFLAG_REFRESH) {
/* SET FLAGS TO MATCH REFRESH RATE */
if (query->hz == 56)
hz_flag = VG_SUPPORTFLAG_56HZ;
else if (query->hz == 60)
hz_flag = VG_SUPPORTFLAG_60HZ;
else if (query->hz == 70)
hz_flag = VG_SUPPORTFLAG_70HZ;
else if (query->hz == 72)
hz_flag = VG_SUPPORTFLAG_72HZ;
else if (query->hz == 75)
hz_flag = VG_SUPPORTFLAG_75HZ;
else if (query->hz == 85)
hz_flag = VG_SUPPORTFLAG_85HZ;
else if (query->hz == 90)
hz_flag = VG_SUPPORTFLAG_90HZ;
else if (query->hz == 100)
hz_flag = VG_SUPPORTFLAG_100HZ;
else
hz_flag = 0;
}
if (query->query_flags & VG_QUERYFLAG_BPP) {
/* SET BPP FLAGS TO LIMIT MODE SELECTION */
if (query->bpp == 8)
bpp_flag = VG_SUPPORTFLAG_8BPP;
else if (query->bpp == 12)
bpp_flag = VG_SUPPORTFLAG_12BPP;
else if (query->bpp == 15)
bpp_flag = VG_SUPPORTFLAG_15BPP;
else if (query->bpp == 16)
bpp_flag = VG_SUPPORTFLAG_16BPP;
else if (query->bpp == 24)
bpp_flag = VG_SUPPORTFLAG_24BPP;
else if (query->bpp == 32)
bpp_flag = VG_SUPPORTFLAG_32BPP;
else
bpp_flag = 0;
}
if (query->query_flags & VG_QUERYFLAG_ENCODER) {
/* SET ENCODER FLAGS TO LIMIT MODE SELECTION */
if (query->encoder == VG_ENCODER_ADV7171)
enc_flag = VG_SUPPORTFLAG_ADV7171;
else if (query->encoder == VG_ENCODER_SAA7127)
enc_flag = VG_SUPPORTFLAG_SAA7127;
else if (query->encoder == VG_ENCODER_FS454)
enc_flag = VG_SUPPORTFLAG_FS454;
else if (query->encoder == VG_ENCODER_ADV7300)
enc_flag = VG_SUPPORTFLAG_ADV7300;
else
enc_flag = 0;
}
if (query->query_flags & VG_QUERYFLAG_TVMODE) {
/* SET ENCODER FLAGS TO LIMIT MODE SELECTION */
if (query->tvmode == VG_TVMODE_NTSC)
tv_flag = VG_SUPPORTFLAG_NTSC;
else if (query->tvmode == VG_TVMODE_PAL)
tv_flag = VG_SUPPORTFLAG_PAL;
else if (query->tvmode == VG_TVMODE_480P)
tv_flag = VG_SUPPORTFLAG_480P;
else if (query->tvmode == VG_TVMODE_720P)
tv_flag = VG_SUPPORTFLAG_720P;
else if (query->tvmode == VG_TVMODE_1080I)
tv_flag = VG_SUPPORTFLAG_1080I;
else if (query->tvmode == VG_TVMODE_6X4_NTSC)
tv_flag = VG_SUPPORTFLAG_6X4_NTSC;
else if (query->tvmode == VG_TVMODE_8X6_NTSC)
tv_flag = VG_SUPPORTFLAG_8X6_NTSC;
else if (query->tvmode == VG_TVMODE_10X7_NTSC)
tv_flag = VG_SUPPORTFLAG_10X7_NTSC;
else if (query->tvmode == VG_TVMODE_6X4_PAL)
tv_flag = VG_SUPPORTFLAG_6X4_PAL;
else if (query->tvmode == VG_TVMODE_8X6_PAL)
tv_flag = VG_SUPPORTFLAG_8X6_PAL;
else if (query->tvmode == VG_TVMODE_10X7_PAL)
tv_flag = VG_SUPPORTFLAG_10X7_PAL;
else
tv_flag = 0xFFFFFFFF;
}
/* SET APPROPRIATE TV AND VOP FLAGS */
if (query->query_flags & VG_QUERYFLAG_INTERLACED)
interlaced = query->interlaced ? VG_MODEFLAG_INTERLACED : 0;
if (query->query_flags & VG_QUERYFLAG_HALFCLOCK)
halfclock = query->halfclock ? VG_MODEFLAG_HALFCLOCK : 0;
/* CHECK FOR INVALID REQUEST */
if (!hz_flag || !bpp_flag || !enc_flag || tv_flag == 0xFFFFFFFF)
return -1;
/* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */
for (mode = 0; mode < NUM_CIMARRON_DISPLAY_MODES; mode++) {
if ((!(query->query_flags & VG_QUERYFLAG_PANEL) ||
(CimarronDisplayModes[mode].internal_flags & VG_SUPPORTFLAG_PANEL))
&& (!(query->query_flags & VG_QUERYFLAG_TVOUT)
|| (CimarronDisplayModes[mode].internal_flags &
VG_SUPPORTFLAG_TVOUT))
&& (!(query->query_flags & VG_QUERYFLAG_INTERLACED)
|| (CimarronDisplayModes[mode].flags & VG_MODEFLAG_INTERLACED)
== interlaced)
&& (!(query->query_flags & VG_QUERYFLAG_HALFCLOCK)
|| (CimarronDisplayModes[mode].flags & VG_MODEFLAG_HALFCLOCK) ==
halfclock)
&& (!(query->query_flags & VG_QUERYFLAG_PANELWIDTH)
|| (CimarronDisplayModes[mode].panel_width ==
query->panel_width))
&& (!(query->query_flags & VG_QUERYFLAG_PANELHEIGHT)
|| (CimarronDisplayModes[mode].panel_height ==
query->panel_height))
&& (!(query->query_flags & VG_QUERYFLAG_ACTIVEWIDTH)
|| (CimarronDisplayModes[mode].hactive == query->active_width))
&& (!(query->query_flags & VG_QUERYFLAG_ACTIVEHEIGHT)
|| (CimarronDisplayModes[mode].vactive == query->active_height))
&& (!(query->query_flags & VG_QUERYFLAG_TOTALWIDTH)
|| (CimarronDisplayModes[mode].htotal == query->total_width))
&& (!(query->query_flags & VG_QUERYFLAG_TOTALHEIGHT)
|| (CimarronDisplayModes[mode].vtotal == query->total_height))
&& (!(query->query_flags & VG_QUERYFLAG_BPP)
|| (CimarronDisplayModes[mode].internal_flags & bpp_flag))
&& (!(query->query_flags & VG_QUERYFLAG_REFRESH)
|| (CimarronDisplayModes[mode].internal_flags & hz_flag))
&& (!(query->query_flags & VG_QUERYFLAG_ENCODER)
|| (CimarronDisplayModes[mode].internal_flags & enc_flag))
&& (!(query->query_flags & VG_QUERYFLAG_TVMODE)
||
((CimarronDisplayModes[mode].internal_flags &
VG_SUPPORTFLAG_TVMODEMASK) == tv_flag))
&& (!(query->query_flags & VG_QUERYFLAG_PIXELCLOCK)
|| (CimarronDisplayModes[mode].frequency == query->frequency))) {
/* ALLOW SEARCHING BASED ON AN APPROXIMATE PIXEL CLOCK */
if (query->query_flags & VG_QUERYFLAG_PIXELCLOCK_APPROX) {
diff = query->frequency - CimarronDisplayModes[mode].frequency;
if (diff < 0)
diff = -diff;
if (diff < minimum) {
minimum = diff;
match = mode;
}
}
else {
match = mode;
break;
}
}
}
/* RETURN DISPLAY MODE INDEX */
return match;
}
/*---------------------------------------------------------------------------
* vg_get_display_mode_information
*
* This routine retrieves all information for a display mode contained
* within Cimarron's mode tables.
*--------------------------------------------------------------------------*/
int
vg_get_display_mode_information(unsigned int index, VG_DISPLAY_MODE * vg_mode)
{
if (index > NUM_CIMARRON_DISPLAY_MODES)
return CIM_STATUS_INVALIDPARAMS;
*vg_mode = CimarronDisplayModes[index];
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_get_display_mode_count
*
* This routine retrieves the count of all predefined Cimarron modes.
*--------------------------------------------------------------------------*/
int
vg_get_display_mode_count(void)
{
return NUM_CIMARRON_DISPLAY_MODES;
}
/*---------------------------------------------------------------------------
* vg_get_current_display_mode
*
* This routine retrieves the settings for the current display. This includes
* any panel settings.
*--------------------------------------------------------------------------*/
int
vg_get_current_display_mode(VG_DISPLAY_MODE * current_display, int *bpp)
{
Q_WORD msr_value;
unsigned long active, blank, sync;
unsigned long i, m, n, p;
unsigned long genlk, irq, temp;
unsigned long flags = 0;
unsigned long iflags = 0;
/* READ THE CURRENT HORIZONTAL DISPLAY TIMINGS */
active = READ_REG32(DC3_H_ACTIVE_TIMING);
blank = READ_REG32(DC3_H_BLANK_TIMING);
sync = READ_REG32(DC3_H_SYNC_TIMING);
current_display->hactive = (active & 0xFFF) + 1;
current_display->hblankstart = (blank & 0xFFF) + 1;
current_display->hsyncstart = (sync & 0xFFF) + 1;
current_display->htotal = ((active >> 16) & 0xFFF) + 1;
current_display->hblankend = ((blank >> 16) & 0xFFF) + 1;
current_display->hsyncend = ((sync >> 16) & 0xFFF) + 1;
/* READ THE CURRENT VERTICAL DISPLAY TIMINGS */
active = READ_REG32(DC3_V_ACTIVE_TIMING);
blank = READ_REG32(DC3_V_BLANK_TIMING);
sync = READ_REG32(DC3_V_SYNC_TIMING);
current_display->vactive = (active & 0x7FF) + 1;
current_display->vblankstart = (blank & 0x7FF) + 1;
current_display->vsyncstart = (sync & 0x7FF) + 1;
current_display->vtotal = ((active >> 16) & 0x7FF) + 1;
current_display->vblankend = ((blank >> 16) & 0x7FF) + 1;
current_display->vsyncend = ((sync >> 16) & 0x7FF) + 1;
/* READ THE CURRENT EVEN FIELD VERTICAL DISPLAY TIMINGS */
active = READ_REG32(DC3_V_ACTIVE_EVEN);
blank = READ_REG32(DC3_V_BLANK_EVEN);
sync = READ_REG32(DC3_V_SYNC_EVEN);
current_display->vactive_even = (active & 0x7FF) + 1;
current_display->vblankstart_even = (blank & 0x7FF) + 1;
current_display->vsyncstart_even = (sync & 0x7FF) + 1;
current_display->vtotal_even = ((active >> 16) & 0x7FF) + 1;
current_display->vblankend_even = ((blank >> 16) & 0x7FF) + 1;
current_display->vsyncend_even = ((sync >> 16) & 0x7FF) + 1;
/* READ THE CURRENT SOURCE DIMENSIONS */
/* The DC3_FB_ACTIVE register is only used when scaling is enabled. */
/* As the goal of this routine is to return a structure that can be */
/* passed to vg_set_custom_mode to exactly recreate the current mode, */
/* we must check the status of the scaler/filter. */
genlk = READ_REG32(DC3_GENLK_CTL);
irq = READ_REG32(DC3_IRQ_FILT_CTL);
temp = READ_REG32(DC3_FB_ACTIVE);
current_display->src_height = (temp & 0xFFFF) + 1;
current_display->src_width = ((temp >> 16) & 0xFFF8) + 8;
/* READ THE CURRENT PANEL CONFIGURATION */
/* We can only infer some of the panel settings based on hardware */
/* (like when panning). We will instead assume that the current */
/* mode was set using Cimarron and use the panel variables inside */
/* Cimarron when returning the current mode information. */
if (vg3_panel_enable) {
flags |= VG_MODEFLAG_PANELOUT;
current_display->panel_width = vg3_panel_width;
current_display->panel_height = vg3_panel_height;
current_display->mode_width = vg3_mode_width;
current_display->mode_height = vg3_mode_height;
if (READ_REG32(DC3_DISPLAY_CFG) & DC3_DCFG_DCEN)
flags |= VG_MODEFLAG_CENTERED;
msr_read64(MSR_DEVICE_GEODELX_DF, DF_MSR_PAD_SEL, &msr_value);
current_display->panel_tim1 = READ_VID32(DF_VIDEO_PANEL_TIM1);
current_display->panel_tim2 = READ_VID32(DF_VIDEO_PANEL_TIM2);
current_display->panel_dither_ctl = READ_VID32(DF_DITHER_CONTROL);
current_display->panel_pad_sel_low = msr_value.low;
current_display->panel_pad_sel_high = msr_value.high;
}
/* SET MISCELLANEOUS MODE FLAGS */
/* INTERLACED */
if (irq & DC3_IRQFILT_INTL_EN) {
flags |= VG_MODEFLAG_INTERLACED;
if (irq & DC3_IRQFILT_INTL_ADDR)
flags |= VG_MODEFLAG_INT_ADDRESS;
else if (genlk & DC3_GC_FLICKER_FILTER_ENABLE)
flags |= VG_MODEFLAG_INT_FLICKER;
else
flags |= VG_MODEFLAG_INT_LINEDOUBLE;
}
/* POLARITIES */
temp = READ_VID32(DF_DISPLAY_CONFIG);
if (temp & DF_DCFG_CRT_HSYNC_POL)
flags |= VG_MODEFLAG_NEG_HSYNC;
if (temp & DF_DCFG_CRT_VSYNC_POL)
flags |= VG_MODEFLAG_NEG_VSYNC;
/* BPP */
temp = READ_REG32(DC3_DISPLAY_CFG) & DC3_DCFG_DISP_MODE_MASK;
if (temp == DC3_DCFG_DISP_MODE_8BPP) {
iflags |= VG_SUPPORTFLAG_8BPP;
*bpp = 8;
}
else if (temp == DC3_DCFG_DISP_MODE_24BPP) {
iflags |= VG_SUPPORTFLAG_24BPP;
*bpp = 24;
}
else if (temp == DC3_DCFG_DISP_MODE_32BPP) {
iflags |= VG_SUPPORTFLAG_32BPP;
*bpp = 32;
}
else if (temp == DC3_DCFG_DISP_MODE_16BPP) {
temp = READ_REG32(DC3_DISPLAY_CFG) & DC3_DCFG_16BPP_MODE_MASK;
if (temp == DC3_DCFG_16BPP) {
iflags |= VG_SUPPORTFLAG_16BPP;
*bpp = 16;
}
else if (temp == DC3_DCFG_15BPP) {
iflags |= VG_SUPPORTFLAG_15BPP;
*bpp = 15;
}
else if (temp == DC3_DCFG_12BPP) {
iflags |= VG_SUPPORTFLAG_12BPP;
*bpp = 12;
}
}
/* TV RELATED FLAGS */
msr_read64(MSR_DEVICE_GEODELX_DF, DF_MSR_PAD_SEL, &msr_value);
if (msr_value.high & DF_INVERT_VOP_CLOCK)
flags |= VG_MODEFLAG_TVOUT;
/* LINEAR PITCH */
temp = (READ_REG32(DC3_GFX_PITCH) & 0x0000FFFF) << 3;
if (temp != 1024 && temp != 2048 && temp != 4096 && temp != 8192)
flags |= VG_MODEFLAG_LINEARPITCH;
/* SIMULTANEOUS CRT/FP */
msr_read64(MSR_DEVICE_GEODELX_DF, MSR_GEODELINK_CONFIG, &msr_value);
if (msr_value.low & DF_SIMULTANEOUS_CRT_FP)
flags |= VG_MODEFLAG_CRT_AND_FP;
/* SET PLL-RELATED FLAGS */
msr_read64(MSR_DEVICE_GEODELX_GLCP, GLCP_DOTPLL, &msr_value);
if (msr_value.high & GLCP_DOTPLL_DIV4)
flags |= VG_MODEFLAG_QVGA;
if (msr_value.low & GLCP_DOTPLL_HALFPIX)
flags |= VG_MODEFLAG_HALFCLOCK;
/* SAVE THE FLAGS IN THE MODE STRUCTURE */
current_display->internal_flags = iflags;
current_display->flags = flags;
/* READ PIXEL CLOCK FREQUENCY */
/* We first search for an exact match. If none is found, we try */
/* a fixed point calculation and return CIM_STATUS_INEXACTMATCH. */
for (i = 0; i < NUM_CIMARRON_PLL_FREQUENCIES; i++) {
if (CimarronPLLFrequencies[i].pll_value == msr_value.high)
break;
}
if (i == NUM_CIMARRON_PLL_FREQUENCIES) {
/* ATTEMPT 16.16 CALCULATION */
/* We assume the input frequency is 48 MHz, which is represented */
/* in 16.16 fixed point as 0x300000. The PLL calculation is: */
/* n + 1 */
/* Fout = 48.000 * -------------- */
/* m + 1 * p + 1 */
p = msr_value.high & 0xF;
n = (msr_value.high >> 4) & 0xFF;
m = (msr_value.high >> 12) & 0x7;
current_display->frequency = (0x300000 * (n + 1)) / ((p + 1) * (m + 1));
return CIM_STATUS_INEXACTMATCH;
}
current_display->frequency = CimarronPLLFrequencies[i].frequency;
/* NOW SEARCH FOR AN IDENTICAL MODE */
/* This is just to inform the user that an exact match was found. */
/* With an exact match, the user can use the refresh rate flag that */
/* is returned in the VG_DISPLAY_MODE structure. */
for (i = 0; i < NUM_CIMARRON_DISPLAY_MODES; i++) {
if ((CimarronDisplayModes[i].flags & current_display->flags) &&
CimarronDisplayModes[i].frequency ==
current_display->frequency &&
CimarronDisplayModes[i].hactive == current_display->hactive &&
CimarronDisplayModes[i].hblankstart ==
current_display->hblankstart
&& CimarronDisplayModes[i].hsyncstart ==
current_display->hsyncstart
&& CimarronDisplayModes[i].hsyncend ==
current_display->hsyncend
&& CimarronDisplayModes[i].hblankend ==
current_display->hblankend
&& CimarronDisplayModes[i].htotal == current_display->htotal
&& CimarronDisplayModes[i].vactive == current_display->vactive
&& CimarronDisplayModes[i].vblankstart ==
current_display->vblankstart
&& CimarronDisplayModes[i].vsyncstart ==
current_display->vsyncstart
&& CimarronDisplayModes[i].vsyncend ==
current_display->vsyncend
&& CimarronDisplayModes[i].vblankend ==
current_display->vblankend
&& CimarronDisplayModes[i].vtotal == current_display->vtotal) {
break;
}
}
if (i == NUM_CIMARRON_DISPLAY_MODES)
return CIM_STATUS_INEXACTMATCH;
current_display->internal_flags |=
(CimarronDisplayModes[i].internal_flags & VG_SUPPORTFLAG_HZMASK);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_scaler_filter_coefficients
*
* This routine sets the vertical and horizontal filter coefficients for
* graphics scaling. If either of the input arrays is specified as NULL, a
* set of default coeffecients will be used.
*--------------------------------------------------------------------------*/
int
vg_set_scaler_filter_coefficients(long h_taps[][5], long v_taps[][3])
{
unsigned long irqfilt, i;
unsigned long temp0, temp1;
unsigned long lock;
/* ENABLE ACCESS TO THE HORIZONTAL COEFFICIENTS */
irqfilt = READ_REG32(DC3_IRQ_FILT_CTL);
irqfilt |= DC3_IRQFILT_H_FILT_SEL;
/* UNLOCK THE COEFFICIENT REGISTERS */
lock = READ_REG32(DC3_UNLOCK);
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
/* WRITE COEFFICIENTS */
/* Coefficient indexes do not auto-increment, so we must */
/* write the address for every phase */
for (i = 0; i < 256; i++) {
WRITE_REG32(DC3_IRQ_FILT_CTL, ((irqfilt & 0xFFFFFF00L) | i));
if (!h_taps) {
temp0 = CimarronHorizontalGraphicsFilter[i][0];
temp1 = CimarronHorizontalGraphicsFilter[i][1];
}
else {
temp0 = ((unsigned long) h_taps[i][0] & 0x3FF) |
(((unsigned long) h_taps[i][1] & 0x3FF) << 10) |
(((unsigned long) h_taps[i][2] & 0x3FF) << 20);
temp1 = ((unsigned long) h_taps[i][3] & 0x3FF) |
(((unsigned long) h_taps[i][4] & 0x3FF) << 10);
}
WRITE_REG32(DC3_FILT_COEFF1, temp0);
WRITE_REG32(DC3_FILT_COEFF2, temp1);
}
/* ENABLE ACCESS TO THE VERTICAL COEFFICIENTS */
irqfilt &= ~DC3_IRQFILT_H_FILT_SEL;
/* WRITE COEFFICIENTS */
for (i = 0; i < 256; i++) {
WRITE_REG32(DC3_IRQ_FILT_CTL, ((irqfilt & 0xFFFFFF00L) | i));
if (!v_taps) {
temp0 = CimarronVerticalGraphicsFilter[i];
}
else {
temp0 = ((unsigned long) v_taps[i][0] & 0x3FF) |
(((unsigned long) v_taps[i][1] & 0x3FF) << 10) |
(((unsigned long) v_taps[i][2] & 0x3FF) << 20);
}
WRITE_REG32(DC3_FILT_COEFF1, temp0);
}
WRITE_REG32(DC3_UNLOCK, lock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_configure_flicker_filter
*
* This routine updates the VG flicker filter settings when in an interlaced
* mode. Note that flicker filtering is enabled inside a mode set. This routine
* is provided to change from the default flicker filter setting of
* 1/4, 1/2, 1/4.
*--------------------------------------------------------------------------*/
int
vg_configure_flicker_filter(unsigned long flicker_strength, int flicker_alpha)
{
unsigned long unlock;
unsigned long genlk_ctl;
/* CHECK FOR VALID FLICKER SETTING */
if (flicker_strength != VG_FLICKER_FILTER_NONE &&
flicker_strength != VG_FLICKER_FILTER_1_16 &&
flicker_strength != VG_FLICKER_FILTER_1_8 &&
flicker_strength != VG_FLICKER_FILTER_1_4 &&
flicker_strength != VG_FLICKER_FILTER_5_16) {
return CIM_STATUS_INVALIDPARAMS;
}
unlock = READ_REG32(DC3_UNLOCK);
genlk_ctl = READ_REG32(DC3_GENLK_CTL) & ~(DC3_GC_FLICKER_FILTER_MASK |
DC3_GC_ALPHA_FLICK_ENABLE);
genlk_ctl |= flicker_strength;
if (flicker_alpha)
genlk_ctl |= DC3_GC_ALPHA_FLICK_ENABLE;
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_GENLK_CTL, genlk_ctl);
WRITE_REG32(DC3_UNLOCK, unlock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_clock_frequency
*
* This routine sets the frequency of the dot clock. The input to this
* routine is a 16.16 fraction. If an exact match is not found, this
* routine will program the closest available frequency and return
* CIM_STATUS_INEXACTMATCH.
*--------------------------------------------------------------------------*/
int
vg_set_clock_frequency(unsigned long frequency, unsigned long pll_flags)
{
Q_WORD msr_value;
unsigned long timeout;
unsigned long index = 0;
unsigned long unlock, i;
unsigned long pll_high, pll_low;
long diff, min = 0;
/* FIND THE REGISTER VALUES FOR THE DESIRED FREQUENCY */
/* Search the table for the closest frequency (16.16 format). */
/* This search is skipped if the user is manually specifying */
/* the MSR value. */
pll_low = 0;
if (!(pll_flags & VG_PLL_MANUAL)) {
min = (long) CimarronPLLFrequencies[0].frequency - (long) frequency;
if (min < 0L)
min = -min;
for (i = 1; i < NUM_CIMARRON_PLL_FREQUENCIES; i++) {
diff = (long) CimarronPLLFrequencies[i].frequency -
(long) frequency;
if (diff < 0L)
diff = -diff;
if (diff < min) {
min = diff;
index = i;
}
}
pll_high = CimarronPLLFrequencies[index].pll_value & 0x00007FFF;
}
else {
pll_high = frequency;
}
if (pll_flags & VG_PLL_DIVIDE_BY_2)
pll_low |= GLCP_DOTPLL_HALFPIX;
if (pll_flags & VG_PLL_DIVIDE_BY_4)
pll_high |= GLCP_DOTPLL_DIV4;
if (pll_flags & VG_PLL_BYPASS)
pll_low |= GLCP_DOTPLL_BYPASS;
if (pll_flags & VG_PLL_VIP_CLOCK)
pll_high |= GLCP_DOTPLL_VIPCLK;
/* VERIFY THAT WE ARE NOT WRITING WHAT IS ALREADY IN THE REGISTERS */
/* The Dot PLL reset bit is tied to VDD for flat panels. This can */
/* cause a brief drop in flat panel power, which can cause serious */
/* glitches on some panels. */
msr_read64(MSR_DEVICE_GEODELX_GLCP, GLCP_DOTPLL, &msr_value);
if ((msr_value.low & GLCP_DOTPLL_LOCK) &&
((msr_value.low & (GLCP_DOTPLL_HALFPIX | GLCP_DOTPLL_BYPASS)) ==
pll_low) && (msr_value.high == pll_high)) {
return CIM_STATUS_OK;
}
/* PROGRAM THE SETTINGS WITH THE RESET BIT SET */
/* Clear the bypass bit to ensure that the programmed */
/* M, N and P values are being used. */
msr_value.high = pll_high;
msr_value.low &= ~(GLCP_DOTPLL_BYPASS | GLCP_DOTPLL_HALFPIX);
msr_value.low |= (pll_low | 0x00000001);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DOTPLL, &msr_value);
/* WAIT FOR THE LOCK BIT */
/* The PLL spec states that the PLL may take up to 100 us to */
/* properly lock. Furthermore, the lock signal is not 100% */
/* reliable. To address this, we add a hefty delay followed */
/* by a polling loop that times out after a 1000 reads. */
unlock = READ_REG32(DC3_UNLOCK);
for (timeout = 0; timeout < 1280; timeout++)
WRITE_REG32(DC3_UNLOCK, unlock);
for (timeout = 0; timeout < 1000; timeout++) {
msr_read64(MSR_DEVICE_GEODELX_GLCP, GLCP_DOTPLL, &msr_value);
if (msr_value.low & GLCP_DOTPLL_LOCK)
break;
}
/* CLEAR THE RESET BIT */
msr_value.low &= 0xFFFFFFFE;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DOTPLL, &msr_value);
/* DID THE PLL SUCCESSFULLY LOCK? */
if (!(msr_value.low & GLCP_DOTPLL_LOCK))
return CIM_STATUS_NOLOCK;
/* RETURN THE APPROPRIATE CODE */
if (min == 0)
return CIM_STATUS_OK;
else
return CIM_STATUS_INEXACTMATCH;
}
/*---------------------------------------------------------------------------
* vg_set_border_color
*
* This routine sets the color used as the border in centered panel modes.
*--------------------------------------------------------------------------*/
int
vg_set_border_color(unsigned long border_color)
{
unsigned long lock = READ_REG32(DC3_UNLOCK);
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_PAL_ADDRESS, 0x104);
WRITE_REG32(DC3_PAL_DATA, border_color);
WRITE_REG32(DC3_UNLOCK, lock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_cursor_enable
*
* This routine enables or disables the hardware cursor. This routine should
* only be called after the hardware cursor has been completely configured.
*--------------------------------------------------------------------------*/
int
vg_set_cursor_enable(int enable)
{
unsigned long unlock, gcfg;
/* SET OR CLEAR CURSOR ENABLE BIT */
unlock = READ_REG32(DC3_UNLOCK);
gcfg = READ_REG32(DC3_GENERAL_CFG);
if (enable)
gcfg |= DC3_GCFG_CURE;
else
gcfg &= ~(DC3_GCFG_CURE);
/* WRITE NEW REGISTER VALUE */
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_GENERAL_CFG, gcfg);
WRITE_REG32(DC3_UNLOCK, unlock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_mono_cursor_colors
*
* This routine sets the colors of the hardware monochrome cursor.
*--------------------------------------------------------------------------*/
int
vg_set_mono_cursor_colors(unsigned long bkcolor, unsigned long fgcolor)
{
unsigned long lock = READ_REG32(DC3_UNLOCK);
/* SET CURSOR COLORS */
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_PAL_ADDRESS, 0x100);
WRITE_REG32(DC3_PAL_DATA, bkcolor);
WRITE_REG32(DC3_PAL_DATA, fgcolor);
WRITE_REG32(DC3_UNLOCK, lock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_cursor_position
*
* This routine sets the position of the hardware cursor. The cursor hotspots
* and memory offset must have been specified in an earlier call to
* a vg_set_cursor_shape_XX routine. The coordinates passed to this routine
* generally specify the focal point of the cursor, NOT the upper left
* coordinate of the cursor pattern. However, for operating systems that do
* not include a hotspot the input parameters may be negative.
*--------------------------------------------------------------------------*/
int
vg_set_cursor_position(long xpos, long ypos, VG_PANNING_COORDINATES * panning)
{
unsigned long unlock, memoffset;
unsigned long gcfg;
long x, xoffset;
long y, yoffset;
memoffset = vg3_cursor_offset;
x = xpos - (long) vg3_x_hotspot;
y = ypos - (long) vg3_y_hotspot;
/* HANDLE NEGATIVE COORDINATES */
/* This routine supports operating systems that use negative */
/* coordinates, instead of positive coordinates with an appropriate */
/* hotspot. */
if (xpos < 0)
xpos = 0;
if (ypos < 0)
ypos = 0;
if (x < -63)
return CIM_STATUS_INVALIDPARAMS;
if (y < -63)
return CIM_STATUS_INVALIDPARAMS;
if (vg3_panel_enable) {
if ((vg3_mode_width > vg3_panel_width)
|| (vg3_mode_height > vg3_panel_height)) {
vg_pan_desktop(xpos, ypos, panning);
x = x - (unsigned short) vg3_delta_x;
y = y - (unsigned short) vg3_delta_y;
}
else {
panning->start_x = 0;
panning->start_y = 0;
panning->start_updated = 0;
}
}
/* ADJUST OFFSETS */
/* Cursor movement and panning work as follows: The cursor position */
/* refers to where the hotspot of the cursor is located. However, for */
/* non-zero hotspots, the cursor buffer actually begins before the */
/* specified position. */
if (x < 0) {
xoffset = -x;
x = 0;
}
else {
xoffset = 0;
}
if (y < 0) {
yoffset = -y;
y = 0;
}
else {
yoffset = 0;
}
if (vg3_color_cursor)
memoffset += (unsigned long) yoffset *192;
else
memoffset += (unsigned long) yoffset << 4;
/* SET COLOR CURSOR BIT */
gcfg = READ_REG32(DC3_GENERAL_CFG);
if (vg3_color_cursor)
gcfg |= DC3_GCFG_CLR_CUR;
else
gcfg &= ~DC3_GCFG_CLR_CUR;
/* SET CURSOR POSITION */
unlock = READ_REG32(DC3_UNLOCK);
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_CURS_ST_OFFSET, memoffset);
WRITE_REG32(DC3_GENERAL_CFG, gcfg);
WRITE_REG32(DC3_CURSOR_X, (unsigned long) x |
(((unsigned long) xoffset) << 11));
WRITE_REG32(DC3_CURSOR_Y, (unsigned long) y |
(((unsigned long) yoffset) << 11));
WRITE_REG32(DC3_UNLOCK, unlock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_mono_cursor_shape32
*
* This routine loads 32x32 cursor data into the cursor buffer in graphics
* memory. The outside of the GeodeLX cursor buffer is padded with
* transparency.
*--------------------------------------------------------------------------*/
int
vg_set_mono_cursor_shape32(unsigned long memoffset, unsigned long *andmask,
unsigned long *xormask, unsigned long x_hotspot,
unsigned long y_hotspot)
{
int i;
/* SAVE THE CURSOR OFFSET AND HOTSPOTS */
/* These are reused later when updating the cursor position, panning */
/* and clipping the cursor pointer. */
vg3_x_hotspot = x_hotspot;
vg3_y_hotspot = y_hotspot;
vg3_cursor_offset = memoffset;
vg3_color_cursor = 0;
for (i = 0; i < 32; i++) {
/* EVEN QWORDS CONTAIN THE AND MASK */
WRITE_FB32(memoffset, 0xFFFFFFFF);
WRITE_FB32(memoffset + 4, andmask[i]);
/* ODD QWORDS CONTAIN THE XOR MASK */
WRITE_FB32(memoffset + 8, 0x00000000);
WRITE_FB32(memoffset + 12, xormask[i]);
memoffset += 16;
}
/* FILL THE LOWER HALF OF THE BUFFER WITH TRANSPARENT PIXELS */
for (i = 0; i < 32; i++) {
WRITE_FB32(memoffset, 0xFFFFFFFF);
WRITE_FB32(memoffset + 4, 0xFFFFFFFF);
WRITE_FB32(memoffset + 8, 0x00000000);
WRITE_FB32(memoffset + 12, 0x00000000);
memoffset += 16;
}
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_mono_cursor_shape64
*
* This routine loads 64x64 cursor data into the cursor buffer in graphics
* memory.
*--------------------------------------------------------------------------*/
int
vg_set_mono_cursor_shape64(unsigned long memoffset, unsigned long *andmask,
unsigned long *xormask, unsigned long x_hotspot,
unsigned long y_hotspot)
{
int i;
/* SAVE THE CURSOR OFFSET AND HOTSPOTS */
/* These are reused later when updating the cursor position, panning */
/* and clipping the cursor pointer. */
vg3_x_hotspot = x_hotspot;
vg3_y_hotspot = y_hotspot;
vg3_cursor_offset = memoffset;
vg3_color_cursor = 0;
for (i = 0; i < 128; i += 2) {
/* EVEN QWORDS CONTAIN THE AND MASK */
/* We invert the dwords to prevent the calling */
/* application from having to think in terms of Qwords. */
/* The hardware data order is actually 63:0, or 31:0 of */
/* the second dword followed by 31:0 of the first dword. */
WRITE_FB32(memoffset, andmask[i + 1]);
WRITE_FB32(memoffset + 4, andmask[i]);
/* ODD QWORDS CONTAIN THE XOR MASK */
WRITE_FB32(memoffset + 8, xormask[i + 1]);
WRITE_FB32(memoffset + 12, xormask[i]);
memoffset += 16;
}
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_color_cursor_shape
*
* This routine loads 8:8:8:8 cursor data into the color cursor buffer.
*--------------------------------------------------------------------------*/
int
vg_set_color_cursor_shape(unsigned long memoffset, unsigned char *data,
unsigned long width, unsigned long height, long pitch,
unsigned long x_hotspot, unsigned long y_hotspot)
{
unsigned long y;
/* SAVE THE CURSOR OFFSET AND HOTSPOTS */
/* These are reused later when updating the cursor position, panning */
/* and clipping the cursor pointer. */
vg3_x_hotspot = x_hotspot;
vg3_y_hotspot = y_hotspot;
vg3_cursor_offset = memoffset;
vg3_color_cursor = 1;
/* WRITE THE CURSOR DATA */
/* The outside edges of the color cursor are filled with transparency */
/* The cursor buffer dimensions are 48x64. */
for (y = 0; y < height; y++) {
/* WRITE THE ACTIVE AND TRANSPARENT DATA */
/* We implement this as a macro in our dedication to squeaking */
/* every ounce of performance out of our code... */
WRITE_FB_STRING32(memoffset, data, width);
WRITE_FB_CONSTANT((memoffset + (width << 2)), 0, (48 - width));
/* INCREMENT PAST THE LINE */
memoffset += 192;
data += pitch;
}
/* WRITE THE EXTRA TRANSPARENT LINES */
/* Write the lines in one big bulk setting. */
WRITE_FB_CONSTANT(memoffset, 0, ((64 - height) * 48));
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_pan_desktop
*
* This routine sets the correct display offset based on the current cursor
* position.
*--------------------------------------------------------------------------*/
int
vg_pan_desktop(unsigned long x, unsigned long y,
VG_PANNING_COORDINATES * panning)
{
unsigned long modeShiftPerPixel;
unsigned long modeBytesPerScanline;
unsigned long startAddress;
/* TEST FOR NO-WORK */
if (x >= vg3_delta_x && x < (vg3_panel_width + vg3_delta_x) &&
y >= vg3_delta_y && y < (vg3_panel_height + vg3_delta_y)) {
panning->start_x = vg3_delta_x;
panning->start_y = vg3_delta_y;
panning->start_updated = 0;
return CIM_STATUS_OK;
}
if (vg3_bpp == 24)
modeShiftPerPixel = 2;
else
modeShiftPerPixel = (vg3_bpp + 7) >> 4;
modeBytesPerScanline = (READ_REG32(DC3_GFX_PITCH) & 0x0000FFFF) << 3;
/* ADJUST PANNING VARIABLES WHEN CURSOR EXCEEDS BOUNDARY */
/* Test the boundary conditions for each coordinate and update */
/* all variables and the starting offset accordingly. */
if (x < vg3_delta_x)
vg3_delta_x = x;
else if (x >= (vg3_delta_x + vg3_panel_width))
vg3_delta_x = x - vg3_panel_width + 1;
if (y < vg3_delta_y)
vg3_delta_y = y;
else if (y >= (vg3_delta_y + vg3_panel_height))
vg3_delta_y = y - vg3_panel_height + 1;
/* CALCULATE THE START OFFSET */
startAddress = (vg3_delta_x << modeShiftPerPixel) +
(vg3_delta_y * modeBytesPerScanline);
vg_set_display_offset(startAddress);
panning->start_updated = 1;
panning->start_x = vg3_delta_x;
panning->start_y = vg3_delta_y;
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_display_offset
*
* This routine sets the start address of the frame buffer. It is
* typically used to pan across a virtual desktop (frame buffer larger than
* the displayed screen) or to flip the display between multiple buffers.
*--------------------------------------------------------------------------*/
int
vg_set_display_offset(unsigned long address)
{
unsigned long lock, gcfg;
lock = READ_REG32(DC3_UNLOCK);
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
/* DISABLE COMPRESSION */
/* When setting a non-zero display offset, we must disable display */
/* compression. We could maintain a variable and re-enable */
/* compression when the offset returns to zero. However, that */
/* creates additional complexity for applications that perform */
/* graphics animation. Re-enabling compression each time would */
/* be tedious and slow for such applications, implying that they */
/* would have to disable compression before starting the animation. */
/* We will instead disable compression and force the user to */
/* re-enable compression when they are ready. */
if (address != 0) {
if (READ_REG32(DC3_GENERAL_CFG) & DC3_GCFG_CMPE) {
gcfg = READ_REG32(DC3_GENERAL_CFG);
WRITE_REG32(DC3_GENERAL_CFG,
(gcfg & ~(DC3_GCFG_CMPE | DC3_GCFG_DECE)));
}
}
WRITE_REG32(DC3_FB_ST_OFFSET, address);
WRITE_REG32(DC3_UNLOCK, lock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_display_pitch
*
* This routine sets the stride between successive lines of data in the frame
* buffer.
*--------------------------------------------------------------------------*/
int
vg_set_display_pitch(unsigned long pitch)
{
unsigned long temp, dvsize, dvtop, value;
unsigned long lock = READ_REG32(DC3_UNLOCK);
value = READ_REG32(DC3_GFX_PITCH) & 0xFFFF0000;
value |= (pitch >> 3);
/* PROGRAM THE DISPLAY PITCH */
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_GFX_PITCH, value);
/* SET THE COMPRESSION BEHAVIOR BASED ON THE PITCH */
/* Strides that are not a power of two will not work with line */
/* by line compression. For these cases, we enable full-screen */
/* compression. In this mode, any write to the frame buffer */
/* region marks the entire frame as dirty. Also, the DV line */
/* size must be updated when the pitch is programmed outside of */
/* the power of 2 range specified in a mode set. */
if (pitch > 4096) {
dvsize = DC3_DV_LINE_SIZE_8192;
}
else if (pitch > 2048) {
dvsize = DC3_DV_LINE_SIZE_4096;
}
else if (pitch > 1024) {
dvsize = DC3_DV_LINE_SIZE_2048;
}
else {
dvsize = DC3_DV_LINE_SIZE_1024;
}
temp = READ_REG32(DC3_DV_CTL);
WRITE_REG32(DC3_DV_CTL,
(temp & ~DC3_DV_LINE_SIZE_MASK) | dvsize | 0x00000001);
value = READ_REG32(DC3_GENERAL_CFG);
if (pitch == 1024 || pitch == 2048 || pitch == 4096 || pitch == 8192) {
value &= ~DC3_GCFG_FDTY;
dvtop = 0;
}
else {
value |= DC3_GCFG_FDTY;
dvtop = (READ_REG32(DC3_FB_ACTIVE) & 0xFFF) + 1;
dvtop = ((dvtop * pitch) + 0x3FF) & 0xFFFFFC00;
dvtop |= DC3_DVTOP_ENABLE;
}
WRITE_REG32(DC3_GENERAL_CFG, value);
WRITE_REG32(DC3_DV_TOP, dvtop);
WRITE_REG32(DC3_UNLOCK, lock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_display_palette_entry
*
* This routine sets a single 8BPP palette entry in the display controller.
*--------------------------------------------------------------------------*/
int
vg_set_display_palette_entry(unsigned long index, unsigned long palette)
{
unsigned long dcfg, unlock;
if (index > 0xFF)
return CIM_STATUS_INVALIDPARAMS;
unlock = READ_REG32(DC3_UNLOCK);
dcfg = READ_REG32(DC3_DISPLAY_CFG);
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_DISPLAY_CFG, dcfg & ~DC3_DCFG_PALB);
WRITE_REG32(DC3_UNLOCK, unlock);
WRITE_REG32(DC3_PAL_ADDRESS, index);
WRITE_REG32(DC3_PAL_DATA, palette);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_set_display_palette
*
* This routine sets the entire palette in the display controller.
* A pointer is provided to a 256 entry table of 32-bit X:R:G:B values.
*--------------------------------------------------------------------------*/
int
vg_set_display_palette(unsigned long *palette)
{
unsigned long unlock, dcfg, i;
WRITE_REG32(DC3_PAL_ADDRESS, 0);
if (palette) {
unlock = READ_REG32(DC3_UNLOCK);
dcfg = READ_REG32(DC3_DISPLAY_CFG);
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_DISPLAY_CFG, dcfg & ~DC3_DCFG_PALB);
WRITE_REG32(DC3_UNLOCK, unlock);
for (i = 0; i < 256; i++)
WRITE_REG32(DC3_PAL_DATA, palette[i]);
return CIM_STATUS_OK;
}
return CIM_STATUS_INVALIDPARAMS;
}
/*---------------------------------------------------------------------------
* vg_set_compression_enable
*
* This routine enables or disables display compression.
*--------------------------------------------------------------------------*/
int
vg_set_compression_enable(int enable)
{
Q_WORD msr_value;
unsigned long unlock, gcfg;
unsigned long temp;
unlock = READ_REG32(DC3_UNLOCK);
gcfg = READ_REG32(DC3_GENERAL_CFG);
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
if (enable) {
/* DO NOT ENABLE IF THE DISPLAY OFFSET IS NOT ZERO */
if (READ_REG32(DC3_FB_ST_OFFSET) & 0x0FFFFFFF)
return CIM_STATUS_ERROR;
/* ENABLE BIT 1 IN THE VG SPARE MSR
* The bus can hang when the VG attempts to merge compression writes.
* No performance is lost due to the GeodeLink QUACK features in
* GeodeLX. We also enable the command word check for a valid
* compression header.
*/
msr_read64(MSR_DEVICE_GEODELX_VG, DC3_SPARE_MSR, &msr_value);
msr_value.low |= DC3_SPARE_FIRST_REQ_MASK;
msr_value.low &= ~DC3_SPARE_DISABLE_CWD_CHECK;
msr_write64(MSR_DEVICE_GEODELX_VG, DC3_SPARE_MSR, &msr_value);
/* CLEAR DIRTY/VALID BITS IN MEMORY CONTROLLER
* We don't want the controller to think that old lines are still
* valid. Writing a 1 to bit 0 of the DV Control register will force
* the hardware to clear all the valid bits.
*/
temp = READ_REG32(DC3_DV_CTL);
WRITE_REG32(DC3_DV_CTL, temp | 0x00000001);
/* ENABLE COMPRESSION BITS */
gcfg |= DC3_GCFG_CMPE | DC3_GCFG_DECE;
}
else {
gcfg &= ~(DC3_GCFG_CMPE | DC3_GCFG_DECE);
}
WRITE_REG32(DC3_GENERAL_CFG, gcfg);
WRITE_REG32(DC3_UNLOCK, unlock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_configure_compression
*
* This routine configures all aspects of display compression, including
* pitch, size and the offset of the compression buffer.
*--------------------------------------------------------------------------*/
int
vg_configure_compression(VG_COMPRESSION_DATA * comp_data)
{
unsigned long delta, size;
unsigned long comp_size, unlock;
/* CHECK FOR VALID PARAMETERS */
/* The maximum size for the compression buffer is 544 bytes (with */
/* the header) Also, the pitch cannot be less than the line size */
/* and the compression buffer offset must be 16-byte aligned. */
if (comp_data->size > 544 || comp_data->pitch < comp_data->size ||
comp_data->compression_offset & 0x0F) {
return CIM_STATUS_INVALIDPARAMS;
}
/* SUBTRACT 32 FROM SIZE */
/* The display controller will actually write 4 extra QWords. So, */
/* if we assume that "size" refers to the allocated size, we must */
/* subtract 32 bytes. */
comp_size = comp_data->size - 32;
/* CALCULATE REGISTER VALUES */
unlock = READ_REG32(DC3_UNLOCK);
size = READ_REG32(DC3_LINE_SIZE) & ~DC3_LINE_SIZE_CBLS_MASK;
delta = READ_REG32(DC3_GFX_PITCH) & ~DC3_GFX_PITCH_CBP_MASK;
size |= ((comp_size >> 3) + 1) << DC3_LINE_SIZE_CB_SHIFT;
delta |= ((comp_data->pitch >> 3) << 16);
/* WRITE COMPRESSION PARAMETERS */
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_CB_ST_OFFSET, comp_data->compression_offset);
WRITE_REG32(DC3_LINE_SIZE, size);
WRITE_REG32(DC3_GFX_PITCH, delta);
WRITE_REG32(DC3_UNLOCK, unlock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_test_timing_active
*
* This routine checks the status of the display timing generator.
*--------------------------------------------------------------------------*/
int
vg_test_timing_active(void)
{
if (READ_REG32(DC3_DISPLAY_CFG) & DC3_DCFG_TGEN)
return 1;
return 0;
}
/*---------------------------------------------------------------------------
* vg_test_vertical_active
*
* This routine checks if the display is currently in the middle of a frame
* (not in the VBlank interval)
*--------------------------------------------------------------------------*/
int
vg_test_vertical_active(void)
{
if (READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_VNA)
return 0;
return 1;
}
/*---------------------------------------------------------------------------
* vg_wait_vertical_blank
*
* This routine waits until the beginning of the vertical blank interval.
* When the display is already in vertical blank, this routine will wait until
* the beginning of the next vertical blank.
*--------------------------------------------------------------------------*/
int
vg_wait_vertical_blank(void)
{
if (vg_test_timing_active()) {
while (!vg_test_vertical_active());
while (vg_test_vertical_active());
}
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_test_even_field
*
* This routine tests the odd/even status of the current VG output field.
*--------------------------------------------------------------------------*/
int
vg_test_even_field(void)
{
if (READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_EVEN_FIELD)
return 1;
return 0;
}
/*---------------------------------------------------------------------------
* vg_configure_line_interrupt
*
* This routine configures the display controller's line count interrupt.
* This interrupt can be used to interrupt mid-frame or to interrupt at the
* beginning of vertical blank.
*--------------------------------------------------------------------------*/
int
vg_configure_line_interrupt(VG_INTERRUPT_PARAMS * interrupt_info)
{
unsigned long irq_line, irq_enable;
unsigned long lock;
irq_line = READ_REG32(DC3_IRQ_FILT_CTL);
irq_enable = READ_REG32(DC3_IRQ);
lock = READ_REG32(DC3_UNLOCK);
irq_line = (irq_line & ~DC3_IRQFILT_LINE_MASK) |
((interrupt_info->line << 16) & DC3_IRQFILT_LINE_MASK);
/* ENABLE OR DISABLE THE INTERRUPT */
/* The line count is set before enabling and after disabling to */
/* minimize spurious interrupts. The line count is set even */
/* when interrupts are disabled to allow polling-based or debug */
/* applications. */
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
if (interrupt_info->enable) {
WRITE_REG32(DC3_IRQ_FILT_CTL, irq_line);
WRITE_REG32(DC3_IRQ, ((irq_enable & ~DC3_IRQ_MASK) | DC3_IRQ_STATUS));
}
else {
WRITE_REG32(DC3_IRQ, (irq_enable | DC3_IRQ_MASK));
WRITE_REG32(DC3_IRQ_FILT_CTL, irq_line);
}
WRITE_REG32(DC3_UNLOCK, lock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_test_and_clear_interrupt
*
* This routine resets any pending interrupt in the video generator. The
* return value indicates the interrupt status prior to the reset.
*--------------------------------------------------------------------------*/
unsigned long
vg_test_and_clear_interrupt(void)
{
unsigned long irq_enable;
unsigned long lock;
irq_enable = READ_REG32(DC3_IRQ);
lock = READ_REG32(DC3_UNLOCK);
/* NO ACTION IF INTERRUPTS ARE MASKED */
/* We are assuming that a driver or application will not want to receive */
/* the status of the interrupt when it is masked. */
if ((irq_enable & (DC3_IRQ_MASK | DC3_VSYNC_IRQ_MASK)) ==
(DC3_IRQ_MASK | DC3_VSYNC_IRQ_MASK))
return 0;
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_IRQ, irq_enable);
WRITE_REG32(DC3_UNLOCK, lock);
return (irq_enable & (DC3_IRQ_STATUS | DC3_VSYNC_IRQ_STATUS));
}
/*---------------------------------------------------------------------------
* vg_test_flip_status
*
* This routine tests if a new display offset has been latched.
*--------------------------------------------------------------------------*/
unsigned long
vg_test_flip_status(void)
{
return (READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_FLIP);
}
/*---------------------------------------------------------------------------
* vg_save_state
*
* This routine saves all persistent VG state information.
*--------------------------------------------------------------------------*/
int
vg_save_state(VG_SAVE_RESTORE * vg_state)
{
Q_WORD msr_value;
unsigned long irqfilt;
unsigned long offset, i;
unsigned long lock;
/* READ ALL CURRENT REGISTER SETTINGS */
vg_state->unlock = READ_REG32(DC3_UNLOCK);
vg_state->gcfg = READ_REG32(DC3_GENERAL_CFG);
vg_state->dcfg = READ_REG32(DC3_DISPLAY_CFG);
vg_state->arb_cfg = READ_REG32(DC3_ARB_CFG);
vg_state->fb_offset = READ_REG32(DC3_FB_ST_OFFSET);
vg_state->cb_offset = READ_REG32(DC3_CB_ST_OFFSET);
vg_state->cursor_offset = READ_REG32(DC3_CURS_ST_OFFSET);
vg_state->video_y_offset = READ_REG32(DC3_VID_Y_ST_OFFSET);
vg_state->video_u_offset = READ_REG32(DC3_VID_U_ST_OFFSET);
vg_state->video_v_offset = READ_REG32(DC3_VID_V_ST_OFFSET);
vg_state->dv_top = READ_REG32(DC3_DV_TOP);
vg_state->line_size = READ_REG32(DC3_LINE_SIZE);
vg_state->gfx_pitch = READ_REG32(DC3_GFX_PITCH);
vg_state->video_yuv_pitch = READ_REG32(DC3_VID_YUV_PITCH);
vg_state->h_active = READ_REG32(DC3_H_ACTIVE_TIMING);
vg_state->h_blank = READ_REG32(DC3_H_BLANK_TIMING);
vg_state->h_sync = READ_REG32(DC3_H_SYNC_TIMING);
vg_state->v_active = READ_REG32(DC3_V_ACTIVE_TIMING);
vg_state->v_blank = READ_REG32(DC3_V_BLANK_TIMING);
vg_state->v_sync = READ_REG32(DC3_V_SYNC_TIMING);
vg_state->fb_active = READ_REG32(DC3_FB_ACTIVE);
vg_state->cursor_x = READ_REG32(DC3_CURSOR_X);
vg_state->cursor_y = READ_REG32(DC3_CURSOR_Y);
vg_state->vid_ds_delta = READ_REG32(DC3_VID_DS_DELTA);
vg_state->fb_base = READ_REG32(DC3_PHY_MEM_OFFSET);
vg_state->dv_ctl = READ_REG32(DC3_DV_CTL);
vg_state->gfx_scale = READ_REG32(DC3_GFX_SCALE);
vg_state->irq_ctl = READ_REG32(DC3_IRQ_FILT_CTL);
vg_state->vbi_even_ctl = READ_REG32(DC3_VBI_EVEN_CTL);
vg_state->vbi_odd_ctl = READ_REG32(DC3_VBI_ODD_CTL);
vg_state->vbi_hor_ctl = READ_REG32(DC3_VBI_HOR);
vg_state->vbi_odd_line_enable = READ_REG32(DC3_VBI_LN_ODD);
vg_state->vbi_even_line_enable = READ_REG32(DC3_VBI_LN_EVEN);
vg_state->vbi_pitch = READ_REG32(DC3_VBI_PITCH);
vg_state->color_key = READ_REG32(DC3_COLOR_KEY);
vg_state->color_key_mask = READ_REG32(DC3_COLOR_MASK);
vg_state->color_key_x = READ_REG32(DC3_CLR_KEY_X);
vg_state->color_key_y = READ_REG32(DC3_CLR_KEY_Y);
vg_state->irq = READ_REG32(DC3_IRQ);
vg_state->genlk_ctl = READ_REG32(DC3_GENLK_CTL);
vg_state->vid_y_even_offset = READ_REG32(DC3_VID_EVEN_Y_ST_OFFSET);
vg_state->vid_u_even_offset = READ_REG32(DC3_VID_EVEN_U_ST_OFFSET);
vg_state->vid_v_even_offset = READ_REG32(DC3_VID_EVEN_V_ST_OFFSET);
vg_state->vactive_even = READ_REG32(DC3_V_ACTIVE_EVEN);
vg_state->vblank_even = READ_REG32(DC3_V_BLANK_EVEN);
vg_state->vsync_even = READ_REG32(DC3_V_SYNC_EVEN);
/* READ THE CURRENT PALETTE */
lock = READ_REG32(DC3_UNLOCK);
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_PAL_ADDRESS, 0);
for (i = 0; i < 261; i++)
vg_state->palette[i] = READ_REG32(DC3_PAL_DATA);
/* READ THE CURRENT FILTER COEFFICIENTS */
/* ENABLE ACCESS TO THE HORIZONTAL COEFFICIENTS */
irqfilt = READ_REG32(DC3_IRQ_FILT_CTL);
irqfilt |= DC3_IRQFILT_H_FILT_SEL;
/* READ HORIZONTAL COEFFICIENTS */
for (i = 0; i < 256; i++) {
WRITE_REG32(DC3_IRQ_FILT_CTL, ((irqfilt & 0xFFFFFF00L) | i));
vg_state->h_coeff[(i << 1)] = READ_REG32(DC3_FILT_COEFF1);
vg_state->h_coeff[(i << 1) + 1] = READ_REG32(DC3_FILT_COEFF2);
}
/* ENABLE ACCESS TO THE VERTICAL COEFFICIENTS */
irqfilt &= ~DC3_IRQFILT_H_FILT_SEL;
/* READ COEFFICIENTS */
for (i = 0; i < 256; i++) {
WRITE_REG32(DC3_IRQ_FILT_CTL, ((irqfilt & 0xFFFFFF00L) | i));
vg_state->v_coeff[i] = READ_REG32(DC3_FILT_COEFF1);
}
/* READ THE CURSOR DATA */
offset = READ_REG32(DC3_CURS_ST_OFFSET) & 0x0FFFFFFF;
for (i = 0; i < 3072; i++)
vg_state->cursor_data[i] = READ_FB32(offset + (i << 2));
/* READ THE CURRENT PLL */
msr_read64(MSR_DEVICE_GEODELX_GLCP, GLCP_DOTPLL, &msr_value);
vg_state->pll_flags = 0;
for (i = 0; i < NUM_CIMARRON_PLL_FREQUENCIES; i++) {
if (CimarronPLLFrequencies[i].pll_value == (msr_value.high & 0x7FFF)) {
vg_state->dot_pll = CimarronPLLFrequencies[i].frequency;
break;
}
}
if (i == NUM_CIMARRON_PLL_FREQUENCIES) {
/* NO MATCH */
/* Enter the frequency as a manual frequency. */
vg_state->dot_pll = msr_value.high;
vg_state->pll_flags |= VG_PLL_MANUAL;
}
if (msr_value.low & GLCP_DOTPLL_HALFPIX)
vg_state->pll_flags |= VG_PLL_DIVIDE_BY_2;
if (msr_value.low & GLCP_DOTPLL_BYPASS)
vg_state->pll_flags |= VG_PLL_BYPASS;
if (msr_value.high & GLCP_DOTPLL_DIV4)
vg_state->pll_flags |= VG_PLL_DIVIDE_BY_4;
if (msr_value.high & GLCP_DOTPLL_VIPCLK)
vg_state->pll_flags |= VG_PLL_VIP_CLOCK;
/* READ ALL VG MSRS */
msr_read64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_CAP, &(vg_state->msr_cap));
msr_read64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_CONFIG,
&(vg_state->msr_config));
msr_read64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_SMI, &(vg_state->msr_smi));
msr_read64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_ERROR,
&(vg_state->msr_error));
msr_read64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_PM, &(vg_state->msr_pm));
msr_read64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_DIAG,
&(vg_state->msr_diag));
msr_read64(MSR_DEVICE_GEODELX_VG, DC3_SPARE_MSR, &(vg_state->msr_spare));
msr_read64(MSR_DEVICE_GEODELX_VG, DC3_RAM_CTL, &(vg_state->msr_ram_ctl));
WRITE_REG32(DC3_UNLOCK, lock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_restore_state
*
* This routine restores all persistent VG state information.
*--------------------------------------------------------------------------*/
int
vg_restore_state(VG_SAVE_RESTORE * vg_state)
{
unsigned long irqfilt, j;
unsigned long memoffset;
/* TEMPORARILY UNLOCK ALL REGISTERS */
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
/* RESTORE THE FRAME BUFFER OFFSET */
WRITE_REG32(DC3_PHY_MEM_OFFSET, vg_state->fb_base);
/* BLANK GCFG AND DCFG */
WRITE_REG32(DC3_GENERAL_CFG, 0);
WRITE_REG32(DC3_DISPLAY_CFG, 0);
/* RESTORE ALL REGISTERS */
WRITE_REG32(DC3_ARB_CFG, vg_state->arb_cfg);
WRITE_REG32(DC3_FB_ST_OFFSET, vg_state->fb_offset);
WRITE_REG32(DC3_CB_ST_OFFSET, vg_state->cb_offset);
WRITE_REG32(DC3_CURS_ST_OFFSET, vg_state->cursor_offset);
WRITE_REG32(DC3_VID_Y_ST_OFFSET, vg_state->video_y_offset);
WRITE_REG32(DC3_VID_U_ST_OFFSET, vg_state->video_u_offset);
WRITE_REG32(DC3_VID_V_ST_OFFSET, vg_state->video_v_offset);
WRITE_REG32(DC3_DV_TOP, vg_state->dv_top);
WRITE_REG32(DC3_LINE_SIZE, vg_state->line_size);
WRITE_REG32(DC3_GFX_PITCH, vg_state->gfx_pitch);
WRITE_REG32(DC3_VID_YUV_PITCH, vg_state->video_yuv_pitch);
WRITE_REG32(DC3_H_ACTIVE_TIMING, vg_state->h_active);
WRITE_REG32(DC3_H_BLANK_TIMING, vg_state->h_blank);
WRITE_REG32(DC3_H_SYNC_TIMING, vg_state->h_sync);
WRITE_REG32(DC3_V_ACTIVE_TIMING, vg_state->v_active);
WRITE_REG32(DC3_V_BLANK_TIMING, vg_state->v_blank);
WRITE_REG32(DC3_V_SYNC_TIMING, vg_state->v_sync);
WRITE_REG32(DC3_FB_ACTIVE, vg_state->fb_active);
WRITE_REG32(DC3_CURSOR_X, vg_state->cursor_x);
WRITE_REG32(DC3_CURSOR_Y, vg_state->cursor_y);
WRITE_REG32(DC3_VID_DS_DELTA, vg_state->vid_ds_delta);
WRITE_REG32(DC3_PHY_MEM_OFFSET, vg_state->fb_base);
WRITE_REG32(DC3_DV_CTL, vg_state->dv_ctl | 0x00000001);
WRITE_REG32(DC3_GFX_SCALE, vg_state->gfx_scale);
WRITE_REG32(DC3_IRQ_FILT_CTL, vg_state->irq_ctl);
WRITE_REG32(DC3_VBI_EVEN_CTL, vg_state->vbi_even_ctl);
WRITE_REG32(DC3_VBI_ODD_CTL, vg_state->vbi_odd_ctl);
WRITE_REG32(DC3_VBI_HOR, vg_state->vbi_hor_ctl);
WRITE_REG32(DC3_VBI_LN_ODD, vg_state->vbi_odd_line_enable);
WRITE_REG32(DC3_VBI_LN_EVEN, vg_state->vbi_even_line_enable);
WRITE_REG32(DC3_VBI_PITCH, vg_state->vbi_pitch);
WRITE_REG32(DC3_COLOR_KEY, vg_state->color_key);
WRITE_REG32(DC3_COLOR_MASK, vg_state->color_key_mask);
WRITE_REG32(DC3_CLR_KEY_X, vg_state->color_key_x);
WRITE_REG32(DC3_CLR_KEY_Y, vg_state->color_key_y);
WRITE_REG32(DC3_IRQ, vg_state->irq);
WRITE_REG32(DC3_GENLK_CTL, vg_state->genlk_ctl);
WRITE_REG32(DC3_VID_EVEN_Y_ST_OFFSET, vg_state->vid_y_even_offset);
WRITE_REG32(DC3_VID_EVEN_U_ST_OFFSET, vg_state->vid_u_even_offset);
WRITE_REG32(DC3_VID_EVEN_V_ST_OFFSET, vg_state->vid_v_even_offset);
WRITE_REG32(DC3_V_ACTIVE_EVEN, vg_state->vactive_even);
WRITE_REG32(DC3_V_BLANK_EVEN, vg_state->vblank_even);
WRITE_REG32(DC3_V_SYNC_EVEN, vg_state->vsync_even);
/* RESTORE THE PALETTE */
WRITE_REG32(DC3_PAL_ADDRESS, 0);
for (j = 0; j < 261; j++)
WRITE_REG32(DC3_PAL_DATA, vg_state->palette[j]);
/* RESTORE THE HORIZONTAL FILTER COEFFICIENTS */
irqfilt = READ_REG32(DC3_IRQ_FILT_CTL);
irqfilt |= DC3_IRQFILT_H_FILT_SEL;
for (j = 0; j < 256; j++) {
WRITE_REG32(DC3_IRQ_FILT_CTL, ((irqfilt & 0xFFFFFF00L) | j));
WRITE_REG32(DC3_FILT_COEFF1, vg_state->h_coeff[(j << 1)]);
WRITE_REG32(DC3_FILT_COEFF2, vg_state->h_coeff[(j << 1) + 1]);
}
/* RESTORE VERTICAL COEFFICIENTS */
irqfilt &= ~DC3_IRQFILT_H_FILT_SEL;
for (j = 0; j < 256; j++) {
WRITE_REG32(DC3_IRQ_FILT_CTL, ((irqfilt & 0xFFFFFF00L) | j));
WRITE_REG32(DC3_FILT_COEFF1, vg_state->v_coeff[j]);
}
/* RESTORE THE CURSOR DATA */
memoffset = READ_REG32(DC3_CURS_ST_OFFSET) & 0x0FFFFFFF;
WRITE_FB_STRING32(memoffset, (unsigned char *) &(vg_state->cursor_data[0]),
3072);
/* RESTORE THE PLL */
/* Use a common routine to use common code to poll for lock bit */
vg_set_clock_frequency(vg_state->dot_pll, vg_state->pll_flags);
/* RESTORE ALL VG MSRS */
msr_write64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_CAP, &(vg_state->msr_cap));
msr_write64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_CONFIG,
&(vg_state->msr_config));
msr_write64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_SMI, &(vg_state->msr_smi));
msr_write64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_ERROR,
&(vg_state->msr_error));
msr_write64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_PM, &(vg_state->msr_pm));
msr_write64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_DIAG,
&(vg_state->msr_diag));
msr_write64(MSR_DEVICE_GEODELX_VG, DC3_SPARE_MSR, &(vg_state->msr_spare));
msr_write64(MSR_DEVICE_GEODELX_VG, DC3_RAM_CTL, &(vg_state->msr_ram_ctl));
/* NOW RESTORE GCFG AND DCFG */
WRITE_REG32(DC3_DISPLAY_CFG, vg_state->dcfg);
WRITE_REG32(DC3_GENERAL_CFG, vg_state->gcfg);
/* FINALLY RESTORE UNLOCK */
WRITE_REG32(DC3_UNLOCK, vg_state->unlock);
return CIM_STATUS_OK;
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* CIMARRON VG READ ROUTINES
* These routines are included for use in diagnostics or when debugging. They
* can be optionally excluded from a project.
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#if CIMARRON_INCLUDE_VG_READ_ROUTINES
/*---------------------------------------------------------------------------
* vg_read_graphics_crc
*
* This routine reads the Cyclic Redundancy Check (CRC) value for the graphics
* frame.
*--------------------------------------------------------------------------*/
unsigned long
vg_read_graphics_crc(int crc_source)
{
unsigned long gcfg, unlock;
unsigned long crc, vbi_even;
unsigned long interlaced;
unsigned long line, field;
if (!(READ_REG32(DC3_DISPLAY_CFG) & DC3_DCFG_TGEN))
return 0xFFFFFFFF;
unlock = READ_REG32(DC3_UNLOCK);
gcfg = READ_REG32(DC3_GENERAL_CFG);
vbi_even = READ_REG32(DC3_VBI_EVEN_CTL);
vbi_even &= ~DC3_VBI_EVEN_ENABLE_CRC;
gcfg |= DC3_GCFG_SGRE | DC3_GCFG_CRC_MODE;
gcfg &= ~(DC3_GCFG_SGFR | DC3_GCFG_SIG_SEL | DC3_GCFG_FILT_SIG_SEL);
switch (crc_source) {
case VG_CRC_SOURCE_PREFILTER_EVEN:
case VG_CRC_SOURCE_PREFILTER:
gcfg |= DC3_GCFG_SIG_SEL;
break;
case VG_CRC_SOURCE_PREFLICKER:
case VG_CRC_SOURCE_PREFLICKER_EVEN:
gcfg |= DC3_GCFG_FILT_SIG_SEL;
break;
case VG_CRC_SOURCE_POSTFLICKER:
case VG_CRC_SOURCE_POSTFLICKER_EVEN: /* NO WORK */
break;
default:
return 0xFFFFFFFF;
}
if (crc_source & VG_CRC_SOURCE_EVEN)
field = 0;
else
field = DC3_LNCNT_EVEN_FIELD;
if ((interlaced = (READ_REG32(DC3_IRQ_FILT_CTL) & DC3_IRQFILT_INTL_EN))) {
/* WAIT FOR THE BEGINNING OF THE FIELD (LINE 1-5) */
/* Note that we wait for the field to be odd when CRCing the even */
/* field and vice versa. This is because the CRC will not begin */
/* until the following field. */
do {
line = READ_REG32(DC3_LINE_CNT_STATUS);
} while ((line & DC3_LNCNT_EVEN_FIELD) != field ||
((line & DC3_LNCNT_V_LINE_CNT) >> 16) < 10 ||
((line & DC3_LNCNT_V_LINE_CNT) >> 16) > 15);
}
else {
/* NON-INTERLACED - EVEN FIELD CRCS ARE INVALID */
if (crc_source & VG_CRC_SOURCE_EVEN)
return 0xFFFFFFFF;
}
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_VBI_EVEN_CTL, vbi_even);
WRITE_REG32(DC3_GENERAL_CFG, gcfg & ~DC3_GCFG_SIGE);
WRITE_REG32(DC3_GENERAL_CFG, gcfg | DC3_GCFG_SIGE);
/* WAIT FOR THE CRC TO BE COMPLETED */
while (!(READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_SIGC));
/* READ THE COMPLETED CRC */
crc = READ_REG32(DC3_PAL_DATA);
/* RESTORE THE PALETTE SETTINGS */
gcfg &= ~DC3_GCFG_SGRE;
WRITE_REG32(DC3_GENERAL_CFG, gcfg);
WRITE_REG32(DC3_UNLOCK, unlock);
return crc;
}
/*---------------------------------------------------------------------------
* vg_read_window_crc
*
* This routine reads the Cyclic Redundancy Check (CRC) value for a sub-
* section of the frame.
*--------------------------------------------------------------------------*/
unsigned long
vg_read_window_crc(int crc_source, unsigned long x, unsigned long y,
unsigned long width, unsigned long height)
{
Q_WORD msr_value;
unsigned long crc = 0;
unsigned long hactive, hblankstart;
unsigned long htotal, hblankend;
unsigned long line, field;
unsigned long diag;
hactive = ((READ_REG32(DC3_H_ACTIVE_TIMING)) & 0xFFF) + 1;
hblankstart = ((READ_REG32(DC3_H_BLANK_TIMING)) & 0xFFF) + 1;
htotal = ((READ_REG32(DC3_H_ACTIVE_TIMING) >> 16) & 0xFFF) + 1;
hblankend = ((READ_REG32(DC3_H_BLANK_TIMING) >> 16) & 0xFFF) + 1;
/* TIMINGS MUST BE ACTIVE */
if (!(READ_REG32(DC3_DISPLAY_CFG) & DC3_DCFG_TGEN))
return 0xFFFFFFFF;
/* DISABLE GLCP ACTIONS */
msr_value.low = 0;
msr_value.high = 0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DIAGCTL, &msr_value);
if ((x == 0 && width == 1) || x == 1) {
/* SPECIAL CASE FOR X == 0 */
/* The comparator output is a clock late in the MCP, so we cannot */
/* easily catch the first pixel. If the first pixel is desired, */
/* we will insert a special state machine to CRC just the first */
/* pixel. */
/* N2 - DISPE HIGH AND Y == 1 */
/* Goto state YState = 2 */
msr_value.high = 0x00000002;
msr_value.low = 0x00000C00;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETN0CTL + 2, &msr_value);
/* M3 - DISPE HIGH AND Y == 0 */
/* Goto YState = 1 */
msr_value.high = 0x00000002;
msr_value.low = 0x00000A00;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETM0CTL + 3, &msr_value);
/* N3 - DISPE LOW */
/* Goto YState = 0 */
msr_value.high = 0x00080000;
msr_value.low = 0x00000000;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETN0CTL + 3, &msr_value);
/* Y0 -> Y1 (SET M3) */
msr_value.high = 0x00000000;
msr_value.low = 0x0000C000;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 18, &msr_value);
/* Y1 -> Y0 (SET N3) */
msr_value.low = 0x0000A000;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 17, &msr_value);
/* Y1 -> Y2 (SET N2) */
msr_value.low = 0x00000A00;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 19, &msr_value);
/* N5 (XSTATE = 10 && CMP2 <= V. COUNTER <= CMP3) &&DISPE&& Y == 0 */
/* CRC into REGB */
msr_value.high = 0x00000002;
msr_value.low = 0x10800B20;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETN0CTL + 5, &msr_value);
/* N6 (XSTATE = 10 && CMP2 <= V. COUNTER <= CMP3) && DISPE&&Y == 1 */
/* CRC into REGB */
msr_value.high = 0x00000002;
msr_value.low = 0x10800D20;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETN0CTL + 6, &msr_value);
}
/* M4 (XSTATE = 00 AND VSYNC HIGH) */
/* Goto state 01 */
/* Note: VSync = H3A */
msr_value.high = 0x00000001;
msr_value.low = 0x000000A0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETM0CTL + 4, &msr_value);
/* N0 (XSTATE = 01 AND VSYNC LOW) */
/* Goto state 02 */
/* Note: VSync low = H3B */
msr_value.high = 0x00040000;
msr_value.low = 0x000000C0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETN0CTL, &msr_value);
/* M5 (XSTATE = 10 AND VSYNC HIGH) */
/* Goto state 11 */
msr_value.high = 0x00000001;
msr_value.low = 0x00000120;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETM0CTL + 5, &msr_value);
/* N1 (XSTATE = 10 and DISPE HIGH) */
/* Increment H. Counter */
/* Note: DispE = H4 */
msr_value.high = 0x00000002;
msr_value.low = 0x00000120;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETN0CTL + 1, &msr_value);
/* M0 (XSTATE = 10 and H. COUNTER == LIMIT) */
/* Clear H. Counter and increment V. Counter */
msr_value.high = 0x00000000;
msr_value.low = 0x00000122;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETM0CTL, &msr_value);
/* N4 (XSTATE = 10 && CMP0 <= H. COUNTER <= CMP1 && CMP2 <= V. COUNTER
* <= CMP3) && DISPE
* CRC into REGB
*/
msr_value.high = 0x00000002;
msr_value.low = 0x10C20120;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_SETN0CTL + 4, &msr_value);
/* COMPARATOR 0 VALUE */
/* We subtract 1 to account for a pipeline delay in the GLCP. */
/* When the x coordinate is 0, we must play a special game. */
/* If the width is exactly 1, we will set up a state machine */
/* to only CRC the first pixel. Otherwise, we will set it */
/* as an OR combination of a state that CRCs the first pixel */
/* and a state that CRCs 1 clock delayed width (width - 1) */
msr_value.high = 0;
if (x > 1)
msr_value.low = (x - 1) & 0xFFFF;
else
msr_value.low = x;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_CMPVAL0, &msr_value);
/* COMPARATOR 1 VALUE */
if ((x == 0 || x == 1) && width > 1)
msr_value.low += width - 2;
else
msr_value.low += width - 1;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_CMPVAL0 + 2, &msr_value);
/* COMPARATOR 2 VALUE */
msr_value.low = y << 16;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_CMPVAL0 + 4, &msr_value);
/* COMPARATOR 3 VALUE */
msr_value.low += (height - 1) << 16;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_CMPVAL0 + 6, &msr_value);
/* COMPARATOR MASKS */
/* Comparators 0 and 1 refer to lower 16 bits of RegB */
msr_value.low = 0x0000FFFF;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_CMPMASK0, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_CMPMASK0 + 2, &msr_value);
/* Comparators 2 and 3 refer to upper 16 bits of RegB */
msr_value.low = 0xFFFF0000;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_CMPMASK0 + 4, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_CMPMASK0 + 6, &msr_value);
/* SET REGB MASK */
/* We set the mask such that all all 32 bits of data are CRCed */
msr_value.low = 0xFFFFFFFF;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_REGBMASK, &msr_value);
/* ACTIONS */
/* STATE 00->01 (SET 4M) */
msr_value.low = 0x000C0000;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 14, &msr_value);
/* STATE 01->10 (SET 0N) */
msr_value.low = 0x0000000A;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 15, &msr_value);
/* STATE 10->11 (SET 5M) */
msr_value.low = 0x00C00000;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 16, &msr_value);
/* CLEAR REGA WHEN TRANSITIONING TO STATE 10 */
/* Do not clear RegB as the initial value must be 0x00000001 */
msr_value.low = 0x0000000A;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0, &msr_value);
/* REGISTER ACTION 1
* CRC into RegB if cmp0 <= h.counter <= cmp1 && cmp2 <= v. counter <
* cmp3 && 7 xstate = 10
* Increment h.counter if xstate = 10 and HSync is low.
*/
msr_value.low = 0x000A00A0;
if (x == 0 && width == 1)
msr_value.low = 0x00A000A0;
else if (x == 1 && width == 1)
msr_value.low = 0x0A0000A0;
else if (x == 1 && width > 1)
msr_value.low |= 0x0A000000;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 1, &msr_value);
/* REGISTER ACTION 2 */
/* Increment V. Counter in REGA */
msr_value.low = 0x0000000C;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 2, &msr_value);
/* SET REGB TO 0x00000001 */
msr_value.low = 0x00000001;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_REGB, &msr_value);
/* SET XSTATE TO 0 */
msr_value.low = 0x00000000;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_XSTATE, &msr_value);
/* SET YSTATE TO 0 */
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_YSTATE, &msr_value);
/* CLEAR ALL OTHER ACTIONS */
/* This prevents side-effects from previous accesses to the GLCP */
/* debug logic. */
msr_value.low = 0x00000000;
msr_value.high = 0x00000000;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 3, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 4, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 5, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 6, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 7, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 8, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 9, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 10, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 11, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 12, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 13, &msr_value);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_ACTION0 + 20, &msr_value);
/* SET DIAG SETTINGS BASED ON DESIRED CRC */
if (crc_source == VG_CRC_SOURCE_POSTFLICKER
|| crc_source == VG_CRC_SOURCE_POSTFLICKER_EVEN) {
diag = 0x80808086;
/* ENABLE HW CLOCK GATING AND SET GLCP CLOCK TO DOT CLOCK */
msr_value.high = 0;
msr_value.low = 5;
msr_write64(MSR_DEVICE_GEODELX_GLCP, MSR_GEODELINK_PM, &msr_value);
msr_value.low = 0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DBGCLKCTL, &msr_value);
msr_value.low = 3;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DBGCLKCTL, &msr_value);
/* SET REGA LIMITS */
/* Lower counter uses pixels/line */
/* Upper counter is 0xFFFF to prevent rollover. */
msr_value.low = 0xFFFF0000 | (hactive - 1);
if (READ_REG32(DC3_DISPLAY_CFG) & DC3_DCFG_DCEN) {
msr_value.low += hblankstart - hactive;
msr_value.low += htotal - hblankend;
}
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_REGAVAL, &msr_value);
/* USE H4 FUNCTION A FOR DISPE AND H4 FUNCTION B FOR NOT DISPE */
/* DISPE is bit 34 */
msr_value.high = 0x00000002;
msr_value.low = 0x20000FF0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_H0CTL + 4, &msr_value);
/* USE H3 FUNCTION A FOR VSYNC AND H3 FUNCTION B FOR NOT VSYNC */
/* VSYNC is bit 32. */
msr_value.high = 0x00000000;
msr_value.low = 0x002055AA;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_H0CTL + 3, &msr_value);
}
else if (crc_source == VG_CRC_SOURCE_PREFLICKER
|| crc_source == VG_CRC_SOURCE_PREFLICKER_EVEN) {
diag = 0x801F8032;
/* ENABLE HW CLOCK GATING AND SET GLCP CLOCK TO GEODELINK CLOCK */
msr_value.high = 0;
msr_value.low = 5;
msr_write64(MSR_DEVICE_GEODELX_GLCP, MSR_GEODELINK_PM, &msr_value);
msr_value.low = 0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DBGCLKCTL, &msr_value);
msr_value.low = 2;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DBGCLKCTL, &msr_value);
/* SET REGA LIMITS */
/* Lower counter uses pixels/line */
/* Upper counter is 0xFFFF to prevent rollover. */
msr_value.low = 0xFFFF0000 | (hactive - 1);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_REGAVAL, &msr_value);
/* USE H4 FUNCTION A FOR DISPE AND H4 FUNCTION B FOR NOT DISPE */
/* DISPE is bit 47 */
msr_value.high = 0x00000002;
msr_value.low = 0xF0000FF0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_H0CTL + 4, &msr_value);
/* USE H3 FUNCTION A FOR VSYNC AND H3 FUNCTION B FOR NOT VSYNC */
/* VSYNC is bit 45. */
msr_value.high = 0x00000000;
msr_value.low = 0x002D55AA;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_H0CTL + 3, &msr_value);
}
else {
/* PREFILTER CRC */
diag = 0x80138048;
msr_write64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_DIAG, &msr_value);
/* ENABLE HW CLOCK GATING AND SET GLCP CLOCK TO GEODELINK CLOCK */
msr_value.high = 0;
msr_value.low = 5;
msr_write64(MSR_DEVICE_GEODELX_GLCP, MSR_GEODELINK_PM, &msr_value);
msr_value.low = 0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DBGCLKCTL, &msr_value);
msr_value.low = 2;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DBGCLKCTL, &msr_value);
/* SET REGA LIMITS */
/* Lower counter uses pixels/line */
/* Upper counter is 0xFFFF to prevent rollover. */
/* Note that we are assuming that the number of */
/* source pixels is specified in the FB_ACTIVE register */
msr_value.low =
0xFFFF0000 | ((READ_REG32(DC3_FB_ACTIVE) >> 16) & 0xFFF);
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_REGAVAL, &msr_value);
/* USE H4 FUNCTION A FOR DISPE AND H4 FUNCTION B FOR NOT DISPE */
/* DISPE is bit 55 */
msr_value.high = 0x00000003;
msr_value.low = 0x70000FF0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_H0CTL + 4, &msr_value);
/* USE H3 FUNCTION A FOR VSYNC AND H3 FUNCTION B FOR NOT VSYNC */
/* VSYNC is bit 53. */
msr_value.high = 0x00000000;
msr_value.low = 0x003555AA;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_H0CTL + 3, &msr_value);
}
/* WAIT FOR THE CORRECT FIELD */
/* We use the VG line count and field indicator to determine when */
/* to kick off a CRC. */
if (crc_source & VG_CRC_SOURCE_EVEN)
field = 0;
else
field = DC3_LNCNT_EVEN_FIELD;
if (READ_REG32(DC3_IRQ_FILT_CTL) & DC3_IRQFILT_INTL_EN) {
/* WAIT FOR THE BEGINNING OF THE FIELD (LINE 1-5) */
/* Note that we wait for the field to be odd when CRCing the even */
/* field and vice versa. This is because the CRC will not begin */
/* until the following field. */
do {
line = READ_REG32(DC3_LINE_CNT_STATUS);
} while ((line & DC3_LNCNT_EVEN_FIELD) != field ||
((line & DC3_LNCNT_V_LINE_CNT) >> 16) < 1 ||
((line & DC3_LNCNT_V_LINE_CNT) >> 16) > 5);
}
else {
/* NON-INTERLACED - EVEN FIELD CRCS ARE INVALID */
if (crc_source & VG_CRC_SOURCE_EVEN)
return 0xFFFFFFFF;
}
/* UPDATE VG DIAG OUTPUT */
msr_value.high = 0;
msr_value.low = diag;
msr_write64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_DIAG, &msr_value);
/* CONFIGURE DIAG CONTROL */
/* Set RegA action1 to increment lower 16 bits and clear at limit. (5) */
/* Set RegA action2 to increment upper 16 bits. (6) */
/* Set RegB action1 to CRC32 (1) */
/* Set all comparators to REGA override (0,1 lower mbus, 2,3 upper mbus) */
/* Enable all actions */
msr_value.low = 0x80EA20A0;
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DIAGCTL, &msr_value);
/* DELAY TWO FRAMES */
while (READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_VNA);
while (!(READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_VNA));
while (READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_VNA);
while (!(READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_VNA));
while (READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_VNA);
/* VERIFY THAT XSTATE = 11 */
msr_read64(MSR_DEVICE_GEODELX_GLCP, GLCP_XSTATE, &msr_value);
if ((msr_value.low & 3) == 3) {
msr_read64(MSR_DEVICE_GEODELX_GLCP, GLCP_REGB, &msr_value);
crc = msr_value.low;
}
/* DISABLE VG DIAG BUS OUTPUTS */
msr_value.low = 0x00000000;
msr_value.high = 0x00000000;
msr_write64(MSR_DEVICE_GEODELX_VG, MSR_GEODELINK_DIAG, &msr_value);
/* DISABLE GLCP ACTIONS */
msr_write64(MSR_DEVICE_GEODELX_GLCP, GLCP_DIAGCTL, &msr_value);
return crc;
}
/*---------------------------------------------------------------------------
* vg_get_scaler_filter_coefficients
*
* This routine gets the vertical and horizontal filter coefficients for
* graphics scaling. The coefficients are sign extended to 32-bit values.
*--------------------------------------------------------------------------*/
int
vg_get_scaler_filter_coefficients(long h_taps[][5], long v_taps[][3])
{
unsigned long irqfilt, i;
unsigned long temp;
long coeff0, coeff1, coeff2;
unsigned long lock;
/* ENABLE ACCESS TO THE HORIZONTAL COEFFICIENTS */
lock = READ_REG32(DC3_UNLOCK);
irqfilt = READ_REG32(DC3_IRQ_FILT_CTL);
irqfilt |= DC3_IRQFILT_H_FILT_SEL;
/* WRITE COEFFICIENTS */
/* Coefficient indexes do not auto-increment, so we must */
/* write the address for every phase */
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
for (i = 0; i < 256; i++) {
WRITE_REG32(DC3_IRQ_FILT_CTL, ((irqfilt & 0xFFFFFF00L) | i));
temp = READ_REG32(DC3_FILT_COEFF1);
coeff0 = (temp & 0x3FF);
coeff1 = (temp >> 10) & 0x3FF;
coeff2 = (temp >> 20) & 0x3FF;
h_taps[i][0] = (coeff0 << 22) >> 22;
h_taps[i][1] = (coeff1 << 22) >> 22;
h_taps[i][2] = (coeff2 << 22) >> 22;
temp = READ_REG32(DC3_FILT_COEFF2);
coeff0 = (temp & 0x3FF);
coeff1 = (temp >> 10) & 0x3FF;
h_taps[i][3] = (coeff0 << 22) >> 22;
h_taps[i][4] = (coeff1 << 22) >> 22;
}
/* ENABLE ACCESS TO THE VERTICAL COEFFICIENTS */
irqfilt &= ~DC3_IRQFILT_H_FILT_SEL;
/* WRITE COEFFICIENTS */
for (i = 0; i < 256; i++) {
WRITE_REG32(DC3_IRQ_FILT_CTL, ((irqfilt & 0xFFFFFF00L) | i));
temp = READ_REG32(DC3_FILT_COEFF1);
coeff0 = (temp & 0x3FF);
coeff1 = (temp >> 10) & 0x3FF;
coeff2 = (temp >> 20) & 0x3FF;
v_taps[i][0] = (coeff0 << 22) >> 22;
v_taps[i][1] = (coeff1 << 22) >> 22;
v_taps[i][2] = (coeff2 << 22) >> 22;
}
WRITE_REG32(DC3_UNLOCK, lock);
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_get_flicker_filter_configuration
*
* This routine returns the current VG flicker filter configuration.
*--------------------------------------------------------------------------*/
int
vg_get_flicker_filter_configuration(unsigned long *strength, int *flicker_alpha)
{
unsigned long genlk_ctl;
if (!strength || !flicker_alpha)
return CIM_STATUS_INVALIDPARAMS;
genlk_ctl = READ_REG32(DC3_GENLK_CTL);
*strength = genlk_ctl & DC3_GC_FLICKER_FILTER_MASK;
if (genlk_ctl & DC3_GC_ALPHA_FLICK_ENABLE)
*flicker_alpha = 1;
else
*flicker_alpha = 0;
return CIM_STATUS_OK;
}
/*---------------------------------------------------------------------------
* vg_get_display_pitch
*
* This routine returns the current stride between successive lines of frame
* buffer data.
*--------------------------------------------------------------------------*/
unsigned long
vg_get_display_pitch(void)
{
return ((READ_REG32(DC3_GFX_PITCH) & 0x0000FFFF) << 3);
}
/*---------------------------------------------------------------------------
* vg_get_frame_buffer_line_size
*
* This routine returns the current size in bytes of one line of frame buffer
* data.
*--------------------------------------------------------------------------*/
unsigned long
vg_get_frame_buffer_line_size(void)
{
return ((READ_REG32(DC3_LINE_SIZE) & 0x3FF) << 3);
}
/*---------------------------------------------------------------------------
* vg_get_current_vline
*
* This routine returns the number of the current line that is being displayed
* by the display controller.
*--------------------------------------------------------------------------*/
unsigned long
vg_get_current_vline(void)
{
unsigned long current_line;
/* READ THE REGISTER TWICE TO ENSURE THAT THE VALUE IS NOT TRANSITIONING */
do {
current_line = READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_V_LINE_CNT;
}
while (current_line !=
(READ_REG32(DC3_LINE_CNT_STATUS) & DC3_LNCNT_V_LINE_CNT));
return (current_line >> 16);
}
/*---------------------------------------------------------------------------
* vg_get_display_offset
*
* This routine returns the offset into the frame buffer for the first pixel
* of the display.
*--------------------------------------------------------------------------*/
unsigned long
vg_get_display_offset(void)
{
return (READ_REG32(DC3_FB_ST_OFFSET) & 0x0FFFFFFF);
}
/*---------------------------------------------------------------------------
* vg_get_cursor_info
*
* This routine returns the current settings for the hardware cursor.
*--------------------------------------------------------------------------*/
int
vg_get_cursor_info(VG_CURSOR_DATA * cursor_data)
{
unsigned long temp;
/* CURSOR OFFSET */
cursor_data->cursor_offset = READ_REG32(DC3_CURS_ST_OFFSET) & 0x0FFFFFFF;
/* CURSOR X POSITION */
temp = READ_REG32(DC3_CURSOR_X);
cursor_data->cursor_x = temp & 0x7FF;
cursor_data->clipx = (temp >> 11) & 0x3F;
/* CURSOR Y POSITION */
temp = READ_REG32(DC3_CURSOR_Y);
cursor_data->cursor_y = temp & 0x7FF;
cursor_data->clipy = (temp >> 11) & 0x3F;
/* CURSOR COLORS */
WRITE_REG32(DC3_PAL_ADDRESS, 0x100);
cursor_data->mono_color0 = READ_REG32(DC3_PAL_DATA);
cursor_data->mono_color1 = READ_REG32(DC3_PAL_DATA);
/* CURSOR ENABLES */
temp = READ_REG32(DC3_GENERAL_CFG);
if (temp & DC3_GCFG_CURE)
cursor_data->enable = 1;
else
cursor_data->enable = 0;
if (temp & DC3_GCFG_CLR_CUR)
cursor_data->color_cursor = 1;
else
cursor_data->color_cursor = 0;
return CIM_STATUS_OK;
}
/*----------------------------------------------------------------------------
* vg_get_display_palette_entry
*
* This routine reads a single entry in the 8BPP display palette.
*--------------------------------------------------------------------------*/
int
vg_get_display_palette_entry(unsigned long index, unsigned long *entry)
{
if (index > 0xFF)
return CIM_STATUS_INVALIDPARAMS;
WRITE_REG32(DC3_PAL_ADDRESS, index);
*entry = READ_REG32(DC3_PAL_DATA);
return CIM_STATUS_OK;
}
/*----------------------------------------------------------------------------
* vg_get_border_color
*
* This routine reads the current border color for centered displays.
*--------------------------------------------------------------------------*/
unsigned long
vg_get_border_color(void)
{
WRITE_REG32(DC3_PAL_ADDRESS, 0x104);
return READ_REG32(DC3_PAL_DATA);
}
/*----------------------------------------------------------------------------
* vg_get_display_palette
*
* This routines reads the entire contents of the display palette into a
* buffer. The display palette consists of 256 X:R:G:B values.
*--------------------------------------------------------------------------*/
int
vg_get_display_palette(unsigned long *palette)
{
unsigned long i;
if (palette) {
WRITE_REG32(DC3_PAL_ADDRESS, 0);
for (i = 0; i < 256; i++) {
palette[i] = READ_REG32(DC3_PAL_DATA);
}
return CIM_STATUS_OK;
}
return CIM_STATUS_INVALIDPARAMS;
}
/*----------------------------------------------------------------------------
* vg_get_compression_info
*
* This routines reads the current status of the display compression hardware.
*--------------------------------------------------------------------------*/
int
vg_get_compression_info(VG_COMPRESSION_DATA * comp_data)
{
comp_data->compression_offset = READ_REG32(DC3_CB_ST_OFFSET) & 0x0FFFFFFF;
comp_data->pitch = (READ_REG32(DC3_GFX_PITCH) >> 13) & 0x7FFF8;
comp_data->size = ((READ_REG32(DC3_LINE_SIZE) >> (DC3_LINE_SIZE_CB_SHIFT -
3)) & 0x3F8) + 24;
return CIM_STATUS_OK;
}
/*----------------------------------------------------------------------------
* vg_get_compression_enable
*
* This routines reads the current enable status of the display compression
* hardware.
*--------------------------------------------------------------------------*/
int
vg_get_compression_enable(void)
{
if (READ_REG32(DC3_GENERAL_CFG) & DC3_GCFG_CMPE)
return 1;
return 0;
}
/*----------------------------------------------------------------------------
* vg_get_valid_bit
*--------------------------------------------------------------------------*/
int
vg_get_valid_bit(int line)
{
unsigned long offset;
unsigned long valid;
unsigned long lock;
lock = READ_REG32(DC3_UNLOCK);
offset = READ_REG32(DC3_PHY_MEM_OFFSET) & 0xFF000000;
offset |= line;
WRITE_REG32(DC3_UNLOCK, DC3_UNLOCK_VALUE);
WRITE_REG32(DC3_PHY_MEM_OFFSET, offset);
WRITE_REG32(DC3_UNLOCK, lock);
valid = READ_REG32(DC3_DV_ACC) & 2;
if (valid)
return 1;
return 0;
}
#endif
|