omapfb: add support for the OMAP2EVM LCD
[safe/jmp/linux-2.6] / drivers / video / chipsfb.c
index 4131243..57b9d27 100644 (file)
  *  more details.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/mm.h>
-#include <linux/tty.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/fb.h>
+#include <linux/pm.h>
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/console.h>
@@ -91,7 +90,6 @@ static struct fb_ops chipsfb_ops = {
        .fb_fillrect    = cfb_fillrect,
        .fb_copyarea    = cfb_copyarea,
        .fb_imageblit   = cfb_imageblit,
-       .fb_cursor      = soft_cursor,
 };
 
 static int chipsfb_check_var(struct fb_var_screeninfo *var,
@@ -148,12 +146,6 @@ static int chipsfb_set_par(struct fb_info *info)
 
 static int chipsfb_blank(int blank, struct fb_info *info)
 {
-#ifdef CONFIG_PMAC_BACKLIGHT
-       // used to disable backlight only for blank > 1, but it seems
-       // useful at blank = 1 too (saves battery, extends backlight life)
-       set_backlight_enable(!blank);
-#endif /* CONFIG_PMAC_BACKLIGHT */
-
        return 1;       /* get fb_blank to set the colormap to all black */
 }
 
@@ -179,8 +171,6 @@ struct chips_init_reg {
        unsigned char data;
 };
 
-#define N_ELTS(x)      (sizeof(x) / sizeof(x[0]))
-
 static struct chips_init_reg chips_init_sr[] = {
        { 0x00, 0x03 },
        { 0x01, 0x01 },
@@ -288,22 +278,22 @@ static void __init chips_hw_init(void)
 {
        int i;
 
-       for (i = 0; i < N_ELTS(chips_init_xr); ++i)
+       for (i = 0; i < ARRAY_SIZE(chips_init_xr); ++i)
                write_xr(chips_init_xr[i].addr, chips_init_xr[i].data);
        outb(0x29, 0x3c2); /* set misc output reg */
-       for (i = 0; i < N_ELTS(chips_init_sr); ++i)
+       for (i = 0; i < ARRAY_SIZE(chips_init_sr); ++i)
                write_sr(chips_init_sr[i].addr, chips_init_sr[i].data);
-       for (i = 0; i < N_ELTS(chips_init_gr); ++i)
+       for (i = 0; i < ARRAY_SIZE(chips_init_gr); ++i)
                write_gr(chips_init_gr[i].addr, chips_init_gr[i].data);
-       for (i = 0; i < N_ELTS(chips_init_ar); ++i)
+       for (i = 0; i < ARRAY_SIZE(chips_init_ar); ++i)
                write_ar(chips_init_ar[i].addr, chips_init_ar[i].data);
-       for (i = 0; i < N_ELTS(chips_init_cr); ++i)
+       for (i = 0; i < ARRAY_SIZE(chips_init_cr); ++i)
                write_cr(chips_init_cr[i].addr, chips_init_cr[i].data);
-       for (i = 0; i < N_ELTS(chips_init_fr); ++i)
+       for (i = 0; i < ARRAY_SIZE(chips_init_fr); ++i)
                write_fr(chips_init_fr[i].addr, chips_init_fr[i].data);
 }
 
-static struct fb_fix_screeninfo chipsfb_fix __initdata = {
+static struct fb_fix_screeninfo chipsfb_fix __devinitdata = {
        .id =           "C&T 65550",
        .type =         FB_TYPE_PACKED_PIXELS,
        .visual =       FB_VISUAL_PSEUDOCOLOR,
@@ -320,7 +310,7 @@ static struct fb_fix_screeninfo chipsfb_fix __initdata = {
        .smem_len =     0x100000,       /* 1MB */
 };
 
-static struct fb_var_screeninfo chipsfb_var __initdata = {
+static struct fb_var_screeninfo chipsfb_var __devinitdata = {
        .xres = 800,
        .yres = 600,
        .xres_virtual = 800,
@@ -341,7 +331,7 @@ static struct fb_var_screeninfo chipsfb_var __initdata = {
        .vsync_len = 8,
 };
 
-static void __init init_chips(struct fb_info *p, unsigned long addr)
+static void __devinit init_chips(struct fb_info *p, unsigned long addr)
 {
        memset(p->screen_base, 0, 0x100000);
 
@@ -404,7 +394,12 @@ chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
 
 #ifdef CONFIG_PMAC_BACKLIGHT
        /* turn on the backlight */
-       set_backlight_enable(1);
+       mutex_lock(&pmac_backlight_mutex);
+       if (pmac_backlight) {
+               pmac_backlight->props.power = FB_BLANK_UNBLANK;
+               backlight_update_status(pmac_backlight);
+       }
+       mutex_unlock(&pmac_backlight_mutex);
 #endif /* CONFIG_PMAC_BACKLIGHT */
 
 #ifdef CONFIG_PPC
@@ -419,7 +414,6 @@ chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
        }
 
        pci_set_drvdata(dp, p);
-       p->device = &dp->dev;
 
        init_chips(p, addr);
 
@@ -464,7 +458,7 @@ static int chipsfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 
        if (state.event == pdev->dev.power.power_state.event)
                return 0;
-       if (state.event != PM_SUSPEND_MEM)
+       if (!(state.event & PM_EVENT_SLEEP))
                goto done;
 
        acquire_console_sem();