Just backing up progress (again)
authorThomas White <taw@bitwiz.org.uk>
Mon, 15 Jun 2009 00:21:30 +0000 (01:21 +0100)
committerThomas White <taw@bitwiz.org.uk>
Mon, 15 Jun 2009 00:21:30 +0000 (01:21 +0100)
Nearly there...

Signed-off-by: Thomas White <taw@bitwiz.org.uk>
drivers/mfd/glamo/Kconfig
drivers/mfd/glamo/Makefile
drivers/mfd/glamo/glamo-core.c
drivers/mfd/glamo/glamo-display.c
drivers/mfd/glamo/glamo-display.h
drivers/mfd/glamo/glamo-drm-drv.c
drivers/mfd/glamo/glamo-drm-private.h
drivers/mfd/glamo/glamo-kms-fb.c [new file with mode: 0644]
drivers/mfd/glamo/glamo-kms-fb.h [new file with mode: 0644]

index 30932b0..3b942ab 100644 (file)
@@ -61,6 +61,9 @@ config MFD_GLAMO_MCI
 config MFD_GLAMO_DRM
        tristate "Glamo direct rendering and kernel modesetting support"
        depends on MFD_GLAMO && DRM
+       select FB_CFB_FILLRECT
+       select FB_CFB_COPYAREA
+       select FB_CFB_IMAGEBLIT
        help
          Direct Rendering Manager interface for the S-Media Glamo chip, as
          used in Openmoko FreeRunner (GTA02).
index 7d3f7d6..155427c 100644 (file)
@@ -12,4 +12,5 @@ obj-$(CONFIG_MFD_GLAMO_SPI_FB)                += glamo-lcm-spi.o
 obj-$(CONFIG_MFD_GLAMO_MCI)            += glamo-mci.o
 obj-$(CONFIG_MFD_GLAMO_DRM)            += glamo-drm.o
 
