Пример #1
0
static VOID FASTCALL
vgaSaveRegisters(PVGA_REGISTERS Registers)
{
   UCHAR i;

   for (i = 0; i < sizeof(Registers->CRT); i++)
   {
      VideoPortWritePortUchar(CRTC, i);
      Registers->CRT[i] = VideoPortReadPortUchar(CRTCDATA);
   }

   for (i = 0; i < sizeof(Registers->Attribute); i++)
   {
      VideoPortReadPortUchar(STATUS);
      VideoPortWritePortUchar(ATTRIB, i);
      Registers->Attribute[i] = VideoPortReadPortUchar(ATTRIBREAD);
   }

   for (i = 0; i < sizeof(Registers->Graphics); i++)
   {
      VideoPortWritePortUchar(GRAPHICS, i);
      Registers->Graphics[i] = VideoPortReadPortUchar(GRAPHICSDATA);
   }

   for (i = 0; i < sizeof(Registers->Sequencer); i++)
   {
      VideoPortWritePortUchar(SEQ, i);
      Registers->Sequencer[i] = VideoPortReadPortUchar(SEQDATA);
   }

   Registers->Misc = VideoPortReadPortUchar(MISC);
}
Пример #2
0
VOID
DevDisableDGX(
    PHW_DEVICE_EXTENSION HwDeviceExtension
    )

/*++

Routine Description:

    Disables the DGX and turns on VGA pass-thru.

Arguments:

    HwDeviceExtension - Pointer to the miniport driver's device extension.


Return Value:

--*/
{
    UCHAR cTemp, *pPort;

    VideoDebugPrint((2, "DGX: DevDisableDGX\n"));

    *HwDeviceExtension->pControlRegA = 0xb47370;
    DacDelay();
    pPort = (PCHAR)HwDeviceExtension->DGXControlPorts;

    if (HwDeviceExtension->ModelNumber == 1) {

        VideoPortWritePortUchar((PUCHAR)HwDeviceExtension->DGX1OutputPort,
                0x6);
        DacDelay();
        pPort += 4;
        VideoPortWritePortUchar(pPort, 0x1);

    } else {

        if (HwDeviceExtension->ModelNumber == 2) {

            pPort += 8;
            cTemp = VideoPortReadPortUchar(pPort);
            cTemp &= 0xaf;
            VideoPortWritePortUchar(pPort,
                                    cTemp);

        } else {

            return;

        }
    }
}
Пример #3
0
VOID
VgaZeroVideoMemory(
    PHW_DEVICE_EXTENSION HwDeviceExtension
    )
/*++

Routine Description:

    This routine zeros the first 256K on the VGA.

Arguments:

    HwDeviceExtension - Pointer to the miniport driver's device extension.


Return Value:

    None.

--*/
{
    UCHAR temp;

    //
    // Map font buffer at A0000
    //

    VgaInterpretCmdStream(HwDeviceExtension, EnableA000Data);

    //
    // Enable all planes.
    //
    VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_ADDRESS_PORT,
            IND_MAP_MASK);

    temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
            SEQ_DATA_PORT) | (UCHAR)0x0F;

    VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_DATA_PORT,
            temp);

    //
    // Zero the memory.
    //

    VideoPortZeroDeviceMemory(HwDeviceExtension->VideoMemoryAddress,
                              0xFFFF);

    VgaInterpretCmdStream(HwDeviceExtension, DisableA000Color);

} // VgaZeroVideoMemory(...)
Пример #4
0
BOOLEAN  VGASetColorRegisters(IN PVIDEO_CLUT  ColorLookUpTable,
                              OUT PSTATUS_BLOCK  StatusBlock)
{
    int i;

    for (i=ColorLookUpTable->FirstEntry; i<ColorLookUpTable->NumEntries; i++)
    {
        VideoPortWritePortUchar((PUCHAR)0x03c8, i);
        VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[i].RgbArray.Red);
        VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[i].RgbArray.Green);
        VideoPortWritePortUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[i].RgbArray.Blue);
    }

    return TRUE;
}
Пример #5
0
VOID
DevSetPanel(
    PHW_DEVICE_EXTENSION HwDeviceExtension,
    PUCHAR pMessage
    )

