
#ifdef INCL_32
#pragma pack(1)
#pragma linkage(VcaiDllVersionQuery, far16 cdecl)
#pragma linkage(VcaiLastError, far16 cdecl)
#pragma linkage(VcaiQuery, far16 cdecl)
#pragma linkage(VcaiDeviceOpen, far16 cdecl)
#pragma linkage(VcaiDeviceClose, far16 cdecl)
#pragma linkage(VcaiDeviceConnect, far16 cdecl)
#pragma linkage(VcaiDeviceStateSave, far16 cdecl)
#pragma linkage(VcaiDeviceStateRestore, far16 cdecl)
#pragma linkage(VcaiScreenInfoSet, far16 cdecl)
#pragma linkage(VcaiVideoInputSet, far16 cdecl)
#pragma linkage(VcaiVideoDefaultSet, far16 cdecl)
#pragma linkage(VcaiVideoInputQuery, far16 cdecl)
#pragma linkage(VcaiCaptureRectSet, far16 cdecl)
#pragma linkage(VcaiImageScaleGet, far16 cdecl)
#pragma linkage(VcaiDeviceInfoGet, far16 cdecl)
#pragma linkage(VcaiVideoRectValidate, far16 cdecl)
#pragma linkage(VcaiVideoSet, far16 cdecl)
#pragma linkage(VcaiVideoGet, far16 cdecl)
#pragma linkage(VcaiAudioSet, far16 cdecl)
#pragma linkage(VcaiAudioGet, far16 cdecl)
#pragma linkage(VcaiFrameRateSet, far16 cdecl)
#pragma linkage(VcaiOverlay, far16 cdecl)
#pragma linkage(VcaiColourkey, far16 cdecl)
#pragma linkage(VcaiColourkeySet, far16 cdecl)
#pragma linkage(VcaiColourkeyGet, far16 cdecl)
#pragma linkage(VcaiChromakey, far16 cdecl)
#pragma linkage(VcaiFreeze, far16 cdecl)
#pragma linkage(VcaiAdvSet, far16 cdecl)
#pragma linkage(VcaiAdvGet, far16 cdecl)
#pragma linkage(VcaiSmartlockSet, far16 cdecl)
#pragma linkage(VcaiSmartlockGet, far16 cdecl)
#pragma linkage(VcaiConfigSet, far16 cdecl)
#pragma linkage(VcaiConfigGet, far16 cdecl)
#pragma linkage(VcaiInfoGet, far16 cdecl)
#pragma linkage(VcaiCkSet, far16 cdecl)
#pragma linkage(VcaiCkGet, far16 cdecl)
#pragma linkage(VcaiReset, far16 cdecl)
#pragma linkage(VcaiRedraw, far16 cdecl)
#pragma linkage(VcaiI2cWrite, far16 cdecl)
#pragma linkage(VcaiI2cWriteRead, far16 cdecl)
#pragma linkage(VcaiI2cRead, far16 cdecl)
#pragma linkage(VcaiVarRead, far16 cdecl)
#pragma linkage(VcaiVarWrite, far16 cdecl)
#pragma linkage(VcaiVarEnum, far16 cdecl)

#pragma linkage(VcaiVxpSet, far16 cdecl)
#pragma linkage(VcaiVxpGet, far16 cdecl)
#pragma linkage(VcaiBt848Set, far16 cdecl)
#pragma linkage(VcaiBt848Get, far16 cdecl)
#pragma linkage(VcaiBt812Set, far16 cdecl)
#pragma linkage(VcaiBt812Get, far16 cdecl)

#pragma linkage(VcaiBt848SetGpio, far16 cdecl)
#pragma linkage(VcaiBt848GetGpio, far16 cdecl)

#pragma linkage(VcaiTeletextStatus, far16 cdecl)
#pragma linkage(VcaiTeletextAcquire, far16 cdecl)
#pragma linkage(VcaiTeletextQuery, far16 cdecl)
#pragma linkage(VcaiTeletextGet, far16 cdecl)

#pragma linkage(VcaiTunerSignal, far16 cdecl)
#pragma linkage(VcaiTunerSet, far16 cdecl)
#pragma linkage(VcaiTunerGet, far16 cdecl)
#pragma linkage(VcaiTunerFreqSet, far16 cdecl)
#pragma linkage(VcaiTunerFreqGet, far16 cdecl)
#pragma linkage(VcaiTunerRegionGet, far16 cdecl)
#pragma linkage(VcaiTunerFineGet, far16 cdecl)
#pragma linkage(VcaiPaletteGet, far16 cdecl)

