dvi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /*
  2. * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.
  3. * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public
  6. * License as published by the Free Software Foundation;
  7. * either version 2, or (at your option) any later version.
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
  10. * the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. * A PARTICULAR PURPOSE.See the GNU General Public License
  12. * for more details.
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc.,
  16. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. #include <linux/via-core.h>
  19. #include <linux/via_i2c.h>
  20. #include "global.h"
  21. static void tmds_register_write(int index, u8 data);
  22. static int tmds_register_read(int index);
  23. static int tmds_register_read_bytes(int index, u8 *buff, int buff_len);
  24. static void __devinit dvi_get_panel_size_from_DDCv1(
  25. struct tmds_chip_information *tmds_chip,
  26. struct tmds_setting_information *tmds_setting);
  27. static void __devinit dvi_get_panel_size_from_DDCv2(
  28. struct tmds_chip_information *tmds_chip,
  29. struct tmds_setting_information *tmds_setting);
  30. static int viafb_dvi_query_EDID(void);
  31. static int check_tmds_chip(int device_id_subaddr, int device_id)
  32. {
  33. if (tmds_register_read(device_id_subaddr) == device_id)
  34. return OK;
  35. else
  36. return FAIL;
  37. }
  38. void __devinit viafb_init_dvi_size(struct tmds_chip_information *tmds_chip,
  39. struct tmds_setting_information *tmds_setting)
  40. {
  41. DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n");
  42. viafb_dvi_sense();
  43. switch (viafb_dvi_query_EDID()) {
  44. case 1:
  45. dvi_get_panel_size_from_DDCv1(tmds_chip, tmds_setting);
  46. break;
  47. case 2:
  48. dvi_get_panel_size_from_DDCv2(tmds_chip, tmds_setting);
  49. break;
  50. default:
  51. printk(KERN_WARNING "viafb_init_dvi_size: DVI panel size undetected!\n");
  52. break;
  53. }
  54. return;
  55. }
  56. int __devinit viafb_tmds_trasmitter_identify(void)
  57. {
  58. unsigned char sr2a = 0, sr1e = 0, sr3e = 0;
  59. /* Turn on ouputting pad */
  60. switch (viaparinfo->chip_info->gfx_chip_name) {
  61. case UNICHROME_K8M890:
  62. /*=* DFP Low Pad on *=*/
  63. sr2a = viafb_read_reg(VIASR, SR2A);
  64. viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1);
  65. break;
  66. case UNICHROME_P4M900:
  67. case UNICHROME_P4M890:
  68. /* DFP Low Pad on */
  69. sr2a = viafb_read_reg(VIASR, SR2A);
  70. viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1);
  71. /* DVP0 Pad on */
  72. sr1e = viafb_read_reg(VIASR, SR1E);
  73. viafb_write_reg_mask(SR1E, VIASR, 0xC0, BIT6 + BIT7);
  74. break;
  75. default:
  76. /* DVP0/DVP1 Pad on */
  77. sr1e = viafb_read_reg(VIASR, SR1E);
  78. viafb_write_reg_mask(SR1E, VIASR, 0xF0, BIT4 +
  79. BIT5 + BIT6 + BIT7);
  80. /* SR3E[1]Multi-function selection:
  81. 0 = Emulate I2C and DDC bus by GPIO2/3/4. */
  82. sr3e = viafb_read_reg(VIASR, SR3E);
  83. viafb_write_reg_mask(SR3E, VIASR, 0x0, BIT5);
  84. break;
  85. }
  86. /* Check for VT1632: */
  87. viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = VT1632_TMDS;
  88. viaparinfo->chip_info->
  89. tmds_chip_info.tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR;
  90. viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_PORT_31;
  91. if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) != FAIL) {
  92. /*
  93. * Currently only support 12bits,dual edge,add 24bits mode later
  94. */
  95. tmds_register_write(0x08, 0x3b);
  96. DEBUG_MSG(KERN_INFO "\n VT1632 TMDS ! \n");
  97. DEBUG_MSG(KERN_INFO "\n %2d",
  98. viaparinfo->chip_info->tmds_chip_info.tmds_chip_name);
  99. DEBUG_MSG(KERN_INFO "\n %2d",
  100. viaparinfo->chip_info->tmds_chip_info.i2c_port);
  101. return OK;
  102. } else {
  103. viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_PORT_2C;
  104. if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID)
  105. != FAIL) {
  106. tmds_register_write(0x08, 0x3b);
  107. DEBUG_MSG(KERN_INFO "\n VT1632 TMDS ! \n");
  108. DEBUG_MSG(KERN_INFO "\n %2d",
  109. viaparinfo->chip_info->
  110. tmds_chip_info.tmds_chip_name);
  111. DEBUG_MSG(KERN_INFO "\n %2d",
  112. viaparinfo->chip_info->
  113. tmds_chip_info.i2c_port);
  114. return OK;
  115. }
  116. }
  117. viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = INTEGRATED_TMDS;
  118. if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) &&
  119. ((viafb_display_hardware_layout == HW_LAYOUT_DVI_ONLY) ||
  120. (viafb_display_hardware_layout == HW_LAYOUT_LCD_DVI))) {
  121. DEBUG_MSG(KERN_INFO "\n Integrated TMDS ! \n");
  122. return OK;
  123. }
  124. switch (viaparinfo->chip_info->gfx_chip_name) {
  125. case UNICHROME_K8M890:
  126. viafb_write_reg(SR2A, VIASR, sr2a);
  127. break;
  128. case UNICHROME_P4M900:
  129. case UNICHROME_P4M890:
  130. viafb_write_reg(SR2A, VIASR, sr2a);
  131. viafb_write_reg(SR1E, VIASR, sr1e);
  132. break;
  133. default:
  134. viafb_write_reg(SR1E, VIASR, sr1e);
  135. viafb_write_reg(SR3E, VIASR, sr3e);
  136. break;
  137. }
  138. viaparinfo->chip_info->
  139. tmds_chip_info.tmds_chip_name = NON_TMDS_TRANSMITTER;
  140. viaparinfo->chip_info->tmds_chip_info.
  141. tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR;
  142. return FAIL;
  143. }
  144. static void tmds_register_write(int index, u8 data)
  145. {
  146. viafb_i2c_writebyte(viaparinfo->chip_info->tmds_chip_info.i2c_port,
  147. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr,
  148. index, data);
  149. }
  150. static int tmds_register_read(int index)
  151. {
  152. u8 data;
  153. viafb_i2c_readbyte(viaparinfo->chip_info->tmds_chip_info.i2c_port,
  154. (u8) viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr,
  155. (u8) index, &data);
  156. return data;
  157. }
  158. static int tmds_register_read_bytes(int index, u8 *buff, int buff_len)
  159. {
  160. viafb_i2c_readbytes(viaparinfo->chip_info->tmds_chip_info.i2c_port,
  161. (u8) viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr,
  162. (u8) index, buff, buff_len);
  163. return 0;
  164. }
  165. /* DVI Set Mode */
  166. void viafb_dvi_set_mode(struct VideoModeTable *mode, int mode_bpp,
  167. int set_iga)
  168. {
  169. struct VideoModeTable *rb_mode;
  170. struct crt_mode_table *pDviTiming;
  171. unsigned long desirePixelClock, maxPixelClock;
  172. pDviTiming = mode->crtc;
  173. desirePixelClock = pDviTiming->refresh_rate
  174. * pDviTiming->crtc.hor_total * pDviTiming->crtc.ver_total
  175. / 1000000;
  176. maxPixelClock = (unsigned long)viaparinfo->
  177. tmds_setting_info->max_pixel_clock;
  178. DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n");
  179. if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) {
  180. rb_mode = viafb_get_rb_mode(mode->crtc[0].crtc.hor_addr,
  181. mode->crtc[0].crtc.ver_addr);
  182. if (rb_mode) {
  183. mode = rb_mode;
  184. pDviTiming = rb_mode->crtc;
  185. }
  186. }
  187. viafb_fill_crtc_timing(pDviTiming, mode, mode_bpp / 8, set_iga);
  188. }
  189. /* Sense DVI Connector */
  190. int viafb_dvi_sense(void)
  191. {
  192. u8 RegSR1E = 0, RegSR3E = 0, RegCR6B = 0, RegCR91 = 0,
  193. RegCR93 = 0, RegCR9B = 0, data;
  194. int ret = false;
  195. DEBUG_MSG(KERN_INFO "viafb_dvi_sense!!\n");
  196. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
  197. /* DI1 Pad on */
  198. RegSR1E = viafb_read_reg(VIASR, SR1E);
  199. viafb_write_reg(SR1E, VIASR, RegSR1E | 0x30);
  200. /* CR6B[0]VCK Input Selection: 1 = External clock. */
  201. RegCR6B = viafb_read_reg(VIACR, CR6B);
  202. viafb_write_reg(CR6B, VIACR, RegCR6B | 0x08);
  203. /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off
  204. [0] Software Control Power Sequence */
  205. RegCR91 = viafb_read_reg(VIACR, CR91);
  206. viafb_write_reg(CR91, VIACR, 0x1D);
  207. /* CR93[7] DI1 Data Source Selection: 1 = DSP2.
  208. CR93[5] DI1 Clock Source: 1 = internal.
  209. CR93[4] DI1 Clock Polarity.
  210. CR93[3:1] DI1 Clock Adjust. CR93[0] DI1 enable */
  211. RegCR93 = viafb_read_reg(VIACR, CR93);
  212. viafb_write_reg(CR93, VIACR, 0x01);
  213. } else {
  214. /* DVP0/DVP1 Pad on */
  215. RegSR1E = viafb_read_reg(VIASR, SR1E);
  216. viafb_write_reg(SR1E, VIASR, RegSR1E | 0xF0);
  217. /* SR3E[1]Multi-function selection:
  218. 0 = Emulate I2C and DDC bus by GPIO2/3/4. */
  219. RegSR3E = viafb_read_reg(VIASR, SR3E);
  220. viafb_write_reg(SR3E, VIASR, RegSR3E & (~0x20));
  221. /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off
  222. [0] Software Control Power Sequence */
  223. RegCR91 = viafb_read_reg(VIACR, CR91);
  224. viafb_write_reg(CR91, VIACR, 0x1D);
  225. /*CR9B[4] DVP1 Data Source Selection: 1 = From secondary
  226. display.CR9B[2:0] DVP1 Clock Adjust */
  227. RegCR9B = viafb_read_reg(VIACR, CR9B);
  228. viafb_write_reg(CR9B, VIACR, 0x01);
  229. }
  230. data = (u8) tmds_register_read(0x09);
  231. if (data & 0x04)
  232. ret = true;
  233. if (ret == false) {
  234. if (viafb_dvi_query_EDID())
  235. ret = true;
  236. }
  237. /* Restore status */
  238. viafb_write_reg(SR1E, VIASR, RegSR1E);
  239. viafb_write_reg(CR91, VIACR, RegCR91);
  240. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
  241. viafb_write_reg(CR6B, VIACR, RegCR6B);
  242. viafb_write_reg(CR93, VIACR, RegCR93);
  243. } else {
  244. viafb_write_reg(SR3E, VIASR, RegSR3E);
  245. viafb_write_reg(CR9B, VIACR, RegCR9B);
  246. }
  247. return ret;
  248. }
  249. /* Query Flat Panel's EDID Table Version Through DVI Connector */
  250. static int viafb_dvi_query_EDID(void)
  251. {
  252. u8 data0, data1;
  253. int restore;
  254. DEBUG_MSG(KERN_INFO "viafb_dvi_query_EDID!!\n");
  255. restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr;
  256. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0;
  257. data0 = (u8) tmds_register_read(0x00);
  258. data1 = (u8) tmds_register_read(0x01);
  259. if ((data0 == 0) && (data1 == 0xFF)) {
  260. viaparinfo->chip_info->
  261. tmds_chip_info.tmds_chip_slave_addr = restore;
  262. return EDID_VERSION_1; /* Found EDID1 Table */
  263. }
  264. data0 = (u8) tmds_register_read(0x00);
  265. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore;
  266. if (data0 == 0x20)
  267. return EDID_VERSION_2; /* Found EDID2 Table */
  268. else
  269. return false;
  270. }
  271. /* Get Panel Size Using EDID1 Table */
  272. static void __devinit dvi_get_panel_size_from_DDCv1(
  273. struct tmds_chip_information *tmds_chip,
  274. struct tmds_setting_information *tmds_setting)
  275. {
  276. int i, max_h = 0, tmp, restore;
  277. unsigned char rData;
  278. unsigned char EDID_DATA[18];
  279. DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n");
  280. restore = tmds_chip->tmds_chip_slave_addr;
  281. tmds_chip->tmds_chip_slave_addr = 0xA0;
  282. rData = tmds_register_read(0x23);
  283. if (rData & 0x3C)
  284. max_h = 640;
  285. if (rData & 0xC0)
  286. max_h = 720;
  287. if (rData & 0x03)
  288. max_h = 800;
  289. rData = tmds_register_read(0x24);
  290. if (rData & 0xC0)
  291. max_h = 800;
  292. if (rData & 0x1E)
  293. max_h = 1024;
  294. if (rData & 0x01)
  295. max_h = 1280;
  296. for (i = 0x25; i < 0x6D; i++) {
  297. switch (i) {
  298. case 0x26:
  299. case 0x28:
  300. case 0x2A:
  301. case 0x2C:
  302. case 0x2E:
  303. case 0x30:
  304. case 0x32:
  305. case 0x34:
  306. rData = tmds_register_read(i);
  307. if (rData == 1)
  308. break;
  309. /* data = (data + 31) * 8 */
  310. tmp = (rData + 31) << 3;
  311. if (tmp > max_h)
  312. max_h = tmp;
  313. break;
  314. case 0x36:
  315. case 0x48:
  316. case 0x5A:
  317. case 0x6C:
  318. tmds_register_read_bytes(i, EDID_DATA, 10);
  319. if (!(EDID_DATA[0] || EDID_DATA[1])) {
  320. /* The first two byte must be zero. */
  321. if (EDID_DATA[3] == 0xFD) {
  322. /* To get max pixel clock. */
  323. tmds_setting->max_pixel_clock =
  324. EDID_DATA[9] * 10;
  325. }
  326. }
  327. break;
  328. default:
  329. break;
  330. }
  331. }
  332. tmds_setting->max_hres = max_h;
  333. switch (max_h) {
  334. case 640:
  335. tmds_setting->max_vres = 480;
  336. break;
  337. case 800:
  338. tmds_setting->max_vres = 600;
  339. break;
  340. case 1024:
  341. tmds_setting->max_vres = 768;
  342. break;
  343. case 1280:
  344. tmds_setting->max_vres = 1024;
  345. break;
  346. case 1400:
  347. tmds_setting->max_vres = 1050;
  348. break;
  349. case 1440:
  350. tmds_setting->max_vres = 1050;
  351. break;
  352. case 1600:
  353. tmds_setting->max_vres = 1200;
  354. break;
  355. case 1920:
  356. tmds_setting->max_vres = 1080;
  357. break;
  358. default:
  359. DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d ! "
  360. "set default panel size.\n", max_h);
  361. break;
  362. }
  363. DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n",
  364. tmds_setting->max_pixel_clock);
  365. tmds_chip->tmds_chip_slave_addr = restore;
  366. }
  367. /* Get Panel Size Using EDID2 Table */
  368. static void __devinit dvi_get_panel_size_from_DDCv2(
  369. struct tmds_chip_information *tmds_chip,
  370. struct tmds_setting_information *tmds_setting)
  371. {
  372. int restore;
  373. unsigned char R_Buffer[2];
  374. DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n");
  375. restore = tmds_chip->tmds_chip_slave_addr;
  376. tmds_chip->tmds_chip_slave_addr = 0xA2;
  377. /* Horizontal: 0x76, 0x77 */
  378. tmds_register_read_bytes(0x76, R_Buffer, 2);
  379. tmds_setting->max_hres = R_Buffer[0] + (R_Buffer[1] << 8);
  380. switch (tmds_setting->max_hres) {
  381. case 640:
  382. tmds_setting->max_vres = 480;
  383. break;
  384. case 800:
  385. tmds_setting->max_vres = 600;
  386. break;
  387. case 1024:
  388. tmds_setting->max_vres = 768;
  389. break;
  390. case 1280:
  391. tmds_setting->max_vres = 1024;
  392. break;
  393. case 1400:
  394. tmds_setting->max_vres = 1050;
  395. break;
  396. case 1440:
  397. tmds_setting->max_vres = 1050;
  398. break;
  399. case 1600:
  400. tmds_setting->max_vres = 1200;
  401. break;
  402. default:
  403. DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d! "
  404. "set default panel size.\n", tmds_setting->max_hres);
  405. break;
  406. }
  407. tmds_chip->tmds_chip_slave_addr = restore;
  408. }
  409. /* If Disable DVI, turn off pad */
  410. void viafb_dvi_disable(void)
  411. {
  412. if (viaparinfo->chip_info->
  413. tmds_chip_info.output_interface == INTERFACE_TMDS)
  414. /* Turn off TMDS power. */
  415. viafb_write_reg(CRD2, VIACR,
  416. viafb_read_reg(VIACR, CRD2) | 0x08);
  417. }
  418. static void dvi_patch_skew_dvp0(void)
  419. {
  420. /* Reset data driving first: */
  421. viafb_write_reg_mask(SR1B, VIASR, 0, BIT1);
  422. viafb_write_reg_mask(SR2A, VIASR, 0, BIT4);
  423. switch (viaparinfo->chip_info->gfx_chip_name) {
  424. case UNICHROME_P4M890:
  425. {
  426. if ((viaparinfo->tmds_setting_info->h_active == 1600) &&
  427. (viaparinfo->tmds_setting_info->v_active ==
  428. 1200))
  429. viafb_write_reg_mask(CR96, VIACR, 0x03,
  430. BIT0 + BIT1 + BIT2);
  431. else
  432. viafb_write_reg_mask(CR96, VIACR, 0x07,
  433. BIT0 + BIT1 + BIT2);
  434. break;
  435. }
  436. case UNICHROME_P4M900:
  437. {
  438. viafb_write_reg_mask(CR96, VIACR, 0x07,
  439. BIT0 + BIT1 + BIT2 + BIT3);
  440. viafb_write_reg_mask(SR1B, VIASR, 0x02, BIT1);
  441. viafb_write_reg_mask(SR2A, VIASR, 0x10, BIT4);
  442. break;
  443. }
  444. default:
  445. {
  446. break;
  447. }
  448. }
  449. }
  450. static void dvi_patch_skew_dvp_low(void)
  451. {
  452. switch (viaparinfo->chip_info->gfx_chip_name) {
  453. case UNICHROME_K8M890:
  454. {
  455. viafb_write_reg_mask(CR99, VIACR, 0x03, BIT0 + BIT1);
  456. break;
  457. }
  458. case UNICHROME_P4M900:
  459. {
  460. viafb_write_reg_mask(CR99, VIACR, 0x08,
  461. BIT0 + BIT1 + BIT2 + BIT3);
  462. break;
  463. }
  464. case UNICHROME_P4M890:
  465. {
  466. viafb_write_reg_mask(CR99, VIACR, 0x0F,
  467. BIT0 + BIT1 + BIT2 + BIT3);
  468. break;
  469. }
  470. default:
  471. {
  472. break;
  473. }
  474. }
  475. }
  476. /* If Enable DVI, turn off pad */
  477. void viafb_dvi_enable(void)
  478. {
  479. u8 data;
  480. switch (viaparinfo->chip_info->tmds_chip_info.output_interface) {
  481. case INTERFACE_DVP0:
  482. viafb_write_reg_mask(CR6B, VIACR, 0x01, BIT0);
  483. viafb_write_reg_mask(CR6C, VIACR, 0x21, BIT0 + BIT5);
  484. dvi_patch_skew_dvp0();
  485. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
  486. tmds_register_write(0x88, 0x3b);
  487. else
  488. /*clear CR91[5] to direct on display period
  489. in the secondary diplay path */
  490. via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
  491. break;
  492. case INTERFACE_DVP1:
  493. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
  494. viafb_write_reg_mask(CR93, VIACR, 0x21, BIT0 + BIT5);
  495. /*fix dvi cann't be enabled with MB VT5718C4 - Al Zhang */
  496. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
  497. tmds_register_write(0x88, 0x3b);
  498. else
  499. /*clear CR91[5] to direct on display period
  500. in the secondary diplay path */
  501. via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
  502. /*fix DVI cannot enable on EPIA-M board */
  503. if (viafb_platform_epia_dvi == 1) {
  504. viafb_write_reg_mask(CR91, VIACR, 0x1f, 0x1f);
  505. viafb_write_reg_mask(CR88, VIACR, 0x00, BIT6 + BIT0);
  506. if (viafb_bus_width == 24) {
  507. if (viafb_device_lcd_dualedge == 1)
  508. data = 0x3F;
  509. else
  510. data = 0x37;
  511. viafb_i2c_writebyte(viaparinfo->chip_info->
  512. tmds_chip_info.i2c_port,
  513. viaparinfo->chip_info->
  514. tmds_chip_info.tmds_chip_slave_addr,
  515. 0x08, data);
  516. }
  517. }
  518. break;
  519. case INTERFACE_DFP_HIGH:
  520. if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266)
  521. via_write_reg_mask(VIACR, CR97, 0x03, 0x03);
  522. via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
  523. break;
  524. case INTERFACE_DFP_LOW:
  525. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
  526. break;
  527. dvi_patch_skew_dvp_low();
  528. via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
  529. break;
  530. case INTERFACE_TMDS:
  531. /* Turn on Display period in the panel path. */
  532. viafb_write_reg_mask(CR91, VIACR, 0, BIT7);
  533. /* Turn on TMDS power. */
  534. viafb_write_reg_mask(CRD2, VIACR, 0, BIT3);
  535. break;
  536. }
  537. if (viaparinfo->tmds_setting_info->iga_path == IGA2) {
  538. /* Disable LCD Scaling */
  539. viafb_write_reg_mask(CR79, VIACR, 0x00, BIT0);
  540. }
  541. }