⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 radeon_video.c

📁 ati driver
💻 C
📖 第 1 页 / 共 3 页
字号:
    OUTREG(RADEON_OV0_VID_BUF1_BASE_ADRS, offset2 & 0xfffffff0);    OUTREG(RADEON_OV0_VID_BUF2_BASE_ADRS, offset1 & 0xfffffff0);    RADEONWaitForFifo(pScrn, 9);    OUTREG(RADEON_OV0_VID_BUF3_BASE_ADRS, offset2 & 0xfffffff0);    OUTREG(RADEON_OV0_VID_BUF4_BASE_ADRS, offset1 & 0xfffffff0);    OUTREG(RADEON_OV0_VID_BUF5_BASE_ADRS, offset2 & 0xfffffff0);    OUTREG(RADEON_OV0_P1_V_ACCUM_INIT, p1_v_accum_init);    OUTREG(RADEON_OV0_P1_H_ACCUM_INIT, p1_h_accum_init);    OUTREG(RADEON_OV0_P23_H_ACCUM_INIT, p23_h_accum_init);#if 0    if(id == FOURCC_UYVY)       OUTREG(RADEON_OV0_SCALE_CNTL, 0x41008C03);    else       OUTREG(RADEON_OV0_SCALE_CNTL, 0x41008B03);#endif    if (id == FOURCC_UYVY)	OUTREG(RADEON_OV0_SCALE_CNTL, (RADEON_SCALER_SOURCE_YVYU422				       | RADEON_SCALER_ADAPTIVE_DEINT				       | RADEON_SCALER_SMART_SWITCH				       | RADEON_SCALER_DOUBLE_BUFFER				       | RADEON_SCALER_ENABLE				       | scaler_src));    else	OUTREG(RADEON_OV0_SCALE_CNTL, (RADEON_SCALER_SOURCE_VYUY422				       | RADEON_SCALER_ADAPTIVE_DEINT				       | RADEON_SCALER_SMART_SWITCH				       | RADEON_SCALER_DOUBLE_BUFFER				       | RADEON_SCALER_ENABLE				       | scaler_src));    OUTREG(RADEON_OV0_REG_LOAD_CNTL, 0);}static intRADEONPutImage(  ScrnInfoPtr pScrn,  short src_x, short src_y,  short drw_x, short drw_y,  short src_w, short src_h,  short drw_w, short drw_h,  int id, unsigned char* buf,  short width, short height,  Bool Sync,  RegionPtr clipBoxes, pointer data){   RADEONInfoPtr info = RADEONPTR(pScrn);   RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)data;   INT32 xa, xb, ya, yb;   unsigned char *dst_start;   int pitch, new_size, offset, s2offset, s3offset;   int srcPitch, srcPitch2, dstPitch;   int top, left, npixels, nlines, bpp;   BoxRec dstBox;   CARD32 tmp;#if X_BYTE_ORDER == X_BIG_ENDIAN   unsigned char *RADEONMMIO = info->MMIO;   CARD32 surface_cntl = INREG(RADEON_SURFACE_CNTL);   OUTREG(RADEON_SURFACE_CNTL, (surface_cntl | 		RADEON_NONSURF_AP0_SWP_32BPP) & ~RADEON_NONSURF_AP0_SWP_16BPP);#endif   /*    * s2offset, s3offset - byte offsets into U and V plane of the    *                      source where copying starts.  Y plane is    *                      done by editing "buf".    *    * offset - byte offset to the first line of the destination.    *    * dst_start - byte address to the first displayed pel.    *    */   /* make the compiler happy */   s2offset = s3offset = srcPitch2 = 0;   if(src_w > (drw_w << 4))	drw_w = src_w >> 4;   if(src_h > (drw_h << 4))	drw_h = src_h >> 4;   /* Clip */   xa = src_x;   xb = src_x + src_w;   ya = src_y;   yb = src_y + src_h;   dstBox.x1 = drw_x;   dstBox.x2 = drw_x + drw_w;   dstBox.y1 = drw_y;   dstBox.y2 = drw_y + drw_h;   if(!xf86XVClipVideoHelper(&dstBox, &xa, &xb, &ya, &yb,			     clipBoxes, width, height))	return Success;   dstBox.x1 -= pScrn->frameX0;   dstBox.x2 -= pScrn->frameX0;   dstBox.y1 -= pScrn->frameY0;   dstBox.y2 -= pScrn->frameY0;   bpp = pScrn->bitsPerPixel >> 3;   pitch = bpp * pScrn->displayWidth;   switch(id) {   case FOURCC_YV12:   case FOURCC_I420:	dstPitch = ((width << 1) + 15) & ~15;	new_size = ((dstPitch * height) + bpp - 1) / bpp;	srcPitch = (width + 3) & ~3;	s2offset = srcPitch * height;	srcPitch2 = ((width >> 1) + 3) & ~3;	s3offset = (srcPitch2 * (height >> 1)) + s2offset;	break;   case FOURCC_UYVY:   case FOURCC_YUY2:   default:	dstPitch = ((width << 1) + 15) & ~15;	new_size = ((dstPitch * height) + bpp - 1) / bpp;	srcPitch = (width << 1);	break;   }   if(!(info->videoLinear = RADEONAllocateMemory(pScrn, info->videoLinear,		pPriv->doubleBuffer ? (new_size << 1) : new_size)))   {	return BadAlloc;   }   pPriv->currentBuffer ^= 1;    /* copy data */   top = ya >> 16;   left = (xa >> 16) & ~1;   npixels = ((((xb + 0xffff) >> 16) + 1) & ~1) - left;   offset = (info->videoLinear->offset * bpp) + (top * dstPitch);   if(pPriv->doubleBuffer)	offset += pPriv->currentBuffer * new_size * bpp;   dst_start = info->FB + offset;   switch(id) {    case FOURCC_YV12:    case FOURCC_I420:	top &= ~1;	dst_start += left << 1;	tmp = ((top >> 1) * srcPitch2) + (left >> 1);	s2offset += tmp;	s3offset += tmp;	if(id == FOURCC_I420) {	   tmp = s2offset;	   s2offset = s3offset;	   s3offset = tmp;	}	nlines = ((((yb + 0xffff) >> 16) + 1) & ~1) - top;#if X_BYTE_ORDER == X_BIG_ENDIAN	OUTREG(RADEON_SURFACE_CNTL, (surface_cntl | RADEON_NONSURF_AP0_SWP_32BPP)				    & ~RADEON_NONSURF_AP0_SWP_16BPP);#endif	RADEONCopyMungedData(buf + (top * srcPitch) + left, buf + s2offset,			     buf + s3offset, dst_start, srcPitch, srcPitch2,			     dstPitch, nlines, npixels);	break;    case FOURCC_UYVY:    case FOURCC_YUY2:    default:	left <<= 1;	buf += (top * srcPitch) + left;	nlines = ((yb + 0xffff) >> 16) - top;	dst_start += left;#if X_BYTE_ORDER == X_BIG_ENDIAN	OUTREG(RADEON_SURFACE_CNTL, surface_cntl & ~(RADEON_NONSURF_AP0_SWP_32BPP						   | RADEON_NONSURF_AP0_SWP_16BPP));#endif	RADEONCopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels);	break;    }#if X_BYTE_ORDER == X_BIG_ENDIAN    /* restore byte swapping */    OUTREG(RADEON_SURFACE_CNTL, surface_cntl);#endif    /* update cliplist */    if(!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes))     {	REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes);	/* draw these */	if(pPriv->autopaint_colorkey)	    xf86XVFillKeyHelper(pScrn->pScreen, pPriv->colorKey, clipBoxes);    }    RADEONDisplayVideo(pScrn, id, offset, offset, width, height, dstPitch,		     xa, xb, ya, &dstBox, src_w, src_h, drw_w, drw_h);    pPriv->videoStatus = CLIENT_VIDEO_ON;    info->VideoTimerCallback = RADEONVideoTimerCallback;    return Success;}static intRADEONQueryImageAttributes(    ScrnInfoPtr pScrn,    int id,    unsigned short *w, unsigned short *h,    int *pitches, int *offsets){    int size, tmp;    if(*w > 2048) *w = 2048;    if(*h > 2048) *h = 2048;    *w = (*w + 1) & ~1;    if(offsets) offsets[0] = 0;    switch(id) {    case FOURCC_YV12:    case FOURCC_I420:	*h = (*h + 1) & ~1;	size = (*w + 3) & ~3;	if(pitches) pitches[0] = size;	size *= *h;	if(offsets) offsets[1] = size;	tmp = ((*w >> 1) + 3) & ~3;	if(pitches) pitches[1] = pitches[2] = tmp;	tmp *= (*h >> 1);	size += tmp;	if(offsets) offsets[2] = size;	size += tmp;	break;    case FOURCC_UYVY:    case FOURCC_YUY2:    default:	size = *w << 1;	if(pitches) pitches[0] = size;	size *= *h;	break;    }    return size;}static voidRADEONVideoTimerCallback(ScrnInfoPtr pScrn, Time now){    RADEONInfoPtr info = RADEONPTR(pScrn);    RADEONPortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr;    if(pPriv->videoStatus & TIMER_MASK) {	if(pPriv->videoStatus & OFF_TIMER) {	    if(pPriv->offTime < now) {		unsigned char *RADEONMMIO = info->MMIO;		OUTREG(RADEON_OV0_SCALE_CNTL, 0);		pPriv->videoStatus = FREE_TIMER;		pPriv->freeTime = now + FREE_DELAY;	    }	} else {  /* FREE_TIMER */	    if(pPriv->freeTime < now) {		if(info->videoLinear) {		   xf86FreeOffscreenLinear(info->videoLinear);		   info->videoLinear = NULL;		}		pPriv->videoStatus = 0;		info->VideoTimerCallback = NULL;	    }	}    } else  /* shouldn't get here */	info->VideoTimerCallback = NULL;}/****************** Offscreen stuff ***************/typedef struct {  FBLinearPtr linear;  Bool isOn;} OffscreenPrivRec, * OffscreenPrivPtr;static int RADEONAllocateSurface(    ScrnInfoPtr pScrn,    int id,    unsigned short w, 	    unsigned short h,    XF86SurfacePtr surface){    FBLinearPtr linear;    int pitch, fbpitch, size, bpp;    OffscreenPrivPtr pPriv;    if((w > 1024) || (h > 1024))	return BadAlloc;    w = (w + 1) & ~1;    pitch = ((w << 1) + 15) & ~15;    bpp = pScrn->bitsPerPixel >> 3;    fbpitch = bpp * pScrn->displayWidth;    size = ((pitch * h) + bpp - 1) / bpp;    if(!(linear = RADEONAllocateMemory(pScrn, NULL, size)))	return BadAlloc;    surface->width = w;    surface->height = h;    if(!(surface->pitches = xalloc(sizeof(int)))) {	xf86FreeOffscreenLinear(linear);	return BadAlloc;    }    if(!(surface->offsets = xalloc(sizeof(int)))) {	xfree(surface->pitches);	xf86FreeOffscreenLinear(linear);	return BadAlloc;    }    if(!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) {	xfree(surface->pitches);	xfree(surface->offsets);	xf86FreeOffscreenLinear(linear);	return BadAlloc;    }    pPriv->linear = linear;    pPriv->isOn = FALSE;    surface->pScrn = pScrn;    surface->id = id;       surface->pitches[0] = pitch;    surface->offsets[0] = linear->offset * bpp;    surface->devPrivate.ptr = (pointer)pPriv;    return Success;}static int RADEONStopSurface(    XF86SurfacePtr surface){  OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr;  RADEONInfoPtr info = RADEONPTR(surface->pScrn);  unsigned char *RADEONMMIO = info->MMIO;  if(pPriv->isOn) {	OUTREG(RADEON_OV0_SCALE_CNTL, 0);	pPriv->isOn = FALSE;  }  return Success;}static int RADEONFreeSurface(    XF86SurfacePtr surface){    OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr;    if(pPriv->isOn)	RADEONStopSurface(surface);    xf86FreeOffscreenLinear(pPriv->linear);    xfree(surface->pitches);    xfree(surface->offsets);    xfree(surface->devPrivate.ptr);    return Success;}static intRADEONGetSurfaceAttribute(    ScrnInfoPtr pScrn,    Atom attribute,    INT32 *value){   return RADEONGetPortAttribute(pScrn, attribute, value,    		(pointer)(GET_PORT_PRIVATE(pScrn)));}static intRADEONSetSurfaceAttribute(    ScrnInfoPtr pScrn,    Atom attribute,    INT32 value){   return RADEONSetPortAttribute(pScrn, attribute, value,    		(pointer)(GET_PORT_PRIVATE(pScrn)));}static int RADEONDisplaySurface(    XF86SurfacePtr surface,    short src_x, short src_y,     short drw_x, short drw_y,    short src_w, short src_h,     short drw_w, short drw_h,    RegionPtr clipBoxes){    OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr;    ScrnInfoPtr pScrn = surface->pScrn;    RADEONInfoPtr info = RADEONPTR(pScrn);    RADEONPortPrivPtr portPriv = info->adaptor->pPortPrivates[0].ptr;    INT32 xa, ya, xb, yb;    BoxRec dstBox;	    if (src_w > (drw_w << 4))	drw_w = src_w >> 4;    if (src_h > (drw_h << 4))	drw_h = src_h >> 4;    xa = src_x;    xb = src_x + src_w;    ya = src_y;    yb = src_y + src_h;    dstBox.x1 = drw_x;    dstBox.x2 = drw_x + drw_w;    dstBox.y1 = drw_y;    dstBox.y2 = drw_y + drw_h;    if (!xf86XVClipVideoHelper(&dstBox, &xa, &xb, &ya, &yb, clipBoxes, 			       surface->width, surface->height))	return Success;    dstBox.x1 -= pScrn->frameX0;    dstBox.x2 -= pScrn->frameX0;    dstBox.y1 -= pScrn->frameY0;    dstBox.y2 -= pScrn->frameY0;    RADEONResetVideo(pScrn);    RADEONDisplayVideo(pScrn, surface->id,		       surface->offsets[0], surface->offsets[0],		       surface->width, surface->height, surface->pitches[0],		       xa, xb, ya, &dstBox, src_w, src_h, drw_w, drw_h);    if (portPriv->autopaint_colorkey)	xf86XVFillKeyHelper(pScrn->pScreen, portPriv->colorKey, clipBoxes);    pPriv->isOn = TRUE;    /* we've prempted the XvImage stream so set its free timer */    if (portPriv->videoStatus & CLIENT_VIDEO_ON) {	REGION_EMPTY(pScrn->pScreen, &portPriv->clip);   	UpdateCurrentTime();	portPriv->videoStatus = FREE_TIMER;	portPriv->freeTime = currentTime.milliseconds + FREE_DELAY;	info->VideoTimerCallback = RADEONVideoTimerCallback;    }    return Success;}static void RADEONInitOffscreenImages(ScreenPtr pScreen){/*  ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];    RADEONInfoPtr info = RADEONPTR(pScrn); */    XF86OffscreenImagePtr offscreenImages;    /* need to free this someplace */    if (!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))))	return;    offscreenImages[0].image = &Images[0];    offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES | 			       VIDEO_CLIP_TO_VIEWPORT;    offscreenImages[0].alloc_surface = RADEONAllocateSurface;    offscreenImages[0].free_surface = RADEONFreeSurface;    offscreenImages[0].display = RADEONDisplaySurface;    offscreenImages[0].stop = RADEONStopSurface;    offscreenImages[0].setAttribute = RADEONSetSurfaceAttribute;    offscreenImages[0].getAttribute = RADEONGetSurfaceAttribute;    offscreenImages[0].max_width = 1024;    offscreenImages[0].max_height = 1024;    offscreenImages[0].num_attributes = NUM_ATTRIBUTES;    offscreenImages[0].attributes = Attributes;    xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -