Ejemplo n.º 1
0
int sis_ioctl_agp_alloc( DRM_IOCTL_ARGS )
{
	DRM_DEVICE;
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_mem_t agp;
	PMemBlock block;
	int retval = 0;
   
	if (dev_priv == NULL || dev_priv->AGPHeap == NULL)
		return DRM_ERR(EINVAL);
  
	DRM_COPY_FROM_USER_IOCTL(agp, (drm_sis_mem_t *)data, sizeof(agp));
  
	block = mmAllocMem(dev_priv->AGPHeap, agp.size, 0, 0);
	if (block) {
		/* TODO */
		agp.offset = block->ofs;
		agp.free = (unsigned long)block;
		if (!add_alloc_set(agp.context, AGP_TYPE, agp.free)) {
			DRM_DEBUG("adding to allocation set fails\n");
			mmFreeMem((PMemBlock)agp.free);
			retval = -1;
		}
	} else {  
		agp.offset = 0;
		agp.size = 0;
		agp.free = 0;
	}

	DRM_COPY_TO_USER_IOCTL((drm_sis_mem_t *)data, agp, sizeof(agp));

	DRM_DEBUG("alloc agp, size = %d, offset = %d\n", agp.size, agp.offset);

	return retval;
}
Ejemplo n.º 2
0
static int sis_ioctl_agp_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_mem_t *agp = data;
	PMemBlock block;
	int retval = 0;

	if (dev_priv == NULL || dev_priv->AGPHeap == NULL)
		return -EINVAL;

	block = mmAllocMem(dev_priv->AGPHeap, agp->size, 0, 0);
	if (block) {
		/* TODO */
		agp->offset = block->ofs;
		agp->free = (unsigned long)block;
		if (!add_alloc_set(agp->context, AGP_TYPE, agp->free)) {
			DRM_DEBUG("adding to allocation set fails\n");
			mmFreeMem((PMemBlock) agp->free);
			retval = -1;
		}
	} else {
		agp->offset = 0;
		agp->size = 0;
		agp->free = 0;
	}

	DRM_DEBUG("alloc agp, size = %d, offset = %d\n", agp->size,
	    agp->offset);

	return retval;
}
Ejemplo n.º 3
0
static int sis_fb_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_mem_t *fb = data;
	PMemBlock block;
	int retval = 0;

	if (dev_priv == NULL || dev_priv->FBHeap == NULL)
		return -EINVAL;

	block = mmAllocMem(dev_priv->FBHeap, fb->size, 0, 0);
	if (block) {
		/* TODO */
		fb->offset = block->ofs;
		fb->free = (unsigned long)block;
		if (!add_alloc_set(fb->context, VIDEO_TYPE, fb->free)) {
			DRM_DEBUG("adding to allocation set fails\n");
			mmFreeMem((PMemBlock) fb->free);
			retval = -EINVAL;
		}
	} else {
		fb->offset = 0;
		fb->size = 0;
		fb->free = 0;
	}

	DRM_DEBUG("alloc fb, size = %d, offset = %d\n", fb->size, fb->offset);

	return retval;
}
Ejemplo n.º 4
0
int sis_fb_alloc( DRM_IOCTL_ARGS )
{
	DRM_DEVICE;
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_mem_t fb;
	PMemBlock block;
	int retval = 0;

	if (dev_priv == NULL || dev_priv->FBHeap == NULL)
		return DRM_ERR(EINVAL);
  
	DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_mem_t *)data, sizeof(fb));
  
	block = mmAllocMem(dev_priv->FBHeap, fb.size, 0, 0);
	if (block) {
		/* TODO */
		fb.offset = block->ofs;
		fb.free = (unsigned long)block;
		if (!add_alloc_set(fb.context, VIDEO_TYPE, fb.free)) {
			DRM_DEBUG("adding to allocation set fails\n");
			mmFreeMem((PMemBlock)fb.free);
			retval = DRM_ERR(EINVAL);
		}
	} else {
		fb.offset = 0;
		fb.size = 0;
		fb.free = 0;
	}

	DRM_COPY_TO_USER_IOCTL((drm_sis_mem_t *)data, fb, sizeof(fb));

	DRM_DEBUG("alloc fb, size = %d, offset = %d\n", fb.size, fb.offset);

	return retval;
}
Ejemplo n.º 5
0
int sis_final_context(struct drm_device *dev, int context)
{
	int i;

	for (i = 0; i < MAX_CONTEXT; i++) {
		if (global_ppriv[i].used &&
		    (global_ppriv[i].context == context))
			break;
	}

	if (i < MAX_CONTEXT) {
		set_t *set;
		ITEM_TYPE item;
		int retval;

		DRM_DEBUG("find socket %d, context = %d\n", i, context);

		/* Video Memory */
		set = global_ppriv[i].sets[0];
		retval = setFirst(set, &item);
		while (retval) {
			DRM_DEBUG("free video memory 0x%lx\n", item);
#if defined(__linux__) && defined(CONFIG_FB_SIS)
			sis_free(item);
#else
			mmFreeMem((PMemBlock) item);
#endif
			retval = setNext(set, &item);
		}
		setDestroy(set);

		/* AGP Memory */
		set = global_ppriv[i].sets[1];
		retval = setFirst(set, &item);
		while (retval) {
			DRM_DEBUG("free agp memory 0x%lx\n", item);
			mmFreeMem((PMemBlock) item);
			retval = setNext(set, &item);
		}
		setDestroy(set);

		global_ppriv[i].used = 0;
	}

	return 1;
}
/**
 * \brief Keep track of swapped out texture objects.
 * 
 * \param rmesa Radeon context.
 * \param t Radeon texture object.
 *
 * Frees the memory associated with the texture, marks all mipmap images in
 * the texture as dirty and add it to the radeon_texture::swapped list.
 */
