コード例 #1
0
ファイル: fbdev_surface_pool.c プロジェクト: ysei/uclinux-2
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;
}
コード例 #2
0
ファイル: fbdev_surface_pool.c プロジェクト: maxupunk/DIR685
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;
}