# These are various fixes needed to make the psb kernel driver build against
# 2.6.33.2.
# The Makefile patch is specific to the Poky environment - the external kernel
# module build expects the kernel tree it's building against to have fixdep
# and modpost built, which isn't the case here.  So, the modules rule makes
# sure that they are built before the module is built.
# Aside from that, the changes involve adding missing header files and 
# compensating for a structure field changing name and type.

Index: psb-kernel-source-4.42.0/drm_os_linux.h
===================================================================
--- psb-kernel-source-4.42.0.orig/drm_os_linux.h
+++ psb-kernel-source-4.42.0/drm_os_linux.h
@@ -50,12 +50,6 @@
 
 /** IRQ handler arguments and return type and values */
 #define DRM_IRQ_ARGS		int irq, void *arg
-/** backwards compatibility with old irq return values */
-#ifndef IRQ_HANDLED
-typedef void irqreturn_t;
-#define IRQ_HANDLED		/* nothing */
-#define IRQ_NONE		/* nothing */
-#endif
 
 /** AGP types */
 #if __OS_HAS_AGP
Index: psb-kernel-source-4.42.0/Makefile
===================================================================
--- psb-kernel-source-4.42.0.orig/Makefile
+++ psb-kernel-source-4.42.0/Makefile
@@ -165,7 +165,10 @@ endif
 all: modules
 
 modules: includes
-	+make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules
+	+make -C $(LINUXDIR)/scripts/basic fixdep
+#	+make -C $(LINUXDIR) SUBDIRS=scripts/mod modpost
+	+make -C $(LINUXDIR) SUBDIRS=scripts
+	+make -k -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules
 
 ifeq ($(HEADERFROMBOOT),1)
 
@@ -243,7 +246,7 @@ dristat: dristat.c
 drmstat: drmstat.c
 	$(CC) $(PRGCFLAGS) $< -o $@ $(DRMSTATLIBS)
 
-install:
+modules_install:
 	make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules_install
 
 else
Index: psb-kernel-source-4.42.0/drm_edid.c
===================================================================
--- psb-kernel-source-4.42.0.orig/drm_edid.c
+++ psb-kernel-source-4.42.0/drm_edid.c
@@ -11,6 +11,7 @@
 #include "drm_edid.h"
 
 #include <acpi/acpi_drivers.h>
+#include <linux/i2c.h>
 
 /* Valid EDID header has these bytes */
 static u8 edid_header[] = { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 };
@@ -39,7 +40,7 @@ int drm_get_acpi_edid(char *method, char
 	if (obj && obj->type == ACPI_TYPE_BUFFER)
 		memcpy(edid, obj->buffer.pointer, obj->buffer.length);
 	else {
-		printk(KERN_ERR PREFIX "Invalid _DDC data\n");
+		printk(KERN_ERR "Invalid _DDC data\n");
 		status = -EFAULT;
 		kfree(obj);
 	}
Index: psb-kernel-source-4.42.0/drm_ttm.c
===================================================================
--- psb-kernel-source-4.42.0.orig/drm_ttm.c
+++ psb-kernel-source-4.42.0/drm_ttm.c
@@ -28,6 +28,8 @@
  * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
  */
 
+#include "linux/spinlock.h"
+#include "asm/agp.h"
 #include "drmP.h"
 
 static void drm_ttm_ipi_handler(void *null)
Index: psb-kernel-source-4.42.0/psb_drv.c
===================================================================
--- psb-kernel-source-4.42.0.orig/psb_drv.c
+++ psb-kernel-source-4.42.0/psb_drv.c
@@ -34,8 +34,10 @@
 #include <linux/cpu.h>
 #include <linux/notifier.h>
 #include <linux/fb.h>
+#include "linux/spinlock.h"
+#include "asm/agp.h"
 
-int drm_psb_debug = 0;
+int drm_psb_debug = 255;
 EXPORT_SYMBOL(drm_psb_debug);
 static int drm_psb_trap_pagefaults = 0;
 static int drm_psb_clock_gating = 0;
Index: psb-kernel-source-4.42.0/intel_lvds.c
===================================================================
--- psb-kernel-source-4.42.0.orig/intel_lvds.c
+++ psb-kernel-source-4.42.0/intel_lvds.c
@@ -29,6 +29,7 @@
 
 #include <linux/i2c.h>
 #include <linux/backlight.h>
+#include <linux/i2c.h>
 #include "drm_crtc.h"
 #include "drm_edid.h"
 #include "intel_lvds.h"
Index: psb-kernel-source-4.42.0/drm_memory.c
===================================================================
--- psb-kernel-source-4.42.0.orig/drm_memory.c
+++ psb-kernel-source-4.42.0/drm_memory.c
@@ -264,9 +264,9 @@ static void *agp_remap(unsigned long off
 		return NULL;
 
 	phys_addr_map =
-	    agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE;
+	    agpmem->memory->pages + (offset - agpmem->bound) / PAGE_SIZE;
 	for (i = 0; i < num_pages; ++i)
-		page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT);
+                page_map[i] = phys_addr_map[i];
 	addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP);
 	vfree(page_map);
 
Index: psb-kernel-source-4.42.0/drm_agpsupport.c
===================================================================
--- psb-kernel-source-4.42.0.orig/drm_agpsupport.c
+++ psb-kernel-source-4.42.0/drm_agpsupport.c
@@ -524,7 +524,7 @@ static int drm_agp_populate(struct drm_t
 	DRM_DEBUG("Current page count is %ld\n", (long) mem->page_count);
 	mem->page_count = 0;
 	for (cur_page = pages; cur_page < last_page; ++cur_page)
-		mem->pages[mem->page_count++] = phys_to_gart(page_to_phys(*cur_page));
+		mem->pages[mem->page_count++] = page_to_phys(*cur_page);
 	agp_be->mem = mem;
 	return 0;
 }
Index: psb-kernel-source-4.42.0/drm_vm.c
===================================================================
--- psb-kernel-source-4.42.0.orig/drm_vm.c
+++ psb-kernel-source-4.42.0/drm_vm.c
@@ -145,13 +145,13 @@ static int drm_do_vm_fault(struct vm_are
 		 * Get the page, inc the use count, and return it
 		 */
 		offset = (baddr - agpmem->bound) >> PAGE_SHIFT;
-		page = virt_to_page(__va(agpmem->memory->memory[offset]));
+		page = agpmem->memory->pages[offset];
 		get_page(page);
 		vmf->page = page;
 
 		DRM_DEBUG
 		    ("baddr = 0x%lx page = 0x%p, offset = 0x%lx, count=%d\n",
-		     baddr, __va(agpmem->memory->memory[offset]), offset,
+		     baddr, agpmem->memory->pages[offset], offset,
 		     page_count(page));
 		return 0;
 	}
Index: psb-kernel-source-4.42.0/psb_drv.h
===================================================================
--- psb-kernel-source-4.42.0.orig/psb_drv.h
+++ psb-kernel-source-4.42.0/psb_drv.h
@@ -809,7 +809,7 @@ extern int drm_psb_detear;
 #define PSB_DEBUG(_flag, _fmt, _arg...)					\
 	do {								\
 	  if (unlikely((_flag) & drm_psb_debug))			\
-			printk(KERN_DEBUG				\
+			printk(KERN_ERR				\
 			       "[psb:0x%02x:%s] " _fmt , _flag,	\
 			       __FUNCTION__ , ##_arg);			\
 	} while (0)
