<?xml version='1.0'?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->

<!-- Included from spec.xml -->

<mmlite-spec xmlns="x-schema:spec-schema.xml">

  <interface-group name="Graphics">
    <P>Interfaces for video and 2D/3D graphics.</P>
    <discussion>
      <P>Mostly TBD at this point.
      </P>
    </discussion>
  </interface-group>

  <interface name="IFrameBuffer" type="PIFRAMEBUFFER" extends="IUnknown"
             iid="00cd7721-3f64-4a15-a17d-1448515a701b">

    <P>Basic frame buffer interface.  </P>
    <P>Intended for direct access to hardware-supported 2D drawing surfaces.
    Exposes the associated memory (VRAM) and the palette, if present.
    </P>

<!-- Constants -->

    <constant name="FRAMEBUFFER_PROPERTY" type="UINT32" prefix="FB_PROP_" base="0">
      <P>Values for the <I>Property</I> argument in the <B>GetProperty</B> method.</P>
      <constant-value name="TOTAL_SIZE"        ordinal="0">
        <P>Total length, in bytes, of the frame buffer.</P>
      </constant-value>
      <constant-value name="HORIZONTAL_LENGTH"        ordinal="1">
        <P>Total length, in bytes, of one horizontal line (video scanline). Includes both the visible and the non visible portions.</P>
      </constant-value>
      <constant-value name="HORIZONTAL_VISIBLE_LENGTH"        ordinal="2">
        <P>Length in bytes of the visible portion of one horizontal line.</P>
      </constant-value>
      <constant-value name="HORIZONTAL_PORCH"        ordinal="3">
        <P>Length in bytes of the initial (left side) invisible portion of one horizontal line.
        Usually zero.</P>
      </constant-value>
      <constant-value name="VERTICAL_LENGTH"        ordinal="4">
        <P>Total number of scanlines. Includes both the visible and the non visible ones.</P>
      </constant-value>
      <constant-value name="VERTICAL_VISIBLE_LENGTH"        ordinal="5">
        <P>Number of visible scanlines.</P>
      </constant-value>
      <constant-value name="VERTICAL_PORCH"        ordinal="6">
        <P>Number of invisible scanlines at the start of the frame buffer.
        Usually zero.</P>
      </constant-value>
      <constant-value name="PIXEL_BITSIZE"        ordinal="7">
        <P>Number of effective bits in a pixel.</P>
      </constant-value>
      <constant-value name="PIXEL_BYTESIZE"        ordinal="8">
        <P>Number of bytes in a pixel. Accounts for spacing between adjecent pixels</P>
      </constant-value>
      <constant-value name="PIXEL_ENCODING"        ordinal="9">
        <P>The meaning of one pixel value, a constant of type <I>PIXEL_ENCODING</I> .
        A pixel value might be a simple index into a palette, or the encoding of coordinates in a color space such as RGB or YUV.
        </P>
      </constant-value>
      <constant-value name="MODE"        ordinal="10">
        <P>Summarization of the visual properties of the frame buffer, a constant of type <I>FRAMEBUFFER_MODE</I> </P>
      </constant-value>
      <constant-value name="PALETTE_LENGTH"        ordinal="11">
        <P>Number of addressable entries in the palette. Usually a power of 2.
         </P>
      </constant-value>
      <constant-value name="PALETTE_BITSIZE"        ordinal="12">
        <P>Number of effective bits in a palette entry.</P>
      </constant-value>
      <constant-value name="PALETTE_BYTESIZE"        ordinal="13">
        <P>Number of bytes in a palette entry. Accounts for any unused bits.</P>
      </constant-value>
      <constant-value name="PALETTE_ENCODING"        ordinal="14">
        <P>The meaning of one palette entry, a constant of type <I>PIXEL_ENCODING</I>.
        A palette entry is the encoding of coordinates in a color space such as RGB or YUV.
        </P>
      </constant-value>
    </constant>

    <constant name="FRAMEBUFFER_MODE" type="UINT32" prefix="FB_MODE_" base="0">
      <P>Values for <I>Mode</I> arguments in <B>IFrameBuffer</B>
      methods and returned values.</P>
      <constant-value name="320x200_in_320x400_8bpp_PALETTE"        ordinal="0">
        <P>Doom's favorite video mode.</P>
      </constant-value>
      <constant-value name="640x480_in_768x480_8bpp_PALETTE"        ordinal="1">
        <P>Another popular video mode.</P>
      </constant-value>
      <constant-value name="VGA_MODE13"        ordinal="2">
      </constant-value>
      <constant-value name="640x480_in_768x480_24bpp"        ordinal="3">
      </constant-value>
      <constant-value name="768x512_24bpp"        ordinal="4">
      </constant-value>
      <constant-value name="UNDEFINED"        ordinal="0xffffffff">
        <P>Mode has not been set yet.</P>
      </constant-value>
    </constant>

    <constant name="PIXEL_ENCODING" type="UINT32" prefix="PIXEL_TYPE_" base="0">
      <P>Meaning of a pixel value in the frame buffer memory or in the palette.</P>
      <constant-value name="PALETTE_INDEX"        ordinal="0">
        <P>A pixel value is an index into the associated palette.
        The value 0 will index the first entry in the palette, this in turn can be retrieved with <B>GetPaletteEntry</B> method.
        The encoding of a palette entry can be retrieved with the <B>GetProperty</B> method.
        </P>
      </constant-value>
      <constant-value name="R8G8B8"        ordinal="1">
        <P>A pixel value is an ordered triple of 8 bit values, one each for the red, green and blue components.
        </P>
      </constant-value>
      <constant-value name="R8G8B8X8"        ordinal="2">
        <P>A pixel value is an ordered triple of 8 bit values, one each for the red, green and blue components,
         followed by a padding byte.
        </P>
      </constant-value>
    </constant>