-glamo-drm-objs :=  glamo-drm-drv.o glamo-cmdq.o glamo-buffer.o glamo-display.o
+glamo-drm-objs :=  glamo-drm-drv.o glamo-cmdq.o glamo-buffer.o \
+                    glamo-display.o glamo-kms-fb.o
index 075b9a0..9e690b5 100644 (file)
@@ -175,7 +175,7 @@ static inline void glamo_vmem_read(struct glamo_core *glamo, u_int16_t *buf,
 /***********************************************************************
  * resources of sibling devices
  ***********************************************************************/
-static struct resource glamo_cmdq_resources[] = {
+static struct resource glamo_graphics_resources[] = {
        {
                .name   = "glamo-cmdq-regs",
                .start  = GLAMO_REGOFS_CMDQUEUE,
@@ -193,22 +193,7 @@ static struct resource glamo_cmdq_resources[] = {
                .end    = GLAMO_MEM_BASE + GLAMO_OFFSET_FB +
                          GLAMO_FB_SIZE - 1,
                .flags  = IORESOURCE_MEM,
-       },
-};
-
-static struct platform_device glamo_cmdq_dev = {
-       .name           = "glamo-cmdq",
-       .resource       = glamo_cmdq_resources,
-       .num_resources  = ARRAY_SIZE(glamo_cmdq_resources),
-};
-
-static struct platform_device glamo_spigpio_dev = {
-       .name           = "glamo-spi-gpio",
-};
-
-static struct resource glamo_fb_resources[] = {
-       /* FIXME: those need to be incremented by parent base */
-       {
+       }, {
                .name   = "glamo-fb-regs",
                .start  = GLAMO_REGOFS_LCD,
                .end    = GLAMO_REGOFS_MMC - 1,
@@ -216,12 +201,17 @@ static struct resource glamo_fb_resources[] = {
        }
 };
 
-static struct platform_device glamo_fb_dev = {
-       .name           = "glamo-fb",
-       .resource       = glamo_fb_resources,
-       .num_resources  = ARRAY_SIZE(glamo_fb_resources),
+static struct platform_device glamo_graphics_dev = {
+       .name           = "glamo-graphics",
+       .resource       = glamo_graphics_resources,
+       .num_resources  = ARRAY_SIZE(glamo_graphics_resources),
+};
+
+static struct platform_device glamo_spigpio_dev = {
+       .name           = "glamo-spi-gpio",
 };
 
+
 static struct resource glamo_mmc_resources[] = {
        {
                /* FIXME: those need to be incremented by parent base */
@@ -1253,18 +1243,11 @@ static int __init glamo_probe(struct platform_device *pdev)
        glamo->pdata->glamo = glamo;
 
        /* Command queue device (for DRM) */
-       glamo_cmdq_dev.dev.parent = &pdev->dev;
-       glamo_cmdq_dev.dev.platform_data = glamo;
-       mangle_mem_resources(glamo_cmdq_dev.resource,
-                            glamo_cmdq_dev.num_resources, glamo->mem);
-       platform_device_register(&glamo_cmdq_dev);
-
-       /* Frambuffer device */
-       glamo_fb_dev.dev.parent = &pdev->dev;
-       glamo_fb_dev.dev.platform_data = glamo->pdata;
-       mangle_mem_resources(glamo_fb_dev.resource,
-                            glamo_fb_dev.num_resources, glamo->mem);
-       platform_device_register(&glamo_fb_dev);
+       glamo_graphics_dev.dev.parent = &pdev->dev;
+       glamo_graphics_dev.dev.platform_data = glamo;
+       mangle_mem_resources(glamo_graphics_dev.resource,
+                            glamo_graphics_dev.num_resources, glamo->mem);
+       platform_device_register(&glamo_graphics_dev);
 
        /* GPIO */
        glamo->pdata->spigpio_info->glamo = glamo;
@@ -1325,8 +1308,10 @@ static int glamo_remove(struct platform_device *pdev)
        }
 
        platform_set_drvdata(pdev, NULL);
-       platform_device_unregister(&glamo_fb_dev);
        platform_device_unregister(glamo->pdata->mmc_dev);
+       /* FIXME: Don't we need to unregister these as well?
+        * platform_device_unregister(glamo->pdata->graphics_dev);
+        * platform_device_unregister(glamo->pdata->gpio_dev); */
        iounmap(glamo->base);
        release_mem_region(glamo->mem->start, GLAMO_REGOFS_VIDCAP);
        glamo_handle = NULL;
index afa4c11..1ced367 100644 (file)
@@ -52,6 +52,7 @@
  *
  */
 
+#define DEBUG 1
 
 #include <drm/drmP.h>
 #include <drm/glamo_drm.h>
 #include "glamo-core.h"
 #include "glamo-drm-private.h"
 #include "glamo-regs.h"
+#include "glamo-kms-fb.h"
 
 
+struct glamofb_par {
+       struct drm_device *dev;
+       struct drm_display_mode *our_mode;
+       struct glamo_framebuffer *glamo_fb;
+       int crtc_count;
+       /* crtc currently bound to this */
+       uint32_t crtc_ids[2];
+};
+
+
+#if 0
+static int reg_read(struct glamodrm_handle *gdrm, u_int16_t reg)
+{
+       int i = 0;
+
+       for (i = 0; i != 2; i++)
+               nop();
+
+       return ioread16(gdrm->lcd_base + reg);
+}
+#endif
+
+
+static void reg_write(struct glamodrm_handle *gdrm,
+                      u_int16_t reg, u_int16_t val)
+{
+       int i = 0;
+
+       for (i = 0; i != 2; i++)
+               nop();
+
+       iowrite16(val, gdrm->lcd_base + reg);
+}
+
+
+static struct glamo_script lcd_init_script[] = {
+       { GLAMO_REG_LCD_MODE1, 0x0020 },
+       /* no display rotation, no hardware cursor, no dither, no gamma,
+        * no retrace flip, vsync low-active, hsync low active,
+        * no TVCLK, no partial display, hw dest color from fb,
+        * no partial display mode, LCD1, software flip,  */
+       { GLAMO_REG_LCD_MODE2, 0x9020 },
+         /* video flip, no ptr, no ptr, dhclk off,
+          * normal mode,  no cpuif,
+          * res, serial msb first, single fb, no fr ctrl,
+          * cpu if bits all zero, no crc
+          * 0000 0000 0010  0000 */
+       { GLAMO_REG_LCD_MODE3, 0x0b40 },
+         /* src data rgb565, res, 18bit rgb666
+          * 000 01 011 0100 0000 */
+       { GLAMO_REG_LCD_POLARITY, 0x440c },
+         /* DE high active, no cpu/lcd if, cs0 force low, a0 low active,
+          * np cpu if, 9bit serial data, sclk rising edge latch data
+          * 01 00 0 100 0 000 01 0 0 */
+       /* The following values assume 640*480@16bpp */
+       { GLAMO_REG_LCD_A_BASE1, 0x0000 }, /* display A base address 15:0 */
+       { GLAMO_REG_LCD_A_BASE2, 0x0000 }, /* display A base address 22:16 */
+       { GLAMO_REG_LCD_B_BASE1, 0x6000 }, /* display B base address 15:0 */
+       { GLAMO_REG_LCD_B_BASE2, 0x0009 }, /* display B base address 22:16 */
+       { GLAMO_REG_LCD_CURSOR_BASE1, 0xC000 }, /* cursor base address 15:0 */
+       { GLAMO_REG_LCD_CURSOR_BASE2, 0x0012 }, /* cursor base address 22:16 */
+       { GLAMO_REG_LCD_COMMAND2, 0x0000 }, /* display page A */
+};
+
+
+static int glamo_run_lcd_script(struct glamodrm_handle *gdrm,
+                                struct glamo_script *script, int len)
+{
+       int i;
+
+       for (i = 0; i < len; i++) {
+               struct glamo_script *line = &script[i];
+
+               if (line->reg == 0xffff)
+                       return 0;
+               else if (line->reg == 0xfffe)
+                       msleep(line->val);
+               else
+                       reg_write(gdrm, script[i].reg, script[i].val);
+       }
+
+       return 0;
+}
+
+
+#if 0
 static void notify_blank(struct drm_crtc *crtc, int mode)
 {
        struct fb_event event;
@@ -71,37 +159,42 @@ static void notify_blank(struct drm_crtc *crtc, int mode)
        event.data = &blank_mode;
        fb_notifier_call_chain(FB_EVENT_CONBLANK, &event);
 }
+#endif
 
 
 /* Power on/off */
 static void glamo_crtc_dpms(struct drm_crtc *crtc, int mode)
 {
-       dev_dbg(gfb->dev, "glamofb_blank(%u)\n", blank_mode);
-
+       struct glamodrm_handle *gdrm;
+       struct glamo_crtc *glamo_crtc = to_glamo_crtc(crtc);
+       
+       printk(KERN_CRIT "glamo_crtc_dpms(%u)\n", mode);
+       gdrm = glamo_crtc->gdrm;
+       
        switch (mode) {
        case DRM_MODE_DPMS_OFF:
                /* Simulating FB_BLANK_NORMAL allow turning off backlight */
-               if (gfb->blank_mode != FB_BLANK_NORMAL)
-                       notify_blank(info, FB_BLANK_NORMAL);
+               //if (gfb->blank_mode != FB_BLANK_NORMAL)
+               //      notify_blank(info, FB_BLANK_NORMAL);
 
                /* LCM need notification before pixel clock is stopped */
-               notify_blank(crtc, blank_mode);
+               //notify_blank(crtc, blank_mode);
 
                /* disable the pixel clock */
-               glamo_engine_clkreg_set(gcore, GLAMO_ENGINE_LCD,
+               glamo_engine_clkreg_set(gdrm->glamo_core, GLAMO_ENGINE_LCD,
                                        GLAMO_CLOCK_LCD_EN_DCLK, 0);
-               gfb->blank_mode = blank_mode;
+               glamo_crtc->blank_mode = mode;
                break;
        case DRM_MODE_DPMS_ON:
                /* enable the pixel clock if off */
-               if (gfb->blank_mode == DRM_MODE_DPMS_OFF)
-                       glamo_engine_clkreg_set(gcore,
+               if (glamo_crtc->blank_mode == DRM_MODE_DPMS_OFF)
+                       glamo_engine_clkreg_set(gdrm->glamo_core,
                                        GLAMO_ENGINE_LCD,
                                        GLAMO_CLOCK_LCD_EN_DCLK,
                                        GLAMO_CLOCK_LCD_EN_DCLK);
 
-               notify_blank(info, blank_mode);
-               gfb->blank_mode = blank_mode;
+               //notify_blank(info, blank_mode);
+               glamo_crtc->blank_mode = mode;
                break;
        }
 
@@ -112,6 +205,7 @@ static bool glamo_crtc_mode_fixup(struct drm_crtc *crtc,
                                   struct drm_display_mode *mode,
                                   struct drm_display_mode *adjusted_mode)
 {
+       printk(KERN_CRIT "glamo_crtc_mode_fixup\n");
        return true;
 }
 
@@ -122,6 +216,7 @@ static void glamo_crtc_mode_set(struct drm_crtc *crtc,
                                 int x, int y,
                                 struct drm_framebuffer *old_fb)
 {
+       printk(KERN_CRIT "glamo_crtc_mode_set\n");
 }
 
 
@@ -129,12 +224,14 @@ static void glamo_crtc_mode_set(struct drm_crtc *crtc,
 static void glamo_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
                                      struct drm_framebuffer *old_fb)
 {
+       printk(KERN_CRIT "glamo_crtc_mode_set\n");
 }
 
 
 static void glamo_crtc_prepare(struct drm_crtc *crtc)
 {
        struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+       printk(KERN_CRIT "glamo_crtc_prepare\n");
        crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
 }
 
@@ -142,6 +239,7 @@ static void glamo_crtc_prepare(struct drm_crtc *crtc)
 static void glamo_crtc_commit(struct drm_crtc *crtc)
 {
        struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+       printk(KERN_CRIT "glamo_crtc_commit\n");
        crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
 }
 
@@ -151,12 +249,14 @@ static int glamo_crtc_cursor_set(struct drm_crtc *crtc,
                                  uint32_t handle,
                                  uint32_t width, uint32_t height)
 {
+       printk(KERN_CRIT "glamo_crtc_cursor_set\n");
        return 0;
 }
 
 
 static int glamo_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 {
+       printk(KERN_CRIT "glamo_crtc_cursor_move\n");
        return 0;
 }
 
@@ -164,13 +264,14 @@ static int glamo_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 static void glamo_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
                                  u16 *blue, uint32_t size)
 {
+       printk(KERN_CRIT "glamo_crtc_gamma_set\n");
 }
 
 
 static void glamo_crtc_destroy(struct drm_crtc *crtc)
 {
        struct glamo_crtc *glamo_crtc = to_glamo_crtc(crtc);
-
+       printk(KERN_CRIT "glamo_crtc_destroy\n");
        drm_crtc_cleanup(crtc);
        kfree(glamo_crtc);
 }
@@ -180,12 +281,14 @@ static enum drm_connector_status
 glamo_connector_detect(struct drm_connector *connector)
 {
        /* One hopes it hasn't been de-soldered... */
+       printk(KERN_CRIT "glamo_connector_detect\n");
        return connector_status_connected;
 }
 
 
 static void glamo_connector_destroy(struct drm_connector *connector)
 {
+       printk(KERN_CRIT "glamo_connector_destroy\n");
        drm_sysfs_connector_remove(connector);
        drm_connector_cleanup(connector);
        kfree(connector);
@@ -194,6 +297,7 @@ static void glamo_connector_destroy(struct drm_connector *connector)
 
 static int glamo_connector_get_modes(struct drm_connector *connector)
 {
+       printk(KERN_CRIT "glamo_connector_get_modes\n");
        return false;
 }
 
@@ -202,6 +306,7 @@ static int glamo_connector_set_property(struct drm_connector *connector,
                                  struct drm_property *property,
                                  uint64_t value)
 {
+       printk(KERN_CRIT "glamo_connector_set_property\n");
        return 0;
 }
 
@@ -209,6 +314,7 @@ static int glamo_connector_set_property(struct drm_connector *connector,
 static int glamo_connector_mode_valid(struct drm_connector *connector,
                                       struct drm_display_mode *mode)
 {
+       printk(KERN_CRIT "glamo_connector_mode_valid\n");
        if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
                return MODE_NO_DBLESCAN;
 
@@ -223,13 +329,14 @@ struct drm_encoder *
 glamo_connector_best_encoder(struct drm_connector *connector)
 {
        struct glamo_output *glamo_output = to_glamo_output(connector);
-
+       printk(KERN_CRIT "glamo_connector_best_encoder\n");     
        return &glamo_output->enc;
 }
 
 
 static void glamo_encoder_dpms(struct drm_encoder *encoder, int mode)
 {
+       printk(KERN_CRIT "glamo_encoder_dpms\n");
 }
 
 
@@ -237,17 +344,20 @@ static bool glamo_encoder_mode_fixup(struct drm_encoder *encoder,
                                  struct drm_display_mode *mode,
                                  struct drm_display_mode *adjusted_mode)
 {
+       printk(KERN_CRIT "glamo_encoder_mode_fixup\n");
        return true;
 }
 
 
 void glamo_encoder_prepare(struct drm_encoder *encoder)
 {
+       printk(KERN_CRIT "glamo_encoder_prepare\n");
 }
 
 
 void glamo_encoder_commit(struct drm_encoder *encoder)
 {
+       printk(KERN_CRIT "glamo_encoder_commit\n");
 }
 
 
@@ -255,19 +365,22 @@ static void glamo_encoder_mode_set(struct drm_encoder *encoder,
                                struct drm_display_mode *mode,
                                struct drm_display_mode *adjusted_mode)
 {
+       printk(KERN_CRIT "glamo_encoder_mode_set\n");
 }
 
 
 static void glamo_encoder_destroy(struct drm_encoder *encoder)
 {
+       printk(KERN_CRIT "glamo_encoder_destroy\n");
        drm_encoder_cleanup(encoder);
 }
 
 
-static void glamo_user_framebuffer_destroy(struct drm_framebuffer *fb)
+static void glamo_framebuffer_destroy(struct drm_framebuffer *fb)
 {
        struct glamo_framebuffer *glamo_fb = to_glamo_framebuffer(fb);
        struct drm_device *dev = fb->dev;
+       printk(KERN_CRIT "glamo_user_framebuffer_destroy\n");
 
        drm_framebuffer_cleanup(fb);
        mutex_lock(&dev->struct_mutex);
@@ -277,12 +390,13 @@ static void glamo_user_framebuffer_destroy(struct drm_framebuffer *fb)
        kfree(glamo_fb);
 }
 
-static int glamo_user_framebuffer_create_handle(struct drm_framebuffer *fb,
+static int glamo_framebuffer_create_handle(struct drm_framebuffer *fb,
                                                struct drm_file *file_priv,
                                                unsigned int *handle)
 {
        struct glamo_framebuffer *glamo_fb = to_glamo_framebuffer(fb);
        struct drm_gem_object *object = glamo_fb->obj;
+       printk(KERN_CRIT "glamo_user_framebuffer_create_handle\n");
 
        return drm_gem_handle_create(file_priv, object, handle);
 }
@@ -290,8 +404,8 @@ static int glamo_user_framebuffer_create_handle(struct drm_framebuffer *fb,
 
 
 static const struct drm_framebuffer_funcs glamo_fb_funcs = {
-       .destroy = glamo_user_framebuffer_destroy,
-       .create_handle = glamo_user_framebuffer_create_handle,
+       .destroy = glamo_framebuffer_destroy,
+       .create_handle = glamo_framebuffer_create_handle,
 };
 
 
@@ -303,6 +417,7 @@ int glamo_framebuffer_create(struct drm_device *dev,
        struct glamo_framebuffer *glamo_fb;
        int ret;
 
+       printk(KERN_CRIT "glamo_framebuffer_create\n");
        glamo_fb = kzalloc(sizeof(*glamo_fb), GFP_KERNEL);
        if (!glamo_fb)
                return -ENOMEM;
@@ -331,6 +446,7 @@ glamo_user_framebuffer_create(struct drm_device *dev,
        struct drm_gem_object *obj;
        struct drm_framebuffer *fb;
        int ret;
+       printk(KERN_CRIT "glamo_user_framebuffer_create\n");
 
        obj = drm_gem_object_lookup(dev, filp, mode_cmd->handle);
        if (!obj)
@@ -346,8 +462,9 @@ glamo_user_framebuffer_create(struct drm_device *dev,
 }
 
 
-int glamo_fb_changed(struct drm_device *dev)
+int glamo_fbchanged(struct drm_device *dev)
 {
+       printk(KERN_CRIT "glamo_fb_changed\n");
        return 0;
 }
 
@@ -410,7 +527,7 @@ static const struct drm_encoder_helper_funcs glamo_encoder_helper_funcs = {
 /* Mode functions */
 static const struct drm_mode_config_funcs glamo_mode_funcs = {
        .fb_create = glamo_user_framebuffer_create,
-       .fb_changed = glamofb_fbchanged
+       .fb_changed = glamo_fbchanged
 };
 
 
@@ -420,9 +537,12 @@ int glamo_display_init(struct drm_device *dev)
        struct glamo_crtc *glamo_crtc;
        struct glamo_output *glamo_output;
        struct drm_connector *connector;
+       struct glamo_framebuffer *glamo_fb;
 
        gdrm = dev->dev_private;
 
+       printk(KERN_CRIT "glamo_display_init\n");
+
        drm_mode_config_init(dev);
 
        dev->mode_config.min_width = 0;
@@ -434,6 +554,8 @@ int glamo_display_init(struct drm_device *dev)
        glamo_crtc = kzalloc(sizeof(struct glamo_crtc)
                           + sizeof(struct drm_connector *), GFP_KERNEL);
        if (glamo_crtc == NULL) return 1;
+       glamo_crtc->gdrm = gdrm;
+       glamo_crtc->blank_mode = DRM_MODE_DPMS_OFF;
        drm_crtc_init(dev, &glamo_crtc->base, &glamo_crtc_funcs);
        drm_crtc_helper_add(&glamo_crtc->base, &glamo_crtc_helper_funcs);
 
@@ -457,6 +579,17 @@ int glamo_display_init(struct drm_device *dev)
 
        drm_encoder_helper_add(&glamo_output->enc, &glamo_encoder_helper_funcs);
        drm_connector_helper_add(connector, &glamo_connector_helper_funcs);
-
+       
+       /* Initial setup of the LCD controller */
+       glamo_run_lcd_script(gdrm, lcd_init_script,
+                                  ARRAY_SIZE(lcd_init_script));
+
+       if (list_empty(&dev->mode_config.fb_kernel_list)) {
+               int ret;
+               printk(KERN_CRIT "creating new fb (console size %dx%d, "
+                                "buffer size %dx%d)\n", 480, 640, 480, 640);
+               ret = glamofb_create(dev, 480, 640, 480, 640, &glamo_fb);
+               if (ret) return -EINVAL;
+       }
        return 0;
 }
index 6d8d43c..c8f526d 100644 (file)
@@ -1,4 +1,4 @@
-/* Smedia Glamo 336x/337x display
+/* Smedia Glamo 336x/337x Display
  *
  * Copyright (c) 2008-2009 Thomas White <taw@bitwiz.org.uk>
  *
@@ -27,4 +27,9 @@
 
 extern int glamo_display_init(struct drm_device *dev);
 
+extern int glamo_framebuffer_create(struct drm_device *dev,
+                                    struct drm_mode_fb_cmd *mode_cmd,
+                                    struct drm_framebuffer **fb,
+                                    struct drm_gem_object *obj);
+                            
 #endif /* __GLAMO_DISPLAY_H */
index a2303ce..dbcb8eb 100644 (file)
@@ -1,4 +1,4 @@
-/* Smedia Glamo 336x/337x driver
+/* Smedia Glamo 336x/337x Graphics Driver
  *
  * Copyright (C) 2009 Openmoko, Inc. Jorge Luis Zapata <turran@openmoko.com>
  * Copyright (C) 2008-2009 Thomas White <taw@bitwiz.org.uk>
@@ -36,7 +36,7 @@
 #define DRIVER_AUTHOR           "Openmoko, Inc."
 #define DRIVER_NAME             "glamo-drm"
 #define DRIVER_DESC             "SMedia Glamo 3362"
-#define DRIVER_DATE             "20090426"
+#define DRIVER_DATE             "20090614"
 
 #define RESSIZE(ressource) (((ressource)->end - (ressource)->start)+1)
 
@@ -130,7 +130,6 @@ static void glamodrm_master_destroy(struct drm_device *dev,
 static int glamodrm_load(struct drm_device *dev, unsigned long flags)
 {
        struct glamodrm_handle *gdrm;
-
        gdrm = dev->dev_private;
 
        glamo_buffer_init(gdrm);
@@ -200,7 +199,7 @@ static int glamodrm_probe(struct platform_device *pdev)
        int rc;
        struct glamodrm_handle *gdrm;
 
-       printk(KERN_INFO "[glamo-drm] SMedia Glamo Direct Rendering Support\n");
+       printk(KERN_CRIT "[glamo-drm] SMedia Glamo Direct Rendering Support\n");
 
        gdrm = kmalloc(sizeof(*gdrm), GFP_KERNEL);
        if ( !gdrm )
@@ -271,15 +270,41 @@ static int glamodrm_probe(struct platform_device *pdev)
                goto out_release_vram;
        }
 
+       /* Find the LCD controller */
+       gdrm->lcd_regs = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+       if ( !gdrm->lcd_regs ) {
+               dev_err(&pdev->dev, "Unable to find LCD registers.\n");
+               rc = -ENOENT;
+               goto out_unmap_cmdq;
+       }
+       gdrm->lcd_regs = request_mem_region(gdrm->lcd_regs->start,
+                                           RESSIZE(gdrm->lcd_regs),
+                                           pdev->name);
+       if ( !gdrm->lcd_regs ) {
+               dev_err(&pdev->dev, "failed to request VRAM region\n");
+               rc = -ENOENT;
+               goto out_release_lcd;
+       }
+       gdrm->lcd_base = ioremap(gdrm->lcd_regs->start, RESSIZE(gdrm->lcd_regs));
+       if ( !gdrm->lcd_base ) {
+               dev_err(&pdev->dev, "failed to ioremap() VRAM\n");
+               rc = -ENOENT;
+               goto out_release_lcd;
+       }
+
        gdrm->vram_size = GLAMO_FB_SIZE;
        printk(KERN_INFO "[glamo-drm] %lli bytes of VRAM\n",
-                                       (long long int)gdrm->vram_size);
+                        (long long int)gdrm->vram_size);
 
        /* Initialise DRM */
        drm_platform_init(&glamodrm_drm_driver, pdev, (void *)gdrm);
 
        return 0;
 
+out_release_lcd:
+       release_mem_region(gdrm->lcd_regs->start, RESSIZE(gdrm->lcd_regs));
+out_unmap_cmdq:
+       iounmap(gdrm->cmdq_base);
 out_release_cmdq:
        release_mem_region(gdrm->cmdq->start, RESSIZE(gdrm->cmdq));
 out_unmap_vram:
@@ -344,7 +369,7 @@ static struct platform_driver glamodrm_driver = {
        .suspend        = glamodrm_suspend,
        .resume         = glamodrm_resume,
        .driver         = {
-               .name   = "glamo-cmdq",
+               .name   = "glamo-graphics",
                .owner  = THIS_MODULE,
        },
 };
index 835b65b..ae65d10 100644 (file)
@@ -52,6 +52,10 @@ struct glamodrm_handle {
        struct resource *cmdq;
        char __iomem *cmdq_base;
 
+       /* LCD controller registers */
+       struct resource *lcd_regs;
+       char __iomem *lcd_base;
+
        ssize_t vram_size;
 
        /* Memory management */
@@ -68,6 +72,10 @@ struct drm_glamo_gem_object {
 
 struct glamo_crtc {
        struct drm_crtc base;
+       struct glamodrm_handle *gdrm;
+       /* a mode_set for fbdev users on this crtc */
+       struct drm_mode_set mode_set;
+       int blank_mode;
 };
 
 
diff --git a/drivers/mfd/glamo/glamo-kms-fb.c b/drivers/mfd/glamo/glamo-kms-fb.c
new file mode 100644 (file)
index 0000000..4a7c551
--- /dev/null
@@ -0,0 +1,561 @@
+/*
+ * SMedia Glamo 336x/337x KMS Framebuffer
+ *
+ * Copyright (C) 2009 Thomas White <taw@bitwiz.org.uk>
+ *
+ * Based on glamo-fb.c (C) 2007-2008 by Openmoko, Inc.
+ * Author: Harald Welte <laforge@openmoko.org>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Based on intel_fb.c from drivers/gpu/drm/i915
+ *  to which the following licence applies:
+ *
+ * Copyright © 2006-2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *     Eric Anholt <eric@anholt.net>
+ *
+ */
+
+
+#include <drm/drmP.h>
+#include <drm/glamo_drm.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_crtc.h>
+
+#include "glamo-core.h"
+#include "glamo-drm-private.h"
+#include "glamo-regs.h"
+#include "glamo-display.h"
+
+
+struct glamofb_par {
+       struct drm_device *dev;
+       struct drm_display_mode *our_mode;
+       struct glamo_framebuffer *glamo_fb;
+       int crtc_count;
+       /* crtc currently bound to this */
+       uint32_t crtc_ids[2];
+};
+
+
+static int reg_read(struct glamodrm_handle *gdrm, u_int16_t reg)
+{
+       int i = 0;
+
+       for (i = 0; i != 2; i++)
+               nop();
+
+       return ioread16(gdrm->lcd_base + reg);
+}
+
+
+static void reg_write(struct glamodrm_handle *gdrm,
+                      u_int16_t reg, u_int16_t val)
+{
+       int i = 0;
+
+       for (i = 0; i != 2; i++)
+               nop();
+
+       iowrite16(val, gdrm->lcd_base + reg);
+}
+
+
+
+static int glamofb_setcolreg(unsigned regno, unsigned red, unsigned green,
+                       unsigned blue, unsigned transp,
+                       struct fb_info *info)
+{
+       struct glamofb_par *par = info->par;
+       struct drm_device *dev = par->dev;
+       struct drm_crtc *crtc;
+       int i;
+
+       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+               struct glamo_crtc *glamo_crtc = to_glamo_crtc(crtc);
+               struct drm_mode_set *modeset = &glamo_crtc->mode_set;
+               struct drm_framebuffer *fb = modeset->fb;
+
+               for (i = 0; i < par->crtc_count; i++)
+                       if (crtc->base.id == par->crtc_ids[i])
+                               break;
+
+               if (i == par->crtc_count)
+                       continue;
+
+
+               if (regno > 255)
+                       return 1;
+
+               if (regno < 16) {
+                       switch (fb->depth) {
+                       case 15:
+                               fb->pseudo_palette[regno] = ((red & 0xf800) >> 1) |
+                                       ((green & 0xf800) >>  6) |
+                                       ((blue & 0xf800) >> 11);
+                               break;
+                       case 16:
+                               fb->pseudo_palette[regno] = (red & 0xf800) |
+                                       ((green & 0xfc00) >>  5) |
+                                       ((blue  & 0xf800) >> 11);
+                               break;
+                       case 24:
+                       case 32:
+                               fb->pseudo_palette[regno] = ((red & 0xff00) << 8) |
+                                       (green & 0xff00) |
+                                       ((blue  & 0xff00) >> 8);
+                               break;
+                       }
+               }
+       }
+       return 0;
+}
+
+static int glamofb_check_var(struct fb_var_screeninfo *var,
+                       struct fb_info *info)
+{
+       struct glamofb_par *par = info->par;
+       struct glamo_framebuffer *glamo_fb = par->glamo_fb;
+       struct drm_framebuffer *fb = &glamo_fb->base;
+       int depth;
+
+       if (var->pixclock == -1 || !var->pixclock)
+               return -EINVAL;
+
+       /* Need to resize the fb object !!! */
+       if (var->xres > fb->width || var->yres > fb->height) {
+               DRM_ERROR("Requested width/height is greater than current fb object %dx%d > %dx%d\n",var->xres,var->yres,fb->width,fb->height);
+               DRM_ERROR("Need resizing code.\n");
+               return -EINVAL;
+       }
+
+       switch (var->bits_per_pixel) {
+       case 16:
+               depth = (var->green.length == 6) ? 16 : 15;
+               break;
+       case 32:
+               depth = (var->transp.length > 0) ? 32 : 24;
+               break;
+       default:
+               depth = var->bits_per_pixel;
+               break;
+       }
+
+       switch (depth) {
+       case 16:
+               var->red.offset = 11;
+               var->green.offset = 5;
+               var->blue.offset = 0;
+               var->red.length = 5;
+               var->green.length = 6;
+               var->blue.length = 5;
+               var->transp.length = 0;
+               var->transp.offset = 0;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+/* this will let fbcon do the mode init */
+/* FIXME: take mode config lock? */
+static int glamofb_set_par(struct fb_info *info)
+{
+       struct glamofb_par *par = info->par;
+       struct drm_device *dev = par->dev;
+       struct fb_var_screeninfo *var = &info->var;
+       int i;
+
+       DRM_DEBUG("%d %d\n", var->xres, var->pixclock);
+
+       if (var->pixclock != -1) {
+
+               DRM_ERROR("PIXEL CLOCK SET\n");
+               return -EINVAL;
+       } else {
+               struct drm_crtc *crtc;
+               int ret;
+
+               list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+                       struct glamo_crtc *glamo_crtc = to_glamo_crtc(crtc);
+
+                       for (i = 0; i < par->crtc_count; i++)
+                               if (crtc->base.id == par->crtc_ids[i])
+                                       break;
+
+                       if (i == par->crtc_count)
+                               continue;
+
+                       if (crtc->fb == glamo_crtc->mode_set.fb) {
+                               mutex_lock(&dev->mode_config.mutex);
+                               ret = crtc->funcs->set_config(&glamo_crtc->mode_set);
+                               mutex_unlock(&dev->mode_config.mutex);
+                               if (ret)
+                                       return ret;
+                       }
+               }
+               return 0;
+       }
+}
+
+static int glamofb_pan_display(struct fb_var_screeninfo *var,
+                               struct fb_info *info)
+{
+       struct glamofb_par *par = info->par;
+       struct drm_device *dev = par->dev;
+       struct drm_mode_set *modeset;
+       struct drm_crtc *crtc;
+       struct glamo_crtc *glamo_crtc;
+       int ret = 0;
+       int i;
+
+       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+               for (i = 0; i < par->crtc_count; i++)
+                       if (crtc->base.id == par->crtc_ids[i])
+                               break;
+
+               if (i == par->crtc_count)
+                       continue;
+
+               glamo_crtc = to_glamo_crtc(crtc);
+               modeset = &glamo_crtc->mode_set;
+
+               modeset->x = var->xoffset;
+               modeset->y = var->yoffset;
+
+               if (modeset->num_connectors) {
+                       mutex_lock(&dev->mode_config.mutex);
+                       ret = crtc->funcs->set_config(modeset);
+                       mutex_unlock(&dev->mode_config.mutex);
+                       if (!ret) {
+                               info->var.xoffset = var->xoffset;
+                               info->var.yoffset = var->yoffset;
+                       }
+               }
+       }
+
+       return ret;
+}
+
+static void glamofb_on(struct fb_info *info)
+{
+       struct glamofb_par *par = info->par;
+       struct drm_device *dev = par->dev;
+       struct drm_crtc *crtc;
+       struct drm_encoder *encoder;
+       int i;
+
+       /*
+        * For each CRTC in this fb, find all associated encoders
+        * and turn them off, then turn off the CRTC.
+        */
+       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+               struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+
+               for (i = 0; i < par->crtc_count; i++)
+                       if (crtc->base.id == par->crtc_ids[i])
+                               break;
+
+               crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
+
+               /* Found a CRTC on this fb, now find encoders */
+               list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+                       if (encoder->crtc == crtc) {
+                               struct drm_encoder_helper_funcs *encoder_funcs;
+                               encoder_funcs = encoder->helper_private;
+                               encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON);
+                       }
+               }
+       }
+}
+
+static void glamofb_off(struct fb_info *info, int dpms_mode)
+{
+       struct glamofb_par *par = info->par;
+       struct drm_device *dev = par->dev;
+       struct drm_crtc *crtc;
+       struct drm_encoder *encoder;
+       int i;
+
+       /*
+        * For each CRTC in this fb, find all associated encoders
+        * and turn them off, then turn off the CRTC.
+        */
+       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+               struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+
+               for (i = 0; i < par->crtc_count; i++)
+                       if (crtc->base.id == par->crtc_ids[i])
+                               break;
+
+               /* Found a CRTC on this fb, now find encoders */
+               list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+                       if (encoder->crtc == crtc) {
+                               struct drm_encoder_helper_funcs *encoder_funcs;
+                               encoder_funcs = encoder->helper_private;
+                               encoder_funcs->dpms(encoder, dpms_mode);
+                       }
+               }
+               if (dpms_mode == DRM_MODE_DPMS_OFF)
+                       crtc_funcs->dpms(crtc, dpms_mode);
+       }
+}
+
+static int glamofb_blank(int blank, struct fb_info *info)
+{
+       switch (blank) {
+       case FB_BLANK_UNBLANK:
+               glamofb_on(info);
+               break;
+       case FB_BLANK_NORMAL:
+               glamofb_off(info, DRM_MODE_DPMS_STANDBY);
+               break;
+       case FB_BLANK_HSYNC_SUSPEND:
+               glamofb_off(info, DRM_MODE_DPMS_STANDBY);
+               break;
+       case FB_BLANK_VSYNC_SUSPEND:
+               glamofb_off(info, DRM_MODE_DPMS_SUSPEND);
+               break;
+       case FB_BLANK_POWERDOWN:
+               glamofb_off(info, DRM_MODE_DPMS_OFF);
+               break;
+       }
+       return 0;
+}
+
+static struct fb_ops glamofb_ops = {
+       .owner = THIS_MODULE,
+       .fb_check_var = glamofb_check_var,
+       .fb_set_par = glamofb_set_par,
+       .fb_setcolreg = glamofb_setcolreg,
+       .fb_fillrect = cfb_fillrect,
+       .fb_copyarea = cfb_copyarea,
+       .fb_imageblit = cfb_imageblit,
+       .fb_pan_display = glamofb_pan_display,
+       .fb_blank = glamofb_blank,
+};
+
+
+/* Here, we create a GEM object of the correct size, and then turn it into
+ * /dev/fbX so that the kernel can put a console on it. */
+int glamofb_create(struct drm_device *dev, uint32_t fb_width,
+                   uint32_t fb_height, uint32_t surface_width,
+                   uint32_t surface_height,
+                   struct glamo_framebuffer **glamo_fb_p)
+{
+       struct fb_info *info;
+       struct glamofb_par *par;
+       struct drm_framebuffer *fb;
+       struct glamo_framebuffer *glamo_fb;
+       struct drm_mode_fb_cmd mode_cmd;
+       struct drm_gem_object *fbo = NULL;
+       struct drm_glamo_gem_object *obj_priv;
+       struct device *device = &dev->pdev->dev;
+       struct glamodrm_handle *gdrm;
+       int size, ret;
+       
+       printk(KERN_ERR "1\n");
+
+       gdrm = dev->dev_private;
+       
+       mode_cmd.width = surface_width;
+       mode_cmd.height = surface_height;
+
+       mode_cmd.bpp = 2;
+       mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 1) / 8), 64);
+       mode_cmd.depth = 16;
+
+       printk(KERN_ERR "2\n");
+       size = mode_cmd.pitch * mode_cmd.height;
+       size = ALIGN(size, PAGE_SIZE);
+       fbo = drm_gem_object_alloc(dev, size);
+       printk(KERN_ERR "3\n");
+       if (!fbo) {
+               printk(KERN_ERR "failed to allocate framebuffer\n");
+               ret = -ENOMEM;
+               goto out;
+       }
+       obj_priv = fbo->driver_private;
+       printk(KERN_ERR "4\n");
+
+       mutex_lock(&dev->struct_mutex);
+
+       ret = glamo_framebuffer_create(dev, &mode_cmd, &fb, fbo);
+       printk(KERN_ERR "5\n");
+       if (ret) {
+               DRM_ERROR("failed to allocate fb.\n");
+               goto out_unref;
+       }
+       printk(KERN_ERR "6\n");
+
+       list_add(&fb->filp_head, &dev->mode_config.fb_kernel_list);
+
+       glamo_fb = to_glamo_framebuffer(fb);
+       *glamo_fb_p = glamo_fb;
+
+       printk(KERN_ERR "7\n");
+       info = framebuffer_alloc(sizeof(struct glamofb_par), device);
+       printk(KERN_ERR "8\n");
+       if (!info) {
+               ret = -ENOMEM;
+               goto out_unref;
+       }
+       printk(KERN_ERR "9\n");
+
+       par = info->par;
+
+       strcpy(info->fix.id, "glamodrmfb");
+       info->fix.type = FB_TYPE_PACKED_PIXELS;
+       info->fix.visual = FB_VISUAL_TRUECOLOR;
+       info->fix.type_aux = 0;
+       info->fix.xpanstep = 1; /* doing it in hw */
+       info->fix.ypanstep = 1; /* doing it in hw */
+       info->fix.ywrapstep = 0;
+       info->fix.accel = FB_ACCEL_I830;
+       info->fix.type_aux = 0;
+       printk(KERN_ERR "10\n");
+       info->flags = FBINFO_DEFAULT;
+
+       info->fbops = &glamofb_ops;
+
+       info->fix.line_length = fb->pitch;
+       info->fix.smem_start = dev->mode_config.fb_base
+                               + (unsigned long) gdrm->vram->start;
+       info->fix.smem_len = size;
+
+       info->flags = FBINFO_DEFAULT;
+
+       info->screen_base = ioremap_wc(gdrm->vram->start, size);
+       if (!info->screen_base) {
+               printk(KERN_ERR "[glamo-drm] Couldn't map framebuffer!\n");
+               ret = -ENOSPC;
+               goto out_unref;
+       }
+       info->screen_size = size;
+
+       info->pseudo_palette = fb->pseudo_palette;
+       info->var.xres_virtual = fb->width;
+       info->var.yres_virtual = fb->height;
+       info->var.bits_per_pixel = fb->bits_per_pixel;
+       info->var.xoffset = 0;
+       info->var.yoffset = 0;
+       info->var.activate = FB_ACTIVATE_NOW;
+       info->var.height = -1;
+       info->var.width = -1;
+       printk(KERN_ERR "11\n");
+       info->var.xres = fb_width;
+       info->var.yres = fb_height;
+
+       info->fix.mmio_start = 0;
+       info->fix.mmio_len = 0;
+
+       info->pixmap.size = 64*1024;
+       info->pixmap.buf_align = 8;
+       info->pixmap.access_align = 32;
+       info->pixmap.flags = FB_PIXMAP_SYSTEM;
+       info->pixmap.scan_align = 1;
+
+       switch (fb->depth) {
+       case 16:
+               switch (reg_read(gdrm, GLAMO_REG_LCD_MODE3) & 0xc000) {
+               case GLAMO_LCD_SRC_RGB565:
+                       info->var.red.offset    = 11;
+                       info->var.green.offset  = 5;
+                       info->var.blue.offset   = 0;
+                       info->var.red.length    = 5;
+                       info->var.green.length  = 6;
+                       info->var.blue.length   = 5;
+                       info->var.transp.length = 0;
+                       break;
+               case GLAMO_LCD_SRC_ARGB1555:
+                       info->var.transp.offset = 15;
+                       info->var.red.offset    = 10;
+                       info->var.green.offset  = 5;
+                       info->var.blue.offset   = 0;
+                       info->var.transp.length = 1;
+                       info->var.red.length    = 5;
+                       info->var.green.length  = 5;
+                       info->var.blue.length   = 5;
+                       break;
+               case GLAMO_LCD_SRC_ARGB4444:
+                       info->var.transp.offset = 12;
+                       info->var.red.offset    = 8;
+                       info->var.green.offset  = 4;
+                       info->var.blue.offset   = 0;
+                       info->var.transp.length = 4;
+                       info->var.red.length    = 4;
+                       info->var.green.length  = 4;
+                       info->var.blue.length   = 4;
+                       break;
+               }
+               break;
+       case 24:
+       case 32:
+       default:
+               /* The Smedia Glamo doesn't support anything but 16bit color */
+               printk(KERN_ERR
+                      "Smedia driver does not [yet?] support 24/32bpp\n");
+               return -EINVAL;
+       }
+
+       fb->fbdev = info;
+printk(KERN_ERR "12\n");
+       par->glamo_fb = glamo_fb;
+       par->dev = dev;
+
+       /* To allow resizeing without swapping buffers */
+       printk("allocated %dx%d fb: bo %p\n", glamo_fb->base.width,
+              glamo_fb->base.height, fbo);
+printk(KERN_ERR "13\n");
+       mutex_unlock(&dev->struct_mutex);
+       return 0;
+
+out_unref:
+       printk(KERN_ERR "14\n");
+       drm_gem_object_unreference(fbo);
+       printk(KERN_ERR "15\n");
+       mutex_unlock(&dev->struct_mutex);
+       printk(KERN_ERR "16\n");
+out:
+       printk(KERN_ERR "7\n");
+       return ret;
+}
+
diff --git a/drivers/mfd/glamo/glamo-kms-fb.h b/drivers/mfd/glamo/glamo-kms-fb.h
new file mode 100644 (file)
index 0000000..f98bf65
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * SMedia Glamo 336x/337x KMS framebuffer
+ *
+ * Copyright (C) 2009 Thomas White <taw@bitwiz.org.uk>
+ *
+ * Based on glamo-fb.c (C) 2007-2008 by Openmoko, Inc.
+ * Author: Harald Welte <laforge@openmoko.org>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#ifndef __GLAMO_KMS_FB_H
+#define __GLAMO_KMS_FB_H
+
+#include <drm/drmP.h>
+
+extern int glamofb_create(struct drm_device *dev, uint32_t fb_width,
+                          uint32_t fb_height, uint32_t surface_width,
+                          uint32_t surface_height,
+                          struct glamo_framebuffer **glamo_fb_p);
+
+#endif /* __GLAMO_KMS_FB_H */