]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/video/omap/omapfb_main.c
ARM: OMAP: Frambuffer driver CodingStyle changes.
[linux-2.6-omap-h63xx.git] / drivers / video / omap / omapfb_main.c
index 731b0575595654a4cd9c77d715cb54d38d60a29b..3d8dff1c2dd1ac39631cb8204b784db97a957614 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * File: drivers/video/omap/omapfb_main.c
- *
  * Framebuffer driver for TI OMAP boards
  *
  * Copyright (C) 2004 Nokia Corporation
@@ -26,7 +24,6 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
-#include <linux/config.h>
 #include <linux/platform_device.h>
 
 #include <asm/uaccess.h>
@@ -54,14 +51,34 @@ static struct platform_device       *fbdev_pdev;
 static struct lcd_panel                *fbdev_panel;
 static struct omapfb_device    *omapfb_dev;
 
-static struct caps_table_struct {
+struct caps_table_struct {
         unsigned long flag;
         const char *name;
-} omapfb_caps_table[] = {
+};
+
+static struct caps_table_struct ctrl_caps[] = {
        { OMAPFB_CAPS_MANUAL_UPDATE, "manual update" },
+       { OMAPFB_CAPS_TEARSYNC,      "tearing synchronization" },
+       { OMAPFB_CAPS_PLANE_RELOCATE_MEM, "relocate plane memory" },
+       { OMAPFB_CAPS_PLANE_SCALE,   "scale plane" },
+       { OMAPFB_CAPS_WINDOW_PIXEL_DOUBLE, "pixel double window" },
+       { OMAPFB_CAPS_WINDOW_SCALE,  "scale window" },
+       { OMAPFB_CAPS_WINDOW_OVERLAY,"overlay window" },
        { OMAPFB_CAPS_SET_BACKLIGHT, "backlight setting" },
 };
 
+static struct caps_table_struct color_caps[] = {
+       { 1 << OMAPFB_COLOR_RGB565,     "RGB565", },
+       { 1 << OMAPFB_COLOR_YUV422,     "YUV422", },
+       { 1 << OMAPFB_COLOR_YUV420,     "YUV420", },
+       { 1 << OMAPFB_COLOR_CLUT_8BPP,  "CLUT8", },
+       { 1 << OMAPFB_COLOR_CLUT_4BPP,  "CLUT4", },
+       { 1 << OMAPFB_COLOR_CLUT_2BPP,  "CLUT2", },
+       { 1 << OMAPFB_COLOR_CLUT_1BPP,  "CLUT1", },
+       { 1 << OMAPFB_COLOR_RGB444,     "RGB444", },
+       { 1 << OMAPFB_COLOR_YUY422,     "YUY422", },
+};
+
 /*
  * ---------------------------------------------------------------------------
  * LCD panel
@@ -70,6 +87,7 @@ static struct caps_table_struct {
 extern struct lcd_ctrl omap1_int_ctrl;
 extern struct lcd_ctrl omap2_int_ctrl;
 extern struct lcd_ctrl hwa742_ctrl;
+extern struct lcd_ctrl blizzard_ctrl;
 
 static struct lcd_ctrl *ctrls[] = {
 #ifdef CONFIG_ARCH_OMAP1
@@ -81,6 +99,9 @@ static struct lcd_ctrl *ctrls[] = {
 #ifdef CONFIG_FB_OMAP_LCDC_HWA742
        &hwa742_ctrl,
 #endif
+#ifdef CONFIG_FB_OMAP_LCDC_BLIZZARD
+       &blizzard_ctrl,
+#endif
 };
 
 #ifdef CONFIG_FB_OMAP_LCDC_EXTERNAL
@@ -115,7 +136,8 @@ static const int dma_elem_type[] = {
        OMAP_DMA_DATA_TYPE_S32,
 };
 
-/* Allocate resources needed for LCD controller and LCD DMA operations. Video
+/*
+ * Allocate resources needed for LCD controller and LCD DMA operations. Video
  * memory is allocated from system memory according to the virtual display
  * size, except if a bigger memory size is specified explicitly as a kernel
  * parameter.
@@ -128,7 +150,8 @@ static int ctrl_init(struct omapfb_device *fbdev)
        /* kernel/module vram parameters override boot tags/board config */
        if (def_vram_cnt) {
                for (i = 0; i < def_vram_cnt; i++)
-                       fbdev->mem_desc.region[i].size = def_vram[i];
+                       fbdev->mem_desc.region[i].size =
+                               PAGE_ALIGN(def_vram[i]);
                fbdev->mem_desc.region_cnt = i;
        } else {
                struct omapfb_platform_data *conf;
@@ -147,7 +170,7 @@ static int ctrl_init(struct omapfb_device *fbdev)
                        bpp = 16;
                def_size = def_vxres * def_vyres * bpp / 8;
                fbdev->mem_desc.region_cnt = 1;
-               fbdev->mem_desc.region[0].size = def_size;
+               fbdev->mem_desc.region[0].size = PAGE_ALIGN(def_size);
        }
        r = fbdev->ctrl->init(fbdev, 0, &fbdev->mem_desc);
        if (r < 0) {
@@ -172,6 +195,7 @@ static void ctrl_cleanup(struct omapfb_device *fbdev)
        fbdev->ctrl->cleanup();
 }
 
+/* Must be called with fbdev->rqueue_mutex held. */
 static int ctrl_change_mode(struct fb_info *fbi)
 {
        int r;
@@ -183,7 +207,8 @@ static int ctrl_change_mode(struct fb_info *fbi)
        offset = var->yoffset * fbi->fix.line_length +
                 var->xoffset * var->bits_per_pixel / 8;
 
-       omapfb_rqueue_lock(fbdev);
+       if (fbdev->ctrl->sync)
+               fbdev->ctrl->sync();
        r = fbdev->ctrl->setup_plane(plane->idx, plane->info.channel_out,
                                 offset, var->xres_virtual,
                                 plane->info.pos_x, plane->info.pos_y,
@@ -193,7 +218,6 @@ static int ctrl_change_mode(struct fb_info *fbi)
                                   var->xres, var->yres,
                                   plane->info.out_width,
                                   plane->info.out_height);
-       omapfb_rqueue_unlock(fbdev);
 
        return r;
 }
@@ -353,15 +377,23 @@ static void omapfb_sync(struct fb_info *fbi)
        omapfb_rqueue_unlock(fbdev);
 }
 
