dev_priv->cce_buffers_offset = dev->sg->handle; 
dev_priv->cce_buffers_offset = (unsigned long)dev->sg->virtual; 
static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init ){	drm_r128_private_t *dev_priv;	DRM_DEBUG( "\n" );	dev_priv = drm_alloc( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );	if ( dev_priv == NULL )		return DRM_ERR(ENOMEM);	memset( dev_priv, 0, sizeof(drm_r128_private_t) );	dev_priv->is_pci = init->is_pci;	if ( dev_priv->is_pci && !dev->sg ) {		DRM_ERROR( "PCI GART memory not allocated!\n" );		dev->dev_private = (void *)dev_priv;		r128_do_cleanup_cce( dev );		return DRM_ERR(EINVAL);	}	dev_priv->usec_timeout = init->usec_timeout;	if ( dev_priv->usec_timeout < 1 ||	     dev_priv->usec_timeout > R128_MAX_USEC_TIMEOUT ) {		DRM_DEBUG( "TIMEOUT problem!\n" );		dev->dev_private = (void *)dev_priv;		r128_do_cleanup_cce( dev );		return DRM_ERR(EINVAL);	}	dev_priv->cce_mode = init->cce_mode;	/* GH: Simple idle check.	 */	atomic_set( &dev_priv->idle_count, 0 );	/* We don't support anything other than bus-mastering ring mode,	 * but the ring can be in either AGP or PCI space for the ring	 * read pointer.	 */	if ( ( init->cce_mode != R128_PM4_192BM ) &&	     ( init->cce_mode != R128_PM4_128BM_64INDBM ) &&	     ( init->cce_mode != R128_PM4_64BM_128INDBM ) &&	     ( init->cce_mode != R128_PM4_64BM_64VCBM_64INDBM ) ) {		DRM_DEBUG( "Bad cce_mode!\n" );		dev->dev_private = (void *)dev_priv;		r128_do_cleanup_cce( dev );		return DRM_ERR(EINVAL);	}	switch ( init->cce_mode ) {	case R128_PM4_NONPM4:		dev_priv->cce_fifo_size = 0;		break;	case R128_PM4_192PIO:	case R128_PM4_192BM:		dev_priv->cce_fifo_size = 192;		break;	case R128_PM4_128PIO_64INDBM:	case R128_PM4_128BM_64INDBM:		dev_priv->cce_fifo_size = 128;		break;	case R128_PM4_64PIO_128INDBM:	case R128_PM4_64BM_128INDBM:	case R128_PM4_64PIO_64VCBM_64INDBM:	case R128_PM4_64BM_64VCBM_64INDBM:	case R128_PM4_64PIO_64VCPIO_64INDPIO:		dev_priv->cce_fifo_size = 64;		break;	}	switch ( init->fb_bpp ) {	case 16:		dev_priv->color_fmt = R128_DATATYPE_RGB565;		break;	case 32:	default:		dev_priv->color_fmt = R128_DATATYPE_ARGB8888;		break;	}	dev_priv->front_offset	= init->front_offset;	dev_priv->front_pitch	= init->front_pitch;	dev_priv->back_offset	= init->back_offset;	dev_priv->back_pitch	= init->back_pitch;	switch ( init->depth_bpp ) {	case 16:		dev_priv->depth_fmt = R128_DATATYPE_RGB565;		break;	case 24:	case 32:	default:		dev_priv->depth_fmt = R128_DATATYPE_ARGB8888;		break;	}	dev_priv->depth_offset	= init->depth_offset;	dev_priv->depth_pitch	= init->depth_pitch;	dev_priv->span_offset	= init->span_offset;	dev_priv->front_pitch_offset_c = (((dev_priv->front_pitch/8) << 21) |					  (dev_priv->front_offset >> 5));	dev_priv->back_pitch_offset_c = (((dev_priv->back_pitch/8) << 21) |					 (dev_priv->back_offset >> 5));	dev_priv->depth_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) |					  (dev_priv->depth_offset >> 5) |					  R128_DST_TILE);	dev_priv->span_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) |					 (dev_priv->span_offset >> 5));	DRM_GETSAREA();		if(!dev_priv->sarea) {		DRM_ERROR("could not find sarea!\n");		dev->dev_private = (void *)dev_priv;		r128_do_cleanup_cce( dev );		return DRM_ERR(EINVAL);	}	dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset);	if(!dev_priv->mmio) {		DRM_ERROR("could not find mmio region!\n");		dev->dev_private = (void *)dev_priv;		r128_do_cleanup_cce( dev );		return DRM_ERR(EINVAL);	}	dev_priv->cce_ring = drm_core_findmap(dev, init->ring_offset);	if(!dev_priv->cce_ring) {		DRM_ERROR("could not find cce ring region!\n");		dev->dev_private = (void *)dev_priv;		r128_do_cleanup_cce( dev );		return DRM_ERR(EINVAL);	}	dev_priv->ring_rptr = drm_core_findmap(dev, init->ring_rptr_offset);	if(!dev_priv->ring_rptr) {		DRM_ERROR("could not find ring read pointer!\n");		dev->dev_private = (void *)dev_priv;		r128_do_cleanup_cce( dev );		return DRM_ERR(EINVAL);	}	dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);	if(!dev->agp_buffer_map) {		DRM_ERROR("could not find dma buffer region!\n");		dev->dev_private = (void *)dev_priv;		r128_do_cleanup_cce( dev );		return DRM_ERR(EINVAL);	}	if ( !dev_priv->is_pci ) {		dev_priv->agp_textures = drm_core_findmap(dev, init->agp_textures_offset);		if(!dev_priv->agp_textures) {			DRM_ERROR("could not find agp texture region!\n");			dev->dev_private = (void *)dev_priv;			r128_do_cleanup_cce( dev );			return DRM_ERR(EINVAL);		}	}	dev_priv->sarea_priv =		(drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle +				     init->sarea_priv_offset);#if __OS_HAS_AGP	if ( !dev_priv->is_pci ) {		drm_core_ioremap( dev_priv->cce_ring, dev );		drm_core_ioremap( dev_priv->ring_rptr, dev );		drm_core_ioremap( dev->agp_buffer_map, dev );		if(!dev_priv->cce_ring->handle ||		   !dev_priv->ring_rptr->handle ||		   !dev->agp_buffer_map->handle) {			DRM_ERROR("Could not ioremap agp regions!\n");			dev->dev_private = (void *)dev_priv;			r128_do_cleanup_cce( dev );			return DRM_ERR(ENOMEM);		}	} else#endif	{		dev_priv->cce_ring->handle =			(void *)dev_priv->cce_ring->offset;		dev_priv->ring_rptr->handle =			(void *)dev_priv->ring_rptr->offset;		dev->agp_buffer_map->handle = (void *)dev->agp_buffer_map->offset;	}#if __OS_HAS_AGP	if ( !dev_priv->is_pci )		dev_priv->cce_buffers_offset = dev->agp->base;	else#endif		dev_priv->cce_buffers_offset = dev->sg->handle;	dev_priv->ring.start = (u32 *)dev_priv->cce_ring->handle;	dev_priv->ring.end = ((u32 *)dev_priv->cce_ring->handle			      + init->ring_size / sizeof(u32));	dev_priv->ring.size = init->ring_size;	dev_priv->ring.size_l2qw = drm_order( init->ring_size / 8 );	dev_priv->ring.tail_mask =		(dev_priv->ring.size / sizeof(u32)) - 1;	dev_priv->ring.high_mark = 128;	dev_priv->sarea_priv->last_frame = 0;	R128_WRITE( R128_LAST_FRAME_REG, dev_priv->sarea_priv->last_frame );	dev_priv->sarea_priv->last_dispatch = 0;	R128_WRITE( R128_LAST_DISPATCH_REG,		    dev_priv->sarea_priv->last_dispatch );#if __OS_HAS_AGP	if ( dev_priv->is_pci ) {#endif		if (!drm_ati_pcigart_init( dev, &dev_priv->phys_pci_gart,     					    &dev_priv->bus_pci_gart) ) {			DRM_ERROR( "failed to init PCI GART!\n" );			dev->dev_private = (void *)dev_priv;			r128_do_cleanup_cce( dev );			return DRM_ERR(ENOMEM);		}		R128_WRITE( R128_PCI_GART_PAGE, dev_priv->bus_pci_gart );#if __OS_HAS_AGP	}#endif	r128_cce_init_ring_buffer( dev, dev_priv );	r128_cce_load_microcode( dev_priv );	dev->dev_private = (void *)dev_priv;	r128_do_engine_reset( dev );	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/d1f2b55ad2c11f46e30547a9f7754e99b478348e/r128_cce.c/buggy/drivers/char/drm/r128_cce.c