<!-- Methods -->

    <method name="Map">
      <P>Makes the frame buffer accessible to the caller.</P>
      <discussion>
        <P>
       </P>
      </discussion>
      <arg name="Where" type="PTR *"
           direction="inout" optional="false">
        <P>Address where the frame buffer should be mapped, passed by reference.
           If the pointed-to value is NULL the caller indicates no mapping preference
           and the implementation of this method will select an appropriate address.
           Note that this might be mandatory in the absence of virtual memory.
           Upon return, the field will contain the (virtual) address of the start of the frame buffer.
           An argument value of NULL is <B>not</B> acceptable.
        </P>
      </arg>
      <arg name="Length" type="UINT *"
           direction="inout" optional="false">
        <P>Length of the frame buffer to be mapped.
           If the pointed-to integer is 0 the whole frame buffer is mapped,
           otherwise only the requested initial portion of it.
           This value might be rounded up to a multiple of a pagesize in the presence of virtual memory.
           Upon return, this field will contain the mapped length in bytes of the frame buffer.
           An argument value of NULL is <B>not</B> acceptable.
        </P>
      </arg>
      <return-value value="E_INVALID_PARAMETER">
        <P>The combination of in/out values was unacceptable.</P>
      </return-value>
    </method>

    <method name="Unmap">
      <P>Makes the frame buffer unaccessible to the caller.</P>
      <discussion>
        <P>The call might fail in the absence of hardware memory protection.
       </P>
      </discussion>
      <arg name="Where" type="PTR"
           direction="inout" optional="true">
        <P>Address where the frame buffer had previously been mapped.
           An argument value of NULL <B>might be</B> acceptable,
           depending on the implementation,
            and will remove all the mappings of the frame buffer.
        </P>
      </arg>
      <return-value value="E_INVALID_PARAMETER">
        <P>The frame buffer was never mapped as indicated.</P>
      </return-value>
    </method>

    <method name="GetProperty">
      <P>Returns one of the properties of the frame buffer.</P>
      <discussion>
        <P> </P>
      </discussion>
      <arg name="Property" type="FRAMEBUFFER_PROPERTY">
        <P>The desired property.</P>
      </arg>
      <arg name="Value" type="UINT32 *"
           direction="inout" optional="false">
        <P>Where to return the current value of the desired property.</P>
      </arg>
      <return-value value="E_INVALID_PARAMETER">
        <P>Invalid property or pointer argument.</P>
      </return-value>
    </method>

    <method name="SetMode">
      <P>Atomically change a number of properties of the frame buffer.</P>
      <discussion>
        <P></P>
      </discussion>
      <arg name="Mode" type="FRAMEBUFFER_MODE" >
        <P>The desired video mode.</P>
      </arg>
      <return-value value="E_INVALID_PARAMETER">
        <P>Something is wrong with the arguments.</P>
      </return-value>
      <return-value value="E_NOT_IMPLEMENTED">
        <P>This frame buffer does not implement the given mode.</P>
      </return-value>
    </method>

    <method name="GetPalette">
      <P>Returns the entire content of the palette associated with the frame buffer.</P>
      <discussion>
        <P>This might be faster than asking for individual entries,
        for instance if the hardware uses auto-increment.</P>
      </discussion>
      <arg name="Buffer" type="UINT8*" direction="out" optional="false">
        <P>The buffer where to return the palette contents.</P>
      </arg>
      <arg name="Length" type="UINT">
        <P>Length of the passed buffer.</P>
      </arg>
      <arg name="ExpectedPixelFormat" type="PIXEL_ENCODING">
        <P>Format in which the palette should be returned.
        The call might fail if this is not the same format returned
        as the <I>PALETTE_ENCODING</I> property of the frame buffer.
        </P>
      </arg>
      <return-value value="E_INVALID_PARAMETER">
        <P>The buffer or its length are unacceptable.</P>
      </return-value>
    </method>
    
    <method name="GetPaletteEntry">
      <P>Returns an individual entry in the palette associated with the frame buffer.</P>
      <discussion>
        <P>There have been cases of palettes that are only readable in full,
        in one such case this call might fail.</P>
      </discussion>
      <arg name="Index" type="UINT" >
        <P>The index of the desired entry, starting at 0.</P>
      </arg>
      <arg name="Buffer" type="UINT8*" direction="out" optional="false">
        <P>The buffer where to return the palette entry.</P>
      </arg>
      <arg name="Length" type="UINT">
        <P>Length of the passed buffer.</P>
      </arg>
      <arg name="ExpectedPixelFormat" type="PIXEL_ENCODING">
        <P>Format in which the palette should be returned.
        The call might fail if this is not the same format returned
        as the <I>PALETTE_ENCODING</I> property of the frame buffer.
        </P>
      </arg>
      <return-value value="E_INVALID_PARAMETER">
        <P>The index is invalid or the buffer is unacceptable.</P>
      </return-value>
    </method>
    
    <method name="SetPalette">
      <P>Changes the entire content of the palette associated with the frame buffer.</P>
      <discussion>
        <P>This might be faster than changing individual entries,
        for instance if the hardware uses auto-increment.</P>
      </discussion>
      <arg name="Buffer" type="const UINT8*" direction="in" optional="false">
        <P>The buffer with the palette contents.</P>
      </arg>
      <arg name="Length" type="UINT">
        <P>Length of the passed buffer.</P>
      </arg>
      <arg name="PixelFormat" type="PIXEL_ENCODING">
        <P>Format of entries in the palette.
        The call might fail if this is not the same format returned
        as the <I>PALETTE_ENCODING</I> property of the frame buffer.
        </P>
      </arg>
      <return-value value="E_INVALID_PARAMETER">
        <P>The buffer or its length are unacceptable.</P>
      </return-value>
    </method>
    
    <method name="SetPaletteEntry">
      <P>Changes an individual entry in the palette associated with the frame buffer.</P>
      <discussion>
        <P>There have been cases of palettes that are only writeable in full,
        in one such case this call might fail.</P>
      </discussion>
      <arg name="Index" type="UINT" >
        <P>The index of the desired entry, starting at 0.</P>
      </arg>
      <arg name="Buffer" type="const UINT8*" direction="in" optional="false">
        <P>The buffer with the palette entry contents.</P>
      </arg>
      <arg name="Length" type="UINT">
        <P>Length of the passed buffer.</P>
      </arg>
      <arg name="PixelFormat" type="PIXEL_ENCODING">
        <P>Format of entries in the palette.
        The call might fail if this is not the same format returned
        as the <I>PALETTE_ENCODING</I> property of the frame buffer.
        </P>
      </arg>
      <return-value value="E_INVALID_PARAMETER">
        <P>The index is invalid or the buffer is unacceptable.</P>
      </return-value>
    </method>
    
    <constructor>
      <P>Basic constructor for most frame buffers.</P>
      <arg name="BaseAddress" type="ADDRESS">
        <P>Identifies the frame buffer in the I/O space.
           Could be a busmaster reference.
        </P>
      </arg>
      <arg name="PaletteAddress" type="ADDRESS">
        <P>Identifies the palette in the I/O space.
        </P>
      </arg>
    </constructor>

  </interface>

<!-- Constructor interface is IDeviceConstructor -->

</mmlite-spec>


