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