Loading...
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 | /* * linux/drivers/video/riva/fbdev.c - nVidia RIVA 128/TNT/TNT2 fb driver * * Maintained by Ani Joshi <ajoshi@shell.unixbox.com> * * Copyright 1999-2000 Jeff Garzik * * Contributors: * * Ani Joshi: Lots of debugging and cleanup work, really helped * get the driver going * * Ferenc Bakonyi: Bug fixes, cleanup, modularization * * Jindrich Makovicka: Accel code help, hw cursor, mtrr * * Initial template from skeletonfb.c, created 28 Dec 1997 by Geert Uytterhoeven * Includes riva_hw.c from nVidia, see copyright below. * KGI code provided the basis for state storage, init, and mode switching. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive * for more details. * * Known bugs and issues: * restoring text mode fails * doublescan modes are broken * option 'noaccel' has no effect */ #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/selection.h> #include <linux/tty.h> #include <linux/slab.h> #include <linux/delay.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/pci.h> #include <linux/console.h> #ifdef CONFIG_MTRR #include <asm/mtrr.h> #endif #include "rivafb.h" #include "nvreg.h" #ifndef CONFIG_PCI /* sanity check */ #error This driver requires PCI support. #endif /* version number of this driver */ #define RIVAFB_VERSION "0.9.2a" /* ------------------------------------------------------------------------- * * * various helpful macros and constants * * ------------------------------------------------------------------------- */ #undef RIVAFBDEBUG #ifdef RIVAFBDEBUG #define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) #else #define DPRINTK(fmt, args...) #endif #ifndef RIVA_NDEBUG #define assert(expr) \ if(!(expr)) { \ printk( "Assertion failed! %s,%s,%s,line=%d\n",\ #expr,__FILE__,__FUNCTION__,__LINE__); \ BUG(); \ } #else #define assert(expr) #endif #define PFX "rivafb: " /* macro that allows you to set overflow bits */ #define SetBitField(value,from,to) SetBF(to,GetBF(value,from)) #define SetBit(n) (1<<(n)) #define Set8Bits(value) ((value)&0xff) /* HW cursor parameters */ #define DEFAULT_CURSOR_BLINK_RATE (40) #define CURSOR_HIDE_DELAY (20) #define CURSOR_SHOW_DELAY (3) #define CURSOR_COLOR 0x7fff #define TRANSPARENT_COLOR 0x0000 #define MAX_CURS 32 /* ------------------------------------------------------------------------- * * * prototypes * * ------------------------------------------------------------------------- */ static void rivafb_blank(int blank, struct fb_info *info); extern void riva_setup_accel(struct rivafb_info *rinfo); extern inline void wait_for_idle(struct rivafb_info *rinfo); /* ------------------------------------------------------------------------- * * * card identification * * ------------------------------------------------------------------------- */ enum riva_chips { CH_RIVA_128 = 0, CH_RIVA_TNT, CH_RIVA_TNT2, CH_RIVA_UTNT2, /* UTNT2 */ CH_RIVA_VTNT2, /* VTNT2 */ CH_RIVA_UVTNT2, /* VTNT2 */ CH_RIVA_ITNT2, /* ITNT2 */ CH_GEFORCE_SDR, CH_GEFORCE_DDR, CH_QUADRO, CH_GEFORCE2_MX, CH_QUADRO2_MXR, CH_GEFORCE2_GTS, CH_GEFORCE2_ULTRA, CH_QUADRO2_PRO, }; /* directly indexed by riva_chips enum, above */ static struct riva_chip_info { const char *name; unsigned arch_rev; } riva_chip_info[] __devinitdata = { { "RIVA-128", NV_ARCH_03 }, { "RIVA-TNT", NV_ARCH_04 }, { "RIVA-TNT2", NV_ARCH_04 }, { "RIVA-UTNT2", NV_ARCH_04 }, { "RIVA-VTNT2", NV_ARCH_04 }, { "RIVA-UVTNT2", NV_ARCH_04 }, { "RIVA-ITNT2", NV_ARCH_04 }, { "GeForce-SDR", NV_ARCH_10}, { "GeForce-DDR", NV_ARCH_10}, { "Quadro", NV_ARCH_10}, { "GeForce2-MX", NV_ARCH_10}, { "Quadro2-MXR", NV_ARCH_10}, { "GeForce2-GTS", NV_ARCH_10}, { "GeForce2-ULTRA", NV_ARCH_10}, { "Quadro2-PRO", NV_ARCH_10}, }; static struct pci_device_id rivafb_pci_tbl[] __devinitdata = { { PCI_VENDOR_ID_NVIDIA_SGS, PCI_DEVICE_ID_NVIDIA_SGS_RIVA128, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RIVA_128 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_TNT, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RIVA_TNT }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_TNT2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RIVA_TNT2 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_UTNT2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RIVA_UTNT2 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_VTNT2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RIVA_VTNT2 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_UVTNT2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RIVA_VTNT2 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_ITNT2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RIVA_ITNT2 }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE_SDR }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE_DDR }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_MX }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_MX }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO2_MXR }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_GTS }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_GTS }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_GEFORCE2_ULTRA }, { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_QUADRO2_PRO }, { 0, } /* terminate list */ }; MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl); /* ------------------------------------------------------------------------- * * * framebuffer related structures * * ------------------------------------------------------------------------- */ #ifdef FBCON_HAS_CFB8 extern struct display_switch fbcon_riva8; #endif #ifdef FBCON_HAS_CFB16 extern struct display_switch fbcon_riva16; #endif #ifdef FBCON_HAS_CFB32 extern struct display_switch fbcon_riva32; #endif #if 0 /* describes the state of a Riva board */ struct rivafb_par { struct riva_regs state; /* state of hw board */ __u32 visual; /* FB_VISUAL_xxx */ unsigned depth; /* bpp of current mode */ }; #endif struct riva_cursor { int enable; int on; int vbl_cnt; int last_move_delay; int blink_rate; struct { u16 x, y; } pos, size; unsigned short image[MAX_CURS*MAX_CURS]; struct timer_list *timer; }; /* ------------------------------------------------------------------------- * * * global variables * * ------------------------------------------------------------------------- */ struct rivafb_info *riva_boards = NULL; /* command line data, set in rivafb_setup() */ static char fontname[40] __initdata = { 0 }; static char noaccel __initdata = 0; static char nomove = 0; static char nohwcursor __initdata = 0; static char noblink = 0; #ifdef CONFIG_MTRR static char nomtrr __initdata = 0; #endif #ifndef MODULE static char *mode_option __initdata = NULL; #else static char *font = NULL; #endif static struct fb_var_screeninfo rivafb_default_var = { xres: 640, yres: 480, xres_virtual: 640, yres_virtual: 480, xoffset: 0, yoffset: 0, bits_per_pixel: 8, grayscale: 0, red: {0, 6, 0}, green: {0, 6, 0}, blue: {0, 6, 0}, transp: {0, 0, 0}, nonstd: 0, activate: 0, height: -1, width: -1, accel_flags: 0, pixclock: 39721, left_margin: 40, right_margin: 24, upper_margin: 32, lower_margin: 11, hsync_len: 96, vsync_len: 2, sync: 0, vmode: FB_VMODE_NONINTERLACED }; /* from GGI */ static const struct riva_regs reg_template = { {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* ATTR */ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x41, 0x01, 0x0F, 0x00, 0x00}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* CRT */ 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, /* 0x10 */ 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20 */ 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40 */ }, {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, /* GRA */ 0xFF}, {0x03, 0x01, 0x0F, 0x00, 0x0E}, /* SEQ */ 0xEB /* MISC */ }; /* ------------------------------------------------------------------------- * * * MMIO access macros * * ------------------------------------------------------------------------- */ static inline void CRTCout(struct rivafb_info *rinfo, unsigned char index, unsigned char val) { VGA_WR08(rinfo->riva.PCIO, 0x3d4, index); VGA_WR08(rinfo->riva.PCIO, 0x3d5, val); } static inline unsigned char CRTCin(struct rivafb_info *rinfo, unsigned char index) { VGA_WR08(rinfo->riva.PCIO, 0x3d4, index); return (VGA_RD08(rinfo->riva.PCIO, 0x3d5)); } static inline void GRAout(struct rivafb_info *rinfo, unsigned char index, unsigned char val) { VGA_WR08(rinfo->riva.PVIO, 0x3ce, index); VGA_WR08(rinfo->riva.PVIO, 0x3cf, val); } static inline unsigned char GRAin(struct rivafb_info *rinfo, unsigned char index) { VGA_WR08(rinfo->riva.PVIO, 0x3ce, index); return (VGA_RD08(rinfo->riva.PVIO, 0x3cf)); } static inline void SEQout(struct rivafb_info *rinfo, unsigned char index, unsigned char val) { VGA_WR08(rinfo->riva.PVIO, 0x3c4, index); VGA_WR08(rinfo->riva.PVIO, 0x3c5, val); } static inline unsigned char SEQin(struct rivafb_info *rinfo, unsigned char index) { VGA_WR08(rinfo->riva.PVIO, 0x3c4, index); return (VGA_RD08(rinfo->riva.PVIO, 0x3c5)); } static inline void ATTRout(struct rivafb_info *rinfo, unsigned char index, unsigned char val) { VGA_WR08(rinfo->riva.PCIO, 0x3c0, index); VGA_WR08(rinfo->riva.PCIO, 0x3c0, val); } static inline unsigned char ATTRin(struct rivafb_info *rinfo, unsigned char index) { VGA_WR08(rinfo->riva.PCIO, 0x3c0, index); return (VGA_RD08(rinfo->riva.PCIO, 0x3c1)); } static inline void MISCout(struct rivafb_info *rinfo, unsigned char val) { VGA_WR08(rinfo->riva.PVIO, 0x3c2, val); } static inline unsigned char MISCin(struct rivafb_info *rinfo) { return (VGA_RD08(rinfo->riva.PVIO, 0x3cc)); } /* ------------------------------------------------------------------------- * * * cursor stuff * * ------------------------------------------------------------------------- */ /** * riva_cursor_timer_handler - blink timer * @dev_addr: pointer to rivafb_info object containing info for current riva board * * DESCRIPTION: * Cursor blink timer. */ static void riva_cursor_timer_handler(unsigned long dev_addr) { struct rivafb_info *rinfo = (struct rivafb_info *)dev_addr; if (!rinfo->cursor) return; if (!rinfo->cursor->enable) goto out; if (rinfo->cursor->last_move_delay < 1000) rinfo->cursor->last_move_delay++; if (rinfo->cursor->vbl_cnt && --rinfo->cursor->vbl_cnt == 0) { rinfo->cursor->on ^= 1; if (rinfo->cursor->on) *(rinfo->riva.CURSORPOS) = (rinfo->cursor->pos.x & 0xFFFF) | (rinfo->cursor->pos.y << 16); rinfo->riva.ShowHideCursor(&rinfo->riva, rinfo->cursor->on); if (!noblink) rinfo->cursor->vbl_cnt = rinfo->cursor->blink_rate; } out: rinfo->cursor->timer->expires = jiffies + (HZ / 100); add_timer(rinfo->cursor->timer); } /** * rivafb_init_cursor - allocates cursor structure and starts blink timer * @rinfo: pointer to rivafb_info object containing info for current riva board * * DESCRIPTION: * Allocates cursor structure and starts blink timer. * * RETURNS: * Pointer to allocated cursor structure. * * CALLED FROM: * rivafb_init_one() */ static struct riva_cursor * __init rivafb_init_cursor(struct rivafb_info *rinfo) { struct riva_cursor *cursor; cursor = kmalloc(sizeof(struct riva_cursor), GFP_KERNEL); if (!cursor) return 0; memset(cursor, 0, sizeof(*cursor)); cursor->timer = kmalloc(sizeof(*cursor->timer), GFP_KERNEL); if (!cursor->timer) { kfree(cursor); return 0; } memset(cursor->timer, 0, sizeof(*cursor->timer)); cursor->blink_rate = DEFAULT_CURSOR_BLINK_RATE; init_timer(cursor->timer); cursor->timer->expires = jiffies + (HZ / 100); cursor->timer->data = (unsigned long)rinfo; cursor->timer->function = riva_cursor_timer_handler; add_timer(cursor->timer); return cursor; } /** * rivafb_exit_cursor - stops blink timer and releases cursor structure * @rinfo: pointer to rivafb_info object containing info for current riva board * * DESCRIPTION: * Stops blink timer and releases cursor structure. * * CALLED FROM: * rivafb_init_one() * rivafb_remove_one() */ static void rivafb_exit_cursor(struct rivafb_info *rinfo) { struct riva_cursor *cursor = rinfo->cursor; if (cursor) { if (cursor->timer) { del_timer_sync(cursor->timer); kfree(cursor->timer); } kfree(cursor); rinfo->cursor = 0; } } /** * rivafb_download_cursor - writes cursor shape into card registers * @rinfo: pointer to rivafb_info object containing info for current riva board * * DESCRIPTION: * Writes cursor shape into card registers. * * CALLED FROM: * riva_load_video_mode() */ static void rivafb_download_cursor(struct rivafb_info *rinfo) { int i, save; int *image; if (!rinfo->cursor) return; image = (int *)rinfo->cursor->image; save = rinfo->riva.ShowHideCursor(&rinfo->riva, 0); for (i = 0; i < (MAX_CURS*MAX_CURS*2)/sizeof(int); i++) writel(image[i], rinfo->riva.CURSOR + i); rinfo->riva.ShowHideCursor(&rinfo->riva, save); } /** * rivafb_create_cursor - sets rectangular cursor * @rinfo: pointer to rivafb_info object containing info for current riva board * @width: cursor width in pixels * @height: cursor height in pixels * * DESCRIPTION: * Sets rectangular cursor. * * CALLED FROM: * rivafb_set_font() * rivafb_set_var() */ static void rivafb_create_cursor(struct rivafb_info *rinfo, int width, int height) { struct riva_cursor *c = rinfo->cursor; int i, j, idx; if (c) { if (width <= 0 || height <= 0) { width = 8; height = 16; } if (width > MAX_CURS) width = MAX_CURS; if (height > MAX_CURS) height = MAX_CURS; c->size.x = width; c->size.y = height; idx = 0; for (i = 0; i < height; i++) { for (j = 0; j < width; j++,idx++) c->image[idx] = CURSOR_COLOR; for (j = width; j < MAX_CURS; j++,idx++) c->image[idx] = TRANSPARENT_COLOR; } for (i = height; i < MAX_CURS; i++) for (j = 0; j < MAX_CURS; j++,idx++) c->image[idx] = TRANSPARENT_COLOR; } } /** * rivafb_set_font - change font size * @p: pointer to display object * @width: font width in pixels * @height: font height in pixels * * DESCRIPTION: * Callback function called if font settings changed. * * RETURNS: * 1 (Always succeeds.) */ static int rivafb_set_font(struct display *p, int width, int height) { struct rivafb_info *fb = (struct rivafb_info *)(p->fb_info); rivafb_create_cursor(fb, width, height); return 1; } /** * rivafb_cursor - cursor handler * @p: pointer to display object * @mode: cursor mode (see CM_*) * @x: cursor x coordinate in characters * @y: cursor y coordinate in characters * * DESCRIPTION: * Cursor handler. */ static void rivafb_cursor(struct display *p, int mode, int x, int y) { struct rivafb_info *rinfo = (struct rivafb_info *)(p->fb_info); struct riva_cursor *c = rinfo->cursor; if (!c) return; x = x * fontwidth(p) - p->var.xoffset; y = y * fontheight(p) - p->var.yoffset; if (c->pos.x == x && c->pos.y == y && (mode == CM_ERASE) == !c->enable) return; c->enable = 0; if (c->on) rinfo->riva.ShowHideCursor(&rinfo->riva, 0); c->pos.x = x; c->pos.y = y; switch (mode) { case CM_ERASE: c->on = 0; break; case CM_DRAW: case CM_MOVE: if (c->last_move_delay <= 1) { /* rapid cursor movement */ c->vbl_cnt = CURSOR_SHOW_DELAY; } else { *(rinfo->riva.CURSORPOS) = (x & 0xFFFF) | (y << 16); rinfo->riva.ShowHideCursor(&rinfo->riva, 1); if (!noblink) c->vbl_cnt = CURSOR_HIDE_DELAY; c->on = 1; } c->last_move_delay = 0; c->enable = 1; break; } } /* ------------------------------------------------------------------------- * * * general utility functions * * ------------------------------------------------------------------------- */ /** * riva_set_dispsw - sets dispsw * @rinfo: pointer to internal driver struct for a given Riva card * @disp: pointer to display object * * DESCRIPTION: * Sets up console low level operations depending on the current? color depth * of the display. * * CALLED FROM: * rivafb_set_var() * rivafb_switch() * riva_init_disp() */ static void riva_set_dispsw(struct rivafb_info *rinfo, struct display *disp) { int accel = disp->var.accel_flags & FB_ACCELF_TEXT; DPRINTK("ENTER\n"); assert(rinfo != NULL); disp->dispsw_data = NULL; disp->screen_base = rinfo->fb_base; disp->type = FB_TYPE_PACKED_PIXELS; disp->type_aux = 0; disp->ypanstep = 1; disp->ywrapstep = 0; disp->can_soft_blank = 1; disp->inverse = 0; switch (disp->var.bits_per_pixel) { #ifdef FBCON_HAS_CFB8 case 8: rinfo->dispsw = accel ? fbcon_riva8 : fbcon_cfb8; disp->dispsw = &rinfo->dispsw; disp->line_length = disp->var.xres_virtual; disp->visual = FB_VISUAL_PSEUDOCOLOR; break; #endif #ifdef FBCON_HAS_CFB16 case 16: rinfo->dispsw = accel ? fbcon_riva16 : fbcon_cfb16; disp->dispsw_data = &rinfo->con_cmap.cfb16; disp->dispsw = &rinfo->dispsw; disp->line_length = disp->var.xres_virtual * 2; disp->visual = FB_VISUAL_DIRECTCOLOR; break; #endif #ifdef FBCON_HAS_CFB32 case 32: rinfo->dispsw = accel ? fbcon_riva32 : fbcon_cfb32; disp->dispsw_data = rinfo->con_cmap.cfb32; disp->dispsw = &rinfo->dispsw; disp->line_length = disp->var.xres_virtual * 4; disp->visual = FB_VISUAL_DIRECTCOLOR; break; #endif default: DPRINTK("Setting fbcon_dummy renderer\n"); rinfo->dispsw = fbcon_dummy; disp->dispsw = &rinfo->dispsw; } /* FIXME: verify that the above code sets dsp->* fields correctly */ if (rinfo->cursor) { rinfo->dispsw.cursor = rivafb_cursor; rinfo->dispsw.set_font = rivafb_set_font; } DPRINTK("EXIT\n"); } /** * riva_wclut - set CLUT entry * @chip: pointer to RIVA_HW_INST object * @regnum: register number * @red: red component * @green: green component * @blue: blue component * * DESCRIPTION: * Sets color register @regnum. * * CALLED FROM: * riva_setcolreg() */ static void riva_wclut(RIVA_HW_INST *chip, unsigned char regnum, unsigned char red, unsigned char green, unsigned char blue) { VGA_WR08(chip->PDIO, 0x3c8, regnum); VGA_WR08(chip->PDIO, 0x3c9, red); VGA_WR08(chip->PDIO, 0x3c9, green); VGA_WR08(chip->PDIO, 0x3c9, blue); } /** * riva_save_state - saves current chip state * @rinfo: pointer to rivafb_info object containing info for current riva board * @regs: pointer to riva_regs object * * DESCRIPTION: * Saves current chip state to @regs. * * CALLED FROM: * rivafb_init_one() */ /* from GGI */ static void riva_save_state(struct rivafb_info *rinfo, struct riva_regs *regs) { int i; rinfo->riva.LockUnlock(&rinfo->riva, 0); rinfo->riva.UnloadStateExt(&rinfo->riva, ®s->ext); regs->misc_output = MISCin(rinfo); for (i = 0; i < NUM_CRT_REGS; i++) { regs->crtc[i] = CRTCin(rinfo, i); } for (i = 0; i < NUM_ATC_REGS; i++) { regs->attr[i] = ATTRin(rinfo, i); } for (i = 0; i < NUM_GRC_REGS; i++) { regs->gra[i] = GRAin(rinfo, i); } for (i = 0; i < NUM_SEQ_REGS; i++) { regs->seq[i] = SEQin(rinfo, i); } } /** * riva_load_state - loads current chip state * @rinfo: pointer to rivafb_info object containing info for current riva board * @regs: pointer to riva_regs object * * DESCRIPTION: * Loads chip state from @regs. * * CALLED FROM: * riva_load_video_mode() * rivafb_init_one() * rivafb_remove_one() */ /* from GGI */ static void riva_load_state(struct rivafb_info *rinfo, struct riva_regs *regs) { int i; RIVA_HW_STATE *state = ®s->ext; CRTCout(rinfo, 0x11, 0x00); rinfo->riva.LockUnlock(&rinfo->riva, 0); rinfo->riva.LoadStateExt(&rinfo->riva, state); MISCout(rinfo, regs->misc_output); for (i = 0; i < NUM_CRT_REGS; i++) { switch (i) { case 0x19: case 0x20 ... 0x40: break; default: CRTCout(rinfo, i, regs->crtc[i]); } } for (i = 0; i < NUM_ATC_REGS; i++) { ATTRout(rinfo, i, regs->attr[i]); } for (i = 0; i < NUM_GRC_REGS; i++) { GRAout(rinfo, i, regs->gra[i]); } for (i = 0; i < NUM_SEQ_REGS; i++) { SEQout(rinfo, i, regs->seq[i]); } } /** * riva_load_video_mode - calculate timings * @rinfo: pointer to rivafb_info object containing info for current riva board * @video_mode: video mode to set * * DESCRIPTION: * Calculate some timings and then send em off to riva_load_state(). * * CALLED FROM: * rivafb_set_var() */ static void riva_load_video_mode(struct rivafb_info *rinfo, struct fb_var_screeninfo *video_mode) { struct riva_regs newmode; int bpp, width, hDisplaySize, hDisplay, hStart, hEnd, hTotal, height, vDisplay, vStart, vEnd, vTotal, dotClock; /* time to calculate */ rivafb_blank(1, (struct fb_info *)rinfo); bpp = video_mode->bits_per_pixel; if (bpp == 16 && video_mode->green.length == 5) bpp = 15; width = video_mode->xres_virtual; hDisplaySize = video_mode->xres; hDisplay = (hDisplaySize / 8) - 1; hStart = (hDisplaySize + video_mode->right_margin) / 8 + 2; hEnd = (hDisplaySize + video_mode->right_margin + video_mode->hsync_len) / 8 - 1; hTotal = (hDisplaySize + video_mode->right_margin + video_mode->hsync_len + video_mode->left_margin) / 8 - 1; height = video_mode->yres_virtual; vDisplay = video_mode->yres - 1; vStart = video_mode->yres + video_mode->lower_margin - 1; vEnd = video_mode->yres + video_mode->lower_margin + video_mode->vsync_len - 1; vTotal = video_mode->yres + video_mode->lower_margin + video_mode->vsync_len + video_mode->upper_margin + 2; dotClock = 1000000000 / video_mode->pixclock; memcpy(&newmode, ®_template, sizeof(struct riva_regs)); newmode.crtc[0x0] = Set8Bits (hTotal - 4); newmode.crtc[0x1] = Set8Bits (hDisplay); newmode.crtc[0x2] = Set8Bits (hDisplay); newmode.crtc[0x3] = SetBitField (hTotal, 4: 0, 4:0) | SetBit (7); newmode.crtc[0x4] = Set8Bits (hStart); newmode.crtc[0x5] = SetBitField (hTotal, 5: 5, 7:7) | SetBitField (hEnd, 4: 0, 4:0); newmode.crtc[0x6] = SetBitField (vTotal, 7: 0, 7:0); newmode.crtc[0x7] = SetBitField (vTotal, 8: 8, 0:0) | SetBitField (vDisplay, 8: 8, 1:1) | SetBitField (vStart, 8: 8, 2:2) | SetBitField (vDisplay, 8: 8, 3:3) | SetBit (4) | SetBitField (vTotal, 9: 9, 5:5) | SetBitField (vDisplay, 9: 9, 6:6) | SetBitField (vStart, 9: 9, 7:7); newmode.crtc[0x9] = SetBitField (vDisplay, 9: 9, 5:5) | SetBit (6); newmode.crtc[0x10] = Set8Bits (vStart); newmode.crtc[0x11] = SetBitField (vEnd, 3: 0, 3:0) | SetBit (5); newmode.crtc[0x12] = Set8Bits (vDisplay); newmode.crtc[0x13] = ((width / 8) * ((bpp + 1) / 8)) & 0xFF; newmode.crtc[0x15] = Set8Bits (vDisplay); newmode.crtc[0x16] = Set8Bits (vTotal + 1); newmode.ext.bpp = bpp; newmode.ext.width = width; newmode.ext.height = height; rinfo->riva.CalcStateExt(&rinfo->riva, &newmode.ext, bpp, width, hDisplaySize, hDisplay, hStart, hEnd, hTotal, height, vDisplay, vStart, vEnd, vTotal, dotClock); rinfo->current_state = newmode; riva_load_state(rinfo, &rinfo->current_state); rinfo->riva.LockUnlock(&rinfo->riva, 0); /* important for HW cursor */ rivafb_download_cursor(rinfo); } /** * riva_board_list_add - maintains board list * @board_list: root node of list of boards * @new_node: new node to be added * * DESCRIPTION: * Adds @new_node to the list referenced by @board_list. * * RETURNS: * New root node * * CALLED FROM: * rivafb_init_one() */ static struct rivafb_info *riva_board_list_add(struct rivafb_info *board_list, struct rivafb_info *new_node) { struct rivafb_info *i_p = board_list; new_node->next = NULL; if (board_list == NULL) return new_node; while (i_p->next != NULL) i_p = i_p->next; i_p->next = new_node; return board_list; } /** * riva_board_list_del - maintains board list * @board_list: root node of list of boards * @del_node: node to be removed * * DESCRIPTION: * Removes @del_node from the list referenced by @board_list. * * RETURNS: * New root node * * CALLED FROM: * rivafb_remove_one() */ static struct rivafb_info *riva_board_list_del(struct rivafb_info *board_list, struct rivafb_info *del_node) { struct rivafb_info *i_p = board_list; if (board_list == del_node) return del_node->next; while (i_p->next != del_node) i_p = i_p->next; i_p->next = del_node->next; return board_list; } /** * rivafb_do_maximize - * @rinfo: pointer to rivafb_info object containing info for current riva board * @var: * @v: * @nom: * @den: * * DESCRIPTION: * . * * RETURNS: * -EINVAL on failure, 0 on success * * * CALLED FROM: * rivafb_set_var() */ static int rivafb_do_maximize(struct rivafb_info *rinfo, struct fb_var_screeninfo *var, struct fb_var_screeninfo *v, int nom, int den) { static struct { int xres, yres; } modes[] = { {1600, 1280}, {1280, 1024}, {1024, 768}, {800, 600}, {640, 480}, {-1, -1} }; int i; /* use highest possible virtual resolution */ if (v->xres_virtual == -1 && v->yres_virtual == -1) { printk(KERN_WARNING PFX "using maximum available virtual resolution\n"); for (i = 0; modes[i].xres != -1; i++) { if (modes[i].xres * nom / den * modes[i].yres < rinfo->ram_amount / 2) break; } if (modes[i].xres == -1) { printk(KERN_ERR PFX "could not find a virtual resolution that fits into video memory!!\n"); DPRINTK("EXIT - EINVAL error\n"); return -EINVAL; } v->xres_virtual = modes[i].xres; v->yres_virtual = modes[i].yres; printk(KERN_INFO PFX "virtual resolution set to maximum of %dx%d\n", v->xres_virtual, v->yres_virtual); } else if (v->xres_virtual == -1) { v->xres_virtual = (rinfo->ram_amount * den / (nom * v->yres_virtual * 2)) & ~15; printk(KERN_WARNING PFX "setting virtual X resolution to %d\n", v->xres_virtual); } else if (v->yres_virtual == -1) { v->xres_virtual = (v->xres_virtual + 15) & ~15; v->yres_virtual = rinfo->ram_amount * den / (nom * v->xres_virtual * 2); printk(KERN_WARNING PFX "setting virtual Y resolution to %d\n", v->yres_virtual); } else { v->xres_virtual = (v->xres_virtual + 15) & ~15; if (v->xres_virtual * nom / den * v->yres_virtual > rinfo->ram_amount) { printk(KERN_ERR PFX "mode %dx%dx%d rejected...resolution too high to fit into video memory!\n", var->xres, var->yres, var->bits_per_pixel); DPRINTK("EXIT - EINVAL error\n"); return -EINVAL; } } if (v->xres_virtual * nom / den >= 8192) { printk(KERN_WARNING PFX "virtual X resolution (%d) is too high, lowering to %d\n", v->xres_virtual, 8192 * den / nom - 16); v->xres_virtual = 8192 * den / nom - 16; } if (v->xres_virtual < v->xres) { printk(KERN_ERR PFX "virtual X resolution (%d) is smaller than real\n", v->xres_virtual); return -EINVAL; } if (v->yres_virtual < v->yres) { printk(KERN_ERR PFX "virtual Y resolution (%d) is smaller than real\n", v->yres_virtual); return -EINVAL; } return 0; } /* ------------------------------------------------------------------------- * * * internal fb_ops helper functions * * ------------------------------------------------------------------------- */ /** * riva_get_cmap_len - query current color map length * @var: standard kernel fb changeable data * * DESCRIPTION: * Get current color map length. * * RETURNS: * Length of color map * * CALLED FROM: * riva_getcolreg() * riva_setcolreg() * rivafb_get_cmap() * rivafb_set_cmap() */ static int riva_get_cmap_len(const struct fb_var_screeninfo *var) { int rc = 16; /* reasonable default */ assert(var != NULL); switch (var->bits_per_pixel) { #ifdef FBCON_HAS_CFB8 case 8: rc = 256; /* pseudocolor... 256 entries HW palette */ break; #endif #ifdef FBCON_HAS_CFB16 case 15: rc = 15; /* fix for 15 bpp depths on Riva 128 based cards */ break; case 16: rc = 16; /* directcolor... 16 entries SW palette */ break; /* Mystique: truecolor, 16 entries SW palette, HW palette hardwired into 1:1 mapping */ #endif #ifdef FBCON_HAS_CFB32 case 32: rc = 16; /* directcolor... 16 entries SW palette */ break; /* Mystique: truecolor, 16 entries SW palette, HW palette hardwired into 1:1 mapping */ #endif default: /* should not occur */ break; } return rc; } /** * riva_getcolreg * @regno: register index * @red: red component * @green: green component * @blue: blue component * @transp: transparency * @info: pointer to rivafb_info object containing info for current riva board * * DESCRIPTION: * Read a single color register and split it into colors/transparent. * The return values must have a 16 bit magnitude. * * RETURNS: * Return != 0 for invalid regno. * * CALLED FROM: * rivafb_get_cmap() * rivafb_switch() * fbcmap.c:fb_get_cmap() * fbgen.c:fbgen_get_cmap() * fbgen.c:fbgen_switch() */ static int riva_getcolreg(unsigned regno, unsigned *red, unsigned *green, unsigned *blue, unsigned *transp, struct fb_info *info) { struct rivafb_info *rivainfo = (struct rivafb_info *)info; if (regno >= riva_get_cmap_len(&rivainfo->currcon_display->var)) return 1; *red = rivainfo->palette[regno].red; *green = rivainfo->palette[regno].green; *blue = rivainfo->palette[regno].blue; *transp = 0; return 0; } /** * riva_setcolreg * @regno: register index * @red: red component * @green: green component * @blue: blue component * @transp: transparency * @info: pointer to rivafb_info object containing info for current riva board * * DESCRIPTION: * Set a single color register. The values supplied have a 16 bit * magnitude. * * RETURNS: * Return != 0 for invalid regno. * * CALLED FROM: * rivafb_set_cmap() * fbcmap.c:fb_set_cmap() * fbgen.c:fbgen_get_cmap() * fbgen.c:fbgen_install_cmap() * fbgen.c:fbgen_set_var() * fbgen.c:fbgen_switch() * fbgen.c:fbgen_blank() * fbgen.c:fbgen_blank() */ static int riva_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *info) { struct rivafb_info *rivainfo = (struct rivafb_info *)info; RIVA_HW_INST *chip = &rivainfo->riva; struct display *p; DPRINTK("ENTER\n"); assert(rivainfo != NULL); assert(rivainfo->currcon_display != NULL); p = rivainfo->currcon_display; if (regno >= riva_get_cmap_len(&p->var)) return -EINVAL; rivainfo->palette[regno].red = red; rivainfo->palette[regno].green = green; rivainfo->palette[regno].blue = blue; if (p->var.grayscale) { /* gray = 0.30*R + 0.59*G + 0.11*B */ red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; } switch (p->var.bits_per_pixel) { #ifdef FBCON_HAS_CFB8 case 8: /* "transparent" stuff is completely ignored. */ riva_wclut(chip, regno, red >> 8, green >> 8, blue >> 8); break; #endif /* FBCON_HAS_CFB8 */ #ifdef FBCON_HAS_CFB16 case 16: assert(regno < 16); if (p->var.green.length == 5) { /* 0rrrrrgg gggbbbbb */ rivainfo->con_cmap.cfb16[regno] = ((red & 0xf800) >> 1) | ((green & 0xf800) >> 6) | ((blue & 0xf800) >> 11); } else { /* rrrrrggg gggbbbbb */ rivainfo->con_cmap.cfb16[regno] = ((red & 0xf800) >> 0) | ((green & 0xf800) >> 5) | ((blue & 0xf800) >> 11); } break; #endif /* FBCON_HAS_CFB16 */ #ifdef FBCON_HAS_CFB32 case 32: assert(regno < 16); rivainfo->con_cmap.cfb32[regno] = ((red & 0xff00) << 8) | ((green & 0xff00)) | ((blue & 0xff00) >> 8); break; #endif /* FBCON_HAS_CFB32 */ default: /* do nothing */ break; } return 0; } /* ------------------------------------------------------------------------- * * * framebuffer operations * * ------------------------------------------------------------------------- */ static int rivafb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info) { struct rivafb_info *rivainfo = (struct rivafb_info *)info; struct display *p; DPRINTK("ENTER\n"); assert(fix != NULL); assert(info != NULL); assert(rivainfo->drvr_name && rivainfo->drvr_name[0]); assert(rivainfo->fb_base_phys > 0); assert(rivainfo->ram_amount > 0); p = (con < 0) ? rivainfo->info.disp : &fb_display[con]; memset(fix, 0, sizeof(struct fb_fix_screeninfo)); sprintf(fix->id, "nVidia %s", rivainfo->drvr_name); fix->smem_start = rivainfo->fb_base_phys; fix->smem_len = rivainfo->ram_amount; fix->type = p->type; fix->type_aux = p->type_aux; fix->visual = p->visual; fix->xpanstep = 1; fix->ypanstep = 1; fix->ywrapstep = 0; /* FIXME: no ywrap for now */ fix->line_length = p->line_length; fix->mmio_start = rivainfo->ctrl_base_phys; fix->mmio_len = rivainfo->base0_region_size; fix->smem_start = rivainfo->fb_base_phys; fix->smem_len = rivainfo->base1_region_size; switch (rivainfo->riva.Architecture) { case NV_ARCH_03: fix->accel = FB_ACCEL_NV3; break; case NV_ARCH_04: /* riva_hw.c now doesn't distinguish between TNT & TNT2 */ fix->accel = FB_ACCEL_NV4; break; case NV_ARCH_10: /* FIXME: ID for GeForce */ fix->accel = FB_ACCEL_NV4; break; } DPRINTK("EXIT, returning 0\n"); return 0; } static int rivafb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) { struct rivafb_info *rivainfo = (struct rivafb_info *)info; DPRINTK("ENTER\n"); assert(info != NULL); assert(var != NULL); *var = (con < 0) ? rivainfo->disp.var : fb_display[con].var; DPRINTK("EXIT, returning 0\n"); return 0; } static int rivafb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) { struct rivafb_info *rivainfo = (struct rivafb_info *)info; struct display *dsp; struct fb_var_screeninfo v; int nom, den; /* translating from pixels->bytes */ int accel; unsigned chgvar = 0; DPRINTK("ENTER\n"); assert(info != NULL); assert(var != NULL); DPRINTK("Requested: %dx%dx%d\n", var->xres, var->yres, var->bits_per_pixel); DPRINTK(" virtual: %dx%d\n", var->xres_virtual, var->yres_virtual); DPRINTK(" offset: (%d,%d)\n", var->xoffset, var->yoffset); DPRINTK("grayscale: %d\n", var->grayscale); dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con]; assert(dsp != NULL); /* if var has changed, we should call changevar() later */ if (con >= 0) { chgvar = ((dsp->var.xres != var->xres) || (dsp->var.yres != var->yres) || (dsp->var.xres_virtual != var->xres_virtual) || (dsp->var.yres_virtual != var->yres_virtual) || (dsp->var.accel_flags != var->accel_flags) || (dsp->var.bits_per_pixel != var->bits_per_pixel) || memcmp(&dsp->var.red, &var->red, sizeof(var->red)) || memcmp(&dsp->var.green, &var->green, sizeof(var->green)) || memcmp(&dsp->var.blue, &var->blue, sizeof(var->blue))); } memcpy(&v, var, sizeof(v)); accel = v.accel_flags & FB_ACCELF_TEXT; switch (v.bits_per_pixel) { #ifdef FBCON_HAS_CFB8 case 1 ... 8: v.bits_per_pixel = 8; nom = 1; den = 1; v.red.offset = 0; v.red.length = 8; v.green.offset = 0; v.green.length = 8; v.blue.offset = 0; v.blue.length = 8; break; #endif #ifdef FBCON_HAS_CFB16 case 9 ... 15: v.green.length = 5; /* fall through */ case 16: v.bits_per_pixel = 16; nom = 2; den = 1; if (v.green.length == 5) { /* 0rrrrrgg gggbbbbb */ v.red.offset = 10; v.green.offset = 5; v.blue.offset = 0; v.red.length = 5; v.green.length = 5; v.blue.length = 5; } else { /* rrrrrggg gggbbbbb */ v.red.offset = 11; v.green.offset = 5; v.blue.offset = 0; v.red.length = 5; v.green.length = 6; v.blue.length = 5; } break; #endif #ifdef FBCON_HAS_CFB32 case 17 ... 32: v.bits_per_pixel = 32; nom = 4; den = 1; v.red.offset = 16; v.green.offset = 8; v.blue.offset = 0; v.red.length = 8; v.green.length = 8; v.blue.length = 8; break; #endif default: printk(KERN_ERR PFX "mode %dx%dx%d rejected...color depth not supported.\n", var->xres, var->yres, var->bits_per_pixel); DPRINTK("EXIT, returning -EINVAL\n"); return -EINVAL; } if (rivafb_do_maximize(rivainfo, var, &v, nom, den) < 0) return -EINVAL; if (v.xoffset < 0) v.xoffset = 0; if (v.yoffset < 0) v.yoffset = 0; /* truncate xoffset and yoffset to maximum if too high */ if (v.xoffset > v.xres_virtual - v.xres) v.xoffset = v.xres_virtual - v.xres - 1; if (v.yoffset > v.yres_virtual - v.yres) v.yoffset = v.yres_virtual - v.yres - 1; v.red.msb_right = v.green.msb_right = v.blue.msb_right = v.transp.offset = v.transp.length = v.transp.msb_right = 0; switch (v.activate & FB_ACTIVATE_MASK) { case FB_ACTIVATE_TEST: DPRINTK("EXIT - FB_ACTIVATE_TEST\n"); return 0; case FB_ACTIVATE_NXTOPEN: /* ?? */ case FB_ACTIVATE_NOW: break; /* continue */ default: DPRINTK("EXIT - unknown activation type\n"); return -EINVAL; /* unknown */ } memcpy(&dsp->var, &v, sizeof(v)); if (chgvar) { riva_set_dispsw(rivainfo, dsp); if (accel) { if (nomove) dsp->scrollmode = SCROLL_YNOMOVE; else dsp->scrollmode = 0; } else dsp->scrollmode = SCROLL_YREDRAW; if (info && info->changevar) info->changevar(con); } rivafb_create_cursor(rivainfo, fontwidth(dsp), fontheight(dsp)); riva_load_video_mode(rivainfo, &v); if (accel) riva_setup_accel(rivainfo); DPRINTK("EXIT, returning 0\n"); return 0; } static int rivafb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { struct rivafb_info *rivainfo = (struct rivafb_info *)info; struct display *dsp; DPRINTK("ENTER\n"); assert(rivainfo != NULL); assert(cmap != NULL); dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con]; if (con == rivainfo->currcon) { /* current console? */ int rc = fb_get_cmap(cmap, kspc, riva_getcolreg, info); DPRINTK("EXIT - returning %d\n", rc); return rc; } else if (dsp->cmap.len) /* non default colormap? */ fb_copy_cmap(&dsp->cmap, cmap, kspc ? 0 : 2); else fb_copy_cmap(fb_default_cmap (riva_get_cmap_len(&dsp->var)), cmap, kspc ? 0 : 2); DPRINTK("EXIT, returning 0\n"); return 0; } static int rivafb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) { struct rivafb_info *rivainfo = (struct rivafb_info *)info; struct display *dsp; unsigned int cmap_len; DPRINTK("ENTER\n"); assert(rivainfo != NULL); assert(cmap != NULL); dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con]; cmap_len = riva_get_cmap_len(&dsp->var); if (dsp->cmap.len != cmap_len) { int err = fb_alloc_cmap(&dsp->cmap, cmap_len, 0); if (err) { DPRINTK("EXIT - returning %d\n", err); return err; } } if (con == rivainfo->currcon) { /* current console? */ int rc = fb_set_cmap(cmap, kspc, riva_setcolreg, info); DPRINTK("EXIT - returning %d\n", rc); return rc; } else fb_copy_cmap(cmap, &dsp->cmap, kspc ? 0 : 1); DPRINTK("EXIT, returning 0\n"); return 0; } /** * rivafb_pan_display * @var: standard kernel fb changeable data * @con: TODO * @info: pointer to rivafb_info object containing info for current riva board * * DESCRIPTION: * Pan (or wrap, depending on the `vmode' field) the display using the * `xoffset' and `yoffset' fields of the `var' structure. * If the values don't fit, return -EINVAL. * * This call looks only at xoffset, yoffset and the FB_VMODE_YWRAP flag */ static int rivafb_pan_display(struct fb_var_screeninfo *var, int con, struct fb_info *info) { unsigned int base; struct display *dsp; struct rivafb_info *rivainfo = (struct rivafb_info *)info; DPRINTK("ENTER\n"); assert(rivainfo != NULL); if (var->xoffset > (var->xres_virtual - var->xres)) return -EINVAL; if (var->yoffset > (var->yres_virtual - var->yres)) return -EINVAL; dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con]; if (var->vmode & FB_VMODE_YWRAP) { if (var->yoffset < 0 || var->yoffset >= dsp->var.yres_virtual || var->xoffset) return -EINVAL; } else { if (var->xoffset + dsp->var.xres > dsp->var.xres_virtual || var->yoffset + dsp->var.yres > dsp->var.yres_virtual) return -EINVAL; } base = var->yoffset * dsp->line_length + var->xoffset; if (con == rivainfo->currcon) { rivainfo->riva.SetStartAddress(&rivainfo->riva, base); } dsp->var.xoffset = var->xoffset; dsp->var.yoffset = var->yoffset; if (var->vmode & FB_VMODE_YWRAP) dsp->var.vmode |= FB_VMODE_YWRAP; else dsp->var.vmode &= ~FB_VMODE_YWRAP; DPRINTK("EXIT, returning 0\n"); return 0; } static int rivafb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg, int con, struct fb_info *info) { struct rivafb_info *rivainfo = (struct rivafb_info *)info; DPRINTK("ENTER\n"); assert(rivainfo != NULL); /* no rivafb-specific ioctls */ DPRINTK("EXIT, returning -EINVAL\n"); return -EINVAL; } static int rivafb_rasterimg(struct fb_info *info, int start) { struct rivafb_info *rinfo = (struct rivafb_info *)info; wait_for_idle(rinfo); return 0; } static int rivafb_switch(int con, struct fb_info *info) { struct rivafb_info *rivainfo = (struct rivafb_info *)info; struct fb_cmap *cmap; struct display *dsp; DPRINTK("ENTER\n"); assert(rivainfo != NULL); dsp = (con < 0) ? rivainfo->info.disp : &fb_display[con]; if (rivainfo->currcon >= 0) { /* Do we have to save the colormap? */ cmap = &(rivainfo->currcon_display->cmap); DPRINTK("switch1: con = %d, cmap.len = %d\n", rivainfo->currcon, cmap->len); if (cmap->len) { DPRINTK("switch1a: %p %p %p %p\n", cmap->red, cmap->green, cmap->blue, cmap->transp); fb_get_cmap(cmap, 1, riva_getcolreg, info); } } rivainfo->currcon = con; rivainfo->currcon_display = dsp; rivafb_set_var(&dsp->var, con, info); riva_set_dispsw(rivainfo, dsp); DPRINTK("EXIT, returning 0\n"); return 0; } static int rivafb_updatevar(int con, struct fb_info *info) { int rc; DPRINTK("ENTER\n"); rc = (con < 0) ? -EINVAL : rivafb_pan_display(&fb_display[con].var, con, info); DPRINTK("EXIT, returning %d\n", rc); return rc; } static void rivafb_blank(int blank, struct fb_info *info) { unsigned char tmp, vesa; struct rivafb_info *rinfo = (struct rivafb_info *)info; DPRINTK("ENTER\n"); assert(rinfo != NULL); tmp = SEQin(rinfo, 0x01) & ~0x20; /* screen on/off */ vesa = CRTCin(rinfo, 0x1a) & ~0xc0; /* sync on/off */ if (blank) { tmp |= 0x20; switch (blank - 1) { case VESA_NO_BLANKING: break; case VESA_VSYNC_SUSPEND: vesa |= 0x80; break; case VESA_HSYNC_SUSPEND: vesa |= 0x40; break; case VESA_POWERDOWN: vesa |= 0xc0; break; } } SEQout(rinfo, 0x01, tmp); CRTCout(rinfo, 0x1a, vesa); DPRINTK("EXIT\n"); } /* ------------------------------------------------------------------------- * * * initialization helper functions * * ------------------------------------------------------------------------- */ /* kernel interface */ static struct fb_ops riva_fb_ops = { owner: THIS_MODULE, fb_get_fix: rivafb_get_fix, fb_get_var: rivafb_get_var, fb_set_var: rivafb_set_var, fb_get_cmap: rivafb_get_cmap, fb_set_cmap: rivafb_set_cmap, fb_pan_display: rivafb_pan_display, fb_ioctl: rivafb_ioctl, fb_rasterimg: rivafb_rasterimg, }; static int __devinit riva_init_disp_var(struct rivafb_info *rinfo) { #ifndef MODULE if (mode_option) fb_find_mode(&rinfo->disp.var, &rinfo->info, mode_option, NULL, 0, NULL, 8); #endif return 0; } static int __devinit riva_init_disp(struct rivafb_info *rinfo) { struct fb_info *info; struct display *disp; DPRINTK("ENTER\n"); assert(rinfo != NULL); info = &rinfo->info; disp = &rinfo->disp; disp->var = rivafb_default_var; if (noaccel) disp->var.accel_flags &= ~FB_ACCELF_TEXT; else disp->var.accel_flags |= FB_ACCELF_TEXT; info->disp = disp; /* FIXME: assure that disp->cmap is completely filled out */ rinfo->currcon_display = disp; if ((riva_init_disp_var(rinfo)) < 0) { DPRINTK("EXIT, returning -1\n"); return -1; } riva_set_dispsw(rinfo, disp); DPRINTK("EXIT, returning 0\n"); return 0; } static int __devinit riva_set_fbinfo(struct rivafb_info *rinfo) { struct fb_info *info; assert(rinfo != NULL); info = &rinfo->info; strcpy(info->modename, rinfo->drvr_name); info->node = -1; info->flags = FBINFO_FLAG_DEFAULT; info->fbops = &riva_fb_ops; /* FIXME: set monspecs to what??? */ info->display_fg = NULL; strncpy(info->fontname, fontname, sizeof(info->fontname)); info->fontname[sizeof(info->fontname) - 1] = 0; info->changevar = NULL; info->switch_con = rivafb_switch; info->updatevar = rivafb_updatevar; info->blank = rivafb_blank; if (riva_init_disp(rinfo) < 0) /* must be done last */ return -1; return 0; } /* ------------------------------------------------------------------------- * * * PCI bus * * ------------------------------------------------------------------------- */ static int __devinit rivafb_init_one(struct pci_dev *pd, const struct pci_device_id *ent) { struct rivafb_info *rinfo; struct riva_chip_info *rci = &riva_chip_info[ent->driver_data]; assert(pd != NULL); assert(rci != NULL); rinfo = kmalloc(sizeof(struct rivafb_info), GFP_KERNEL); if (!rinfo) goto err_out; memset(rinfo, 0, sizeof(struct rivafb_info)); rinfo->drvr_name = rci->name; rinfo->riva.Architecture = rci->arch_rev; rinfo->pd = pd; rinfo->base0_region_size = pci_resource_len(pd, 0); rinfo->base1_region_size = pci_resource_len(pd, 1); assert(rinfo->base0_region_size >= 0x00800000); /* from GGI */ assert(rinfo->base1_region_size >= 0x01000000); /* from GGI */ rinfo->ctrl_base_phys = pci_resource_start(rinfo->pd, 0); rinfo->fb_base_phys = pci_resource_start(rinfo->pd, 1); if (!request_mem_region(rinfo->ctrl_base_phys, rinfo->base0_region_size, "rivafb")) { printk(KERN_ERR PFX "cannot reserve MMIO region\n"); goto err_out_kfree; } if (!request_mem_region(rinfo->fb_base_phys, rinfo->base1_region_size, "rivafb")) { printk(KERN_ERR PFX "cannot reserve FB region\n"); goto err_out_free_base0; } rinfo->ctrl_base = ioremap(rinfo->ctrl_base_phys, rinfo->base0_region_size); if (!rinfo->ctrl_base) { printk(KERN_ERR PFX "cannot ioremap MMIO base\n"); goto err_out_free_base1; } rinfo->fb_base = ioremap(rinfo->fb_base_phys, rinfo->base1_region_size); if (!rinfo->fb_base) { printk(KERN_ERR PFX "cannot ioremap FB base\n"); goto err_out_iounmap_ctrl; } #ifdef CONFIG_MTRR if (!nomtrr) { rinfo->mtrr.vram = mtrr_add(rinfo->fb_base_phys, rinfo->base1_region_size, MTRR_TYPE_WRCOMB, 1); if (rinfo->mtrr.vram < 0) { printk(KERN_ERR PFX "unable to setup MTRR\n"); } else { rinfo->mtrr.vram_valid = 1; /* let there be speed */ printk(KERN_INFO PFX "RIVA MTRR set to ON\n"); } } #endif /* CONFIG_MTRR */ rinfo->riva.EnableIRQ = 0; rinfo->riva.PRAMDAC = (unsigned *)(rinfo->ctrl_base + 0x00680000); rinfo->riva.PFB = (unsigned *)(rinfo->ctrl_base + 0x00100000); rinfo->riva.PFIFO = (unsigned *)(rinfo->ctrl_base + 0x00002000); rinfo->riva.PGRAPH = (unsigned *)(rinfo->ctrl_base + 0x00400000); rinfo->riva.PEXTDEV = (unsigned *)(rinfo->ctrl_base + 0x00101000); rinfo->riva.PTIMER = (unsigned *)(rinfo->ctrl_base + 0x00009000); rinfo->riva.PMC = (unsigned *)(rinfo->ctrl_base + 0x00000000); rinfo->riva.FIFO = (unsigned *)(rinfo->ctrl_base + 0x00800000); rinfo->riva.PCIO = (U008 *)(rinfo->ctrl_base + 0x00601000); rinfo->riva.PDIO = (U008 *)(rinfo->ctrl_base + 0x00681000); rinfo->riva.PVIO = (U008 *)(rinfo->ctrl_base + 0x000C0000); rinfo->riva.IO = (MISCin(rinfo) & 0x01) ? 0x3D0 : 0x3B0; switch (rinfo->riva.Architecture) { case NV_ARCH_03: rinfo->riva.PRAMIN = (unsigned *)(rinfo->fb_base + 0x00C00000); break; case NV_ARCH_04: case NV_ARCH_10: rinfo->riva.PCRTC = (unsigned *)(rinfo->ctrl_base + 0x00600000); rinfo->riva.PRAMIN = (unsigned *)(rinfo->ctrl_base + 0x00710000); break; } RivaGetConfig(&rinfo->riva); /* back to normal */ assert(rinfo->pd != NULL); /* unlock io */ CRTCout(rinfo, 0x11, 0xFF); /* vgaHWunlock() + riva unlock (0x7F) */ rinfo->riva.LockUnlock(&rinfo->riva, 0); riva_save_state(rinfo, &rinfo->initial_state); rinfo->ram_amount = rinfo->riva.RamAmountKBytes * 1024; rinfo->dclk_max = rinfo->riva.MaxVClockFreqKHz * 1000; if (!nohwcursor) rinfo->cursor = rivafb_init_cursor(rinfo); if (riva_set_fbinfo(rinfo) < 0) { printk(KERN_ERR PFX "error setting initial video mode\n"); goto err_out_cursor; } if (register_framebuffer((struct fb_info *)rinfo) < 0) { printk(KERN_ERR PFX "error registering riva framebuffer\n"); goto err_out_load_state; } riva_boards = riva_board_list_add(riva_boards, rinfo); pci_set_drvdata(pd, rinfo); printk(KERN_INFO PFX "PCI nVidia NV%d framebuffer ver %s (%s, %dMB @ 0x%lX)\n", rinfo->riva.Architecture, RIVAFB_VERSION, rinfo->drvr_name, rinfo->ram_amount / (1024 * 1024), rinfo->fb_base_phys); return 0; err_out_load_state: riva_load_state(rinfo, &rinfo->initial_state); err_out_cursor: rivafb_exit_cursor(rinfo); /* err_out_iounmap_fb: */ iounmap(rinfo->fb_base); err_out_iounmap_ctrl: iounmap(rinfo->ctrl_base); err_out_free_base1: release_mem_region(rinfo->fb_base_phys, rinfo->base1_region_size); err_out_free_base0: release_mem_region(rinfo->ctrl_base_phys, rinfo->base0_region_size); err_out_kfree: kfree(rinfo); err_out: return -ENODEV; } static void __devexit rivafb_remove_one(struct pci_dev *pd) { struct rivafb_info *board = pci_get_drvdata(pd); if (!board) return; riva_boards = riva_board_list_del(riva_boards, board); riva_load_state(board, &board->initial_state); unregister_framebuffer((struct fb_info *)board); rivafb_exit_cursor(board); #ifdef CONFIG_MTRR if (board->mtrr.vram_valid) mtrr_del(board->mtrr.vram, board->fb_base_phys, board->base1_region_size); #endif /* CONFIG_MTRR */ iounmap(board->ctrl_base); iounmap(board->fb_base); release_mem_region(board->ctrl_base_phys, board->base0_region_size); release_mem_region(board->fb_base_phys, board->base1_region_size); kfree(board); pci_set_drvdata(pd, NULL); } /* ------------------------------------------------------------------------- * * * initialization * * ------------------------------------------------------------------------- */ #ifndef MODULE int __init rivafb_setup(char *options) { char *this_opt; if (!options || !*options) return 0; while (this_opt = strsep(&options, ",")) { if (!strncmp(this_opt, "font:", 5)) { char *p; int i; p = this_opt + 5; for (i = 0; i < sizeof(fontname) - 1; i++) if (!*p || *p == ' ' || *p == ',') break; memcpy(fontname, this_opt + 5, i); fontname[i] = 0; } else if (!strncmp(this_opt, "noblink", 7)) { noblink = 1; } else if (!strncmp(this_opt, "noaccel", 7)) { noaccel = 1; } else if (!strncmp(this_opt, "nomove", 6)) { nomove = 1; #ifdef CONFIG_MTRR } else if (!strncmp(this_opt, "nomtrr", 6)) { nomtrr = 1; #endif } else if (!strncmp(this_opt, "nohwcursor", 10)) { nohwcursor = 1; } else mode_option = this_opt; } return 0; } #endif /* !MODULE */ static struct pci_driver rivafb_driver = { name: "rivafb", id_table: rivafb_pci_tbl, probe: rivafb_init_one, remove: rivafb_remove_one, }; /* ------------------------------------------------------------------------- * * * modularization * * ------------------------------------------------------------------------- */ int __init rivafb_init(void) { int err; #ifdef MODULE if (font) strncpy(fontname, font, sizeof(fontname)-1); #endif err = pci_module_init(&rivafb_driver); if (err) return err; return 0; } #ifdef MODULE static void __exit rivafb_exit(void) { pci_unregister_driver(&rivafb_driver); } module_init(rivafb_init); module_exit(rivafb_exit); MODULE_PARM(font, "s"); MODULE_PARM_DESC(font, "Specifies one of the compiled-in fonts (default=none)"); MODULE_PARM(noaccel, "i"); MODULE_PARM_DESC(noaccel, "Disables hardware acceleration (0 or 1=disabled) (default=0)"); MODULE_PARM(nomove, "i"); MODULE_PARM_DESC(nomove, "Enables YSCROLL_NOMOVE (0 or 1=enabled) (default=0)"); MODULE_PARM(nohwcursor, "i"); MODULE_PARM_DESC(nohwcursor, "Disables hardware cursor (0 or 1=disabled) (default=0)"); MODULE_PARM(noblink, "i"); MODULE_PARM_DESC(noblink, "Disables hardware cursor blinking (0 or 1=disabled) (default=0)"); #ifdef CONFIG_MTRR MODULE_PARM(nomtrr, "i"); MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)"); #endif #endif /* MODULE */ MODULE_AUTHOR("Ani Joshi, maintainer"); MODULE_DESCRIPTION("Framebuffer driver for nVidia Riva 128, TNT, TNT2"); MODULE_LICENSE("GPL"); |