intelfb.h 6.1 KB

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