summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2012-01-30intel: Fix bufmgr_gem->gen for gen > 4Chad Versace
If the pci_device's actual gen was > 4, then we stupidly set bufmgr_gem->gen = 6. Luckily this caused no bugs, and this fix shouldn't change any behavior, because all checks against the gen currently have one of the forms below: gen == 2 gen == 3 gen >= 4 Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com> Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2012-01-27intel: Add minimal decode for remaining gen7 packets in use.Eric Anholt
This just gets packet name and length in place, with the remainder unfinished. I've long since finished the work that got me started fixing up the decode.
2012-01-27intel: Add decode for gen7 constant buffer packets.Eric Anholt
2012-01-27intel: Add decode for gen7 state pointers.Eric Anholt
Since CC_STATE_POINTERS for gen6 and 7 are quite different but use the same opcode, move gen6 out to a helper function too, so we can use a helper function for gen7.
2012-01-27intel: Add support for parsing gen7 URB packets.Eric Anholt
2012-01-27intel: Make most of the logic for 965 3d packet length checks table-driven.Eric Anholt
This puts the error message in a consistent location relative to the packet, and while I'm here I made the error message a bit more informative. Now, most static length packets need to just declare their length in the table and not worry.
2012-01-27intel: Move the logic for getting 965 3d packet length to the packet table.Eric Anholt
While I'm touching every line of the table, sort it by opcode.
2012-01-27intel: Add support for parsing 965 3d packets using helper functions.Eric Anholt
I want to add packets, without contributing to the switch statement of doom.
2012-01-27intel: Parse the correct length for gen7 3DSTATE_MULTISAMPLE.Eric Anholt
2012-01-27intel: Put the "gen" shorthand chipset identifier in the context.Eric Anholt
It's a lot nicer than using IS_WHATEVER(devid) all over the place, and we have this in our other projects too.
2012-01-27intel: Avoid the need for most overflow checks by using a scratch page.Eric Anholt
The overflow checks were all thoroughly untested, and a bunch of the ones I'm deleting were pretty broken. Now, in the case of overflow, you just decode data of 0xd0d0d0d0, and instr_out prints the warning message instead. Note that this still has the same issue of being under-tested, but at least it's one place instead of per-packet. A couple of BUFFER_FAIL uses are left where the length to be decoded could be (significantly) larger than a page, and the decode didn't just call instr_out (which doesn't dereference data itself unless it's safe).
2012-01-27intel: Make instr_out take the decode context.Eric Anholt
This reduces some of the extra derefs of the pointers.
2012-01-27intel: Use the context to simplify BR01 decode.Eric Anholt
Similar to BR00, count was always 1 and was always an index, not a count.
2012-01-27intel: Use the context to simplify BR00 decode.Eric Anholt
The count (actually index) was always 0, because BR00 is dword 0.
2012-01-27intel: Plumb the context through the decode callchain.Eric Anholt
We still deref the context at the start of every call, but that will change next.
2012-01-27intel: Drop the code for counting parsing failures.Eric Anholt
Nothing was consuming it. If something wants this in the future, would be done using the decode context anyway.
2012-01-27intel: Track the current packet location in the decode context.Eric Anholt
This is the start of plumbing the context through the decode callchain instead of the current 4 arguments.
2012-01-27intel: Add a regression test for 2D decode, which I'm about to refactor.Eric Anholt
2012-01-09intel: add sprite ioctl defines and struct for i915 sprite codeJesse Barnes
2012-01-06configure: Bump version for 2.4.30Eric Anholt
2012-01-04intel: Update for new i915_drm.h defines.Eric Anholt
2012-01-04intel: Add regression tests for batch decode.Eric Anholt
The .batch was generated using the dump-a-batch branch of git://people.freedesktop.org/~anholt/mesa using glxgears on gen7 hardware, using INTEL_DEVID_OVERRIDE for non-gen7 (this means that offsets in the buffers for non-gen7 are 0!). The .ref was generated by: ./test_decode tests/gen7-3d.batch -dump. The .sh exists because you can't supply arguments to tests using the simple automake tests driver. Something reasonable could be done using automake's parallel-tests driver (in fact, a previous version of the patch did that), but I was concerned that: 1) The parallel-tests driver is documented to be unstable -- they may change interfaces on us later. 2) The parallel-tests driver hides the output of tests in .log files scattered all over the tree, which was ugly and more painful to work with. v2: Actually add the batch files, add a .gitignore for the *-new.txt files added after failures, and fix failure mode for undetected chipset name. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v1)
2012-01-04intel: Add a regression test program for intel_decode.c.Eric Anholt
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2012-01-04intel: Add an interface for setting the output file for decode.Eric Anholt
Consumers often want to choose stdout vs stderr, and for testing I want to output to an open_memstream file. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2011-12-30intel/intel_decode.c: Remove #include "intel_decode.h".Johannes Obermayr
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2011-12-29intel: Disable unused decode_logic_op().Eric Anholt
It was producing an unused code warning. I'm tempted to just remove it, since it's unused, but I *might* use it soon. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Turn on normal warnings for intel_decode.c build.Eric Anholt
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Remove c99ish variable declarations.Eric Anholt
I'd rather be able to use c99 variable declarations (there's a lot of awful code layout due to being c90ish), but I'll leave that for later. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Fix printf format warnings for intel_decode.Eric Anholt
There was plenty of dropped useful data, and some horribly mis-formatted data. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Add printflike warnings for instr_out.Eric Anholt
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Fix a ton of signed vs unsigned and const char *warningsEric Anholt
We've got a different (better) set of warning flags in place in this tree. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Fix Wsigned-compare warnings (soon to be enabled).Eric Anholt
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Get intel_decode.c minimally building.Eric Anholt
My plan is to use this drm_intel_dump_batchbuffer() interface for the current GPU tools, and the current Mesa batch dumping usage, while eventually building more interesting interfaces for other uses. Warnings are currently suppressed by using a helper lib with CFLAGS set manually, because the code is totally not ready for libdrm's warnings setup. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Minor style tweaks after Lindent.Eric Anholt
Some comments weren't wrapped, and for some reason uint32_t *data got an extra space (while other instances of "type *identifier" didn't), and the indentation of the opcode-list structs got trashed. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Reformat intel_decode.c from intel-gpu-tools using Lindent.Eric Anholt
We generally go for kernel style in this tree, and this 4-space indent stuff was bothering me. The new results have some ugly bits, but they're in places where we desperately want to be using helper functions anyway. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: intel: Add IS_GEN[567] macros.Eric Anholt
These will be used by intel_decode.c, and were taken from intel-gpu-tools. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Make intel_chipset handle devid directly.Eric Anholt
This will make these macros reusable from intel_decode.c, which doesn't have a bufmgr_gem context, without faking the struct. We should generally only be using these macros from bufmgr_gem context setup anyway. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-29intel: Import intel_decode.c from intel-gpu-tools.Eric Anholt
This is from commit dd9a5b4f7fb07c78db4e7481bedca1b981030e3f. We've been sharing this file between that repo and Mesa, and it's time to build a real interface using it. I'm also hoping to apply some of its packet-walking logic for AUB dumping and batch validation purposes. Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Eugeni Dodonov <eugeni@dodonov.net>
2011-12-18tests/gem_flink: Check for MASTER before proceedingChris Wilson
gem_flink|gem_open are DRM_AUTH ioctl, and being lazy we do not establish ourselves as authenticated before testing the ioctls. So instead of aborting, skip the test unless we have root privileges (and so DRM_MASTER and the DRM_AUTH restriction no longer applies). A future test could assert that the flink fails without proper authentication. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=43924 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-14intel: Reset vma list upon purgeChris Wilson
During free we unconditionally delete the bo from the vma cache. This relies on the its list member being kept in a sane state. This fails after the object is purged, as the purge operation performs a pure deletion and doesn't reset the list member, leaving a pair of dangling pointers. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-13libdrm: update drm headers from kernel, including new overlay ioctls & structsJesse Barnes
Add structs and functions necessary for the new plane and fb handling code, including a new header, drm_fourcc.h, that includes the surface formats supported by various DRM drivers. Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-12-13configure: Bump version for 2.4.29Chris Wilson
Yet another release required for new API
2011-12-13intel: Remove the fresh assertions used to debug the vma cacheingChris Wilson
Hopefully all the bugs in the callers have been found, so time to handle the failures "gracefully" again. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-13intel: Update map-count for an early error return during mappingChris Wilson
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-06intel: Evict cached VMA in order to make room for new mappingsChris Wilson
As the max number of VMA mappings is a hard per-process limit, we need to include the number of currently active mappings when evicting in order to make room for a new mmap. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-05intel: Add an interface to limit vma cachingChris Wilson
There is a per-process limit on the number of vma that the process can keep open, so we cannot keep an unlimited cache of unused vma's (besides keeping track of all those vma in the kernel adds considerable overhead). However, in order to work around inefficiencies in the kernel it is beneficial to reuse the vma, so keep a MRU cache of vma. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-05test/radeon: add missing files for distDave Airlie
2011-12-05intel: Clean up mmaps on freeing the bufferChris Wilson
As a precautionary measure munmap on buffer free so that we never leak the vma. Also include a warning during debugging. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-05configure: Bump version to 2.4.28Chris Wilson
So that we can pull a couple of Intel bug fixes into xf86-video-intel. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-05intel: Unmap buffers during drm_intel_gem_bo_unmapChris Wilson
We cannot afford to cache the vma per open bo as this may exhaust the per-process limits. References: https://bugs.freedesktop.org/show_bug.cgi?id=43075 References: https://bugs.freedesktop.org/show_bug.cgi?id=40066 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
ref='#n836'>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
/*
 * Copyright (C) 2007 Ben Skeggs.
 * All Rights Reserved.
 *
 * 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 (including the
 * next paragraph) 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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.
 *
 */

