summaryrefslogtreecommitdiff
path: root/Source/DirectFB/systems/devmem
diff options
context:
space:
mode:
Diffstat (limited to 'Source/DirectFB/systems/devmem')
-rwxr-xr-xSource/DirectFB/systems/devmem/Makefile.am40
-rwxr-xr-xSource/DirectFB/systems/devmem/Makefile.in628
-rwxr-xr-xSource/DirectFB/systems/devmem/devmem.c374
-rwxr-xr-xSource/DirectFB/systems/devmem/devmem.h60
-rwxr-xr-xSource/DirectFB/systems/devmem/devmem_surface_pool.c394
-rwxr-xr-xSource/DirectFB/systems/devmem/surfacemanager.c575
-rwxr-xr-xSource/DirectFB/systems/devmem/surfacemanager.h110
7 files changed, 2181 insertions, 0 deletions
diff --git a/Source/DirectFB/systems/devmem/Makefile.am b/Source/DirectFB/systems/devmem/Makefile.am
new file mode 100755
index 0000000..b85d92a
--- /dev/null
+++ b/Source/DirectFB/systems/devmem/Makefile.am
@@ -0,0 +1,40 @@
+## Makefile.am for DirectFB/systems/devmem
+
+INCLUDES = \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/lib \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src
+
+
+internalincludedir = $(INTERNALINCLUDEDIR)/devmem
+
+internalinclude_HEADERS = \
+ devmem.h \
+ surfacemanager.h
+
+
+systemsdir = $(MODULEDIR)/systems
+
+if BUILD_STATIC
+systems_DATA = libdirectfb_devmem.o
+endif
+systems_LTLIBRARIES = libdirectfb_devmem.la
+
+libdirectfb_devmem_la_LDFLAGS = \
+ -avoid-version \
+ -module
+
+libdirectfb_devmem_la_SOURCES = \
+ devmem.c \
+ devmem_surface_pool.c \
+ surfacemanager.c
+
+libdirectfb_devmem_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/Source/DirectFB/systems/devmem/Makefile.in b/Source/DirectFB/systems/devmem/Makefile.in
new file mode 100755
index 0000000..54985c4
--- /dev/null
+++ b/Source/DirectFB/systems/devmem/Makefile.in
@@ -0,0 +1,628 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+DIST_COMMON = $(internalinclude_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(top_srcdir)/rules/libobject.make
+subdir = systems/devmem
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(systemsdir)" "$(DESTDIR)$(systemsdir)" \
+ "$(DESTDIR)$(internalincludedir)"
+systemsLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(systems_LTLIBRARIES)
+libdirectfb_devmem_la_DEPENDENCIES = \
+ $(top_builddir)/lib/direct/libdirect.la \
+ $(top_builddir)/lib/fusion/libfusion.la \
+ $(top_builddir)/src/libdirectfb.la
+am_libdirectfb_devmem_la_OBJECTS = devmem.lo devmem_surface_pool.lo \
+ surfacemanager.lo
+libdirectfb_devmem_la_OBJECTS = $(am_libdirectfb_devmem_la_OBJECTS)
+libdirectfb_devmem_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libdirectfb_devmem_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libdirectfb_devmem_la_SOURCES)
+DIST_SOURCES = $(libdirectfb_devmem_la_SOURCES)
+systemsDATA_INSTALL = $(INSTALL_DATA)
+DATA = $(systems_DATA)
+internalincludeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(internalinclude_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+ASFLAGS = @ASFLAGS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATADIR = @DATADIR@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DFB_CFLAGS_OMIT_FRAME_POINTER = @DFB_CFLAGS_OMIT_FRAME_POINTER@
+DFB_INTERNAL_CFLAGS = @DFB_INTERNAL_CFLAGS@
+DFB_LDFLAGS = @DFB_LDFLAGS@
+DFB_SMOOTH_SCALING = @DFB_SMOOTH_SCALING@
+DIRECTFB_BINARY_AGE = @DIRECTFB_BINARY_AGE@
+DIRECTFB_CSOURCE = @DIRECTFB_CSOURCE@
+DIRECTFB_INTERFACE_AGE = @DIRECTFB_INTERFACE_AGE@
+DIRECTFB_MAJOR_VERSION = @DIRECTFB_MAJOR_VERSION@
+DIRECTFB_MICRO_VERSION = @DIRECTFB_MICRO_VERSION@
+DIRECTFB_MINOR_VERSION = @DIRECTFB_MINOR_VERSION@
+DIRECTFB_VERSION = @DIRECTFB_VERSION@
+DIRECT_BUILD_DEBUG = @DIRECT_BUILD_DEBUG@
+DIRECT_BUILD_DEBUGS = @DIRECT_BUILD_DEBUGS@
+DIRECT_BUILD_GETTID = @DIRECT_BUILD_GETTID@
+DIRECT_BUILD_NETWORK = @DIRECT_BUILD_NETWORK@
+DIRECT_BUILD_STDBOOL = @DIRECT_BUILD_STDBOOL@
+DIRECT_BUILD_TEXT = @DIRECT_BUILD_TEXT@
+DIRECT_BUILD_TRACE = @DIRECT_BUILD_TRACE@
+DSYMUTIL = @DSYMUTIL@
+DYNLIB = @DYNLIB@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+FREETYPE_PROVIDER = @FREETYPE_PROVIDER@
+FUSION_BUILD_KERNEL = @FUSION_BUILD_KERNEL@
+FUSION_BUILD_MULTI = @FUSION_BUILD_MULTI@
+FUSION_MESSAGE_SIZE = @FUSION_MESSAGE_SIZE@
+GIF_PROVIDER = @GIF_PROVIDER@
+GREP = @GREP@
+HAVE_LINUX = @HAVE_LINUX@
+INCLUDEDIR = @INCLUDEDIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTERNALINCLUDEDIR = @INTERNALINCLUDEDIR@
+JPEG_PROVIDER = @JPEG_PROVIDER@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBJPEG = @LIBJPEG@
+LIBOBJS = @LIBOBJS@
+LIBPNG = @LIBPNG@
+LIBPNG_CONFIG = @LIBPNG_CONFIG@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_BINARY = @LT_BINARY@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAN2HTML = @MAN2HTML@
+MKDIR_P = @MKDIR_P@
+MODULEDIR = @MODULEDIR@
+MODULEDIRNAME = @MODULEDIRNAME@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+OSX_LIBS = @OSX_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PNG_PROVIDER = @PNG_PROVIDER@
+RANLIB = @RANLIB@
+RUNTIME_SYSROOT = @RUNTIME_SYSROOT@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOPATH = @SOPATH@
+STRIP = @STRIP@
+SYSCONFDIR = @SYSCONFDIR@
+SYSFS_LIBS = @SYSFS_LIBS@
+THREADFLAGS = @THREADFLAGS@
+THREADLIB = @THREADLIB@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+VERSION = @VERSION@
+VNC_CFLAGS = @VNC_CFLAGS@
+VNC_CONFIG = @VNC_CONFIG@
+VNC_LIBS = @VNC_LIBS@
+X11_CFLAGS = @X11_CFLAGS@
+X11_LIBS = @X11_LIBS@
+ZLIB_LIBS = @ZLIB_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/lib \
+ -I$(top_srcdir)/lib \
+ -I$(top_srcdir)/src
+
+internalincludedir = $(INTERNALINCLUDEDIR)/devmem
+internalinclude_HEADERS = \
+ devmem.h \
+ surfacemanager.h
+
+systemsdir = $(MODULEDIR)/systems
+@BUILD_STATIC_TRUE@systems_DATA = libdirectfb_devmem.o
+systems_LTLIBRARIES = libdirectfb_devmem.la
+libdirectfb_devmem_la_LDFLAGS = \
+ -avoid-version \
+ -module
+
+libdirectfb_devmem_la_SOURCES = \
+ devmem.c \
+ devmem_surface_pool.c \
+ surfacemanager.c
+
+libdirectfb_devmem_la_LIBADD = \
+ $(top_builddir)/lib/direct/libdirect.la \
+ $(top_builddir)/lib/fusion/libfusion.la \
+ $(top_builddir)/src/libdirectfb.la
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/rules/libobject.make $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu systems/devmem/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu systems/devmem/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-systemsLTLIBRARIES: $(systems_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(systemsdir)" || $(MKDIR_P) "$(DESTDIR)$(systemsdir)"
+ @list='$(systems_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(systemsLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(systemsdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(systemsLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(systemsdir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-systemsLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(systems_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(systemsdir)/$$p'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(systemsdir)/$$p"; \
+ done
+
+clean-systemsLTLIBRARIES:
+ -test -z "$(systems_LTLIBRARIES)" || rm -f $(systems_LTLIBRARIES)
+ @list='$(systems_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libdirectfb_devmem.la: $(libdirectfb_devmem_la_OBJECTS) $(libdirectfb_devmem_la_DEPENDENCIES)
+ $(libdirectfb_devmem_la_LINK) -rpath $(systemsdir) $(libdirectfb_devmem_la_OBJECTS) $(libdirectfb_devmem_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/devmem.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/devmem_surface_pool.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/surfacemanager.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-systemsDATA: $(systems_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(systemsdir)" || $(MKDIR_P) "$(DESTDIR)$(systemsdir)"
+ @list='$(systems_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(systemsDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(systemsdir)/$$f'"; \
+ $(systemsDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(systemsdir)/$$f"; \
+ done
+
+uninstall-systemsDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(systems_DATA)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(systemsdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(systemsdir)/$$f"; \
+ done
+install-internalincludeHEADERS: $(internalinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ test -z "$(internalincludedir)" || $(MKDIR_P) "$(DESTDIR)$(internalincludedir)"
+ @list='$(internalinclude_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(internalincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(internalincludedir)/$$f'"; \
+ $(internalincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(internalincludedir)/$$f"; \
+ done
+
+uninstall-internalincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(internalinclude_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(internalincludedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(internalincludedir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(systemsdir)" "$(DESTDIR)$(systemsdir)" "$(DESTDIR)$(internalincludedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-systemsLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am: install-internalincludeHEADERS install-systemsDATA \
+ install-systemsLTLIBRARIES
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-internalincludeHEADERS uninstall-systemsDATA \
+ uninstall-systemsLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-systemsLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am \
+ install-internalincludeHEADERS install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ install-systemsDATA install-systemsLTLIBRARIES installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-internalincludeHEADERS \
+ uninstall-systemsDATA uninstall-systemsLTLIBRARIES
+
+%.o: .libs/%.a %.la
+ rm -f $<.tmp/*.o
+ if test -d $<.tmp; then rmdir $<.tmp; fi
+ mkdir $<.tmp
+ (cd $<.tmp && $(AR) x ../../$<)
+ $(LD) -o $@ -r $<.tmp/*.o
+ rm -f $<.tmp/*.o && rmdir $<.tmp
+
+.PHONY: $(LTLIBRARIES:%.la=.libs/%.a)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/Source/DirectFB/systems/devmem/devmem.c b/Source/DirectFB/systems/devmem/devmem.c
new file mode 100755
index 0000000..9e77777
--- /dev/null
+++ b/Source/DirectFB/systems/devmem/devmem.c
@@ -0,0 +1,374 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ 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 <misc/conf.h>
+
+#include "devmem.h"
+#include "surfacemanager.h"
+
+
+#include <core/core_system.h>
+
+DFB_CORE_SYSTEM( devmem )
+
+/**********************************************************************************************************************/
+
+static DevMemData *m_data; /* FIXME: Fix Core System API to pass data in all functions. */
+
+/**********************************************************************************************************************/
+
+static DFBResult
+MapMemAndReg( DevMemData *data,
+ unsigned long mem_phys,
+ unsigned int mem_length,
+ unsigned long reg_phys,
+ unsigned int reg_length )
+{
+ int fd;
+
+ fd = open( DEV_MEM, O_RDWR | O_SYNC );
+ if (fd < 0) {
+ D_PERROR( "System/DevMem: Opening '%s' failed!\n", DEV_MEM );
+ return DFB_INIT;
+ }
+
+ data->mem = mmap( NULL, mem_length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, mem_phys );
+ if (data->mem == MAP_FAILED) {
+ D_PERROR( "System/DevMem: Mapping %d bytes at 0x%08lx via '%s' failed!\n", mem_length, mem_phys, DEV_MEM );
+ return DFB_INIT;
+ }
+
+ if (reg_phys && reg_length) {
+ data->reg = mmap( NULL, reg_length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, reg_phys );
+ if (data->reg == MAP_FAILED) {
+ D_PERROR( "System/DevMem: Mapping %d bytes at 0x%08lx via '%s' failed!\n", reg_length, reg_phys, DEV_MEM );
+ munmap( data->mem, mem_length );
+ close( fd );
+ return DFB_INIT;
+ }
+ }
+
+ close( fd );
+
+ return DFB_OK;
+}
+
+static void
+UnmapMemAndReg( DevMemData *data,
+ unsigned int mem_length,
+ unsigned int reg_length )
+{
+ munmap( data->mem, mem_length );
+
+ if (reg_length)
+ munmap( (void*) data->reg, reg_length );
+}
+
+/**********************************************************************************************************************/
+
+static void
+system_get_info( CoreSystemInfo *info )
+{
+ info->type = CORE_DEVMEM;
+ info->caps = CSCAPS_ACCELERATION;
+
+ snprintf( info->name, DFB_CORE_SYSTEM_INFO_NAME_LENGTH, "DevMem" );
+}
+
+static DFBResult
+system_initialize( CoreDFB *core, void **ret_data )
+{
+ DFBResult ret;
+ DevMemData *data;
+ DevMemDataShared *shared;
+ FusionSHMPoolShared *pool;
+
+ D_ASSERT( m_data == NULL );
+
+ if (!dfb_config->video_phys || !dfb_config->video_length) {
+ D_ERROR( "System/DevMem: Please supply 'video-phys = 0xXXXXXXXX' and 'video-length = XXXX' options!\n" );
+ return DFB_INVARG;
+ }
+
+ if (dfb_config->mmio_phys && !dfb_config->mmio_length) {
+ D_ERROR( "System/DevMem: Please supply both 'mmio-phys = 0xXXXXXXXX' and 'mmio-length = XXXX' options or none!\n" );
+ return DFB_INVARG;
+ }
+
+ data = D_CALLOC( 1, sizeof(DevMemData) );
+ if (!data)
+ return D_OOM();
+
+ pool = dfb_core_shmpool( core );
+
+ shared = SHCALLOC( pool, 1, sizeof(DevMemDataShared) );
+ if (!shared) {
+ D_FREE( data );
+ return D_OOSHM();
+ }
+
+ shared->shmpool = pool;
+
+ data->shared = shared;
+
+ ret = MapMemAndReg( data,
+ dfb_config->video_phys, dfb_config->video_length,
+ dfb_config->mmio_phys, dfb_config->mmio_length );
+ if (ret) {
+ SHFREE( pool, shared );
+ D_FREE( data );
+ return ret;
+ }
+
+
+ *ret_data = m_data = data;
+
+ dfb_surface_pool_initialize( core, &devmemSurfacePoolFuncs, &shared->pool );
+
+ fusion_arena_add_shared_field( dfb_core_arena( core ), "devmem", shared );
+
+ return DFB_OK;
+}
+
+static DFBResult
+system_join( CoreDFB *core, void **ret_data )
+{
+ DFBResult ret;
+ void *tmp;
+ DevMemData *data;
+ DevMemDataShared *shared;
+
+ D_ASSERT( m_data == NULL );
+
+ if (!dfb_config->video_phys || !dfb_config->video_length) {
+ D_ERROR( "System/DevMem: Please supply 'video-phys = 0xXXXXXXXX' and 'video-length = XXXX' options!\n" );
+ return DFB_INVARG;
+ }
+
+ if (dfb_config->mmio_phys && !dfb_config->mmio_length) {
+ D_ERROR( "System/DevMem: Please supply both 'mmio-phys = 0xXXXXXXXX' and 'mmio-length = XXXX' options or none!\n" );
+ return DFB_INVARG;
+ }
+
+ data = D_CALLOC( 1, sizeof(DevMemData) );
+ if (!data)
+ return D_OOM();
+
+ ret = fusion_arena_get_shared_field( dfb_core_arena( core ), "devmem", &tmp );
+ if (ret) {
+ D_FREE( data );
+ return ret;
+ }
+
+ data->shared = shared = tmp;
+
+ ret = MapMemAndReg( data,
+ dfb_config->video_phys, dfb_config->video_length,
+ dfb_config->mmio_phys, dfb_config->mmio_length );
+ if (ret) {
+ D_FREE( data );
+ return ret;
+ }
+
+ *ret_data = m_data = data;
+
+ dfb_surface_pool_join( core, shared->pool, &devmemSurfacePoolFuncs );
+
+ return DFB_OK;
+}
+
+static DFBResult
+system_shutdown( bool emergency )
+{
+ DevMemDataShared *shared;
+
+ D_ASSERT( m_data != NULL );
+
+ shared = m_data->shared;
+ D_ASSERT( shared != NULL );
+
+ dfb_surface_pool_destroy( shared->pool );
+
+ UnmapMemAndReg( m_data, dfb_config->video_length, dfb_config->mmio_length );
+
+ SHFREE( shared->shmpool, shared );
+
+ D_FREE( m_data );
+ m_data = NULL;
+
+ return DFB_OK;
+}
+
+static DFBResult
+system_leave( bool emergency )
+{
+ DevMemDataShared *shared;
+
+ D_ASSERT( m_data != NULL );
+
+ shared = m_data->shared;
+ D_ASSERT( shared != NULL );
+
+ dfb_surface_pool_leave( shared->pool );
+
+ UnmapMemAndReg( m_data, dfb_config->video_length, dfb_config->mmio_length );
+
+ D_FREE( m_data );
+ m_data = NULL;
+
+ return DFB_OK;
+}
+
+static DFBResult
+system_suspend( void )
+{
+ D_ASSERT( m_data != NULL );
+
+ return DFB_OK;
+}
+
+static DFBResult
+system_resume( void )
+{
+ D_ASSERT( m_data != NULL );
+
+ return DFB_OK;
+}
+
+static volatile void *
+system_map_mmio( unsigned int offset,
+ int length )
+{
+ D_ASSERT( m_data != NULL );
+
+ return m_data->reg + offset;
+}
+
+static void
+system_unmap_mmio( volatile void *addr,
+ int length )
+{
+}
+
+static int
+system_get_accelerator( void )
+{
+ return dfb_config->accelerator;
+}
+
+static VideoMode *
+system_get_modes( void )
+{
+ return NULL;
+}
+
+static VideoMode *
+system_get_current_mode( void )
+{
+ return NULL;
+}
+
+static DFBResult
+system_thread_init( void )
+{
+ 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 dfb_config->video_phys + offset;
+}
+
+static void *
+system_video_memory_virtual( unsigned int offset )
+{
+ D_ASSERT( m_data != NULL );
+
+ return m_data->mem + offset;
+}
+
+static unsigned int
+system_videoram_length( void )
+{
+ return dfb_config->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( void )
+{
+ 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/Source/DirectFB/systems/devmem/devmem.h b/Source/DirectFB/systems/devmem/devmem.h
new file mode 100755
index 0000000..2aa8237
--- /dev/null
+++ b/Source/DirectFB/systems/devmem/devmem.h
@@ -0,0 +1,60 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ 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>
+
+#include <core/surface_pool.h>
+
+#include "surfacemanager.h"
+
+
+#define DEV_MEM "/dev/mem"
+
+extern const SurfacePoolFuncs devmemSurfacePoolFuncs;
+
+
+typedef struct {
+ FusionSHMPoolShared *shmpool;
+
+ CoreSurfacePool *pool;
+ SurfaceManager *manager;
+} DevMemDataShared;
+
+typedef struct {
+ DevMemDataShared *shared;
+
+ void *mem;
+ volatile void *reg;
+} DevMemData;
+
+
+#endif
+
diff --git a/Source/DirectFB/systems/devmem/devmem_surface_pool.c b/Source/DirectFB/systems/devmem/devmem_surface_pool.c
new file mode 100755
index 0000000..1d0b6f6
--- /dev/null
+++ b/Source/DirectFB/systems/devmem/devmem_surface_pool.c
@@ -0,0 +1,394 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ 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 <direct/debug.h>
+#include <direct/mem.h>
+
+#include <core/surface_pool.h>
+
+#include <gfx/convert.h>
+
+#include <misc/conf.h>
+
+#include "devmem.h"
+#include "surfacemanager.h"
+
+D_DEBUG_DOMAIN( DevMem_Surfaces, "DevMem/Surfaces", "DevMem Framebuffer Surface Pool" );
+D_DEBUG_DOMAIN( DevMem_SurfLock, "DevMem/SurfLock", "DevMem Framebuffer Surface Pool Locks" );
+
+/**********************************************************************************************************************/
+
+typedef struct {
+ int magic;
+
+ SurfaceManager *manager;
+} DevMemPoolData;
+
+typedef struct {
+ int magic;
+
+ CoreDFB *core;
+ void *mem;
+} DevMemPoolLocalData;
+
+typedef struct {
+ int magic;
+
+ int offset;
+ int pitch;
+ int size;
+
+ Chunk *chunk;
+} DevMemAllocationData;
+
+/**********************************************************************************************************************/
+
+static int
+devmemPoolDataSize( void )
+{
+ return sizeof(DevMemPoolData);
+}
+
+static int
+devmemPoolLocalDataSize( void )
+{
+ return sizeof(DevMemPoolLocalData);
+}
+
+static int
+devmemAllocationDataSize( void )
+{
+ return sizeof(DevMemAllocationData);
+}
+
+static DFBResult
+devmemInitPool( CoreDFB *core,
+ CoreSurfacePool *pool,
+ void *pool_data,
+ void *pool_local,
+ void *system_data,
+ CoreSurfacePoolDescription *ret_desc )
+{
+ DFBResult ret;
+ DevMemPoolData *data = pool_data;
+ DevMemPoolLocalData *local = pool_local;
+ DevMemData *devmem = system_data;
+
+ D_DEBUG_AT( DevMem_Surfaces, "%s()\n", __FUNCTION__ );
+
+ D_ASSERT( core != NULL );
+ D_MAGIC_ASSERT( pool, CoreSurfacePool );
+ D_ASSERT( data != NULL );
+ D_ASSERT( local != NULL );
+ D_ASSERT( devmem != NULL );
+ D_ASSERT( devmem->shared != NULL );
+ D_ASSERT( ret_desc != NULL );
+
+ ret = dfb_surfacemanager_create( core, dfb_config->video_length, &data->manager );
+ if (ret)
+ return ret;
+
+ ret_desc->caps = CSPCAPS_PHYSICAL | CSPCAPS_VIRTUAL;
+ ret_desc->access[CSAID_CPU] = CSAF_READ | CSAF_WRITE | CSAF_SHARED;
+ ret_desc->access[CSAID_GPU] = CSAF_READ | CSAF_WRITE | CSAF_SHARED;
+ ret_desc->types = CSTF_LAYER | CSTF_WINDOW | CSTF_CURSOR | CSTF_FONT | CSTF_SHARED | CSTF_EXTERNAL;
+ ret_desc->priority = CSPP_DEFAULT;
+ ret_desc->size = dfb_config->video_length;
+
+ /* For hardware layers */
+ ret_desc->access[CSAID_LAYER0] = CSAF_READ;
+ ret_desc->access[CSAID_LAYER1] = CSAF_READ;
+ ret_desc->access[CSAID_LAYER2] = CSAF_READ;
+ ret_desc->access[CSAID_LAYER3] = CSAF_READ;
+ ret_desc->access[CSAID_LAYER4] = CSAF_READ;
+ ret_desc->access[CSAID_LAYER5] = CSAF_READ;
+ ret_desc->access[CSAID_LAYER6] = CSAF_READ;
+ ret_desc->access[CSAID_LAYER7] = CSAF_READ;
+
+ snprintf( ret_desc->name, DFB_SURFACE_POOL_DESC_NAME_LENGTH, "/dev/mem" );
+
+ local->core = core;
+ local->mem = devmem->mem;
+
+ D_MAGIC_SET( data, DevMemPoolData );
+ D_MAGIC_SET( local, DevMemPoolLocalData );
+
+ devmem->shared->manager = data->manager;
+
+ return DFB_OK;
+}
+
+static DFBResult
+devmemJoinPool( CoreDFB *core,
+ CoreSurfacePool *pool,
+ void *pool_data,
+ void *pool_local,
+ void *system_data )
+{
+ DevMemPoolData *data = pool_data;
+ DevMemPoolLocalData *local = pool_local;
+ DevMemData *devmem = system_data;
+
+ D_DEBUG_AT( DevMem_Surfaces, "%s()\n", __FUNCTION__ );
+
+ D_ASSERT( core != NULL );
+ D_MAGIC_ASSERT( pool, CoreSurfacePool );
+ D_MAGIC_ASSERT( data, DevMemPoolData );
+ D_ASSERT( local != NULL );
+ D_ASSERT( devmem != NULL );
+ D_ASSERT( devmem->shared != NULL );
+
+ (void) data;
+
+ local->core = core;
+ local->mem = devmem->mem;
+
+ D_MAGIC_SET( local, DevMemPoolLocalData );
+
+ return DFB_OK;
+}
+
+static DFBResult
+devmemDestroyPool( CoreSurfacePool *pool,
+ void *pool_data,
+ void *pool_local )
+{
+ DevMemPoolData *data = pool_data;
+ DevMemPoolLocalData *local = pool_local;
+
+ D_DEBUG_AT( DevMem_Surfaces, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( pool, CoreSurfacePool );
+ D_MAGIC_ASSERT( data, DevMemPoolData );
+ D_MAGIC_ASSERT( local, DevMemPoolLocalData );
+
+ dfb_surfacemanager_destroy( data->manager );
+
+ D_MAGIC_CLEAR( data );
+ D_MAGIC_CLEAR( local );
+
+ return DFB_OK;
+}
+
+static DFBResult
+devmemLeavePool( CoreSurfacePool *pool,
+ void *pool_data,
+ void *pool_local )
+{
+ DevMemPoolData *data = pool_data;
+ DevMemPoolLocalData *local = pool_local;
+
+ D_DEBUG_AT( DevMem_Surfaces, "%s()\n", __FUNCTION__ );
+
+ D_MAGIC_ASSERT( pool, CoreSurfacePool );
+ D_MAGIC_ASSERT( data, DevMemPoolData );
+ D_MAGIC_ASSERT( local, DevMemPoolLocalData );
+
+ (void) data;
+
+ D_MAGIC_CLEAR( local );
+
+ return DFB_OK;
+}
+
+static DFBResult
+devmemTestConfig( CoreSurfacePool *pool,
+ void *pool_data,
+ void *pool_local,
+ CoreSurfaceBuffer *buffer,
+ const CoreSurfaceConfig *config )
+{
+ DFBResult ret;
+ CoreSurface *surface;
+ DevMemPoolData *data = pool_data;
+ DevMemPoolLocalData *local = pool_local;
+
+ 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 );
+
+ if (surface->type & CSTF_LAYER)
+ return DFB_OK;
+
+ ret = dfb_surfacemanager_allocate( local->core, data->manager, buffer, NULL, NULL );
+
+ D_DEBUG_AT( DevMem_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;
+
+ 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
+devmemDeallocateBuffer( CoreSurfacePool *pool,
+ void *pool_data,
+ void *pool_local,
+ CoreSurfaceBuffer *buffer,
+ CoreSurfaceAllocation *allocation,
+ void *alloc_data )
+{
+ DevMemPoolData *data = pool_data;
+ DevMemAllocationData *alloc = alloc_data;
+
+ D_DEBUG_AT( DevMem_Surfaces, "%s( %p )\n", __FUNCTION__, buffer );
+
+ D_MAGIC_ASSERT( pool, CoreSurfacePool );
+ D_MAGIC_ASSERT( data, DevMemPoolData );
+ D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer );
+ D_MAGIC_ASSERT( alloc, DevMemAllocationData );
+
+ if (alloc->chunk)
+ dfb_surfacemanager_deallocate( data->manager, alloc->chunk );
+
+ D_MAGIC_CLEAR( alloc );
+
+ return DFB_OK;
+}
+
+static DFBResult
+devmemLock( CoreSurfacePool *pool,
+ void *pool_data,
+ void *pool_local,
+ CoreSurfaceAllocation *allocation,
+ void *alloc_data,
+ CoreSurfaceBufferLock *lock )
+{
+ DevMemPoolLocalData *local = pool_local;
+ DevMemAllocationData *alloc = alloc_data;
+
+ D_MAGIC_ASSERT( pool, CoreSurfacePool );
+ D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation );
+ D_MAGIC_ASSERT( alloc, DevMemAllocationData );
+ D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock );
+
+ D_DEBUG_AT( DevMem_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer );
+
+ lock->pitch = alloc->pitch;
+ lock->offset = alloc->offset;
+ lock->addr = local->mem + alloc->offset;
+ lock->phys = dfb_config->video_phys + alloc->offset;
+
+ D_DEBUG_AT( DevMem_SurfLock, " -> offset %lu, pitch %d, addr %p, phys 0x%08lx\n",
+ lock->offset, lock->pitch, lock->addr, lock->phys );
+
+ return DFB_OK;
+}
+
+static DFBResult
+devmemUnlock( CoreSurfacePool *pool,
+ void *pool_data,
+ void *pool_local,
+ CoreSurfaceAllocation *allocation,
+ void *alloc_data,
+ CoreSurfaceBufferLock *lock )
+{
+ DevMemAllocationData *alloc = alloc_data;
+
+ D_MAGIC_ASSERT( pool, CoreSurfacePool );
+ D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation );
+ D_MAGIC_ASSERT( alloc, DevMemAllocationData );
+ D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock );
+
+ D_DEBUG_AT( DevMem_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer );
+
+ (void) alloc;
+
+ return DFB_OK;
+}
+
+const SurfacePoolFuncs devmemSurfacePoolFuncs = {
+ .PoolDataSize = devmemPoolDataSize,
+ .PoolLocalDataSize = devmemPoolLocalDataSize,
+ .AllocationDataSize = devmemAllocationDataSize,
+
+ .InitPool = devmemInitPool,
+ .JoinPool = devmemJoinPool,
+ .DestroyPool = devmemDestroyPool,
+ .LeavePool = devmemLeavePool,
+
+ .TestConfig = devmemTestConfig,
+ .AllocateBuffer = devmemAllocateBuffer,
+ .DeallocateBuffer = devmemDeallocateBuffer,
+
+ .Lock = devmemLock,
+ .Unlock = devmemUnlock,
+};
+
diff --git a/Source/DirectFB/systems/devmem/surfacemanager.c b/Source/DirectFB/systems/devmem/surfacemanager.c
new file mode 100755
index 0000000..c3330cf
--- /dev/null
+++ b/Source/DirectFB/systems/devmem/surfacemanager.c
@@ -0,0 +1,575 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ 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 <fusion/shmalloc.h>
+
+#include <directfb.h>
+#include <directfb_util.h>
+
+#include <core/core.h>
+
+#include <core/gfxcard.h>
+#include <core/surface.h>
+#include <core/surface_buffer.h>
+
+#include <direct/debug.h>
+#include <direct/messages.h>
+#include <direct/util.h>
+
+#include <gfx/convert.h>
+
+#include "surfacemanager.h"
+
+D_DEBUG_DOMAIN( SurfMan, "SurfaceManager", "DirectFB Surface Manager" );
+
+
+static Chunk *split_chunk ( SurfaceManager *manager,
+ Chunk *chunk,
+ int length );
+
+static Chunk *free_chunk ( SurfaceManager *manager,
+ Chunk *chunk );
+
+static Chunk *occupy_chunk( SurfaceManager *manager,
+ Chunk *chunk,
+ CoreSurfaceAllocation *allocation,
+ int length,
+ int pitch );
+
+
+DFBResult
+dfb_surfacemanager_create( CoreDFB *core,
+ unsigned int length,
+ SurfaceManager **ret_manager )
+{
+ FusionSHMPoolShared *pool;
+ SurfaceManager *manager;
+ Chunk *chunk;
+
+ D_DEBUG_AT( SurfMan, "%s( %p, %d )\n", __FUNCTION__, core, length );
+
+ D_ASSERT( core != NULL );
+ D_ASSERT( ret_manager != NULL );
+
+ pool = dfb_core_shmpool( core );
+
+ manager = SHCALLOC( pool, 1, sizeof(SurfaceManager) );
+ if (!manager)
+ return D_OOSHM();
+
+ chunk = SHCALLOC( pool, 1, sizeof(Chunk) );
+ if (!chunk) {
+ D_OOSHM();
+ SHFREE( pool, manager );
+ return DFB_NOSHAREDMEMORY;
+ }
+
+ manager->shmpool = pool;
+ manager->chunks = chunk;
+ manager->offset = 0;
+ manager->length = length;
+ manager->avail = manager->length - manager->offset;
+
+ D_MAGIC_SET( manager, SurfaceManager );
+
+ chunk->offset = manager->offset;
+ chunk->length = manager->avail;
+
+ D_MAGIC_SET( chunk, Chunk );
+
+ D_DEBUG_AT( SurfMan, " -> %p\n", manager );
+
+ *ret_manager = manager;
+
+ return DFB_OK;
+}
+
+void
+dfb_surfacemanager_destroy( SurfaceManager *manager )
+{
+ Chunk *chunk;
+ void *next;
+
+ D_DEBUG_AT( SurfMan, "%s( %p )\n", __FUNCTION__, manager );
+
+ D_MAGIC_ASSERT( manager, SurfaceManager );
+
+ /* Deallocate all video chunks. */
+ chunk = manager->chunks;
+ while (chunk) {
+ next = chunk->next;
+
+ D_MAGIC_CLEAR( chunk );
+
+ SHFREE( manager->shmpool, chunk );
+
+ chunk = next;
+ }
+
+ D_MAGIC_CLEAR( manager );
+
+ /* Deallocate manager struct. */
+ SHFREE( manager->shmpool, manager );
+}
+
+/** public functions NOT locking the surfacemanger theirself,
+ to be called between lock/unlock of surfacemanager **/
+
+DFBResult dfb_surfacemanager_allocate( CoreDFB *core,
+ SurfaceManager *manager,
+ CoreSurfaceBuffer *buffer,
+ CoreSurfaceAllocation *allocation,
+ Chunk **ret_chunk )
+{
+ int pitch;
+ int length;
+ Chunk *c;
+ CoreGraphicsDevice *device;
+
+ Chunk *best_free = NULL;
+
+ D_MAGIC_ASSERT( manager, SurfaceManager );
+ D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer );
+ D_MAGIC_ASSERT( buffer->surface, CoreSurface );
+
+ if (ret_chunk)
+ D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation );
+ else
+ D_ASSUME( allocation == NULL );
+
+ D_DEBUG_AT( SurfMan, "%s( %p ) <- %dx%d %s\n", __FUNCTION__, buffer,
+ buffer->surface->config.size.w, buffer->surface->config.size.h,
+ dfb_pixelformat_name( buffer->surface->config.format ) );
+
+ if (manager->suspended)
+ return DFB_SUSPENDED;
+
+ /* FIXME: Only one global device at the moment. */
+ device = dfb_core_get_part( core, DFCP_GRAPHICS );
+ D_ASSERT( device != NULL );
+
+ dfb_gfxcard_calc_buffer_size( device, buffer, &pitch, &length );
+
+ D_DEBUG_AT( SurfMan, " -> pitch %d, length %d\n", pitch, length );
+
+ if (manager->avail < length)
+ return DFB_TEMPUNAVAIL;
+
+ /* examine chunks */
+ c = manager->chunks;
+ D_MAGIC_ASSERT( c, Chunk );
+
+ /* FIXME_SC_2 Workaround creation happening before graphics driver initialization. */
+ if (!c->next) {
+ int length = dfb_gfxcard_memory_length();
+
+ if (c->length != length - manager->offset) {
+ D_WARN( "workaround" );
+
+ manager->length = length;
+ manager->avail = length - manager->offset;
+
+ c->length = length - manager->offset;
+ }
+ }
+
+ while (c) {
+ D_MAGIC_ASSERT( c, Chunk );
+
+ if (!c->buffer && c->length >= length) {
+ /* NULL means check only. */
+ if (!ret_chunk)
+ return DFB_OK;
+
+ /* found a nice place to chill */
+ if (!best_free || best_free->length > c->length)
+ /* first found or better one? */
+ best_free = c;
+
+ if (c->length == length)
+ break;
+ }
+
+ c = c->next;
+ }
+
+ /* if we found a place */
+ if (best_free) {
+ D_DEBUG_AT( SurfMan, " -> found free (%d)\n", best_free->length );
+
+ /* NULL means check only. */
+ if (ret_chunk)
+ *ret_chunk = occupy_chunk( manager, best_free, allocation, length, pitch );
+
+ return DFB_OK;
+ }
+
+ D_DEBUG_AT( SurfMan, " -> failed (%d/%d avail)\n", manager->avail, manager->length );
+
+ /* no luck */
+ return DFB_NOVIDEOMEMORY;
+}
+
+DFBResult dfb_surfacemanager_displace( CoreDFB *core,
+ SurfaceManager *manager,
+ CoreSurfaceBuffer *buffer )
+{
+ int length;
+ Chunk *multi_start = NULL;
+ int multi_size = 0;
+ int multi_tsize = 0;
+ int multi_count = 0;
+ Chunk *bestm_start = NULL;
+ int bestm_count = 0;
+ int bestm_size = 0;
+ int min_toleration;
+ Chunk *chunk;
+ CoreGraphicsDevice *device;
+ CoreSurfaceAllocation *smallest = NULL;
+
+ D_MAGIC_ASSERT( manager, SurfaceManager );
+ D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer );
+ D_MAGIC_ASSERT( buffer->surface, CoreSurface );
+
+ D_DEBUG_AT( SurfMan, "%s( %p ) <- %dx%d %s\n", __FUNCTION__, buffer,
+ buffer->surface->config.size.w, buffer->surface->config.size.h,
+ dfb_pixelformat_name( buffer->surface->config.format ) );
+
+ /* FIXME: Only one global device at the moment. */
+ device = dfb_core_get_part( core, DFCP_GRAPHICS );
+ D_ASSERT( device != NULL );
+
+ dfb_gfxcard_calc_buffer_size( dfb_core_get_part( core, DFCP_GRAPHICS ), buffer, NULL, &length );
+
+ min_toleration = manager->min_toleration/8 + 2;
+
+ D_DEBUG_AT( SurfMan, " -> %7d required, min toleration %d\n", length, min_toleration );
+
+ chunk = manager->chunks;
+ while (chunk) {
+ CoreSurfaceAllocation *allocation;
+
+ D_MAGIC_ASSERT( chunk, Chunk );
+
+ allocation = chunk->allocation;
+ if (allocation) {
+ CoreSurfaceBuffer *other;
+ int size;
+
+ D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation );
+ D_ASSERT( chunk->buffer == allocation->buffer );
+ D_ASSERT( chunk->length >= allocation->size );
+
+ other = allocation->buffer;
+ D_MAGIC_ASSERT( other, CoreSurfaceBuffer );
+
+ if (other->locked) {
+ D_DEBUG_AT( SurfMan, " ++ %7d locked %dx\n", allocation->size, other->locked );
+ goto next_reset;
+ }
+
+ if (other->policy > buffer->policy) {
+ D_DEBUG_AT( SurfMan, " ++ %7d policy %d > %d\n", allocation->size, other->policy, buffer->policy );
+ goto next_reset;
+ }
+
+ if (other->policy == CSP_VIDEOONLY) {
+ D_DEBUG_AT( SurfMan, " ++ %7d policy videoonly\n", allocation->size );
+ goto next_reset;
+ }
+
+ chunk->tolerations++;
+ if (chunk->tolerations > 0xff)
+ chunk->tolerations = 0xff;
+
+ if (other->policy == buffer->policy && chunk->tolerations < min_toleration) {
+ D_DEBUG_AT( SurfMan, " ++ %7d tolerations %d/%d\n",
+ allocation->size, chunk->tolerations, min_toleration );
+ goto next_reset;
+ }
+
+ size = allocation->size;
+
+ if (chunk->prev && !chunk->prev->allocation)
+ size += chunk->prev->length;
+
+ if (chunk->next && !chunk->next->allocation)
+ size += chunk->next->length;
+
+ if (size >= length) {
+ if (!smallest || smallest->size > allocation->size) {
+ D_DEBUG_AT( SurfMan, " => %7d [%d] < %d, tolerations %d\n",
+ allocation->size, size, smallest ? smallest->size : 0, chunk->tolerations );
+
+ smallest = allocation;
+ }
+ else
+ D_DEBUG_AT( SurfMan, " -> %7d [%d] > %d\n", allocation->size, size, smallest->size );
+ }
+ else
+ D_DEBUG_AT( SurfMan, " -> %7d [%d]\n", allocation->size, size );
+ }
+ else
+ D_DEBUG_AT( SurfMan, " - %7d free\n", chunk->length );
+
+
+ if (!smallest) {
+ if (!multi_start) {
+ multi_start = chunk;
+ multi_tsize = chunk->length;
+ multi_size = chunk->allocation ? chunk->length : 0;
+ multi_count = chunk->allocation ? 1 : 0;
+ }
+ else {
+ multi_tsize += chunk->length;
+ multi_size += chunk->allocation ? chunk->length : 0;
+ multi_count += chunk->allocation ? 1 : 0;
+
+ while (multi_tsize >= length && multi_count > 1) {
+ if (!bestm_start || bestm_size > multi_size * multi_count / bestm_count) {
+ D_DEBUG_AT( SurfMan, " =====> %7d, %7d %2d used [%7d %2d]\n",
+ multi_tsize, multi_size, multi_count, bestm_size, bestm_count );
+
+ bestm_size = multi_size;
+ bestm_start = multi_start;
+ bestm_count = multi_count;
+ }
+ else
+ D_DEBUG_AT( SurfMan, " -----> %7d, %7d %2d used\n",
+ multi_tsize, multi_size, multi_count );
+
+ if (multi_count <= 2)
+ break;
+
+ if (!multi_start->allocation) {
+ multi_tsize -= multi_start->length;
+ multi_start = multi_start->next;
+ }
+
+ D_ASSUME( multi_start->allocation != NULL );
+
+ multi_tsize -= multi_start->length;
+ multi_size -= multi_start->allocation ? multi_start->length : 0;
+ multi_count -= multi_start->allocation ? 1 : 0;
+ multi_start = multi_start->next;
+ }
+ }
+ }
+
+ chunk = chunk->next;
+
+ continue;
+
+
+next_reset:
+ multi_start = NULL;
+
+ chunk = chunk->next;
+ }
+
+ if (smallest) {
+ D_MAGIC_ASSERT( smallest, CoreSurfaceAllocation );
+ D_MAGIC_ASSERT( smallest->buffer, CoreSurfaceBuffer );
+
+ smallest->flags |= CSALF_MUCKOUT;
+
+ D_DEBUG_AT( SurfMan, " -> offset %lu, size %d\n", smallest->offset, smallest->size );
+
+ return DFB_OK;
+ }
+
+ if (bestm_start) {
+ chunk = bestm_start;
+
+ while (bestm_count) {
+ CoreSurfaceAllocation *allocation = chunk->allocation;
+
+ if (allocation) {
+ D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation );
+ D_MAGIC_ASSERT( allocation->buffer, CoreSurfaceBuffer );
+
+ allocation->flags |= CSALF_MUCKOUT;
+
+ bestm_count--;
+ }
+
+ D_DEBUG_AT( SurfMan, " ---> offset %d, length %d\n", chunk->offset, chunk->length );
+
+ chunk = chunk->next;
+ }
+
+ return DFB_OK;
+ }
+
+ return DFB_NOVIDEOMEMORY;
+}
+
+DFBResult dfb_surfacemanager_deallocate( SurfaceManager *manager,
+ Chunk *chunk )
+{
+ CoreSurfaceBuffer *buffer;
+
+ D_MAGIC_ASSERT( manager, SurfaceManager );
+ D_MAGIC_ASSERT( chunk, Chunk );
+
+ buffer = chunk->buffer;
+ D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer );
+ D_MAGIC_ASSERT( buffer->surface, CoreSurface );
+
+ D_DEBUG_AT( SurfMan, "%s( %p ) <- %dx%d %s\n", __FUNCTION__, buffer,
+ buffer->surface->config.size.w, buffer->surface->config.size.h,
+ dfb_pixelformat_name( buffer->surface->config.format ) );
+
+ free_chunk( manager, chunk );
+
+ return DFB_OK;
+}
+
+/** internal functions NOT locking the surfacemanager **/
+
+static Chunk *
+split_chunk( SurfaceManager *manager, Chunk *c, int length )
+{
+ Chunk *newchunk;
+
+ D_MAGIC_ASSERT( c, Chunk );
+
+ if (c->length == length) /* does not need be splitted */
+ return c;
+
+ newchunk = (Chunk*) SHCALLOC( manager->shmpool, 1, sizeof(Chunk) );
+ if (!newchunk) {
+ D_OOSHM();
+ return NULL;
+ }
+
+ /* calculate offsets and lengths of resulting chunks */
+ newchunk->offset = c->offset + c->length - length;
+ newchunk->length = length;
+ c->length -= newchunk->length;
+
+ /* insert newchunk after chunk c */
+ newchunk->prev = c;
+ newchunk->next = c->next;
+ if (c->next)
+ c->next->prev = newchunk;
+ c->next = newchunk;
+
+ D_MAGIC_SET( newchunk, Chunk );
+
+ return newchunk;
+}
+
+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( SurfMan, "Deallocating %d bytes at offset %d.\n", chunk->length, chunk->offset );
+ }
+
+ if (chunk->buffer->policy == CSP_VIDEOONLY)
+ manager->avail += chunk->length;
+
+ chunk->allocation = NULL;
+ chunk->buffer = NULL;
+
+ manager->min_toleration--;
+
+ if (chunk->prev && !chunk->prev->buffer) {
+ Chunk *prev = chunk->prev;
+
+ //D_DEBUG_AT( SurfMan, " -> 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( SurfMan, " -> freeing %p (prev %p, next %p)\n", chunk, chunk->prev, chunk->next);
+
+ D_MAGIC_CLEAR( chunk );
+
+ SHFREE( manager->shmpool, chunk );
+ chunk = prev;
+ }
+
+ if (chunk->next && !chunk->next->buffer) {
+ Chunk *next = chunk->next;
+
+ //D_DEBUG_AT( SurfMan, " -> 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( manager->shmpool, next );
+ }
+
+ return chunk;
+}
+
+static Chunk *
+occupy_chunk( SurfaceManager *manager, Chunk *chunk, CoreSurfaceAllocation *allocation, int length, int pitch )
+{
+ D_MAGIC_ASSERT( manager, SurfaceManager );
+ D_MAGIC_ASSERT( chunk, Chunk );
+ D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation );
+ D_MAGIC_ASSERT( allocation->buffer, CoreSurfaceBuffer );
+
+ if (allocation->buffer->policy == CSP_VIDEOONLY)
+ manager->avail -= length;
+
+ chunk = split_chunk( manager, chunk, length );
+ if (!chunk)
+ return NULL;
+
+ D_DEBUG_AT( SurfMan, "Allocating %d bytes at offset %d.\n", chunk->length, chunk->offset );
+
+ chunk->allocation = allocation;
+ chunk->buffer = allocation->buffer;
+ chunk->pitch = pitch;
+
+ manager->min_toleration++;
+
+ return chunk;
+}
+
diff --git a/Source/DirectFB/systems/devmem/surfacemanager.h b/Source/DirectFB/systems/devmem/surfacemanager.h
new file mode 100755
index 0000000..e6136c5
--- /dev/null
+++ b/Source/DirectFB/systems/devmem/surfacemanager.h
@@ -0,0 +1,110 @@
+/*
+ (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
+ (c) Copyright 2000-2004 Convergence (integrated media) GmbH
+
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@directfb.org>,
+ Andreas Hundt <andi@fischlustig.de>,
+ Sven Neumann <neo@directfb.org>,
+ Ville Syrjälä <syrjala@sci.fi> and
+ Claudio Ciccani <klan@users.sf.net>.
+
+ 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 __SURFACEMANAGER_H__
+#define __SURFACEMANAGER_H__
+
+#include <directfb.h>
+
+#include <core/coretypes.h>
+
+typedef struct _SurfaceManager SurfaceManager;
+typedef struct _Chunk Chunk;
+
+/*
+ * initially there is one big free chunk,
+ * chunks are splitted into a free and an occupied chunk if memory is allocated,
+ * two chunks are merged to one free chunk if memory is deallocated
+ */
+struct _Chunk {
+ int magic;
+
+ int offset; /* offset in memory,
+ is greater or equal to the heap offset */
+ int length; /* length of this chunk in bytes */
+
+ int pitch;
+
+ CoreSurfaceBuffer *buffer; /* pointer to surface buffer occupying
+ this chunk, or NULL if chunk is free */
+ CoreSurfaceAllocation *allocation;
+
+ int tolerations; /* number of times this chunk was scanned
+ occupied, resetted in assure_video */
+
+ Chunk *prev;
+ Chunk *next;
+};
+
+struct _SurfaceManager {
+ int magic;
+
+ FusionSHMPoolShared *shmpool;
+
+ Chunk *chunks;
+
+ int offset;
+ int length; /* length of the heap in bytes */
+ int avail; /* amount of available memory in bytes */
+
+ int min_toleration;
+
+ bool suspended;
+};
+
+
+DFBResult dfb_surfacemanager_create ( CoreDFB *core,
+ unsigned int length,
+ SurfaceManager **ret_manager );
+
+void dfb_surfacemanager_destroy( SurfaceManager *manager );
+
+/*
+ * finds and allocates one for the surface or fails,
+ * after success the video health is CSH_RESTORE.
+ * NOTE: this does not notify the listeners
+ */
+DFBResult dfb_surfacemanager_allocate( CoreDFB *core,
+ SurfaceManager *manager,
+ CoreSurfaceBuffer *buffer,
+ CoreSurfaceAllocation *allocation,
+ Chunk **ret_chunk );
+
+DFBResult dfb_surfacemanager_displace( CoreDFB *core,
+ SurfaceManager *manager,
+ CoreSurfaceBuffer *buffer );
+
+/*
+ * sets the video health to CSH_INVALID frees the chunk and
+ * notifies the listeners
+ */
+DFBResult dfb_surfacemanager_deallocate( SurfaceManager *manager,
+ Chunk *chunk );
+
+#endif
+