diff options
author | Jeff Hartmann <jhartmann@valinux.com> | 2000-02-07 23:07:35 +0000 |
---|---|---|
committer | Jeff Hartmann <jhartmann@valinux.com> | 2000-02-07 23:07:35 +0000 |
commit | 061a60b5b95f57055b1c92653a7e114dbe70238a (patch) | |
tree | 49abdf0794359dfe82293edaca9c5021f7697bf0 | |
parent | 1354a250023c5372ea9d24fe6917ec768776df41 (diff) |
Iload debugging stuff
-rw-r--r-- | linux-core/mga_drv.c | 16 | ||||
-rw-r--r-- | linux/mga_bufs.c | 102 | ||||
-rw-r--r-- | linux/mga_clear.c | 24 | ||||
-rw-r--r-- | linux/mga_dma.c | 74 | ||||
-rw-r--r-- | linux/mga_dma.h | 1 | ||||
-rw-r--r-- | linux/mga_drm_public.h | 13 | ||||
-rw-r--r-- | linux/mga_drv.c | 16 |
7 files changed, 144 insertions, 102 deletions
diff --git a/linux-core/mga_drv.c b/linux-core/mga_drv.c index 733bde49..583afe77 100644 --- a/linux-core/mga_drv.c +++ b/linux-core/mga_drv.c @@ -125,7 +125,7 @@ MODULE_PARM(mga, "s"); int init_module(void) { - printk("doing mga_init()\n"); + DRM_DEBUG("doing mga_init()\n"); return mga_init(); } @@ -366,7 +366,7 @@ int mga_init(void) #ifdef MODULE drm_parse_options(mga); #endif - printk("doing misc_register\n"); + DRM_DEBUG("doing misc_register\n"); if ((retcode = misc_register(&mga_misc))) { DRM_ERROR("Cannot register \"%s\"\n", MGA_NAME); return retcode; @@ -374,13 +374,13 @@ int mga_init(void) dev->device = MKDEV(MISC_MAJOR, mga_misc.minor); dev->name = MGA_NAME; - printk("doing mem init\n"); + DRM_DEBUG("doing mem init\n"); drm_mem_init(); - printk("doing proc init\n"); + DRM_DEBUG("doing proc init\n"); drm_proc_init(dev); - printk("doing agp init\n"); + DRM_DEBUG("doing agp init\n"); dev->agp = drm_agp_init(); - printk("doing ctxbitmap init\n"); + DRM_DEBUG("doing ctxbitmap init\n"); if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); drm_proc_cleanup(); @@ -388,10 +388,6 @@ int mga_init(void) mga_takedown(dev); return retcode; } -#if 0 - printk("doing mga_dma_init\n"); - mga_dma_init(dev); -#endif DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", MGA_NAME, diff --git a/linux/mga_bufs.c b/linux/mga_bufs.c index b588094b..e77f3389 100644 --- a/linux/mga_bufs.c +++ b/linux/mga_bufs.c @@ -72,16 +72,16 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; byte_count = 0; -#if 0 - printk("count: %d\n", count); - printk("order: %d\n", order); - printk("size: %d\n", size); - printk("agp_offset: %d\n", agp_offset); - printk("alignment: %d\n", alignment); - printk("page_order: %d\n", page_order); - printk("total: %d\n", total); - printk("byte_count: %d\n", byte_count); -#endif + + DRM_DEBUG("count: %d\n", count); + DRM_DEBUG("order: %d\n", order); + DRM_DEBUG("size: %d\n", size); + DRM_DEBUG("agp_offset: %d\n", agp_offset); + DRM_DEBUG("alignment: %d\n", alignment); + DRM_DEBUG("page_order: %d\n", page_order); + DRM_DEBUG("total: %d\n", total); + DRM_DEBUG("byte_count: %d\n", byte_count); + if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; if (dev->queue_count) return -EBUSY; /* Not while in use */ spin_lock(&dev->count_lock); @@ -120,9 +120,9 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, buf->total = alignment; buf->order = order; buf->used = 0; -#if 0 - printk("offset : %d\n", offset); -#endif + + DRM_DEBUG("offset : %d\n", offset); + buf->offset = offset; /* Hrm */ buf->bus_address = dev->agp->base + agp_offset + offset; buf->address = (void *)(agp_offset + offset + dev->agp->base); @@ -145,7 +145,7 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, entry->buf_count++; byte_count += PAGE_SIZE << page_order; - printk(KERN_INFO "buffer %d @ %p\n", + DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address); } @@ -158,13 +158,13 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, dma->buflist[i] = &entry->buflist[i - dma->buf_count]; dma->buf_count += entry->buf_count; -#if 0 - printk("dma->buf_count : %d\n", dma->buf_count); -#endif + + DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); + dma->byte_count += byte_count; -#if 0 - printk("entry->buf_count : %d\n", entry->buf_count); -#endif + + DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); + drm_freelist_create(&entry->freelist, entry->buf_count); for (i = 0; i < entry->buf_count; i++) { drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]); @@ -181,20 +181,20 @@ int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, -EFAULT); atomic_dec(&dev->buf_alloc); -#if 0 - printk("count: %d\n", count); - printk("order: %d\n", order); - printk("size: %d\n", size); - printk("agp_offset: %d\n", agp_offset); - printk("alignment: %d\n", alignment); - printk("page_order: %d\n", page_order); - printk("total: %d\n", total); - printk("byte_count: %d\n", byte_count); -#endif + + DRM_DEBUG("count: %d\n", count); + DRM_DEBUG("order: %d\n", order); + DRM_DEBUG("size: %d\n", size); + DRM_DEBUG("agp_offset: %d\n", agp_offset); + DRM_DEBUG("alignment: %d\n", alignment); + DRM_DEBUG("page_order: %d\n", page_order); + DRM_DEBUG("total: %d\n", total); + DRM_DEBUG("byte_count: %d\n", byte_count); + dma->flags = _DRM_DMA_USE_AGP; -#if 0 - printk("dma->flags : %lx\n", dma->flags); -#endif + + DRM_DEBUG("dma->flags : %lx\n", dma->flags); + return 0; } @@ -546,7 +546,7 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, spin_lock(&dev->count_lock); if (atomic_read(&dev->buf_alloc)) { spin_unlock(&dev->count_lock); - printk("Buzy\n"); + DRM_DEBUG("Buzy\n"); return -EBUSY; } ++dev->buf_use; /* Can't allocate more after this call */ @@ -556,10 +556,10 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, (drm_buf_map_t *)arg, sizeof(request), -EFAULT); -#if 0 - printk("mga_mapbufs\n"); - printk("dma->flags : %lx\n", dma->flags); -#endif + + DRM_DEBUG("mga_mapbufs\n"); + DRM_DEBUG("dma->flags : %lx\n", dma->flags); + if (request.count >= dma->buf_count) { if(dma->flags & _DRM_DMA_USE_AGP) { drm_mga_private_t *dev_priv = dev->dev_private; @@ -567,18 +567,18 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, map = dev->maplist[dev_priv->buffer_map_idx]; if (!map) { - printk("map is null\n"); + DRM_DEBUG("map is null\n"); retcode = -EINVAL; goto done; } -#if 0 - printk("map->offset : %lx\n", map->offset); - printk("map->size : %lx\n", map->size); - printk("map->type : %d\n", map->type); - printk("map->flags : %x\n", map->flags); - printk("map->handle : %lx\n", map->handle); - printk("map->mtrr : %d\n", map->mtrr); -#endif + + DRM_DEBUG("map->offset : %lx\n", map->offset); + DRM_DEBUG("map->size : %lx\n", map->size); + DRM_DEBUG("map->type : %d\n", map->type); + DRM_DEBUG("map->flags : %x\n", map->flags); + DRM_DEBUG("map->handle : %lx\n", map->handle); + DRM_DEBUG("map->mtrr : %d\n", map->mtrr); + virtual = do_mmap(filp, 0, map->size, PROT_READ|PROT_WRITE, MAP_SHARED, (unsigned long)map->offset); } else { @@ -587,7 +587,7 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, } if (virtual > -1024UL) { /* Real error */ - printk("mmap error\n"); + DRM_DEBUG("mmap error\n"); retcode = (signed long)virtual; goto done; } @@ -629,8 +629,8 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, &request, sizeof(request), -EFAULT); -#if 0 - printk("retcode : %d\n", retcode); -#endif + + DRM_DEBUG("retcode : %d\n", retcode); + return retcode; } diff --git a/linux/mga_clear.c b/linux/mga_clear.c index 34da1ec0..10dece86 100644 --- a/linux/mga_clear.c +++ b/linux/mga_clear.c @@ -223,6 +223,7 @@ static int mgaIload(drm_device_t *dev, drm_mga_iload_t *args) drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; drm_dma_t d; + int pixperdword; buf_priv->dma_type = MGA_DMA_ILOAD; buf_priv->boxes[0].y1 = args->texture.y1; @@ -231,9 +232,28 @@ static int mgaIload(drm_device_t *dev, drm_mga_iload_t *args) buf_priv->boxes[0].x2 = args->texture.x2; buf_priv->ContextState[MGA_CTXREG_DSTORG] = args->destOrg; buf_priv->ContextState[MGA_CTXREG_MACCESS] = args->mAccess; + buf_priv->ServerState[MGA_2DREG_PITCH] = args->pitch; buf_priv->nbox = 1; - sarea_priv->dirty |= MGASAREA_NEW_CONTEXT; - buf->used = args->used; + sarea_priv->dirty |= (MGASAREA_NEW_CONTEXT | MGASAREA_NEW_2D); + switch((args->mAccess & 0x00000003)) { + case 0: + pixperdword = 4; + break; + case 1: + pixperdword = 2; + break; + case 2: + pixperdword = 1; + break; + default: + DRM_ERROR("Invalid maccess value passed" + " to mgaIload\n"); + return -EINVAL; + } + buf->used = ((args->texture.y2 - args->texture.y1) * + (args->texture.x2 - args->texture.x1) / + pixperdword); + DRM_DEBUG("buf->used : %d\n", buf->used); d.context = DRM_KERNEL_CONTEXT; d.send_count = 1; d.send_indices = &buf->idx; diff --git a/linux/mga_dma.c b/linux/mga_dma.c index 86d6d707..aed29f5b 100644 --- a/linux/mga_dma.c +++ b/linux/mga_dma.c @@ -99,13 +99,13 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { if(dev_priv == NULL) return -ENOMEM; dev->dev_private = (void *) dev_priv; - printk("dev_private\n"); + DRM_DEBUG("dev_private\n"); memset(dev_priv, 0, sizeof(drm_mga_private_t)); if((init->reserved_map_idx >= dev->map_count) || (init->buffer_map_idx >= dev->map_count)) { mga_dma_cleanup(dev); - printk("reserved_map or buffer_map are invalid\n"); + DRM_DEBUG("reserved_map or buffer_map are invalid\n"); return -EINVAL; } @@ -115,7 +115,7 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { dev_priv->sarea_priv = (drm_mga_sarea_t *) ((u8 *)sarea_map->handle + init->sarea_priv_offset); - printk("sarea_priv\n"); + DRM_DEBUG("sarea_priv\n"); /* Scale primary size to the next page */ dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) / @@ -137,24 +137,24 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { dev_priv->mAccess = init->mAccess; - printk("memcpy\n"); + DRM_DEBUG("memcpy\n"); memcpy(&dev_priv->WarpIndex, &init->WarpIndex, sizeof(mgaWarpIndex) * MGA_MAX_WARP_PIPES); - printk("memcpy done\n"); + DRM_DEBUG("memcpy done\n"); prim_map = dev->maplist[init->reserved_map_idx]; dev_priv->prim_phys_head = dev->agp->base + init->reserved_map_agpstart; temp = init->warp_ucode_size + dev_priv->primary_size; temp = ((temp + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; - printk("temp : %x\n", temp); - printk("dev->agp->base: %lx\n", dev->agp->base); - printk("init->reserved_map_agpstart: %x\n", init->reserved_map_agpstart); + DRM_DEBUG("temp : %x\n", temp); + DRM_DEBUG("dev->agp->base: %lx\n", dev->agp->base); + DRM_DEBUG("init->reserved_map_agpstart: %x\n", init->reserved_map_agpstart); dev_priv->ioremap = drm_ioremap(dev->agp->base + init->reserved_map_agpstart, temp); if(dev_priv->ioremap == NULL) { - printk("Ioremap failed\n"); + DRM_DEBUG("Ioremap failed\n"); mga_dma_cleanup(dev); return -ENOMEM; } @@ -162,12 +162,12 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { dev_priv->prim_head = (u32 *)dev_priv->ioremap; - printk("dev_priv->prim_head : %p\n", dev_priv->prim_head); + DRM_DEBUG("dev_priv->prim_head : %p\n", dev_priv->prim_head); dev_priv->current_dma_ptr = dev_priv->prim_head; dev_priv->prim_num_dwords = 0; dev_priv->prim_max_dwords = dev_priv->primary_size / 4; - printk("dma initialization\n"); + DRM_DEBUG("dma initialization\n"); /* Private is now filled in, initialize the hardware */ { @@ -183,7 +183,7 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { /* Poll for the first buffer to insure that * the status register will be correct */ - printk(KERN_INFO "phys_head : %lx\n", phys_head); + DRM_DEBUG("phys_head : %lx\n", phys_head); MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG); @@ -204,7 +204,7 @@ static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { } - printk("dma init was successful\n"); + DRM_DEBUG("dma init was successful\n"); return 0; } @@ -299,18 +299,43 @@ static void __mga_iload_xy(drm_device_t *dev, int x2 = buf_priv->boxes[0].x2; int dstorg = buf_priv->ContextState[MGA_CTXREG_DSTORG]; int maccess = buf_priv->ContextState[MGA_CTXREG_MACCESS]; + int pitch = buf_priv->ServerState[MGA_2DREG_PITCH]; + int width, height; + int texperdword = 0; PRIMLOCALS; - + + width = (x2 - x1); + height = (y2 - y1); + switch((maccess & 0x00000003)) { + case 0: + texperdword = 4; + break; + case 1: + texperdword = 2; + break; + case 2: + texperdword = 1; + break; + default: + DRM_ERROR("Invalid maccess value passed to __mga_iload_xy\n"); + return; + } + + x2 = x1 + width; + x2 = (x2 + (texperdword - 1)) & ~(texperdword - 1); + x1 = (x1 + (texperdword - 1)) & ~(texperdword - 1); + width = x2 - x1; + PRIMRESET(dev_priv); PRIMGETPTR(dev_priv); PRIMOUTREG(MGAREG_DSTORG, dstorg | use_agp); PRIMOUTREG(MGAREG_MACCESS, maccess); - PRIMOUTREG(MGAREG_PITCH, (x2 - x1)); - PRIMOUTREG(MGAREG_YDSTLEN, (y1 << 16) | (y2 - y1)); - - PRIMOUTREG(MGAREG_FXBNDRY, (x2 << 16) | x1); - PRIMOUTREG(MGAREG_AR0, (x2 - x1) * (y2 - y1 - 1)); - PRIMOUTREG(MGAREG_AR3, 0 ); + PRIMOUTREG(MGAREG_PITCH, pitch); + PRIMOUTREG(MGAREG_YDSTLEN, (y1 << 16) | height); + + PRIMOUTREG(MGAREG_FXBNDRY, ((x1+width-1) << 16) | x1); + PRIMOUTREG(MGAREG_AR0, width * height - 1); + PRIMOUTREG(MGAREG_AR3, 0 ); PRIMOUTREG(MGAREG_DWGCTL+MGAREG_MGA_EXEC, MGA_ILOAD_CMD); PRIMOUTREG(MGAREG_DMAPAD, 0); @@ -343,8 +368,10 @@ static void mga_dma_dispatch_iload(drm_device_t *dev, drm_buf_t *buf) int x2 = buf_priv->boxes[0].x2; if((x2 - x1) < 32) { + DRM_DEBUG("using iload small\n"); __mga_iload_small(dev, buf, use_agp); } else { + DRM_DEBUG("using iload xy\n"); __mga_iload_xy(dev, buf, use_agp); } } @@ -431,7 +458,6 @@ static inline void mga_dma_quiescent(drm_device_t *dev) { drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - while(1) { atomic_inc(&dev_priv->dispatch_lock); if(atomic_read(&dev_priv->dispatch_lock) == 1) { @@ -580,7 +606,7 @@ static int mga_do_dma(drm_device_t *dev, int locked) mga_dma_dispatch_iload(dev, buf); break; default: - printk("bad buffer type %x in dispatch\n", buf_priv->dma_type); + DRM_DEBUG("bad buffer type %x in dispatch\n", buf_priv->dma_type); break; } @@ -845,10 +871,10 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, if (!ret) { if (lock.flags & _DRM_LOCK_QUIESCENT) { - printk("_DRM_LOCK_QUIESCENT\n"); + DRM_DEBUG("_DRM_LOCK_QUIESCENT\n"); mga_dma_quiescent(dev); } } - printk("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); + DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); return ret; } diff --git a/linux/mga_dma.h b/linux/mga_dma.h index 2f0ea4a2..958756a4 100644 --- a/linux/mga_dma.h +++ b/linux/mga_dma.h @@ -11,6 +11,7 @@ typedef struct { int dma_type; unsigned int ContextState[MGA_CTX_SETUP_SIZE]; + unsigned int ServerState[MGA_2D_SETUP_SIZE]; unsigned int TexState[2][MGA_TEX_SETUP_SIZE]; unsigned int WarpPipe; unsigned int dirty; diff --git a/linux/mga_drm_public.h b/linux/mga_drm_public.h index cc051b38..e6e9b2d7 100644 --- a/linux/mga_drm_public.h +++ b/linux/mga_drm_public.h @@ -125,9 +125,9 @@ typedef struct { typedef struct { unsigned int destOrg; unsigned int mAccess; + unsigned int pitch; xf86drmClipRectRec texture; int idx; - int used; } drm_mga_iload_t; /* Each context has a state: @@ -143,6 +143,11 @@ typedef struct { #define MGA_CTXREG_TDUAL1 8 #define MGA_CTX_SETUP_SIZE 9 +/* 2d state + */ +#define MGA_2DREG_PITCH 0 +#define MGA_2D_SETUP_SIZE 1 + /* Each texture unit has a state: */ #define MGA_TEXREG_CTL 0 @@ -165,6 +170,7 @@ typedef struct { #define MGASAREA_NEW_TEX0 0x2 #define MGASAREA_NEW_TEX1 0x4 #define MGASAREA_NEW_PIPE 0x8 +#define MGASAREA_NEW_2D 0x10 /* Keep this small for testing @@ -185,6 +191,7 @@ typedef struct { typedef struct { unsigned int ContextState[MGA_CTX_SETUP_SIZE]; + unsigned int ServerState[MGA_2D_SETUP_SIZE]; unsigned int TexState[2][MGA_TEX_SETUP_SIZE]; unsigned int WarpPipe; unsigned int dirty; @@ -198,10 +205,6 @@ typedef struct int texAge; } drm_mga_sarea_t; - - - - #define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t) #define DRM_IOCTL_MGA_SWAP DRM_IOW( 0x41, drm_mga_swap_t) #define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x42, drm_mga_clear_t) diff --git a/linux/mga_drv.c b/linux/mga_drv.c index 733bde49..583afe77 100644 --- a/linux/mga_drv.c +++ b/linux/mga_drv.c @@ -125,7 +125,7 @@ MODULE_PARM(mga, "s"); int init_module(void) { - printk("doing mga_init()\n"); + DRM_DEBUG("doing mga_init()\n"); return mga_init(); } @@ -366,7 +366,7 @@ int mga_init(void) #ifdef MODULE drm_parse_options(mga); #endif - printk("doing misc_register\n"); + DRM_DEBUG("doing misc_register\n"); if ((retcode = misc_register(&mga_misc))) { DRM_ERROR("Cannot register \"%s\"\n", MGA_NAME); return retcode; @@ -374,13 +374,13 @@ int mga_init(void) dev->device = MKDEV(MISC_MAJOR, mga_misc.minor); dev->name = MGA_NAME; - printk("doing mem init\n"); + DRM_DEBUG("doing mem init\n"); drm_mem_init(); - printk("doing proc init\n"); + DRM_DEBUG("doing proc init\n"); drm_proc_init(dev); - printk("doing agp init\n"); + DRM_DEBUG("doing agp init\n"); dev->agp = drm_agp_init(); - printk("doing ctxbitmap init\n"); + DRM_DEBUG("doing ctxbitmap init\n"); if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); drm_proc_cleanup(); @@ -388,10 +388,6 @@ int mga_init(void) mga_takedown(dev); return retcode; } -#if 0 - printk("doing mga_dma_init\n"); - mga_dma_init(dev); -#endif DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", MGA_NAME, |