intelfb.h 7.8 KB

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