#include "drmP.h"
#include "drm.h"
#include "nouveau_drv.h"

#define IS_G80 ((dev_priv->chipset & 0xf0) == 0x50)

static void
nv50_graph_init_reset(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
	uint32_t pmc_e = NV_PMC_ENABLE_PGRAPH | (1 << 21);

	DRM_DEBUG("\n");

	NV_WRITE(NV03_PMC_ENABLE, NV_READ(NV03_PMC_ENABLE) & ~pmc_e);
	NV_WRITE(NV03_PMC_ENABLE, NV_READ(NV03_PMC_ENABLE) |  pmc_e);
}

static void
nv50_graph_init_intr(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;

	DRM_DEBUG("\n");
	NV_WRITE(NV03_PGRAPH_INTR, 0xffffffff);
	NV_WRITE(0x400138, 0xffffffff);
	NV_WRITE(NV40_PGRAPH_INTR_EN, 0xffffffff);
}

static void
nv50_graph_init_regs__nv(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;

	DRM_DEBUG("\n");

	NV_WRITE(0x400804, 0xc0000000);
	NV_WRITE(0x406800, 0xc0000000);
	NV_WRITE(0x400c04, 0xc0000000);
	NV_WRITE(0x401804, 0xc0000000);
	NV_WRITE(0x405018, 0xc0000000);
	NV_WRITE(0x402000, 0xc0000000);

	NV_WRITE(0x400108, 0xffffffff);

	NV_WRITE(0x400824, 0x00004000);
	NV_WRITE(0x400500, 0x00010001);
}

