diff options
author | Jeff Hartmann <jhartmann@valinux.com> | 2000-02-13 06:26:38 +0000 |
---|---|---|
committer | Jeff Hartmann <jhartmann@valinux.com> | 2000-02-13 06:26:38 +0000 |
commit | 597acf4bb2cb1d9805abfecaeb69e8aa255d53d4 (patch) | |
tree | b4d72cc1ba2d65addfce2e5f4479438650b99ea0 | |
parent | d1cb058afadb264494d8e138bc2edb84956fca4c (diff) |
I810 bugfixes in progress
-rw-r--r-- | linux-core/i810_dma.c | 3 | ||||
-rw-r--r-- | linux-core/i810_drv.c | 104 | ||||
-rw-r--r-- | linux/Makefile.linux | 3 | ||||
-rw-r--r-- | linux/agpsupport.c | 10 | ||||
-rw-r--r-- | linux/i810_dma.c | 3 | ||||
-rw-r--r-- | linux/i810_drv.c | 104 |
6 files changed, 216 insertions, 11 deletions
diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c index bda2ad01..b28b2401 100644 --- a/linux-core/i810_dma.c +++ b/linux-core/i810_dma.c @@ -219,11 +219,12 @@ static int i810_wait_ring(drm_device_t *dev, int n, int timeout_millis) } else if (curTime - startTime > timeout_millis) { DRM_ERROR("space: %d wanted %d\n", ring->space, n); DRM_ERROR("lockup\n"); - schedule(); /* JEFF - what to do here ??? */ + goto out_wait_ring; } for (i = 0 ; i < 2000 ; i++) ; } +out_wait_ring: return iters; } diff --git a/linux-core/i810_drv.c b/linux-core/i810_drv.c index b7625a84..9c8531ed 100644 --- a/linux-core/i810_drv.c +++ b/linux-core/i810_drv.c @@ -356,6 +356,96 @@ static int i810_takedown(drm_device_t *dev) /* i810_init is called via init_module at module load time, or via * linux/init/main.c (this is not currently supported). */ +typedef union { + void (*free_memory)(agp_memory *); + agp_memory *(*allocate_memory)(size_t, u32); + int (*bind_memory)(agp_memory *, off_t); + int (*unbind_memory)(agp_memory *); + void (*enable)(u32); + int (*acquire)(void); + void (*release)(void); + void (*copy_info)(agp_kern_info *); + unsigned long address; +} drm_agp_func_u; + +typedef struct drm_agp_fill { + const char *name; + drm_agp_func_u *f; +} drm_agp_fill_t; + +static drm_agp_fill_t drm_agp_fill[] = { + { __MODULE_STRING(agp_free_memory), + (drm_agp_func_u *)&drm_agp.free_memory }, + { __MODULE_STRING(agp_allocate_memory), + (drm_agp_func_u *)&drm_agp.allocate_memory }, + { __MODULE_STRING(agp_bind_memory), + (drm_agp_func_u *)&drm_agp.bind_memory }, + { __MODULE_STRING(agp_unbind_memory), + (drm_agp_func_u *)&drm_agp.unbind_memory }, + { __MODULE_STRING(agp_enable), + (drm_agp_func_u *)&drm_agp.enable }, + { __MODULE_STRING(agp_backend_acquire), + (drm_agp_func_u *)&drm_agp.acquire }, + { __MODULE_STRING(agp_backend_release), + (drm_agp_func_u *)&drm_agp.release }, + { __MODULE_STRING(agp_copy_info), + (drm_agp_func_u *)&drm_agp.copy_info }, + { NULL, NULL } +}; + +drm_agp_head_t *i810_agp_init(void) +{ + drm_agp_fill_t *fill; + drm_agp_head_t *head = NULL; + int agp_available = 1; + + for (fill = &drm_agp_fill[0]; fill->name; fill++) { + char *n = (char *)fill->name; + *fill->f = (drm_agp_func_u)get_module_symbol(NULL, n); + printk("%s resolves to 0x%08lx\n", n, (*fill->f).address); + if (!(*fill->f).address) agp_available = 0; + } + + printk("agp_available = %d\n", agp_available); + + if(agp_available == 0) { + printk("agp is not available\n"); + return NULL; + } + + if (agp_available) { + if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS))) + return NULL; + memset((void *)head, 0, sizeof(*head)); + (*drm_agp.copy_info)(&head->agp_info); + head->memory = NULL; + switch (head->agp_info.chipset) { + case INTEL_GENERIC: head->chipset = "Intel"; break; + case INTEL_LX: head->chipset = "Intel 440LX"; break; + case INTEL_BX: head->chipset = "Intel 440BX"; break; + case INTEL_GX: head->chipset = "Intel 440GX"; break; + case INTEL_I810: head->chipset = "Intel i810"; break; + case VIA_GENERIC: head->chipset = "VIA"; break; + case VIA_VP3: head->chipset = "VIA VP3"; break; + case VIA_MVP3: head->chipset = "VIA MVP3"; break; + case VIA_APOLLO_PRO: head->chipset = "VIA Apollo Pro"; break; + case SIS_GENERIC: head->chipset = "SiS"; break; + case AMD_GENERIC: head->chipset = "AMD"; break; + case AMD_IRONGATE: head->chipset = "AMD Irongate"; break; + case ALI_GENERIC: head->chipset = "ALi"; break; + case ALI_M1541: head->chipset = "ALi M1541"; break; + default: + } + DRM_INFO("AGP %d.%d on %s @ 0x%08lx %dMB\n", + head->agp_info.version.major, + head->agp_info.version.minor, + head->chipset, + head->agp_info.aper_base, + head->agp_info.aper_size); + } + return head; +} + int i810_init(void) { int retcode; @@ -383,7 +473,16 @@ int i810_init(void) printk("doing proc init\n"); drm_proc_init(dev); printk("doing agp init\n"); - dev->agp = drm_agp_init(); + dev->agp = i810_agp_init(); + if(dev->agp == NULL) { + printk("The i810 drm module requires the agpgart module" + " to function correctly\nPlease load the agpgart" + " module before you load the i810 module\n"); + drm_proc_cleanup(); + misc_deregister(&i810_misc); + i810_takedown(dev); + return -ENOMEM; + } printk("doing ctxbitmap init\n"); if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); @@ -419,9 +518,6 @@ void i810_cleanup(void) DRM_INFO("Module unloaded\n"); } drm_ctxbitmap_cleanup(dev); -#if 0 - i810_dma_cleanup(dev); -#endif i810_takedown(dev); if (dev->agp) { drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); diff --git a/linux/Makefile.linux b/linux/Makefile.linux index 15556caf..585f2eff 100644 --- a/linux/Makefile.linux +++ b/linux/Makefile.linux @@ -78,7 +78,8 @@ MGAHEADERS= mga_drv.h mga_drm_public.h $(DRMHEADERS) R128OBJS= r128_drv.o r128_context.o R128HEADERS= r128_drv.h $(DRMHEADERS) -I810OBJS= i810_drv.o i810_dma.o i810_bufs.o i810_context.o +I810OBJS= i810_drv.o i810_dma.o i810_bufs.o i810_context.o \ + i810_clear.o I810HEADERS= i810_drv.h $(DRMHEADERS) PROGOBJS= drmstat.po xf86drm.po xf86drmHash.po xf86drmRandom.po sigio.po diff --git a/linux/agpsupport.c b/linux/agpsupport.c index b1266cfa..6dde31da 100644 --- a/linux/agpsupport.c +++ b/linux/agpsupport.c @@ -117,6 +117,8 @@ int drm_agp_release(struct inode *inode, struct file *filp, unsigned int cmd, { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; + + printk("drm_agp_release\n"); if (!dev->agp->acquired || !drm_agp.release) return -EINVAL; (*drm_agp.release)(); @@ -131,6 +133,8 @@ int drm_agp_enable(struct inode *inode, struct file *filp, unsigned int cmd, drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_agp_mode_t mode; + + printk("drm_agp_enable\n"); if (!dev->agp->acquired || !drm_agp.enable) return -EINVAL; @@ -154,6 +158,9 @@ int drm_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, agp_memory *memory; unsigned long pages; u32 type; + + printk("drm_agp_alloc\n"); + if (!dev->agp->acquired) return -EINVAL; copy_from_user_ret(&request, (drm_agp_buffer_t *)arg, sizeof(request), -EFAULT); @@ -228,6 +235,8 @@ int drm_agp_bind(struct inode *inode, struct file *filp, unsigned int cmd, int retcode; int page; + printk("drm_agp_bind\n"); + if (!dev->agp->acquired || !drm_agp.bind_memory) return -EINVAL; copy_from_user_ret(&request, (drm_agp_binding_t *)arg, sizeof(request), -EFAULT); @@ -248,6 +257,7 @@ int drm_agp_free(struct inode *inode, struct file *filp, unsigned int cmd, drm_agp_buffer_t request; drm_agp_mem_t *entry; + printk("drm_agp_free\n"); if (!dev->agp->acquired) return -EINVAL; copy_from_user_ret(&request, (drm_agp_buffer_t *)arg, sizeof(request), -EFAULT); diff --git a/linux/i810_dma.c b/linux/i810_dma.c index bda2ad01..b28b2401 100644 --- a/linux/i810_dma.c +++ b/linux/i810_dma.c @@ -219,11 +219,12 @@ static int i810_wait_ring(drm_device_t *dev, int n, int timeout_millis) } else if (curTime - startTime > timeout_millis) { DRM_ERROR("space: %d wanted %d\n", ring->space, n); DRM_ERROR("lockup\n"); - schedule(); /* JEFF - what to do here ??? */ + goto out_wait_ring; } for (i = 0 ; i < 2000 ; i++) ; } +out_wait_ring: return iters; } diff --git a/linux/i810_drv.c b/linux/i810_drv.c index b7625a84..9c8531ed 100644 --- a/linux/i810_drv.c +++ b/linux/i810_drv.c @@ -356,6 +356,96 @@ static int i810_takedown(drm_device_t *dev) /* i810_init is called via init_module at module load time, or via * linux/init/main.c (this is not currently supported). */ +typedef union { + void (*free_memory)(agp_memory *); + agp_memory *(*allocate_memory)(size_t, u32); + int (*bind_memory)(agp_memory *, off_t); + int (*unbind_memory)(agp_memory *); + void (*enable)(u32); + int (*acquire)(void); + void (*release)(void); + void (*copy_info)(agp_kern_info *); + unsigned long address; +} drm_agp_func_u; + +typedef struct drm_agp_fill { + const char *name; + drm_agp_func_u *f; +} drm_agp_fill_t; + +static drm_agp_fill_t drm_agp_fill[] = { + { __MODULE_STRING(agp_free_memory), + (drm_agp_func_u *)&drm_agp.free_memory }, + { __MODULE_STRING(agp_allocate_memory), + (drm_agp_func_u *)&drm_agp.allocate_memory }, + { __MODULE_STRING(agp_bind_memory), + (drm_agp_func_u *)&drm_agp.bind_memory }, + { __MODULE_STRING(agp_unbind_memory), + (drm_agp_func_u *)&drm_agp.unbind_memory }, + { __MODULE_STRING(agp_enable), + (drm_agp_func_u *)&drm_agp.enable }, + { __MODULE_STRING(agp_backend_acquire), + (drm_agp_func_u *)&drm_agp.acquire }, + { __MODULE_STRING(agp_backend_release), + (drm_agp_func_u *)&drm_agp.release }, + { __MODULE_STRING(agp_copy_info), + (drm_agp_func_u *)&drm_agp.copy_info }, + { NULL, NULL } +}; + +drm_agp_head_t *i810_agp_init(void) +{ + drm_agp_fill_t *fill; + drm_agp_head_t *head = NULL; + int agp_available = 1; + + for (fill = &drm_agp_fill[0]; fill->name; fill++) { + char *n = (char *)fill->name; + *fill->f = (drm_agp_func_u)get_module_symbol(NULL, n); + printk("%s resolves to 0x%08lx\n", n, (*fill->f).address); + if (!(*fill->f).address) agp_available = 0; + } + + printk("agp_available = %d\n", agp_available); + + if(agp_available == 0) { + printk("agp is not available\n"); + return NULL; + } + + if (agp_available) { + if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS))) + return NULL; + memset((void *)head, 0, sizeof(*head)); + (*drm_agp.copy_info)(&head->agp_info); + head->memory = NULL; + switch (head->agp_info.chipset) { + case INTEL_GENERIC: head->chipset = "Intel"; break; + case INTEL_LX: head->chipset = "Intel 440LX"; break; + case INTEL_BX: head->chipset = "Intel 440BX"; break; + case INTEL_GX: head->chipset = "Intel 440GX"; break; + case INTEL_I810: head->chipset = "Intel i810"; break; + case VIA_GENERIC: head->chipset = "VIA"; break; + case VIA_VP3: head->chipset = "VIA VP3"; break; + case VIA_MVP3: head->chipset = "VIA MVP3"; break; + case VIA_APOLLO_PRO: head->chipset = "VIA Apollo Pro"; break; + case SIS_GENERIC: head->chipset = "SiS"; break; + case AMD_GENERIC: head->chipset = "AMD"; break; + case AMD_IRONGATE: head->chipset = "AMD Irongate"; break; + case ALI_GENERIC: head->chipset = "ALi"; break; + case ALI_M1541: head->chipset = "ALi M1541"; break; + default: + } + DRM_INFO("AGP %d.%d on %s @ 0x%08lx %dMB\n", + head->agp_info.version.major, + head->agp_info.version.minor, + head->chipset, + head->agp_info.aper_base, + head->agp_info.aper_size); + } + return head; +} + int i810_init(void) { int retcode; @@ -383,7 +473,16 @@ int i810_init(void) printk("doing proc init\n"); drm_proc_init(dev); printk("doing agp init\n"); - dev->agp = drm_agp_init(); + dev->agp = i810_agp_init(); + if(dev->agp == NULL) { + printk("The i810 drm module requires the agpgart module" + " to function correctly\nPlease load the agpgart" + " module before you load the i810 module\n"); + drm_proc_cleanup(); + misc_deregister(&i810_misc); + i810_takedown(dev); + return -ENOMEM; + } printk("doing ctxbitmap init\n"); if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); @@ -419,9 +518,6 @@ void i810_cleanup(void) DRM_INFO("Module unloaded\n"); } drm_ctxbitmap_cleanup(dev); -#if 0 - i810_dma_cleanup(dev); -#endif i810_takedown(dev); if (dev->agp) { drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); |