-/* Set fb_info.fix fields and also updates fbdev.
+/*
+ * Set fb_info.fix fields and also updates fbdev.
  * When calling this fb_info.var must be set up already.
  */
 static void set_fb_fix(struct fb_info *fbi)
 {
        struct fb_fix_screeninfo *fix = &fbi->fix;
        struct fb_var_screeninfo *var = &fbi->var;
+       struct omapfb_plane_struct *plane = fbi->par;
+       struct omapfb_mem_region *rg;
        int bpp;
 
+       rg = &plane->fbdev->mem_desc.region[plane->idx];
+       fbi->screen_base        = (char __iomem *)rg->vaddr;
+       fix->smem_start         = rg->paddr;
+       fix->smem_len           = rg->size;
+
        fix->type = FB_TYPE_PACKED_PIXELS;
        bpp = var->bits_per_pixel;
        if (var->nonstd)
@@ -431,7 +463,8 @@ static int set_color_mode(struct omapfb_plane_struct *plane,
        }
 }
 
-/* Check the values in var against our capabilities and in case of out of
+/*
+ * Check the values in var against our capabilities and in case of out of
  * bound values try to adjust them.
  */
 static int set_fb_var(struct fb_info *fbi,
@@ -460,7 +493,7 @@ static int set_fb_var(struct fb_info *fbi,
                xres_max = panel->x_res;
                yres_min = OMAPFB_PLANE_YRES_MIN;
                yres_max = panel->y_res;
-               if (cpu_is_omap1510()) {
+               if (cpu_is_omap15xx()) {
                        var->xres = panel->x_res;
                        var->yres = panel->y_res;
                }
@@ -471,7 +504,7 @@ static int set_fb_var(struct fb_info *fbi,
                xres_max = panel->y_res;
                yres_min = OMAPFB_PLANE_XRES_MIN;
                yres_max = panel->x_res;
-               if (cpu_is_omap1510()) {
+               if (cpu_is_omap15xx()) {
                        var->xres = panel->y_res;
                        var->yres = panel->x_res;
                }
@@ -505,6 +538,13 @@ static int set_fb_var(struct fb_info *fbi,
                        line_size = var->xres * bpp / 8;
                        var->yres_virtual = max_frame_size / line_size;
                }
+               /* Recheck this, as the virtual size changed. */
+               if (var->xres_virtual < var->xres)
+                       var->xres = var->xres_virtual;
+               if (var->yres_virtual < var->yres)
+                       var->yres = var->yres_virtual;
+               if (var->xres < xres_min || var->yres < yres_min)
+                       return -EINVAL;
        }
        if (var->xres + var->xoffset > var->xres_virtual)
                var->xoffset = var->xres_virtual - var->xres;
@@ -548,42 +588,55 @@ static int set_fb_var(struct fb_info *fbi,
        return 0;
 }
 
-static struct fb_var_screeninfo new_var;
 
 /* Set rotation (0, 90, 180, 270 degree), and switch to the new mode. */
 static void omapfb_rotate(struct fb_info *fbi, int rotate)
 {
-       if (cpu_is_omap1510() && rotate != fbi->var.rotate) {
-               memcpy(&new_var, &fbi->var, sizeof(new_var));
-               new_var.rotate = rotate;
-               if (set_fb_var(fbi, &new_var) == 0 &&
-                   memcmp(&new_var, &fbi->var, sizeof(new_var))) {
-                       memcpy(&fbi->var, &new_var, sizeof(new_var));
+       struct omapfb_plane_struct *plane = fbi->par;
+       struct omapfb_device *fbdev = plane->fbdev;
+
+       omapfb_rqueue_lock(fbdev);
+       if (cpu_is_omap15xx() && rotate != fbi->var.rotate) {
+               struct fb_var_screeninfo *new_var = &fbdev->new_var;
+
+               memcpy(new_var, &fbi->var, sizeof(*new_var));
+               new_var->rotate = rotate;
+               if (set_fb_var(fbi, new_var) == 0 &&
+                   memcmp(new_var, &fbi->var, sizeof(*new_var))) {
+                       memcpy(&fbi->var, new_var, sizeof(*new_var));
                        ctrl_change_mode(fbi);
                }
        }
+       omapfb_rqueue_unlock(fbdev);
 }
 
-/* Set new x,y offsets in the virtual display for the visible area and switch
+/*
+ * Set new x,y offsets in the virtual display for the visible area and switch
  * to the new mode.
  */
 static int omapfb_pan_display(struct fb_var_screeninfo *var,
                               struct fb_info *fbi)
 {
+       struct omapfb_plane_struct *plane = fbi->par;
+       struct omapfb_device *fbdev = plane->fbdev;
        int r = 0;
 
+       omapfb_rqueue_lock(fbdev);
        if (var->xoffset != fbi->var.xoffset ||
            var->yoffset != fbi->var.yoffset) {
-               memcpy(&new_var, &fbi->var, sizeof(new_var));
-               new_var.xoffset = var->xoffset;
-               new_var.yoffset = var->yoffset;
-               if (set_fb_var(fbi, &new_var))
+               struct fb_var_screeninfo *new_var = &fbdev->new_var;
+
+               memcpy(new_var, &fbi->var, sizeof(*new_var));
+               new_var->xoffset = var->xoffset;
+               new_var->yoffset = var->yoffset;
+               if (set_fb_var(fbi, new_var))
                        r = -EINVAL;
                else {
-                       memcpy(&fbi->var, &new_var, sizeof(new_var));
+                       memcpy(&fbi->var, new_var, sizeof(*new_var));
                        ctrl_change_mode(fbi);
                }
        }
+       omapfb_rqueue_unlock(fbdev);
 
        return r;
 }
@@ -592,34 +645,57 @@ static int omapfb_pan_display(struct fb_var_screeninfo *var,
 static int omapfb_mirror(struct fb_info *fbi, int mirror)
 {
        struct omapfb_plane_struct *plane = fbi->par;
+       struct omapfb_device *fbdev = plane->fbdev;
        int r = 0;
 
+       omapfb_rqueue_lock(fbdev);
        mirror = mirror ? 1 : 0;
-       if (cpu_is_omap1510())
+       if (cpu_is_omap15xx())
                r = -EINVAL;
        else if (mirror != plane->info.mirror) {
                plane->info.mirror = mirror;
                r = ctrl_change_mode(fbi);
        }
+       omapfb_rqueue_unlock(fbdev);
 
        return r;
 }
 
-/* Check values in var, try to adjust them in case of out of bound values if
+/*
+ * Check values in var, try to adjust them in case of out of bound values if
  * possible, or return error.
  */
 static int omapfb_check_var(struct fb_var_screeninfo *var, struct fb_info *fbi)
 {
-       return set_fb_var(fbi, var);
+       struct omapfb_plane_struct *plane = fbi->par;
+       struct omapfb_device *fbdev = plane->fbdev;
+       int r;
+
+       omapfb_rqueue_lock(fbdev);
+       if (fbdev->ctrl->sync != NULL)
+               fbdev->ctrl->sync();
+       r = set_fb_var(fbi, var);
+       omapfb_rqueue_unlock(fbdev);
+
+       return r;
 }
 
-/* Switch to a new mode. The parameters for it has been check already by
+/*
+ * Switch to a new mode. The parameters for it has been check already by
  * omapfb_check_var.
  */
 static int omapfb_set_par(struct fb_info *fbi)
 {
+       struct omapfb_plane_struct *plane = fbi->par;
+       struct omapfb_device *fbdev = plane->fbdev;
+       int r = 0;
+
+       omapfb_rqueue_lock(fbdev);
        set_fb_fix(fbi);
-       return ctrl_change_mode(fbi);
+       r = ctrl_change_mode(fbi);
+       omapfb_rqueue_unlock(fbdev);
+
+       return r;
 }
 
 int omapfb_update_window_async(struct fb_info *fbi,
@@ -632,8 +708,8 @@ int omapfb_update_window_async(struct fb_info *fbi,
        struct fb_var_screeninfo *var;
 
        var = &fbi->var;
-
-       if (win->x >= var->xres || win->y >= var->yres)
+       if (win->x >= var->xres || win->y >= var->yres ||
+           win->out_x > var->xres || win->out_y >= var->yres)
                return -EINVAL;
 
        if (!fbdev->ctrl->update_window ||
@@ -644,7 +720,12 @@ int omapfb_update_window_async(struct fb_info *fbi,
                win->width = var->xres - win->x;
        if (win->y + win->height >= var->yres)
                win->height = var->yres - win->y;
-       if (!win->width || !win->height)
+       /* The out sizes should be cropped to the LCD size */
+       if (win->out_x + win->out_width > fbdev->panel->x_res)
+               win->out_width = fbdev->panel->x_res - win->out_x;
+       if (win->out_y + win->out_height > fbdev->panel->y_res)
+               win->out_height = fbdev->panel->y_res - win->out_y;
+       if (!win->width || !win->height || !win->out_width || !win->out_height)
                return 0;
 
        return fbdev->ctrl->update_window(fbi, win, callback, callback_data);
@@ -679,6 +760,10 @@ static int omapfb_update_full_screen(struct fb_info *fbi)
        win.y = 0;
        win.width = fbi->var.xres;
        win.height = fbi->var.yres;
+       win.out_x = 0;
+       win.out_y = 0;
+       win.out_width = fbi->var.xres;
+       win.out_height = fbi->var.yres;
        win.format = 0;
 
        omapfb_rqueue_lock(fbdev);
@@ -693,17 +778,39 @@ static int omapfb_setup_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
        struct omapfb_plane_struct *plane = fbi->par;
        struct omapfb_device *fbdev = plane->fbdev;
        struct lcd_panel *panel = fbdev->panel;
-       int r;
+       struct omapfb_plane_info old_info;
+       int r = 0;
 
        if (pi->pos_x + pi->out_width > panel->x_res ||
            pi->pos_y + pi->out_height > panel->y_res)
                return -EINVAL;
 
+       omapfb_rqueue_lock(fbdev);
+       if (pi->enabled && !fbdev->mem_desc.region[plane->idx].size) {
+               /*
+                * This plane's memory was freed, can't enable it
+                * until it's reallocated.
+                */
+               r = -EINVAL;
+               goto out;
+       }
+       old_info = plane->info;
        plane->info = *pi;
-       r = ctrl_change_mode(fbi);
-       if (r < 0)
-               return r;
-       return fbdev->ctrl->enable_plane(plane->idx, pi->enabled);
+       if (pi->enabled) {
+               r = ctrl_change_mode(fbi);
+               if (r < 0) {
+                       plane->info = old_info;
+                       goto out;
+               }
+       }
+       r = fbdev->ctrl->enable_plane(plane->idx, pi->enabled);
+       if (r < 0) {
+               plane->info = old_info;
+               goto out;
+       }
+out:
+       omapfb_rqueue_unlock(fbdev);
+       return r;
 }
 
 static int omapfb_query_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
@@ -714,6 +821,94 @@ static int omapfb_query_plane(struct fb_info *fbi, struct omapfb_plane_info *pi)
        return 0;
 }
 
+static int omapfb_setup_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
+{
+       struct omapfb_plane_struct *plane = fbi->par;
+       struct omapfb_device *fbdev = plane->fbdev;
+       struct omapfb_mem_region *rg = &fbdev->mem_desc.region[plane->idx];
+       size_t size;
+       int r = 0;
+
+       if (fbdev->ctrl->setup_mem == NULL)
+               return -ENODEV;
+       if (mi->type > OMAPFB_MEMTYPE_MAX)
+               return -EINVAL;
+
+       size = PAGE_ALIGN(mi->size);
+       omapfb_rqueue_lock(fbdev);
+       if (plane->info.enabled) {
+               r = -EBUSY;
+               goto out;
+       }
+       if (rg->size != size || rg->type != mi->type) {
+               struct fb_var_screeninfo *new_var = &fbdev->new_var;
+               unsigned long old_size = rg->size;
+               u8            old_type = rg->type;
+               unsigned long paddr;
+
+               rg->size = size;
+               rg->type = mi->type;
+               /*
+                * size == 0 is a special case, for which we
+                * don't check / adjust the screen parameters.
+                * This isn't a problem since the plane can't
+                * be reenabled unless its size is > 0.
+                */
+               if (old_size != size && size) {
+                       if (size) {
+                               memcpy(new_var, &fbi->var, sizeof(*new_var));
+                               r = set_fb_var(fbi, new_var);
+                               if (r < 0)
+                                       goto out;
+                       }
+               }
+
+               if (fbdev->ctrl->sync)
+                       fbdev->ctrl->sync();
+               r = fbdev->ctrl->setup_mem(plane->idx, size, mi->type, &paddr);
+               if (r < 0) {
+                       /* Revert changes. */
+                       rg->size = old_size;
+                       rg->type = old_type;
+                       goto out;
+               }
+               rg->paddr = paddr;
+
+               if (old_size != size) {
+                       if (size) {
+                               memcpy(&fbi->var, new_var, sizeof(fbi->var));
+                               set_fb_fix(fbi);
+                       } else {
+                               /*
+                                * Set these explicitly to indicate that the
+                                * plane memory is dealloce'd, the other
+                                * screen parameters in var / fix are invalid.
+                                */
+                               fbi->fix.smem_start = 0;
+                               fbi->fix.smem_len = 0;
+                       }
+               }
+       }
+out:
+       omapfb_rqueue_unlock(fbdev);
+
+       return r;
+}
+
+static int omapfb_query_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
+{
+       struct omapfb_plane_struct *plane = fbi->par;
+       struct omapfb_device *fbdev = plane->fbdev;
+       struct omapfb_mem_region *rg;
+
+       rg = &fbdev->mem_desc.region[plane->idx];
+       memset(mi, 0, sizeof(*mi));
+       mi->size = rg->size;
+       mi->type = rg->type;
+
+       return 0;
+}
+
 static int omapfb_set_color_key(struct omapfb_device *fbdev,
                                struct omapfb_color_key *ck)
 {
@@ -830,14 +1025,12 @@ static enum omapfb_update_mode omapfb_get_update_mode(struct omapfb_device *fbde
        return r;
 }
 
-static unsigned long omapfb_get_caps(struct omapfb_device *fbdev)
+static void omapfb_get_caps(struct omapfb_device *fbdev, int plane,
+                                    struct omapfb_caps *caps)
 {
-       unsigned long caps;
-
-       caps = 0;
-       caps |= fbdev->panel->get_caps(fbdev->panel);
-       caps |= fbdev->ctrl->get_caps();
-       return caps;
+       memset(caps, 0, sizeof(*caps));
+       fbdev->ctrl->get_caps(plane, caps);
+       caps->ctrl |= fbdev->panel->get_caps(fbdev->panel);
 }
 
 /* For lcd testing */
@@ -848,18 +1041,19 @@ void omapfb_write_first_pixel(struct omapfb_device *fbdev, u16 pixval)
        if (fbdev->ctrl->get_update_mode() == OMAPFB_MANUAL_UPDATE) {
                struct omapfb_update_window win;
 
-               win.x = 0;
-               win.y = 0;
-               win.width = 1;
-               win.height = 1;
-               win.format = 0;
+               memset(&win, 0, sizeof(win));
+               win.width = 2;
+               win.height = 2;
+               win.out_width = 2;
+               win.out_height = 2;
                fbdev->ctrl->update_window(fbdev->fb_info[0], &win, NULL, 0);
        }
        omapfb_rqueue_unlock(fbdev);
 }
 EXPORT_SYMBOL(omapfb_write_first_pixel);
 
-/* Ioctl interface. Part of the kernel mode frame buffer API is duplicated
+/*
+ * Ioctl interface. Part of the kernel mode frame buffer API is duplicated
  * here to be accessible by user mode code.
  */
 static int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd,
@@ -871,9 +1065,10 @@ static int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd,
        union {
                struct omapfb_update_window     update_window;
                struct omapfb_plane_info        plane_info;
+               struct omapfb_mem_info          mem_info;
                struct omapfb_color_key         color_key;
                enum omapfb_update_mode         update_mode;
-               unsigned long           caps;
+               struct omapfb_caps              caps;
                unsigned int            mirror;
                int                     plane_out;
                int                     enable_plane;
@@ -911,8 +1106,13 @@ static int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd,
                                   sizeof(struct omapfb_update_window_old)))
                        r = -EFAULT;
                else {
-                       p.update_window.format = 0;
-                       r = omapfb_update_win(fbi, &p.update_window);
+                       struct omapfb_update_window *u = &p.update_window;
+                       u->out_x = u->x;
+                       u->out_y = u->y;
+                       u->out_width = u->width;
+                       u->out_height = u->height;
+                       memset(u->reserved, 0, sizeof(u->reserved));
+                       r = omapfb_update_win(fbi, u);
                }
                break;
        case OMAPFB_UPDATE_WINDOW:
@@ -936,6 +1136,20 @@ static int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd,
                                   sizeof(p.plane_info)))
                        r = -EFAULT;
                break;
+       case OMAPFB_SETUP_MEM:
+               if (copy_from_user(&p.mem_info, (void __user *)arg,
+                                  sizeof(p.mem_info)))
+                       r = -EFAULT;
+               else
+                       r = omapfb_setup_mem(fbi, &p.mem_info);
+               break;
+       case OMAPFB_QUERY_MEM:
+               if ((r = omapfb_query_mem(fbi, &p.mem_info)) < 0)
+                       break;
+               if (copy_to_user((void __user *)arg, &p.mem_info,
+                                  sizeof(p.mem_info)))
+                       r = -EFAULT;
+               break;
        case OMAPFB_SET_COLOR_KEY:
                if (copy_from_user(&p.color_key, (void __user *)arg,
                                   sizeof(p.color_key)))
@@ -950,6 +1164,11 @@ static int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd,
                                 sizeof(p.color_key)))
                        r = -EFAULT;
                break;
+       case OMAPFB_GET_CAPS:
+               omapfb_get_caps(fbdev, plane->idx, &p.caps);
+               if (copy_to_user((void __user *)arg, &p.caps, sizeof(p.caps)))
+                       r = -EFAULT;
+               break;
        case OMAPFB_LCD_TEST:
                {
                        int test_num;
@@ -987,7 +1206,21 @@ static int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd,
        return r;
 }
 
-/* Callback table for the frame buffer framework. Some of these pointers
+static int omapfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
+{
+       struct omapfb_plane_struct *plane = info->par;
+       struct omapfb_device *fbdev = plane->fbdev;
+       int r;
+
+       omapfb_rqueue_lock(fbdev);
+       r = fbdev->ctrl->mmap(info, vma);
+       omapfb_rqueue_unlock(fbdev);
+
+       return r;
+}
+
+/*
+ * Callback table for the frame buffer framework. Some of these pointers
  * will be changed according to the current setting of fb_info->accel_flags.
  */
 static struct fb_ops omapfb_ops = {
@@ -1013,28 +1246,67 @@ static struct fb_ops omapfb_ops = {
  * ---------------------------------------------------------------------------
  */
 /* omapfbX sysfs entries */
-static ssize_t omapfb_show_caps_num(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t omapfb_show_caps_num(struct device *dev,
+                                   struct device_attribute *attr, char *buf)
 {
        struct omapfb_device *fbdev = (struct omapfb_device *)dev->driver_data;
-
-       return snprintf(buf, PAGE_SIZE, "%#010lx\n", omapfb_get_caps(fbdev));
+       int plane;
+       size_t size;
+       struct omapfb_caps caps;
+
+       plane = 0;
+       size = 0;
+       while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) {
+               omapfb_get_caps(fbdev, plane, &caps);
+               size += snprintf(&buf[size], PAGE_SIZE - size,
+                       "plane#%d %#010x %#010x %#010x\n",
+                       plane, caps.ctrl, caps.plane_color, caps.wnd_color);
+               plane++;
+       }
+       return size;
 }
 
-static ssize_t omapfb_show_caps_text(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t omapfb_show_caps_text(struct device *dev,
+                                    struct device_attribute *attr, char *buf)
 {
        struct omapfb_device *fbdev = (struct omapfb_device *)dev->driver_data;
-       int pos = 0;
        int i;
-       unsigned long caps;
-
-       caps = omapfb_get_caps(fbdev);
-       for (i = 0; i < ARRAY_SIZE(omapfb_caps_table) && pos < PAGE_SIZE; i++) {
-               if (omapfb_caps_table[i].flag & caps) {
-                       pos += snprintf(&buf[pos], PAGE_SIZE - pos, "%s\n",
-                                       omapfb_caps_table[i].name);
+       struct omapfb_caps caps;
+       int plane;
+       size_t size;
+
+       plane = 0;
+       size = 0;
+       while (size < PAGE_SIZE && plane < OMAPFB_PLANE_NUM) {
+               omapfb_get_caps(fbdev, plane, &caps);
+               size += snprintf(&buf[size], PAGE_SIZE - size,
+                                "plane#%d:\n", plane);
+               for (i = 0; i < ARRAY_SIZE(ctrl_caps) &&
+                    size < PAGE_SIZE; i++) {
+                       if (ctrl_caps[i].flag & caps.ctrl)
+                               size += snprintf(&buf[size], PAGE_SIZE - size,
+                                       " %s\n", ctrl_caps[i].name);
+               }
+               size += snprintf(&buf[size], PAGE_SIZE - size,
+                                " plane colors:\n");
+               for (i = 0; i < ARRAY_SIZE(color_caps) &&
+                    size < PAGE_SIZE; i++) {
+                       if (color_caps[i].flag & caps.plane_color)
+                               size += snprintf(&buf[size], PAGE_SIZE - size,
+                                       "  %s\n", color_caps[i].name);
                }
+               size += snprintf(&buf[size], PAGE_SIZE - size,
+                                " window colors:\n");
+               for (i = 0; i < ARRAY_SIZE(color_caps) &&
+                    size < PAGE_SIZE; i++) {
+                       if (color_caps[i].flag & caps.wnd_color)
+                               size += snprintf(&buf[size], PAGE_SIZE - size,
+                                       "  %s\n", color_caps[i].name);
+               }
+
+               plane++;
        }
-       return min((int)PAGE_SIZE, pos);
+       return size;
 }
 
 static DEVICE_ATTR(caps_num, 0444, omapfb_show_caps_num, NULL);
@@ -1181,8 +1453,7 @@ static void omapfb_unregister_sysfs(struct omapfb_device *fbdev)
 /* Initialize system fb_info object and set the default video mode.
  * The frame buffer memory already allocated by lcddma_init
  */
-static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info,
-                       struct omapfb_mem_region *region)
+static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info)
 {
        struct fb_var_screeninfo        *var = &info->var;
        struct fb_fix_screeninfo        *fix = &info->fix;
@@ -1193,10 +1464,6 @@ static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info,
 
        strncpy(fix->id, MODULE_NAME, sizeof(fix->id));
 
-       info->screen_base       = (char __iomem *)region->vaddr;
-       fix->smem_start         = region->paddr;
-       fix->smem_len           = region->size;
-
        info->pseudo_palette = fbdev->pseudo_palette;
 
        var->accel_flags  = def_accel ? FB_ACCELF_TEXT : 0;
@@ -1257,8 +1524,7 @@ static int planes_init(struct omapfb_device *fbdev)
                plane->info.mirror = def_mirror;
                fbdev->fb_info[i] = fbi;
 
-               if ((r = fbinfo_init(fbdev, fbi,
-                                       &fbdev->mem_desc.region[i])) < 0) {
+               if ((r = fbinfo_init(fbdev, fbi)) < 0) {
                        framebuffer_release(fbi);
                        planes_cleanup(fbdev);
                        return r;
@@ -1269,7 +1535,8 @@ static int planes_init(struct omapfb_device *fbdev)
        return 0;
 }
 
-/* Free driver resources. Can be called to rollback an aborted initialization
+/*
+ * Free driver resources. Can be called to rollback an aborted initialization
  * sequence.
  */
 static void omapfb_free_resources(struct omapfb_device *fbdev, int state)
@@ -1350,7 +1617,8 @@ static void check_required_callbacks(struct omapfb_device *fbdev)
 #undef _C
 }
 
-/* Called by LDM binding to probe and attach a new device.
+/*
+ * Called by LDM binding to probe and attach a new device.
  * Initialization sequence:
  *   1. allocate system omapfb_device structure
  *   2. select controller type according to platform configuration
@@ -1432,6 +1700,8 @@ static int omapfb_do_probe(struct platform_device *pdev, struct lcd_panel *panel
        r = ctrl_init(fbdev);
        if (r)
                goto cleanup;
+       if (fbdev->ctrl->mmap != NULL)
+               omapfb_ops.fb_mmap = omapfb_mmap;
        init_state++;
 
        check_required_callbacks(fbdev);