static void radeonSwapOutTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
{
   if ( t->memBlock ) {
      mmFreeMem( t->memBlock );
      t->memBlock = NULL;
   }

   t->dirty_images = ~0;
   move_to_tail( &rmesa->texture.swapped, t );
}
Ejemplo n.º 7
0
void
_mesa_exec_free(void *addr)
{
    _glthread_LOCK_MUTEX(exec_mutex);

    if (exec_heap) {
        struct mem_block *block = mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem);

        if (block)
            mmFreeMem(block);
    }

    _glthread_UNLOCK_MUTEX(exec_mutex);
}
Ejemplo n.º 8
0
void 
_mesa_exec_free(void *addr)
{
   mtx_lock(&exec_mutex);

   if (exec_heap) {
      struct mem_block *block = mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem);
   
      if (block)
	 mmFreeMem(block);
   }

   mtx_unlock(&exec_mutex);
}
Ejemplo n.º 9
0
int sis_final_context(int context)
{
	int i;

	for(i=0; i<MAX_CONTEXT; i++)
	  if(global_ppriv[i].used && (global_ppriv[i].context == context))
	    break;
          
	if(i < MAX_CONTEXT){
	  set_t *set;
	  unsigned int item;
	  int retval;
	  
  	  DRM_DEBUG("find socket %d, context = %d\n", i, context);

	  /* Video Memory */
	  set = global_ppriv[i].sets[0];
	  retval = setFirst(set, &item);
	  while(retval){
   	    DRM_DEBUG("free video memory 0x%x\n", item);
            sis_free(item);
	    retval = setNext(set, &item);
	  }
	  setDestroy(set);

	  /* AGP Memory */
	  set = global_ppriv[i].sets[1];
	  retval = setFirst(set, &item);
	  while(retval){
   	    DRM_DEBUG("free agp memory 0x%x\n", item);
	    mmFreeMem((PMemBlock)item);
	    retval = setNext(set, &item);
	  }
	  setDestroy(set);
	  
	  global_ppriv[i].used = 0;	  
        }

	/* turn-off auto-flip */
	/* TODO */
#if defined(SIS_STEREO)
	flip_final();
#endif
	
	return 1;
}
Ejemplo n.º 10
0
static int sis_ioctl_agp_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_mem_t *agp = data;

	if (dev_priv == NULL || dev_priv->AGPHeap == NULL)
		return -EINVAL;

	if (!mmBlockInHeap(dev_priv->AGPHeap, (PMemBlock) agp->free))
		return -EINVAL;

	mmFreeMem((PMemBlock) agp->free);
	if (!del_alloc_set(agp->context, AGP_TYPE, agp->free))
		return -EINVAL;

	DRM_DEBUG("free agp, free = 0x%lx\n", agp->free);

	return 0;
}
Ejemplo n.º 11
0
static int sis_fb_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_mem_t *fb = data;

	if (dev_priv == NULL || dev_priv->FBHeap == NULL)
		return -EINVAL;

	if (!mmBlockInHeap(dev_priv->FBHeap, (PMemBlock) fb->free))
		return -EINVAL;

	if (!del_alloc_set(fb->context, VIDEO_TYPE, fb->free))
		return -EINVAL;
	mmFreeMem((PMemBlock) fb->free);

	DRM_DEBUG("free fb, free = 0x%lx\n", fb->free);

	return 0;
}
Ejemplo n.º 12
0
/**
 * \brief Destroy hardware state associated with a texture.
 *
 * \param rmesa Radeon context.
 * \param t Radeon texture object to be destroyed.
 *
 * Frees the memory associated with the texture and if the texture is bound to
 * a texture unit cleans the associated hardware state.
 */
