hw.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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. #ifndef __HW_H__
  19. #define __HW_H__
  20. #include <linux/seq_file.h>
  21. #include "viamode.h"
  22. #include "global.h"
  23. #include "via_modesetting.h"
  24. #define viafb_read_reg(p, i) via_read_reg(p, i)
  25. #define viafb_write_reg(i, p, d) via_write_reg(p, i, d)
  26. #define viafb_write_reg_mask(i, p, d, m) via_write_reg_mask(p, i, d, m)
  27. /* VIA output devices */
  28. #define VIA_LDVP0 0x00000001
  29. #define VIA_LDVP1 0x00000002
  30. #define VIA_DVP0 0x00000004
  31. #define VIA_CRT 0x00000010
  32. #define VIA_DVP1 0x00000020
  33. #define VIA_LVDS1 0x00000040
  34. #define VIA_LVDS2 0x00000080
  35. /* VIA output device power states */
  36. #define VIA_STATE_ON 0
  37. #define VIA_STATE_STANDBY 1
  38. #define VIA_STATE_SUSPEND 2
  39. #define VIA_STATE_OFF 3
  40. /* VIA output device sync polarity */
  41. #define VIA_HSYNC_NEGATIVE 0x01
  42. #define VIA_VSYNC_NEGATIVE 0x02
  43. /**********************************************************/
  44. /* Definition IGA2 Design Method of CRTC Shadow Registers */
  45. /**********************************************************/
  46. #define IGA2_HOR_TOTAL_SHADOW_FORMULA(x) ((x/8)-5)
  47. #define IGA2_HOR_BLANK_END_SHADOW_FORMULA(x, y) (((x+y)/8)-1)
  48. #define IGA2_VER_TOTAL_SHADOW_FORMULA(x) ((x)-2)
  49. #define IGA2_VER_ADDR_SHADOW_FORMULA(x) ((x)-1)
  50. #define IGA2_VER_BLANK_START_SHADOW_FORMULA(x) ((x)-1)
  51. #define IGA2_VER_BLANK_END_SHADOW_FORMULA(x, y) ((x+y)-1)
  52. #define IGA2_VER_SYNC_START_SHADOW_FORMULA(x) (x)
  53. #define IGA2_VER_SYNC_END_SHADOW_FORMULA(x, y) (x+y)
  54. /* Define Register Number for IGA2 Shadow CRTC Timing */
  55. /* location: {CR6D,0,7},{CR71,3,3} */
  56. #define IGA2_SHADOW_HOR_TOTAL_REG_NUM 2
  57. /* location: {CR6E,0,7} */
  58. #define IGA2_SHADOW_HOR_BLANK_END_REG_NUM 1
  59. /* location: {CR6F,0,7},{CR71,0,2} */
  60. #define IGA2_SHADOW_VER_TOTAL_REG_NUM 2
  61. /* location: {CR70,0,7},{CR71,4,6} */
  62. #define IGA2_SHADOW_VER_ADDR_REG_NUM 2
  63. /* location: {CR72,0,7},{CR74,4,6} */
  64. #define IGA2_SHADOW_VER_BLANK_START_REG_NUM 2
  65. /* location: {CR73,0,7},{CR74,0,2} */
  66. #define IGA2_SHADOW_VER_BLANK_END_REG_NUM 2
  67. /* location: {CR75,0,7},{CR76,4,6} */
  68. #define IGA2_SHADOW_VER_SYNC_START_REG_NUM 2
  69. /* location: {CR76,0,3} */
  70. #define IGA2_SHADOW_VER_SYNC_END_REG_NUM 1
  71. /* Define Fetch Count Register*/
  72. /* location: {SR1C,0,7},{SR1D,0,1} */
  73. #define IGA1_FETCH_COUNT_REG_NUM 2
  74. /* 16 bytes alignment. */
  75. #define IGA1_FETCH_COUNT_ALIGN_BYTE 16
  76. /* x: H resolution, y: color depth */
  77. #define IGA1_FETCH_COUNT_PATCH_VALUE 4
  78. #define IGA1_FETCH_COUNT_FORMULA(x, y) \
  79. (((x*y)/IGA1_FETCH_COUNT_ALIGN_BYTE) + IGA1_FETCH_COUNT_PATCH_VALUE)
  80. /* location: {CR65,0,7},{CR67,2,3} */
  81. #define IGA2_FETCH_COUNT_REG_NUM 2
  82. #define IGA2_FETCH_COUNT_ALIGN_BYTE 16
  83. #define IGA2_FETCH_COUNT_PATCH_VALUE 0
  84. #define IGA2_FETCH_COUNT_FORMULA(x, y) \
  85. (((x*y)/IGA2_FETCH_COUNT_ALIGN_BYTE) + IGA2_FETCH_COUNT_PATCH_VALUE)
  86. /* Staring Address*/
  87. /* location: {CR0C,0,7},{CR0D,0,7},{CR34,0,7},{CR48,0,1} */
  88. #define IGA1_STARTING_ADDR_REG_NUM 4
  89. /* location: {CR62,1,7},{CR63,0,7},{CR64,0,7} */
  90. #define IGA2_STARTING_ADDR_REG_NUM 3
  91. /* Define Display OFFSET*/
  92. /* These value are by HW suggested value*/
  93. /* location: {SR17,0,7} */
  94. #define K800_IGA1_FIFO_MAX_DEPTH 384
  95. /* location: {SR16,0,5},{SR16,7,7} */
  96. #define K800_IGA1_FIFO_THRESHOLD 328
  97. /* location: {SR18,0,5},{SR18,7,7} */
  98. #define K800_IGA1_FIFO_HIGH_THRESHOLD 296
  99. /* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
  100. /* because HW only 5 bits */
  101. #define K800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  102. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  103. #define K800_IGA2_FIFO_MAX_DEPTH 384
  104. /* location: {CR68,0,3},{CR95,4,6} */
  105. #define K800_IGA2_FIFO_THRESHOLD 328
  106. /* location: {CR92,0,3},{CR95,0,2} */
  107. #define K800_IGA2_FIFO_HIGH_THRESHOLD 296
  108. /* location: {CR94,0,6} */
  109. #define K800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  110. /* location: {SR17,0,7} */
  111. #define P880_IGA1_FIFO_MAX_DEPTH 192
  112. /* location: {SR16,0,5},{SR16,7,7} */
  113. #define P880_IGA1_FIFO_THRESHOLD 128
  114. /* location: {SR18,0,5},{SR18,7,7} */
  115. #define P880_IGA1_FIFO_HIGH_THRESHOLD 64
  116. /* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
  117. /* because HW only 5 bits */
  118. #define P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  119. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  120. #define P880_IGA2_FIFO_MAX_DEPTH 96
  121. /* location: {CR68,0,3},{CR95,4,6} */
  122. #define P880_IGA2_FIFO_THRESHOLD 64
  123. /* location: {CR92,0,3},{CR95,0,2} */
  124. #define P880_IGA2_FIFO_HIGH_THRESHOLD 32
  125. /* location: {CR94,0,6} */
  126. #define P880_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  127. /* VT3314 chipset*/
  128. /* location: {SR17,0,7} */
  129. #define CN700_IGA1_FIFO_MAX_DEPTH 96
  130. /* location: {SR16,0,5},{SR16,7,7} */
  131. #define CN700_IGA1_FIFO_THRESHOLD 80
  132. /* location: {SR18,0,5},{SR18,7,7} */
  133. #define CN700_IGA1_FIFO_HIGH_THRESHOLD 64
  134. /* location: {SR22,0,4}. (128/4) =64, P800 must be set zero,
  135. because HW only 5 bits */
  136. #define CN700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  137. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  138. #define CN700_IGA2_FIFO_MAX_DEPTH 96
  139. /* location: {CR68,0,3},{CR95,4,6} */
  140. #define CN700_IGA2_FIFO_THRESHOLD 80
  141. /* location: {CR92,0,3},{CR95,0,2} */
  142. #define CN700_IGA2_FIFO_HIGH_THRESHOLD 32
  143. /* location: {CR94,0,6} */
  144. #define CN700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  145. /* For VT3324, these values are suggested by HW */
  146. /* location: {SR17,0,7} */
  147. #define CX700_IGA1_FIFO_MAX_DEPTH 192
  148. /* location: {SR16,0,5},{SR16,7,7} */
  149. #define CX700_IGA1_FIFO_THRESHOLD 128
  150. /* location: {SR18,0,5},{SR18,7,7} */
  151. #define CX700_IGA1_FIFO_HIGH_THRESHOLD 128
  152. /* location: {SR22,0,4} */
  153. #define CX700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
  154. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  155. #define CX700_IGA2_FIFO_MAX_DEPTH 96
  156. /* location: {CR68,0,3},{CR95,4,6} */
  157. #define CX700_IGA2_FIFO_THRESHOLD 64
  158. /* location: {CR92,0,3},{CR95,0,2} */
  159. #define CX700_IGA2_FIFO_HIGH_THRESHOLD 32
  160. /* location: {CR94,0,6} */
  161. #define CX700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  162. /* VT3336 chipset*/
  163. /* location: {SR17,0,7} */
  164. #define K8M890_IGA1_FIFO_MAX_DEPTH 360
  165. /* location: {SR16,0,5},{SR16,7,7} */
  166. #define K8M890_IGA1_FIFO_THRESHOLD 328
  167. /* location: {SR18,0,5},{SR18,7,7} */
  168. #define K8M890_IGA1_FIFO_HIGH_THRESHOLD 296
  169. /* location: {SR22,0,4}. */
  170. #define K8M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
  171. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  172. #define K8M890_IGA2_FIFO_MAX_DEPTH 360
  173. /* location: {CR68,0,3},{CR95,4,6} */
  174. #define K8M890_IGA2_FIFO_THRESHOLD 328
  175. /* location: {CR92,0,3},{CR95,0,2} */
  176. #define K8M890_IGA2_FIFO_HIGH_THRESHOLD 296
  177. /* location: {CR94,0,6} */
  178. #define K8M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 124
  179. /* VT3327 chipset*/
  180. /* location: {SR17,0,7} */
  181. #define P4M890_IGA1_FIFO_MAX_DEPTH 96
  182. /* location: {SR16,0,5},{SR16,7,7} */
  183. #define P4M890_IGA1_FIFO_THRESHOLD 76
  184. /* location: {SR18,0,5},{SR18,7,7} */
  185. #define P4M890_IGA1_FIFO_HIGH_THRESHOLD 64
  186. /* location: {SR22,0,4}. (32/4) =8 */
  187. #define P4M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
  188. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  189. #define P4M890_IGA2_FIFO_MAX_DEPTH 96
  190. /* location: {CR68,0,3},{CR95,4,6} */
  191. #define P4M890_IGA2_FIFO_THRESHOLD 76
  192. /* location: {CR92,0,3},{CR95,0,2} */
  193. #define P4M890_IGA2_FIFO_HIGH_THRESHOLD 64
  194. /* location: {CR94,0,6} */
  195. #define P4M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
  196. /* VT3364 chipset*/
  197. /* location: {SR17,0,7} */
  198. #define P4M900_IGA1_FIFO_MAX_DEPTH 96
  199. /* location: {SR16,0,5},{SR16,7,7} */
  200. #define P4M900_IGA1_FIFO_THRESHOLD 76
  201. /* location: {SR18,0,5},{SR18,7,7} */
  202. #define P4M900_IGA1_FIFO_HIGH_THRESHOLD 76
  203. /* location: {SR22,0,4}. */
  204. #define P4M900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
  205. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  206. #define P4M900_IGA2_FIFO_MAX_DEPTH 96
  207. /* location: {CR68,0,3},{CR95,4,6} */
  208. #define P4M900_IGA2_FIFO_THRESHOLD 76
  209. /* location: {CR92,0,3},{CR95,0,2} */
  210. #define P4M900_IGA2_FIFO_HIGH_THRESHOLD 76
  211. /* location: {CR94,0,6} */
  212. #define P4M900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
  213. /* For VT3353, these values are suggested by HW */
  214. /* location: {SR17,0,7} */
  215. #define VX800_IGA1_FIFO_MAX_DEPTH 192
  216. /* location: {SR16,0,5},{SR16,7,7} */
  217. #define VX800_IGA1_FIFO_THRESHOLD 152
  218. /* location: {SR18,0,5},{SR18,7,7} */
  219. #define VX800_IGA1_FIFO_HIGH_THRESHOLD 152
  220. /* location: {SR22,0,4} */
  221. #define VX800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 64
  222. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  223. #define VX800_IGA2_FIFO_MAX_DEPTH 96
  224. /* location: {CR68,0,3},{CR95,4,6} */
  225. #define VX800_IGA2_FIFO_THRESHOLD 64
  226. /* location: {CR92,0,3},{CR95,0,2} */
  227. #define VX800_IGA2_FIFO_HIGH_THRESHOLD 32
  228. /* location: {CR94,0,6} */
  229. #define VX800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  230. /* For VT3409 */
  231. #define VX855_IGA1_FIFO_MAX_DEPTH 400
  232. #define VX855_IGA1_FIFO_THRESHOLD 320
  233. #define VX855_IGA1_FIFO_HIGH_THRESHOLD 320
  234. #define VX855_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 160
  235. #define VX855_IGA2_FIFO_MAX_DEPTH 200
  236. #define VX855_IGA2_FIFO_THRESHOLD 160
  237. #define VX855_IGA2_FIFO_HIGH_THRESHOLD 160
  238. #define VX855_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 320
  239. /* For VT3410 */
  240. #define VX900_IGA1_FIFO_MAX_DEPTH 400
  241. #define VX900_IGA1_FIFO_THRESHOLD 320
  242. #define VX900_IGA1_FIFO_HIGH_THRESHOLD 320
  243. #define VX900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 160
  244. #define VX900_IGA2_FIFO_MAX_DEPTH 192
  245. #define VX900_IGA2_FIFO_THRESHOLD 160
  246. #define VX900_IGA2_FIFO_HIGH_THRESHOLD 160
  247. #define VX900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 320
  248. #define IGA1_FIFO_DEPTH_SELECT_REG_NUM 1
  249. #define IGA1_FIFO_THRESHOLD_REG_NUM 2
  250. #define IGA1_FIFO_HIGH_THRESHOLD_REG_NUM 2
  251. #define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
  252. #define IGA2_FIFO_DEPTH_SELECT_REG_NUM 3
  253. #define IGA2_FIFO_THRESHOLD_REG_NUM 2
  254. #define IGA2_FIFO_HIGH_THRESHOLD_REG_NUM 2
  255. #define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
  256. #define IGA1_FIFO_DEPTH_SELECT_FORMULA(x) ((x/2)-1)
  257. #define IGA1_FIFO_THRESHOLD_FORMULA(x) (x/4)
  258. #define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
  259. #define IGA1_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
  260. #define IGA2_FIFO_DEPTH_SELECT_FORMULA(x) (((x/2)/4)-1)
  261. #define IGA2_FIFO_THRESHOLD_FORMULA(x) (x/4)
  262. #define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
  263. #define IGA2_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
  264. /************************************************************************/
  265. /* LCD Timing */
  266. /************************************************************************/
  267. /* 500 ms = 500000 us */
  268. #define LCD_POWER_SEQ_TD0 500000
  269. /* 50 ms = 50000 us */
  270. #define LCD_POWER_SEQ_TD1 50000
  271. /* 0 us */
  272. #define LCD_POWER_SEQ_TD2 0
  273. /* 210 ms = 210000 us */
  274. #define LCD_POWER_SEQ_TD3 210000
  275. /* 2^10 * (1/14.31818M) = 71.475 us (K400.revA) */
  276. #define CLE266_POWER_SEQ_UNIT 71
  277. /* 2^11 * (1/14.31818M) = 142.95 us (K400.revB) */
  278. #define K800_POWER_SEQ_UNIT 142
  279. /* 2^13 * (1/14.31818M) = 572.1 us */
  280. #define P880_POWER_SEQ_UNIT 572
  281. #define CLE266_POWER_SEQ_FORMULA(x) ((x)/CLE266_POWER_SEQ_UNIT)
  282. #define K800_POWER_SEQ_FORMULA(x) ((x)/K800_POWER_SEQ_UNIT)
  283. #define P880_POWER_SEQ_FORMULA(x) ((x)/P880_POWER_SEQ_UNIT)
  284. /* location: {CR8B,0,7},{CR8F,0,3} */
  285. #define LCD_POWER_SEQ_TD0_REG_NUM 2
  286. /* location: {CR8C,0,7},{CR8F,4,7} */
  287. #define LCD_POWER_SEQ_TD1_REG_NUM 2
  288. /* location: {CR8D,0,7},{CR90,0,3} */
  289. #define LCD_POWER_SEQ_TD2_REG_NUM 2
  290. /* location: {CR8E,0,7},{CR90,4,7} */
  291. #define LCD_POWER_SEQ_TD3_REG_NUM 2
  292. /* LCD Scaling factor*/
  293. /* x: indicate setting horizontal size*/
  294. /* y: indicate panel horizontal size*/
  295. /* Horizontal scaling factor 10 bits (2^10) */
  296. #define CLE266_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
  297. /* Vertical scaling factor 10 bits (2^10) */
  298. #define CLE266_LCD_VER_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
  299. /* Horizontal scaling factor 10 bits (2^12) */
  300. #define K800_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*4096)/(y-1))
  301. /* Vertical scaling factor 10 bits (2^11) */
  302. #define K800_LCD_VER_SCF_FORMULA(x, y) (((x-1)*2048)/(y-1))
  303. /* location: {CR9F,0,1},{CR77,0,7},{CR79,4,5} */
  304. #define LCD_HOR_SCALING_FACTOR_REG_NUM 3
  305. /* location: {CR79,3,3},{CR78,0,7},{CR79,6,7} */
  306. #define LCD_VER_SCALING_FACTOR_REG_NUM 3
  307. /* location: {CR77,0,7},{CR79,4,5} */
  308. #define LCD_HOR_SCALING_FACTOR_REG_NUM_CLE 2
  309. /* location: {CR78,0,7},{CR79,6,7} */
  310. #define LCD_VER_SCALING_FACTOR_REG_NUM_CLE 2
  311. struct io_register {
  312. u8 io_addr;
  313. u8 start_bit;
  314. u8 end_bit;
  315. };
  316. /*****************************************************
  317. ** Define IGA2 Shadow Display Timing ****
  318. *****************************************************/
  319. /* IGA2 Shadow Horizontal Total */
  320. struct iga2_shadow_hor_total {
  321. int reg_num;
  322. struct io_register reg[IGA2_SHADOW_HOR_TOTAL_REG_NUM];
  323. };
  324. /* IGA2 Shadow Horizontal Blank End */
  325. struct iga2_shadow_hor_blank_end {
  326. int reg_num;
  327. struct io_register reg[IGA2_SHADOW_HOR_BLANK_END_REG_NUM];
  328. };
  329. /* IGA2 Shadow Vertical Total */
  330. struct iga2_shadow_ver_total {
  331. int reg_num;
  332. struct io_register reg[IGA2_SHADOW_VER_TOTAL_REG_NUM];
  333. };
  334. /* IGA2 Shadow Vertical Addressable Video */
  335. struct iga2_shadow_ver_addr {
  336. int reg_num;
  337. struct io_register reg[IGA2_SHADOW_VER_ADDR_REG_NUM];
  338. };
  339. /* IGA2 Shadow Vertical Blank Start */
  340. struct iga2_shadow_ver_blank_start {
  341. int reg_num;
  342. struct io_register reg[IGA2_SHADOW_VER_BLANK_START_REG_NUM];
  343. };
  344. /* IGA2 Shadow Vertical Blank End */
  345. struct iga2_shadow_ver_blank_end {
  346. int reg_num;
  347. struct io_register reg[IGA2_SHADOW_VER_BLANK_END_REG_NUM];
  348. };
  349. /* IGA2 Shadow Vertical Sync Start */
  350. struct iga2_shadow_ver_sync_start {
  351. int reg_num;
  352. struct io_register reg[IGA2_SHADOW_VER_SYNC_START_REG_NUM];
  353. };
  354. /* IGA2 Shadow Vertical Sync End */
  355. struct iga2_shadow_ver_sync_end {
  356. int reg_num;
  357. struct io_register reg[IGA2_SHADOW_VER_SYNC_END_REG_NUM];
  358. };
  359. /* IGA1 Fetch Count Register */
  360. struct iga1_fetch_count {
  361. int reg_num;
  362. struct io_register reg[IGA1_FETCH_COUNT_REG_NUM];
  363. };
  364. /* IGA2 Fetch Count Register */
  365. struct iga2_fetch_count {
  366. int reg_num;
  367. struct io_register reg[IGA2_FETCH_COUNT_REG_NUM];
  368. };
  369. struct fetch_count {
  370. struct iga1_fetch_count iga1_fetch_count_reg;
  371. struct iga2_fetch_count iga2_fetch_count_reg;
  372. };
  373. /* Starting Address Register */
  374. struct iga1_starting_addr {
  375. int reg_num;
  376. struct io_register reg[IGA1_STARTING_ADDR_REG_NUM];
  377. };
  378. struct iga2_starting_addr {
  379. int reg_num;
  380. struct io_register reg[IGA2_STARTING_ADDR_REG_NUM];
  381. };
  382. struct starting_addr {
  383. struct iga1_starting_addr iga1_starting_addr_reg;
  384. struct iga2_starting_addr iga2_starting_addr_reg;
  385. };
  386. /* LCD Power Sequence Timer */
  387. struct lcd_pwd_seq_td0 {
  388. int reg_num;
  389. struct io_register reg[LCD_POWER_SEQ_TD0_REG_NUM];
  390. };
  391. struct lcd_pwd_seq_td1 {
  392. int reg_num;
  393. struct io_register reg[LCD_POWER_SEQ_TD1_REG_NUM];
  394. };
  395. struct lcd_pwd_seq_td2 {
  396. int reg_num;
  397. struct io_register reg[LCD_POWER_SEQ_TD2_REG_NUM];
  398. };
  399. struct lcd_pwd_seq_td3 {
  400. int reg_num;
  401. struct io_register reg[LCD_POWER_SEQ_TD3_REG_NUM];
  402. };
  403. struct _lcd_pwd_seq_timer {
  404. struct lcd_pwd_seq_td0 td0;
  405. struct lcd_pwd_seq_td1 td1;
  406. struct lcd_pwd_seq_td2 td2;
  407. struct lcd_pwd_seq_td3 td3;
  408. };
  409. /* LCD Scaling Factor */
  410. struct _lcd_hor_scaling_factor {
  411. int reg_num;
  412. struct io_register reg[LCD_HOR_SCALING_FACTOR_REG_NUM];
  413. };
  414. struct _lcd_ver_scaling_factor {
  415. int reg_num;
  416. struct io_register reg[LCD_VER_SCALING_FACTOR_REG_NUM];
  417. };
  418. struct _lcd_scaling_factor {
  419. struct _lcd_hor_scaling_factor lcd_hor_scaling_factor;
  420. struct _lcd_ver_scaling_factor lcd_ver_scaling_factor;
  421. };
  422. struct pll_limit {
  423. u16 multiplier_min;
  424. u16 multiplier_max;
  425. u8 divisor;
  426. u8 rshift;
  427. };
  428. struct rgbLUT {
  429. u8 red;
  430. u8 green;
  431. u8 blue;
  432. };
  433. struct lcd_pwd_seq_timer {
  434. u16 td0;
  435. u16 td1;
  436. u16 td2;
  437. u16 td3;
  438. };
  439. /* Display FIFO Relation Registers*/
  440. struct iga1_fifo_depth_select {
  441. int reg_num;
  442. struct io_register reg[IGA1_FIFO_DEPTH_SELECT_REG_NUM];
  443. };
  444. struct iga1_fifo_threshold_select {
  445. int reg_num;
  446. struct io_register reg[IGA1_FIFO_THRESHOLD_REG_NUM];
  447. };
  448. struct iga1_fifo_high_threshold_select {
  449. int reg_num;
  450. struct io_register reg[IGA1_FIFO_HIGH_THRESHOLD_REG_NUM];
  451. };
  452. struct iga1_display_queue_expire_num {
  453. int reg_num;
  454. struct io_register reg[IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
  455. };
  456. struct iga2_fifo_depth_select {
  457. int reg_num;
  458. struct io_register reg[IGA2_FIFO_DEPTH_SELECT_REG_NUM];
  459. };
  460. struct iga2_fifo_threshold_select {
  461. int reg_num;
  462. struct io_register reg[IGA2_FIFO_THRESHOLD_REG_NUM];
  463. };
  464. struct iga2_fifo_high_threshold_select {
  465. int reg_num;
  466. struct io_register reg[IGA2_FIFO_HIGH_THRESHOLD_REG_NUM];
  467. };
  468. struct iga2_display_queue_expire_num {
  469. int reg_num;
  470. struct io_register reg[IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
  471. };
  472. struct fifo_depth_select {
  473. struct iga1_fifo_depth_select iga1_fifo_depth_select_reg;
  474. struct iga2_fifo_depth_select iga2_fifo_depth_select_reg;
  475. };
  476. struct fifo_threshold_select {
  477. struct iga1_fifo_threshold_select iga1_fifo_threshold_select_reg;
  478. struct iga2_fifo_threshold_select iga2_fifo_threshold_select_reg;
  479. };
  480. struct fifo_high_threshold_select {
  481. struct iga1_fifo_high_threshold_select
  482. iga1_fifo_high_threshold_select_reg;
  483. struct iga2_fifo_high_threshold_select
  484. iga2_fifo_high_threshold_select_reg;
  485. };
  486. struct display_queue_expire_num {
  487. struct iga1_display_queue_expire_num
  488. iga1_display_queue_expire_num_reg;
  489. struct iga2_display_queue_expire_num
  490. iga2_display_queue_expire_num_reg;
  491. };
  492. struct iga2_shadow_crtc_timing {
  493. struct iga2_shadow_hor_total hor_total_shadow;
  494. struct iga2_shadow_hor_blank_end hor_blank_end_shadow;
  495. struct iga2_shadow_ver_total ver_total_shadow;
  496. struct iga2_shadow_ver_addr ver_addr_shadow;
  497. struct iga2_shadow_ver_blank_start ver_blank_start_shadow;
  498. struct iga2_shadow_ver_blank_end ver_blank_end_shadow;
  499. struct iga2_shadow_ver_sync_start ver_sync_start_shadow;
  500. struct iga2_shadow_ver_sync_end ver_sync_end_shadow;
  501. };
  502. /* device ID */
  503. #define CLE266_FUNCTION3 0x3123
  504. #define KM400_FUNCTION3 0x3205
  505. #define CN400_FUNCTION2 0x2259
  506. #define CN400_FUNCTION3 0x3259
  507. /* support VT3314 chipset */
  508. #define CN700_FUNCTION2 0x2314
  509. #define CN700_FUNCTION3 0x3208
  510. /* VT3324 chipset */
  511. #define CX700_FUNCTION2 0x2324
  512. #define CX700_FUNCTION3 0x3324
  513. /* VT3204 chipset*/
  514. #define KM800_FUNCTION3 0x3204
  515. /* VT3336 chipset*/
  516. #define KM890_FUNCTION3 0x3336
  517. /* VT3327 chipset*/
  518. #define P4M890_FUNCTION3 0x3327
  519. /* VT3293 chipset*/
  520. #define CN750_FUNCTION3 0x3208
  521. /* VT3364 chipset*/
  522. #define P4M900_FUNCTION3 0x3364
  523. /* VT3353 chipset*/
  524. #define VX800_FUNCTION3 0x3353
  525. /* VT3409 chipset*/
  526. #define VX855_FUNCTION3 0x3409
  527. /* VT3410 chipset*/
  528. #define VX900_FUNCTION3 0x3410
  529. struct IODATA {
  530. u8 Index;
  531. u8 Mask;
  532. u8 Data;
  533. };
  534. struct pci_device_id_info {
  535. u32 vendor;
  536. u32 device;
  537. u32 chip_index;
  538. };
  539. struct via_device_mapping {
  540. u32 device;
  541. const char *name;
  542. };
  543. extern int viafb_SAMM_ON;
  544. extern int viafb_dual_fb;
  545. extern int viafb_LCD2_ON;
  546. extern int viafb_LCD_ON;
  547. extern int viafb_DVI_ON;
  548. extern int viafb_hotplug;
  549. struct via_display_timing var_to_timing(const struct fb_var_screeninfo *var,
  550. u16 cxres, u16 cyres);
  551. void viafb_fill_crtc_timing(const struct fb_var_screeninfo *var,
  552. u16 cxres, u16 cyres, int iga);
  553. void viafb_set_vclock(u32 CLK, int set_iga);
  554. void viafb_load_reg(int timing_value, int viafb_load_reg_num,
  555. struct io_register *reg,
  556. int io_type);
  557. void via_set_source(u32 devices, u8 iga);
  558. void via_set_state(u32 devices, u8 state);
  559. void via_set_sync_polarity(u32 devices, u8 polarity);
  560. u32 via_parse_odev(char *input, char **end);
  561. void via_odev_to_seq(struct seq_file *m, u32 odev);
  562. void init_ad9389(void);
  563. /* Access I/O Function */
  564. void viafb_lock_crt(void);
  565. void viafb_unlock_crt(void);
  566. void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga);
  567. void viafb_write_regx(struct io_reg RegTable[], int ItemNum);
  568. void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active);
  569. void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
  570. *p_gfx_dpa_setting);
  571. int viafb_setmode(void);
  572. void viafb_fill_var_timing_info(struct fb_var_screeninfo *var,
  573. const struct fb_videomode *mode);
  574. void viafb_init_chip_info(int chip_type);
  575. void viafb_init_dac(int set_iga);
  576. int viafb_get_refresh(int hres, int vres, u32 float_refresh);
  577. void viafb_update_device_setting(int hres, int vres, int bpp, int flag);
  578. void viafb_set_iga_path(void);
  579. void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue);
  580. void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue);
  581. void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len);
  582. #endif /* __HW_H__ */