static void
nv50_graph_init_regs(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;

	DRM_DEBUG("\n");

	NV_WRITE(NV04_PGRAPH_DEBUG_3, (1<<2) /* HW_CONTEXT_SWITCH_ENABLED */);
}

static uint32_t nv84_ctx_voodoo[] = {
	0x0070008e, 0x0070009c, 0x00200020, 0x00600008, 0x0050004c, 0x00400e89,
	0x00200000, 0x00600007, 0x00300000, 0x00c000ff, 0x00200000, 0x008000ff,
	0x00700009, 0x0041634d, 0x00402944, 0x00402905, 0x0040290d, 0x00413e06,
	0x00600005, 0x004015c5, 0x00600011, 0x0040270b, 0x004021c5, 0x00700000,
	0x00700081, 0x00600004, 0x0050004a, 0x00216f40, 0x00600007, 0x00c02801,
	0x0020002e, 0x00800001, 0x005000cb, 0x0090ffff, 0x0091ffff, 0x00200020,
	0x00600008, 0x0050004c, 0x00600009, 0x00413e45, 0x0041594d, 0x0070009d,
	0x00402dcf, 0x0070009f, 0x0050009f, 0x00402ac0, 0x00200200, 0x00600008,
	0x00402a4f, 0x00402ac0, 0x004030cc, 0x00700081, 0x00200000, 0x00600006,
	0x00700000, 0x00111bfc, 0x00700083, 0x00300000, 0x00216f40, 0x00600007,
	0x00c00b01, 0x0020001e, 0x00800001, 0x005000cb, 0x00c000ff, 0x00700080,
	0x00700083, 0x00200047, 0x00600006, 0x0011020a, 0x00200480, 0x00600007,
	0x00300000, 0x00c000ff, 0x00c800ff, 0x00414907, 0x00202916, 0x008000ff,
	0x0040508c, 0x005000cb, 0x00a0023f, 0x00200040, 0x00600006, 0x0070000f,
	0x00170202, 0x0011020a, 0x00200032, 0x0010020d, 0x001c0242, 0x00120302,
	0x00140402, 0x00180500, 0x00130509, 0x00150550, 0x00110605, 0x0020000f,
	0x00100607, 0x00110700, 0x00110900, 0x00120902, 0x00110a00, 0x00160b02,
	0x00120b28, 0x00140b2b, 0x00110c01, 0x00111400, 0x00111405, 0x00111407,
	0x00111409, 0x0011140b, 0x002000cb, 0x00101500, 0x0040790f, 0x0040794b,
	0x00214d40, 0x00600007, 0x0020043e, 0x008800ff, 0x0070008f, 0x0040798c,
	0x005000cb, 0x00000000, 0x0020002b, 0x00101a05, 0x00131c00, 0x00121c04,
	0x00141c20, 0x00111c25, 0x00131c40, 0x00121c44, 0x00141c60, 0x00111c65,
	0x00131c80, 0x00121c84, 0x00141ca0, 0x00111ca5, 0x00131cc0, 0x00121cc4,
	0x00141ce0, 0x00111ce5, 0x00131f00, 0x00191f40, 0x0040a1e0, 0x002001ed,
	0x00600006, 0x00200044, 0x00102080, 0x001120c6, 0x001520c9, 0x001920d0,
	0x00122100, 0x00122103, 0x00162200, 0x00122207, 0x00112280, 0x00112300,
	0x00112302, 0x00122380, 0x0011238b, 0x00112394, 0x0011239c, 0x0040bee1,
	0x00200254, 0x00600006, 0x00200044, 0x00102480, 0x0040af0f, 0x0040af4b,
	0x00214d40, 0x00600007, 0x0020043e, 0x008800ff, 0x0070008f, 0x0040af8c,
	0x005000cb, 0x00000000, 0x001124c6, 0x001524c9, 0x001924d0, 0x00122500,
	0x00122503, 0x00162600, 0x00122607, 0x00112680, 0x00112700, 0x00112702,
	0x00122780, 0x0011278b, 0x00112794, 0x0011279c, 0x0040d1e2, 0x002002bb,
	0x00600006, 0x00200044, 0x00102880, 0x001128c6, 0x001528c9, 0x001928d0,
	0x00122900, 0x00122903, 0x00162a00, 0x00122a07, 0x00112a80, 0x00112b00,
	0x00112b02, 0x00122b80, 0x00112b8b, 0x00112b94, 0x00112b9c, 0x0040eee3,
	0x00200322, 0x00600006, 0x00200044, 0x00102c80, 0x0040df0f, 0x0040df4b,
	0x00214d40, 0x00600007, 0x0020043e, 0x008800ff, 0x0070008f, 0x0040df8c,
	0x005000cb, 0x00000000, 0x00112cc6, 0x00152cc9, 0x00192cd0, 0x00122d00,
	0x00122d03, 0x00162e00, 0x00122e07, 0x00112e80, 0x00112f00, 0x00112f02,
	0x00122f80, 0x00112f8b, 0x00112f94, 0x00112f9c, 0x004101e4, 0x00200389,
	0x00600006, 0x00200044, 0x00103080, 0x001130c6, 0x001530c9, 0x001930d0,
	0x00123100, 0x00123103, 0x00163200, 0x00123207, 0x00113280, 0x00113300,
	0x00113302, 0x00123380, 0x0011338b, 0x00113394, 0x0011339c, 0x00411ee5,
	0x002003f0, 0x00600006, 0x00200044, 0x00103480, 0x00410f0f, 0x00410f4b,
	0x00214d40, 0x00600007, 0x0020043e, 0x008800ff, 0x0070008f, 0x00410f8c,
	0x005000cb, 0x00000000, 0x001134c6, 0x001534c9, 0x001934d0, 0x00123500,
	0x00123503, 0x00163600, 0x00123607, 0x00113680, 0x00113700, 0x00113702,
	0x00123780, 0x0011378b, 0x00113794, 0x0011379c, 0x00000000, 0x0041250f,
	0x005000cb, 0x00214d40, 0x00600007, 0x0020043e, 0x008800ff, 0x005000cb,
	0x00412887, 0x0060000a, 0x00000000, 0x00413700, 0x007000a0, 0x00700080,
	0x00200480, 0x00600007, 0x00200004, 0x00c000ff, 0x008000ff, 0x005000cb,
	0x00700000, 0x00200000, 0x00600006, 0x00111bfe, 0x0041594d, 0x00700000,
	0x00200000, 0x00600006, 0x00111bfe, 0x00700080, 0x0070001d, 0x0040114d,
	0x00700081, 0x00600004, 0x0050004a, 0x00414388, 0x0060000b, 0x00200000,
	0x00600006, 0x00700000, 0x0041590b, 0x00111bfd, 0x0040424d, 0x00202916,
	0x008000fd, 0x005000cb, 0x00c00002, 0x00200480, 0x00600007, 0x00200160,
	0x00800002, 0x005000cb, 0x00c01802, 0x002027b6, 0x00800002, 0x005000cb,
	0x00404e4d, 0x0060000b, 0x0041574d, 0x00700001, 0x005000cf, 0x00700003,
	0x00415e06, 0x00415f05, 0x0060000d, 0x00700005, 0x0070000d, 0x00700006,
	0x0070000b, 0x0070000e, 0x0070001c, 0x0060000c, ~0
};
 
