home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 45 / cda45.iso / Linux / XFree86-4.0 / doc / README.DGA < prev    next >
Encoding:
Text File  |  2000-03-09  |  13.5 KB  |  482 lines

  1.                    XFree86-DGA Extension version 2.0
  2.  
  3.    The XFree86-DGA extension is an X server extension for allowing client
  4. programs direct access to the video frame buffer.
  5.  
  6.    This is a brief description of the programming interface for the
  7. XFree86-DGA extension.  This describes version 2.0, which is the second
  8. official version.  The functions described here are found in the library
  9. libXxf86dga.a, and their prototypes are in <X11/extensions/xf86dga.h>.
  10.  
  11.    XFree86 DGA is not intended as a direct rendering API, but rather,
  12. as a mechanism to "get the X-Server out of the way" so that a direct
  13. rendering API, such as OpenGL, can have full access to the hardware.
  14. With this in mind, DGA does provide clients some direct access to
  15. the hardware without requiring a separate rendering API, but this
  16. access is limited to direct linear framebuffer access.
  17.  
  18.    DGA is initialized by passing a number corresponding to a valid
  19. XDGAMode to XDGASetMode().  Clients can get a list of valid modes
  20. from XDGAQueryModes().  Each XDGAMode corresponds to a different
  21. framebuffer layout.
  22.  
  23. typedef struct {
  24.    int num;            
  25.    char *name;          
  26.    float verticalRefresh;
  27.    int flags;           
  28.    int imageWidth;      
  29.    int imageHeight;
  30.    int pixmapWidth;     
  31.    int pixmapHeight;    
  32.    int bytesPerScanline; 
  33.    int byteOrder;       
  34.    int depth;           
  35.    int bitsPerPixel;
  36.    unsigned long redMask;
  37.    unsigned long greenMask;
  38.    unsigned long blueMask;
  39.    short visualClass;
  40.    int viewportWidth;
  41.    int viewportHeight;
  42.    int xViewportStep;   
  43.    int yViewportStep;
  44.    int maxViewportX;    
  45.    int maxViewportY;
  46.    int viewportFlags;   
  47. } XDGAMode;
  48.  
  49.    num
  50.  
  51.     A unique identifying number (num > 0) for the mode.  This is the
  52.     number referenced when initializing the mode.
  53.  
  54.    name
  55.  
  56.     The name of the corresponding modeline as given in the XF86Config file.
  57.  
  58.    verticalRefresh
  59.  
  60.     The vertical refresh rate for the modeline (in Hz).
  61.  
  62.    flags
  63.     
  64.     Any of the following may be OR'd together:
  65.  
  66.     XDGAConcurrentAccess
  67.  
  68.        Indicates that concurrent client/server access to the 
  69.        framebuffer is possible.  If this flag is not set it is
  70.        very important to call XDGASync() before directly accessing
  71.        the framebuffer if a call to XDGAFillRectangle(),
  72.        XDGACopyArea() or XDGACopyTransparentArea() or any Xlib
  73.        rendering function has been made prior to such accesses.
  74.  
  75.     XDGASolidFillRect
  76.  
  77.        Indicates that XDGAFillRectangle() is supported.
  78.  
  79.     XDGABlitRect
  80.  
  81.        Indicates that XDGACopyArea() is supported.
  82.  
  83.     XDGABlitTransRect
  84.  
  85.        Indicates that XDGACopyTransparentArea() is supported.
  86.  
  87.     XDGAPixmap
  88.  
  89.        Indicates that a Pixmap will be returned when the mode is
  90.        initialized.  This means that rendering with Xlib is possible
  91.        for this mode.
  92.  
  93.     XDGAInterlaced
  94.     XDGADoublescan
  95.     
  96.        Indicates that the mode is an interlaced or doublescan mode.
  97.         
  98.  
  99.    imageWidth
  100.    imageHeight
  101.  
  102.     The width and height of the framebuffer area accessible by the client.
  103.     This rectangle is always justified to the upper left-hand corner.
  104.  
  105.    pixmapWidth
  106.    pixmapHeight
  107.  
  108.     The width and height of the framebuffer area accessible by Xlib.
  109.     This rectangle is always justified to the upper left-hand corner.
  110.     These fields are only valid if the XDGAPixmap flag is set in the
  111.         "flags" field.
  112.  
  113.    bytesPerScanline
  114.     
  115.     The pitch of the framebuffer in bytes.
  116.  
  117.    byteOrder
  118.  
  119.     MSBFirst or LSBFirst.
  120.  
  121.    depth
  122.  
  123.     The number of bits in each pixel which contain usable data.
  124.  
  125.    bitsPerPixel
  126.  
  127.     The number of bits taken up by each pixel.
  128.  
  129.    redMask
  130.    greenMask
  131.    blueMask
  132.  
  133.     The RGB masks.  These do not apply to color-indexed modes.
  134.  
  135.    visualClass
  136.  
  137.     TrueColor, PseudoColor, DirectColor, etc...
  138.  
  139.    viewportWidth
  140.    viewportHeight
  141.  
  142.     The dimensions of the portion of the framebuffer which will be
  143.     displayed on the screen.
  144.  
  145.    xViewPortStep
  146.    yViewPortStep
  147.  
  148.     The granularity of the x,y viewport positioning possible with
  149.     the XDGASetViewport function.
  150.  
  151.    maxViewportX
  152.    maxViewportY
  153.  
  154.     The maximimum x and y positions possible with the XDGASetViewport
  155.     function.
  156.  
  157.    viewportFlags
  158.  
  159.     Any of the following may be OR'd together:
  160.  
  161.     XDGAFlipRetrace
  162.  
  163.         Indicates that the hardware can switch viewports during
  164.         the vertical retrace.
  165.  
  166.     XDGAFlipImmediate
  167.  
  168.         Indicates that the hardware can switch viewports immediately
  169.         without waiting for the vertical retrace.
  170.  
  171.  
  172.  
  173. XDGAMode* XDGAQueryModes(
  174.     Display     *dpy,
  175.     int         screen,
  176.     int         *num
  177. );
  178.  
  179.    XDGAQueryModes() returns a pointer to an array of XDGAModes which 
  180. are valid for the given screen.  "num" is the number of elements in the
  181. array.  The returned array can be freed with XFree();
  182.   
  183.  
  184.  
  185. XDGADevice* XDGASetMode(
  186.     Display     *dpy,
  187.     int         screen,
  188.     int         num
  189. );
  190.  
  191.    A XDGAMode will be initialized when its "num" is passed to
  192. XDGASetMode().  To exit DGA mode and return to normal server operation,
  193. pass number zero to XDGASetMode().  XDGASetMode() returns a pointer
  194. to an XDGADevice if successful.  The XDGADevice can be freed with
  195. XFree().
  196.  
  197.     struct {
  198.         XDGAMode mode;
  199.         unsigned char *data;
  200.         Pixmap pixmap;
  201.     } XDGADevice;
  202.  
  203.  
  204.     mode
  205.  
  206.     The XDGAMode structure, identical to the information returned
  207.     by XDGAQueryModes.
  208.  
  209.     data
  210.  
  211.     If direct framebuffer access is desired and possible, this field
  212.     will contain a pointer to the mapped framebuffer memory.  Generally,
  213.     this field will be zero unless a call to XDGAOpenFramebuffer()
  214.     is made prior to initialization of the mode.
  215.  
  216.     pixmap
  217.  
  218.     If the mode supports Xlib rendering as indicated by XDGAPixmap
  219.     in the flags field, this will contain a Pixmap handle suitable
  220.         for passing as the drawable argument to Xlib functions.  This
  221.     field will be zero if Xlib rendering is not supported.
  222.  
  223.  
  224. Bool XDGAQueryExtension(
  225.     Display     *dpy,
  226.     int         *eventBase,
  227.     int         *errorBase
  228. );
  229.  
  230.     XDGAQueryExtension() checks for the prescence of the extension
  231. and returns the event and error bases.
  232.  
  233.  
  234. Bool XDGAQueryVersion(
  235.     Display     *dpy,
  236.     int         *majorVersion,
  237.     int         *minorVersion
  238. );
  239.  
  240.     XDGAQueryVersion() returns the major and minor version numbers (duh).
  241.  
  242.  
  243. Bool XDGAOpenFramebuffer(
  244.     Display     *dpy,
  245.     int         screen
  246. );
  247.  
  248. void XDGACloseFramebuffer(
  249.     Display     *dpy,
  250.     int         screen
  251. );
  252.    
  253.  
  254.     XDGAOpenFramebuffer() maps the framebuffer memory.  The client
  255. needs sufficient privledges to be able to do this.
  256.  
  257.     XDGAOpenFramebuffer() should be called prior to initializing
  258. a dga mode if direct framebuffer access is desired for that mode.
  259. XDGAOpenFramebuffer() does not need to be called if direct framebuffer
  260. access is not required.   If the framebuffer is opened, 
  261. XDGACloseFramebuffer() should be called prior to client exit to 
  262. unmap the memory. 
  263.  
  264.  
  265.  
  266. void XDGAChangePixmapMode(
  267.     Display     *dpy,
  268.     int         screen,
  269.     int         *x,
  270.     int         *y,
  271.     int         mode
  272. );
  273.  
  274.    In the case where a Pixmap is available for Xlib rendering, this
  275. function allows changing between two pixmap sizes.  The following
  276. values for "mode" are possible.
  277.  
  278.    XDGAPixmapModeLarge
  279.     
  280.     The pixmap size is defined by the pixmapWidth and pixmapHeight
  281.     fields in the XDGAMode structure.  The "x" and "y" values are
  282.     ignored in this case.
  283.  
  284.    XDGAPixmapModeSmall
  285.     
  286.     The pixmap size is defined by the viewportWidth and viewportHeight
  287.     fields in the XDGAMode structure.  In this mode, the "x" and "y"
  288.     values specify where in the framebuffer this pixmap rectangle
  289.     is located.  It may be placed anywhere within the Xlib renderable
  290.     region described by the pixmapWidth and pixmapHeight fields in 
  291.     the XDGAMode.  The "x" and "y" values returned are the resultant
  292.     location of the pixmap and may be different from the requested
  293.     x,y location due to platform specific alignment constraints.
  294.     All Xlib rendering is clipped to this pixmap rectangle.
  295.  
  296.  
  297. void XDGASetViewport(
  298.     Display     *dpy,
  299.     int         screen,
  300.     int         x,
  301.     int         y,
  302.     int         flags
  303. );
  304.  
  305.     Set the upper left-hand corner of the rectangle of framebuffer
  306. that is to be displayed on the screen.  Not all locations may be
  307. supported by the hardware and requested locations will be adjusted
  308. according to the xViewPortStep and yViewPortStep fields in the XDGAMode.
  309.  
  310.     "flags" can be XDGAFlipRetrace or XDGAFlipImmediate to adjust
  311. the viewport location at the next vertical retrace or immediately.
  312. Values other than the supported values advertised in the mode's
  313. viewportFlags field will result in hardware-specific default behavior.
  314. XDGAFlipImmediate will block until the flip is completed. 
  315. XDGAFlipRetrace will generally NOT block so it is necessary to 
  316. monitor the viewport status with XDGAGetViewportStatus().
  317.  
  318.     FlipImmediate requests during pending FlipRetrace requests
  319. will be ignored.
  320.  
  321.  
  322. int XDGAGetViewportStatus(
  323.     Display     *dpy,
  324.     int         screen
  325. );
  326.  
  327.      
  328.    XDGAGetViewportStatus() keeps track of the XDGASetViewport() 
  329. requests still pending.  The return value of the function will
  330. have consecutive bits set (LSB justified), each bit representing
  331. a pending viewport change.  For example:
  332.  
  333.      while(XDGAGetViewportStatus(dpy, screen));
  334.  
  335.    waits for all pending viewport changes to finish.
  336.  
  337.      while(0x2 & XDGAGetViewportStatus(dpy, screen));
  338.  
  339.    waits until all but the last viewport changes have completed.
  340.  
  341.  
  342. Colormap XDGACreateColormap(
  343.     Display     *dpy,
  344.     int         screen,
  345.     XDGADevice  *device,
  346.     int         alloc
  347. );
  348.  
  349. void XDGAInstallColormap(
  350.     Display     *dpy,
  351.     int         screen,
  352.     Colormap    cmap
  353. );
  354.  
  355.    XDGACreateColormap() is similar to the Xlib function XCreateColormap() 
  356. except that it takes an XDGADevice as an argument instead of a Window
  357. and Visual.  Though XCreateColormap() may create useable colormaps in
  358. some cases, XDGACreateColormap() is the prefered method for creating
  359. colormaps in DGA since there may not be an advertised visual compatible
  360. with the DGA device.
  361.  
  362.    XDGAInstallColormap() must be used to install colormaps in DGA
  363. mode.  XInstallColormap() will not work.
  364.  
  365.  
  366.  
  367. void XDGASelectInput(
  368.     Display     *dpy,
  369.     int         screen,
  370.     long        event_mask
  371. );
  372.  
  373.    DGA provides its own events.  These can be enabled by calling
  374. XDGASelectInput().  This function is similar to XSelectInput()
  375. and all Xlib Key, Button and Motion masks are supported.
  376.  
  377.  
  378.  The following DGA events are defined.
  379.  
  380. typedef struct {
  381.    int type;         /* ButtonPress or ButtonRelease + the DGA event base*/
  382.    unsigned long serial; /* # or last request processed by the server */
  383.    Display *display;     /* Display the event was read from */
  384.    int screen;           /* The screen number the event came from */
  385.    Time time;            /* milliseconds */
  386.    unsigned int state;   /* key or button mask */
  387.    unsigned int button;  /* detail */
  388. } XDGAButtonEvent;   
  389.  
  390. typedef struct {
  391.    int type;             /* KeyPress or KeyRelease + the DGA event base*/
  392.    unsigned long serial; /* # or last request processed by the server */
  393.    Display *display;     /* Display the event was read from */
  394.    int screen;           /* The screen number the event came from */
  395.    Time time;            /* milliseconds */
  396.    unsigned int state;   /* key or button mask */
  397.    unsigned int keycode; /* detail */
  398. } XDGAKeyEvent;
  399.  
  400. typedef struct {
  401.    int type;             /* MotionNotify + the DGA event base*/
  402.    unsigned long serial; /* # or last request processed by the server */
  403.    Display *display;     /* Display the event was read from */
  404.    int screen;           /* The screen number the event came from */
  405.    Time time;            /* milliseconds */
  406.    unsigned int state;   /* key or button mask */
  407.    int dx;               /* relative pointer motion */
  408.    int dy;               /* relative pointer motion */
  409. } XDGAMotionEvent;
  410.  
  411.  
  412. void 
  413. XDGAKeyEventToXKeyEvent(XDGAKeyEvent* dk, XKeyEvent* xk);
  414.  
  415.    XDGAKeyEventToXKeyEvent() is a helper function to translate 
  416. XDGAKeyEvents into XKeyEvents suitable for use with XLookupKeysym().
  417.  
  418.  
  419. void XDGAFillRectangle(
  420.     Display     *dpy,
  421.     int         screen,
  422.     int         x,
  423.     int         y,
  424.     unsigned int        width,
  425.     unsigned int        height,
  426.     unsigned long       color
  427. );
  428.  
  429.  
  430. void XDGACopyArea(
  431.     Display     *dpy,
  432.     int         screen,
  433.     int         srcx,
  434.     int         srcy,
  435.     unsigned int        width,
  436.     unsigned int        height,
  437.     int         dstx,
  438.     int         dsty
  439. );
  440.  
  441.  
  442. void XDGACopyTransparentArea(
  443.     Display     *dpy,
  444.     int         screen,
  445.     int         srcx,
  446.     int         srcy,
  447.     unsigned int        width,
  448.     unsigned int        height,
  449.     int         dstx,
  450.     int         dsty,
  451.     unsigned long key      /* source pixels of this value will not be copied */
  452. );
  453.  
  454.    These three functions are included with some reserveration since
  455. DGA is not intended as a rendering API.  These are merely convience
  456. routines and are optionally supported.  The associated flags will
  457. be set in the XDGAMode's "flags" field if these functions are supported.  
  458. These functions will be no-ops otherwise. 
  459.  
  460.    These functions do not provide direct access to the hardware,
  461. but are merely context-less operations performed by the server.
  462.  
  463.  
  464. void XDGASync(
  465.     Display     *dpy,
  466.     int         screen
  467. );
  468.  
  469.     This function blocks until all server rendering to the framebuffer
  470. completes.  If Xlib or the 3 rendering functions above are used, XDGASync()
  471. must be called before the client directly accesses the framebuffer as
  472. the server rendering is asynchronous with the client and may have not
  473. completed.  This is especially important if the XDGAConcurrentAccess 
  474. flag is not set in the XDGAMode's "flags" field since concurrent access 
  475. by the server and client may result in a system lockup.
  476.  
  477.  
  478.  
  479.  
  480.  
  481. $XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DGA,v 3.6 2000/03/04 00:58:15 dawes Exp $
  482.