i810_wmark.c revision fa225cbc
1/************************************************************************** 2 3Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. 4All Rights Reserved. 5 6Permission is hereby granted, free of charge, to any person obtaining a 7copy of this software and associated documentation files (the 8"Software"), to deal in the Software without restriction, including 9without limitation the rights to use, copy, modify, merge, publish, 10distribute, sub license, and/or sell copies of the Software, and to 11permit persons to whom the Software is furnished to do so, subject to 12the following conditions: 13 14The above copyright notice and this permission notice (including the 15next paragraph) shall be included in all copies or substantial portions 16of the Software. 17 18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 22ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 26**************************************************************************/ 27 28/* 29 * Authors: 30 * Keith Whitwell <keith@tungstengraphics.com> 31 */ 32 33#ifdef HAVE_CONFIG_H 34#include "config.h" 35#endif 36 37#include "xf86.h" 38#include "i810.h" 39 40struct wm_info { 41 double freq; 42 unsigned int wm; 43}; 44 45static struct wm_info i810_wm_8_100[] = { 46 {0, 0x22003000}, 47 {25.2, 0x22003000}, 48 {28.0, 0x22003000}, 49 {31.5, 0x22003000}, 50 {36.0, 0x22007000}, 51 {40.0, 0x22007000}, 52 {45.0, 0x22007000}, 53 {49.5, 0x22008000}, 54 {50.0, 0x22008000}, 55 {56.3, 0x22008000}, 56 {65.0, 0x22008000}, 57 {75.0, 0x22008000}, 58 {78.8, 0x22008000}, 59 {80.0, 0x22008000}, 60 {94.0, 0x22008000}, 61 {96.0, 0x22107000}, 62 {99.0, 0x22107000}, 63 {108.0, 0x22107000}, 64 {121.0, 0x22107000}, 65 {128.9, 0x22107000}, 66 {132.0, 0x22109000}, 67 {135.0, 0x22109000}, 68 {157.5, 0x2210b000}, 69 {162.0, 0x2210b000}, 70 {175.5, 0x2210b000}, 71 {189.0, 0x2220e000}, 72 {202.5, 0x2220e000} 73}; 74 75static struct wm_info i810_wm_16_100[] = { 76 {0, 0x22004000}, 77 {25.2, 0x22006000}, 78 {28.0, 0x22006000}, 79 {31.5, 0x22007000}, 80 {36.0, 0x22007000}, 81 {40.0, 0x22007000}, 82 {45.0, 0x22007000}, 83 {49.5, 0x22009000}, 84 {50.0, 0x22009000}, 85 {56.3, 0x22108000}, 86 {65.0, 0x2210e000}, 87 {75.0, 0x2210e000}, 88 {78.8, 0x2210e000}, 89 {80.0, 0x22210000}, 90 {94.5, 0x22210000}, 91 {96.0, 0x22210000}, 92 {99.0, 0x22210000}, 93 {108.0, 0x22210000}, 94 {121.0, 0x22210000}, 95 {128.9, 0x22210000}, 96 {132.0, 0x22314000}, 97 {135.0, 0x22314000}, 98 {157.5, 0x22415000}, 99 {162.0, 0x22416000}, 100 {175.5, 0x22416000}, 101 {189.0, 0x22416000}, 102 {195.0, 0x22416000}, 103 {202.5, 0x22416000} 104}; 105 106static struct wm_info i810_wm_24_100[] = { 107 {0, 0x22006000}, 108 {25.2, 0x22009000}, 109 {28.0, 0x22009000}, 110 {31.5, 0x2200a000}, 111 {36.0, 0x2210c000}, 112 {40.0, 0x2210c000}, 113 {45.0, 0x2210c000}, 114 {49.5, 0x22111000}, 115 {50.0, 0x22111000}, 116 {56.3, 0x22111000}, 117 {65.0, 0x22214000}, 118 {75.0, 0x22214000}, 119 {78.8, 0x22215000}, 120 {80.0, 0x22216000}, 121 {94.5, 0x22218000}, 122 {96.0, 0x22418000}, 123 {99.0, 0x22418000}, 124 {108.0, 0x22418000}, 125 {121.0, 0x22418000}, 126 {128.9, 0x22419000}, 127 {132.0, 0x22519000}, 128 {135.0, 0x4441d000}, 129 {157.5, 0x44419000}, 130 {162.0, 0x44419000}, 131 {175.5, 0x44419000}, 132 {189.0, 0x44419000}, 133 {195.0, 0x44419000}, 134 {202.5, 0x44419000} 135}; 136 137#if 0 138/* not used */ 139static struct wm_info i810_wm_32_100[] = { 140 {0, 0x2210b000}, 141 {60, 0x22415000}, /* 0x314000 works too */ 142 {80, 0x22419000} /* 0x518000 works too */ 143}; 144#endif 145 146static struct wm_info i810_wm_8_133[] = { 147 {0, 0x22003000}, 148 {25.2, 0x22003000}, 149 {28.0, 0x22003000}, 150 {31.5, 0x22003000}, 151 {36.0, 0x22007000}, 152 {40.0, 0x22007000}, 153 {45.0, 0x22007000}, 154 {49.5, 0x22008000}, 155 {50.0, 0x22008000}, 156 {56.3, 0x22008000}, 157 {65.0, 0x22008000}, 158 {75.0, 0x22008000}, 159 {78.8, 0x22008000}, 160 {80.0, 0x22008000}, 161 {94.0, 0x22008000}, 162 {96.0, 0x22107000}, 163 {99.0, 0x22107000}, 164 {108.0, 0x22107000}, 165 {121.0, 0x22107000}, 166 {128.9, 0x22107000}, 167 {132.0, 0x22109000}, 168 {135.0, 0x22109000}, 169 {157.5, 0x2210b000}, 170 {162.0, 0x2210b000}, 171 {175.5, 0x2210b000}, 172 {189.0, 0x2220e000}, 173 {202.5, 0x2220e000} 174}; 175 176static struct wm_info i810_wm_16_133[] = { 177 {0, 0x22004000}, 178 {25.2, 0x22006000}, 179 {28.0, 0x22006000}, 180 {31.5, 0x22007000}, 181 {36.0, 0x22007000}, 182 {40.0, 0x22007000}, 183 {45.0, 0x22007000}, 184 {49.5, 0x22009000}, 185 {50.0, 0x22009000}, 186 {56.3, 0x22108000}, 187 {65.0, 0x2210e000}, 188 {75.0, 0x2210e000}, 189 {78.8, 0x2210e000}, 190 {80.0, 0x22210000}, 191 {94.5, 0x22210000}, 192 {96.0, 0x22210000}, 193 {99.0, 0x22210000}, 194 {108.0, 0x22210000}, 195 {121.0, 0x22210000}, 196 {128.9, 0x22210000}, 197 {132.0, 0x22314000}, 198 {135.0, 0x22314000}, 199 {157.5, 0x22415000}, 200 {162.0, 0x22416000}, 201 {175.5, 0x22416000}, 202 {189.0, 0x22416000}, 203 {195.0, 0x22416000}, 204 {202.5, 0x22416000} 205}; 206 207static struct wm_info i810_wm_24_133[] = { 208 {0, 0x22006000}, 209 {25.2, 0x22009000}, 210 {28.0, 0x22009000}, 211 {31.5, 0x2200a000}, 212 {36.0, 0x2210c000}, 213 {40.0, 0x2210c000}, 214 {45.0, 0x2210c000}, 215 {49.5, 0x22111000}, 216 {50.0, 0x22111000}, 217 {56.3, 0x22111000}, 218 {65.0, 0x22214000}, 219 {75.0, 0x22214000}, 220 {78.8, 0x22215000}, 221 {80.0, 0x22216000}, 222 {94.5, 0x22218000}, 223 {96.0, 0x22418000}, 224 {99.0, 0x22418000}, 225 {108.0, 0x22418000}, 226 {121.0, 0x22418000}, 227 {128.9, 0x22419000}, 228 {132.0, 0x22519000}, 229 {135.0, 0x4441d000}, 230 {157.5, 0x44419000}, 231 {162.0, 0x44419000}, 232 {175.5, 0x44419000}, 233 {189.0, 0x44419000}, 234 {195.0, 0x44419000}, 235 {202.5, 0x44419000} 236}; 237 238#define Elements(x) (sizeof(x)/sizeof(*x)) 239 240/* 241 * I810CalcFIFO -- 242 * 243 * Calculate burst length and FIFO watermark. 244 */ 245 246unsigned int 247I810CalcWatermark(ScrnInfoPtr pScrn, double freq, Bool dcache) 248{ 249 I810Ptr pI810 = I810PTR(pScrn); 250 struct wm_info *tab; 251 int nr; 252 int i; 253 254 if (pI810->LmFreqSel == 100) { 255 switch (pScrn->bitsPerPixel) { 256 case 8: 257 tab = i810_wm_8_100; 258 nr = Elements(i810_wm_8_100); 259 break; 260 case 16: 261 tab = i810_wm_16_100; 262 nr = Elements(i810_wm_16_100); 263 break; 264 case 24: 265 tab = i810_wm_24_100; 266 nr = Elements(i810_wm_24_100); 267 break; 268 default: 269 return 0; 270 } 271 } else { 272 switch (pScrn->bitsPerPixel) { 273 case 8: 274 tab = i810_wm_8_133; 275 nr = Elements(i810_wm_8_133); 276 break; 277 case 16: 278 tab = i810_wm_16_133; 279 nr = Elements(i810_wm_16_133); 280 break; 281 case 24: 282 tab = i810_wm_24_133; 283 nr = Elements(i810_wm_24_133); 284 break; 285 default: 286 return 0; 287 } 288 } 289 290 for (i = 0; i < nr && tab[i].freq < freq; i++) ; 291 292 if (i == nr) 293 i--; 294 295 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, 296 "chose watermark 0x%x: (tab.freq %.1f)\n", 297 tab[i].wm, tab[i].freq); 298 299 /* None of these values (sourced from intel) have watermarks for 300 * the dcache memory. Fake it for now by using the same watermark 301 * for both... 302 * 303 * Update: this is probably because dcache isn't real useful as 304 * framebuffer memory, so intel's drivers don't need watermarks 305 * for that memory because they never use it to feed the ramdacs. 306 * We do use it in the fallback mode, so keep the watermarks for 307 * now. 308 */ 309 if (dcache) 310 return (tab[i].wm & ~0xffffff) | ((tab[i].wm >> 12) & 0xfff); 311 else 312 return tab[i].wm; 313} 314