static uint32_t nv86_ctx_voodoo[] = {
	0x0070008e, 0x0070009c, 0x00200020, 0x00600008, 0x0050004c, 0x00400e89,
	0x00200000, 0x00600007, 0x00300000, 0x00c000ff, 0x00200000, 0x008000ff,
	0x00700009, 0x0040dd4d, 0x00402944, 0x00402905, 0x0040290d, 0x0040b906,
	0x00600005, 0x004015c5, 0x00600011, 0x0040270b, 0x004021c5, 0x00700000,
	0x00700081, 0x00600004, 0x0050004a, 0x00216d80, 0x00600007, 0x00c02801,
	0x0020002e, 0x00800001, 0x005000cb, 0x0090ffff, 0x0091ffff, 0x00200020,
	0x00600008, 0x0050004c, 0x00600009, 0x0040b945, 0x0040d44d, 0x0070009d,
	0x00402dcf, 0x0070009f, 0x0050009f, 0x00402ac0, 0x00200200, 0x00600008,
	0x00402a4f, 0x00402ac0, 0x004030cc, 0x00700081, 0x00200000, 0x00600006,
	0x00700000, 0x00111bfc, 0x00700083, 0x00300000, 0x00216d80, 0x00600007,
	0x00c00b01, 0x0020001e, 0x00800001, 0x005000cb, 0x00c000ff, 0x00700080,
	0x00700083, 0x00200047, 0x00600006, 0x0011020a, 0x00200280, 0x00600007,
	0x00300000, 0x00c000ff, 0x00c800ff, 0x0040c407, 0x00202916, 0x008000ff,
	0x0040508c, 0x005000cb, 0x00a0023f, 0x00200040, 0x00600006, 0x0070000f,
	0x00170202, 0x0011020a, 0x00200032, 0x0010020d, 0x001c0242, 0x00120302,
	0x00140402, 0x00180500, 0x00130509, 0x00150550, 0x00110605, 0x0020000f,
	0x00100607, 0x00110700, 0x00110900, 0x00120902, 0x00110a00, 0x00160b02,
	0x00120b28, 0x00140b2b, 0x00110c01, 0x00111400, 0x00111405, 0x00111407,
	0x00111409, 0x0011140b, 0x002000cb, 0x00101500, 0x0040790f, 0x0040794b,
	0x00214b40, 0x00600007, 0x00200442, 0x008800ff, 0x0070008f, 0x0040798c,
	0x005000cb, 0x00000000, 0x0020002b, 0x00101a05, 0x00131c00, 0x00121c04,
	0x00141c20, 0x00111c25, 0x00131c40, 0x00121c44, 0x00141c60, 0x00111c65,
	0x00131f00, 0x00191f40, 0x004099e0, 0x002001d9, 0x00600006, 0x00200044,
	0x00102080, 0x001120c6, 0x001520c9, 0x001920d0, 0x00122100, 0x00122103,
	0x00162200, 0x00122207, 0x00112280, 0x00112300, 0x00112302, 0x00122380,
	0x0011238b, 0x00112394, 0x0011239c, 0x00000000, 0x0040a00f, 0x005000cb,
	0x00214b40, 0x00600007, 0x00200442, 0x008800ff, 0x005000cb, 0x0040a387,
	0x0060000a, 0x00000000, 0x0040b200, 0x007000a0, 0x00700080, 0x00200280,
	0x00600007, 0x00200004, 0x00c000ff, 0x008000ff, 0x005000cb, 0x00700000,
	0x00200000, 0x00600006, 0x00111bfe, 0x0040d44d, 0x00700000, 0x00200000,
	0x00600006, 0x00111bfe, 0x00700080, 0x0070001d, 0x0040114d, 0x00700081,
	0x00600004, 0x0050004a, 0x0040be88, 0x0060000b, 0x00200000, 0x00600006,
	0x00700000, 0x0040d40b, 0x00111bfd, 0x0040424d, 0x00202916, 0x008000fd,
	0x005000cb, 0x00c00002, 0x00200280, 0x00600007, 0x00200160, 0x00800002,
	0x005000cb, 0x00c01802, 0x002027b6, 0x00800002, 0x005000cb, 0x00404e4d,
	0x0060000b, 0x0040d24d, 0x00700001, 0x00700003, 0x0040d806, 0x0040d905,
	0x0060000d, 0x00700005, 0x0070000d, 0x00700006, 0x0070000b, 0x0070000e,
	0x0060000c, ~0
};

