intelfb.h 7.9 KB

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