dvi.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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 "global.h"
  19. static void tmds_register_write(int index, u8 data);
  20. static int tmds_register_read(int index);
  21. static int tmds_register_read_bytes(int index, u8 *buff, int buff_len);
  22. static int check_reduce_blanking_mode(int mode_index,
  23. int refresh_rate);
  24. static int dvi_get_panel_size_from_DDCv1(void);
  25. static int dvi_get_panel_size_from_DDCv2(void);
  26. static unsigned char dvi_get_panel_info(void);
  27. static int viafb_dvi_query_EDID(void);
  28. static int check_tmds_chip(int device_id_subaddr, int device_id)
  29. {
  30. if (tmds_register_read(device_id_subaddr) == device_id)
  31. return OK;
  32. else
  33. return FAIL;
  34. }
  35. void viafb_init_dvi_size(void)
  36. {
  37. DEBUG_MSG(KERN_INFO "viafb_init_dvi_size()\n");
  38. DEBUG_MSG(KERN_INFO
  39. "viaparinfo->tmds_setting_info->get_dvi_size_method %d\n",
  40. viaparinfo->tmds_setting_info->get_dvi_size_method);
  41. switch (viaparinfo->tmds_setting_info->get_dvi_size_method) {
  42. case GET_DVI_SIZE_BY_SYSTEM_BIOS:
  43. break;
  44. case GET_DVI_SZIE_BY_HW_STRAPPING:
  45. break;
  46. case GET_DVI_SIZE_BY_VGA_BIOS:
  47. default:
  48. dvi_get_panel_info();
  49. break;
  50. }
  51. return;
  52. }
  53. int viafb_tmds_trasmitter_identify(void)
  54. {
  55. unsigned char sr2a = 0, sr1e = 0, sr3e = 0;
  56. /* Turn on ouputting pad */
  57. switch (viaparinfo->chip_info->gfx_chip_name) {
  58. case UNICHROME_K8M890:
  59. /*=* DFP Low Pad on *=*/
  60. sr2a = viafb_read_reg(VIASR, SR2A);
  61. viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1);
  62. break;
  63. case UNICHROME_P4M900:
  64. case UNICHROME_P4M890:
  65. /* DFP Low Pad on */
  66. sr2a = viafb_read_reg(VIASR, SR2A);
  67. viafb_write_reg_mask(SR2A, VIASR, 0x03, BIT0 + BIT1);
  68. /* DVP0 Pad on */
  69. sr1e = viafb_read_reg(VIASR, SR1E);
  70. viafb_write_reg_mask(SR1E, VIASR, 0xC0, BIT6 + BIT7);
  71. break;
  72. default:
  73. /* DVP0/DVP1 Pad on */
  74. sr1e = viafb_read_reg(VIASR, SR1E);
  75. viafb_write_reg_mask(SR1E, VIASR, 0xF0, BIT4 +
  76. BIT5 + BIT6 + BIT7);
  77. /* SR3E[1]Multi-function selection:
  78. 0 = Emulate I2C and DDC bus by GPIO2/3/4. */
  79. sr3e = viafb_read_reg(VIASR, SR3E);
  80. viafb_write_reg_mask(SR3E, VIASR, 0x0, BIT5);
  81. break;
  82. }
  83. /* Check for VT1632: */
  84. viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = VT1632_TMDS;
  85. viaparinfo->chip_info->
  86. tmds_chip_info.tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR;
  87. viaparinfo->chip_info->tmds_chip_info.i2c_port = I2CPORTINDEX;
  88. if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) != FAIL) {
  89. /*
  90. * Currently only support 12bits,dual edge,add 24bits mode later
  91. */
  92. tmds_register_write(0x08, 0x3b);
  93. DEBUG_MSG(KERN_INFO "\n VT1632 TMDS ! \n");
  94. DEBUG_MSG(KERN_INFO "\n %2d",
  95. viaparinfo->chip_info->tmds_chip_info.tmds_chip_name);
  96. DEBUG_MSG(KERN_INFO "\n %2d",
  97. viaparinfo->chip_info->tmds_chip_info.i2c_port);
  98. return OK;
  99. } else {
  100. viaparinfo->chip_info->tmds_chip_info.i2c_port = GPIOPORTINDEX;
  101. if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID)
  102. != FAIL) {
  103. tmds_register_write(0x08, 0x3b);
  104. DEBUG_MSG(KERN_INFO "\n VT1632 TMDS ! \n");
  105. DEBUG_MSG(KERN_INFO "\n %2d",
  106. viaparinfo->chip_info->
  107. tmds_chip_info.tmds_chip_name);
  108. DEBUG_MSG(KERN_INFO "\n %2d",
  109. viaparinfo->chip_info->
  110. tmds_chip_info.i2c_port);
  111. return OK;
  112. }
  113. }
  114. viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = INTEGRATED_TMDS;
  115. if ((viaparinfo->chip_info->gfx_chip_name == UNICHROME_CX700) &&
  116. ((viafb_display_hardware_layout == HW_LAYOUT_DVI_ONLY) ||
  117. (viafb_display_hardware_layout == HW_LAYOUT_LCD_DVI))) {
  118. DEBUG_MSG(KERN_INFO "\n Integrated TMDS ! \n");
  119. return OK;
  120. }
  121. switch (viaparinfo->chip_info->gfx_chip_name) {
  122. case UNICHROME_K8M890:
  123. viafb_write_reg(SR2A, VIASR, sr2a);
  124. break;
  125. case UNICHROME_P4M900:
  126. case UNICHROME_P4M890:
  127. viafb_write_reg(SR2A, VIASR, sr2a);
  128. viafb_write_reg(SR1E, VIASR, sr1e);
  129. break;
  130. default:
  131. viafb_write_reg(SR1E, VIASR, sr1e);
  132. viafb_write_reg(SR3E, VIASR, sr3e);
  133. break;
  134. }
  135. viaparinfo->chip_info->
  136. tmds_chip_info.tmds_chip_name = NON_TMDS_TRANSMITTER;
  137. viaparinfo->chip_info->tmds_chip_info.
  138. tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR;
  139. return FAIL;
  140. }
  141. static void tmds_register_write(int index, u8 data)
  142. {
  143. viaparinfo->shared->i2c_stuff.i2c_port =
  144. viaparinfo->chip_info->tmds_chip_info.i2c_port;
  145. viafb_i2c_writebyte(viaparinfo->chip_info->tmds_chip_info.
  146. tmds_chip_slave_addr, index,
  147. data);
  148. }
  149. static int tmds_register_read(int index)
  150. {
  151. u8 data;
  152. viaparinfo->shared->i2c_stuff.i2c_port =
  153. viaparinfo->chip_info->tmds_chip_info.i2c_port;
  154. viafb_i2c_readbyte((u8) viaparinfo->chip_info->
  155. tmds_chip_info.tmds_chip_slave_addr,
  156. (u8) index, &data);
  157. return data;
  158. }
  159. static int tmds_register_read_bytes(int index, u8 *buff, int buff_len)
  160. {
  161. viaparinfo->shared->i2c_stuff.i2c_port =
  162. viaparinfo->chip_info->tmds_chip_info.i2c_port;
  163. viafb_i2c_readbytes((u8) viaparinfo->chip_info->tmds_chip_info.
  164. tmds_chip_slave_addr, (u8) index, buff, buff_len);
  165. return 0;
  166. }
  167. static int check_reduce_blanking_mode(int mode_index,
  168. int refresh_rate)
  169. {
  170. if (refresh_rate != 60)
  171. return false;
  172. switch (mode_index) {
  173. /* Following modes have reduce blanking mode. */
  174. case VIA_RES_1360X768:
  175. case VIA_RES_1400X1050:
  176. case VIA_RES_1440X900:
  177. case VIA_RES_1600X900:
  178. case VIA_RES_1680X1050:
  179. case VIA_RES_1920X1080:
  180. case VIA_RES_1920X1200:
  181. break;
  182. default:
  183. DEBUG_MSG(KERN_INFO
  184. "This dvi mode %d have no reduce blanking mode!\n",
  185. mode_index);
  186. return false;
  187. }
  188. return true;
  189. }
  190. /* DVI Set Mode */
  191. void viafb_dvi_set_mode(int video_index, int mode_bpp, int set_iga)
  192. {
  193. struct VideoModeTable *videoMode = NULL;
  194. struct crt_mode_table *pDviTiming;
  195. unsigned long desirePixelClock, maxPixelClock;
  196. int status = 0;
  197. videoMode = viafb_get_modetbl_pointer(video_index);
  198. pDviTiming = videoMode->crtc;
  199. desirePixelClock = pDviTiming->clk / 1000000;
  200. maxPixelClock = (unsigned long)viaparinfo->
  201. tmds_setting_info->max_pixel_clock;
  202. DEBUG_MSG(KERN_INFO "\nDVI_set_mode!!\n");
  203. if ((maxPixelClock != 0) && (desirePixelClock > maxPixelClock)) {
  204. /*Check if reduce-blanking mode is exist */
  205. status =
  206. check_reduce_blanking_mode(video_index,
  207. pDviTiming->refresh_rate);
  208. if (status) {
  209. video_index += 100; /*Use reduce-blanking mode */
  210. videoMode = viafb_get_modetbl_pointer(video_index);
  211. pDviTiming = videoMode->crtc;
  212. DEBUG_MSG(KERN_INFO
  213. "DVI use reduce blanking mode %d!!\n",
  214. video_index);
  215. }
  216. }
  217. viafb_fill_crtc_timing(pDviTiming, video_index, mode_bpp / 8, set_iga);
  218. viafb_set_output_path(DEVICE_DVI, set_iga,
  219. viaparinfo->chip_info->tmds_chip_info.output_interface);
  220. }
  221. /* Sense DVI Connector */
  222. int viafb_dvi_sense(void)
  223. {
  224. u8 RegSR1E = 0, RegSR3E = 0, RegCR6B = 0, RegCR91 = 0,
  225. RegCR93 = 0, RegCR9B = 0, data;
  226. int ret = false;
  227. DEBUG_MSG(KERN_INFO "viafb_dvi_sense!!\n");
  228. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
  229. /* DI1 Pad on */
  230. RegSR1E = viafb_read_reg(VIASR, SR1E);
  231. viafb_write_reg(SR1E, VIASR, RegSR1E | 0x30);
  232. /* CR6B[0]VCK Input Selection: 1 = External clock. */
  233. RegCR6B = viafb_read_reg(VIACR, CR6B);
  234. viafb_write_reg(CR6B, VIACR, RegCR6B | 0x08);
  235. /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off
  236. [0] Software Control Power Sequence */
  237. RegCR91 = viafb_read_reg(VIACR, CR91);
  238. viafb_write_reg(CR91, VIACR, 0x1D);
  239. /* CR93[7] DI1 Data Source Selection: 1 = DSP2.
  240. CR93[5] DI1 Clock Source: 1 = internal.
  241. CR93[4] DI1 Clock Polarity.
  242. CR93[3:1] DI1 Clock Adjust. CR93[0] DI1 enable */
  243. RegCR93 = viafb_read_reg(VIACR, CR93);
  244. viafb_write_reg(CR93, VIACR, 0x01);
  245. } else {
  246. /* DVP0/DVP1 Pad on */
  247. RegSR1E = viafb_read_reg(VIASR, SR1E);
  248. viafb_write_reg(SR1E, VIASR, RegSR1E | 0xF0);
  249. /* SR3E[1]Multi-function selection:
  250. 0 = Emulate I2C and DDC bus by GPIO2/3/4. */
  251. RegSR3E = viafb_read_reg(VIASR, SR3E);
  252. viafb_write_reg(SR3E, VIASR, RegSR3E & (~0x20));
  253. /* CR91[4] VDD On [3] Data On [2] VEE On [1] Back Light Off
  254. [0] Software Control Power Sequence */
  255. RegCR91 = viafb_read_reg(VIACR, CR91);
  256. viafb_write_reg(CR91, VIACR, 0x1D);
  257. /*CR9B[4] DVP1 Data Source Selection: 1 = From secondary
  258. display.CR9B[2:0] DVP1 Clock Adjust */
  259. RegCR9B = viafb_read_reg(VIACR, CR9B);
  260. viafb_write_reg(CR9B, VIACR, 0x01);
  261. }
  262. data = (u8) tmds_register_read(0x09);
  263. if (data & 0x04)
  264. ret = true;
  265. if (ret == false) {
  266. if (viafb_dvi_query_EDID())
  267. ret = true;
  268. }
  269. /* Restore status */
  270. viafb_write_reg(SR1E, VIASR, RegSR1E);
  271. viafb_write_reg(CR91, VIACR, RegCR91);
  272. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
  273. viafb_write_reg(CR6B, VIACR, RegCR6B);
  274. viafb_write_reg(CR93, VIACR, RegCR93);
  275. } else {
  276. viafb_write_reg(SR3E, VIASR, RegSR3E);
  277. viafb_write_reg(CR9B, VIACR, RegCR9B);
  278. }
  279. return ret;
  280. }
  281. /* Query Flat Panel's EDID Table Version Through DVI Connector */
  282. static int viafb_dvi_query_EDID(void)
  283. {
  284. u8 data0, data1;
  285. int restore;
  286. DEBUG_MSG(KERN_INFO "viafb_dvi_query_EDID!!\n");
  287. restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr;
  288. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0;
  289. data0 = (u8) tmds_register_read(0x00);
  290. data1 = (u8) tmds_register_read(0x01);
  291. if ((data0 == 0) && (data1 == 0xFF)) {
  292. viaparinfo->chip_info->
  293. tmds_chip_info.tmds_chip_slave_addr = restore;
  294. return EDID_VERSION_1; /* Found EDID1 Table */
  295. }
  296. data0 = (u8) tmds_register_read(0x00);
  297. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore;
  298. if (data0 == 0x20)
  299. return EDID_VERSION_2; /* Found EDID2 Table */
  300. else
  301. return false;
  302. }
  303. /*
  304. *
  305. * int dvi_get_panel_size_from_DDCv1(void)
  306. *
  307. * - Get Panel Size Using EDID1 Table
  308. *
  309. * Return Type: int
  310. *
  311. */
  312. static int dvi_get_panel_size_from_DDCv1(void)
  313. {
  314. int i, max_h = 0, max_v = 0, tmp, restore;
  315. unsigned char rData;
  316. unsigned char EDID_DATA[18];
  317. DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv1 \n");
  318. restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr;
  319. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA0;
  320. rData = tmds_register_read(0x23);
  321. if (rData & 0x3C)
  322. max_h = 640;
  323. if (rData & 0xC0)
  324. max_h = 720;
  325. if (rData & 0x03)
  326. max_h = 800;
  327. rData = tmds_register_read(0x24);
  328. if (rData & 0xC0)
  329. max_h = 800;
  330. if (rData & 0x1E)
  331. max_h = 1024;
  332. if (rData & 0x01)
  333. max_h = 1280;
  334. for (i = 0x25; i < 0x6D; i++) {
  335. switch (i) {
  336. case 0x26:
  337. case 0x28:
  338. case 0x2A:
  339. case 0x2C:
  340. case 0x2E:
  341. case 0x30:
  342. case 0x32:
  343. case 0x34:
  344. rData = tmds_register_read(i);
  345. if (rData == 1)
  346. break;
  347. /* data = (data + 31) * 8 */
  348. tmp = (rData + 31) << 3;
  349. if (tmp > max_h)
  350. max_h = tmp;
  351. break;
  352. case 0x36:
  353. case 0x48:
  354. case 0x5A:
  355. case 0x6C:
  356. tmds_register_read_bytes(i, EDID_DATA, 10);
  357. if (!(EDID_DATA[0] || EDID_DATA[1])) {
  358. /* The first two byte must be zero. */
  359. if (EDID_DATA[3] == 0xFD) {
  360. /* To get max pixel clock. */
  361. viaparinfo->tmds_setting_info->
  362. max_pixel_clock = EDID_DATA[9] * 10;
  363. }
  364. }
  365. break;
  366. default:
  367. break;
  368. }
  369. }
  370. switch (max_h) {
  371. case 640:
  372. viaparinfo->tmds_setting_info->dvi_panel_size =
  373. VIA_RES_640X480;
  374. break;
  375. case 800:
  376. viaparinfo->tmds_setting_info->dvi_panel_size =
  377. VIA_RES_800X600;
  378. break;
  379. case 1024:
  380. viaparinfo->tmds_setting_info->dvi_panel_size =
  381. VIA_RES_1024X768;
  382. break;
  383. case 1280:
  384. viaparinfo->tmds_setting_info->dvi_panel_size =
  385. VIA_RES_1280X1024;
  386. break;
  387. case 1400:
  388. viaparinfo->tmds_setting_info->dvi_panel_size =
  389. VIA_RES_1400X1050;
  390. break;
  391. case 1440:
  392. viaparinfo->tmds_setting_info->dvi_panel_size =
  393. VIA_RES_1440X1050;
  394. break;
  395. case 1600:
  396. viaparinfo->tmds_setting_info->dvi_panel_size =
  397. VIA_RES_1600X1200;
  398. break;
  399. case 1920:
  400. if (max_v == 1200) {
  401. viaparinfo->tmds_setting_info->dvi_panel_size =
  402. VIA_RES_1920X1200;
  403. } else {
  404. viaparinfo->tmds_setting_info->dvi_panel_size =
  405. VIA_RES_1920X1080;
  406. }
  407. break;
  408. default:
  409. viaparinfo->tmds_setting_info->dvi_panel_size =
  410. VIA_RES_1024X768;
  411. DEBUG_MSG(KERN_INFO "Unknow panel size max resolution = %d !\
  412. set default panel size.\n", max_h);
  413. break;
  414. }
  415. DEBUG_MSG(KERN_INFO "DVI max pixelclock = %d\n",
  416. viaparinfo->tmds_setting_info->max_pixel_clock);
  417. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore;
  418. return viaparinfo->tmds_setting_info->dvi_panel_size;
  419. }
  420. /*
  421. *
  422. * int dvi_get_panel_size_from_DDCv2(void)
  423. *
  424. * - Get Panel Size Using EDID2 Table
  425. *
  426. * Return Type: int
  427. *
  428. */
  429. static int dvi_get_panel_size_from_DDCv2(void)
  430. {
  431. int HSize = 0, restore;
  432. unsigned char R_Buffer[2];
  433. DEBUG_MSG(KERN_INFO "\n dvi_get_panel_size_from_DDCv2 \n");
  434. restore = viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr;
  435. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = 0xA2;
  436. /* Horizontal: 0x76, 0x77 */
  437. tmds_register_read_bytes(0x76, R_Buffer, 2);
  438. HSize = R_Buffer[0];
  439. HSize += R_Buffer[1] << 8;
  440. switch (HSize) {
  441. case 640:
  442. viaparinfo->tmds_setting_info->dvi_panel_size =
  443. VIA_RES_640X480;
  444. break;
  445. case 800:
  446. viaparinfo->tmds_setting_info->dvi_panel_size =
  447. VIA_RES_800X600;
  448. break;
  449. case 1024:
  450. viaparinfo->tmds_setting_info->dvi_panel_size =
  451. VIA_RES_1024X768;
  452. break;
  453. case 1280:
  454. viaparinfo->tmds_setting_info->dvi_panel_size =
  455. VIA_RES_1280X1024;
  456. break;
  457. case 1400:
  458. viaparinfo->tmds_setting_info->dvi_panel_size =
  459. VIA_RES_1400X1050;
  460. break;
  461. case 1440:
  462. viaparinfo->tmds_setting_info->dvi_panel_size =
  463. VIA_RES_1440X1050;
  464. break;
  465. case 1600:
  466. viaparinfo->tmds_setting_info->dvi_panel_size =
  467. VIA_RES_1600X1200;
  468. break;
  469. default:
  470. viaparinfo->tmds_setting_info->dvi_panel_size =
  471. VIA_RES_1024X768;
  472. DEBUG_MSG(KERN_INFO "Unknow panel size max resolution = %d!\
  473. set default panel size.\n", HSize);
  474. break;
  475. }
  476. viaparinfo->chip_info->tmds_chip_info.tmds_chip_slave_addr = restore;
  477. return viaparinfo->tmds_setting_info->dvi_panel_size;
  478. }
  479. /*
  480. *
  481. * unsigned char dvi_get_panel_info(void)
  482. *
  483. * - Get Panel Size
  484. *
  485. * Return Type: unsigned char
  486. */
  487. static unsigned char dvi_get_panel_info(void)
  488. {
  489. unsigned char dvipanelsize;
  490. DEBUG_MSG(KERN_INFO "dvi_get_panel_info! \n");
  491. viafb_dvi_sense();
  492. switch (viafb_dvi_query_EDID()) {
  493. case 1:
  494. dvi_get_panel_size_from_DDCv1();
  495. break;
  496. case 2:
  497. dvi_get_panel_size_from_DDCv2();
  498. break;
  499. default:
  500. break;
  501. }
  502. DEBUG_MSG(KERN_INFO "dvi panel size is %2d \n",
  503. viaparinfo->tmds_setting_info->dvi_panel_size);
  504. dvipanelsize = (unsigned char)(viaparinfo->
  505. tmds_setting_info->dvi_panel_size);
  506. return dvipanelsize;
  507. }
  508. /* If Disable DVI, turn off pad */
  509. void viafb_dvi_disable(void)
  510. {
  511. if (viaparinfo->chip_info->
  512. tmds_chip_info.output_interface == INTERFACE_DVP0)
  513. viafb_write_reg(SR1E, VIASR,
  514. viafb_read_reg(VIASR, SR1E) & (~0xC0));
  515. if (viaparinfo->chip_info->
  516. tmds_chip_info.output_interface == INTERFACE_DVP1)
  517. viafb_write_reg(SR1E, VIASR,
  518. viafb_read_reg(VIASR, SR1E) & (~0x30));
  519. if (viaparinfo->chip_info->
  520. tmds_chip_info.output_interface == INTERFACE_DFP_HIGH)
  521. viafb_write_reg(SR2A, VIASR,
  522. viafb_read_reg(VIASR, SR2A) & (~0x0C));
  523. if (viaparinfo->chip_info->
  524. tmds_chip_info.output_interface == INTERFACE_DFP_LOW)
  525. viafb_write_reg(SR2A, VIASR,
  526. viafb_read_reg(VIASR, SR2A) & (~0x03));
  527. if (viaparinfo->chip_info->
  528. tmds_chip_info.output_interface == INTERFACE_TMDS)
  529. /* Turn off TMDS power. */
  530. viafb_write_reg(CRD2, VIACR,
  531. viafb_read_reg(VIACR, CRD2) | 0x08);
  532. }
  533. /* If Enable DVI, turn off pad */
  534. void viafb_dvi_enable(void)
  535. {
  536. u8 data;
  537. if (viaparinfo->chip_info->
  538. tmds_chip_info.output_interface == INTERFACE_DVP0) {
  539. viafb_write_reg(SR1E, VIASR,
  540. viafb_read_reg(VIASR, SR1E) | 0xC0);
  541. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266)
  542. tmds_register_write(0x88, 0x3b);
  543. else
  544. /*clear CR91[5] to direct on display period
  545. in the secondary diplay path */
  546. viafb_write_reg(CR91, VIACR,
  547. viafb_read_reg(VIACR, CR91) & 0xDF);
  548. }
  549. if (viaparinfo->chip_info->
  550. tmds_chip_info.output_interface == INTERFACE_DVP1) {
  551. viafb_write_reg(SR1E, VIASR,
  552. viafb_read_reg(VIASR, SR1E) | 0x30);
  553. /*fix dvi cann't be enabled with MB VT5718C4 - Al Zhang */
  554. if (viaparinfo->chip_info->gfx_chip_name == UNICHROME_CLE266) {
  555. tmds_register_write(0x88, 0x3b);
  556. } else {
  557. /*clear CR91[5] to direct on display period
  558. in the secondary diplay path */
  559. viafb_write_reg(CR91, VIACR,
  560. viafb_read_reg(VIACR, CR91) & 0xDF);
  561. }
  562. /*fix DVI cannot enable on EPIA-M board */
  563. if (viafb_platform_epia_dvi == 1) {
  564. viafb_write_reg_mask(CR91, VIACR, 0x1f, 0x1f);
  565. viafb_write_reg_mask(CR88, VIACR, 0x00, BIT6 + BIT0);
  566. if (viafb_bus_width == 24) {
  567. if (viafb_device_lcd_dualedge == 1)
  568. data = 0x3F;
  569. else
  570. data = 0x37;
  571. viafb_i2c_writebyte(viaparinfo->chip_info->
  572. tmds_chip_info.
  573. tmds_chip_slave_addr,
  574. 0x08, data);
  575. }
  576. }
  577. }
  578. if (viaparinfo->chip_info->
  579. tmds_chip_info.output_interface == INTERFACE_DFP_HIGH) {
  580. viafb_write_reg(SR2A, VIASR,
  581. viafb_read_reg(VIASR, SR2A) | 0x0C);
  582. viafb_write_reg(CR91, VIACR,
  583. viafb_read_reg(VIACR, CR91) & 0xDF);
  584. }
  585. if (viaparinfo->chip_info->
  586. tmds_chip_info.output_interface == INTERFACE_DFP_LOW) {
  587. viafb_write_reg(SR2A, VIASR,
  588. viafb_read_reg(VIASR, SR2A) | 0x03);
  589. viafb_write_reg(CR91, VIACR,
  590. viafb_read_reg(VIACR, CR91) & 0xDF);
  591. }
  592. if (viaparinfo->chip_info->
  593. tmds_chip_info.output_interface == INTERFACE_TMDS) {
  594. /* Turn on Display period in the panel path. */
  595. viafb_write_reg_mask(CR91, VIACR, 0, BIT7);
  596. /* Turn on TMDS power. */
  597. viafb_write_reg_mask(CRD2, VIACR, 0, BIT3);
  598. }
  599. }