/*++


Routine Description:

    Writes out a four byte message to the Dell LCD display panel on
    the front of the machine. This should probably exist as an IOCTL
    (along with the set mode code from above).

Arguments:

    HwDeviceExtension - Pointer to the miniport driver's device extension.
    PUCHAR - ASCII string (4 characters always used)

Return Value:

    None.

--*/
{
    PUCHAR pPanel;

    VideoDebugPrint((2, "DGX: DevSetPanel\n"));

    pPanel = (PUCHAR)HwDeviceExtension->FrontPanel;
    pPanel += 3;

    VideoPortWritePortUchar( pPanel--, *pMessage++ );
    VideoPortWritePortUchar( pPanel--, *pMessage++ );
    VideoPortWritePortUchar( pPanel--, *pMessage++ );
    VideoPortWritePortUchar( pPanel,   *pMessage++ );
}
Пример #6
0
VP_STATUS
VgaInterpretCmdStream(
    PHW_DEVICE_EXTENSION HwDeviceExtension,
    PUSHORT pusCmdStream
    )

/*++

Routine Description:

    Interprets the appropriate command array to set up VGA registers for the
    requested mode. Typically used to set the VGA into a particular mode by
    programming all of the registers

Arguments:

    HwDeviceExtension - Pointer to the miniport driver's device extension.

    pusCmdStream - array of commands to be interpreted.

Return Value:

    The status of the operation (can only fail on a bad command); TRUE for
    success, FALSE for failure.

--*/

{
    ULONG ulCmd;
    ULONG ulPort;
    UCHAR jValue;
    USHORT usValue;
    ULONG culCount;
    ULONG ulIndex;
    ULONG ulBase;

    if (pusCmdStream == NULL) {

        VideoDebugPrint((1, "VgaInterpretCmdStream - Invalid pusCmdStream\n"));
        return TRUE;
    }

    ulBase = (ULONG)HwDeviceExtension->IOAddress;

    //
    // Now set the adapter to the desired mode.
    //

    while ((ulCmd = *pusCmdStream++) != EOD) {

        //
        // Determine major command type
        //

        switch (ulCmd & 0xF0) {

            //
            // Basic input/output command
            //

            case INOUT:

                //
                // Determine type of inout instruction
                //

                if (!(ulCmd & IO)) {

                    //
                    // Out instruction. Single or multiple outs?
                    //

                    if (!(ulCmd & MULTI)) {

                        //
                        // Single out. Byte or word out?
                        //

                        if (!(ulCmd & BW)) {

                            //
                            // Single byte out
                            //

                            ulPort = *pusCmdStream++;
                            jValue = (UCHAR) *pusCmdStream++;
                            VideoPortWritePortUchar((PUCHAR)(ulBase+ulPort),
                                    jValue);

                        } else {

                            //
                            // Single word out
                            //

                            ulPort = *pusCmdStream++;
                            usValue = *pusCmdStream++;
                            VideoPortWritePortUshort((PUSHORT)(ulBase+ulPort),
                                    usValue);

                        }

                    } else {

                        //
                        // Output a string of values
                        // Byte or word outs?
                        //

                        if (!(ulCmd & BW)) {

                            //
                            // String byte outs. Do in a loop; can't use
                            // VideoPortWritePortBufferUchar because the data
                            // is in USHORT form
                            //

                            ulPort = ulBase + *pusCmdStream++;
                            culCount = *pusCmdStream++;

                            while (culCount--) {
                                jValue = (UCHAR) *pusCmdStream++;
                                VideoPortWritePortUchar((PUCHAR)ulPort,
                                        jValue);

                            }

                        } else {

                            //
                            // String word outs
                            //

                            ulPort = *pusCmdStream++;
                            culCount = *pusCmdStream++;
                            VideoPortWritePortBufferUshort((PUSHORT)
                                    (ulBase + ulPort), pusCmdStream, culCount);
                            pusCmdStream += culCount;

                        }
                    }

                } else {

                    // In instruction
                    //
                    // Currently, string in instructions aren't supported; all
                    // in instructions are handled as single-byte ins
                    //
                    // Byte or word in?
                    //

                    if (!(ulCmd & BW)) {
                        //
                        // Single byte in
                        //

                        ulPort = *pusCmdStream++;
                        jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);

                    } else {

                        //
                        // Single word in
                        //

                        ulPort = *pusCmdStream++;
                        usValue = VideoPortReadPortUshort((PUSHORT)
                                (ulBase+ulPort));

                    }

                }

                break;

            //
            // Higher-level input/output commands
            //

            case METAOUT:

                //
                // Determine type of metaout command, based on minor
                // command field
                //
                switch (ulCmd & 0x0F) {

                    //
                    // Indexed outs
                    //

                    case INDXOUT:

                        ulPort = ulBase + *pusCmdStream++;
                        culCount = *pusCmdStream++;
                        ulIndex = *pusCmdStream++;

                        while (culCount--) {

                            usValue = (USHORT) (ulIndex +
                                      (((ULONG)(*pusCmdStream++)) << 8));
                            VideoPortWritePortUshort((PUSHORT)ulPort, usValue);

                            ulIndex++;

                        }

                        break;

                    //
                    // Masked out (read, AND, XOR, write)
                    //

                    case MASKOUT:

                        ulPort = *pusCmdStream++;
                        jValue = VideoPortReadPortUchar((PUCHAR)ulBase+ulPort);
                        jValue &= *pusCmdStream++;
                        jValue ^= *pusCmdStream++;
                        VideoPortWritePortUchar((PUCHAR)ulBase + ulPort,
                                jValue);
                        break;

                    //
                    // Attribute Controller out
                    //

                    case ATCOUT:

                        ulPort = ulBase + *pusCmdStream++;
                        culCount = *pusCmdStream++;
                        ulIndex = *pusCmdStream++;

                        while (culCount--) {

                            // Write Attribute Controller index
                            VideoPortWritePortUchar((PUCHAR)ulPort,
                                    (UCHAR)ulIndex);

                            // Write Attribute Controller data
                            jValue = (UCHAR) *pusCmdStream++;
                            VideoPortWritePortUchar((PUCHAR)ulPort, jValue);

                            ulIndex++;

                        }

                        break;

                    //
                    // None of the above; error
                    //
                    default:

                        return FALSE;

                }


                break;

            //
            // NOP
            //

            case NCMD:

                break;

            //
            // Unknown command; error
            //

            default:

                return FALSE;

        }

    }

    return TRUE;

} // end VgaInterpretCmdStream()
Пример #7
0
VP_STATUS
VgaSetMode(
    PHW_DEVICE_EXTENSION HwDeviceExtension,
    PVIDEO_MODE Mode,
    ULONG ModeSize
    )

/*++

Routine Description:

    This routine sets the vga into the requested mode.

Arguments:

    HwDeviceExtension - Pointer to the miniport driver's device extension.

    Mode - Pointer to the structure containing the information about the
        font to be set.

    ModeSize - Length of the input buffer supplied by the user.

Return Value:

    ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough
        for the input data.

    ERROR_INVALID_PARAMETER if the mode number is invalid.

    NO_ERROR if the operation completed successfully.

--*/

{

    PVIDEOMODE pRequestedMode;
    VP_STATUS status;

#ifdef INT10_MODE_SET
    VIDEO_X86_BIOS_ARGUMENTS biosArguments;
#endif

    //
    // Check if the size of the data in the input buffer is large enough.
    //

    if (ModeSize < sizeof(VIDEO_MODE)) {

        return ERROR_INSUFFICIENT_BUFFER;

    }

    //
    // Extract the clear memory bit.
    //

    if (Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY) {

        Mode->RequestedMode &= ~VIDEO_MODE_NO_ZERO_MEMORY;

    }  else {

        VgaZeroVideoMemory(HwDeviceExtension);

    }

    //
    // Check to see if we are requesting a valid mode
    //

    if ( (Mode->RequestedMode >= NumVideoModes) ||
         (!ModesVGA[Mode->RequestedMode].ValidMode) ) {

        return ERROR_INVALID_PARAMETER;

    }

    pRequestedMode = &ModesVGA[Mode->RequestedMode];

#ifdef INT10_MODE_SET

    VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));

    biosArguments.Ebx = pRequestedMode->Int10ModeNumber;

    if (biosArguments.Ebx != 0) {

        biosArguments.Eax = 0x6f05;

        status = VideoPortInt10(HwDeviceExtension, &biosArguments);

        if (status != NO_ERROR) {

            return status;

        }
    }

#endif

    //
    // Call the interpreter
    //

    VgaInterpretCmdStream(HwDeviceExtension,
                          pRequestedMode->CmdStrings[HwDeviceExtension->AdapterType]);

