ggi_accel_t *GGI_kgi_map_accelerator(ggi_visual_t vis, kgi_u_t resource, kgi_u_t min, kgi_u_t max, kgi_u_t buffers, kgi_u_t priority) { ggi_accel_t *accel; kgi_error_t err; err = kgiSetupMmapAccel(&KGI_CTX(vis), resource, min, max, buffers, priority); DPRINT("setup err: %d\n", err); if (err != KGI_EOK) return NULL; accel = malloc(sizeof(ggi_accel_t)); if (! accel) return NULL; accel->u32.current = 0; accel->u32.buffer = mmap(0, (0x1000 << max) * buffers, PROT_READ | PROT_WRITE, MAP_SHARED, KGI_CTX(vis).mapper.fd, 0); DPRINT("mmap buffer: %d\n", accel->u32.buffer); if (accel->u32.buffer == MAP_FAILED) { free(accel); return NULL; } return accel; }
int GGI_kgi_setPalette(struct ggi_visual *vis, size_t start, size_t len, const ggi_color *colormap) { kgic_ilut_set_request_t ilut; size_t nocols = 1 << GT_DEPTH(LIBGGI_GT(vis)); APP_ASSERT(colormap != NULL, "GGI_kgi_setPalette() - colormap == NULL"); DPRINT_COLOR("display-kgi: SetPalVec(%d,%d)\n", start, len); if (start == (size_t)GGI_PALETTE_DONTCARE) { start = 0; } if ((start < 0) || (len < 0) || (start+len > nocols)) { return GGI_ENOSPACE; } memcpy(LIBGGI_PAL(vis)->clut.data, colormap, len*sizeof(ggi_color)); ilut.image = 0; ilut.resource = 0; ilut.lut = 0; ilut.idx = start; ilut.cnt = len; ilut.am = KGI_AM_COLORS; ilut.data = (kgi_u16_t *)KGI_PRIV(vis); for (start = 0; len > 0; start++, colormap++, len--) { ilut.data[start*3] = colormap->r; ilut.data[start*3 + 1] = colormap->g; ilut.data[start*3 + 2] = colormap->b; } if(kgiSetIlut(&KGI_CTX(vis), &ilut) != KGI_EOK) { DPRINT_COLOR("display-kgi: PUTCMAP failed."); return -1; } return 0; }