sis.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. /*
  2. * SiS 300/540/630[S]/730[S],
  3. * SiS 315[E|PRO]/550/[M]65x/[M]661[F|M]X/740/[M]741[GX]/330/[M]76x[GX],
  4. * XGI V3XT/V5/V8, Z7
  5. * frame buffer driver for Linux kernels >=2.4.14 and >=2.6.3
  6. *
  7. * Copyright (C) 2001-2005 Thomas Winischhofer, Vienna, Austria.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the named License,
  12. * or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
  22. */
  23. #ifndef _SIS_H_
  24. #define _SIS_H_
  25. #include <video/sisfb.h>
  26. #include "vgatypes.h"
  27. #include "vstruct.h"
  28. #include "init.h"
  29. #define VER_MAJOR 1
  30. #define VER_MINOR 8
  31. #define VER_LEVEL 9
  32. #include <linux/spinlock.h>
  33. #ifdef CONFIG_COMPAT
  34. #define SIS_NEW_CONFIG_COMPAT
  35. #endif /* CONFIG_COMPAT */
  36. #undef SISFBDEBUG
  37. #ifdef SISFBDEBUG
  38. #define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
  39. #define TWDEBUG(x) printk(KERN_INFO x "\n");
  40. #else
  41. #define DPRINTK(fmt, args...)
  42. #define TWDEBUG(x)
  43. #endif
  44. #define SISFAIL(x) do { printk(x "\n"); return -EINVAL; } while(0)
  45. /* To be included in pci_ids.h */
  46. #ifndef PCI_DEVICE_ID_SI_650_VGA
  47. #define PCI_DEVICE_ID_SI_650_VGA 0x6325
  48. #endif
  49. #ifndef PCI_DEVICE_ID_SI_650
  50. #define PCI_DEVICE_ID_SI_650 0x0650
  51. #endif
  52. #ifndef PCI_DEVICE_ID_SI_651
  53. #define PCI_DEVICE_ID_SI_651 0x0651
  54. #endif
  55. #ifndef PCI_DEVICE_ID_SI_740
  56. #define PCI_DEVICE_ID_SI_740 0x0740
  57. #endif
  58. #ifndef PCI_DEVICE_ID_SI_330
  59. #define PCI_DEVICE_ID_SI_330 0x0330
  60. #endif
  61. #ifndef PCI_DEVICE_ID_SI_660_VGA
  62. #define PCI_DEVICE_ID_SI_660_VGA 0x6330
  63. #endif
  64. #ifndef PCI_DEVICE_ID_SI_661
  65. #define PCI_DEVICE_ID_SI_661 0x0661
  66. #endif
  67. #ifndef PCI_DEVICE_ID_SI_741
  68. #define PCI_DEVICE_ID_SI_741 0x0741
  69. #endif
  70. #ifndef PCI_DEVICE_ID_SI_660
  71. #define PCI_DEVICE_ID_SI_660 0x0660
  72. #endif
  73. #ifndef PCI_DEVICE_ID_SI_760
  74. #define PCI_DEVICE_ID_SI_760 0x0760
  75. #endif
  76. #ifndef PCI_DEVICE_ID_SI_761
  77. #define PCI_DEVICE_ID_SI_761 0x0761
  78. #endif
  79. #ifndef PCI_VENDOR_ID_XGI
  80. #define PCI_VENDOR_ID_XGI 0x18ca
  81. #endif
  82. #ifndef PCI_DEVICE_ID_XGI_20
  83. #define PCI_DEVICE_ID_XGI_20 0x0020
  84. #endif
  85. #ifndef PCI_DEVICE_ID_XGI_40
  86. #define PCI_DEVICE_ID_XGI_40 0x0040
  87. #endif
  88. /* To be included in fb.h */
  89. #ifndef FB_ACCEL_SIS_GLAMOUR_2
  90. #define FB_ACCEL_SIS_GLAMOUR_2 40 /* SiS 315, 65x, 740, 661, 741 */
  91. #endif
  92. #ifndef FB_ACCEL_SIS_XABRE
  93. #define FB_ACCEL_SIS_XABRE 41 /* SiS 330 ("Xabre"), 76x */
  94. #endif
  95. #ifndef FB_ACCEL_XGI_VOLARI_V
  96. #define FB_ACCEL_XGI_VOLARI_V 47 /* XGI Volari Vx (V3XT, V5, V8) */
  97. #endif
  98. #ifndef FB_ACCEL_XGI_VOLARI_Z
  99. #define FB_ACCEL_XGI_VOLARI_Z 48 /* XGI Volari Z7 */
  100. #endif
  101. /* ivideo->caps */
  102. #define HW_CURSOR_CAP 0x80
  103. #define TURBO_QUEUE_CAP 0x40
  104. #define AGP_CMD_QUEUE_CAP 0x20
  105. #define VM_CMD_QUEUE_CAP 0x10
  106. #define MMIO_CMD_QUEUE_CAP 0x08
  107. /* For 300 series */
  108. #define TURBO_QUEUE_AREA_SIZE (512 * 1024) /* 512K */
  109. #define HW_CURSOR_AREA_SIZE_300 4096 /* 4K */
  110. /* For 315/Xabre series */
  111. #define COMMAND_QUEUE_AREA_SIZE (512 * 1024) /* 512K */
  112. #define COMMAND_QUEUE_AREA_SIZE_Z7 (128 * 1024) /* 128k for XGI Z7 */
  113. #define HW_CURSOR_AREA_SIZE_315 16384 /* 16K */
  114. #define COMMAND_QUEUE_THRESHOLD 0x1F
  115. #define SIS_OH_ALLOC_SIZE 4000
  116. #define SENTINEL 0x7fffffff
  117. #define SEQ_ADR 0x14
  118. #define SEQ_DATA 0x15
  119. #define DAC_ADR 0x18
  120. #define DAC_DATA 0x19
  121. #define CRTC_ADR 0x24
  122. #define CRTC_DATA 0x25
  123. #define DAC2_ADR (0x16-0x30)
  124. #define DAC2_DATA (0x17-0x30)
  125. #define VB_PART1_ADR (0x04-0x30)
  126. #define VB_PART1_DATA (0x05-0x30)
  127. #define VB_PART2_ADR (0x10-0x30)
  128. #define VB_PART2_DATA (0x11-0x30)
  129. #define VB_PART3_ADR (0x12-0x30)
  130. #define VB_PART3_DATA (0x13-0x30)
  131. #define VB_PART4_ADR (0x14-0x30)
  132. #define VB_PART4_DATA (0x15-0x30)
  133. #define SISSR ivideo->SiS_Pr.SiS_P3c4
  134. #define SISCR ivideo->SiS_Pr.SiS_P3d4
  135. #define SISDACA ivideo->SiS_Pr.SiS_P3c8
  136. #define SISDACD ivideo->SiS_Pr.SiS_P3c9
  137. #define SISPART1 ivideo->SiS_Pr.SiS_Part1Port
  138. #define SISPART2 ivideo->SiS_Pr.SiS_Part2Port
  139. #define SISPART3 ivideo->SiS_Pr.SiS_Part3Port
  140. #define SISPART4 ivideo->SiS_Pr.SiS_Part4Port
  141. #define SISPART5 ivideo->SiS_Pr.SiS_Part5Port
  142. #define SISDAC2A SISPART5
  143. #define SISDAC2D (SISPART5 + 1)
  144. #define SISMISCR (ivideo->SiS_Pr.RelIO + 0x1c)
  145. #define SISMISCW ivideo->SiS_Pr.SiS_P3c2
  146. #define SISINPSTAT (ivideo->SiS_Pr.RelIO + 0x2a)
  147. #define SISPEL ivideo->SiS_Pr.SiS_P3c6
  148. #define SISVGAENABLE (ivideo->SiS_Pr.RelIO + 0x13)
  149. #define SISVID (ivideo->SiS_Pr.RelIO + 0x02 - 0x30)
  150. #define SISCAP (ivideo->SiS_Pr.RelIO + 0x00 - 0x30)
  151. #define IND_SIS_PASSWORD 0x05 /* SRs */
  152. #define IND_SIS_COLOR_MODE 0x06
  153. #define IND_SIS_RAMDAC_CONTROL 0x07
  154. #define IND_SIS_DRAM_SIZE 0x14
  155. #define IND_SIS_MODULE_ENABLE 0x1E
  156. #define IND_SIS_PCI_ADDRESS_SET 0x20
  157. #define IND_SIS_TURBOQUEUE_ADR 0x26
  158. #define IND_SIS_TURBOQUEUE_SET 0x27
  159. #define IND_SIS_POWER_ON_TRAP 0x38
  160. #define IND_SIS_POWER_ON_TRAP2 0x39
  161. #define IND_SIS_CMDQUEUE_SET 0x26
  162. #define IND_SIS_CMDQUEUE_THRESHOLD 0x27
  163. #define IND_SIS_AGP_IO_PAD 0x48
  164. #define SIS_CRT2_WENABLE_300 0x24 /* Part1 */
  165. #define SIS_CRT2_WENABLE_315 0x2F
  166. #define SIS_PASSWORD 0x86 /* SR05 */
  167. #define SIS_INTERLACED_MODE 0x20 /* SR06 */
  168. #define SIS_8BPP_COLOR_MODE 0x0
  169. #define SIS_15BPP_COLOR_MODE 0x1
  170. #define SIS_16BPP_COLOR_MODE 0x2
  171. #define SIS_32BPP_COLOR_MODE 0x4
  172. #define SIS_ENABLE_2D 0x40 /* SR1E */
  173. #define SIS_MEM_MAP_IO_ENABLE 0x01 /* SR20 */
  174. #define SIS_PCI_ADDR_ENABLE 0x80
  175. #define SIS_AGP_CMDQUEUE_ENABLE 0x80 /* 315/330/340 series SR26 */
  176. #define SIS_VRAM_CMDQUEUE_ENABLE 0x40
  177. #define SIS_MMIO_CMD_ENABLE 0x20
  178. #define SIS_CMD_QUEUE_SIZE_512k 0x00
  179. #define SIS_CMD_QUEUE_SIZE_1M 0x04
  180. #define SIS_CMD_QUEUE_SIZE_2M 0x08
  181. #define SIS_CMD_QUEUE_SIZE_4M 0x0C
  182. #define SIS_CMD_QUEUE_RESET 0x01
  183. #define SIS_CMD_AUTO_CORR 0x02
  184. #define SIS_CMD_QUEUE_SIZE_Z7_64k 0x00 /* XGI Z7 */
  185. #define SIS_CMD_QUEUE_SIZE_Z7_128k 0x04
  186. #define SIS_SIMULTANEOUS_VIEW_ENABLE 0x01 /* CR30 */
  187. #define SIS_MODE_SELECT_CRT2 0x02
  188. #define SIS_VB_OUTPUT_COMPOSITE 0x04
  189. #define SIS_VB_OUTPUT_SVIDEO 0x08
  190. #define SIS_VB_OUTPUT_SCART 0x10
  191. #define SIS_VB_OUTPUT_LCD 0x20
  192. #define SIS_VB_OUTPUT_CRT2 0x40
  193. #define SIS_VB_OUTPUT_HIVISION 0x80
  194. #define SIS_VB_OUTPUT_DISABLE 0x20 /* CR31 */
  195. #define SIS_DRIVER_MODE 0x40
  196. #define SIS_VB_COMPOSITE 0x01 /* CR32 */
  197. #define SIS_VB_SVIDEO 0x02
  198. #define SIS_VB_SCART 0x04
  199. #define SIS_VB_LCD 0x08
  200. #define SIS_VB_CRT2 0x10
  201. #define SIS_CRT1 0x20
  202. #define SIS_VB_HIVISION 0x40
  203. #define SIS_VB_YPBPR 0x80
  204. #define SIS_VB_TV (SIS_VB_COMPOSITE | SIS_VB_SVIDEO | \
  205. SIS_VB_SCART | SIS_VB_HIVISION | SIS_VB_YPBPR)
  206. #define SIS_EXTERNAL_CHIP_MASK 0x0E /* CR37 (< SiS 660) */
  207. #define SIS_EXTERNAL_CHIP_SIS301 0x01 /* in CR37 << 1 ! */
  208. #define SIS_EXTERNAL_CHIP_LVDS 0x02
  209. #define SIS_EXTERNAL_CHIP_TRUMPION 0x03
  210. #define SIS_EXTERNAL_CHIP_LVDS_CHRONTEL 0x04
  211. #define SIS_EXTERNAL_CHIP_CHRONTEL 0x05
  212. #define SIS310_EXTERNAL_CHIP_LVDS 0x02
  213. #define SIS310_EXTERNAL_CHIP_LVDS_CHRONTEL 0x03
  214. #define SIS_AGP_2X 0x20 /* CR48 */
  215. /* vbflags, private entries (others in sisfb.h) */
  216. #define VB_CONEXANT 0x00000800 /* 661 series only */
  217. #define VB_TRUMPION VB_CONEXANT /* 300 series only */
  218. #define VB_302ELV 0x00004000
  219. #define VB_301 0x00100000 /* Video bridge type */
  220. #define VB_301B 0x00200000
  221. #define VB_302B 0x00400000
  222. #define VB_30xBDH 0x00800000 /* 30xB DH version (w/o LCD support) */
  223. #define VB_LVDS 0x01000000
  224. #define VB_CHRONTEL 0x02000000
  225. #define VB_301LV 0x04000000
  226. #define VB_302LV 0x08000000
  227. #define VB_301C 0x10000000
  228. #define VB_SISBRIDGE (VB_301|VB_301B|VB_301C|VB_302B|VB_301LV|VB_302LV|VB_302ELV)
  229. #define VB_VIDEOBRIDGE (VB_SISBRIDGE | VB_LVDS | VB_CHRONTEL | VB_CONEXANT)
  230. /* vbflags2 (static stuff only!) */
  231. #define VB2_SISUMC 0x00000001
  232. #define VB2_301 0x00000002 /* Video bridge type */
  233. #define VB2_301B 0x00000004
  234. #define VB2_301C 0x00000008
  235. #define VB2_307T 0x00000010
  236. #define VB2_302B 0x00000800
  237. #define VB2_301LV 0x00001000
  238. #define VB2_302LV 0x00002000
  239. #define VB2_302ELV 0x00004000
  240. #define VB2_307LV 0x00008000
  241. #define VB2_30xBDH 0x08000000 /* 30xB DH version (w/o LCD support) */
  242. #define VB2_CONEXANT 0x10000000
  243. #define VB2_TRUMPION 0x20000000
  244. #define VB2_LVDS 0x40000000
  245. #define VB2_CHRONTEL 0x80000000
  246. #define VB2_SISLVDSBRIDGE (VB2_301LV | VB2_302LV | VB2_302ELV | VB2_307LV)
  247. #define VB2_SISTMDSBRIDGE (VB2_301 | VB2_301B | VB2_301C | VB2_302B | VB2_307T)
  248. #define VB2_SISBRIDGE (VB2_SISLVDSBRIDGE | VB2_SISTMDSBRIDGE)
  249. #define VB2_SISTMDSLCDABRIDGE (VB2_301C | VB2_307T)
  250. #define VB2_SISLCDABRIDGE (VB2_SISTMDSLCDABRIDGE | VB2_301LV | VB2_302LV | VB2_302ELV | VB2_307LV)
  251. #define VB2_SISHIVISIONBRIDGE (VB2_301 | VB2_301B | VB2_302B)
  252. #define VB2_SISYPBPRBRIDGE (VB2_301C | VB2_307T | VB2_SISLVDSBRIDGE)
  253. #define VB2_SISYPBPRARBRIDGE (VB2_301C | VB2_307T | VB2_307LV)
  254. #define VB2_SISTAP4SCALER (VB2_301C | VB2_307T | VB2_302ELV | VB2_307LV)
  255. #define VB2_SISTVBRIDGE (VB2_SISHIVISIONBRIDGE | VB2_SISYPBPRBRIDGE)
  256. #define VB2_SISVGA2BRIDGE (VB2_301 | VB2_301B | VB2_301C | VB2_302B | VB2_307T)
  257. #define VB2_VIDEOBRIDGE (VB2_SISBRIDGE | VB2_LVDS | VB2_CHRONTEL | VB2_CONEXANT)
  258. #define VB2_30xB (VB2_301B | VB2_301C | VB2_302B | VB2_307T)
  259. #define VB2_30xBLV (VB2_30xB | VB2_SISLVDSBRIDGE)
  260. #define VB2_30xC (VB2_301C | VB2_307T)
  261. #define VB2_30xCLV (VB2_301C | VB2_307T | VB2_302ELV| VB2_307LV)
  262. #define VB2_SISEMIBRIDGE (VB2_302LV | VB2_302ELV | VB2_307LV)
  263. #define VB2_LCD162MHZBRIDGE (VB2_301C | VB2_307T)
  264. #define VB2_LCDOVER1280BRIDGE (VB2_301C | VB2_307T | VB2_302LV | VB2_302ELV | VB2_307LV)
  265. #define VB2_LCDOVER1600BRIDGE (VB2_307T | VB2_307LV)
  266. #define VB2_RAMDAC202MHZBRIDGE (VB2_301C | VB2_307T)
  267. /* I/O port access functions */
  268. void SiS_SetReg(SISIOADDRESS, u8, u8);
  269. void SiS_SetRegByte(SISIOADDRESS, u8);
  270. void SiS_SetRegShort(SISIOADDRESS, u16);
  271. void SiS_SetRegLong(SISIOADDRESS, u32);
  272. void SiS_SetRegANDOR(SISIOADDRESS, u8, u8, u8);
  273. void SiS_SetRegAND(SISIOADDRESS, u8, u8);
  274. void SiS_SetRegOR(SISIOADDRESS, u8, u8);
  275. u8 SiS_GetReg(SISIOADDRESS, u8);
  276. u8 SiS_GetRegByte(SISIOADDRESS);
  277. u16 SiS_GetRegShort(SISIOADDRESS);
  278. u32 SiS_GetRegLong(SISIOADDRESS);
  279. /* Chrontel TV, DDC and DPMS functions */
  280. /* from init.c */
  281. bool SiSInitPtr(struct SiS_Private *SiS_Pr);
  282. unsigned short SiS_GetModeID_LCD(int VGAEngine, unsigned int VBFlags, int HDisplay,
  283. int VDisplay, int Depth, bool FSTN,
  284. unsigned short CustomT, int LCDwith, int LCDheight,
  285. unsigned int VBFlags2);
  286. unsigned short SiS_GetModeID_TV(int VGAEngine, unsigned int VBFlags, int HDisplay,
  287. int VDisplay, int Depth, unsigned int VBFlags2);
  288. unsigned short SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay,
  289. int VDisplay, int Depth, unsigned int VBFlags2);
  290. void SiS_DisplayOn(struct SiS_Private *SiS_Pr);
  291. void SiS_DisplayOff(struct SiS_Private *SiS_Pr);
  292. void SiSRegInit(struct SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr);
  293. void SiS_SetEnableDstn(struct SiS_Private *SiS_Pr, int enable);
  294. void SiS_SetEnableFstn(struct SiS_Private *SiS_Pr, int enable);
  295. unsigned short SiS_GetModeFlag(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  296. unsigned short ModeIdIndex);
  297. bool SiSDetermineROMLayout661(struct SiS_Private *SiS_Pr);
  298. bool SiS_SearchModeID(struct SiS_Private *SiS_Pr, unsigned short *ModeNo,
  299. unsigned short *ModeIdIndex);
  300. unsigned short SiS_GetModePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  301. unsigned short ModeIdIndex);
  302. unsigned short SiS_GetRefCRTVCLK(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
  303. unsigned short SiS_GetRefCRT1CRTC(struct SiS_Private *SiS_Pr, unsigned short Index, int UseWide);
  304. unsigned short SiS_GetColorDepth(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  305. unsigned short ModeIdIndex);
  306. unsigned short SiS_GetOffset(struct SiS_Private *SiS_Pr,unsigned short ModeNo,
  307. unsigned short ModeIdIndex, unsigned short RRTI);
  308. #ifdef CONFIG_FB_SIS_300
  309. void SiS_GetFIFOThresholdIndex300(struct SiS_Private *SiS_Pr, unsigned short *idx1,
  310. unsigned short *idx2);
  311. unsigned short SiS_GetFIFOThresholdB300(unsigned short idx1, unsigned short idx2);
  312. unsigned short SiS_GetLatencyFactor630(struct SiS_Private *SiS_Pr, unsigned short index);
  313. #endif
  314. void SiS_LoadDAC(struct SiS_Private *SiS_Pr, unsigned short ModeNo, unsigned short ModeIdIndex);
  315. bool SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo);
  316. void SiS_CalcCRRegisters(struct SiS_Private *SiS_Pr, int depth);
  317. void SiS_CalcLCDACRT1Timing(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  318. unsigned short ModeIdIndex);
  319. void SiS_Generic_ConvertCRData(struct SiS_Private *SiS_Pr, unsigned char *crdata, int xres,
  320. int yres, struct fb_var_screeninfo *var, bool writeres);
  321. /* From init301.c: */
  322. extern void SiS_GetVBInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  323. unsigned short ModeIdIndex, int chkcrt2mode);
  324. extern void SiS_GetLCDResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  325. unsigned short ModeIdIndex);
  326. extern void SiS_SetYPbPr(struct SiS_Private *SiS_Pr);
  327. extern void SiS_SetTVMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  328. unsigned short ModeIdIndex);
  329. extern void SiS_UnLockCRT2(struct SiS_Private *SiS_Pr);
  330. extern void SiS_DisableBridge(struct SiS_Private *);
  331. extern bool SiS_SetCRT2Group(struct SiS_Private *, unsigned short);
  332. extern unsigned short SiS_GetRatePtr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  333. unsigned short ModeIdIndex);
  334. extern void SiS_WaitRetrace1(struct SiS_Private *SiS_Pr);
  335. extern unsigned short SiS_GetResInfo(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  336. unsigned short ModeIdIndex);
  337. extern unsigned short SiS_GetCH700x(struct SiS_Private *SiS_Pr, unsigned short tempax);
  338. extern unsigned short SiS_GetVCLK2Ptr(struct SiS_Private *SiS_Pr, unsigned short ModeNo,
  339. unsigned short ModeIdIndex, unsigned short RRTI);
  340. extern bool SiS_IsVAMode(struct SiS_Private *);
  341. extern bool SiS_IsDualEdge(struct SiS_Private *);
  342. #ifdef CONFIG_FB_SIS_300
  343. extern unsigned int sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg);
  344. extern void sisfb_write_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg,
  345. unsigned int val);
  346. #endif
  347. #ifdef CONFIG_FB_SIS_315
  348. extern void sisfb_write_nbridge_pci_byte(struct SiS_Private *SiS_Pr, int reg,
  349. unsigned char val);
  350. extern unsigned int sisfb_read_mio_pci_word(struct SiS_Private *SiS_Pr, int reg);
  351. #endif
  352. /* MMIO access macros */
  353. #define MMIO_IN8(base, offset) readb((base+offset))
  354. #define MMIO_IN16(base, offset) readw((base+offset))
  355. #define MMIO_IN32(base, offset) readl((base+offset))
  356. #define MMIO_OUT8(base, offset, val) writeb(((u8)(val)), (base+offset))
  357. #define MMIO_OUT16(base, offset, val) writew(((u16)(val)), (base+offset))
  358. #define MMIO_OUT32(base, offset, val) writel(((u32)(val)), (base+offset))
  359. /* Queue control MMIO registers */
  360. #define Q_BASE_ADDR 0x85C0 /* Base address of software queue */
  361. #define Q_WRITE_PTR 0x85C4 /* Current write pointer */
  362. #define Q_READ_PTR 0x85C8 /* Current read pointer */
  363. #define Q_STATUS 0x85CC /* queue status */
  364. #define MMIO_QUEUE_PHYBASE Q_BASE_ADDR
  365. #define MMIO_QUEUE_WRITEPORT Q_WRITE_PTR
  366. #define MMIO_QUEUE_READPORT Q_READ_PTR
  367. #ifndef FB_BLANK_UNBLANK
  368. #define FB_BLANK_UNBLANK 0
  369. #endif
  370. #ifndef FB_BLANK_NORMAL
  371. #define FB_BLANK_NORMAL 1
  372. #endif
  373. #ifndef FB_BLANK_VSYNC_SUSPEND
  374. #define FB_BLANK_VSYNC_SUSPEND 2
  375. #endif
  376. #ifndef FB_BLANK_HSYNC_SUSPEND
  377. #define FB_BLANK_HSYNC_SUSPEND 3
  378. #endif
  379. #ifndef FB_BLANK_POWERDOWN
  380. #define FB_BLANK_POWERDOWN 4
  381. #endif
  382. enum _SIS_LCD_TYPE {
  383. LCD_INVALID = 0,
  384. LCD_800x600,
  385. LCD_1024x768,
  386. LCD_1280x1024,
  387. LCD_1280x960,
  388. LCD_640x480,
  389. LCD_1600x1200,
  390. LCD_1920x1440,
  391. LCD_2048x1536,
  392. LCD_320x240, /* FSTN */
  393. LCD_1400x1050,
  394. LCD_1152x864,
  395. LCD_1152x768,
  396. LCD_1280x768,
  397. LCD_1024x600,
  398. LCD_320x240_2, /* DSTN */
  399. LCD_320x240_3, /* DSTN */
  400. LCD_848x480,
  401. LCD_1280x800,
  402. LCD_1680x1050,
  403. LCD_1280x720,
  404. LCD_1280x854,
  405. LCD_CUSTOM,
  406. LCD_UNKNOWN
  407. };
  408. enum _SIS_CMDTYPE {
  409. MMIO_CMD = 0,
  410. AGP_CMD_QUEUE,
  411. VM_CMD_QUEUE,
  412. };
  413. struct SIS_OH {
  414. struct SIS_OH *poh_next;
  415. struct SIS_OH *poh_prev;
  416. u32 offset;
  417. u32 size;
  418. };
  419. struct SIS_OHALLOC {
  420. struct SIS_OHALLOC *poha_next;
  421. struct SIS_OH aoh[1];
  422. };
  423. struct SIS_HEAP {
  424. struct SIS_OH oh_free;
  425. struct SIS_OH oh_used;
  426. struct SIS_OH *poh_freelist;
  427. struct SIS_OHALLOC *poha_chain;
  428. u32 max_freesize;
  429. struct sis_video_info *vinfo;
  430. };
  431. /* Our "par" */
  432. struct sis_video_info {
  433. int cardnumber;
  434. struct fb_info *memyselfandi;
  435. struct SiS_Private SiS_Pr;
  436. struct sisfb_info sisfbinfo; /* For ioctl SISFB_GET_INFO */
  437. struct fb_var_screeninfo default_var;
  438. struct fb_fix_screeninfo sisfb_fix;
  439. u32 pseudo_palette[16];
  440. struct sisfb_monitor {
  441. u16 hmin;
  442. u16 hmax;
  443. u16 vmin;
  444. u16 vmax;
  445. u32 dclockmax;
  446. u8 feature;
  447. bool datavalid;
  448. } sisfb_thismonitor;
  449. unsigned short chip_id; /* PCI ID of chip */
  450. unsigned short chip_vendor; /* PCI ID of vendor */
  451. char myid[40];
  452. struct pci_dev *nbridge;
  453. struct pci_dev *lpcdev;
  454. int mni; /* Mode number index */
  455. unsigned long video_size;
  456. unsigned long video_base;
  457. unsigned long mmio_size;
  458. unsigned long mmio_base;
  459. unsigned long vga_base;
  460. unsigned long video_offset;
  461. unsigned long UMAsize, LFBsize;
  462. void __iomem *video_vbase;
  463. void __iomem *mmio_vbase;
  464. unsigned char *bios_abase;
  465. int wc_cookie;
  466. u32 sisfb_mem;
  467. u32 sisfb_parm_mem;
  468. int sisfb_accel;
  469. int sisfb_ypan;
  470. int sisfb_max;
  471. int sisfb_userom;
  472. int sisfb_useoem;
  473. int sisfb_mode_idx;
  474. int sisfb_parm_rate;
  475. int sisfb_crt1off;
  476. int sisfb_forcecrt1;
  477. int sisfb_crt2type;
  478. int sisfb_crt2flags;
  479. int sisfb_dstn;
  480. int sisfb_fstn;
  481. int sisfb_tvplug;
  482. int sisfb_tvstd;
  483. int sisfb_nocrt2rate;
  484. u32 heapstart; /* offset */
  485. void __iomem *sisfb_heap_start; /* address */
  486. void __iomem *sisfb_heap_end; /* address */
  487. u32 sisfb_heap_size;
  488. int havenoheap;
  489. struct SIS_HEAP sisfb_heap; /* This card's vram heap */
  490. int video_bpp;
  491. int video_cmap_len;
  492. int video_width;
  493. int video_height;
  494. unsigned int refresh_rate;
  495. unsigned int chip;
  496. unsigned int chip_real_id;
  497. u8 revision_id;
  498. int sisvga_enabled; /* PCI device was enabled */
  499. int video_linelength; /* real pitch */
  500. int scrnpitchCRT1; /* pitch regarding interlace */
  501. u16 DstColor; /* For 2d acceleration */
  502. u32 SiS310_AccelDepth;
  503. u32 CommandReg;
  504. int cmdqueuelength; /* Current (for accel) */
  505. u32 cmdQueueSize; /* Total size in KB */
  506. spinlock_t lockaccel; /* Do not use outside of kernel! */
  507. unsigned int pcibus;
  508. unsigned int pcislot;
  509. unsigned int pcifunc;
  510. int accel;
  511. int engineok;
  512. u16 subsysvendor;
  513. u16 subsysdevice;
  514. u32 vbflags; /* Replacing deprecated stuff from above */
  515. u32 currentvbflags;
  516. u32 vbflags2;
  517. int lcdxres, lcdyres;
  518. int lcddefmodeidx, tvdefmodeidx, defmodeidx;
  519. u32 CRT2LCDType; /* defined in "SIS_LCD_TYPE" */
  520. u32 curFSTN, curDSTN;
  521. int current_bpp;
  522. int current_width;
  523. int current_height;
  524. int current_htotal;
  525. int current_vtotal;
  526. int current_linelength;
  527. __u32 current_pixclock;
  528. int current_refresh_rate;
  529. unsigned int current_base;
  530. u8 mode_no;
  531. u8 rate_idx;
  532. int modechanged;
  533. unsigned char modeprechange;
  534. u8 sisfb_lastrates[128];
  535. int newrom;
  536. int haveXGIROM;
  537. int registered;
  538. int warncount;
  539. int sisvga_engine;
  540. int hwcursor_size;
  541. int CRT2_write_enable;
  542. u8 caps;
  543. u8 detectedpdc;
  544. u8 detectedpdca;
  545. u8 detectedlcda;
  546. void __iomem *hwcursor_vbase;
  547. int chronteltype;
  548. int tvxpos, tvypos;
  549. u8 p2_1f,p2_20,p2_2b,p2_42,p2_43,p2_01,p2_02;
  550. int tvx, tvy;
  551. u8 sisfblocked;
  552. struct sisfb_info sisfb_infoblock;
  553. struct sisfb_cmd sisfb_command;
  554. u32 sisfb_id;
  555. u8 sisfb_can_post;
  556. u8 sisfb_card_posted;
  557. u8 sisfb_was_boot_device;
  558. struct sis_video_info *next;
  559. };
  560. /* from sis_accel.c */
  561. extern void fbcon_sis_fillrect(struct fb_info *info,
  562. const struct fb_fillrect *rect);
  563. extern void fbcon_sis_copyarea(struct fb_info *info,
  564. const struct fb_copyarea *area);
  565. extern int fbcon_sis_sync(struct fb_info *info);
  566. /* Internal 2D accelerator functions */
  567. extern int sisfb_initaccel(struct sis_video_info *ivideo);
  568. extern void sisfb_syncaccel(struct sis_video_info *ivideo);
  569. /* Internal general routines */
  570. #ifdef CONFIG_FB_SIS_300
  571. unsigned int sisfb_read_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg);
  572. void sisfb_write_nbridge_pci_dword(struct SiS_Private *SiS_Pr, int reg, unsigned int val);
  573. unsigned int sisfb_read_lpc_pci_dword(struct SiS_Private *SiS_Pr, int reg);
  574. #endif
  575. #ifdef CONFIG_FB_SIS_315
  576. void sisfb_write_nbridge_pci_byte(struct SiS_Private *SiS_Pr, int reg, unsigned char val);
  577. unsigned int sisfb_read_mio_pci_word(struct SiS_Private *SiS_Pr, int reg);
  578. #endif
  579. /* SiS-specific exported functions */
  580. void sis_malloc(struct sis_memreq *req);
  581. void sis_malloc_new(struct pci_dev *pdev, struct sis_memreq *req);
  582. void sis_free(u32 base);
  583. void sis_free_new(struct pci_dev *pdev, u32 base);
  584. /* Routines from init.c/init301.c */
  585. extern unsigned short SiS_GetModeID_LCD(int VGAEngine, unsigned int VBFlags, int HDisplay,
  586. int VDisplay, int Depth, bool FSTN, unsigned short CustomT,
  587. int LCDwith, int LCDheight, unsigned int VBFlags2);
  588. extern unsigned short SiS_GetModeID_TV(int VGAEngine, unsigned int VBFlags, int HDisplay,
  589. int VDisplay, int Depth, unsigned int VBFlags2);
  590. extern unsigned short SiS_GetModeID_VGA2(int VGAEngine, unsigned int VBFlags, int HDisplay,
  591. int VDisplay, int Depth, unsigned int VBFlags2);
  592. extern void SiSRegInit(struct SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr);
  593. extern bool SiSSetMode(struct SiS_Private *SiS_Pr, unsigned short ModeNo);
  594. extern void SiS_SetEnableDstn(struct SiS_Private *SiS_Pr, int enable);
  595. extern void SiS_SetEnableFstn(struct SiS_Private *SiS_Pr, int enable);
  596. extern bool SiSDetermineROMLayout661(struct SiS_Private *SiS_Pr);
  597. extern bool sisfb_gettotalfrommode(struct SiS_Private *SiS_Pr, unsigned char modeno,
  598. int *htotal, int *vtotal, unsigned char rateindex);
  599. extern int sisfb_mode_rate_to_dclock(struct SiS_Private *SiS_Pr,
  600. unsigned char modeno, unsigned char rateindex);
  601. extern int sisfb_mode_rate_to_ddata(struct SiS_Private *SiS_Pr, unsigned char modeno,
  602. unsigned char rateindex, struct fb_var_screeninfo *var);
  603. #endif