dvi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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->clk / 1000000;
  174. maxPixelClock = (unsigned long)viaparinfo->
  175. tmds_setting_info->max_pixel_clock;
  176. DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n");
  177. if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) {
  178. rb_mode = viafb_get_rb_mode(mode->crtc[0].crtc.hor_addr,
  179. mode->crtc[0].crtc.ver_addr);
  180. if (rb_mode) {
  181. mode = rb_mode;
  182. pDviTiming = rb_mode->crtc;
  183. }
  184. }
  185. viafb_fill_crtc_timing(pDviTiming, mode, mode_bpp / 8, set_iga);
  186. }
  187. /* Sense DVI Connector */
  188. int viafb_dvi_sense(void)
  189. {
  190. u8 RegSR1E = 0, RegSR3E = 0, RegCR6B = 0, RegCR91 = 0,
  191. RegCR93 = 0, RegCR9B = 0, data;
  192. int ret = false;
  193. DEBUG_MSG(KERN_INFO "viafb_dvi_sense!!\n");
  194. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
  195. /* DI1 Pad on */
  196. RegSR1E = viafb_read_reg(VIASR, SR1E);
  197. viafb_write_reg(SR1E, VIASR, RegSR1E | 0x30);
  198. /* CR6B[0]VCK Input Selection: 1 = External clock. */
  199. RegCR6B = viafb_read_reg(VIACR, CR6B);
  200. viafb_write_reg(CR6B, VIACR, RegCR6B | 0x08);
  201. /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off
  202. [0] Software Control Power Sequence */
  203. RegCR91 = viafb_read_reg(VIACR, CR91);
  204. viafb_write_reg(CR91, VIACR, 0x1D);
  205. /* CR93[7] DI1 Data Source Selection: 1 = DSP2.
  206. CR93[5] DI1 Clock Source: 1 = internal.
  207. CR93[4] DI1 Clock Polarity.
  208. CR93[3:1] DI1 Clock Adjust. CR93[0] DI1 enable */
  209. RegCR93 = viafb_read_reg(VIACR, CR93);
  210. viafb_write_reg(CR93, VIACR, 0x01);
  211. } else {
  212. /* DVP0/DVP1 Pad on */
  213. RegSR1E = viafb_read_reg(VIASR, SR1E);
  214. viafb_write_reg(SR1E, VIASR, RegSR1E | 0xF0);
  215. /* SR3E[1]Multi-function selection:
  216. 0 = Emulate I2C and DDC bus by GPIO2/3/4. */
  217. RegSR3E = viafb_read_reg(VIASR, SR3E);
  218. viafb_write_reg(SR3E, VIASR, RegSR3E & (~0x20));
  219. /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off
  220. [0] Software Control Power Sequence */
  221. RegCR91 = viafb_read_reg(VIACR, CR91);
  222. viafb_write_reg(CR91, VIACR, 0x1D);
  223. /*CR9B[4] DVP1 Data Source Selection: 1 = From secondary
  224. display.CR9B[2:0] DVP1 Clock Adjust */
  225. RegCR9B = viafb_read_reg(VIACR, CR9B);
  226. viafb_write_reg(CR9B, VIACR, 0x01);
  227. }
  228. data = (u8) tmds_register_read(0x09);
  229. if (data & 0x04)
  230. ret = true;
  231. if (ret == false) {
  232. if (viafb_dvi_query_EDID())
  233. ret = true;
  234. }
  235. /* Restore status */
  236. viafb_write_reg(SR1E, VIASR, RegSR1E);
  237. viafb_write_reg(CR91, VIACR, RegCR91);
  238. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
  239. viafb_write_reg(CR6B, VIACR, RegCR6B);
  240. viafb_write_reg(CR93, VIACR, RegCR93);
  241. } else {
  242. viafb_write_reg(SR3E, VIASR, RegSR3E);
  243. viafb_write_reg(CR9B, VIACR, RegCR9B);
  244. }
  245. return ret;
  246. }
  247. /* Query Flat Panel's EDID Table Version Through DVI Connector */
  248. static int viafb_dvi_query_EDID(void)
  249. {
  250. u8 data0, data1;
  251. int restore;
  252. DEBUG_MSG(KERN_INFO "viafb_dvi_query_EDID!!\n");
  253. restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr;
  254. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0;
  255. data0 = (u8) tmds_register_read(0x00);
  256. data1 = (u8) tmds_register_read(0x01);
  257. if ((data0 == 0) && (data1 == 0xFF)) {
  258. viaparinfo->chip_info->
  259. tmds_chip_info.tmds_chip_slave_addr = restore;
  260. return EDID_VERSION_1; /* Found EDID1 Table */
  261. }
  262. data0 = (u8) tmds_register_read(0x00);
  263. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore;
  264. if (data0 == 0x20)
  265. return EDID_VERSION_2; /* Found EDID2 Table */
  266. else
  267. return false;
  268. }
  269. /* Get Panel Size Using EDID1 Table */
  270. static void __devinit dvi_get_panel_size_from_DDCv1(
  271. struct tmds_chip_information *tmds_chip,
  272. struct tmds_setting_information *tmds_setting)
  273. {
  274. int i, max_h = 0, tmp, restore;
  275. unsigned char rData;
  276. unsigned char EDID_DATA[18];
  277. DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n");
  278. restore = tmds_chip->tmds_chip_slave_addr;
  279. tmds_chip->tmds_chip_slave_addr = 0xA0;
  280. rData = tmds_register_read(0x23);
  281. if (rData & 0x3C)
  282. max_h = 640;
  283. if (rData & 0xC0)
  284. max_h = 720;
  285. if (rData & 0x03)
  286. max_h = 800;
  287. rData = tmds_register_read(0x24);
  288. if (rData & 0xC0)
  289. max_h = 800;
  290. if (rData & 0x1E)
  291. max_h = 1024;
  292. if (rData & 0x01)
  293. max_h = 1280;
  294. for (i = 0x25; i < 0x6D; i++) {
  295. switch (i) {
  296. case 0x26:
  297. case 0x28:
  298. case 0x2A:
  299. case 0x2C:
  300. case 0x2E:
  301. case 0x30:
  302. case 0x32:
  303. case 0x34:
  304. rData = tmds_register_read(i);
  305. if (rData == 1)
  306. break;
  307. /* data = (data + 31) * 8 */
  308. tmp = (rData + 31) << 3;
  309. if (tmp > max_h)
  310. max_h = tmp;
  311. break;
  312. case 0x36:
  313. case 0x48:
  314. case 0x5A:
  315. case 0x6C:
  316. tmds_register_read_bytes(i, EDID_DATA, 10);
  317. if (!(EDID_DATA[0] || EDID_DATA[1])) {
  318. /* The first two byte must be zero. */
  319. if (EDID_DATA[3] == 0xFD) {
  320. /* To get max pixel clock. */
  321. tmds_setting->max_pixel_clock =
  322. EDID_DATA[9] * 10;
  323. }
  324. }
  325. break;
  326. default:
  327. break;
  328. }
  329. }
  330. tmds_setting->max_hres = max_h;
  331. switch (max_h) {
  332. case 640:
  333. tmds_setting->max_vres = 480;
  334. break;
  335. case 800:
  336. tmds_setting->max_vres = 600;
  337. break;
  338. case 1024:
  339. tmds_setting->max_vres = 768;
  340. break;
  341. case 1280:
  342. tmds_setting->max_vres = 1024;
  343. break;
  344. case 1400:
  345. tmds_setting->max_vres = 1050;
  346. break;
  347. case 1440:
  348. tmds_setting->max_vres = 1050;
  349. break;
  350. case 1600:
  351. tmds_setting->max_vres = 1200;
  352. break;
  353. case 1920:
  354. tmds_setting->max_vres = 1080;
  355. break;
  356. default:
  357. DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d ! "
  358. "set default panel size.\n", max_h);
  359. break;
  360. }
  361. DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n",
  362. tmds_setting->max_pixel_clock);
  363. tmds_chip->tmds_chip_slave_addr = restore;
  364. }
  365. /* Get Panel Size Using EDID2 Table */
  366. static void __devinit dvi_get_panel_size_from_DDCv2(
  367. struct tmds_chip_information *tmds_chip,
  368. struct tmds_setting_information *tmds_setting)
  369. {
  370. int restore;
  371. unsigned char R_Buffer[2];
  372. DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n");
  373. restore = tmds_chip->tmds_chip_slave_addr;
  374. tmds_chip->tmds_chip_slave_addr = 0xA2;
  375. /* Horizontal: 0x76, 0x77 */
  376. tmds_register_read_bytes(0x76, R_Buffer, 2);
  377. tmds_setting->max_hres = R_Buffer[0] + (R_Buffer[1] << 8);
  378. switch (tmds_setting->max_hres) {
  379. case 640:
  380. tmds_setting->max_vres = 480;
  381. break;
  382. case 800:
  383. tmds_setting->max_vres = 600;
  384. break;
  385. case 1024:
  386. tmds_setting->max_vres = 768;
  387. break;
  388. case 1280:
  389. tmds_setting->max_vres = 1024;
  390. break;
  391. case 1400:
  392. tmds_setting->max_vres = 1050;
  393. break;
  394. case 1440:
  395. tmds_setting->max_vres = 1050;
  396. break;
  397. case 1600:
  398. tmds_setting->max_vres = 1200;
  399. break;
  400. default:
  401. DEBUG_MSG(KERN_INFO "Unknown panel size max resolution = %d! "
  402. "set default panel size.\n", tmds_setting->max_hres);
  403. break;
  404. }
  405. tmds_chip->tmds_chip_slave_addr = restore;
  406. }
  407. /* If Disable DVI, turn off pad */
  408. void viafb_dvi_disable(void)
  409. {
  410. if (viaparinfo->chip_info->
  411. tmds_chip_info.output_interface == INTERFACE_TMDS)
  412. /* Turn off TMDS power. */
  413. viafb_write_reg(CRD2, VIACR,
  414. viafb_read_reg(VIACR, CRD2) | 0x08);
  415. }
  416. static void dvi_patch_skew_dvp0(void)
  417. {
  418. /* Reset data driving first: */
  419. viafb_write_reg_mask(SR1B, VIASR, 0, BIT1);
  420. viafb_write_reg_mask(SR2A, VIASR, 0, BIT4);
  421. switch (viaparinfo->chip_info->gfx_chip_name) {
  422. case UNICHROME_P4M890:
  423. {
  424. if ((viaparinfo->tmds_setting_info->h_active == 1600) &&
  425. (viaparinfo->tmds_setting_info->v_active ==
  426. 1200))
  427. viafb_write_reg_mask(CR96, VIACR, 0x03,
  428. BIT0 + BIT1 + BIT2);
  429. else
  430. viafb_write_reg_mask(CR96, VIACR, 0x07,
  431. BIT0 + BIT1 + BIT2);
  432. break;
  433. }
  434. case UNICHROME_P4M900:
  435. {
  436. viafb_write_reg_mask(CR96, VIACR, 0x07,
  437. BIT0 + BIT1 + BIT2 + BIT3);
  438. viafb_write_reg_mask(SR1B, VIASR, 0x02, BIT1);
  439. viafb_write_reg_mask(SR2A, VIASR, 0x10, BIT4);
  440. break;
  441. }
  442. default:
  443. {
  444. break;
  445. }
  446. }
  447. }
  448. static void dvi_patch_skew_dvp_low(void)
  449. {
  450. switch (viaparinfo->chip_info->gfx_chip_name) {
  451. case UNICHROME_K8M890:
  452. {
  453. viafb_write_reg_mask(CR99, VIACR, 0x03, BIT0 + BIT1);
  454. break;
  455. }
  456. case UNICHROME_P4M900:
  457. {
  458. viafb_write_reg_mask(CR99, VIACR, 0x08,
  459. BIT0 + BIT1 + BIT2 + BIT3);
  460. break;
  461. }
  462. case UNICHROME_P4M890:
  463. {
  464. viafb_write_reg_mask(CR99, VIACR, 0x0F,
  465. BIT0 + BIT1 + BIT2 + BIT3);
  466. break;
  467. }
  468. default:
  469. {
  470. break;
  471. }
  472. }
  473. }
  474. /* If Enable DVI, turn off pad */
  475. void viafb_dvi_enable(void)
  476. {
  477. u8 data;
  478. switch (viaparinfo->chip_info->tmds_chip_info.output_interface) {
  479. case INTERFACE_DVP0:
  480. viafb_write_reg_mask(CR6B, VIACR, 0x01, BIT0);
  481. viafb_write_reg_mask(CR6C, VIACR, 0x21, BIT0 + BIT5);
  482. dvi_patch_skew_dvp0();
  483. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
  484. tmds_register_write(0x88, 0x3b);
  485. else
  486. /*clear CR91[5] to direct on display period
  487. in the secondary diplay path */
  488. via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
  489. break;
  490. case INTERFACE_DVP1:
  491. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
  492. viafb_write_reg_mask(CR93, VIACR, 0x21, BIT0 + BIT5);
  493. /*fix dvi cann't be enabled with MB VT5718C4 - Al Zhang */
  494. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
  495. tmds_register_write(0x88, 0x3b);
  496. else
  497. /*clear CR91[5] to direct on display period
  498. in the secondary diplay path */
  499. via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
  500. /*fix DVI cannot enable on EPIA-M board */
  501. if (viafb_platform_epia_dvi == 1) {
  502. viafb_write_reg_mask(CR91, VIACR, 0x1f, 0x1f);
  503. viafb_write_reg_mask(CR88, VIACR, 0x00, BIT6 + BIT0);
  504. if (viafb_bus_width == 24) {
  505. if (viafb_device_lcd_dualedge == 1)
  506. data = 0x3F;
  507. else
  508. data = 0x37;
  509. viafb_i2c_writebyte(viaparinfo->chip_info->
  510. tmds_chip_info.i2c_port,
  511. viaparinfo->chip_info->
  512. tmds_chip_info.tmds_chip_slave_addr,
  513. 0x08, data);
  514. }
  515. }
  516. break;
  517. case INTERFACE_DFP_HIGH:
  518. if (viaparinfo->chip_info->gfx_chip_name != UNICHROME_CLE266)
  519. via_write_reg_mask(VIACR, CR97, 0x03, 0x03);
  520. via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
  521. break;
  522. case INTERFACE_DFP_LOW:
  523. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
  524. break;
  525. dvi_patch_skew_dvp_low();
  526. via_write_reg_mask(VIACR, 0x91, 0x00, 0x20);
  527. break;
  528. case INTERFACE_TMDS:
  529. /* Turn on Display period in the panel path. */
  530. viafb_write_reg_mask(CR91, VIACR, 0, BIT7);
  531. /* Turn on TMDS power. */
  532. viafb_write_reg_mask(CRD2, VIACR, 0, BIT3);
  533. break;
  534. }
  535. if (viaparinfo->tmds_setting_info->iga_path == IGA2) {
  536. /* Disable LCD Scaling */
  537. viafb_write_reg_mask(CR79, VIACR, 0x00, BIT0);
  538. }
  539. }