static int
nv50_graph_init_ctxctl(struct drm_device *dev)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
	uint32_t *voodoo = NULL;

	DRM_DEBUG("\n");

	switch (dev_priv->chipset) {
	case 0x84:
		voodoo = nv84_ctx_voodoo;
		break;
	case 0x86:
		voodoo = nv86_ctx_voodoo;
		break;
	default:
		DRM_ERROR("no voodoo for chipset NV%02x\n", dev_priv->chipset);
		return -EINVAL;
	}

	NV_WRITE(NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
	while (*voodoo != ~0) {
		NV_WRITE(NV40_PGRAPH_CTXCTL_UCODE_DATA, *voodoo);
		voodoo++;
	}

	NV_WRITE(0x400320, 4);
	NV_WRITE(NV40_PGRAPH_CTXCTL_CUR, 0);
	NV_WRITE(NV20_PGRAPH_CHANNEL_CTX_POINTER, 0);

	return 0;
}

int
nv50_graph_init(struct drm_device *dev)
{
	int ret;

	DRM_DEBUG("\n");

	nv50_graph_init_reset(dev);
	nv50_graph_init_intr(dev);
	nv50_graph_init_regs__nv(dev);
	nv50_graph_init_regs(dev);

	ret = nv50_graph_init_ctxctl(dev);
	if (ret)
		return ret;

	return 0;
}

void
nv50_graph_takedown(struct drm_device *dev)
{
	DRM_DEBUG("\n");
}

