1 /* SPDX-License-Identifier: GPL-2.0 */
5 /* $DHD: intelfb/intelfb.h,v 1.40 2003/06/27 15:06:25 dawes Exp $ */
7 #include <linux/agp_backend.h>
10 #ifdef CONFIG_FB_INTEL_I2C
11 #include <linux/i2c.h>
12 #include <linux/i2c-algo-bit.h>
15 /*** Version/name ***/
16 #define INTELFB_VERSION "0.9.6"
17 #define INTELFB_MODULE_NAME "intelfb"
18 #define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/945GME/965G/965GM"
21 /*** Debug/feature defines ***/
35 #ifndef DETECT_VGA_CLASS_ONLY
36 #define DETECT_VGA_CLASS_ONLY 1
39 #ifndef ALLOCATE_FOR_PANNING
40 #define ALLOCATE_FOR_PANNING 1
43 #ifndef PREFERRED_MODE
44 #define PREFERRED_MODE "1024x768-32@70"
47 /*** hw-related values ***/
49 /* Resource Allocation */
50 #define INTELFB_FB_ACQUIRED 1
51 #define INTELFB_MMIO_ACQUIRED 2
53 /* PCI ids for supported devices */
54 #define PCI_DEVICE_ID_INTEL_830M 0x3577
55 #define PCI_DEVICE_ID_INTEL_845G 0x2562
56 #define PCI_DEVICE_ID_INTEL_85XGM 0x3582
57 #define PCI_DEVICE_ID_INTEL_854 0x358E
58 #define PCI_DEVICE_ID_INTEL_865G 0x2572
59 #define PCI_DEVICE_ID_INTEL_915G 0x2582
60 #define PCI_DEVICE_ID_INTEL_915GM 0x2592
61 #define PCI_DEVICE_ID_INTEL_945G 0x2772
62 #define PCI_DEVICE_ID_INTEL_945GM 0x27A2
63 #define PCI_DEVICE_ID_INTEL_945GME 0x27AE
64 #define PCI_DEVICE_ID_INTEL_965G 0x29A2
65 #define PCI_DEVICE_ID_INTEL_965GM 0x2A02
67 /* Size of MMIO region */
68 #define INTEL_REG_SIZE 0x80000
70 #define STRIDE_ALIGNMENT 16
71 #define STRIDE_ALIGNMENT_I9XX 64
73 #define PALETTE_8_ENTRIES 256
78 /* basic arithmetic */
79 #define KB(x) ((x) * 1024)
80 #define MB(x) ((x) * 1024 * 1024)
81 #define BtoKB(x) ((x) / 1024)
82 #define BtoMB(x) ((x) / 1024 / 1024)
84 #define GTT_PAGE_SIZE KB(4)
86 #define ROUND_UP_TO(x, y) (((x) + (y) - 1) / (y) * (y))
87 #define ROUND_DOWN_TO(x, y) ((x) / (y) * (y))
88 #define ROUND_UP_TO_PAGE(x) ROUND_UP_TO((x), GTT_PAGE_SIZE)
89 #define ROUND_DOWN_TO_PAGE(x) ROUND_DOWN_TO((x), GTT_PAGE_SIZE)
92 #define PFX INTELFB_MODULE_NAME ": "
94 #define ERR_MSG(fmt, args...) printk(KERN_ERR PFX fmt, ## args)
95 #define WRN_MSG(fmt, args...) printk(KERN_WARNING PFX fmt, ## args)
96 #define NOT_MSG(fmt, args...) printk(KERN_NOTICE PFX fmt, ## args)
97 #define INF_MSG(fmt, args...) printk(KERN_INFO PFX fmt, ## args)
99 #define DBG_MSG(fmt, args...) printk(KERN_DEBUG PFX fmt, ## args)
101 #define DBG_MSG(fmt, args...) while (0) printk(fmt, ## args)
104 /* get commonly used pointers */
105 #define GET_DINFO(info) (info)->par
108 #define ACCEL(d, i) \
109 ((d)->accel && !(d)->ring_lockup && \
110 ((i)->var.accel_flags & FB_ACCELF_TEXT))
112 /*#define NOACCEL_CHIPSET(d) \
113 ((d)->chipset != INTEL_865G)*/
114 #define NOACCEL_CHIPSET(d) \
117 #define FIXED_MODE(d) ((d)->fixed_mode)
119 /*** Driver parameters ***/
121 #define RINGBUFFER_SIZE KB(64)
122 #define HW_CURSOR_SIZE KB(4)
124 /* Intel agpgart driver */
125 #define AGP_PHYSICAL_MEMORY 2
127 /* store information about an Ixxx DVO */
128 /* The i830->i865 use multiple DVOs with multiple i2cs */
129 /* the i915, i945 have a single sDVO i2c bus - which is different */
130 #define MAX_OUTPUTS 6
132 /* these are outputs from the chip - integrated only
133 external chips are via DVO or SDVO output */
134 #define INTELFB_OUTPUT_UNUSED 0
135 #define INTELFB_OUTPUT_ANALOG 1
136 #define INTELFB_OUTPUT_DVO 2
137 #define INTELFB_OUTPUT_SDVO 3
138 #define INTELFB_OUTPUT_LVDS 4
139 #define INTELFB_OUTPUT_TVOUT 5
141 #define INTELFB_DVO_CHIP_NONE 0
142 #define INTELFB_DVO_CHIP_LVDS 1
143 #define INTELFB_DVO_CHIP_TMDS 2
144 #define INTELFB_DVO_CHIP_TVOUT 4
146 #define INTELFB_OUTPUT_PIPE_NC 0
147 #define INTELFB_OUTPUT_PIPE_A 1
148 #define INTELFB_OUTPUT_PIPE_B 2
152 /* supported chipsets */
172 struct intelfb_hwstate
{
182 u32 palette_a
[PALETTE_8_ENTRIES
];
183 u32 palette_b
[PALETTE_8_ENTRIES
];
211 u32 cursor_a_control
;
212 u32 cursor_b_control
;
220 u32 cursor_a_palette
[4];
221 u32 cursor_b_palette
[4];
240 struct intelfb_heap_data
{
243 u32 offset
; /* in GATT pages */
244 u32 size
; /* in bytes */
247 #ifdef CONFIG_FB_INTEL_I2C
248 struct intelfb_i2c_chan
{
249 struct intelfb_info
*dinfo
;
251 struct i2c_adapter adapter
;
252 struct i2c_algo_bit_data algo
;
256 struct intelfb_output_rec
{
261 #ifdef CONFIG_FB_INTEL_I2C
262 struct intelfb_i2c_chan i2c_bus
;
263 struct intelfb_i2c_chan ddc_bus
;
267 struct intelfb_vsync
{
268 wait_queue_head_t wait
;
274 struct intelfb_info
{
275 struct fb_info
*info
;
276 const struct fb_ops
*fbops
;
277 struct pci_dev
*pdev
;
279 struct intelfb_hwstate save_state
;
281 /* agpgart structs */
282 struct agp_memory
*gtt_fb_mem
; /* use all stolen memory or vram */
283 struct agp_memory
*gtt_ring_mem
; /* ring buffer */
284 struct agp_memory
*gtt_cursor_mem
; /* hw cursor */
286 /* use a gart reserved fb mem */
292 struct intelfb_heap_data aperture
;
293 struct intelfb_heap_data fb
;
294 struct intelfb_heap_data ring
;
295 struct intelfb_heap_data cursor
;
299 u8 __iomem
*mmio_base
;
301 /* fb start offset (in bytes) */
312 u32 pseudo_palette
[16];
323 int xres
, yres
, pitch
;
335 unsigned long irq_flags
;
339 struct intelfb_vsync vsync
;
347 /* initial parameters */
349 struct fb_var_screeninfo initial_var
;
351 u32 initial_video_ram
;
354 /* driver registered */
357 /* index into plls */
362 struct intelfb_output_rec output
[MAX_OUTPUTS
];
365 #define IS_I9XX(dinfo) (((dinfo)->chipset == INTEL_915G) || \
366 ((dinfo)->chipset == INTEL_915GM) || \
367 ((dinfo)->chipset == INTEL_945G) || \
368 ((dinfo)->chipset == INTEL_945GM) || \
369 ((dinfo)->chipset == INTEL_945GME) || \
370 ((dinfo)->chipset == INTEL_965G) || \
371 ((dinfo)->chipset == INTEL_965GM))
373 /*** function prototypes ***/
375 extern int intelfb_var_to_depth(const struct fb_var_screeninfo
*var
);
377 #ifdef CONFIG_FB_INTEL_I2C
378 extern void intelfb_create_i2c_busses(struct intelfb_info
*dinfo
);
379 extern void intelfb_delete_i2c_busses(struct intelfb_info
*dinfo
);
382 #endif /* _INTELFB_H */