Пример #1
0
int GGI_m2164w_drawline(ggi_visual *vis, int x, int y, int x2, int y2)
{
	struct m2164w_priv *priv = M2164W_PRIV(vis);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
	uint32_t dwgctl;

	if (yadd) {
		y += yadd;
		y2 += yadd;
	}

	dwgctl = OP_AUTOLINE_CLOSE | SOLID | SHFTZERO | BOP_COPY |
		BLTMOD_BFCOL;

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
		     LIBGGI_VIRTX(vis), yadd);

	if (priv->dwgctl != dwgctl) {
		mga_waitfifo(mmioaddr, 3);
		mga_setdwgctl(mmioaddr, priv, dwgctl);
	} else {
		mga_waitfifo(mmioaddr, 2);
	}
	mga_out32(mmioaddr, (unsigned)RS16(x) | (RS16(y) << 16), XYSTRT);
	mga_out32(mmioaddr, (unsigned)RS16(x2) | (RS16(y2) << 16),
		  XYEND | EXECUTE);

	vis->accelactive = 1;

	return 0;
}
Пример #2
0
int GGI_m2164w_drawbox(struct ggi_visual *vis, int x, int y, int w, int h)
{
	if (w > 0 && h > 0) {	/* 0 width is not OK! */
		struct m2164w_priv *priv = M2164W_PRIV(vis);
		volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
		int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);

		y += yadd;

		mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
			     LIBGGI_VIRTX(vis), yadd);

		if (priv->dwgctl != priv->drawboxcmd) {
			mga_waitfifo(mmioaddr, 3);
			mga_setdwgctl(mmioaddr, priv, priv->drawboxcmd);
		} else {
			mga_waitfifo(mmioaddr, 2);
		}
		mga_out32(mmioaddr, (unsigned)(RS16(x + w) << 16) | RS16(x),
			  FXBNDRY);
		mga_out32(mmioaddr, (unsigned)(RS16(y) << 16) | RS16(h),
			  YDSTLEN | EXECUTE);

		vis->accelactive = 1;
	}

	return 0;
}
Пример #3
0
int GGI_m2164w_fillscreen(struct ggi_visual *vis)
{
	struct m2164w_priv *priv = M2164W_PRIV(vis);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
	int virtx = LIBGGI_VIRTX(vis);
	int virty = LIBGGI_VIRTY(vis);
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis),
		     LIBGGI_GC(vis), LIBGGI_VIRTX(vis), yadd);

	if (priv->dwgctl != priv->drawboxcmd) {
		mga_waitfifo(mmioaddr, 3);
		mga_setdwgctl(mmioaddr, priv, priv->drawboxcmd);
	} else {
		mga_waitfifo(mmioaddr, 2);
	}
	mga_out32(mmioaddr, (unsigned)RS16(virtx) << 16, FXBNDRY);
	mga_out32(mmioaddr, (unsigned)(RS16(yadd) << 16) | RS16(virty + yadd),
		  YDSTLEN | EXECUTE);

	vis->accelactive = 1;

	return 0;
}
Пример #4
0
int GGI_mga_g400_drawhline(ggi_visual *vis, int x, int y, int w)
{
	struct mga_g400_priv *priv = MGA_G400_PRIV(vis);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
	uint32_t dwgctl;

	y += yadd;
	y = RS16(y) << 16;

	dwgctl = OP_AUTOLINE_CLOSE | SOLID | SHFTZERO | BOP_COPY |
		BLTMOD_BFCOL;

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
		     LIBGGI_VIRTX(vis), yadd);

	if (priv->dwgctl != dwgctl) {
		mga_waitfifo(mmioaddr, 3);
		mga_setdwgctl(mmioaddr, priv, dwgctl);
	} else {
		mga_waitfifo(mmioaddr, 2);
	}
	/* y has been shifted above */
	mga_out32(mmioaddr, (unsigned)RS16(x) | y, XYSTRT);
	mga_out32(mmioaddr, (unsigned)RS16(x + w-1) | y, XYEND | EXECUTE);

	vis->accelactive = 1;

	return 0;
}
Пример #5
0
static int
FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color)
{
    int dstX, dstY;
    Uint32 fxbndry;
    Uint32 ydstlen;
    Uint32 fillop;

    /* Don't blit to the display surface when switched away */
    if (switched_away) {
        return -2;              /* no hardware access */
    }
    if (dst == this->screen) {
        SDL_mutexP(hw_lock);
    }

    switch (dst->format->BytesPerPixel) {
    case 1:
        color |= (color << 8);
    case 2:
        color |= (color << 16);
        break;
    }

    /* Set up the X/Y base coordinates */
    FB_dst_to_xy(this, dst, &dstX, &dstY);

    /* Adjust for the current rectangle */
    dstX += rect->x;
    dstY += rect->y;

    /* Set up the X boundaries */
    fxbndry = (dstX | ((dstX + rect->w) << 16));

    /* Set up the Y boundaries */
    ydstlen = (rect->h | (dstY << 16));

    /* Set up for color fill operation */
    fillop = MGADWG_TRAP | MGADWG_SOLID |
        MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO;

    /* Execute the operations! */
    mga_wait(5);
    mga_out32(MGAREG_DWGCTL, fillop | MGADWG_REPLACE);
    mga_out32(MGAREG_FCOL, color);
    mga_out32(MGAREG_FXBNDRY, fxbndry);
    mga_out32(MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen);

    FB_AddBusySurface(dst);

    if (dst == this->screen) {
        SDL_mutexV(hw_lock);
    }
    return (0);
}
Пример #6
0
static int FillHWRect(_THIS, GAL_Surface *dst, GAL_Rect *rect, Uint32 color)
{
	int dstX, dstY;
	Uint32 fxbndry;
	Uint32 ydstlen;
	Uint32 fillop;

	switch (dst->format->BytesPerPixel) {
	    case 1:
		color |= (color<<8);
	    case 2:
		color |= (color<<16);
		break;
	}

	/* Set up the X/Y base coordinates */
	FB_dst_to_xy(this, dst, &dstX, &dstY);

	/* Adjust for the current rectangle */
	dstX += rect->x;
	dstY += rect->y;

	/* Set up the X boundaries */
	fxbndry = (dstX | ((dstX+rect->w) << 16));

	/* Set up the Y boundaries */
	ydstlen = (rect->h | (dstY << 16));

	/* Set up for color fill operation */
	fillop = MGADWG_TRAP | MGADWG_SOLID |
	         MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO;

	/* Execute the operations! */
	mga_wait(5);
	mga_out32(MGAREG_DWGCTL, fillop | MGADWG_REPLACE);
	mga_out32(MGAREG_FCOL, color);
	mga_out32(MGAREG_FXBNDRY, fxbndry);
	mga_out32(MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen);

	FB_AddBusySurface(dst);

	return(0);
}
Пример #7
0
void matrox_set_clip( MatroxDriverData *mdrv,
                      MatroxDeviceData *mdev,
                      DFBRegion        *clip )
{
    volatile u8 *mmio = mdrv->mmio_base;

    mga_waitfifo( mdrv, mdev, 3 );

    if (mdev->old_matrox) {
        mga_out32( mmio, (mdev->dst_offset[0][0] +
                          mdev->dst_pitch * clip->y1) & 0xFFFFFF, YTOP );
        mga_out32( mmio, (mdev->dst_offset[0][0] +
                          mdev->dst_pitch * clip->y2) & 0xFFFFFF, YBOT );
    }
    else {
        mga_out32( mmio, (mdev->dst_pitch * clip->y1) & 0xFFFFFF, YTOP );
        mga_out32( mmio, (mdev->dst_pitch * clip->y2) & 0xFFFFFF, YBOT );
    }

    mga_out32( mmio, ((clip->x2 & 0x0FFF) << 16) | (clip->x1 & 0x0FFF), CXBNDRY );
}
Пример #8
0
static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
                       SDL_Surface *dst, SDL_Rect *dstrect)
{
	SDL_VideoDevice *this = current_video;
	int pitch, w, h;
	int srcX, srcY;
	int dstX, dstY;
	Uint32 sign;
	Uint32 start, stop;
	int skip;
	Uint32 blitop;

	/* FIXME: For now, only blit to display surface */
	if ( dst->pitch != SDL_VideoSurface->pitch ) {
		return(src->map->sw_blit(src, srcrect, dst, dstrect));
	}

	/* Don't blit to the display surface when switched away */
	if ( dst == this->screen ) {
		SDL_mutexP(hw_lock);
	}

	/* Calculate source and destination base coordinates (in pixels) */
	w = dstrect->w;
	h = dstrect->h;
	FB_dst_to_xy(this, src, &srcX, &srcY);
	FB_dst_to_xy(this, dst, &dstX, &dstY);

	/* Adjust for the current blit rectangles */
	srcX += srcrect->x;
	srcY += srcrect->y;
	dstX += dstrect->x;
	dstY += dstrect->y;
	pitch = dst->pitch/dst->format->BytesPerPixel;

	/* Set up the blit direction (sign) flags */
	sign = 0;
	if ( srcX < dstX ) {
		sign |= 1;
	}
	if ( srcY < dstY ) {
		sign |= 4;
		srcY += (h - 1);
		dstY += (h - 1);
	}

	/* Set up the blit source row start, end, and skip (in pixels) */
	stop = start = (srcY * pitch) + srcX;
	if ( srcX < dstX ) {
		start += (w - 1);
	} else {
		stop  += (w - 1);
	}
	if ( srcY < dstY ) {
		skip = -pitch;
	} else {
		skip = pitch;
	}

	/* Set up the blit operation */
	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
		Uint32 colorkey;

		blitop = MGADWG_BFCOL | MGADWG_BITBLT |
		         MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16) |
		         MGADWG_TRANSC;

		colorkey = src->format->colorkey;
		switch (dst->format->BytesPerPixel) {
		    case 1:
			colorkey |= (colorkey<<8);
		    case 2:
			colorkey |= (colorkey<<16);
			break;
		}
		mga_wait(2);
		mga_out32(MGAREG_FCOL, colorkey);
		mga_out32(MGAREG_BCOL, 0xFFFFFFFF);
	} else {
		blitop = MGADWG_BFCOL | MGADWG_BITBLT |
		         MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16);
	}
	mga_wait(7);
	mga_out32(MGAREG_SGN, sign);
	mga_out32(MGAREG_AR3, start);
	mga_out32(MGAREG_AR0, stop);
	mga_out32(MGAREG_AR5, skip);
	mga_out32(MGAREG_FXBNDRY, (dstX | ((dstX + w-1) << 16)));
	mga_out32(MGAREG_YDSTLEN, (dstY << 16) | h);
	mga_out32(MGAREG_DWGCTL + MGAREG_EXEC, blitop);

	FB_AddBusySurface(src);
	FB_AddBusySurface(dst);

	if ( dst == this->screen ) {
		SDL_mutexV(hw_lock);
	}
	return(0);
}
Пример #9
0
int GGI_mga_g400_copybox(ggi_visual *vis, int x, int y, int w, int h,
		       int dstx, int dsty)
{
	struct mga_g400_priv *priv = MGA_G400_PRIV(vis);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
	int virtx = LIBGGI_VIRTX(vis);
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
	int32_t ar5 = virtx;
	int32_t begin, end;
	uint32_t sgn = 0;
	uint32_t dwgctl;

#define COPY_LEFT	1
#define COPY_UP		4

	dsty += yadd;
	y += vis->r_frame_num*LIBGGI_VIRTY(vis);

	if (dsty > y) {
		sgn |= COPY_UP;
		y += h - 1;
		dsty += h - 1;
		ar5 = - ar5;
	}
	
	begin = end = y * virtx + x;

	w--;
	if (dstx > x) {
		sgn |= COPY_LEFT;
		begin += w;
	} else {
		end += w;
	}

	dwgctl = BLTMOD_BFCOL | BOP_COPY | SHFTZERO | OP_BITBLT
		| (sgn ? 0 : SGNZERO);

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis),
		     LIBGGI_GC(vis), virtx, yadd);

	if (priv->dwgctl != dwgctl) {
		if (sgn) mga_waitfifo(mmioaddr, 7);
		else mga_waitfifo(mmioaddr, 6);
		mga_setdwgctl(mmioaddr, priv, dwgctl);
	} else {
		if (sgn) mga_waitfifo(mmioaddr, 6);
		else mga_waitfifo(mmioaddr, 5);
	}
	if (sgn) {
		mga_out32(mmioaddr, sgn, SGN);
	}