void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
{
   if ( t->memBlock ) {
      mmFreeMem( t->memBlock );
      t->memBlock = NULL;
   }

   if ( t->tObj )
      t->tObj->DriverData = NULL;

   if ( rmesa ) {
      if ( t == rmesa->state.texture.unit[0].texobj ) {
         rmesa->state.texture.unit[0].texobj = NULL;
	 rmesa->hw.tex[0].dirty = GL_FALSE;
      }
   }

   remove_from_list( t );
   FREE( t );
}
Ejemplo n.º 13
0
int sis_ioctl_agp_free( DRM_IOCTL_ARGS )
{
	DRM_DEVICE;
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_mem_t agp;

	if (dev_priv == NULL || dev_priv->AGPHeap == NULL)
		return DRM_ERR(EINVAL);

	DRM_COPY_FROM_USER_IOCTL(agp, (drm_sis_mem_t *)data, sizeof(agp));

	if (!mmBlockInHeap(dev_priv->AGPHeap, (PMemBlock)agp.free))
		return DRM_ERR(EINVAL);

	mmFreeMem((PMemBlock)agp.free);
	if (!del_alloc_set(agp.context, AGP_TYPE, agp.free))
		return DRM_ERR(EINVAL);

	DRM_DEBUG("free agp, free = 0x%lx\n", agp.free);

	return 0;
}
Ejemplo n.º 14
0
int sis_fb_free( DRM_IOCTL_ARGS )
{
	DRM_DEVICE;
	drm_sis_private_t *dev_priv = dev->dev_private;
	drm_sis_mem_t fb;

	if (dev_priv == NULL || dev_priv->FBHeap == NULL)
		return DRM_ERR(EINVAL);

	DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_mem_t *)data, sizeof(fb));

	if (!mmBlockInHeap(dev_priv->FBHeap, (PMemBlock)fb.free))
		return DRM_ERR(EINVAL);

	if (!del_alloc_set(fb.context, VIDEO_TYPE, fb.free))
		return DRM_ERR(EINVAL);
	mmFreeMem((PMemBlock)fb.free);

	DRM_DEBUG("free fb, free = 0x%lx\n", fb.free);

	return 0;
}
Ejemplo n.º 15
0
int sisp_agp_free(struct inode *inode, struct file *filp, unsigned int cmd,
		  unsigned long arg)
{
  drm_sis_mem_t agp;
  int retval = 0;

  if(!AgpHeap)
    return -1;
    
  if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp)))
	  return -EFAULT;
  
  if(!agp.free){
    return -1;
  }

  mmFreeMem((PMemBlock)agp.free);
  if(!del_alloc_set(agp.context, AGP_TYPE, agp.free))
    retval = -1;

  DRM_DEBUG("free agp, free = %ld\n", agp.free);
  
  return retval;
}
Ejemplo n.º 16
0
int sisp_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
		  unsigned long arg)
{
  drm_sis_mem_t agp;
  PMemBlock block;
  int retval = 0;
   
  if(!AgpHeap)
    return -1;
  
  if (copy_from_user(&agp, (drm_sis_mem_t *)arg, sizeof(agp)))
	  return -EFAULT;
  
  block = mmAllocMem(AgpHeap, agp.size, 0, 0);
  if(block){
    /* TODO */
    agp.offset = block->ofs;
    agp.free = (unsigned long)block;
    if(!add_alloc_set(agp.context, AGP_TYPE, agp.free)){
      DRM_DEBUG("adding to allocation set fails\n");
      mmFreeMem((PMemBlock)agp.free);
      retval = -1;
    }
  }
  else{  
    agp.offset = 0;
    agp.size = 0;
    agp.free = 0;
  }
   
  if (copy_to_user((drm_sis_mem_t *)arg, &agp, sizeof(agp))) return -EFAULT;

  DRM_DEBUG("alloc agp, size = %d, offset = %d\n", agp.size, agp.offset);

  return retval;
}