#ifdef INT10_MODE_SET
{
    UCHAR temp;
    UCHAR dummy;
    UCHAR bIsColor;

    if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS)) {

            //
            // Fix to make sure we always set the colors in text mode to be
            // intensity, and not flashing
            // For this zero out the Mode Control Regsiter bit 3 (index 0x10
            // of the Attribute controller).
            //

            if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                    MISC_OUTPUT_REG_READ_PORT) & 0x01) {

                bIsColor = TRUE;

            } else {

                bIsColor = FALSE;

            }

            if (bIsColor) {

                dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                        INPUT_STATUS_1_COLOR);
            } else {

                dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                        INPUT_STATUS_1_MONO);
            }

            VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
                    ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE));
            temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                    ATT_DATA_READ_PORT);

            temp &= 0xF7;

            if (bIsColor) {

                dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                        INPUT_STATUS_1_COLOR);
            } else {

                dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                        INPUT_STATUS_1_MONO);
            }

            VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
                    ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE));
            VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
                    ATT_DATA_WRITE_PORT, temp);
    }
}

#endif

    //
    // Update the location of the physical frame buffer within video memory.
    //

    HwDeviceExtension->PhysicalFrameLength =
            MemoryMaps[pRequestedMode->MemMap].MaxSize;

    HwDeviceExtension->PhysicalFrameBase.LowPart =
            MemoryMaps[pRequestedMode->MemMap].Start;

    //
    // Store the new mode value.
    //

    HwDeviceExtension->ModeIndex = Mode->RequestedMode;
    HwDeviceExtension->CurrentMode = pRequestedMode;

    return NO_ERROR;

} //end VgaSetMode()
Пример #8
0
VOID
DevInitDGX(
    PHW_DEVICE_EXTENSION HwDeviceExtension,
    PULONG pData,
    ULONG ulCount
    )

/*++

Routine Description:

    Initializes the modes and vars for the mode.

Arguments:

    HwDeviceExtension - Pointer to the miniport driver's device extension.

    pData - Mode set data

    ulCount - size of mode set data.

Return Value:

--*/

{
    PUCHAR pScreen, pReg;
    PULONG pSetMode;

    pScreen = (PUCHAR)(HwDeviceExtension->FrameAddress);

    //
    // Setup pointers to the interesting parts of the DAC
    //

    HwDeviceExtension->pCursorPositionReg = (PULONG)(pScreen + DAC_OFFSET
        + DAC_HWCURSORPOS);
    HwDeviceExtension->pControlRegA = (PULONG)(pScreen + DAC_OFFSET
        + DAC_CONTROLREGA);
    HwDeviceExtension->pPaletteRegs = (PULONG)(pScreen + DAC_OFFSET
        + DAC_PALETTE);
    HwDeviceExtension->pHardWareCursorAddr = (PULONG)(pScreen + DAC_OFFSET
        + DAC_HWCURSORSHAPE);

    //
    // reset the jaws adapter
    //

    if (HwDeviceExtension->ModelNumber == 1) {

        VideoPortWritePortUchar((PUCHAR)(HwDeviceExtension->DGX1Misc),
                (UCHAR)0x24);
        DacDelay();

        pReg = (PUCHAR)(HwDeviceExtension->DGXControlPorts);
        pReg += 4;

        VideoPortWritePortUchar(pReg,(UCHAR)4);
        DacDelay();

        VideoPortWritePortUchar((PUCHAR)(HwDeviceExtension->DGX1OutputPort),
                (UCHAR)4);
        DacDelay();

        VideoPortWritePortUchar(pReg, (UCHAR)1);
        DacDelay();

    } else {

        pReg = (PUCHAR)(HwDeviceExtension->DGXControlPorts);
        pReg += 8;

        VideoPortWritePortUchar(pReg, (UCHAR)0x15);
        DacDelay();

        VideoPortWritePortUchar(pReg, (UCHAR)5);
        DacDelay();

        VideoPortWritePortUchar(pReg, (UCHAR)0x45);
        DacDelay();
    }

    //
    // Set the mode
    //

    while (ulCount--) {

        pSetMode = (PULONG)(pScreen + DAC_OFFSET + *pData++);

        if (*pData == 0xFFFFFFFF) {

            DacDelay();
            pData++;

        } else {

            VideoDebugPrint((3,"%lx <- %lx\n",pSetMode, *pData));
            *pSetMode = *pData++;
        }
        DacDelay();
    }

    //
    // set HW cursor colors;
    //

    pSetMode = (PULONG)(pScreen + DAC_OFFSET + DAC_HWCURSORCOLOR);

    *pSetMode++ = 0;                // Black
    DacDelay();
    *pSetMode++ = 0xffffffff;       // White
    DacDelay();
    *pSetMode = 0xffffffff;         // White (Not Used)
    DacDelay();

    DevPointerOff(HwDeviceExtension);
    VideoDebugPrint((2, "DGX: DevInitDGXComplete\n"));
}
Пример #9
0
VP_STATUS
VgaSetMode(
    PHW_DEVICE_EXTENSION HwDeviceExtension,
    PVIDEO_MODE Mode,
    ULONG ModeSize
    )

