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; }
int _GGI_stubs_L3_getvline(struct ggi_visual *vis, int x, int y, int h, void *buffer) { uint8_t *dest = (uint8_t *) buffer; ggi_pixel pix; if (x < 0 || x >= LIBGGI_VIRTX(vis)) return 0; if (y < 0) { h += y; dest -= y * 3; y = 0; } if (y + h > LIBGGI_VIRTY(vis)) h = LIBGGI_VIRTY(vis) - y; for (; h > 0; h--, y++) { _ggiGetPixelNC(vis, x, y, &pix); *dest++ = (uint8_t) pix; pix >>= 8; *dest++ = (uint8_t) pix; pix >>= 8; *dest++ = (uint8_t) pix; } return 0; }
int _ggi_palemu_Flush(struct ggi_visual *vis) { ggi_palemu_priv *priv = PALEMU_PRIV(vis); int sx = priv->dirty_tl.x; int sy = priv->dirty_tl.y; int ex = priv->dirty_br.x; int ey = priv->dirty_br.y; /* clear the `dirty region' */ priv->dirty_tl.x = LIBGGI_VIRTX(vis); priv->dirty_tl.y = LIBGGI_VIRTY(vis); priv->dirty_br.x = 0; priv->dirty_br.y = 0; /* When write_frame != display_frame, then there is no need to * update the parent since the affected area(s) are not visible. */ if ((vis->w_frame_num == vis->d_frame_num) && (sx < ex) && (sy < ey)) { return _ggi_palemu_Transfer(vis, sx, sy, ex-sx, ey-sy); } return 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; }
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; }
int GGI_directfb_drawbox(ggi_visual *vis, int x, int y, int w, int h) { if (w > 0 && h > 0) { /* 0 width is not OK! */ struct directfb_priv *priv = DIRECTFB_PRIV(vis); int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis); DFBRectangle dfbobj; y += yadd; directfb_gcupdate(vis, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis), LIBGGI_VIRTX(vis), yadd, DFXL_FILLRECTANGLE); dfbobj.x = x; dfbobj.y = y; dfbobj.h = h; dfbobj.w = w; priv->device.funcs.FillRectangle(priv->device.driver_data, priv->device.device_data, &dfbobj); vis->accelactive = 1; } return 0; }
int GGI_3dlabs_pm2_drawhline(struct ggi_visual *vis, int x, int y, int w) { struct _3dlabs_pm2_priv *priv = PM2_PRIV(vis); volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr; int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis); DPRINT_DRAW("drawhline(%p, %i,%i, %i) entered\n", vis, x,y, w); y += yadd; pm2_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis), yadd); pm2_waitfifo(mmioaddr, 6); pm2_out32(mmioaddr, x << 16, PM2R_START_X_DOM); pm2_out32(mmioaddr, y << 16, PM2R_START_Y); /* Horizontal */ pm2_out32(mmioaddr, 1 << 16, PM2R_D_X_DOM); pm2_out32(mmioaddr, 0 << 16, PM2R_D_Y); pm2_out32(mmioaddr, w, PM2R_COUNT); pm2_out32(mmioaddr, PM2F_RENDER_LINE | PM2F_RENDER_XPOSITIVE | PM2F_RENDER_YPOSITIVE, PM2R_RENDER); vis->accelactive = 1; return 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; }
void _ggi_file_ppm_write(struct ggi_visual *vis) { unsigned char buf[200]; int x, y; ggi_pixel last; ggi_color col; /* PPM files rewind and write from scratch */ /* FIXME shouldn't we truncate the file as well? Size changes? */ _ggi_file_rewind(vis); /* write header info */ _ggi_file_write_string(vis, (const unsigned char *)"P6\n"); _ggi_file_write_string(vis, (const unsigned char *)PPM_INFO_STRING); snprintf((char *)buf, sizeof(buf), "%d %d\n255\n", LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis)); _ggi_file_write_string(vis, buf); /* write out the pixels */ ggiGetPixel(vis->instance.stem, 0, 0, &last); last = ~last; /* must be different from first pixel */ for (y=0; y < LIBGGI_VIRTY(vis); y++) for (x=0; x < LIBGGI_VIRTX(vis); x++) { ggi_pixel pix; ggiGetPixel(vis->instance.stem, x, y, &pix); if (pix != last) { ggiUnmapPixel(vis->instance.stem, pix, &col); } _ggi_file_write_byte(vis, (unsigned)(col.r >> 8)); _ggi_file_write_byte(vis, (unsigned)(col.g >> 8)); _ggi_file_write_byte(vis, (unsigned)(col.b >> 8)); last = pix; } _ggi_file_flush(vis); }
int GGI_X_fillscreen_draw(ggi_visual *vis) { ggi_x_priv *priv; XGCValues gcValue; GC gc; priv = GGIX_PRIV(vis); DPRINT("X_fillscreen_draw enter!\n"); GGI_X_LOCK_XLIB(vis); /* XXX: What is priv->gc ? is it appropriate to use that here? */ gcValue.foreground = LIBGGI_GC(vis)->fg_color; gcValue.background = LIBGGI_GC(vis)->fg_color; gcValue.function = GXcopy; gc = XCreateGC( priv->disp, priv->drawable, GCForeground | GCBackground | GCFunction, &gcValue); if (LIBGGI_GC(vis)->cliptl.x > 0 || LIBGGI_GC(vis)->cliptl.y > 0 || LIBGGI_GC(vis)->clipbr.x < LIBGGI_VIRTX(vis) || LIBGGI_GC(vis)->clipbr.y < LIBGGI_VIRTY(vis)) { int y; /* Note: GGI_X_WRITE_Y is a macro that makes use * of the value stored in y. */ y = LIBGGI_GC(vis)->cliptl.y; y = GGI_X_WRITE_Y; /* CLIPSIZE macro is defined above in * GGI_X_fillscreen_slave_draw() */ XFillRectangle(priv->disp, priv->drawable, gc, LIBGGI_GC(vis)->cliptl.x, y, CLIPSIZE(x), CLIPSIZE(y) ); } else { XFillRectangle(priv->disp, priv->drawable, gc, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis) ); } GGI_X_MAYBE_SYNC(vis); GGI_X_UNLOCK_XLIB(vis); DPRINT_LIBS("X_fillscreen_draw exit!\n"); return 0; }
int GGI_palemu_fillscreen(struct ggi_visual *vis) { ggi_palemu_priv *priv = PALEMU_PRIV(vis); UPDATE_MOD(vis, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis)); return priv->mem_opdraw->fillscreen(vis); }
int GGI_svga_drawhline_nc(ggi_visual *vis, int x, int y, int w) { vga_setcolor(LIBGGI_GC_FGCOLOR(vis)); y += vis->w_frame_num * LIBGGI_VIRTY(vis); vga_drawline(x,y,x+w-1,y); return 0; }
int GGI_stubs_getpixel(struct ggi_visual *vis, int x, int y, ggi_pixel *col) { if (y < 0 || y >= LIBGGI_VIRTY(vis)) return 0; if (x < 0 || x >= LIBGGI_VIRTX(vis)) return 0; return _ggiGetPixelNC(vis, x, y, col); }
int GGI_ati_mach64_fillscreen(struct ggi_visual *vis) { struct ati_mach64_priv *priv = ATI_MACH64_PRIV(vis); int virtx = LIBGGI_VIRTX(vis); int virty = LIBGGI_VIRTY(vis); draw_rect(priv,0,0,virtx,virty); vis->accelactive = 1; return 0; }
int GGI_X_fillscreen_slave(ggi_visual *vis) { ggi_x_priv *priv; priv = GGIX_PRIV(vis); DPRINT("X_fillscreen_slave enter!\n"); if (LIBGGI_GC(vis)->cliptl.x > 0 || LIBGGI_GC(vis)->cliptl.y > 0 || LIBGGI_GC(vis)->clipbr.x < LIBGGI_VIRTX(vis) || LIBGGI_GC(vis)->clipbr.y < LIBGGI_VIRTY(vis)) { GGI_X_DIRTY(vis, LIBGGI_GC(vis)->cliptl.x, LIBGGI_GC(vis)->cliptl.y, LIBGGI_GC(vis)->clipbr.x-LIBGGI_GC(vis)->cliptl.x, LIBGGI_GC(vis)->clipbr.y-LIBGGI_GC(vis)->cliptl.y); } else { GGI_X_DIRTY(vis, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis)); } priv->slave->opdraw->fillscreen(priv->slave); return GGI_OK; }
int GGI_ati_mach64_drawbox(struct ggi_visual *vis, int x, int y, int w, int h) { if (w > 0 && h > 0) { /* 0 width is not OK! */ struct ati_mach64_priv *priv = ATI_MACH64_PRIV(vis); int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis); y += yadd; draw_rect(priv,x,y,w,h); vis->accelactive = 1; } return 0; }
int GGI_monotext_fillscreen(struct ggi_visual *vis) { ggi_palemu_priv *priv = PALEMU_PRIV(vis); int err; err = priv->mem_opdraw->fillscreen(vis); if (err < 0) { return err; } return _ggi_monotext_Update(vis, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis)); }
static void gl_ggiGetSize(GLframebuffer *fb, GLuint *width, GLuint *height) { /* FIXME: this is a hack to work around the new interface */ GLcontext *ctx; ggi_mesa_context_t ggi_ctx; ctx = _mesa_get_current_context(); ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx; GGIMESADPRINT_CORE("gl_ggiGetSize() called\n"); *width = LIBGGI_VIRTX(ggi_ctx->ggi_visual); *height = LIBGGI_VIRTY(ggi_ctx->ggi_visual); printf("returning %d, %d\n", *width, *height); }
int GGI_directfb_fillscreen(ggi_visual *vis) { struct directfb_priv *priv = DIRECTFB_PRIV(vis); int virtx = LIBGGI_VIRTX(vis); int virty = LIBGGI_VIRTY(vis); int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis); DFBRectangle dfbobj; directfb_gcupdate(vis, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis), LIBGGI_VIRTX(vis), yadd, DFXL_FILLRECTANGLE); dfbobj.x = 0; dfbobj.y = 0; dfbobj.h = virty; dfbobj.w = virtx; priv->device.funcs.FillRectangle(priv->device.driver_data, priv->device.device_data, &dfbobj); vis->accelactive = 1; return 0; }
int GGI_X_setorigin_child(struct ggi_visual *vis, int x, int y) { ggi_x_priv *priv; priv = GGIX_PRIV(vis); if (x < 0) return GGI_EARGINVAL; if (y < 0) return GGI_EARGINVAL; if (x > LIBGGI_VIRTX(vis) - LIBGGI_X(vis)) return GGI_EARGINVAL; if (y > LIBGGI_VIRTY(vis) - LIBGGI_Y(vis)) return GGI_EARGINVAL; vis->origin_x = x; vis->origin_y = y; XMoveWindow(priv->disp, priv->win, -x, - y - priv->pf_offset); GGI_X_MAYBE_SYNC(vis); return 0; }
int GGI_X_setdisplayframe_child(struct ggi_visual *vis, int num) { ggi_x_priv *priv; struct gii_xwin_cmddata_set_page_offset data; priv = GGIX_PRIV(vis); if (_ggi_db_find_frame(vis, num) == NULL) return GGI_EARGINVAL; vis->d_frame_num = num; priv->pf_offset = num*LIBGGI_VIRTY(vis); XMoveWindow(priv->disp, priv->win, -vis->origin_x, - vis->origin_y - priv->pf_offset); GGI_X_MAYBE_SYNC(vis); data.yoffset=priv->pf_offset; ggControl(priv->inp->channel, GII_CMDCODE_SET_PAGE_OFFSET, &data); return 0; }
int GGI_X_expose(void *arg, int x, int y, int w, int h) { struct ggi_visual *vis; ggi_x_priv *priv; int err; vis = arg; priv = GGIX_PRIV(vis); /* Expose event may be queued from a previous (larger) mode. In that case we just ignore it and return. */ if ((x+w > LIBGGI_VIRTX(vis)) || y+h > LIBGGI_VIRTY(vis) * (vis->d_frame_num + 1)) return 0; priv->fullflush = 1; err = _ggiInternFlush(vis, x, y, w, h, 2); priv->fullflush = 0; return err; }
int GGI_svga_puthline(ggi_visual *vis,int x,int y,int w,const void *buffer) { int pixelsize = (LIBGGI_PIXFMT(vis)->size+7)/8; const uint8_t *buf = buffer; LIBGGICLIP_XYW_BUFMOD(vis, x, y, w, buf, *pixelsize); y += vis->w_frame_num * LIBGGI_VIRTY(vis); if (SVGA_PRIV(vis)->ismodex && x%4 != 0) { /* ModeX is always 8bpp */ for (;x%4 != 0; x++,w--) { ggiPutPixel(vis, x, y, *buf); buf++; } for (;w%4 != 0; w--) { ggiPutPixel(vis, x, y, *(buf+w)); } } vga_drawscansegment((uint8_t *)buf, x, y, w*pixelsize); return 0; }
int ggiSetGCClipping(ggi_visual_t v,int left,int top,int right,int bottom) { struct ggi_visual *vis = GGI_VISUAL(v); if ((left < 0) || (top < 0) || (right > LIBGGI_VIRTX(vis)) || (bottom > LIBGGI_VIRTY(vis)) || (left>right) || (top>bottom)) { return GGI_ENOSPACE; } LIBGGI_GC(vis)->cliptl.x = left; LIBGGI_GC(vis)->cliptl.y = top; LIBGGI_GC(vis)->clipbr.x = right; LIBGGI_GC(vis)->clipbr.y = bottom; LIBGGI_GC(vis)->version++; if (vis->opgc->gcchanged != NULL) { vis->opgc->gcchanged(vis, GGI_GCCHANGED_CLIP); } return 0; }
int GGI_directfb_drawhline(struct ggi_visual *vis, int x, int y, int w) { struct directfb_priv *priv = DIRECTFB_PRIV(vis); int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis); DFBRectangle dfbobj; y += yadd; directfb_gcupdate(vis, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis), LIBGGI_VIRTX(vis), yadd, DFXL_FILLRECTANGLE); dfbobj.x = x; dfbobj.y = y; dfbobj.w = w; dfbobj.h = 1; priv->device.funcs.FillRectangle(priv->device.driver_data, priv->device.device_data, &dfbobj); vis->accelactive = 1; return 0; }
int GGI_directfb_copybox(struct ggi_visual *vis, int x, int y, int w, int h, int dstx, int dsty) { struct directfb_priv *priv = DIRECTFB_PRIV(vis); int virtx = LIBGGI_VIRTX(vis); int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis); DFBRectangle dfbobj; directfb_gcupdate(vis, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis), LIBGGI_VIRTX(vis), yadd, DFXL_BLIT); dfbobj.x = x; dfbobj.y = y; dfbobj.h = h; dfbobj.w = w; priv->device.funcs.Blit(priv->device.driver_data, priv->device.device_data, &dfbobj, dstx, dsty); vis->accelactive = 1; return 0; }
int GGI_palemu_setPalette(ggi_visual_t vis, size_t start, size_t len, const ggi_color *colormap) { ggi_palemu_priv *priv = PALEMU_PRIV(vis); const ggi_color *src = colormap; size_t end = start + len; DPRINT("display-palemu: SetPalette(%d,%d)\n", start, len); if (start < 0 || start + len > 256) { return GGI_ENOSPACE; } memcpy(LIBGGI_PAL(vis)->clut.data+start, src, len*sizeof(ggi_color)); if (end > start) { UPDATE_MOD(vis, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis)); } for (; start < end; ++start, ++src) { priv->palette[start] = *src; priv->lookup[start] = ggiMapColor(priv->parent, src); } return 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; }
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; } } }
int _ggi_x_createfb(struct ggi_visual *vis) { char target[GGI_MAX_APILEN]; ggi_mode tm; ggi_x_priv *priv; int err, i; err = GGI_OK; priv = GGIX_PRIV(vis); DPRINT_MODE("_ggi_x_createfb(%p) called\n", vis); DPRINT("viidx = %i\n", priv->viidx); _ggi_x_freefb(vis); DPRINT_MODE("Creating vanilla XImage client-side buffer\n"); priv->fb = calloc(1, GT_ByPPP(LIBGGI_VIRTX(vis),LIBGGI_GT(vis)) * LIBGGI_VIRTY(vis) * LIBGGI_MODE(vis)->frames); if (priv->fb == NULL) { DPRINT("_ggi_x_createfb: XImage buffer allocation failed.\n"); err = GGI_ENOMEM; goto err0; } /* We assume LIBGGI_MODE(vis) structure has already been filled out */ memcpy(&tm, LIBGGI_MODE(vis), sizeof(ggi_mode)); /* Make sure we do not fail due to physical size constraints, * which are meaningless on a memory visual. */ tm.size.x = tm.size.y = GGI_AUTO; i = 0; memset(target, '\0', sizeof(target)); i += snprintf(target, sizeof(target), "display-memory:-noblank:-pixfmt="); _ggi_build_pixfmtstr(vis, target + i, sizeof(target) - i, 1); i = strlen(target); snprintf(target + i, sizeof(target) - i, ":-physz=%i,%i:pointer", LIBGGI_MODE(vis)->size.x, LIBGGI_MODE(vis)->size.y); err = _ggi_openslave(vis, target, &tm); if (err) goto err1; priv->ximage = _ggi_x_create_ximage( vis, (char*)priv->fb, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis) ); if (priv->ximage == NULL) { DPRINT("_ggi_x_createfb: _ggi_x_create_ximage() failed\n"); err = GGI_ENOMEM; goto err1; } err = _ggi_create_dbs(vis); if (err) goto err1; DPRINT_MODE("X: XImage %p and slave visual %p share buffer at %p\n", priv->ximage, priv->slave, priv->fb); return GGI_OK; err1: _ggi_x_freefb(vis); err0: return err; }