#pragma linkage(VcaiSnapStart, far16 cdecl)
#pragma linkage(VcaiSnapGet, far16 cdecl)
#pragma linkage(VcaiSnapStop, far16 cdecl)
#pragma linkage(VcaiPlayStart, far16 cdecl)
#pragma linkage(VcaiPlaySet, far16 cdecl)
#pragma linkage(VcaiPlayStop, far16 cdecl)

#pragma linkage(VcaiWCastMonitor, far16 cdecl)
#pragma linkage(VcaiDMAStart, far16 cdecl)
/*
#pragma linkage(VcaiWCastPos, far16 cdecl)
#pragma linkage(VcaiRegisterHwnd, far16 cdecl)
#pragma linkage(VcaiHwndSet, far16 cdecl)
#pragma linkage(VcaiHwndGet, far16 cdecl)
*/
#endif

#define DRIVERHANDLE    short int

USHORT VcaiDllVersionQuery (VOID);
USHORT VcaiLastError (VOID);
VOID   VcaiQuery (VOID);
DRIVERHANDLE VcaiDeviceOpen (CHAR *name, USHORT device);
USHORT VcaiDeviceClose (DRIVERHANDLE vcahand);
VOID   VcaiDeviceConnect (DRIVERHANDLE vcahandle);
VOID   VcaiDeviceStateSave (VOID);
VOID   VcaiDeviceStateRestore (VOID);
VOID   VcaiScreenInfoSet (PVCASCREENINFO vs);
ULONG  VcaiVideoInputSet (LONG connector);
ULONG  VcaiVideoDefaultSet (VOID);
ULONG  VcaiVideoInputQuery (VOID);
VOID   VcaiCaptureRectSet (USHORT sx,   USHORT sy,
                           USHORT swid, USHORT sht,
                           USHORT dx,   USHORT dy,
                           USHORT dwid, USHORT dht);
VOID   VcaiImageScaleGet  (USHORT len, ULONG address,
                           USHORT sx, USHORT sy,
                           USHORT swid, USHORT sht,
                           USHORT dx, USHORT dy,
                           USHORT dwid, USHORT dht);
VOID   VcaiDeviceInfoGet (PVCADEVINFO info);
VOID   VcaiVideoRectValidate (USHORT sx,   USHORT sy,
                              USHORT swid, USHORT sht,
                              USHORT dx,   USHORT dy,
                              USHORT dwid, USHORT dht);
VOID   VcaiVideoGet (USHORT *b, USHORT *c, USHORT *s, USHORT *h);
VOID   VcaiVideoSet (USHORT b, USHORT c, USHORT s, USHORT h);
VOID   VcaiAudioGet (USHORT *lv, USHORT *rv, USHORT *lb, USHORT *rb,
                     USHORT *lt, USHORT *rt, USHORT *mute);
VOID   VcaiAudioSet (USHORT lv, USHORT rv, USHORT lb, USHORT rb,
                     USHORT lt, USHORT rt, USHORT mute);
VOID   VcaiFrameRateSet (ULONG fps, USHORT flag);
VOID   VcaiOverlay (BOOL OnOffFlag);
VOID   VcaiColourkey (BOOL OnOffFlag);
VOID   VcaiColourkeySet (ULONG ckey);
ULONG  VcaiColourkeyGet (VOID);
VOID   VcaiChromakey (BOOL OnOffFlag);
VOID   VcaiFreeze (BOOL OnOffFlag);
VOID   VcaiAdvSet (PAF paf);
VOID   VcaiAdvGet (PAF paf);
VOID   VcaiSmartlockSet (USHORT settings[]);
VOID   VcaiSmartlockGet (USHORT settings[]);
VOID   VcaiConfigSet (USHORT settings[]);
VOID   VcaiConfigGet (USHORT settings[]);
VOID   VcaiInfoGet   (USHORT settings[]);
VOID   VcaiCkSet     (USHORT settings[]);
VOID   VcaiCkGet     (USHORT settings[]);
VOID   VcaiReset  (VOID);
VOID   VcaiRedraw (VOID);
USHORT VcaiI2cWrite (UCHAR id, USHORT length, UCHAR FAR *db);
USHORT VcaiI2cRead  (UCHAR id, USHORT length, UCHAR FAR *db);
USHORT VcaiI2cWriteRead (UCHAR id, USHORT length_out, UCHAR FAR *db_out,
                                   USHORT length_in,  UCHAR FAR *db_in);
