1 /* 2 Copyright (c) 2002, Thomas Kurschel 3 4 5 Part of Radeon kernel driver 6 7 AGP fix. Some motherboard BIOSes enable FastWrite even 8 though the graphics card doesn't support it. Here, we'll 9 fix that (hopefully it is generic enough). 10 11 updated to use AGP_BUS mananager 12 */ 13 14 15 #include "radeon_driver.h" 16 17 static void agp_list_info(agp_info ai); 18 static void agp_list_active(uint32 cmd); 19 20 // fix invalid AGP settings 21 void Radeon_Set_AGP( device_info *di, bool enable_agp ) 22 { 23 uint8 agp_index = 0; 24 agp_info nth_agp_info; 25 bool found = false; 26 uint32 agp_cmd; 27 28 /* abort if no agp busmanager found */ 29 if (!agp_bus) 30 { 31 SHOW_INFO0(1, "Busmanager not installed.\nWarning Card May hang if AGP Fastwrites are Enabled." ); 32 return; 33 } 34 35 /* contact driver and get a pointer to the registers and shared data */ 36 /* get nth AGP device info */ 37 while((*agp_bus->get_nth_agp_info)(agp_index, &nth_agp_info) == B_NO_ERROR) { 38 39 /* see if we are this one */ 40 if ((nth_agp_info.device_id == di->pcii.device_id) && 41 (nth_agp_info.vendor_id == di->pcii.vendor_id) && 42 (nth_agp_info.bus == di->pcii.bus) && 43 (nth_agp_info.device == di->pcii.device) && 44 (nth_agp_info.function == di->pcii.function)) 45 { 46 SHOW_INFO0(1, "Found AGP capable device" ); 47 found = true; 48 49 /* remember our info */ 50 di->agpi = nth_agp_info; 51 52 /* log capabilities */ 53 agp_list_info(nth_agp_info); 54 55 break; 56 57 } 58 59 agp_index++; 60 } 61 62 if (!found) { 63 if (agp_index != 0) { 64 SHOW_INFO0(1, "End of AGP capable devices list."); 65 } else { 66 SHOW_INFO0(1, "No AGP capable devices found."); 67 } 68 return; 69 } 70 71 if (di->settings.force_pci | !enable_agp) { 72 73 SHOW_INFO0(1, "Disabling AGP mode..."); 74 75 /* we want zero agp features enabled */ 76 agp_cmd = 0; 77 78 /* write the stuff */ 79 (*agp_bus->enable_agp)(&agp_cmd); 80 } else { 81 /* activate AGP mode */ 82 SHOW_INFO0(1, "Activating AGP mode..."); 83 agp_cmd = 0xfffffff7; 84 85 /* set agp 3 speed bit is agp is v3 */ 86 if (nth_agp_info.interface.agp_stat & AGP_rate_rev) agp_cmd |= AGP_rate_rev; 87 88 /* we want to perma disable fastwrites as they're evil, evil i say */ 89 agp_cmd &= ~AGP_FW; 90 91 /* write the stuff */ 92 (*agp_bus->enable_agp)(&agp_cmd); 93 } 94 95 /* list mode now activated, 96 * make sure we have the correct speed scheme for logging */ 97 agp_list_active(nth_agp_info.interface.agp_cmd | 98 (nth_agp_info.interface.agp_stat & AGP_rate_rev)); 99 100 } 101 102 static void agp_list_info(agp_info ai) 103 { 104 /* 105 list device 106 */ 107 if (ai.class_base == PCI_display) { 108 SHOW_INFO(4, "Device is a graphics card, subclass ID is $%02x", ai.class_sub); 109 } else { 110 SHOW_INFO(4, "Device is a hostbridge, subclass ID is $%02x", ai.class_sub); 111 } 112 113 SHOW_INFO(4, "Vendor ID $%04x", ai.vendor_id); 114 SHOW_INFO(4, "Device ID $%04x", ai.device_id); 115 SHOW_INFO(4, "Bus %d, device %d, function %d", ai.bus, ai.device, ai.function); 116 117 /* 118 list capabilities 119 */ 120 SHOW_INFO(4, "This device supports AGP specification %ld.%ld;", 121 ((ai.interface.agp_cap_id & AGP_rev_major) >> AGP_rev_major_shift), 122 ((ai.interface.agp_cap_id & AGP_rev_minor) >> AGP_rev_minor_shift)); 123 124 /* the AGP devices determine AGP speed scheme version used on power-up/reset */ 125 if (!(ai.interface.agp_stat & AGP_rate_rev)) 126 { 127 /* AGP 2.0 scheme applies */ 128 if (ai.interface.agp_stat & AGP_2_1x) 129 SHOW_INFO0(4, "AGP 2.0 1x mode is available"); 130 if (ai.interface.agp_stat & AGP_2_2x) 131 SHOW_INFO0(4, "AGP 2.0 2x mode is available"); 132 if (ai.interface.agp_stat & AGP_2_4x) 133 SHOW_INFO0(41, "AGP 2.0 4x mode is available"); 134 } 135 else 136 { 137 /* AGP 3.0 scheme applies */ 138 if (ai.interface.agp_stat & AGP_3_4x) 139 SHOW_INFO0(4, "AGP 3.0 4x mode is available"); 140 if (ai.interface.agp_stat & AGP_3_8x) 141 SHOW_INFO0(4, "AGP 3.0 8x mode is available"); 142 } 143 144 if (ai.interface.agp_stat & AGP_FW) SHOW_INFO0(4, "Fastwrite transfers are supported"); 145 if (ai.interface.agp_stat & AGP_SBA) SHOW_INFO0(4, "Sideband adressing is supported"); 146 147 SHOW_INFO(1, "%ld queued AGP requests can be handled.", 148 ((ai.interface.agp_stat & AGP_RQ) >> AGP_RQ_shift) + 1); 149 150 /* 151 list current settings, 152 make sure we have the correct speed scheme for logging 153 */ 154 agp_list_active(ai.interface.agp_cmd | (ai.interface.agp_stat & AGP_rate_rev)); 155 } 156 157 static void agp_list_active(uint32 cmd) 158 { 159 SHOW_INFO0(4, "listing settings now in use:"); 160 if (!(cmd & AGP_rate_rev)) { 161 /* AGP 2.0 scheme applies */ 162 if (cmd & AGP_2_1x) 163 SHOW_INFO0(2,"AGP 2.0 1x mode is set"); 164 if (cmd & AGP_2_2x) 165 SHOW_INFO0(2,"AGP 2.0 2x mode is set"); 166 if (cmd & AGP_2_4x) 167 SHOW_INFO0(2,"AGP 2.0 4x mode is set"); 168 } else { 169 /* AGP 3.0 scheme applies */ 170 if (cmd & AGP_3_4x) 171 SHOW_INFO0(2,"AGP 3.0 4x mode is set"); 172 if (cmd & AGP_3_8x) 173 SHOW_INFO0(2,"AGP 3.0 8x mode is set"); 174 } 175 176 if (cmd & AGP_FW) { 177 SHOW_INFO0(2, "Fastwrite transfers are enabled"); 178 } else { 179 SHOW_INFO0(2, "Fastwrite transfers are disabled"); 180 } 181 if (cmd & AGP_SBA) SHOW_INFO0(4, "Sideband adressing is enabled"); 182 183 SHOW_INFO(4, "Max. AGP queued request depth is set to %ld", 184 (((cmd & AGP_RQ) >> AGP_RQ_shift) + 1)); 185 186 if (cmd & AGP_enable) 187 SHOW_INFO0(2, "The AGP interface is enabled."); 188 else 189 SHOW_INFO0(2, "The AGP interface is disabled."); 190 } 191