/*++

Routine Description:

    This routine sets the VGA into the requested mode.

Arguments:

    HwDeviceExtension - Pointer to the miniport driver's device extension.

    Mode - Pointer to the structure containing the information about the
        font to be set.

    ModeSize - Length of the input buffer supplied by the user.

Return Value:

    ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough
        for the input data.

    ERROR_INVALID_PARAMETER if the mode number is invalid.

    NO_ERROR if the operation completed successfully.

--*/

{

   PVIDEOMODE pRequestedMode;
   VP_STATUS status;

   //
   // Check if the size of the data in the input buffer is large enough.
   //

   if (ModeSize < sizeof(VIDEO_MODE)) {

       return ERROR_INSUFFICIENT_BUFFER;

   }

   //
   // Extract the clear memory bit.
   //

   if (Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY) {

       Mode->RequestedMode &= ~VIDEO_MODE_NO_ZERO_MEMORY;

   }  else {

       VgaZeroVideoMemory(HwDeviceExtension);

   }

   //
   // Check to see if we are requesting a valid mode
   //

   if ((Mode->RequestedMode >= NUM_VIDEO_MODES) ||
       (!ModesVGA[Mode->RequestedMode].ValidMode)) {

       VideoDebugPrint((0,"AVGA.sys: VGASetMode - ERROR_INVALID_PARAMETER.\n"));
       return ERROR_INVALID_PARAMETER;

   }

    pRequestedMode = &ModesVGA[Mode->RequestedMode];
    HwDeviceExtension->ModeIndex = Mode->RequestedMode;


    //
    // Store the new mode value.
    //

    HwDeviceExtension->CurrentMode = pRequestedMode;

#ifdef INT10_MODE_SET
{

    VIDEO_X86_BIOS_ARGUMENTS biosArguments;
    UCHAR temp;
    UCHAR dummy;
    UCHAR bIsColor;

    /***********************************************************************
    ***   There appears to be a problem with some application            ***
    ***   which reset the first 16 palette registers.                    ***
    ***   Since the palette is not reset when going to and               ***
    ***   from text modes by doing a set mode (instead of                ***
    ***   the hardware save restore), some colors might not              ***
    ***   appear as expected in the text modes.  The bios                ***
    ***   calls seem to reload the palette so Andre Vachon               ***
    ***   suggested that we implement an Int10 mode set for the          ***
    ***   text modes.                                                    ***
    ***   To accomplish this, we need to hard code the first             ***
    ***   three modes in modeset.h in the following switch.              ***
    ***   If more text modes are added to modeset.h, their               ***
    ***   index must be added to this switch statement.                  ***
    ***********************************************************************/
    VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
    switch (Mode->RequestedMode) {
       case 0:                               // 720x400
                    /***********************************************************************
          ***   Prepare the card for the VGA mode 3+ instead of the CGA mode 3  ***
                    ***********************************************************************/
         biosArguments.Eax = 0x1202;              // Select Scan line number
          biosArguments.Ebx = 0x0030;             // to be 400 scan lines
          status = VideoPortInt10(HwDeviceExtension, &biosArguments);

          /***********************************************************************
          ***   Set the video mode to BIOS mode 3.                              ***
          ***********************************************************************/
                    VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
          biosArguments.Eax = 0x03;          // bios mode 0x03
          status = VideoPortInt10(HwDeviceExtension, &biosArguments);
          break;
       case 1:                               // 640x350
          /***********************************************************************
          ***   Prepare the card for the EGA mode 3* instead of the CGA mode 3  ***
          ***********************************************************************/
         biosArguments.Eax = 0x1201;              // Select Scan line number
          biosArguments.Ebx = 0x0030;             // to be 350 scan lines
          status = VideoPortInt10(HwDeviceExtension, &biosArguments);

                    /***********************************************************************
          ***   Set the video mode to BIOS mode 3.                              ***
                    ***********************************************************************/
                    VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
          biosArguments.Eax = 0x03;          // bios mode 0x03
          status = VideoPortInt10(HwDeviceExtension, &biosArguments);
          break;

       default:                              // all graphics modes are
                                             // handled by the default case
          biosArguments.Eax = pRequestedMode->Int10ModeNumber;
          status = VideoPortInt10(HwDeviceExtension, &biosArguments);
          break;

    }

    if (status != NO_ERROR) {
        return status;
    }

    //
    // Fix to get 640x350 text mode
    //

    if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS)) {

//        if ((pRequestedMode->hres == 640) &&
//            (pRequestedMode->vres == 350)) {
//
//            VgaInterpretCmdStream(HwDeviceExtension, VGA_TEXT_1);
//
//        } else {

            //
            // Fix to make sure we always set the colors in text mode to be
            // intensity, and not flashing
            // For this zero out the Mode Control Regsiter bit 3 (index 0x10
            // of the Attribute controller).
            //

            if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                    MISC_OUTPUT_REG_READ_PORT) & 0x01) {

                bIsColor = TRUE;

            } else {

                bIsColor = FALSE;

            }

            if (bIsColor) {

                dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                        INPUT_STATUS_1_COLOR);
            } else {

                dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                        INPUT_STATUS_1_MONO);
            }

            VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
                    ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE));
            temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                    ATT_DATA_READ_PORT);

            temp &= 0xF7;

            if (bIsColor) {

                dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                        INPUT_STATUS_1_COLOR);
            } else {

                dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
                        INPUT_STATUS_1_MONO);
            }

            VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
                    ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE));
            VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
                    ATT_DATA_WRITE_PORT, temp);
