intelfb.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. /* store information about an Ixxx DVO */
  90. /* The i830->i865 use multiple DVOs with multiple i2cs */
  91. /* the i915, i945 have a single sDVO i2c bus - which is different */
  92. #define MAX_OUTPUTS 6
  93. /* these are outputs from the chip - integrated only
  94. external chips are via DVO or SDVO output */
  95. #define INTELFB_OUTPUT_UNUSED 0
  96. #define INTELFB_OUTPUT_ANALOG 1
  97. #define INTELFB_OUTPUT_DVO 2
  98. #define INTELFB_OUTPUT_SDVO 3
  99. #define INTELFB_OUTPUT_LVDS 4
  100. #define INTELFB_OUTPUT_TVOUT 5
  101. #define INTELFB_DVO_CHIP_NONE 0
  102. #define INTELFB_DVO_CHIP_LVDS 1
  103. #define INTELFB_DVO_CHIP_TMDS 2
  104. #define INTELFB_DVO_CHIP_TVOUT 4
  105. #define INTELFB_OUTPUT_PIPE_NC 0
  106. #define INTELFB_OUTPUT_PIPE_A 1
  107. #define INTELFB_OUTPUT_PIPE_B 2
  108. /*** Data Types ***/
  109. /* supported chipsets */
  110. enum intel_chips {
  111. INTEL_830M,
  112. INTEL_845G,
  113. INTEL_85XGM,
  114. INTEL_852GM,
  115. INTEL_852GME,
  116. INTEL_855GM,
  117. INTEL_855GME,
  118. INTEL_865G,
  119. INTEL_915G,
  120. INTEL_915GM,
  121. INTEL_945G,
  122. INTEL_945GM,
  123. };
  124. struct intelfb_hwstate {
  125. u32 vga0_divisor;
  126. u32 vga1_divisor;
  127. u32 vga_pd;
  128. u32 dpll_a;
  129. u32 dpll_b;
  130. u32 fpa0;
  131. u32 fpa1;
  132. u32 fpb0;
  133. u32 fpb1;
  134. u32 palette_a[PALETTE_8_ENTRIES];
  135. u32 palette_b[PALETTE_8_ENTRIES];
  136. u32 htotal_a;
  137. u32 hblank_a;
  138. u32 hsync_a;
  139. u32 vtotal_a;
  140. u32 vblank_a;
  141. u32 vsync_a;
  142. u32 src_size_a;
  143. u32 bclrpat_a;
  144. u32 htotal_b;
  145. u32 hblank_b;
  146. u32 hsync_b;
  147. u32 vtotal_b;
  148. u32 vblank_b;
  149. u32 vsync_b;
  150. u32 src_size_b;
  151. u32 bclrpat_b;
  152. u32 adpa;
  153. u32 dvoa;
  154. u32 dvob;
  155. u32 dvoc;
  156. u32 dvoa_srcdim;
  157. u32 dvob_srcdim;
  158. u32 dvoc_srcdim;
  159. u32 lvds;
  160. u32 pipe_a_conf;
  161. u32 pipe_b_conf;
  162. u32 disp_arb;
  163. u32 cursor_a_control;
  164. u32 cursor_b_control;
  165. u32 cursor_a_base;
  166. u32 cursor_b_base;
  167. u32 cursor_size;
  168. u32 disp_a_ctrl;
  169. u32 disp_b_ctrl;
  170. u32 disp_a_base;
  171. u32 disp_b_base;
  172. u32 cursor_a_palette[4];
  173. u32 cursor_b_palette[4];
  174. u32 disp_a_stride;
  175. u32 disp_b_stride;
  176. u32 vgacntrl;
  177. u32 add_id;
  178. u32 swf0x[7];
  179. u32 swf1x[7];
  180. u32 swf3x[3];
  181. u32 fence[8];
  182. u32 instpm;
  183. u32 mem_mode;
  184. u32 fw_blc_0;
  185. u32 fw_blc_1;
  186. u16 hwstam;
  187. u16 ier;
  188. u16 iir;
  189. u16 imr;
  190. };
  191. struct intelfb_heap_data {
  192. u32 physical;
  193. u8 __iomem *virtual;
  194. u32 offset; /* in GATT pages */
  195. u32 size; /* in bytes */
  196. };
  197. #ifdef CONFIG_FB_INTEL_I2C
  198. struct intelfb_i2c_chan {
  199. struct intelfb_info *dinfo;
  200. u32 reg;
  201. struct i2c_adapter adapter;
  202. struct i2c_algo_bit_data algo;
  203. };
  204. #endif
  205. struct intelfb_output_rec {
  206. int type;
  207. int pipe;
  208. int flags;
  209. #ifdef CONFIG_FB_INTEL_I2C
  210. struct intelfb_i2c_chan i2c_bus;
  211. struct intelfb_i2c_chan ddc_bus;
  212. #endif
  213. };
  214. struct intelfb_vsync {
  215. wait_queue_head_t wait;
  216. unsigned int count;
  217. int pan_display;
  218. u32 pan_offset;
  219. };
  220. struct intelfb_info {
  221. struct fb_info *info;
  222. struct fb_ops *fbops;
  223. struct pci_dev *pdev;
  224. struct intelfb_hwstate save_state;
  225. /* agpgart structs */
  226. struct agp_memory *gtt_fb_mem; /* use all stolen memory or vram */
  227. struct agp_memory *gtt_ring_mem; /* ring buffer */
  228. struct agp_memory *gtt_cursor_mem; /* hw cursor */
  229. /* use a gart reserved fb mem */
  230. u8 fbmem_gart;
  231. /* mtrr support */
  232. int mtrr_reg;
  233. u32 has_mtrr;
  234. /* heap data */
  235. struct intelfb_heap_data aperture;
  236. struct intelfb_heap_data fb;
  237. struct intelfb_heap_data ring;
  238. struct intelfb_heap_data cursor;
  239. /* mmio regs */
  240. u32 mmio_base_phys;
  241. u8 __iomem *mmio_base;
  242. /* fb start offset (in bytes) */
  243. u32 fb_start;
  244. /* ring buffer */
  245. u32 ring_head;
  246. u32 ring_tail;
  247. u32 ring_tail_mask;
  248. u32 ring_space;
  249. u32 ring_lockup;
  250. /* palette */
  251. u32 pseudo_palette[16];
  252. /* chip info */
  253. int pci_chipset;
  254. int chipset;
  255. const char *name;
  256. int mobile;
  257. /* current mode */
  258. int bpp, depth;
  259. u32 visual;
  260. int xres, yres, pitch;
  261. int pixclock;
  262. /* current pipe */
  263. int pipe;
  264. /* some flags */
  265. int accel;
  266. int hwcursor;
  267. int fixed_mode;
  268. int ring_active;
  269. int flag;
  270. unsigned long irq_flags;
  271. int open;
  272. /* vsync */
  273. struct intelfb_vsync vsync;
  274. spinlock_t int_lock;
  275. /* hw cursor */
  276. int cursor_on;
  277. int cursor_blanked;
  278. u8 cursor_src[64];
  279. /* initial parameters */
  280. int initial_vga;
  281. struct fb_var_screeninfo initial_var;
  282. u32 initial_fb_base;
  283. u32 initial_video_ram;
  284. u32 initial_pitch;
  285. /* driver registered */
  286. int registered;
  287. /* index into plls */
  288. int pll_index;
  289. /* outputs */
  290. int num_outputs;
  291. struct intelfb_output_rec output[MAX_OUTPUTS];
  292. };
  293. #define IS_I9XX(dinfo) (((dinfo)->chipset == INTEL_915G) || \
  294. ((dinfo)->chipset == INTEL_915GM) || \
  295. ((dinfo)->chipset == INTEL_945G) || \
  296. ((dinfo)->chipset==INTEL_945GM))
  297. #ifndef FBIO_WAITFORVSYNC
  298. #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
  299. #endif
  300. /*** function prototypes ***/
  301. extern int intelfb_var_to_depth(const struct fb_var_screeninfo *var);
  302. #ifdef CONFIG_FB_INTEL_I2C
  303. extern void intelfb_create_i2c_busses(struct intelfb_info *dinfo);
  304. extern void intelfb_delete_i2c_busses(struct intelfb_info *dinfo);
  305. #endif
  306. #endif /* _INTELFB_H */