intelfb.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. #ifndef _INTELFB_H
  2. #define _INTELFB_H
  3. /* $DHD: intelfb/intelfb.h,v 1.40 2003/06/27 15:06:25 dawes Exp $ */
  4. #include <linux/agp_backend.h>
  5. #include <linux/fb.h>
  6. #ifdef CONFIG_FB_INTEL_I2C
  7. #include <linux/i2c.h>
  8. #include <linux/i2c-algo-bit.h>
  9. #endif
  10. /*** Version/name ***/
  11. #define INTELFB_VERSION "0.9.4"
  12. #define INTELFB_MODULE_NAME "intelfb"
  13. #define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM"
  14. /*** Debug/feature defines ***/
  15. #ifndef DEBUG
  16. #define DEBUG 0
  17. #endif
  18. #ifndef VERBOSE
  19. #define VERBOSE 0
  20. #endif
  21. #ifndef REGDUMP
  22. #define REGDUMP 0
  23. #endif
  24. #ifndef DETECT_VGA_CLASS_ONLY
  25. #define DETECT_VGA_CLASS_ONLY 1
  26. #endif
  27. #ifndef ALLOCATE_FOR_PANNING
  28. #define ALLOCATE_FOR_PANNING 1
  29. #endif
  30. #ifndef PREFERRED_MODE
  31. #define PREFERRED_MODE "1024x768-32@70"
  32. #endif
  33. /*** hw-related values ***/
  34. /* Resource Allocation */
  35. #define INTELFB_FB_ACQUIRED 1
  36. #define INTELFB_MMIO_ACQUIRED 2
  37. /* PCI ids for supported devices */
  38. #define PCI_DEVICE_ID_INTEL_830M 0x3577
  39. #define PCI_DEVICE_ID_INTEL_845G 0x2562
  40. #define PCI_DEVICE_ID_INTEL_85XGM 0x3582
  41. #define PCI_DEVICE_ID_INTEL_865G 0x2572
  42. #define PCI_DEVICE_ID_INTEL_915G 0x2582
  43. #define PCI_DEVICE_ID_INTEL_915GM 0x2592
  44. #define PCI_DEVICE_ID_INTEL_945G 0x2772
  45. #define PCI_DEVICE_ID_INTEL_945GM 0x27A2
  46. /* Size of MMIO region */
  47. #define INTEL_REG_SIZE 0x80000
  48. #define STRIDE_ALIGNMENT 16
  49. #define STRIDE_ALIGNMENT_I9XX 64
  50. #define PALETTE_8_ENTRIES 256
  51. /*** Macros ***/
  52. /* basic arithmetic */
  53. #define KB(x) ((x) * 1024)
  54. #define MB(x) ((x) * 1024 * 1024)
  55. #define BtoKB(x) ((x) / 1024)
  56. #define BtoMB(x) ((x) / 1024 / 1024)
  57. #define GTT_PAGE_SIZE KB(4)
  58. #define ROUND_UP_TO(x, y) (((x) + (y) - 1) / (y) * (y))
  59. #define ROUND_DOWN_TO(x, y) ((x) / (y) * (y))
  60. #define ROUND_UP_TO_PAGE(x) ROUND_UP_TO((x), GTT_PAGE_SIZE)
  61. #define ROUND_DOWN_TO_PAGE(x) ROUND_DOWN_TO((x), GTT_PAGE_SIZE)
  62. /* messages */
  63. #define PFX INTELFB_MODULE_NAME ": "
  64. #define ERR_MSG(fmt, args...) printk(KERN_ERR PFX fmt, ## args)
  65. #define WRN_MSG(fmt, args...) printk(KERN_WARNING PFX fmt, ## args)
  66. #define NOT_MSG(fmt, args...) printk(KERN_NOTICE PFX fmt, ## args)
  67. #define INF_MSG(fmt, args...) printk(KERN_INFO PFX fmt, ## args)
  68. #if DEBUG
  69. #define DBG_MSG(fmt, args...) printk(KERN_DEBUG PFX fmt, ## args)
  70. #else
  71. #define DBG_MSG(fmt, args...) while (0) printk(fmt, ## args)
  72. #endif
  73. /* get commonly used pointers */
  74. #define GET_DINFO(info) (info)->par
  75. /* misc macros */
  76. #define ACCEL(d, i) \
  77. ((d)->accel && !(d)->ring_lockup && \
  78. ((i)->var.accel_flags & FB_ACCELF_TEXT))
  79. /*#define NOACCEL_CHIPSET(d) \
  80. ((d)->chipset != INTEL_865G)*/
  81. #define NOACCEL_CHIPSET(d) \
  82. (0)
  83. #define FIXED_MODE(d) ((d)->fixed_mode)
  84. /*** Driver paramters ***/
  85. #define RINGBUFFER_SIZE KB(64)
  86. #define HW_CURSOR_SIZE KB(4)
  87. /* Intel agpgart driver */
  88. #define AGP_PHYSICAL_MEMORY 2
  89. /* these are outputs from the chip - integrated only
  90. external chips are via DVO or SDVO output */
  91. #define INTELFB_OUTPUT_UNUSED 0
  92. #define INTELFB_OUTPUT_ANALOG 1
  93. #define INTELFB_OUTPUT_DVO 2
  94. #define INTELFB_OUTPUT_SDVO 3
  95. #define INTELFB_OUTPUT_LVDS 4
  96. #define INTELFB_OUTPUT_TVOUT 5
  97. #define INTELFB_DVO_CHIP_NONE 0
  98. #define INTELFB_DVO_CHIP_LVDS 1
  99. #define INTELFB_DVO_CHIP_TMDS 2
  100. #define INTELFB_DVO_CHIP_TVOUT 4
  101. #define INTELFB_OUTPUT_PIPE_NC 0
  102. #define INTELFB_OUTPUT_PIPE_A 1
  103. #define INTELFB_OUTPUT_PIPE_B 2
  104. /*** Data Types ***/
  105. /* supported chipsets */
  106. enum intel_chips {
  107. INTEL_830M,
  108. INTEL_845G,
  109. INTEL_85XGM,
  110. INTEL_852GM,
  111. INTEL_852GME,
  112. INTEL_855GM,
  113. INTEL_855GME,
  114. INTEL_865G,
  115. INTEL_915G,
  116. INTEL_915GM,
  117. INTEL_945G,
  118. INTEL_945GM,
  119. };
  120. struct intelfb_hwstate {
  121. u32 vga0_divisor;
  122. u32 vga1_divisor;
  123. u32 vga_pd;
  124. u32 dpll_a;
  125. u32 dpll_b;
  126. u32 fpa0;
  127. u32 fpa1;
  128. u32 fpb0;
  129. u32 fpb1;
  130. u32 palette_a[PALETTE_8_ENTRIES];
  131. u32 palette_b[PALETTE_8_ENTRIES];
  132. u32 htotal_a;
  133. u32 hblank_a;
  134. u32 hsync_a;
  135. u32 vtotal_a;
  136. u32 vblank_a;
  137. u32 vsync_a;
  138. u32 src_size_a;
  139. u32 bclrpat_a;
  140. u32 htotal_b;
  141. u32 hblank_b;
  142. u32 hsync_b;
  143. u32 vtotal_b;
  144. u32 vblank_b;
  145. u32 vsync_b;
  146. u32 src_size_b;
  147. u32 bclrpat_b;
  148. u32 adpa;
  149. u32 dvoa;
  150. u32 dvob;
  151. u32 dvoc;
  152. u32 dvoa_srcdim;
  153. u32 dvob_srcdim;
  154. u32 dvoc_srcdim;
  155. u32 lvds;
  156. u32 pipe_a_conf;
  157. u32 pipe_b_conf;
  158. u32 disp_arb;
  159. u32 cursor_a_control;
  160. u32 cursor_b_control;
  161. u32 cursor_a_base;
  162. u32 cursor_b_base;
  163. u32 cursor_size;
  164. u32 disp_a_ctrl;
  165. u32 disp_b_ctrl;
  166. u32 disp_a_base;
  167. u32 disp_b_base;
  168. u32 cursor_a_palette[4];
  169. u32 cursor_b_palette[4];
  170. u32 disp_a_stride;
  171. u32 disp_b_stride;
  172. u32 vgacntrl;
  173. u32 add_id;
  174. u32 swf0x[7];
  175. u32 swf1x[7];
  176. u32 swf3x[3];
  177. u32 fence[8];
  178. u32 instpm;
  179. u32 mem_mode;
  180. u32 fw_blc_0;
  181. u32 fw_blc_1;
  182. u16 hwstam;
  183. u16 ier;
  184. u16 iir;
  185. u16 imr;
  186. };
  187. struct intelfb_heap_data {
  188. u32 physical;
  189. u8 __iomem *virtual;
  190. u32 offset; // in GATT pages
  191. u32 size; // in bytes
  192. };
  193. #ifdef CONFIG_FB_INTEL_I2C
  194. struct intelfb_i2c_chan {
  195. struct intelfb_info *dinfo;
  196. u32 reg;
  197. struct i2c_adapter adapter;
  198. struct i2c_algo_bit_data algo;
  199. };
  200. #endif
  201. struct intelfb_output_rec {
  202. int type;
  203. int pipe;
  204. int flags;
  205. #ifdef CONFIG_FB_INTEL_I2C
  206. struct intelfb_i2c_chan i2c_bus;
  207. struct intelfb_i2c_chan ddc_bus;
  208. #endif
  209. };
  210. struct intelfb_vsync {
  211. wait_queue_head_t wait;
  212. unsigned int count;
  213. int pan_display;
  214. u32 pan_offset;
  215. };
  216. struct intelfb_info {
  217. struct fb_info *info;
  218. struct fb_ops *fbops;
  219. struct pci_dev *pdev;
  220. struct intelfb_hwstate save_state;
  221. /* agpgart structs */
  222. struct agp_memory *gtt_fb_mem; // use all stolen memory or vram
  223. struct agp_memory *gtt_ring_mem; // ring buffer
  224. struct agp_memory *gtt_cursor_mem; // hw cursor
  225. /* use a gart reserved fb mem */
  226. u8 fbmem_gart;
  227. /* mtrr support */
  228. u32 mtrr_reg;
  229. u32 has_mtrr;
  230. /* heap data */
  231. struct intelfb_heap_data aperture;
  232. struct intelfb_heap_data fb;
  233. struct intelfb_heap_data ring;
  234. struct intelfb_heap_data cursor;
  235. /* mmio regs */
  236. u32 mmio_base_phys;
  237. u8 __iomem *mmio_base;
  238. /* fb start offset (in bytes) */
  239. u32 fb_start;
  240. /* ring buffer */
  241. u32 ring_head;
  242. u32 ring_tail;
  243. u32 ring_tail_mask;
  244. u32 ring_space;
  245. u32 ring_lockup;
  246. /* palette */
  247. u32 pseudo_palette[17];
  248. /* chip info */
  249. int pci_chipset;
  250. int chipset;
  251. const char *name;
  252. int mobile;
  253. /* current mode */
  254. int bpp, depth;
  255. u32 visual;
  256. int xres, yres, pitch;
  257. int pixclock;
  258. /* current pipe */
  259. int pipe;
  260. /* some flags */
  261. int accel;
  262. int hwcursor;
  263. int fixed_mode;
  264. int ring_active;
  265. int flag;
  266. unsigned long irq_flags;
  267. int open;
  268. /* vsync */
  269. struct intelfb_vsync vsync;
  270. spinlock_t int_lock;
  271. /* hw cursor */
  272. int cursor_on;
  273. int cursor_blanked;
  274. u8 cursor_src[64];
  275. /* initial parameters */
  276. int initial_vga;
  277. struct fb_var_screeninfo initial_var;
  278. u32 initial_fb_base;
  279. u32 initial_video_ram;
  280. u32 initial_pitch;
  281. /* driver registered */
  282. int registered;
  283. /* index into plls */
  284. int pll_index;
  285. };
  286. #define IS_I9XX(dinfo) (((dinfo)->chipset == INTEL_915G)||(dinfo->chipset == INTEL_915GM)||((dinfo)->chipset == INTEL_945G)||(dinfo->chipset==INTEL_945GM))
  287. #ifndef FBIO_WAITFORVSYNC
  288. #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
  289. #endif
  290. /*** function prototypes ***/
  291. extern int intelfb_var_to_depth(const struct fb_var_screeninfo *var);
  292. #endif /* _INTELFB_H */