[ARM] 3848/1: pxafb: Add option of fixing video modes and spitz QVGA mode support
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / corgi_lcd.c
index c02ef7c..d781549 100644 (file)
 
 #include <linux/delay.h>
 #include <linux/kernel.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/module.h>
+#include <linux/string.h>
 #include <asm/arch/akita.h>
 #include <asm/arch/corgi.h>
-#include <asm/arch/hardware.h>
+#include <asm/hardware.h>
 #include <asm/arch/pxa-regs.h>
 #include <asm/arch/sharpsl.h>
 #include <asm/arch/spitz.h>
@@ -430,10 +431,10 @@ struct platform_device corgifb_device = {
 
 #include <asm/arch/pxafb.h>
 
-void spitz_lcd_power(int on)
+void spitz_lcd_power(int on, struct fb_var_screeninfo *var)
 {
        if (on)
-               lcdtg_hw_init(480);
+               lcdtg_hw_init(var->xres);
        else
                lcdtg_suspend();
 }
@@ -467,6 +468,7 @@ void corgi_put_hsync(void)
 {
        if (get_hsync_time)
                symbol_put(w100fb_get_hsynclen);
+       get_hsync_time = NULL;
 }
 
 void corgi_wait_hsync(void)
@@ -476,20 +478,39 @@ void corgi_wait_hsync(void)
 #endif
 
 #ifdef CONFIG_PXA_SHARP_Cxx00
+static struct device *spitz_pxafb_dev;
+
+static int is_pxafb_device(struct device * dev, void * data)
+{
+       struct platform_device *pdev = container_of(dev, struct platform_device, dev);
+
+       return (strncmp(pdev->name, "pxa2xx-fb", 9) == 0);
+}
+
 unsigned long spitz_get_hsync_len(void)
 {
+#ifdef CONFIG_FB_PXA
+       if (!spitz_pxafb_dev) {
+               spitz_pxafb_dev = bus_find_device(&platform_bus_type, NULL, NULL, is_pxafb_device);
+               if (!spitz_pxafb_dev)
+                       return 0;
+       }
        if (!get_hsync_time)
                get_hsync_time = symbol_get(pxafb_get_hsync_time);
        if (!get_hsync_time)
+#endif
                return 0;
 
-       return pxafb_get_hsync_time(&pxafb_device.dev);
+       return pxafb_get_hsync_time(spitz_pxafb_dev);
 }
 
 void spitz_put_hsync(void)
 {
+       put_device(spitz_pxafb_dev);
        if (get_hsync_time)
                symbol_put(pxafb_get_hsync_time);
+       spitz_pxafb_dev = NULL;
+       get_hsync_time = NULL;
 }
 
 void spitz_wait_hsync(void)