IBM.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. #include <xf86RamDac.h>
  2. extern _X_EXPORT RamDacHelperRecPtr IBMramdacProbe(ScrnInfoPtr pScrn,
  3. RamDacSupportedInfoRecPtr
  4. ramdacs);
  5. extern _X_EXPORT void IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr RamDacRec,
  6. RamDacRegRecPtr RamDacRegRec);
  7. extern _X_EXPORT void IBMramdacRestore(ScrnInfoPtr pScrn,
  8. RamDacRecPtr RamDacRec,
  9. RamDacRegRecPtr RamDacRegRec);
  10. extern _X_EXPORT void IBMramdac526SetBpp(ScrnInfoPtr pScrn,
  11. RamDacRegRecPtr RamDacRegRec);
  12. extern _X_EXPORT void IBMramdac640SetBpp(ScrnInfoPtr pScrn,
  13. RamDacRegRecPtr RamDacRegRec);
  14. extern _X_EXPORT unsigned long IBMramdac526CalculateMNPCForClock(unsigned long
  15. RefClock,
  16. unsigned long
  17. ReqClock,
  18. char
  19. IsPixClock,
  20. unsigned long
  21. MinClock,
  22. unsigned long
  23. MaxClock,
  24. unsigned long
  25. *rM,
  26. unsigned long
  27. *rN,
  28. unsigned long
  29. *rP,
  30. unsigned long
  31. *rC);
  32. extern _X_EXPORT unsigned long IBMramdac640CalculateMNPCForClock(unsigned long
  33. RefClock,
  34. unsigned long
  35. ReqClock,
  36. char
  37. IsPixClock,
  38. unsigned long
  39. MinClock,
  40. unsigned long
  41. MaxClock,
  42. unsigned long
  43. *rM,
  44. unsigned long
  45. *rN,
  46. unsigned long
  47. *rP,
  48. unsigned long
  49. *rC);
  50. extern _X_EXPORT void IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr);
  51. extern _X_EXPORT void IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr);
  52. typedef void IBMramdac526SetBppProc(ScrnInfoPtr, RamDacRegRecPtr);
  53. extern _X_EXPORT IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void);
  54. #define IBM524_RAMDAC ((VENDOR_IBM << 16) | 0x00)
  55. #define IBM524A_RAMDAC ((VENDOR_IBM << 16) | 0x01)
  56. #define IBM525_RAMDAC ((VENDOR_IBM << 16) | 0x02)
  57. #define IBM526_RAMDAC ((VENDOR_IBM << 16) | 0x03)
  58. #define IBM526DB_RAMDAC ((VENDOR_IBM << 16) | 0x04)
  59. #define IBM528_RAMDAC ((VENDOR_IBM << 16) | 0x05)
  60. #define IBM528A_RAMDAC ((VENDOR_IBM << 16) | 0x06)
  61. #define IBM624_RAMDAC ((VENDOR_IBM << 16) | 0x07)
  62. #define IBM624DB_RAMDAC ((VENDOR_IBM << 16) | 0x08)
  63. #define IBM640_RAMDAC ((VENDOR_IBM << 16) | 0x09)
  64. /*
  65. * IBM Ramdac registers
  66. */
  67. #define IBMRGB_REF_FREQ_1 14.31818
  68. #define IBMRGB_REF_FREQ_2 50.00000
  69. #define IBMRGB_rev 0x00
  70. #define IBMRGB_id 0x01
  71. #define IBMRGB_misc_clock 0x02
  72. #define IBMRGB_sync 0x03
  73. #define IBMRGB_hsync_pos 0x04
  74. #define IBMRGB_pwr_mgmt 0x05
  75. #define IBMRGB_dac_op 0x06
  76. #define IBMRGB_pal_ctrl 0x07
  77. #define IBMRGB_sysclk 0x08 /* not RGB525 */
  78. #define IBMRGB_pix_fmt 0x0a
  79. #define IBMRGB_8bpp 0x0b
  80. #define IBMRGB_16bpp 0x0c
  81. #define IBMRGB_24bpp 0x0d
  82. #define IBMRGB_32bpp 0x0e
  83. #define IBMRGB_pll_ctrl1 0x10
  84. #define IBMRGB_pll_ctrl2 0x11
  85. #define IBMRGB_pll_ref_div_fix 0x14
  86. #define IBMRGB_sysclk_ref_div 0x15 /* not RGB525 */
  87. #define IBMRGB_sysclk_vco_div 0x16 /* not RGB525 */
  88. /* #define IBMRGB_f0 0x20 */
  89. #define IBMRGB_sysclk_n 0x15
  90. #define IBMRGB_sysclk_m 0x16
  91. #define IBMRGB_sysclk_p 0x17
  92. #define IBMRGB_sysclk_c 0x18
  93. #define IBMRGB_m0 0x20
  94. #define IBMRGB_n0 0x21
  95. #define IBMRGB_p0 0x22
  96. #define IBMRGB_c0 0x23
  97. #define IBMRGB_m1 0x24
  98. #define IBMRGB_n1 0x25
  99. #define IBMRGB_p1 0x26
  100. #define IBMRGB_c1 0x27
  101. #define IBMRGB_m2 0x28
  102. #define IBMRGB_n2 0x29
  103. #define IBMRGB_p2 0x2a
  104. #define IBMRGB_c2 0x2b
  105. #define IBMRGB_m3 0x2c
  106. #define IBMRGB_n3 0x2d
  107. #define IBMRGB_p3 0x2e
  108. #define IBMRGB_c3 0x2f
  109. #define IBMRGB_curs 0x30
  110. #define IBMRGB_curs_xl 0x31
  111. #define IBMRGB_curs_xh 0x32
  112. #define IBMRGB_curs_yl 0x33
  113. #define IBMRGB_curs_yh 0x34
  114. #define IBMRGB_curs_hot_x 0x35
  115. #define IBMRGB_curs_hot_y 0x36
  116. #define IBMRGB_curs_col1_r 0x40
  117. #define IBMRGB_curs_col1_g 0x41
  118. #define IBMRGB_curs_col1_b 0x42
  119. #define IBMRGB_curs_col2_r 0x43
  120. #define IBMRGB_curs_col2_g 0x44
  121. #define IBMRGB_curs_col2_b 0x45
  122. #define IBMRGB_curs_col3_r 0x46
  123. #define IBMRGB_curs_col3_g 0x47
  124. #define IBMRGB_curs_col3_b 0x48
  125. #define IBMRGB_border_col_r 0x60
  126. #define IBMRGB_border_col_g 0x61
  127. #define IBMRGB_botder_col_b 0x62
  128. #define IBMRGB_key 0x68
  129. #define IBMRGB_key_mask 0x6C
  130. #define IBMRGB_misc1 0x70
  131. #define IBMRGB_misc2 0x71
  132. #define IBMRGB_misc3 0x72
  133. #define IBMRGB_misc4 0x73 /* not RGB525 */
  134. #define IBMRGB_key_control 0x78
  135. #define IBMRGB_dac_sense 0x82
  136. #define IBMRGB_misr_r 0x84
  137. #define IBMRGB_misr_g 0x86
  138. #define IBMRGB_misr_b 0x88
  139. #define IBMRGB_pll_vco_div_in 0x8e
  140. #define IBMRGB_pll_ref_div_in 0x8f
  141. #define IBMRGB_vram_mask_0 0x90
  142. #define IBMRGB_vram_mask_1 0x91
  143. #define IBMRGB_vram_mask_2 0x92
  144. #define IBMRGB_vram_mask_3 0x93
  145. #define IBMRGB_curs_array 0x100
  146. /* Constants rgb525.h */
  147. /* RGB525_REVISION_LEVEL */
  148. #define RGB525_PRODUCT_REV_LEVEL 0xf0
  149. /* RGB525_ID */
  150. #define RGB525_PRODUCT_ID 0x01
  151. /* RGB525_MISC_CTRL_1 */
  152. #define MISR_CNTL_ENABLE 0x80
  153. #define VMSK_CNTL_ENABLE 0x40
  154. #define PADR_RDMT_RDADDR 0x0
  155. #define PADR_RDMT_PAL_STATE 0x20
  156. #define SENS_DSAB_DISABLE 0x10
  157. #define SENS_SEL_BIT3 0x0
  158. #define SENS_SEL_BIT7 0x08
  159. #define VRAM_SIZE_32 0x0
  160. #define VRAM_SIZE_64 0x01
  161. /* RGB525_MISC_CTRL_2 */
  162. #define PCLK_SEL_LCLK 0x0
  163. #define PCLK_SEL_PLL 0x40
  164. #define PCLK_SEL_EXT 0x80
  165. #define INTL_MODE_ENABLE 0x20
  166. #define BLANK_CNTL_ENABLE 0x10
  167. #define COL_RES_6BIT 0x0
  168. #define COL_RES_8BIT 0x04
  169. #define PORT_SEL_VGA 0x0
  170. #define PORT_SEL_VRAM 0x01
  171. /* RGB525_MISC_CTRL_3 */
  172. #define SWAP_RB 0x80
  173. #define SWAP_WORD_LOHI 0x0
  174. #define SWAP_WORD_HILO 0x10
  175. #define SWAP_NIB_HILO 0x0
  176. #define SWAP_NIB_LOHI 0x02
  177. /* RGB525_MISC_CLK_CTRL */
  178. #define DDOT_CLK_ENABLE 0x0
  179. #define DDOT_CLK_DISABLE 0x80
  180. #define SCLK_ENABLE 0x0
  181. #define SCLK_DISABLE 0x40
  182. #define B24P_DDOT_PLL 0x0
  183. #define B24P_DDOT_SCLK 0x20
  184. #define DDOT_DIV_PLL_1 0x0
  185. #define DDOT_DIV_PLL_2 0x02
  186. #define DDOT_DIV_PLL_4 0x04
  187. #define DDOT_DIV_PLL_8 0x06
  188. #define DDOT_DIV_PLL_16 0x08
  189. #define PLL_DISABLE 0x0
  190. #define PLL_ENABLE 0x01
  191. /* RGB525_SYNC_CTRL */
  192. #define DLY_CNTL_ADD 0x0
  193. #define DLY_SYNC_NOADD 0x80
  194. #define CSYN_INVT_DISABLE 0x0
  195. #define CSYN_INVT_ENABLE 0x40
  196. #define VSYN_INVT_DISABLE 0x0
  197. #define VSYN_INVT_ENABLE 0x20
  198. #define HSYN_INVT_DISABLE 0x0
  199. #define HSYN_INVT_ENABLE 0x10
  200. #define VSYN_CNTL_NORMAL 0x0
  201. #define VSYN_CNTL_HIGH 0x04
  202. #define VSYN_CNTL_LOW 0x08
  203. #define VSYN_CNTL_DISABLE 0x0C
  204. #define HSYN_CNTL_NORMAL 0x0
  205. #define HSYN_CNTL_HIGH 0x01
  206. #define HSYN_CNTL_LOW 0x02
  207. #define HSYN_CNTL_DISABLE 0x03
  208. /* RGB525_HSYNC_CTRL */
  209. #define HSYN_POS(n) (n)
  210. /* RGB525_POWER_MANAGEMENT */
  211. #define SCLK_PWR_NORMAL 0x0
  212. #define SCLK_PWR_DISABLE 0x10
  213. #define DDOT_PWR_NORMAL 0x0
  214. #define DDOT_PWR_DISABLE 0x08
  215. #define SYNC_PWR_NORMAL 0x0
  216. #define SYNC_PWR_DISABLE 0x04
  217. #define ICLK_PWR_NORMAL 0x0
  218. #define ICLK_PWR_DISABLE 0x02
  219. #define DAC_PWR_NORMAL 0x0
  220. #define DAC_PWR_DISABLE 0x01
  221. /* RGB525_DAC_OPERATION */
  222. #define SOG_DISABLE 0x0
  223. #define SOG_ENABLE 0x08
  224. #define BRB_NORMAL 0x0
  225. #define BRB_ALWAYS 0x04
  226. #define DSR_DAC_SLOW 0x02
  227. #define DSR_DAC_FAST 0x0
  228. #define DPE_DISABLE 0x0
  229. #define DPE_ENABLE 0x01
  230. /* RGB525_PALETTE_CTRL */
  231. #define SIXBIT_LINEAR_ENABLE 0x0
  232. #define SIXBIT_LINEAR_DISABLE 0x80
  233. #define PALETTE_PARITION(n) (n)
  234. /* RGB525_PIXEL_FORMAT */
  235. #define PIXEL_FORMAT_4BPP 0x02
  236. #define PIXEL_FORMAT_8BPP 0x03
  237. #define PIXEL_FORMAT_16BPP 0x04
  238. #define PIXEL_FORMAT_24BPP 0x05
  239. #define PIXEL_FORMAT_32BPP 0x06
  240. /* RGB525_8BPP_CTRL */
  241. #define B8_DCOL_INDIRECT 0x0
  242. #define B8_DCOL_DIRECT 0x01
  243. /* RGB525_16BPP_CTRL */
  244. #define B16_DCOL_INDIRECT 0x0
  245. #define B16_DCOL_DYNAMIC 0x40
  246. #define B16_DCOL_DIRECT 0xC0
  247. #define B16_POL_FORCE_BYPASS 0x0
  248. #define B16_POL_FORCE_LOOKUP 0x20
  249. #define B16_ZIB 0x0
  250. #define B16_LINEAR 0x04
  251. #define B16_555 0x0
  252. #define B16_565 0x02
  253. #define B16_SPARSE 0x0
  254. #define B16_CONTIGUOUS 0x01
  255. /* RGB525_24BPP_CTRL */
  256. #define B24_DCOL_INDIRECT 0x0
  257. #define B24_DCOL_DIRECT 0x01
  258. /* RGB525_32BPP_CTRL */
  259. #define B32_POL_FORCE_BYPASS 0x0
  260. #define B32_POL_FORCE_LOOKUP 0x04
  261. #define B32_DCOL_INDIRECT 0x0
  262. #define B32_DCOL_DYNAMIC 0x01
  263. #define B32_DCOL_DIRECT 0x03
  264. /* RGB525_PLL_CTRL_1 */
  265. #define REF_SRC_REFCLK 0x0
  266. #define REF_SRC_EXTCLK 0x10
  267. #define PLL_EXT_FS_3_0 0x0
  268. #define PLL_EXT_FS_2_0 0x01
  269. #define PLL_CNTL2_3_0 0x02
  270. #define PLL_CNTL2_2_0 0x03
  271. /* RGB525_PLL_CTRL_2 */
  272. #define PLL_INT_FS_3_0(n) (n)
  273. #define PLL_INT_FS_2_0(n) (n)
  274. /* RGB525_PLL_REF_DIV_COUNT */
  275. #define REF_DIV_COUNT(n) (n)
  276. /* RGB525_F0 - RGB525_F15 */
  277. #define VCO_DIV_COUNT(n) (n)
  278. /* RGB525_PLL_REFCLK values */
  279. #define RGB525_PLL_REFCLK_MHz(n) ((n)/2)
  280. /* RGB525_CURSOR_CONTROL */
  281. #define SMLC_PART_0 0x0
  282. #define SMLC_PART_1 0x40
  283. #define SMLC_PART_2 0x80
  284. #define SMLC_PART_3 0xC0
  285. #define PIX_ORDER_RL 0x0
  286. #define PIX_ORDER_LR 0x20
  287. #define LOC_READ_LAST 0x0
  288. #define LOC_READ_ACTUAL 0x10
  289. #define UPDT_CNTL_DELAYED 0x0
  290. #define UPDT_CNTL_IMMEDIATE 0x08
  291. #define CURSOR_SIZE_32 0x0
  292. #define CURSOR_SIZE_64 0x40
  293. #define CURSOR_MODE_OFF 0x0
  294. #define CURSOR_MODE_3_COLOR 0x01
  295. #define CURSOR_MODE_2_COLOR_HL 0x02
  296. #define CURSOR_MODE_2_COLOR 0x03
  297. /* RGB525_REVISION_LEVEL */
  298. #define REVISION_LEVEL 0xF0 /* predefined */
  299. /* RGB525_ID */
  300. #define ID_CODE 0x01 /* predefined */
  301. /* MISR status */
  302. #define RGB525_MISR_DONE 0x01
  303. /* the IBMRGB640 is rather different from the rest of the RAMDACs,
  304. so we define a completely new set of register names for it */
  305. #define RGB640_SER_07_00 0x02
  306. #define RGB640_SER_15_08 0x03
  307. #define RGB640_SER_23_16 0x04
  308. #define RGB640_SER_31_24 0x05
  309. #define RGB640_SER_WID_03_00 0x06
  310. #define RGB640_SER_WID_07_04 0x07
  311. #define RGB640_SER_MODE 0x08
  312. #define IBM640_SER_2_1 0x00
  313. #define IBM640_SER_4_1 0x01
  314. #define IBM640_SER_8_1 0x02
  315. #define IBM640_SER_16_1 0x03
  316. #define IBM640_SER_16_3 0x05
  317. #define IBM640_SER_5_1 0x06
  318. #define RGB640_PIXEL_INTERLEAVE 0x09
  319. #define RGB640_MISC_CONF 0x0a
  320. #define IBM640_PCLK 0x00
  321. #define IBM640_PCLK_2 0x40
  322. #define IBM640_PCLK_4 0x80
  323. #define IBM640_PCLK_8 0xc0
  324. #define IBM640_PSIZE10 0x10
  325. #define IBM640_LCI 0x08
  326. #define IBM640_WIDCTL_MASK 0x07
  327. #define RGB640_VGA_CONTROL 0x0b
  328. #define IBM640_RDBK 0x04
  329. #define IBM640_PSIZE8 0x02
  330. #define IBM640_VRAM 0x01
  331. #define RGB640_DAC_CONTROL 0x0d
  332. #define IBM640_MONO 0x08
  333. #define IBM640_DACENBL 0x04
  334. #define IBM640_SHUNT 0x02
  335. #define IBM640_SLOWSLEW 0x01
  336. #define RGB640_OUTPUT_CONTROL 0x0e
  337. #define IBM640_RDAI 0x04
  338. #define IBM640_WDAI 0x02
  339. #define IBM640_WATCTL 0x01
  340. #define RGB640_SYNC_CONTROL 0x0f
  341. #define IBM640_PWR 0x20
  342. #define IBM640_VSP 0x10
  343. #define IBM640_HSP 0x08
  344. #define IBM640_CSE 0x04
  345. #define IBM640_CSG 0x02
  346. #define IBM640_BPE 0x01
  347. #define RGB640_PLL_N 0x10
  348. #define RGB640_PLL_M 0x11
  349. #define RGB640_PLL_P 0x12
  350. #define RGB640_PLL_CTL 0x13
  351. #define IBM640_PLL_EN 0x04
  352. #define IBM640_PLL_HIGH 0x10
  353. #define IBM640_PLL_LOW 0x01
  354. #define RGB640_AUX_PLL_CTL 0x17
  355. #define IBM640_AUXPLL 0x04
  356. #define IBM640_AUX_HI 0x02
  357. #define IBM640_AUX_LO 0x01
  358. #define RGB640_CHROMA_KEY0 0x20
  359. #define RGB640_CHROMA_MASK0 0x21
  360. #define RGB640_CURS_X_LOW 0x40
  361. #define RGB640_CURS_X_HIGH 0x41
  362. #define RGB640_CURS_Y_LOW 0x42
  363. #define RGB640_CURS_Y_HIGH 0x43
  364. #define RGB640_CURS_OFFSETX 0x44
  365. #define RGB640_CURS_OFFSETY 0x45
  366. #define RGB640_CURSOR_CONTROL 0x4B
  367. #define IBM640_CURS_OFF 0x00
  368. #define IBM640_CURS_MODE0 0x01
  369. #define IBM640_CURS_MODE1 0x02
  370. #define IBM640_CURS_MODE2 0x03
  371. #define IBM640_CURS_ADV 0x04
  372. #define RGB640_CROSSHAIR_CONTROL 0x57
  373. #define RGB640_VRAM_MASK0 0xf0
  374. #define RGB640_VRAM_MASK1 0xf1
  375. #define RGB640_VRAM_MASK2 0xf2
  376. #define RGB640_DIAGS 0xfa
  377. #define RGB640_CURS_WRITE 0x1000
  378. #define RGB640_CURS_COL0 0x4800
  379. #define RGB640_CURS_COL1 0x4801
  380. #define RGB640_CURS_COL2 0x4802
  381. #define RGB640_CURS_COL3 0x4803