*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* dga_db.c - the client side code for DGA double buffering
*/
#include <stdio.h>
#ifndef FBIOVRTOFFSET
#ifdef SVR4
#else
#endif
#endif
#include <netdb.h>
#include <unistd.h>
#include "dga_incls.h"
{ \
} \
}
{ \
DGA_UNLOCK(win); \
}
#ifdef _LP64
static int _dga_db_vrtfunc_internal(Dga_window);
#else /* _LP64 */
#if defined(__STDC__)
static int _dga_db_vrtfunc_internal(Dga_window);
#else
static int _dga_db_vrtfunc_internal();
#endif
#endif /* _LP64 */
static u_int *dga_vrt_access();
static void dga_vrt_release();
int
{
u_int *dga_vrt_access();
if (wg_clientp->db_enabled)
return 0;
return 1;
if (cpage)
{
return(0);
}
else
return(1);
}
void
{
void dga_vrt_release();
if (wg_clientp->db_vrtcntrp)
wg_clientp->db_enabled = 0;
}
void
int buffer;
#ifdef _LP64
int (*writefunc)(void*, Dga_window, int);
#else /* _LP64 */
#if defined (__STDC__)
int (*writefunc)(void*, Dga_window, int);
#else
int (*writefunc)();
#endif
#endif /* _LP64 */
void* data;
{
if (writefunc)
}
void
int buffer;
#ifdef _LP64
int (*readfunc)(void*, Dga_window, int);
#else /* _LP64 */
#if defined (__STDC__)
int (*readfunc)(void*, Dga_window, int);
#else
int (*readfunc)();
#endif
#endif /* _LP64 */
void* data;
{
if (readfunc)
}
void
int buffer;
#ifdef _LP64
int (*visfunc)(void*, Dga_window, int);
#else /* _LP64 */
#if defined (__STDC__)
int (*visfunc)(void*, Dga_window, int);
#else
int (*visfunc)();
#endif
#endif /* _LP64 */
void* data;
{
if (!dga_db_interval_check(wg_clientpi))
if (visfunc)
if (wg_clientp->db_vrtcntrp)
}
void
int interval; /* number of milliseconds */
{
int ref_rate;
float rr;
if (interval < 0)
interval = 0;
if (wg_clientp->db_swapint == 0)
}
void
{
/* Do a block if necessary and if vrt_func has been supplied */
< wg_clientp->db_swapint)
{
}
return;
}
int
{
if ((wg_clientp->db_vrtcntrp) &&
< wg_clientp->db_swapint)
return(0);
else
return(1);
}
int
{
}
int
{
}
int
{
}
/* INTERNAL INTERFACE */
int
int flag;
{
if (wg_clientp->db_vrtcntrp &&
return 1;
if (flag == 0)
return 0;
return 0;
return 1;
}
/* INTERNAL INTERFACE */
static u_int
int devfd;
{
dev_offset = 0;
return (NULL);
#ifdef SVR4
#else
pagesize = getpagesize();
#endif
/*
* the driver provides the dev_offset into the mmaped page
* where the vertical retrace counter word is.
* We will mmap a shared memory page that is on a
* page boundary then modify the pointer to the
* vertical retrace counter to reflect the exact
* location where the counter word exists
*/
/* if the mmap failed then return NULL otherwide return
* the computed address of the vertical retract counter
* by adding the beginning of the mmaped page to the
* dev_offset into the page returned by the device driver
*/
return NULL;
}
static void
{
char *counter_page;
int pagesize;
#ifdef SVR4
#else
pagesize = getpagesize();
#endif
/* Unmap the page for this client.
* remove the offset computation and munmap the
* vertical retrace counter page. we remove the
* offset by simply setting the lower bits of
* the address to 0
*/
return;
}
/* New routines that will be exposed to the public */
int
int flag;
#ifdef _LP64
int (*display_done_func)(Dga_window);
{
int (*vrt_func)(Dga_window);
#else /* _LP64 */
#if defined (__STDC__)
int (*display_done_func)(Dga_window);
#else
int (*display_done_func)();
#endif
{
#if defined (__STDC__)
int (*vrt_func)(Dga_window);
#else
int (*vrt_func)();
#endif
#endif /* _LP64 */
int ret_val;
/* Return 1 = done, 0 = not done, -1 = error */
/* If the user does not want to block or if the
* display_done_func() returned a non-zero, we return
* else we try till success after each vrt_retrace()
*/
return (ret_val);
if (!vrt_func) return 1;
return (ret_val);
}
/* Returns 0 on fail and non-zero on success */
int
int nbuffers;
#ifdef _LP64
int (*vrtfunc)(Dga_window);
#else /* _LP64 */
#if defined (__STDC__)
int (*vrtfunc)(Dga_window);
#else
int (*vrtfunc)();
#endif
#endif /* _LP64 */
{
/*
* Check for an invalid Dga_window
*/
#ifdef DEBUG
#endif
return (0);
}
/*
* If the buffers has already been grabbed. Don't
* do anything.
*/
if (clientp->db_enabled)
return (1);
/*
* Find out if this is an X window. If so get the Display and window
* id.
*/
#ifdef DEBUG
#endif
return (0);
}
/*
* Request the server to allow DGA to the buffers associated
* with this Dga_window.
*/
#ifdef DEBUG
#endif
return (0);
}
/* Now if they supplied vrtfunc, update the clientp
*/
/* Now update the clientp pointer with other info */
if (vrtcounterp) {
return(1);
} else {
/* Even though they have not supplied vrtp we allow the db_grab
* to succeed but we null out vrtfunc and set vrtcntrp to point
* to itself!
*/
return(1);
}
}
/* Returns 0 on failure and non-zero on success */
int
{
/*
* Check for an invalid Dga_window
*/
#ifdef DEBUG
#endif
return (0);
}
/* If it wasm't grabbed in the first place. don't do anything */
if (!clientp->db_enabled)
return 1;
/*
* Find out if this is an X window. If so get the Display and window
* id.
*/
#ifdef DEBUG
#endif
return (0);
}
/* Mark the window as single buffered */
clientp->db_enabled = 0;
/* Tell server t ungrab */
}
/* This is just for internal use */
static int
{
return(1);
}