void VoodooDispatcher::ProcessMessages( VoodooMessageHeader *first, size_t total_length ) { D_DEBUG_AT( Voodoo_Dispatcher, "VoodooDispatcher::%s( %p, first %p, total_length "_ZU" )\n", __func__, this, first, total_length ); D_MAGIC_ASSERT( this, VoodooDispatcher ); VoodooMessageHeader *header = first; size_t offset = 0; size_t aligned; while (offset < total_length) { /* Get the message header. */ header = (VoodooMessageHeader *)((char*) first + offset); aligned = VOODOO_MSG_ALIGN( header->size ); D_DEBUG_AT( Voodoo_Dispatcher, " -> Next message has %d ("_ZU") bytes and is of type %d... (offset "_ZU"/"_ZU")\n", header->size, aligned, header->type, offset, total_length ); D_ASSERT( header->size >= (int) sizeof(VoodooMessageHeader) ); D_ASSERT( header->size <= MAX_MSG_SIZE ); D_ASSERT( offset + aligned <= total_length ); switch (header->type) { case VMSG_SUPER: manager->handle_super( (VoodooSuperMessage*) header ); break; case VMSG_REQUEST: manager->handle_request( (VoodooRequestMessage*) header ); break; case VMSG_RESPONSE: manager->handle_response( (VoodooResponseMessage*) header ); break; case VMSG_DISCOVER: manager->handle_discover( header ); break; case VMSG_SENDINFO: // should only be received by TCP fake player, not manager D_BUG( "received SENDINFO" ); break; default: D_BUG( "invalid message type %d", header->type ); break; } offset += aligned; } D_ASSERT( offset == total_length ); }
static void sdlSetState( void *drv, void *dev, GraphicsDeviceFuncs *funcs, CardState *state, DFBAccelerationMask accel ) { SDLDeviceData *sdev = (SDLDeviceData*) dev; sdev->dest = state->dst.handle; sdev->source = state->src.handle; if (state->mod_hw & (SMF_SOURCE | SMF_BLITTING_FLAGS | SMF_SRC_COLORKEY)) sdev->key_valid = false; if (state->mod_hw & (SMF_DESTINATION | SMF_COLOR)) sdev->color_valid = false; switch (accel) { case DFXL_FILLRECTANGLE: if (!sdev->color_valid) { switch (state->destination->config.format) { case DSPF_RGB16: case DSPF_RGB32: sdev->color = dfb_color_to_pixel( state->destination->config.format, state->color.r, state->color.g, state->color.b ); break; default: D_BUG( "unexpected format" ); } sdev->color_valid = true; } state->set |= SDL_DRAWING_FUNCTIONS; break; case DFXL_BLIT: if (!sdev->key_valid) { SDL_SetColorKey( sdev->source, (state->blittingflags & DSBLIT_SRC_COLORKEY) ? SDL_SRCCOLORKEY : 0, state->src_colorkey | 0xff000000 ); sdev->key_valid = true; } state->set |= SDL_BLITTING_FUNCTIONS; break; default: D_BUG("unexpected acceleration" ); break; } state->mod_hw = 0; }
/* * Open the device, fill out information about it, * allocate and fill private data, start input thread. * Called during initialization, resuming or taking over mastership. */ static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { InputHubDeviceNode *node; D_DEBUG_AT( Input_Hub, "%s( ID %u )\n", __FUNCTION__, number ); node = direct_hash_lookup( m_nodes, number ); if (!node) { D_BUG( "did not find device (ID %u)", number ); return DFB_BUG; } info->prefered_id = number; info->desc = node->description; node->device = device; *driver_data = (void*)(long) (number + 1); return DFB_OK; }
/* * Called by vmwareSetState() to ensure that the color register is properly set * for execution of rendering functions. */ static inline void vmware_validate_COLOR( VMWareDeviceData *vdev, CardState *state ) { switch (vdev->dst_format) { case DSPF_ARGB: vdev->color_pixel = PIXEL_ARGB( state->color.a, state->color.r, state->color.g, state->color.b ); break; case DSPF_RGB32: vdev->color_pixel = PIXEL_RGB32( state->color.r, state->color.g, state->color.b ); break; case DSPF_RGB16: vdev->color_pixel = PIXEL_RGB16( state->color.r, state->color.g, state->color.b ); break; default: D_BUG( "unexpected format %s", dfb_pixelformat_name(vdev->dst_format) ); } /* Set the flag. */ VMWARE_VALIDATE( COLOR ); }
static inline void i810_set_color(I810DriverData *i810drv, I810DeviceData *i810dev, CardState *state) { if (i810dev->i_color) return; switch (state->destination->config.format) { case DSPF_LUT8: i810dev->color_value = state->color_index; break; case DSPF_ARGB1555: i810dev->color_value = PIXEL_ARGB1555(state->color.a, state->color.r, state->color.g, state->color.b); break; case DSPF_RGB16: i810dev->color_value = PIXEL_RGB16(state->color.r, state->color.g, state->color.b); break; case DSPF_RGB24: i810dev->color_value = PIXEL_RGB32(state->color.r, state->color.g, state->color.b); break; default: D_BUG("unexpected pixelformat~"); } i810dev->i_color = 1; }
static inline void i810_set_dest(I810DriverData *i810drv, I810DeviceData *i810dev, CardState *state) { CoreSurface *destination = state->destination; if (i810dev->i_dst) return; i810dev->destaddr = dfb_gfxcard_memory_physical((CoreGraphicsDevice *) i810dev, state->dst.offset); i810dev->destpitch = state->dst.pitch; switch (destination->config.format) { case DSPF_LUT8: i810dev->pixeldepth = 1; i810dev->blit_color = BPP8; break; case DSPF_ARGB1555: i810dev->pixeldepth = 2; i810dev->blit_color = BPP16; break; case DSPF_RGB16: i810dev->pixeldepth = 2; i810dev->blit_color = BPP16; break; case DSPF_RGB24: i810dev->pixeldepth = 3; i810dev->blit_color = BPP24; break; default: D_BUG("unexpected pixelformat~"); } i810dev->i_dst = 1; }
/* * Called by pvr2dSetState() to ensure that the source parameters are properly * set for execution of blitting functions. gdev->prog_index must be valid. */ static inline void pvr2d_validate_SOURCE(PVR2DDriverData *gdrv, PVR2DDeviceData *gdev, CardState *state) { D_DEBUG_AT(PVR2D__2D, "%s( format 0x%08x )\n", __FUNCTION__, state->source->config.format); gdrv->bltinfo.pSrcMemInfo = state->src.handle; gdrv->bltinfo.SrcOffset = 0; gdrv->bltinfo.SrcStride = state->src.pitch; gdrv->bltinfo.SrcSurfWidth = state->source->config.size.w; gdrv->bltinfo.SrcSurfHeight = state->source->config.size.h; switch (state->source->config.format) { case DSPF_A8: gdrv->bltinfo.SrcFormat = PVR2D_ALPHA8; break; case DSPF_ARGB: case DSPF_RGB32: gdrv->bltinfo.SrcFormat = PVR2D_ARGB8888; break; case DSPF_RGB16: gdrv->bltinfo.SrcFormat = PVR2D_RGB565; break; default: D_BUG( "unexpected pixelformat %d", state->source->config.format ); } // Set the flag. PVR2D_VALIDATE(SOURCE); }
void dfb_state_set_rop_pattern( CardState *state, const u32 *pattern, DFBSurfacePatternMode pattern_mode ) { D_MAGIC_ASSERT( state, CardState ); D_ASSERT( pattern != NULL ); switch (pattern_mode) { case DSPM_8_8_MONO: if (state->rop_pattern_mode != pattern_mode || memcmp( state->rop_pattern, pattern, sizeof(u32) * 8*8/32 )) { direct_memcpy( state->rop_pattern, pattern, sizeof(u32) * 8*8/32 ); state->rop_pattern_mode = pattern_mode; state->modified |= SMF_ROP_PATTERN; } break; case DSPM_32_32_MONO: if (state->rop_pattern_mode != pattern_mode || memcmp( state->rop_pattern, pattern, sizeof(u32) * 32*32/32 )) { direct_memcpy( state->rop_pattern, pattern, sizeof(u32) * 32*32/32 ); state->rop_pattern_mode = pattern_mode; state->modified |= SMF_ROP_PATTERN; } break; default: D_BUG( "unknown pattern mode %d", pattern_mode ); } }
static inline void ep9x_set_destination( EP9XDriverData *ep9xdrv, EP9XDeviceData *ep9xdev, CardState *state ) { CoreSurfaceBuffer *buffer = state->dst.buffer; if (ep9xdev->smf_destination) return; ep9xdev->destaddr = state->dst.offset; ep9xdev->destpitch = state->dst.pitch; switch (buffer->format) { case DSPF_RGB16: ep9xdev->pixeldepth = 2; ep9xdev->pixelformat = DSPF_RGB16; break; case DSPF_RGB24: ep9xdev->pixeldepth = 3; ep9xdev->pixelformat = DSPF_RGB24; break; case DSPF_RGB32: ep9xdev->pixeldepth = 3; ep9xdev->pixelformat = DSPF_RGB32; break; default: D_BUG("unexpected pixelformat~"); } ep9xdev->smf_destination = 1; }
static inline int i810_wait_for_space(I810DriverData *i810drv, I810DeviceData *i810dev, u32 space ) { u32 head, count = TIMER_LOOP, tail, tries = 0; i810dev->waitfifo_calls++; tail = i810dev->cur_tail; space += BUFFER_PADDING; space <<= 2; i810dev->waitfifo_sum += space; while (count--) { i810dev->fifo_waitcycles++; head = i810_readl(i810drv->mmio_base, LRING + 4) & RBUFFER_HEAD_MASK; if ((tail == head) || (tail > head && (RINGBUFFER_SIZE - tail + head) >= space) || (tail < head && (head - tail) >= space)) { if (!tries) i810dev->fifo_cache_hits++; return 0; } tries++; } D_BUG("warning: buffer space timout error"); return 1; }
DirectResult fusion_ref_watch (FusionRef *ref, FusionCall *call, int call_arg) { DirectResult ret; D_ASSERT( ref != NULL ); D_ASSERT( call != NULL ); ret = fusion_skirmish_prevail( &ref->multi.builtin.lock ); if (ret) return ret; if (ref->multi.builtin.local+ref->multi.builtin.global == 0) { D_BUG( "ref has no references" ); ret = DR_BUG; } else if (ref->multi.builtin.call) { ret = DR_BUSY; } else { ref->multi.builtin.call = call; ref->multi.builtin.call_arg = call_arg; fusion_skirmish_notify( &ref->multi.builtin.lock ); } fusion_skirmish_dismiss( &ref->multi.builtin.lock ); return ret; }
/** * fusion_hash_insert: * @hash: a #FusionHash. * @key: a key to insert. * @value: the value to associate with the key. * * Inserts a new key and value into a #FusionHash. * If the key already exists in the #FusionHash DFB_BUG is returned * If you think a key may exist you should call fusion_hash_replace * Generally this is only used on a new FusionHash **/ DirectResult fusion_hash_insert( FusionHash *hash, void *key, void *value ) { FusionHashNode **node; D_MAGIC_ASSERT( hash, FusionHash ); node = fusion_hash_lookup_node (hash, key); if (*node) { D_BUG( "key already exists" ); return DFB_BUG; } else { if (hash->local) (*node) = D_CALLOC(1,sizeof(FusionHashNode)); else (*node) = SHCALLOC(hash->pool, 1, sizeof(FusionHashNode)); if ( !(*node) ) return hash->local?DFB_NOSYSTEMMEMORY:DFB_NOSHAREDMEMORY; (*node)->key = key; (*node)->value = value; hash->nnodes++; if ( fusion_hash_should_resize(hash) ) fusion_hash_resize(hash); } return DFB_OK; }
void mach64_set_destination( Mach64DriverData *mdrv, Mach64DeviceData *mdev, CardState *state ) { volatile u8 *mmio = mdrv->mmio_base; CoreSurface *destination = state->destination; unsigned int pitch = state->dst.pitch / DFB_BYTES_PER_PIXEL( destination->config.format ); mdev->pix_width &= ~DST_PIX_WIDTH; switch (destination->config.format) { case DSPF_RGB332: mdev->pix_width |= DST_PIX_WIDTH_8BPP; break; case DSPF_RGB555: case DSPF_ARGB1555: mdev->pix_width |= DST_PIX_WIDTH_15BPP; break; case DSPF_RGB16: mdev->pix_width |= DST_PIX_WIDTH_16BPP; break; case DSPF_RGB32: case DSPF_ARGB: mdev->pix_width |= DST_PIX_WIDTH_32BPP; break; default: D_BUG( "unexpected pixelformat!" ); return; } mach64_waitfifo( mdrv, mdev, 1 ); mach64_out32( mmio, DST_OFF_PITCH, (state->dst.offset/8) | ((pitch/8) << 22) ); }
static void CoreInputHubClient_Dispatch( void *context, const OnePacketHeader *header, void *data, OneThread *thread ) { CoreInputHubClient *client = context; const InputHubNotification *notification = data; D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ ); switch (notification->type) { case IHNT_DEVICE_ADD: CoreInputHubClient_Dispatch_DeviceAdd( client, notification ); break; case IHNT_DEVICE_REMOVE: CoreInputHubClient_Dispatch_DeviceRemove( client, notification ); break; case IHNT_EVENT_DISPATCH: CoreInputHubClient_Dispatch_EventDispatch( client, notification ); break; default: D_BUG( "unknown notification type %d", notification->type ); } }
/* * Called by pvr2dSetState() to ensure that the destination parameters are * properly set for execution of rendering functions. gdev->prog_index * must be valid. */ static inline void pvr2d_validate_DESTINATION(PVR2DDriverData *gdrv, PVR2DDeviceData *gdev, CardState *state) { D_DEBUG_AT(PVR2D__2D, "%s( format 0x%08x )\n", __FUNCTION__, state->destination->config.format); gdrv->bltinfo.pDstMemInfo = state->dst.handle; gdrv->bltinfo.DstOffset = 0; gdrv->bltinfo.DstStride = state->dst.pitch; gdrv->bltinfo.DstSurfWidth = state->destination->config.size.w; gdrv->bltinfo.DstSurfHeight = state->destination->config.size.h; switch (state->destination->config.format) { case DSPF_ARGB: case DSPF_RGB32: gdrv->bltinfo.DstFormat = PVR2D_ARGB8888; break; case DSPF_RGB16: gdrv->bltinfo.DstFormat = PVR2D_RGB565; break; default: D_BUG( "unexpected pixelformat %d", state->destination->config.format ); } // Set the flag. PVR2D_VALIDATE(DESTINATION); }
FusionCallHandlerResult dfb_rtd_call_handler( int caller, int call_arg, void *call_ptr, void *ctx, unsigned int serial, int *ret_val ) { switch (call_arg) { case RTD_SET_VIDEO_MODE: *ret_val = dfb_rtd_set_video_mode_handler( call_ptr ); break; case RTD_UPDATE_SCREEN: *ret_val = dfb_rtd_update_screen_handler( call_ptr ); break; case RTD_SET_PALETTE: *ret_val = dfb_rtd_set_palette_handler( call_ptr ); break; default: D_BUG( "unknown call" ); *ret_val = DFB_BUG; break; } return FCHR_RETURN; }
static inline void i830_wait_for_blit_idle( I830DriverData *idrv, I830DeviceData *idev ) { u32 count = 0; u32 head , tail; if (idev != NULL) idev->idle_calls++; head = i830_readl(idrv->mmio_base, LP_RING + RING_HEAD) & I830_HEAD_MASK; tail = i830_readl(idrv->mmio_base, LP_RING + RING_TAIL) & I830_TAIL_MASK; while ((head != tail) && (count++ < TIMER_LOOP)) { if (idev != NULL) idev->idle_waitcycles++; head = i830_readl(idrv->mmio_base, LP_RING + RING_HEAD) & I830_HEAD_MASK; tail = i830_readl(idrv->mmio_base, LP_RING + RING_TAIL) & I830_TAIL_MASK; } if (count >= TIMER_LOOP) { if (idev != NULL) idev->idle_timeoutsum++; D_BUG("warning: idle timeout exceeded"); } }
DirectResult _fusion_ref_change (FusionRef *ref, int add, bool global) { DirectResult ret; D_ASSERT( ref != NULL ); D_ASSERT( add != 0 ); ret = fusion_skirmish_prevail( &ref->multi.builtin.lock ); if (ret) return ret; if (global) { if (ref->multi.builtin.global+add < 0) { D_BUG( "ref has no global references" ); fusion_skirmish_dismiss( &ref->multi.builtin.lock ); return DR_BUG; } ref->multi.builtin.global += add; } else { if (ref->multi.builtin.local+add < 0) { D_BUG( "ref has no local references" ); fusion_skirmish_dismiss( &ref->multi.builtin.lock ); return DR_BUG; } ref->multi.builtin.local += add; _fusion_add_local( _fusion_world(ref->multi.shared), ref, add ); } if (ref->multi.builtin.local+ref->multi.builtin.global == 0) { fusion_skirmish_notify( &ref->multi.builtin.lock ); if (ref->multi.builtin.call) { fusion_skirmish_dismiss( &ref->multi.builtin.lock ); return fusion_call_execute( ref->multi.builtin.call, FCEF_ONEWAY, ref->multi.builtin.call_arg, NULL, NULL ); } } fusion_skirmish_dismiss( &ref->multi.builtin.lock ); return DR_OK; }
static Chunk* free_chunk( SurfaceManager *manager, Chunk *chunk ) { D_MAGIC_ASSERT( manager, SurfaceManager ); D_MAGIC_ASSERT( chunk, _Chunk_ ); if (!chunk->buffer) { D_BUG( "freeing free chunk" ); return chunk; } else { D_DEBUG_AT( Core_SM, "Deallocating %d bytes at offset %d.\n", chunk->length, chunk->offset ); } if (chunk->buffer->policy == CSP_VIDEOONLY) manager->available += chunk->length; chunk->buffer = NULL; manager->min_toleration--; if (chunk->prev && !chunk->prev->buffer) { Chunk *prev = chunk->prev; //D_DEBUG_AT( Core_SM, " -> merging with previous chunk at %d\n", prev->offset ); prev->length += chunk->length; prev->next = chunk->next; if (prev->next) prev->next->prev = prev; //D_DEBUG_AT( Core_SM, " -> freeing %p (prev %p, next %p)\n", chunk, chunk->prev, chunk->next); D_MAGIC_CLEAR( chunk ); SHFREE( chunk ); chunk = prev; } if (chunk->next && !chunk->next->buffer) { Chunk *next = chunk->next; //D_DEBUG_AT( Core_SM, " -> merging with next chunk at %d\n", next->offset ); chunk->length += next->length; chunk->next = next->next; if (chunk->next) chunk->next->prev = chunk; D_MAGIC_CLEAR( next ); SHFREE( next ); } return chunk; }
static void savage4SetState( void *drv, void *dev, GraphicsDeviceFuncs *funcs, CardState *state, DFBAccelerationMask accel ) { Savage4DriverData *sdrv = (Savage4DriverData*) drv; Savage4DeviceData *sdev = (Savage4DeviceData*) dev; SVGDBG("savage4setstate\n"); if (state->mod_hw) { if (state->mod_hw & SMF_DESTINATION) sdev->v_gbd = sdev->v_color = 0; else if (state->mod_hw & SMF_COLOR) sdev->v_color = 0; if (state->mod_hw & SMF_SOURCE) sdev->v_pbd = 0; } savage4_validate_gbd( sdrv, sdev, state ); switch (accel) { case DFXL_FILLRECTANGLE: case DFXL_DRAWRECTANGLE: case DFXL_DRAWLINE: case DFXL_FILLTRIANGLE: savage4_validate_color( sdev, state ); state->set |= SAVAGE4_DRAWING_FUNCTIONS; break; case DFXL_BLIT: case DFXL_STRETCHBLIT: savage4_validate_pbd( sdrv, sdev, state ); state->set |= SAVAGE4_BLITTING_FUNCTIONS; break; default: D_BUG( "unexpected drawing/blitting function!" ); return; } if (state->mod_hw & SMF_BLITTING_FLAGS) { if (state->blittingflags & DSBLIT_SRC_COLORKEY) sdev->Cmd_Src_Transparent = BCI_CMD_SRC_TRANSPARENT | BCI_CMD_SEND_COLOR; else sdev->Cmd_Src_Transparent = 0; } if (state->mod_hw & SMF_CLIP) savage4_set_clip( sdrv, sdev, &state->clip ); if (state->mod_hw & SMF_SRC_COLORKEY) sdev->src_colorkey = state->src_colorkey; state->mod_hw = 0; }
DirectResult direct_map_insert( DirectMap *map, const void *key, void *object ) { unsigned int hash; int pos; MapEntry *entry; D_DEBUG_AT( Direct_Map, "%s( key %p, object %p )\n", __func__, key, object ); DIRECT_MAP_ASSERT( map ); D_ASSERT( key != NULL ); D_ASSERT( object != NULL ); /* Need to resize the map? */ if ((map->count + map->removed) > map->size / 4) resize_map( map, map->size * 3 ); hash = map->hash( map, key, map->ctx ); pos = hash % map->size; D_DEBUG_AT( Direct_Map, " -> hash %u, pos %d\n", hash, pos ); entry = &map->entries[pos]; while (entry->object && entry->object != REMOVED) { if (entry->hash == hash && map->compare( map, key, entry->object, map->ctx )) { if (entry->object == object) { D_DEBUG_AT( Direct_Map, " -> same object with matching key already exists\n" ); return DR_BUSY; } else { D_DEBUG_AT( Direct_Map, " -> different object with matching key already exists\n" ); D_BUG( "different object with matching key already exists" ); return DR_BUG; } } if (++pos == map->size) pos = 0; entry = &map->entries[pos]; } if (entry->object == REMOVED) map->removed--; entry->hash = hash; entry->object = object; map->count++; D_DEBUG_AT( Direct_Map, " -> new count = %d, removed = %d, size = %d\n", map->count, map->removed, map->size ); return DR_OK; }
static DFBResult x11DeallocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { x11AllocationData *alloc = alloc_data; x11PoolLocalData *local = pool_local; DFBX11 *x11 = local->x11; DFBX11Shared *shared = x11->shared; void *addr; D_DEBUG_AT( X11_Surfaces, "%s()\n", __FUNCTION__ ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); CORE_SURFACE_ALLOCATION_ASSERT( allocation ); switch (alloc->type) { case X11_ALLOC_PIXMAP: case X11_ALLOC_WINDOW: if (allocation->type & CSTF_PREALLOCATED) { // don't delete } else XFreePixmap( x11->display, alloc->xid ); break; case X11_ALLOC_IMAGE: x11ImageDestroy( x11, &alloc->image ); // FIXME: also detach in other processes! (e.g. via reactor) addr = direct_hash_lookup( local->hash, alloc->image.seginfo.shmid ); if (addr) { x11ImageDetach( &alloc->image, addr ); direct_hash_remove( local->hash, alloc->image.seginfo.shmid ); } break; case X11_ALLOC_SHM: if (alloc->ptr) SHFREE( shared->data_shmpool, alloc->ptr ); break; default: D_BUG( "unexpected allocation type %d\n", alloc->type ); return DFB_BUG; } return DFB_OK; }
gfxDirectFBSurface::gfxDirectFBSurface(const gfxIntSize& size, gfxImageFormat format) : mDFB(nsnull), mDFBSurface(nsnull) { DFBResult ret; DFBSurfaceDescription desc; if (!CheckSurfaceSize(size) || size.width <= 0 || size.height <= 0) return; /* Lightweight, getting singleton */ ret = DirectFBCreate( &mDFB ); if (ret) { D_DERROR( (DirectResult) ret, "gfxDirectFBSurface: DirectFBCreate() failed!\n" ); return; } desc.flags = (DFBSurfaceDescriptionFlags)( DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT ); desc.width = size.width; desc.height = size.height; switch (format) { case gfxASurface::ImageFormatARGB32: desc.pixelformat = DSPF_ARGB; break; case gfxASurface::ImageFormatRGB24: desc.pixelformat = DSPF_RGB32; break; case gfxASurface::ImageFormatA8: desc.pixelformat = DSPF_A8; break; case gfxASurface::ImageFormatA1: desc.pixelformat = DSPF_A1; break; default: D_BUG( "unknown format" ); return; } ret = mDFB->CreateSurface( mDFB, &desc, &mDFBSurface ); if (ret) { D_DERROR( (DirectResult) ret, "gfxDirectFBSurface: " "IDirectFB::CreateSurface( %dx%d ) failed!\n", desc.width, desc.height ); return; } cairo_surface_t *surface = cairo_directfb_surface_create(mDFB, mDFBSurface); Init(surface); }
void _fusion_call_process( FusionWorld *world, int call_id, FusionCallMessage *msg ) { FusionCallHandler call_handler; FusionCallReturn call_ret; FusionCallHandlerResult result; D_DEBUG_AT( Fusion_Call, "%s()\n", __FUNCTION__ ); D_MAGIC_ASSERT( world, FusionWorld ); D_ASSERT( msg != NULL ); call_handler = msg->handler; D_ASSERT( call_handler != NULL ); D_DEBUG_AT( Fusion_Call, " -> %s\n", direct_trace_lookup_symbol_at( call_handler ) ); call_ret.val = 0; result = call_handler( msg->caller, msg->call_arg, msg->call_ptr, msg->ctx, msg->serial, &call_ret.val ); switch (result) { case FCHR_RETURN: if (msg->serial) { call_ret.serial = msg->serial; call_ret.call_id = call_id; while (ioctl (world->fusion_fd, FUSION_CALL_RETURN, &call_ret)) { switch (errno) { case EINTR: continue; case EIDRM: D_WARN( "caller withdrawn (signal?)" ); return; case EINVAL: D_ERROR( "Fusion/Call: invalid call\n" ); return; default: D_PERROR( "FUSION_CALL_RETURN" ); return; } } } break; case FCHR_RETAIN: break; default: D_BUG( "unknown result %d from call handler", result ); } }
static void i830SetState( void *drv, void *dev, GraphicsDeviceFuncs *funcs, CardState *state, DFBAccelerationMask accel ) { switch (accel) { default: D_BUG("unexpected drawing/blitting function"); } state->mod_hw = 0; }
DFBResult dfb_core_part_initialize( CoreDFB *core, CorePart *core_part ) { DFBResult ret; void *local = NULL; void *shared = NULL; FusionSHMPoolShared *pool; pool = dfb_core_shmpool( core ); if (core_part->initialized) { D_BUG( "%s already initialized", core_part->name ); return DFB_BUG; } D_DEBUG_AT( Core_Parts, "Going to initialize '%s' core...\n", core_part->name ); if (core_part->size_local) local = D_CALLOC( 1, core_part->size_local ); if (core_part->size_shared) shared = SHCALLOC( pool, 1, core_part->size_shared ); D_INFO("Going to initialize '%s' core...\n", core_part->name ); ret = core_part->Initialize( core, local, shared ); D_INFO("Core '%s' initialized ...\n", core_part->name ); if (ret) { D_ERROR( "DirectFB/Core: Could not initialize '%s' core!\n" " --> %s\n", core_part->name, DirectFBErrorString( ret ) ); if (shared) SHFREE( pool, shared ); if (local) D_FREE( local ); return ret; } if (shared) fusion_arena_add_shared_field( dfb_core_arena( core ), core_part->name, shared ); core_part->data_local = local; core_part->data_shared = shared; core_part->initialized = true; return DFB_OK; }
static void call_handlers( int num, void *addr ) { DirectLink *l, *n; if (num == SIG_DUMP_STACK) num = DIRECT_SIGNAL_DUMP_STACK; /* Loop through all handlers. */ direct_mutex_lock( &handlers_lock ); direct_list_foreach_safe (l, n, handlers) { DirectSignalHandler *handler = (DirectSignalHandler*) l; if (handler->removed) { direct_list_remove( &handlers, &handler->link ); D_MAGIC_CLEAR( handler ); D_FREE( handler ); continue; } D_LOG( Direct_Signals, FATAL, " --> %d\n", handler->num ); if (handler->num != num && handler->num != DIRECT_SIGNAL_ANY) continue; if (handler->num == DIRECT_SIGNAL_ANY && num == DIRECT_SIGNAL_DUMP_STACK) continue; switch (handler->func( num, addr, handler->ctx )) { case DSHR_OK: break; case DSHR_REMOVE: direct_list_remove( &handlers, &handler->link ); D_MAGIC_CLEAR( handler ); D_FREE( handler ); break; case DSHR_RESUME: D_LOG( Direct_Signals, FATAL, " '-> cured!\n" ); direct_mutex_unlock( &handlers_lock ); return; default: D_BUG( "unknown result" ); break; } }
static void neo2200SetState( void *drv, void *dev, GraphicsDeviceFuncs *funcs, CardState *state, DFBAccelerationMask accel ) { Neo2200DriverData *ndrv = (Neo2200DriverData*) drv; Neo2200DeviceData *ndev = (Neo2200DeviceData*) dev; if (state->mod_hw & SMF_DESTINATION) ndev->n_fgColor = ndev->n_bltMode_dst = 0; else if (state->mod_hw & SMF_COLOR) ndev->n_fgColor = 0; if (state->mod_hw & SMF_SOURCE) ndev->n_src = 0; if (state->mod_hw & SMF_SRC_COLORKEY) ndev->n_xpColor = 0; neo2200_validate_bltMode_dst( ndrv, ndev, state->destination, &state->dst ); switch (accel) { case DFXL_BLIT: neo2200_validate_src( ndrv, ndev, state->source, &state->src ); ndev->src_dst_equal = (state->src.buffer == state->dst.buffer); if (state->blittingflags & DSBLIT_SRC_COLORKEY) { ndev->bltCntl = NEO_BC0_SRC_TRANS; neo2200_validate_xpColor( ndrv, ndev, state ); } else ndev->bltCntl = 0; state->set |= DFXL_BLIT; break; case DFXL_FILLRECTANGLE: case DFXL_DRAWRECTANGLE: neo2200_validate_fgColor( ndrv, ndev, state ); state->set |= DFXL_FILLRECTANGLE | DFXL_DRAWRECTANGLE; break; default: D_BUG( "unexpected drawing/blitting function!" ); break; } state->mod_hw = 0; }
static void * vt_thread( DirectThread *thread, void *arg ) { D_DEBUG_AT( VT, "%s( %p, %p )\n", __FUNCTION__, thread, arg ); pthread_mutex_lock( &dfb_vt->lock ); while (true) { direct_thread_testcancel( thread ); D_DEBUG_AT( VT, "...%s (signal %d)\n", __FUNCTION__, dfb_vt->vt_sig); switch (dfb_vt->vt_sig) { default: D_BUG( "unexpected vt_sig" ); /* fall through */ case -1: pthread_cond_wait( &dfb_vt->wait, &dfb_vt->lock ); continue; case SIG_SWITCH_FROM: if (dfb_core_suspend( dfb_fbdev->core ) == DFB_OK) { if (ioctl( dfb_vt->fd, VT_RELDISP, VT_ACKACQ ) < 0) D_PERROR( "DirectFB/fbdev/vt: VT_RELDISP failed\n" ); } break; case SIG_SWITCH_TO: if (dfb_core_resume( dfb_fbdev->core ) == DFB_OK) { if (ioctl( dfb_vt->fd, VT_RELDISP, VT_ACKACQ ) < 0) D_PERROR( "DirectFB/fbdev/vt: VT_RELDISP failed\n" ); if (dfb_config->kd_graphics) { if (ioctl( dfb_vt->fd, KDSETMODE, KD_GRAPHICS ) < 0) D_PERROR( "DirectFB/fbdev/vt: KD_GRAPHICS failed!\n" ); } } break; } dfb_vt->vt_sig = -1; pthread_cond_signal( &dfb_vt->wait ); } return NULL; }
static void i810SetState( void *drv, void *dev, GraphicsDeviceFuncs *funcs, CardState *state, DFBAccelerationMask accel ) { I810DriverData *i810drv = (I810DriverData *) drv; I810DeviceData *i810dev = (I810DeviceData *) dev; if (state->mod_hw) { if ((state->mod_hw & SMF_SOURCE) && state->source) i810dev->i_src = 0; if (state->mod_hw & SMF_DESTINATION) i810dev->i_dst = 0; if (state->mod_hw & SMF_COLOR) i810dev->i_color = 0; if (state->mod_hw & SMF_CLIP) i810dev->i_clip = 0; if (state->mod_hw & SMF_SRC_COLORKEY || state->mod_hw & SMF_DST_COLORKEY) { i810dev->i_colorkey = 0; } } switch (accel) { case DFXL_DRAWRECTANGLE: case DFXL_FILLRECTANGLE: case DFXL_FILLTRIANGLE: i810_set_dest(i810drv, i810dev, state); i810_set_color(i810drv, i810dev, state); i810_set_clip(i810drv, i810dev, &state->clip); state->set |= DFXL_FILLRECTANGLE | DFXL_DRAWRECTANGLE; break; case DFXL_BLIT: i810_set_src( i810drv, i810dev, state); i810_set_dest(i810drv, i810dev, state); i810_set_color(i810drv, i810dev, state); i810_set_clip(i810drv, i810dev, &state->clip); if (state->blittingflags & DSBLIT_SRC_COLORKEY || state->blittingflags & DSBLIT_DST_COLORKEY) i810_set_colorkey(i810drv, i810dev, state); state->set |= DFXL_BLIT; break; default: D_BUG("unexpected drawing/blitting function"); } state->mod_hw = 0; }