Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
6.9 KiB

4 years ago
  1. #/*
  2. * hardware.h
  3. *
  4. * 32-bit Video Capture driver
  5. * hardware-specific data structures and definitions for Bravado-16 board.
  6. *
  7. * Geraint Davies, Feb 93
  8. */
  9. #ifndef _HARDWARE_H_
  10. #define _HARDWARE_H_
  11. /* register layout details of Bravado board */
  12. /* number of registers in PCVideo chip */
  13. #define NR_REG_PCVIDEO 0x51
  14. /* nr registers in 9051 a-d chip */
  15. #define NR_REG_9051 12
  16. /* nr registers in 4680 d-a chip */
  17. #define NR_REG_4680 16
  18. /* hardware-specific data structure - stored in device extension and
  19. * accessed by VC_GetHWInfo(pDevInfo)
  20. */
  21. typedef struct _HWINFO {
  22. /* Copy of registers in PCVideo and other chips so we can save the
  23. * entire board state by saving this structure - and we also dont
  24. * have to struggle getting bytes back over the I2C bus.
  25. */
  26. BYTE bRegPCVideo[NR_REG_PCVIDEO];
  27. BYTE bReg9051[NR_REG_9051];
  28. BYTE bReg4680[NR_REG_4680];
  29. BYTE bKeyColour;
  30. /* index into MODEINIT table */
  31. int iModeIndex;
  32. VIDSTD VideoStd;
  33. /* vga screen co-ords of overlay window */
  34. RECT rcDisplay;
  35. /* co-ords of acquisition area within original (pal, ntsc) video source */
  36. RECT rcAcquire;
  37. int PanLeft, PanTop; // pan: offset of video within overlay rect
  38. /* stream position variables */
  39. DWORD dwInterruptCount; // count of ints since stream began
  40. DWORD dwVideoTime; // time (based on frame syncs) since start
  41. DWORD dwMicroPerInterrupt; // - interrupt rate based on NTSC/PAL
  42. DWORD dwMicroPerFrame; // microsecs per frame desired
  43. DWORD dwNextFrameNr;
  44. DWORD dwNextFrameTime; // next capture time in msecs from stream start
  45. BOOL bVideoIn; // are we actually doing video in ?
  46. BOOL bCapturing; // in DPC routine now
  47. int iNotBusy; // count of consecutive non-busy fields
  48. /* capture format information */
  49. CAPTUREFORMAT Format; // format of destination DIB
  50. DWORD dwWidth, dwHeight; // size of destination DIB
  51. PVOID pXlate; // format-dependent translation table
  52. ULONG ulSizeXlate; // size of Xlate table in bytes
  53. } HWINFO, *PHWINFO;
  54. /* default config info */
  55. #define NUMBER_OF_PORTS 0x2
  56. #define FRAMEBUFFER_SIZE 0x100000 // 1 Mb = 512 lines of 2048 bytes
  57. #define DEF_VIDEOSTD PAL
  58. /* width of one line in the frame buffer in bytes */
  59. #define FRAMEBUFFERWIDTH 2048
  60. /* frame timing. we get one interrupt per frame (we only enable
  61. * even field interrupts) so the ms per interrupt is the frame not field rate
  62. */
  63. #define PAL_MICROSPERFRAME (1000000L/25)
  64. #define NTSC_MICROSPERFRAME (1000000L/30)
  65. /* VGA-Mode specific setup table */
  66. typedef struct _MODEINIT {
  67. int ModeNum;
  68. int DispWinSkewX; /* Offset to add to display window registers */
  69. int DispWinSkewY;
  70. int DispAddrSkewX; /* Offset to be added to display address */
  71. int DispAddrSkewY;
  72. int ShiftClkStart; /* Shift clock start position */
  73. int PaletteSkew; /* 2 MSBs of Display Window Control Reg. */
  74. int VideoSkewX; /* Add to acquistion window start X and Y */
  75. int VideoSkewY;
  76. int VGAWidth; /* VGA resolution */
  77. int VGAHeight;
  78. int VGADepth;
  79. int VGASync;
  80. int PLLDivisor;
  81. } MODEINIT, *PMODEINIT;
  82. /* defined in init.c */
  83. extern MODEINIT ModeInit[];
  84. /* functions called from dispatch code via callback table */
  85. BOOLEAN HW_ConfigFormat(PDEVICE_INFO, PCONFIG_INFO);
  86. BOOLEAN HW_ConfigDisplay(PDEVICE_INFO, PCONFIG_INFO);
  87. BOOLEAN HW_ConfigSource(PDEVICE_INFO, PCONFIG_INFO);
  88. DWORD HW_GetOverlayMode(PDEVICE_INFO);
  89. BOOLEAN HW_SetKeyRGB(PDEVICE_INFO, PRGBQUAD);
  90. BOOLEAN HW_SetKeyPalIdx(PDEVICE_INFO, ULONG);
  91. ULONG HW_GetKeyColour(PDEVICE_INFO);
  92. BOOLEAN HW_SetOverlayRects(PDEVICE_INFO, POVERLAY_RECTS);
  93. BOOLEAN HW_SetOverlayOffset(PDEVICE_INFO, PRECT);
  94. BOOLEAN HW_Overlay(PDEVICE_INFO, BOOL);
  95. BOOLEAN HW_Capture(PDEVICE_INFO, BOOL);
  96. BOOLEAN HW_DrawFrame(PDEVICE_INFO, PDRAWBUFFER);
  97. BOOLEAN HW_StreamInit(PDEVICE_INFO pDevInfo, ULONG microsecperframe);
  98. BOOLEAN HW_StreamFini(PDEVICE_INFO pDevInfo);
  99. BOOLEAN HW_StreamStart(PDEVICE_INFO pDevInfo);
  100. BOOLEAN HW_StreamStop(PDEVICE_INFO pDevInfo);
  101. ULONG HW_StreamGetPosition(PDEVICE_INFO);
  102. BOOLEAN HW_InterruptAcknowledge(PDEVICE_INFO pDevInfo);
  103. ULONG HW_CaptureService(PDEVICE_INFO pDevInfo, PUCHAR pBuffer, PULONG pTimeStamp,
  104. ULONG BufferLength);
  105. BOOLEAN HW_Cleanup(PDEVICE_INFO);
  106. BOOLEAN HW_DeviceOpen(PDEVICE_INFO pDevInfo);
  107. /* hardware access functions in hardware.c */
  108. VOID HW_SetPan(PDEVICE_INFO pDevInfo, int x, int y);
  109. VOID HW_SetScale(PDEVICE_INFO pDevInfo, int scalex, int scaley);
  110. VOID HW_SetAcqRect(PDEVICE_INFO pDevInfo, int left, int top, int width, int height);
  111. VOID HW_SetDisplayWin(PDEVICE_INFO pDevInfo, PHWINFO pHw);
  112. VOID HW_SetVideoStd(PDEVICE_INFO pDevInfo, PHWINFO pHw);
  113. VOID HW_EnableInts(PDEVICE_INFO pDevInfo, BOOL bInIsr);
  114. VOID HW_ReEnableInts(PDEVICE_INFO pDevInfo, BOOL bInIsr);
  115. VOID HW_DisableInts(PDEVICE_INFO pDevInfo, BOOL bInIsr);
  116. /* copy/conversion routines in xlate.c */
  117. BOOLEAN HW_BuildYUVToRGB555(PDEVICE_INFO pDevInfo, PHWINFO pHw);
  118. BOOLEAN
  119. HW_BuildYuvToPal(
  120. PDEVICE_INFO pDevInfo,
  121. PUCHAR pBuffer,
  122. ULONG Length,
  123. PVOID pContext
  124. );
  125. /*
  126. * build a translation table to a default 64-grey level palette
  127. */
  128. BOOLEAN HW_BuildDefaultXlate(PDEVICE_INFO, PHWINFO);
  129. /*
  130. * copy a rectangle of bytes width bytes * height lines. Sourcewidth is
  131. * the entire source line length in bytes. pSrc is a pointer to IOMemory and
  132. * (the frame buffer) and will be accessed using VC_ReadIOMemory* functions.
  133. */
  134. VOID CopyRectFromIOMemory(
  135. PUCHAR pDst,
  136. PUCHAR pSrc,
  137. DWORD Width,
  138. DWORD Height,
  139. DWORD SourceWidth
  140. );
  141. /*
  142. * convert to 24-bit RGB DIB format. width * height pixels. WidthBytes
  143. * is the source line length in bytes.
  144. */
  145. VOID
  146. CopyYUVToRGB24(
  147. PUCHAR pDst, /* destination pixels */
  148. PUCHAR pSrc, /* source pixels */
  149. DWORD Width, /* width of copy rect in pixels */
  150. DWORD Height, /* height of copy rect in lines */
  151. DWORD WidthBytes /* width of one entire source line in bytes */
  152. );
  153. /*
  154. * convert to 16-bit RGB DIB format width*height pixels from pSrc to pDst.
  155. * WidthBytes is the source line length in bytes
  156. */
  157. VOID
  158. CopyYUVToRGB555(
  159. PUCHAR pDst, /* destination pixels */
  160. PUCHAR pSrc, /* source pixels */
  161. PWORD pXlate, /* translation table yuv-15 to rgb-15 */
  162. DWORD Width, /* width of copy rect in pixels */
  163. DWORD Height, /* height of copy rect in lines */
  164. DWORD WidthBytes /* width of one entire source line in bytes */
  165. );
  166. /*
  167. * convert to 8-bit palettised DIB format width * height pixels from pSrc
  168. * to pDst. WidthBytes is the source line length in bytes.
  169. */
  170. VOID
  171. CopyYUVToPal8(
  172. PUCHAR pDst, /* destination pixels */
  173. PUCHAR pSrc, /* source pixels */
  174. PUCHAR pXlate, /* translation table yuv-15 to palette entry */
  175. DWORD Width, /* width of copy rect in pixels */
  176. DWORD Height, /* height of copy rect in lines */
  177. DWORD WidthBytes /* width of one entire source line in bytes */
  178. );
  179. #endif // _HARDWARE_H_