blob: 6919830c38672c72ee10e029a4f6a44674f88dbf [file] [log] [blame]
Stefan Reinauer564e90f2012-05-04 15:37:18 -07001/* cocci issues ;-( */
2#ifndef VIDEO_H
3#define VIDEO_H 1
4#include <stdio.h>
5#include <stdlib.h>
6#include <assert.h>
7#include <sys/types.h>
8#include <sys/stat.h>
9#include <sys/mman.h>
10#include <fcntl.h>
11#include <string.h>
12#include <pci/pci.h>
13#include <sys/io.h>
14#include <sys/time.h>
15#include <linux/types.h>
16/* stuff we can't get coccinelle to do yet */
17#define __iomem
18#define __read_mostly
19#define __always_unused
20#define module_param_named(a, b, c, d)
21#define MODULE_PARM_DESC(a, b)
22#define DRM_DEBUG_KMS printf
23#define CONFIG_DRM_I915_KMS 1
24#define module_init(x);
25#define module_exit(x);
26
27#define MODULE_AUTHOR(x)
28#define MODULE_DESCRIPTION(x)
29#define MODULE_LICENSE(a)
30#define MODULE_DEVICE_TABLE(a, b)
31
32/* constants that will never change from linux/vga.h */
33/* Legacy VGA regions */
34#define VGA_RSRC_NONE 0x00
35#define VGA_RSRC_LEGACY_IO 0x01
36#define VGA_RSRC_LEGACY_MEM 0x02
37#define VGA_RSRC_LEGACY_MASK (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)
38/* Non-legacy access */
39#define VGA_RSRC_NORMAL_IO 0x04
40#define VGA_RSRC_NORMAL_MEM 0x08
41
42
43/* define in pci.h! */
44#include <pci/pci.h>
45/* idiocy. how many names to we need for a type? */
46typedef u32 uint32_t;
47typedef u64 uint64_t;
48/* WTF */
49typedef int bool;
50enum {false = 0, true};
51
52/* we define our own. The kernel one is too full of stuff. */
53struct mode_config {
54 int num_fb;
55 int num_connector;
56 int num_crtc;
57 int num_encoder;
58 int min_width, min_height, max_width, max_height;
59};
60
61struct drm_device {
62 struct pci_dev *pdev;
63 u8 *bios_bin;
64 struct drm_i915_private *dev_private;
65 struct mode_config mode_config;
66};
67
68/* we're willing to define our own here because it's relatively unchanging */
69#define PCI_ANY_ID (~0)
70
71struct pci_device_id {
72 u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
73 u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
74 u32 class, class_mask; /* (class,subclass,prog-if) triplet */
75 unsigned long driver_data; /* Data private to the driver */
76};
77
78
79/* per the cocinelle people, they can't handle this.
80 * It also almost never changes */
81#define INTEL_VGA_DEVICE(id, info) { \
82 .class = PCI_CLASS_DISPLAY_VGA << 8, \
83 .class_mask = 0xff0000, \
84 .vendor = 0x8086, \
85 .device = id, \
86 .subvendor = PCI_ANY_ID, \
87 .subdevice = PCI_ANY_ID, \
88 .driver_data = (unsigned long) info }
89
90#define wait_for(condition, time) (sleep(1+time/50) && (!condition))
91
92
93/* random crap from kernel.h.
94 * Kernel.h is a catch-all for all kinds of junk and it's
95 * not worth using coccinelle (yet) to pull it apart. Maybe later.
96 * And, yes, gcc still does not have nelem!
97 */
98#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
99#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
100#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
101#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
102#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
103#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
104#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
105#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
106
107
108/* temporary. */
109void *dmi_check_system(unsigned long);
110
111#include "final/drm_dp_helper.h"
112#include "final/i915_reg.h"
113#include "final/i915_drv.h"
114#include "final/drm_mode.h"
115#include "final/drm_crtc.h"
116
117unsigned long I915_READ(unsigned long addr);
118void I915_WRITE(unsigned long addr, unsigned long val);
119u16 I915_READ16(unsigned long addr);
120void I915_WRITE16(unsigned long addr, u16 val);
121unsigned long msecs(void);
122void mdelay(unsigned long ms);
123
124/* these should be the same. */
125#define POSTING_READ I915_READ
126#define POSTING_READ16 I915_READ16
127
128void *pci_map_rom(struct pci_dev *dev, size_t *size);
129void *pci_unmap_rom(struct pci_dev *dev, void *p);
130extern unsigned int i915_lvds_downclock;
131extern int i915_vbt_sdvo_panel_type;
132unsigned long lvds_do_not_use_alternate_frequency;
133#endif /* VIDEO_H */