USHORT VcaiVarRead  (UCHAR FAR *name, USHORT table, ULONG FAR *value);
USHORT VcaiVarWrite (UCHAR FAR *name, USHORT table, ULONG value);
USHORT VcaiVarEnum (UCHAR FAR *name, USHORT table, USHORT off, ULONG FAR *value);

VOID   VcaiVxpSet   (USHORT reg, USHORT value);
USHORT VcaiVxpGet   (USHORT reg);
VOID   VcaiBt848Set (USHORT reg, USHORT value);
USHORT VcaiBt848Get (USHORT reg);
VOID   VcaiBt812Set (USHORT reg, USHORT value);
USHORT VcaiBt812Get (USHORT reg);

VOID   VcaiBt848SetGpio (USHORT value);
USHORT VcaiBt848GetGpio (void);

USHORT VcaiTeletextStatus (PTTSTATUS ptt_status);
VOID   VcaiTeletextAcquire (USHORT page_no, USHORT acq);
USHORT VcaiTeletextQuery (USHORT page_no);
USHORT VcaiTeletextGet (USHORT page_no, USHORT offset, USHORT length,
                          UCHAR FAR *buff);

USHORT VcaiTunerSignal (VOID);
USHORT VcaiTunerSet (ULONG region, ULONG channel, ULONG freq, LONG finetune,
                     BOOL afc, BOOL polarization);
VOID   VcaiTunerGet (ULONG FAR *region, ULONG FAR *channel,
                     ULONG FAR *freq,   LONG FAR *fine);
USHORT VcaiTunerFreqSet (ULONG freq, LONG finetune);
ULONG  VcaiTunerFreqGet (VOID);
ULONG  VcaiTunerRegionGet (VOID);
LONG   VcaiTunerFineGet (VOID);
VOID   VcaiPaletteGet   (ULONG len, ULONG *address, USHORT type);

VOID   VcaiSnapStart      (USHORT width, USHORT height);
VOID   VcaiSnapGet        (ULONG address);
VOID   VcaiSnapStop       (VOID);

VOID   VcaiFastSnapStart  (USHORT width, USHORT height, ULONG address);
VOID   VcaiFastSnapGet    (VOID);
VOID   VcaiFastSnapStop   (VOID);

VOID   VcaiPlayStart      (USHORT width, USHORT height);
VOID   VcaiPlaySet        (ULONG address);
VOID   VcaiPlayStop       (VOID);

/* Driver specific functions for the WinCast board                          */
VOID   VcaiWCastMonitor (ULONG width, ULONG height, ULONG address);
// VOID   VcaiWCastPos (CRECT *prect);

VOID   VcaiDMAStart (VOID);

                    //            E S C
#define  VCAI_USER_CODE        (0x45534300L)
#define  VCAI_GET_ADVANCED     (0x01 | VCAI_USER_CODE)
#define  VCAI_SET_ADVANCED     (0x02 | VCAI_USER_CODE)
#define  VCAI_GET_SL           (0x03 | VCAI_USER_CODE)
#define  VCAI_SET_SL           (0x04 | VCAI_USER_CODE)
#define  VCAI_GET_CONF         (0x05 | VCAI_USER_CODE)
#define  VCAI_SET_CONF         (0x06 | VCAI_USER_CODE)
#define  VCAI_GET_INFO         (0x07 | VCAI_USER_CODE)
#define  VCAI_I2CIO            (0x08 | VCAI_USER_CODE)
#define  VCAI_RESET            (0x09 | VCAI_USER_CODE)
#define  VCAI_HARDWARE         (0x0A | VCAI_USER_CODE)
#define  VCAI_SET_CK           (0x0B | VCAI_USER_CODE)
#define  VCAI_GET_CK           (0x0C | VCAI_USER_CODE)
#define  VCAI_SET_TUNER        (0x0D | VCAI_USER_CODE)
#define  VCAI_GET_TUNER        (0x0E | VCAI_USER_CODE)
#define  VCAI_VARIABLE         (0x0F | VCAI_USER_CODE)
#define  VCAI_GET_PALETTE      (0x10 | VCAI_USER_CODE)
#define  VCAI_REDRAW           (0x11 | VCAI_USER_CODE)
#define  VCAI_SNAP_START       (0x12 | VCAI_USER_CODE)
#define  VCAI_SNAP_GET         (0x13 | VCAI_USER_CODE)
#define  VCAI_SNAP_STOP        (0x14 | VCAI_USER_CODE)
#define  VCAI_PLAY_START       (0x15 | VCAI_USER_CODE)
#define  VCAI_PLAY_SET         (0x16 | VCAI_USER_CODE)
#define  VCAI_PLAY_STOP        (0x17 | VCAI_USER_CODE)

