Attached is the new ram only system.
On Dec 4, 2007 9:05 AM, Mike Emmel <[EMAIL PROTECTED]> wrote: > Will do. > One thing this brought up was the ability to run various shadow > buffers for example for devices > the ability to use a VNC backend along with the hardware makes a nice > development environment. > > > > > > On Dec 4, 2007 3:46 AM, Denis Oliver Kropp <[EMAIL PROTECTED]> wrote: > > Mike Emmel wrote: > > > I recently had a need for directfb without any display so I've patched > > > up the devmem system to work with allocated > > > memory. > > > > > > So far it works ok for my usage. > > > > > > > > > Patch attached. > > > > > > Some notes their seems to some assumptions about the amount of memory > > > available for surfaces and layers. > > > > > > Sample config that worked > > > > > > export > > > DFBARGS="system=devmem,video-allocate=0x0,video-allocate-length=614400,mode=320x240" > > > > I'd prefer another system module named "sysmem" for example. > > > > We also don't need the video-allocate and video-allocate-length options > > then, just: > > > > export DFBARGS="system=sysmem,video-length=614400,mode=320x240" > > > > -- > > Best regards, > > Denis Oliver Kropp > > > > .------------------------------------------. > > | DirectFB - Hardware accelerated graphics | > > | http://www.directfb.org/ | > > "------------------------------------------" > > >
diff --git a/configure.in b/configure.in index 2349cec..f995079 100644 --- a/configure.in +++ b/configure.in @@ -552,6 +552,13 @@ AC_ARG_ENABLE(devmem, AM_CONDITIONAL(DEVMEM_CORE, test "$enable_devmem" = "yes") +dnl Test for SysMem system +AC_ARG_ENABLE(sysmem, + [ --enable-sysmem build with generic mem support [[default=yes]]],, + enable_sysmem=yes) + +AM_CONDITIONAL(SYSMEM_CORE, test "$enable_sysmem" = "yes") + dnl Test for Linux frame buffer device @@ -1507,6 +1514,7 @@ systems/fbdev/Makefile systems/x11/Makefile systems/osx/Makefile systems/sdl/Makefile +systems/sysmem/Makefile systems/vnc/Makefile wm/Makefile @@ -1608,6 +1616,7 @@ Misc options: Building Core Systems: Linux FBDev support $enable_fbdev Generic /dev/mem support $enable_devmem + Generic mem support $enable_sysmem X11 support $enable_x11 OSX support $enable_osx SDL support $enable_sdl diff --git a/lib/fusion/lock.c b/lib/fusion/lock.c index 9b756ba..bc1b22d 100644 --- a/lib/fusion/lock.c +++ b/lib/fusion/lock.c @@ -592,9 +592,9 @@ fusion_skirmish_lock_count( const FusionSkirmish *skirmish, int *lock_count ) D_UNIMPLEMENTED(); - *lock_count = 0; + *lock_count = 1; - return DFB_UNIMPLEMENTED; + return DFB_OK; } DirectResult diff --git a/src/misc/conf.c b/src/misc/conf.c index a4d0c69..8c406bf 100644 --- a/src/misc/conf.c +++ b/src/misc/conf.c @@ -129,10 +129,11 @@ static const char *config_usage = " agpmem-limit=<amount> Limit amount of AGP memory in kb\n" " screenshot-dir=<directory> Dump screen content on <Print> key presses\n" " video-phys=<hexaddress> Physical start of video memory (devmem system)\n" - " video-length=<bytes> Length of video memory (devmem system)\n" + " video-length=<bytes> Length of video memory (devmem and sysmem system)\n" " mmio-phys=<hexaddress> Physical start of MMIO area (devmem system)\n" " mmio-length=<bytes> Length of MMIO area (devmem system)\n" " accelerator=<id> Accelerator ID selecting graphics driver (devmem system)\n" + " video-address=<hexaddress> Start of virtual video memory (sysmem system)\n" "\n" " [no-]matrox-sgram Use Matrox SGRAM features\n" " [no-]matrox-crtc2 Experimental Matrox CRTC2 support\n" @@ -1364,6 +1365,25 @@ DFBResult dfb_config_set( const char *name, const char *value ) return DFB_INVARG; } } else + if (strcmp (name, "video-address" ) == 0) { + if (value) { + char *error; + ulong address; + + address = strtoul( value, &error, 16 ); + + if (*error) { + D_ERROR( "DirectFB/Config '%s': Error in hex value '%s'!\n", name, error ); + return DFB_INVARG; + } + + dfb_config->video_address = address; + } + else { + D_ERROR( "DirectFB/Config '%s': No value specified!\n", name ); + return DFB_INVARG; + } + } else if (strcmp (name, "matrox-tv-standard" ) == 0) { if (value) { if (strcmp( value, "pal-60" ) == 0) { diff --git a/src/misc/conf.h b/src/misc/conf.h index 39724cc..ffb051d 100644 --- a/src/misc/conf.h +++ b/src/misc/conf.h @@ -195,6 +195,7 @@ typedef struct unsigned long mmio_phys; /* Physical base address of MMIO area */ unsigned int mmio_length; /* Size of MMIO area */ int accelerator; /* Accelerator ID */ + unsigned long video_address; /* virtual base address of video memory */ bool font_premult; /* Use premultiplied data in case of ARGB glyph images */ diff --git a/systems/Makefile.am b/systems/Makefile.am index 4137b44..e197113 100644 --- a/systems/Makefile.am +++ b/systems/Makefile.am @@ -24,6 +24,12 @@ else DEVMEM_DIR = endif +if SYSMEM_CORE +SYSMEM_DIR = sysmem +else +SYSMEM_DIR = +endif + if FBDEV_CORE FBDEV_DIR = fbdev else @@ -37,4 +43,4 @@ VNC_DIR = endif -SUBDIRS = $(DEVMEM_DIR) $(FBDEV_DIR) $(X11_DIR) $(SDL_DIR) $(OSX_DIR) $(VNC_DIR) +SUBDIRS = $(DEVMEM_DIR) $(FBDEV_DIR) $(X11_DIR) $(SDL_DIR) $(SYSMEM_DIR) $(OSX_DIR) $(VNC_DIR) diff --git a/systems/sysmem/Makefile.am b/systems/sysmem/Makefile.am new file mode 100644 index 0000000..152e02d --- /dev/null +++ b/systems/sysmem/Makefile.am @@ -0,0 +1,37 @@ +## Makefile.am for DirectFB/systems/sysmem + +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src + + +internalincludedir = $(INTERNALINCLUDEDIR)/sysmem + +internalinclude_HEADERS = \ + sysmem.h + + +systemsdir = $(MODULEDIR)/systems + +if BUILD_STATIC +systems_DATA = libdirectfb_sysmem.o +endif +systems_LTLIBRARIES = libdirectfb_sysmem.la + +libdirectfb_sysmem_la_LDFLAGS = \ + -avoid-version \ + -module + +libdirectfb_sysmem_la_SOURCES = \ + sysmem.c + +libdirectfb_sysmem_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la + + +include $(top_srcdir)/rules/libobject.make diff --git a/systems/sysmem/sysmem.c b/systems/sysmem/sysmem.c new file mode 100644 index 0000000..2cedb53 --- /dev/null +++ b/systems/sysmem/sysmem.c @@ -0,0 +1,518 @@ +/* + (c) Copyright 2001-2007 The DirectFB Organization (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + Written by Denis Oliver Kropp <[EMAIL PROTECTED]>, + Andreas Hundt <[EMAIL PROTECTED]>, + Sven Neumann <[EMAIL PROTECTED]>, + Ville Syrjälä <[EMAIL PROTECTED]> and + Claudio Ciccani <[EMAIL PROTECTED]>. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include <config.h> + +#include <fcntl.h> +#include <sys/mman.h> + +#include <directfb.h> + +#include <direct/mem.h> + +#include <fusion/arena.h> +#include <fusion/shmalloc.h> + +#include <core/core.h> +#include <core/surface_pool.h> +#include <core/layers.h> +#include <core/screens.h> +#include <gfx/convert.h> + +#include <misc/conf.h> + +#include "sysmem.h" +#include <core/core_system.h> + +DFB_CORE_SYSTEM( sysmem ) + +static DFBResult +primaryInitScreen( CoreScreen *screen, + CoreGraphicsDevice *device, + void *driver_data, + void *screen_data, + DFBScreenDescription *description ) +{ + /* Set the screen capabilities. */ + description->caps = DSCCAPS_NONE; + + /* Set the screen name. */ + snprintf( description->name, + DFB_SCREEN_DESC_NAME_LENGTH, "System Memory Primary Screen" ); + + return DFB_OK; +} + +static DFBResult +primaryGetScreenSize( CoreScreen *screen, + void *driver_data, + void *screen_data, + int *ret_width, + int *ret_height ) +{ + + if (dfb_config->mode.width) + *ret_width = dfb_config->mode.width; + else + *ret_width = dfb_config->video_length/2; + + if (dfb_config->mode.height) + *ret_height = dfb_config->mode.height; + else + *ret_height = dfb_config->video_length/2; + return DFB_OK; +} + +ScreenFuncs sysmemPrimaryScreenFuncs = { + InitScreen: primaryInitScreen, + GetScreenSize: primaryGetScreenSize +}; + +/******************************************************************************/ + +static int +primaryLayerDataSize() +{ + return 0; +} + +static int +primaryRegionDataSize() +{ + return 0; +} + +static DFBResult +primaryInitLayer( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *config, + DFBColorAdjustment *adjustment ) +{ + /* set capabilities and type */ + description->caps = DLCAPS_SURFACE; + description->type = DLTF_GRAPHICS; + + /* set name */ + snprintf( description->name, + DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, "X11 Primary Layer" ); + + /* fill out the default configuration */ + config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | + DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE; + config->buffermode = DLBM_FRONTONLY; + + if (dfb_config->mode.width) + config->width = dfb_config->mode.width; + else + config->width = dfb_config->video_length/2; + + if (dfb_config->mode.height) + config->height = dfb_config->mode.height; + else + config->height = dfb_config->video_length/2; + + if (dfb_config->mode.format != DSPF_UNKNOWN) + config->pixelformat = dfb_config->mode.format; + else if (dfb_config->mode.depth > 0) + config->pixelformat = dfb_pixelformat_for_depth( dfb_config->mode.depth ); + else { + config->pixelformat = DSPF_RGB32; + } + + return DFB_OK; +} + +static DFBResult +primaryTestRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags *failed ) +{ + CoreLayerRegionConfigFlags fail = 0; + + switch (config->buffermode) { + case DLBM_FRONTONLY: + case DLBM_BACKSYSTEM: + case DLBM_BACKVIDEO: + case DLBM_TRIPLE: + break; + + default: + fail |= CLRCF_BUFFERMODE; + break; + } + + if (config->options) + fail |= CLRCF_OPTIONS; + + if (failed) + *failed = fail; + + if (fail) + return DFB_UNSUPPORTED; + + return DFB_OK; +} + +static DFBResult +primaryAddRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config ) +{ + return DFB_OK; +} + +static DFBResult +primarySetRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags updated, + CoreSurface *surface, + CorePalette *palette, + CoreSurfaceBufferLock *lock ) +{ + return DFB_OK; +} + +static DFBResult +primaryRemoveRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data ) +{ + return DFB_OK; +} + +static DFBResult +primaryFlipRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + DFBSurfaceFlipFlags flags, + CoreSurfaceBufferLock *lock ) +{ + return DFB_OK; +} + +static DFBResult +primaryUpdateRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + const DFBRegion *update, + CoreSurfaceBufferLock *lock ) +{ + return DFB_OK; +} + + +DisplayLayerFuncs sysmemPrimaryLayerFuncs = { + LayerDataSize: primaryLayerDataSize, + RegionDataSize: primaryRegionDataSize, + InitLayer: primaryInitLayer, + + TestRegion: primaryTestRegion, + AddRegion: primaryAddRegion, + SetRegion: primarySetRegion, + RemoveRegion: primaryRemoveRegion, + FlipRegion: primaryFlipRegion, + UpdateRegion: primaryUpdateRegion, +}; + + +/**********************************************************************************************************************/ + +static SysMemData *m_data; /* FIXME: Fix Core System API to pass data in all functions. */ + +/**********************************************************************************************************************/ + +/**********************************************************************************************************************/ + +static void +system_get_info( CoreSystemInfo *info ) +{ + info->type = CORE_DEVMEM; + info->caps = CSCAPS_ACCELERATION; + + snprintf( info->name, DFB_CORE_SYSTEM_INFO_NAME_LENGTH, "SysMem" ); +} + +static DFBResult +system_initialize( CoreDFB *core, void **ret_data ) +{ + DFBResult ret = DFB_OK; + SysMemData *data; + SysMemDataShared *shared; + FusionSHMPoolShared *pool; + CoreScreen *screen; + + D_ASSERT( m_data == NULL ); + if (!dfb_config->video_length) { + D_ERROR( "System/SysMem: Please supply 'video-length = XXXX' option!\n" ); + return DFB_INVARG; + } + + data = D_CALLOC( 1, sizeof(SysMemData) ); + if (!data) + return D_OOM(); + m_data = data; + + pool = dfb_core_shmpool( core ); + + shared = SHCALLOC( pool, 1, sizeof(SysMemDataShared) ); + if (!shared) { + D_FREE( data ); + return D_OOSHM(); + } + + shared->shmpool = pool; + + data->shared = shared; + data->shared->video_length = dfb_config->video_length; + + if(dfb_config->video_address) { + data->shared->mem = (void*)dfb_config->video_address; + D_INFO("System/SysMem: Memory Preallocated at %p %d bytes\n", dfb_config->video_address,dfb_config->video_length, "MAP_SHARED|MAP_ANONYMOUS" ); + } + else { + data->shared->mem = mmap(NULL,dfb_config->video_length, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, 0, 0); + if (data->shared->mem == MAP_FAILED) { + D_PERROR( "System/SysMem: Mapping %d bytes via '%s' failed!\n", dfb_config->video_length, "MAP_SHARED|MAP_ANONYMOUS" ); + ret = DFB_INIT; + } + D_INFO("System/SysMem: Mapping %d bytes at %p via \n", dfb_config->video_length,data->shared->mem); + } + screen = dfb_screens_register( NULL, NULL, &sysmemPrimaryScreenFuncs ); + dfb_layers_register( screen, NULL, &sysmemPrimaryLayerFuncs ); + if (ret) { + SHFREE( pool, shared ); + D_FREE( data ); + return ret; + } + + + *ret_data = data; + + fusion_arena_add_shared_field( dfb_core_arena( core ), "sysmem", shared ); + + return DFB_OK; +} + +static DFBResult +system_join( CoreDFB *core, void **ret_data ) +{ + DFBResult ret; + void *tmp; + SysMemData *data; + SysMemDataShared *shared; + void* mem; + + D_ASSERT( m_data == NULL ); + + data = D_CALLOC( 1, sizeof(SysMemData) ); + if (!data) + return D_OOM(); + + ret = fusion_arena_get_shared_field( dfb_core_arena( core ), "sysmem", &tmp ); + if (ret) { + D_FREE( data ); + return ret; + } + + data->shared = shared = tmp; + + mem = mmap(shared->mem,dfb_config->video_length, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS|MAP_FIXED, 0, 0); + if (mem == MAP_FAILED) + ret = DFB_INVARG; + + if (ret) { + D_FREE( data ); + return ret; + } + + *ret_data = m_data = data; + + return DFB_OK; +} + +static DFBResult +system_shutdown( bool emergency ) +{ + SysMemDataShared *shared; + + D_ASSERT( m_data != NULL ); + + shared = m_data->shared; + D_ASSERT( shared != NULL ); + + if(!dfb_config->video_address) + munmap( shared->mem, shared->video_length); + SHFREE( shared->shmpool, shared ); + D_FREE( m_data ); + m_data = NULL; + return DFB_OK; +} + +static DFBResult +system_leave( bool emergency ) +{ + SysMemDataShared *shared; + + D_ASSERT( m_data != NULL ); + + shared = m_data->shared; + D_ASSERT( shared != NULL ); + + if(!dfb_config->video_address) + munmap( shared->mem, shared->video_length); + D_FREE( m_data ); + m_data = NULL; + + return DFB_OK; +} + +static DFBResult +system_suspend() +{ + D_ASSERT( m_data != NULL ); + + return DFB_OK; +} + +static DFBResult +system_resume() +{ + D_ASSERT( m_data != NULL ); + + return DFB_OK; +} + +static volatile void * +system_map_mmio( unsigned int offset, + int length ) +{ + return NULL; +} + +static void +system_unmap_mmio( volatile void *addr, + int length ) +{ +} + +static int +system_get_accelerator() +{ + return dfb_config->accelerator; +} + +static VideoMode * +system_get_modes() +{ + return NULL; +} + +static VideoMode * +system_get_current_mode() +{ + return NULL; +} + +static DFBResult +system_thread_init() +{ + return DFB_OK; +} + +static bool +system_input_filter( CoreInputDevice *device, + DFBInputEvent *event ) +{ + return false; +} + +static unsigned long +system_video_memory_physical( unsigned int offset ) +{ + return 0; +} + +static void * +system_video_memory_virtual( unsigned int offset ) +{ + D_ASSERT( m_data != NULL ); + + return m_data->shared->mem + offset; +} + +static unsigned int +system_videoram_length() +{ + return m_data->shared->video_length; +} + +static unsigned long +system_aux_memory_physical( unsigned int offset ) +{ + return 0; +} + +static void * +system_aux_memory_virtual( unsigned int offset ) +{ + return NULL; +} + +static unsigned int +system_auxram_length() +{ + return 0; +} + +static void +system_get_busid( int *ret_bus, int *ret_dev, int *ret_func ) +{ + return; +} + +static void +system_get_deviceid( unsigned int *ret_vendor_id, + unsigned int *ret_device_id ) +{ + return; +} + diff --git a/systems/sysmem/sysmem.h b/systems/sysmem/sysmem.h new file mode 100644 index 0000000..8fe0e03 --- /dev/null +++ b/systems/sysmem/sysmem.h @@ -0,0 +1,47 @@ +/* + (c) Copyright 2001-2007 The DirectFB Organization (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + Written by Denis Oliver Kropp <[EMAIL PROTECTED]>, + Andreas Hundt <[EMAIL PROTECTED]>, + Sven Neumann <[EMAIL PROTECTED]>, + Ville Syrjälä <[EMAIL PROTECTED]> and + Claudio Ciccani <[EMAIL PROTECTED]>. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef __DEVMEM_DEVMEM_H__ +#define __DEVMEM_DEVMEM_H__ + +#include <fusion/shmalloc.h> + + +typedef struct { + FusionSHMPoolShared *shmpool; + void* mem; + ulong video_length; +} SysMemDataShared; + +typedef struct { + SysMemDataShared *shared; +} SysMemData; + + +#endif +
_______________________________________________ directfb-dev mailing list directfb-dev@directfb.org http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev