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.

1088 lines
40 KiB

  1. /*++
  2. Copyright (c) 1996-1997 Microsoft Corporation.
  3. Copyright (c) 1996-1997 Cirrus Logic, Inc.,
  4. Module Name:
  5. CLPANEL.C
  6. Abstract:
  7. This routine accesses panning scrolling information from the following
  8. NT 4.0 laptop.
  9. Environment:
  10. Kernel mode only
  11. Notes:
  12. *
  13. * myf28 :02-03-97 : Fixed NT3.51 PDR#8357, mode 3, 12, panning scrolling bug,
  14. * and move 4 routine from modeset.c to clpanel.c
  15. * myf29 :02-12-97 : Support Gamma correction graphic/video LUT for 755x
  16. * myf30 :02-10-97 : Fixed NT3.51, 6x4 LCD boot set 256 coloe, test 64K mode
  17. * myf31 :03-12-97 : XGA DSTN panel can't support 24bpp mode for 7556
  18. * myf32 :03-11-97 : check expension on, disable HW cursor fot 755x
  19. * myf33 :03-21-97 : check TV on, disable HW video & HW cursor, PDR #9006
  20. *
  21. --*/
  22. //---------------------------------------------------------------------------
  23. // HEADER FILES
  24. //---------------------------------------------------------------------------
  25. //#include <ntddk.h>
  26. #include <dderror.h>
  27. #include <devioctl.h>
  28. #include <miniport.h>
  29. #include "clmini.h"
  30. #include <ntddvdeo.h>
  31. #include <video.h>
  32. #include "cirrus.h"
  33. // crus
  34. #define DSTN (Dual_LCD | STN_LCD)
  35. #define DSTN10 (DSTN | panel10x7)
  36. #define DSTN8 (DSTN | panel8x6)
  37. #define DSTN6 (DSTN | panel)
  38. #define PanelType (panel | panel8x6 | panel10x7)
  39. #define ScreenType (DSTN | PanelType)
  40. SHORT Panning_flag = 0;
  41. //myf1, begin
  42. //#define PANNING_SCROLL
  43. #ifdef PANNING_SCROLL
  44. extern RESTABLE ResolutionTable[];
  45. extern PANNMODE PanningMode;
  46. extern USHORT ViewPoint_Mode;
  47. PANNMODE PanningMode = {1024, 768, 1024, 8, -1 };
  48. #endif
  49. extern UCHAR HWcur, HWicon0, HWicon1, HWicon2, HWicon3; //myf11
  50. //---------------------------------------------------------------------------
  51. // FUNCTION PROTOTYPE
  52. //---------------------------------------------------------------------------
  53. //myf28 VP_STATUS
  54. ULONG
  55. SetLaptopMode(
  56. PHW_DEVICE_EXTENSION HwDeviceExtension,
  57. PVIDEOMODE pRequestedMode,
  58. // VIDEOMODE* RequestedMode,
  59. ULONG RequestedModeNum
  60. );
  61. VOID //myf11
  62. AccessHWiconcursor(
  63. PHW_DEVICE_EXTENSION HwDeviceExtension,
  64. SHORT Access_flag
  65. );
  66. ULONG
  67. GetPanelFlags( //myf17
  68. PHW_DEVICE_EXTENSION HwDeviceExtension
  69. );
  70. // LCD Support
  71. USHORT
  72. CheckLCDSupportMode(
  73. PHW_DEVICE_EXTENSION HwDeviceExtension,
  74. ULONG i
  75. );
  76. #if defined(ALLOC_PRAGMA)
  77. #pragma alloc_text(PAGE,SetLaptopMode)
  78. #pragma alloc_text(PAGE,AccessHWiconcursor) //myf11, crus
  79. #pragma alloc_text(PAGE,GetPanelFlags) //myf17
  80. #pragma alloc_text(PAGE,CheckLCDSupportMode)
  81. #endif
  82. //myf28 VP_STATUS
  83. ULONG
  84. SetLaptopMode(
  85. PHW_DEVICE_EXTENSION HwDeviceExtension,
  86. PVIDEOMODE pRequestedMode,
  87. // VIDEOMODE* RequestedMode,
  88. ULONG RequestedModeNum
  89. )
  90. /*++
  91. Routine Description:
  92. This routine sets the laptop mode.
  93. Arguments:
  94. HwDeviceExtension - Pointer to the miniport driver's device extension.
  95. Mode - Pointer to the structure containing the information about the
  96. font to be set.
  97. ModeSize - Length of the input buffer supplied by the user.
  98. Return Value:
  99. ERROR_INSUFFICIENT_BUFFER if the input buffer was not large enough
  100. for the input data.
  101. ERROR_INVALID_PARAMETER if the mode number is invalid.
  102. NO_ERROR if the operation completed successfully.
  103. --*/
  104. {
  105. // PVIDEOMODE pRequestedMode;
  106. VP_STATUS status;
  107. VIDEO_X86_BIOS_ARGUMENTS biosArguments;
  108. USHORT Int10ModeNumber;
  109. // ULONG RequestedModeNum;
  110. UCHAR originalGRIndex, tempB ;
  111. UCHAR SEQIndex ;
  112. SHORT i; //myf1
  113. VideoDebugPrint((1, "Miniport - SetLaptopMode\n")); //myfr
  114. // pRequestedMode = (PVIDEOMODE) RequestedMode;
  115. // Set SR14 bit 2 to lock panel, Panel will not be turned on if setting
  116. // this bit. For laptop products only.
  117. //
  118. VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
  119. if ((HwDeviceExtension->ChipType == CL756x) ||
  120. (HwDeviceExtension->ChipType & CL755x) ||
  121. (HwDeviceExtension->ChipType == CL6245) ||
  122. (HwDeviceExtension->ChipType & CL754x))
  123. {
  124. //myf33: check TV on, disable HW video & HW cursor, PDR #9006
  125. biosArguments.Eax = 0x12FF;
  126. biosArguments.Ebx = 0xB0; // set/get TV Output
  127. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  128. if ((biosArguments.Eax & 0x0003) &&
  129. (biosArguments.Ebx & 0x0100))
  130. {
  131. HwDeviceExtension->CursorEnable = FALSE;
  132. HwDeviceExtension->VideoPointerEnabled = FALSE; //disable HW Cursor
  133. }
  134. //myf33: check TV on, disable HW video & HW cursor, PDR #9006
  135. biosArguments.Eax = pRequestedMode->BiosModes.BiosModeCL542x;
  136. biosArguments.Eax |= 0x1200;
  137. biosArguments.Eax &= 0xFF7F; //myf1
  138. biosArguments.Ebx = 0xA0; // query video mode availability
  139. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  140. #ifdef PANNING_SCROLL
  141. if (PanningMode.flag == -1)
  142. {
  143. PanningMode.hres = pRequestedMode->hres;
  144. PanningMode.vres = pRequestedMode->vres;
  145. PanningMode.wbytes = pRequestedMode->wbytes;
  146. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  147. PanningMode.flag = 0;
  148. Panning_flag = 0;
  149. }
  150. #endif //PAANNING_SCROLL
  151. //crus
  152. // bit0=1:video mode support
  153. if ((HwDeviceExtension->ChipType == CL6245) &&
  154. !(biosArguments.Eax & 0x0100))
  155. {
  156. return ERROR_INVALID_PARAMETER;
  157. }
  158. // fix CL6245 bug -- In 640x480x256C mode, with DSTN panel,
  159. // 512K bytes memory is not enought
  160. else if ((HwDeviceExtension->ChipType == CL6245) &&
  161. (biosArguments.Eax & 0x0500) &&
  162. (pRequestedMode->BiosModes.BiosModeCL542x == 0x5F) &&
  163. //myf28 (pRequestedMode->DisplayType & DSTN))
  164. (HwDeviceExtension->DisplayType & DSTN)) //myf28
  165. {
  166. return ERROR_INVALID_PARAMETER;
  167. }
  168. //myf27: 1-9-97 fixed connect XGA panel, set 64K color mode for 754x, begin
  169. else if ((HwDeviceExtension->ChipType & CL754x) &&
  170. (biosArguments.Eax & 0x0400) &&
  171. //myf27 (!(HwDeviceExtension->DisplayType & Jump_type)) && //myf27
  172. ((pRequestedMode->BiosModes.BiosModeCL542x == 0x64) ||
  173. (pRequestedMode->BiosModes.BiosModeCL542x == 0x65) ||
  174. (pRequestedMode->BiosModes.BiosModeCL542x == 0x74)) &&
  175. //myf28 (pRequestedMode->DisplayType & (TFT_LCD | panel10x7)) )
  176. ((HwDeviceExtension->DisplayType & (TFT_LCD | panel10x7)) ==
  177. (TFT_LCD | panel10x7)) )//myf28
  178. {
  179. return ERROR_INVALID_PARAMETER;
  180. }
  181. else if ((HwDeviceExtension->ChipType & CL754x) &&
  182. ((pRequestedMode->BiosModes.BiosModeCL542x == 0x64) ||
  183. (pRequestedMode->BiosModes.BiosModeCL542x == 0x65) ||
  184. (pRequestedMode->BiosModes.BiosModeCL542x == 0x74)) &&
  185. (biosArguments.Eax & 0x0400) &&
  186. //myf27 (!(HwDeviceExtension->DisplayType & Jump_type)) && //myf27
  187. //myf28 ((pRequestedMode->DisplayType & DSTN8) ||
  188. //myf28 (pRequestedMode->DisplayType & DSTN10)) )
  189. (((HwDeviceExtension->DisplayType & DSTN8) ==DSTN8) || //myf28
  190. ((HwDeviceExtension->DisplayType & DSTN10)==DSTN10))) //myf28
  191. {
  192. return ERROR_INVALID_PARAMETER;
  193. }
  194. //myf28 begin
  195. else if ((pRequestedMode->BiosModes.BiosModeCL542x == 0x03) ||
  196. (pRequestedMode->BiosModes.BiosModeCL542x == 0x12))
  197. {
  198. goto PANNING_OVER;
  199. }
  200. //myf31:3-12-97, XGA DSTN panel can't support 24bpp mode for 7556
  201. else if ((HwDeviceExtension->ChipType & CL755x) &&
  202. ((pRequestedMode->BiosModes.BiosModeCL542x == 0x71) ||
  203. (pRequestedMode->BiosModes.BiosModeCL542x == 0x78) ||
  204. (pRequestedMode->BiosModes.BiosModeCL542x == 0x79) ||
  205. (pRequestedMode->BiosModes.BiosModeCL542x == 0x77)) &&
  206. (biosArguments.Eax & 0x0400) &&
  207. ((HwDeviceExtension->DisplayType & DSTN10)==DSTN10))
  208. {
  209. return ERROR_INVALID_PARAMETER;
  210. }
  211. //myf31 end
  212. //myf28 end
  213. //myf27: 1-9-97 fixed connect DSTN panel, set 64K color mode for 754x, end
  214. //
  215. // bit3=1:panel support, bit2=1:panel enable,
  216. // bit1=1:crt enable(in AH)
  217. //
  218. //panel turn on, mode not support (1)
  219. else if ((biosArguments.Eax & 0x0400) &&
  220. (HwDeviceExtension->ChipType != CL6245) &&
  221. !(biosArguments.Eax & 0x0800))
  222. {
  223. #ifndef PANNING_SCROLL //myf1
  224. return ERROR_INVALID_PARAMETER;
  225. #else
  226. //myf1, begin
  227. biosArguments.Eax = 0x1280;
  228. biosArguments.Ebx = 0x9C; // Inquire panel information
  229. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  230. if ((biosArguments.Eax & 0x0002) && //Dual-Scan STN
  231. (biosArguments.Ebx > 640) && //myf19
  232. (pRequestedMode->bitsPerPlane > 8) &&
  233. (HwDeviceExtension->ChipType & CL754x))
  234. {
  235. pRequestedMode = &ModesVGA[DefaultMode]; //myf19
  236. pRequestedMode->Frequency = 60;
  237. return ERROR_INVALID_PARAMETER;
  238. }
  239. else
  240. {
  241. i = 0;
  242. while ((ResolutionTable[i].Hres != 0) &&
  243. (ResolutionTable[i].Vres != 0))
  244. {
  245. if ((biosArguments.Ebx == ResolutionTable[i].Hres) &&
  246. (biosArguments.Ecx == ResolutionTable[i].Vres) &&
  247. (pRequestedMode->bitsPerPlane ==
  248. ResolutionTable[i].BitsPerPlane) &&
  249. (ResolutionTable[i].ModesVgaStart != NULL))
  250. {
  251. if ((PanningMode.bpp != pRequestedMode->bitsPerPlane) &&
  252. (Panning_flag == 1))
  253. {
  254. PanningMode.hres = pRequestedMode->hres;
  255. PanningMode.vres = pRequestedMode->vres;
  256. PanningMode.wbytes = pRequestedMode->wbytes;
  257. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  258. PanningMode.flag = 0;
  259. Panning_flag = 0;
  260. //myf30 begin
  261. PanningMode.flag = 1;
  262. Panning_flag = 1;
  263. pRequestedMode =
  264. &ModesVGA[ResolutionTable[i].ModesVgaStart];
  265. RequestedModeNum = ResolutionTable[i].ModesVgaStart;
  266. //myf12
  267. pRequestedMode->Frequency = 60;
  268. ViewPoint_Mode = ResolutionTable[i].Mode;
  269. //myf30 end
  270. }
  271. else if ((Panning_flag == 1) &&
  272. (PanningMode.bpp == pRequestedMode->bitsPerPlane))
  273. {
  274. #if 1 //myf18 add
  275. PanningMode.hres = pRequestedMode->hres;
  276. PanningMode.vres = pRequestedMode->vres;
  277. PanningMode.wbytes = pRequestedMode->wbytes;
  278. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  279. PanningMode.flag = 1;
  280. #endif
  281. pRequestedMode =
  282. &ModesVGA[ResolutionTable[i].ModesVgaStart];
  283. RequestedModeNum = ResolutionTable[i].ModesVgaStart;
  284. //myf12
  285. pRequestedMode->Frequency = 60;
  286. ViewPoint_Mode = ResolutionTable[i].Mode;
  287. }
  288. else
  289. {
  290. PanningMode.hres = pRequestedMode->hres;
  291. PanningMode.vres = pRequestedMode->vres;
  292. PanningMode.wbytes = pRequestedMode->wbytes;
  293. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  294. PanningMode.flag = 1;
  295. Panning_flag = 1;
  296. pRequestedMode =
  297. &ModesVGA[ResolutionTable[i].ModesVgaStart];
  298. RequestedModeNum = ResolutionTable[i].ModesVgaStart;
  299. //myf12
  300. pRequestedMode->Frequency = 60;
  301. ViewPoint_Mode = ResolutionTable[i].Mode;
  302. }
  303. break;
  304. }
  305. i ++;
  306. }
  307. }
  308. #endif
  309. //myf1, end
  310. }
  311. //panel turn off, mode not support (2)
  312. else if (!(biosArguments.Eax & 0x0800) &&
  313. (HwDeviceExtension->ChipType != CL6245) &&
  314. !(biosArguments.Eax & 0x0400))
  315. {
  316. //myf1, begin
  317. #ifdef PANNING_SCROLL
  318. PanningMode.flag = 0;
  319. Panning_flag = 0;
  320. #if 0
  321. biosArguments.Eax = 0x1280;
  322. biosArguments.Ebx = 0x9C; // Inquire panel information
  323. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  324. if ((biosArguments.Eax & 0x0002) && //Dual-Scan STN
  325. (biosArguments.Ebx > 640) && //myf19
  326. (pRequestedMode->bitsPerPlane > 8) &&
  327. (HwDeviceExtension->ChipType & CL754x))
  328. {
  329. pRequestedMode = &ModesVGA[DefaultMode]; //myf19
  330. pRequestedMode->Frequency = 60;
  331. return ERROR_INVALID_PARAMETER;
  332. }
  333. else
  334. {
  335. i = 0;
  336. while ((ResolutionTable[i].Hres != 0) &&
  337. (ResolutionTable[i].Vres != 0))
  338. {
  339. if ((biosArguments.Ebx == ResolutionTable[i].Hres) &&
  340. (biosArguments.Ecx == ResolutionTable[i].Vres) &&
  341. (pRequestedMode->bitsPerPlane ==
  342. ResolutionTable[i].BitsPerPlane) &&
  343. (ResolutionTable[i].ModesVgaStart != NULL))
  344. {
  345. if ((PanningMode.bpp != pRequestedMode->bitsPerPlane) &&
  346. (Panning_flag == 1))
  347. {
  348. PanningMode.hres = pRequestedMode->hres;
  349. PanningMode.vres = pRequestedMode->vres;
  350. PanningMode.wbytes = pRequestedMode->wbytes;
  351. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  352. PanningMode.flag = 0;
  353. Panning_flag = 0;
  354. }
  355. else if ((Panning_flag == 1) &&
  356. (PanningMode.bpp == pRequestedMode->bitsPerPlane))
  357. {
  358. pRequestedMode =
  359. &ModesVGA[ResolutionTable[i].ModesVgaStart];
  360. RequestedModeNum = ResolutionTable[i].ModesVgaStart;
  361. //myf12
  362. pRequestedMode->Frequency = 60;
  363. ViewPoint_Mode = ResolutionTable[i].Mode;
  364. }
  365. else
  366. {
  367. PanningMode.hres = pRequestedMode->hres;
  368. PanningMode.vres = pRequestedMode->vres;
  369. PanningMode.wbytes = pRequestedMode->wbytes;
  370. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  371. PanningMode.flag = 1;
  372. Panning_flag = 1;
  373. pRequestedMode =
  374. &ModesVGA[ResolutionTable[i].ModesVgaStart];
  375. RequestedModeNum = ResolutionTable[i].ModesVgaStart;
  376. //myf12
  377. pRequestedMode->Frequency = 60;
  378. ViewPoint_Mode = ResolutionTable[i].Mode;
  379. }
  380. break;
  381. }
  382. i ++;
  383. }
  384. }
  385. #endif //0
  386. #else
  387. //myf1, end
  388. //
  389. // Lock turn on panel
  390. //
  391. SEQIndex = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  392. SEQ_ADDRESS_PORT);
  393. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  394. SEQ_ADDRESS_PORT, 0x14);
  395. tempB = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  396. SEQ_DATA_PORT) | 0x04;
  397. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  398. SEQ_DATA_PORT,tempB);
  399. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  400. SEQ_ADDRESS_PORT, SEQIndex);
  401. #endif //myf1, ifdef PANNING_SCROLL
  402. }
  403. //myf1, begin
  404. //panel turn on, mode support (3)
  405. else if ((biosArguments.Eax & 0x0800) &&
  406. (HwDeviceExtension->ChipType != CL6245) &&
  407. (biosArguments.Eax & 0x0400))
  408. {
  409. #ifdef PANNING_SCROLL
  410. biosArguments.Eax = 0x1280;
  411. biosArguments.Ebx = 0x9C; // Inquire panel information
  412. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  413. if ((biosArguments.Eax & 0x0002) && //Dual-Scan STN
  414. (biosArguments.Ebx > 640) && //myf19
  415. (pRequestedMode->bitsPerPlane > 8) &&
  416. (HwDeviceExtension->ChipType & CL754x))
  417. {
  418. pRequestedMode = &ModesVGA[DefaultMode]; //myf19
  419. pRequestedMode->Frequency = 60;
  420. return ERROR_INVALID_PARAMETER;
  421. }
  422. //myf26, begin
  423. else if ((pRequestedMode->hres == 640) &&
  424. (pRequestedMode->vres == 480) &&
  425. (pRequestedMode->bitsPerPlane == 1) &&
  426. ((HwDeviceExtension->ChipType & CL754x) ||
  427. (HwDeviceExtension->ChipType & CL755x) || //myf32
  428. (HwDeviceExtension->ChipType == CL756x)))
  429. {
  430. pRequestedMode->Frequency = 60;
  431. PanningMode.hres = pRequestedMode->hres;
  432. PanningMode.vres = pRequestedMode->vres;
  433. PanningMode.wbytes = pRequestedMode->wbytes;
  434. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  435. PanningMode.flag = 0;
  436. Panning_flag = 0;
  437. pRequestedMode =
  438. &ModesVGA[ResolutionTable[0].ModesVgaStart];
  439. RequestedModeNum =
  440. ResolutionTable[0].ModesVgaStart;
  441. //myf12
  442. pRequestedMode->Frequency = 60;
  443. ViewPoint_Mode = ResolutionTable[0].Mode;
  444. }
  445. //myf26, end
  446. else
  447. {
  448. i = 0;
  449. while ((ResolutionTable[i].Hres != 0) &&
  450. (ResolutionTable[i].Vres != 0))
  451. {
  452. if ((biosArguments.Ebx == ResolutionTable[i].Hres) &&
  453. (biosArguments.Ecx == ResolutionTable[i].Vres) &&
  454. (pRequestedMode->bitsPerPlane ==
  455. ResolutionTable[i].BitsPerPlane) &&
  456. (ResolutionTable[i].ModesVgaStart != NULL))
  457. {
  458. if ((pRequestedMode->hres < biosArguments.Ebx) &&
  459. (pRequestedMode->vres < biosArguments.Eax))
  460. {
  461. #if 1 //myf18 add
  462. PanningMode.hres = pRequestedMode->hres;
  463. PanningMode.vres = pRequestedMode->vres;
  464. PanningMode.wbytes = pRequestedMode->wbytes;
  465. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  466. #endif//myf18
  467. Panning_flag = 0;
  468. PanningMode.flag = 0;
  469. }
  470. else if ((PanningMode.bpp !=
  471. pRequestedMode->bitsPerPlane) &&
  472. (Panning_flag == 1))
  473. {
  474. PanningMode.hres = pRequestedMode->hres;
  475. PanningMode.vres = pRequestedMode->vres;
  476. PanningMode.wbytes = pRequestedMode->wbytes;
  477. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  478. PanningMode.flag = 0;
  479. Panning_flag = 0;
  480. }
  481. else if ((Panning_flag == 1) &&
  482. (PanningMode.bpp == pRequestedMode->bitsPerPlane))
  483. {
  484. if ((pRequestedMode->hres<ResolutionTable[i].Hres)||
  485. (pRequestedMode->vres <ResolutionTable[i].Vres))
  486. {
  487. while ((ResolutionTable[i].Hres !=
  488. pRequestedMode->hres) &&
  489. (ResolutionTable[i].Vres !=
  490. pRequestedMode->vres))
  491. {
  492. if ((pRequestedMode->bitsPerPlane ==
  493. ResolutionTable[i].BitsPerPlane) &&
  494. (ResolutionTable[i].Hres ==
  495. pRequestedMode->hres) &&
  496. (ResolutionTable[i].Vres ==
  497. pRequestedMode->vres))
  498. {
  499. #if 1 //myf18 add
  500. PanningMode.hres = pRequestedMode->hres;
  501. PanningMode.vres = pRequestedMode->vres;
  502. PanningMode.wbytes = pRequestedMode->wbytes;
  503. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  504. PanningMode.flag = 1;
  505. #endif
  506. pRequestedMode =
  507. &ModesVGA[ResolutionTable[i].ModesVgaStart];
  508. RequestedModeNum =
  509. ResolutionTable[i].ModesVgaStart;
  510. //myf12
  511. pRequestedMode->Frequency = 60;
  512. ViewPoint_Mode = ResolutionTable[i].Mode;
  513. break;
  514. }
  515. i ++;
  516. }
  517. }
  518. else
  519. {
  520. #if 1 //myf18 add
  521. PanningMode.hres = pRequestedMode->hres;
  522. PanningMode.vres = pRequestedMode->vres;
  523. PanningMode.wbytes = pRequestedMode->wbytes;
  524. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  525. PanningMode.flag = 1;
  526. #endif
  527. pRequestedMode =
  528. &ModesVGA[ResolutionTable[i].ModesVgaStart];
  529. RequestedModeNum = ResolutionTable[i].ModesVgaStart;
  530. //myf12
  531. pRequestedMode->Frequency = 60;
  532. ViewPoint_Mode = ResolutionTable[i].Mode;
  533. }
  534. }
  535. else
  536. {
  537. PanningMode.hres = pRequestedMode->hres;
  538. PanningMode.vres = pRequestedMode->vres;
  539. PanningMode.wbytes = pRequestedMode->wbytes;
  540. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  541. PanningMode.flag = 1;
  542. Panning_flag = 1;
  543. pRequestedMode =
  544. &ModesVGA[ResolutionTable[i].ModesVgaStart];
  545. RequestedModeNum = ResolutionTable[i].ModesVgaStart;
  546. //myf12
  547. pRequestedMode->Frequency = 60;
  548. ViewPoint_Mode = ResolutionTable[i].Mode;
  549. }
  550. break;
  551. }
  552. i ++;
  553. }
  554. }
  555. #endif
  556. //myf1, end
  557. }
  558. //myf1, begin
  559. //panel turn off, mode support (4)
  560. else if ((biosArguments.Eax & 0x0800) &&
  561. (HwDeviceExtension->ChipType != CL6245) &&
  562. !(biosArguments.Eax & 0x0400))
  563. {
  564. #ifdef PANNING_SCROLL
  565. #if 1
  566. //myf18 if (PanningMode.flag == -1)
  567. {
  568. PanningMode.hres = pRequestedMode->hres;
  569. PanningMode.vres = pRequestedMode->vres;
  570. PanningMode.wbytes = pRequestedMode->wbytes;
  571. PanningMode.bpp = pRequestedMode->bitsPerPlane;
  572. PanningMode.flag = 0;
  573. Panning_flag = 0;
  574. }
  575. #endif
  576. #else
  577. //myf18
  578. //
  579. // UnLock turn on panel
  580. //
  581. SEQIndex = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  582. SEQ_ADDRESS_PORT);
  583. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  584. SEQ_ADDRESS_PORT, 0x14);
  585. tempB = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  586. SEQ_DATA_PORT) & 0xFB;
  587. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  588. SEQ_DATA_PORT,tempB);
  589. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  590. SEQ_ADDRESS_PORT, SEQIndex);
  591. //myf18 end
  592. #endif
  593. }
  594. //myf1, end
  595. //myf4: patch Viking BIOS bug, PDR #4287, begin
  596. /*
  597. else if ((biosArguments.Eax & 0x0800) && !(biosArguments.Eax & 0x0400)
  598. && (HwDeviceExtension->ChipType & CL754x))
  599. {
  600. //by self check panel if or not supported
  601. //myf16, begin
  602. biosArguments.Eax = 0x1280;
  603. biosArguments.Ebx = 0x9C; // query panel information
  604. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  605. if (status == NO_ERROR)
  606. {
  607. if ( (((biosArguments.Ebx & 0x0000FFFF) == 640) &&
  608. (pRequestedMode->vres > 480)) || //6x4 VGA
  609. (((biosArguments.Ebx & 0x0000FFFF) == 800) &&
  610. (pRequestedMode->vres > 600)) || //8x6 SVGA
  611. (((biosArguments.Ebx & 0x0000FFFF) == 1024) &&
  612. (pRequestedMode->vres > 768)) ) //10x7 XGA
  613. {
  614. //myf16, end
  615. SEQIndex = VideoPortReadPortUchar(HwDeviceExtension->IOAddress+
  616. SEQ_ADDRESS_PORT);
  617. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  618. SEQ_ADDRESS_PORT, 0x14);
  619. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  620. SEQ_DATA_PORT,
  621. (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  622. SEQ_DATA_PORT) | 0x04));
  623. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  624. SEQ_ADDRESS_PORT, SEQIndex);
  625. }
  626. }
  627. }
  628. */
  629. //myf4: patch Viking BIOS bug, PDR #4287, end
  630. }
  631. #ifdef PANNING_SCROLL
  632. VideoDebugPrint((1, "Info on Panning Mode:\n"
  633. "\tResolution: %dx%dx%d (%d bytes) -- %x\n",
  634. PanningMode.hres,
  635. PanningMode.vres,
  636. PanningMode.bpp,
  637. PanningMode.wbytes,
  638. ViewPoint_Mode ));
  639. #endif
  640. //
  641. // Set the Vertical Monitor type, if BIOS supports it
  642. //
  643. if ((pRequestedMode->MonTypeAX) &&
  644. ((HwDeviceExtension->ChipType & CL754x) ||
  645. (HwDeviceExtension->ChipType == CL756x) ||
  646. (HwDeviceExtension->ChipType == CL6245) ||
  647. (HwDeviceExtension->ChipType & CL755x)) )
  648. {
  649. //
  650. // Re-write this part.
  651. //
  652. biosArguments.Eax = 0x1200;
  653. biosArguments.Ebx = 0x9A;
  654. status = VideoPortInt10(HwDeviceExtension, &biosArguments);
  655. if (status != NO_ERROR)
  656. {
  657. return status;
  658. }
  659. else
  660. {
  661. biosArguments.Eax = ((biosArguments.Ecx >> 4) & 0x000F);
  662. //myf5 : 9-01-96, PDR #4365 keep all default refresh rate, begin
  663. biosArguments.Eax |= (biosArguments.Ebx >> 8) & 0x0030; //VGA
  664. biosArguments.Ebx = 0x00A4;
  665. biosArguments.Ebx |= (biosArguments.Ecx & 0xFF00); //XGA, SVGA
  666. biosArguments.Ecx = (biosArguments.Ecx & 0x000E) << 11; //12x10
  667. //myf5 : 9-01-96, PDR #4365, end
  668. if (pRequestedMode->vres == 480)
  669. {
  670. biosArguments.Eax |= 0x1200;
  671. biosArguments.Eax &= 0xFFCF; //myf5: 09-01-96
  672. if (pRequestedMode->Frequency == 85) //myf0
  673. biosArguments.Eax |= 0x30; //myf0
  674. else if (pRequestedMode->Frequency == 75)
  675. biosArguments.Eax |= 0x20;
  676. else if (pRequestedMode->Frequency == 72)
  677. biosArguments.Eax |= 0x10;
  678. }
  679. else if (pRequestedMode->vres == 600)
  680. {
  681. biosArguments.Eax |= 0x1200;
  682. biosArguments.Ebx &= 0xF0FF; //myf5: 09-01-96
  683. if (pRequestedMode->Frequency == 85) //myf0
  684. biosArguments.Ebx |= 0x0400; //myf0
  685. else if (pRequestedMode->Frequency == 75)
  686. biosArguments.Ebx |= 0x0300;
  687. else if (pRequestedMode->Frequency == 72)
  688. biosArguments.Ebx |= 0x0200;
  689. else if (pRequestedMode->Frequency == 60)
  690. biosArguments.Ebx |= 0x0100;
  691. }
  692. else if (pRequestedMode->vres == 768)
  693. {
  694. biosArguments.Eax |= 0x1200;
  695. biosArguments.Ebx &= 0x0FFF; //myf5: 09-01-96
  696. if (pRequestedMode->Frequency == 85) //myf0
  697. biosArguments.Ebx |= 0x5000; //myf0
  698. else if (pRequestedMode->Frequency == 75)
  699. biosArguments.Ebx |= 0x4000;
  700. else if (pRequestedMode->Frequency == 72)
  701. biosArguments.Ebx |= 0x3000;
  702. else if (pRequestedMode->Frequency == 70)
  703. biosArguments.Ebx |= 0x2000;
  704. else if (pRequestedMode->Frequency == 60)
  705. biosArguments.Ebx |= 0x1000;
  706. }
  707. else if (pRequestedMode->vres == 1024)
  708. {
  709. biosArguments.Eax |= 0x1200;
  710. biosArguments.Ecx &= 0x0FFF; //myf5: 09-01-96
  711. if (pRequestedMode->Frequency == 45)
  712. biosArguments.Ecx |= 0x0000;
  713. else if (pRequestedMode->Frequency == 60) //myf0
  714. biosArguments.Ecx |= 0x1000; //myf0
  715. else if (pRequestedMode->Frequency == 72) //myf0
  716. biosArguments.Ecx |= 0x2000; //myf0
  717. else if (pRequestedMode->Frequency == 75) //myf0
  718. biosArguments.Ecx |= 0x3000; //myf0
  719. else if (pRequestedMode->Frequency == 85) //myf0
  720. biosArguments.Ecx |= 0x4000; //myf0
  721. }
  722. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  723. if (status != NO_ERROR)
  724. {
  725. return status;
  726. }
  727. }
  728. }
  729. HwDeviceExtension->bCurrentMode = RequestedModeNum; //myf12
  730. //VideoDebugPrint((0, "SetMode Info :\n"
  731. // "\tMode : %x, CurrentModeNum : %x, ( %d)\n",
  732. // Int10ModeNumber,
  733. // RequestedModeNum,
  734. // RequestedModeNum));
  735. PANNING_OVER:
  736. return NO_ERROR;
  737. //return(pRequestedMode);
  738. } //end SetLaptopMode()
  739. //myf11 : begin
  740. VOID
  741. AccessHWiconcursor(
  742. // PVOID HwDeviceExtension,
  743. PHW_DEVICE_EXTENSION HwDeviceExtension,
  744. SHORT Access_flag
  745. )
  746. /*++
  747. Routine Description:
  748. This routine determines disable/enable HW icon & HW cursor
  749. Arguments:
  750. HwDeviceExtension - Supplies a pointer to the miniport's device extension.
  751. Access_flag - equal 0: Disable, equal 1: Enable.
  752. Return Value:
  753. none
  754. --*/
  755. {
  756. UCHAR savSEQidx;
  757. savSEQidx = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  758. SEQ_ADDRESS_PORT);
  759. if (Access_flag) //Enable hw icon/cursor
  760. {
  761. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  762. SEQ_ADDRESS_PORT, 0x12);
  763. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  764. SEQ_DATA_PORT, HWcur);
  765. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  766. SEQ_ADDRESS_PORT, 0x2A);
  767. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  768. SEQ_DATA_PORT, HWicon0);
  769. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  770. SEQ_ADDRESS_PORT, 0x2B);
  771. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  772. SEQ_DATA_PORT, HWicon1);
  773. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  774. SEQ_ADDRESS_PORT, 0x2C);
  775. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  776. SEQ_DATA_PORT, HWicon2);
  777. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  778. SEQ_ADDRESS_PORT, 0x2D);
  779. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  780. SEQ_DATA_PORT, HWicon3);
  781. }
  782. else //Disable HW cursor, icons
  783. {
  784. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  785. SEQ_ADDRESS_PORT, 0x12);
  786. HWcur = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  787. SEQ_DATA_PORT);
  788. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  789. SEQ_DATA_PORT, (UCHAR)(HWcur & 0xFE));
  790. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  791. SEQ_ADDRESS_PORT, 0x2A);
  792. HWicon0 = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  793. SEQ_DATA_PORT);
  794. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  795. SEQ_DATA_PORT, (UCHAR)(HWicon0 & 0xFE));
  796. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  797. SEQ_ADDRESS_PORT, 0x2B);
  798. HWicon1 = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  799. SEQ_DATA_PORT);
  800. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  801. SEQ_DATA_PORT, (UCHAR)(HWicon1 & 0xFE));
  802. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  803. SEQ_ADDRESS_PORT, 0x2C);
  804. HWicon2 = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  805. SEQ_DATA_PORT);
  806. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  807. SEQ_DATA_PORT, (UCHAR)(HWicon2 & 0xFE));
  808. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  809. SEQ_ADDRESS_PORT, 0x2D);
  810. HWicon3 = VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  811. SEQ_DATA_PORT);
  812. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  813. SEQ_DATA_PORT, (UCHAR)(HWicon3 & 0xFE));
  814. }
  815. VideoPortWritePortUchar(HwDeviceExtension->IOAddress +
  816. SEQ_ADDRESS_PORT, savSEQidx);
  817. } // end AccessHWiconcursor()
  818. //myf11 : end
  819. //crus begin
  820. //myf10, begin
  821. ULONG
  822. GetPanelFlags (
  823. PHW_DEVICE_EXTENSION HwDeviceExtension
  824. )
  825. {
  826. ULONG ChipType = HwDeviceExtension->ChipType;
  827. ULONG ulFlags = 0;
  828. UCHAR savSEQidx, Panel_Type =0, LCD;
  829. ULONG ulCRTCAddress, ulCRTCData;
  830. //myf16, begin
  831. VP_STATUS status;
  832. VIDEO_X86_BIOS_ARGUMENTS biosArguments;
  833. VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
  834. biosArguments.Eax = 0x1280;
  835. biosArguments.Ebx = 0x9C; // query panel information
  836. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  837. if (status == NO_ERROR)
  838. {
  839. if ((biosArguments.Eax & 0x00000002) == 2)
  840. Panel_Type = (UCHAR)1; //DSTN panel
  841. if (((biosArguments.Ebx & 0x0000FFFF) == 640) &&
  842. ((biosArguments.Ecx & 0x0000FFFF) == 480))
  843. ulFlags |= CAPS_VGA_PANEL;
  844. else if (((biosArguments.Ebx & 0x0000FFFF) == 800) &&
  845. ((biosArguments.Ecx & 0x0000FFFF) == 600))
  846. ulFlags |= CAPS_SVGA_PANEL;
  847. else if (((biosArguments.Ebx & 0x0000FFFF) == 1024) &&
  848. ((biosArguments.Ecx & 0x0000FFFF) == 768))
  849. ulFlags |= CAPS_XGA_PANEL;
  850. }
  851. //myf33: check TV on, disable HW video & HW cursor, PDR #9006
  852. biosArguments.Eax = 0x12FF;
  853. biosArguments.Ebx = 0xB0; // set/get TV Output
  854. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  855. if ((biosArguments.Eax & 0x0003) &&
  856. (biosArguments.Ebx & 0x0100))
  857. {
  858. ulFlags |= CAPS_TV_ON;
  859. ulFlags |= CAPS_SW_POINTER;
  860. }
  861. else
  862. ulFlags &= ~CAPS_TV_ON;
  863. //myf33: check TV on, disable HW video & HW cursor, PDR #9006
  864. #if 0
  865. if (VideoPortReadPortUchar(HwDeviceExtension->IOAddress +
  866. MISC_OUTPUT_REG_READ_PORT) & 0x01)
  867. {
  868. ulCRTCAddress = CRTC_ADDRESS_PORT_COLOR;
  869. ulCRTCData = CRTC_DATA_PORT_COLOR;
  870. }
  871. else
  872. {
  873. ulCRTCAddress = CRTC_ADDRESS_PORT_MONO;
  874. ulCRTCData = CRTC_DATA_PORT_MONO;
  875. }
  876. savSEQidx = VideoPortReadPortUchar(ulCRTCAddress);
  877. if ((ChipType & CL754x)) //7548/7543/7541
  878. {
  879. VideoPortWritePortUchar(ulCRTCAddress, 0x20);
  880. LCD = VideoPortReadPortUchar(ulCRTCData) & 0x20;
  881. }
  882. else if (ChipType & CL755x) //7555
  883. {
  884. VideoPortWritePortUchar(ulCRTCAddress, 0x80);
  885. LCD = VideoPortReadPortUchar(ulCRTCData) & 0x01;
  886. }
  887. VideoPortWritePortUchar(ulCRTCAddress, savSEQidx);
  888. #endif
  889. if (((ChipType & CL754x) || (ChipType & CL755x)) &&
  890. (Panel_Type == 1)) //myf20
  891. {
  892. ulFlags |= CAPS_DSTN_PANEL;
  893. }
  894. //myf16, end
  895. //ms1016, begin
  896. // if (HwDeviceExtension->DisplayType & (STN_LCD | TFT_LCD))
  897. // {
  898. // ulFlags |= CAPS_DSTN_PANEL;
  899. // }
  900. //ms1016, end
  901. if ((Panning_flag) && ((ChipType & CL754x) || (ChipType & CL755x)))
  902. {
  903. ulFlags |= CAPS_PANNING; //myf15
  904. }
  905. return(ulFlags);
  906. }
  907. //myf10, end
  908. USHORT
  909. CheckLCDSupportMode(
  910. PHW_DEVICE_EXTENSION HwDeviceExtension,
  911. ULONG i
  912. )
  913. /*++
  914. Routine Description:
  915. Determines if LCD support the modes.
  916. Arguments:
  917. HwDeviceExtension - Pointer to the miniport driver's device extension.
  918. Return Value:
  919. None.
  920. --*/
  921. {
  922. VP_STATUS status;
  923. VIDEO_X86_BIOS_ARGUMENTS biosArguments;
  924. // DbgBreakPoint();
  925. // biosArguments.Eax = 0x1202;
  926. // biosArguments.Ebx = 0x92; // set LCD & CRT turn on
  927. // status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  928. // VideoDebugPrint((1, "LCD & CRT all Turn ON\n"));
  929. // crus
  930. #ifdef INT10_MODE_SET
  931. VideoPortZeroMemory(&biosArguments, sizeof(VIDEO_X86_BIOS_ARGUMENTS));
  932. biosArguments.Eax = 0x1200 | ModesVGA[i].BiosModes.BiosModeCL542x;
  933. biosArguments.Ebx = 0xA0; // query video mode availability
  934. status = VideoPortInt10 (HwDeviceExtension, &biosArguments);
  935. if (status == NO_ERROR)
  936. {
  937. // crus
  938. if ((biosArguments.Eax & 0x00000800) && //bit3=1:support
  939. (HwDeviceExtension->ChipType != CL6245))
  940. return TRUE ;
  941. // crus
  942. else if ((biosArguments.Eax & 0x00000100) && //bit0=1:video support
  943. (HwDeviceExtension->ChipType == CL6245))
  944. return TRUE ;
  945. // end crus
  946. else
  947. {
  948. return FALSE ;
  949. }
  950. }
  951. else
  952. return FALSE ;
  953. // crus
  954. #endif
  955. } // end CheckLCDSupportMode()