/* Added in support of the Hauppauge WinCast board.                         */
#define  VCAI_WCAST_MONITOR     (0x18 | VCAI_USER_CODE)
// #define  VCAI_WCAST_POS         (0x19 | VCAI_USER_CODE)
// #define  VCAI_SET_HWND          (0x1A | VCAI_USER_CODE)
// #define  VCAI_GET_HWND          (0x1B | VCAI_USER_CODE)
#define  VCAI_DMA_START         (0x1C | VCAI_USER_CODE)

#define  VCAI_GRADD_MODEINFO    (0x20 | VCAI_USER_CODE)
#define  VCAI_GRADD_MOVEPTR     (0x21 | VCAI_USER_CODE)
#define  VCAI_GRADD_SETPTR      (0x22 | VCAI_USER_CODE)
#define  VCAI_GRADD_SHOWPTR     (0x23 | VCAI_USER_CODE)

                            // This is a USER EScape IOCTL and is provided
                            // because the MCI layer does not set or
                            // get Region or channel information from the
                            // driver. But the driver needs the information !

typedef struct VCATUNER
{
   ULONG  tune_region;
   ULONG  tune_channel;
   ULONG  tune_freq;
   LONG   tune_fine;
   BOOL   tune_afc;
   BOOL   tune_polarization;
} VCATUNER, FAR * PVCATUNER;

                            // This is a USER EScape IOCTL and is provided
                            // to allow configuration utilities access to
                            // internal variables within the device driver.
typedef struct VCAVARIABLE
{
   USHORT var_func;         // ENUM, GET, SET
   USHORT var_type;         // VCA Generic, or HW specific variable table
   UCHAR  var_name[40];     // Null terminated variable name
   ULONG  var_value;        // Value to set or value to return
   USHORT var_offset;       // Offset of variable in its table
} VCAVARIABLE, FAR * PVCAVARIABLE;

#define VCA_VARIABLE_GET       (0)     // Get the value for a variable
#define VCA_VARIABLE_SET       (1)     // Set a variables value
#define VCA_VARIABLE_ENUM      (2)     // Get the name of a variable

#define VCA_VARIABLE_GENERIC   (0)     // Use the generic variable table
#define VCA_VARIABLE_HW        (1)     // Use the hardware specific table

typedef struct VCAPALETTE
{
   ULONG  pal_len;
   ULONG FAR *pal_address;
   USHORT pal_type;
} VCAPALETTE, FAR * PVCAPALETTE;

#define     VCA_HW_PALETTE                  (0)
#define     VCA_MCI_PALETTE                 (1)

#define     VCA_CFG_WIDTH                   (0)
#define     VCA_CFG_HEIGHT                  (1)
#define     VCA_CFG_HSCALE                  (2)
#define     VCA_CFG_VSCALE                  (3)
#define     VCA_CFG_XOFFSET                 (4)
#define     VCA_CFG_YOFFSET                 (5)
#define     VCA_CFG_INPUT                   (6)
#define     VCA_CFG_INTERLACE               (7)
#define     VCA_CFG_HSYNC                   (8)
#define     VCA_CFG_VSYNC                   (9)
#define     VCA_CFG_SLAUTO                  (10)
#define     VCA_CFG_DIVIDER                 (11)
#define     VCA_CFG_VCOGAIN                 (12)
#define     VCA_CFG_PHDETGAIN               (13)
#define     VCA_CFG_VGA_CLOCK               (11)
#define     VCA_CFG_VGA_COLOUR              (12)

#define VCAI_DLL_VERSION (0x502)
#define VCAI_DLL_MIN_VERSION (PMTV_DLL_VERSION)

