[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dri-patches
Subject:    drm: Branch 'modesetting-101' - 5 commits
From:       airlied () kemper ! freedesktop ! org (Dave Airlie)
Date:       2007-04-11 6:35:01
Message-ID: 20070411063501.E834910089 () kemper ! freedesktop ! org
[Download RAW message or body]

linux-core/Makefile.kernel |    2 
 linux-core/drm_crtc.c      |    2 
 linux-core/drm_crtc.h      |    6 +
 linux-core/drm_drv.c       |    4 
 linux-core/drm_fb.c        |  185 +++++++++++++++++++++++++++++++++++++++++++++
 shared-core/i915_dma.c     |    1 
 shared-core/i915_init.c    |   17 ++--
 7 files changed, 205 insertions(+), 12 deletions(-)

New commits:
diff-tree c582eaac194411f52a2c0527ffa093b5a422d7b9 (from 32f6a58db216f23a7c71ca9c7eda56aaa8293078)
Author: Dave Airlie <airlied@airlied2.(none)>
Date:   Wed Apr 11 16:34:40 2007 +1000

    add copyright statement

diff --git a/linux-core/drm_fb.c b/linux-core/drm_fb.c
index 9bf2187..1fe3e54 100644
--- a/linux-core/drm_fb.c
+++ b/linux-core/drm_fb.c
@@ -1,3 +1,28 @@
+/*
+ * Copyright  © 2007 David Airlie
+ *
+ * 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:
+ *     David Airlie
+ */
     /*
      *  Modularization
      */
diff-tree 32f6a58db216f23a7c71ca9c7eda56aaa8293078 (from add7a928ad1819df17d5764d06fb81985b285d08)
Author: Dave Airlie <airlied@airlied2.(none)>
Date:   Wed Apr 11 16:33:03 2007 +1000

    add initial drm_fb framebuffer
    
    So far I can load fbcon, once I use my miniglx to add a framebuffer.
    fbcon doesn't show anything on screen but baby steps and all that.

diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel
index c767116..b9684d6 100644
--- a/linux-core/Makefile.kernel
+++ b/linux-core/Makefile.kernel
@@ -14,7 +14,7 @@ drm-objs    := drm_auth.o drm_bufs.o drm
 		drm_memory_debug.o ati_pcigart.o drm_sman.o \
 		drm_hashtab.o drm_mm.o drm_object.o drm_compat.o \
 	        drm_fence.o drm_ttm.o drm_bo.o drm_bo_move.o drm_crtc.o \
-		drm_edid.o drm_modes.o
+		drm_edid.o drm_modes.o drm_fb.o
 tdfx-objs   := tdfx_drv.o
 r128-objs   := r128_drv.o r128_cce.o r128_state.o r128_irq.o
 mga-objs    := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o
diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c
index 1270527..83f8e16 100644
--- a/linux-core/drm_crtc.c
+++ b/linux-core/drm_crtc.c
@@ -1022,6 +1022,7 @@ int drm_mode_addfb(struct inode *inode, 
 	if (copy_to_user(argp, &r, sizeof(r)))
 		return -EFAULT;
 
+	drmfb_probe(dev, fb);
 	return 0;
 }
 
@@ -1040,6 +1041,7 @@ int drm_mode_rmfb(struct inode *inode, s
 		return -EINVAL;
 	}
 
+	drmfb_remove(dev, fb);
 	/* TODO check if we own the buffer */
 	/* TODO release all crtc connected to the framebuffer */
 	/* bind the fb to the crtc for now */
diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h
index 57bfb10..d5d256d 100644
--- a/linux-core/drm_crtc.h
+++ b/linux-core/drm_crtc.h
@@ -11,6 +11,8 @@
 #include <linux/types.h>
 #include <linux/idr.h>
 
+#include <linux/fb.h>
+
 struct drm_device;
 
 /*
@@ -179,6 +181,9 @@ struct drm_framebuffer {
 	int bits_per_pixel;
 	int flags;
 	struct drm_buffer_object *bo;
+	void *fbdev;
+	u32 pseudo_palette[17];
+	void *virtual_base;
 };
 struct drm_crtc;
 struct drm_output;
@@ -412,6 +417,7 @@ struct drm_mode_config {
 	/* DamagePtr rotationDamage? */
 	/* DGA stuff? */
 	struct drm_mode_config_funcs *funcs;
+	int fb_base;
 };
 
 struct drm_output *drm_output_create(struct drm_device *dev,
diff --git a/linux-core/drm_fb.c b/linux-core/drm_fb.c
new file mode 100644
index 0000000..9bf2187
--- /dev/null
+++ b/linux-core/drm_fb.c
@@ -0,0 +1,160 @@
+    /*
+     *  Modularization
+     */
+
+#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/delay.h>
+#include <linux/fb.h>
+#include <linux/init.h>
+
+#include "drmP.h"
+struct drmfb_par {
+	struct drm_device *dev;
+	struct drm_framebuffer *fb;
+};
+
+static int drmfb_setcolreg(unsigned regno, unsigned red, unsigned green,
+			   unsigned blue, unsigned transp,
+			   struct fb_info *info)
+{
+	struct drmfb_par *par = info->par;
+	struct drm_framebuffer *fb = par->fb;
+	if (regno > 17)
+		return 1;
+
+	printk(KERN_INFO "Got set col reg %d %d %d %d\n", red, green, blue, regno);
+
+	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:
+			fb->pseudo_palette[regno] = ((red & 0xff00) << 8) |
+				(green & 0xff00) |
+				((blue  & 0xff00) >> 8);
+			break;
+		}
+	}
+
+	return 0;
+}
+
+static struct fb_ops drmfb_ops = {
+	.owner = THIS_MODULE,
+	//	.fb_open = drmfb_open,
+	//	.fb_read = drmfb_read,
+	//	.fb_write = drmfb_write,
+	//	.fb_release = drmfb_release,
+	//	.fb_ioctl = drmfb_ioctl,
+	.fb_setcolreg = drmfb_setcolreg,
+	.fb_fillrect = cfb_fillrect,
+	.fb_copyarea = cfb_copyarea,
+	.fb_imageblit = cfb_imageblit,
+};
+
+int drmfb_probe(struct drm_device *dev, struct drm_framebuffer *fb)
+{
+	struct fb_info *info;
+	struct drmfb_par *par;
+	struct device *device = &dev->pdev->dev; 
+	struct fb_var_screeninfo *var_info;
+	unsigned long base, size;
+
+	info = framebuffer_alloc(sizeof(struct drmfb_par), device);
+	if (!info){
+		return -EINVAL;
+	}
+
+	fb->fbdev = info;
+		
+	par = info->par;
+
+	par->dev = dev;
+	par->fb = fb;
+
+	info->fbops = &drmfb_ops;
+
+	strcpy(info->fix.id, "drmfb");
+	info->fix.smem_start = fb->offset + dev->mode_config.fb_base;
+	info->fix.smem_len = (8*1024*1024);
+	info->fix.type = FB_TYPE_PACKED_PIXELS;
+	info->fix.visual = FB_VISUAL_DIRECTCOLOR;
+	info->fix.type_aux = 0;
+	info->fix.mmio_start = 0;
+	info->fix.mmio_len = 0;
+	info->fix.line_length = fb->pitch;
+
+	info->flags = FBINFO_DEFAULT;
+
+	base = fb->bo->offset + dev->mode_config.fb_base;
+	size = (fb->bo->mem.num_pages * PAGE_SIZE);
+
+	DRM_DEBUG("remapping %08X %d\n", base, size);
+	fb->virtual_base = ioremap_nocache(base, size);
+
+	info->screen_base = fb->virtual_base;
+	info->screen_size = size;
+	info->pseudo_palette = fb->pseudo_palette;
+	info->var.xres = fb->width;
+	info->var.xres_virtual = fb->pitch;
+	info->var.yres = fb->height;
+	info->var.yres_virtual = fb->height;
+	info->var.bits_per_pixel = fb->bits_per_pixel;
+	info->var.xoffset = 0;
+	info->var.yoffset = 0;
+
+	switch(fb->depth) {
+	case 8:
+	case 15:
+	case 16:
+		break;
+	case 24:
+	case 32:
+		info->var.red.offset = 16;
+		info->var.green.offset = 8;
+		info->var.blue.offset = 0;
+		info->var.red.length = info->var.green.length =
+			info->var.blue.length = 8;
+		if (fb->depth == 32) {
+			info->var.transp.offset = 24;
+			info->var.transp.length = 8;
+		}
+		break;
+	}
+
+	if (register_framebuffer(info) < 0)
+		return -EINVAL;
+
+	printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node,
+	       info->fix.id);
+	return 0;
+}
+EXPORT_SYMBOL(drmfb_probe);
+
+int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb)
+{
+	struct fb_info *info = fb->fbdev;
+	
+	if (info) {
+		iounmap(fb->virtual_base);
+		unregister_framebuffer(info);
+		framebuffer_release(info);
+	}
+	return 0;
+}
+EXPORT_SYMBOL(drmfb_remove);
+MODULE_LICENSE("GPL");
diff --git a/shared-core/i915_init.c b/shared-core/i915_init.c
index 61c128c..5af86f8 100644
--- a/shared-core/i915_init.c
+++ b/shared-core/i915_init.c
@@ -28,11 +28,11 @@ int i915_driver_load(drm_device_t *dev, 
 	if (IS_I9XX(dev)) {
 		dev_priv->mmiobase = drm_get_resource_start(dev, 0);
 		dev_priv->mmiolen = drm_get_resource_len(dev, 0);
-		dev_priv->baseaddr = drm_get_resource_start(dev, 2) & 0xff000000;
+		dev->mode_config.fb_base = dev_priv->baseaddr = drm_get_resource_start(dev, 2) & 0xff000000;
 	} else if (drm_get_resource_start(dev, 1)) {
 		dev_priv->mmiobase = drm_get_resource_start(dev, 1);
 		dev_priv->mmiolen = drm_get_resource_len(dev, 1);
-		dev_priv->baseaddr = drm_get_resource_start(dev, 0) & 0xff000000;
+		dev->mode_config.fb_base = dev_priv->baseaddr = drm_get_resource_start(dev, 0) & 0xff000000;
 	} else {
 		DRM_ERROR("Unable to find MMIO registers\n");
 		return -ENODEV;
diff-tree add7a928ad1819df17d5764d06fb81985b285d08 (from 3dd5dc5728620cadec24ee5db323a20c3bb48bf0)
Author: Dave Airlie <airlied@airlied2.(none)>
Date:   Wed Apr 11 14:43:02 2007 +1000

    comment out unworkable code

diff --git a/shared-core/i915_init.c b/shared-core/i915_init.c
index 038e393..61c128c 100644
--- a/shared-core/i915_init.c
+++ b/shared-core/i915_init.c
@@ -45,7 +45,7 @@ int i915_driver_load(drm_device_t *dev, 
 		return ret;
 	}
 
-	
+#if 0	
 	ret = drm_setup(dev);
 	if (ret) {
 		DRM_ERROR("drm_setup failed\n");
@@ -61,17 +61,17 @@ int i915_driver_load(drm_device_t *dev, 
 	}
 
 	/* FIXME: where does the sarea_priv really go? */
-	dev_priv->sarea_priv = kmalloc(sizeof(drm_i915_sarea_t), GFP_KERNEL);
+        //	dev_priv->sarea_priv = kmalloc(sizeof(drm_i915_sarea_t), GFP_KERNEL);
 
 	/* FIXME: need real front buffer offset */
-	dev_priv->sarea_priv->front_handle = dev_priv->baseaddr + 1024*1024;
-
+        ///	dev_priv->sarea_priv->front_handle = dev_priv->baseaddr + 1024*1024;
+#endif
 	drm_bo_driver_init(dev);
 	/* this probably doesn't belong here - TODO */
 	//drm_framebuffer_set_object(dev, dev_priv->sarea_priv->front_handle);
 	intel_modeset_init(dev);
-	drm_set_desired_modes(dev);
-
+        //	drm_set_desired_modes(dev);
+#if 0
 	/* FIXME: command ring needs AGP space, do we own it at this point? */
 	dev_priv->ring.Start = dev_priv->baseaddr;
 	dev_priv->ring.End = 128*1024;
@@ -125,6 +125,7 @@ int i915_driver_load(drm_device_t *dev, 
 
 	I915_WRITE(0x02080, dev_priv->dma_status_page);
 	DRM_DEBUG("Enabled hardware status page\n");
+#endif
 
 	return 0;
 }
diff-tree 3dd5dc5728620cadec24ee5db323a20c3bb48bf0 (from 9d12da5917ec57605a2c4cd81c1753145f7e229c)
Author: Dave Airlie <airlied@airlied2.(none)>
Date:   Wed Apr 11 14:34:43 2007 +1000

    only init at driver load

diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index 1c8a0d4..a760340 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -896,7 +896,6 @@ int i915_driver_firstopen(struct drm_dev
 	drm_i915_private_t *dev_priv = dev->dev_private;
 	int ret;
 	DRM_DEBUG("\n");
-	drm_bo_driver_init(dev);
 
 	if (!dev_priv->mmio_map) {
 		ret = drm_addmap(dev, dev_priv->mmiobase, dev_priv->mmiolen,
diff-tree 9d12da5917ec57605a2c4cd81c1753145f7e229c (from b329f91502a20cc6def44b7bea6cbc8b016edd5e)
Author: Dave Airlie <airlied@airlied2.(none)>
Date:   Wed Apr 11 14:34:22 2007 +1000

    only bo finish at driver unload

diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 8000717..b43af32 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -156,8 +156,6 @@ int drm_lastclose(drm_device_t * dev)
 	 * We can't do much about this function failing.
 	 */
 
-	drm_bo_driver_finish(dev);
-
 	if (dev->driver->lastclose)
 		dev->driver->lastclose(dev);
 	DRM_DEBUG("driver lastclose completed\n");
@@ -400,6 +398,8 @@ static void drm_cleanup(drm_device_t * d
 		DRM_DEBUG("mtrr_del=%d\n", retval);
 	}
 
+	drm_bo_driver_finish(dev);
+
 	if (drm_core_has_AGP(dev) && dev->agp) {
 		drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
 		dev->agp = NULL;



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

--
_______________________________________________
Dri-patches mailing list
Dri-patches@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-patches


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic