hw.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  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_6C 0x00000001
  29. #define VIA_93 0x00000002
  30. #define VIA_96 0x00000004
  31. #define VIA_CRT 0x00000010
  32. #define VIA_DVP1 0x00000020
  33. #define VIA_LVDS1 0x00000040
  34. #define VIA_LVDS2 0x00000080
  35. /***************************************************
  36. * Definition IGA1 Design Method of CRTC Registers *
  37. ****************************************************/
  38. #define IGA1_HOR_TOTAL_FORMULA(x) (((x)/8)-5)
  39. #define IGA1_HOR_ADDR_FORMULA(x) (((x)/8)-1)
  40. #define IGA1_HOR_BLANK_START_FORMULA(x) (((x)/8)-1)
  41. #define IGA1_HOR_BLANK_END_FORMULA(x, y) (((x+y)/8)-1)
  42. #define IGA1_HOR_SYNC_START_FORMULA(x) ((x)/8)
  43. #define IGA1_HOR_SYNC_END_FORMULA(x, y) ((x+y)/8)
  44. #define IGA1_VER_TOTAL_FORMULA(x) ((x)-2)
  45. #define IGA1_VER_ADDR_FORMULA(x) ((x)-1)
  46. #define IGA1_VER_BLANK_START_FORMULA(x) ((x)-1)
  47. #define IGA1_VER_BLANK_END_FORMULA(x, y) ((x+y)-1)
  48. #define IGA1_VER_SYNC_START_FORMULA(x) ((x)-1)
  49. #define IGA1_VER_SYNC_END_FORMULA(x, y) ((x+y)-1)
  50. /***************************************************
  51. ** Definition IGA2 Design Method of CRTC Registers *
  52. ****************************************************/
  53. #define IGA2_HOR_TOTAL_FORMULA(x) ((x)-1)
  54. #define IGA2_HOR_ADDR_FORMULA(x) ((x)-1)
  55. #define IGA2_HOR_BLANK_START_FORMULA(x) ((x)-1)
  56. #define IGA2_HOR_BLANK_END_FORMULA(x, y) ((x+y)-1)
  57. #define IGA2_HOR_SYNC_START_FORMULA(x) ((x)-1)
  58. #define IGA2_HOR_SYNC_END_FORMULA(x, y) ((x+y)-1)
  59. #define IGA2_VER_TOTAL_FORMULA(x) ((x)-1)
  60. #define IGA2_VER_ADDR_FORMULA(x) ((x)-1)
  61. #define IGA2_VER_BLANK_START_FORMULA(x) ((x)-1)
  62. #define IGA2_VER_BLANK_END_FORMULA(x, y) ((x+y)-1)
  63. #define IGA2_VER_SYNC_START_FORMULA(x) ((x)-1)
  64. #define IGA2_VER_SYNC_END_FORMULA(x, y) ((x+y)-1)
  65. /**********************************************************/
  66. /* Definition IGA2 Design Method of CRTC Shadow Registers */
  67. /**********************************************************/
  68. #define IGA2_HOR_TOTAL_SHADOW_FORMULA(x) ((x/8)-5)
  69. #define IGA2_HOR_BLANK_END_SHADOW_FORMULA(x, y) (((x+y)/8)-1)
  70. #define IGA2_VER_TOTAL_SHADOW_FORMULA(x) ((x)-2)
  71. #define IGA2_VER_ADDR_SHADOW_FORMULA(x) ((x)-1)
  72. #define IGA2_VER_BLANK_START_SHADOW_FORMULA(x) ((x)-1)
  73. #define IGA2_VER_BLANK_END_SHADOW_FORMULA(x, y) ((x+y)-1)
  74. #define IGA2_VER_SYNC_START_SHADOW_FORMULA(x) (x)
  75. #define IGA2_VER_SYNC_END_SHADOW_FORMULA(x, y) (x+y)
  76. /* Define Register Number for IGA1 CRTC Timing */
  77. /* location: {CR00,0,7},{CR36,3,3} */
  78. #define IGA1_HOR_TOTAL_REG_NUM 2
  79. /* location: {CR01,0,7} */
  80. #define IGA1_HOR_ADDR_REG_NUM 1
  81. /* location: {CR02,0,7} */
  82. #define IGA1_HOR_BLANK_START_REG_NUM 1
  83. /* location: {CR03,0,4},{CR05,7,7},{CR33,5,5} */
  84. #define IGA1_HOR_BLANK_END_REG_NUM 3
  85. /* location: {CR04,0,7},{CR33,4,4} */
  86. #define IGA1_HOR_SYNC_START_REG_NUM 2
  87. /* location: {CR05,0,4} */
  88. #define IGA1_HOR_SYNC_END_REG_NUM 1
  89. /* location: {CR06,0,7},{CR07,0,0},{CR07,5,5},{CR35,0,0} */
  90. #define IGA1_VER_TOTAL_REG_NUM 4
  91. /* location: {CR12,0,7},{CR07,1,1},{CR07,6,6},{CR35,2,2} */
  92. #define IGA1_VER_ADDR_REG_NUM 4
  93. /* location: {CR15,0,7},{CR07,3,3},{CR09,5,5},{CR35,3,3} */
  94. #define IGA1_VER_BLANK_START_REG_NUM 4
  95. /* location: {CR16,0,7} */
  96. #define IGA1_VER_BLANK_END_REG_NUM 1
  97. /* location: {CR10,0,7},{CR07,2,2},{CR07,7,7},{CR35,1,1} */
  98. #define IGA1_VER_SYNC_START_REG_NUM 4
  99. /* location: {CR11,0,3} */
  100. #define IGA1_VER_SYNC_END_REG_NUM 1
  101. /* Define Register Number for IGA2 Shadow CRTC Timing */
  102. /* location: {CR6D,0,7},{CR71,3,3} */
  103. #define IGA2_SHADOW_HOR_TOTAL_REG_NUM 2
  104. /* location: {CR6E,0,7} */
  105. #define IGA2_SHADOW_HOR_BLANK_END_REG_NUM 1
  106. /* location: {CR6F,0,7},{CR71,0,2} */
  107. #define IGA2_SHADOW_VER_TOTAL_REG_NUM 2
  108. /* location: {CR70,0,7},{CR71,4,6} */
  109. #define IGA2_SHADOW_VER_ADDR_REG_NUM 2
  110. /* location: {CR72,0,7},{CR74,4,6} */
  111. #define IGA2_SHADOW_VER_BLANK_START_REG_NUM 2
  112. /* location: {CR73,0,7},{CR74,0,2} */
  113. #define IGA2_SHADOW_VER_BLANK_END_REG_NUM 2
  114. /* location: {CR75,0,7},{CR76,4,6} */
  115. #define IGA2_SHADOW_VER_SYNC_START_REG_NUM 2
  116. /* location: {CR76,0,3} */
  117. #define IGA2_SHADOW_VER_SYNC_END_REG_NUM 1
  118. /* Define Register Number for IGA2 CRTC Timing */
  119. /* location: {CR50,0,7},{CR55,0,3} */
  120. #define IGA2_HOR_TOTAL_REG_NUM 2
  121. /* location: {CR51,0,7},{CR55,4,6} */
  122. #define IGA2_HOR_ADDR_REG_NUM 2
  123. /* location: {CR52,0,7},{CR54,0,2} */
  124. #define IGA2_HOR_BLANK_START_REG_NUM 2
  125. /* location: CLE266: {CR53,0,7},{CR54,3,5} => CLE266's CR5D[6]
  126. is reserved, so it may have problem to set 1600x1200 on IGA2. */
  127. /* Others: {CR53,0,7},{CR54,3,5},{CR5D,6,6} */
  128. #define IGA2_HOR_BLANK_END_REG_NUM 3
  129. /* location: {CR56,0,7},{CR54,6,7},{CR5C,7,7} */
  130. /* VT3314 and Later: {CR56,0,7},{CR54,6,7},{CR5C,7,7}, {CR5D,7,7} */
  131. #define IGA2_HOR_SYNC_START_REG_NUM 4
  132. /* location: {CR57,0,7},{CR5C,6,6} */
  133. #define IGA2_HOR_SYNC_END_REG_NUM 2
  134. /* location: {CR58,0,7},{CR5D,0,2} */
  135. #define IGA2_VER_TOTAL_REG_NUM 2
  136. /* location: {CR59,0,7},{CR5D,3,5} */
  137. #define IGA2_VER_ADDR_REG_NUM 2
  138. /* location: {CR5A,0,7},{CR5C,0,2} */
  139. #define IGA2_VER_BLANK_START_REG_NUM 2
  140. /* location: {CR5E,0,7},{CR5C,3,5} */
  141. #define IGA2_VER_BLANK_END_REG_NUM 2
  142. /* location: {CR5E,0,7},{CR5F,5,7} */
  143. #define IGA2_VER_SYNC_START_REG_NUM 2
  144. /* location: {CR5F,0,4} */
  145. #define IGA2_VER_SYNC_END_REG_NUM 1
  146. /* Define Fetch Count Register*/
  147. /* location: {SR1C,0,7},{SR1D,0,1} */
  148. #define IGA1_FETCH_COUNT_REG_NUM 2
  149. /* 16 bytes alignment. */
  150. #define IGA1_FETCH_COUNT_ALIGN_BYTE 16
  151. /* x: H resolution, y: color depth */
  152. #define IGA1_FETCH_COUNT_PATCH_VALUE 4
  153. #define IGA1_FETCH_COUNT_FORMULA(x, y) \
  154. (((x*y)/IGA1_FETCH_COUNT_ALIGN_BYTE) + IGA1_FETCH_COUNT_PATCH_VALUE)
  155. /* location: {CR65,0,7},{CR67,2,3} */
  156. #define IGA2_FETCH_COUNT_REG_NUM 2
  157. #define IGA2_FETCH_COUNT_ALIGN_BYTE 16
  158. #define IGA2_FETCH_COUNT_PATCH_VALUE 0
  159. #define IGA2_FETCH_COUNT_FORMULA(x, y) \
  160. (((x*y)/IGA2_FETCH_COUNT_ALIGN_BYTE) + IGA2_FETCH_COUNT_PATCH_VALUE)
  161. /* Staring Address*/
  162. /* location: {CR0C,0,7},{CR0D,0,7},{CR34,0,7},{CR48,0,1} */
  163. #define IGA1_STARTING_ADDR_REG_NUM 4
  164. /* location: {CR62,1,7},{CR63,0,7},{CR64,0,7} */
  165. #define IGA2_STARTING_ADDR_REG_NUM 3
  166. /* Define Display OFFSET*/
  167. /* These value are by HW suggested value*/
  168. /* location: {SR17,0,7} */
  169. #define K800_IGA1_FIFO_MAX_DEPTH 384
  170. /* location: {SR16,0,5},{SR16,7,7} */
  171. #define K800_IGA1_FIFO_THRESHOLD 328
  172. /* location: {SR18,0,5},{SR18,7,7} */
  173. #define K800_IGA1_FIFO_HIGH_THRESHOLD 296
  174. /* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
  175. /* because HW only 5 bits */
  176. #define K800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  177. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  178. #define K800_IGA2_FIFO_MAX_DEPTH 384
  179. /* location: {CR68,0,3},{CR95,4,6} */
  180. #define K800_IGA2_FIFO_THRESHOLD 328
  181. /* location: {CR92,0,3},{CR95,0,2} */
  182. #define K800_IGA2_FIFO_HIGH_THRESHOLD 296
  183. /* location: {CR94,0,6} */
  184. #define K800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  185. /* location: {SR17,0,7} */
  186. #define P880_IGA1_FIFO_MAX_DEPTH 192
  187. /* location: {SR16,0,5},{SR16,7,7} */
  188. #define P880_IGA1_FIFO_THRESHOLD 128
  189. /* location: {SR18,0,5},{SR18,7,7} */
  190. #define P880_IGA1_FIFO_HIGH_THRESHOLD 64
  191. /* location: {SR22,0,4}. (128/4) =64, K800 must be set zero, */
  192. /* because HW only 5 bits */
  193. #define P880_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  194. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  195. #define P880_IGA2_FIFO_MAX_DEPTH 96
  196. /* location: {CR68,0,3},{CR95,4,6} */
  197. #define P880_IGA2_FIFO_THRESHOLD 64
  198. /* location: {CR92,0,3},{CR95,0,2} */
  199. #define P880_IGA2_FIFO_HIGH_THRESHOLD 32
  200. /* location: {CR94,0,6} */
  201. #define P880_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  202. /* VT3314 chipset*/
  203. /* location: {SR17,0,7} */
  204. #define CN700_IGA1_FIFO_MAX_DEPTH 96
  205. /* location: {SR16,0,5},{SR16,7,7} */
  206. #define CN700_IGA1_FIFO_THRESHOLD 80
  207. /* location: {SR18,0,5},{SR18,7,7} */
  208. #define CN700_IGA1_FIFO_HIGH_THRESHOLD 64
  209. /* location: {SR22,0,4}. (128/4) =64, P800 must be set zero,
  210. because HW only 5 bits */
  211. #define CN700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 0
  212. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  213. #define CN700_IGA2_FIFO_MAX_DEPTH 96
  214. /* location: {CR68,0,3},{CR95,4,6} */
  215. #define CN700_IGA2_FIFO_THRESHOLD 80
  216. /* location: {CR92,0,3},{CR95,0,2} */
  217. #define CN700_IGA2_FIFO_HIGH_THRESHOLD 32
  218. /* location: {CR94,0,6} */
  219. #define CN700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  220. /* For VT3324, these values are suggested by HW */
  221. /* location: {SR17,0,7} */
  222. #define CX700_IGA1_FIFO_MAX_DEPTH 192
  223. /* location: {SR16,0,5},{SR16,7,7} */
  224. #define CX700_IGA1_FIFO_THRESHOLD 128
  225. /* location: {SR18,0,5},{SR18,7,7} */
  226. #define CX700_IGA1_FIFO_HIGH_THRESHOLD 128
  227. /* location: {SR22,0,4} */
  228. #define CX700_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
  229. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  230. #define CX700_IGA2_FIFO_MAX_DEPTH 96
  231. /* location: {CR68,0,3},{CR95,4,6} */
  232. #define CX700_IGA2_FIFO_THRESHOLD 64
  233. /* location: {CR92,0,3},{CR95,0,2} */
  234. #define CX700_IGA2_FIFO_HIGH_THRESHOLD 32
  235. /* location: {CR94,0,6} */
  236. #define CX700_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  237. /* VT3336 chipset*/
  238. /* location: {SR17,0,7} */
  239. #define K8M890_IGA1_FIFO_MAX_DEPTH 360
  240. /* location: {SR16,0,5},{SR16,7,7} */
  241. #define K8M890_IGA1_FIFO_THRESHOLD 328
  242. /* location: {SR18,0,5},{SR18,7,7} */
  243. #define K8M890_IGA1_FIFO_HIGH_THRESHOLD 296
  244. /* location: {SR22,0,4}. */
  245. #define K8M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 124
  246. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  247. #define K8M890_IGA2_FIFO_MAX_DEPTH 360
  248. /* location: {CR68,0,3},{CR95,4,6} */
  249. #define K8M890_IGA2_FIFO_THRESHOLD 328
  250. /* location: {CR92,0,3},{CR95,0,2} */
  251. #define K8M890_IGA2_FIFO_HIGH_THRESHOLD 296
  252. /* location: {CR94,0,6} */
  253. #define K8M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 124
  254. /* VT3327 chipset*/
  255. /* location: {SR17,0,7} */
  256. #define P4M890_IGA1_FIFO_MAX_DEPTH 96
  257. /* location: {SR16,0,5},{SR16,7,7} */
  258. #define P4M890_IGA1_FIFO_THRESHOLD 76
  259. /* location: {SR18,0,5},{SR18,7,7} */
  260. #define P4M890_IGA1_FIFO_HIGH_THRESHOLD 64
  261. /* location: {SR22,0,4}. (32/4) =8 */
  262. #define P4M890_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
  263. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  264. #define P4M890_IGA2_FIFO_MAX_DEPTH 96
  265. /* location: {CR68,0,3},{CR95,4,6} */
  266. #define P4M890_IGA2_FIFO_THRESHOLD 76
  267. /* location: {CR92,0,3},{CR95,0,2} */
  268. #define P4M890_IGA2_FIFO_HIGH_THRESHOLD 64
  269. /* location: {CR94,0,6} */
  270. #define P4M890_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
  271. /* VT3364 chipset*/
  272. /* location: {SR17,0,7} */
  273. #define P4M900_IGA1_FIFO_MAX_DEPTH 96
  274. /* location: {SR16,0,5},{SR16,7,7} */
  275. #define P4M900_IGA1_FIFO_THRESHOLD 76
  276. /* location: {SR18,0,5},{SR18,7,7} */
  277. #define P4M900_IGA1_FIFO_HIGH_THRESHOLD 76
  278. /* location: {SR22,0,4}. */
  279. #define P4M900_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 32
  280. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  281. #define P4M900_IGA2_FIFO_MAX_DEPTH 96
  282. /* location: {CR68,0,3},{CR95,4,6} */
  283. #define P4M900_IGA2_FIFO_THRESHOLD 76
  284. /* location: {CR92,0,3},{CR95,0,2} */
  285. #define P4M900_IGA2_FIFO_HIGH_THRESHOLD 76
  286. /* location: {CR94,0,6} */
  287. #define P4M900_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 32
  288. /* For VT3353, these values are suggested by HW */
  289. /* location: {SR17,0,7} */
  290. #define VX800_IGA1_FIFO_MAX_DEPTH 192
  291. /* location: {SR16,0,5},{SR16,7,7} */
  292. #define VX800_IGA1_FIFO_THRESHOLD 152
  293. /* location: {SR18,0,5},{SR18,7,7} */
  294. #define VX800_IGA1_FIFO_HIGH_THRESHOLD 152
  295. /* location: {SR22,0,4} */
  296. #define VX800_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 64
  297. /* location: {CR68,4,7},{CR94,7,7},{CR95,7,7} */
  298. #define VX800_IGA2_FIFO_MAX_DEPTH 96
  299. /* location: {CR68,0,3},{CR95,4,6} */
  300. #define VX800_IGA2_FIFO_THRESHOLD 64
  301. /* location: {CR92,0,3},{CR95,0,2} */
  302. #define VX800_IGA2_FIFO_HIGH_THRESHOLD 32
  303. /* location: {CR94,0,6} */
  304. #define VX800_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 128
  305. /* For VT3409 */
  306. #define VX855_IGA1_FIFO_MAX_DEPTH 400
  307. #define VX855_IGA1_FIFO_THRESHOLD 320
  308. #define VX855_IGA1_FIFO_HIGH_THRESHOLD 320
  309. #define VX855_IGA1_DISPLAY_QUEUE_EXPIRE_NUM 160
  310. #define VX855_IGA2_FIFO_MAX_DEPTH 200
  311. #define VX855_IGA2_FIFO_THRESHOLD 160
  312. #define VX855_IGA2_FIFO_HIGH_THRESHOLD 160
  313. #define VX855_IGA2_DISPLAY_QUEUE_EXPIRE_NUM 320
  314. #define IGA1_FIFO_DEPTH_SELECT_REG_NUM 1
  315. #define IGA1_FIFO_THRESHOLD_REG_NUM 2
  316. #define IGA1_FIFO_HIGH_THRESHOLD_REG_NUM 2
  317. #define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
  318. #define IGA2_FIFO_DEPTH_SELECT_REG_NUM 3
  319. #define IGA2_FIFO_THRESHOLD_REG_NUM 2
  320. #define IGA2_FIFO_HIGH_THRESHOLD_REG_NUM 2
  321. #define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM 1
  322. #define IGA1_FIFO_DEPTH_SELECT_FORMULA(x) ((x/2)-1)
  323. #define IGA1_FIFO_THRESHOLD_FORMULA(x) (x/4)
  324. #define IGA1_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
  325. #define IGA1_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
  326. #define IGA2_FIFO_DEPTH_SELECT_FORMULA(x) (((x/2)/4)-1)
  327. #define IGA2_FIFO_THRESHOLD_FORMULA(x) (x/4)
  328. #define IGA2_DISPLAY_QUEUE_EXPIRE_NUM_FORMULA(x) (x/4)
  329. #define IGA2_FIFO_HIGH_THRESHOLD_FORMULA(x) (x/4)
  330. /************************************************************************/
  331. /* LCD Timing */
  332. /************************************************************************/
  333. /* 500 ms = 500000 us */
  334. #define LCD_POWER_SEQ_TD0 500000
  335. /* 50 ms = 50000 us */
  336. #define LCD_POWER_SEQ_TD1 50000
  337. /* 0 us */
  338. #define LCD_POWER_SEQ_TD2 0
  339. /* 210 ms = 210000 us */
  340. #define LCD_POWER_SEQ_TD3 210000
  341. /* 2^10 * (1/14.31818M) = 71.475 us (K400.revA) */
  342. #define CLE266_POWER_SEQ_UNIT 71
  343. /* 2^11 * (1/14.31818M) = 142.95 us (K400.revB) */
  344. #define K800_POWER_SEQ_UNIT 142
  345. /* 2^13 * (1/14.31818M) = 572.1 us */
  346. #define P880_POWER_SEQ_UNIT 572
  347. #define CLE266_POWER_SEQ_FORMULA(x) ((x)/CLE266_POWER_SEQ_UNIT)
  348. #define K800_POWER_SEQ_FORMULA(x) ((x)/K800_POWER_SEQ_UNIT)
  349. #define P880_POWER_SEQ_FORMULA(x) ((x)/P880_POWER_SEQ_UNIT)
  350. /* location: {CR8B,0,7},{CR8F,0,3} */
  351. #define LCD_POWER_SEQ_TD0_REG_NUM 2
  352. /* location: {CR8C,0,7},{CR8F,4,7} */
  353. #define LCD_POWER_SEQ_TD1_REG_NUM 2
  354. /* location: {CR8D,0,7},{CR90,0,3} */
  355. #define LCD_POWER_SEQ_TD2_REG_NUM 2
  356. /* location: {CR8E,0,7},{CR90,4,7} */
  357. #define LCD_POWER_SEQ_TD3_REG_NUM 2
  358. /* LCD Scaling factor*/
  359. /* x: indicate setting horizontal size*/
  360. /* y: indicate panel horizontal size*/
  361. /* Horizontal scaling factor 10 bits (2^10) */
  362. #define CLE266_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
  363. /* Vertical scaling factor 10 bits (2^10) */
  364. #define CLE266_LCD_VER_SCF_FORMULA(x, y) (((x-1)*1024)/(y-1))
  365. /* Horizontal scaling factor 10 bits (2^12) */
  366. #define K800_LCD_HOR_SCF_FORMULA(x, y) (((x-1)*4096)/(y-1))
  367. /* Vertical scaling factor 10 bits (2^11) */
  368. #define K800_LCD_VER_SCF_FORMULA(x, y) (((x-1)*2048)/(y-1))
  369. /* location: {CR9F,0,1},{CR77,0,7},{CR79,4,5} */
  370. #define LCD_HOR_SCALING_FACTOR_REG_NUM 3
  371. /* location: {CR79,3,3},{CR78,0,7},{CR79,6,7} */
  372. #define LCD_VER_SCALING_FACTOR_REG_NUM 3
  373. /* location: {CR77,0,7},{CR79,4,5} */
  374. #define LCD_HOR_SCALING_FACTOR_REG_NUM_CLE 2
  375. /* location: {CR78,0,7},{CR79,6,7} */
  376. #define LCD_VER_SCALING_FACTOR_REG_NUM_CLE 2
  377. /************************************************
  378. ***** Define IGA1 Display Timing *****
  379. ************************************************/
  380. struct io_register {
  381. u8 io_addr;
  382. u8 start_bit;
  383. u8 end_bit;
  384. };
  385. /* IGA1 Horizontal Total */
  386. struct iga1_hor_total {
  387. int reg_num;
  388. struct io_register reg[IGA1_HOR_TOTAL_REG_NUM];
  389. };
  390. /* IGA1 Horizontal Addressable Video */
  391. struct iga1_hor_addr {
  392. int reg_num;
  393. struct io_register reg[IGA1_HOR_ADDR_REG_NUM];
  394. };
  395. /* IGA1 Horizontal Blank Start */
  396. struct iga1_hor_blank_start {
  397. int reg_num;
  398. struct io_register reg[IGA1_HOR_BLANK_START_REG_NUM];
  399. };
  400. /* IGA1 Horizontal Blank End */
  401. struct iga1_hor_blank_end {
  402. int reg_num;
  403. struct io_register reg[IGA1_HOR_BLANK_END_REG_NUM];
  404. };
  405. /* IGA1 Horizontal Sync Start */
  406. struct iga1_hor_sync_start {
  407. int reg_num;
  408. struct io_register reg[IGA1_HOR_SYNC_START_REG_NUM];
  409. };
  410. /* IGA1 Horizontal Sync End */
  411. struct iga1_hor_sync_end {
  412. int reg_num;
  413. struct io_register reg[IGA1_HOR_SYNC_END_REG_NUM];
  414. };
  415. /* IGA1 Vertical Total */
  416. struct iga1_ver_total {
  417. int reg_num;
  418. struct io_register reg[IGA1_VER_TOTAL_REG_NUM];
  419. };
  420. /* IGA1 Vertical Addressable Video */
  421. struct iga1_ver_addr {
  422. int reg_num;
  423. struct io_register reg[IGA1_VER_ADDR_REG_NUM];
  424. };
  425. /* IGA1 Vertical Blank Start */
  426. struct iga1_ver_blank_start {
  427. int reg_num;
  428. struct io_register reg[IGA1_VER_BLANK_START_REG_NUM];
  429. };
  430. /* IGA1 Vertical Blank End */
  431. struct iga1_ver_blank_end {
  432. int reg_num;
  433. struct io_register reg[IGA1_VER_BLANK_END_REG_NUM];
  434. };
  435. /* IGA1 Vertical Sync Start */
  436. struct iga1_ver_sync_start {
  437. int reg_num;
  438. struct io_register reg[IGA1_VER_SYNC_START_REG_NUM];
  439. };
  440. /* IGA1 Vertical Sync End */
  441. struct iga1_ver_sync_end {
  442. int reg_num;
  443. struct io_register reg[IGA1_VER_SYNC_END_REG_NUM];
  444. };
  445. /*****************************************************
  446. ** Define IGA2 Shadow Display Timing ****
  447. *****************************************************/
  448. /* IGA2 Shadow Horizontal Total */
  449. struct iga2_shadow_hor_total {
  450. int reg_num;
  451. struct io_register reg[IGA2_SHADOW_HOR_TOTAL_REG_NUM];
  452. };
  453. /* IGA2 Shadow Horizontal Blank End */
  454. struct iga2_shadow_hor_blank_end {
  455. int reg_num;
  456. struct io_register reg[IGA2_SHADOW_HOR_BLANK_END_REG_NUM];
  457. };
  458. /* IGA2 Shadow Vertical Total */
  459. struct iga2_shadow_ver_total {
  460. int reg_num;
  461. struct io_register reg[IGA2_SHADOW_VER_TOTAL_REG_NUM];
  462. };
  463. /* IGA2 Shadow Vertical Addressable Video */
  464. struct iga2_shadow_ver_addr {
  465. int reg_num;
  466. struct io_register reg[IGA2_SHADOW_VER_ADDR_REG_NUM];
  467. };
  468. /* IGA2 Shadow Vertical Blank Start */
  469. struct iga2_shadow_ver_blank_start {
  470. int reg_num;
  471. struct io_register reg[IGA2_SHADOW_VER_BLANK_START_REG_NUM];
  472. };
  473. /* IGA2 Shadow Vertical Blank End */
  474. struct iga2_shadow_ver_blank_end {
  475. int reg_num;
  476. struct io_register reg[IGA2_SHADOW_VER_BLANK_END_REG_NUM];
  477. };
  478. /* IGA2 Shadow Vertical Sync Start */
  479. struct iga2_shadow_ver_sync_start {
  480. int reg_num;
  481. struct io_register reg[IGA2_SHADOW_VER_SYNC_START_REG_NUM];
  482. };
  483. /* IGA2 Shadow Vertical Sync End */
  484. struct iga2_shadow_ver_sync_end {
  485. int reg_num;
  486. struct io_register reg[IGA2_SHADOW_VER_SYNC_END_REG_NUM];
  487. };
  488. /*****************************************************
  489. ** Define IGA2 Display Timing ****
  490. ******************************************************/
  491. /* IGA2 Horizontal Total */
  492. struct iga2_hor_total {
  493. int reg_num;
  494. struct io_register reg[IGA2_HOR_TOTAL_REG_NUM];
  495. };
  496. /* IGA2 Horizontal Addressable Video */
  497. struct iga2_hor_addr {
  498. int reg_num;
  499. struct io_register reg[IGA2_HOR_ADDR_REG_NUM];
  500. };
  501. /* IGA2 Horizontal Blank Start */
  502. struct iga2_hor_blank_start {
  503. int reg_num;
  504. struct io_register reg[IGA2_HOR_BLANK_START_REG_NUM];
  505. };
  506. /* IGA2 Horizontal Blank End */
  507. struct iga2_hor_blank_end {
  508. int reg_num;
  509. struct io_register reg[IGA2_HOR_BLANK_END_REG_NUM];
  510. };
  511. /* IGA2 Horizontal Sync Start */
  512. struct iga2_hor_sync_start {
  513. int reg_num;
  514. struct io_register reg[IGA2_HOR_SYNC_START_REG_NUM];
  515. };
  516. /* IGA2 Horizontal Sync End */
  517. struct iga2_hor_sync_end {
  518. int reg_num;
  519. struct io_register reg[IGA2_HOR_SYNC_END_REG_NUM];
  520. };
  521. /* IGA2 Vertical Total */
  522. struct iga2_ver_total {
  523. int reg_num;
  524. struct io_register reg[IGA2_VER_TOTAL_REG_NUM];
  525. };
  526. /* IGA2 Vertical Addressable Video */
  527. struct iga2_ver_addr {
  528. int reg_num;
  529. struct io_register reg[IGA2_VER_ADDR_REG_NUM];
  530. };
  531. /* IGA2 Vertical Blank Start */
  532. struct iga2_ver_blank_start {
  533. int reg_num;
  534. struct io_register reg[IGA2_VER_BLANK_START_REG_NUM];
  535. };
  536. /* IGA2 Vertical Blank End */
  537. struct iga2_ver_blank_end {
  538. int reg_num;
  539. struct io_register reg[IGA2_VER_BLANK_END_REG_NUM];
  540. };
  541. /* IGA2 Vertical Sync Start */
  542. struct iga2_ver_sync_start {
  543. int reg_num;
  544. struct io_register reg[IGA2_VER_SYNC_START_REG_NUM];
  545. };
  546. /* IGA2 Vertical Sync End */
  547. struct iga2_ver_sync_end {
  548. int reg_num;
  549. struct io_register reg[IGA2_VER_SYNC_END_REG_NUM];
  550. };
  551. /* IGA1 Fetch Count Register */
  552. struct iga1_fetch_count {
  553. int reg_num;
  554. struct io_register reg[IGA1_FETCH_COUNT_REG_NUM];
  555. };
  556. /* IGA2 Fetch Count Register */
  557. struct iga2_fetch_count {
  558. int reg_num;
  559. struct io_register reg[IGA2_FETCH_COUNT_REG_NUM];
  560. };
  561. struct fetch_count {
  562. struct iga1_fetch_count iga1_fetch_count_reg;
  563. struct iga2_fetch_count iga2_fetch_count_reg;
  564. };
  565. /* Starting Address Register */
  566. struct iga1_starting_addr {
  567. int reg_num;
  568. struct io_register reg[IGA1_STARTING_ADDR_REG_NUM];
  569. };
  570. struct iga2_starting_addr {
  571. int reg_num;
  572. struct io_register reg[IGA2_STARTING_ADDR_REG_NUM];
  573. };
  574. struct starting_addr {
  575. struct iga1_starting_addr iga1_starting_addr_reg;
  576. struct iga2_starting_addr iga2_starting_addr_reg;
  577. };
  578. /* LCD Power Sequence Timer */
  579. struct lcd_pwd_seq_td0 {
  580. int reg_num;
  581. struct io_register reg[LCD_POWER_SEQ_TD0_REG_NUM];
  582. };
  583. struct lcd_pwd_seq_td1 {
  584. int reg_num;
  585. struct io_register reg[LCD_POWER_SEQ_TD1_REG_NUM];
  586. };
  587. struct lcd_pwd_seq_td2 {
  588. int reg_num;
  589. struct io_register reg[LCD_POWER_SEQ_TD2_REG_NUM];
  590. };
  591. struct lcd_pwd_seq_td3 {
  592. int reg_num;
  593. struct io_register reg[LCD_POWER_SEQ_TD3_REG_NUM];
  594. };
  595. struct _lcd_pwd_seq_timer {
  596. struct lcd_pwd_seq_td0 td0;
  597. struct lcd_pwd_seq_td1 td1;
  598. struct lcd_pwd_seq_td2 td2;
  599. struct lcd_pwd_seq_td3 td3;
  600. };
  601. /* LCD Scaling Factor */
  602. struct _lcd_hor_scaling_factor {
  603. int reg_num;
  604. struct io_register reg[LCD_HOR_SCALING_FACTOR_REG_NUM];
  605. };
  606. struct _lcd_ver_scaling_factor {
  607. int reg_num;
  608. struct io_register reg[LCD_VER_SCALING_FACTOR_REG_NUM];
  609. };
  610. struct _lcd_scaling_factor {
  611. struct _lcd_hor_scaling_factor lcd_hor_scaling_factor;
  612. struct _lcd_ver_scaling_factor lcd_ver_scaling_factor;
  613. };
  614. struct pll_config {
  615. u16 multiplier;
  616. u8 divisor;
  617. u8 rshift;
  618. };
  619. struct pll_map {
  620. u32 clk;
  621. struct pll_config cle266_pll;
  622. struct pll_config k800_pll;
  623. struct pll_config cx700_pll;
  624. struct pll_config vx855_pll;
  625. };
  626. struct rgbLUT {
  627. u8 red;
  628. u8 green;
  629. u8 blue;
  630. };
  631. struct lcd_pwd_seq_timer {
  632. u16 td0;
  633. u16 td1;
  634. u16 td2;
  635. u16 td3;
  636. };
  637. /* Display FIFO Relation Registers*/
  638. struct iga1_fifo_depth_select {
  639. int reg_num;
  640. struct io_register reg[IGA1_FIFO_DEPTH_SELECT_REG_NUM];
  641. };
  642. struct iga1_fifo_threshold_select {
  643. int reg_num;
  644. struct io_register reg[IGA1_FIFO_THRESHOLD_REG_NUM];
  645. };
  646. struct iga1_fifo_high_threshold_select {
  647. int reg_num;
  648. struct io_register reg[IGA1_FIFO_HIGH_THRESHOLD_REG_NUM];
  649. };
  650. struct iga1_display_queue_expire_num {
  651. int reg_num;
  652. struct io_register reg[IGA1_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
  653. };
  654. struct iga2_fifo_depth_select {
  655. int reg_num;
  656. struct io_register reg[IGA2_FIFO_DEPTH_SELECT_REG_NUM];
  657. };
  658. struct iga2_fifo_threshold_select {
  659. int reg_num;
  660. struct io_register reg[IGA2_FIFO_THRESHOLD_REG_NUM];
  661. };
  662. struct iga2_fifo_high_threshold_select {
  663. int reg_num;
  664. struct io_register reg[IGA2_FIFO_HIGH_THRESHOLD_REG_NUM];
  665. };
  666. struct iga2_display_queue_expire_num {
  667. int reg_num;
  668. struct io_register reg[IGA2_DISPLAY_QUEUE_EXPIRE_NUM_REG_NUM];
  669. };
  670. struct fifo_depth_select {
  671. struct iga1_fifo_depth_select iga1_fifo_depth_select_reg;
  672. struct iga2_fifo_depth_select iga2_fifo_depth_select_reg;
  673. };
  674. struct fifo_threshold_select {
  675. struct iga1_fifo_threshold_select iga1_fifo_threshold_select_reg;
  676. struct iga2_fifo_threshold_select iga2_fifo_threshold_select_reg;
  677. };
  678. struct fifo_high_threshold_select {
  679. struct iga1_fifo_high_threshold_select
  680. iga1_fifo_high_threshold_select_reg;
  681. struct iga2_fifo_high_threshold_select
  682. iga2_fifo_high_threshold_select_reg;
  683. };
  684. struct display_queue_expire_num {
  685. struct iga1_display_queue_expire_num
  686. iga1_display_queue_expire_num_reg;
  687. struct iga2_display_queue_expire_num
  688. iga2_display_queue_expire_num_reg;
  689. };
  690. struct iga1_crtc_timing {
  691. struct iga1_hor_total hor_total;
  692. struct iga1_hor_addr hor_addr;
  693. struct iga1_hor_blank_start hor_blank_start;
  694. struct iga1_hor_blank_end hor_blank_end;
  695. struct iga1_hor_sync_start hor_sync_start;
  696. struct iga1_hor_sync_end hor_sync_end;
  697. struct iga1_ver_total ver_total;
  698. struct iga1_ver_addr ver_addr;
  699. struct iga1_ver_blank_start ver_blank_start;
  700. struct iga1_ver_blank_end ver_blank_end;
  701. struct iga1_ver_sync_start ver_sync_start;
  702. struct iga1_ver_sync_end ver_sync_end;
  703. };
  704. struct iga2_shadow_crtc_timing {
  705. struct iga2_shadow_hor_total hor_total_shadow;
  706. struct iga2_shadow_hor_blank_end hor_blank_end_shadow;
  707. struct iga2_shadow_ver_total ver_total_shadow;
  708. struct iga2_shadow_ver_addr ver_addr_shadow;
  709. struct iga2_shadow_ver_blank_start ver_blank_start_shadow;
  710. struct iga2_shadow_ver_blank_end ver_blank_end_shadow;
  711. struct iga2_shadow_ver_sync_start ver_sync_start_shadow;
  712. struct iga2_shadow_ver_sync_end ver_sync_end_shadow;
  713. };
  714. struct iga2_crtc_timing {
  715. struct iga2_hor_total hor_total;
  716. struct iga2_hor_addr hor_addr;
  717. struct iga2_hor_blank_start hor_blank_start;
  718. struct iga2_hor_blank_end hor_blank_end;
  719. struct iga2_hor_sync_start hor_sync_start;
  720. struct iga2_hor_sync_end hor_sync_end;
  721. struct iga2_ver_total ver_total;
  722. struct iga2_ver_addr ver_addr;
  723. struct iga2_ver_blank_start ver_blank_start;
  724. struct iga2_ver_blank_end ver_blank_end;
  725. struct iga2_ver_sync_start ver_sync_start;
  726. struct iga2_ver_sync_end ver_sync_end;
  727. };
  728. /* device ID */
  729. #define CLE266_FUNCTION3 0x3123
  730. #define KM400_FUNCTION3 0x3205
  731. #define CN400_FUNCTION2 0x2259
  732. #define CN400_FUNCTION3 0x3259
  733. /* support VT3314 chipset */
  734. #define CN700_FUNCTION2 0x2314
  735. #define CN700_FUNCTION3 0x3208
  736. /* VT3324 chipset */
  737. #define CX700_FUNCTION2 0x2324
  738. #define CX700_FUNCTION3 0x3324
  739. /* VT3204 chipset*/
  740. #define KM800_FUNCTION3 0x3204
  741. /* VT3336 chipset*/
  742. #define KM890_FUNCTION3 0x3336
  743. /* VT3327 chipset*/
  744. #define P4M890_FUNCTION3 0x3327
  745. /* VT3293 chipset*/
  746. #define CN750_FUNCTION3 0x3208
  747. /* VT3364 chipset*/
  748. #define P4M900_FUNCTION3 0x3364
  749. /* VT3353 chipset*/
  750. #define VX800_FUNCTION3 0x3353
  751. /* VT3409 chipset*/
  752. #define VX855_FUNCTION3 0x3409
  753. #define NUM_TOTAL_PLL_TABLE ARRAY_SIZE(pll_value)
  754. struct IODATA {
  755. u8 Index;
  756. u8 Mask;
  757. u8 Data;
  758. };
  759. struct pci_device_id_info {
  760. u32 vendor;
  761. u32 device;
  762. u32 chip_index;
  763. };
  764. struct via_device_mapping {
  765. u32 device;
  766. const char *name;
  767. };
  768. extern unsigned int viafb_second_virtual_xres;
  769. extern int viafb_SAMM_ON;
  770. extern int viafb_dual_fb;
  771. extern int viafb_LCD2_ON;
  772. extern int viafb_LCD_ON;
  773. extern int viafb_DVI_ON;
  774. extern int viafb_hotplug;
  775. void viafb_fill_crtc_timing(struct crt_mode_table *crt_table,
  776. struct VideoModeTable *video_mode, int bpp_byte, int set_iga);
  777. void viafb_set_vclock(u32 CLK, int set_iga);
  778. void viafb_load_reg(int timing_value, int viafb_load_reg_num,
  779. struct io_register *reg,
  780. int io_type);
  781. void viafb_crt_disable(void);
  782. void viafb_crt_enable(void);
  783. void via_set_source(u32 devices, u8 iga);
  784. u32 via_parse_odev(char *input, char **end);
  785. void via_odev_to_seq(struct seq_file *m, u32 odev);
  786. void init_ad9389(void);
  787. /* Access I/O Function */
  788. void viafb_lock_crt(void);
  789. void viafb_unlock_crt(void);
  790. void viafb_load_fetch_count_reg(int h_addr, int bpp_byte, int set_iga);
  791. void viafb_write_regx(struct io_reg RegTable[], int ItemNum);
  792. u32 viafb_get_clk_value(int clk);
  793. void viafb_load_FIFO_reg(int set_iga, int hor_active, int ver_active);
  794. void viafb_set_dpa_gfx(int output_interface, struct GFX_DPA_SETTING\
  795. *p_gfx_dpa_setting);
  796. int viafb_setmode(struct VideoModeTable *vmode_tbl, int video_bpp,
  797. struct VideoModeTable *vmode_tbl1, int video_bpp1);
  798. void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh,
  799. struct VideoModeTable *vmode_tbl);
  800. void __devinit viafb_init_chip_info(int chip_type);
  801. void __devinit viafb_init_dac(int set_iga);
  802. int viafb_get_pixclock(int hres, int vres, int vmode_refresh);
  803. int viafb_get_refresh(int hres, int vres, u32 float_refresh);
  804. void viafb_update_device_setting(int hres, int vres, int bpp,
  805. int vmode_refresh, int flag);
  806. void viafb_set_iga_path(void);
  807. void viafb_set_primary_color_register(u8 index, u8 red, u8 green, u8 blue);
  808. void viafb_set_secondary_color_register(u8 index, u8 red, u8 green, u8 blue);
  809. void viafb_get_fb_info(unsigned int *fb_base, unsigned int *fb_len);
  810. #endif /* __HW_H__ */