static DFBResult stmfbdevTestConfig (CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, const CoreSurfaceConfig *config) { CoreSurface *surface; STMfbdevPoolData * const data = pool_data; STMfbdevPoolLocalData * const local = pool_local; DFBResult ret; D_DEBUG_AT (STMfbdev_Surfaces, "%s (%p)\n", __FUNCTION__, buffer); D_MAGIC_ASSERT (pool, CoreSurfacePool); D_MAGIC_ASSERT (data, STMfbdevPoolData); D_MAGIC_ASSERT (local, STMfbdevPoolLocalData); D_MAGIC_ASSERT (buffer, CoreSurfaceBuffer); D_ASSERT (config != NULL); surface = buffer->surface; D_MAGIC_ASSERT (surface, CoreSurface); D_DEBUG_AT (STMfbdev_Surfaces, " -> buffer/type/id %p/0x%x/%lu\n", buffer, surface->type, surface->resource_id); ret = dfb_surfacemanager_allocate (local->core, data->manager, buffer, NULL, NULL); D_DEBUG_AT (STMfbdev_Surfaces, " -> %s\n", DirectFBErrorString (ret)); return ret; }
static DFBResult fbdevTestConfig( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, const CoreSurfaceConfig *config ) { DFBResult ret; CoreSurface *surface; FBDevPoolData *data = pool_data; FBDevPoolLocalData *local = pool_local; D_DEBUG_AT( FBDev_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, FBDevPoolData ); D_MAGIC_ASSERT( local, FBDevPoolLocalData ); D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); surface = buffer->surface; D_MAGIC_ASSERT( surface, CoreSurface ); if (surface->type & CSTF_LAYER) return DFB_OK; ret = dfb_surfacemanager_allocate( local->core, data->manager, buffer, NULL, NULL ); D_DEBUG_AT( FBDev_Surfaces, " -> %s\n", DirectFBErrorString(ret) ); return ret; }
static DFBResult devmemAllocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { DFBResult ret; Chunk *chunk; CoreSurface *surface; DevMemPoolData *data = pool_data; DevMemPoolLocalData *local = pool_local; DevMemAllocationData *alloc = alloc_data; (void)surface; D_DEBUG_AT( DevMem_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, DevMemPoolData ); D_MAGIC_ASSERT( local, DevMemPoolLocalData ); D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); surface = buffer->surface; D_MAGIC_ASSERT( surface, CoreSurface ); ret = dfb_surfacemanager_allocate( local->core, data->manager, buffer, allocation, &chunk ); if (ret) return ret; D_MAGIC_ASSERT( chunk, Chunk ); alloc->offset = chunk->offset; alloc->pitch = chunk->pitch; alloc->size = chunk->length; alloc->chunk = chunk; D_DEBUG_AT( DevMem_Surfaces, " -> offset %d, pitch %d, size %d\n", alloc->offset, alloc->pitch, alloc->size ); allocation->size = alloc->size; allocation->offset = alloc->offset; D_MAGIC_SET( alloc, DevMemAllocationData ); return DFB_OK; }
static DFBResult fbdevAllocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { DFBResult ret; CoreSurface *surface; FBDevPoolData *data = pool_data; FBDevPoolLocalData *local = pool_local; FBDevAllocationData *alloc = alloc_data; D_DEBUG_AT( FBDev_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, FBDevPoolData ); D_MAGIC_ASSERT( local, FBDevPoolLocalData ); D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); surface = buffer->surface; D_MAGIC_ASSERT( surface, CoreSurface ); if (surface->type & CSTF_LAYER && surface->resource_id == DLID_PRIMARY) { D_DEBUG_AT( FBDev_Surfaces, " -> primary layer buffer (index %d)\n", dfb_surface_buffer_index( buffer ) ); dfb_surface_calc_buffer_size( surface, 8, 1, NULL, &allocation->size ); } else { ret = dfb_surfacemanager_allocate( local->core, data->manager, buffer, allocation, &alloc->chunk ); if (ret) return ret; D_MAGIC_ASSERT( alloc->chunk, Chunk ); allocation->offset = alloc->chunk->offset; allocation->size = alloc->chunk->length; } D_MAGIC_SET( alloc, FBDevAllocationData ); return DFB_OK; }
static DFBResult fbdevAllocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { DFBResult ret; CoreSurface *surface; FBDevPoolData *data = pool_data; FBDevPoolLocalData *local = pool_local; FBDevAllocationData *alloc = alloc_data; D_DEBUG_AT( FBDev_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, FBDevPoolData ); D_MAGIC_ASSERT( local, FBDevPoolLocalData ); D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); surface = buffer->surface; D_MAGIC_ASSERT( surface, CoreSurface ); if ((surface->type & CSTF_LAYER) && surface->resource_id == DLID_PRIMARY) { FBDevShared *shared = dfb_fbdev->shared; int index = dfb_surface_buffer_index( buffer ); D_DEBUG_AT( FBDev_Surfaces, " -> primary layer buffer (index %d)\n", index ); if (( (surface->config.caps & DSCAPS_FLIPPING) && index == 1) || (!(surface->config.caps & DSCAPS_FLIPPING) && index == 0) ) { const VideoMode *highest; /* FIXME: this should use source.w/source.h from layer region config! */ unsigned int width = surface->config.size.w; unsigned int height = surface->config.size.h; D_INFO( "FBDev/Mode: Setting %dx%d %s\n", width, height, dfb_pixelformat_name(surface->config.format) ); highest = dfb_fbdev_find_mode( width, height ); if (!highest) return DFB_UNSUPPORTED; ret = dfb_fbdev_set_mode( highest, surface, 0, 0 ); if (ret) return ret; } alloc->pitch = shared->fix.line_length; alloc->size = surface->config.size.h * alloc->pitch; alloc->offset = index * alloc->size; D_INFO( "FBDev/Surface: Allocated %dx%d %d bit %s buffer (index %d) at offset %d and pitch %d.\n", surface->config.size.w, surface->config.size.h, shared->current_var.bits_per_pixel, dfb_pixelformat_name(buffer->format), index, alloc->offset, alloc->pitch ); } else { Chunk *chunk; ret = dfb_surfacemanager_allocate( local->core, data->manager, buffer, allocation, &chunk ); if (ret) return ret; D_MAGIC_ASSERT( chunk, Chunk ); alloc->offset = chunk->offset; alloc->pitch = chunk->pitch; alloc->size = chunk->length; alloc->chunk = chunk; } D_DEBUG_AT( FBDev_Surfaces, " -> offset %d, pitch %d, size %d\n", alloc->offset, alloc->pitch, alloc->size ); allocation->size = alloc->size; allocation->offset = alloc->offset; D_MAGIC_SET( alloc, FBDevAllocationData ); return DFB_OK; }
DFBResult dfb_surfacemanager_assure_video( SurfaceManager *manager, SurfaceBuffer *buffer ) { DFBResult ret; CoreSurface *surface = buffer->surface; D_MAGIC_ASSERT( manager, SurfaceManager ); if (manager->suspended) return DFB_NOVIDEOMEMORY; switch (buffer->video.health) { case CSH_STORED: if (buffer->video.chunk) buffer->video.chunk->tolerations = 0; return DFB_OK; case CSH_INVALID: ret = dfb_surfacemanager_allocate( manager, buffer ); if (ret) return ret; /* FALL THROUGH, because after successful allocation the surface health is CSH_RESTORE */ case CSH_RESTORE: if (buffer->system.health != CSH_STORED) D_BUG( "system/video instances both not stored!" ); if (buffer->flags & SBF_WRITTEN) { int i; char *src = buffer->system.addr; char *dst = dfb_system_video_memory_virtual( buffer->video.offset ); for (i=0; i<surface->height; i++) { direct_memcpy( dst, src, DFB_BYTES_PER_LINE(buffer->format, surface->width) ); src += buffer->system.pitch; dst += buffer->video.pitch; } if (buffer->format == DSPF_YV12 || buffer->format == DSPF_I420) { for (i=0; i<surface->height; i++) { direct_memcpy( dst, src, DFB_BYTES_PER_LINE(buffer->format, surface->width / 2) ); src += buffer->system.pitch / 2; dst += buffer->video.pitch / 2; } } else if (buffer->format == DSPF_NV12 || buffer->format == DSPF_NV21) { for (i=0; i<surface->height/2; i++) { direct_memcpy( dst, src, DFB_BYTES_PER_LINE(buffer->format, surface->width) ); src += buffer->system.pitch; dst += buffer->video.pitch; } } else if (buffer->format == DSPF_NV16) { for (i=0; i<surface->height; i++) { direct_memcpy( dst, src, DFB_BYTES_PER_LINE(buffer->format, surface->width) ); src += buffer->system.pitch; dst += buffer->video.pitch; } } } buffer->video.health = CSH_STORED; buffer->video.chunk->tolerations = 0; dfb_surface_notify_listeners( surface, CSNF_VIDEO ); return DFB_OK; default: break; } D_BUG( "unknown video instance health" ); return DFB_BUG; }
static DFBResult fbdevAllocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { DFBResult ret; CoreSurface *surface; FBDevPoolData *data = pool_data; FBDevPoolLocalData *local = pool_local; FBDevAllocationData *alloc = alloc_data; D_DEBUG_AT( FBDev_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, FBDevPoolData ); D_MAGIC_ASSERT( local, FBDevPoolLocalData ); D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); surface = buffer->surface; D_MAGIC_ASSERT( surface, CoreSurface ); if ((surface->type & CSTF_LAYER) && surface->resource_id == DLID_PRIMARY) { int i, index = dfb_surface_buffer_index( buffer ); /* HACK FIXME_SC_2 ALLOCATE/SETMODE TWIST */ for (i=0; i<surface->num_buffers; i++) { if (surface->buffers[i]->allocs.elements) break; } if (i == surface->num_buffers && dfb_fbdev->shared->test_mode) { ret = dfb_fbdev_set_mode( surface, dfb_fbdev->shared->test_mode, &dfb_fbdev->shared->test_config ); if (ret) return ret; dfb_fbdev->shared->test_mode = NULL; } /* /HACK FIXME_SC_2 ALLOCATE/SETMODE TWIST */ alloc->pitch = dfb_fbdev->shared->fix.line_length; alloc->size = surface->config.size.h * alloc->pitch; alloc->offset = index * alloc->size; D_INFO( "FBDev/Surface: Allocated %dx%d %dbit %s buffer at offset %d and pitch %d.\n", surface->config.size.w, surface->config.size.h, dfb_fbdev->shared->current_var.bits_per_pixel, dfb_pixelformat_name(buffer->format), alloc->offset, alloc->pitch ); } else { Chunk *chunk; ret = dfb_surfacemanager_allocate( local->core, data->manager, buffer, &chunk ); if (ret) return ret; D_MAGIC_ASSERT( chunk, Chunk ); alloc->offset = chunk->offset; alloc->pitch = chunk->pitch; alloc->size = chunk->length;// DFB_PLANE_MULTIPLY( buffer->format, surface->config.size.h ) * alloc->pitch; alloc->chunk = chunk; } D_DEBUG_AT( FBDev_Surfaces, " -> offset %d, pitch %d, size %d\n", alloc->offset, alloc->pitch, alloc->size ); allocation->size = alloc->size; allocation->offset = alloc->offset; D_MAGIC_SET( alloc, FBDevAllocationData ); return DFB_OK; }
static DFBResult stmfbdevAllocateBuffer (CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data) { CoreSurface *surface; STMfbdevPoolData * const data = pool_data; STMfbdevPoolLocalData * const local = pool_local; STMfbdevPoolAllocationData * const alloc = alloc_data; DFBResult ret; Chunk *chunk; D_DEBUG_AT (STMfbdev_Surfaces, "%s (%p)\n", __FUNCTION__, buffer); D_MAGIC_ASSERT (pool, CoreSurfacePool); D_MAGIC_ASSERT (data, STMfbdevPoolData); D_MAGIC_ASSERT (local, STMfbdevPoolLocalData); D_MAGIC_ASSERT (buffer, CoreSurfaceBuffer); D_MAGIC_ASSERT (allocation, CoreSurfaceAllocation); surface = buffer->surface; D_MAGIC_ASSERT (surface, CoreSurface); ret = dfb_surfacemanager_allocate (local->core, data->manager, buffer, allocation, &chunk); if (ret) return ret; D_MAGIC_ASSERT (chunk, Chunk); alloc->chunk = chunk; D_DEBUG_AT (STMfbdev_Surfaces, " -> offset 0x%.8x (%u), format: %s, pitch %d, size %d\n", chunk->offset, chunk->offset, dfb_pixelformat_name (buffer->format), chunk->pitch, chunk->length); allocation->size = chunk->length; allocation->offset = chunk->offset; #if STGFX_DRIVER == 2 if (unlikely (buffer->format == DSPF_RGB32)) { /* for RGB32, we need to set the alpha to 0xff */ STGFX2DriverData * const stdrv = dfb_gfxcard_get_driver_data (); STGFX2DeviceData * const stdev = dfb_gfxcard_get_device_data (); DFBRectangle rect = { .x = 0, .y = 0, .w = buffer->surface->config.size.w, .h = buffer->surface->config.size.h }; D_WARN ("BDisp/Surfaces: RGB32 support is experimental and slow!"); if (dfb_system_type () != CORE_STMFBDEV) D_WARN ("BDisp/Surfaces: RGB32 is only supported in STMfbdev system!"); D_DEBUG_AT (STMfbdev_Surfaces, " -> rgb32 allocation!\n"); dfb_gfxcard_lock (GDLF_WAIT); _bdisp_aq_RGB32_init (stdrv, stdev, data->physical + chunk->offset, chunk->pitch, &rect); dfb_gfxcard_unlock (); } #endif D_MAGIC_SET (alloc, STMfbdevPoolAllocationData); return DFB_OK; }