#if 0
	mga_out32(mmioaddr, RS18(end), AR0);
	mga_out32(mmioaddr, RS24(begin), AR3);
	mga_out32(mmioaddr, RS18(ar5), AR5);
#else
	mga_out32(mmioaddr, RS22(end), AR0);
	mga_out32(mmioaddr, RS24(begin), AR3);
	mga_out32(mmioaddr, RS22(ar5), AR5);
#endif
	mga_out32(mmioaddr, (unsigned)(RS16(dstx + w) << 16) | RS16(dstx),
		  FXBNDRY);
	mga_out32(mmioaddr, (unsigned)(RS16(dsty) << 16) | RS16(h), 
		  YDSTLEN | EXECUTE);

	vis->accelactive = 1;

	return 0;
}
Пример #10
0
static inline void
dbblit_32bpp(ggi_visual *src, int sx, int sy, int w, int h, 
	     ggi_visual *dst, int dx, int dy, uint32_t srcfmt)
{
	struct m2164w_priv *priv = M2164W_PRIV(dst);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(dst)->mmioaddr;
	int yadd = dst->w_frame_num * LIBGGI_VIRTY(dst);
	volatile uint32_t *dstptr;
	uint32_t dwgctl, bltmod = BLTMOD_BU32RGB;
	uint16_t opmode;
	uint8_t *srcptr;
	uint32_t *srcptr32;
	int srcinc;
	int maxpix;

	dstptr = priv->dmaaddr;
	srcinc = LIBGGI_FB_R_STRIDE(src);
	srcptr = (uint8_t*) LIBGGI_CURWRITE(src) + sy*srcinc + sx*4;
	srcinc -= w*4;
	maxpix = priv->dma_len/4;

	dy += yadd;

	switch (srcfmt) {
#if 0 /* This case is the default. */
	case GGI_DB_STD_24a32p8r8g8b8:
		bltmod = BLTMOD_BU32RGB;
		break;
#endif
	case GGI_DB_STD_24a32p8b8g8r8:
		bltmod = BLTMOD_BU32BGR;
		break;
	}

	dwgctl = bltmod | BOP_COPY | SHFTZERO | OP_ILOAD | SGNZERO;
#ifdef GGI_BIG_ENDIAN
	opmode = OPMODE_DMA_BLIT_WRITE | OPMODE_DMA_BE_32BPP;
#else
	opmode = OPMODE_DMA_BLIT_WRITE | OPMODE_DMA_LE;
#endif

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(dst), LIBGGI_GC(dst),
		     LIBGGI_VIRTX(dst), yadd);

	if (priv->curopmode != opmode) {
		priv->curopmode = opmode;
		mga_waitidle(mmioaddr);
		mga_out16(mmioaddr, opmode, OPMODE);
	}
	if (priv->dwgctl != dwgctl) {
		mga_waitfifo(mmioaddr, 6);
		mga_setdwgctl(mmioaddr, priv, dwgctl);
	} else {
		mga_waitfifo(mmioaddr, 5);
	}
	mga_out32(mmioaddr, RS18(w-1), AR0);
	mga_out32(mmioaddr, 0, AR3);
	mga_out32(mmioaddr, 0, AR5);
	mga_out32(mmioaddr, (unsigned)(RS16(dx + w - 1) << 16) | RS16(dx), 
		  FXBNDRY);
	mga_out32(mmioaddr, (unsigned)(RS16(dy) << 16) | RS16(h),
		  YDSTLEN | EXECUTE);

	dst->accelactive = 1;

	if (w > maxpix) {
		while (h--) {
			int tmpw = w;

			while (tmpw) {
				int tmpw2 = (tmpw > maxpix ? maxpix : tmpw);

				tmpw -= tmpw2;
				while (tmpw2--) {
					srcptr32 = (uint32_t *)srcptr;
					*(dstptr++) = *(srcptr32++);
					srcptr = (uint8_t *)srcptr32;
				}
				dstptr = priv->dmaaddr;
			}
			srcptr += srcinc;
		}
	} else {
		while (h--) {
			int tmpw = w;

			while (tmpw--) {
				srcptr32 = (uint32_t *)srcptr;
				*(dstptr++) = *(srcptr32++);
				srcptr = (uint8_t *)srcptr32;
			}
			srcptr += srcinc;
			dstptr = priv->dmaaddr;
		}
	}
}
Пример #11
0
static DFBResult
besInitLayer( CoreLayer                  *layer,
              void                       *driver_data,
              void                       *layer_data,
              DFBDisplayLayerDescription *description,
              DFBDisplayLayerConfig      *config,
              DFBColorAdjustment         *adjustment )
{
     MatroxDriverData   *mdrv = (MatroxDriverData*) driver_data;
     volatile u8        *mmio = mdrv->mmio_base;

     /* set capabilities and type */
     description->caps = DLCAPS_SCREEN_LOCATION | DLCAPS_SURFACE |
                         DLCAPS_DEINTERLACING | DLCAPS_DST_COLORKEY;
     description->type = DLTF_GRAPHICS | DLTF_VIDEO | DLTF_STILL_PICTURE;

     /* set name */
     snprintf( description->name,
               DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, "Matrox Backend Scaler" );

     /* fill out the default configuration */
     config->flags       = DLCONF_WIDTH | DLCONF_HEIGHT |
                           DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE |
                           DLCONF_OPTIONS;
     config->width       = 640;
     config->height      = 480;
     config->pixelformat = DSPF_YUY2;
     config->buffermode  = DLBM_FRONTONLY;
     config->options     = DLOP_NONE;

     adjustment->flags   = DCAF_NONE;

     if (mdrv->accelerator != FB_ACCEL_MATROX_MGAG200) {
          description->caps      |= DLCAPS_BRIGHTNESS | DLCAPS_CONTRAST;

          /* fill out default color adjustment,
             only fields set in flags will be accepted from applications */
          adjustment->flags      |= DCAF_BRIGHTNESS | DCAF_CONTRAST;
          adjustment->brightness  = 0x8000;
          adjustment->contrast    = 0x8000;

          mga_out32( mmio, 0x80, BESLUMACTL );
     }

     /* make sure BES registers get updated (besvcnt) */
     mga_out32( mmio, 0, BESGLOBCTL );
     /* disable backend scaler */
     mga_out32( mmio, 0, BESCTL );

     /* set defaults */
     mga_out_dac( mmio, XKEYOPMODE, 0x00 ); /* keying off */

     mga_out_dac( mmio, XCOLMSK0RED,   0xFF ); /* full mask */
     mga_out_dac( mmio, XCOLMSK0GREEN, 0xFF );
     mga_out_dac( mmio, XCOLMSK0BLUE,  0xFF );

     mga_out_dac( mmio, XCOLKEY0RED,   0x00 ); /* default to black */
     mga_out_dac( mmio, XCOLKEY0GREEN, 0x00 );
     mga_out_dac( mmio, XCOLKEY0BLUE,  0x00 );

     return DFB_OK;
}
Пример #12
0
void matrox_validate_destination( MatroxDriverData *mdrv,
                                  MatroxDeviceData *mdev,
                                  CardState        *state )
{
    volatile u8   *mmio            = mdrv->mmio_base;
    CoreSurface   *destination     = state->destination;
    CoreSurfaceBuffer *depth_buffer    = NULL;//destination->depth_buffer;
    int            bytes_per_pixel = DFB_BYTES_PER_PIXEL( destination->config.format );

    if (MGA_IS_VALID( m_destination ))
        return;

    mdev->dst_pitch = state->dst.pitch / bytes_per_pixel;

    mdev->depth_buffer = depth_buffer != NULL;

    if (destination->config.format == DSPF_YUY2 || destination->config.format == DSPF_UYVY)
        mdev->dst_pitch /= 2;

    if (mdev->blit_fields && !(destination->config.caps & DSCAPS_SEPARATED))
        mdev->dst_pitch *= 2;

    D_ASSERT( mdev->dst_pitch % 32 == 0 );

    matrox_calc_offsets( mdev, destination, &state->dst, mdev->old_matrox, mdev->dst_offset );

    mga_waitfifo( mdrv, mdev, depth_buffer ? 4 : 3 );

    mga_out32( mmio, mdev->dst_offset[0][0], mdev->old_matrox ? YDSTORG : DSTORG );
    mga_out32( mmio, mdev->dst_pitch, PITCH );

#if 0
    if (depth_buffer)
        mga_out32( mmio, depth_buffer->video.offset, ZORG );
#endif

    switch (destination->config.format) {
    case DSPF_A8:
    case DSPF_ALUT44:
    case DSPF_LUT8:
    case DSPF_RGB332:
        mga_out32( mmio, PW8, MACCESS );
        break;
    case DSPF_RGB555:
    case DSPF_ARGB1555:
        mga_out32( mmio, PW16 | DIT555, MACCESS );
        break;
    case DSPF_RGB444:
    case DSPF_ARGB4444:
    case DSPF_RGB16:
        mga_out32( mmio, PW16, MACCESS );
        break;
    case DSPF_RGB24:
        mga_out32( mmio, PW24, MACCESS );
        break;
    case DSPF_RGB32:
    case DSPF_ARGB:
        mga_out32( mmio, PW32, MACCESS );
        break;
    case DSPF_I420:
    case DSPF_YV12:
    case DSPF_NV12:
    case DSPF_NV21:
        mga_out32( mmio, PW8 | BYPASS332 | NODITHER, MACCESS );
        break;
    case DSPF_YUY2:
    case DSPF_UYVY:
        mga_out32( mmio, PW32 | NODITHER, MACCESS );
        break;
    default:
        D_BUG( "unexpected pixelformat!" );
        break;
    }

    MGA_VALIDATE( m_destination );
}