int main (int argc, char *argv[]) { struct fb_var_screeninfo var; struct fb_fix_screeninfo fix; bool fb1 = false; bool vr = false; int fh; ProgramName = argv[0]; while (--argc > 0) { argv++; if (!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) Usage(); else if (!strcmp(argv[0], "-fb1")) fb1 = true; else if (!strcmp(argv[0], "-vr")) vr = true; } fbset * rset; if(!fb1) fh=OpenFrameBuffer(true,"/dev/fb0"); else fh=OpenFrameBuffer(true,"/dev/fb1"); rset = new fbset(true,fh,"/etc/videomode"); rset->GetVarScreenInfo(&var); rset->update_var_screeninfo(&var); if(!vr) { rset->SetVarScreenInfo(&var); rset->set_background(); } CloseFrameBuffer(fh); return (0); }
cFbRawOsd(int Left, int Top, uint Level, const char* device) : cOsd(Left, Top, Level), m_fd(0), m_fb(0), m_size(0) { if (OpenFrameBuffer(device)) DLOG("opened OSD frame buffer %dx%d, %dbpp", m_vinfo.xres, m_vinfo.yres, m_vinfo.bits_per_pixel); }
int main(int argc, CHAR *argv[]) { INT i; UINT begin; UINT end; UINT lapsed; MATRIX vtrans, Vinv; /* View transformation and inverse. */ /* * First, process command line arguments. */ i = 1; while ((i < argc) && (argv[i][0] == '-')) { switch (argv[i][1]) { case '?': case 'h': case 'H': Usage(); exit(1); case 'a': case 'A': AntiAlias = TRUE; if (argv[i][2] != '\0') { NumSubRays = atoi(&argv[i][2]); } else { NumSubRays = atoi(&argv[++i][0]); } break; case 'm': if (argv[i][2] != '\0') { MaxGlobMem = atoi(&argv[i][2]); } else { MaxGlobMem = atoi(&argv[++i][0]); } break; case 'p': if (argv[i][2] != '\0') { nprocs = atoi(&argv[i][2]); } else { nprocs = atoi(&argv[++i][0]); } break; case 's': case 'S': dostats = TRUE; break; default: fprintf(stderr, "%s: Invalid option \'%c\'.\n", ProgName, argv[i][0]); exit(1); } i++; } if (i == argc) { Usage(); exit(1); } /* * Make sure nprocs is within valid range. */ if (nprocs < 1 || nprocs > MAX_PROCS) { fprintf(stderr, "%s: Valid range for #processors is [1, %d].\n", ProgName, MAX_PROCS); exit(1); } /* * Print command line parameters. */ printf("\n"); printf("Number of processors: \t%ld\n", nprocs); printf("Global shared memory size:\t%ld MB\n", MaxGlobMem); printf("Samples per pixel: \t%ld\n", NumSubRays); printf("\n"); /* * Initialize the shared memory environment and request the total * amount of amount of shared memory we might need. This * includes memory for the database, grid, and framebuffer. */ MaxGlobMem <<= 20; /* Convert MB to bytes. */ MAIN_INITENV(,MaxGlobMem + 512*1024) THREAD_INIT_FREE(); gm = (GMEM *)G_MALLOC(sizeof(GMEM)); /* * Perform shared environment initializations. */ gm->nprocs = nprocs; gm->pid = 0; gm->rid = 1; BARINIT(gm->start, nprocs) LOCKINIT(gm->pidlock) LOCKINIT(gm->ridlock) LOCKINIT(gm->memlock) ALOCKINIT(gm->wplock, nprocs) /* POSSIBLE ENHANCEMENT: Here is where one might distribute the raystruct data structure across physically distributed memories as desired. */ if (!GlobalHeapInit(MaxGlobMem)) { fprintf(stderr, "%s: Cannot initialize global heap.\n", ProgName); exit(1); } /* * Initialize HUG parameters, read environment and geometry files. */ Huniform_defaults(); ReadEnvFile(/* *argv*/argv[i]); ReadGeoFile(GeoFileName); OpenFrameBuffer(); /* * Compute view transform and its inverse. */ CreateViewMatrix(); MatrixCopy(vtrans, View.vtrans); MatrixInverse(Vinv, vtrans); MatrixCopy(View.vtransInv, Vinv); /* * Print out what we have so far. */ printf("Number of primitive objects: \t%ld\n", prim_obj_cnt); printf("Number of primitive elements:\t%ld\n", prim_elem_cnt); /* * Preprocess database into hierarchical uniform grid. */ if (TraversalType == TT_HUG) BuildHierarchy_Uniform(); /* * Now create slave processes. */ CLOCK(begin) CREATE(StartRayTrace, gm->nprocs); WAIT_FOR_END(gm->nprocs); CLOCK(end) /* * We are finished. Clean up, print statistics and run time. */ CloseFrameBuffer(PicFileName); PrintStatistics(); lapsed = (end - begin) & 0x7FFFFFFF; printf("TIMING STATISTICS MEASURED BY MAIN PROCESS:\n"); printf(" Overall start time %20lu\n", begin); printf(" Overall end time %20lu\n", end); printf(" Total time with initialization %20lu\n", lapsed); printf(" Total time without initialization %20lu\n", end - gm->par_start_time); if (dostats) { unsigned totalproctime, maxproctime, minproctime; printf("\n\n\nPER-PROCESS STATISTICS:\n"); printf("%20s%20s\n","Proc","Time"); printf("%20s%20s\n\n","","Tracing Rays"); for (i = 0; i < gm->nprocs; i++) printf("%20ld%20ld\n",i,gm->partime[i]); totalproctime = gm->partime[0]; minproctime = gm->partime[0]; maxproctime = gm->partime[0]; for (i = 1; i < gm->nprocs; i++) { totalproctime += gm->partime[i]; if (gm->partime[i] > maxproctime) maxproctime = gm->partime[i]; if (gm->partime[i] < minproctime) minproctime = gm->partime[i]; } printf("\n\n%20s%20d\n","Max = ",maxproctime); printf("%20s%20d\n","Min = ",minproctime); printf("%20s%20d\n","Avg = ",(int) (((double) totalproctime) / ((double) (1.0 * gm->nprocs)))); } MAIN_END }
FbData* FbGetData(void) { FbData *fb; struct VideoMode vmode; struct fb_var_screeninfo var; int res,sstart,send,total; str ht,vt; str flags; int fh = -1; fb = (FbData*)malloc(sizeof(FbData)); fb->x = 640; fb->y = 480; fb->depth = 8; fb->hsync = 33; fb->vsync = 72; fb->clock = 35; strcpy(fb->ht,""); strcpy(fb->vt,""); strcpy(fb->flags,""); fh = OpenFrameBuffer(DEFAULT_FRAMEBUFFER); if (fh < 0) { return(fb); } GetVarScreenInfo(fh, &var); ConvertToVideoMode(&var, &vmode); #if __powerpc__ // on PPC we had a real framebuffer driver which provides // the correct timing values of the active framebuffer // ... #else // on other architectures we will limit the framebuffer // to a 60Hz mode // ... vmode.hrate = (60.0 / vmode.vrate) * vmode.hrate; vmode.drate = (vmode.xres+vmode.right+vmode.hslen+vmode.left) * vmode.hrate; vmode.vrate = 60; #endif fb->x = vmode.xres; fb->y = vmode.yres; fb->depth = vmode.transp.offset; fb->hsync = vmode.hrate/1e3; fb->vsync = vmode.vrate; fb->clock = vmode.drate/1e6; res = vmode.xres; sstart = res+vmode.right; send = sstart+vmode.hslen; total = send+vmode.left; sprintf(ht,"%d %d %d %d",res, sstart, send, total); res = vmode.yres; sstart = res+vmode.lower; send = sstart+vmode.vslen; total = send+vmode.upper; sprintf(vt,"%d %d %d %d", res, sstart, send, total); strcpy(flags,""); if (vmode.laced) strcat(flags,"Interlace "); if (vmode.dblscan) strcat(flags,"DoubleScan "); if (vmode.hsync) strcat(flags,"+HSync "); else strcat(flags,"-HSync "); if (vmode.vsync) strcat(flags,"+VSync "); else strcat(flags,"-VSync "); if (vmode.csync) strcat(flags,"Composite "); if (vmode.bcast) strcat(flags,"bcast "); strcpy(fb->ht,ht); strcpy(fb->vt,vt); strcpy(fb->flags,flags); CloseFrameBuffer(fh); return(fb); }