source: trunk/src/opengl/glide/cvg/init/info.c

Last change on this file was 6653, checked in by bird, 24 years ago

Added $Id:$ keyword.

File size: 21.8 KB
Line 
1/* $Id: info.c,v 1.2 2001-09-05 14:30:37 bird Exp $ */
2/*
3** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
4** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
5** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
6** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
7** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
8** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
9** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
10** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
11**
12** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
13** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
14** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
15** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
16** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
17** THE UNITED STATES.
18**
19** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
20**
21**
22** $Revision: 1.2 $
23** $Date: 2001-09-05 14:30:37 $
24**
25** Routines to detect memory size, strapping pin, and other initialization
26** configuration information.
27**
28*/
29#pragma optimize ("",off)
30#include <stdio.h>
31#include <stdlib.h>
32#ifdef BUILD_FOR_SST1
33#include <sst.h>
34#else
35#include <3dfx.h>
36#include <cvgregs.h>
37#include <cvgdefs.h>
38#endif
39#define FX_DLL_DEFINITION
40#include <fxdll.h>
41#include <sst1vid.h>
42#include <sst1init.h>
43
44#define XY_ONE (1<<SST_XY_FRACBITS)
45
46static FxBool
47readAndSum4x4(FxU32 *sstbase, FxU32 x, FxU32 y,
48 FxU32 *r_sum, FxU32 *g_sum, FxU32 *b_sum)
49{
50 FxU32 rd_x, rd_y;
51 FxU32 rd_col;
52 FxU32 rd_r, rd_g, rd_b;
53 SstRegs *sst = (SstRegs *) sstbase;
54
55 /* wait for idle board */
56 ISET(sst->lfbMode, SST_LFB_RGBALANES_ARGB | SST_LFB_READFRONTBUFFER);
57 sst1InitIdle(sstbase);
58 if (x & 1) {
59 INIT_PRINTF(("ERROR: readAndSum4x4 must have an even X (%d)\n", x));
60 return(FXFALSE);
61 }
62
63 /* get 16 pixels (4 x 4 array) from frame buffer and sum the colors */
64 *r_sum = 0;
65 *g_sum = 0;
66 *b_sum = 0;
67
68 for (rd_y = 0; rd_y < 4; rd_y++) { /* read 4 scanlines */
69 for (rd_x = 0; rd_x < 4; rd_x ++) {
70 if ((rd_x & 1)==0) { /* read 2 pixels at a time */
71 rd_col =
72 IGET(sstbase[(SST_LFB_ADDR + (y+rd_y)*2048 + (x+rd_x)*2) >> 2]);
73 }
74 else rd_col >>= 16;
75 rd_r = ((rd_col >> 11) & 0x1f) << 3;
76 rd_g = ((rd_col >> 5) & 0x3f) << 2;
77 rd_b = ((rd_col >> 0) & 0x1f) << 3;
78 *r_sum += rd_r;
79 *g_sum += rd_g;
80 *b_sum += rd_b;
81 INIT_INFO((4,"%d,%d = rd_col: 0x%04x rgb: %02x %02x %02x\n",
82 rd_x, rd_y, (rd_col & 0xffff), rd_r, rd_g, rd_b));
83 }
84 }
85 INIT_INFO((3,"sums: r_sum=0x%03x g_sum=0x%03x b_sum=0x%03x\n",
86 *r_sum, *g_sum, *b_sum));
87 return(FXTRUE);
88}
89
90/* xxx - Give these guys some meaningful comments */
91static FxI32 rb_tbl[0xFFF+1];
92static FxI32 g_tbl[0xFFF+1];
93
94/* draw a right angle triangle */
95static void
96drawTriangle(SstRegs *sst, int x, int y, int tSize)
97{
98 ISET(sst->vA.x,x);
99 ISET(sst->vA.y,y);
100 ISET(sst->vB.x,x+XY_ONE*tSize);
101 ISET(sst->vB.y,y);
102 ISET(sst->vC.x,x);
103 ISET(sst->vC.y,y+XY_ONE*tSize);
104 ISET(sst->s,0);
105 ISET(sst->t,0);
106 ISET(sst->w,0);
107 ISET(sst->dsdx,1<<SST_ST_FRACBITS);
108 ISET(sst->dtdx,0);
109 ISET(sst->dwdx,0);
110 ISET(sst->dsdy,0);
111 ISET(sst->dtdy,1<<SST_ST_FRACBITS);
112 ISET(sst->dwdy,0);
113 ISET(sst->triangleCMD,0);
114}
115
116static FxBool
117initSumTables(FxU32 *sstbase)
118{
119 int x=0,y=0;
120 FxU32 tst_color;
121 FxU32 r_sum, g_sum, b_sum;
122 SstRegs *sst = (SstRegs *) sstbase;
123
124 /* init sum array */
125 for (r_sum = 0; r_sum <= 0xfff; r_sum++) {
126 rb_tbl[r_sum] = -1;
127 g_tbl[r_sum] = -1;
128 }
129
130 ISET(sst->fbzColorPath, SST_RGBSEL_C1 | SST_CC_PASS);
131 ISET(sst->fbzMode, SST_DRAWBUFFER_FRONT | SST_RGBWRMASK | SST_ENDITHER);
132
133 /* fill sum array */
134 for (tst_color = 0; tst_color <= 255; tst_color++) {
135 INIT_INFO((2,"tst_color=0x%02x\n", tst_color));
136 ISET(sst->c1, (tst_color << 16) | (tst_color << 8) | tst_color);
137
138 drawTriangle(sst, x,y,36);
139 if(readAndSum4x4(sstbase, x,y, &r_sum,&g_sum,&b_sum) == FXFALSE)
140 return(FXFALSE);
141
142 /* check sums for uniqueness and then store away */
143 if (r_sum != b_sum) {
144 INIT_PRINTF(("ERROR: b_sum=0x%03x r_sum=0x%03x\n", r_sum, b_sum));
145 return(FXFALSE);
146 }
147 if (rb_tbl[r_sum] != -1) {
148 INIT_PRINTF(("ERROR: non-unique r/b_sum=0x%03x\n", r_sum));
149 return(FXFALSE);
150 }
151 rb_tbl[r_sum] = tst_color;
152 if (g_tbl[g_sum] != -1) {
153 INIT_PRINTF(("ERROR: non-unique g_sum=0x%03x\n", g_sum));
154 return(FXFALSE);
155 }
156 g_tbl[g_sum] = tst_color;
157 }
158 return(FXTRUE);
159}
160
161/* remove dither to derive actual 24-bit RGB value */
162static FxBool
163unDither(FxU32 r_sum, FxU32 g_sum, FxU32 b_sum, FxU32 *result)
164{
165 if (rb_tbl[r_sum] == -1 || g_tbl[g_sum] == -1 || rb_tbl[b_sum] == -1)
166 {
167 INIT_PRINTF(("ERROR: unDither: invalid color sum\n"));
168 return(FXFALSE);
169 }
170 *result = (rb_tbl[r_sum] << 16) | (g_tbl[g_sum] << 8) | rb_tbl[b_sum];
171 return(FXTRUE);
172}
173
174static FxBool
175getTmuConfigData(FxU32 *sstbase, sst1DeviceInfoStruct *info)
176{
177 int x=0, y=0;
178 FxU32 r_sum, g_sum, b_sum;
179 SstRegs *sst = (SstRegs *) sstbase;
180 FxU32 tmuRevision;
181
182 /* set trex's (all 3) to output configuration bits */
183 ISET(SST_TREX(sst,0)->trexInit1, info->tmuInit1[0] | (1 << 18));
184 ISET(SST_TREX(sst,1)->trexInit1, info->tmuInit1[1] | (1 << 18));
185 ISET(SST_TREX(sst,2)->trexInit1, info->tmuInit1[2] | (1 << 18));
186
187 /* render into the frame buffer */
188 ISET(sst->fbzColorPath,
189 SST_RGBSEL_TREXOUT | SST_CC_PASS | SST_ENTEXTUREMAP);
190 ISET(sst->texBaseAddr, 0);
191 ISET(sst->textureMode, SST_AI88 | SST_TC_PASS | SST_TCA_PASS);
192 ISET(sst->tLOD, 0);
193 drawTriangle(sst,x,y,36);
194
195 readAndSum4x4(sstbase, x,y, &r_sum,&g_sum,&b_sum);
196 if(GETENV(("SSTV2_TEXMAP_DISABLE"))) {
197 info->tmuConfig = 0x0;
198 } else {
199 if(unDither(r_sum,g_sum,b_sum,&info->tmuConfig) == FXFALSE)
200 return(FXFALSE);
201 }
202
203 /////////////////////////
204 // Get new revision...
205 /////////////////////////
206 ISET(SST_TREX(sst,0)->trexInit1, info->tmuInit1[0] | (1 << 18) |
207 (5 << SST_TEX_SEND_CONFIG_SEL_SHIFT));
208 ISET(SST_TREX(sst,1)->trexInit1, info->tmuInit1[1] | (1 << 18));
209 ISET(SST_TREX(sst,2)->trexInit1, info->tmuInit1[2] | (1 << 18));
210
211 /* render into the frame buffer */
212 ISET(sst->fbzColorPath,
213 SST_RGBSEL_TREXOUT | SST_CC_PASS | SST_ENTEXTUREMAP);
214 ISET(sst->texBaseAddr, 0);
215 ISET(sst->textureMode, SST_AI88 | SST_TC_PASS | SST_TCA_PASS);
216 ISET(sst->tLOD, 0);
217 drawTriangle(sst,x,y,36);
218
219 readAndSum4x4(sstbase, x,y, &r_sum,&g_sum,&b_sum);
220 if(unDither(r_sum,g_sum,b_sum,&tmuRevision) == FXFALSE)
221 return(FXFALSE);
222
223 info->tmuFab[0] = (tmuRevision >> 4) & 0xf;
224 info->tmuFab[1] = (tmuRevision >> 12) & 0xf;
225 info->tmuFab[2] = (tmuRevision >> 20) & 0xf;
226
227 /* Adjust configuration structure for "new" revision ID */
228 info->tmuConfig &= ~(0x7 | (0x7<<7) | (0x7<<14));
229 info->tmuConfig |= (((tmuRevision & 0x7) + 3) |
230 ((((tmuRevision >> 8) & 0x7) + 3) << 7) |
231 ((((tmuRevision >> 16) & 0x7) + 3) << 14));
232
233 /* reset trex's init registers */
234 ISET(SST_TREX(sst,0)->trexInit1, info->tmuInit1[0]);
235 ISET(SST_TREX(sst,1)->trexInit1, info->tmuInit1[1]);
236 ISET(SST_TREX(sst,2)->trexInit1, info->tmuInit1[2]);
237
238 if(GETENV(("SSTV2_TMUCFG")))
239 SSCANF(GETENV(("SSTV2_TMUCFG")), "%i", &info->tmuConfig);
240
241 return(FXTRUE);
242}
243
244#define SENSE2 0x92F56EB0
245#define SENSE1 0xF2A916B5
246#define SENSE0 0xBADBEEF1
247
248static FxU32 sense(FxU32 *sstbase, sst1DeviceInfoStruct *info, FxU32 tmu,
249 FxU32 mem, FxU32 init)
250{
251 SstRegs *sst = (SstRegs *) sstbase;
252 FxU32 *texAddr = (tmu<<(21-2)) + (FxU32 *)SST_TEX_ADDRESS(sst);
253
254 /* set the Init0 register to enable ? MBytes of memory */
255 sst1InitIdle(sstbase);
256 ISET(SST_TREX(sst,tmu)->trexInit0, init | (info->tmuInit0[tmu] & ~0x7000));
257 sst1InitIdle(sstbase);
258
259 ISET(sst->texBaseAddr, 0x200000>>3); /* set to 2 MB */
260 ISET(texAddr[0], SENSE2); /* write a random value */
261
262 ISET(sst->texBaseAddr, 0x100000>>3); /* set to 1 MB */
263 ISET(texAddr[0], SENSE1); /* write a random value */
264
265 ISET(sst->texBaseAddr, 0x000000>>3); /* set to 0 MB */
266 ISET(texAddr[0], SENSE0); /* write a random value */
267
268 ISET(sst->texBaseAddr, mem>>3); /* reset to 2 MB */
269 drawTriangle(sst,0,0,4); /* draw a 4x4 right triangle */
270 sst1InitIdle(sstbase);
271
272 mem = IGET(sstbase[SST_LFB_ADDR>>2]);
273 INIT_INFO((2,"data=0x%08x\n", mem));
274
275 /* reset the Init0 register back to its previous value */
276 sst1InitIdle(sstbase);
277 ISET(SST_TREX(sst,tmu)->trexInit0, info->tmuInit0[tmu]);
278 sst1InitIdle(sstbase);
279 return mem;
280}
281
282FX_EXPORT FxBool FX_CSTYLE
283sst1InitGetTmuMemory(FxU32 *sstbase, sst1DeviceInfoStruct *info, FxU32 tmu,
284 FxU32 *TmuMemorySize)
285{
286 FxU32 i,data;
287 SstRegs *sst = (SstRegs *) sstbase;
288
289 INIT_INFO((1,"sst1InitGetTmuMemory(0x%x, , %d)\n", sstbase,tmu));
290
291 if(GETENV(("SSTV2_TMU_MEMSIZE"))) {
292 *TmuMemorySize = ATOI(GETENV(("SSTV2_TMU_MEMSIZE")));
293 // If user specifies 2 MBytes on a 4 MBytes board, disable the
294 // second RAS so that apps which may incorrectly store data in the
295 // upper 2 Mbytes will not function properly...
296 if(*TmuMemorySize == 2) {
297 info->tmuInit0[tmu] &= ~SST_EN_TEX_MEM_SECOND_RAS;
298 sst1InitIdle(sstbase);
299 ISET(SST_TREX(sst,tmu)->trexInit0, info->tmuInit0[tmu]);
300 sst1InitIdle(sstbase);
301 }
302 return(FXTRUE);
303 }
304
305 ISET(sst->lfbMode, SST_LFB_RGBALANES_ARGB | SST_LFB_READFRONTBUFFER);
306 ISET(sst->fbzMode, SST_DRAWBUFFER_FRONT | SST_RGBWRMASK);
307 ISET(sst->fbzColorPath,
308 SST_RGBSEL_TREXOUT | SST_CC_PASS | SST_ENTEXTUREMAP);
309 ISET(sst->textureMode, SST_RGB565 | SST_TC_REPLACE | SST_TCA_REPLACE);
310 ISET(sst->tLOD, 0);
311
312 /* setup all downstream TMUs to be in pass-thru mode */
313 for (i=0; i<tmu; i++)
314 ISET(SST_TREX(sst,i)->textureMode, SST_TC_PASS | SST_TCA_PASS);
315
316 /* first see if we have 4 Mbytes by writing a texel at 2MB followed by
317 a texel at 1MB and 0MB and then rendering using the texel at 2MB
318 if we have less memory it should not render correctly since we trash
319 the memory locations it would wrap to
320 */
321
322 data = sense(sstbase,info,tmu,0x200000, 0x5000);
323 if (data == SENSE2) {*TmuMemorySize = 4; return(FXTRUE);}
324
325 /* set the Init0 register to enable 2 MBytes of memory and repeat test */
326 data = sense(sstbase,info,tmu,0x100000, 0x2000);
327 if (data == SENSE1) {*TmuMemorySize = 2; return(FXTRUE);}
328
329 /* set the Init0 register to enable 1 MBytes of memory and repeat test */
330 data = sense(sstbase,info,tmu,0x000000, 0x2000);
331 if (data == SENSE0) {*TmuMemorySize = 1; return(FXTRUE);}
332
333 INIT_PRINTF(("sst1InitGetTmuMemory() ERROR: Could not detect memory size.\n"));
334 return(FXFALSE);
335}
336
337/*---------------------------------------------------------------------------
338 NOTES:
339 assumes that board and registers are initialized
340 destroys part of the framebuffer
341 ---------------------------------------------------------------------------*/
342FX_EXPORT FxBool FX_CSTYLE
343sst1InitGetTmuInfo(FxU32 *sstbase, sst1DeviceInfoStruct *info)
344{
345 FxU32 trev;
346
347 if(initSumTables(sstbase) == FXFALSE)
348 return(FXFALSE);
349 if(getTmuConfigData(sstbase,info) == FXFALSE)
350 return(FXFALSE);
351
352 info->numberTmus = 1;
353 if(GETENV(("SSTV2_TEXMAP_DISABLE"))) {
354 info->tmuRevision = 4;
355 sst1InitGetTmuMemory(sstbase, info, 0, &info->tmuMemSize[0]);
356 info->tmuMemSize[0] = 2;
357 } else {
358 /* Get TMU memory size */
359 info->tmuRevision = info->tmuConfig & 0x7;
360 if(sst1InitGetTmuMemory(sstbase, info, 0, &info->tmuMemSize[0]) ==
361 FXFALSE)
362 return(FXFALSE);
363 }
364
365 INIT_INFO((1,"TMU0 memory = %d MB\n", info->tmuMemSize[0]));
366 if (info->tmuConfig & FXBIT(6)) { /* if TMU 1 exists */
367 info->numberTmus++; /* increment TMU count */
368 trev = (info->tmuConfig>>7) & 0x7; /* get its revision */
369#if 0 // Ignore for now...
370 if (info->tmuRevision != trev) {
371 INIT_PRINTF(("sst1InitGetDeviceInfo: ERROR, multiple different TMU revision IDs detected\n"));
372 return(FXFALSE);
373 }
374#endif
375 if(sst1InitGetTmuMemory(sstbase, info, 1, &info->tmuMemSize[1]) == FXFALSE)
376 return(FXFALSE);
377 }
378 if (info->tmuConfig & FXBIT(13)) { /* if TMU 2 exists */
379 info->numberTmus++; /* increment TMU count */
380 trev = (info->tmuConfig>>14) & 0x7; /* get its revision */
381#if 0 // Ignore for now...
382 if (info->tmuRevision != trev) {
383 INIT_PRINTF(("sst1InitGetDeviceInfo: ERROR, multiple different TMU revision IDs detected\n"));
384 return(FXFALSE);
385 }
386#endif
387 if(sst1InitGetTmuMemory(sstbase, info, 2, &info->tmuMemSize[2]) == FXFALSE)
388 return(FXFALSE);
389 }
390 if(GETENV(("SSTV2_NUM_TMUS")))
391 info->numberTmus = ATOI(GETENV(("SSTV2_NUM_TMUS")));
392
393 INIT_INFO((1,"numberTMus = %d\n", info->numberTmus));
394 return(FXTRUE);
395}
396
397/*
398** fbiMemSize():
399** Returns size (in MBytes) of FBI frame buffer memory
400** Returns 0 on error
401** NOTE: fbiMemSize() destroys the contents in memory
402**
403*/
404#define LFB_PUTPIXEL(X, Y, DATA) \
405 ISET(lfbptr[((SST_LFB_ADDR+(X<<1)+(Y<<11))>>1)], DATA)
406#define LFB_GETPIXEL(X, Y) \
407 IGET(lfbptr[((SST_LFB_ADDR+(X<<1)+(Y<<11))>>1)])
408
409static int fbiMemSize(FxU32 *sstbase)
410{
411 SstRegs *sst = (SstRegs *) sstbase;
412 volatile unsigned short *lfbptr = (unsigned short *) sstbase;
413 FxU32 init0Save = IGET(sst->fbiInit0);
414 FxU32 init1Save = IGET(sst->fbiInit1);
415 FxU32 init2Save = IGET(sst->fbiInit2);
416 int retval = 0;
417
418 if(GETENV(("SSTV2_FBI_MEMSIZE")))
419 return(ATOI(GETENV(("SSTV2_FBI_MEMSIZE"))));
420
421 /* Enable dram refresh, disable memory fifo, and setup memory */
422 /* for rendering */
423 ISET(sst->fbiInit0, IGET(sst->fbiInit0) & ~SST_MEM_FIFO_EN);
424 ISET(sst->fbiInit2, IGET(sst->fbiInit2) | SST_EN_DRAM_REFRESH);
425 sst1InitIdleFBI(sstbase);
426
427 /* Setup Basic rendering datapath */
428 ISET(sst->fbzColorPath, SST_CC_MONE);
429 ISET(sst->fogMode, 0x0);
430 ISET(sst->fbzMode, SST_RGBWRMASK | SST_ZAWRMASK | SST_DRAWBUFFER_FRONT);
431 sst1InitIdleFBI(sstbase);
432
433 sst1InitSetResolution(sstbase, &SST_VREZ_800X600_60, 1);
434 sst1InitIdleFBI(sstbase);
435
436 ISET(sst->lfbMode, SST_LFB_ZZ | SST_LFB_WRITEFRONTBUFFER |
437 SST_LFB_READDEPTHABUFFER);
438 sst1InitIdleFBI(sstbase);
439
440 /* Check for 4 MBytes... */
441 /* Write to Zbuffer in 800x600 resolution in upper 2 MBytes of memory */
442 LFB_PUTPIXEL(128, 100, 0xdead); /* maps to row:0x216, col:0x80, bank:0x1 */
443 LFB_PUTPIXEL(0, 0, 0x0);
444 LFB_PUTPIXEL(798, 599, 0xffff);
445 LFB_PUTPIXEL(200, 200, 0x55aa); /* maps to row:0x23d, col:0x104, bank:0x0 */
446 LFB_PUTPIXEL(20, 20, 0xffff);
447 LFB_PUTPIXEL(400, 400, 0x0);
448 sst1InitIdleFBI(sstbase);
449 if((LFB_GETPIXEL(128, 100) == 0xdead) &&
450 (LFB_GETPIXEL(200, 200) == 0x55aa)) {
451 retval = 4;
452 ISET(sst->lfbMode, (SST_LFB_565 | SST_LFB_READBACKBUFFER));
453 sst1InitIdleFBI(sstbase);
454 goto fbiMemSizeDone;
455 }
456
457 /* Check for 2 MBytes... */
458 /* Write to color buffer in 640x480 resolution */
459 sst1InitSetResolution(sstbase, &SST_VREZ_640X480_60, 0);
460 ISET(sst->lfbMode, SST_LFB_565 | SST_LFB_WRITEFRONTBUFFER |
461 SST_LFB_READFRONTBUFFER);
462 sst1InitIdleFBI(sstbase);
463 LFB_PUTPIXEL(50, 100, 0xdead); /* maps to row:0x1e, col:0x99, bank:0x0 */
464 LFB_PUTPIXEL(0, 0, 0x0);
465 LFB_PUTPIXEL(638, 479, 0xffff);
466 ISET(sst->lfbMode, SST_LFB_565 | SST_LFB_WRITEBACKBUFFER |
467 SST_LFB_READFRONTBUFFER);
468 sst1InitIdleFBI(sstbase);
469 LFB_PUTPIXEL(178, 436, 0xaa55); /* maps to row:0x11e, col:0x99, bank:0x0 */
470 LFB_PUTPIXEL(20, 20, 0x0);
471 LFB_PUTPIXEL(400, 400, 0xffff);
472 sst1InitIdleFBI(sstbase);
473 if(LFB_GETPIXEL(50, 100) != 0xdead)
474 goto check1MByte;
475 ISET(sst->lfbMode, (SST_LFB_565 | SST_LFB_READBACKBUFFER));
476 sst1InitIdleFBI(sstbase);
477 if(LFB_GETPIXEL(178, 436) == 0xaa55) {
478 retval = 2;
479 goto fbiMemSizeDone;
480 }
481
482check1MByte:
483 ISET(sst->lfbMode, SST_LFB_565 | SST_LFB_WRITEFRONTBUFFER |
484 SST_LFB_READFRONTBUFFER);
485 sst1InitIdleFBI(sstbase);
486 LFB_PUTPIXEL(10, 10, 0xdead); /* maps to row:0x0, col:0x145, bank:0x0 */
487 LFB_PUTPIXEL(8, 8, 0x0);
488 LFB_PUTPIXEL(340, 340, 0xffff);
489 LFB_PUTPIXEL(100, 200, 0x5a5a); /* maps to row:0x3c, col:0x112, bank:0x1 */
490 LFB_PUTPIXEL(66, 0, 0x0);
491 LFB_PUTPIXEL(360, 360, 0xffff);
492 sst1InitIdleFBI(sstbase);
493 if((LFB_GETPIXEL(10, 10) == 0xdead) &&
494 (LFB_GETPIXEL(100, 200) == 0x5a5a))
495 retval = 1;
496
497fbiMemSizeDone:
498 /* Restore init registers to original state */
499 ISET(sst->fbiInit0, init0Save);
500 ISET(sst->fbiInit1, init1Save);
501 ISET(sst->fbiInit2, init2Save);
502 sst1InitIdleFBI(sstbase);
503
504 return(retval);
505}
506
507FX_EXPORT FxBool FX_CSTYLE
508sst1InitGetFbiInfo(FxU32 *sstbase, sst1DeviceInfoStruct *info)
509{
510 SstRegs *sst = (SstRegs *) sstbase;
511
512 info->fbiMemSize = fbiMemSize(sstbase);
513
514 /* Detect board identification and memory speed */
515 if(GETENV(("SSTV2_FBICFG")))
516 SSCANF(GETENV(("SSTV2_FBICFG")), "%i", &info->fbiConfig);
517 else
518 info->fbiConfig = (IGET(sst->fbiInit3) & SST_FBI_MEM_TYPE) >>
519 SST_FBI_MEM_TYPE_SHIFT;
520
521 info->fbiBoardID = (IGET(sst->fbiInit5) >> 5) & 0xf;
522 if(IGET(sst->fbiInit7) & BIT(0))
523 info->fbiBoardID |= 0x10;
524
525 /* Detect scanline interleaving */
526 info->sliPaired = sst1InitSliPaired(sstbase);
527 info->sliDetected = sst1InitSliDetect(sstbase);
528
529 return FXTRUE;
530}
531
532/*
533** sst1InitGetDeviceInfo():
534** Read device specific information
535** NOTE: info pointer must point to an Info structure which has already
536** been allocated
537**
538*/
539FX_EXPORT FxBool FX_CSTYLE sst1InitGetDeviceInfo(FxU32 *sstbase,
540 sst1DeviceInfoStruct *info)
541{
542 FxBool retval;
543
544 if((retval = sst1InitCheckBoard(sstbase)) == FXTRUE)
545 *info = *sst1CurrentBoard;
546 return(retval);
547}
548
549/*
550** sst1InitFillDeviceInfo():
551** Fill in device information
552** NOTE: This routine destroys current contents in frame buffer memory
553**
554**
555*/
556FxBool sst1InitFillDeviceInfo(FxU32 *sstbase, sst1DeviceInfoStruct *info)
557{
558 if(!sstbase)
559 return(FXFALSE);
560
561 if(info->tmuRevision != 0xdead)
562 return FXTRUE; /* if already got it, return */
563
564 if(GETENV(("SSTV2_NODEVICEINFO"))) {
565 /* fill device info struct with sane values... */
566 INIT_PRINTF(("sst1DeviceInfo: Filling info Struct with default values...\n"));
567
568 if(GETENV(("SSTV2_FBICFG")))
569 SSCANF(GETENV(("SSTV2_FBICFG")), "%i", &info->fbiConfig);
570 else
571 info->fbiConfig = 0x0;
572
573 if(GETENV(("SSTV2_TMUCFG")))
574 SSCANF(GETENV(("SSTV2_TMUCFG")), "%i", &info->tmuConfig);
575 else
576 info->tmuConfig = 0x0;
577
578 info->numberTmus = 1;
579 if (info->tmuConfig & FXBIT(6)) /* if TMU 1 exists */
580 info->numberTmus++;
581 if (info->tmuConfig & FXBIT(13)) /* if TMU 2 exists */
582 info->numberTmus++;
583
584 info->tmuRevision = info->tmuConfig & 0x7;
585
586 if(GETENV(("SSTV2_FBI_MEMSIZE")))
587 info->fbiMemSize = ATOI(GETENV(("SSTV2_FBI_MEMSIZE")));
588 else
589 info->fbiMemSize = 2;
590
591 if(GETENV(("SSTV2_TMU_MEMSIZE")))
592 info->tmuMemSize[0] = ATOI(GETENV(("SSTV2_TMU_MEMSIZE")));
593 else
594 info->tmuMemSize[0] = 2;
595 info->tmuMemSize[1] = info->tmuMemSize[0];
596 info->tmuMemSize[2] = info->tmuMemSize[0];
597 } else {
598 int i;
599
600 for(i=0; i<5; i++) {
601 if(i)
602 INIT_PRINTF(("sst1InitFillDeviceInfo(): Retry #%d for chip GetInfo()...\n", i));
603 /* GetFbiInfo() must be called before GetTmuInfo() */
604 if(sst1InitGetFbiInfo(sstbase, info) == FXFALSE)
605 continue;
606 /* get the revision ID of each TMU and verify that they are all the
607 same */
608 if(sst1InitGetTmuInfo(sstbase, info) == FXFALSE)
609 continue;
610 break;
611 }
612 if(i == 5)
613 return(FXFALSE);
614 }
615 // Measure silicon performance
616 sst1InitMeasureSiProcess(sstbase, 0); // measure NAND-tree
617 sst1InitMeasureSiProcess(sstbase, 1); // measure NOR-tree
618
619 INIT_PRINTF(("sst1DeviceInfo: Board ID: %d\n", info->fbiBoardID));
620 INIT_PRINTF(("sst1DeviceInfo: FbiConfig:0x%x, TmuConfig:0x%x\n",
621 info->fbiConfig, info->tmuConfig));
622 INIT_PRINTF(("sst1DeviceInfo: FBI Revision:%d, TMU Revison:%d, Num TMUs:%d\n",
623 info->fbiRevision, info->tmuRevision, info->numberTmus));
624 INIT_PRINTF(("sst1DeviceInfo: FBI Memory:%d, TMU[0] Memory:%d",
625 info->fbiMemSize, info->tmuMemSize[0]));
626 if(info->numberTmus > 1)
627 INIT_PRINTF((", TMU[1] Memory:%d", info->tmuMemSize[1]));
628 if(info->numberTmus > 2)
629 INIT_PRINTF((", TMU[2] Memory:%d", info->tmuMemSize[2]));
630 INIT_PRINTF(("\n"));
631 if(sst1InitUseVoodooFile == FXTRUE) {
632 if(iniDac == (sst1InitDacStruct *) NULL)
633 INIT_PRINTF(("sst1DeviceInfo: Dac Type: Unknown"));
634 else
635 INIT_PRINTF(("sst1DeviceInfo: Dac Type: %s %s\n",
636 iniDac->dacManufacturer, iniDac->dacDevice));
637 } else {
638 INIT_PRINTF(("sst1DeviceInfo: Dac Type: "));
639 if(info->fbiVideoDacType == SST_FBI_DACTYPE_ATT)
640 INIT_PRINTF(("AT&T ATT20C409\n"));
641 else if(info->fbiVideoDacType == SST_FBI_DACTYPE_ICS)
642 INIT_PRINTF(("ICS ICS5342\n"));
643 else if(info->fbiVideoDacType == SST_FBI_DACTYPE_TI)
644 INIT_PRINTF(("TI TVP3409\n"));
645 else
646 INIT_PRINTF(("Unknown\n"));
647 }
648 INIT_PRINTF(("sst1DeviceInfo: SLI Detected:%d\n", info->sliDetected));
649
650 return(FXTRUE);
651}
652#pragma optimize ("",on)
Note: See TracBrowser for help on using the repository browser.