aboutsummaryrefslogtreecommitdiff
path: root/util/i915tool/video.h
diff options
context:
space:
mode:
authorStefan Reinauer <reinauer@chromium.org>2012-05-04 15:37:18 -0700
committerStefan Reinauer <stefan.reinauer@coreboot.org>2012-05-08 00:40:36 +0200
commit564e90f57185274130aba7b157a7dca1941dcfef (patch)
treef71985b7f878f83d7e5773675ca27a4a2da94cdf /util/i915tool/video.h
parent44a89b34f85492c48a19db1b9b2c2c44ab29c9ae (diff)
Add a tool to work on i915 hardware in user mode
This is the beginning of a tool that transforms the i9x5 code to user mode code. Consider this a very early stage although it does produce two programs. Requires spatch 1.0 or greater. To try it out, assuming you have an up-to-date spatch, sh transform make make broken Please don't fall to the temptation to auto-magicize this process. It's primitive for a reason. That said, suggestions welcome of course. Change-Id: I0188e36637b198b06c17f6d3c714d990e88bd57d Signed-off-by: Ronald G. Minnich <rminnich@chromium.org> Reviewed-on: http://review.coreboot.org/1003 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'util/i915tool/video.h')
-rw-r--r--util/i915tool/video.h133
1 files changed, 133 insertions, 0 deletions
diff --git a/util/i915tool/video.h b/util/i915tool/video.h
new file mode 100644
index 0000000000..6919830c38
--- /dev/null
+++ b/util/i915tool/video.h
@@ -0,0 +1,133 @@
+/* cocci issues ;-( */
+#ifndef VIDEO_H
+#define VIDEO_H 1
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <string.h>
+#include <pci/pci.h>
+#include <sys/io.h>
+#include <sys/time.h>
+#include <linux/types.h>
+/* stuff we can't get coccinelle to do yet */
+#define __iomem
+#define __read_mostly
+#define __always_unused
+#define module_param_named(a, b, c, d)
+#define MODULE_PARM_DESC(a, b)
+#define DRM_DEBUG_KMS printf
+#define CONFIG_DRM_I915_KMS 1
+#define module_init(x);
+#define module_exit(x);
+
+#define MODULE_AUTHOR(x)
+#define MODULE_DESCRIPTION(x)
+#define MODULE_LICENSE(a)
+#define MODULE_DEVICE_TABLE(a, b)
+
+/* constants that will never change from linux/vga.h */
+/* Legacy VGA regions */
+#define VGA_RSRC_NONE 0x00
+#define VGA_RSRC_LEGACY_IO 0x01
+#define VGA_RSRC_LEGACY_MEM 0x02
+#define VGA_RSRC_LEGACY_MASK (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)
+/* Non-legacy access */
+#define VGA_RSRC_NORMAL_IO 0x04
+#define VGA_RSRC_NORMAL_MEM 0x08
+
+
+/* define in pci.h! */
+#include <pci/pci.h>
+/* idiocy. how many names to we need for a type? */
+typedef u32 uint32_t;
+typedef u64 uint64_t;
+/* WTF */
+typedef int bool;
+enum {false = 0, true};
+
+/* we define our own. The kernel one is too full of stuff. */
+struct mode_config {
+ int num_fb;
+ int num_connector;
+ int num_crtc;
+ int num_encoder;
+ int min_width, min_height, max_width, max_height;
+};
+
+struct drm_device {
+ struct pci_dev *pdev;
+ u8 *bios_bin;
+ struct drm_i915_private *dev_private;
+ struct mode_config mode_config;
+};
+
+/* we're willing to define our own here because it's relatively unchanging */
+#define PCI_ANY_ID (~0)
+
+struct pci_device_id {
+ u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
+ u32 subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
+ u32 class, class_mask; /* (class,subclass,prog-if) triplet */
+ unsigned long driver_data; /* Data private to the driver */
+};
+
+
+/* per the cocinelle people, they can't handle this.
+ * It also almost never changes */
+#define INTEL_VGA_DEVICE(id, info) { \
+ .class = PCI_CLASS_DISPLAY_VGA << 8, \
+ .class_mask = 0xff0000, \
+ .vendor = 0x8086, \
+ .device = id, \
+ .subvendor = PCI_ANY_ID, \
+ .subdevice = PCI_ANY_ID, \
+ .driver_data = (unsigned long) info }
+
+#define wait_for(condition, time) (sleep(1+time/50) && (!condition))
+
+
+/* random crap from kernel.h.
+ * Kernel.h is a catch-all for all kinds of junk and it's
+ * not worth using coccinelle (yet) to pull it apart. Maybe later.
+ * And, yes, gcc still does not have nelem!
+ */
+#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
+#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
+#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask))
+#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
+#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
+
+
+/* temporary. */
+void *dmi_check_system(unsigned long);
+
+#include "final/drm_dp_helper.h"
+#include "final/i915_reg.h"
+#include "final/i915_drv.h"
+#include "final/drm_mode.h"
+#include "final/drm_crtc.h"
+
+unsigned long I915_READ(unsigned long addr);
+void I915_WRITE(unsigned long addr, unsigned long val);
+u16 I915_READ16(unsigned long addr);
+void I915_WRITE16(unsigned long addr, u16 val);
+unsigned long msecs(void);
+void mdelay(unsigned long ms);
+
+/* these should be the same. */
+#define POSTING_READ I915_READ
+#define POSTING_READ16 I915_READ16
+
+void *pci_map_rom(struct pci_dev *dev, size_t *size);
+void *pci_unmap_rom(struct pci_dev *dev, void *p);
+extern unsigned int i915_lvds_downclock;
+extern int i915_vbt_sdvo_panel_type;
+unsigned long lvds_do_not_use_alternate_frequency;
+#endif /* VIDEO_H */