/**************************************************************************** REMARKS: Main program entry point ****************************************************************************/ int main( int argc, char *argv[]) { GA_devCtx *dc = NULL; GA_configInfo info; N_uint8 capabilities = 0; N_int32 numMonitorPorts; GA_SCIFuncs sci; uchar edid[128]; EDID_record rec; N_int32 channel = SCI_channelMonitorPrimary; /* Get command line option for SNAP DDC channel */ if (argc > 1) channel = atoi(argv[1]); /* Now handle the query */ dc = LoadDriver(0); if (!dc) { printf("Unable to load SNAP DDC driver!\n"); return -1; } /* Display graphics driver info */ banner(); info.dwSize = sizeof(info); init.GetConfigInfo(&info); printf("Doing DDC for %s %s (device %d) on channel %d:\n\n", info.ManufacturerName, info.ChipsetName, dc->DeviceIndex, channel); /* Detect if the SCI interface is active */ sci.dwSize = sizeof(sci); if (GA_queryFunctions(dc,GA_GET_SCIFUNCS,&sci) && sci.SCIdetect(&capabilities,&numMonitorPorts)) { /* Initialise DDC2B communications */ if (DDC_initExt(dc,channel) == 0) { /* Read EDID data */ DDC_readEDID(0xA0,edid,sizeof(edid),0,channel); /* Parse EDID data and dump into formatted text file */ if (!EDID_parse(edid,&rec,false)) printf("Unable to parse EDID data!\n"); else if (!EDID_format(&rec,EDID_FILENAME)) printf("Unable to format EDID data!\n"); else printf("EDID data formatted into text file " EDID_FILENAME " \n"); printf("DDC channel %d EDID: %s %s\n",channel,rec.mfrName,rec.modelName); } else { printf("Could not perform DDC2B communications!\n"); } } else { printf("No DDC services available in driver!\n"); } /* Unload SNAP and exit */ GA_unloadDriver(dc); return 0; }
/**************************************************************************** REMARKS: Load the SNAP driver and intialise it. ****************************************************************************/ static GA_devCtx *LoadDriver( int deviceIndex) { GA_devCtx *dc; /* Save the state of the console */ hwndConsole = PM_openConsole(0,0,640,480,8,true); if ((stateBuf = malloc(PM_getConsoleStateSize())) == NULL) PM_fatalError("Out of memory!"); PM_saveConsoleState(stateBuf,hwndConsole); /* Register our fatal error cleanup handler */ PM_setFatalErrorCleanup(Cleanup); /* Load the driver */ if ((dc = GA_loadDriver(deviceIndex,false)) == NULL) PM_fatalError(GA_errorMsg(GA_status())); init.dwSize = sizeof(init); if (!GA_queryFunctions(dc,GA_GET_INITFUNCS,&init)) PM_fatalError("Unable to get device driver functions!"); /* Cleanup. We do this here because we know that we will not * be setting any graphics modes after loading the driver, * so we can properly restore the console state and make calls * to non-destructive functions in the driver before we unload * it. */ Cleanup(); return dc; }
/**************************************************************************** REMARKS: Load the SNAP driver and intialise it. ****************************************************************************/ static void LoadDriver( int deviceIndex) { if (!dc) { if ((dc = GA_loadDriver(deviceIndex,false)) == NULL) PM_fatalError(GA_errorMsg(GA_status())); init.dwSize = sizeof(init); if (!GA_queryFunctions(dc,GA_GET_INITFUNCS,&init)) PM_fatalError("Unable to get device driver functions!"); opt.dwSize = sizeof(opt); init.GetOptions(&opt); } }
/**************************************************************************** REMARKS: Load the SNAP driver and intialise it. ****************************************************************************/ static GA_devCtx *LoadDriver( int deviceIndex) { GA_devCtx *dc; #ifdef ISV_LICENSE /* Register ISV license for SNAP DDC API */ GA_registerLicense(OemLicense,false); #endif if ((dc = GA_loadDriver(deviceIndex,false)) == NULL) PM_fatalError(GA_errorMsg(GA_status())); init.dwSize = sizeof(init); if (!GA_queryFunctions(dc,GA_GET_INITFUNCS,&init)) PM_fatalError("Unable to get device driver functions!"); return dc; }
/**************************************************************************** REMARKS: Main routine. Expects the x & y resolution of the desired video mode to be passed on the command line. Will print out a list of available video modes if no command line is present. ****************************************************************************/ int main( int argc, char *argv[]) { /* Check to see if we are running in a window */ if (PM_runningInAWindow()) { printf("This program cannot run in a window. Please switch to a fullscreen mode.\n"); return -1; } /* Save the state of the console */ hwndConsole = PM_openConsole(0,0,640,480,8,true); if ((stateBuf = malloc(PM_getConsoleStateSize())) == NULL) PM_fatalError("Out of memory!"); PM_saveConsoleState(stateBuf,hwndConsole); /* Register our fatal error cleanup handler */ PM_setFatalErrorCleanup(FatalErrorCleanup); /* Register the ISV license file if desired */ #ifdef ISV_LICENSE GA_registerLicense(OemLicense,false); #endif /* Load the device driver for this device */ if ((dc = GA_loadDriver(0,false)) == NULL) PM_fatalError(GA_errorMsg(GA_status())); init.dwSize = sizeof(init); if (!GA_queryFunctions(dc,GA_GET_INITFUNCS,&init)) PM_fatalError("Unable to get device driver functions!"); driver.dwSize = sizeof(driver); if (!GA_queryFunctions(dc,GA_GET_DRIVERFUNCS,&driver)) PM_fatalError("Unable to get device driver functions!"); /* Display available modes for invalid command line */ if (argc != 4) { /* Restore the console */ PM_restoreConsoleState(stateBuf,hwndConsole); PM_closeConsole(hwndConsole); AvailableModes(); GA_unloadDriver(dc); return 0; } /* Get requested resolution, start graphics and draw pattern */ xRes = atoi(argv[1]); yRes = atoi(argv[2]); bpp = atoi(argv[3]); if ((oldMode = InitGraphics(xRes,yRes,bpp)) != -1) { DrawMoire(); PM_getch(); virtualX = virtualY = bytesPerLine = -1; init.SetVideoMode(oldMode,&virtualX,&virtualY,&bytesPerLine,&maxMem,0,NULL); } /* Restore the console */ ExitSoftwareRasterizer(); PM_restoreConsoleState(stateBuf,hwndConsole); PM_closeConsole(hwndConsole); /* Unload the device driver */ GA_unloadDriver(dc); if (oldMode == -1) printf("Unable to find specified graphics mode, or error starting mode.\n"); return 0; }
/**************************************************************************** REMARKS: Displays the menu of DDC tests and allows the DDC functionality to be tested. ****************************************************************************/ void DDCCITests( GC_devCtx *gc) { int choice,err = ddcOk; GA_SCIFuncs sci; /* For NonVGA controllers we need to run this test in graphics modes * to ensure that we are running on the proper controller hardware * that we support DPMS on (ie: the Windows driver hardware). */ SetGraphicsMode(gc); /* Allow a 1.5 second delay before trying to do DDC/CI communications */ _OS_delay(1500000); /* Initialise DDC/CI communications */ sci.dwSize = sizeof(sci); if (!GA_queryFunctions(dc,GA_GET_SCIFUNCS,&sci) || (err = MCS_begin(dc)) != ddcOk) { RestoreMode(gc); GC_clrscr(gc); if (err == ddcNotAvailable) GC_printf(gc,"DDC/CI not supported by monitor!\n\n"); else GC_printf(gc,"DDC monitor not connected!\n\n"); GC_printf(gc,"Press any key to continue"); EVT_getch(); return; } /* Display menu information on screen */ for (;;) { ClearPage(0); gmoveto(40,40); gprintf("DDC/CI support active:"); gnewline(); gprintf("Enter function to test:"); gprintf(" [0] - Is Control Supported"); gprintf(" [1] - Enable Control"); gprintf(" [2] - Get Control Value"); gprintf(" [3] - Set Control Value"); gprintf(" [4] - Reset Control"); gprintf(" [5] - Get Timing Report"); gprintf(" [6] - Save Current Settings"); gprintf(" [7] - Get Self Test Report"); gprintf(" [8] - Get Capabilities String"); gprintf(" [Esc] - Quit"); gprintf("Which: "); /* Loop around trying the different DPMS states */ choice = EVT_getch(); if (choice == 0x1B || tolower(choice) == 'q') break; gnewline(); switch (choice) { case '0': testMCS_isControlSupported(gc); break; case '1': testMCS_enableControl(gc); break; case '2': testMCS_getControlValue(gc); break; case '3': testMCS_setControlValue(gc); break; case '4': testMCS_resetControl(gc); break; case '5': testMCS_getTimingReport(); break; case '6': testMCS_saveCurrentSettings(); break; case '7': testMCS_getSelfTestReport(); break; case '8': testMCS_getCapabilitiesString(); break; } } /* Close the DDC/CI communications channel */ MCS_end(); /* Restore text mode for NonVGA controllers */ RestoreMode(gc); }