static int GGI_helper_x_shm_setup(struct ggi_helper *helper, const char *args, void *argptr) { ggi_x_priv *priv; int major, minor; Bool pixmaps; DPRINT_LIBS("GGI_helper_x_shm_setup(%p, %s, %p) called\n", helper, args, argptr); priv = GGIX_PRIV(helper->visual); if (XShmQueryExtension(priv->disp) != True) return GGI_ENOFUNC; if (XShmQueryVersion(priv->disp, &major, &minor, &pixmaps) != True) return GGI_ENOFUNC; DPRINT_LIBS("X: MIT-SHM: SHM version %i.%i %s pixmap support\n", major, minor, pixmaps ? "with" : "without"); priv->createfb = _ggi_xshm_create_ximage; priv->freefb = _ggi_xshm_free_ximage; return GGI_OK; }
static int GII_save_close(gii_input *inp) { save_priv *priv = inp->priv; DPRINT_LIBS("GII_save_close(%p) called\n", inp); fflush(priv->output); switch (priv->type) { case FIL: fclose(priv->output); break; case PIPE: pclose(priv->output); break; default: break; } free(priv); DPRINT_LIBS("GII_save_close done\n"); return 0; }
static int GIIdlinit(struct gii_input *inp, const char *args, void *argptr, const char *target) { struct target * t; for(t = _targets; t->target != NULL; t++) { if(!strcmp(t->target, target)) { DPRINT_LIBS("- try to launch builtin target \"%s\"\n", target); return t->func(inp, args, argptr, target); } } DPRINT_LIBS("! unknown builtin target \"%s\"\n", target); return GGI_ENOTFOUND; }
int GIIdl_linux_evdev(gii_input * inp, const char *args, void *argptr) { const char *devname = "/dev/input/event0"; gii_levdev_priv *priv; int fd; DPRINT_LIBS("Linux evdev starting.\n"); if (args && *args) devname = args; fd = open(devname, O_RDONLY); if (fd < 0) return GGI_ENODEVICE; priv = malloc(sizeof(*priv)); if (priv == NULL) { close(fd); return GGI_ENOMEM; } if (_giiRegisterDevice(inp, &priv->devinfo, &priv->valinfo[0]) == 0) { free(priv); close(fd); return GGI_ENOMEM; } inp->GIIsendevent = GIIsendevent; inp->GIIeventpoll = GII_levdev_poll; inp->GIIclose = GIIclose; inp->targetcan = emAll; inp->curreventmask = emAll; inp->maxfd = fd + 1; FD_SET(fd, &inp->fdset); priv->fd = fd; priv->eof = 0; inp->priv = priv; init_devinfo(inp); send_devinfo(inp); DPRINT_LIBS("Linux evdev up.\n"); return 0; }
static int GII_save_handler(gii_input *inp, gii_event *event) { save_priv *priv = inp->priv; DPRINT_LIBS("filter-save handler,priv=%p file=%p\n", priv,priv->output); fwrite(event, event->any.size, 1, priv->output); return 0; }
static int GII_quartz_close(gii_input *inp) { quartz_priv *priv = QUARTZ_PRIV(inp); QuartzExit(priv); free(priv); DPRINT_LIBS("exit ok.\n"); return 0; } /* GII_quartz_close */
int GIIdl_filter_save(gii_input *inp, const char *args, void *argptr) { save_priv *priv; DPRINT_LIBS("filter-save init(%p, \"%s\") called\n", inp, args ? args : ""); priv = malloc(sizeof(save_priv)); if (priv == NULL) return GGI_ENOMEM; priv->output = stdout; priv->type = STDOUT; if (args && *args != '\0') { if (*args=='|') { fflush(stdout); fflush(stderr); priv->output = popen(args+1, "wb"); priv->type = PIPE; } else { priv->output = fopen(args, "wb"); priv->type = FIL; } if (priv->output == NULL) { fprintf(stderr, "filter-save: unable to open %s\n", args); free(priv); return GGI_ENODEVICE; } } inp->priv = priv; inp->GIIhandler = GII_save_handler; inp->GIIclose = GII_save_close; DPRINT_LIBS("filter-save fully up, priv=%p file=%p\n", priv,priv->output); return 0; }
int GGI_vcsa_setmode(struct ggi_visual *vis, ggi_mode *mode) { char libname[GGI_MAX_APILEN], libargs[GGI_MAX_APILEN]; int err, id; if ((err = ggiCheckMode(vis->instance.stem, mode)) != 0) { return err; } DPRINT_MODE("display-vcsa: setmode %dx%d#%dx%dF%d[0x%02x]\n", mode->visible.x, mode->visible.y, mode->virt.x, mode->virt.y, mode->frames, mode->graphtype); memcpy(LIBGGI_MODE(vis), mode, sizeof(ggi_mode)); _ggiZapMode(vis, 0); /* load API libraries */ for (id=1; GGI_vcsa_getapi(vis, id, libname, libargs) == 0; id++) { err = _ggiOpenDL(vis, libggi->config, libname, libargs, NULL); if (err) { fprintf(stderr,"display-vcsa: Error opening the " "%s (%s) library.\n", libname, libargs); return GGI_EFATAL; } DPRINT_LIBS("Success in loading %s (%s)\n", libname, libargs); } /* setup drawing primitives */ vis->opdraw->putpixel_nc = GGI_vcsa_putpixel_nc; vis->opdraw->getpixel_nc = GGI_vcsa_getpixel_nc; vis->opdraw->putc = GGI_vcsa_putc; vis->opdraw->puts = GGI_vcsa_puts; vis->opdraw->getcharsize = GGI_vcsa_getcharsize; vis->opdraw->drawhline_nc = GGI_vcsa_drawhline_nc; vis->opdraw->puthline = GGI_vcsa_puthline; vis->opdraw->gethline = GGI_vcsa_gethline; vis->opcolor->mapcolor = GGI_vcsa_mapcolor; vis->opcolor->unmappixel = GGI_vcsa_unmappixel; /* indicate API change */ ggiIndicateChange(vis->instance.stem, GGI_CHG_APILIST); DPRINT_MODE("display-vcsa: setmode Success.\n"); return 0; }
static void GGI_helper_x_dbe_finish(struct ggi_helper *helper) { #if 0 ggi_x_priv *priv = GGIX_PRIV(helper->visual); XdbeBackBuffer backBuffer; /* Deallocate back buffer */ if(!XdbeDeallocateBackBufferName(priv->disp, priv->drawable)) { DPRINT_LIBS("X: DOUBLE-BUFFER: Unable to deallocate back buffer.\n"); return GGI_EFATAL; } #endif }
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; }
static int GGI_helper_x_dbe_setup(struct ggi_helper *helper, const char *args, void *argptr) { ggi_x_priv *priv = GGIX_PRIV(helper->visual); int major_version, minor_version; Status rc; /* Check if DBE is present before initialising */ rc = XdbeQueryExtension(priv->disp, &major_version, &minor_version); if (rc != True) return GGI_ENOFUNC; DPRINT_LIBS("X: DOUBLE-BUFFER: DBE version %i.%i\n", major_version, minor_version); return GGI_OK; }
static void GGI_helper_x_shm_finish(struct ggi_helper *helper) { ggi_x_priv *priv; DPRINT_LIBS("GGI_helper_x_shm_teardown(%p) called\n", helper); priv = GGIX_PRIV(helper->visual); if (priv && priv->freefb) { priv->freefb(helper->visual); priv->freefb = NULL; } return; }
static int do_setmode(struct ggi_visual *vis) { char libname[GGI_MAX_APILEN], libargs[GGI_MAX_APILEN]; ggi_graphtype gt; int err, id; err = do_mmap(vis); if (err) return err; _ggiZapMode(vis, 0); for (id=1; GGI_lcd823_getapi(vis, id, libname, libargs) == 0; id++) { if (_ggiOpenDL(vis, libggi->config, libname, libargs, NULL) != 0) { fprintf(stderr,"display-lcd823: Error opening the " "%s (%s) library.\n", libname, libargs); return GGI_EFATAL; } DPRINT_LIBS("Success in loading %s (%s)\n", libname, libargs); } /* Set up palette */ gt = LIBGGI_GT(vis); if ((GT_SCHEME(gt) == GT_PALETTE) || (GT_SCHEME(gt) == GT_TEXT)) { int nocols = 1 << GT_DEPTH(gt); LIBGGI_PAL(vis)->clut.size = nocols; LIBGGI_PAL(vis)->clut.data = _ggi_malloc(nocols * sizeof(ggi_color)); LIBGGI_PAL(vis)->priv = _ggi_malloc(256 * sizeof(uint16_t)); LIBGGI_PAL(vis)->setPalette = GGI_lcd823_setPalette; LIBGGI_PAL(vis)->getPrivSize = GGI_lcd823_getPrivSize; /* Initialize palette */ ggiSetColorfulPalette(vis); } ggiIndicateChange(vis, GGI_CHG_APILIST); DPRINT_MODE("display-lcd823: do_setmode SUCCESS\n"); return 0; }
static int GGI_DBE_create_window_drawable (struct ggi_visual *vis) { ggi_x_priv *priv = GGIX_PRIV(vis); XdbeBackBuffer backBuffer; if(priv->win == None) return GGI_ENODEVICE; priv->drawable = priv->win; /* Allocate back buffer */ backBuffer = XdbeAllocateBackBufferName(priv->disp, priv->win, XdbeUntouched); if (backBuffer != None) { priv->drawable = backBuffer; } else { DPRINT_LIBS("X: DOUBLE-BUFFER: Back buffer allocation failed\n"); return GGI_EFATAL; } return 0; }
static void * _builtins_get(void * _, const char *symbol) { if(!strcmp(symbol, GII_DLINIT_SYM)) return (void *)GIIdlinit; DPRINT_LIBS("! builtin symbol '%s' not found\n",symbol); return NULL; }
static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh, const char *args, void *argptr, uint32_t *dlret) { ggi_fbdev_priv *fbdevpriv = FBDEV_PRIV(vis); struct m2164w_priv *priv; unsigned long usedmemend; size_t fontlen; int pixbytes; int fd = LIBGGI_FD(vis); int i; if (GT_SIZE(LIBGGI_GT(vis)) % 8 != 0 || GT_SIZE(LIBGGI_GT(vis)) > 32 || GT_SIZE(LIBGGI_GT(vis)) < 8) { /* Unsupported mode */ return GGI_ENOFUNC; } pixbytes = GT_ByPP(LIBGGI_GT(vis)); priv = malloc(sizeof(struct m2164w_priv)); if (priv == NULL) { return GGI_ENOMEM; } fbdevpriv->mmioaddr = mmap(NULL, fbdevpriv->orig_fix.mmio_len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (signed)fbdevpriv->orig_fix.smem_len); if (fbdevpriv->mmioaddr == MAP_FAILED) { /* Can't mmap() MMIO region - bail out */ DPRINT_LIBS("mga-2164w: Unable to map MMIO region: %s\n" " fd: %d, len: %ld, offset: %ld\n", strerror(errno), fd, fbdevpriv->orig_fix.mmio_len, fbdevpriv->orig_fix.smem_len); fbdevpriv->mmioaddr = NULL; free(priv); return GGI_ENODEVICE; } DPRINT_MISC("mga-2164w: Mapped MMIO region at %p\n", fbdevpriv->mmioaddr); /* Set up DirectBuffers */ for (i=0; i < LIBGGI_MODE(vis)->frames; i++) { ggi_directbuffer *buf = LIBGGI_APPBUFS(vis)[i]; ggi_resource *res; res = malloc(sizeof(ggi_resource)); if (res == NULL) { do_cleanup(vis); return GGI_ENOMEM; } buf->resource = res; buf->resource->acquire = m2164w_acquire; buf->resource->release = m2164w_release; buf->resource->self = buf; buf->resource->priv = vis; buf->resource->count = 0; buf->resource->curactype = 0; } priv->drawboxcmd = BOP_COPY | SHFTZERO | SGNZERO | ARZERO | SOLID | OP_TRAP; if (pixbytes != 3) { switch (fbdevpriv->orig_fix.accel) { case FB_ACCEL_MATROX_MGA2064W: case FB_ACCEL_MATROX_MGA1064SG: case FB_ACCEL_MATROX_MGA2164W: case FB_ACCEL_MATROX_MGA2164W_AGP: /* Use block mode */ priv->drawboxcmd |= ATYPE_BLK; break; default: /* For now - assume SDRAM for other cards */ break; } } priv->dwgctl = 0; priv->oldfgcol = LIBGGI_GC(vis)->fg_color - 1; priv->oldbgcol = LIBGGI_GC(vis)->bg_color - 1; priv->oldtl.x = -1; priv->oldtl.y = -1; priv->oldbr.x = -1; priv->oldbr.y = -1; priv->oldyadd = -1; priv->curopmode = priv->origopmode = mga_in16(fbdevpriv->mmioaddr, OPMODE); /* Use the 7k Pseudo-DMA window */ priv->dmaaddr = (void*)fbdevpriv->mmioaddr; priv->dma_len = 0x1c00; vis->needidleaccel = 1; fbdevpriv->idleaccel = m2164w_idleaccel; /* Accelerate fonts if possible */ priv->font = (uint8_t *)(font); usedmemend = LIBGGI_MODE(vis)->frames * fbdevpriv->fix.line_length * LIBGGI_VIRTY(vis); fontlen = 256*8; priv->fontoffset = fbdevpriv->orig_fix.smem_len - fontlen; priv->fontoffset &= ~127; /* Align */ DPRINT_MISC("mga-2164w: usedmemend: %ld, fontoffset: %ld\n", usedmemend, priv->fontoffset); if (usedmemend <= priv->fontoffset) { memcpy((uint8_t*)fbdevpriv->fb_ptr + priv->fontoffset, font, fontlen); priv->fontoffset *= 8; /* In bits */ priv->charadd = FWIDTH*FHEIGHT; vis->opdraw->putc = GGI_m2164w_fastputc; vis->opdraw->puts = GGI_m2164w_fastputs; DPRINT_MISC("mga-2164w: Using fast chars\n"); } else { priv->fontoffset = 0; vis->opdraw->putc = GGI_m2164w_putc; vis->opdraw->puts = GGI_m2164w_puts; DPRINT_MISC("mga-2164w: Using slow chars\n"); } /* Save previous function pointers */ priv->crossblit = vis->opdraw->crossblit; /* Initialize function pointers */ vis->opdraw->getcharsize= GGI_m2164w_getcharsize; vis->opdraw->drawhline = GGI_m2164w_drawhline; vis->opdraw->drawvline = GGI_m2164w_drawvline; vis->opdraw->drawline = GGI_m2164w_drawline; vis->opdraw->drawbox = GGI_m2164w_drawbox; vis->opdraw->copybox = GGI_m2164w_copybox; vis->opdraw->fillscreen = GGI_m2164w_fillscreen; /* The crossblit in linear-* is faster on truecolor modes! */ if (GT_SCHEME(LIBGGI_GT(vis)) == GT_PALETTE || GT_SCHEME(LIBGGI_GT(vis)) == GT_STATIC_PALETTE) { vis->opdraw->crossblit = GGI_m2164w_crossblit; } FBDEV_PRIV(vis)->accelpriv = priv; /* Register cleanup handler */ ggRegisterCleanup((ggcleanup_func *)do_cleanup, vis); *dlret = GGI_DL_OPDRAW; return 0; }