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.

3310 lines
97 KiB

  1. /*++
  2. Copyright (c) 1992-1997 Microsoft Corporation.
  3. Copyright (c) 1996-1997 Cirrus Logic, Inc.
  4. Module Name:
  5. modeset.c
  6. Abstract:
  7. This is the modeset code for the CL6410/20 miniport driver.
  8. Environment:
  9. kernel mode only
  10. Notes:
  11. Revision History:
  12. *
  13. * jl01 09-24-96 Fix Alt+Tab switching between "Introducing Windows NT"
  14. * and "Main". Refer to PDR#5409.
  15. * chu01 08-26-96 CL-GD5480 BitBlt enhancement.
  16. * chu02 10-06-96 Refresh rate setting for CL-GD5480 mode 7B
  17. * ( 1600 x 1200 x 8 bpp )
  18. * sge01 10-06-96 Fix PDR #6794: Correct Monitor refresh rate for 100Hz
  19. * file changed: cldata.c modeset.c
  20. * sge02 10-18-96 Add Monitor.Type Value name in registry
  21. * chu03 10-31-96 Set Mode through registry.
  22. * jl02 12-05-96 Comment out 5446 checking.
  23. * chu04 12-16-96 Enable color correct.
  24. *
  25. * myf0 08-19-96 added 85hz supported
  26. * myf1 08-20-96 supported panning scrolling
  27. * myf2 08-20-96 fixed hardware save/restore state bug for matterhorn
  28. * myf3 09-01-96 Added IOCTL_CIRRUS_PRIVATE_BIOS_CALL for TV supported
  29. * myf4 09-01-96 patch Viking BIOS bug, PDR #4287, begin
  30. * myf5 09-01-96 Fixed PDR #4365 keep all default refresh rate
  31. * myf6 09-17-96 Merged Desktop SRC1001 & MINI102
  32. * myf7 09-19-96 Fixed exclude 60Hz refresh rate selected
  33. * myf8 *09-21-96* May be need change CheckandUpdateDDC2BMonitor --keystring[]
  34. * myf9 09-21-96 8x6 panel in 6x4x256 mode, cursor can't move to bottom scrn
  35. * ms0809 09-25-96 fixed dstn panel icon corrupted
  36. * ms923 09-25-96 merge MS-923 Disp.zip code
  37. * myf10 09-26-96 Fixed DSTN reserved half-frame buffer bug.
  38. * myf11 09-26-96 Fixed 755x CE chip HW bug, access ramdac before disable HW
  39. * icons and cursor
  40. * myf12 10-01-96 Supported Hot Key switch display
  41. * myf13 10-05-96 Fixed /w panning scrolling, vertical expension on bug
  42. * myf14 10-15-96 Fixed PDR#6917, 6x4 panel can't panning scrolling for 754x
  43. * myf15 10-16-96 Fixed disable memory mapped IO for 754x, 755x
  44. * myf16 10-22-96 Fixed PDR #6933,panel type set different demo board setting
  45. * tao1 10-21-96 Added 7555 flag for Direct Draw support.
  46. * smith 10-22-96 Disable Timer event, because sometimes creat PAGE_FAULT or
  47. * IRQ level can't handle
  48. * myf17 11-04-96 Added special escape code must be use 11/5/96 later NTCTRL,
  49. * and added Matterhorn LF Device ID==0x4C
  50. * myf18 11-04-96 Fixed PDR #7075,
  51. * myf19 11-06-96 Fixed Vinking can't work problem, because DEVICEID = 0x30
  52. * is different from data book (CR27=0x2C)
  53. * myf20 11-12-96 Fixed DSTN panel initial reserved 128K memoru
  54. * myf21 11-15-96 fixed #7495 during change resolution, screen appear garbage
  55. * image, because not clear video memory.
  56. * myf22 11-19-96 Added 640x480x256/640x480x64K -85Hz refresh rate for 7548
  57. * myf23 11-21-96 Added fixed NT 3.51 S/W cursor panning problem
  58. * myf24 11-22-96 Added fixed NT 4.0 Japanese dos full screen problem
  59. * myf25 12-03-96 Fixed 8x6x16M 2560byte/line patch H/W bug PDR#7843, and
  60. * fixed pre-install microsoft requested
  61. * myf26 12-11-96 Fixed Japanese NT 4.0 Dos-full screen bug for LCD enable
  62. * myf27 01-09-97 Fixed NT3.51 PDR#7986, horizontal lines appears at logon
  63. * windows, set 8x6x64K mode boot up CRT, jumper set 8x6 DSTN
  64. * Fixed NT3.51 PDR#7987, set 64K color modes, garbage on
  65. * screen when boot up XGA panel.
  66. *
  67. * pat08 Previous changes that didn't make into drv1.11
  68. * sge03 01-23-97 Fix 1280x1024x8 clock mismatch problem for video.
  69. * myf28 02-03-97 Fixed NT dos full screen bug, and add new clpanel.c file
  70. * PDR #8357,mode 3, 12, panning scrolling bug
  71. * myf29 02-12-97 Support Gamma correction graphic/video LUT for 755x
  72. * myf30 02-10-97 Fixed NT3.51, 6x4 LCD boot set 256 coloe, test 64K mode
  73. * chu05 02-19-97 MMIO internal error.
  74. * chu06 03-12-96 Remove SR16 overwrite for 5436 or later. This is requested
  75. * by Siemens Europe.
  76. * myf31 03-12-97 Fixed 755x vertical expension on(CR82), HW cursor bug
  77. * myf33 :03-21-97 check TV on, disable HW video & HW cursor, PDR #9006
  78. * chu07 03-26-97 Get rid of 1024x768x16bpp ( Mode 0x74 ) 85H for IBM only.
  79. * chu08 03-26-97 Common routine to get Cirrus chip and revision IDs.
  80. * myf34 :04-08-97 if Internal TV on, change Vres to 452 (480-28) lines.
  81. * myf35 :05-08-97 fIXED 7548 vl-BUS bug for panning scrolling enable
  82. *
  83. --*/
  84. //#include <ntddk.h>
  85. #include <dderror.h>
  86. #include <devioctl.h>
  87. //#include <clmini.h>
  88. #include <miniport.h>
  89. #include <ntddvdeo.h>
  90. #include <video.h>
  91. #include "cirrus.h"
  92. #include "cmdcnst.h"
  93. //
  94. // Temporarily include defines from NTDDK.H which we can't
  95. // currently include due to header file conflicts.
  96. //
  97. #include "clddk.h"
  98. //crus
  99. #ifndef VIDEO_MODE_MAP_MEM_LINEAR
  100. #define VIDEO_MODE_MAP_MEM_LINEAR 0x40000000
  101. #endif
  102. // crus
  103. #define DSTN (Dual_LCD | STN_LCD)
  104. #define DSTN10 (DSTN | panel10x7)
  105. #define DSTN8 (DSTN | panel8x6)
  106. #define DSTN6 (DSTN | panel)
  107. #define PanelType (panel | panel8x6 | panel10x7)
  108. #define ScreenType (DSTN | PanelType)
  109. extern UCHAR EDIDBuffer[] ;
  110. extern UCHAR EDIDTiming_I ;
  111. extern UCHAR EDIDTiming_II ;
  112. extern UCHAR EDIDTiming_III ;
  113. extern UCHAR DDC2BFlag ;
  114. extern OEMMODE_EXCLUDE ModeExclude ; // chu07
  115. //crus begin
  116. #if 0 //myf28
  117. extern SHORT Panning_flag;
  118. //myf1, begin
  119. //#define PANNING_SCROLL
  120. #ifdef PANNING_SCROLL
  121. extern RESTABLE ResolutionTable[];
  122. extern PANNMODE PanningMode;
  123. extern USHORT ViewPoint_Mode;
  124. PANNMODE PanningMode = {1024, 768, 1024, 8, -1 };
  125. #endif
  126. extern UCHAR HWcur, HWicon0, HWicon1, HWicon2, HWicon3; //myf11
  127. #endif //0,myf28
  128. VOID //myf11
  129. AccessHWiconcursor(
  130. PHW_DEVICE_EXTENSION HwDeviceExtension,
  131. SHORT Access_flag
  132. );
  133. #ifdef PANNING_SCROLL
  134. VP_STATUS
  135. CirrusSetDisplayPitch (
  136. PHW_DEVICE_EXTENSION HwDeviceExtension,
  137. PANNMODE PanningMode
  138. );
  139. #endif
  140. ULONG
  141. GetPanelFlags( //myf17
  142. PHW_DEVICE_EXTENSION HwDeviceExtension
  143. );
  144. //myf28
  145. ULONG
  146. SetLaptopMode(
  147. PHW_DEVICE_EXTENSION HwDeviceExtension,
  148. PVIDEOMODE pRequestedMode,
  149. ULONG RequestedModeNum
  150. );
  151. //myf1, end
  152. //crus end
  153. VP_STATUS
  154. VgaInterpretCmdStream(
  155. PHW_DEVICE_EXTENSION HwDeviceExtension,
  156. PUSHORT pusCmdStream
  157. );
  158. VP_STATUS
  159. VgaSetMode(
  160. PHW_DEVICE_EXTENSION HwDeviceExtension,
  161. PVIDEO_MODE Mode,
  162. ULONG ModeSize
  163. );
  164. VP_STATUS
  165. VgaQueryAvailableModes(
  166. PHW_DEVICE_EXTENSION HwDeviceExtension,
  167. PVIDEO_MODE_INFORMATION ModeInformation,
  168. ULONG ModeInformationSize,
  169. PULONG OutputSize
  170. );
  171. VP_STATUS
  172. VgaQueryNumberOfAvailableModes(
  173. PHW_DEVICE_EXTENSION HwDeviceExtension,
  174. PVIDEO_NUM_MODES NumModes,
  175. ULONG NumModesSize,
  176. PULONG OutputSize
  177. );
  178. VP_STATUS
  179. VgaQueryCurrentMode(
  180. PHW_DEVICE_EXTENSION HwDeviceExtension,
  181. PVIDEO_MODE_INFORMATION ModeInformation,
  182. ULONG ModeInformationSize,
  183. PULONG OutputSize
  184. );
  185. VOID
  186. VgaZeroVideoMemory(
  187. PHW_DEVICE_EXTENSION HwDeviceExtension
  188. );
  189. VOID
  190. CirrusValidateModes(
  191. PHW_DEVICE_EXTENSION HwDeviceExtension
  192. );
  193. //crus
  194. ULONG
  195. GetAttributeFlags(
  196. PHW_DEVICE_EXTENSION HwDeviceExtension
  197. );
  198. //crus
  199. // LCD Support
  200. USHORT
  201. CheckLCDSupportMode(
  202. PHW_DEVICE_EXTENSION HwDeviceExtension,
  203. ULONG i
  204. );
  205. // DDC2B support
  206. BOOLEAN
  207. CheckDDC2B(
  208. PHW_DEVICE_EXTENSION HwDeviceExtension,
  209. ULONG i
  210. );
  211. VOID
  212. AdjFastPgMdOperOnCL5424(
  213. PHW_DEVICE_EXTENSION HwDeviceExtension,
  214. PVIDEOMODE pRequestedMode
  215. );
  216. // crus
  217. // jl02 BOOLEAN
  218. // jl02 CheckGD5446Rev(
  219. // jl02 PHW_DEVICE_EXTENSION HwDeviceExtension
  220. // jl02 );
  221. //crus
  222. VOID CheckAndUpdateDDC2BMonitor(
  223. PHW_DEVICE_EXTENSION hwDeviceExtension
  224. );
  225. VP_STATUS
  226. CirrusDDC2BRegistryCallback(
  227. PVOID HwDeviceExtension,
  228. PVOID Context,
  229. PWSTR ValueName,
  230. PVOID ValueData,
  231. ULONG ValueLength
  232. );
  233. //crus
  234. BOOLEAN
  235. CheckDDC2BMonitor(
  236. PHW_DEVICE_EXTENSION HwDeviceExtension,
  237. ULONG i
  238. );
  239. // chu03
  240. BOOLEAN
  241. VgaSetModeThroughRegistry(
  242. PHW_DEVICE_EXTENSION hwDeviceExtension,
  243. PVIDEOMODE pRequestedMode,
  244. USHORT hres,
  245. USHORT vres
  246. );
  247. // chu07
  248. GetOemModeOffInfoCallBack (
  249. PVOID HwDeviceExtension,
  250. PVOID Context,
  251. PWSTR ValueName,
  252. PVOID ValueData,
  253. ULONG ValueLength
  254. );
  255. // chu08
  256. UCHAR
  257. GetCirrusChipId(
  258. PHW_DEVICE_EXTENSION HwDeviceExtension
  259. );
  260. // chu08
  261. USHORT
  262. GetCirrusChipRevisionId(
  263. PHW_DEVICE_EXTENSION HwDeviceExtension
  264. );
  265. #if defined(ALLOC_PRAGMA)
  266. #pragma alloc_text(PAGE,VgaInterpretCmdStream)
  267. #pragma alloc_text(PAGE,VgaSetMode)
  268. #pragma alloc_text(PAGE,VgaQueryAvailableModes)
  269. #pragma alloc_text(PAGE,VgaQueryNumberOfAvailableModes)
  270. #if 0 //myf28
  271. #ifdef PANNING_SCROLL
  272. #pragma alloc_text(PAGE,CirrusSetDisplayPitch) //myf1, crus
  273. #endif
  274. #pragma alloc_text(PAGE,SetLaptopMode) //myf28
  275. #pragma alloc_text(PAGE,AccessHWiconcursor) //myf11, crus
  276. #pragma alloc_text(PAGE,GetPanelFlags) //myf17
  277. #endif //myf28
  278. #pragma alloc_text(PAGE,VgaQueryCurrentMode)
  279. #pragma alloc_text(PAGE,VgaZeroVideoMemory)
  280. #pragma alloc_text(PAGE,CirrusValidateModes)
  281. #pragma alloc_text(PAGE,GetAttributeFlags)
  282. //myf28 #pragma alloc_text(PAGE,CheckLCDSupportMode)
  283. #pragma alloc_text(PAGE,CheckDDC2B)
  284. #pragma alloc_text(PAGE,AdjFastPgMdOperOnCL5424)
  285. // jl02 #pragma alloc_text(PAGE,CheckGD5446Rev)
  286. //crus
  287. #pragma alloc_text(PAGE,CheckAndUpdateDDC2BMonitor)
  288. #pragma alloc_text(PAGE,CirrusDDC2BRegistryCallback)
  289. #pragma alloc_text(PAGE,GetOemModeOffInfoCallBack) // chu07
  290. #pragma alloc_text(PAGE,GetCirrusChipId) // chu08
  291. #pragma alloc_text(PAGE,GetCirrusChipRevisionId) // chu08
  292. #endif
  293. // the following is defined in cirrus.c
  294. VOID
  295. SetCirrusBanking(
  296. PHW_DEVICE_EXTENSION HwDeviceExtension,
  297. ULONG BankNumber
  298. );
  299. //---------------------------------------------------------------------------
  300. VP_STATUS
  301. VgaInterpretCmdStream(
  302. PHW_DEVICE_EXTENSION HwDeviceExtension,
  303. PUSHORT pusCmdStream
  304. )
  305. /*++
  306. Routine Description:
  307. Interprets the appropriate command array to set up VGA registers for the
  308. requested mode. Typically used to set the VGA into a particular mode by
  309. programming all of the registers
  310. Arguments:
  311. HwDeviceExtension - Pointer to the miniport driver's device extension.
  312. pusCmdStream - array of commands to be interpreted.
  313. Return Value:
  314. The status of the operation (can only fail on a bad command); TRUE for
  315. success, FALSE for failure.
  316. --*/
  317. {
  318. ULONG ulCmd;
  319. ULONG ulPort;
  320. UCHAR jValue;
  321. USHORT usValue;
  322. ULONG culCount;
  323. ULONG ulIndex;
  324. ULONG ulBase;
  325. // chu05
  326. UCHAR i;
  327. USHORT tempW;
  328. // VideoDebugPrint((0, "Miniport - VgaInterpretCmdStream\n")); //myfr
  329. if (pusCmdStream == NULL) {
  330. VideoDebugPrint((1, "VgaInterpretCmdStream - Invalid pusCmdStream\n"));
  331. return TRUE;
  332. }
  333. ulBase = PtrToUlong(HwDeviceExtension->IOAddress);
  334. //
  335. // Now set the adapter to the desired mode.
  336. //
  337. while ((ulCmd = *pusCmdStream++) != EOD) {
  338. //
  339. // Determine major command type
  340. //
  341. switch (ulCmd & 0xF0) {
  342. //
  343. // Basic input/output command
  344. //
  345. case INOUT:
  346. //
  347. // Determine type of inout instruction
  348. //
  349. if (!(ulCmd & IO)) {
  350. //
  351. // Out instruction. Single or multiple outs?
  352. //
  353. if (!(ulCmd & MULTI)) {
  354. //
  355. // Single out. Byte or word out?
  356. //
  357. if (!(ulCmd & BW)) {
  358. //
  359. // Single byte out
  360. //
  361. ulPort = *pusCmdStream++;
  362. jValue = (UCHAR) *pusCmdStream++;
  363. VideoPortWritePortUchar((PUCHAR)(ULONG_PTR)(ulBase+ulPort),
  364. jValue);
  365. } else {
  366. //
  367. // Single word out
  368. //
  369. ulPort = *pusCmdStream++;
  370. usValue = *pusCmdStream++;
  371. VideoPortWritePortUshort((PUSHORT)(ULONG_PTR)(ulBase+ulPort),
  372. usValue);
  373. }
  374. } else {
  375. //
  376. // Output a string of values
  377. // Byte or word outs?
  378. //
  379. if (!(ulCmd & BW)) {
  380. //
  381. // String byte outs. Do in a loop; can't use
  382. // VideoPortWritePortBufferUchar because the data
  383. // is in USHORT form
  384. //
  385. ulPort = ulBase + *pusCmdStream++;
  386. culCount = *pusCmdStream++;
  387. while (culCount--) {
  388. jValue = (UCHAR) *pusCmdStream++;
  389. VideoPortWritePortUchar((PUCHAR)(ULONG_PTR)ulPort,
  390. jValue);
  391. }
  392. } else {
  393. //
  394. // String word outs
  395. //
  396. ulPort = *pusCmdStream++;
  397. culCount = *pusCmdStream++;
  398. // chu05
  399. if (!HwDeviceExtension->bMMAddress)
  400. {
  401. VideoPortWritePortBufferUshort((PUSHORT)(ULONG_PTR)
  402. (ulBase + ulPort), pusCmdStream, culCount);
  403. pusCmdStream += culCount;
  404. }
  405. else
  406. {
  407. for (i = 0; i < culCount; i++)
  408. {
  409. tempW = *pusCmdStream ;
  410. VideoPortWritePortUchar((PUCHAR)(ULONG_PTR)(ulBase + ulPort),
  411. (UCHAR)tempW) ;
  412. VideoPortWritePortUchar((PUCHAR)(ULONG_PTR)(ulBase + ulPort + 1),
  413. (UCHAR)(tempW >> 8)) ;
  414. pusCmdStream++ ;
  415. }
  416. }
  417. }
  418. }
  419. } else {
  420. // In instruction
  421. //
  422. // Currently, string in instructions aren't supported; all
  423. // in instructions are handled as single-byte ins
  424. //
  425. // Byte or word in?
  426. //
  427. if (!(ulCmd & BW)) {
  428. //
  429. // Single byte in
  430. //
  431. ulPort = *pusCmdStream++;
  432. jValue = VideoPortReadPortUchar((PUCHAR)(ULONG_PTR)(ulBase+ulPort));
  433. } else {
  434. //
  435. // Single word in
  436. //
  437. ulPort = *pusCmdStream++;
  438. usValue = VideoPortReadPortUshort((PUSHORT)(ULONG_PTR)
  439. (ulBase+ulPort));
  440. }
  441. }
  442. break;
  443. //
  444. // Higher-level input/output commands
  445. //
  446. case METAOUT:
  447. //
  448. // Determine type of metaout command, based on minor
  449. // command field
  450. //
  451. switch (ulCmd & 0x0F) {
  452. //
  453. // Indexed outs
  454. //
  455. case INDXOUT:
  456. ulPort = ulBase + *pusCmdStream++;
  457. culCount = *pusCmdStream++;
  458. ulIndex = *pusCmdStream++;
  459. while (culCount--) {
  460. usValue = (USHORT) (ulIndex +
  461. (((ULONG)(*pusCmdStream++)) << 8));
  462. VideoPortWritePortUshort((PUSHORT)(ULONG_PTR)ulPort, usValue);
  463. ulIndex++;
  464. }
  465. break;
  466. //
  467. // Masked out (read, AND, XOR, write)
  468. //
  469. case MASKOUT:
  470. ulPort = *pusCmdStream++;
  471. jValue = VideoPortReadPortUchar((PUCHAR)(ULONG_PTR)(ulBase+ulPort));
  472. jValue &= *pusCmdStream++;
  473. jValue ^= *pusCmdStream++;
  474. VideoPortWritePortUchar((PUCHAR)(ULONG_PTR)(ulBase + ulPort),
  475. jValue);
  476. break;
  477. //
  478. // Attribute Controller out
  479. //
  480. case ATCOUT:
  481. ulPort = ulBase + *pusCmdStream++;
  482. culCount = *pusCmdStream++;
  483. ulIndex = *pusCmdStream++;
  484. while (culCount--) {
  485. // Write Attribute Controller index
  486. VideoPortWritePortUchar((PUCHAR)(ULONG_PTR)ulPort,
  487. (UCHAR)ulIndex);
  488. // Write Attribute Controller data
  489. jValue = (UCHAR) *pusCmdStream++;
  490. VideoPortWritePortUchar((PUCHAR)(ULONG_PTR)ulPort, jValue);
  491. ulIndex++;
  492. }
  493. break;
  494. //
  495. // None of the above; error
  496. //
  497. default:
  498. return FALSE;
  499. }
  500. break;
  501. //
  502. // NOP
  503. //
  504. case NCMD:
  505. break;
  506. //
  507. // Unknown command; error
  508. //
  509. default:
  510. return FALSE;
  511. }
  512. }
  513. return TRUE;
  514. } // end VgaInterpretCmdStream()
  515. VP_STATUS
  516. VgaSetMode(
  517. PHW_DEVICE_EXTENSION HwDeviceExtension,
  518. PVIDEO_MODE Mode,
  519. ULONG ModeSize
  520. )
  521. /*++
  522. Routine Description:
  523. This routine sets the vga into the requested mode.
  524. Arguments:
  525. HwDeviceExtension - Pointer to the miniport driver's device extension.
  526. Mode - Pointer to the structure containing the information about the
  527. font to be set.
  528. ModeSize - Length of the input buffer supplied by the user.
  529. Return Value:
  530. ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough
  531. for the input data.
  532. ERROR_INVALID_PARAMETER if the mode number is invalid.
  533. NO_ERROR if the operation completed successfully.
  534. --*/
  535. {
  536. PVIDEOMODE pRequestedMode;
  537. PUSHORT pusCmdStream;
  538. VP_STATUS status;
  539. VIDEO_X86_BIOS_ARGUMENTS biosArguments;
  540. USHORT Int10ModeNumber;
  541. ULONG RequestedModeNum;
  542. // crus
  543. UCHAR originalGRIndex, tempB ;
  544. UCHAR SEQIndex ;
  545. //crus
  546. //myf28 SHORT i; //myf1
  547. // crus chu02
  548. ULONG ulFlags = 0 ;
  549. // chu03, begin
  550. BOOLEAN result = 0 ;
  551. USHORT hres, vres ;
  552. //chu03 end
  553. //
  554. // Check if the size of the data in the input buffer is large enough.
  555. //
  556. // VideoDebugPrint((0, "Miniport - VgaSetMode\n")); //myfr
  557. if (ModeSize < sizeof(VIDEO_MODE))
  558. {
  559. return ERROR_INSUFFICIENT_BUFFER;
  560. }
  561. //
  562. // Extract the clear memory, and map linear bits.
  563. //
  564. RequestedModeNum = Mode->RequestedMode &
  565. ~(VIDEO_MODE_NO_ZERO_MEMORY | VIDEO_MODE_MAP_MEM_LINEAR);
  566. if (!(Mode->RequestedMode & VIDEO_MODE_NO_ZERO_MEMORY))
  567. {
  568. #if defined(_X86_)
  569. #if (_WIN32_WINNT >= 0x0400) //pat08
  570. //
  571. // Don't do the operation. Some Intel servers mysteriously RESET them selves because of this
  572. //
  573. if ((HwDeviceExtension->ChipType & CL754x) == 0) //myf35, fix VL-bus bug
  574. {
  575. //VgaZeroVideoMemory(HwDeviceExtension);
  576. }
  577. #else //pat08
  578. if (((HwDeviceExtension->ChipType & CL754x) == 0) && //pat08
  579. ((HwDeviceExtension->ChipType & CL755x) == 0) ) //pat08
  580. {
  581. //VgaZeroVideoMemory(HwDeviceExtension);
  582. }
  583. #endif //pat08
  584. #endif
  585. }
  586. //
  587. // Check to see if we are requesting a valid mode
  588. //
  589. if ( (RequestedModeNum >= NumVideoModes) ||
  590. (!ModesVGA[RequestedModeNum].ValidMode) )
  591. {
  592. VideoDebugPrint((1, "Invalide Mode Number = %d!\n", RequestedModeNum));
  593. return ERROR_INVALID_PARAMETER;
  594. }
  595. //
  596. // Check to see if we are trying to map a non linear
  597. // mode linearly.
  598. //
  599. // We will fail early if we are trying to set a mode
  600. // with a linearly mapped frame buffer, and either of the
  601. // following two conditions are true:
  602. //
  603. // 1) The mode can not be mapped linearly because it is
  604. // a vga mode, etc.
  605. //
  606. // or,
  607. //
  608. // 2) We did not find the card in a PCI slot, and thus
  609. // can not do linear mappings period.
  610. //
  611. VideoDebugPrint((1, "Linear Mode Requested: %x\n"
  612. "Linear Mode Supported: %x\n",
  613. Mode->RequestedMode & VIDEO_MODE_MAP_MEM_LINEAR,
  614. ModesVGA[RequestedModeNum].LinearSupport));
  615. #if defined(_ALPHA_)
  616. //
  617. // For some reason if we map a linear frame buffer
  618. // for the 5434 and older chips on the alpha, we
  619. // die when we touch the memory. However, if we map
  620. // a banked 64k frame buffer all works fine. So,
  621. // lets always fail the linear frame buffer mode set
  622. // on alpha for older chips.
  623. //
  624. // For some reason which is also a mystery to me, we
  625. // can map the memory linearly for the 5446 and
  626. // newer chips.
  627. //
  628. if (Mode->RequestedMode & VIDEO_MODE_MAP_MEM_LINEAR) {
  629. if ((HwDeviceExtension->ChipRevision != CL5436_ID) &&
  630. (HwDeviceExtension->ChipRevision != CL5446_ID) &&
  631. (HwDeviceExtension->ChipRevision != CL5480_ID)) {
  632. return ERROR_INVALID_PARAMETER;
  633. }
  634. }
  635. #endif
  636. if ((Mode->RequestedMode & VIDEO_MODE_MAP_MEM_LINEAR) &&
  637. ((!ModesVGA[RequestedModeNum].LinearSupport) ||
  638. (!VgaAccessRange[3].RangeLength)))
  639. {
  640. VideoDebugPrint((1, "Cannot set linear mode!\n"));
  641. return ERROR_INVALID_PARAMETER;
  642. }
  643. else
  644. {
  645. #if defined(_X86_) || defined(_ALPHA_)
  646. HwDeviceExtension->LinearMode =
  647. (Mode->RequestedMode & VIDEO_MODE_MAP_MEM_LINEAR) ?
  648. TRUE : FALSE;
  649. #else
  650. HwDeviceExtension->LinearMode = TRUE;
  651. #endif
  652. VideoDebugPrint((1, "Linear Mode = %s\n",
  653. Mode->RequestedMode & VIDEO_MODE_MAP_MEM_LINEAR ?
  654. "TRUE" : "FALSE")); //myfr, 1
  655. }
  656. VideoDebugPrint((1, "Attempting to set mode %d\n",
  657. RequestedModeNum));
  658. pRequestedMode = &ModesVGA[RequestedModeNum];
  659. VideoDebugPrint((1, "Info on Requested Mode:\n"
  660. "\tResolution: %dx%dx%d\n",
  661. pRequestedMode->hres,
  662. pRequestedMode->vres,
  663. pRequestedMode->bitsPerPlane )); //myfr, 2
  664. #ifdef INT10_MODE_SET
  665. //
  666. // Set SR14 bit 2 to lock panel, Panel will not be turned on if setting
  667. // this bit. For laptop products only.
  668. //
  669. //myf28 begin
  670. if ((HwDeviceExtension->ChipType == CL756x) ||
  671. (HwDeviceExtension->ChipType & CL755x) ||
  672. (HwDeviceExtension->ChipType == CL6245) ||
  673. (HwDeviceExtension->ChipType & CL754x))
  674. {
  675. status = SetLaptopMode(HwDeviceExtension,pRequestedMode,
  676. RequestedModeNum);
  677. #if 0
  678. if ((status == ERROR_INVALID_PARAMETER) ||
  679. (status == ERROR_INSUFFICIENT_BUFFER))
  680. return status;
  681. else
  682. pRequestedMode = (PVIDEOMODE)status;
  683. #endif
  684. if (status != NO_ERROR) {
  685. return status;
  686. }
  687. }
  688. //myf28 end
  689. VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
  690. //
  691. // first, set the montype, if valid
  692. //
  693. if ((pRequestedMode->MonitorType) &&
  694. !(HwDeviceExtension->ChipType & CL754x) &&
  695. (HwDeviceExtension->ChipType != CL756x) &&
  696. // crus
  697. (HwDeviceExtension->ChipType != CL6245) &&
  698. !(HwDeviceExtension->ChipType & CL755x) )
  699. {
  700. biosArguments.Eax = 0x1200 | pRequestedMode->MonitorType;
  701. biosArguments.Ebx = 0xA2; // set monitor type command
  702. status = VideoPortInt10(HwDeviceExtension, &biosArguments);
  703. if (status != NO_ERROR)
  704. return status;
  705. }
  706. //
  707. // Set the Vertical Monitor type, if BIOS supports it
  708. //
  709. if ((pRequestedMode->MonTypeAX) &&
  710. !(HwDeviceExtension->ChipType & CL754x) &&
  711. (HwDeviceExtension->ChipType != CL756x) &&
  712. // crus
  713. (HwDeviceExtension->ChipType != CL6245) &&
  714. !(HwDeviceExtension->ChipType & CL755x) )
  715. {
  716. biosArguments.Eax = pRequestedMode->MonTypeAX;
  717. biosArguments.Ebx = pRequestedMode->MonTypeBX; // set monitor type
  718. biosArguments.Ecx = pRequestedMode->MonTypeCX;
  719. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  720. if (status != NO_ERROR)
  721. {
  722. return status;
  723. }
  724. // crus
  725. // chu02
  726. #if 0
  727. ulFlags = GetAttributeFlags(HwDeviceExtension) ;
  728. if ((ulFlags & CAPS_COMMAND_LIST) &&
  729. (pRequestedMode->hres == 1600) &&
  730. (pRequestedMode->bitsPerPlane == 8))
  731. {
  732. switch (pRequestedMode->Frequency)
  733. {
  734. UCHAR tempB ;
  735. case 60 :
  736. // o 3c4 14
  737. VideoPortWritePortUchar (HwDeviceExtension->IOAddress +
  738. SEQ_ADDRESS_PORT, 0x14) ;
  739. // i 3c5 tempB
  740. tempB = VideoPortReadPortUchar (HwDeviceExtension->IOAddress +
  741. SEQ_DATA_PORT) ;
  742. tempB &= 0x1F ;
  743. tempB |= 0x20 ;
  744. // o 3c5 tempB
  745. VideoPortWritePortUchar (HwDeviceExtension->IOAddress +
  746. SEQ_DATA_PORT, tempB) ;
  747. break ;
  748. case 70 :
  749. // o 3c4 14
  750. VideoPortWritePortUchar (HwDeviceExtension->IOAddress +
  751. SEQ_ADDRESS_PORT, 0x14) ;
  752. // i 3c5 tempB
  753. tempB = VideoPortReadPortUchar (HwDeviceExtension->IOAddress +
  754. SEQ_DATA_PORT) ;
  755. tempB &= 0x1F ;
  756. tempB |= 0x40 ;
  757. // o 3c5 tempB
  758. VideoPortWritePortUchar (HwDeviceExtension->IOAddress +
  759. SEQ_DATA_PORT, tempB) ;
  760. break ;
  761. }
  762. }
  763. #endif // 0
  764. }
  765. //
  766. // for 640x480 modes, determine the refresh type
  767. //
  768. if (pRequestedMode->hres == 640)
  769. {
  770. if (!(HwDeviceExtension->ChipType & CL754x) &&
  771. (HwDeviceExtension->ChipType != CL756x) &&
  772. //crus
  773. (HwDeviceExtension->ChipType != CL6245) &&
  774. !(HwDeviceExtension->ChipType & CL755x) )
  775. {
  776. if (HwDeviceExtension->ChipType == CL543x)
  777. {
  778. switch (pRequestedMode->Frequency) {
  779. case 72 :
  780. biosArguments.Eax = 0x1200; // set HIGH refresh to 72hz
  781. break;
  782. case 75:
  783. biosArguments.Eax = 0x1201; // set HIGH refresh to 75hz
  784. break;
  785. case 85:
  786. biosArguments.Eax = 0x1202; // set HIGH refresh to 85hz
  787. break;
  788. // crus
  789. // sge01
  790. case 100:
  791. biosArguments.Eax = 0x1203; // set HIGH refresh to 100hz
  792. break;
  793. }
  794. biosArguments.Ebx = 0xAF; // set refresh type
  795. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  796. biosArguments.Eax = 0x1200;
  797. biosArguments.Ebx = 0xAE; // get refresh type
  798. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  799. } else {
  800. if (pRequestedMode->Frequency == 72)
  801. {
  802. // 72 hz refresh setup only takes effect in 640x480
  803. biosArguments.Eax = 0x1201; // enable HIGH refresh
  804. }
  805. else
  806. {
  807. // set low refresh rate
  808. biosArguments.Eax = 0x1200; // enable LOW refresh, 640x480 only
  809. }
  810. biosArguments.Ebx = 0xA3; // set refresh type
  811. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  812. }
  813. if (status != NO_ERROR)
  814. {
  815. return status;
  816. }
  817. }
  818. }
  819. VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
  820. //
  821. // then, set the mode
  822. //
  823. switch (HwDeviceExtension->ChipType)
  824. {
  825. case CL6410:
  826. Int10ModeNumber = pRequestedMode->BiosModes.BiosModeCL6410;
  827. break;
  828. case CL6420:
  829. Int10ModeNumber = pRequestedMode->BiosModes.BiosModeCL6420;
  830. break;
  831. case CL542x:
  832. case CL543x: //myf1
  833. //crus
  834. Int10ModeNumber = pRequestedMode->BiosModes.BiosModeCL542x;
  835. break;
  836. case CL754x:
  837. case CL755x:
  838. case CL7541:
  839. case CL7542:
  840. case CL7543:
  841. case CL7548:
  842. case CL7555:
  843. case CL7556:
  844. case CL756x:
  845. // crus
  846. case CL6245:
  847. Int10ModeNumber = pRequestedMode->BiosModes.BiosModeCL542x;
  848. //crus
  849. //myf1, begin
  850. #ifdef PANNING_SCROLL
  851. Int10ModeNumber |= 0x80;
  852. #endif
  853. //myf1, end
  854. break;
  855. }
  856. biosArguments.Eax = Int10ModeNumber;
  857. //crus
  858. //myf11: 9-26-96 fixed 755x-CE chip bug
  859. if (HwDeviceExtension->ChipType == CL7555)
  860. {
  861. AccessHWiconcursor(HwDeviceExtension, 0); //disable HW icon, cursor
  862. }
  863. //myf21 : 11-15-96 fixed #7495 during change resolution, screen appear garbage
  864. // image, because not clear video memory.
  865. // SEQIndex = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  866. // SEQ_ADDRESS_PORT);
  867. // VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  868. // SEQ_ADDRESS_PORT, 0x01);
  869. // tempB = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  870. // SEQ_DATA_PORT);
  871. // VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  872. // SEQ_DATA_PORT,(tempB | 0x20));
  873. // VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  874. // SEQ_ADDRESS_PORT, SEQIndex);
  875. status = VideoPortInt10(HwDeviceExtension, &biosArguments);
  876. //myf21 : 11-15-96 fixed #7495 during change resolution, screen appear garbage
  877. // image, because not clear video memory.
  878. // SEQIndex = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  879. // SEQ_ADDRESS_PORT);
  880. // VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  881. // SEQ_ADDRESS_PORT, 0x01);
  882. // tempB = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  883. // SEQ_DATA_PORT);
  884. // VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  885. // SEQ_DATA_PORT,(tempB & ~0x20));
  886. // VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  887. // SEQ_ADDRESS_PORT, SEQIndex);
  888. //crus
  889. if (HwDeviceExtension->ChipType == CL7555)
  890. {
  891. AccessHWiconcursor(HwDeviceExtension, 1); //Enable HW icon, cursor
  892. }
  893. //crus
  894. #if 0 //jl01
  895. if (HwDeviceExtension->AutoFeature)
  896. {
  897. // i 3ce originalGRIndex
  898. originalGRIndex = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  899. GRAPH_ADDRESS_PORT);
  900. // o 3ce 31
  901. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  902. GRAPH_ADDRESS_PORT, INDEX_ENABLE_AUTO_START);
  903. // i 3cf tempB
  904. tempB = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  905. GRAPH_DATA_PORT);
  906. tempB |= (UCHAR) 0x80; //enable auto start bit 7
  907. // o 3cf tempB
  908. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  909. GRAPH_DATA_PORT, tempB);
  910. // o 3ce originalGRIndex
  911. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  912. GRAPH_ADDRESS_PORT, originalGRIndex);
  913. }
  914. #endif //jl01
  915. //
  916. // Lets check to see that we actually went into the mode
  917. // we just tried to set. If not, then return failure.
  918. //
  919. biosArguments.Eax = 0x0f00;
  920. VideoPortInt10(HwDeviceExtension, &biosArguments);
  921. if ((biosArguments.Eax & 0xff) != Int10ModeNumber)
  922. {
  923. //
  924. // The int10 modeset failed. Return the failure back to
  925. // the system.
  926. //
  927. VideoDebugPrint((1, "The INT 10 modeset didn't set the mode.\n"));
  928. return ERROR_INVALID_PARAMETER;
  929. }
  930. //crus begin
  931. #if 0 //myf28
  932. HwDeviceExtension->bCurrentMode = RequestedModeNum; //myf12
  933. VideoDebugPrint((1, "SetMode Info :\n"
  934. "\tMode : %x, CurrentModeNum : %x, ( %d)\n",
  935. Int10ModeNumber,
  936. RequestedModeNum,
  937. RequestedModeNum));
  938. #endif //myf28
  939. //crus end
  940. AdjFastPgMdOperOnCL5424 (HwDeviceExtension, pRequestedMode) ;
  941. //
  942. // this code fixes a bug for color TFT panels only
  943. // when on the 6420 and in 640x480 8bpp only
  944. //
  945. if ( (HwDeviceExtension->ChipType == CL6420) &&
  946. (pRequestedMode->bitsPerPlane == 8) &&
  947. (pRequestedMode->hres == 640) )
  948. {
  949. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  950. GRAPH_ADDRESS_PORT, 0xDC); // color LCD config reg.
  951. if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  952. GRAPH_DATA_PORT) & 01) // if TFT panel
  953. {
  954. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  955. GRAPH_ADDRESS_PORT, 0xD6); // greyscale offset LCD reg.
  956. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  957. GRAPH_DATA_PORT,
  958. (UCHAR)((VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  959. GRAPH_DATA_PORT) & 0x3f) | 0x40));
  960. }
  961. }
  962. #endif //INT10_MODE_SET
  963. // chu03
  964. //MODESET_OK:
  965. //
  966. // Select proper command array for adapter type
  967. //
  968. switch (HwDeviceExtension->ChipType)
  969. {
  970. case CL6410:
  971. VideoDebugPrint((1, "VgaSetMode - Setting mode for 6410\n"));
  972. if (HwDeviceExtension->DisplayType == crt)
  973. pusCmdStream = pRequestedMode->CmdStrings[pCL6410_crt];
  974. else
  975. pusCmdStream = pRequestedMode->CmdStrings[pCL6410_panel];
  976. break;
  977. case CL6420:
  978. VideoDebugPrint((1, "VgaSetMode - Setting mode for 6420\n"));
  979. if (HwDeviceExtension->DisplayType == crt)
  980. pusCmdStream = pRequestedMode->CmdStrings[pCL6420_crt];
  981. else
  982. pusCmdStream = pRequestedMode->CmdStrings[pCL6420_panel];
  983. break;
  984. case CL542x:
  985. VideoDebugPrint((1, "VgaSetMode - Setting mode for 542x\n"));
  986. pusCmdStream = pRequestedMode->CmdStrings[pCL542x];
  987. break;
  988. case CL543x:
  989. if (HwDeviceExtension->BoardType == NEC_ONBOARD_CIRRUS)
  990. {
  991. VideoDebugPrint((1, "VgaSetMode - Setting mode for NEC 543x\n"));
  992. pusCmdStream = pRequestedMode->CmdStrings[pNEC_CL543x];
  993. }
  994. else
  995. {
  996. VideoDebugPrint((1, "VgaSetMode - Setting mode for 543x\n"));
  997. pusCmdStream = pRequestedMode->CmdStrings[pCL543x];
  998. }
  999. break;
  1000. case CL7541:
  1001. case CL7542:
  1002. case CL7543:
  1003. case CL7548:
  1004. case CL754x: // Use 543x cmd strs (16k granularity, >1M modes)
  1005. VideoDebugPrint((1, "VgaSetMode - Setting mode for 754x\n"));
  1006. pusCmdStream = pRequestedMode->CmdStrings[pCL543x];
  1007. //crus
  1008. #if 0 //myf10
  1009. if ( (pRequestedMode->bitsPerPlane == 16) &&
  1010. (pRequestedMode->hres == 640) )
  1011. {
  1012. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1013. CRTC_ADDRESS_PORT_COLOR, 0x2E); //expension_reg.
  1014. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1015. CRTC_DATA_PORT_COLOR,
  1016. (UCHAR)((VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1017. CRTC_DATA_PORT_COLOR) & 0xF0)));
  1018. }
  1019. #endif
  1020. break;
  1021. case CL7555:
  1022. case CL7556:
  1023. case CL755x: // Use 543x cmd strs (16k granularity, >1M modes)
  1024. VideoDebugPrint((1, "VgaSetMode - Setting mode for 755x\n"));
  1025. pusCmdStream = pRequestedMode->CmdStrings[pCL543x];
  1026. break;
  1027. case CL756x: // Use 543x cmd strs (16k granularity, >1M modes)
  1028. VideoDebugPrint((1, "VgaSetMode - Setting mode for 756x\n"));
  1029. pusCmdStream = pRequestedMode->CmdStrings[pCL543x];
  1030. break;
  1031. // crus
  1032. case CL6245:
  1033. VideoDebugPrint((1, "VgaSetMode - Setting mode for 6245\n"));
  1034. pusCmdStream = pRequestedMode->CmdStrings[pCL542x];
  1035. break;
  1036. // end crus
  1037. default:
  1038. VideoDebugPrint((1, "HwDeviceExtension->ChipType is INVALID.\n"));
  1039. return ERROR_INVALID_PARAMETER;
  1040. }
  1041. VgaInterpretCmdStream(HwDeviceExtension, pusCmdStream);
  1042. //
  1043. // Set linear mode on X86 systems w/PCI bus
  1044. //
  1045. if (HwDeviceExtension->LinearMode)
  1046. {
  1047. VideoPortWritePortUchar (HwDeviceExtension->IOAddress +
  1048. SEQ_ADDRESS_PORT, 0x07);
  1049. VideoPortWritePortUchar (HwDeviceExtension->IOAddress + SEQ_DATA_PORT,
  1050. (UCHAR) (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1051. SEQ_DATA_PORT) | 0x10));
  1052. }
  1053. else
  1054. {
  1055. VideoPortWritePortUchar (HwDeviceExtension->IOAddress +
  1056. SEQ_ADDRESS_PORT, 0x07);
  1057. VideoPortWritePortUchar (HwDeviceExtension->IOAddress + SEQ_DATA_PORT,
  1058. (UCHAR) (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1059. SEQ_DATA_PORT) & ~0x10));
  1060. }
  1061. //
  1062. // Support 256 color modes by stretching the scan lines.
  1063. //
  1064. if (pRequestedMode->CmdStrings[pStretchScan])
  1065. {
  1066. VgaInterpretCmdStream(HwDeviceExtension,
  1067. pRequestedMode->CmdStrings[pStretchScan]);
  1068. }
  1069. {
  1070. UCHAR temp;
  1071. UCHAR dummy;
  1072. UCHAR bIsColor;
  1073. if (!(pRequestedMode->fbType & VIDEO_MODE_GRAPHICS))
  1074. {
  1075. //
  1076. // Fix to make sure we always set the colors in text mode to be
  1077. // intensity, and not flashing
  1078. // For this zero out the Mode Control Regsiter bit 3 (index 0x10
  1079. // of the Attribute controller).
  1080. //
  1081. if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1082. MISC_OUTPUT_REG_READ_PORT) & 0x01)
  1083. {
  1084. bIsColor = TRUE;
  1085. }
  1086. else
  1087. {
  1088. bIsColor = FALSE;
  1089. }
  1090. if (bIsColor)
  1091. {
  1092. dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1093. INPUT_STATUS_1_COLOR);
  1094. }
  1095. else
  1096. {
  1097. dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1098. INPUT_STATUS_1_MONO);
  1099. }
  1100. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1101. ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE));
  1102. temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1103. ATT_DATA_READ_PORT);
  1104. temp &= 0xF7;
  1105. if (bIsColor)
  1106. {
  1107. dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1108. INPUT_STATUS_1_COLOR);
  1109. }
  1110. else
  1111. {
  1112. dummy = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1113. INPUT_STATUS_1_MONO);
  1114. }
  1115. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1116. ATT_ADDRESS_PORT, (0x10 | VIDEO_ENABLE));
  1117. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1118. ATT_DATA_WRITE_PORT, temp);
  1119. }
  1120. }
  1121. //
  1122. // Update the location of the physical frame buffer within video memory.
  1123. //
  1124. if (HwDeviceExtension->LinearMode)
  1125. {
  1126. HwDeviceExtension->PhysicalVideoMemoryBase = VgaAccessRange[3].RangeStart;
  1127. HwDeviceExtension->PhysicalVideoMemoryLength = HwDeviceExtension->AdapterMemorySize;
  1128. HwDeviceExtension->PhysicalFrameLength = 0;
  1129. HwDeviceExtension->PhysicalFrameOffset.LowPart = 0;
  1130. }
  1131. else
  1132. {
  1133. HwDeviceExtension->PhysicalVideoMemoryBase = VgaAccessRange[2].RangeStart;
  1134. HwDeviceExtension->PhysicalVideoMemoryLength = VgaAccessRange[2].RangeLength;
  1135. HwDeviceExtension->PhysicalFrameLength =
  1136. MemoryMaps[pRequestedMode->MemMap].MaxSize;
  1137. HwDeviceExtension->PhysicalFrameOffset.LowPart =
  1138. MemoryMaps[pRequestedMode->MemMap].Offset;
  1139. }
  1140. //
  1141. // Store the new mode value.
  1142. //
  1143. HwDeviceExtension->CurrentMode = pRequestedMode;
  1144. HwDeviceExtension->ModeIndex = Mode->RequestedMode;
  1145. if ((HwDeviceExtension->ChipRevision < CL5434_ID) // we saved chip ID here
  1146. && (pRequestedMode->numPlanes != 4) )
  1147. {
  1148. if ((HwDeviceExtension->ChipRevision >= 0x0B) && //Nordic(Lite,Viking)
  1149. (HwDeviceExtension->ChipRevision <= 0x0E) && //and Everest
  1150. (HwDeviceExtension->DisplayType & (panel8x6)) &&
  1151. (pRequestedMode->hres == 640) &&
  1152. ((pRequestedMode->bitsPerPlane == 8) || //myf33
  1153. (pRequestedMode->bitsPerPlane == 16) || //myf33
  1154. (pRequestedMode->bitsPerPlane == 24)) ) //myf33
  1155. { // For 754x on 800x600 panel, disable HW cursor in 640x480 mode
  1156. HwDeviceExtension->VideoPointerEnabled = FALSE; // disable HW Cursor
  1157. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1158. CRTC_ADDRESS_PORT_COLOR, 0x2E);
  1159. HwDeviceExtension->cursor_vert_exp_flag =
  1160. VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1161. CRTC_DATA_PORT_COLOR) & 0x02;
  1162. if (HwDeviceExtension->cursor_vert_exp_flag)
  1163. {
  1164. HwDeviceExtension->CursorEnable = FALSE;
  1165. }
  1166. }
  1167. // crus
  1168. else if (HwDeviceExtension->ChipType == CL6245)
  1169. {
  1170. pRequestedMode->HWCursorEnable = FALSE;
  1171. HwDeviceExtension->VideoPointerEnabled = FALSE;
  1172. }
  1173. // end crus
  1174. //myf31 begin, 3-12-97, 755x expension on, HW cursor bug
  1175. else if (HwDeviceExtension->ChipType & CL755x) //CL755x
  1176. {
  1177. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1178. CRTC_ADDRESS_PORT_COLOR, 0x82);
  1179. HwDeviceExtension->cursor_vert_exp_flag =
  1180. VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1181. CRTC_DATA_PORT_COLOR) & 0x60;
  1182. if (HwDeviceExtension->cursor_vert_exp_flag)
  1183. {
  1184. HwDeviceExtension->CursorEnable = FALSE;
  1185. HwDeviceExtension->VideoPointerEnabled = FALSE; //disable HW Cursor
  1186. }
  1187. //myf33
  1188. if ((pRequestedMode->hres == 640) &&
  1189. ((pRequestedMode->bitsPerPlane == 8) ||
  1190. (pRequestedMode->bitsPerPlane == 16) ||
  1191. (pRequestedMode->bitsPerPlane == 24)) )
  1192. {
  1193. HwDeviceExtension->CursorEnable = FALSE;
  1194. HwDeviceExtension->VideoPointerEnabled = FALSE; //disable HW Cursor
  1195. }
  1196. //myf33 end
  1197. }
  1198. //myf31 end
  1199. else
  1200. {
  1201. HwDeviceExtension->VideoPointerEnabled = TRUE; // enable HW Cursor
  1202. }
  1203. }
  1204. else
  1205. { // For 5434 and 4-bit modes, use value from VideoMode structure
  1206. HwDeviceExtension->VideoPointerEnabled = pRequestedMode->HWCursorEnable;
  1207. }
  1208. //
  1209. // Adjust the FIFO Demand Threshold value for the 5436+.
  1210. // The 5434 values work for all of the other registers
  1211. // except this one.
  1212. //
  1213. // chu06
  1214. //
  1215. // Siemens reports this might cause undesired "yellow" screen on some
  1216. // 5436 16bpp modes. There's no reason to change it after BIOS sets it up
  1217. //
  1218. #if 0
  1219. if (HwDeviceExtension->ChipRevision >= CL5436_ID)
  1220. {
  1221. UCHAR PerfTuningReg, FifoDemandThreshold;
  1222. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1223. SEQ_ADDRESS_PORT, IND_PERF_TUNING);
  1224. PerfTuningReg = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1225. SEQ_DATA_PORT);
  1226. //
  1227. // Add an offset to the threshold that makes the 5434 values work
  1228. // for the 5436+. We do this rather than building a whole new set
  1229. // of 5436-specific structures.
  1230. //
  1231. if ((FifoDemandThreshold = (PerfTuningReg & 0x0F) + 4) > 15)
  1232. {
  1233. FifoDemandThreshold = 15;
  1234. }
  1235. PerfTuningReg = (PerfTuningReg & ~0x0F) | FifoDemandThreshold;
  1236. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1237. SEQ_DATA_PORT, PerfTuningReg);
  1238. }
  1239. #endif // 0
  1240. //crus
  1241. //myf1, begin
  1242. #ifdef PANNING_SCROLL
  1243. {
  1244. VP_STATUS status;
  1245. if (Panning_flag && (((Int10ModeNumber & 0x7f) != 3) &&
  1246. ((Int10ModeNumber & 0x7f) != 0x12))) //myf30
  1247. status = CirrusSetDisplayPitch(HwDeviceExtension, PanningMode);
  1248. }
  1249. #endif
  1250. //myf1, end
  1251. //
  1252. // Adjust the GR18[5] for 5446.
  1253. //
  1254. // sge03
  1255. if (HwDeviceExtension->ChipRevision == CL5446_ID)
  1256. {
  1257. UCHAR bTemp;
  1258. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1259. GRAPH_ADDRESS_PORT, 0x18);
  1260. bTemp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1261. GRAPH_DATA_PORT);
  1262. bTemp &= 0xDF;
  1263. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1264. GRAPH_DATA_PORT, bTemp);
  1265. }
  1266. return NO_ERROR;
  1267. } //end VgaSetMode()
  1268. VP_STATUS
  1269. VgaQueryAvailableModes(
  1270. PHW_DEVICE_EXTENSION HwDeviceExtension,
  1271. PVIDEO_MODE_INFORMATION ModeInformation,
  1272. ULONG ModeInformationSize,
  1273. PULONG OutputSize
  1274. )
  1275. /*++
  1276. Routine Description:
  1277. This routine returns the list of all available available modes on the
  1278. card.
  1279. Arguments:
  1280. HwDeviceExtension - Pointer to the miniport driver's device extension.
  1281. ModeInformation - Pointer to the output buffer supplied by the user.
  1282. This is where the list of all valid modes is stored.
  1283. ModeInformationSize - Length of the output buffer supplied by the user.
  1284. OutputSize - Pointer to a buffer in which to return the actual size of
  1285. the data in the buffer. If the buffer was not large enough, this
  1286. contains the minimum required buffer size.
  1287. Return Value:
  1288. ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
  1289. for the data being returned.
  1290. NO_ERROR if the operation completed successfully.
  1291. --*/
  1292. {
  1293. PVIDEO_MODE_INFORMATION videoModes = ModeInformation;
  1294. ULONG i;
  1295. ULONG ulFlags;
  1296. // chu07
  1297. UCHAR chipId ;
  1298. USHORT chipRevisionId ;
  1299. static VP_STATUS status ;
  1300. //
  1301. // Find out the size of the data to be put in the buffer and return
  1302. // that in the status information (whether or not the information is
  1303. // there). If the buffer passed in is not large enough return an
  1304. // appropriate error code.
  1305. //
  1306. if (ModeInformationSize < (*OutputSize =
  1307. HwDeviceExtension->NumAvailableModes *
  1308. sizeof(VIDEO_MODE_INFORMATION)) ) {
  1309. return ERROR_INSUFFICIENT_BUFFER;
  1310. }
  1311. //
  1312. // The driver specific attribute flags for each mode remains
  1313. // constant, so only calculate them once.
  1314. //
  1315. ulFlags = GetAttributeFlags(HwDeviceExtension);
  1316. //
  1317. // chu07
  1318. // IBM does not favor 1024x768x16bpp 85 Hz for 5446 AC.
  1319. // We access registry to know if there is a key OemModeOff, if there
  1320. // is, we bypass it.
  1321. //
  1322. chipId = GetCirrusChipId(HwDeviceExtension) ;
  1323. chipRevisionId = GetCirrusChipRevisionId(HwDeviceExtension) ;
  1324. //
  1325. // IBM specific
  1326. //
  1327. if ((chipId == 0xB8) &&
  1328. (chipRevisionId != 0x0045) &&
  1329. (ModeExclude.NeverAccessed == TRUE)
  1330. )
  1331. {
  1332. //
  1333. // Access registry
  1334. //
  1335. status = VideoPortGetRegistryParameters(HwDeviceExtension,
  1336. L"OemModeOff",
  1337. FALSE,
  1338. GetOemModeOffInfoCallBack,
  1339. NULL) ;
  1340. if (status != NO_ERROR)
  1341. {
  1342. VideoDebugPrint((1, "Fail to access Contrast key info from registry\n"));
  1343. }
  1344. else
  1345. {
  1346. VideoDebugPrint((2, "ModeExclude.mode = %x\n", ModeExclude.mode));
  1347. VideoDebugPrint((2, "ModeExclude.refresh = %x\n", ModeExclude.refresh));
  1348. }
  1349. ModeExclude.NeverAccessed = FALSE ;
  1350. }
  1351. //
  1352. // For each mode supported by the card, store the mode characteristics
  1353. // in the output buffer.
  1354. //
  1355. for (i = 0; i < NumVideoModes; i++)
  1356. {
  1357. //
  1358. // chu07 : Get rid of modes 0x74, 85Hz if required by IBM.
  1359. //
  1360. if ((status == NO_ERROR) &&
  1361. (ModeExclude.mode == ModesVGA[i].BiosModes.BiosModeCL542x) &&
  1362. (ModeExclude.refresh == ModesVGA[i].Frequency))
  1363. continue ;
  1364. if (ModesVGA[i].ValidMode)
  1365. {
  1366. videoModes->Length = sizeof(VIDEO_MODE_INFORMATION);
  1367. videoModes->ModeIndex = i;
  1368. videoModes->VisScreenWidth = ModesVGA[i].hres;
  1369. videoModes->ScreenStride = ModesVGA[i].wbytes;
  1370. videoModes->VisScreenHeight = ModesVGA[i].vres;
  1371. videoModes->NumberOfPlanes = ModesVGA[i].numPlanes;
  1372. videoModes->BitsPerPlane = ModesVGA[i].bitsPerPlane;
  1373. videoModes->Frequency = ModesVGA[i].Frequency;
  1374. videoModes->XMillimeter = 320; // temporary hardcoded constant
  1375. videoModes->YMillimeter = 240; // temporary hardcoded constant
  1376. videoModes->AttributeFlags = ModesVGA[i].fbType;
  1377. videoModes->AttributeFlags |= ModesVGA[i].Interlaced ?
  1378. VIDEO_MODE_INTERLACED : 0;
  1379. videoModes->DriverSpecificAttributeFlags = ulFlags;
  1380. //
  1381. // The 5434 has a hardware cursor problem at 1280x1024
  1382. // resolution. Use a software cursor on these chips.
  1383. //
  1384. if ((videoModes->VisScreenWidth == 1280) &&
  1385. (HwDeviceExtension->ChipRevision == 0x2A))
  1386. {
  1387. videoModes->DriverSpecificAttributeFlags
  1388. |= CAPS_SW_POINTER;
  1389. }
  1390. // crus
  1391. if (HwDeviceExtension->ChipType == CL6245)
  1392. {
  1393. videoModes->DriverSpecificAttributeFlags
  1394. |= CAPS_SW_POINTER;
  1395. }
  1396. // end crus
  1397. //
  1398. // Account for vertical expansion on laptops
  1399. //
  1400. if ((HwDeviceExtension->ChipType & CL754x) &&
  1401. (videoModes->VisScreenHeight == 480) &&
  1402. (videoModes->BitsPerPlane == 8))
  1403. {
  1404. videoModes->DriverSpecificAttributeFlags
  1405. |= CAPS_SW_POINTER;
  1406. }
  1407. //
  1408. // Calculate the VideoMemoryBitmapWidth
  1409. //
  1410. {
  1411. LONG x;
  1412. x = videoModes->BitsPerPlane;
  1413. if( x == 15 ) x = 16;
  1414. videoModes->VideoMemoryBitmapWidth =
  1415. (videoModes->ScreenStride * 8 ) / x;
  1416. }
  1417. videoModes->VideoMemoryBitmapHeight =
  1418. HwDeviceExtension->AdapterMemorySize / videoModes->ScreenStride;
  1419. //crus
  1420. //myf15, begin
  1421. if ((HwDeviceExtension->ChipType & CL754x) ||
  1422. (HwDeviceExtension->ChipType == CL6245) ||
  1423. (HwDeviceExtension->ChipType & CL755x))
  1424. videoModes->VideoMemoryBitmapHeight =
  1425. (HwDeviceExtension->AdapterMemorySize - 0x4000) /
  1426. videoModes->ScreenStride;
  1427. //myf15, end
  1428. if ((ModesVGA[i].bitsPerPlane == 32) ||
  1429. (ModesVGA[i].bitsPerPlane == 24))
  1430. {
  1431. videoModes->NumberRedBits = 8;
  1432. videoModes->NumberGreenBits = 8;
  1433. videoModes->NumberBlueBits = 8;
  1434. videoModes->RedMask = 0xff0000;
  1435. videoModes->GreenMask = 0x00ff00;
  1436. videoModes->BlueMask = 0x0000ff;
  1437. }
  1438. else if (ModesVGA[i].bitsPerPlane == 16)
  1439. {
  1440. videoModes->NumberRedBits = 6;
  1441. videoModes->NumberGreenBits = 6;
  1442. videoModes->NumberBlueBits = 6;
  1443. videoModes->RedMask = 0x1F << 11;
  1444. videoModes->GreenMask = 0x3F << 5;
  1445. videoModes->BlueMask = 0x1F;
  1446. }
  1447. else
  1448. {
  1449. videoModes->NumberRedBits = 6;
  1450. videoModes->NumberGreenBits = 6;
  1451. videoModes->NumberBlueBits = 6;
  1452. videoModes->RedMask = 0;
  1453. videoModes->GreenMask = 0;
  1454. videoModes->BlueMask = 0;
  1455. videoModes->AttributeFlags |= VIDEO_MODE_PALETTE_DRIVEN |
  1456. VIDEO_MODE_MANAGED_PALETTE;
  1457. }
  1458. videoModes++;
  1459. }
  1460. }
  1461. return NO_ERROR;
  1462. } // end VgaQueryAvailableModes()
  1463. VP_STATUS
  1464. VgaQueryNumberOfAvailableModes(
  1465. PHW_DEVICE_EXTENSION HwDeviceExtension,
  1466. PVIDEO_NUM_MODES NumModes,
  1467. ULONG NumModesSize,
  1468. PULONG OutputSize
  1469. )
  1470. /*++
  1471. Routine Description:
  1472. This routine returns the number of available modes for this particular
  1473. video card.
  1474. Arguments:
  1475. HwDeviceExtension - Pointer to the miniport driver's device extension.
  1476. NumModes - Pointer to the output buffer supplied by the user. This is
  1477. where the number of modes is stored.
  1478. NumModesSize - Length of the output buffer supplied by the user.
  1479. OutputSize - Pointer to a buffer in which to return the actual size of
  1480. the data in the buffer.
  1481. Return Value:
  1482. ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
  1483. for the data being returned.
  1484. NO_ERROR if the operation completed successfully.
  1485. --*/
  1486. {
  1487. //
  1488. // Find out the size of the data to be put in the the buffer and return
  1489. // that in the status information (whether or not the information is
  1490. // there). If the buffer passed in is not large enough return an
  1491. // appropriate error code.
  1492. //
  1493. // VideoDebugPrint((0, "Miniport - VgaQueryNumberofAvailableModes\n")); //myfr
  1494. if (NumModesSize < (*OutputSize = sizeof(VIDEO_NUM_MODES)) ) {
  1495. return ERROR_INSUFFICIENT_BUFFER;
  1496. }
  1497. //
  1498. // Store the number of modes into the buffer.
  1499. //
  1500. NumModes->NumModes = HwDeviceExtension->NumAvailableModes;
  1501. NumModes->ModeInformationLength = sizeof(VIDEO_MODE_INFORMATION);
  1502. return NO_ERROR;
  1503. } // end VgaGetNumberOfAvailableModes()
  1504. VP_STATUS
  1505. VgaQueryCurrentMode(
  1506. PHW_DEVICE_EXTENSION HwDeviceExtension,
  1507. PVIDEO_MODE_INFORMATION ModeInformation,
  1508. ULONG ModeInformationSize,
  1509. PULONG OutputSize
  1510. )
  1511. /*++
  1512. Routine Description:
  1513. This routine returns a description of the current video mode.
  1514. Arguments:
  1515. HwDeviceExtension - Pointer to the miniport driver's device extension.
  1516. ModeInformation - Pointer to the output buffer supplied by the user.
  1517. This is where the current mode information is stored.
  1518. ModeInformationSize - Length of the output buffer supplied by the user.
  1519. OutputSize - Pointer to a buffer in which to return the actual size of
  1520. the data in the buffer. If the buffer was not large enough, this
  1521. contains the minimum required buffer size.
  1522. Return Value:
  1523. ERROR_INSUFFICIENT_BUFFER if the output buffer was not large enough
  1524. for the data being returned.
  1525. NO_ERROR if the operation completed successfully.
  1526. --*/
  1527. {
  1528. //
  1529. // check if a mode has been set
  1530. //
  1531. // VideoDebugPrint((0, "Miniport - VgaQueryCurrentMode\n")); //myfr
  1532. if (HwDeviceExtension->CurrentMode == NULL ) {
  1533. return ERROR_INVALID_FUNCTION;
  1534. }
  1535. //
  1536. // Find out the size of the data to be put in the the buffer and return
  1537. // that in the status information (whether or not the information is
  1538. // there). If the buffer passed in is not large enough return an
  1539. // appropriate error code.
  1540. //
  1541. if (ModeInformationSize < (*OutputSize = sizeof(VIDEO_MODE_INFORMATION))) {
  1542. return ERROR_INSUFFICIENT_BUFFER;
  1543. }
  1544. ModeInformation->DriverSpecificAttributeFlags =
  1545. GetAttributeFlags(HwDeviceExtension); //myf17 move to this
  1546. //
  1547. // Store the characteristics of the current mode into the buffer.
  1548. //
  1549. ModeInformation->Length = sizeof(VIDEO_MODE_INFORMATION);
  1550. ModeInformation->ModeIndex = HwDeviceExtension->ModeIndex;
  1551. //crus begin
  1552. //myf1, begin
  1553. #ifdef PANNING_SCROLL
  1554. if (Panning_flag)
  1555. {
  1556. ModeInformation->VisScreenWidth = PanningMode.hres;
  1557. ModeInformation->ScreenStride = PanningMode.wbytes;
  1558. ModeInformation->VisScreenHeight = PanningMode.vres;
  1559. ModeInformation->BitsPerPlane = PanningMode.bpp;
  1560. ModeInformation->AttributeFlags = HwDeviceExtension->CurrentMode->fbType
  1561. & ~(HwDeviceExtension->CurrentMode->Interlaced ?
  1562. VIDEO_MODE_INTERLACED : 0); //myf22
  1563. }
  1564. else
  1565. #endif
  1566. //myf1, end
  1567. //crus end
  1568. {
  1569. ModeInformation->VisScreenWidth = HwDeviceExtension->CurrentMode->hres;
  1570. ModeInformation->ScreenStride = HwDeviceExtension->CurrentMode->wbytes;
  1571. ModeInformation->VisScreenHeight = HwDeviceExtension->CurrentMode->vres;
  1572. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1573. CRTC_ADDRESS_PORT_COLOR, 0x30); //myf34
  1574. if ((ModeInformation->DriverSpecificAttributeFlags & CAPS_TV_ON) &&
  1575. (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1576. CRTC_DATA_PORT_COLOR) & 0x40) && //myf34, Internal TV
  1577. (ModeInformation->VisScreenHeight == 480) &&
  1578. (ModeInformation->VisScreenWidth == 640))
  1579. {
  1580. ModeInformation->VisScreenHeight =
  1581. HwDeviceExtension->CurrentMode->vres - 28; //myf33
  1582. }
  1583. else if ((ModeInformation->DriverSpecificAttributeFlags & CAPS_TV_ON) &&
  1584. (!(VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1585. CRTC_DATA_PORT_COLOR) & 0x40)) && //myf34, External TV
  1586. (ModeInformation->VisScreenHeight == 480) &&
  1587. (ModeInformation->VisScreenWidth == 640))
  1588. {
  1589. ModeInformation->VisScreenHeight =
  1590. HwDeviceExtension->CurrentMode->vres - 68; //AI Tech.
  1591. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1592. CRTC_ADDRESS_PORT_COLOR, 0x12);
  1593. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1594. CRTC_DATA_PORT_COLOR,
  1595. (UCHAR)ModeInformation->VisScreenHeight);
  1596. }
  1597. ModeInformation->BitsPerPlane = HwDeviceExtension->CurrentMode->bitsPerPlane;
  1598. ModeInformation->AttributeFlags = HwDeviceExtension->CurrentMode->fbType
  1599. | (HwDeviceExtension->CurrentMode->Interlaced ?
  1600. VIDEO_MODE_INTERLACED : 0); //myf22
  1601. }
  1602. ModeInformation->NumberOfPlanes = HwDeviceExtension->CurrentMode->numPlanes;
  1603. //crus
  1604. // ModeInformation->BitsPerPlane = HwDeviceExtension->CurrentMode->bitsPerPlane;
  1605. ModeInformation->Frequency = HwDeviceExtension->CurrentMode->Frequency;
  1606. ModeInformation->XMillimeter = 320; // temporary hardcoded constant
  1607. ModeInformation->YMillimeter = 240; // temporary hardcoded constant
  1608. // ModeInformation->AttributeFlags = HwDeviceExtension->CurrentMode->fbType |
  1609. // (HwDeviceExtension->CurrentMode->Interlaced ?
  1610. // VIDEO_MODE_INTERLACED : 0);
  1611. ModeInformation->DriverSpecificAttributeFlags =
  1612. GetAttributeFlags(HwDeviceExtension); //original, myf17
  1613. //
  1614. // The 5434 has a hardware cursor problem at 1280x1024
  1615. // resolution. Use a software cursor on these chips.
  1616. //
  1617. if ((ModeInformation->VisScreenWidth == 1280) &&
  1618. (HwDeviceExtension->ChipRevision == 0x2A))
  1619. {
  1620. ModeInformation->DriverSpecificAttributeFlags
  1621. |= CAPS_SW_POINTER;
  1622. }
  1623. // crus
  1624. if(HwDeviceExtension->ChipType == CL6245)
  1625. {
  1626. ModeInformation->DriverSpecificAttributeFlags
  1627. |= CAPS_SW_POINTER;
  1628. }
  1629. // end crus
  1630. //crus begin
  1631. //myf13, expension on with panning scrolling bug
  1632. if ((HwDeviceExtension->ChipType & CL754x) &&
  1633. (ModeInformation->VisScreenHeight == 640) && //myf15, myf33
  1634. (ModeInformation->BitsPerPlane == 8)) //myf15
  1635. {
  1636. ModeInformation->DriverSpecificAttributeFlags
  1637. |= CAPS_SW_POINTER;
  1638. }
  1639. /*
  1640. if (((HwDeviceExtension->ChipType & CL754x) ||
  1641. (HwDeviceExtension->ChipType & CL755x)) &&
  1642. (Panning_flag))
  1643. {
  1644. ModeInformation->DriverSpecificAttributeFlags
  1645. |= GCAPS_PANNING; //myf15
  1646. }
  1647. */
  1648. //myf13, end
  1649. //crus end
  1650. //
  1651. // Account for vertical expansion on laptops
  1652. //
  1653. //crus
  1654. if (((HwDeviceExtension->ChipType & CL754x) ||
  1655. (HwDeviceExtension->ChipType & CL755x)) && //myf9, crus
  1656. (ModeInformation->VisScreenWidth == 640) &&
  1657. ((ModeInformation->BitsPerPlane == 8) ||
  1658. (ModeInformation->BitsPerPlane == 16) ||
  1659. (ModeInformation->BitsPerPlane == 24)) )
  1660. {
  1661. ModeInformation->DriverSpecificAttributeFlags
  1662. |= CAPS_SW_POINTER;
  1663. if (HwDeviceExtension->cursor_vert_exp_flag)
  1664. {
  1665. ModeInformation->DriverSpecificAttributeFlags
  1666. |= CAPS_CURSOR_VERT_EXP;
  1667. }
  1668. //myf33 begin
  1669. if (ModeInformation->DriverSpecificAttributeFlags & CAPS_TV_ON)
  1670. ModeInformation->DriverSpecificAttributeFlags
  1671. |= CAPS_SW_POINTER;
  1672. //myf33 end
  1673. }
  1674. //myf31 begin:3-12-97 755x expension on, HW cursor bug
  1675. if ((HwDeviceExtension->ChipType & CL755x))
  1676. {
  1677. //myf33
  1678. if (ModeInformation->DriverSpecificAttributeFlags & CAPS_TV_ON)
  1679. ModeInformation->DriverSpecificAttributeFlags
  1680. |= CAPS_SW_POINTER;
  1681. //myf33 end
  1682. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  1683. CRTC_ADDRESS_PORT_COLOR, 0x82);
  1684. HwDeviceExtension->cursor_vert_exp_flag =
  1685. VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1686. CRTC_DATA_PORT_COLOR) & 0x60;
  1687. if (HwDeviceExtension->cursor_vert_exp_flag)
  1688. {
  1689. ModeInformation->DriverSpecificAttributeFlags
  1690. |= CAPS_SW_POINTER;
  1691. ModeInformation->DriverSpecificAttributeFlags
  1692. |= CAPS_CURSOR_VERT_EXP;
  1693. }
  1694. }
  1695. //myf31 end
  1696. if ((ModeInformation->BitsPerPlane == 24) ||
  1697. (ModeInformation->BitsPerPlane == 32)) {
  1698. ModeInformation->NumberRedBits = 8;
  1699. ModeInformation->NumberGreenBits = 8;
  1700. ModeInformation->NumberBlueBits = 8;
  1701. ModeInformation->RedMask = 0xff0000;
  1702. ModeInformation->GreenMask = 0x00ff00;
  1703. ModeInformation->BlueMask = 0x0000ff;
  1704. } else if (ModeInformation->BitsPerPlane == 16) {
  1705. ModeInformation->NumberRedBits = 6;
  1706. ModeInformation->NumberGreenBits = 6;
  1707. ModeInformation->NumberBlueBits = 6;
  1708. ModeInformation->RedMask = 0x1F << 11;
  1709. ModeInformation->GreenMask = 0x3F << 5;
  1710. ModeInformation->BlueMask = 0x1F;
  1711. } else {
  1712. ModeInformation->NumberRedBits = 6;
  1713. ModeInformation->NumberGreenBits = 6;
  1714. ModeInformation->NumberBlueBits = 6;
  1715. ModeInformation->RedMask = 0;
  1716. ModeInformation->GreenMask = 0;
  1717. ModeInformation->BlueMask = 0;
  1718. ModeInformation->AttributeFlags |=
  1719. VIDEO_MODE_PALETTE_DRIVEN | VIDEO_MODE_MANAGED_PALETTE;
  1720. }
  1721. //
  1722. // Calculate the VideoMemoryBitmapWidth
  1723. //
  1724. {
  1725. LONG x;
  1726. x = ModeInformation->BitsPerPlane;
  1727. if( x == 15 ) x = 16;
  1728. ModeInformation->VideoMemoryBitmapWidth =
  1729. (ModeInformation->ScreenStride * 8 ) / x;
  1730. }
  1731. ModeInformation->VideoMemoryBitmapHeight =
  1732. HwDeviceExtension->AdapterMemorySize / ModeInformation->ScreenStride;
  1733. //crus begin
  1734. //myf15, begin
  1735. if ((HwDeviceExtension->ChipType & CL754x) ||
  1736. (HwDeviceExtension->ChipType == CL6245) ||
  1737. (HwDeviceExtension->ChipType & CL755x))
  1738. ModeInformation->VideoMemoryBitmapHeight =
  1739. (HwDeviceExtension->AdapterMemorySize - 0x4000) /
  1740. ModeInformation->ScreenStride;
  1741. //myf15, end
  1742. //crus end
  1743. return NO_ERROR;
  1744. } // end VgaQueryCurrentMode()
  1745. VOID
  1746. VgaZeroVideoMemory(
  1747. PHW_DEVICE_EXTENSION HwDeviceExtension
  1748. )
  1749. /*++
  1750. Routine Description:
  1751. This routine zeros the first 256K on the VGA.
  1752. Arguments:
  1753. HwDeviceExtension - Pointer to the miniport driver's device extension.
  1754. Return Value:
  1755. None.
  1756. --*/
  1757. {
  1758. UCHAR temp;
  1759. //
  1760. // Map font buffer at A0000
  1761. //
  1762. VgaInterpretCmdStream(HwDeviceExtension, EnableA000Data);
  1763. //
  1764. // Enable all planes.
  1765. //
  1766. VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_ADDRESS_PORT,
  1767. IND_MAP_MASK);
  1768. temp = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  1769. SEQ_DATA_PORT) | (UCHAR)0x0F;
  1770. VideoPortWritePortUchar(HwDeviceExtension->IOAddress + SEQ_DATA_PORT,
  1771. temp);
  1772. VideoPortZeroDeviceMemory(HwDeviceExtension->VideoMemoryAddress, 0xFFFF);
  1773. VgaInterpretCmdStream(HwDeviceExtension, DisableA000Color);
  1774. }
  1775. VOID
  1776. CirrusValidateModes(
  1777. PHW_DEVICE_EXTENSION HwDeviceExtension
  1778. )
  1779. /*++
  1780. Routine Description:
  1781. Determines which modes are valid and which are not.
  1782. Arguments:
  1783. HwDeviceExtension - Pointer to the miniport driver's device extension.
  1784. Return Value:
  1785. None.
  1786. --*/
  1787. {
  1788. ULONG i;
  1789. USHORT usChipIndex;
  1790. // VideoDebugPrint((0, "Miniport - CirrusValidateMode\n")); //myfr
  1791. switch (HwDeviceExtension->ChipType)
  1792. {
  1793. case CL6410: if (HwDeviceExtension->DisplayType == crt)
  1794. {
  1795. usChipIndex = pCL6410_crt;
  1796. }
  1797. else
  1798. {
  1799. usChipIndex = pCL6410_panel;
  1800. }
  1801. break;
  1802. case CL6420: if (HwDeviceExtension->DisplayType == crt)
  1803. {
  1804. usChipIndex = pCL6420_crt;
  1805. }
  1806. else
  1807. {
  1808. usChipIndex = pCL6420_panel;
  1809. }
  1810. break;
  1811. // crus
  1812. case CL6245:
  1813. case CL542x: usChipIndex = pCL542x; break;
  1814. case CL543x:
  1815. case CL5434:
  1816. case CL5434_6:
  1817. case CL5436:
  1818. case CL5446:
  1819. case CL5446BE:
  1820. case CL5480:
  1821. case CL754x:
  1822. case CL7541:
  1823. case CL7543:
  1824. case CL7542:
  1825. case CL7548:
  1826. case CL756x:
  1827. case CL755x:
  1828. case CL7555:
  1829. case CL7556:
  1830. if (HwDeviceExtension->BoardType == NEC_ONBOARD_CIRRUS)
  1831. {
  1832. usChipIndex = pNEC_CL543x;
  1833. }
  1834. else
  1835. {
  1836. usChipIndex = pCL543x;
  1837. }
  1838. break;
  1839. default: usChipIndex = 0xffff; break;
  1840. }
  1841. HwDeviceExtension->NumAvailableModes = 0;
  1842. VideoDebugPrint((2, "Checking for available modes:\n"));
  1843. VideoDebugPrint((2, "\tMemory Size = %x\n"
  1844. "\tChipType = %x\n"
  1845. "\tDisplayType = %x\n",
  1846. HwDeviceExtension->AdapterMemorySize,
  1847. HwDeviceExtension->ChipType,
  1848. HwDeviceExtension->DisplayType));
  1849. for (i = 0; i < NumVideoModes; i++) {
  1850. //
  1851. // The SpeedStarPRO does not support refresh rates.
  1852. // we must return hardware default for all of the modes.
  1853. // clean out the mode tables of duplicates ...
  1854. //
  1855. if (HwDeviceExtension->BoardType == SPEEDSTARPRO)
  1856. {
  1857. ModesVGA[i].Frequency = 1;
  1858. ModesVGA[i].Interlaced = 0;
  1859. if (i &&
  1860. (ModesVGA[i].numPlanes == ModesVGA[i-1].numPlanes) &&
  1861. (ModesVGA[i].bitsPerPlane == ModesVGA[i-1].bitsPerPlane) &&
  1862. (ModesVGA[i].hres == ModesVGA[i-1].hres) &&
  1863. (ModesVGA[i].vres == ModesVGA[i-1].vres))
  1864. {
  1865. //
  1866. // duplicate mode - skip it.
  1867. //
  1868. continue;
  1869. }
  1870. }
  1871. VideoDebugPrint((2, "Mode #%ld %dx%d at %d bpp\n"
  1872. "\tAdapterMemoryRequired: %x\n"
  1873. "\tChipType: %x\n"
  1874. "\tDisplayType: %x\n",
  1875. i, ModesVGA[i].hres, ModesVGA[i].vres,
  1876. ModesVGA[i].bitsPerPlane * ModesVGA[i].numPlanes,
  1877. ModesVGA[i].numPlanes * ModesVGA[i].sbytes,
  1878. ModesVGA[i].ChipType,
  1879. ModesVGA[i].DisplayType));
  1880. if ( (HwDeviceExtension->AdapterMemorySize >=
  1881. ModesVGA[i].numPlanes * ModesVGA[i].sbytes) &&
  1882. (HwDeviceExtension->ChipType & ModesVGA[i].ChipType) &&
  1883. (HwDeviceExtension->DisplayType & ModesVGA[i].DisplayType) &&
  1884. // crus
  1885. (!(HwDeviceExtension->ChipType & CL754x) &&
  1886. !(HwDeviceExtension->ChipType & CL755x) &&
  1887. (HwDeviceExtension->ChipType != CL6245) &&
  1888. (HwDeviceExtension->ChipType != CL756x)) &&
  1889. // end crus
  1890. CheckDDC2BMonitor(HwDeviceExtension, i) &&
  1891. ((ModesVGA[i].bitsPerPlane * ModesVGA[i].numPlanes == 24)
  1892. ? VgaAccessRange[3].RangeLength : TRUE))
  1893. {
  1894. ModesVGA[i].ValidMode = TRUE;
  1895. HwDeviceExtension->NumAvailableModes++;
  1896. VideoDebugPrint((2, "This mode is valid.\n"));
  1897. }
  1898. // check if panel type is DSTN panel, must be used 128K frame buffer
  1899. // for Half-Frame Accelerator
  1900. // crus
  1901. #if 1
  1902. else if ((HwDeviceExtension->AdapterMemorySize >=
  1903. ModesVGA[i].numPlanes * ModesVGA[i].sbytes) &&
  1904. ((HwDeviceExtension->ChipType & CL754x) ||
  1905. (HwDeviceExtension->ChipType & CL755x) ||
  1906. (HwDeviceExtension->ChipType == CL6245) ||
  1907. (HwDeviceExtension->ChipType == CL756x)) &&
  1908. (HwDeviceExtension->ChipType & ModesVGA[i].ChipType) &&
  1909. (HwDeviceExtension->DisplayType & ModesVGA[i].DisplayType) &&
  1910. ((ModesVGA[i].bitsPerPlane * ModesVGA[i].numPlanes == 24)
  1911. ? VgaAccessRange[3].RangeLength : TRUE))
  1912. {
  1913. //DSTN panel must be turn on
  1914. if ((((HwDeviceExtension->DisplayType & ScreenType)==DSTN10) ||
  1915. ((HwDeviceExtension->DisplayType & ScreenType)==DSTN8 ) ||
  1916. ((HwDeviceExtension->DisplayType & ScreenType)==DSTN6 )) &&
  1917. ((LONG)HwDeviceExtension->AdapterMemorySize >=
  1918. (LONG)((ModesVGA[i].wbytes * ModesVGA[i].vres) +0x24000)) )
  1919. {
  1920. //myf27, begin
  1921. if ((HwDeviceExtension->DisplayType & PanelType) &&
  1922. (ModesVGA[i].DisplayType & PanelType) &&
  1923. (HwDeviceExtension->ChipType & CL754x) &&
  1924. (ModesVGA[i].bitsPerPlane >= 16) &&
  1925. (ModesVGA[i].hres > 640) &&
  1926. ((HwDeviceExtension->DisplayType & Jump_type)) && //myf27
  1927. (((ModesVGA[i].DisplayType & HwDeviceExtension->DisplayType)
  1928. - crt) >= panel8x6))
  1929. {
  1930. ModesVGA[i].ValidMode = FALSE;
  1931. VideoDebugPrint((1, "***This mode is not valid.***\n"));
  1932. }
  1933. else if ((HwDeviceExtension->DisplayType & PanelType) &&
  1934. (ModesVGA[i].DisplayType & PanelType) &&
  1935. (!(HwDeviceExtension->DisplayType & Jump_type)) && //myf27
  1936. (HwDeviceExtension->ChipType & CL754x) && //myf27
  1937. (ModesVGA[i].bitsPerPlane >= 16) &&
  1938. // (ModesVGA[i].hres > 640) &&
  1939. ((ModesVGA[i].DisplayType & HwDeviceExtension->DisplayType)
  1940. >= panel8x6))
  1941. {
  1942. ModesVGA[i].ValidMode = FALSE;
  1943. VideoDebugPrint((1, "This mode is valid.\n"));
  1944. }
  1945. //myf27, end
  1946. //myf32 begin :fixed DSTN XGA panel not supported 24bpp mode
  1947. else if ((HwDeviceExtension->DisplayType & PanelType) &&
  1948. (ModesVGA[i].DisplayType & PanelType) &&
  1949. (!(HwDeviceExtension->DisplayType & Jump_type)) && //myf27
  1950. (HwDeviceExtension->ChipType & CL755x) && //myf27
  1951. (ModesVGA[i].bitsPerPlane >= 24) &&
  1952. ((ModesVGA[i].DisplayType & HwDeviceExtension->DisplayType)
  1953. >= panel10x7))
  1954. {
  1955. ModesVGA[i].ValidMode = FALSE;
  1956. VideoDebugPrint((1, "This mode is valid.\n"));
  1957. }
  1958. //myf32 end
  1959. else if ((HwDeviceExtension->DisplayType & PanelType) &&
  1960. (ModesVGA[i].DisplayType & PanelType) &&
  1961. (!(HwDeviceExtension->DisplayType & Jump_type)) && //myf27
  1962. ((ModesVGA[i].DisplayType & HwDeviceExtension->DisplayType) >= panel))
  1963. {
  1964. ModesVGA[i].ValidMode = TRUE ;
  1965. HwDeviceExtension->NumAvailableModes++ ;
  1966. VideoDebugPrint((1, "This mode is valid.\n"));
  1967. }
  1968. //myf7, begin
  1969. //myf7 else if (!(HwDeviceExtension->DisplayType & PanelType))
  1970. else if ((HwDeviceExtension->DisplayType & crt) &&
  1971. (HwDeviceExtension->DisplayType & Jump_type) )//myf27
  1972. {
  1973. ModesVGA[i].ValidMode = TRUE ;
  1974. HwDeviceExtension->NumAvailableModes++ ;
  1975. VideoDebugPrint((1, "This mode is valid.\n"));
  1976. }
  1977. //myf7, end
  1978. //crus end
  1979. }
  1980. else if (((HwDeviceExtension->DisplayType & ScreenType)!=DSTN10) &&
  1981. ((HwDeviceExtension->DisplayType & ScreenType)!=DSTN8) &&
  1982. ((HwDeviceExtension->DisplayType & ScreenType)!=DSTN6) &&
  1983. ((LONG)HwDeviceExtension->AdapterMemorySize >=
  1984. (LONG)((ModesVGA[i].wbytes * ModesVGA[i].vres))))
  1985. {
  1986. //myf27, begin
  1987. if ((HwDeviceExtension->DisplayType & (panel10x7 | TFT_LCD)) &&
  1988. (ModesVGA[i].DisplayType & panel10x7) &&
  1989. (HwDeviceExtension->ChipType & CL754x) &&
  1990. (ModesVGA[i].bitsPerPlane >= 16) &&
  1991. (!(HwDeviceExtension->DisplayType & Jump_type)) && //myf27
  1992. ((ModesVGA[i].DisplayType & HwDeviceExtension->DisplayType)
  1993. >= panel10x7))
  1994. {
  1995. ModesVGA[i].ValidMode = FALSE;
  1996. VideoDebugPrint((1, "===This mode is not valid.===\n"));
  1997. }
  1998. /*
  1999. else if ((HwDeviceExtension->DisplayType &
  2000. (panel10x7 | TFT_LCD)) &&
  2001. (ModesVGA[i].DisplayType & panel10x7) &&
  2002. (HwDeviceExtension->ChipType & CL754x) &&
  2003. (ModesVGA[i].bitsPerPlane >= 16) &&
  2004. (!(HwDeviceExtension->DisplayType & Jump_type)) &&
  2005. ((ModesVGA[i].DisplayType & HwDeviceExtension->DisplayType)
  2006. >= panel10x7))
  2007. {
  2008. ModesVGA[i].ValidMode = FALSE;
  2009. VideoDebugPrint((1, "===This mode is not valid.===\n"));
  2010. }
  2011. */
  2012. //myf27, end
  2013. else if ((HwDeviceExtension->DisplayType & PanelType) &&
  2014. (ModesVGA[i].DisplayType & PanelType) &&
  2015. (!(HwDeviceExtension->DisplayType & Jump_type)) && //myf27
  2016. ((ModesVGA[i].DisplayType & HwDeviceExtension->DisplayType) >= panel) )
  2017. {
  2018. ModesVGA[i].ValidMode = TRUE ;
  2019. HwDeviceExtension->NumAvailableModes++ ;
  2020. VideoDebugPrint((1, "This mode is valid.\n"));
  2021. }
  2022. //myf7, this is fixed crt only can't display exclude 60Hz refresh rate
  2023. //myf7 else if (!(HwDeviceExtension->DisplayType & PanelType))
  2024. else if ((HwDeviceExtension->DisplayType & crt) && //myf7
  2025. (HwDeviceExtension->DisplayType & Jump_type) )//myf27
  2026. {
  2027. ModesVGA[i].ValidMode = TRUE ;
  2028. HwDeviceExtension->NumAvailableModes++ ;
  2029. VideoDebugPrint((1, "This mode is valid.\n"));
  2030. }
  2031. }
  2032. }
  2033. #endif
  2034. // end crus
  2035. else
  2036. {
  2037. VideoDebugPrint((1, "This mode is not valid.\n")); //2
  2038. }
  2039. #if 0
  2040. if (HwDeviceExtension->ChipRevision == 0x3A) {
  2041. if (((ModesVGA[i].numPlanes * ModesVGA[i].sbytes) <= 0x200000) &&
  2042. (HwDeviceExtension->DisplayType & ModesVGA[i].DisplayType)) {
  2043. if (CheckDDC2B(HwDeviceExtension, i)) {
  2044. ModesVGA[i].ValidMode = TRUE ;
  2045. HwDeviceExtension->NumAvailableModes++ ;
  2046. continue ;
  2047. }
  2048. }
  2049. }
  2050. #endif
  2051. /* jl02
  2052. if (CheckGD5446Rev(HwDeviceExtension)) {
  2053. // Block 1152x864, 16-bpp
  2054. if ((ModesVGA[i].hres == 1152) &&
  2055. (ModesVGA[i].vres == 864) &&
  2056. (ModesVGA[i].bitsPerPlane == 16))
  2057. {
  2058. continue ;
  2059. }
  2060. }
  2061. */
  2062. }
  2063. #if 0 //myf28
  2064. //myf27, begin
  2065. if ((HwDeviceExtension->DisplayType & Jump_type) &&
  2066. ((HwDeviceExtension->ChipType & CL754x) ||
  2067. (HwDeviceExtension->ChipType & CL755x) ||
  2068. // (HwDeviceExtension->ChipType == CL6245) ||
  2069. (HwDeviceExtension->ChipType == CL756x)))
  2070. HwDeviceExtension->DisplayType &= crt;
  2071. //myf27, end
  2072. #endif //myf28
  2073. VideoDebugPrint((1, "NumAvailableModes = %ld\n",
  2074. HwDeviceExtension->NumAvailableModes)); //2
  2075. }
  2076. ULONG
  2077. GetAttributeFlags(
  2078. PHW_DEVICE_EXTENSION HwDeviceExtension
  2079. )
  2080. /*++
  2081. Routine Description:
  2082. This routine determines whether or not the detected
  2083. cirrus chip supports Blt's.
  2084. NOTE: This device should not be called until after
  2085. CirrusLogicIsPresent has been called.
  2086. Arguments:
  2087. HwDeviceExtension - Pointer to the device extension.
  2088. Return Value:
  2089. TRUE - If the device supports Blt's
  2090. FALSE - otherwise
  2091. --*/
  2092. {
  2093. ULONG ChipId = HwDeviceExtension->ChipRevision;
  2094. ULONG ChipType = HwDeviceExtension->ChipType;
  2095. ULONG ulFlags = 0;
  2096. //
  2097. // Check for BLT support
  2098. //
  2099. // All 543x & 754x/755x/756x do BLTs
  2100. //
  2101. //myfr VideoDebugPrint((0, "Miniport - VgaAttributeFlags\n"));
  2102. if ((ChipType == CL543x) || (ChipType & CL754x) ||
  2103. (ChipType & CL755x) || (ChipType == CL756x))
  2104. {
  2105. ulFlags |= CAPS_BLT_SUPPORT;
  2106. }
  2107. else if ((ChipType == CL542x) && // 5426-5429 have BLT engines
  2108. (ChipId >= 0x26) || // 26 is CL5428
  2109. (ChipId == 0x24) ) // 24 is CL5426
  2110. {
  2111. ulFlags |= CAPS_BLT_SUPPORT;
  2112. }
  2113. // crus
  2114. else if (ChipType == CL6245)
  2115. {
  2116. ulFlags &= ~CAPS_BLT_SUPPORT;
  2117. }
  2118. // end crus
  2119. //
  2120. // Check for true color support
  2121. //
  2122. if ((ChipType == CL543x) || (ChipType & CL755x) || (ChipType == CL756x))
  2123. {
  2124. ulFlags |= CAPS_TRUE_COLOR;
  2125. // crus
  2126. // Added CL-GD7555 for direct draw support.//tao1
  2127. // if ((ChipType & CL755x))
  2128. // {
  2129. // ulFlags |= CAPS_IS_7555;
  2130. // }
  2131. // end crus
  2132. // crus
  2133. // Set CL-GD5436, CL-GD54UM36 and CL-GD5446 for autostart routine
  2134. // in display driver
  2135. //tso else if (HwDeviceExtension->AutoFeature)
  2136. if (HwDeviceExtension->AutoFeature)
  2137. {
  2138. //ulFlags |= CAPS_AUTOSTART;
  2139. ulFlags |= CAPS_ENGINEMANAGED;
  2140. }
  2141. // D5480 chu01
  2142. // chu04: GAMMACORRECT
  2143. //
  2144. // Specify BLT enhancement flag for later use.
  2145. //
  2146. if (HwDeviceExtension->BitBLTEnhance)
  2147. ulFlags |= ( CAPS_COMMAND_LIST | CAPS_GAMMA_CORRECT) ;
  2148. //myf29
  2149. if (ChipType & CL755x)
  2150. ulFlags |= CAPS_GAMMA_CORRECT;
  2151. }
  2152. //
  2153. // don't do host transfer and avoid hardware problem on fast machines
  2154. //
  2155. ulFlags |= CAPS_NO_HOST_XFER;
  2156. //
  2157. // Can't do host transfers on ISA 5434s
  2158. //
  2159. if ((HwDeviceExtension->BusType == Isa) &&
  2160. (ChipType == CL543x))
  2161. {
  2162. ulFlags |= CAPS_NO_HOST_XFER;
  2163. }
  2164. //
  2165. // Is this a 542x
  2166. //
  2167. if (ChipType == CL542x)
  2168. {
  2169. ulFlags |= CAPS_IS_542x;
  2170. if (ChipId == CL5429_ID)
  2171. {
  2172. //
  2173. // Some 5429s have a problem doing host transfers.
  2174. //
  2175. ulFlags |= CAPS_NO_HOST_XFER;
  2176. }
  2177. //
  2178. // 5428's have problems with HOST_TRANSFERS on MicroChannel bus.
  2179. //
  2180. if ((HwDeviceExtension->BusType == MicroChannel) &&
  2181. (ChipId == CL5428_ID))
  2182. {
  2183. //
  2184. // this is a 5428. We've noticed that some of these have mono
  2185. // expand problems on MCA IBM machines.
  2186. //
  2187. ulFlags |= CAPS_NO_HOST_XFER;
  2188. }
  2189. }
  2190. //
  2191. // The display driver needs to know if a Dual STN panel is
  2192. // in use, so that it can reserve part of the frame buffer for
  2193. // the half frame accelerator.
  2194. //
  2195. // Unfortunately we have found at least one machine with a DSTN
  2196. // panel that reports itself as having a TFT panel. (Dell Latitude
  2197. // XPi 90D). Therefore, we will have to reserve the space for
  2198. // any machine with a LCD panel!
  2199. //
  2200. //crus begin
  2201. //myf10
  2202. if ((ChipType & CL755x) || (ChipType & CL754x))
  2203. {
  2204. ulFlags |= GetPanelFlags(HwDeviceExtension);
  2205. }
  2206. //crus end
  2207. //
  2208. // The cirrus 543x chips don't support transparency.
  2209. //
  2210. ulFlags |= CAPS_TRANSPARENCY;
  2211. if ((ChipType & CL543x) &&
  2212. (ChipType != CL5446) &&
  2213. (ChipType != CL5446BE) &&
  2214. (ChipType != CL5480))
  2215. {
  2216. ulFlags &= ~CAPS_TRANSPARENCY;
  2217. }
  2218. return ulFlags;
  2219. }
  2220. BOOLEAN
  2221. CheckDDC2B(
  2222. PHW_DEVICE_EXTENSION HwDeviceExtension,
  2223. ULONG i
  2224. )
  2225. /*++
  2226. Routine Description:
  2227. Determines if refresh rate support according to DDC2B standard.
  2228. Arguments:
  2229. HwDeviceExtension - Pointer to the miniport driver's device extension.
  2230. Return Value:
  2231. None.
  2232. --*/
  2233. {
  2234. VideoDebugPrint((1, "Miniport -- CheckDDC2B\n")); //2
  2235. VideoDebugPrint((2, "refresh rate = %ld\n", ModesVGA[i].Frequency));
  2236. VideoDebugPrint((2, "hres = %d\n", ModesVGA[i].hres));
  2237. VideoDebugPrint((2, "vres = %d\n", ModesVGA[i].vres));
  2238. VideoDebugPrint((2, "EDIDTiming_I = %d\n", EDIDTiming_I));
  2239. VideoDebugPrint((2, "EDIDTiming_II = %d\n", EDIDTiming_II));
  2240. VideoDebugPrint((2, "EDIDTiming_III = %d\n", EDIDTiming_III));
  2241. if (!DDC2BFlag)
  2242. return TRUE ;
  2243. if (ModesVGA[i].Frequency == 85) {
  2244. if (ModesVGA[i].vres == 1200) { // 1600x1200
  2245. // if (!(EDIDTiming_III & 0x02))
  2246. // return FALSE ;
  2247. ;
  2248. } else if (ModesVGA[i].vres == 1024) { // 1280x1024
  2249. // if (!(EDIDTiming_III & 0x10))
  2250. // return FALSE ;
  2251. ;
  2252. } else if (ModesVGA[i].vres == 864) { // 1152x864
  2253. ;
  2254. } else if (ModesVGA[i].vres == 768) { // 1024x768
  2255. // if (!(EDIDTiming_III & 0x08))
  2256. // return FALSE ;
  2257. ;
  2258. } else if (ModesVGA[i].vres == 600) { // 800x600
  2259. // if (!(EDIDTiming_III & 0x20))
  2260. // return FALSE ;
  2261. ;
  2262. } else if (ModesVGA[i].vres == 480) { // 640x480
  2263. // if (!(EDIDTiming_III & 0x40))
  2264. // return FALSE ;
  2265. ;
  2266. }
  2267. } else if (ModesVGA[i].Frequency == 75) {
  2268. if (ModesVGA[i].vres == 1200) { // 1600x1200
  2269. // if (!(EDIDTiming_III & 0x04))
  2270. // return FALSE ;
  2271. ;
  2272. } else if (ModesVGA[i].vres == 1024) { // 1280x1024
  2273. if (!(EDIDTiming_II & 0x01))
  2274. return FALSE ;
  2275. } else if (ModesVGA[i].vres == 864) { // 1152x864
  2276. if (!(EDIDTiming_III & 0x80))
  2277. return FALSE ;
  2278. } else if (ModesVGA[i].vres == 768) { // 1024x768
  2279. if (!(EDIDTiming_II & 0x02))
  2280. return FALSE ;
  2281. } else if (ModesVGA[i].vres == 600) { // 800x600
  2282. if (!(EDIDTiming_II & 0x40))
  2283. return FALSE ;
  2284. } else if (ModesVGA[i].vres == 480) { // 640x480
  2285. if (!(EDIDTiming_I & 0x04))
  2286. return FALSE ;
  2287. }
  2288. } else if (ModesVGA[i].Frequency == 72) {
  2289. if (ModesVGA[i].vres == 600) { // 800x600
  2290. if (!(EDIDTiming_II & 0x80))
  2291. return FALSE ;
  2292. } else if (ModesVGA[i].vres == 480) { // 640x480
  2293. if (!(EDIDTiming_I & 0x08))
  2294. return FALSE ;
  2295. }
  2296. } else if (ModesVGA[i].Frequency == 70) {
  2297. if (ModesVGA[i].vres == 768) { // 1024x768
  2298. if (!(EDIDTiming_II & 0x04))
  2299. return FALSE ;
  2300. }
  2301. } else if (ModesVGA[i].Frequency == 60) {
  2302. if (ModesVGA[i].vres == 768) { // 1024x768
  2303. if (!(EDIDTiming_II & 0x08))
  2304. return FALSE ;
  2305. } else if (ModesVGA[i].vres == 600) { // 800x600
  2306. if (!(EDIDTiming_I & 0x01))
  2307. return FALSE ;
  2308. }
  2309. } else if (ModesVGA[i].Frequency == 56) {
  2310. if (ModesVGA[i].vres == 600) { // 800x600
  2311. if (!(EDIDTiming_I & 0x02))
  2312. return FALSE ;
  2313. }
  2314. }
  2315. return TRUE ;
  2316. } // end CheckDDC2B ()
  2317. VOID
  2318. AdjFastPgMdOperOnCL5424(
  2319. PHW_DEVICE_EXTENSION HwDeviceExtension,
  2320. PVIDEOMODE pRequestedMode
  2321. )
  2322. /*++
  2323. Routine Description:
  2324. Undesired bars happen on CL5424 800x600x16 color, 512Kb, 56, 60 and 72 Hz
  2325. Compaq Prosignia 300 machine. This can be solved by setting SRF(6) to 1.
  2326. This bit restricts the write buffer to one level, disabling fast page
  2327. mode operation; The faulty control logic is therefore disabled. The
  2328. downside is that the performance will take a hit, since we are dealing
  2329. with a 5424, so we make a slow chip slower.
  2330. Arguments:
  2331. HwDeviceExtension - Pointer to the miniport driver's device extension.
  2332. pRequestedMode
  2333. Return Value:
  2334. None.
  2335. --*/
  2336. {
  2337. UCHAR uc, chipId ;
  2338. /*--- CL5424 : ID = 100101xx ---*/
  2339. chipId = GetCirrusChipId(HwDeviceExtension) ; // chu08
  2340. if (chipId != 0x94)
  2341. return ;
  2342. /*--- 800x600x16 color, 60 or 72 Hz ---*/
  2343. if (pRequestedMode->hres != 800)
  2344. return ;
  2345. if (pRequestedMode->vres != 600)
  2346. return ;
  2347. if (pRequestedMode->bitsPerPlane != 1)
  2348. return ;
  2349. if (!((pRequestedMode->Frequency == 56) ||
  2350. (pRequestedMode->Frequency == 60) ||
  2351. (pRequestedMode->Frequency == 72)))
  2352. return ;
  2353. /*--- 512k ---*/
  2354. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  2355. SEQ_ADDRESS_PORT, 0x0A) ;
  2356. uc = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2357. SEQ_DATA_PORT) ;
  2358. if ((uc & 0x38) != 0x08)
  2359. return ;
  2360. /*--- SRF(6)=1 --- */
  2361. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  2362. SEQ_ADDRESS_PORT, 0x0F) ;
  2363. uc = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2364. SEQ_DATA_PORT) ;
  2365. uc &= 0xBF ;
  2366. uc |= 0x40 ;
  2367. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  2368. SEQ_DATA_PORT, uc) ;
  2369. } // end AdjFastPgMdOperOnCL5424 ()
  2370. // crus
  2371. BOOLEAN
  2372. CheckGD5446Rev(
  2373. PHW_DEVICE_EXTENSION HwDeviceExtension
  2374. )
  2375. /*++
  2376. Routine Description:
  2377. Check if it is CL-GD5446
  2378. Arguments:
  2379. HwDeviceExtension - Pointer to the miniport driver's device extension.
  2380. Return Value:
  2381. FALSE : It isn't CL-GD5446
  2382. TRUE : It is CL-GD5446
  2383. --*/
  2384. {
  2385. UCHAR chipId ;
  2386. //
  2387. // Get Chip ID
  2388. //
  2389. chipId = GetCirrusChipId(HwDeviceExtension) ; // chu08
  2390. // For CL-GD5446, Chip ID = 101110xx
  2391. if (chipId != 0xB8)
  2392. return FALSE ;
  2393. else
  2394. return TRUE ;
  2395. } // end CheckGD5446Rev ()
  2396. #if (_WIN32_WINNT <= 0x0400)
  2397. #pragma message("NOTICE: We want to remove DDC update code before 5.0 ships")
  2398. VOID CheckAndUpdateDDC2BMonitor(
  2399. PHW_DEVICE_EXTENSION hwDeviceExtension
  2400. )
  2401. {
  2402. NTSTATUS ntStatus;
  2403. UNICODE_STRING paramPath;
  2404. ULONG i;
  2405. BOOLEAN bRefreshChanged;
  2406. #if (_WIN32_WINNT < 0x0400)
  2407. WCHAR KeyString[] = L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Cl54xx35\\Device0";
  2408. #else
  2409. WCHAR KeyString[] = L"\\Registry\\Machine\\System\\CurrentControlSet\\Hardware Profiles\\Current\\System\\CurrentControlSet\\Services\\cirrus\\Device0";
  2410. #endif
  2411. RTL_QUERY_REGISTRY_TABLE paramTable[5];
  2412. ULONG ulZero = 0;
  2413. ULONG ulBitsPerPel = 8;
  2414. ULONG ulVRefresh = 60;
  2415. ULONG ulXResolution= 640;
  2416. ULONG ulYResolution= 480;
  2417. //
  2418. // Update the Monitor.Type Valuename
  2419. //
  2420. // sge02
  2421. VideoPortSetRegistryParameters(hwDeviceExtension,
  2422. L"Monitor.Type",
  2423. &DDC2BFlag,
  2424. sizeof(BOOLEAN));
  2425. //
  2426. // First check whether it is a DDC2B monitor
  2427. //
  2428. if(!DDC2BFlag)
  2429. return;
  2430. //
  2431. // Query the registry about the Manufacture and Product ID
  2432. //
  2433. if (NO_ERROR == VideoPortGetRegistryParameters(hwDeviceExtension,
  2434. L"Monitor.ID",
  2435. FALSE,
  2436. CirrusDDC2BRegistryCallback,
  2437. NULL))
  2438. {
  2439. //
  2440. // Same DDC2B Monitor, do nothing
  2441. //
  2442. }
  2443. else
  2444. {
  2445. //
  2446. // Set the Manufacture of the Monitor.
  2447. //
  2448. VideoPortSetRegistryParameters(hwDeviceExtension,
  2449. L"Monitor.ID",
  2450. &EDIDBuffer[8],
  2451. sizeof(ULONG));
  2452. //
  2453. // Set the EDID data of the Monitor.
  2454. //
  2455. VideoPortSetRegistryParameters(hwDeviceExtension,
  2456. L"Monitor.Data",
  2457. EDIDBuffer,
  2458. 128);
  2459. //
  2460. // Change to the highest refresh rate for the new
  2461. // DDC2B monitor.
  2462. //
  2463. paramPath.MaximumLength = sizeof(KeyString);
  2464. paramPath.Buffer = KeyString;
  2465. //
  2466. // We use this to query into the registry as to whether we
  2467. // should break at driver entry.
  2468. //
  2469. VideoPortZeroMemory(&paramTable[0], sizeof(paramTable));
  2470. paramTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
  2471. paramTable[0].Name = L"DefaultSettings.BitsPerPel";
  2472. paramTable[0].EntryContext = &ulBitsPerPel;
  2473. paramTable[0].DefaultType = REG_DWORD;
  2474. paramTable[0].DefaultData = &ulZero;
  2475. paramTable[0].DefaultLength = sizeof(ULONG);
  2476. paramTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
  2477. paramTable[1].Name = L"DefaultSettings.VRefresh";
  2478. paramTable[1].EntryContext = &ulVRefresh;
  2479. paramTable[1].DefaultType = REG_DWORD;
  2480. paramTable[1].DefaultData = &ulZero;
  2481. paramTable[1].DefaultLength = sizeof(ULONG);
  2482. paramTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT;
  2483. paramTable[2].Name = L"DefaultSettings.XResolution";
  2484. paramTable[2].EntryContext = &ulXResolution;
  2485. paramTable[2].DefaultType = REG_DWORD;
  2486. paramTable[2].DefaultData = &ulZero;
  2487. paramTable[2].DefaultLength = sizeof(ULONG);
  2488. paramTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT;
  2489. paramTable[3].Name = L"DefaultSettings.YResolution";
  2490. paramTable[3].EntryContext = &ulYResolution;
  2491. paramTable[3].DefaultType = REG_DWORD;
  2492. paramTable[3].DefaultData = &ulZero;
  2493. paramTable[3].DefaultLength = sizeof(ULONG);
  2494. if (NT_SUCCESS(RtlQueryRegistryValues(
  2495. RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL,
  2496. paramPath.Buffer, &paramTable[0], NULL, NULL)))
  2497. {
  2498. bRefreshChanged = FALSE;
  2499. //
  2500. // Get the highest refresh rate from the mode
  2501. //
  2502. for (i = 0; i < NumVideoModes; i++)
  2503. {
  2504. if (ModesVGA[i].ValidMode &&
  2505. (ModesVGA[i].hres == ulXResolution) &&
  2506. (ModesVGA[i].vres == ulYResolution) &&
  2507. (ModesVGA[i].numPlanes == 1 ) &&
  2508. (ModesVGA[i].bitsPerPlane == ulBitsPerPel))
  2509. {
  2510. if(ulVRefresh < ModesVGA[i].Frequency)
  2511. ulVRefresh = ModesVGA[i].Frequency;
  2512. bRefreshChanged = TRUE;
  2513. }
  2514. }
  2515. //
  2516. // Write to the registry
  2517. //
  2518. if (bRefreshChanged)
  2519. RtlWriteRegistryValue(
  2520. RTL_REGISTRY_ABSOLUTE,
  2521. paramPath.Buffer,
  2522. L"DefaultSettings.VRefresh",
  2523. REG_DWORD,
  2524. &ulVRefresh,
  2525. sizeof(ULONG)
  2526. );
  2527. }
  2528. }
  2529. }
  2530. #endif // (_WIN32_WINNT <= 0x0400)
  2531. //
  2532. // chu08
  2533. //
  2534. UCHAR
  2535. GetCirrusChipId(
  2536. PHW_DEVICE_EXTENSION HwDeviceExtension
  2537. )
  2538. /*++
  2539. Routine Description:
  2540. Get Cirrus Logic chip identifying value.
  2541. Arguments:
  2542. HwDeviceExtension - Pointer to the miniport driver's device extension.
  2543. Return Value:
  2544. Cirrus Logic chip ID.
  2545. --*/
  2546. {
  2547. UCHAR chipId ;
  2548. VideoDebugPrint((4, "GetCirrusChipId\n")) ;
  2549. if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2550. MISC_OUTPUT_REG_READ_PORT) & 0x01)
  2551. {
  2552. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  2553. CRTC_ADDRESS_PORT_COLOR, 0x27) ;
  2554. chipId = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2555. CRTC_DATA_PORT_COLOR) ;
  2556. } else {
  2557. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  2558. CRTC_ADDRESS_PORT_MONO, 0x27) ;
  2559. chipId = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2560. CRTC_DATA_PORT_MONO) ;
  2561. }
  2562. chipId &= 0xFC ;
  2563. return chipId ;
  2564. } // end GetCirrusChipId
  2565. //
  2566. // chu08
  2567. //
  2568. USHORT
  2569. GetCirrusChipRevisionId(
  2570. PHW_DEVICE_EXTENSION HwDeviceExtension
  2571. )
  2572. /*++
  2573. Routine Description:
  2574. Get Cirrus Logic chip revision identifying value.
  2575. Arguments:
  2576. HwDeviceExtension - Pointer to the miniport driver's device extension.
  2577. Return Value:
  2578. e.g., Rev AB = xxxx xx00 0010 0010
  2579. Rev AC = xxxx xx00 0010 0011
  2580. Cirrus Logic chip revision ID.
  2581. --*/
  2582. {
  2583. UCHAR chipId, chipRevision ;
  2584. USHORT chipRevisionId = 0 ;
  2585. VideoDebugPrint((4, "GetCirrusChipRevisionId\n")) ;
  2586. if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2587. MISC_OUTPUT_REG_READ_PORT) & 0x01)
  2588. {
  2589. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  2590. CRTC_ADDRESS_PORT_COLOR, 0x27) ;
  2591. chipId = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2592. CRTC_DATA_PORT_COLOR) ;
  2593. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  2594. CRTC_ADDRESS_PORT_COLOR, 0x25) ;
  2595. chipRevision = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2596. CRTC_DATA_PORT_COLOR) ;
  2597. } else {
  2598. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  2599. CRTC_ADDRESS_PORT_MONO, 0x27) ;
  2600. chipId = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2601. CRTC_DATA_PORT_MONO) ;
  2602. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  2603. CRTC_ADDRESS_PORT_MONO, 0x25) ;
  2604. chipRevision = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  2605. CRTC_DATA_PORT_MONO) ;
  2606. }
  2607. //
  2608. // Chip revision
  2609. //
  2610. chipRevisionId += (chipId & 0x03) ;
  2611. chipRevisionId <<= 8 ;
  2612. chipRevisionId += chipRevision ;
  2613. return chipRevisionId ;
  2614. } // end GetCirrusChipRevisionId