static void
nv86_graph_init_ctxvals(struct drm_device *dev, struct nouveau_gpuobj_ref *ref)
{
	struct drm_nouveau_private *dev_priv = dev->dev_private;
	struct nouveau_gpuobj *ctx = ref->gpuobj;

	INSTANCE_WR(ctx, 0x10C/4, 0x30);
	INSTANCE_WR(ctx, 0x1D4/4, 0x3);
	INSTANCE_WR(ctx, 0x1D8/4, 0x1000);
	INSTANCE_WR(ctx, 0x218/4, 0xFE0C);
	INSTANCE_WR(ctx, 0x22C/4, 0x1000);
	INSTANCE_WR(ctx, 0x258/4, 0x187);
	INSTANCE_WR(ctx, 0x26C/4, 0x1018);
	INSTANCE_WR(ctx, 0x270/4, 0xFF);
	INSTANCE_WR(ctx, 0x2AC/4, 0x4);
	INSTANCE_WR(ctx, 0x2B0/4, 0x44D00DF);
	INSTANCE_WR(ctx, 0x2B8/4, 0x600);
	INSTANCE_WR(ctx, 0x2D0/4, 0x1000000);
	INSTANCE_WR(ctx, 0x2D4/4, 0xFF);
	INSTANCE_WR(ctx, 0x2DC/4, 0x400);
	INSTANCE_WR(ctx, 0x2F4/4, 0x1);
	INSTANCE_WR(ctx, 0x2F8/4, 0x80);
	INSTANCE_WR(ctx, 0x2FC/4, 0x4);
	INSTANCE_WR(ctx, 0x318/4, 0x2);
	INSTANCE_WR(ctx, 0x31C/4, 0x1);
	INSTANCE_WR(ctx, 0x328/4, 0x1);
	INSTANCE_WR(ctx, 0x32C/4, 0x100);
	INSTANCE_WR(ctx, 0x344/4, 0x2);
	INSTANCE_WR(ctx, 0x348/4, 0x1);
	INSTANCE_WR(ctx, 0x34C/4, 0x1);
	INSTANCE_WR(ctx, 0x35C/4, 0x1);
	INSTANCE_WR(ctx, 0x360/4, 0x3FFFFF);
	INSTANCE_WR(ctx, 0x364/4, 0x1FFF);
	INSTANCE_WR(ctx, 0x36C/4, 0x1);
	INSTANCE_WR(ctx, 0x370/4, 0x1);
	INSTANCE_WR(ctx, 0x378/4, 0x1);
	INSTANCE_WR(ctx, 0x37C/4, 0x1);
	INSTANCE_WR(ctx, 0x380/4, 0x1);
	INSTANCE_WR(ctx, 0x384/4, 0x4);
	INSTANCE_WR(ctx, 0x388/4, 0x1);
	INSTANCE_WR(ctx, 0x38C/4, 0x1);
	INSTANCE_WR(ctx, 0x390/4, 0x1);
	INSTANCE_WR(ctx, 0x394/4, 0x7);
	INSTANCE_WR(ctx, 0x398/4, 0x1);
	INSTANCE_WR(ctx, 0x39C/4, 0x7);
	INSTANCE_WR(ctx, 0x3A0/4, 0x1);
	INSTANCE_WR(ctx, 0x3A4/4, 0x1);
	INSTANCE_WR(ctx, 0x3A8/4, 0x1);
	INSTANCE_WR(ctx, 0x3BC/4, 0x1);
	INSTANCE_WR(ctx, 0x3C0/4, 0x100);
	INSTANCE_WR(ctx, 0x3C8/4, 0x1);
	INSTANCE_WR(ctx, 0x3D4/4, 0x100);
	INSTANCE_WR(ctx, 0x3D8/4, 0x1);
	INSTANCE_WR(ctx, 0x3DC/4, 0x100);
	INSTANCE_WR(ctx, 0x3E4/4, 0x1);
	INSTANCE_WR(ctx, 0x3F0/4, 0x100);
	INSTANCE_WR(ctx, 0x404/4, 0x4);
	INSTANCE_WR(ctx, 0x408/4, 0x70);
	INSTANCE_WR(ctx, 0x40C/4, 0x80);
	INSTANCE_WR(ctx, 0x420/4, 0xC);
	INSTANCE_WR(ctx, 0x428/4, 0x8);
	INSTANCE_WR(ctx, 0x42C/4, 0x14);
	INSTANCE_WR(ctx, 0x434/4, 0x29);
	INSTANCE_WR(ctx, 0x438/4, 0x27);
	INSTANCE_WR(ctx, 0x43C/4, 0x26);
	INSTANCE_WR(ctx, 0x440/4, 0x8);
	INSTANCE_WR(ctx, 0x444/4, 0x4);
	INSTANCE_WR(ctx, 0x448/4, 0x27);
	INSTANCE_WR(ctx, 0x454/4, 0x1);
	INSTANCE_WR(ctx, 0x458/4, 0x2);
	INSTANCE_WR(ctx, 0x45C/4, 0x3);
	INSTANCE_WR(ctx, 0x460/4, 0x4);
	INSTANCE_WR(ctx, 0x464/4, 0x5);
	INSTANCE_WR(ctx, 0x468/4, 0x6);
	INSTANCE_WR(ctx, 0x46C/4, 0x7);
	INSTANCE_WR(ctx, 0x470/4, 0x1);
	INSTANCE_WR(ctx, 0x4B4/4, 0xCF);
	INSTANCE_WR(ctx, 0x4E4/4, 0x80);
	INSTANCE_WR(ctx, 0x4E8/4, 0x4);
	INSTANCE_WR(ctx, 0x4EC/4, 0x4);
	INSTANCE_WR(ctx, 0x4F0/4, 0x3);
	INSTANCE_WR(ctx, 0x4F4/4, 0x1);
	INSTANCE_WR(ctx, 0x500/4, 0x12);
	INSTANCE_WR(ctx, 0x504/4, 0x10);
	INSTANCE_WR(ctx, 0x508/4, 0xC);
	INSTANCE_WR(ctx, 0x50C/4, 0x1);
	INSTANCE_WR(ctx, 0x51C/4, 0x4);
	INSTANCE_WR(ctx, 0x520/4, 0x2);
	INSTANCE_WR(ctx, 0x524/4, 0x4);
	INSTANCE_WR(ctx, 0x530/4, 0x3FFFFF);
	INSTANCE_WR(ctx, 0x534/4, 0x1FFF);
	INSTANCE_WR(ctx, 0x55C/4, 0x4);
	INSTANCE_WR(ctx, 0x560/4, 0x14);
	INSTANCE_WR(ctx, 0x564/4, 0x1);
	INSTANCE_WR(ctx, 0x570/4, 0x2);
	INSTANCE_WR(ctx, 0x57C/4, 0x1);
	INSTANCE_WR(ctx, 0x584/4, 0x2);
	INSTANCE_WR(ctx, 0x588/4, 0x1000);
	INSTANCE_WR(ctx, 0x58C/4, 0xE00);
	INSTANCE_WR(ctx, 0x590/4, 0x1000);
	INSTANCE_WR(ctx, 0x594/4, 0x1E00);
	INSTANCE_WR(ctx, 0x59C/4, 0x1);
	INSTANCE_WR(ctx, 0x5A0/4, 0x1);
	INSTANCE_WR(ctx, 0x5A4/4, 0x1);
	INSTANCE_WR(ctx, 0x5A8/4, 0x1);
	INSTANCE_WR(ctx, 0x5AC/4, 0x1);
	INSTANCE_WR(ctx, 0x5BC/4, 0x200);
	INSTANCE_WR(ctx, 0x5C4/4, 0x1);
	INSTANCE_WR(ctx, 0x5C8/4, 0x70);
	INSTANCE_WR(ctx, 0x5CC/4, 0x80);
	INSTANCE_WR(ctx, 0x5D8/4, 0x1);
	INSTANCE_WR(ctx, 0x5DC/4, 0x70);
	INSTANCE_WR(ctx, 0x5E0/4, 0x80);
	INSTANCE_WR(ctx, 0x5F0/4, 0x1);
	INSTANCE_WR(ctx, 0x5F4/4, 0xCF);
	INSTANCE_WR(ctx, 0x5FC/4, 0x1);
	INSTANCE_WR(ctx, 0x60C/4, 0xCF);
	INSTANCE_WR(ctx, 0x614/4, 0x2);
	INSTANCE_WR(ctx, 0x61C/4, 0x1);
	INSTANCE_WR(ctx, 0x624/4, 0x1);
	INSTANCE_WR(ctx, 0x62C/4, 0xCF);
	INSTANCE_WR(ctx, 0x630/4, 0xCF);
	INSTANCE_WR(ctx, 0x634/4, 0x1);
	INSTANCE_WR(ctx, 0x63C/4, 0xF80);
	INSTANCE_WR(ctx, 0x684/4, 0x7F0080);
	INSTANCE_WR(ctx, 0x6C0/4, 0x7F0080);
	INSTANCE_WR(ctx, 0x6E4/4, 0x3B74F821);
	INSTANCE_WR(ctx, 0x6E8/4, 0x89058001);
	INSTANCE_WR(ctx, 0x6F0/4, 0x1000);
	INSTANCE_WR(ctx, 0x6F4/4, 0x1F);
	INSTANCE_WR(ctx, 0x6F8/4, 0x27C10FA);
	INSTANCE_WR(ctx, 0x6FC/4, 0x400000C0);
	INSTANCE_WR(ctx, 0x700/4, 0xB7892080);
	INSTANCE_WR(ctx, 0x70C/4, 0x3B74F821);
	INSTANCE_WR(ctx, 0x710/4, 0x89058001);
	INSTANCE_WR(ctx, 0x718/4, 0x1000);
	INSTANCE_WR(ctx, 0x71C/4, 0x1F);
	INSTANCE_WR(ctx, 0x720/4, 0x27C10FA);
	INSTANCE_WR(ctx, 0x724/4, 0x400000C0);
	INSTANCE_WR(ctx, 0x728/4, 0xB7892080);
	INSTANCE_WR(ctx, 0x734/4, 0x10040);
	INSTANCE_WR(ctx, 0x73C/4, 0x22);
	INSTANCE_WR(ctx, 0x748/4, 0x10040);
	INSTANCE_WR(ctx, 0x74C/4, 0x22);
	INSTANCE_WR(ctx, 0x764/4, 0x1800000);
	INSTANCE_WR(ctx, 0x768/4, 0x160000);
	INSTANCE_WR(ctx, 0x76C/4, 0x1800000);
	INSTANCE_WR(ctx, 0x77C/4, 0x3FFFF);
	INSTANCE_WR(ctx, 0x780/4, 0x8C0000);
	INSTANCE_WR(ctx, 0x7A4/4, 0x10401);
	INSTANCE_WR(ctx, 0x7AC/4, 0x78);
	INSTANCE_WR(ctx, 0x7B4/4, 0xBF);
	INSTANCE_WR(ctx, 0x7BC/4, 0x1210);
	INSTANCE_WR(ctx, 0x7C0/4, 0x8000080);
	INSTANCE_WR(ctx, 0x7E4/4, 0x1800000);
	INSTANCE_WR(ctx, 0x7E8/4, 0x160000);
	INSTANCE_WR(ctx, 0x7EC/4, 0x1800000);
	INSTANCE_WR(ctx, 0x7FC/4, 0x3FFFF);
	INSTANCE_WR(ctx, 0x800/4, 0x8C0000);
	INSTANCE_WR(ctx, 0x824/4, 0x10401);
	INSTANCE_WR(ctx, 0x82C/4, 0x78);
	INSTANCE_WR(ctx, 0x834/4, 0xBF);
	INSTANCE_WR(ctx, 0x83C/4, 0x1210);
	INSTANCE_WR(ctx, 0x840/4, 0x8000080);
	INSTANCE_WR(ctx, 0x868/4, 0x27070);
	INSTANCE_WR(ctx, 0x874/4, 0x3FFFFFF);
	INSTANCE_WR(ctx, 0x88C/4, 0x120407);
	INSTANCE_WR(ctx, 0x890/4, 0x5091507);
	INSTANCE_WR(ctx, 0x894/4, 0x5010202);
	INSTANCE_WR(ctx, 0x898/4, 0x30201);
	INSTANCE_WR(ctx, 0x8B4/4, 0x40);
	INSTANCE_WR(ctx, 0x8B8/4, 0xD0C0B0A);
	INSTANCE_WR(ctx, 0x8BC/4, 0x141210);
	INSTANCE_WR(ctx, 0x8C0/4, 0x1F0);
	INSTANCE_WR(ctx, 0x8C4/4, 0x1);
	INSTANCE_WR(ctx, 0x8C8/4, 0x3);
	INSTANCE_WR(ctx, 0x8D4/4, 0x39E00);
	INSTANCE_WR(ctx, 0x8D8/4, 0x100);
	INSTANCE_WR(ctx, 0x8DC/4, 0x3800);
	INSTANCE_WR(ctx, 0x8E0/4, 0x404040);
	INSTANCE_WR(ctx, 0x8E4/4, 0xFF0A);
	INSTANCE_WR(ctx, 0x8EC/4, 0x77F005);
	INSTANCE_WR(ctx, 0x8F0/4, 0x3F7FFF);
	INSTANCE_WR(ctx, 0x7BA0/4, 0x21);
	INSTANCE_WR(ctx, 0x7BC0/4, 0x1);
	INSTANCE_WR(ctx, 0x7BE0/4, 0x2);
	INSTANCE_WR(ctx, 0x7C00/4, 0x100);
	INSTANCE_WR(ctx, 0x7C20/4, 0x100);
	INSTANCE_WR(ctx, 0x7C40/4, 0x1);
	INSTANCE_WR(ctx, 0x7CA0/4, 0x1);
	INSTANCE_WR(ctx, 0x7CC0/4, 0x2);
	INSTANCE_WR(ctx, 0x7CE0/4, 0x100);
	INSTANCE_WR(ctx, 0x7D00/4, 0x100);
	INSTANCE_WR(ctx, 0x7D20/4, 0x1);
	INSTANCE_WR(ctx, 0x11640/4, 0x4);
	INSTANCE_WR(ctx, 0x11660/4, 0x4);
	INSTANCE_WR(ctx, 0x49FE0/4, 0x4);
	INSTANCE_WR(ctx, 0x4A000/4, 0x4);
	INSTANCE_WR(ctx, 0x4A020/4, 0x8100C12);
	INSTANCE_WR(ctx, 0x4A040/4, 0x3);
	INSTANCE_WR(ctx, 0x4A080/4, 0x8100C12);
	INSTANCE_WR(ctx, 0x4A0C0/4, 0x80C14);
	INSTANCE_WR(ctx, 0x4A0E0/4, 0x1);
	INSTANCE_WR(ctx, 0x4A100/4, 0x80C14);
	INSTANCE_WR(ctx, 0x4A160/4, 0x8100C12);
	INSTANCE_WR(ctx, 0x4A180/4, 0x27);
	INSTANCE_WR(ctx, 0x4A1E0/4, 0x1);
	INSTANCE_WR(ctx, 0x51A20/4, 0x1);
	INSTANCE_WR(ctx, 0x51D00/4, 0x8100C12);
	INSTANCE_WR(ctx, 0x51EA0/4, 0x4000000);
	INSTANCE_WR(ctx, 0x51EC0/4, 0x4000000);
	INSTANCE_WR(ctx, 0x51F00/4, 0x80);
	INSTANCE_WR(ctx, 0x51F80/4, 0x80);
	INSTANCE_WR(ctx, 0x51FC0/4, 0x3F);
	INSTANCE_WR(ctx, 0x52120/4, 0x2);
	INSTANCE_WR(ctx, 0x52140/4, 0x4000000);
	INSTANCE_WR(ctx, 0x52160/4, 0x4000000);
	INSTANCE_WR(ctx, 0x52280/4, 0x4);
	INSTANCE_WR(ctx, 0x52300/4, 0x4);
	INSTANCE_WR(ctx, 0x52540/4, 0x1);
	INSTANCE_WR(ctx, 0x52560/4, 0x1001);
	INSTANCE_WR(ctx, 0x52580/4, 0xFFFF);
	INSTANCE_WR(ctx, 0x525A0/4, 0xFFFF);
	INSTANCE_WR(ctx, 0x525C0/4, 0xFFFF);
	INSTANCE_WR(ctx, 0x525E0/4, 0xFFFF);
	INSTANCE_WR(ctx, 0x52A00/4, 0x3F800000);
	INSTANCE_WR(ctx, 0x52A20/4, 0x3F800000);
	INSTANCE_WR(ctx, 0x52A40/4, 0x3F800000);
	INSTANCE_WR(ctx, 0x52A60/4, 0x3F800000);
	INSTANCE_WR(ctx, 0x52A80/4, 0x3F800000);
	INSTANCE_WR(ctx, 0x52AA0/4, 0x3F800000);