PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/edk2/Clover/Trash/IntelGmaDxe/VideoModes.c

https://gitlab.com/envieidoc/Clover
C | 694 lines | 574 code | 21 blank | 99 comment | 0 complexity | 4339ad2da2d119625941e4cfab21a86d MD5 | raw file
  1. /*++
  2. Copyright (c) 2006 - 2010 Intel Corporation. All rights reserved
  3. This program and the accompanying materials
  4. are licensed and made available under the terms and conditions of the BSD License
  5. which accompanies this distribution. The full text of the license may be found at
  6. http://opensource.org/licenses/bsd-license.php.
  7. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  9. Module Name:
  10. VideoModes.c
  11. Abstract:
  12. Intel Video Controller Driver
  13. Revision History
  14. --*/
  15. #include "Gop.h"
  16. //
  17. // MODE 0 - Turns off display controller.
  18. //
  19. MODE_FORMAT DS_0_0_0_0[] = {
  20. {
  21. DPLLADivisor,
  22. 0x00000000,
  23. FALSE
  24. },
  25. {
  26. DPLLAControl,
  27. 0x00000000,
  28. FALSE
  29. },
  30. {
  31. HTOTAL_A,
  32. 0x00000000,
  33. FALSE
  34. },
  35. {
  36. HBLANK_A,
  37. 0x00000000,
  38. FALSE
  39. },
  40. {
  41. HSYNC_A,
  42. 0x00000000,
  43. FALSE
  44. },
  45. {
  46. VTOTAL_A,
  47. 0x00000000,
  48. FALSE
  49. },
  50. {
  51. VBLANK_A,
  52. 0x00000000,
  53. FALSE
  54. },
  55. {
  56. VSYNC_A,
  57. 0x00000000,
  58. FALSE
  59. },
  60. {
  61. PIPESRC_A,
  62. 0x00000000,
  63. FALSE
  64. },
  65. {
  66. BDRCOLRPTRN_A,
  67. 0x00000000,
  68. FALSE
  69. },
  70. {
  71. ColorChannel_Red_A,
  72. 0x00000000,
  73. FALSE
  74. },
  75. {
  76. ColorChannel_Grn_A,
  77. 0x00000000,
  78. FALSE
  79. },
  80. {
  81. ColorChannel_Blue_A,
  82. 0x00000000,
  83. FALSE
  84. },
  85. {
  86. PIPEASTAT,
  87. 0x00000000,
  88. FALSE
  89. },
  90. {
  91. DSPASTRIDE,
  92. 0x00000000,
  93. FALSE
  94. },
  95. {
  96. ADPA,
  97. 0x00000000,
  98. FALSE
  99. },
  100. };
  101. //
  102. // Make sure there are NUM_DS_ENTRIES in the structure
  103. //
  104. //C_ASSERT(sizeof (DS_0_0_0_0) == NUM_DS_ENTRIES * sizeof (MODE_FORMAT));
  105. //
  106. // 640x480 Modes 60Hz
  107. // MODE 640x480x32x60
  108. //
  109. MODE_FORMAT DS_640_480_32_60[] = {
  110. {
  111. HTOTAL_A,
  112. 0x031f027f,
  113. FALSE
  114. },
  115. {
  116. HBLANK_A,
  117. 0x03170287,
  118. FALSE
  119. },
  120. {
  121. HSYNC_A,
  122. 0x02ef028f,
  123. FALSE
  124. },
  125. {
  126. VTOTAL_A,
  127. 0x020c01df,
  128. FALSE
  129. },
  130. {
  131. VBLANK_A,
  132. 0x020401e7,
  133. FALSE
  134. },
  135. {
  136. VSYNC_A,
  137. 0x01eb01e9,
  138. FALSE
  139. },
  140. {
  141. PIPESRC_A,
  142. 0x027f01df,
  143. FALSE
  144. },
  145. {
  146. BDRCOLRPTRN_A,
  147. 0x00000000,
  148. FALSE
  149. },
  150. {
  151. ColorChannel_Red_A,
  152. 0x00000000,
  153. FALSE
  154. },
  155. {
  156. ColorChannel_Grn_A,
  157. 0x00000000,
  158. FALSE
  159. },
  160. {
  161. ColorChannel_Blue_A,
  162. 0x00000000,
  163. FALSE
  164. },
  165. {
  166. DPLLADivisor,
  167. 0x00200067,
  168. FALSE
  169. },
  170. {
  171. DPLLAControl,
  172. 0x94400000,
  173. FALSE
  174. },
  175. {
  176. PIPEASTAT,
  177. 0x00000203,
  178. FALSE
  179. },
  180. {
  181. DSPASTRIDE,
  182. 0x00000a00,
  183. FALSE
  184. },
  185. {
  186. ADPA,
  187. 0x80000000,
  188. FALSE
  189. },
  190. };
  191. //C_ASSERT(sizeof (DS_640_480_32_60) == NUM_DS_ENTRIES * sizeof (MODE_FORMAT));
  192. //
  193. // 800x600 Modes 60Hz
  194. // MODE 800x600x32x60
  195. //
  196. MODE_FORMAT DS_800_600_32_60[] = {
  197. {
  198. HTOTAL_A,
  199. 0x041f031f,
  200. FALSE
  201. },
  202. {
  203. HBLANK_A,
  204. 0x041f031f,
  205. FALSE
  206. },
  207. {
  208. HSYNC_A,
  209. 0x03c70347,
  210. FALSE
  211. },
  212. {
  213. VTOTAL_A,
  214. 0x02730257,
  215. FALSE
  216. },
  217. {
  218. VBLANK_A,
  219. 0x02730257,
  220. FALSE
  221. },
  222. {
  223. VSYNC_A,
  224. 0x025c0258,
  225. FALSE
  226. },
  227. {
  228. PIPESRC_A,
  229. 0x031f0257,
  230. FALSE
  231. },
  232. {
  233. BDRCOLRPTRN_A,
  234. 0x00000000,
  235. FALSE
  236. },
  237. {
  238. ColorChannel_Red_A,
  239. 0x00000000,
  240. FALSE
  241. },
  242. {
  243. ColorChannel_Grn_A,
  244. 0x00000000,
  245. FALSE
  246. },
  247. {
  248. ColorChannel_Blue_A,
  249. 0x00000000,
  250. FALSE
  251. },
  252. {
  253. DPLLADivisor,
  254. 0x0020007B,
  255. FALSE
  256. },
  257. {
  258. DPLLAControl,
  259. 0x94100000,
  260. FALSE
  261. },
  262. {
  263. PIPEASTAT,
  264. 0x00000203,
  265. FALSE
  266. },
  267. {
  268. DSPASTRIDE,
  269. 0x00000c80,
  270. FALSE
  271. },
  272. {
  273. ADPA,
  274. 0x80000018,
  275. FALSE
  276. },
  277. };
  278. //C_ASSERT(sizeof (DS_800_600_32_60) == NUM_DS_ENTRIES * sizeof (MODE_FORMAT));
  279. //
  280. // 1024x768 Modes 60Hz
  281. // MODE 1024x768x32x60
  282. //
  283. MODE_FORMAT DS_1024_768_32_60[] = {
  284. {
  285. HTOTAL_A,
  286. 0x053F03FF,
  287. FALSE
  288. },
  289. {
  290. HBLANK_A,
  291. 0x053F03FF,
  292. FALSE
  293. },
  294. {
  295. HSYNC_A,
  296. 0x049F0417,
  297. FALSE
  298. },
  299. {
  300. VTOTAL_A,
  301. 0x032502FF,
  302. FALSE
  303. },
  304. {
  305. VBLANK_A,
  306. 0x032502FF,
  307. FALSE
  308. },
  309. {
  310. VSYNC_A,
  311. 0x03080302,
  312. FALSE
  313. },
  314. {
  315. PIPESRC_A,
  316. 0x03FF02FF,
  317. FALSE
  318. },
  319. {
  320. BDRCOLRPTRN_A,
  321. 0x00000000,
  322. FALSE
  323. },
  324. {
  325. ColorChannel_Red_A,
  326. 0x00000000,
  327. FALSE
  328. },
  329. {
  330. ColorChannel_Grn_A,
  331. 0x00000000,
  332. FALSE
  333. },
  334. {
  335. ColorChannel_Blue_A,
  336. 0x00000000,
  337. FALSE
  338. },
  339. {
  340. DPLLADivisor,
  341. 0x0010006A,
  342. FALSE
  343. },
  344. {
  345. DPLLAControl,
  346. 0x94040000,
  347. FALSE
  348. },
  349. {
  350. PIPEASTAT,
  351. 0x00000203,
  352. FALSE
  353. },
  354. {
  355. DSPASTRIDE,
  356. 0x00001000,
  357. FALSE
  358. },
  359. {
  360. ADPA,
  361. 0x80000000,
  362. FALSE
  363. },
  364. };
  365. //C_ASSERT(sizeof (DS_1024_768_32_60) == NUM_DS_ENTRIES * sizeof (MODE_FORMAT));
  366. //
  367. // Generic shutdown controller; this is used to turn off the controller
  368. // before changing the mode. These must be done in this order. The order
  369. // in which these entries appear in the table is the order in which the
  370. // values are written to the h/w.
  371. //
  372. MODE_FORMAT mDISPLAY_SHUTDOWN[] = {
  373. {
  374. DSPACNTR,
  375. 0x00000000,
  376. FALSE
  377. },
  378. //
  379. // Turn off display plane A
  380. //
  381. {
  382. ADPA,
  383. 0x00000000,
  384. FALSE
  385. },
  386. //
  387. // Turn off port (disable sync signals)
  388. //
  389. {
  390. PIPEACONF,
  391. 0x00000000,
  392. FALSE
  393. },
  394. //
  395. // Shutdown pipe
  396. //
  397. {
  398. VGACNTRL,
  399. 0x00000000,
  400. FALSE
  401. },
  402. //
  403. // Turn off VGA display register
  404. //
  405. {
  406. DPLLAControl,
  407. 0x00000000,
  408. FALSE
  409. },
  410. //
  411. // Turn off PLL
  412. //
  413. {
  414. PGTBL_CTL,
  415. 0x00000000,
  416. FALSE
  417. },
  418. //
  419. // { PGTBL_CTL, 0x00000000, TRUE },
  420. //
  421. };
  422. UINT16 mNUM_SHUTDOWN_ENTRIES = sizeof (mDISPLAY_SHUTDOWN) / sizeof (mDISPLAY_SHUTDOWN[0]);
  423. //
  424. // Generic start-up controller; This is used to turn on the controller
  425. // before changing the mode. These must be done in this order. The order
  426. // in which these entries appear in the table is the order in which the
  427. // values are written to the h/w.
  428. //
  429. MODE_FORMAT mDISPLAY_STARTUP[] = {
  430. {
  431. PIPEACONF,
  432. 0x80000000,
  433. FALSE
  434. },
  435. //
  436. // Turn on the display pipe
  437. //
  438. {
  439. VGACNTRL,
  440. 0x80100000,
  441. FALSE
  442. },
  443. //
  444. // 8-bit DAC, disable VGA
  445. //
  446. {
  447. DSPACNTR,
  448. 0x98000000,
  449. FALSE
  450. },
  451. //
  452. // Enable plane A & set x:8:8:8 format
  453. //
  454. {
  455. DSPABASE,
  456. 0x00000000,
  457. FALSE
  458. },
  459. //
  460. // Display starts at base address of GTT
  461. //
  462. };
  463. UINT16 mNUM_STARTUP_ENTRIES = sizeof (mDISPLAY_STARTUP) / sizeof (mDISPLAY_STARTUP[0]);
  464. MODE_FORMAT LVDS_SHUTDOWN[] = {
  465. {PP_CONTROL , 0xabcd0000, FALSE},
  466. {PIPEBSTAT , 0 , FALSE},
  467. {BLC_PWM_CTL , 0 , FALSE},
  468. {PFIT_CONTROL , 0 , FALSE},
  469. {LVDSPC , 0 , FALSE},
  470. {DSPBCNTR , 0 , TRUE},
  471. {DSPBLINOFFSET , 0 , TRUE},
  472. {DSPBSTRIDE , 0 , TRUE},
  473. {DSPBSIZE , 0 , TRUE},
  474. {VGACNTRL , 0 , FALSE},
  475. {PIPEBCONF , 0 , TRUE},
  476. {CRCCtrlColorBB, 0 , FALSE},
  477. {CRCCtrlColorBG, 0 , FALSE},
  478. {CRCCtrlColorBR, 0 , FALSE},
  479. {BCLRPAT_B , 0 , FALSE},
  480. {PIPEBSRC , 0 , FALSE},
  481. {DPLLB_CTRL , 0 , FALSE},
  482. {FPB0 , 0 , FALSE},
  483. {VSYNC_B , 0 , FALSE},
  484. {VBLANK_B , 0 , FALSE},
  485. {VTOTAL_B , 0 , FALSE},
  486. {HSYNC_B , 0 , FALSE},
  487. {HBLANK_B , 0 , FALSE},
  488. {HTOTAL_B , 0 , FALSE},
  489. {PP_DIVISOR , 0 , FALSE},
  490. {PP_OFF_DELAYS , 0 , FALSE},
  491. {PP_ON_DELAYS , 0 , TRUE},
  492. {PP_CONTROL , 0 , FALSE},
  493. {0,0,0}
  494. };
  495. MODE_FORMAT LVDS_MODE_DATA_640_480[] = {
  496. {PP_CONTROL , 0xabcd0000, FALSE},
  497. {PP_ON_DELAYS , 0x25807d0 , TRUE},
  498. {PP_OFF_DELAYS , 0x1f407d0 , FALSE},
  499. {PP_DIVISOR , 0x209d05 , FALSE},
  500. {HTOTAL_B , 0x4af03ff , FALSE},
  501. {HBLANK_B , 0x4af03ff , FALSE},
  502. {HSYNC_B , 0x44f042f , FALSE},
  503. {VTOTAL_B , 0x26e0257 , FALSE},
  504. {VBLANK_B , 0x26e0257 , FALSE},
  505. {VSYNC_B , 0x260025a , FALSE},
  506. {FPB0 , 0x100067 , FALSE},
  507. {DPLLB_CTRL , 0x98040000, FALSE},
  508. {PIPEBSRC , 0x27f01df , FALSE},
  509. {BCLRPAT_B , 0x0 , FALSE},
  510. {CRCCtrlColorBR, 0x0 , FALSE},
  511. {CRCCtrlColorBG, 0x0 , FALSE},
  512. {CRCCtrlColorBB, 0x0 , FALSE},
  513. {PIPEBCONF , 0x80000000, TRUE },
  514. {VGACNTRL , 0xa2c4008e, FALSE},
  515. {DSPBSIZE , 0x1df027f , TRUE },
  516. {DSPBSTRIDE , 0xa00 , TRUE },
  517. {DSPBLINOFFSET , 0x0 , TRUE },
  518. {DSPBCNTR , 0x99000000, TRUE },
  519. {LVDSPC , 0xc0300300, FALSE},
  520. {PFIT_CONTROL , 0x80002668, FALSE},
  521. {BLC_PWM_CTL , 0x65ed65ed, FALSE},
  522. {PIPEBSTAT , 0x00020202, FALSE},
  523. {PP_CONTROL , 0x00000001, FALSE},
  524. {0,0,0}
  525. };
  526. MODE_FORMAT LVDS_MODE_DATA_800_600[] = {
  527. {PP_CONTROL , 0xabcd0000, FALSE},
  528. {PP_ON_DELAYS , 0x25807d0 , TRUE },
  529. {PP_OFF_DELAYS , 0x1f407d0 , FALSE},
  530. {PP_DIVISOR , 0x209d05 , FALSE},
  531. {HTOTAL_B , 0x4af03ff , FALSE},
  532. {HBLANK_B , 0x4af03ff , FALSE},
  533. {HSYNC_B , 0x44f042f , FALSE},
  534. {VTOTAL_B , 0x26e0257 , FALSE},
  535. {VBLANK_B , 0x26e0257 , FALSE},
  536. {VSYNC_B , 0x260025a , FALSE},
  537. {FPB0 , 0x100067 , FALSE},
  538. {DPLLB_CTRL , 0x98040000, FALSE},
  539. {PIPEBSRC , 0x31f0257 , FALSE},
  540. {BCLRPAT_B , 0x0 , FALSE},
  541. {CRCCtrlColorBR, 0x0 , FALSE},
  542. {CRCCtrlColorBG, 0x0 , FALSE},
  543. {CRCCtrlColorBB, 0x0 , FALSE},
  544. {PIPEBCONF , 0x80000000, TRUE },
  545. {VGACNTRL , 0xa2c4008e, FALSE},
  546. {DSPBSIZE , 0x257031f , TRUE },
  547. {DSPBSTRIDE , 0xc80 , TRUE },
  548. {DSPBLINOFFSET , 0x0 , TRUE },
  549. {DSPBCNTR , 0x99000000, TRUE },
  550. {LVDSPC , 0xc0300300, FALSE},
  551. {PFIT_CONTROL , 0x80002668, FALSE},
  552. {BLC_PWM_CTL , 0x65ed65ed, FALSE},
  553. {PIPEBSTAT , 0x00020202, FALSE},
  554. {PP_CONTROL , 0x00000001, FALSE},
  555. {0,0,0}
  556. };
  557. MODE_FORMAT LVDS_MODE_DATA_1024_768[] = {
  558. {PP_CONTROL , 0xabcd0000, FALSE},
  559. {PP_ON_DELAYS , 0x25807d0 , TRUE},
  560. {PP_OFF_DELAYS , 0x1f407d0 , FALSE},
  561. {PP_DIVISOR , 0x209d05 , FALSE},
  562. {HTOTAL_B , 0x4af03ff , FALSE},
  563. {HBLANK_B , 0x4af03ff , FALSE},
  564. {HSYNC_B , 0x44f042f , FALSE},
  565. {VTOTAL_B , 0x26e0257 , FALSE},
  566. {VBLANK_B , 0x26e0257 , FALSE},
  567. {VSYNC_B , 0x260025a , FALSE},
  568. {FPB0 , 0x100067 , FALSE},
  569. {DPLLB_CTRL , 0x98040000, FALSE},
  570. {PIPEBSRC , 0x3ff02fF , FALSE},
  571. {BCLRPAT_B , 0x0 , FALSE},
  572. {CRCCtrlColorBR, 0x0 , FALSE},
  573. {CRCCtrlColorBG, 0x0 , FALSE},
  574. {CRCCtrlColorBB, 0x0 , FALSE},
  575. {PIPEBCONF , 0x80000000, TRUE },
  576. {VGACNTRL , 0xa2c4008e, FALSE},
  577. {DSPBSIZE , 0x25f03ff , TRUE },
  578. {DSPBSTRIDE , 0x1000 , TRUE },
  579. {DSPBLINOFFSET , 0x0 , TRUE },
  580. {DSPBCNTR , 0x99000000, TRUE },
  581. {LVDSPC , 0xc0300300, FALSE},
  582. {PFIT_CONTROL , 0x80002668, FALSE},
  583. {BLC_PWM_CTL , 0x65ed65ed, FALSE},
  584. {PIPEBSTAT , 0x00020202, FALSE},
  585. {PP_CONTROL , 0x00000001, FALSE},
  586. {0,0,0}
  587. };
  588. MODE_FORMAT LVDS_MODE_DATA_0_0[] = {
  589. {PP_CONTROL , 0xabcd0000, FALSE},
  590. {PP_ON_DELAYS , 0, FALSE},
  591. {PP_OFF_DELAYS , 0, FALSE},
  592. {PP_DIVISOR , 0, FALSE},
  593. {HTOTAL_B , 0, FALSE},
  594. {HBLANK_B , 0, FALSE},
  595. {HSYNC_B , 0, FALSE},
  596. {VTOTAL_B , 0, FALSE},
  597. {VBLANK_B , 0, FALSE},
  598. {VSYNC_B , 0, FALSE},
  599. {FPB0 , 0, FALSE},
  600. {DPLLB_CTRL , 0, FALSE},
  601. {PIPEBSRC , 0, FALSE},
  602. {BCLRPAT_B , 0, FALSE},
  603. {CRCCtrlColorBR, 0, FALSE},
  604. {CRCCtrlColorBG, 0, FALSE},
  605. {CRCCtrlColorBB, 0, FALSE},
  606. {PIPEBCONF , 0, FALSE},
  607. {VGACNTRL , 0, FALSE},
  608. {DSPBSIZE , 0, FALSE},
  609. {DSPBSTRIDE , 0, FALSE},
  610. {DSPBLINOFFSET , 0, FALSE},
  611. {DSPBCNTR , 0, FALSE},
  612. {LVDSPC , 0, FALSE},
  613. {PFIT_CONTROL , 0, FALSE},
  614. {BLC_PWM_CTL , 0, FALSE},
  615. {PIPEBSTAT , 0, FALSE},
  616. {PP_CONTROL , 0, FALSE},
  617. {0,0,0}
  618. };
  619. INTEL_VIDEO_MODES mVideoModes[] = {
  620. {
  621. 0,
  622. 0,
  623. 0,
  624. 0,
  625. &DS_0_0_0_0[0],
  626. &LVDS_MODE_DATA_0_0[0]
  627. },
  628. //
  629. // Mode #0: turns off monitor
  630. //
  631. {
  632. 640,
  633. 480,
  634. 32,
  635. 60,
  636. &DS_640_480_32_60[0],
  637. &LVDS_MODE_DATA_640_480[0]
  638. },
  639. //
  640. // Mode #1: sets 640x480x32x60
  641. //
  642. {
  643. 800,
  644. 600,
  645. 32,
  646. 60,
  647. &DS_800_600_32_60[0],
  648. &LVDS_MODE_DATA_800_600[0]
  649. },
  650. //
  651. // Mode #2: sets 800x600x32x60
  652. //
  653. {
  654. 1024,
  655. 768,
  656. 32,
  657. 60,
  658. &DS_1024_768_32_60[0],
  659. &LVDS_MODE_DATA_1024_768[0]
  660. },
  661. //
  662. // Mode #3: sets 1024x768x32x60
  663. //
  664. };