Esempio n. 1
0
/****************************************************************************
REMARKS:
Tests the MCS_saveCurrentSettings function
****************************************************************************/
void testMCS_saveCurrentSettings(void)
{
    if (MCS_saveCurrentSettings())
        gprintf("Current settings saved in monitor NVRAM");
    else
        gprintf("MCS_saveCurrentSettings failed!");
    EVT_getch();
}
Esempio n. 2
0
/****************************************************************************
REMARKS:
Display an error message on the screen and wait for a key press
****************************************************************************/
static void displayError(
    char *msg)
{
    y += 16;
    gprintf(msg);
    y += 16;
    gprintf("Press any key to continue");
    EVT_getch();
}
Esempio n. 3
0
void testMCS_getCapabilitiesString(void)
{
    char    data[1024];

    if (MCS_getCapabilitiesString(data,sizeof(data)) != -1) {
        gprintf("Capabilities String:");
        gprintf("%s", data);
        }
    else
        gprintf("MCS_getCapabilitiesString failed!");
    EVT_getch();
}
Esempio n. 4
0
/****************************************************************************
REMARKS:
Handles key press for VSync and single-step in all video overlay tests
****************************************************************************/
static ibool handleKeypress(
    int *key,
    int *freezeVideo)
{
    if (EVT_kbhit()) {
        *key = EVT_getch();                /* Swallow keypress */
        if (*key == ' ')
            *freezeVideo ^= 1;
        else
            return true;
        }
    return false;
}
Esempio n. 5
0
/****************************************************************************
REMARKS:
Tests the MCS_getSelfTestReport function
****************************************************************************/
void testMCS_getSelfTestReport(void)
{
    uchar   flags,data[256],length;

    if (MCS_getSelfTestReport(&flags,data,&length)) {
        gprintf("Self Test Report:");
        gprintf(" flags  = %02X", flags);
        gprintf(" length = %d", length);
        }
    else
        gprintf("MCS_getSelfTestReport failed!");
    EVT_getch();
}
Esempio n. 6
0
/****************************************************************************
REMARKS:
Tests the MCS_isControlSupported function
****************************************************************************/
void testMCS_isControlSupported(
    GC_devCtx *gc)
{
    int     controlCode;
    char    buf[80];

    gprintf("Enter control code: ");
    safeGetLine(gc,buf,sizeof(buf));
    sscanf(buf,"%x",&controlCode);
    if (MCS_isControlSupported(controlCode))
        gprintf("Control is supported");
    else
        gprintf("Control is not supported");
    EVT_getch();
}
Esempio n. 7
0
/****************************************************************************
REMARKS:
Tests the MCS_resetControl function
****************************************************************************/
void testMCS_resetControl(
    GC_devCtx *gc)
{
    int     controlCode;
    char    buf[80];

    gprintf("Enter control code: ");
    safeGetLine(gc,buf,sizeof(buf));
    sscanf(buf,"%x",&controlCode);
    if (MCS_resetControl(controlCode))
        gprintf("Control value reset to factory default");
    else
        gprintf("MCS_resetControl failed!");
    EVT_getch();
}
Esempio n. 8
0
/****************************************************************************
REMARKS:
Tests the MCS_getTimingReport function
****************************************************************************/
void testMCS_getTimingReport(void)
{
    uchar   flags;
    ushort  hFreq,vFreq;

    if (MCS_getTimingReport(&flags,&hFreq,&vFreq)) {
        gprintf("Timing Report:");
        gprintf(" flags = %02X", flags);
        gprintf(" hFreq = %.2f kHz", (hFreq+50.0) / 100.0);
        gprintf(" vFreq = %.2f Hz", (vFreq+50.0) / 100.0);
        gprintf(" hSync = %c", (flags & MCS_hSyncPositive) ? '+' : '-');
        gprintf(" vSync = %c", (flags & MCS_vSyncPositive) ? '+' : '-');
        }
    else
        gprintf("MCS_getTimingReport failed!");
    EVT_getch();
}
Esempio n. 9
0
/****************************************************************************
REMARKS:
Tests the MCS_enableControl function
****************************************************************************/
void testMCS_enableControl(
    GC_devCtx *gc)
{
    int     controlCode,enable;
    char    buf[80];

    gprintf("Enter control code: ");
    safeGetLine(gc,buf,sizeof(buf));
    sscanf(buf,"%x",&controlCode);
    gprintf("Enter enable code (0 or 1): ");
    safeGetLine(gc,buf,sizeof(buf));
    sscanf(buf,"%d",&enable);
    if (MCS_enableControl(controlCode,enable))
        gprintf("Control enable updated");
    else
        gprintf("MCS_enableControl failed!");
    EVT_getch();
}
Esempio n. 10
0
/****************************************************************************
REMARKS:
Tests the MCS_getControlValue function
****************************************************************************/
void testMCS_getControlValue(
    GC_devCtx *gc)
{
    int     controlCode;
    ushort  value,max;
    char    buf[80];

    gprintf("Enter control code: ");
    safeGetLine(gc,buf,sizeof(buf));
    sscanf(buf,"%x",&controlCode);
    if (MCS_getControlMax(controlCode,&max) && MCS_getControlValue(controlCode,&value)) {
        gprintf("Control Values:");
        gprintf(" value = %d", value);
        gprintf(" max   = %d", max);
        }
    else
        gprintf("MCS_getControlValue failed!");
    EVT_getch();
}
Esempio n. 11
0
/****************************************************************************
REMARKS:
Tests the MCS_setControlValue function
****************************************************************************/
void testMCS_setControlValue(
    GC_devCtx *gc)
{
    int     controlCode;
    ushort  value;
    char    buf[80];

    gprintf("Enter control code: ");
    safeGetLine(gc,buf,sizeof(buf));
    sscanf(buf,"%x",&controlCode);
    gprintf("Enter value: ");
    safeGetLine(gc,buf,sizeof(buf));
    sscanf(buf,"%hd",&value);
    if (MCS_setControlValue(controlCode,value))
        gprintf("Control value updated");
    else
        gprintf("MCS_setControlValue failed!");
    EVT_getch();
}
Esempio n. 12
0
/****************************************************************************
REMARKS:
Function to read a string from the keyboard, using the console library
for output.
****************************************************************************/
int GetString(
    GC_devCtx *gc,
    char *str,
    int maxLen)
{
    int x,y,c,len = 0;

    x = GC_wherex(gc);
    y = GC_wherey(gc);
    for (;;) {
        if ((c = EVT_getch()) == 0xD) {
            str[len] = 0;
            GC_printf(gc,"\n");
            return 1;
            }
        if (c == 0x1B)
            return -1;
        if (c == 0x08) {
            if (len > 0) {
                len--;
                x--;
                GC_gotoxy(gc,x,y);
                GC_putc(gc,' ');
                GC_gotoxy(gc,x,y);
                }
            }
        else if (isprint(c)) {
            if (len < maxLen) {
                str[len++] = c;
                GC_gotoxy(gc,x,y);
                GC_putc(gc,c & 0xFF);
                x++;
                }
            }
        }
}
Esempio n. 13
0
int bounceTest(
    GA_HGLRC glrc,
    int width,
    int height)
{
    ibool   done = false;
    int     initPageCount = 20;
    int     fpsRate = 0,key = 0,waitVRT = gaWaitVRT,pageCount = initPageCount;
    ulong   lastCount = 0,newCount;

    /* Init global variables */
    Zrot = 0.0;     Zstep = 4.0;
    Xpos = 0.0;     Ypos = 1.0;
    Xvel = 0.1;     Yvel = 0.0;
    Xmin = -4.0;    Xmax=4.0;
    Ymin = -3.8;    G = -0.05;

    /* Init ball and OpenGL rendering state */
    Ball = make_ball();
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);
    glShadeModel(GL_FLAT);
    reshape(width,height);
    LZTimerOn();
    while (!done) {
        idle();
        gmoveto(0,0);
        gprintf("%d x %d %d bit %s (%d.%d fps)",(int)maxX+1,(int)maxY+1,
            (int)modeInfo.BitsPerPixel,
            (cntMode & gaLinearBuffer) ? "Linear" : "Banked",
            fpsRate / 10, fpsRate % 10);
        if (softwareOnly)             
            gprintf("Rendering to system memory back buffer");
        switch (waitVRT) {
            case gaTripleBuffer:
                gprintf("Triple buffering - should be no flicker");
                gprintf("Frame rate *must* max at refresh rate");
                break;
            case gaWaitVRT:
                gprintf("Double buffering - should be no flicker");
                gprintf("Frame rate *must* lock to multiple of refresh");
                break;
            default:
                gprintf("Page flipping (no wait) - may flicker");
                gprintf("Frame rate *must* max at hardware limit");
                break;
            }
        glFuncs.SwapBuffers(glrc,waitVRT);
        if (EVT_kbhit()) {
            key = EVT_getch();                /* Swallow keypress */
            if (key == 'v' || key == 'V') {
                waitVRT -= 1;
                if (modeInfo.Attributes & gaHaveTripleBuffer) {
                    if (waitVRT < gaTripleBuffer)
                        waitVRT = gaDontWait;
                    }
                else {
                    if (waitVRT < gaWaitVRT)
                        waitVRT = gaDontWait;
                    }
                }
            else                
                break;
            }
        /* Compute the frames per second rate after going through a large
         * number of pages. 
         */
        if (--pageCount == 0) {
            newCount = LZTimerLap();
            fpsRate = (int)(10000000L / (newCount - lastCount)) * initPageCount;
            lastCount = newCount;
            pageCount = initPageCount;
            }
        }
    LZTimerOff();
    return key;
}
Esempio n. 14
0
/****************************************************************************
REMARKS:
Main function to do the interactive tests.
****************************************************************************/
ibool doVideoCaptureTest(
    GC_devCtx *gc,
    GA_glCtx *gl,
    int xRes,
    int yRes,
    int bitsPerPixel,
    N_uint32 flags,
    int refreshRate,
    GA_CRTCInfo *crtc,
    N_uint32 planeMask,
    ibool force1bppShadow)
{
    int                     i,choice;
    ibool                   success = true,all = true;
    GA_videoFuncs           video;
    GA_videoCaptureFuncs    capture;
    GA_VideoCaptureInf      captureInfo;
    GA_captureInputTypes    inputs[ ] = { gaCaptureCompositeInput,
                                          gaCaptureSVideoInput,
                                          gaCaptureRGBInput,
                                          gaCaptureRS170Input };
#define NUM_INPUTS (sizeof(inputs) / sizeof(inputs[0]))

    /* Obtain the mode information before setting the mode */
    dc = gc->dc;
    virtualX = virtualY = bytesPerLine = -1;
    modeInfo.dwSize = sizeof(modeInfo);
    if (xRes == -1) {
        if (init.GetVideoModeInfo(flags,&modeInfo) != 0)
            return false;
        }
    else {
        if (init.GetCustomVideoModeInfo(xRes,yRes,-1,-1,bitsPerPixel,&modeInfo) != 0)
            return false;
        }

    /* Check mode for video acceleration capabilities */
    if (!(modeInfo.Attributes & gaHaveAccelVideo)) {
        GC_printf(gc,"Video acceleration not available!\n\n");
        return false;
        }

    /* Check mode for video capture format list */
    captureInfo.dwSize = sizeof(captureInfo);
    if (!(modeInfo.VideoWindows)) {
        GC_printf(gc,"Video capture format list not available!\n\n");
        return false;
        }
    else
        memcpy(&captureInfo,*modeInfo.VideoCapture,captureInfo.dwSize);

    for (;;) {
        /* Display video format menu while in graphics console mode */
        GC_clrscr(gc);
        GC_printf(gc,"Video Capture Test\n\n");

        /* Display menu of available video overlay formats */
        GC_printf(gc,"Select Video Capture input to test:\n\n");
        for (i = 0; i < NUM_INPUTS; i++) {
            if ((captureInfo.InputType & inputs[i]) != inputs[i])
                continue;
            GC_printf(gc,"  [%i] - %s\n",i,displayInput(inputs[i]));
            }
        GC_printf(gc,"  [Q] - Quit\n\n");
        GC_printf(gc,"Choice: ");
        for (;;) {
            choice = EVT_getch();
            if (tolower(choice) == 'q' || choice == 0x1B)
                return true;
            choice = (choice) - '0';
            if (choice >= 0 && choice < NUM_INPUTS) {
                if ((captureInfo.InputType & inputs[choice]) == inputs[choice])
                    break;
                }
            }

        /* Obtain the mode information and set the display mode */
        GC_leave(gc);
        dc = gc->dc;
        virtualX = virtualY = bytesPerLine = -1;
        modeInfo.dwSize = sizeof(modeInfo);
        if (xRes == -1) {
            if (init.GetVideoModeInfo(flags,&modeInfo) != 0)
                return false;
            if (init.SetVideoMode(flags,&virtualX,&virtualY,&bytesPerLine,&maxMem,refreshRate,crtc) != 0)
                return false;
            }
        else {
            if (init.GetCustomVideoModeInfo(xRes,yRes,-1,-1,bitsPerPixel,&modeInfo) != 0)
                return false;
            if (init.SetCustomVideoMode(xRes,yRes,bitsPerPixel,flags,&virtualX,&virtualY,&bytesPerLine,&maxMem,crtc) != 0)
                return false;
            }
        cntMode = flags;
        if (!InitSoftwareRasterizer(cntDevice,1,false))
            PM_fatalError("Unable to initialise software rasteriser!");

        /* Get the hardware video overlay functions */
        video.dwSize = sizeof(video);
        if (!REF2D_queryFunctions(ref2d,GA_GET_VIDEOFUNCS,&video)) {
            displayError("Video functions not available!");
            success = false;
            goto DoneTests;
            }
        capture.dwSize = sizeof(capture);
        if (!REF2D_queryFunctions(ref2d,GA_GET_VIDEOCAPTUREFUNCS,&capture)) {
            displayError("Video capture functions not available!");
            success = false;
            goto DoneTests;
            }

        /* Run the tests for the selected capture input */
        i = choice;
        all = (stricmp(accelTestName,"all") == 0);
        if (all || stricmp(accelTestName,"capture") == 0)
            if (staticTest(&video,&capture,inputs[i],gaCaptureStandardNTSC,&captureInfo) == 0x1B)
                goto DoneTests;

DoneTests:
        /* Return to text mode, restore the state of the console and reloop */
        ExitSoftwareRasterizer();
        GC_restore(gc);
        if (!success)
            break;
        }

    (void)gl;
    (void)planeMask;
    (void)force1bppShadow;
    return success;
}
Esempio n. 15
0
/****************************************************************************
REMARKS:
Does a simple overlay buffer static video capture test. The overlay will
show what is coming in via the video capture engine.
****************************************************************************/
static int staticTest(
    GA_videoFuncs *video,
    GA_videoCaptureFuncs *capture,
    GA_captureInputTypes input,
    GA_captureStandardTypes standard,
    GA_VideoCaptureInf *captureInfo)
{
    int             key,x,y,width = DEF_WIDTH,height = DEF_HEIGHT;
    int             centerX, centerY;
    ibool           done = false,freezeInput = false,newFreezeInput = false;
    GA_captureBuf   *captureBuf = NULL;
    GA_buf          *primaryVideo = NULL;
    int             outputHead = init.GetActiveHead();
    char            str[80];

    /* Draw background for video overlay */
    SetActivePage(0);
    ClearPage(0);
    moire(defcolor);
    if (maxX >= 479)
        gmoveto(80,80);
    else
        gmoveto(8,40);
    gprintf("Video capture static test");  y += 16;
    displaymodeInfo();
    gprintf("Press any key to continue");
    if (EVT_getch() == 0x1B)
        return 0x1B;

    /* Use larger overlay window for higher resolutions */
    if (modeInfo.XResolution >= 1280) {
        width *= 2;
        height *= 2;
        }
    else if (modeInfo.XResolution <= DEF_WIDTH) {
        width /= 2;
        height /= 2;
        }

    /* Allocate the source video buffer */
    if ((captureBuf = capture->AllocCaptureBuffer(width,height,captureInfo->VideoFormat,1)) == NULL) {
        displayError("Unable to allocate video capture buffer!");
        return 0x1B;
        }
    primaryVideo = captureBuf->VideoBuffers;
    centerX = (maxX - primaryVideo->Width)/2;
    centerY = (maxY - primaryVideo->Height)/2;

    /* Set up for single buffer video overlay */
    SetActiveBuffer(primaryVideo);
    ClearVideoBuffer(primaryVideo);

    /* Set the video output window */
    x = centerX;
    y = centerY;
    if (!video->SetVideoOutput(0,outputHead,primaryVideo,
            0,0,primaryVideo->Width,primaryVideo->Height,
            x,y,primaryVideo->Width,primaryVideo->Height,0)) {
        displayError("Unable to set video output window!");
        return 0x1B;
        }

    /* Set up the video capture and start it */
    capture->SetVideoInput(captureBuf,input,standard,0,false);
    capture->StartLiveVideo(captureBuf);

    /* Now loop around and display the video capture */
    sprintf(str,"%d x %d %d bit %s overlay",primaryVideo->Width,primaryVideo->Height,
        primaryVideo->BitsPerPixel,displayFormat(primaryVideo->Format));
    if (width < DEF_WIDTH)
        WriteText(8,60,displayFormat(primaryVideo->Format),defcolor);
    else
        WriteText(8,80,str,defcolor);
    while (!done) {
        if (handleKeypress(&key,&newFreezeInput))
            break;
        if (freezeInput != newFreezeInput) {
            freezeInput = newFreezeInput;
            if (freezeInput)
                capture->FreezeLiveVideo(captureBuf,gaCaptureFieldAny);
            else
                capture->StartLiveVideo(captureBuf);
            }
        }
    SetActivePage(0);
    video->DisableVideoOutput(0);
    capture->FreeCaptureBuffer(captureBuf);
    return key;
}
Esempio n. 16
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);
}
Esempio n. 17
0
int gears2Test(
    GA_HGLRC glrc,
    int width,
    int height)
{
    ibool   done = false;
    int     initPageCount = 5;
    int     fpsRate = 0,key = 0,waitVRT = gaWaitVRT,pageCount = initPageCount;
    ulong   lastCount = 0,newCount;
    
    myinit();
    myReshape(width,height);
    LZTimerOn();
    while (!done) {
        oneFrame();
        gmoveto(0,0);
        gprintf("%d x %d %d bit %s (%d.%d fps)",(int)maxX+1,(int)maxY+1,
            (int)modeInfo.BitsPerPixel,
            (cntMode & gaLinearBuffer) ? "Linear" : "Banked",
            fpsRate / 10, fpsRate % 10);
        if (softwareOnly)             
            gprintf("Rendering to system memory back buffer");
        switch (waitVRT) {
            case gaTripleBuffer:
                gprintf("Triple buffering - should be no flicker");
                gprintf("Frame rate *must* max at refresh rate");
                break;
            case gaWaitVRT:
                gprintf("Double buffering - should be no flicker");
                gprintf("Frame rate *must* lock to multiple of refresh");
                break;
            default:
                gprintf("Page flipping (no wait) - may flicker");
                gprintf("Frame rate *must* max at hardware limit");
                break;
            }
        glFuncs.SwapBuffers(glrc,waitVRT);
        if (EVT_kbhit()) {
            key = EVT_getch();                /* Swallow keypress */
            if (key == 'v' || key == 'V') {
                waitVRT -= 1;
                if (modeInfo.Attributes & gaHaveTripleBuffer) {
                    if (waitVRT < gaTripleBuffer)
                        waitVRT = gaDontWait;
                    }
                else {
                    if (waitVRT < gaWaitVRT)
                        waitVRT = gaDontWait;
                    }
                }
            else                
                break;
            }
        /* Compute the frames per second rate after going through a large
         * number of pages. 
         */
        if (--pageCount == 0) {
            newCount = LZTimerLap();
            fpsRate = (int)(10000000L / (newCount - lastCount)) * initPageCount;
            lastCount = newCount;
            pageCount = initPageCount;
            }
        }
    LZTimerOff();
    return key;
}