//        }
    }
}
#else
    VgaInterpretCmdStream(HwDeviceExtension, pRequestedMode->CmdStrings);
#endif

    //
    // Update the location of the physical frame buffer within video memory.
    //

    HwDeviceExtension->PhysicalFrameLength =
            MemoryMaps[pRequestedMode->MemMap].MaxSize;

    HwDeviceExtension->PhysicalFrameBase.LowPart =
            MemoryMaps[pRequestedMode->MemMap].Start;

    return NO_ERROR;

} // end VgaSetMode()
Пример #10
0
static VOID FASTCALL
vgaSetRegisters(PVGA_REGISTERS Registers)
{
   UCHAR i;

   /* Update misc output register */
   VideoPortWritePortUchar(MISC, Registers->Misc);

   /* Synchronous reset on */
   VideoPortWritePortUchar(SEQ, 0x00);
   VideoPortWritePortUchar(SEQDATA, 0x01);

   /* Write sequencer registers */
   for (i = 1; i < sizeof(Registers->Sequencer); i++)
   {
      VideoPortWritePortUchar(SEQ, i);
      VideoPortWritePortUchar(SEQDATA, Registers->Sequencer[i]);
   }

   /* Synchronous reset off */
   VideoPortWritePortUchar(SEQ, 0x00);
   VideoPortWritePortUchar(SEQDATA, 0x03);

   /* Deprotect CRT registers 0-7 */
   VideoPortWritePortUchar(CRTC, 0x11);
   VideoPortWritePortUchar(CRTCDATA, Registers->CRT[0x11] & 0x7f);

   /* Write CRT registers */
   for (i = 0; i < sizeof(Registers->CRT); i++)
   {
      VideoPortWritePortUchar(CRTC, i);
      VideoPortWritePortUchar(CRTCDATA, Registers->CRT[i]);
   }

   /* Write graphics controller registers */
   for (i = 0; i < sizeof(Registers->Graphics); i++)
   {
      VideoPortWritePortUchar(GRAPHICS, i);
      VideoPortWritePortUchar(GRAPHICSDATA, Registers->Graphics[i]);
   }

   /* Write attribute controller registers */
   for (i = 0; i < sizeof(Registers->Attribute); i++)
   {
      VideoPortReadPortUchar(STATUS);
      VideoPortWritePortUchar(ATTRIB, i);
      VideoPortWritePortUchar(ATTRIB, Registers->Attribute[i]);
   }

   /* Renable screen. */
   VideoPortWritePortUchar(ATTRIB, 0x20);
}
Пример #11
0
static BOOLEAN
ReadfromSMBus(UCHAR Address, UCHAR bRegister, UCHAR Size, ULONG *Data_to_smbus)
{
  int nRetriesToLive=50;

  while (0 != (VideoPortReadPortUshort((PUSHORT) (I2C_IO_BASE + 0)) & 0x0800))
    {
      ;  /* Franz's spin while bus busy with any master traffic */
    }

  while (0 != nRetriesToLive--)
    {
      UCHAR b;
      int temp;

      VideoPortWritePortUchar((PUCHAR) (I2C_IO_BASE + 4), (Address << 1) | 1);
      VideoPortWritePortUchar((PUCHAR) (I2C_IO_BASE + 8), bRegister);

      temp = VideoPortReadPortUshort((PUSHORT) (I2C_IO_BASE + 0));
      VideoPortWritePortUshort((PUSHORT) (I2C_IO_BASE + 0), temp);  /* clear down all preexisting errors */

      switch (Size)
        {
          case 4:
            VideoPortWritePortUchar((PUCHAR) (I2C_IO_BASE + 2), 0x0d);      /* DWORD modus ? */
            break;
          case 2:
            VideoPortWritePortUchar((PUCHAR) (I2C_IO_BASE + 2), 0x0b);      /* WORD modus */
            break;
          default:
            VideoPortWritePortUchar((PUCHAR) (I2C_IO_BASE + 2), 0x0a);      // BYTE
            break;
        }

      b = 0;

      while (0 == (b & 0x36))
        {
          b = VideoPortReadPortUchar((PUCHAR) (I2C_IO_BASE + 0));
        }

      if (0 != (b & 0x24))
        {
          /* printf("I2CTransmitByteGetReturn error %x\n", b); */
        }

      if(0 == (b & 0x10))
        {
          /* printf("I2CTransmitByteGetReturn no complete, retry\n"); */
        }
      else
        {
          switch (Size)
            {
              case 4:
                VideoPortReadPortUchar((PUCHAR) (I2C_IO_BASE + 6));
                VideoPortReadPortUchar((PUCHAR) (I2C_IO_BASE + 9));
                VideoPortReadPortUchar((PUCHAR) (I2C_IO_BASE + 9));
                VideoPortReadPortUchar((PUCHAR) (I2C_IO_BASE + 9));
                VideoPortReadPortUchar((PUCHAR) (I2C_IO_BASE + 9));
                break;
              case 2:
                *Data_to_smbus = VideoPortReadPortUshort((PUSHORT) (I2C_IO_BASE + 6));
                break;
              default:
                *Data_to_smbus = VideoPortReadPortUchar((PUCHAR) (I2C_IO_BASE + 6));
                break;
            }


          return TRUE;
        }
    }

  return FALSE;
}
Пример #12
0
VP_STATUS
NTAPI
VbeSetColorLookup(IN PHW_DEVICE_EXTENSION VgaExtension,
                  IN PVIDEO_CLUT ClutBuffer)
{
    PVBE_COLOR_REGISTER VesaClut;
    INT10_BIOS_ARGUMENTS BiosArguments;
    PVOID Context;
    ULONG Entries;
    ULONG BufferSize = 4 * 1024;
    USHORT TrampolineMemorySegment, TrampolineMemoryOffset;
    VP_STATUS Status;
    USHORT i;
    PVIDEOMODE CurrentMode = VgaExtension->CurrentMode;

    Entries = ClutBuffer->NumEntries;
    
    VideoDebugPrint((0, "Setting %lu entries.\n", Entries));
    
    /* 
     * For Vga compatible modes, write them directly.
     * Otherwise, the LGPL VGABIOS (used in bochs) fails!
     * It is also said that this way is faster.
     */
    if(!CurrentMode->NonVgaMode)
    {
        for (i=ClutBuffer->FirstEntry; i<ClutBuffer->FirstEntry + Entries; i++)
        {
            VideoPortWritePortUchar((PUCHAR)0x03c8, i);
            VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Red);
            VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Green);
            VideoPortWritePortUchar((PUCHAR)0x03c9, ClutBuffer->LookupTable[i].RgbArray.Blue);
        }
        return NO_ERROR;
    }

    /* Allocate INT10 context/buffer */
    VesaClut = VideoPortAllocatePool(VgaExtension, 1, sizeof(ULONG) * Entries, ' agV');
    if (!VesaClut) return ERROR_INVALID_PARAMETER;
    if (!VgaExtension->Int10Interface.Size) return ERROR_INVALID_PARAMETER;
    Context = VgaExtension->Int10Interface.Context;
    Status = VgaExtension->Int10Interface.Int10AllocateBuffer(Context,
                                                            &TrampolineMemorySegment,
                                                            &TrampolineMemoryOffset,
                                                            &BufferSize);
    if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER;

    /* VESA has color registers backward! */
    for (i = 0; i < Entries; i++)
    {
        VesaClut[i].Blue = ClutBuffer->LookupTable[i].RgbArray.Blue;
        VesaClut[i].Green = ClutBuffer->LookupTable[i].RgbArray.Green;
        VesaClut[i].Red = ClutBuffer->LookupTable[i].RgbArray.Red;
        VesaClut[i].Pad = 0;
    }
    Status = VgaExtension->Int10Interface.Int10WriteMemory(Context,
                                                         TrampolineMemorySegment,
                                                         TrampolineMemoryOffset,
                                                         VesaClut,
                                                         Entries * sizeof(ULONG));
    if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER;

    /* Write the palette */
    VideoPortZeroMemory(&BiosArguments, sizeof(BiosArguments));
    BiosArguments.Ebx = 0;
    BiosArguments.Ecx = Entries;
    BiosArguments.Edx = ClutBuffer->FirstEntry;
    BiosArguments.Edi = TrampolineMemoryOffset;
    BiosArguments.SegEs = TrampolineMemorySegment;
    BiosArguments.Eax = VBE_SET_GET_PALETTE_DATA;
    Status = VgaExtension->Int10Interface.Int10CallBios(Context, &BiosArguments);
    if (Status != NO_ERROR) return ERROR_INVALID_PARAMETER;
    VideoPortFreePool(VgaExtension, VesaClut);
    VideoDebugPrint((Error, "VBE Status: %lx\n", BiosArguments.Eax));
    if (VBE_GETRETURNCODE(BiosArguments.Eax) == VBE_SUCCESS)
        return NO_ERROR;
    return ERROR_INVALID_PARAMETER;
}
Пример #13
0
ULONG
QRY_ControllerASICID( PUCHAR IOAddress )
/*++
   Function: QRY_ControllerASICID

   This function returns the ASIC id of Compaq Video controllers.

   Return value:
    The return value is a ULONG with bytes defined as follows:

	       3   2  1  0    (byte positions)
    ULONG ---> XX FF FF FF
	       -- -- -- --
		|  |  |	 |____ASIC ID
		|  |  |_______Extended ID
		|  |__________Second Extended ID
		|_____________Not used (will be zero)

--*/
//---------------------------------------------------------------------------
{
   ULONG ulReturn = 0L;
   UCHAR ucTemp   = 0 ;

   // unlock QVision registers
   //
   VideoPortWritePortUchar((PUCHAR)(IOAddress + GRAPH_ADDRESS_PORT),
                            0x0f);
   ucTemp = VideoPortReadPortUchar((IOAddress + \
                                    GRAPH_DATA_PORT)) & 0xf0;
   VideoPortWritePortUchar((PUCHAR)(IOAddress + GRAPH_DATA_PORT),
                            (UCHAR)(0x05 | ucTemp));
   VideoPortWritePortUchar((PUCHAR)(IOAddress + GRAPH_ADDRESS_PORT),
                            0x10);
   ucTemp = VideoPortReadPortUchar((PUCHAR)(IOAddress + GRAPH_DATA_PORT));
   VideoPortWritePortUchar((PUCHAR)(IOAddress + GRAPH_DATA_PORT),
			    (UCHAR)(0x28 | ucTemp));

   //
   // get asic id
   //
   VideoPortWritePortUchar((PUCHAR)(IOAddress + GRAPH_ADDRESS_PORT), 0x0c);

   // read in asic id
   //
   ucTemp = VideoPortReadPortUchar(IOAddress + GRAPH_DATA_PORT) ;

   ulReturn = (ULONG)ucTemp;  // save asic id

   //
   // is extended id info available ?
   //
   if (ucTemp & EXTENDED_ID_BIT) {

      VideoPortWritePortUchar((PUCHAR)(IOAddress + GRAPH_ADDRESS_PORT), 0x0d);

      //
      // read in extended id
      //
      ucTemp = VideoPortReadPortUchar(IOAddress + GRAPH_DATA_PORT) ;
      ulReturn |= ((ULONG)(ucTemp)) << 8 ;

      //
      // is second extended id info available ?
      //
      if (ucTemp & EXTENDED_ID2_BIT) {

	 VideoPortWritePortUchar((PUCHAR)(IOAddress + GRAPH_ADDRESS_PORT), 0x0e);

	 //
	 // read in second extended id
	 //
	 ucTemp = VideoPortReadPortUchar(IOAddress + GRAPH_DATA_PORT) ;
	 ulReturn |= ((ULONG)(ucTemp)) << 16 ;
	 }
      }

 return (ulReturn);
}