Source code of Windows XP (NT5)
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.

545 lines
13 KiB

  1. /*++
  2. Copyright (c) 1993 Weitek Corporation
  3. Module Name:
  4. p9.h
  5. Abstract:
  6. This module contains the definitions for the code that implements the
  7. Weitek P9 miniport device driver.
  8. Environment:
  9. Kernel mode
  10. Revision History may be found at the end of this file.
  11. --*/
  12. #include "dderror.h"
  13. #include "devioctl.h"
  14. #include "miniport.h"
  15. #include "ntddvdeo.h"
  16. #include "video.h"
  17. //
  18. // Sync Polarities.
  19. //
  20. #define NEGATIVE 0L
  21. #define POSITIVE 1L
  22. #define CURSOR_WIDTH 32
  23. #define CURSOR_HEIGHT 32
  24. extern VIDEO_ACCESS_RANGE VLDefDACRegRange[];
  25. //
  26. // Structure containing the video parameters. Pack the structure on
  27. // 1 byte boundaries. This is done so that the size of the structure
  28. // matches exactly the size of the video parms data value stored in the
  29. // registry.
  30. //
  31. #pragma pack(1)
  32. typedef struct tagVDATA
  33. {
  34. ULONG dotfreq1; // Input pixel dot rate shift value
  35. ULONG hsyncp; // horizontal sync pulse width in dots
  36. ULONG hbp; // horizontal back porch width
  37. ULONG XSize; // my personal global copy of the current
  38. ULONG hfp; // horizontal front porch
  39. ULONG hco; // horizontal cursor offset
  40. ULONG hp; // horizontal sync polarity
  41. ULONG vlr; // Vertical Refresh Rate in Hz.
  42. ULONG vsp; // vertical sync pulse height in lines
  43. ULONG vbp; // vertical back porch width
  44. ULONG YSize; // screen width and height
  45. ULONG vfp; // vertical front porch
  46. ULONG vco; // vertical cursor offset
  47. ULONG vp; // vertical sync polarity
  48. // Added for P9100 support
  49. // Potential overides...
  50. //
  51. ULONG ulIcdSerPixClk; // IcdSerPixClk
  52. ULONG ulIcdCtrlPixClk; // IcdCtrlPixClk
  53. ULONG ulIcdSer525Ref; // IcdSer525Ref
  54. ULONG ulIcdCtrl525Ref; // IcdCtrl525Ref
  55. ULONG ul525RefClkCnt; // 525RefClkCnt
  56. ULONG ul525VidClkFreq; // 525VidClkFreq
  57. ULONG ulMemCfgClr; // MemCfgClr
  58. ULONG ulMemCfgSet; // MemCfgSet
  59. } VDATA, *PVDATA;
  60. //
  61. // Restore strcuture packing to the default value.
  62. //
  63. #pragma pack()
  64. //
  65. // Structure containing the mode information.
  66. //
  67. #define P9000_ID 0x01
  68. #define P9100_ID 0x02
  69. #define IS_DEV_P9100 (HwDeviceExtension->P9CoprocInfo.CoprocId == P9100_ID)
  70. //
  71. // DriverSpecificAttributeFlags
  72. //
  73. #define CAPS_WEITEK_CHIPTYPE_IS_P9000 0x0001 // represents p9000 chip
  74. typedef struct tagP9INITDATA
  75. {
  76. ULONG Count;
  77. ULONG ulChips;
  78. PVDATA pvData; // Ptr to the default video parms
  79. BOOLEAN valid;
  80. VIDEO_MODE_INFORMATION modeInformation; // NT Mode Info structure.
  81. } P9INITDATA, *PP9INITDATA;
  82. //
  83. // Mode enumeration.
  84. //
  85. typedef enum _P9_MODES
  86. {
  87. m640_480_8_60,
  88. m640_480_16_60,
  89. m640_480_24_60,
  90. m640_480_32_60,
  91. m640_480_8_72,
  92. m640_480_16_72,
  93. m640_480_24_72,
  94. m640_480_32_72,
  95. m800_600_8_60,
  96. m800_600_8_72,
  97. m800_600_16_60,
  98. m800_600_16_72,
  99. m800_600_24_60,
  100. m800_600_24_72,
  101. m800_600_32_60,
  102. m800_600_32_72,
  103. m1K_768_8_60,
  104. m1K_768_8_70,
  105. m1K_768_16_60,
  106. m1K_768_16_70,
  107. m1K_768_24_60,
  108. m1K_768_24_70,
  109. m1K_768_32_60,
  110. m1K_768_32_70,
  111. m1280_1K_8_55,
  112. m1280_1K_8_60,
  113. m1280_1K_8_74,
  114. m1280_1K_8_75,
  115. m1280_1K_16_60,
  116. m1280_1K_16_74,
  117. m1280_1K_16_75,
  118. m1280_1K_24_60,
  119. m1280_1K_24_74,
  120. m1280_1K_24_75,
  121. m1600_1200_8_60,
  122. m1600_1200_16_60,
  123. mP9ModeCount
  124. } P9_MODES;
  125. //
  126. // Define P9 coprocessor data structure. This contains info about the
  127. // one member of the P9 family of coprocessors.
  128. //
  129. typedef struct _P9_COPROC {
  130. //
  131. // Coprocessor type ID.
  132. //
  133. ULONG CoprocId;
  134. //
  135. // Size of the P9 address space.
  136. //
  137. ULONG AddrSpace;
  138. //
  139. // Offset from the base address to the coprocessor registers.
  140. //
  141. ULONG CoprocRegOffset;
  142. //
  143. // Length of the coprocessor register block.
  144. //
  145. ULONG CoprocLength;
  146. //
  147. // Offset from the base address to the frame buffer.
  148. //
  149. ULONG FrameBufOffset;
  150. //
  151. // Routine to perform frame buffer memory sizing.
  152. //
  153. VOID (*SizeMem)(PHW_DEVICE_EXTENSION);
  154. } P9_COPROC, *PP9_COPROC;
  155. //
  156. // DAC IDs:
  157. // NOTE: These DAC ID's are the same as the bits in the P9100 power up
  158. // configuration register. Were just going to "borrow" them so
  159. // can place the DAC ID in the DAC info structure. (This makes
  160. // displaying of the DAC info real easy).
  161. #define DAC_ID_BT485 (0x0) // BT485
  162. #define DAC_ID_IBM525 (0x8) // IBMRGB525
  163. #define DAC_ID_BT489 (0x1) // BT489
  164. //
  165. // Define the DAC support routines structure.
  166. //
  167. typedef struct _DAC {
  168. ULONG ulDacId;
  169. UCHAR cDacRegs; // Number of DAC registers
  170. //
  171. // Routine to Initialize the DAC.
  172. //
  173. BOOLEAN (*DACInit)(PHW_DEVICE_EXTENSION);
  174. //
  175. // Routine to enable hardware pointer.
  176. //
  177. VOID (*DACRestore)(PHW_DEVICE_EXTENSION);
  178. //
  179. // Routine to set palette entries.
  180. //
  181. VOID (*DACSetPalette)(PHW_DEVICE_EXTENSION, PULONG, ULONG, ULONG);
  182. //
  183. // Routine to clear the palette.
  184. //
  185. VOID (*DACClearPalette)(PHW_DEVICE_EXTENSION);
  186. //
  187. // Routine to enable hardware pointer.
  188. //
  189. VOID (*HwPointerOn)(PHW_DEVICE_EXTENSION);
  190. //
  191. // Routine to disable hw pointer.
  192. //
  193. VOID (*HwPointerOff)(PHW_DEVICE_EXTENSION);
  194. //
  195. // Routine to set hw pointer pos.
  196. //
  197. VOID (*HwPointerSetPos)(PHW_DEVICE_EXTENSION, ULONG, ULONG);
  198. //
  199. // Routine to set hw ptr shape.
  200. //
  201. VOID (*HwPointerSetShape)(PHW_DEVICE_EXTENSION, PUCHAR);
  202. //
  203. // Maximum frequency supported by this DAC w/o clock doubling (if the
  204. // DAC supports it, see below).
  205. //
  206. ULONG ulMaxClkFreq;
  207. //
  208. // DAC routine to set clock double mode (if supported).
  209. //
  210. VOID (*DACSetClkDblMode)(PHW_DEVICE_EXTENSION);
  211. //
  212. // DAC routine to clear clock double mode (if supported).
  213. //
  214. VOID (*DACClrClkDblMode)(PHW_DEVICE_EXTENSION);
  215. //
  216. // The following structure members are for the P9100 DAC support
  217. //
  218. USHORT usRamdacID,
  219. usRamdacWidth;
  220. BOOLEAN bRamdacUsePLL,
  221. bRamdacDivides,
  222. bRamdac24BPP;
  223. } DAC, *PDAC;
  224. //
  225. // Define Adapter Description structure. This contains the Adapter support
  226. // information.
  227. //
  228. typedef struct _ADAPTER_DESC {
  229. USHORT ausAdapterIDString[32];
  230. //
  231. // P9000 Register values which vary depending upon the OEM configuration.
  232. //
  233. ULONG ulMemConfVal; // Memory config reg value.
  234. ULONG ulSrctlVal; // Screen repaint control reg value.
  235. //
  236. // Flag which indicates whether autodetection should be attempted.
  237. //
  238. BOOLEAN bAutoDetect;
  239. //
  240. // Is this a PCI adapter ?
  241. //
  242. BOOLEAN bPCIAdapter;
  243. //
  244. // OEM board detect/P9 memory map routine.
  245. //
  246. BOOLEAN (*OEMGetBaseAddr)(PHW_DEVICE_EXTENSION);
  247. //
  248. // OEM set video mode routine.
  249. //
  250. VOID (*OEMSetMode)(PHW_DEVICE_EXTENSION);
  251. //
  252. // Routines to enable/disable P9 video.
  253. //
  254. VOID (*P9EnableVideo)(PHW_DEVICE_EXTENSION);
  255. BOOLEAN (*P9DisableVideo)(PHW_DEVICE_EXTENSION);
  256. //
  257. // Routine to enable the P9 memory map.
  258. //
  259. BOOLEAN (*P9EnableMem)(PHW_DEVICE_EXTENSION);
  260. //
  261. // Misc OEM specific fields.
  262. //
  263. LONG iClkDiv; // Clock divisor
  264. BOOLEAN bWtk5x86; // Is a Weitek 5x86 VGA present?
  265. BOOLEAN bRequiresIORanges; // Will this adapter try to use
  266. // non memory mapped registers.
  267. } ADAPTER_DESC, *PADAPTER_DESC;
  268. //
  269. // Structure which defines an OEM P9 based adapter.
  270. //
  271. typedef struct tagP9ADAPTER
  272. {
  273. //
  274. // OEM adapter information.
  275. //
  276. PADAPTER_DESC pAdapterDesc;
  277. //
  278. // DAC used by this adapter.
  279. //
  280. PDAC pDac;
  281. //
  282. // P9 Coprocessor type used by this adapter.
  283. //
  284. PP9_COPROC pCoprocInfo;
  285. } P9ADAPTER, *PP9ADAPTER;
  286. //
  287. // P9100 additions
  288. // Define standard bus types.
  289. //
  290. #define VESA 1
  291. #define PCI 2
  292. //
  293. // maximum Amount of address space used by both types of cards
  294. //
  295. #define RESERVE_PCI_ADDRESS_SPACE 0x01000000 // 16 MEG
  296. typedef struct {
  297. BOOLEAN bEnabled,
  298. bInitialized,
  299. bVram256,
  300. bVideoPowerEnabled;
  301. ULONG ulPuConfig,
  302. ulMemConfVal,
  303. ulSrctlVal,
  304. ulBlnkDlyAdj,
  305. ulFrameBufferSize;
  306. USHORT usClockID,
  307. usRevisionID,
  308. usMemConfNum,
  309. usNumVramBanks;
  310. } P91STATE;
  311. typedef P91STATE *PP91STATE;
  312. typedef enum
  313. {
  314. GENERIC, SIEMENS, SIEMENS_P9100_VLB, SIEMENS_P9100_PCi
  315. // ^ SNI-Od: add an id to manage viper P9100 VL
  316. // boards on SIEMENS-NIXDORF RM200/RM300/RM400 machines
  317. } MACHINE_TYPE;
  318. #define VideoPortIsCpu(typeCpu) \
  319. (NO_ERROR == VideoPortGetDeviceData(HwDeviceExtension,VpMachineData,\
  320. &GetCPUIdCallback, typeCpu))
  321. #define if_SIEMENS_Box() \
  322. if (HwDeviceExtension->MachineType == SIEMENS \
  323. || HwDeviceExtension->MachineType == SIEMENS_P9100_VLB \
  324. || HwDeviceExtension->MachineType == SIEMENS_P9100_PCi)
  325. #define if_SIEMENS_P9100_VLB() \
  326. if (HwDeviceExtension->MachineType == SIEMENS_P9100_VLB)
  327. #define if_SIEMENS_P9100() \
  328. if (HwDeviceExtension->MachineType == SIEMENS_P9100_VLB \
  329. || HwDeviceExtension->MachineType == SIEMENS_P9100_PCi)
  330. #define if_Not_SIEMENS_P9100_VLB() \
  331. if (HwDeviceExtension->MachineType != SIEMENS_P9100_VLB)
  332. #define if_SIEMENS_VLB() \
  333. if (HwDeviceExtension->MachineType == SIEMENS \
  334. || HwDeviceExtension->MachineType == SIEMENS_P9100_VLB)
  335. //
  336. // Define device extension structure. This is device dependant/private
  337. // information.
  338. //
  339. typedef struct _HW_DEVICE_EXTENSION {
  340. PVOID Vga;
  341. PVOID Coproc;
  342. PVOID FrameAddress;
  343. PVOID CoprocVirtAddr;
  344. PHYSICAL_ADDRESS P9PhysAddr;
  345. PHYSICAL_ADDRESS CoprocPhyAddr; // these two addresses are part
  346. PHYSICAL_ADDRESS PhysicalFrameAddr; // of the P9PhysAddr address space.
  347. PHYSICAL_ADDRESS P9001PhysicalAddress;
  348. ULONG FrameLength;
  349. USHORT MiscRegState; // Original value for MISCOUT reg
  350. ULONG CurrentModeNumber;
  351. ULONG usBitsPixel; // BPP of current mode
  352. VDATA VideoData;
  353. ULONG ulPointerX;
  354. ULONG ulPointerY;
  355. ULONG flPtrState;
  356. // P9100 stuff...
  357. USHORT usBusType;
  358. PVOID ConfigAddr;
  359. P91STATE p91State;
  360. // End of P9100 sutff...
  361. P9_COPROC P9CoprocInfo;
  362. ADAPTER_DESC AdapterDesc; // The adapter support info
  363. DAC Dac; // ptr to the DAC information
  364. PULONG pDACRegs; // ptr to DAC register block
  365. ULONG ulNumAvailModes; // number of available modes
  366. ULONG PciSlotNum; // Slot number for PCI machine
  367. MACHINE_TYPE MachineType; // If the miniport needs to
  368. // behave differently on a
  369. // given machine, then the
  370. // machine type should be
  371. // detected during HwFindAdapter,
  372. // and we can check this field
  373. // anywhere where we need to
  374. // behave differently.
  375. } HW_DEVICE_EXTENSION, *PHW_DEVICE_EXTENSION;
  376. //
  377. // Macros to read and write a register.
  378. //
  379. #define WR_REG(addr, data) \
  380. VideoPortWritePortUchar(addr, (data))
  381. #define RD_REG(addr) \
  382. VideoPortReadPortUchar(addr)
  383. //
  384. // Macros to read and write VGA registers.
  385. //
  386. #define VGA_WR_REG(index, data) \
  387. VideoPortWritePortUchar((PUCHAR) HwDeviceExtension->Vga + index, (UCHAR) (data))
  388. #define VGA_RD_REG(index) \
  389. VideoPortReadPortUchar((PUCHAR) HwDeviceExtension->Vga + index)
  390. //
  391. // Macros to read and write P9 registers.
  392. //
  393. #define P9_WR_REG(index, data) \
  394. VideoPortWriteRegisterUlong((PULONG)((PUCHAR) HwDeviceExtension->Coproc + index), (ULONG) (data))
  395. #define P9_RD_REG(index) \
  396. VideoPortReadRegisterUlong((PULONG) ((PUCHAR) HwDeviceExtension->Coproc + index))
  397. #define P9_WR_BYTE_REG(index, data) \
  398. VideoPortWriteRegisterUchar(((PUCHAR) HwDeviceExtension->Coproc + index), (UCHAR) (data))