From 7fe60435bce6595a9c58a9bfd8244d74b5320e96 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 15 Jan 2013 08:46:13 +0100 Subject: Import DirectFB141_2k11R3_beta5 --- Source/DirectFB/systems/Makefile.am | 40 + Source/DirectFB/systems/Makefile.in | 568 ++++ Source/DirectFB/systems/devmem/Makefile.am | 40 + Source/DirectFB/systems/devmem/Makefile.in | 628 +++++ Source/DirectFB/systems/devmem/devmem.c | 374 +++ Source/DirectFB/systems/devmem/devmem.h | 60 + .../DirectFB/systems/devmem/devmem_surface_pool.c | 394 +++ Source/DirectFB/systems/devmem/surfacemanager.c | 575 ++++ Source/DirectFB/systems/devmem/surfacemanager.h | 110 + Source/DirectFB/systems/fbdev/Makefile.am | 48 + Source/DirectFB/systems/fbdev/Makefile.in | 637 +++++ Source/DirectFB/systems/fbdev/agp.c | 511 ++++ Source/DirectFB/systems/fbdev/agp.h | 53 + Source/DirectFB/systems/fbdev/fb.h | 366 +++ Source/DirectFB/systems/fbdev/fbdev.c | 2782 ++++++++++++++++++++ Source/DirectFB/systems/fbdev/fbdev.h | 142 + Source/DirectFB/systems/fbdev/fbdev_surface_pool.c | 423 +++ Source/DirectFB/systems/fbdev/surfacemanager.c | 617 +++++ Source/DirectFB/systems/fbdev/surfacemanager.h | 117 + Source/DirectFB/systems/fbdev/vt.c | 675 +++++ Source/DirectFB/systems/fbdev/vt.h | 83 + Source/DirectFB/systems/osx/Makefile.am | 59 + Source/DirectFB/systems/osx/Makefile.in | 685 +++++ Source/DirectFB/systems/osx/osx.c | 263 ++ Source/DirectFB/systems/osx/osx.h | 43 + Source/DirectFB/systems/osx/osxinput.c | 311 +++ Source/DirectFB/systems/osx/primary.c | 623 +++++ Source/DirectFB/systems/osx/primary.h | 49 + Source/DirectFB/systems/sdl/Makefile.am | 86 + Source/DirectFB/systems/sdl/Makefile.in | 773 ++++++ Source/DirectFB/systems/sdl/primary.c | 669 +++++ Source/DirectFB/systems/sdl/primary.h | 49 + Source/DirectFB/systems/sdl/sdl.c | 396 +++ Source/DirectFB/systems/sdl/sdl.h | 70 + Source/DirectFB/systems/sdl/sdl_surface_pool.c | 349 +++ Source/DirectFB/systems/sdl/sdlgfx.c | 302 +++ Source/DirectFB/systems/sdl/sdlinput.c | 571 ++++ Source/DirectFB/systems/vnc/Makefile.am | 55 + Source/DirectFB/systems/vnc/Makefile.in | 682 +++++ Source/DirectFB/systems/vnc/primary.c | 993 +++++++ Source/DirectFB/systems/vnc/primary.h | 50 + Source/DirectFB/systems/vnc/vnc.c | 313 +++ Source/DirectFB/systems/vnc/vnc.h | 86 + Source/DirectFB/systems/vnc/vncinput.c | 128 + Source/DirectFB/systems/x11/Makefile.am | 63 + Source/DirectFB/systems/x11/Makefile.in | 624 +++++ Source/DirectFB/systems/x11/README | 11 + Source/DirectFB/systems/x11/glx_surface_pool.c | 838 ++++++ Source/DirectFB/systems/x11/glx_surface_pool.h | 79 + Source/DirectFB/systems/x11/primary.c | 664 +++++ Source/DirectFB/systems/x11/primary.h | 39 + Source/DirectFB/systems/x11/surfacemanager.c | 559 ++++ Source/DirectFB/systems/x11/surfacemanager.h | 110 + Source/DirectFB/systems/x11/vpsmem_surface_pool.c | 421 +++ Source/DirectFB/systems/x11/vpsmem_surface_pool.h | 37 + Source/DirectFB/systems/x11/x11.c | 570 ++++ Source/DirectFB/systems/x11/x11.h | 116 + Source/DirectFB/systems/x11/x11_surface_pool.c | 369 +++ Source/DirectFB/systems/x11/x11_surface_pool.h | 47 + .../DirectFB/systems/x11/x11_surface_pool_bridge.c | 331 +++ .../DirectFB/systems/x11/x11_surface_pool_bridge.h | 37 + Source/DirectFB/systems/x11/x11image.c | 231 ++ Source/DirectFB/systems/x11/x11image.h | 76 + Source/DirectFB/systems/x11/x11input.c | 768 ++++++ Source/DirectFB/systems/x11/x11types.h | 35 + Source/DirectFB/systems/x11/xwindow.c | 294 +++ Source/DirectFB/systems/x11/xwindow.h | 77 + 67 files changed, 23244 insertions(+) create mode 100755 Source/DirectFB/systems/Makefile.am create mode 100755 Source/DirectFB/systems/Makefile.in create mode 100755 Source/DirectFB/systems/devmem/Makefile.am create mode 100755 Source/DirectFB/systems/devmem/Makefile.in create mode 100755 Source/DirectFB/systems/devmem/devmem.c create mode 100755 Source/DirectFB/systems/devmem/devmem.h create mode 100755 Source/DirectFB/systems/devmem/devmem_surface_pool.c create mode 100755 Source/DirectFB/systems/devmem/surfacemanager.c create mode 100755 Source/DirectFB/systems/devmem/surfacemanager.h create mode 100755 Source/DirectFB/systems/fbdev/Makefile.am create mode 100755 Source/DirectFB/systems/fbdev/Makefile.in create mode 100755 Source/DirectFB/systems/fbdev/agp.c create mode 100755 Source/DirectFB/systems/fbdev/agp.h create mode 100755 Source/DirectFB/systems/fbdev/fb.h create mode 100755 Source/DirectFB/systems/fbdev/fbdev.c create mode 100755 Source/DirectFB/systems/fbdev/fbdev.h create mode 100755 Source/DirectFB/systems/fbdev/fbdev_surface_pool.c create mode 100755 Source/DirectFB/systems/fbdev/surfacemanager.c create mode 100755 Source/DirectFB/systems/fbdev/surfacemanager.h create mode 100755 Source/DirectFB/systems/fbdev/vt.c create mode 100755 Source/DirectFB/systems/fbdev/vt.h create mode 100755 Source/DirectFB/systems/osx/Makefile.am create mode 100755 Source/DirectFB/systems/osx/Makefile.in create mode 100755 Source/DirectFB/systems/osx/osx.c create mode 100755 Source/DirectFB/systems/osx/osx.h create mode 100755 Source/DirectFB/systems/osx/osxinput.c create mode 100755 Source/DirectFB/systems/osx/primary.c create mode 100755 Source/DirectFB/systems/osx/primary.h create mode 100755 Source/DirectFB/systems/sdl/Makefile.am create mode 100755 Source/DirectFB/systems/sdl/Makefile.in create mode 100755 Source/DirectFB/systems/sdl/primary.c create mode 100755 Source/DirectFB/systems/sdl/primary.h create mode 100755 Source/DirectFB/systems/sdl/sdl.c create mode 100755 Source/DirectFB/systems/sdl/sdl.h create mode 100755 Source/DirectFB/systems/sdl/sdl_surface_pool.c create mode 100755 Source/DirectFB/systems/sdl/sdlgfx.c create mode 100755 Source/DirectFB/systems/sdl/sdlinput.c create mode 100755 Source/DirectFB/systems/vnc/Makefile.am create mode 100755 Source/DirectFB/systems/vnc/Makefile.in create mode 100755 Source/DirectFB/systems/vnc/primary.c create mode 100755 Source/DirectFB/systems/vnc/primary.h create mode 100755 Source/DirectFB/systems/vnc/vnc.c create mode 100755 Source/DirectFB/systems/vnc/vnc.h create mode 100755 Source/DirectFB/systems/vnc/vncinput.c create mode 100755 Source/DirectFB/systems/x11/Makefile.am create mode 100755 Source/DirectFB/systems/x11/Makefile.in create mode 100755 Source/DirectFB/systems/x11/README create mode 100755 Source/DirectFB/systems/x11/glx_surface_pool.c create mode 100755 Source/DirectFB/systems/x11/glx_surface_pool.h create mode 100755 Source/DirectFB/systems/x11/primary.c create mode 100755 Source/DirectFB/systems/x11/primary.h create mode 100755 Source/DirectFB/systems/x11/surfacemanager.c create mode 100755 Source/DirectFB/systems/x11/surfacemanager.h create mode 100755 Source/DirectFB/systems/x11/vpsmem_surface_pool.c create mode 100755 Source/DirectFB/systems/x11/vpsmem_surface_pool.h create mode 100755 Source/DirectFB/systems/x11/x11.c create mode 100755 Source/DirectFB/systems/x11/x11.h create mode 100755 Source/DirectFB/systems/x11/x11_surface_pool.c create mode 100755 Source/DirectFB/systems/x11/x11_surface_pool.h create mode 100755 Source/DirectFB/systems/x11/x11_surface_pool_bridge.c create mode 100755 Source/DirectFB/systems/x11/x11_surface_pool_bridge.h create mode 100755 Source/DirectFB/systems/x11/x11image.c create mode 100755 Source/DirectFB/systems/x11/x11image.h create mode 100755 Source/DirectFB/systems/x11/x11input.c create mode 100755 Source/DirectFB/systems/x11/x11types.h create mode 100755 Source/DirectFB/systems/x11/xwindow.c create mode 100755 Source/DirectFB/systems/x11/xwindow.h (limited to 'Source/DirectFB/systems') diff --git a/Source/DirectFB/systems/Makefile.am b/Source/DirectFB/systems/Makefile.am new file mode 100755 index 0000000..4137b44 --- /dev/null +++ b/Source/DirectFB/systems/Makefile.am @@ -0,0 +1,40 @@ +## Makefile.am for DirectFB/systems + +if SDL_CORE +SDL_DIR = sdl +else +SDL_DIR = +endif + +if OSX_CORE +OSX_DIR = osx +else +OSX_DIR = +endif + +if X11_CORE +X11_DIR = x11 +else +X11_DIR = +endif + +if DEVMEM_CORE +DEVMEM_DIR = devmem +else +DEVMEM_DIR = +endif + +if FBDEV_CORE +FBDEV_DIR = fbdev +else +FBDEV_DIR = +endif + +if VNC_CORE +VNC_DIR = vnc +else +VNC_DIR = +endif + + +SUBDIRS = $(DEVMEM_DIR) $(FBDEV_DIR) $(X11_DIR) $(SDL_DIR) $(OSX_DIR) $(VNC_DIR) diff --git a/Source/DirectFB/systems/Makefile.in b/Source/DirectFB/systems/Makefile.in new file mode 100755 index 0000000..54c4641 --- /dev/null +++ b/Source/DirectFB/systems/Makefile.in @@ -0,0 +1,568 @@ +# 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@ +subdir = systems +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +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 = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = devmem fbdev x11 sdl osx vnc +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@ +@SDL_CORE_FALSE@SDL_DIR = +@SDL_CORE_TRUE@SDL_DIR = sdl +@OSX_CORE_FALSE@OSX_DIR = +@OSX_CORE_TRUE@OSX_DIR = osx +@X11_CORE_FALSE@X11_DIR = +@X11_CORE_TRUE@X11_DIR = x11 +@DEVMEM_CORE_FALSE@DEVMEM_DIR = +@DEVMEM_CORE_TRUE@DEVMEM_DIR = devmem +@FBDEV_CORE_FALSE@FBDEV_DIR = +@FBDEV_CORE_TRUE@FBDEV_DIR = fbdev +@VNC_CORE_FALSE@VNC_DIR = +@VNC_CORE_TRUE@VNC_DIR = vnc +SUBDIRS = $(DEVMEM_DIR) $(FBDEV_DIR) $(X11_DIR) $(SDL_DIR) $(OSX_DIR) $(VNC_DIR) +all: all-recursive + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(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/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu systems/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 + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + 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: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + 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: ctags-recursive $(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 + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +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-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-exec-am: + +install-html: install-html-recursive + +install-info: install-info-recursive + +install-man: + +install-pdf: install-pdf-recursive + +install-ps: install-ps-recursive + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ + install-strip + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-generic clean-libtool \ + ctags ctags-recursive distclean 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-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am + +# 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/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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include + +#include + +#include + +#include +#include + +#include +#include + +#include + +#include "devmem.h" +#include "surfacemanager.h" + + +#include + +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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include + +#include + +#include + +#include + +#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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +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 + diff --git a/Source/DirectFB/systems/fbdev/Makefile.am b/Source/DirectFB/systems/fbdev/Makefile.am new file mode 100755 index 0000000..9aa25b4 --- /dev/null +++ b/Source/DirectFB/systems/fbdev/Makefile.am @@ -0,0 +1,48 @@ +## Makefile.am for DirectFB/systems/fbdev + +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src + +AM_CPPFLAGS = -D_XOPEN_SOURCE=500 + + +internalincludedir = $(INTERNALINCLUDEDIR)/fbdev + +internalinclude_HEADERS = \ + agp.h \ + fb.h \ + fbdev.h \ + surfacemanager.h \ + vt.h + + +systemsdir = $(MODULEDIR)/systems + +if BUILD_STATIC +systems_DATA = libdirectfb_fbdev.o +endif +systems_LTLIBRARIES = libdirectfb_fbdev.la + +libdirectfb_fbdev_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(SYSFS_LIBS) + +libdirectfb_fbdev_la_SOURCES = \ + agp.c \ + fbdev.c \ + fbdev_surface_pool.c \ + surfacemanager.c \ + vt.c + +libdirectfb_fbdev_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/fbdev/Makefile.in b/Source/DirectFB/systems/fbdev/Makefile.in new file mode 100755 index 0000000..ddf7e26 --- /dev/null +++ b/Source/DirectFB/systems/fbdev/Makefile.in @@ -0,0 +1,637 @@ +# 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/fbdev +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_fbdev_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la +am_libdirectfb_fbdev_la_OBJECTS = agp.lo fbdev.lo \ + fbdev_surface_pool.lo surfacemanager.lo vt.lo +libdirectfb_fbdev_la_OBJECTS = $(am_libdirectfb_fbdev_la_OBJECTS) +libdirectfb_fbdev_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_fbdev_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_fbdev_la_SOURCES) +DIST_SOURCES = $(libdirectfb_fbdev_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 + +AM_CPPFLAGS = -D_XOPEN_SOURCE=500 +internalincludedir = $(INTERNALINCLUDEDIR)/fbdev +internalinclude_HEADERS = \ + agp.h \ + fb.h \ + fbdev.h \ + surfacemanager.h \ + vt.h + +systemsdir = $(MODULEDIR)/systems +@BUILD_STATIC_TRUE@systems_DATA = libdirectfb_fbdev.o +systems_LTLIBRARIES = libdirectfb_fbdev.la +libdirectfb_fbdev_la_LDFLAGS = \ + -avoid-version \ + -module \ + $(SYSFS_LIBS) + +libdirectfb_fbdev_la_SOURCES = \ + agp.c \ + fbdev.c \ + fbdev_surface_pool.c \ + surfacemanager.c \ + vt.c + +libdirectfb_fbdev_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/fbdev/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu systems/fbdev/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_fbdev.la: $(libdirectfb_fbdev_la_OBJECTS) $(libdirectfb_fbdev_la_DEPENDENCIES) + $(libdirectfb_fbdev_la_LINK) -rpath $(systemsdir) $(libdirectfb_fbdev_la_OBJECTS) $(libdirectfb_fbdev_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbdev.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbdev_surface_pool.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/surfacemanager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vt.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/fbdev/agp.c b/Source/DirectFB/systems/fbdev/agp.c new file mode 100755 index 0000000..286d4db --- /dev/null +++ b/Source/DirectFB/systems/fbdev/agp.c @@ -0,0 +1,511 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include /* Needs to be included before dfb_types.h */ + +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include "fbdev.h" +#include "agp.h" + +#define PAGE_SIZE direct_pagesize() + +/*****************************************************************************/ + +extern FBDev *dfb_fbdev; + +static AGPDevice *dfb_agp = NULL; + +/*****************************************************************************/ + +static DFBResult +dfb_agp_info( agp_info *info ) +{ + D_ASSERT( info != NULL ); + + if (ioctl( dfb_agp->fd, AGPIOC_INFO, info )) { + D_PERROR( "DirectFB/FBDev/agp: Could not get AGP info!\n" ); + return errno2result( errno ); + } + + return DFB_OK; +} + +static DFBResult +dfb_agp_setup( u32 mode ) +{ + agp_setup setup; + + setup.agp_mode = mode; + + if (ioctl( dfb_agp->fd, AGPIOC_SETUP, &setup )) { + D_PERROR( "DirectFB/FBDev/agp: AGP setup failed!\n" ); + return errno2result( errno ); + } + + return DFB_OK; +} + +static DFBResult +dfb_agp_acquire( void ) +{ + if (ioctl( dfb_agp->fd, AGPIOC_ACQUIRE, 0 )) { + D_PERROR( "DirectFB/FBDev/agp: Acquire failed!\n" ); + return errno2result( errno ); + } + + return DFB_OK; +} + +static DFBResult +dfb_agp_release( void ) +{ + if (ioctl( dfb_agp->fd, AGPIOC_RELEASE, 0 )) { + D_PERROR( "DirectFB/FBDev/agp: Release failed!\n" ); + return errno2result( errno ); + } + + return DFB_OK; +} + +static DFBResult +dfb_agp_allocate( unsigned long size, int *key ) +{ + agp_allocate alloc; + int pages; + + D_ASSERT( key != NULL ); + + pages = size / PAGE_SIZE; + if (pages % PAGE_SIZE) + pages++; + + if (pages == 0) { + D_BUG( "attempted to allocate 0 pages!"); + return DFB_BUG; + } + + alloc.pg_count = pages; + alloc.type = 0; + + if (ioctl( dfb_agp->fd, AGPIOC_ALLOCATE, &alloc )) { + D_PERROR( "DirectFB/FBDev/agp: " + "Could not allocate %d pages!\n", pages ); + return errno2result( errno ); + } + + *key = alloc.key; + + return DFB_OK; +} + +static DFBResult +dfb_agp_deallocate( int key ) +{ + if (ioctl( dfb_agp->fd, AGPIOC_DEALLOCATE, key )) { + D_PERROR( "DirectFB/FBDev/agp: " + "Deallocate failed (key = %d)!\n", key ); + return errno2result( errno ); + } + + return DFB_OK; +} + +static DFBResult +dfb_agp_bind( unsigned int offset, int key ) +{ + agp_bind bind; + + if (offset % PAGE_SIZE) { + D_BUG( "offset is not page-aligned!" ); + return DFB_BUG; + } + + bind.pg_start = offset / PAGE_SIZE; + bind.key = key; + + if (ioctl( dfb_agp->fd, AGPIOC_BIND, &bind )) { + D_PERROR( "DirectFB/FBDev/agp: " + "Bind failed (key = %d, offset = 0x%x)!\n", + key, offset ); + return errno2result( errno ); + } + + return DFB_OK; +} + +static DFBResult +dfb_agp_unbind( int key ) +{ + agp_unbind unbind; + + unbind.priority = 0; + unbind.key = key; + + if (ioctl( dfb_agp->fd, AGPIOC_UNBIND, &unbind )) { + D_PERROR( "DirectFB/FBDev/agp: " + "Unbind failed (key = %d)!\n", + key ); + return errno2result( errno ); + } + + return DFB_OK; +} + +/*****************************************************************************/ + +static inline u16 +pci_read_word( int fd, int pos ) +{ + u8 b[2]; + + if (pread( fd, b, 2, pos ) < 2) + return 0; + + return b[0] | (b[1] << 8); +} + +static inline u8 +pci_read_byte( int fd, int pos ) +{ + u8 b; + + if (pread( fd, &b, 1, pos ) < 1) + return 0; + + return b; +} + +#define PCI_STATUS 0x06 +#define PCI_STATUS_CAP_LIST 0x10 +#define PCI_CAPABILITY_LIST 0x34 +#define PCI_CAP_ID_AGP 0x02 + +static bool +dfb_agp_capable( int bus, int dev, int func ) +{ + bool found = false; + char path[22]; + int fd; + + /* XXX: the following detection method requires suid root */ + + snprintf( path, sizeof(path), + "/proc/bus/pci/%02x/%02x.%01x", bus, dev, func ); + + fd = open( path, O_RDONLY | O_SYNC ); + if (fd < 0) { + D_PERROR( "DirectFB/FBDev/agp: " + "Couldn't open '%s'!\n", path ); + return false; + } + + /* stolen from linux/drivers/pci/pci.c */ + if (pci_read_word( fd, PCI_STATUS ) & PCI_STATUS_CAP_LIST) { + int pos, id; + int ttl = 48; + + pos = pci_read_byte( fd, PCI_CAPABILITY_LIST ); + while (ttl-- && pos >= 0x40) { + pos &= ~3; + + id = pci_read_byte( fd, pos ); + if (id == 0xff) + break; + if (id == PCI_CAP_ID_AGP) { + found = true; + break; + } + + pos = pci_read_byte( fd, pos+1 ); + } + } + + close( fd ); + + return found; +} + +/*****************************************************************************/ + +DFBResult +dfb_agp_initialize( void ) +{ + AGPShared *shared; + unsigned int agp_avail; + DFBResult ret = DFB_FAILURE; + + if (dfb_agp) { + D_BUG( "dfb_agp_initialize() already called!" ); + return DFB_BUG; + } + + /* Precheck for AGP capable device. */ + if (!dfb_agp_capable( dfb_fbdev->shared->pci.bus, + dfb_fbdev->shared->pci.dev, + dfb_fbdev->shared->pci.func )) + return DFB_UNSUPPORTED; + + dfb_agp = D_CALLOC( 1, sizeof(AGPDevice) ); + if (!dfb_agp) + return D_OOM(); + + shared = SHCALLOC( dfb_fbdev->shared->shmpool, 1, sizeof(AGPShared) ); + if (!shared) { + D_ERROR( "DirectFB/FBDev/agp: Could not allocate shared memory!\n" ); + ret = DFB_NOSHAREDMEMORY; + goto error0; + } + + dfb_agp->fd = direct_try_open( "/dev/agpgart", + "/dev/misc/agpgart", O_RDWR, true ); + if (dfb_agp->fd < 0) { + ret = errno2result( errno ); + D_ERROR( "DirectFB/FBDev/agp: Error opening AGP device!\n" ); + goto error1; + } + + ret = dfb_agp_acquire(); + if (ret) + goto error2; + + ret = dfb_agp_info( &shared->info ); + if (ret) + goto error2; + + D_DEBUG( "DirectFB/FBDev/agp: " + "Bridge supports: AGP%s%s%s%s%s%s\n", + shared->info.agp_mode & 0x001 ? " 1X" : "", + shared->info.agp_mode & 0x002 ? " 2X" : "", + shared->info.agp_mode & 0x004 ? " 4X" : "", + shared->info.agp_mode & 0x008 ? " 8X" : "", + shared->info.agp_mode & 0x200 ? ", SBA" : "", + shared->info.agp_mode & 0x010 ? ", FW" : "" ); + + shared->info.agp_mode &= ~0xf; + shared->info.agp_mode |= dfb_config->agp; + shared->info.agp_mode |= dfb_config->agp - 1; + + ret = dfb_agp_setup( shared->info.agp_mode ); + if (ret) + goto error2; + dfb_agp_info( &shared->info ); + + D_DEBUG( "DirectFB/FBDev/agp: " + "AGP aperture at 0x%x (%zu MB)\n", + (unsigned int)shared->info.aper_base, shared->info.aper_size ); + + agp_avail = (shared->info.pg_total - shared->info.pg_used) * PAGE_SIZE; + if (agp_avail == 0) { + D_ERROR( "DirectFB/FBDev/agp: No AGP memory available!\n" ); + ret = DFB_INIT; + goto error2; + } + + shared->agp_mem = shared->info.aper_size << 20; + if (shared->agp_mem > agp_avail) + shared->agp_mem = agp_avail; + + ret = dfb_agp_allocate( shared->agp_mem, &shared->agp_key ); + if (ret) + goto error3; + + ret = dfb_agp_bind( shared->agp_key, 0 ); + if (ret) + goto error4; + + dfb_agp->base = mmap( NULL, shared->info.aper_size << 20, + PROT_READ | PROT_WRITE, MAP_SHARED, + dfb_agp->fd, 0 ); + if (dfb_agp->base == MAP_FAILED) { + D_PERROR( "DirectFB/FBDev/agp: Could not mmap the AGP aperture!\n" ); + ret = DFB_INIT; + goto error5; + } + + dfb_agp_release(); + + dfb_fbdev->agp = dfb_agp; + dfb_fbdev->shared->agp = shared; + + return DFB_OK; + +error5: + dfb_agp_unbind( shared->agp_key ); +error4: + dfb_agp_deallocate( shared->agp_key ); +error3: + dfb_agp_release(); +error2: + close( dfb_agp->fd ); +error1: + SHFREE( dfb_fbdev->shared->shmpool, shared ); +error0: + D_FREE( dfb_agp ); + dfb_agp = NULL; + + return ret; +} + +DFBResult +dfb_agp_join( void ) +{ + AGPShared *shared; + DFBResult ret = DFB_FAILURE; + + if (dfb_agp) { + D_BUG( "dfb_agp_join() already called!" ); + return DFB_BUG; + } + + shared = dfb_fbdev->shared->agp; + if (!shared) + return DFB_OK; + + dfb_agp = D_CALLOC( 1, sizeof(AGPDevice) ); + if (!dfb_agp) + return D_OOM(); + + dfb_agp->fd = direct_try_open( "/dev/agpgart", + "/dev/misc/agpgart", O_RDWR, true ); + if (dfb_agp->fd < 0) { + ret = errno2result( errno ); + D_ERROR( "DirectFB/FBDev/agp: Error opening AGP device!\n" ); + goto error0; + } + + ret = dfb_agp_acquire(); + if (ret) + goto error1; + + dfb_agp->base = mmap( NULL, shared->info.aper_size << 20, + PROT_READ | PROT_WRITE, MAP_SHARED, + dfb_agp->fd, 0 ); + if (dfb_agp->base == MAP_FAILED) { + D_PERROR( "DirectFB/FBDev/agp: Could not mmap the AGP aperture!\n" ); + ret = DFB_INIT; + goto error2; + } + + D_DEBUG( "DirectFB/FBDev/agp: AGP aperture mapped at %p\n", dfb_agp->base ); + + dfb_agp_release(); + + dfb_fbdev->agp = dfb_agp; + + return DFB_OK; + +error2: + dfb_agp_release(); +error1: + close( dfb_agp->fd ); +error0: + D_FREE( dfb_agp ); + dfb_agp = NULL; + + return ret; +} + +DFBResult +dfb_agp_shutdown( void ) +{ + AGPShared *shared; + + if (!dfb_agp) + return DFB_INVARG; + + shared = dfb_fbdev->shared->agp; + + dfb_agp_acquire(); + + munmap( dfb_agp->base, shared->info.aper_size << 20 ); + + dfb_agp_unbind( shared->agp_key ); + dfb_agp_deallocate( shared->agp_key ); + + dfb_agp_release(); + close( dfb_agp->fd ); + + SHFREE( dfb_fbdev->shared->shmpool, shared ); + D_FREE( dfb_agp ); + + dfb_fbdev->shared->agp = NULL; + dfb_fbdev->agp = dfb_agp = NULL; + + return DFB_OK; +} + +DFBResult +dfb_agp_leave( void ) +{ + AGPShared *shared; + + if (!dfb_agp) + return DFB_INVARG; + + shared = dfb_fbdev->shared->agp; + + dfb_agp_acquire(); + + munmap( dfb_agp->base, shared->info.aper_size << 20 ); + + dfb_agp_release(); + + close( dfb_agp->fd ); + D_FREE( dfb_agp ); + + dfb_fbdev->agp = dfb_agp = NULL; + + return DFB_OK; +} + diff --git a/Source/DirectFB/systems/fbdev/agp.h b/Source/DirectFB/systems/fbdev/agp.h new file mode 100755 index 0000000..44313a3 --- /dev/null +++ b/Source/DirectFB/systems/fbdev/agp.h @@ -0,0 +1,53 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __AGP_H__ +#define __AGP_H__ + +#include + +typedef struct { + unsigned int agp_mem; + int agp_key; + agp_info info; +} AGPShared; + +typedef struct { + int fd; + void *base; +} AGPDevice; + + +DFBResult dfb_agp_initialize( void ); +DFBResult dfb_agp_shutdown( void ); + +DFBResult dfb_agp_join( void ); +DFBResult dfb_agp_leave( void ); + +#endif /* __AGP_H__ */ + diff --git a/Source/DirectFB/systems/fbdev/fb.h b/Source/DirectFB/systems/fbdev/fb.h new file mode 100755 index 0000000..6cc1399 --- /dev/null +++ b/Source/DirectFB/systems/fbdev/fb.h @@ -0,0 +1,366 @@ +#ifndef _LINUX_FB_H +#define _LINUX_FB_H + +#include + +/* Definitions of frame buffers */ + +#define FB_MAJOR 29 +#define FB_MAX 32 /* sufficient for now */ + +/* ioctls + 0x46 is 'F' */ +#define FBIOGET_VSCREENINFO 0x4600 +#define FBIOPUT_VSCREENINFO 0x4601 +#define FBIOGET_FSCREENINFO 0x4602 +#define FBIOGETCMAP 0x4604 +#define FBIOPUTCMAP 0x4605 +#define FBIOPAN_DISPLAY 0x4606 +#define FBIO_CURSOR _IOWR('F', 0x08, struct fb_cursor) +/* 0x4607-0x460B are defined below */ +/* #define FBIOGET_MONITORSPEC 0x460C */ +/* #define FBIOPUT_MONITORSPEC 0x460D */ +/* #define FBIOSWITCH_MONIBIT 0x460E */ +#define FBIOGET_CON2FBMAP 0x460F +#define FBIOPUT_CON2FBMAP 0x4610 +#define FBIOBLANK 0x4611 /* arg: 0 or vesa level + 1 */ +#define FBIOGET_VBLANK _IOR('F', 0x12, struct fb_vblank) +#define FBIO_ALLOC 0x4613 +#define FBIO_FREE 0x4614 +#define FBIOGET_GLYPH 0x4615 +#define FBIOGET_HWCINFO 0x4616 +#define FBIOPUT_MODEINFO 0x4617 +#define FBIOGET_DISPINFO 0x4618 + + +#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */ +#define FB_TYPE_PLANES 1 /* Non interleaved planes */ +#define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */ +#define FB_TYPE_TEXT 3 /* Text/attributes */ +#define FB_TYPE_VGA_PLANES 4 /* EGA/VGA planes */ + +#define FB_AUX_TEXT_MDA 0 /* Monochrome text */ +#define FB_AUX_TEXT_CGA 1 /* CGA/EGA/VGA Color text */ +#define FB_AUX_TEXT_S3_MMIO 2 /* S3 MMIO fasttext */ +#define FB_AUX_TEXT_MGA_STEP16 3 /* MGA Millenium I: text, attr, 14 reserved bytes */ +#define FB_AUX_TEXT_MGA_STEP8 4 /* other MGAs: text, attr, 6 reserved bytes */ + +#define FB_AUX_VGA_PLANES_VGA4 0 /* 16 color planes (EGA/VGA) */ +#define FB_AUX_VGA_PLANES_CFB4 1 /* CFB4 in planes (VGA) */ +#define FB_AUX_VGA_PLANES_CFB8 2 /* CFB8 in planes (VGA) */ + +#define FB_VISUAL_MONO01 0 /* Monochr. 1=Black 0=White */ +#define FB_VISUAL_MONO10 1 /* Monochr. 1=White 0=Black */ +#define FB_VISUAL_TRUECOLOR 2 /* True color */ +#define FB_VISUAL_PSEUDOCOLOR 3 /* Pseudo color (like atari) */ +#define FB_VISUAL_DIRECTCOLOR 4 /* Direct color */ +#define FB_VISUAL_STATIC_PSEUDOCOLOR 5 /* Pseudo color readonly */ + +#define FB_ACCEL_NONE 0 /* no hardware accelerator */ +#define FB_ACCEL_ATARIBLITT 1 /* Atari Blitter */ +#define FB_ACCEL_AMIGABLITT 2 /* Amiga Blitter */ +#define FB_ACCEL_S3_TRIO64 3 /* Cybervision64 (S3 Trio64) */ +#define FB_ACCEL_NCR_77C32BLT 4 /* RetinaZ3 (NCR 77C32BLT) */ +#define FB_ACCEL_S3_VIRGE 5 /* Cybervision64/3D (S3 ViRGE) */ +#define FB_ACCEL_ATI_MACH64GX 6 /* ATI Mach 64GX family */ +#define FB_ACCEL_DEC_TGA 7 /* DEC 21030 TGA */ +#define FB_ACCEL_ATI_MACH64CT 8 /* ATI Mach 64CT family */ +#define FB_ACCEL_ATI_MACH64VT 9 /* ATI Mach 64CT family VT class */ +#define FB_ACCEL_ATI_MACH64GT 10 /* ATI Mach 64CT family GT class */ +#define FB_ACCEL_SUN_CREATOR 11 /* Sun Creator/Creator3D */ +#define FB_ACCEL_SUN_CGSIX 12 /* Sun cg6 */ +#define FB_ACCEL_SUN_LEO 13 /* Sun leo/zx */ +#define FB_ACCEL_IMS_TWINTURBO 14 /* IMS Twin Turbo */ +#define FB_ACCEL_3DLABS_PERMEDIA2 15 /* 3Dlabs Permedia 2 */ +#define FB_ACCEL_MATROX_MGA2064W 16 /* Matrox MGA2064W (Millenium) */ +#define FB_ACCEL_MATROX_MGA1064SG 17 /* Matrox MGA1064SG (Mystique) */ +#define FB_ACCEL_MATROX_MGA2164W 18 /* Matrox MGA2164W (Millenium II) */ +#define FB_ACCEL_MATROX_MGA2164W_AGP 19 /* Matrox MGA2164W (Millenium II) */ +#define FB_ACCEL_MATROX_MGAG100 20 /* Matrox G100 (Productiva G100) */ +#define FB_ACCEL_MATROX_MGAG200 21 /* Matrox G200 (Myst, Mill, ...) */ +#define FB_ACCEL_SUN_CG14 22 /* Sun cgfourteen */ +#define FB_ACCEL_SUN_BWTWO 23 /* Sun bwtwo */ +#define FB_ACCEL_SUN_CGTHREE 24 /* Sun cgthree */ +#define FB_ACCEL_SUN_TCX 25 /* Sun tcx */ +#define FB_ACCEL_MATROX_MGAG400 26 /* Matrox G400 */ +#define FB_ACCEL_NV3 27 /* nVidia RIVA 128 */ +#define FB_ACCEL_NV4 28 /* nVidia RIVA TNT */ +#define FB_ACCEL_NV5 29 /* nVidia RIVA TNT2 */ +#define FB_ACCEL_CT_6555x 30 /* C&T 6555x */ +#define FB_ACCEL_3DFX_BANSHEE 31 /* 3Dfx Banshee */ +#define FB_ACCEL_ATI_RAGE128 32 /* ATI Rage128 family */ +#define FB_ACCEL_IGS_CYBER2000 33 /* CyberPro 2000 */ +#define FB_ACCEL_IGS_CYBER2010 34 /* CyberPro 2010 */ +#define FB_ACCEL_IGS_CYBER5000 35 /* CyberPro 5000 */ +#define FB_ACCEL_SIS_GLAMOUR 36 /* SiS 300/630/540 */ +#define FB_ACCEL_3DLABS_PERMEDIA3 37 /* 3Dlabs Permedia 3 */ +#define FB_ACCEL_ATI_RADEON 38 /* ATI Radeon family */ +#define FB_ACCEL_I810 39 /* Intel 810/815 */ +#define FB_ACCEL_SIS_GLAMOUR_2 40 /* SiS 315, 650, 740 */ +#define FB_ACCEL_SIS_XABRE 41 /* SiS 330 ("Xabre") */ +#define FB_ACCEL_I830 42 /* Intel 830M/845G/85x/865G */ +#define FB_ACCEL_NV_10 43 /* nVidia Arch 10 */ +#define FB_ACCEL_NV_20 44 /* nVidia Arch 20 */ +#define FB_ACCEL_NV_30 45 /* nVidia Arch 30 */ +#define FB_ACCEL_NV_40 46 /* nVidia Arch 40 */ +#define FB_ACCEL_XGI_VOLARI_V 47 /* XGI Volari V3XT, V5, V8 */ +#define FB_ACCEL_XGI_VOLARI_Z 48 /* XGI Volari Z7 */ +#define FB_ACCEL_NEOMAGIC_NM2070 90 /* NeoMagic NM2070 */ +#define FB_ACCEL_NEOMAGIC_NM2090 91 /* NeoMagic NM2090 */ +#define FB_ACCEL_NEOMAGIC_NM2093 92 /* NeoMagic NM2093 */ +#define FB_ACCEL_NEOMAGIC_NM2097 93 /* NeoMagic NM2097 */ +#define FB_ACCEL_NEOMAGIC_NM2160 94 /* NeoMagic NM2160 */ +#define FB_ACCEL_NEOMAGIC_NM2200 95 /* NeoMagic NM2200 */ +#define FB_ACCEL_NEOMAGIC_NM2230 96 /* NeoMagic NM2230 */ +#define FB_ACCEL_NEOMAGIC_NM2360 97 /* NeoMagic NM2360 */ +#define FB_ACCEL_NEOMAGIC_NM2380 98 /* NeoMagic NM2380 */ +#define FB_ACCEL_EP9X 99 /* CirrusLogic EP9X family */ + +#define FB_ACCEL_SAVAGE4 0x80 /* S3 Savage4 */ +#define FB_ACCEL_SAVAGE3D 0x81 /* S3 Savage3D */ +#define FB_ACCEL_SAVAGE3D_MV 0x82 /* S3 Savage3D-MV */ +#define FB_ACCEL_SAVAGE2000 0x83 /* S3 Savage2000 */ +#define FB_ACCEL_SAVAGE_MX_MV 0x84 /* S3 Savage/MX-MV */ +#define FB_ACCEL_SAVAGE_MX 0x85 /* S3 Savage/MX */ +#define FB_ACCEL_SAVAGE_IX_MV 0x86 /* S3 Savage/IX-MV */ +#define FB_ACCEL_SAVAGE_IX 0x87 /* S3 Savage/IX */ +#define FB_ACCEL_PROSAVAGE_PM 0x88 /* S3 ProSavage PM133 */ +#define FB_ACCEL_PROSAVAGE_KM 0x89 /* S3 ProSavage KM133 */ +#define FB_ACCEL_S3TWISTER_P 0x8a /* S3 Twister */ +#define FB_ACCEL_S3TWISTER_K 0x8b /* S3 TwisterK */ +#define FB_ACCEL_SUPERSAVAGE 0x8c /* S3 Supersavage */ +#define FB_ACCEL_PROSAVAGE_DDR 0x8d /* S3 ProSavage DDR */ +#define FB_ACCEL_PROSAVAGE_DDRK 0x8e /* S3 ProSavage DDR-K */ + +struct fb_fix_screeninfo { + char id[16]; /* identification string eg "TT Builtin" */ + unsigned long smem_start; /* Start of frame buffer mem */ + /* (physical address) */ + u32 smem_len; /* Length of frame buffer mem */ + u32 type; /* see FB_TYPE_* */ + u32 type_aux; /* Interleave for interleaved Planes */ + u32 visual; /* see FB_VISUAL_* */ + u16 xpanstep; /* zero if no hardware panning */ + u16 ypanstep; /* zero if no hardware panning */ + u16 ywrapstep; /* zero if no hardware ywrap */ + u32 line_length; /* length of a line in bytes */ + unsigned long mmio_start; /* Start of Memory Mapped I/O */ + /* (physical address) */ + u32 mmio_len; /* Length of Memory Mapped I/O */ + u32 accel; /* Indicate to driver which */ + /* specific chip/card we have */ + u16 reserved[3]; /* Reserved for future compatibility */ +}; + +/* Interpretation of offset for color fields: All offsets are from the right, + * inside a "pixel" value, which is exactly 'bits_per_pixel' wide (means: you + * can use the offset as right argument to <<). A pixel afterwards is a bit + * stream and is written to video memory as that unmodified. This implies + * big-endian byte order if bits_per_pixel is greater than 8. + */ +struct fb_bitfield { + u32 offset; /* beginning of bitfield */ + u32 length; /* length of bitfield */ + u32 msb_right; /* != 0 : Most significant bit is */ + /* right */ +}; + +#define FB_NONSTD_HAM 1 /* Hold-And-Modify (HAM) */ + +#define FB_ACTIVATE_NOW 0 /* set values immediately (or vbl)*/ +#define FB_ACTIVATE_NXTOPEN 1 /* activate on next open */ +#define FB_ACTIVATE_TEST 2 /* don't set, round up impossible */ +#define FB_ACTIVATE_MASK 15 + /* values */ +#define FB_ACTIVATE_VBL 16 /* activate values on next vbl */ +#define FB_CHANGE_CMAP_VBL 32 /* change colormap on vbl */ +#define FB_ACTIVATE_ALL 64 /* change all VCs on this fb */ +#define FB_ACTIVATE_FORCE 128 /* force apply even when no change*/ +#define FB_ACTIVATE_INV_MODE 256 /* invalidate videomode */ + +#define FB_ACCELF_TEXT 1 /* (OBSOLETE) see fb_info.flags and vc_mode */ + +#define FB_SYNC_HOR_HIGH_ACT 1 /* horizontal sync high active */ +#define FB_SYNC_VERT_HIGH_ACT 2 /* vertical sync high active */ +#define FB_SYNC_EXT 4 /* external sync */ +#define FB_SYNC_COMP_HIGH_ACT 8 /* composite sync high active */ +#define FB_SYNC_BROADCAST 16 /* broadcast video timings */ + /* vtotal = 144d/288n/576i => PAL */ + /* vtotal = 121d/242n/484i => NTSC */ +#define FB_SYNC_ON_GREEN 32 /* sync on green */ + +#define FB_VMODE_NONINTERLACED 0 /* non interlaced */ +#define FB_VMODE_INTERLACED 1 /* interlaced */ +#define FB_VMODE_DOUBLE 2 /* double scan */ +#define FB_VMODE_MASK 255 + +#define FB_VMODE_YWRAP 256 /* ywrap instead of panning */ +#define FB_VMODE_SMOOTH_XPAN 512 /* smooth xpan possible (internally used) */ +#define FB_VMODE_CONUPDATE 512 /* don't update x/yoffset */ + +/* + * Display rotation support + */ +#define FB_ROTATE_UR 0 +#define FB_ROTATE_CW 1 +#define FB_ROTATE_UD 2 +#define FB_ROTATE_CCW 3 + +#define PICOS2KHZ(a) (1000000000UL/(a)) +#define KHZ2PICOS(a) (1000000000UL/(a)) + +struct fb_var_screeninfo { + u32 xres; /* visible resolution */ + u32 yres; + u32 xres_virtual; /* virtual resolution */ + u32 yres_virtual; + u32 xoffset; /* offset from virtual to visible */ + u32 yoffset; /* resolution */ + + u32 bits_per_pixel; /* guess what */ + u32 grayscale; /* != 0 Graylevels instead of colors */ + + struct fb_bitfield red; /* bitfield in fb mem if true color, */ + struct fb_bitfield green; /* else only length is significant */ + struct fb_bitfield blue; + struct fb_bitfield transp; /* transparency */ + + u32 nonstd; /* != 0 Non standard pixel format */ + + u32 activate; /* see FB_ACTIVATE_* */ + + u32 height; /* height of picture in mm */ + u32 width; /* width of picture in mm */ + + u32 accel_flags; /* (OBSOLETE) see fb_info.flags */ + + /* Timing: All values in pixclocks, except pixclock (of course) */ + u32 pixclock; /* pixel clock in ps (pico seconds) */ + u32 left_margin; /* time from sync to picture */ + u32 right_margin; /* time from picture to sync */ + u32 upper_margin; /* time from sync to picture */ + u32 lower_margin; + u32 hsync_len; /* length of horizontal sync */ + u32 vsync_len; /* length of vertical sync */ + u32 sync; /* see FB_SYNC_* */ + u32 vmode; /* see FB_VMODE_* */ + u32 rotate; /* angle we rotate counter clockwise */ + u32 reserved[5]; /* Reserved for future compatibility */ +}; + +struct fb_cmap { + u32 start; /* First entry */ + u32 len; /* Number of entries */ + u16 *red; /* Red values */ + u16 *green; + u16 *blue; + u16 *transp; /* transparency, can be NULL */ +}; + +struct fb_con2fbmap { + u32 console; + u32 framebuffer; +}; + +/* VESA Blanking Levels */ +#define VESA_NO_BLANKING 0 +#define VESA_VSYNC_SUSPEND 1 +#define VESA_HSYNC_SUSPEND 2 +#define VESA_POWERDOWN 3 + + +enum { + /* screen: unblanked, hsync: on, vsync: on */ + FB_BLANK_UNBLANK = VESA_NO_BLANKING, + + /* screen: blanked, hsync: on, vsync: on */ + FB_BLANK_NORMAL = VESA_NO_BLANKING + 1, + + /* screen: blanked, hsync: on, vsync: off */ + FB_BLANK_VSYNC_SUSPEND = VESA_VSYNC_SUSPEND + 1, + + /* screen: blanked, hsync: off, vsync: on */ + FB_BLANK_HSYNC_SUSPEND = VESA_HSYNC_SUSPEND + 1, + + /* screen: blanked, hsync: off, vsync: off */ + FB_BLANK_POWERDOWN = VESA_POWERDOWN + 1 +}; + +#define FB_VBLANK_VBLANKING 0x001 /* currently in a vertical blank */ +#define FB_VBLANK_HBLANKING 0x002 /* currently in a horizontal blank */ +#define FB_VBLANK_HAVE_VBLANK 0x004 /* vertical blanks can be detected */ +#define FB_VBLANK_HAVE_HBLANK 0x008 /* horizontal blanks can be detected */ +#define FB_VBLANK_HAVE_COUNT 0x010 /* global retrace counter is available */ +#define FB_VBLANK_HAVE_VCOUNT 0x020 /* the vcount field is valid */ +#define FB_VBLANK_HAVE_HCOUNT 0x040 /* the hcount field is valid */ +#define FB_VBLANK_VSYNCING 0x080 /* currently in a vsync */ +#define FB_VBLANK_HAVE_VSYNC 0x100 /* verical syncs can be detected */ + +struct fb_vblank { + u32 flags; /* FB_VBLANK flags */ + u32 count; /* counter of retraces since boot */ + u32 vcount; /* current scanline position */ + u32 hcount; /* current scandot position */ + u32 reserved[4]; /* reserved for future compatibility */ +}; + +/* Internal HW accel */ +#define ROP_COPY 0 +#define ROP_XOR 1 + +struct fb_copyarea { + u32 dx; + u32 dy; + u32 width; + u32 height; + u32 sx; + u32 sy; +}; + +struct fb_fillrect { + u32 dx; /* screen-relative */ + u32 dy; + u32 width; + u32 height; + u32 color; + u32 rop; +}; + +struct fb_image { + u32 dx; /* Where to place image */ + u32 dy; + u32 width; /* Size of image */ + u32 height; + u32 fg_color; /* Only used when a mono bitmap */ + u32 bg_color; + u8 depth; /* Depth of the image */ + const char *data; /* Pointer to image data */ + struct fb_cmap cmap; /* color map info */ +}; + +/* + * hardware cursor control + */ + +#define FB_CUR_SETIMAGE 0x01 +#define FB_CUR_SETPOS 0x02 +#define FB_CUR_SETHOT 0x04 +#define FB_CUR_SETCMAP 0x08 +#define FB_CUR_SETSHAPE 0x10 +#define FB_CUR_SETSIZE 0x20 +#define FB_CUR_SETALL 0xFF + +struct fbcurpos { + u16 x, y; +}; + +struct fb_cursor { + u16 set; /* what to set */ + u16 enable; /* cursor on/off */ + u16 rop; /* bitop operation */ + const char *mask; /* cursor mask bits */ + struct fbcurpos hot; /* cursor hot spot */ + struct fb_image image; /* Cursor image */ +}; + +#endif /* _LINUX_FB_H */ diff --git a/Source/DirectFB/systems/fbdev/fbdev.c b/Source/DirectFB/systems/fbdev/fbdev.c new file mode 100755 index 0000000..3691cff --- /dev/null +++ b/Source/DirectFB/systems/fbdev/fbdev.c @@ -0,0 +1,2782 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include /* Needs to be included before dfb_types.h */ + +#include +#include +#include +#include +#include +#include +#if defined(HAVE_SYSIO) +# include +#endif +#include +#include +#include +#include + +#include + +#ifdef USE_SYSFS +# include +#endif + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "fbdev.h" +#include "fb.h" +#include "vt.h" +#include "agp.h" + +#include + +DFB_CORE_SYSTEM( fbdev ) + + +D_DEBUG_DOMAIN( FBDev_Mode, "FBDev/Mode", "FBDev System Module Mode Switching" ); + +/******************************************************************************/ + +extern const SurfacePoolFuncs fbdevSurfacePoolFuncs; + +static FusionCallHandlerResult +fbdev_ioctl_call_handler( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ); + +static int fbdev_ioctl( int request, void *arg, int arg_size ); + +#define FBDEV_IOCTL(request,arg) fbdev_ioctl( request, arg, sizeof(*(arg)) ) + +FBDev *dfb_fbdev = NULL; + +/******************************************************************************/ + +static int primaryLayerDataSize ( void ); + +static int primaryRegionDataSize( void ); + +static DFBResult primaryInitLayer ( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *config, + DFBColorAdjustment *adjustment ); + +static DFBResult primarySetColorAdjustment( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBColorAdjustment *adjustment ); + +static DFBResult primaryTestRegion ( CoreLayer *layer, + void *driver_data, + void *layer_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags *failed ); + +static DFBResult primaryAddRegion ( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config ); + +static DFBResult primarySetRegion ( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags updated, + CoreSurface *surface, + CorePalette *palette, + CoreSurfaceBufferLock *lock ); + +static DFBResult primaryRemoveRegion ( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data ); + +static DFBResult primaryFlipRegion ( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + DFBSurfaceFlipFlags flags, + CoreSurfaceBufferLock *lock ); + + +static DisplayLayerFuncs primaryLayerFuncs = { + .LayerDataSize = primaryLayerDataSize, + .RegionDataSize = primaryRegionDataSize, + .InitLayer = primaryInitLayer, + + .SetColorAdjustment = primarySetColorAdjustment, + + .TestRegion = primaryTestRegion, + .AddRegion = primaryAddRegion, + .SetRegion = primarySetRegion, + .RemoveRegion = primaryRemoveRegion, + .FlipRegion = primaryFlipRegion, +}; + +/******************************************************************************/ + +static DFBResult primaryInitScreen ( CoreScreen *screen, + CoreGraphicsDevice *device, + void *driver_data, + void *screen_data, + DFBScreenDescription *description ); + +static DFBResult primarySetPowerMode( CoreScreen *screen, + void *driver_data, + void *screen_data, + DFBScreenPowerMode mode ); + +static DFBResult primaryWaitVSync ( CoreScreen *screen, + void *driver_data, + void *layer_data ); + +static DFBResult primaryGetScreenSize( CoreScreen *screen, + void *driver_data, + void *screen_data, + int *ret_width, + int *ret_height ); + +static ScreenFuncs primaryScreenFuncs = { + .InitScreen = primaryInitScreen, + .SetPowerMode = primarySetPowerMode, + .WaitVSync = primaryWaitVSync, + .GetScreenSize = primaryGetScreenSize, +}; + +/******************************************************************************/ + +static DFBResult dfb_fbdev_read_modes( void ); +static DFBResult dfb_fbdev_set_gamma_ramp( DFBSurfacePixelFormat format ); +static DFBResult dfb_fbdev_set_palette( CorePalette *palette ); +static DFBResult dfb_fbdev_set_rgb332_palette( void ); +static DFBResult dfb_fbdev_pan( int xoffset, int yoffset, bool onsync ); +static DFBResult dfb_fbdev_blank( int level ); +static void dfb_fbdev_var_to_mode( const struct fb_var_screeninfo *var, + VideoMode *mode ); + +/******************************************************************************/ + +static inline +void waitretrace (void) +{ +#if defined(HAVE_INB_OUTB_IOPL) + if (iopl(3)) + return; + + if (!(inb (0x3cc) & 1)) { + while ((inb (0x3ba) & 0x8)) + ; + + while (!(inb (0x3ba) & 0x8)) + ; + } + else { + while ((inb (0x3da) & 0x8)) + ; + + while (!(inb (0x3da) & 0x8)) + ; + } +#endif +} + +/******************************************************************************/ + +static DFBResult dfb_fbdev_open( void ) +{ + DFBResult error_result = DFB_FAILURE; + + if (dfb_config->fb_device) { + dfb_fbdev->fd = open( dfb_config->fb_device, O_RDWR ); + if (dfb_fbdev->fd < 0) { + D_PERROR( "DirectFB/FBDev: Error opening '%s'!\n", + dfb_config->fb_device); + + error_result = errno2result( errno ); + goto error; + } + } + else if (getenv( "FRAMEBUFFER" ) && *getenv( "FRAMEBUFFER" ) != '\0') { + dfb_fbdev->fd = open( getenv ("FRAMEBUFFER"), O_RDWR ); + if (dfb_fbdev->fd < 0) { + D_PERROR( "DirectFB/FBDev: Error opening '%s'!\n", + getenv ("FRAMEBUFFER")); + + error_result = errno2result( errno ); + goto error; + } + } + else { + dfb_fbdev->fd = direct_try_open( "/dev/fb0", "/dev/fb/0", O_RDWR, true ); + if (dfb_fbdev->fd < 0) { + D_ERROR( "DirectFB/FBDev: Error opening framebuffer device!\n" ); + D_ERROR( "DirectFB/FBDev: Use 'fbdev' option or set FRAMEBUFFER environment variable.\n" ); + error_result = DFB_INIT; + goto error; + } + } + + /* should be closed automatically in children upon exec(...) */ + if (fcntl( dfb_fbdev->fd, F_SETFD, FD_CLOEXEC ) < 0) + { + D_PERROR( "Fusion/Init: Setting FD_CLOEXEC flag failed!\n" ); + goto error; + } + + return DFB_OK; +error: + return error_result; +} + +/******************************************************************************/ + +static void +dfb_fbdev_get_pci_info( FBDevShared *shared ) +{ + char buf[512]; + int vendor = -1; + int model = -1; + +#ifdef USE_SYSFS + if (!sysfs_get_mnt_path( buf, 512 )) { + struct sysfs_class_device *classdev; + struct sysfs_device *device; + struct sysfs_attribute *attr; + char *fbdev; + char dev[5] = { 'f', 'b', '0', 0, 0 }; + + fbdev = dfb_config->fb_device; + if (!fbdev) + fbdev = getenv( "FRAMEBUFFER" ); + + if (fbdev) { + if (!strncmp( fbdev, "/dev/fb/", 8 )) + snprintf( dev, 5, "fb%s", fbdev+8 ); + else if (!strncmp( fbdev, "/dev/fb", 7 )) + snprintf( dev, 5, "fb%s", fbdev+7 ); + } + + classdev = sysfs_open_class_device( "graphics", dev ); + if (classdev) { + device = sysfs_get_classdev_device( classdev ); + + if (device) { + attr = sysfs_get_device_attr( device, "vendor" ); + if (attr) + sscanf( attr->value, "0x%04x", &vendor ); + + attr = sysfs_get_device_attr( device, "device" ); + if (attr) + sscanf( attr->value, "0x%04x", &model ); + + if (vendor != -1 && model != -1) { + sscanf( device->name, "0000:%02x:%02x.%1x", + &shared->pci.bus, + &shared->pci.dev, + &shared->pci.func ); + + shared->device.vendor = vendor; + shared->device.model = model; + } + } + + sysfs_close_class_device( classdev ); + } + } +#endif /* USE_SYSFS */ + + /* try /proc interface */ + if (vendor == -1 || model == -1) { + FILE *fp; + int id; + int bus; + int dev; + int func; + + fp = fopen( "/proc/bus/pci/devices", "r" ); + if (!fp) { + D_DEBUG( "DirectFB/FBDev: " + "couldn't access /proc/bus/pci/devices!\n" ); + return; + } + + while (fgets( buf, 512, fp )) { + if (sscanf( buf, "%04x\t%04x%04x", &id, &vendor, &model ) == 3) { + bus = (id & 0xff00) >> 8; + dev = (id & 0x00ff) >> 3; + func = (id & 0x0007); + + if (bus == dfb_config->pci.bus && + dev == dfb_config->pci.dev && + func == dfb_config->pci.func) + { + shared->pci.bus = bus; + shared->pci.dev = dev; + shared->pci.func = func; + + shared->device.vendor = vendor; + shared->device.model = model; + + break; + } + } + } + + fclose( fp ); + } +} + + +/** public **/ + +static void +system_get_info( CoreSystemInfo *info ) +{ + info->type = CORE_FBDEV; + info->caps = CSCAPS_ACCELERATION; + + snprintf( info->name, DFB_CORE_SYSTEM_INFO_NAME_LENGTH, "FBDev" ); +} + +static DFBResult +system_initialize( CoreDFB *core, void **data ) +{ + DFBResult ret; + CoreScreen *screen; + long page_size; + FBDevShared *shared = NULL; + FusionSHMPoolShared *pool; + FusionSHMPoolShared *pool_data; + + D_ASSERT( dfb_fbdev == NULL ); + + pool = dfb_core_shmpool( core ); + pool_data = dfb_core_shmpool_data( core ); + + dfb_fbdev = D_CALLOC( 1, sizeof(FBDev) ); + if (!dfb_fbdev) + return D_OOM(); + + dfb_fbdev->fd = -1; + + shared = (FBDevShared*) SHCALLOC( pool, 1, sizeof(FBDevShared) ); + if (!shared) { + ret = D_OOSHM(); + goto error; + } + + shared->shmpool = pool; + shared->shmpool_data = pool_data; + + fusion_arena_add_shared_field( dfb_core_arena( core ), "fbdev", shared ); + + dfb_fbdev->core = core; + dfb_fbdev->shared = shared; + + page_size = direct_pagesize(); + + shared->page_mask = page_size < 0 ? 0 : (page_size - 1); + + ret = dfb_fbdev_open(); + if (ret) + goto error; + + if (dfb_config->vt) { + ret = dfb_vt_initialize(); + if (ret) + goto error; + } + + ret = DFB_INIT; + + /* Retrieve fixed informations like video ram size */ + if (ioctl( dfb_fbdev->fd, FBIOGET_FSCREENINFO, &shared->fix ) < 0) { + D_PERROR( "DirectFB/FBDev: " + "Could not get fixed screen information!\n" ); + goto error; + } + + D_INFO( "DirectFB/FBDev: Found '%s' (ID %d) with frame buffer at 0x%08lx, %dk (MMIO 0x%08lx, %dk)\n", + shared->fix.id, shared->fix.accel, + shared->fix.smem_start, shared->fix.smem_len >> 10, + shared->fix.mmio_start, shared->fix.mmio_len >> 10 ); + + /* Map the framebuffer */ + dfb_fbdev->framebuffer_base = mmap( NULL, shared->fix.smem_len, + PROT_READ | PROT_WRITE, MAP_SHARED, + dfb_fbdev->fd, 0 ); + if (dfb_fbdev->framebuffer_base == MAP_FAILED) { + D_PERROR( "DirectFB/FBDev: " + "Could not mmap the framebuffer!\n"); + dfb_fbdev->framebuffer_base = NULL; + goto error; + } + + if (ioctl( dfb_fbdev->fd, FBIOGET_VSCREENINFO, &shared->orig_var ) < 0) { + D_PERROR( "DirectFB/FBDev: " + "Could not get variable screen information!\n" ); + goto error; + } + + shared->current_var = shared->orig_var; + shared->current_var.accel_flags = 0; + + if (ioctl( dfb_fbdev->fd, FBIOPUT_VSCREENINFO, &shared->current_var ) < 0) { + D_PERROR( "DirectFB/FBDev: " + "Could not disable console acceleration!\n" ); + goto error; + } + + dfb_fbdev_var_to_mode( &shared->current_var, + &shared->current_mode ); + + shared->orig_cmap_memory = SHMALLOC( pool_data, 256 * 2 * 4 ); + if (!shared->orig_cmap_memory) { + ret = D_OOSHM(); + goto error; + } + + shared->orig_cmap.start = 0; + shared->orig_cmap.len = 256; + shared->orig_cmap.red = shared->orig_cmap_memory + 256 * 2 * 0; + shared->orig_cmap.green = shared->orig_cmap_memory + 256 * 2 * 1; + shared->orig_cmap.blue = shared->orig_cmap_memory + 256 * 2 * 2; + shared->orig_cmap.transp = shared->orig_cmap_memory + 256 * 2 * 3; + + if (ioctl( dfb_fbdev->fd, FBIOGETCMAP, &shared->orig_cmap ) < 0) { + D_DEBUG( "DirectFB/FBDev: " + "Could not retrieve palette for backup!\n" ); + + memset( &shared->orig_cmap, 0, sizeof(shared->orig_cmap) ); + + SHFREE( pool_data, shared->orig_cmap_memory ); + shared->orig_cmap_memory = NULL; + } + + shared->temp_cmap_memory = SHMALLOC( pool_data, 256 * 2 * 4 ); + if (!shared->temp_cmap_memory) { + ret = D_OOSHM(); + goto error; + } + + shared->temp_cmap.start = 0; + shared->temp_cmap.len = 256; + shared->temp_cmap.red = shared->temp_cmap_memory + 256 * 2 * 0; + shared->temp_cmap.green = shared->temp_cmap_memory + 256 * 2 * 1; + shared->temp_cmap.blue = shared->temp_cmap_memory + 256 * 2 * 2; + shared->temp_cmap.transp = shared->temp_cmap_memory + 256 * 2 * 3; + + shared->current_cmap_memory = SHMALLOC( pool_data, 256 * 2 * 4 ); + if (!shared->current_cmap_memory) { + ret = D_OOSHM(); + goto error; + } + + shared->current_cmap.start = 0; + shared->current_cmap.len = 256; + shared->current_cmap.red = shared->current_cmap_memory + 256 * 2 * 0; + shared->current_cmap.green = shared->current_cmap_memory + 256 * 2 * 1; + shared->current_cmap.blue = shared->current_cmap_memory + 256 * 2 * 2; + shared->current_cmap.transp = shared->current_cmap_memory + 256 * 2 * 3; + + dfb_fbdev_get_pci_info( shared ); + + if (dfb_config->agp) { + /* Do not fail here, AGP slot could be unavailable */ + ret = dfb_agp_initialize(); + if (ret) { + D_DEBUG( "DirectFB/FBDev: dfb_agp_initialize()\n\t->%s\n", + DirectFBErrorString( ret ) ); + ret = DFB_OK; + } + } + + fusion_call_init( &shared->fbdev_ioctl, + fbdev_ioctl_call_handler, NULL, dfb_core_world(core) ); + + dfb_surface_pool_initialize( core, &fbdevSurfacePoolFuncs, &dfb_fbdev->shared->pool ); + + /* Register primary screen functions */ + screen = dfb_screens_register( NULL, NULL, &primaryScreenFuncs ); + + /* Register primary layer functions */ + dfb_layers_register( screen, NULL, &primaryLayerFuncs ); + + *data = dfb_fbdev; + + return DFB_OK; + + +error: + if (shared) { + if (shared->orig_cmap_memory) + SHFREE( pool_data, shared->orig_cmap_memory ); + + if (shared->temp_cmap_memory) + SHFREE( pool_data, shared->temp_cmap_memory ); + + if (shared->current_cmap_memory) + SHFREE( pool_data, shared->current_cmap_memory ); + + SHFREE( pool, shared ); + } + + if (dfb_fbdev->framebuffer_base) + munmap( dfb_fbdev->framebuffer_base, shared->fix.smem_len ); + + if (dfb_fbdev->fd != -1) + close( dfb_fbdev->fd ); + + D_FREE( dfb_fbdev ); + dfb_fbdev = NULL; + + return ret; +} + +static DFBResult +system_join( CoreDFB *core, void **data ) +{ + DFBResult ret; + CoreScreen *screen; + void *shared; + + D_ASSERT( dfb_fbdev == NULL ); + + if (dfb_config->vt) { + ret = dfb_vt_join(); + if (ret) + return ret; + } + + dfb_fbdev = D_CALLOC( 1, sizeof(FBDev) ); + if (!dfb_fbdev) + return D_OOM(); + + fusion_arena_get_shared_field( dfb_core_arena( core ), + "fbdev", &shared ); + + dfb_fbdev->core = core; + dfb_fbdev->shared = shared; + + /* Open framebuffer device */ + ret = dfb_fbdev_open(); + if (ret) { + D_FREE( dfb_fbdev ); + dfb_fbdev = NULL; + return ret; + } + + /* Map the framebuffer */ + dfb_fbdev->framebuffer_base = mmap( NULL, dfb_fbdev->shared->fix.smem_len, + PROT_READ | PROT_WRITE, MAP_SHARED, + dfb_fbdev->fd, 0 ); + if (dfb_fbdev->framebuffer_base == MAP_FAILED) { + D_PERROR( "DirectFB/FBDev: " + "Could not mmap the framebuffer!\n"); + close( dfb_fbdev->fd ); + D_FREE( dfb_fbdev ); + dfb_fbdev = NULL; + + return DFB_INIT; + } + + /* Open AGP device */ + ret = dfb_agp_join(); + if (ret) { + D_ERROR( "DirectFB/FBDev: Could not join AGP!\n" ); + munmap( dfb_fbdev->framebuffer_base, + dfb_fbdev->shared->fix.smem_len ); + close( dfb_fbdev->fd ); + D_FREE( dfb_fbdev ); + dfb_fbdev = NULL; + + return ret; + } + + dfb_surface_pool_join( core, dfb_fbdev->shared->pool, &fbdevSurfacePoolFuncs ); + + /* Register primary screen functions */ + screen = dfb_screens_register( NULL, NULL, &primaryScreenFuncs ); + + /* Register primary layer functions */ + dfb_layers_register( screen, NULL, &primaryLayerFuncs ); + + *data = dfb_fbdev; + + return DFB_OK; +} + +static DFBResult +system_shutdown( bool emergency ) +{ + DFBResult ret; + VideoMode *m; + FBDevShared *shared; + FusionSHMPoolShared *pool; + + D_ASSERT( dfb_fbdev != NULL ); + + shared = dfb_fbdev->shared; + + D_ASSERT( shared != NULL ); + + pool = shared->shmpool; + + D_ASSERT( pool != NULL ); + + m = shared->modes; + while (m) { + VideoMode *next = m->next; + SHFREE( pool, m ); + m = next; + } + + if (ioctl( dfb_fbdev->fd, FBIOPUT_VSCREENINFO, &shared->orig_var ) < 0) { + D_PERROR( "DirectFB/FBDev: " + "Could not restore variable screen information!\n" ); + } + + if (shared->orig_cmap.len) { + if (ioctl( dfb_fbdev->fd, FBIOPUTCMAP, &shared->orig_cmap ) < 0) + D_DEBUG( "DirectFB/FBDev: " + "Could not restore palette!\n" ); + } + + if (shared->orig_cmap_memory) + SHFREE( shared->shmpool_data, shared->orig_cmap_memory ); + + if (shared->temp_cmap_memory) + SHFREE( shared->shmpool_data, shared->temp_cmap_memory ); + + if (shared->current_cmap_memory) + SHFREE( shared->shmpool_data, shared->current_cmap_memory ); + + fusion_call_destroy( &shared->fbdev_ioctl ); + + dfb_agp_shutdown(); + + dfb_surface_pool_destroy( dfb_fbdev->shared->pool ); + + munmap( dfb_fbdev->framebuffer_base, shared->fix.smem_len ); + + if (dfb_config->vt) { + ret = dfb_vt_shutdown( emergency ); + if (ret) + return ret; + } + + close( dfb_fbdev->fd ); + + SHFREE( pool, shared ); + D_FREE( dfb_fbdev ); + dfb_fbdev = NULL; + + return DFB_OK; +} + +static DFBResult +system_leave( bool emergency ) +{ + DFBResult ret; + + D_ASSERT( dfb_fbdev != NULL ); + + dfb_agp_leave(); + + dfb_surface_pool_leave( dfb_fbdev->shared->pool ); + + munmap( dfb_fbdev->framebuffer_base, + dfb_fbdev->shared->fix.smem_len ); + + if (dfb_config->vt) { + ret = dfb_vt_leave( emergency ); + if (ret) + return ret; + } + + close( dfb_fbdev->fd ); + + D_FREE( dfb_fbdev ); + dfb_fbdev = NULL; + + return DFB_OK; +} + +static DFBResult +system_suspend( void ) +{ + return DFB_OK; +} + +static DFBResult +system_resume( void ) +{ + return DFB_OK; +} + +/******************************************************************************/ + +static volatile void * +system_map_mmio( unsigned int offset, + int length ) +{ + void *addr; + + if (length <= 0) + length = dfb_fbdev->shared->fix.mmio_len; + + addr = mmap( NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, + dfb_fbdev->fd, dfb_fbdev->shared->fix.smem_len + offset ); + if (addr == MAP_FAILED) { + D_PERROR( "DirectFB/FBDev: Could not mmap MMIO region " + "(offset %d, length %d)!\n", offset, length ); + return NULL; + } + + return(volatile void*) ((u8*) addr + (dfb_fbdev->shared->fix.mmio_start & + dfb_fbdev->shared->page_mask)); +} + +static void +system_unmap_mmio( volatile void *addr, + int length ) +{ + if (length <= 0) + length = dfb_fbdev->shared->fix.mmio_len; + + if (munmap( (void*) ((u8*) addr - (dfb_fbdev->shared->fix.mmio_start & + dfb_fbdev->shared->page_mask)), length ) < 0) + D_PERROR( "DirectFB/FBDev: Could not unmap MMIO region " + "at %p (length %d)!\n", addr, length ); +} + +static int +system_get_accelerator( void ) +{ +#ifdef FB_ACCEL_MATROX_MGAG400 + if (!strcmp( dfb_fbdev->shared->fix.id, "MATROX DH" )) + return FB_ACCEL_MATROX_MGAG400; +#endif +#ifdef FB_ACCEL_EP9X + if (!strcmp( dfb_fbdev->shared->fix.id, "ep9xfb" )) + return FB_ACCEL_EP9X; +#endif + + if (dfb_config->accelerator) + return dfb_config->accelerator; + + if (dfb_fbdev->shared->fix.mmio_len > 0) + return dfb_fbdev->shared->fix.accel; + return -1; +} + +static VideoMode * +system_get_modes( void ) +{ + return dfb_fbdev->shared->modes; +} + +static VideoMode * +system_get_current_mode( void ) +{ + return &dfb_fbdev->shared->current_mode; +} + +static DFBResult +system_thread_init( void ) +{ + if (dfb_config->block_all_signals) + direct_signals_block_all(); + + return DFB_OK; +} + +static bool +system_input_filter( CoreInputDevice *device, + DFBInputEvent *event ) +{ + if (dfb_config->vt && dfb_config->vt_switching) { + switch (event->type) { + case DIET_KEYPRESS: + if (DFB_KEY_TYPE(event->key_symbol) == DIKT_FUNCTION && + event->modifiers == (DIMM_CONTROL | DIMM_ALT)) + return dfb_vt_switch( event->key_symbol - DIKS_F1 + 1 ); + + break; + + case DIET_KEYRELEASE: + if (DFB_KEY_TYPE(event->key_symbol) == DIKT_FUNCTION && + event->modifiers == (DIMM_CONTROL | DIMM_ALT)) + return true; + + break; + + default: + break; + } + } + + return false; +} + +static unsigned long +system_video_memory_physical( unsigned int offset ) +{ + return dfb_fbdev->shared->fix.smem_start + offset; +} + +static void * +system_video_memory_virtual( unsigned int offset ) +{ + return(void*)((u8*)(dfb_fbdev->framebuffer_base) + offset); +} + +static unsigned int +system_videoram_length( void ) +{ + return dfb_fbdev->shared->fix.smem_len; +} + +static unsigned long +system_aux_memory_physical( unsigned int offset ) +{ + if (dfb_fbdev->shared->agp) + return dfb_fbdev->shared->agp->info.aper_base + offset; + return 0; +} + +static void * +system_aux_memory_virtual( unsigned int offset ) +{ + if (dfb_fbdev->agp) + return (void*)(u8*)dfb_fbdev->agp->base + offset; + return NULL; +} + +static unsigned int +system_auxram_length( void ) +{ + if (dfb_fbdev->shared->agp) + return dfb_fbdev->shared->agp->agp_mem; + return 0; +} + +static void +system_get_busid( int *ret_bus, int *ret_dev, int *ret_func ) +{ + *ret_bus = dfb_fbdev->shared->pci.bus; + *ret_dev = dfb_fbdev->shared->pci.dev; + *ret_func = dfb_fbdev->shared->pci.func; +} + +static void +system_get_deviceid( unsigned int *ret_vendor_id, + unsigned int *ret_device_id ) +{ + *ret_vendor_id = dfb_fbdev->shared->device.vendor; + *ret_device_id = dfb_fbdev->shared->device.model; +} + +/******************************************************************************/ + +static DFBResult +init_modes( void ) +{ + dfb_fbdev_read_modes(); + + if (!dfb_fbdev->shared->modes) { + /* try to use current mode*/ + dfb_fbdev->shared->modes = (VideoMode*) SHCALLOC( dfb_fbdev->shared->shmpool, + 1, sizeof(VideoMode) ); + if (!dfb_fbdev->shared->modes) + return D_OOSHM(); + + *dfb_fbdev->shared->modes = dfb_fbdev->shared->current_mode; + + if (dfb_fbdev_test_mode_simple(dfb_fbdev->shared->modes)) { + D_ERROR("DirectFB/FBDev: " + "No supported modes found in /etc/fb.modes and " + "current mode not supported!\n"); + + D_ERROR( "DirectFB/FBDev: Current mode's pixelformat: " + "rgba %d/%d, %d/%d, %d/%d, %d/%d (%dbit)\n", + dfb_fbdev->shared->orig_var.red.length, + dfb_fbdev->shared->orig_var.red.offset, + dfb_fbdev->shared->orig_var.green.length, + dfb_fbdev->shared->orig_var.green.offset, + dfb_fbdev->shared->orig_var.blue.length, + dfb_fbdev->shared->orig_var.blue.offset, + dfb_fbdev->shared->orig_var.transp.length, + dfb_fbdev->shared->orig_var.transp.offset, + dfb_fbdev->shared->orig_var.bits_per_pixel ); + + return DFB_INIT; + } + } + + return DFB_OK; +} + +/******************************************************************************/ + +static DFBResult +primaryInitScreen( CoreScreen *screen, + CoreGraphicsDevice *device, + void *driver_data, + void *screen_data, + DFBScreenDescription *description ) +{ + /* Set the screen capabilities. */ + description->caps = DSCCAPS_VSYNC | DSCCAPS_POWER_MANAGEMENT; + + /* Set the screen name. */ + snprintf( description->name, + DFB_SCREEN_DESC_NAME_LENGTH, "FBDev Primary Screen" ); + + return DFB_OK; +} + +static DFBResult +primarySetPowerMode( CoreScreen *screen, + void *driver_data, + void *screen_data, + DFBScreenPowerMode mode ) +{ + int level; + + switch (mode) { + case DSPM_OFF: + level = 4; + break; + case DSPM_SUSPEND: + level = 3; + break; + case DSPM_STANDBY: + level = 2; + break; + case DSPM_ON: + level = 0; + break; + default: + return DFB_INVARG; + } + + return dfb_fbdev_blank( level ); +} + +static DFBResult +primaryWaitVSync( CoreScreen *screen, + void *driver_data, + void *screen_data ) +{ + static const int zero = 0; + + if (dfb_config->pollvsync_none) + return DFB_OK; + + if (ioctl( dfb_fbdev->fd, FBIO_WAITFORVSYNC, &zero )) + waitretrace(); + + return DFB_OK; +} + +static DFBResult +primaryGetScreenSize( CoreScreen *screen, + void *driver_data, + void *screen_data, + int *ret_width, + int *ret_height ) +{ + D_ASSERT( dfb_fbdev != NULL ); + D_ASSERT( dfb_fbdev->shared != NULL ); + + *ret_width = dfb_fbdev->shared->current_mode.xres; + *ret_height = dfb_fbdev->shared->current_mode.yres; + + return DFB_OK; +} + +/******************************************************************************/ + +static int +primaryLayerDataSize( void ) +{ + return 0; +} + +static int +primaryRegionDataSize( void ) +{ + return 0; +} + +static DFBResult +primaryInitLayer( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *config, + DFBColorAdjustment *adjustment ) +{ + DFBResult ret; + VideoMode *default_mode; + + /* initialize mode table */ + ret = init_modes(); + if (ret) + return ret; + + default_mode = dfb_fbdev->shared->modes; + + /* set capabilities and type */ + description->caps = DLCAPS_SURFACE | DLCAPS_CONTRAST | + DLCAPS_SATURATION | DLCAPS_BRIGHTNESS; + description->type = DLTF_GRAPHICS; + + /* set name */ + snprintf( description->name, + DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, "FBDev Primary Layer" ); + + /* fill out default color adjustment */ + adjustment->flags = DCAF_BRIGHTNESS | DCAF_CONTRAST | DCAF_SATURATION; + adjustment->brightness = 0x8000; + adjustment->contrast = 0x8000; + adjustment->saturation = 0x8000; + + /* fill out the default configuration */ + config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | + DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE; + config->buffermode = DLBM_FRONTONLY; + config->width = dfb_config->mode.width ? dfb_config->mode.width : default_mode->xres; + config->height = dfb_config->mode.height ? dfb_config->mode.height : default_mode->yres; + + if (dfb_config->mode.format) + config->pixelformat = dfb_config->mode.format; + else + config->pixelformat = dfb_pixelformat_for_depth( default_mode->bpp ); + + return DFB_OK; +} + +static DFBResult +primarySetColorAdjustment( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBColorAdjustment *adjustment ) +{ + struct fb_cmap *cmap = &dfb_fbdev->shared->current_cmap; + struct fb_cmap *temp = &dfb_fbdev->shared->temp_cmap; + int contrast = adjustment->contrast >> 8; + int brightness = (adjustment->brightness >> 8) - 128; + int saturation = adjustment->saturation >> 8; + int r, g, b, i; + + if (dfb_fbdev->shared->fix.visual != FB_VISUAL_DIRECTCOLOR) + return DFB_UNIMPLEMENTED; + + /* Use gamma ramp to set color attributes */ + for (i = 0; i < (int)cmap->len; i++) { + r = cmap->red[i]; + g = cmap->green[i]; + b = cmap->blue[i]; + r >>= 8; + g >>= 8; + b >>= 8; + + /* + * Brightness Adjustment: Increase/Decrease each color channels + * by a constant amount as specified by value of brightness. + */ + if (adjustment->flags & DCAF_BRIGHTNESS) { + r += brightness; + g += brightness; + b += brightness; + + r = CLAMP( r, 0, 255 ); + g = CLAMP( g, 0, 255 ); + b = CLAMP( b, 0, 255 ); + } + + /* + * Contrast Adjustment: We increase/decrease the "separation" + * between colors in proportion to the value specified by the + * contrast control. Decreasing the contrast has a side effect + * of decreasing the brightness. + */ + + if (adjustment->flags & DCAF_CONTRAST) { + /* Increase contrast */ + if (contrast > 128) { + int c = contrast - 128; + + r = ((r + c/2)/c) * c; + g = ((g + c/2)/c) * c; + b = ((b + c/2)/c) * c; + } + /* Decrease contrast */ + else if (contrast < 127) { + r = (r * contrast) >> 7; + g = (g * contrast) >> 7; + b = (b * contrast) >> 7; + } + + r = CLAMP( r, 0, 255 ); + g = CLAMP( g, 0, 255 ); + b = CLAMP( b, 0, 255 ); + } + + /* + * Saturation Adjustment: This is is a better implementation. + * Saturation is implemented by "mixing" a proportion of medium + * gray to the color value. On the other side, "removing" + * a proportion of medium gray oversaturates the color. + */ + if (adjustment->flags & DCAF_SATURATION) { + if (saturation > 128) { + int gray = saturation - 128; + int color = 128 - gray; + + r = ((r - gray) << 7) / color; + g = ((g - gray) << 7) / color; + b = ((b - gray) << 7) / color; + } + else if (saturation < 128) { + int color = saturation; + int gray = 128 - color; + + r = ((r * color) >> 7) + gray; + g = ((g * color) >> 7) + gray; + b = ((b * color) >> 7) + gray; + } + + r = CLAMP( r, 0, 255 ); + g = CLAMP( g, 0, 255 ); + b = CLAMP( b, 0, 255 ); + } + r |= r << 8; + g |= g << 8; + b |= b << 8; + + temp->red[i] = (unsigned short)r; + temp->green[i] = (unsigned short)g; + temp->blue[i] = (unsigned short)b; + } + + temp->len = cmap->len; + temp->start = cmap->start; + if (FBDEV_IOCTL( FBIOPUTCMAP, temp ) < 0) { + D_PERROR( "DirectFB/FBDev: Could not set the palette!\n" ); + + return errno2result(errno); + } + + return DFB_OK; +} + +const VideoMode * +dfb_fbdev_find_mode( int width, int height ) +{ + FBDevShared *shared = dfb_fbdev->shared; + const VideoMode *videomode = shared->modes; + const VideoMode *highest = NULL; + + while (videomode) { + if (videomode->xres == width && videomode->yres == height) { + if (!highest || highest->priority < videomode->priority) + highest = videomode; + } + + videomode = videomode->next; + } + + if (!highest) + D_ERROR( "FBDev/Mode: No mode found for %dx%d!\n", width, height ); + + return highest; +} + +static DFBResult +primaryTestRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags *failed ) +{ + FBDevShared *shared = dfb_fbdev->shared; + CoreLayerRegionConfigFlags fail = CLRCF_NONE; + const VideoMode *mode; + + D_DEBUG_AT( FBDev_Mode, "%s( %dx%d, %s )\n", __FUNCTION__, + config->source.w, config->source.h, dfb_pixelformat_name(config->format) ); + + mode = dfb_fbdev_find_mode( config->source.w, config->source.h ); + + if (!mode || dfb_fbdev_test_mode( mode, config )) + fail |= CLRCF_WIDTH | CLRCF_HEIGHT | CLRCF_FORMAT | CLRCF_BUFFERMODE; + + if (config->options) + fail |= CLRCF_OPTIONS; + + if ((config->source.x && !shared->fix.xpanstep) || + (config->source.y && !shared->fix.ypanstep && !shared->fix.ywrapstep)) + fail |= CLRCF_SOURCE; + + 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 ) +{ + DFBResult ret; + FBDevShared *shared = dfb_fbdev->shared; + + if (updated & CLRCF_SOURCE) { + if (config->source.w == shared->current_var.xres && config->source.h == shared->current_var.yres) { + ret = dfb_fbdev_pan( config->source.x, lock->offset / lock->pitch + config->source.y, true ); + if (ret) + return ret; + } + else { + const VideoMode *mode; + + D_INFO( "FBDev/Mode: Setting %dx%d %s\n", config->source.w, config->source.h, + dfb_pixelformat_name( surface->config.format ) ); + + mode = dfb_fbdev_find_mode( config->source.w, config->source.h ); + if (!mode) + return DFB_UNSUPPORTED; + + ret = dfb_fbdev_set_mode( mode, surface, config->source.x, + lock->offset / lock->pitch + config->source.y ); + if (ret) + return ret; + } + } + + if ((updated & CLRCF_PALETTE) && palette) + dfb_fbdev_set_palette( palette ); + + /* remember configuration */ + shared->config = *config; + + 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 ) +{ + DFBResult ret; + CoreLayerRegionConfig *config = &dfb_fbdev->shared->config; + + if (((flags & DSFLIP_WAITFORSYNC) == DSFLIP_WAITFORSYNC) && + !dfb_config->pollvsync_after) + dfb_screen_wait_vsync( dfb_screens_at(DSCID_PRIMARY) ); + + ret = dfb_fbdev_pan( config->source.x, + lock->offset / lock->pitch + config->source.y, + (flags & DSFLIP_WAITFORSYNC) == DSFLIP_ONSYNC ); + if (ret) + return ret; + + if ((flags & DSFLIP_WAIT) && + (dfb_config->pollvsync_after || !(flags & DSFLIP_ONSYNC))) + dfb_screen_wait_vsync( dfb_screens_at(DSCID_PRIMARY) ); + + dfb_surface_flip( surface, false ); + + return DFB_OK; +} + +/** fbdev internal **/ + +static void +dfb_fbdev_var_to_mode( const struct fb_var_screeninfo *var, + VideoMode *mode ) +{ + mode->xres = var->xres; + mode->yres = var->yres; + mode->bpp = var->bits_per_pixel; + mode->hsync_len = var->hsync_len; + mode->vsync_len = var->vsync_len; + mode->left_margin = var->left_margin; + mode->right_margin = var->right_margin; + mode->upper_margin = var->upper_margin; + mode->lower_margin = var->lower_margin; + mode->pixclock = var->pixclock; + mode->hsync_high = (var->sync & FB_SYNC_HOR_HIGH_ACT) ? 1 : 0; + mode->vsync_high = (var->sync & FB_SYNC_VERT_HIGH_ACT) ? 1 : 0; + mode->csync_high = (var->sync & FB_SYNC_COMP_HIGH_ACT) ? 1 : 0; + mode->sync_on_green = (var->sync & FB_SYNC_ON_GREEN) ? 1 : 0; + mode->external_sync = (var->sync & FB_SYNC_EXT) ? 1 : 0; + mode->broadcast = (var->sync & FB_SYNC_BROADCAST) ? 1 : 0; + mode->laced = (var->vmode & FB_VMODE_INTERLACED) ? 1 : 0; + mode->doubled = (var->vmode & FB_VMODE_DOUBLE) ? 1 : 0; +} + +#if 0 +static int dfb_fbdev_compatible_format( struct fb_var_screeninfo *var, + int al, int rl, int gl, int bl, + int ao, int ro, int go, int bo ) +{ + int ah, rh, gh, bh; + int vah, vrh, vgh, vbh; + + ah = al + ao - 1; + rh = rl + ro - 1; + gh = gl + go - 1; + bh = bl + bo - 1; + + vah = var->transp.length + var->transp.offset - 1; + vrh = var->red.length + var->red.offset - 1; + vgh = var->green.length + var->green.offset - 1; + vbh = var->blue.length + var->blue.offset - 1; + + if ((!al || (ah == vah && al >= (int)var->transp.length)) && + (!rl || (rh == vrh && rl >= (int)var->red.length)) && + (!gl || (gh == vgh && gl >= (int)var->green.length)) && + (!bl || (bh == vbh && bl >= (int)var->blue.length))) + return 1; + + return 0; +} + +static DFBSurfacePixelFormat dfb_fbdev_get_pixelformat( struct fb_var_screeninfo *var ) +{ + switch (var->bits_per_pixel) { + + case 8: +/* + This check is omitted, since we want to use RGB332 even if the + hardware uses a palette (in that case we initialize a calculated + one to have correct colors) + + if (fbdev_compatible_format( var, 0, 3, 3, 2, 0, 5, 2, 0 ))*/ + + return DSPF_RGB332; + + case 15: + if (dfb_fbdev_compatible_format( var, 0, 5, 5, 5, 0, 10, 5, 0 )) + return DSPF_RGB555; + + if(dfb_fbdev_compatible_format( var, 1, 5, 5, 5, 15, 10, 5, 0 )) + return DSPF_ARGB1555; + + if (dfb_fbdev_compatible_format( var, 0, 5, 5, 5, 0, 0, 5, 10 )) + return DSPF_BGR555; + + break; + + case 16: + if (dfb_fbdev_compatible_format( var, 0, 5, 5, 5, 0, 10, 5, 0 )) + return DSPF_RGB555; + + if(dfb_fbdev_compatible_format( var, 1, 5, 5, 5, 15, 10, 5, 0 )) + return DSPF_ARGB1555; + + if (dfb_fbdev_compatible_format( var, 4, 4, 4, 4, 12, 8, 4, 0 )) + return DSPF_ARGB4444; + + if (dfb_fbdev_compatible_format( var, 4, 4, 4, 4, 0, 12, 8, 4 )) + return DSPF_RGBA4444; + + if (dfb_fbdev_compatible_format( var, 0, 4, 4, 4, 0, 8, 4, 0 )) + return DSPF_RGB444; + + if (dfb_fbdev_compatible_format( var, 0, 5, 6, 5, 0, 11, 5, 0 )) + return DSPF_RGB16; + + if (dfb_fbdev_compatible_format( var, 0, 5, 5, 5, 0, 0, 5, 10 )) + return DSPF_BGR555; + + break; + + case 18: + if (dfb_fbdev_compatible_format( var, 1, 6, 6, 6, 18, 12, 6, 0 )) + return DSPF_ARGB1666; + + if (dfb_fbdev_compatible_format( var, 6, 6, 6, 6, 18, 12, 6, 0 )) + return DSPF_ARGB6666; + + if (dfb_fbdev_compatible_format( var, 0, 6, 6, 6, 0, 12, 6, 0 )) + return DSPF_RGB18; + break; + + case 24: + if (dfb_fbdev_compatible_format( var, 0, 8, 8, 8, 0, 16, 8, 0 )) + return DSPF_RGB24; + + if (dfb_fbdev_compatible_format( var, 6, 6, 6, 6, 18, 12, 6, 0 )) + return DSPF_ARGB6666; + break; + + case 32: + if (dfb_fbdev_compatible_format( var, 0, 8, 8, 8, 0, 16, 8, 0 )) + return DSPF_RGB32; + + if (dfb_fbdev_compatible_format( var, 8, 8, 8, 8, 24, 16, 8, 0 )) + return DSPF_ARGB; + + break; + } + + D_ERROR( "DirectFB/FBDev: Unsupported pixelformat: " + "rgba %d/%d, %d/%d, %d/%d, %d/%d (%dbit)\n", + var->red.length, var->red.offset, + var->green.length, var->green.offset, + var->blue.length, var->blue.offset, + var->transp.length, var->transp.offset, + var->bits_per_pixel ); + + return DSPF_UNKNOWN; +} +#endif + +/* + * pans display (flips buffer) using fbdev ioctl + */ +static DFBResult +dfb_fbdev_pan( int xoffset, int yoffset, bool onsync ) +{ +// DFBResult ret; + int result; + struct fb_var_screeninfo *var; + FBDevShared *shared = dfb_fbdev->shared; + + if (!shared->fix.xpanstep && !shared->fix.ypanstep && !shared->fix.ywrapstep) + return DFB_OK; + + var = &shared->current_var; + + if (var->xres_virtual < xoffset + var->xres) { + D_ERROR( "DirectFB/FBDev: xres %d, vxres %d, xoffset %d\n", + var->xres, var->xres_virtual, xoffset ); + D_BUG( "panning buffer out of range" ); + return DFB_BUG; + } + + if (var->yres_virtual < yoffset + var->yres) { + D_ERROR( "DirectFB/FBDev: yres %d, vyres %d, offset %d\n", + var->yres, var->yres_virtual, yoffset ); + D_BUG( "panning buffer out of range" ); + return DFB_BUG; + } + + if (shared->fix.xpanstep) + var->xoffset = xoffset - (xoffset % shared->fix.xpanstep); + else + var->xoffset = 0; + + if (shared->fix.ywrapstep) { + var->yoffset = yoffset - (yoffset % shared->fix.ywrapstep); + var->vmode |= FB_VMODE_YWRAP; + } + else if (shared->fix.ypanstep) { + var->yoffset = yoffset - (yoffset % shared->fix.ypanstep); + var->vmode &= ~FB_VMODE_YWRAP; + } + else { + var->yoffset = 0; + } + + var->activate = onsync ? FB_ACTIVATE_VBL : FB_ACTIVATE_NOW; + +#if 0 + ret = fusion_call_execute( &shared->fbdev_ioctl, FCEF_NONE, FBIOPAN_DISPLAY, var, &result ); + if (ret) + return DFB_FUSION; + + if (result) { + errno = result; +#else + if (ioctl( dfb_fbdev->fd, FBIOPAN_DISPLAY, var ) < 0) { + result = errno; +#endif + D_PERROR( "DirectFB/FBDev: Panning display failed (x=%u y=%u ywrap=%d vbl=%d)!\n", + var->xoffset, var->yoffset, + (var->vmode & FB_VMODE_YWRAP) ? 1 : 0, + (var->activate & FB_ACTIVATE_VBL) ? 1 : 0); + + return errno2result(result); + } + + return DFB_OK; +} + +/* + * blanks display using fbdev ioctl + */ +static DFBResult +dfb_fbdev_blank( int level ) +{ + if (ioctl( dfb_fbdev->fd, FBIOBLANK, level ) < 0) { + D_PERROR( "DirectFB/FBDev: Display blanking failed!\n" ); + + return errno2result( errno ); + } + + return DFB_OK; +} + +static DFBResult +dfb_fbdev_mode_to_var( const VideoMode *mode, + DFBSurfacePixelFormat pixelformat, + unsigned int vxres, + unsigned int vyres, + unsigned int xoffset, + unsigned int yoffset, + DFBDisplayLayerBufferMode buffermode, + struct fb_var_screeninfo *ret_var ) +{ + struct fb_var_screeninfo var; + FBDevShared *shared = dfb_fbdev->shared; + + D_DEBUG_AT( FBDev_Mode, "%s( mode: %p )\n", __FUNCTION__, mode ); + + D_ASSERT( mode != NULL ); + D_ASSERT( ret_var != NULL ); + + D_DEBUG_AT( FBDev_Mode, " -> resolution %dx%d\n", mode->xres, mode->yres ); + D_DEBUG_AT( FBDev_Mode, " -> virtual %dx%d\n", vxres, vyres ); + D_DEBUG_AT( FBDev_Mode, " -> pixelformat %s\n", dfb_pixelformat_name(pixelformat) ); + D_DEBUG_AT( FBDev_Mode, " -> buffermode %s\n", + buffermode == DLBM_FRONTONLY ? "FRONTONLY" : + buffermode == DLBM_BACKVIDEO ? "BACKVIDEO" : + buffermode == DLBM_BACKSYSTEM ? "BACKSYSTEM" : + buffermode == DLBM_TRIPLE ? "TRIPLE" : "invalid!" ); + + /* Start from current information */ + var = shared->current_var; + var.activate = FB_ACTIVATE_NOW; + + /* Set timings */ + var.pixclock = mode->pixclock; + var.left_margin = mode->left_margin; + var.right_margin = mode->right_margin; + var.upper_margin = mode->upper_margin; + var.lower_margin = mode->lower_margin; + var.hsync_len = mode->hsync_len; + var.vsync_len = mode->vsync_len; + + /* Set resolution */ + var.xres = mode->xres; + var.yres = mode->yres; + var.xres_virtual = vxres; + var.yres_virtual = vyres; + + if (shared->fix.xpanstep) + var.xoffset = xoffset - (xoffset % shared->fix.xpanstep); + else + var.xoffset = 0; + + if (shared->fix.ywrapstep) + var.yoffset = yoffset - (yoffset % shared->fix.ywrapstep); + else if (shared->fix.ypanstep) + var.yoffset = yoffset - (yoffset % shared->fix.ypanstep); + else + var.yoffset = 0; + + /* Set buffer mode */ + switch (buffermode) { + case DLBM_TRIPLE: + if (shared->fix.ypanstep == 0 && shared->fix.ywrapstep == 0) + return DFB_UNSUPPORTED; + + var.yres_virtual *= 3; + break; + + case DLBM_BACKVIDEO: + if (shared->fix.ypanstep == 0 && shared->fix.ywrapstep == 0) + return DFB_UNSUPPORTED; + + var.yres_virtual *= 2; + break; + + case DLBM_BACKSYSTEM: + case DLBM_FRONTONLY: + break; + + default: + return DFB_UNSUPPORTED; + } + + /* Set pixel format */ + var.bits_per_pixel = DFB_BITS_PER_PIXEL(pixelformat); + var.transp.length = var.transp.offset = 0; + + switch (pixelformat) { + case DSPF_ARGB1555: + var.transp.length = 1; + var.red.length = 5; + var.green.length = 5; + var.blue.length = 5; + var.transp.offset = 15; + var.red.offset = 10; + var.green.offset = 5; + var.blue.offset = 0; + break; + + case DSPF_RGB555: + var.red.length = 5; + var.green.length = 5; + var.blue.length = 5; + var.red.offset = 10; + var.green.offset = 5; + var.blue.offset = 0; + break; + + case DSPF_ARGB4444: + var.transp.length = 4; + var.red.length = 4; + var.green.length = 4; + var.blue.length = 4; + var.transp.offset = 12; + var.red.offset = 8; + var.green.offset = 4; + var.blue.offset = 0; + break; + + case DSPF_RGBA4444: + var.transp.length = 4; + var.red.length = 4; + var.green.length = 4; + var.blue.length = 4; + var.transp.offset = 0; + var.red.offset = 12; + var.green.offset = 8; + var.blue.offset = 4; + break; + + case DSPF_RGB444: + var.red.length = 4; + var.green.length = 4; + var.blue.length = 4; + var.red.offset = 8; + var.green.offset = 4; + var.blue.offset = 0; + break; + + case DSPF_RGB32: + var.red.length = 8; + var.green.length = 8; + var.blue.length = 8; + var.red.offset = 16; + var.green.offset = 8; + var.blue.offset = 0; + break; + + case DSPF_RGB16: + var.red.length = 5; + var.green.length = 6; + var.blue.length = 5; + var.red.offset = 11; + var.green.offset = 5; + var.blue.offset = 0; + break; + + case DSPF_ARGB: + case DSPF_AiRGB: + var.transp.length = 8; + var.red.length = 8; + var.green.length = 8; + var.blue.length = 8; + var.transp.offset = 24; + var.red.offset = 16; + var.green.offset = 8; + var.blue.offset = 0; + break; + + case DSPF_LUT8: + case DSPF_RGB24: + case DSPF_RGB332: + break; + + case DSPF_ARGB1666: + var.transp.length = 1; + var.red.length = 6; + var.green.length = 6; + var.blue.length = 6; + var.transp.offset = 18; + var.red.offset = 12; + var.green.offset = 6; + var.blue.offset = 0; + break; + + case DSPF_ARGB6666: + var.transp.length = 6; + var.red.length = 6; + var.green.length = 6; + var.blue.length = 6; + var.transp.offset = 18; + var.red.offset = 12; + var.green.offset = 6; + var.blue.offset = 0; + break; + + case DSPF_RGB18: + var.red.length = 6; + var.green.length = 6; + var.blue.length = 6; + var.red.offset = 12; + var.green.offset = 6; + var.blue.offset = 0; + break; + + default: + return DFB_UNSUPPORTED; + } + + /* Set sync options */ + var.sync = 0; + if (mode->hsync_high) + var.sync |= FB_SYNC_HOR_HIGH_ACT; + if (mode->vsync_high) + var.sync |= FB_SYNC_VERT_HIGH_ACT; + if (mode->csync_high) + var.sync |= FB_SYNC_COMP_HIGH_ACT; + if (mode->sync_on_green) + var.sync |= FB_SYNC_ON_GREEN; + if (mode->external_sync) + var.sync |= FB_SYNC_EXT; + if (mode->broadcast) + var.sync |= FB_SYNC_BROADCAST; + + /* Set interlace/linedouble */ + var.vmode = 0; + if (mode->laced) + var.vmode |= FB_VMODE_INTERLACED; + if (mode->doubled) + var.vmode |= FB_VMODE_DOUBLE; + + *ret_var = var; + + return DFB_OK; +} + +DFBResult +dfb_fbdev_test_mode( const VideoMode *mode, + const CoreLayerRegionConfig *config ) +{ + DFBResult ret; + struct fb_var_screeninfo var; + FBDevShared *shared = dfb_fbdev->shared; + const DFBRectangle *source = &config->source; + + D_DEBUG_AT( FBDev_Mode, "%s( mode: %p, config: %p )\n", __FUNCTION__, mode, config ); + + D_ASSERT( mode != NULL ); + D_ASSERT( config != NULL ); + + /* Is panning supported? */ + if (source->w != mode->xres && shared->fix.xpanstep == 0) + return DFB_UNSUPPORTED; + if (source->h != mode->yres && shared->fix.ypanstep == 0 && shared->fix.ywrapstep == 0) + return DFB_UNSUPPORTED; + + ret = dfb_fbdev_mode_to_var( mode, config->format, config->width, config->height, + 0, 0, config->buffermode, &var ); + if (ret) + return ret; + + /* Enable test mode */ + var.activate = FB_ACTIVATE_TEST; + + + dfb_gfxcard_lock( GDLF_WAIT | GDLF_SYNC | GDLF_RESET | GDLF_INVALIDATE ); + + if (FBDEV_IOCTL( FBIOPUT_VSCREENINFO, &var ) < 0) { + int erno = errno; + dfb_gfxcard_unlock(); + D_DEBUG_AT( FBDev_Mode, " => FAILED!\n" ); + return errno2result( erno ); + } + + dfb_gfxcard_unlock(); + + D_DEBUG_AT( FBDev_Mode, " => SUCCESS\n" ); + + return DFB_OK; +} + +DFBResult +dfb_fbdev_test_mode_simple( const VideoMode *mode ) +{ + DFBResult ret; + struct fb_var_screeninfo var; + + D_DEBUG_AT( FBDev_Mode, "%s( mode: %p )\n", __FUNCTION__, mode ); + + D_ASSERT( mode != NULL ); + + ret = dfb_fbdev_mode_to_var( mode, dfb_pixelformat_for_depth(mode->bpp), mode->xres, mode->yres, + 0, 0, DLBM_FRONTONLY, &var ); + if (ret) + return ret; + + /* Enable test mode */ + var.activate = FB_ACTIVATE_TEST; + + if (FBDEV_IOCTL( FBIOPUT_VSCREENINFO, &var ) < 0) { + D_DEBUG_AT( FBDev_Mode, " => FAILED!\n" ); + return errno2result( errno ); + } + + D_DEBUG_AT( FBDev_Mode, " => SUCCESS\n" ); + + return DFB_OK; +} + +static int num_video_buffers( CoreSurface *surface ) +{ + int i; + + for (i = 0; i < surface->num_buffers; i++) { + if (surface->buffers[i]->policy == CSP_SYSTEMONLY) + break; + } + + return i; +} + +DFBResult +dfb_fbdev_set_mode( const VideoMode *mode, + CoreSurface *surface, + unsigned int xoffset, + unsigned int yoffset ) +{ + DFBResult ret; + struct fb_var_screeninfo var; + FBDevShared *shared = dfb_fbdev->shared; + DFBDisplayLayerBufferMode buffermode = DLBM_FRONTONLY; + const CoreSurfaceConfig *config = &surface->config ; + + D_DEBUG_AT( FBDev_Mode, "%s( mode: %p, config: %p )\n", __FUNCTION__, mode, config ); + + D_ASSERT( mode != NULL ); + D_ASSERT( config != NULL ); + + switch (num_video_buffers( surface )) { + case 3: + buffermode = DLBM_TRIPLE; + break; + case 2: + buffermode = DLBM_BACKVIDEO; + break; + case 1: + buffermode = DLBM_FRONTONLY; + break; + default: + D_BUG( "dfb_fbdev_set_mode() called with %d video buffers!", num_video_buffers( surface ) ); + return DFB_BUG; + } + + ret = dfb_fbdev_mode_to_var( mode, config->format, config->size.w, config->size.h, + xoffset, yoffset, buffermode, &var ); + if (ret) { + D_ERROR( "FBDev/Mode: Failed to switch to %dx%d %s (buffermode %d)\n", + config->size.w, config->size.h, dfb_pixelformat_name(config->format), buffermode ); + return ret; + } + + + dfb_gfxcard_lock( GDLF_WAIT | GDLF_SYNC | GDLF_RESET | GDLF_INVALIDATE ); + + if (FBDEV_IOCTL( FBIOPUT_VSCREENINFO, &var ) < 0) { + int erno = errno; + + dfb_gfxcard_unlock(); + + D_DEBUG_AT( FBDev_Mode, " => FAILED!\n" ); + + D_ERROR( "FBDev/Mode: Failed to switched to %dx%d (virtual %dx%d) at %d bit (%s)!\n", + var.xres, var.yres, var.xres_virtual, var.yres_virtual, var.bits_per_pixel, + dfb_pixelformat_name(config->format) ); + + return errno2result( erno ); + } + + D_DEBUG_AT( FBDev_Mode, " => SUCCESS\n" ); + + shared->current_var = var; + dfb_fbdev_var_to_mode( &var, &shared->current_mode ); + + /* To get the new pitch */ + FBDEV_IOCTL( FBIOGET_FSCREENINFO, &shared->fix ); + + D_INFO( "FBDev/Mode: Switched to %dx%d (virtual %dx%d) at %d bit (%s), pitch %d\n", + var.xres, var.yres, var.xres_virtual, var.yres_virtual, var.bits_per_pixel, + dfb_pixelformat_name(config->format), shared->fix.line_length ); + + if (config->format == DSPF_RGB332) + dfb_fbdev_set_rgb332_palette(); + else + dfb_fbdev_set_gamma_ramp( config->format ); + + /* invalidate original pan offset */ + shared->orig_var.xoffset = 0; + shared->orig_var.yoffset = 0; + + dfb_surfacemanager_adjust_heap_offset( dfb_fbdev->shared->manager, + var.yres_virtual * shared->fix.line_length ); + + dfb_gfxcard_after_set_var(); + + dfb_gfxcard_unlock(); + + return DFB_OK; +} + + +#if 0 +DFBResult +dfb_fbdev_set_mode( CoreSurface *surface, + VideoMode *mode, + CoreLayerRegionConfig *config ) +{ + unsigned int vxres, vyres; + struct fb_var_screeninfo var; + FBDevShared *shared = dfb_fbdev->shared; + DFBSurfacePixelFormat format; + + D_DEBUG("DirectFB/FBDev: dfb_fbdev_set_mode (surface: %p, " + "mode: %p, buffermode: %d)\n", surface, mode, + config ? config->buffermode : DLBM_FRONTONLY); + + if (!mode) + mode = &shared->current_mode; + + var = shared->current_var; + + if (config) { + DFBRectangle *source = &config->source; + + /* Is panning supported? */ + if (source->w != mode->xres && shared->fix.xpanstep == 0) + return DFB_UNSUPPORTED; + if (source->h != mode->yres && shared->fix.ypanstep == 0 && shared->fix.ywrapstep == 0) + return DFB_UNSUPPORTED; + + vxres = config->width; + vyres = config->height; + + var.xoffset = source->x; + var.yoffset = source->y; + + switch (config->buffermode) { + case DLBM_TRIPLE: + if (shared->fix.ypanstep == 0 && shared->fix.ywrapstep == 0) + return DFB_UNSUPPORTED; + vyres *= 3; + break; + + case DLBM_BACKVIDEO: + if (shared->fix.ypanstep == 0 && shared->fix.ywrapstep == 0) + return DFB_UNSUPPORTED; + vyres *= 2; + break; + + case DLBM_BACKSYSTEM: + case DLBM_FRONTONLY: + break; + + default: + return DFB_UNSUPPORTED; + } + + var.bits_per_pixel = DFB_BYTES_PER_PIXEL(config->format) * 8; + + var.transp.length = var.transp.offset = 0; + + switch (config->format) { + case DSPF_ARGB1555: + var.transp.length = 1; + var.red.length = 5; + var.green.length = 5; + var.blue.length = 5; + var.transp.offset = 15; + var.red.offset = 10; + var.green.offset = 5; + var.blue.offset = 0; + break; + + case DSPF_RGB555: + var.red.length = 5; + var.green.length = 5; + var.blue.length = 5; + var.red.offset = 10; + var.green.offset = 5; + var.blue.offset = 0; + break; + + case DSPF_BGR555: + var.red.length = 5; + var.green.length = 5; + var.blue.length = 5; + var.red.offset = 0; + var.green.offset = 5; + var.blue.offset = 10; + break; + + case DSPF_ARGB4444: + var.transp.length = 4; + var.red.length = 4; + var.green.length = 4; + var.blue.length = 4; + var.transp.offset = 12; + var.red.offset = 8; + var.green.offset = 4; + var.blue.offset = 0; + break; + + case DSPF_RGBA4444: + var.transp.length = 4; + var.red.length = 4; + var.green.length = 4; + var.blue.length = 4; + var.transp.offset = 0; + var.red.offset = 12; + var.green.offset = 8; + var.blue.offset = 4; + break; + + case DSPF_RGB444: + var.red.length = 4; + var.green.length = 4; + var.blue.length = 4; + var.red.offset = 8; + var.green.offset = 4; + var.blue.offset = 0; + break; + + case DSPF_RGB32: + var.red.length = 8; + var.green.length = 8; + var.blue.length = 8; + var.red.offset = 16; + var.green.offset = 8; + var.blue.offset = 0; + break; + + case DSPF_RGB16: + var.red.length = 5; + var.green.length = 6; + var.blue.length = 5; + var.red.offset = 11; + var.green.offset = 5; + var.blue.offset = 0; + break; + + case DSPF_ARGB: + case DSPF_AiRGB: + var.transp.length = 8; + var.red.length = 8; + var.green.length = 8; + var.blue.length = 8; + var.transp.offset = 24; + var.red.offset = 16; + var.green.offset = 8; + var.blue.offset = 0; + break; + + case DSPF_LUT8: + case DSPF_RGB24: + case DSPF_RGB332: + break; + + case DSPF_ARGB1666: + var.transp.length = 1; + var.red.length = 6; + var.green.length = 6; + var.blue.length = 6; + var.transp.offset = 18; + var.red.offset = 12; + var.green.offset = 6; + var.blue.offset = 0; + break; + + case DSPF_ARGB6666: + var.transp.length = 6; + var.red.length = 6; + var.green.length = 6; + var.blue.length = 6; + var.transp.offset = 18; + var.red.offset = 12; + var.green.offset = 6; + var.blue.offset = 0; + break; + + case DSPF_RGB18: + var.red.length = 6; + var.green.length = 6; + var.blue.length = 6; + var.red.offset = 12; + var.green.offset = 6; + var.blue.offset = 0; + break; + + default: + return DFB_UNSUPPORTED; + } + } + else { + vxres = mode->xres; + vyres = mode->yres; + + var.xoffset = 0; + var.yoffset = 0; + + var.bits_per_pixel = mode->bpp; + } + + var.activate = surface ? FB_ACTIVATE_NOW : FB_ACTIVATE_TEST; + + var.xres = mode->xres; + var.yres = mode->yres; + var.xres_virtual = vxres; + var.yres_virtual = vyres; + + var.pixclock = mode->pixclock; + var.left_margin = mode->left_margin; + var.right_margin = mode->right_margin; + var.upper_margin = mode->upper_margin; + var.lower_margin = mode->lower_margin; + var.hsync_len = mode->hsync_len; + var.vsync_len = mode->vsync_len; + + var.sync = 0; + if (mode->hsync_high) + var.sync |= FB_SYNC_HOR_HIGH_ACT; + if (mode->vsync_high) + var.sync |= FB_SYNC_VERT_HIGH_ACT; + if (mode->csync_high) + var.sync |= FB_SYNC_COMP_HIGH_ACT; + if (mode->sync_on_green) + var.sync |= FB_SYNC_ON_GREEN; + if (mode->external_sync) + var.sync |= FB_SYNC_EXT; + if (mode->broadcast) + var.sync |= FB_SYNC_BROADCAST; + + var.vmode = 0; + if (mode->laced) + var.vmode |= FB_VMODE_INTERLACED; + if (mode->doubled) + var.vmode |= FB_VMODE_DOUBLE; + + dfb_gfxcard_lock( GDLF_WAIT | GDLF_SYNC | GDLF_RESET | GDLF_INVALIDATE ); + + if (FBDEV_IOCTL( FBIOPUT_VSCREENINFO, &var ) < 0) { + int erno = errno; + + if (surface) + D_PERROR( "DirectFB/FBDev: " + "Could not set video mode (FBIOPUT_VSCREENINFO)!\n" ); + + dfb_gfxcard_unlock(); + + return errno2result( erno ); + } + + /* + * the video mode was set successfully, check if there is enough + * video ram (for buggy framebuffer drivers) + */ + + if (shared->fix.smem_len < (var.yres_virtual * + var.xres_virtual * + var.bits_per_pixel >> 3) + || (var.xres_virtual < vxres) + || (var.yres_virtual < vyres)) + { + if (surface) { + D_PERROR( "DirectFB/FBDev: " + "Could not set video mode (not enough video ram)!\n" ); + + /* restore mode */ + FBDEV_IOCTL( FBIOPUT_VSCREENINFO, &shared->current_var ); + } + + dfb_gfxcard_unlock(); + + return DFB_INVARG; + } + + /* If surface is NULL the mode was only tested, otherwise apply changes. */ + if (surface) { + struct fb_fix_screeninfo fix; + + FBDEV_IOCTL( FBIOGET_VSCREENINFO, &var ); + + vxres = var.xres_virtual; + switch (config->buffermode) { + case DLBM_TRIPLE: + vyres = var.yres_virtual / 3; + break; + case DLBM_BACKVIDEO: + vyres = var.yres_virtual / 2; + break; + default: + vyres = var.yres_virtual; + break; + } + + format = dfb_fbdev_get_pixelformat( &var ); + if (format == DSPF_UNKNOWN) { + D_WARN( "unknown format" ); + + /* restore mode */ + FBDEV_IOCTL( FBIOPUT_VSCREENINFO, &shared->current_var ); + + dfb_gfxcard_unlock(); + + return DFB_UNSUPPORTED; + } + + if (!config) { + dfb_gfxcard_unlock(); + + return DFB_OK; + } + + if (format != config->format) { + if (DFB_BYTES_PER_PIXEL(format) == 1 || + (format == DSPF_RGB32 && config->format == DSPF_ARGB) || + (format == DSPF_RGB32 && config->format == DSPF_AiRGB) || + (format == DSPF_ARGB && config->format == DSPF_AiRGB)) + format = config->format; + } + + if (config->format == DSPF_RGB332) + dfb_fbdev_set_rgb332_palette(); + else + dfb_fbdev_set_gamma_ramp( config->format ); + + shared->current_var = var; + dfb_fbdev_var_to_mode( &var, &shared->current_mode ); + + /* invalidate original pan offset */ + shared->orig_var.xoffset = 0; + shared->orig_var.yoffset = 0; + + surface->config.size.w = vxres; + surface->config.size.h = vyres; + surface->config.format = format; + + /* To get the new pitch */ + FBDEV_IOCTL( FBIOGET_FSCREENINFO, &fix ); + + D_INFO( "FBDev/Mode: Switched to %dx%d (%dx%d) at %d bit %s (wanted %s).\n", + var.xres, var.yres, var.xres_virtual, var.yres_virtual, var.bits_per_pixel, + dfb_pixelformat_name(format), dfb_pixelformat_name(config->format) ); + + /* ++Tony: Other information (such as visual formats) will also change */ + shared->fix = fix; + + dfb_surfacemanager_adjust_heap_offset( dfb_fbdev->shared->manager, + var.yres_virtual * fix.line_length ); + + if (shared->fix.xpanstep || shared->fix.ypanstep || shared->fix.ywrapstep) + dfb_fbdev_pan( var.xoffset, var.yoffset, false ); + + dfb_gfxcard_after_set_var(); + + dfb_surface_notify( surface, + CSNF_SIZEFORMAT | CSNF_FLIP | + CSNF_VIDEO | CSNF_SYSTEM ); + } + + dfb_gfxcard_unlock(); + + return DFB_OK; +} +#endif + +/* + * parses video modes in /etc/fb.modes and stores them in dfb_fbdev->shared->modes + * (to be replaced by DirectFB's own config system + */ +static DFBResult +dfb_fbdev_read_modes( void ) +{ + FILE *fp; + char line[80],label[32],value[16]; + int geometry=0, timings=0; + int dummy; + VideoMode temp_mode; + FBDevShared *shared = dfb_fbdev->shared; + VideoMode *prev = shared->modes; + + D_DEBUG_AT( FBDev_Mode, "%s()\n", __FUNCTION__ ); + + if (!(fp = fopen("/etc/fb.modes","r"))) + return errno2result( errno ); + + while (fgets(line,79,fp)) { + if (sscanf(line, "mode \"%31[^\"]\"",label) == 1) { + memset( &temp_mode, 0, sizeof(VideoMode) ); + + geometry = 0; + timings = 0; + + while (fgets(line,79,fp) && !(strstr(line,"endmode"))) { + if (5 == sscanf(line," geometry %d %d %d %d %d", &temp_mode.xres, &temp_mode.yres, &dummy, &dummy, &temp_mode.bpp)) { + geometry = 1; + } + else if (7 == sscanf(line," timings %d %d %d %d %d %d %d", &temp_mode.pixclock, &temp_mode.left_margin, &temp_mode.right_margin, + &temp_mode.upper_margin, &temp_mode.lower_margin, &temp_mode.hsync_len, &temp_mode.vsync_len)) { + timings = 1; + } + else if (1 == sscanf(line, " hsync %15s",value) && 0 == strcasecmp(value,"high")) { + temp_mode.hsync_high = 1; + } + else if (1 == sscanf(line, " vsync %15s",value) && 0 == strcasecmp(value,"high")) { + temp_mode.vsync_high = 1; + } + else if (1 == sscanf(line, " csync %15s",value) && 0 == strcasecmp(value,"high")) { + temp_mode.csync_high = 1; + } + else if (1 == sscanf(line, " laced %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.laced = 1; + } + else if (1 == sscanf(line, " double %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.doubled = 1; + } + else if (1 == sscanf(line, " gsync %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.sync_on_green = 1; + } + else if (1 == sscanf(line, " extsync %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.external_sync = 1; + } + else if (1 == sscanf(line, " bcast %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.broadcast = 1; + } + } + + if (geometry && timings && !dfb_fbdev_test_mode_simple(&temp_mode)) { + VideoMode *mode = SHCALLOC( shared->shmpool, 1, sizeof(VideoMode) ); + if (!mode) { + D_OOSHM(); + continue; + } + + if (!prev) + shared->modes = mode; + else + prev->next = mode; + + direct_memcpy (mode, &temp_mode, sizeof(VideoMode)); + + prev = mode; + + D_DEBUG_AT( FBDev_Mode, " +-> %16s %4dx%4d %s%s\n", label, temp_mode.xres, temp_mode.yres, + temp_mode.laced ? "interlaced " : "", temp_mode.doubled ? "doublescan" : "" ); + } + } + } + + fclose (fp); + + return DFB_OK; +} + +/* + * some fbdev drivers use the palette as gamma ramp in >8bpp modes, to have + * correct colors, the gamme ramp has to be initialized. + */ + +static u16 +dfb_fbdev_calc_gamma(int n, int max) +{ + int ret = 65535 * n / max; + return CLAMP( ret, 0, 65535 ); +} + +static DFBResult +dfb_fbdev_set_gamma_ramp( DFBSurfacePixelFormat format ) +{ + int i; + + int red_size = 0; + int green_size = 0; + int blue_size = 0; + int red_max = 0; + int green_max = 0; + int blue_max = 0; + + struct fb_cmap *cmap; + + if (!dfb_fbdev) { + D_BUG( "dfb_fbdev_set_gamma_ramp() called while dfb_fbdev == NULL!" ); + + return DFB_BUG; + } + + switch (format) { + case DSPF_ARGB1555: + case DSPF_RGB555: + case DSPF_BGR555: + red_size = 32; + green_size = 32; + blue_size = 32; + break; + case DSPF_ARGB4444: + case DSPF_RGBA4444: + case DSPF_RGB444: + case DSPF_RGB16: + red_size = 32; + green_size = 64; + blue_size = 32; + break; + case DSPF_RGB24: + case DSPF_RGB32: + case DSPF_ARGB: + red_size = 256; + green_size = 256; + blue_size = 256; + break; + default: + return DFB_OK; + } + + /* + * ++Tony: The gamma ramp must be set differently if in DirectColor, + * ie, to mimic TrueColor, index == color[index]. + */ + if (dfb_fbdev->shared->fix.visual == FB_VISUAL_DIRECTCOLOR) { + red_max = 65536 / (256/red_size); + green_max = 65536 / (256/green_size); + blue_max = 65536 / (256/blue_size); + } + else { + red_max = red_size; + green_max = green_size; + blue_max = blue_size; + } + + cmap = &dfb_fbdev->shared->current_cmap; + + /* assume green to have most weight */ + cmap->len = green_size; + + for (i = 0; i < red_size; i++) + cmap->red[i] = dfb_fbdev_calc_gamma( i, red_max ); + + for (i = 0; i < green_size; i++) + cmap->green[i] = dfb_fbdev_calc_gamma( i, green_max ); + + for (i = 0; i < blue_size; i++) + cmap->blue[i] = dfb_fbdev_calc_gamma( i, blue_max ); + + /* ++Tony: Some drivers use the upper byte, some use the lower */ + if (dfb_fbdev->shared->fix.visual == FB_VISUAL_DIRECTCOLOR) { + for (i = 0; i < red_size; i++) + cmap->red[i] |= cmap->red[i] << 8; + + for (i = 0; i < green_size; i++) + cmap->green[i] |= cmap->green[i] << 8; + + for (i = 0; i < blue_size; i++) + cmap->blue[i] |= cmap->blue[i] << 8; + } + + if (FBDEV_IOCTL( FBIOPUTCMAP, cmap ) < 0) { + D_PERROR( "DirectFB/FBDev: " + "Could not set gamma ramp" ); + + return errno2result(errno); + } + + return DFB_OK; +} + +static DFBResult +dfb_fbdev_set_palette( CorePalette *palette ) +{ + int i; + struct fb_cmap *cmap = &dfb_fbdev->shared->current_cmap; + + D_ASSERT( palette != NULL ); + + cmap->len = palette->num_entries <= 256 ? palette->num_entries : 256; + + for (i = 0; i < (int)cmap->len; i++) { + cmap->red[i] = palette->entries[i].r; + cmap->green[i] = palette->entries[i].g; + cmap->blue[i] = palette->entries[i].b; + cmap->transp[i] = 0xff - palette->entries[i].a; + + cmap->red[i] |= cmap->red[i] << 8; + cmap->green[i] |= cmap->green[i] << 8; + cmap->blue[i] |= cmap->blue[i] << 8; + cmap->transp[i] |= cmap->transp[i] << 8; + } + + if (FBDEV_IOCTL( FBIOPUTCMAP, cmap ) < 0) { + D_PERROR( "DirectFB/FBDev: Could not set the palette!\n" ); + + return errno2result(errno); + } + + return DFB_OK; +} + +static DFBResult +dfb_fbdev_set_rgb332_palette( void ) +{ + DFBResult ret = DFB_OK; + int red_val; + int green_val; + int blue_val; + int i = 0; + FusionSHMPoolShared *pool = dfb_fbdev->shared->shmpool_data; + + struct fb_cmap cmap; + + if (!dfb_fbdev) { + D_BUG( "dfb_fbdev_set_rgb332_palette() called while dfb_fbdev == NULL!" ); + + return DFB_BUG; + } + + cmap.start = 0; + cmap.len = 256; + cmap.red = (u16*)SHMALLOC( pool, 2 * 256 ); + if (!cmap.red) { + return D_OOSHM(); + } + cmap.green = (u16*)SHMALLOC( pool, 2 * 256 ); + if (!cmap.green) { + ret = D_OOSHM(); + goto free_red; + } + cmap.blue = (u16*)SHMALLOC( pool, 2 * 256 ); + if (!cmap.blue) { + ret = D_OOSHM(); + goto free_green; + } + cmap.transp = (u16*)SHMALLOC( pool, 2 * 256 ); + if (!cmap.transp) { + ret = D_OOSHM(); + goto free_blue; + } + + for (red_val = 0; red_val < 8 ; red_val++) { + for (green_val = 0; green_val < 8 ; green_val++) { + for (blue_val = 0; blue_val < 4 ; blue_val++) { + cmap.red[i] = dfb_fbdev_calc_gamma( red_val, 7 ); + cmap.green[i] = dfb_fbdev_calc_gamma( green_val, 7 ); + cmap.blue[i] = dfb_fbdev_calc_gamma( blue_val, 3 ); + cmap.transp[i] = (i ? 0x2000 : 0xffff); + i++; + } + } + } + + if (FBDEV_IOCTL( FBIOPUTCMAP, &cmap ) < 0) { + D_PERROR( "DirectFB/FBDev: " + "Could not set rgb332 palette" ); + ret = errno2result(errno); + goto free_transp; + } + + free_transp: + SHFREE( pool, cmap.transp ); + free_blue: + SHFREE( pool, cmap.blue ); + free_green: + SHFREE( pool, cmap.green ); + free_red: + SHFREE( pool, cmap.red ); + + return ret; +} + +static FusionCallHandlerResult +fbdev_ioctl_call_handler( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ) +{ + int ret; + const char cursoroff_str[] = "\033[?1;0;0c"; + const char blankoff_str[] = "\033[9;0]"; + + if (dfb_config->vt) { + if (!dfb_config->kd_graphics && call_arg == FBIOPUT_VSCREENINFO) + ioctl( dfb_fbdev->vt->fd, KDSETMODE, KD_GRAPHICS ); + } + + ret = ioctl( dfb_fbdev->fd, call_arg, call_ptr ); + if (ret) + ret = errno; + + if (dfb_config->vt) { + if (call_arg == FBIOPUT_VSCREENINFO) { + if (!dfb_config->kd_graphics) { + ioctl( dfb_fbdev->vt->fd, KDSETMODE, KD_TEXT ); + write( dfb_fbdev->vt->fd, cursoroff_str, strlen(cursoroff_str) ); + write( dfb_fbdev->vt->fd, blankoff_str, strlen(blankoff_str) ); + } + } + } + + *ret_val = ret; + + return FCHR_RETURN; +} + +static int +fbdev_ioctl( int request, void *arg, int arg_size ) +{ + int ret; + int erno; + void *tmp_shm = NULL; + FBDevShared *shared; + + D_ASSERT( dfb_fbdev != NULL ); + + shared = dfb_fbdev->shared; + + D_ASSERT( shared != NULL ); + + if (dfb_core_is_master( dfb_fbdev->core )) { + fbdev_ioctl_call_handler( 1, request, arg, NULL, 0, &ret ); + errno = ret; + return errno ? -1 : 0; + } + + if (arg) { + if (!fusion_is_shared( dfb_core_world(dfb_fbdev->core), arg )) { + tmp_shm = SHMALLOC( shared->shmpool, arg_size ); + if (!tmp_shm) { + errno = ENOMEM; + return -1; + } + + direct_memcpy( tmp_shm, arg, arg_size ); + } + } + + ret = fusion_call_execute( &shared->fbdev_ioctl, FCEF_NONE, + request, tmp_shm ? tmp_shm : arg, &erno ); + + if (tmp_shm) { + direct_memcpy( arg, tmp_shm, arg_size ); + SHFREE( shared->shmpool, tmp_shm ); + } + + errno = erno; + + return errno ? -1 : 0; +} + diff --git a/Source/DirectFB/systems/fbdev/fbdev.h b/Source/DirectFB/systems/fbdev/fbdev.h new file mode 100755 index 0000000..a90a76b --- /dev/null +++ b/Source/DirectFB/systems/fbdev/fbdev.h @@ -0,0 +1,142 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __CORE__FBDEV_H__ +#define __CORE__FBDEV_H__ + +#include /* Needs to be included before dfb_types.h */ + +#include + +#include + +#include + +#include +#include + +#include "agp.h" +#include "fb.h" +#include "surfacemanager.h" +#include "vt.h" + +#ifndef FBIO_WAITFORVSYNC +#define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t) +#endif + + +typedef struct { + /* fbdev fixed screeninfo, contains infos about memory and type of card */ + struct fb_fix_screeninfo fix; + + VideoMode *modes; /* linked list of valid + video modes */ + VideoMode current_mode; /* current video mode */ + + struct fb_var_screeninfo current_var; /* fbdev variable screeninfo + set by DirectFB */ + struct fb_var_screeninfo orig_var; /* fbdev variable screeninfo + before DirectFB was started */ + + void *orig_cmap_memory; + void *temp_cmap_memory; + void *current_cmap_memory; + + struct fb_cmap orig_cmap; /* original palette */ + + struct fb_cmap current_cmap; /* our copy of the cmap */ + + struct fb_cmap temp_cmap; /* scratch */ + + FusionCall fbdev_ioctl; /* ioctl rpc */ + + unsigned long page_mask; /* PAGE_SIZE - 1 */ + + CoreSurfacePool *pool; + + struct { + int bus; + int dev; + int func; + } pci; /* PCI Bus ID of graphics device */ + + struct { + unsigned short vendor; /* Graphics device vendor id */ + unsigned short model; /* Graphics device model id */ + } device; + + AGPShared *agp; + + FusionSHMPoolShared *shmpool; + FusionSHMPoolShared *shmpool_data; + + CoreLayerRegionConfig config; + + SurfaceManager *manager; +} FBDevShared; + +typedef struct { + FBDevShared *shared; + + CoreDFB *core; + + /* virtual framebuffer address */ + void *framebuffer_base; + + int fd; /* file descriptor for /dev/fb */ + + VirtualTerminal *vt; + + AGPDevice *agp; +} FBDev; + +/* + * core init function, opens /dev/fb, get fbdev screeninfo + * disables font acceleration, reads mode list + */ +DFBResult dfb_fbdev_initialize( void ); +DFBResult dfb_fbdev_join( void ); + +/* + * deinitializes DirectFB fbdev stuff and restores fbdev settings + */ +DFBResult dfb_fbdev_shutdown( bool emergency ); +DFBResult dfb_fbdev_leave ( bool emergency ); + +const VideoMode *dfb_fbdev_find_mode( int width, + int height ); +DFBResult dfb_fbdev_test_mode ( const VideoMode *mode, + const CoreLayerRegionConfig *config ); +DFBResult dfb_fbdev_test_mode_simple( const VideoMode *mode ); + +DFBResult dfb_fbdev_set_mode ( const VideoMode *mode, + CoreSurface *surface, + unsigned int xoffset, + unsigned int yoffset ); + +#endif diff --git a/Source/DirectFB/systems/fbdev/fbdev_surface_pool.c b/Source/DirectFB/systems/fbdev/fbdev_surface_pool.c new file mode 100755 index 0000000..c5454a6 --- /dev/null +++ b/Source/DirectFB/systems/fbdev/fbdev_surface_pool.c @@ -0,0 +1,423 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#include +#include + +#include + +#include + +#include "fbdev.h" +#include "surfacemanager.h" + +extern FBDev *dfb_fbdev; + +D_DEBUG_DOMAIN( FBDev_Surfaces, "FBDev/Surfaces", "FBDev Framebuffer Surface Pool" ); +D_DEBUG_DOMAIN( FBDev_SurfLock, "FBDev/SurfLock", "FBDev Framebuffer Surface Pool Locks" ); + +/**********************************************************************************************************************/ + +typedef struct { + int magic; + + SurfaceManager *manager; +} FBDevPoolData; + +typedef struct { + int magic; + + CoreDFB *core; +} FBDevPoolLocalData; + +typedef struct { + int magic; + + int offset; + int pitch; + int size; + + Chunk *chunk; +} FBDevAllocationData; + +/**********************************************************************************************************************/ + +static int +fbdevPoolDataSize( void ) +{ + return sizeof(FBDevPoolData); +} + +static int +fbdevPoolLocalDataSize( void ) +{ + return sizeof(FBDevPoolLocalData); +} + +static int +fbdevAllocationDataSize( void ) +{ + return sizeof(FBDevAllocationData); +} + +static DFBResult +fbdevInitPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data, + CoreSurfacePoolDescription *ret_desc ) +{ + DFBResult ret; + FBDevPoolData *data = pool_data; + FBDevPoolLocalData *local = pool_local; + + D_DEBUG_AT( FBDev_Surfaces, "%s()\n", __FUNCTION__ ); + + D_ASSERT( core != NULL ); + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_ASSERT( data != NULL ); + D_ASSERT( local != NULL ); + D_ASSERT( ret_desc != NULL ); + + ret = dfb_surfacemanager_create( core, dfb_fbdev->shared->fix.smem_len, &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; + + /* 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, "Frame Buffer Memory" ); + + local->core = core; + + D_MAGIC_SET( data, FBDevPoolData ); + D_MAGIC_SET( local, FBDevPoolLocalData ); + + + D_ASSERT( dfb_fbdev != NULL ); + D_ASSERT( dfb_fbdev->shared != NULL ); + + dfb_fbdev->shared->manager = data->manager; + + return DFB_OK; +} + +static DFBResult +fbdevJoinPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data ) +{ + FBDevPoolData *data = pool_data; + FBDevPoolLocalData *local = pool_local; + + D_DEBUG_AT( FBDev_Surfaces, "%s()\n", __FUNCTION__ ); + + D_ASSERT( core != NULL ); + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, FBDevPoolData ); + D_ASSERT( local != NULL ); + + (void) data; + + local->core = core; + + D_MAGIC_SET( local, FBDevPoolLocalData ); + + return DFB_OK; +} + +static DFBResult +fbdevDestroyPool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + FBDevPoolData *data = pool_data; + FBDevPoolLocalData *local = pool_local; + + D_DEBUG_AT( FBDev_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, FBDevPoolData ); + D_MAGIC_ASSERT( local, FBDevPoolLocalData ); + + dfb_surfacemanager_destroy( data->manager ); + + D_MAGIC_CLEAR( data ); + D_MAGIC_CLEAR( local ); + + return DFB_OK; +} + +static DFBResult +fbdevLeavePool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + FBDevPoolData *data = pool_data; + FBDevPoolLocalData *local = pool_local; + + D_DEBUG_AT( FBDev_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, FBDevPoolData ); + D_MAGIC_ASSERT( local, FBDevPoolLocalData ); + + (void) data; + + D_MAGIC_CLEAR( local ); + + return DFB_OK; +} + +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) && surface->resource_id == DLID_PRIMARY) + 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 +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 (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; +} + +static DFBResult +fbdevDeallocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + FBDevPoolData *data = pool_data; + 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( buffer, CoreSurfaceBuffer ); + D_MAGIC_ASSERT( alloc, FBDevAllocationData ); + + if (alloc->chunk) + dfb_surfacemanager_deallocate( data->manager, alloc->chunk ); + + D_MAGIC_CLEAR( alloc ); + + return DFB_OK; +} + +static DFBResult +fbdevLock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + FBDevAllocationData *alloc = alloc_data; + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, FBDevAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + D_DEBUG_AT( FBDev_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer ); + + lock->pitch = alloc->pitch; + lock->offset = alloc->offset; + lock->addr = dfb_fbdev->framebuffer_base + alloc->offset; + lock->phys = dfb_fbdev->shared->fix.smem_start + alloc->offset; + + D_DEBUG_AT( FBDev_SurfLock, " -> offset %lu, pitch %d, addr %p, phys 0x%08lx\n", + lock->offset, lock->pitch, lock->addr, lock->phys ); + + return DFB_OK; +} + +static DFBResult +fbdevUnlock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + FBDevAllocationData *alloc = alloc_data; + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, FBDevAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + D_DEBUG_AT( FBDev_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer ); + + (void) alloc; + + return DFB_OK; +} + +const SurfacePoolFuncs fbdevSurfacePoolFuncs = { + .PoolDataSize = fbdevPoolDataSize, + .PoolLocalDataSize = fbdevPoolLocalDataSize, + .AllocationDataSize = fbdevAllocationDataSize, + + .InitPool = fbdevInitPool, + .JoinPool = fbdevJoinPool, + .DestroyPool = fbdevDestroyPool, + .LeavePool = fbdevLeavePool, + + .TestConfig = fbdevTestConfig, + .AllocateBuffer = fbdevAllocateBuffer, + .DeallocateBuffer = fbdevDeallocateBuffer, + + .Lock = fbdevLock, + .Unlock = fbdevUnlock, +}; + diff --git a/Source/DirectFB/systems/fbdev/surfacemanager.c b/Source/DirectFB/systems/fbdev/surfacemanager.c new file mode 100755 index 0000000..811288b --- /dev/null +++ b/Source/DirectFB/systems/fbdev/surfacemanager.c @@ -0,0 +1,617 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#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 ); +} + +DFBResult dfb_surfacemanager_adjust_heap_offset( SurfaceManager *manager, + int offset ) +{ + D_MAGIC_ASSERT( manager, SurfaceManager ); + D_ASSERT( offset >= 0 ); + + D_DEBUG_AT( SurfMan, "%s( %p, %d )\n", __FUNCTION__, manager, offset ); + +/*FIXME_SC_2 if (manager->limits.surface_byteoffset_alignment > 1) { + offset += manager->limits.surface_byteoffset_alignment - 1; + offset -= offset % manager->limits.surface_byteoffset_alignment; + } +*/ + /* + * Adjust the offset of the heap. + */ + if (manager->chunks->buffer == NULL) { + /* first chunk is free */ + if (offset <= manager->chunks->offset + manager->chunks->length) { + /* ok, just recalculate offset and length */ + manager->chunks->length = manager->chunks->offset + + manager->chunks->length - offset; + manager->chunks->offset = offset; + } + else { + D_WARN("unable to adjust heap offset"); + /* more space needed than free at the beginning */ + /* TODO: move/destroy instances */ + } + } + else { + D_WARN("unable to adjust heap offset"); + /* very rare case that the first chunk is occupied */ + /* TODO: move/destroy instances */ + } + + manager->avail -= offset - manager->offset; + manager->offset = offset; + + return DFB_OK; +} + +/** 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/fbdev/surfacemanager.h b/Source/DirectFB/systems/fbdev/surfacemanager.h new file mode 100755 index 0000000..f7812d1 --- /dev/null +++ b/Source/DirectFB/systems/fbdev/surfacemanager.h @@ -0,0 +1,117 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +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 ); + +/* + * adjust the offset within the framebuffer for surface storage, + * needs to be called after a resolution switch + */ +DFBResult dfb_surfacemanager_adjust_heap_offset( SurfaceManager *manager, + int offset ); + +/* + * 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 + diff --git a/Source/DirectFB/systems/fbdev/vt.c b/Source/DirectFB/systems/fbdev/vt.c new file mode 100755 index 0000000..02bad77 --- /dev/null +++ b/Source/DirectFB/systems/fbdev/vt.c @@ -0,0 +1,675 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include /* Needs to be included before dfb_types.h */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "fbdev.h" +#include "fb.h" +#include "vt.h" + +D_DEBUG_DOMAIN( VT, "FBDev/VT", "FBDev System Module VT Handling" ); + +/* + * FIXME: the following looks like a bad hack. + * + * SIGUNUSED is no longer unused, but is defined for backwards compatibility. + * sparc, mips and alpha signal.h however do not define SIGUNUSED. + */ + +#ifdef SIGUNUSED + #define SIG_SWITCH_FROM (SIGUNUSED + 10) + #define SIG_SWITCH_TO (SIGUNUSED + 11) +#else + #define SIG_SWITCH_FROM (31 + 10) + #define SIG_SWITCH_TO (31 + 11) +#endif + +#ifndef SI_KERNEL +/* glibc 2.1.x doesn't have this in /usr/include/bits/siginfo.h */ + #define SI_KERNEL 0x80 +#endif + + +extern FBDev *dfb_fbdev; + +static VirtualTerminal *dfb_vt = NULL; + +static DFBResult vt_init_switching( void ); +static int vt_get_fb( int vt ); +static void vt_set_fb( int vt, int fb ); +static void *vt_thread( DirectThread *thread, void *arg ); + +static void vt_start_flushing( void ); +static void vt_stop_flushing( void ); +static void *vt_flush_thread( DirectThread *thread, void *arg ); + +DFBResult +dfb_vt_initialize( void ) +{ + DFBResult ret; + struct vt_stat vs; + + D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ ); + + dfb_vt = D_CALLOC( 1, sizeof(VirtualTerminal) ); + if (!dfb_vt) + return D_OOM(); + + setsid(); + dfb_vt->fd0 = open( "/dev/tty0", O_RDONLY | O_NOCTTY ); + if (dfb_vt->fd0 < 0) { + if (errno == ENOENT) { + dfb_vt->fd0 = open( "/dev/vc/0", O_RDONLY | O_NOCTTY ); + if (dfb_vt->fd0 < 0) { + if (errno == ENOENT) { + D_PERROR( "DirectFB/core/vt: Couldn't open " + "neither `/dev/tty0' nor `/dev/vc/0'!\n" ); + } + else { + D_PERROR( "DirectFB/core/vt: " + "Error opening `/dev/vc/0'!\n" ); + } + + D_FREE( dfb_vt ); + dfb_vt = NULL; + + return DFB_INIT; + } + } + else { + D_PERROR( "DirectFB/core/vt: Error opening `/dev/tty0'!\n"); + + D_FREE( dfb_vt ); + dfb_vt = NULL; + + return DFB_INIT; + } + } + + if (ioctl( dfb_vt->fd0, VT_GETSTATE, &vs ) < 0) { + D_PERROR( "DirectFB/core/vt: VT_GETSTATE failed!\n" ); + close( dfb_vt->fd0 ); + D_FREE( dfb_vt ); + dfb_vt = NULL; + return DFB_INIT; + } + + dfb_vt->prev = vs.v_active; + + + if (!dfb_config->vt_switch) { + if (dfb_config->vt_num != -1) + dfb_vt->num = dfb_config->vt_num; + else + dfb_vt->num = dfb_vt->prev; + + /* move vt to framebuffer */ + dfb_vt->old_fb = vt_get_fb( dfb_vt->num ); + vt_set_fb( dfb_vt->num, -1 ); + } + else { + if (dfb_config->vt_num == -1) { + int n; + + n = ioctl( dfb_vt->fd0, VT_OPENQRY, &dfb_vt->num ); + if (n < 0 || dfb_vt->num == -1) { + D_PERROR( "DirectFB/core/vt: Cannot allocate VT!\n" ); + close( dfb_vt->fd0 ); + D_FREE( dfb_vt ); + dfb_vt = NULL; + return DFB_INIT; + } + } + else { + dfb_vt->num = dfb_config->vt_num; + } + + /* move vt to framebuffer */ + dfb_vt->old_fb = vt_get_fb( dfb_vt->num ); + vt_set_fb( dfb_vt->num, -1 ); + + /* switch to vt */ + while (ioctl( dfb_vt->fd0, VT_ACTIVATE, dfb_vt->num ) < 0) { + if (errno == EINTR) + continue; + D_PERROR( "DirectFB/core/vt: VT_ACTIVATE failed!\n" ); + close( dfb_vt->fd0 ); + D_FREE( dfb_vt ); + dfb_vt = NULL; + return DFB_INIT; + } + + while (ioctl( dfb_vt->fd0, VT_WAITACTIVE, dfb_vt->num ) < 0) { + if (errno == EINTR) + continue; + D_PERROR( "DirectFB/core/vt: VT_WAITACTIVE failed!\n" ); + close( dfb_vt->fd0 ); + D_FREE( dfb_vt ); + dfb_vt = NULL; + return DFB_INIT; + } + + usleep( 40000 ); + } + + ret = vt_init_switching(); + if (ret) { + if (dfb_config->vt_switch) { + D_DEBUG_AT( VT, " -> switching back...\n" ); + ioctl( dfb_vt->fd0, VT_ACTIVATE, dfb_vt->prev ); + ioctl( dfb_vt->fd0, VT_WAITACTIVE, dfb_vt->prev ); + D_DEBUG_AT( VT, " -> ...switched back\n" ); + ioctl( dfb_vt->fd0, VT_DISALLOCATE, dfb_vt->num ); + } + + close( dfb_vt->fd0 ); + D_FREE( dfb_vt ); + dfb_vt = NULL; + return ret; + } + + vt_start_flushing(); + + dfb_fbdev->vt = dfb_vt; + + return DFB_OK; +} + +DFBResult +dfb_vt_join( void ) +{ + D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ ); + + dfb_vt_detach( true ); + + return DFB_OK; +} + +DFBResult +dfb_vt_shutdown( bool emergency ) +{ + const char cursoron_str[] = "\033[?0;0;0c"; + const char blankon_str[] = "\033[9;10]"; + + D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ ); + + if (!dfb_vt) + return DFB_OK; + + vt_stop_flushing(); + + if (dfb_config->vt_switching) { + if (ioctl( dfb_vt->fd, VT_SETMODE, &dfb_vt->vt_mode ) < 0) + D_PERROR( "DirectFB/fbdev/vt: Unable to restore VT mode!!!\n" ); + + sigaction( SIG_SWITCH_FROM, &dfb_vt->sig_usr1, NULL ); + sigaction( SIG_SWITCH_TO, &dfb_vt->sig_usr2, NULL ); + + direct_thread_cancel( dfb_vt->thread ); + direct_thread_join( dfb_vt->thread ); + direct_thread_destroy( dfb_vt->thread ); + + pthread_mutex_destroy( &dfb_vt->lock ); + pthread_cond_destroy( &dfb_vt->wait ); + } + + if (dfb_config->kd_graphics) { + if (ioctl( dfb_vt->fd, KDSETMODE, KD_TEXT ) < 0) + D_PERROR( "DirectFB/fbdev/vt: KD_TEXT failed!\n" ); + } + else { + write( dfb_vt->fd, blankon_str, sizeof(blankon_str) ); + } + write( dfb_vt->fd, cursoron_str, sizeof(cursoron_str) ); + + if (tcsetattr( dfb_vt->fd, TCSAFLUSH, &dfb_vt->old_ts ) < 0) + D_PERROR("DirectFB/fbdev/vt: tcsetattr for original values failed!\n"); + + if (ioctl( dfb_vt->fd, KDSKBMODE, K_XLATE ) < 0) + D_PERROR( "DirectFB/fbdev/vt: K_XLATE failed!\n" ); + + if (dfb_config->vt_switch) { + D_DEBUG_AT( VT, " -> switching back...\n" ); + + if (ioctl( dfb_vt->fd0, VT_ACTIVATE, dfb_vt->prev ) < 0) + D_PERROR( "DirectFB/core/vt: VT_ACTIVATE" ); + + if (ioctl( dfb_vt->fd0, VT_WAITACTIVE, dfb_vt->prev ) < 0) + D_PERROR( "DirectFB/core/vt: VT_WAITACTIVE" ); + + D_DEBUG_AT( VT, " -> switched back...\n" ); + + usleep( 40000 ); + + /* restore con2fbmap */ + vt_set_fb( dfb_vt->num, dfb_vt->old_fb ); + + if (close( dfb_vt->fd ) < 0) + D_PERROR( "DirectFB/core/vt: Unable to " + "close file descriptor of allocated VT!\n" ); + + if (ioctl( dfb_vt->fd0, VT_DISALLOCATE, dfb_vt->num ) < 0) + D_PERROR( "DirectFB/core/vt: Unable to disallocate VT!\n" ); + } + else { + /* restore con2fbmap */ + vt_set_fb( dfb_vt->num, dfb_vt->old_fb ); + + if (close( dfb_vt->fd ) < 0) + D_PERROR( "DirectFB/core/vt: Unable to " + "close file descriptor of current VT!\n" ); + } + + if (close( dfb_vt->fd0 ) < 0) + D_PERROR( "DirectFB/core/vt: Unable to " + "close file descriptor of tty0!\n" ); + + D_FREE( dfb_vt ); + dfb_vt = dfb_fbdev->vt = NULL; + + return DFB_OK; +} + +DFBResult +dfb_vt_leave( bool emergency ) +{ + D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ ); + + return DFB_OK; +} + +DFBResult +dfb_vt_detach( bool force ) +{ + D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ ); + + if (dfb_config->vt_switch || force) { + int fd; + struct vt_stat vt_state; + + fd = open( "/dev/tty", O_RDONLY | O_NOCTTY ); + if (fd < 0) { + if (errno == ENXIO) + return DFB_OK; + + D_PERROR( "DirectFB/VT: Opening /dev/tty failed!\n" ); + return errno2result( errno ); + } + + if (ioctl( fd, VT_GETSTATE, &vt_state )) { + close( fd ); + return DFB_OK; + } + + if (ioctl( fd, TIOCNOTTY )) { + D_PERROR( "DirectFB/VT: TIOCNOTTY on /dev/tty failed\n" ); + close( fd ); + return errno2result( errno ); + } + + close( fd ); + } + + return DFB_OK; +} + +bool +dfb_vt_switch( int num ) +{ + D_DEBUG_AT( VT, "%s( %d )\n", __FUNCTION__, num ); + + if (!dfb_config->vt_switching) + return false; + + D_DEBUG_AT( VT, " -> switching to vt %d...\n", num ); + + if (ioctl( dfb_vt->fd0, VT_ACTIVATE, num ) < 0) + D_PERROR( "DirectFB/fbdev/vt: VT_ACTIVATE failed\n" ); + + return true; +} + +static void * +vt_thread( DirectThread *thread, void *arg ) +{ + D_DEBUG_AT( VT, "%s( %p, %p )\n", __FUNCTION__, thread, arg ); + + pthread_mutex_lock( &dfb_vt->lock ); + + while (true) { + direct_thread_testcancel( thread ); + + D_DEBUG_AT( VT, "...%s (signal %d)\n", __FUNCTION__, dfb_vt->vt_sig); + + switch (dfb_vt->vt_sig) { + default: + D_BUG( "unexpected vt_sig" ); + /* fall through */ + + case -1: + pthread_cond_wait( &dfb_vt->wait, &dfb_vt->lock ); + continue; + + case SIG_SWITCH_FROM: + if (dfb_core_suspend( dfb_fbdev->core ) == DFB_OK) { + if (ioctl( dfb_vt->fd, VT_RELDISP, VT_ACKACQ ) < 0) + D_PERROR( "DirectFB/fbdev/vt: VT_RELDISP failed\n" ); + } + + break; + + case SIG_SWITCH_TO: + if (dfb_core_resume( dfb_fbdev->core ) == DFB_OK) { + if (ioctl( dfb_vt->fd, VT_RELDISP, VT_ACKACQ ) < 0) + D_PERROR( "DirectFB/fbdev/vt: VT_RELDISP failed\n" ); + + if (dfb_config->kd_graphics) { + if (ioctl( dfb_vt->fd, KDSETMODE, KD_GRAPHICS ) < 0) + D_PERROR( "DirectFB/fbdev/vt: KD_GRAPHICS failed!\n" ); + } + } + + break; + } + + dfb_vt->vt_sig = -1; + + pthread_cond_signal( &dfb_vt->wait ); + } + + return NULL; +} + +static void +vt_switch_handler( int signum ) +{ + D_DEBUG_AT( VT, "%s( %d )\n", __FUNCTION__, signum ); + + pthread_mutex_lock( &dfb_vt->lock ); + + while (dfb_vt->vt_sig != -1) + pthread_cond_wait( &dfb_vt->wait, &dfb_vt->lock ); + + dfb_vt->vt_sig = signum; + + pthread_cond_signal( &dfb_vt->wait ); + + pthread_mutex_unlock( &dfb_vt->lock ); +} + +static DFBResult +vt_init_switching( void ) +{ + struct termios ts; + const char cursoroff_str[] = "\033[?1;0;0c"; + const char blankoff_str[] = "\033[9;0]"; + char buf[32]; + + D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ ); + + /* FIXME: Opening the device should be moved out of this function. */ + + snprintf(buf, 32, "/dev/tty%d", dfb_vt->num); + dfb_vt->fd = open( buf, O_RDWR | O_NOCTTY ); + if (dfb_vt->fd < 0) { + if (errno == ENOENT) { + snprintf(buf, 32, "/dev/vc/%d", dfb_vt->num); + dfb_vt->fd = open( buf, O_RDWR | O_NOCTTY ); + if (dfb_vt->fd < 0) { + if (errno == ENOENT) { + D_PERROR( "DirectFB/core/vt: Couldn't open " + "neither `/dev/tty%d' nor `/dev/vc/%d'!\n", + dfb_vt->num, dfb_vt->num ); + } + else { + D_PERROR( "DirectFB/core/vt: " + "Error opening `%s'!\n", buf ); + } + + return errno2result( errno ); + } + } + else { + D_PERROR( "DirectFB/core/vt: Error opening `%s'!\n", buf ); + return errno2result( errno ); + } + } + + /* attach to the new TTY before doing anything like KDSETMODE with it, + otherwise we'd get access denied error: */ + ioctl( dfb_vt->fd, TIOCSCTTY, 0 ); + + if (ioctl( dfb_vt->fd, KDSKBMODE, K_MEDIUMRAW ) < 0) { + D_PERROR( "DirectFB/fbdev/vt: K_MEDIUMRAW failed!\n" ); + close( dfb_vt->fd ); + return DFB_INIT; + } + + if (tcgetattr( dfb_vt->fd, &dfb_vt->old_ts ) < 0) { + D_PERROR( "DirectFB/fbdev/vt: tcgetattr failed!\n" ); + ioctl( dfb_vt->fd, KDSKBMODE, K_XLATE ); + close( dfb_vt->fd ); + return DFB_INIT; + } + ts = dfb_vt->old_ts; + ts.c_cc[VTIME] = 0; + ts.c_cc[VMIN] = 1; + ts.c_lflag &= ~(ICANON|ECHO|ISIG); + ts.c_iflag = 0; + if (tcsetattr( dfb_vt->fd, TCSAFLUSH, &ts ) < 0) { + D_PERROR( "DirectFB/fbdev/vt: tcsetattr for new values failed!\n" ); + ioctl( dfb_vt->fd, KDSKBMODE, K_XLATE ); + close( dfb_vt->fd ); + return DFB_INIT; + } + + write( dfb_vt->fd, cursoroff_str, sizeof(cursoroff_str) ); + if (dfb_config->kd_graphics) { + if (ioctl( dfb_vt->fd, KDSETMODE, KD_GRAPHICS ) < 0) { + D_PERROR( "DirectFB/fbdev/vt: KD_GRAPHICS failed!\n" ); + tcsetattr( dfb_vt->fd, TCSAFLUSH, &dfb_vt->old_ts ); + ioctl( dfb_vt->fd, KDSKBMODE, K_XLATE ); + close( dfb_vt->fd ); + return DFB_INIT; + } + } + else { + write( dfb_vt->fd, blankoff_str, sizeof(blankoff_str) ); + } + + if (dfb_config->vt_switching) { + struct vt_mode vt; + struct sigaction sig_tty; + + memset( &sig_tty, 0, sizeof( sig_tty ) ); + sig_tty.sa_handler = vt_switch_handler; + sigfillset( &sig_tty.sa_mask ); + + if (sigaction( SIG_SWITCH_FROM, &sig_tty, &dfb_vt->sig_usr1 ) || + sigaction( SIG_SWITCH_TO, &sig_tty, &dfb_vt->sig_usr2 )) { + D_PERROR( "DirectFB/fbdev/vt: sigaction failed!\n" ); + tcsetattr( dfb_vt->fd, TCSAFLUSH, &dfb_vt->old_ts ); + ioctl( dfb_vt->fd, KDSKBMODE, K_XLATE ); + close( dfb_vt->fd ); + return DFB_INIT; + } + + + vt.mode = VT_PROCESS; + vt.waitv = 0; + vt.relsig = SIG_SWITCH_FROM; + vt.acqsig = SIG_SWITCH_TO; + + if (ioctl( dfb_vt->fd, VT_SETMODE, &vt ) < 0) { + D_PERROR( "DirectFB/fbdev/vt: VT_SETMODE failed!\n" ); + + sigaction( SIG_SWITCH_FROM, &dfb_vt->sig_usr1, NULL ); + sigaction( SIG_SWITCH_TO, &dfb_vt->sig_usr2, NULL ); + + tcsetattr( dfb_vt->fd, TCSAFLUSH, &dfb_vt->old_ts ); + ioctl( dfb_vt->fd, KDSKBMODE, K_XLATE ); + close( dfb_vt->fd ); + + return DFB_INIT; + } + + direct_util_recursive_pthread_mutex_init( &dfb_vt->lock ); + + pthread_cond_init( &dfb_vt->wait, NULL ); + + dfb_vt->vt_sig = -1; + + dfb_vt->thread = direct_thread_create( DTT_CRITICAL, vt_thread, NULL, "VT Switcher" ); + } + + return DFB_OK; +} + +static int +vt_get_fb( int vt ) +{ + struct fb_con2fbmap c2m; + + D_DEBUG_AT( VT, "%s( %d )\n", __FUNCTION__, vt ); + + c2m.console = vt; + + if (ioctl( dfb_fbdev->fd, FBIOGET_CON2FBMAP, &c2m )) { + D_PERROR( "DirectFB/FBDev/vt: " + "FBIOGET_CON2FBMAP failed!\n" ); + return 0; + } + + D_DEBUG_AT( VT, " -> %d\n", c2m.framebuffer ); + + return c2m.framebuffer; +} + +static void +vt_set_fb( int vt, int fb ) +{ + struct fb_con2fbmap c2m; + struct stat sbf; + + D_DEBUG_AT( VT, "%s( %d, %d )\n", __FUNCTION__, vt, fb ); + + if (fstat( dfb_fbdev->fd, &sbf )) { + D_PERROR( "DirectFB/FBDev/vt: Could not fstat fb device!\n" ); + return; + } + + if (fb >= 0) + c2m.framebuffer = fb; + else + c2m.framebuffer = (sbf.st_rdev & 0xFF) >> 5; + + c2m.console = vt; + + if (ioctl( dfb_fbdev->fd, FBIOPUT_CON2FBMAP, &c2m ) < 0) { + D_PERROR( "DirectFB/FBDev/vt: " + "FBIOPUT_CON2FBMAP failed!\n" ); + } +} + +static void +vt_start_flushing( void ) +{ + dfb_vt->flush = true; + dfb_vt->flush_thread = direct_thread_create( DTT_DEFAULT, vt_flush_thread, NULL, "VT Flusher" ); +} + +static void +vt_stop_flushing( void ) +{ + dfb_vt->flush = false; + direct_thread_cancel( dfb_vt->flush_thread ); + direct_thread_join( dfb_vt->flush_thread ); + direct_thread_destroy( dfb_vt->flush_thread ); + dfb_vt->flush_thread = NULL; +} + +/* + * If the vt buffer in not kept clean the kernel may stop sleeping. + */ +static void * +vt_flush_thread( DirectThread *thread, void *arg ) +{ + D_DEBUG_AT( VT, "%s( %p, %p )\n", __FUNCTION__, thread, arg ); + + while (dfb_vt->flush) { + fd_set set; + int ret; + + FD_ZERO( &set ); + FD_SET( dfb_vt->fd, &set ); + + ret = select( dfb_vt->fd + 1, &set, NULL, NULL, NULL ); + + if (ret < 0 && errno == EINTR) + continue; + + if (ret < 0) + break; + + tcflush( dfb_vt->fd, TCIFLUSH ); + } + + return NULL; +} diff --git a/Source/DirectFB/systems/fbdev/vt.h b/Source/DirectFB/systems/fbdev/vt.h new file mode 100755 index 0000000..d9b1019 --- /dev/null +++ b/Source/DirectFB/systems/fbdev/vt.h @@ -0,0 +1,83 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __VT_H__ +#define __VT_H__ + +#include +#include +#include +#include + +#include + +typedef struct { + int fd0; /* file descriptor of /dev/tty0 */ + int fd; /* file descriptor of /dev/ttyN + where N is the number of the allocated VT, + may be equal to 'fd0' if VT allocation + is disabled by "--no-vt-switch" */ + + int num; /* number of vt where DirectFB runs */ + int prev; /* number of vt DirectFB was started from */ + + int old_fb; /* original fb mapped to vt */ + + struct sigaction sig_usr1; /* previous signal handler for USR1 */ + struct sigaction sig_usr2; /* previous signal handler for USR2 */ + + struct vt_mode vt_mode; /* previous VT mode */ + + DirectThread *thread; + pthread_mutex_t lock; + pthread_cond_t wait; + + int vt_sig; + struct termios old_ts; + + bool flush; + DirectThread *flush_thread; +} VirtualTerminal; + +/* + * allocates and switches to a new virtual terminal + */ +DFBResult dfb_vt_initialize( void ); +DFBResult dfb_vt_join( void ); + +/* + * deallocates virtual terminal + */ +DFBResult dfb_vt_shutdown( bool emergency ); +DFBResult dfb_vt_leave( bool emergency ); + +DFBResult dfb_vt_detach( bool force ); + +bool dfb_vt_switch( int num ); + +#endif diff --git a/Source/DirectFB/systems/osx/Makefile.am b/Source/DirectFB/systems/osx/Makefile.am new file mode 100755 index 0000000..7f12422 --- /dev/null +++ b/Source/DirectFB/systems/osx/Makefile.am @@ -0,0 +1,59 @@ +## Makefile.am for DirectFB/systems/osx + +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src + +systemsdir = $(MODULEDIR)/systems + +systems_LTLIBRARIES = libdirectfb_osx.la + +if BUILD_STATIC +systems_DATA = libdirectfb_osx.o +endif + + +libdirectfb_osx_la_LDFLAGS = \ + -framework ApplicationServices \ + -avoid-version \ + -module + +libdirectfb_osx_la_SOURCES = \ + primary.c \ + primary.h \ + osx.c \ + osx.h + +libdirectfb_osx_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la + +inputdriversdir = $(MODULEDIR)/inputdrivers + +inputdrivers_LTLIBRARIES = libdirectfb_osxinput.la + +if BUILD_STATIC +inputdrivers_DATA = libdirectfb_osxinput.o +endif + + +libdirectfb_osxinput_la_LDFLAGS = \ + -framework Carbon \ + -avoid-version \ + -module + +libdirectfb_osxinput_la_SOURCES = \ + osxinput.c + +libdirectfb_osxinput_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/osx/Makefile.in b/Source/DirectFB/systems/osx/Makefile.in new file mode 100755 index 0000000..84b6c67 --- /dev/null +++ b/Source/DirectFB/systems/osx/Makefile.in @@ -0,0 +1,685 @@ +# 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 = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/rules/libobject.make +subdir = systems/osx +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)$(inputdriversdir)" \ + "$(DESTDIR)$(systemsdir)" "$(DESTDIR)$(inputdriversdir)" \ + "$(DESTDIR)$(systemsdir)" +inputdriversLTLIBRARIES_INSTALL = $(INSTALL) +systemsLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(inputdrivers_LTLIBRARIES) $(systems_LTLIBRARIES) +libdirectfb_osx_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la +am_libdirectfb_osx_la_OBJECTS = primary.lo osx.lo +libdirectfb_osx_la_OBJECTS = $(am_libdirectfb_osx_la_OBJECTS) +libdirectfb_osx_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_osx_la_LDFLAGS) $(LDFLAGS) -o $@ +libdirectfb_osxinput_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la +am_libdirectfb_osxinput_la_OBJECTS = osxinput.lo +libdirectfb_osxinput_la_OBJECTS = \ + $(am_libdirectfb_osxinput_la_OBJECTS) +libdirectfb_osxinput_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_osxinput_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_osx_la_SOURCES) \ + $(libdirectfb_osxinput_la_SOURCES) +DIST_SOURCES = $(libdirectfb_osx_la_SOURCES) \ + $(libdirectfb_osxinput_la_SOURCES) +inputdriversDATA_INSTALL = $(INSTALL_DATA) +systemsDATA_INSTALL = $(INSTALL_DATA) +DATA = $(inputdrivers_DATA) $(systems_DATA) +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 + +systemsdir = $(MODULEDIR)/systems +systems_LTLIBRARIES = libdirectfb_osx.la +@BUILD_STATIC_TRUE@systems_DATA = libdirectfb_osx.o +libdirectfb_osx_la_LDFLAGS = \ + -framework ApplicationServices \ + -avoid-version \ + -module + +libdirectfb_osx_la_SOURCES = \ + primary.c \ + primary.h \ + osx.c \ + osx.h + +libdirectfb_osx_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la + +inputdriversdir = $(MODULEDIR)/inputdrivers +inputdrivers_LTLIBRARIES = libdirectfb_osxinput.la +@BUILD_STATIC_TRUE@inputdrivers_DATA = libdirectfb_osxinput.o +libdirectfb_osxinput_la_LDFLAGS = \ + -framework Carbon \ + -avoid-version \ + -module + +libdirectfb_osxinput_la_SOURCES = \ + osxinput.c + +libdirectfb_osxinput_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/osx/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu systems/osx/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-inputdriversLTLIBRARIES: $(inputdrivers_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(inputdriversdir)" || $(MKDIR_P) "$(DESTDIR)$(inputdriversdir)" + @list='$(inputdrivers_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(inputdriversLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(inputdriversdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(inputdriversLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(inputdriversdir)/$$f"; \ + else :; fi; \ + done + +uninstall-inputdriversLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(inputdrivers_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(inputdriversdir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(inputdriversdir)/$$p"; \ + done + +clean-inputdriversLTLIBRARIES: + -test -z "$(inputdrivers_LTLIBRARIES)" || rm -f $(inputdrivers_LTLIBRARIES) + @list='$(inputdrivers_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 +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_osx.la: $(libdirectfb_osx_la_OBJECTS) $(libdirectfb_osx_la_DEPENDENCIES) + $(libdirectfb_osx_la_LINK) -rpath $(systemsdir) $(libdirectfb_osx_la_OBJECTS) $(libdirectfb_osx_la_LIBADD) $(LIBS) +libdirectfb_osxinput.la: $(libdirectfb_osxinput_la_OBJECTS) $(libdirectfb_osxinput_la_DEPENDENCIES) + $(libdirectfb_osxinput_la_LINK) -rpath $(inputdriversdir) $(libdirectfb_osxinput_la_OBJECTS) $(libdirectfb_osxinput_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osxinput.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/primary.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-inputdriversDATA: $(inputdrivers_DATA) + @$(NORMAL_INSTALL) + test -z "$(inputdriversdir)" || $(MKDIR_P) "$(DESTDIR)$(inputdriversdir)" + @list='$(inputdrivers_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(inputdriversDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(inputdriversdir)/$$f'"; \ + $(inputdriversDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(inputdriversdir)/$$f"; \ + done + +uninstall-inputdriversDATA: + @$(NORMAL_UNINSTALL) + @list='$(inputdrivers_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(inputdriversdir)/$$f'"; \ + rm -f "$(DESTDIR)$(inputdriversdir)/$$f"; \ + done +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 + +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) +installdirs: + for dir in "$(DESTDIR)$(inputdriversdir)" "$(DESTDIR)$(systemsdir)" "$(DESTDIR)$(inputdriversdir)" "$(DESTDIR)$(systemsdir)"; 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-inputdriversLTLIBRARIES 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-inputdriversDATA \ + install-inputdriversLTLIBRARIES 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-inputdriversDATA \ + uninstall-inputdriversLTLIBRARIES uninstall-systemsDATA \ + uninstall-systemsLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-inputdriversLTLIBRARIES 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-inputdriversDATA \ + install-inputdriversLTLIBRARIES 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-inputdriversDATA \ + uninstall-inputdriversLTLIBRARIES 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/osx/osx.c b/Source/DirectFB/systems/osx/osx.c new file mode 100755 index 0000000..e051fb8 --- /dev/null +++ b/Source/DirectFB/systems/osx/osx.c @@ -0,0 +1,263 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include + +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include "osx.h" +#include "primary.h" + +#include + +DFB_CORE_SYSTEM( osx ) + + +DFBOSX *dfb_osx = NULL; +CoreDFB *dfb_osx_core = NULL; + + +static void +system_get_info( CoreSystemInfo *info ) +{ + info->type = CORE_OSX; + + snprintf( info->name, DFB_CORE_SYSTEM_INFO_NAME_LENGTH, "OSX" ); +} + +static DFBResult +system_initialize( CoreDFB *core, void **data ) +{ + char *driver; + CoreScreen *screen; + + D_ASSERT( dfb_osx == NULL ); + + dfb_osx = (DFBOSX*) SHCALLOC( dfb_core_shmpool(dfb_osx_core), 1, sizeof(DFBOSX) ); + if (!dfb_osx) { + D_ERROR( "DirectFB/OSX: Couldn't allocate shared memory!\n" ); + return D_OOSHM(); + } + + dfb_osx_core = core; + + /* Initialize OSX */ + fusion_skirmish_init( &dfb_osx->lock, "OSX System", dfb_core_world(core) ); + + fusion_call_init( &dfb_osx->call, dfb_osx_call_handler, NULL, dfb_core_world(core) ); + + screen = dfb_screens_register( NULL, NULL, &osxPrimaryScreenFuncs ); + + dfb_layers_register( screen, NULL, &osxPrimaryLayerFuncs ); + + fusion_arena_add_shared_field( dfb_core_arena( core ), "OSX", dfb_osx ); + + *data = dfb_osx; + + return DFB_OK; +} + +static DFBResult +system_join( CoreDFB *core, void **data ) +{ + void *ret; + CoreScreen *screen; + + D_ASSERT( dfb_osx == NULL ); + + fusion_arena_get_shared_field( dfb_core_arena( core ), "OSX", &ret ); + + dfb_osx = ret; + dfb_osx_core = core; + + screen = dfb_screens_register( NULL, NULL, &osxPrimaryScreenFuncs ); + + dfb_layers_register( screen, NULL, &osxPrimaryLayerFuncs ); + + *data = dfb_osx; + + return DFB_OK; +} + +static DFBResult +system_shutdown( bool emergency ) +{ + D_ASSERT( dfb_osx != NULL ); + + fusion_call_destroy( &dfb_osx->call ); + + fusion_skirmish_prevail( &dfb_osx->lock ); + + fusion_skirmish_destroy( &dfb_osx->lock ); + + SHFREE( dfb_core_shmpool(dfb_osx_core), dfb_osx ); + dfb_osx = NULL; + dfb_osx_core = NULL; + + return DFB_OK; +} + +static DFBResult +system_leave( bool emergency ) +{ + D_ASSERT( dfb_osx != NULL ); + + dfb_osx = NULL; + dfb_osx_core = NULL; + + return DFB_OK; +} + +static DFBResult +system_suspend( void ) +{ + return DFB_UNIMPLEMENTED; +} + +static DFBResult +system_resume( void ) +{ + return DFB_UNIMPLEMENTED; +} + +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( void ) +{ + return -1; +} + +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 0; +} + +static void * +system_video_memory_virtual( unsigned int offset ) +{ + return NULL; +} + +static unsigned int +system_videoram_length( void ) +{ + return 0; +} + +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/osx/osx.h b/Source/DirectFB/systems/osx/osx.h new file mode 100755 index 0000000..820a8d5 --- /dev/null +++ b/Source/DirectFB/systems/osx/osx.h @@ -0,0 +1,43 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __OSX__OSX_H__ +#define __OSX__OSX_H__ + +#include +#include + +typedef struct { + FusionSkirmish lock; + FusionCall call; + + CoreSurface *primary; +} DFBOSX; + +#endif + diff --git a/Source/DirectFB/systems/osx/osxinput.c b/Source/DirectFB/systems/osx/osxinput.c new file mode 100755 index 0000000..056bb0d --- /dev/null +++ b/Source/DirectFB/systems/osx/osxinput.c @@ -0,0 +1,311 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include + +#include + + +#include +#include +#include +#include + +#include +#include + +#include + +#include "osx.h" + +#include + + +DFB_INPUT_DRIVER( osxinput ) + +/* + * declaration of private data + */ +typedef struct { + CoreInputDevice *device; + DirectThread *thread; + DFBOSX *dfb_osx; + int stop; +} OSXInputData; + +static DFBInputEvent motionX = { + .type = DIET_UNKNOWN, + .axisabs = 0, +}; + +static DFBInputEvent motionY = { + .type = DIET_UNKNOWN, + .axisabs = 0, +}; + +static void +motion_compress( int x, int y ) +{ + if (motionX.axisabs != x) { + motionX.type = DIET_AXISMOTION; + motionX.flags = DIEF_AXISABS; + motionX.axis = DIAI_X; + motionX.axisabs = x; + } + + if (motionY.axisabs != y) { + motionY.type = DIET_AXISMOTION; + motionY.flags = DIEF_AXISABS; + motionY.axis = DIAI_Y; + motionY.axisabs = y; + } +} + +static void +motion_realize( OSXInputData *data ) +{ + if (motionX.type != DIET_UNKNOWN) { + dfb_input_dispatch( data->device, &motionX ); + + motionX.type = DIET_UNKNOWN; + } + + if (motionY.type != DIET_UNKNOWN) { + dfb_input_dispatch( data->device, &motionY ); + + motionY.type = DIET_UNKNOWN; + } +} + + +static bool +translate_key( unsigned short key, DFBInputEvent *evt ) +{ + unsigned char charcode = (unsigned char)key; + unsigned char keycode = (unsigned char)(key>>8); + + printf("keycode: %d char: %d\n",keycode,charcode); + + if (charcode) { + evt->flags = DIEF_KEYSYMBOL; + switch (charcode) { + case 28: evt->key_symbol = DIKS_CURSOR_LEFT; break; + case 29: evt->key_symbol = DIKS_CURSOR_RIGHT; break; + case 30: evt->key_symbol = DIKS_CURSOR_UP; break; + case 31: evt->key_symbol = DIKS_CURSOR_DOWN; break; + default: + evt->key_symbol = charcode; + break; + } + return true; + } + else if (keycode) { + evt->flags = DIEF_KEYID; + evt->key_id = keycode; + return true; + } + + return false; +} + +/* + * Input thread reading from device. + * Generates events on incoming data. + */ +static void* +osxEventThread( DirectThread *thread, void *driver_data ) +{ + OSXInputData *data = (OSXInputData*) driver_data; + DFBOSX *dfb_osx = data->dfb_osx; + + while (!data->stop) { + DFBInputEvent evt; + EventRecord event; + + fusion_skirmish_prevail( &dfb_osx->lock ); + + /* Check for events */ + while ( WaitNextEvent( everyEvent, &event, 0, nil) ) { + fusion_skirmish_dismiss( &dfb_osx->lock ); + + switch (event.what) { + case keyDown: + case keyUp: + case autoKey: + if (event.what == keyUp) + evt.type = DIET_KEYRELEASE; + else + evt.type = DIET_KEYPRESS; + + if (translate_key( event.message & (charCodeMask | keyCodeMask), &evt )) { + dfb_input_dispatch( data->device, &evt ); + } + + break; + case mouseDown: + evt.type = DIET_BUTTONPRESS; + evt.button = DIBI_LEFT; + dfb_input_dispatch( data->device, &evt ); + break; + case mouseUp: + evt.type = DIET_BUTTONRELEASE; + evt.button = DIBI_LEFT; + dfb_input_dispatch( data->device, &evt ); + break; + default: + printf("%d\n",event.what); + break; + } + + fusion_skirmish_prevail( &dfb_osx->lock ); + } + + fusion_skirmish_dismiss( &dfb_osx->lock ); + + usleep(10000); + + direct_thread_testcancel( thread ); + } + + return NULL; +} + +/* exported symbols */ + +/* + * Return the number of available devices. + * Called once during initialization of DirectFB. + */ +static int +driver_get_available( void ) +{ + if (dfb_system_type() == CORE_OSX) + return 1; + + return 0; +} + +/* + * Fill out general information about this driver. + * Called once during initialization of DirectFB. + */ +static void +driver_get_info( InputDriverInfo *info ) +{ + /* fill driver info structure */ + snprintf ( info->name, + DFB_INPUT_DRIVER_INFO_NAME_LENGTH, "OSX Input Driver" ); + snprintf ( info->vendor, + DFB_INPUT_DRIVER_INFO_VENDOR_LENGTH, "Andreas Hundt" ); + + info->version.major = 0; + info->version.minor = 1; +} + +/* + * Open the device, fill out information about it, + * allocate and fill private data, start input thread. + * Called during initialization, resuming or taking over mastership. + */ +static DFBResult +driver_open_device( CoreInputDevice *device, + unsigned int number, + InputDeviceInfo *info, + void **driver_data ) +{ + OSXInputData *data; + DFBOSX *dfb_osx = dfb_system_data(); + + fusion_skirmish_prevail( &dfb_osx->lock ); + + fusion_skirmish_dismiss( &dfb_osx->lock ); + + /* set device name */ + snprintf( info->desc.name, + DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "OSX Input" ); + + /* set device vendor */ + snprintf( info->desc.vendor, + DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "OSX" ); + + /* set one of the primary input device IDs */ + info->prefered_id = DIDID_KEYBOARD; + + /* set type flags */ + info->desc.type = DIDTF_KEYBOARD | DIDTF_MOUSE; + + /* set capabilities */ + info->desc.caps = DICAPS_ALL; + + /* allocate and fill private data */ + data = D_CALLOC( 1, sizeof(OSXInputData) ); + + data->device = device; + data->dfb_osx = dfb_osx; + + /* start input thread */ + data->thread = direct_thread_create( DTT_INPUT, osxEventThread, data, "OSX Input" ); + + /* set private data pointer */ + *driver_data = data; + + return DFB_OK; +} + +/* + * Fetch one entry from the device's keymap if supported. + */ +static DFBResult +driver_get_keymap_entry( CoreInputDevice *device, + void *driver_data, + DFBInputDeviceKeymapEntry *entry ) +{ + return DFB_UNSUPPORTED; +} + +/* + * End thread, close device and free private data. + */ +static void +driver_close_device( void *driver_data ) +{ + OSXInputData *data = (OSXInputData*) driver_data; + + /* stop input thread */ + data->stop = 1; + + direct_thread_join( data->thread ); + direct_thread_destroy( data->thread ); + + /* free private data */ + D_FREE ( data ); +} diff --git a/Source/DirectFB/systems/osx/primary.c b/Source/DirectFB/systems/osx/primary.c new file mode 100755 index 0000000..0d0cac6 --- /dev/null +++ b/Source/DirectFB/systems/osx/primary.c @@ -0,0 +1,623 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +#include + +#include "osx.h" +#include "primary.h" + +extern DFBOSX *dfb_osx; +extern CoreDFB *dfb_osx_core; + +/******************************************************************************/ + +static DFBResult dfb_osx_set_video_mode( CoreDFB *core, CoreLayerRegionConfig *config ); +static DFBResult dfb_osx_update_screen( CoreDFB *core, DFBRegion *region ); +static DFBResult dfb_osx_set_palette( CorePalette *palette ); + +static DFBResult update_screen( CoreSurface *surface, + int x, int y, int w, int h ); + +static CGDirectDisplayID screen = NULL; + +/******************************************************************************/ + +static DFBResult +primaryInitScreen( CoreScreen *screen, + GraphicsDevice *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, "OSX Primary Screen" ); + + return DFB_OK; +} + +static DFBResult +primaryGetScreenSize( CoreScreen *screen, + void *driver_data, + void *screen_data, + int *ret_width, + int *ret_height ) +{ + D_ASSERT( dfb_osx != NULL ); + + if (dfb_osx->primary) { + *ret_width = dfb_osx->primary->width; + *ret_height = dfb_osx->primary->height; + } + else { + if (dfb_config->mode.width) + *ret_width = dfb_config->mode.width; + else + *ret_width = 640; + + if (dfb_config->mode.height) + *ret_height = dfb_config->mode.height; + else + *ret_height = 480; + } + + return DFB_OK; +} + +ScreenFuncs osxPrimaryScreenFuncs = { + .InitScreen = primaryInitScreen, + .GetScreenSize = primaryGetScreenSize, +}; + +/******************************************************************************/ + +static int +primaryLayerDataSize( void ) +{ + return 0; +} + +static int +primaryRegionDataSize( void ) +{ + 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, "OSX 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 = 640; + + if (dfb_config->mode.height) + config->height = dfb_config->mode.height; + else + config->height = 480; + + 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_ARGB1555; + + 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: + 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 ) +{ + DFBResult ret; + + if (surface) + dfb_osx->primary = surface; + + ret = dfb_osx_set_video_mode( dfb_osx_core, config ); + if (ret) + return ret; + + if (palette) + dfb_osx_set_palette( palette ); + + return DFB_OK; +} + +static DFBResult +primaryRemoveRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data ) +{ + dfb_osx->primary = NULL; + + return DFB_OK; +} + +static DFBResult +primaryFlipRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + DFBSurfaceFlipFlags flags ) +{ + dfb_surface_flip_buffers( surface, false ); + + return dfb_osx_update_screen( dfb_osx_core, NULL ); +} + +static DFBResult +primaryUpdateRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + const DFBRegion *update ) +{ + + if (surface && (surface->caps & DSCAPS_FLIPPING)) { + if (update) { + DFBRegion region = *update; + + return dfb_osx_update_screen( dfb_osx_core, ®ion ); + } + else + return dfb_osx_update_screen( dfb_osx_core, NULL ); + } + + return DFB_OK; +} + +static DFBResult +primaryAllocateSurface( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreSurface **ret_surface ) +{ + DFBSurfaceCapabilities caps = DSCAPS_SYSTEMONLY; + + if (config->buffermode != DLBM_FRONTONLY) { + caps |= DSCAPS_DOUBLE; + return dfb_surface_create( NULL, config->width, config->height, + config->format, CSP_SYSTEMONLY, + caps, NULL, ret_surface ); + } + else { + DFBResult ret; + CoreSurface *surface = NULL; + + surface = dfb_core_create_surface( NULL ); + if (!surface) + return DFB_FAILURE; + + /* reallocation just needs an allocated buffer structure */ + surface->idle_buffer = surface->back_buffer = surface->front_buffer + = SHCALLOC( dfb_core_shmpool(dfb_osx_core), 1, sizeof(SurfaceBuffer) ); + + surface->front_buffer->policy = CSP_SYSTEMONLY; + surface->front_buffer->format = config->format; + + *ret_surface = surface; + + ret = dfb_surface_init( NULL, surface, + config->width, config->height, + config->format, caps, NULL ); + + if (ret) + return ret; + + /* activate object */ + fusion_object_activate( &surface->object ); + + return ret; + } +} + +static DFBResult +primaryReallocateSurface( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreSurface *surface ) +{ + DFBResult ret; + + /* FIXME: write surface management functions + for easier configuration changes */ + switch (config->buffermode) { + case DLBM_BACKVIDEO: + case DLBM_BACKSYSTEM: + surface->caps |= DSCAPS_DOUBLE; + + ret = dfb_surface_reconfig( surface, + CSP_SYSTEMONLY, CSP_SYSTEMONLY ); + break; + + case DLBM_FRONTONLY: + surface->caps &= ~DSCAPS_DOUBLE; + + ret = dfb_surface_reconfig( surface, + CSP_SYSTEMONLY, CSP_SYSTEMONLY ); + break; + + default: + D_BUG("unknown buffermode"); + return DFB_BUG; + } + if (ret) + return ret; + + ret = dfb_surface_reformat( NULL, surface, config->width, + config->height, config->format ); + if (ret) + return ret; + + + if (DFB_PIXELFORMAT_IS_INDEXED(config->format) && !surface->palette) { + DFBResult ret; + CorePalette *palette; + + ret = dfb_palette_create( NULL, /* FIXME */ + 1 << DFB_COLOR_BITS_PER_PIXEL( config->format ), + &palette ); + if (ret) + return ret; + + if (config->format == DSPF_LUT8) + dfb_palette_generate_rgb332_map( palette ); + + dfb_surface_set_palette( surface, palette ); + + dfb_palette_unref( palette ); + } + + return DFB_OK; +} + +DisplayLayerFuncs osxPrimaryLayerFuncs = { + .LayerDataSize = primaryLayerDataSize, + .RegionDataSize = primaryRegionDataSize, + .InitLayer = primaryInitLayer, + + .TestRegion = primaryTestRegion, + .AddRegion = primaryAddRegion, + .SetRegion = primarySetRegion, + .RemoveRegion = primaryRemoveRegion, + .FlipRegion = primaryFlipRegion, + .UpdateRegion = primaryUpdateRegion, + + .AllocateSurface = primaryAllocateSurface, + .ReallocateSurface = primaryReallocateSurface, +}; + +/******************************************************************************/ + +static DFBResult +update_screen( CoreSurface *surface, int x, int y, int w, int h ) +{ + int i; + void *dst; + void *src; + int pitch; + int dst_pitch; + DFBResult ret; + + D_ASSERT( surface != NULL ); + ret = dfb_surface_soft_lock( dfb_osx_core, surface, DSLF_READ, &src, &pitch, true ); + if (ret) { + D_ERROR( "DirectFB/OSX: Couldn't lock layer surface: %s\n", + DirectFBErrorString( ret ) ); + return ret; + } + + dst = CGDisplayBaseAddress( screen ); + dst_pitch = CGDisplayBytesPerRow( screen ); + src += DFB_BYTES_PER_LINE( surface->config.format, x ) + y * pitch; + dst += DFB_BYTES_PER_LINE( surface->config.format, x ) + y * dst_pitch; + + for (i=0; iconfig.format, w ) ); + + src += pitch; + dst += dst_pitch; + } + + dfb_surface_unlock( surface, true ); + + return DFB_OK; +} + +/******************************************************************************/ + +typedef enum { + OSX_SET_VIDEO_MODE, + OSX_UPDATE_SCREEN, + OSX_SET_PALETTE +} DFBOSXCall; + +static DFBResult +dfb_osx_set_video_mode_handler( CoreLayerRegionConfig *config ) +{ + boolean_t exactMatch; + CFDictionaryRef mode; + + fusion_skirmish_prevail( &dfb_osx->lock ); + + mode = CGDisplayBestModeForParameters( screen, DFB_BITS_PER_PIXEL(config->format), + config->width, config->height, &exactMatch); + if (!mode || !exactMatch) + { + D_ERROR( "DirectFB/OSX: Couldn't set %dx%dx%d video mode.\n", + config->width, config->height, + DFB_COLOR_BITS_PER_PIXEL(config->format)); + + fusion_skirmish_dismiss( &dfb_osx->lock ); + + return DFB_FAILURE; + } + CGDisplaySwitchToMode( screen, mode ); + CGDisplayCapture(screen); + + if (config->buffermode == DLBM_FRONTONLY) { + /* update primary surface information */ + dfb_osx->primary->front_buffer->system.addr = CGDisplayBaseAddress( screen ); + dfb_osx->primary->front_buffer->system.pitch = CGDisplayBytesPerRow( screen ); + } + fusion_skirmish_dismiss( &dfb_osx->lock ); + + return DFB_OK; +} + +static DFBResult +dfb_osx_update_screen_handler( DFBRegion *region ) +{ + DFBResult ret; + CoreSurface *surface = dfb_osx->primary; + + fusion_skirmish_prevail( &dfb_osx->lock ); + + if (!region) + ret = update_screen( surface, 0, 0, surface->config.size.w, surface->config.size.h ); + else + ret = update_screen( surface, + region->x1, region->y1, + region->x2 - region->x1 + 1, + region->y2 - region->y1 + 1 ); + + fusion_skirmish_dismiss( &dfb_osx->lock ); + + return DFB_OK; +} + +static DFBResult +dfb_osx_set_palette_handler( CorePalette *palette ) +{ + fusion_skirmish_prevail( &dfb_osx->lock ); + +// do something usefull + fusion_skirmish_dismiss( &dfb_osx->lock ); + + return DFB_OK; +} + +FusionCallHandlerResult +dfb_osx_call_handler( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ) +{ + switch (call_arg) { + case OSX_SET_VIDEO_MODE: + *ret_val = dfb_osx_set_video_mode_handler( call_ptr ); + break; + + case OSX_UPDATE_SCREEN: + *ret_val = dfb_osx_update_screen_handler( call_ptr ); + break; + + case OSX_SET_PALETTE: + *ret_val = dfb_osx_set_palette_handler( call_ptr ); + break; + + default: + D_BUG( "unknown call" ); + *ret_val = DFB_BUG; + break; + } + + return FCHR_RETURN; +} + +static DFBResult +dfb_osx_set_video_mode( CoreDFB *core, CoreLayerRegionConfig *config ) +{ + int ret; + CoreLayerRegionConfig *tmp = NULL; + + D_ASSERT( config != NULL ); + + if (dfb_core_is_master( core )) + return dfb_osx_set_video_mode_handler( config ); + + if (!fusion_is_shared( dfb_core_world(core), config )) { + tmp = SHMALLOC( dfb_core_shmpool(dfb_osx_core), sizeof(CoreLayerRegionConfig) ); + if (!tmp) + return D_OOSHM(); + + direct_memcpy( tmp, config, sizeof(CoreLayerRegionConfig) ); + } + + fusion_call_execute( &dfb_osx->call, FCEF_NONE, OSX_SET_VIDEO_MODE, + tmp ? tmp : config, &ret ); + + if (tmp) + SHFREE( dfb_core_shmpool(dfb_osx_core), tmp ); + + return ret; +} + +static DFBResult +dfb_osx_update_screen( CoreDFB *core, DFBRegion *region ) +{ + int ret; + DFBRegion *tmp = NULL; + + if (dfb_core_is_master( core )) + return dfb_osx_update_screen_handler( region ); + + if (region) { + if (!fusion_is_shared( dfb_core_world(core), region )) { + tmp = SHMALLOC( dfb_core_shmpool(dfb_osx_core), sizeof(DFBRegion) ); + if (!tmp) + return D_OOSHM(); + + direct_memcpy( tmp, region, sizeof(DFBRegion) ); + } + } + + fusion_call_execute( &dfb_osx->call, FCEF_ONEWAY, OSX_UPDATE_SCREEN, + tmp ? tmp : region, &ret ); + + if (tmp) + SHFREE( dfb_core_shmpool(dfb_osx_core), tmp ); + + return ret; +} + +static DFBResult +dfb_osx_set_palette( CorePalette *palette ) +{ + int ret; + + fusion_call_execute( &dfb_osx->call, FCEF_NONE, OSX_SET_PALETTE, + palette, &ret ); + + return ret; +} + diff --git a/Source/DirectFB/systems/osx/primary.h b/Source/DirectFB/systems/osx/primary.h new file mode 100755 index 0000000..5399dbc --- /dev/null +++ b/Source/DirectFB/systems/osx/primary.h @@ -0,0 +1,49 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __OSX__PRIMARY_H__ +#define __OSX__PRIMARY_H__ + +#include + +#include +#include + +extern ScreenFuncs osxPrimaryScreenFuncs; +extern DisplayLayerFuncs osxPrimaryLayerFuncs; + +FusionCallHandlerResult +dfb_osx_call_handler( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ) + +#endif + diff --git a/Source/DirectFB/systems/sdl/Makefile.am b/Source/DirectFB/systems/sdl/Makefile.am new file mode 100755 index 0000000..728362e --- /dev/null +++ b/Source/DirectFB/systems/sdl/Makefile.am @@ -0,0 +1,86 @@ +## Makefile.am for DirectFB/systems/sdl + +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src \ + $(SDL_CFLAGS) + + +systemsdir = $(MODULEDIR)/systems + +if BUILD_STATIC +systems_DATA = libdirectfb_sdl.o +endif + +systems_LTLIBRARIES = libdirectfb_sdl.la + + +inputdriversdir = $(MODULEDIR)/inputdrivers + +if BUILD_STATIC +inputdrivers_DATA = libdirectfb_sdlinput.o +endif + +inputdrivers_LTLIBRARIES = libdirectfb_sdlinput.la + + +gfxdriversdir = $(MODULEDIR)/gfxdrivers + +if BUILD_STATIC +gfxdrivers_DATA = libdirectfb_sdlgraphics.o +endif + +gfxdrivers_LTLIBRARIES = libdirectfb_sdlgraphics.la + + +libdirectfb_sdl_la_LDFLAGS = \ + -avoid-version \ + -module + +libdirectfb_sdl_la_SOURCES = \ + primary.c \ + primary.h \ + sdl.c \ + sdl.h \ + sdl_surface_pool.c + +libdirectfb_sdl_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la \ + $(SDL_LIBS) + + +libdirectfb_sdlinput_la_LDFLAGS = \ + -avoid-version \ + -module + +libdirectfb_sdlinput_la_SOURCES = \ + sdlinput.c + +libdirectfb_sdlinput_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la \ + $(SDL_LIBS) + + +libdirectfb_sdlgraphics_la_LDFLAGS = \ + -avoid-version \ + -module + +libdirectfb_sdlgraphics_la_SOURCES = \ + sdlgfx.c + +libdirectfb_sdlgraphics_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la \ + $(SDL_LIBS) + + +include $(top_srcdir)/rules/libobject.make + diff --git a/Source/DirectFB/systems/sdl/Makefile.in b/Source/DirectFB/systems/sdl/Makefile.in new file mode 100755 index 0000000..e628cd6 --- /dev/null +++ b/Source/DirectFB/systems/sdl/Makefile.in @@ -0,0 +1,773 @@ +# 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 = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/rules/libobject.make +subdir = systems/sdl +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)$(gfxdriversdir)" \ + "$(DESTDIR)$(inputdriversdir)" "$(DESTDIR)$(systemsdir)" \ + "$(DESTDIR)$(gfxdriversdir)" "$(DESTDIR)$(inputdriversdir)" \ + "$(DESTDIR)$(systemsdir)" +gfxdriversLTLIBRARIES_INSTALL = $(INSTALL) +inputdriversLTLIBRARIES_INSTALL = $(INSTALL) +systemsLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(gfxdrivers_LTLIBRARIES) $(inputdrivers_LTLIBRARIES) \ + $(systems_LTLIBRARIES) +am__DEPENDENCIES_1 = +libdirectfb_sdl_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la $(am__DEPENDENCIES_1) +am_libdirectfb_sdl_la_OBJECTS = primary.lo sdl.lo sdl_surface_pool.lo +libdirectfb_sdl_la_OBJECTS = $(am_libdirectfb_sdl_la_OBJECTS) +libdirectfb_sdl_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_sdl_la_LDFLAGS) $(LDFLAGS) -o $@ +libdirectfb_sdlgraphics_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la $(am__DEPENDENCIES_1) +am_libdirectfb_sdlgraphics_la_OBJECTS = sdlgfx.lo +libdirectfb_sdlgraphics_la_OBJECTS = \ + $(am_libdirectfb_sdlgraphics_la_OBJECTS) +libdirectfb_sdlgraphics_la_LINK = $(LIBTOOL) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(libdirectfb_sdlgraphics_la_LDFLAGS) \ + $(LDFLAGS) -o $@ +libdirectfb_sdlinput_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la $(am__DEPENDENCIES_1) +am_libdirectfb_sdlinput_la_OBJECTS = sdlinput.lo +libdirectfb_sdlinput_la_OBJECTS = \ + $(am_libdirectfb_sdlinput_la_OBJECTS) +libdirectfb_sdlinput_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_sdlinput_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_sdl_la_SOURCES) \ + $(libdirectfb_sdlgraphics_la_SOURCES) \ + $(libdirectfb_sdlinput_la_SOURCES) +DIST_SOURCES = $(libdirectfb_sdl_la_SOURCES) \ + $(libdirectfb_sdlgraphics_la_SOURCES) \ + $(libdirectfb_sdlinput_la_SOURCES) +gfxdriversDATA_INSTALL = $(INSTALL_DATA) +inputdriversDATA_INSTALL = $(INSTALL_DATA) +systemsDATA_INSTALL = $(INSTALL_DATA) +DATA = $(gfxdrivers_DATA) $(inputdrivers_DATA) $(systems_DATA) +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 \ + $(SDL_CFLAGS) + +systemsdir = $(MODULEDIR)/systems +@BUILD_STATIC_TRUE@systems_DATA = libdirectfb_sdl.o +systems_LTLIBRARIES = libdirectfb_sdl.la +inputdriversdir = $(MODULEDIR)/inputdrivers +@BUILD_STATIC_TRUE@inputdrivers_DATA = libdirectfb_sdlinput.o +inputdrivers_LTLIBRARIES = libdirectfb_sdlinput.la +gfxdriversdir = $(MODULEDIR)/gfxdrivers +@BUILD_STATIC_TRUE@gfxdrivers_DATA = libdirectfb_sdlgraphics.o +gfxdrivers_LTLIBRARIES = libdirectfb_sdlgraphics.la +libdirectfb_sdl_la_LDFLAGS = \ + -avoid-version \ + -module + +libdirectfb_sdl_la_SOURCES = \ + primary.c \ + primary.h \ + sdl.c \ + sdl.h \ + sdl_surface_pool.c + +libdirectfb_sdl_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la \ + $(SDL_LIBS) + +libdirectfb_sdlinput_la_LDFLAGS = \ + -avoid-version \ + -module + +libdirectfb_sdlinput_la_SOURCES = \ + sdlinput.c + +libdirectfb_sdlinput_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la \ + $(SDL_LIBS) + +libdirectfb_sdlgraphics_la_LDFLAGS = \ + -avoid-version \ + -module + +libdirectfb_sdlgraphics_la_SOURCES = \ + sdlgfx.c + +libdirectfb_sdlgraphics_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la \ + $(SDL_LIBS) + +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/sdl/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu systems/sdl/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-gfxdriversLTLIBRARIES: $(gfxdrivers_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(gfxdriversdir)" || $(MKDIR_P) "$(DESTDIR)$(gfxdriversdir)" + @list='$(gfxdrivers_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(gfxdriversLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(gfxdriversdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(gfxdriversLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(gfxdriversdir)/$$f"; \ + else :; fi; \ + done + +uninstall-gfxdriversLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(gfxdrivers_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(gfxdriversdir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(gfxdriversdir)/$$p"; \ + done + +clean-gfxdriversLTLIBRARIES: + -test -z "$(gfxdrivers_LTLIBRARIES)" || rm -f $(gfxdrivers_LTLIBRARIES) + @list='$(gfxdrivers_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 +install-inputdriversLTLIBRARIES: $(inputdrivers_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(inputdriversdir)" || $(MKDIR_P) "$(DESTDIR)$(inputdriversdir)" + @list='$(inputdrivers_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(inputdriversLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(inputdriversdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(inputdriversLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(inputdriversdir)/$$f"; \ + else :; fi; \ + done + +uninstall-inputdriversLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(inputdrivers_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(inputdriversdir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(inputdriversdir)/$$p"; \ + done + +clean-inputdriversLTLIBRARIES: + -test -z "$(inputdrivers_LTLIBRARIES)" || rm -f $(inputdrivers_LTLIBRARIES) + @list='$(inputdrivers_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 +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_sdl.la: $(libdirectfb_sdl_la_OBJECTS) $(libdirectfb_sdl_la_DEPENDENCIES) + $(libdirectfb_sdl_la_LINK) -rpath $(systemsdir) $(libdirectfb_sdl_la_OBJECTS) $(libdirectfb_sdl_la_LIBADD) $(LIBS) +libdirectfb_sdlgraphics.la: $(libdirectfb_sdlgraphics_la_OBJECTS) $(libdirectfb_sdlgraphics_la_DEPENDENCIES) + $(libdirectfb_sdlgraphics_la_LINK) -rpath $(gfxdriversdir) $(libdirectfb_sdlgraphics_la_OBJECTS) $(libdirectfb_sdlgraphics_la_LIBADD) $(LIBS) +libdirectfb_sdlinput.la: $(libdirectfb_sdlinput_la_OBJECTS) $(libdirectfb_sdlinput_la_DEPENDENCIES) + $(libdirectfb_sdlinput_la_LINK) -rpath $(inputdriversdir) $(libdirectfb_sdlinput_la_OBJECTS) $(libdirectfb_sdlinput_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/primary.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdl_surface_pool.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdlgfx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdlinput.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-gfxdriversDATA: $(gfxdrivers_DATA) + @$(NORMAL_INSTALL) + test -z "$(gfxdriversdir)" || $(MKDIR_P) "$(DESTDIR)$(gfxdriversdir)" + @list='$(gfxdrivers_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(gfxdriversDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(gfxdriversdir)/$$f'"; \ + $(gfxdriversDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(gfxdriversdir)/$$f"; \ + done + +uninstall-gfxdriversDATA: + @$(NORMAL_UNINSTALL) + @list='$(gfxdrivers_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(gfxdriversdir)/$$f'"; \ + rm -f "$(DESTDIR)$(gfxdriversdir)/$$f"; \ + done +install-inputdriversDATA: $(inputdrivers_DATA) + @$(NORMAL_INSTALL) + test -z "$(inputdriversdir)" || $(MKDIR_P) "$(DESTDIR)$(inputdriversdir)" + @list='$(inputdrivers_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(inputdriversDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(inputdriversdir)/$$f'"; \ + $(inputdriversDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(inputdriversdir)/$$f"; \ + done + +uninstall-inputdriversDATA: + @$(NORMAL_UNINSTALL) + @list='$(inputdrivers_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(inputdriversdir)/$$f'"; \ + rm -f "$(DESTDIR)$(inputdriversdir)/$$f"; \ + done +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 + +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) +installdirs: + for dir in "$(DESTDIR)$(gfxdriversdir)" "$(DESTDIR)$(inputdriversdir)" "$(DESTDIR)$(systemsdir)" "$(DESTDIR)$(gfxdriversdir)" "$(DESTDIR)$(inputdriversdir)" "$(DESTDIR)$(systemsdir)"; 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-gfxdriversLTLIBRARIES \ + clean-inputdriversLTLIBRARIES 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-gfxdriversDATA install-gfxdriversLTLIBRARIES \ + install-inputdriversDATA install-inputdriversLTLIBRARIES \ + 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-gfxdriversDATA uninstall-gfxdriversLTLIBRARIES \ + uninstall-inputdriversDATA uninstall-inputdriversLTLIBRARIES \ + uninstall-systemsDATA uninstall-systemsLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-gfxdriversLTLIBRARIES clean-inputdriversLTLIBRARIES \ + 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-gfxdriversDATA install-gfxdriversLTLIBRARIES \ + install-html install-html-am install-info install-info-am \ + install-inputdriversDATA install-inputdriversLTLIBRARIES \ + 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-gfxdriversDATA \ + uninstall-gfxdriversLTLIBRARIES uninstall-inputdriversDATA \ + uninstall-inputdriversLTLIBRARIES 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/sdl/primary.c b/Source/DirectFB/systems/sdl/primary.c new file mode 100755 index 0000000..94c0fb7 --- /dev/null +++ b/Source/DirectFB/systems/sdl/primary.c @@ -0,0 +1,669 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include "sdl.h" +#include "primary.h" + +D_DEBUG_DOMAIN( SDL_Screen, "SDL/Screen", "SDL System Screen" ); +D_DEBUG_DOMAIN( SDL_Updates, "SDL/Updates", "SDL System Screen Updates" ); + +/******************************************************************************/ + +static DFBResult update_screen( int x, int y, int w, int h ); + +/******************************************************************************/ + +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, "SDL Primary Screen" ); + + return DFB_OK; +} + +static DFBResult +primaryGetScreenSize( CoreScreen *screen, + void *driver_data, + void *screen_data, + int *ret_width, + int *ret_height ) +{ + D_ASSERT( dfb_sdl != NULL ); + + if (dfb_sdl->primary) { + *ret_width = dfb_sdl->primary->config.size.w; + *ret_height = dfb_sdl->primary->config.size.w; + } + else { + if (dfb_config->mode.width) + *ret_width = dfb_config->mode.width; + else + *ret_width = 640; + + if (dfb_config->mode.height) + *ret_height = dfb_config->mode.height; + else + *ret_height = 480; + } + + return DFB_OK; +} + +ScreenFuncs sdlPrimaryScreenFuncs = { + .InitScreen = primaryInitScreen, + .GetScreenSize = primaryGetScreenSize, +}; + +/******************************************************************************/ + +static void * ScreenUpdateLoop( DirectThread *thread, void *arg ); + +/******************************************************************************/ + +static int +primaryLayerDataSize( void ) +{ + return 0; +} + +static int +primaryRegionDataSize( void ) +{ + 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, "SDL 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 = 640; + + if (dfb_config->mode.height) + config->height = dfb_config->mode.height; + else + config->height = 480; + + 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_RGB16; + + /* Initialize update lock and condition. */ + pthread_mutex_init( &dfb_sdl->update.lock, NULL ); + pthread_cond_init( &dfb_sdl->update.cond, NULL ); + + /* Start update thread. */ + dfb_sdl->update.thread = direct_thread_create( DTT_OUTPUT, ScreenUpdateLoop, NULL, "Screen Update" ); + if (!dfb_sdl->update.thread) + return DFB_FAILURE; + + 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: + 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 ) +{ + if (surface) { + pthread_mutex_lock( &dfb_sdl->update.lock ); + dfb_sdl->primary = surface; + dfb_sdl->update.pending = false; + pthread_mutex_unlock( &dfb_sdl->update.lock ); + } + + if (palette) + dfb_sdl_set_palette( palette ); + + return DFB_OK; +} + +static DFBResult +primaryRemoveRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data ) +{ + D_DEBUG_AT( SDL_Updates, "%s( %p )\n", __FUNCTION__, layer ); + + D_DEBUG_AT( SDL_Updates, " -> locking sdl lock...\n" ); + + fusion_skirmish_prevail( &dfb_sdl->lock ); + + D_DEBUG_AT( SDL_Updates, " -> setting primary to NULL...\n" ); + + dfb_sdl->primary = NULL; + + D_DEBUG_AT( SDL_Updates, " -> unlocking sdl lock...\n" ); + + fusion_skirmish_dismiss( &dfb_sdl->lock ); + + D_DEBUG_AT( SDL_Updates, " -> done.\n" ); + + return DFB_OK; +} + +static DFBResult +primaryFlipRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + DFBSurfaceFlipFlags flags, + CoreSurfaceBufferLock *lock ) +{ + dfb_surface_flip( surface, false ); + + return dfb_sdl_update_screen( dfb_sdl_core, NULL ); +} + +static DFBResult +primaryUpdateRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + const DFBRegion *update, + CoreSurfaceBufferLock *lock ) +{ + if (update) { + DFBRegion region = *update; + + return dfb_sdl_update_screen( dfb_sdl_core, ®ion ); + } + + return dfb_sdl_update_screen( dfb_sdl_core, NULL ); +} + +DisplayLayerFuncs sdlPrimaryLayerFuncs = { + .LayerDataSize = primaryLayerDataSize, + .RegionDataSize = primaryRegionDataSize, + .InitLayer = primaryInitLayer, + + .TestRegion = primaryTestRegion, + .AddRegion = primaryAddRegion, + .SetRegion = primarySetRegion, + .RemoveRegion = primaryRemoveRegion, + .FlipRegion = primaryFlipRegion, + .UpdateRegion = primaryUpdateRegion, +}; + +/******************************************************************************/ + +static DFBResult +update_screen( int x, int y, int w, int h ) +{ +#if 0 + int i, n; + void *dst; + void *src; + DFBResult ret; + CoreSurface *surface; + CoreSurfaceBuffer *buffer; + CoreSurfaceBufferLock lock; + u16 *src16, *dst16; + u8 *src8; +#endif + + D_DEBUG_AT( SDL_Updates, "%s( %d, %d, %d, %d )\n", __FUNCTION__, x, y, w, h ); + + D_DEBUG_AT( SDL_Updates, " -> locking sdl lock...\n" ); + + fusion_skirmish_prevail( &dfb_sdl->lock ); +#if 0 + surface = dfb_sdl->primary; + D_MAGIC_ASSERT_IF( surface, CoreSurface ); + + D_DEBUG_AT( SDL_Updates, " -> primary is %p\n", surface ); + + if (!surface) { + D_DEBUG_AT( SDL_Updates, " -> unlocking sdl lock...\n" ); + fusion_skirmish_dismiss( &dfb_sdl->lock ); + D_DEBUG_AT( SDL_Updates, " -> done.\n" ); + return DFB_OK; + } + + buffer = dfb_surface_get_buffer( surface, CSBR_FRONT ); + + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + D_DEBUG_AT( SDL_Updates, " -> locking sdl surface...\n" ); + + if (SDL_LockSurface( screen ) < 0) { + D_ERROR( "DirectFB/SDL: " + "Couldn't lock the display surface: %s\n", SDL_GetError() ); + fusion_skirmish_dismiss( &dfb_sdl->lock ); + return DFB_FAILURE; + } + + D_DEBUG_AT( SDL_Updates, " -> locking dfb surface...\n" ); + + ret = dfb_surface_buffer_lock( buffer, CSAF_CPU_READ, &lock ); + if (ret) { + D_ERROR( "DirectFB/SDL: Couldn't lock layer surface: %s\n", + DirectFBErrorString( ret ) ); + SDL_UnlockSurface(screen); + fusion_skirmish_dismiss( &dfb_sdl->lock ); + return ret; + } + + src = lock.addr; + dst = screen->pixels; + + src += DFB_BYTES_PER_LINE( surface->config.format, x ) + y * lock.pitch; + dst += DFB_BYTES_PER_LINE( surface->config.format, x ) + y * screen->pitch; + + D_DEBUG_AT( SDL_Updates, " -> copying pixels...\n" ); + + switch (screen->format->BitsPerPixel) { + case 16: + dfb_convert_to_rgb16( surface->config.format, + src, lock.pitch, surface->config.size.h, + dst, screen->pitch, w, h ); + break; + + default: + direct_memcpy( dst, src, DFB_BYTES_PER_LINE( surface->config.format, w ) ); + } + + D_DEBUG_AT( SDL_Updates, " -> unlocking dfb surface...\n" ); + + dfb_surface_buffer_unlock( &lock ); + + D_DEBUG_AT( SDL_Updates, " -> unlocking sdl surface...\n" ); + + SDL_UnlockSurface( screen ); +#endif + D_DEBUG_AT( SDL_Updates, " -> calling SDL_UpdateRect()...\n" ); + + SDL_UpdateRect( dfb_sdl->screen, x, y, w, h ); + + D_DEBUG_AT( SDL_Updates, " -> unlocking sdl lock...\n" ); + + fusion_skirmish_dismiss( &dfb_sdl->lock ); + + D_DEBUG_AT( SDL_Updates, " -> done.\n" ); + + return DFB_OK; +} + +static void * +ScreenUpdateLoop( DirectThread *thread, void *arg ) +{ + pthread_mutex_lock( &dfb_sdl->update.lock ); + + D_DEBUG_AT( SDL_Updates, "Entering %s()...\n", __FUNCTION__ ); + + while (!dfb_sdl->update.quit) { + if (dfb_sdl->update.pending) { + DFBRectangle update = DFB_RECTANGLE_INIT_FROM_REGION( &dfb_sdl->update.region ); + + dfb_sdl->update.pending = false; + + D_DEBUG_AT( SDL_Updates, "Got update %d,%d - %dx%d...\n", DFB_RECTANGLE_VALS( &update ) ); + + pthread_mutex_unlock( &dfb_sdl->update.lock ); + + + update_screen( update.x, update.y, update.w, update.h ); + + + pthread_mutex_lock( &dfb_sdl->update.lock ); + } + else + pthread_cond_wait( &dfb_sdl->update.cond, &dfb_sdl->update.lock ); + } + + D_DEBUG_AT( SDL_Updates, "Returning from %s()...\n", __FUNCTION__ ); + + pthread_mutex_unlock( &dfb_sdl->update.lock ); + + return NULL; +} + +/******************************************************************************/ + +typedef enum { + SDL_SET_VIDEO_MODE, + SDL_UPDATE_SCREEN, + SDL_SET_PALETTE +} DFBSDLCall; + +static inline int +get_pixelformat_target_depth( DFBSurfacePixelFormat format ) +{ + switch (format) { + case DSPF_NV16: + return 16; + + default: + break; + } + + return DFB_BITS_PER_PIXEL( format ); +} + +static DFBResult +dfb_sdl_set_video_mode_handler( CoreSurfaceConfig *config ) +{ + int depth = get_pixelformat_target_depth( config->format ); + Uint32 flags = SDL_HWSURFACE | SDL_RESIZABLE;// | SDL_ASYNCBLIT | SDL_FULLSCREEN; + SDL_Surface *screen; + + if (config->caps & DSCAPS_FLIPPING) + flags |= SDL_DOUBLEBUF; + + fusion_skirmish_prevail( &dfb_sdl->lock ); + + D_DEBUG_AT( SDL_Screen, " -> SDL_SetVideoMode( %dx%d, %d, 0x%08x )\n", + config->size.w, config->size.h, DFB_BITS_PER_PIXEL(config->format), flags ); + + /* Set video mode */ + screen = SDL_SetVideoMode( config->size.w, config->size.h, depth, flags ); + if (!screen) { + D_ERROR( "DirectFB/SDL: Couldn't set %dx%dx%d video mode: %s\n", + config->size.w, config->size.h, depth, SDL_GetError()); + + fusion_skirmish_dismiss( &dfb_sdl->lock ); + + return DFB_FAILURE; + } + + dfb_sdl->screen = screen; + + /* Hide SDL's cursor */ + SDL_ShowCursor( SDL_DISABLE ); + + fusion_skirmish_dismiss( &dfb_sdl->lock ); + + return DFB_OK; +} + +static DFBResult +dfb_sdl_update_screen_handler( const DFBRegion *region ) +{ + DFBRegion update; + CoreSurface *surface = dfb_sdl->primary; + + DFB_REGION_ASSERT_IF( region ); + + if (region) + update = *region; + else { + update.x1 = 0; + update.y1 = 0; + update.x2 = surface->config.size.w - 1; + update.y2 = surface->config.size.h - 1; + } + +#if 0 + pthread_mutex_lock( &dfb_sdl->update.lock ); + + if (dfb_sdl->update.pending) + dfb_region_region_union( &dfb_sdl->update.region, &update ); + else { + dfb_sdl->update.region = update; + dfb_sdl->update.pending = true; + } + + pthread_cond_signal( &dfb_sdl->update.cond ); + + pthread_mutex_unlock( &dfb_sdl->update.lock ); +#else + if (surface->config.caps & DSCAPS_FLIPPING) + SDL_Flip( dfb_sdl->screen ); + else + SDL_UpdateRect( dfb_sdl->screen, DFB_RECTANGLE_VALS_FROM_REGION(&update) ); +#endif + + return DFB_OK; +} + +static DFBResult +dfb_sdl_set_palette_handler( CorePalette *palette ) +{ + unsigned int i; + SDL_Color colors[palette->num_entries]; + + for (i=0; inum_entries; i++) { + colors[i].r = palette->entries[i].r; + colors[i].g = palette->entries[i].g; + colors[i].b = palette->entries[i].b; + } + + fusion_skirmish_prevail( &dfb_sdl->lock ); + + SDL_SetColors( dfb_sdl->screen, colors, 0, palette->num_entries ); + + fusion_skirmish_dismiss( &dfb_sdl->lock ); + + return DFB_OK; +} + +FusionCallHandlerResult +dfb_sdl_call_handler( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ) +{ + switch (call_arg) { + case SDL_SET_VIDEO_MODE: + *ret_val = dfb_sdl_set_video_mode_handler( call_ptr ); + break; + + case SDL_UPDATE_SCREEN: + *ret_val = dfb_sdl_update_screen_handler( call_ptr ); + break; + + case SDL_SET_PALETTE: + *ret_val = dfb_sdl_set_palette_handler( call_ptr ); + break; + + default: + D_BUG( "unknown call" ); + *ret_val = DFB_BUG; + break; + } + + return FCHR_RETURN; +} + +DFBResult +dfb_sdl_set_video_mode( CoreDFB *core, CoreSurfaceConfig *config ) +{ + int ret; + CoreSurfaceConfig *tmp = NULL; + + D_ASSERT( config != NULL ); + + if (dfb_core_is_master( core )) + return dfb_sdl_set_video_mode_handler( config ); + + if (!fusion_is_shared( dfb_core_world(core), config )) { + tmp = SHMALLOC( dfb_core_shmpool(core), sizeof(CoreSurfaceConfig) ); + if (!tmp) + return D_OOSHM(); + + direct_memcpy( tmp, config, sizeof(CoreSurfaceConfig) ); + } + + fusion_call_execute( &dfb_sdl->call, FCEF_NONE, SDL_SET_VIDEO_MODE, + tmp ? tmp : config, &ret ); + + if (tmp) + SHFREE( dfb_core_shmpool(core), tmp ); + + return ret; +} + +DFBResult +dfb_sdl_update_screen( CoreDFB *core, DFBRegion *region ) +{ + int ret; + DFBRegion *tmp = NULL; + + if (dfb_core_is_master( core )) + return dfb_sdl_update_screen_handler( region ); + + if (region) { + tmp = SHMALLOC( dfb_core_shmpool(core), sizeof(DFBRegion) ); + if (!tmp) + return D_OOSHM(); + + direct_memcpy( tmp, region, sizeof(DFBRegion) ); + } + + fusion_call_execute( &dfb_sdl->call, FCEF_NONE, SDL_UPDATE_SCREEN, tmp ? tmp : region, &ret ); + + if (tmp) + SHFREE( dfb_core_shmpool(core), tmp ); + + return DFB_OK; +} + +DFBResult +dfb_sdl_set_palette( CorePalette *palette ) +{ + int ret; + + fusion_call_execute( &dfb_sdl->call, FCEF_NONE, SDL_SET_PALETTE, palette, &ret ); + + return ret; +} + diff --git a/Source/DirectFB/systems/sdl/primary.h b/Source/DirectFB/systems/sdl/primary.h new file mode 100755 index 0000000..faa34d2 --- /dev/null +++ b/Source/DirectFB/systems/sdl/primary.h @@ -0,0 +1,49 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __SDL__PRIMARY_H__ +#define __SDL__PRIMARY_H__ + +#include + +#include +#include + +extern ScreenFuncs sdlPrimaryScreenFuncs; +extern DisplayLayerFuncs sdlPrimaryLayerFuncs; + +FusionCallHandlerResult +dfb_sdl_call_handler( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ); + +#endif + diff --git a/Source/DirectFB/systems/sdl/sdl.c b/Source/DirectFB/systems/sdl/sdl.c new file mode 100755 index 0000000..8ecc4ca --- /dev/null +++ b/Source/DirectFB/systems/sdl/sdl.c @@ -0,0 +1,396 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include "sdl.h" +#include "primary.h" + +#include + +DFB_CORE_SYSTEM( sdl ) + + +DFBSDL *dfb_sdl = NULL; +CoreDFB *dfb_sdl_core = NULL; + +extern const SurfacePoolFuncs sdlSurfacePoolFuncs; + +static DFBResult dfb_fbdev_read_modes( void ); + + +static void +system_get_info( CoreSystemInfo *info ) +{ + info->type = CORE_SDL; + info->caps = CSCAPS_ACCELERATION; + + snprintf( info->name, DFB_CORE_SYSTEM_INFO_NAME_LENGTH, "SDL" ); +} + +static DFBResult +system_initialize( CoreDFB *core, void **data ) +{ + char *driver; + CoreScreen *screen; + + D_ASSERT( dfb_sdl == NULL ); + + dfb_sdl = (DFBSDL*) SHCALLOC( dfb_core_shmpool(core), 1, sizeof(DFBSDL) ); + if (!dfb_sdl) { + D_ERROR( "DirectFB/SDL: Couldn't allocate shared memory!\n" ); + return D_OOSHM(); + } + + dfb_sdl_core = core; + + dfb_fbdev_read_modes(); /* use same mode list as a fake */ + + driver = getenv( "SDL_VIDEODRIVER" ); + if (driver && !strcasecmp( driver, "directfb" )) { + D_INFO( "DirectFB/SDL: SDL_VIDEODRIVER is 'directfb', unsetting it.\n" ); + unsetenv( "SDL_VIDEODRIVER" ); + } + + /* Initialize SDL */ + if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) { + D_ERROR( "DirectFB/SDL: Couldn't initialize SDL: %s\n", SDL_GetError() ); + + SHFREE( dfb_core_shmpool(core), dfb_sdl ); + dfb_sdl = NULL; + + return DFB_INIT; + } + + fusion_skirmish_init( &dfb_sdl->lock, "SDL System", dfb_core_world(core) ); + + fusion_call_init( &dfb_sdl->call, dfb_sdl_call_handler, NULL, dfb_core_world(core) ); + + screen = dfb_screens_register( NULL, NULL, &sdlPrimaryScreenFuncs ); + + dfb_layers_register( screen, NULL, &sdlPrimaryLayerFuncs ); + + fusion_arena_add_shared_field( dfb_core_arena( core ), "sdl", dfb_sdl ); + + dfb_surface_pool_initialize( core, &sdlSurfacePoolFuncs, &dfb_sdl->sdl_pool ); + + *data = dfb_sdl; + + return DFB_OK; +} + +static DFBResult +system_join( CoreDFB *core, void **data ) +{ + void *ret; + CoreScreen *screen; + + D_ASSERT( dfb_sdl == NULL ); + + fusion_arena_get_shared_field( dfb_core_arena( core ), "sdl", &ret ); + + dfb_sdl = ret; + dfb_sdl_core = core; + + screen = dfb_screens_register( NULL, NULL, &sdlPrimaryScreenFuncs ); + + dfb_layers_register( screen, NULL, &sdlPrimaryLayerFuncs ); + + dfb_surface_pool_join( core, dfb_sdl->sdl_pool, &sdlSurfacePoolFuncs ); + + *data = dfb_sdl; + + return DFB_OK; +} + +static DFBResult +system_shutdown( bool emergency ) +{ + FusionSHMPoolShared *pool; + + D_ASSERT( dfb_sdl != NULL ); + + /* Stop update thread. */ + if (dfb_sdl->update.thread) { + if (!emergency) { + dfb_sdl->update.quit = true; + + pthread_cond_signal( &dfb_sdl->update.cond ); + + direct_thread_join( dfb_sdl->update.thread ); + } + + direct_thread_destroy( dfb_sdl->update.thread ); + } + + dfb_surface_pool_destroy( dfb_sdl->sdl_pool ); + + fusion_call_destroy( &dfb_sdl->call ); + + fusion_skirmish_prevail( &dfb_sdl->lock ); + + SDL_Quit(); + + fusion_skirmish_destroy( &dfb_sdl->lock ); + + pool = dfb_core_shmpool(dfb_sdl_core); + + while (dfb_sdl->modes) { + VideoMode *next = dfb_sdl->modes->next; + + SHFREE( pool, dfb_sdl->modes ); + + dfb_sdl->modes = next; + } + + SHFREE( pool, dfb_sdl ); + dfb_sdl = NULL; + dfb_sdl_core = NULL; + + return DFB_OK; +} + +static DFBResult +system_leave( bool emergency ) +{ + D_ASSERT( dfb_sdl != NULL ); + + dfb_sdl = NULL; + dfb_sdl_core = NULL; + + return DFB_OK; +} + +static DFBResult +system_suspend( void ) +{ + return DFB_UNIMPLEMENTED; +} + +static DFBResult +system_resume( void ) +{ + return DFB_UNIMPLEMENTED; +} + +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( void ) +{ + return -1; +} + +static VideoMode * +system_get_modes( void ) +{ + return dfb_sdl->modes; +} + +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 0; +} + +static void * +system_video_memory_virtual( unsigned int offset ) +{ + return NULL; +} + +static unsigned int +system_videoram_length( void ) +{ + return 0; +} + +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; +} + + +/* + * parses video modes in /etc/fb.modes and stores them in dfb_fbdev->shared->modes + * (to be replaced by DirectFB's own config system + */ +static DFBResult dfb_fbdev_read_modes( void ) +{ + FILE *fp; + char line[80],label[32],value[16]; + int geometry=0, timings=0; + int dummy; + VideoMode temp_mode; + VideoMode *m = dfb_sdl->modes; + + if (!(fp = fopen("/etc/fb.modes","r"))) + return errno2result( errno ); + + while (fgets(line,79,fp)) { + if (sscanf(line, "mode \"%31[^\"]\"",label) == 1) { + memset( &temp_mode, 0, sizeof(VideoMode) ); + geometry = 0; + timings = 0; + while (fgets(line,79,fp) && !(strstr(line,"endmode"))) { + if (5 == sscanf(line," geometry %d %d %d %d %d", &temp_mode.xres, &temp_mode.yres, &dummy, &dummy, &temp_mode.bpp)) { + geometry = 1; + } + else if (7 == sscanf(line," timings %d %d %d %d %d %d %d", &temp_mode.pixclock, &temp_mode.left_margin, &temp_mode.right_margin, + &temp_mode.upper_margin, &temp_mode.lower_margin, &temp_mode.hsync_len, &temp_mode.vsync_len)) { + timings = 1; + } + else if (1 == sscanf(line, " hsync %15s",value) && 0 == strcasecmp(value,"high")) { + temp_mode.hsync_high = 1; + } + else if (1 == sscanf(line, " vsync %15s",value) && 0 == strcasecmp(value,"high")) { + temp_mode.vsync_high = 1; + } + else if (1 == sscanf(line, " csync %15s",value) && 0 == strcasecmp(value,"high")) { + temp_mode.csync_high = 1; + } + else if (1 == sscanf(line, " laced %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.laced = 1; + } + else if (1 == sscanf(line, " double %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.doubled = 1; + } + else if (1 == sscanf(line, " gsync %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.sync_on_green = 1; + } + else if (1 == sscanf(line, " extsync %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.external_sync = 1; + } + else if (1 == sscanf(line, " bcast %15s",value) && 0 == strcasecmp(value,"true")) { + temp_mode.broadcast = 1; + } + } + if (geometry && timings) { + if (!m) { + dfb_sdl->modes = SHCALLOC( dfb_core_shmpool(dfb_sdl_core), 1, sizeof(VideoMode) ); + m = dfb_sdl->modes; + } + else { + m->next = SHCALLOC( dfb_core_shmpool(dfb_sdl_core), 1, sizeof(VideoMode) ); + m = m->next; + } + direct_memcpy (m, &temp_mode, sizeof(VideoMode)); + D_DEBUG( "DirectFB/FBDev: %20s %4dx%4d %s%s\n", label, temp_mode.xres, temp_mode.yres, + temp_mode.laced ? "interlaced " : "", temp_mode.doubled ? "doublescan" : "" ); + } + } + } + + fclose (fp); + + return DFB_OK; +} + diff --git a/Source/DirectFB/systems/sdl/sdl.h b/Source/DirectFB/systems/sdl/sdl.h new file mode 100755 index 0000000..2ed9ef6 --- /dev/null +++ b/Source/DirectFB/systems/sdl/sdl.h @@ -0,0 +1,70 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __SDL__SDL_H__ +#define __SDL__SDL_H__ + +#include +#include + +#include +#include + +typedef struct { + FusionSkirmish lock; + FusionCall call; + + CoreSurface *primary; + CoreSurfacePool *sdl_pool; + + struct { + pthread_mutex_t lock; + pthread_cond_t cond; + + DirectThread *thread; + + bool pending; + DFBRegion region; + + bool quit; + } update; + + VideoMode *modes; /* linked list of valid video modes */ + + SDL_Surface *screen; +} DFBSDL; + +extern DFBSDL *dfb_sdl; +extern CoreDFB *dfb_sdl_core; + +DFBResult dfb_sdl_set_video_mode( CoreDFB *core, CoreSurfaceConfig *config ); +DFBResult dfb_sdl_update_screen( CoreDFB *core, DFBRegion *region ); +DFBResult dfb_sdl_set_palette( CorePalette *palette ); + +#endif + diff --git a/Source/DirectFB/systems/sdl/sdl_surface_pool.c b/Source/DirectFB/systems/sdl/sdl_surface_pool.c new file mode 100755 index 0000000..d1b8703 --- /dev/null +++ b/Source/DirectFB/systems/sdl/sdl_surface_pool.c @@ -0,0 +1,349 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#include +#include + +#include + +#include + +#include + +#include "sdl.h" + +D_DEBUG_DOMAIN( SDL_Pool, "SDL/Pool", "SDL Surface Pool" ); + +/**********************************************************************************************************************/ + +typedef struct { +} SDLPoolData; + +typedef struct { + int magic; + + SDL_Surface *sdl_surf; +} SDLAllocationData; + +/**********************************************************************************************************************/ + +static int +sdlPoolDataSize( void ) +{ + return sizeof(SDLPoolData); +} + +static int +sdlAllocationDataSize( void ) +{ + return sizeof(SDLAllocationData); +} + +static DFBResult +sdlInitPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data, + CoreSurfacePoolDescription *ret_desc ) +{ + D_DEBUG_AT( SDL_Pool, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_ASSERT( ret_desc != NULL ); + + ret_desc->caps = CSPCAPS_NONE; + ret_desc->access[CSAID_CPU] = CSAF_READ | CSAF_WRITE; + ret_desc->access[CSAID_GPU] = CSAF_READ | CSAF_WRITE; + ret_desc->types = CSTF_LAYER | CSTF_WINDOW | CSTF_CURSOR | CSTF_FONT | CSTF_SHARED | CSTF_EXTERNAL; + ret_desc->priority = CSPP_PREFERED; + + snprintf( ret_desc->name, DFB_SURFACE_POOL_DESC_NAME_LENGTH, "SDL" ); + + return DFB_OK; +} + +static DFBResult +sdlDestroyPool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + D_DEBUG_AT( SDL_Pool, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + + return DFB_OK; +} + +static DFBResult +sdlTestConfig( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + const CoreSurfaceConfig *config ) +{ + D_DEBUG_AT( SDL_Pool, "%s()\n", __FUNCTION__ ); + + switch (config->format) { + case DSPF_A8: + case DSPF_RGB16: + case DSPF_RGB32: + case DSPF_ARGB: + break; + + default: + return DFB_UNSUPPORTED; + } + + return DFB_OK; +} + +static DFBResult +sdlAllocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + DFBResult ret; + CoreSurface *surface; + SDLAllocationData *alloc = alloc_data; + + D_DEBUG_AT( SDL_Pool, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + if (surface->type & CSTF_LAYER) { + dfb_sdl->screen = NULL; /* clear? */ + + ret = dfb_sdl_set_video_mode( dfb_sdl_core, &surface->config ); + if (ret) { + D_DERROR( ret, "SDL/Surface: dfb_sdl_set_video_mode() failed!\n" ); + return ret; + } + + D_ASSERT( dfb_sdl->screen != NULL ); + + if (!dfb_sdl->screen) { + D_ERROR( "SDL/Surface: No screen surface!?\n" ); + return DFB_BUG; + } + + alloc->sdl_surf = dfb_sdl->screen; + + D_DEBUG_AT( SDL_Pool, " -> screen surface %dx%d, %d, 0x%08x, pitch %d\n", + dfb_sdl->screen->w, dfb_sdl->screen->h, dfb_sdl->screen->format->BitsPerPixel, + dfb_sdl->screen->flags, dfb_sdl->screen->pitch ); + + allocation->flags |= CSALF_ONEFORALL; + } + else { + DFBSurfacePixelFormat format = surface->config.format; + Uint32 flags = SDL_HWSURFACE;// | SDL_ASYNCBLIT | SDL_FULLSCREEN; + Uint32 rmask; + Uint32 gmask; + Uint32 bmask; + Uint32 amask; + + if (surface->config.caps & DSCAPS_FLIPPING) + flags |= SDL_DOUBLEBUF; + + switch (format) { + case DSPF_A8: + rmask = 0x00; + gmask = 0x00; + bmask = 0x00; + amask = 0xff; + break; + + case DSPF_RGB16: + rmask = 0xf800; + gmask = 0x07e0; + bmask = 0x001f; + amask = 0x0000; + break; + + case DSPF_RGB32: + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0x00000000; + break; + + case DSPF_ARGB: + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0xff000000; + break; + + default: + D_ERROR( "SDL/Surface: %s() has no support for %s!\n", + __FUNCTION__, dfb_pixelformat_name(format) ); + return DFB_UNSUPPORTED; + } + + D_DEBUG_AT( SDL_Pool, " -> SDL_CreateRGBSurface( 0x%08x, " + "%dx%d, %d, 0x%08x, 0x%08x, 0x%08x, 0x%08x )\n", + flags, surface->config.size.w, surface->config.size.h, + DFB_BITS_PER_PIXEL(format), rmask, gmask, bmask, amask ); + + alloc->sdl_surf = SDL_CreateRGBSurface( flags, + surface->config.size.w, + surface->config.size.h, + DFB_BITS_PER_PIXEL(format), + rmask, gmask, bmask, amask ); + if (!alloc->sdl_surf) { + D_ERROR( "SDL/Surface: SDL_CreateRGBSurface( 0x%08x, " + "%dx%d, %d, 0x%08x, 0x%08x, 0x%08x, 0x%08x ) failed!\n", + flags, surface->config.size.w, surface->config.size.h, + DFB_BITS_PER_PIXEL(format), rmask, gmask, bmask, amask ); + + return DFB_FAILURE; + } + } + + D_MAGIC_SET( alloc, SDLAllocationData ); + + return DFB_OK; +} + +static DFBResult +sdlDeallocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + SDLAllocationData *alloc = alloc_data; + + D_DEBUG_AT( SDL_Pool, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + D_MAGIC_ASSERT( alloc, SDLAllocationData ); + + SDL_FreeSurface( alloc->sdl_surf ); + + D_MAGIC_CLEAR( alloc ); + + return DFB_OK; +} + +static DFBResult +sdlLock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + SDLAllocationData *alloc = alloc_data; + SDL_Surface *sdl_surf; + +// D_DEBUG_AT( SDL_Pool, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, SDLAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + sdl_surf = alloc->sdl_surf; + D_ASSERT( sdl_surf != NULL ); + + if (SDL_MUSTLOCK( sdl_surf ) && SDL_LockSurface( sdl_surf )) { + D_ERROR( "SDL/Surface: SDL_LockSurface() on a %dx%dx surface failed!\n", sdl_surf->w, sdl_surf->h ); + return DFB_FAILURE; + } + + D_ASSUME( sdl_surf->pixels != NULL ); + if (!sdl_surf->pixels) + return DFB_UNSUPPORTED; + + D_ASSERT( sdl_surf->pitch > 0 ); + + lock->addr = sdl_surf->pixels; + lock->pitch = sdl_surf->pitch; + lock->offset = sdl_surf->offset; + lock->handle = sdl_surf; + + return DFB_OK; +} + +static DFBResult +sdlUnlock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + SDLAllocationData *alloc = alloc_data; + SDL_Surface *sdl_surf; + +// D_DEBUG_AT( SDL_Pool, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, SDLAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + sdl_surf = alloc->sdl_surf; + D_ASSERT( sdl_surf != NULL ); + + if (SDL_MUSTLOCK( sdl_surf )) + SDL_UnlockSurface( sdl_surf ); + + return DFB_OK; +} + +const SurfacePoolFuncs sdlSurfacePoolFuncs = { + .PoolDataSize = sdlPoolDataSize, + .AllocationDataSize = sdlAllocationDataSize, + .InitPool = sdlInitPool, + .DestroyPool = sdlDestroyPool, + + .TestConfig = sdlTestConfig, + + .AllocateBuffer = sdlAllocateBuffer, + .DeallocateBuffer = sdlDeallocateBuffer, + + .Lock = sdlLock, + .Unlock = sdlUnlock, +}; + diff --git a/Source/DirectFB/systems/sdl/sdlgfx.c b/Source/DirectFB/systems/sdl/sdlgfx.c new file mode 100755 index 0000000..811d545 --- /dev/null +++ b/Source/DirectFB/systems/sdl/sdlgfx.c @@ -0,0 +1,302 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +DFB_GRAPHICS_DRIVER( sdlgraphics ) + +#include "sdl.h" + +/* FIXME: support for destination color keying */ + +#define SDL_DRAWING_FLAGS \ + (DSDRAW_NOFX) + +#define SDL_DRAWING_FUNCTIONS \ + (DFXL_FILLRECTANGLE) + +#define SDL_BLITTING_FLAGS \ + (DSBLIT_SRC_COLORKEY) + +#define SDL_BLITTING_FUNCTIONS \ + (DFXL_BLIT) + +D_DEBUG_DOMAIN( SDL_GFX, "SDL/Graphics", "SDL Graphics" ); + +typedef struct { +} SDLDriverData; + +typedef struct { + SDL_Surface *dest; + SDL_Surface *source; + + u32 color; + + bool color_valid; + bool key_valid; +} SDLDeviceData; + + +static DFBResult sdlEngineSync( void *drv, void *dev ) +{ + return DFB_OK; +} + +static void sdlCheckState( void *drv, void *dev, + CardState *state, DFBAccelerationMask accel ) +{ + /* check destination format first */ + switch (state->destination->config.format) { + case DSPF_RGB16: + case DSPF_RGB32: + break; + default: + return; + } + + if (DFB_DRAWING_FUNCTION( accel )) { + /* if there are no other drawing flags than the supported */ + if (state->drawingflags & ~SDL_DRAWING_FLAGS) + return; + + state->accel |= SDL_DRAWING_FUNCTIONS; + } + else { + /* if there are no other blitting flags than the supported + and the source and destination formats are the same */ + if (state->blittingflags & ~SDL_BLITTING_FLAGS) + return; + + /* check source format */ + switch (state->source->config.format) { + case DSPF_RGB16: + case DSPF_RGB32: + break; + default: + return; + } + + state->accel |= SDL_BLITTING_FUNCTIONS; + } +} + +static void sdlSetState( void *drv, void *dev, GraphicsDeviceFuncs *funcs, + CardState *state, DFBAccelerationMask accel ) +{ + SDLDeviceData *sdev = (SDLDeviceData*) dev; + + sdev->dest = state->dst.handle; + sdev->source = state->src.handle; + + if (state->mod_hw & (SMF_SOURCE | SMF_BLITTING_FLAGS | SMF_SRC_COLORKEY)) + sdev->key_valid = false; + + if (state->mod_hw & (SMF_DESTINATION | SMF_COLOR)) + sdev->color_valid = false; + + switch (accel) { + case DFXL_FILLRECTANGLE: + if (!sdev->color_valid) { + switch (state->destination->config.format) { + case DSPF_RGB16: + case DSPF_RGB32: + sdev->color = dfb_color_to_pixel( state->destination->config.format, + state->color.r, + state->color.g, + state->color.b ); + break; + + default: + D_BUG( "unexpected format" ); + } + + sdev->color_valid = true; + } + + state->set |= SDL_DRAWING_FUNCTIONS; + break; + + case DFXL_BLIT: + if (!sdev->key_valid) { + SDL_SetColorKey( sdev->source, + (state->blittingflags & + DSBLIT_SRC_COLORKEY) ? SDL_SRCCOLORKEY : 0, + state->src_colorkey | 0xff000000 ); + + sdev->key_valid = true; + } + + state->set |= SDL_BLITTING_FUNCTIONS; + break; + + default: + D_BUG("unexpected acceleration" ); + break; + } + + state->mod_hw = 0; +} + +static bool sdlFillRectangle( void *drv, void *dev, DFBRectangle *rect ) +{ + SDLDeviceData *sdev = (SDLDeviceData*) dev; + SDL_Rect dr; + + dr.x = rect->x; + dr.y = rect->y; + dr.w = rect->w; + dr.h = rect->h; + + return SDL_FillRect( sdev->dest, &dr, sdev->color ) == 0; +} + +static bool sdlBlit( void *drv, void *dev, DFBRectangle *rect, int dx, int dy ) +{ + SDLDeviceData *sdev = (SDLDeviceData*) dev; + SDL_Rect sr, dr; + + D_DEBUG_AT( SDL_GFX, "%s()\n", __FUNCTION__ ); + + sr.x = rect->x; + sr.y = rect->y; + sr.w = rect->w; + sr.h = rect->h; + + dr.x = dx; + dr.y = dy; + dr.w = rect->w; + dr.h = rect->h; + + return SDL_BlitSurface( sdev->source, &sr, sdev->dest, &dr ) == 0; +} + + +/* exported symbols */ + +static int +driver_probe( CoreGraphicsDevice *device ) +{ + return dfb_system_type() == CORE_SDL; +} + +static void +driver_get_info( CoreGraphicsDevice *device, + GraphicsDriverInfo *info ) +{ + /* fill driver info structure */ + snprintf( info->name, + DFB_GRAPHICS_DRIVER_INFO_NAME_LENGTH, + "SDL Graphics Driver" ); + + snprintf( info->vendor, + DFB_GRAPHICS_DRIVER_INFO_VENDOR_LENGTH, + "directfb.org" ); + + info->version.major = 0; + info->version.minor = 1; + + info->driver_data_size = sizeof (SDLDriverData); + info->device_data_size = sizeof (SDLDeviceData); +} + +static DFBResult +driver_init_driver( CoreGraphicsDevice *device, + GraphicsDeviceFuncs *funcs, + void *driver_data, + void *device_data, + CoreDFB *core ) +{ + /* fill acceleration function table */ + funcs->EngineSync = sdlEngineSync; + funcs->CheckState = sdlCheckState; + funcs->SetState = sdlSetState; + + funcs->FillRectangle = sdlFillRectangle; + funcs->Blit = sdlBlit; + + return DFB_OK; +} + +static DFBResult +driver_init_device( CoreGraphicsDevice *device, + GraphicsDeviceInfo *device_info, + void *driver_data, + void *device_data ) +{ + /* fill device info */ + snprintf( device_info->name, + DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH, "Graphics" ); + + snprintf( device_info->vendor, + DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "SDL" ); + + + device_info->caps.flags = CCF_READSYSMEM; + device_info->caps.accel = SDL_DRAWING_FUNCTIONS | + SDL_BLITTING_FUNCTIONS; + device_info->caps.drawing = SDL_DRAWING_FLAGS; + device_info->caps.blitting = SDL_BLITTING_FLAGS; + + return DFB_OK; +} + +static void +driver_close_device( CoreGraphicsDevice *device, + void *driver_data, + void *device_data ) +{ +} + +static void +driver_close_driver( CoreGraphicsDevice *device, + void *driver_data ) +{ +} + diff --git a/Source/DirectFB/systems/sdl/sdlinput.c b/Source/DirectFB/systems/sdl/sdlinput.c new file mode 100755 index 0000000..4b94b14 --- /dev/null +++ b/Source/DirectFB/systems/sdl/sdlinput.c @@ -0,0 +1,571 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include "sdl.h" + +#include + + +DFB_INPUT_DRIVER( sdlinput ) + +/* + * declaration of private data + */ +typedef struct { + CoreInputDevice *device; + DirectThread *thread; + DFBSDL *dfb_sdl; + int stop; +} SDLInputData; + + +static DFBInputEvent motionX = { + .type = DIET_UNKNOWN, + .axisabs = 0, +}; + +static DFBInputEvent motionY = { + .type = DIET_UNKNOWN, + .axisabs = 0, +}; + +static void +motion_compress( int x, int y ) +{ + if (motionX.axisabs != x) { + motionX.type = DIET_AXISMOTION; + motionX.flags = DIEF_AXISABS; + motionX.axis = DIAI_X; + motionX.axisabs = x; + } + + if (motionY.axisabs != y) { + motionY.type = DIET_AXISMOTION; + motionY.flags = DIEF_AXISABS; + motionY.axis = DIAI_Y; + motionY.axisabs = y; + } +} + +static void +motion_realize( SDLInputData *data ) +{ + if (motionX.type != DIET_UNKNOWN) { + if (motionY.type != DIET_UNKNOWN) { + /* let DirectFB know two events are coming */ + motionX.flags |= DIEF_FOLLOW; + } + + dfb_input_dispatch( data->device, &motionX ); + + motionX.type = DIET_UNKNOWN; + } + + if (motionY.type != DIET_UNKNOWN) { + dfb_input_dispatch( data->device, &motionY ); + + motionY.type = DIET_UNKNOWN; + } +} + +static bool +translate_key( SDLKey key, DFBInputEvent *evt ) +{ + evt->flags = DIEF_KEYID; + /* Numeric keypad */ + if (key >= SDLK_KP0 && key <= SDLK_KP9) { + evt->key_id = DIKI_KP_0 + key - SDLK_KP0; + return true; + } + + /* Function keys */ + if (key >= SDLK_F1 && key <= SDLK_F12) { + evt->key_id = DIKI_F1 + key - SDLK_F1; + return true; + } + + /* letter keys */ + if (key >= SDLK_a && key <= SDLK_z) { + evt->key_id = DIKI_A + key - SDLK_a; + return true; + } + + if (key >= SDLK_0 && key <= SDLK_9) { + evt->key_id = DIKI_0 + key - SDLK_0; + return true; + } + + switch (key) { + case SDLK_QUOTE: + evt->key_id = DIKI_QUOTE_RIGHT; + return true; + case SDLK_BACKQUOTE: + evt->key_id = DIKI_QUOTE_LEFT; + return true; + case SDLK_COMMA: + evt->key_id = DIKI_COMMA; + return true; + case SDLK_MINUS: + evt->key_id = DIKI_MINUS_SIGN; + return true; + case SDLK_PERIOD: + evt->key_id = DIKI_PERIOD; + return true; + case SDLK_SLASH: + evt->key_id = DIKI_SLASH; + return true; + case SDLK_SEMICOLON: + evt->key_id = DIKI_SEMICOLON; + return true; + case SDLK_LESS: + evt->key_id = DIKI_LESS_SIGN; + return true; + case SDLK_EQUALS: + evt->key_id = DIKI_EQUALS_SIGN; + return true; + case SDLK_LEFTBRACKET: + evt->key_id = DIKI_BRACKET_LEFT; + return true; + case SDLK_RIGHTBRACKET: + evt->key_id = DIKI_BRACKET_RIGHT; + return true; + case SDLK_BACKSLASH: + evt->key_id = DIKI_BACKSLASH; + return true; + /* Numeric keypad */ + case SDLK_KP_PERIOD: + evt->key_id = DIKI_KP_DECIMAL; + return true; + + case SDLK_KP_DIVIDE: + evt->key_id = DIKI_KP_DIV; + return true; + + case SDLK_KP_MULTIPLY: + evt->key_id = DIKI_KP_MULT; + return true; + + case SDLK_KP_MINUS: + evt->key_id = DIKI_KP_MINUS; + return true; + case SDLK_KP_PLUS: + evt->key_id = DIKI_KP_PLUS; + return true; + case SDLK_KP_ENTER: + evt->key_id = DIKI_KP_ENTER; + return true; + + case SDLK_KP_EQUALS: + evt->key_id = DIKI_KP_EQUAL; + return true; + case SDLK_ESCAPE: + evt->key_id = DIKI_ESCAPE; + return true; + case SDLK_TAB: + evt->key_id = DIKI_TAB; + return true; + case SDLK_RETURN: + evt->key_id = DIKI_ENTER; + return true; + case SDLK_SPACE: + evt->key_id = DIKI_SPACE; + return true; + case SDLK_BACKSPACE: + evt->key_id = DIKI_BACKSPACE; + return true; + case SDLK_INSERT: + evt->key_id = DIKI_INSERT; + return true; + case SDLK_DELETE: + evt->key_id = DIKI_DELETE; + return true; + case SDLK_PRINT: + evt->key_id = DIKI_PRINT; + return true; + case SDLK_PAUSE: + evt->key_id = DIKI_PAUSE; + return true; + /* Arrows + Home/End pad */ + case SDLK_UP: + evt->key_id = DIKI_UP; + return true; + + case SDLK_DOWN: + evt->key_id = DIKI_DOWN; + return true; + + case SDLK_RIGHT: + evt->key_id = DIKI_RIGHT; + return true; + case SDLK_LEFT: + evt->key_id = DIKI_LEFT; + return true; + case SDLK_HOME: + evt->key_id = DIKI_HOME; + return true; + case SDLK_END: + evt->key_id = DIKI_END; + return true; + + case SDLK_PAGEUP: + evt->key_id = DIKI_PAGE_UP; + return true; + + case SDLK_PAGEDOWN: + evt->key_id = DIKI_PAGE_DOWN; + return true; + + + /* Key state modifier keys */ + case SDLK_NUMLOCK: + evt->key_id = DIKI_NUM_LOCK; + return true; + + case SDLK_CAPSLOCK: + evt->key_id = DIKI_CAPS_LOCK; + return true; + case SDLK_SCROLLOCK: + evt->key_id = DIKI_SCROLL_LOCK; + return true; + case SDLK_RSHIFT: + evt->key_id = DIKI_SHIFT_R; + return true; + + case SDLK_LSHIFT: + evt->key_id = DIKI_SHIFT_L; + return true; + case SDLK_RCTRL: + evt->key_id = DIKI_CONTROL_R; + return true; + + case SDLK_LCTRL: + evt->key_id = DIKI_CONTROL_L; + return true; + + case SDLK_RALT: + evt->key_id = DIKI_ALT_R; + return true; + + case SDLK_LALT: + evt->key_id = DIKI_ALT_L; + return true; + + case SDLK_RMETA: + evt->key_id = DIKI_META_R; + return true; + + case SDLK_LMETA: + evt->key_id = DIKI_META_L; + return true; + + case SDLK_LSUPER: + evt->key_id = DIKI_SUPER_L; + return true; + + case SDLK_RSUPER: + evt->key_id = DIKI_SUPER_R; + return true; + + case SDLK_MODE: + evt->key_id = DIKI_ALT_R; + evt->flags |= DIEF_KEYSYMBOL; + evt->key_symbol = DIKS_ALTGR; + return true; + default: + break; + } + + evt->flags = DIEF_NONE; + return false; +} + +/* + * Input thread reading from device. + * Generates events on incoming data. + */ +static void* +sdlEventThread( DirectThread *thread, void *driver_data ) +{ + SDLInputData *data = (SDLInputData*) driver_data; + DFBSDL *dfb_sdl = data->dfb_sdl; + + while (!data->stop) { + DFBInputEvent evt; + SDL_Event event; + + fusion_skirmish_prevail( &dfb_sdl->lock ); + + /* Check for events */ + while ( SDL_PollEvent(&event) ) { + fusion_skirmish_dismiss( &dfb_sdl->lock ); + + switch (event.type) { + case SDL_MOUSEMOTION: + motion_compress( event.motion.x, event.motion.y ); + break; + + case SDL_MOUSEBUTTONUP: + case SDL_MOUSEBUTTONDOWN: + motion_realize( data ); + + if (event.type == SDL_MOUSEBUTTONDOWN) + evt.type = DIET_BUTTONPRESS; + else + evt.type = DIET_BUTTONRELEASE; + + evt.flags = DIEF_NONE; + + switch (event.button.button) { + case SDL_BUTTON_LEFT: + evt.button = DIBI_LEFT; + break; + case SDL_BUTTON_MIDDLE: + evt.button = DIBI_MIDDLE; + break; + case SDL_BUTTON_RIGHT: + evt.button = DIBI_RIGHT; + break; + case SDL_BUTTON_WHEELUP: + case SDL_BUTTON_WHEELDOWN: + if (event.type != SDL_MOUSEBUTTONDOWN) { + fusion_skirmish_prevail( &dfb_sdl->lock ); + continue; + } + evt.type = DIET_AXISMOTION; + evt.flags = DIEF_AXISREL; + evt.axis = DIAI_Z; + if (event.button.button == SDL_BUTTON_WHEELUP) + evt.axisrel = -1; + else + evt.axisrel = 1; + break; + default: + fusion_skirmish_prevail( &dfb_sdl->lock ); + continue; + } + + dfb_input_dispatch( data->device, &evt ); + break; + + case SDL_KEYUP: + case SDL_KEYDOWN: + if (event.type == SDL_KEYDOWN) + evt.type = DIET_KEYPRESS; + else + evt.type = DIET_KEYRELEASE; + + /* Get a key id first */ + translate_key( event.key.keysym.sym, &evt ); + + /* If SDL provided a symbol, use it */ + if (event.key.keysym.unicode) { + evt.flags |= DIEF_KEYSYMBOL; + evt.key_symbol = event.key.keysym.unicode; + + /** + * Hack to translate the Control+[letter] + * combination to + * Modifier: CONTROL, Key Symbol: [letter] + * A side effect here is that Control+Backspace + * produces Control+h + */ + if (evt.modifiers == DIMM_CONTROL && + evt.key_symbol >= 1 && evt.key_symbol <= ('z'-'a'+1)) + { + evt.key_symbol += 'a'-1; + } + } + + dfb_input_dispatch( data->device, &evt ); + break; + case SDL_QUIT: + evt.type = DIET_KEYPRESS; + evt.flags = DIEF_KEYSYMBOL; + evt.key_symbol = DIKS_ESCAPE; + + dfb_input_dispatch( data->device, &evt ); + + evt.type = DIET_KEYRELEASE; + evt.flags = DIEF_KEYSYMBOL; + evt.key_symbol = DIKS_ESCAPE; + + dfb_input_dispatch( data->device, &evt ); + break; + + default: + break; + } + + fusion_skirmish_prevail( &dfb_sdl->lock ); + } + + fusion_skirmish_dismiss( &dfb_sdl->lock ); + + motion_realize( data ); + + usleep(10000); + + direct_thread_testcancel( thread ); + } + + return NULL; +} + +/* exported symbols */ + +/* + * Return the number of available devices. + * Called once during initialization of DirectFB. + */ +static int +driver_get_available( void ) +{ + if (dfb_system_type() == CORE_SDL) + return 1; + + return 0; +} + +/* + * Fill out general information about this driver. + * Called once during initialization of DirectFB. + */ +static void +driver_get_info( InputDriverInfo *info ) +{ + /* fill driver info structure */ + snprintf ( info->name, + DFB_INPUT_DRIVER_INFO_NAME_LENGTH, "SDL Input Driver" ); + snprintf ( info->vendor, + DFB_INPUT_DRIVER_INFO_VENDOR_LENGTH, "Denis Oliver Kropp" ); + + info->version.major = 0; + info->version.minor = 1; +} + +/* + * Open the device, fill out information about it, + * allocate and fill private data, start input thread. + * Called during initialization, resuming or taking over mastership. + */ +static DFBResult +driver_open_device( CoreInputDevice *device, + unsigned int number, + InputDeviceInfo *info, + void **driver_data ) +{ + SDLInputData *data; + DFBSDL *dfb_sdl = dfb_system_data(); + + fusion_skirmish_prevail( &dfb_sdl->lock ); + + SDL_EnableUNICODE( true ); + + SDL_EnableKeyRepeat( 250, 40 ); + + fusion_skirmish_dismiss( &dfb_sdl->lock ); + + /* set device name */ + snprintf( info->desc.name, + DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "SDL Input" ); + + /* set device vendor */ + snprintf( info->desc.vendor, + DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "SDL" ); + + /* set one of the primary input device IDs */ + info->prefered_id = DIDID_KEYBOARD; + + /* set type flags */ + info->desc.type = DIDTF_JOYSTICK | DIDTF_KEYBOARD | DIDTF_MOUSE; + + /* set capabilities */ + info->desc.caps = DICAPS_ALL; + + + /* allocate and fill private data */ + data = D_CALLOC( 1, sizeof(SDLInputData) ); + + data->device = device; + data->dfb_sdl = dfb_sdl; + + /* start input thread */ + data->thread = direct_thread_create( DTT_INPUT, sdlEventThread, data, "SDL Input" ); + + /* set private data pointer */ + *driver_data = data; + + return DFB_OK; +} + +/* + * Fetch one entry from the device's keymap if supported. + */ +static DFBResult +driver_get_keymap_entry( CoreInputDevice *device, + void *driver_data, + DFBInputDeviceKeymapEntry *entry ) +{ + return DFB_UNSUPPORTED; +} +/* + * End thread, close device and free private data. + */ +static void +driver_close_device( void *driver_data ) +{ + SDLInputData *data = (SDLInputData*) driver_data; + + /* stop input thread */ + data->stop = 1; + + direct_thread_join( data->thread ); + direct_thread_destroy( data->thread ); + + /* free private data */ + D_FREE ( data ); +} + diff --git a/Source/DirectFB/systems/vnc/Makefile.am b/Source/DirectFB/systems/vnc/Makefile.am new file mode 100755 index 0000000..025bf6a --- /dev/null +++ b/Source/DirectFB/systems/vnc/Makefile.am @@ -0,0 +1,55 @@ +## Makefile.am for DirectFB/systems/vnc + +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src \ + $(VNC_CFLAGS) + +systemsdir = $(MODULEDIR)/systems + +if BUILD_STATIC +systems_DATA = libdirectfb_vnc.o +endif + +systems_LTLIBRARIES = libdirectfb_vnc.la + +inputdriversdir = $(MODULEDIR)/inputdrivers + +if BUILD_STATIC +inputdrivers_DATA = libdirectfb_vncinput.o +endif +inputdrivers_LTLIBRARIES = libdirectfb_vncinput.la + +libdirectfb_vnc_la_LDFLAGS = \ + $(VNC_LIBS) \ + -avoid-version \ + -module + +libdirectfb_vnc_la_SOURCES = \ + primary.c \ + primary.h \ + vnc.c \ + vnc.h + +libdirectfb_vnc_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la + +libdirectfb_vncinput_la_LDFLAGS = \ + $(VNC_LIBS) \ + -avoid-version \ + -module + +libdirectfb_vncinput_la_SOURCES = \ + vncinput.c + +libdirectfb_vncinput_la_LIBADD = \ + $(top_builddir)/src/libdirectfb.la + + +include $(top_srcdir)/rules/libobject.make + diff --git a/Source/DirectFB/systems/vnc/Makefile.in b/Source/DirectFB/systems/vnc/Makefile.in new file mode 100755 index 0000000..f509745 --- /dev/null +++ b/Source/DirectFB/systems/vnc/Makefile.in @@ -0,0 +1,682 @@ +# 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 = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/rules/libobject.make +subdir = systems/vnc +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)$(inputdriversdir)" \ + "$(DESTDIR)$(systemsdir)" "$(DESTDIR)$(inputdriversdir)" \ + "$(DESTDIR)$(systemsdir)" +inputdriversLTLIBRARIES_INSTALL = $(INSTALL) +systemsLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(inputdrivers_LTLIBRARIES) $(systems_LTLIBRARIES) +libdirectfb_vnc_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la +am_libdirectfb_vnc_la_OBJECTS = primary.lo vnc.lo +libdirectfb_vnc_la_OBJECTS = $(am_libdirectfb_vnc_la_OBJECTS) +libdirectfb_vnc_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_vnc_la_LDFLAGS) $(LDFLAGS) -o $@ +libdirectfb_vncinput_la_DEPENDENCIES = \ + $(top_builddir)/src/libdirectfb.la +am_libdirectfb_vncinput_la_OBJECTS = vncinput.lo +libdirectfb_vncinput_la_OBJECTS = \ + $(am_libdirectfb_vncinput_la_OBJECTS) +libdirectfb_vncinput_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_vncinput_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_vnc_la_SOURCES) \ + $(libdirectfb_vncinput_la_SOURCES) +DIST_SOURCES = $(libdirectfb_vnc_la_SOURCES) \ + $(libdirectfb_vncinput_la_SOURCES) +inputdriversDATA_INSTALL = $(INSTALL_DATA) +systemsDATA_INSTALL = $(INSTALL_DATA) +DATA = $(inputdrivers_DATA) $(systems_DATA) +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 \ + $(VNC_CFLAGS) + +systemsdir = $(MODULEDIR)/systems +@BUILD_STATIC_TRUE@systems_DATA = libdirectfb_vnc.o +systems_LTLIBRARIES = libdirectfb_vnc.la +inputdriversdir = $(MODULEDIR)/inputdrivers +@BUILD_STATIC_TRUE@inputdrivers_DATA = libdirectfb_vncinput.o +inputdrivers_LTLIBRARIES = libdirectfb_vncinput.la +libdirectfb_vnc_la_LDFLAGS = \ + $(VNC_LIBS) \ + -avoid-version \ + -module + +libdirectfb_vnc_la_SOURCES = \ + primary.c \ + primary.h \ + vnc.c \ + vnc.h + +libdirectfb_vnc_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la + +libdirectfb_vncinput_la_LDFLAGS = \ + $(VNC_LIBS) \ + -avoid-version \ + -module + +libdirectfb_vncinput_la_SOURCES = \ + vncinput.c + +libdirectfb_vncinput_la_LIBADD = \ + $(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/vnc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu systems/vnc/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-inputdriversLTLIBRARIES: $(inputdrivers_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(inputdriversdir)" || $(MKDIR_P) "$(DESTDIR)$(inputdriversdir)" + @list='$(inputdrivers_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(inputdriversLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(inputdriversdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(inputdriversLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(inputdriversdir)/$$f"; \ + else :; fi; \ + done + +uninstall-inputdriversLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(inputdrivers_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(inputdriversdir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(inputdriversdir)/$$p"; \ + done + +clean-inputdriversLTLIBRARIES: + -test -z "$(inputdrivers_LTLIBRARIES)" || rm -f $(inputdrivers_LTLIBRARIES) + @list='$(inputdrivers_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 +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_vnc.la: $(libdirectfb_vnc_la_OBJECTS) $(libdirectfb_vnc_la_DEPENDENCIES) + $(libdirectfb_vnc_la_LINK) -rpath $(systemsdir) $(libdirectfb_vnc_la_OBJECTS) $(libdirectfb_vnc_la_LIBADD) $(LIBS) +libdirectfb_vncinput.la: $(libdirectfb_vncinput_la_OBJECTS) $(libdirectfb_vncinput_la_DEPENDENCIES) + $(libdirectfb_vncinput_la_LINK) -rpath $(inputdriversdir) $(libdirectfb_vncinput_la_OBJECTS) $(libdirectfb_vncinput_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/primary.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vncinput.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-inputdriversDATA: $(inputdrivers_DATA) + @$(NORMAL_INSTALL) + test -z "$(inputdriversdir)" || $(MKDIR_P) "$(DESTDIR)$(inputdriversdir)" + @list='$(inputdrivers_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(inputdriversDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(inputdriversdir)/$$f'"; \ + $(inputdriversDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(inputdriversdir)/$$f"; \ + done + +uninstall-inputdriversDATA: + @$(NORMAL_UNINSTALL) + @list='$(inputdrivers_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(inputdriversdir)/$$f'"; \ + rm -f "$(DESTDIR)$(inputdriversdir)/$$f"; \ + done +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 + +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) +installdirs: + for dir in "$(DESTDIR)$(inputdriversdir)" "$(DESTDIR)$(systemsdir)" "$(DESTDIR)$(inputdriversdir)" "$(DESTDIR)$(systemsdir)"; 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-inputdriversLTLIBRARIES 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-inputdriversDATA \ + install-inputdriversLTLIBRARIES 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-inputdriversDATA \ + uninstall-inputdriversLTLIBRARIES uninstall-systemsDATA \ + uninstall-systemsLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-inputdriversLTLIBRARIES 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-inputdriversDATA \ + install-inputdriversLTLIBRARIES 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-inputdriversDATA \ + uninstall-inputdriversLTLIBRARIES 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/vnc/primary.c b/Source/DirectFB/systems/vnc/primary.c new file mode 100755 index 0000000..17de20e --- /dev/null +++ b/Source/DirectFB/systems/vnc/primary.c @@ -0,0 +1,993 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include "vnc.h" +#include "primary.h" + + +D_DEBUG_DOMAIN( VNC_Layer, "VNC/Layer", "VNC Layer" ); + +/**********************************************************************************************************************/ + +/******************************************************************************/ +/*VNC server setup*/ +/* Here we create a structure so that every client has it's own pointer */ + +typedef struct ClientData { + DFBVNC *vnc; + int oldButtonMask; + int oldx,oldy; +} ClientData; + +static void process_key_event(rfbBool down, rfbKeySym key, struct _rfbClientRec* cl); +static void process_pointer_event(int buttonMask, int x, int y, struct _rfbClientRec* cl); +static bool translate_key(rfbKeySym key, DFBInputEvent *evt ); +static void clientgone(rfbClientPtr cl); +static enum rfbNewClientAction newclient(rfbClientPtr cl); + +extern CoreInputDevice *vncInputDevice; + +/******************************************************************************/ + +static DFBResult +primaryInitScreen( CoreScreen *screen, + CoreGraphicsDevice *device, + void *driver_data, + void *screen_data, + DFBScreenDescription *description ) +{ + int argc = 0; + char **argv = NULL; + DFBVNC *vnc = driver_data; + DFBVNCShared *shared = vnc->shared; + + /* Set the screen capabilities. */ + description->caps = DSCCAPS_NONE; + + /* Set the screen name. */ + direct_snputs( description->name, "VNC Primary Screen", DFB_SCREEN_DESC_NAME_LENGTH ); + + /* + * Allocate shared memory for RFB screen frame buffer + */ + shared->screen_buffer = SHCALLOC( dfb_core_shmpool_data(vnc->core), 2 * shared->screen_size.h, 4 * shared->screen_size.w ); + if (!shared->screen_buffer) + return D_OOSHM(); + + + /* Set video mode */ + vnc->rfb_screen = rfbGetScreen( &argc, argv, shared->screen_size.w, shared->screen_size.h, 8, 3, 4 ); + if (!vnc->rfb_screen) { + D_ERROR( "DirectFB/VNC: rfbGetScreen( %dx%d, 8, 3, 4 ) failed!\n", shared->screen_size.w, shared->screen_size.h ); + SHFREE( dfb_core_shmpool_data(vnc->core), shared->screen_buffer ); + return DFB_FAILURE; + } + + vnc->rfb_screen->screenData = vnc; + + rfbNewFramebuffer( vnc->rfb_screen, shared->screen_buffer, shared->screen_size.w, shared->screen_size.h, 8, 3, 4 ); + + vnc->rfb_screen->serverFormat.redShift = 16; + vnc->rfb_screen->serverFormat.greenShift = 8; + vnc->rfb_screen->serverFormat.blueShift = 0; + vnc->rfb_screen->serverFormat.redMax = 255; + vnc->rfb_screen->serverFormat.greenMax = 255; + vnc->rfb_screen->serverFormat.blueMax = 255; + + + /* Connect key handler */ + + vnc->rfb_screen->kbdAddEvent = process_key_event; + vnc->rfb_screen->ptrAddEvent = process_pointer_event; + vnc->rfb_screen->newClientHook = newclient; + vnc->rfb_screen->autoPort = TRUE; + + /* Initialize VNC */ + + rfbInitServer(vnc->rfb_screen); + + if (vnc->rfb_screen->listenSock == -1) { + D_ERROR( "DirectFB/VNC: rfbInitServer() failed to initialize listening socket!\n" ); + SHFREE( dfb_core_shmpool_data(vnc->core), shared->screen_buffer ); + return DFB_FAILURE; + } + + + DFBResult ret; + CoreSurfaceConfig config; + + config.flags = CSCONF_SIZE | CSCONF_FORMAT | CSCONF_CAPS | CSCONF_PREALLOCATED; + config.size.w = shared->screen_size.w; + config.size.h = shared->screen_size.h; + config.format = DSPF_ARGB; + config.caps = DSCAPS_SYSTEMONLY | DSCAPS_DOUBLE;// | DSCAPS_SHARED; + config.preallocated[0].addr = shared->screen_buffer; + config.preallocated[0].pitch = shared->screen_size.w * 4; + config.preallocated[1].addr = shared->screen_buffer + shared->screen_size.w * 4 * shared->screen_size.h; + config.preallocated[1].pitch = shared->screen_size.w * 4; + + ret = dfb_surface_create( vnc->core, &config, CSTF_PREALLOCATED, 0, NULL, &shared->screen_surface ); + if (ret) { + D_DERROR( ret, "DirectFB/VNC: Could not create preallocated screen surface!\n" ); + SHFREE( dfb_core_shmpool_data(vnc->core), shared->screen_buffer ); + return ret; + } + + + rfbRunEventLoop( vnc->rfb_screen, -1, TRUE ); + + return DFB_OK; +} +/* +static DFBResult +primaryShutdownScreen( CoreScreen *screen, + void *driver_data, + void *screen_data ) +{ + DFBVNC *vnc = driver_data; + + rfbScreenCleanup( vnc->rfb_screen ); + + SHFREE( dfb_core_shmpool_data(vnc->core), vnc->shared->screen_buffer ); + + return DFB_OK; +} +*/ +static DFBResult +primaryGetScreenSize( CoreScreen *screen, + void *driver_data, + void *screen_data, + int *ret_width, + int *ret_height ) +{ + DFBVNC *vnc = driver_data; + + *ret_width = vnc->shared->screen_size.w; + *ret_height = vnc->shared->screen_size.h; + + return DFB_OK; +} + +static const ScreenFuncs _vncPrimaryScreenFuncs = { + .InitScreen = primaryInitScreen, +// .ShutdownScreen = primaryShutdownScreen, + .GetScreenSize = primaryGetScreenSize, +}; + +const ScreenFuncs *vncPrimaryScreenFuncs = &_vncPrimaryScreenFuncs; + +/******************************************************************************/ + +static int +primaryLayerDataSize( void ) +{ + return sizeof(VNCLayerData); +} + +static int +primaryRegionDataSize( void ) +{ + return 0; +} + +static DFBResult +primaryInitLayer( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *config, + DFBColorAdjustment *adjustment ) +{ + DFBVNC *vnc = driver_data; + VNCLayerData *data = layer_data; + const char *name; + + D_DEBUG( "DirectFB/VNC: primaryInitLayer\n"); + + char *names[] = { "Primary", "Secondary", "Tertiary" }; + + if (vnc->layer_count < 3) + name = names[vnc->layer_count]; + else + name = "Other"; + + data->layer_id = vnc->layer_count; + + vnc->shared->layer_data[vnc->layer_count++] = data; + + + /* set capabilities and type */ + description->caps = DLCAPS_SURFACE | DLCAPS_SCREEN_LOCATION | DLCAPS_ALPHACHANNEL | DLCAPS_OPACITY; + description->type = DLTF_GRAPHICS; + + /* set name */ + snprintf( description->name, + DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, "VNC %s Layer", name ); + + /* fill out the default configuration */ + config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | + DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE; + config->buffermode = DLBM_FRONTONLY; + config->width = vnc->shared->screen_size.w; + config->height = vnc->shared->screen_size.h; + + 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 & ~(DLOP_ALPHACHANNEL | DLOP_OPACITY)) + 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 +UpdateScreen( DFBVNC *vnc, + const DFBRectangle *update ) +{ + DFBVNCShared *shared = vnc->shared; + DFBRegion clip = { 0, 0, shared->screen_size.w - 1, shared->screen_size.h - 1 }; + CardState state; + unsigned int i; + + D_DEBUG_AT( VNC_Layer, "%s()\n", __FUNCTION__ ); + + if (update) { + if (!dfb_region_rectangle_intersect( &clip, update )) { + D_DEBUG_AT( VNC_Layer, " -> update not intersecting with screen area!\n" ); + return DFB_OK; + } + } + + dfb_state_init( &state, vnc->core ); + + state.destination = shared->screen_surface; + state.clip = clip; + state.src_blend = DSBF_ONE; + state.dst_blend = DSBF_INVSRCALPHA; + + // FIXME: optimize out clear + DFBRectangle rect = { + 0, 0, shared->screen_size.w, shared->screen_size.h + }; + + dfb_gfxcard_fillrectangles( &rect, 1, &state ); + + + for (i=0; ilayer_data[i]; + + if (data->surface) { + DFBRectangle src = data->config.source; + DFBRectangle dst = data->config.dest; + + state.modified |= SMF_SOURCE | SMF_BLITTING_FLAGS; + state.source = data->surface; + + /* emulate missing hw layer clipping */ + if (dst.x + dst.w > shared->screen_size.w || dst.y + dst.h > shared->screen_size.h) + return DFB_ACCESSDENIED; + + + if (data->config.options & DLOP_ALPHACHANNEL) { + state.blittingflags = DSBLIT_BLEND_ALPHACHANNEL; + + if (!(data->surface->config.caps & DSCAPS_PREMULTIPLIED)) + state.blittingflags |= DSBLIT_SRC_PREMULTIPLY; + } + else + state.blittingflags = DSBLIT_NOFX; + + if ((data->config.options & DLOP_OPACITY) && data->config.opacity != 0xff) { + state.blittingflags |= DSBLIT_BLEND_COLORALPHA; + + if (data->surface->config.caps & DSCAPS_PREMULTIPLIED) + state.blittingflags |= DSBLIT_SRC_PREMULTCOLOR; + + + state.modified |= SMF_COLOR; + state.color.a = data->config.opacity; + } + + dfb_gfxcard_stretchblit( &src, &dst, &state ); + } + } + + state.destination = NULL; + state.source = NULL; + + dfb_state_destroy( &state ); + + + dfb_back_to_front_copy( shared->screen_surface, &clip ); + + + dfb_gfxcard_sync(); + + DirectResult ret; + DFBVNCMarkRectAsModified mark; + + mark.region = clip; + + ret = fusion_call_execute( &shared->call, FCEF_ONEWAY, + (int)((clip.x1 << 16) | clip.x2), + (void*)(long)((clip.y1 << 16) | clip.y2), + NULL ); + if (ret) { + D_DERROR( ret, "DirectFB/VNC: fusion_call_execute2() failed!\n" ); + return ret; + } + + 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 *left_lock ) +{ + DFBVNC *vnc = driver_data; + VNCLayerData *data = layer_data; + + D_DEBUG_AT( VNC_Layer, "%s()\n", __FUNCTION__ ); + + data->config = *config; + + if (updated & CLRCF_OPACITY) + D_DEBUG_AT( VNC_Layer, " -> opacity %d\n", config->opacity ); + + dfb_surface_link( &vnc->shared->layer_data[data->layer_id]->surface, surface ); + + if (data->shown) + return UpdateScreen( vnc, NULL ); + else + D_DEBUG_AT( VNC_Layer, " -> not shown\n" ); + + return DFB_OK; +} + +static DFBResult +primaryRemoveRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data ) +{ + DFBVNC *vnc = driver_data; + VNCLayerData *data = layer_data; + + D_DEBUG_AT( VNC_Layer, "%s()\n", __FUNCTION__ ); + + D_DEBUG_AT( VNC_Layer, " -> setting shown to false\n" ); + + data->shown = false; + + dfb_surface_unlink( &vnc->shared->layer_data[data->layer_id]->surface ); + + return UpdateScreen( vnc, NULL ); +} + +static DFBResult +primaryFlipRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + DFBSurfaceFlipFlags flags, + CoreSurfaceBufferLock *left_lock ) +{ + DFBVNC *vnc = driver_data; + VNCLayerData *data = layer_data; + + D_DEBUG_AT( VNC_Layer, "%s()\n", __FUNCTION__ ); + + dfb_surface_flip( surface, false ); + + D_DEBUG_AT( VNC_Layer, " -> setting shown to true\n" ); + + data->shown = true; + + return UpdateScreen( vnc, &data->config.dest ); +} + +static DFBResult +primaryUpdateRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + const DFBRegion *left_update, + CoreSurfaceBufferLock *left_lock ) +{ + DFBVNC *vnc = driver_data; + VNCLayerData *data = layer_data; + + DFBRectangle update = data->config.dest; + + D_DEBUG_AT( VNC_Layer, "%s()\n", __FUNCTION__ ); + + if (left_update) { + DFBRegion screen_update = { + left_update->x1 + data->config.dest.x, + left_update->y1 + data->config.dest.y, + left_update->x2 + data->config.dest.x, + left_update->y2 + data->config.dest.y + }; + + D_DEBUG_AT( VNC_Layer, " -> update %d,%d-%dx%d\n", DFB_RECTANGLE_VALS_FROM_REGION(&screen_update) ); + + if (!dfb_rectangle_intersect_by_region( &update, &screen_update )) { + D_DEBUG_AT( VNC_Layer, " -> no intersection with %d,%d-%dx%d!\n", DFB_RECTANGLE_VALS( &data->config.dest ) ); + + return DFB_OK; + } + } + + D_DEBUG_AT( VNC_Layer, " -> setting shown to true\n" ); + + data->shown = true; + + return UpdateScreen( vnc, &update ); +} + +static DFBResult +primaryAllocateSurface( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreSurface **ret_surface ) +{ + DFBVNC *vnc = driver_data; + CoreSurfaceConfig conf; + + conf.flags = CSCONF_SIZE | CSCONF_FORMAT | CSCONF_CAPS; + conf.size.w = config->width; + conf.size.h = config->height; + conf.format = config->format; + conf.caps = DSCAPS_SYSTEMONLY; + + if (config->buffermode != DLBM_FRONTONLY) + conf.caps |= DSCAPS_DOUBLE; + + return dfb_surface_create( vnc->core, &conf, CSTF_LAYER, DLID_PRIMARY, NULL, ret_surface ); +} + +static DFBResult +primaryReallocateSurface( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreSurface *surface ) +{ + DFBResult ret; + CoreSurfaceConfig conf; + + conf.flags = CSCONF_SIZE | CSCONF_FORMAT | CSCONF_CAPS; + conf.size.w = config->width; + conf.size.h = config->height; + conf.format = config->format; + conf.caps = DSCAPS_SYSTEMONLY; + + if (config->buffermode != DLBM_FRONTONLY) + conf.caps |= DSCAPS_DOUBLE; + + ret = dfb_surface_reconfig( surface, &conf ); + if (ret) + return ret; + + if (DFB_PIXELFORMAT_IS_INDEXED(config->format) && !surface->palette) { + DFBResult ret; + CorePalette *palette; + + ret = dfb_palette_create( NULL, /* FIXME */ + 1 << DFB_COLOR_BITS_PER_PIXEL( config->format ), + &palette ); + if (ret) + return ret; + + if (config->format == DSPF_LUT8) + dfb_palette_generate_rgb332_map( palette ); + + dfb_surface_set_palette( surface, palette ); + + dfb_palette_unref( palette ); + } + + return DFB_OK; +} + +static const DisplayLayerFuncs _vncPrimaryLayerFuncs = { + .LayerDataSize = primaryLayerDataSize, + .RegionDataSize = primaryRegionDataSize, + .InitLayer = primaryInitLayer, + + .TestRegion = primaryTestRegion, + .AddRegion = primaryAddRegion, + .SetRegion = primarySetRegion, + .RemoveRegion = primaryRemoveRegion, + .FlipRegion = primaryFlipRegion, + .UpdateRegion = primaryUpdateRegion, + + .AllocateSurface = primaryAllocateSurface, + .ReallocateSurface = primaryReallocateSurface, +}; + +const DisplayLayerFuncs *vncPrimaryLayerFuncs = &_vncPrimaryLayerFuncs; + + +/**********************************************************************************************************************/ + +/** + VNC Server setup +**/ + +static void +clientgone(rfbClientPtr cl) +{ + D_FREE( cl->clientData ); +} + +static enum rfbNewClientAction +newclient(rfbClientPtr cl) +{ + ClientData *cd; + DFBVNC *vnc = cl->screen->screenData; + + cd = D_CALLOC( 1, sizeof(ClientData) ); + if (!cd) { + D_OOM(); + return RFB_CLIENT_REFUSE; + } + + cd->vnc = vnc; + + cl->clientData = cd; + cl->clientGoneHook = clientgone; + + return RFB_CLIENT_ACCEPT; +} + +static void +send_button_event( DFBInputDeviceButtonIdentifier button, + bool press ) +{ + if (vncInputDevice) { + DFBInputEvent evt; + + evt.flags = DIEF_NONE; + evt.type = press ? DIET_BUTTONPRESS : DIET_BUTTONRELEASE; + evt.button = button; + + dfb_input_dispatch( vncInputDevice, &evt ); + } +} + +static void +process_pointer_event(int buttonMask, int x, int y, rfbClientPtr cl) +{ + if (vncInputDevice) { + ClientData *cd = cl->clientData; + DFBInputEvent evt; + + evt.type = DIET_AXISMOTION; + evt.flags = DIEF_AXISABS | DIEF_MIN | DIEF_MAX; + + if (cd->oldx != x) { + cd->oldx = x; + + evt.axis = DIAI_X; + evt.axisabs = x; + evt.min = 0; + evt.max = cd->vnc->shared->screen_size.w - 1; + + dfb_input_dispatch( vncInputDevice, &evt ); + } + + if (cd->oldy != y) { + cd->oldy = y; + + evt.axis = DIAI_Y; + evt.axisabs = y; + evt.min = 0; + evt.max = cd->vnc->shared->screen_size.h - 1; + + dfb_input_dispatch( vncInputDevice, &evt ); + } + + if (buttonMask != cd->oldButtonMask) { + if ((buttonMask & (1 << 0)) != (cd->oldButtonMask & (1 << 0))) + send_button_event( DIBI_LEFT, !!(buttonMask & (1 << 0)) ); + + if ((buttonMask & (1 << 1)) != (cd->oldButtonMask & (1 << 1))) + send_button_event( DIBI_MIDDLE, !!(buttonMask & (1 << 1)) ); + + if ((buttonMask & (1 << 2)) != (cd->oldButtonMask & (1 << 2))) + send_button_event( DIBI_RIGHT, !!(buttonMask & (1 << 2)) ); + + cd->oldButtonMask = buttonMask; + } + } + + rfbDefaultPtrAddEvent(buttonMask,x,y,cl); +} + +/* + * declaration of private data + */ +static void +process_key_event(rfbBool down, rfbKeySym key, rfbClientPtr cl) +{ + if (vncInputDevice) { + DFBInputEvent evt; + + if (down) + evt.type = DIET_KEYPRESS; + else + evt.type = DIET_KEYRELEASE; + + if (translate_key( key, &evt )) + dfb_input_dispatch( vncInputDevice, &evt ); + } +} + + +static bool +translate_key(rfbKeySym key, DFBInputEvent *evt ) +{ + /* Unicode */ + if (key <= 0xf000) { + evt->flags = DIEF_KEYSYMBOL; + evt->key_symbol = key; + return true; + } + + /* Dead keys */ + /* todo */ + + /* Numeric keypad */ + if (key >= XK_KP_0 && key <= XK_KP_9) { + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_KP_0 + key - XK_KP_0; + return true; + } + + /* Function keys */ + if (key >= XK_F1 && key <= XK_F11) { + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_F1 + key - XK_F1; + return true; + } + + switch (key) { + /* Numeric keypad */ + case XK_KP_Decimal: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_KP_DECIMAL; + break; + + case XK_KP_Separator: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_KP_SEPARATOR; + break; + + case XK_KP_Divide: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_KP_DIV; + break; + + case XK_KP_Multiply: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_KP_MULT; + break; + + case XK_KP_Subtract: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_KP_MINUS; + break; + + case XK_KP_Add: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_KP_PLUS; + break; + + case XK_KP_Enter: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_KP_ENTER; + break; + + case XK_KP_Equal: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_KP_EQUAL; + break; + + + /* Arrows + Home/End pad */ + case XK_Up: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_UP; + break; + + case XK_Down: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_DOWN; + break; + + case XK_Right: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_RIGHT; + break; + + case XK_Left: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_LEFT; + break; + + case XK_Insert: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_INSERT; + break; + + case XK_Delete: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_DELETE; + break; + + case XK_Home: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_HOME; + break; + + case XK_End: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_END; + break; + + case XK_Page_Up: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_PAGE_UP; + break; + + case XK_Page_Down: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_PAGE_DOWN; + break; + + + /* Key state modifier keys */ + case XK_Num_Lock: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_NUM_LOCK; + break; + + case XK_Caps_Lock: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_CAPS_LOCK; + break; + + case XK_Scroll_Lock: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_SCROLL_LOCK; + break; + + case XK_Shift_R: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_SHIFT_R; + break; + + case XK_Shift_L: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_SHIFT_L; + break; + + case XK_Control_R: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_CONTROL_R; + break; + + case XK_Control_L: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_CONTROL_L; + break; + + case XK_Alt_R: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_ALT_R; + break; + + case XK_Alt_L: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_ALT_L; + break; + + case XK_Meta_R: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_META_R; + break; + + case XK_Meta_L: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_META_L; + break; + + case XK_Super_L: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_SUPER_L; + break; + + case XK_Super_R: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_SUPER_R; + break; + + case XK_Hyper_L: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_HYPER_L; + break; + + case XK_Hyper_R: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_HYPER_R; + break; + + /*case ??: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_ALTGR; + break;*/ + + case XK_BackSpace: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_BACKSPACE; + break; + + case XK_Tab: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_HYPER_L; + break; + + case XK_Return: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_ENTER; + break; + + case XK_Escape: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_ESCAPE; + break; + + case XK_Pause: + evt->flags = DIEF_KEYID; + evt->key_id = DIKI_PAUSE; + break; + + /* Miscellaneous function keys */ + case XK_Help: + evt->flags = DIEF_KEYSYMBOL; + evt->key_symbol = DIKS_HELP; + break; + + case XK_Print: + evt->flags = DIEF_KEYSYMBOL; + evt->key_symbol = DIKS_PRINT; + break; + + case XK_Break: + evt->flags = DIEF_KEYSYMBOL; + evt->key_symbol = DIKS_BREAK; + break; + + default: + return false; + } + + return true; +} + diff --git a/Source/DirectFB/systems/vnc/primary.h b/Source/DirectFB/systems/vnc/primary.h new file mode 100755 index 0000000..6c981b9 --- /dev/null +++ b/Source/DirectFB/systems/vnc/primary.h @@ -0,0 +1,50 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __SDL__PRIMARY_H__ +#define __SDL__PRIMARY_H__ + +#include + +#include +#include + +extern const ScreenFuncs *vncPrimaryScreenFuncs; +extern const DisplayLayerFuncs *vncPrimaryLayerFuncs; + +FusionCallHandlerResult +dfb_vnc_call_handler( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ); + + +#endif + diff --git a/Source/DirectFB/systems/vnc/vnc.c b/Source/DirectFB/systems/vnc/vnc.c new file mode 100755 index 0000000..1277ad3 --- /dev/null +++ b/Source/DirectFB/systems/vnc/vnc.c @@ -0,0 +1,313 @@ +/* + (c) Copyright 2001-2010 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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include +#include "vnc.h" +#include "primary.h" + +#include + + +DFB_CORE_SYSTEM( vnc ) + + +static DFBVNC *dfb_vnc; + +static FusionCallHandlerResult +VNC_Dispatch( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ); + +/**********************************************************************************************************************/ + +static void +system_get_info( CoreSystemInfo *info ) +{ + info->type = CORE_VNC; + + snprintf( info->name, DFB_CORE_SYSTEM_INFO_NAME_LENGTH, "VNC" ); +} + +static DFBResult +system_initialize( CoreDFB *core, void **data ) +{ + D_ASSERT( dfb_vnc == NULL ); + + dfb_vnc = (DFBVNC*) D_CALLOC( 1, sizeof(DFBVNC) ); + if (!dfb_vnc) + return D_OOM(); + + dfb_vnc->core = core; + + dfb_vnc->shared = (DFBVNCShared*) SHCALLOC( dfb_core_shmpool(core), 1, sizeof(DFBVNCShared) ); + if (!dfb_vnc->shared) { + D_FREE( dfb_vnc ); + return D_OOSHM(); + } + + dfb_vnc->shared->screen_size.w = dfb_config->mode.width ? dfb_config->mode.width : 1280; + dfb_vnc->shared->screen_size.h = dfb_config->mode.height ? dfb_config->mode.height : 720; + + fusion_call_init( &dfb_vnc->shared->call, VNC_Dispatch, dfb_vnc, dfb_core_world(core) ); + + dfb_vnc->screen = dfb_screens_register( NULL, dfb_vnc, (void*) vncPrimaryScreenFuncs ); + + dfb_vnc->layer[0] = dfb_layers_register( dfb_vnc->screen, dfb_vnc, vncPrimaryLayerFuncs ); + dfb_vnc->layer[1] = dfb_layers_register( dfb_vnc->screen, dfb_vnc, vncPrimaryLayerFuncs ); + + fusion_arena_add_shared_field( dfb_core_arena( core ), "vnc", dfb_vnc->shared ); + + *data = dfb_vnc; + + return DFB_OK; +} + +static DFBResult +system_join( CoreDFB *core, void **data ) +{ + void *ret; + + D_ASSERT( dfb_vnc == NULL ); + + fusion_arena_get_shared_field( dfb_core_arena( core ), "vnc", &ret ); + + dfb_vnc = (DFBVNC*) D_CALLOC( 1, sizeof(DFBVNC) ); + if (!dfb_vnc) + return D_OOM(); + + dfb_vnc->core = core; + + dfb_vnc->shared = ret; + + dfb_vnc->screen = dfb_screens_register( NULL, dfb_vnc, (void*) vncPrimaryScreenFuncs ); + + dfb_vnc->layer[0] = dfb_layers_register( dfb_vnc->screen, dfb_vnc, vncPrimaryLayerFuncs ); + dfb_vnc->layer[1] = dfb_layers_register( dfb_vnc->screen, dfb_vnc, vncPrimaryLayerFuncs ); + + *data = dfb_vnc; + + return DFB_OK; +} + +static DFBResult +system_shutdown( bool emergency ) +{ + D_ASSERT( dfb_vnc != NULL ); + + fusion_call_destroy( &dfb_vnc->shared->call ); + + SHFREE( dfb_core_shmpool(dfb_vnc->core), dfb_vnc->shared ); + + D_FREE( dfb_vnc ); + dfb_vnc = NULL; + + return DFB_OK; +} + +static DFBResult +system_leave( bool emergency ) +{ + D_ASSERT( dfb_vnc != NULL ); + + D_FREE( dfb_vnc ); + dfb_vnc = NULL; + + return DFB_OK; +} + +static DFBResult +system_suspend( void ) +{ + return DFB_UNIMPLEMENTED; +} + +static DFBResult +system_resume( void ) +{ + return DFB_UNIMPLEMENTED; +} + + +static int +system_get_accelerator( void ) +{ + return -1; +} + +static VideoMode * +system_get_modes( void ) +{ + return NULL; +} + +static VideoMode * +system_get_current_mode( void ) +{ + return NULL; +} + + +static volatile void * +system_map_mmio( unsigned int offset, + int length ) +{ + return NULL; +} + +static void +system_unmap_mmio( volatile void *addr, + int length ) +{ +} + +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 0; +} + +static void * +system_video_memory_virtual( unsigned int offset ) +{ + return NULL; +} + +static unsigned int +system_videoram_length( void ) +{ + return 0; +} + +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; +} + +/**********************************************************************************************************************/ + +static int +VNC_Dispatch_MarkRectAsModified( DFBVNC *vnc, + DFBVNCMarkRectAsModified *mark ) +{ + rfbMarkRectAsModified( vnc->rfb_screen, mark->region.x1, mark->region.y1, mark->region.x2 + 1, mark->region.y2 + 1 ); + + return 0; +} + +static FusionCallHandlerResult +VNC_Dispatch( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ) +{ + DFBVNC *vnc = ctx; + + DFBVNCMarkRectAsModified modified; + + modified.region.x1 = call_arg >> 16; + modified.region.x2 = call_arg & 0xffff; + + modified.region.y1 = (long)call_ptr >> 16; + modified.region.y2 = (long)call_ptr & 0xffff; + + *ret_val = VNC_Dispatch_MarkRectAsModified( vnc, &modified ); + + return FCHR_RETURN; +} + diff --git a/Source/DirectFB/systems/vnc/vnc.h b/Source/DirectFB/systems/vnc/vnc.h new file mode 100755 index 0000000..9184aab --- /dev/null +++ b/Source/DirectFB/systems/vnc/vnc.h @@ -0,0 +1,86 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __VNC__VNC_H__ +#define __VNC__VNC_H__ + +#include + +#include + +#include +#include + +#include +#include + +#define VNC_MAX_LAYERS 2 + +typedef struct { + bool shown; + CoreLayerRegionConfig config; + + DFBDisplayLayerID layer_id; + + CoreSurface *surface; +} VNCLayerData; + + +typedef struct { + FusionCall call; + + DFBDimension screen_size; + void *screen_buffer; + CoreSurface *screen_surface; + + VNCLayerData *layer_data[VNC_MAX_LAYERS]; +} DFBVNCShared; + +typedef struct { + DFBVNCShared *shared; + + CoreDFB *core; + + CoreScreen *screen; + CoreLayer *layer[VNC_MAX_LAYERS]; + + rfbScreenInfoPtr rfb_screen; + + unsigned int layer_count; +} DFBVNC; + +typedef enum { + VNC_MARK_RECT_AS_MODIFIED, +} DFBVNCCall; + +typedef struct { + DFBRegion region; +} DFBVNCMarkRectAsModified; + +#endif + diff --git a/Source/DirectFB/systems/vnc/vncinput.c b/Source/DirectFB/systems/vnc/vncinput.c new file mode 100755 index 0000000..e693bba --- /dev/null +++ b/Source/DirectFB/systems/vnc/vncinput.c @@ -0,0 +1,128 @@ +/* + 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 + +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +DFB_INPUT_DRIVER( vncinput ) + + +CoreInputDevice *vncInputDevice = NULL; + +/* exported symbols */ + +/* + * Return the number of available devices. + * Called once during initialization of DirectFB. + */ +static int +driver_get_available( void ) +{ + if (dfb_system_type() == CORE_VNC) + return 1; + + return 0; +} + +/* + * Fill out general information about this driver. + * Called once during initialization of DirectFB. + */ +static void +driver_get_info( InputDriverInfo *info ) +{ + /* fill driver info structure */ + snprintf ( info->name, + DFB_INPUT_DRIVER_INFO_NAME_LENGTH, "VNC Input Driver" ); + snprintf ( info->vendor, + DFB_INPUT_DRIVER_INFO_VENDOR_LENGTH, "Leonard Schneider" ); + + info->version.major = 0; + info->version.minor = 1; +} + +/* + * Open the device, fill out information about it, + * allocate and fill private data, start input thread. + * Called during initialization, resuming or taking over mastership. + */ +static DFBResult +driver_open_device( CoreInputDevice *device, + unsigned int number, + InputDeviceInfo *info, + void **driver_data ) +{ + vncInputDevice = device; + + /* set device name */ + snprintf( info->desc.name, + DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "VNC Input" ); + + /* set device vendor */ + snprintf( info->desc.vendor, + DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "VNC" ); + + /* set one of the primary input device IDs */ + info->prefered_id = DIDID_KEYBOARD; + + /* set type flags */ + info->desc.type = /*DIDTF_JOYSTICK |*/ DIDTF_KEYBOARD| DIDTF_MOUSE; + + /* set capabilities */ + info->desc.caps = DICAPS_ALL; + + /* set private data pointer */ + /* *driver_data = device;*/ + + return DFB_OK; +} + +/* + * Fetch one entry from the device's keymap if supported. + */ +static DFBResult +driver_get_keymap_entry( CoreInputDevice *device, + void *driver_data, + DFBInputDeviceKeymapEntry *entry ) +{ + return DFB_UNSUPPORTED; +} + +/* + * End thread, close device and free private data. + */ +static void +driver_close_device( void *driver_data ) +{ +} + diff --git a/Source/DirectFB/systems/x11/Makefile.am b/Source/DirectFB/systems/x11/Makefile.am new file mode 100755 index 0000000..23c0b88 --- /dev/null +++ b/Source/DirectFB/systems/x11/Makefile.am @@ -0,0 +1,63 @@ +# Makefile.am for DirectFB/systems/x11 + +INCLUDES = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/gfxdrivers \ + $(X11_CFLAGS) + + +systemsdir = $(MODULEDIR)/systems + +if BUILD_STATIC +systems_DATA = libdirectfb_x11.o +endif + +systems_LTLIBRARIES = libdirectfb_x11.la + +libdirectfb_x11_la_LDFLAGS = \ + $(X11_LIBS) \ + -avoid-version \ + -module + +if GFX_GLX +libdirectfb_x11_la_LDFLAGS += -lGL +endif + +libdirectfb_x11_la_SOURCES = \ + primary.c \ + primary.h \ + surfacemanager.c \ + surfacemanager.h \ + vpsmem_surface_pool.c \ + vpsmem_surface_pool.h \ + x11.c \ + x11.h \ + x11image.c \ + x11image.h \ + x11input.c \ + x11_surface_pool.c \ + x11_surface_pool.h \ + x11types.h \ + xwindow.h \ + xwindow.c + +if GFX_GLX +libdirectfb_x11_la_SOURCES += \ + glx_surface_pool.c \ + glx_surface_pool.h \ + x11_surface_pool_bridge.c \ + x11_surface_pool_bridge.h +endif + +libdirectfb_x11_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/x11/Makefile.in b/Source/DirectFB/systems/x11/Makefile.in new file mode 100755 index 0000000..e25aa5b --- /dev/null +++ b/Source/DirectFB/systems/x11/Makefile.in @@ -0,0 +1,624 @@ +# 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@ + +# Makefile.am for DirectFB/systems/x11 + + +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@ +@GFX_GLX_TRUE@am__append_1 = -lGL +@GFX_GLX_TRUE@am__append_2 = \ +@GFX_GLX_TRUE@ glx_surface_pool.c \ +@GFX_GLX_TRUE@ glx_surface_pool.h \ +@GFX_GLX_TRUE@ x11_surface_pool_bridge.c \ +@GFX_GLX_TRUE@ x11_surface_pool_bridge.h + +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/rules/libobject.make +subdir = systems/x11 +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)" +systemsLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(systems_LTLIBRARIES) +libdirectfb_x11_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/lib/fusion/libfusion.la \ + $(top_builddir)/src/libdirectfb.la +am__libdirectfb_x11_la_SOURCES_DIST = primary.c primary.h \ + surfacemanager.c surfacemanager.h vpsmem_surface_pool.c \ + vpsmem_surface_pool.h x11.c x11.h x11image.c x11image.h \ + x11input.c x11_surface_pool.c x11_surface_pool.h x11types.h \ + xwindow.h xwindow.c glx_surface_pool.c glx_surface_pool.h \ + x11_surface_pool_bridge.c x11_surface_pool_bridge.h +@GFX_GLX_TRUE@am__objects_1 = glx_surface_pool.lo \ +@GFX_GLX_TRUE@ x11_surface_pool_bridge.lo +am_libdirectfb_x11_la_OBJECTS = primary.lo surfacemanager.lo \ + vpsmem_surface_pool.lo x11.lo x11image.lo x11input.lo \ + x11_surface_pool.lo xwindow.lo $(am__objects_1) +libdirectfb_x11_la_OBJECTS = $(am_libdirectfb_x11_la_OBJECTS) +libdirectfb_x11_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_x11_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_x11_la_SOURCES) +DIST_SOURCES = $(am__libdirectfb_x11_la_SOURCES_DIST) +systemsDATA_INSTALL = $(INSTALL_DATA) +DATA = $(systems_DATA) +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 \ + -I$(top_srcdir)/gfxdrivers \ + $(X11_CFLAGS) + +systemsdir = $(MODULEDIR)/systems +@BUILD_STATIC_TRUE@systems_DATA = libdirectfb_x11.o +systems_LTLIBRARIES = libdirectfb_x11.la +libdirectfb_x11_la_LDFLAGS = $(X11_LIBS) -avoid-version -module \ + $(am__append_1) +libdirectfb_x11_la_SOURCES = primary.c primary.h surfacemanager.c \ + surfacemanager.h vpsmem_surface_pool.c vpsmem_surface_pool.h \ + x11.c x11.h x11image.c x11image.h x11input.c \ + x11_surface_pool.c x11_surface_pool.h x11types.h xwindow.h \ + xwindow.c $(am__append_2) +libdirectfb_x11_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/x11/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu systems/x11/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_x11.la: $(libdirectfb_x11_la_OBJECTS) $(libdirectfb_x11_la_DEPENDENCIES) + $(libdirectfb_x11_la_LINK) -rpath $(systemsdir) $(libdirectfb_x11_la_OBJECTS) $(libdirectfb_x11_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glx_surface_pool.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/primary.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/surfacemanager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vpsmem_surface_pool.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11_surface_pool.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11_surface_pool_bridge.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11image.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11input.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xwindow.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 + +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) +installdirs: + for dir in "$(DESTDIR)$(systemsdir)" "$(DESTDIR)$(systemsdir)"; 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-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-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-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-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/x11/README b/Source/DirectFB/systems/x11/README new file mode 100755 index 0000000..7258175 --- /dev/null +++ b/Source/DirectFB/systems/x11/README @@ -0,0 +1,11 @@ +This is an X11 system in very early stages, it is not really usable yet. +Tested with RGB16, ARGB1555 and ARGB mode. + +BUGS +- occasional segfault during startup +- does not work with multi-application core + +TODO +- support for RGB32 +- test RGB24, RGB332, and palette mode +- code cleanup diff --git a/Source/DirectFB/systems/x11/glx_surface_pool.c b/Source/DirectFB/systems/x11/glx_surface_pool.c new file mode 100755 index 0000000..98b909d --- /dev/null +++ b/Source/DirectFB/systems/x11/glx_surface_pool.c @@ -0,0 +1,838 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include + +#include "x11.h" + +#include "glx_surface_pool.h" +#include "x11_surface_pool.h" + +D_DEBUG_DOMAIN( GLX_Surfaces, "GLX/Surfaces", "GLX Surface Pool" ); +D_DEBUG_DOMAIN( GLX_Pixmaps, "GLX/Pixmaps", "GLX Surface Pool Pixmaps" ); + +/**********************************************************************************************************************/ + +typedef void (*GLXBindTexImageEXTProc) ( Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list ); +typedef void (*GLXReleaseTexImageEXTProc)( Display *dpy, GLXDrawable drawable, int buffer ); + +typedef struct { + int magic; + + Display *display; + + GLXFBConfig *configs; + int num_configs; + + GLXFBConfig config24; + Visual *visual24; + + GLXFBConfig config32; + Visual *visual32; + + GLXBindTexImageEXTProc BindTexImageEXT; + GLXReleaseTexImageEXTProc ReleaseTexImageEXT; + + DirectHash *pixmaps; + + /* Every thread needs its own context! */ + pthread_key_t context_key; + pthread_key_t context_key2; +} glxPoolLocalData; + +typedef struct { +} glxPoolData; + +/**********************************************************************************************************************/ + +static void +destroy_context( void *arg ) +{ + ThreadContext *ctx = arg; + + XLockDisplay( ctx->display ); + + glXDestroyContext( ctx->display, ctx->context ); + + XUnlockDisplay( ctx->display ); + + D_FREE( ctx ); +} + +/**********************************************************************************************************************/ + +static DFBResult +InitLocal( glxPoolLocalData *local, + DFBX11 *x11 ) +{ + DFBResult ret; + + int i; + int attribs[] = { + GLX_DOUBLEBUFFER, + False, + + GLX_DRAWABLE_TYPE, + GLX_PIXMAP_BIT, + + GLX_X_RENDERABLE, + True, + + GLX_RED_SIZE, + 8, + + GLX_GREEN_SIZE, + 8, + + GLX_BLUE_SIZE, + 8, + + GLX_ALPHA_SIZE, + 8, + + GLX_DEPTH_SIZE, + 8, + + GLX_X_VISUAL_TYPE, + GLX_TRUE_COLOR, + + None + }; + + + local->display = x11->display; + + local->BindTexImageEXT = (GLXBindTexImageEXTProc) glXGetProcAddress( (unsigned char*) "glXBindTexImageEXT" ); + if (!local->BindTexImageEXT) { + D_ERROR( "glXGetProcAddress( 'glXBindTexImageEXT' ) failed!\n" ); + return DFB_UNSUPPORTED; + } + + local->ReleaseTexImageEXT = (GLXReleaseTexImageEXTProc) glXGetProcAddress( (unsigned char*) "glXReleaseTexImageEXT" ); + if (!local->ReleaseTexImageEXT) { + D_ERROR( "glXGetProcAddress( 'glXReleaseTexImageEXT' ) failed!\n" ); + return DFB_UNSUPPORTED; + } + + + ret = direct_hash_create( 7, &local->pixmaps ); + if (ret) + return ret; + + + XLockDisplay( local->display ); + + + local->configs = glXChooseFBConfig( local->display, DefaultScreen(local->display), attribs, &local->num_configs ); + + D_DEBUG_AT( GLX_Surfaces, " -> found %d configs\n", local->num_configs ); + + for (i=0; inum_configs; i++) { + int depth; + XVisualInfo *info = glXGetVisualFromFBConfig( local->display, local->configs[i] ); + + glXGetFBConfigAttrib( local->display, local->configs[i], GLX_DEPTH_SIZE, &depth ); + + D_DEBUG_AT( GLX_Surfaces, " [%2d] ID 0x%02lx, depth %d, RGB 0x%06lx/0x%06lx/0x%06lx {%d}, class %d, z %d\n", + i, info->visualid, info->depth, + info->red_mask, info->green_mask, info->blue_mask, + info->bits_per_rgb, info->class, depth ); + + if (depth >= 8 && info->class == TrueColor) { + switch (info->depth) { + case 32: + local->config32 = local->configs[i]; + local->visual32 = info->visual; + break; + + case 24: + local->config24 = local->configs[i]; + local->visual24 = info->visual; + break; + } + } + } + + if (!local->config24 || !local->config32) { + D_ERROR( "GLX/Surfaces: Could not find useful visuals!\n" ); + direct_hash_destroy( local->pixmaps ); + XUnlockDisplay( local->display ); + return DFB_UNSUPPORTED; + } + + XVisualInfo *info24 = glXGetVisualFromFBConfig( local->display, local->config24 ); + XVisualInfo *info32 = glXGetVisualFromFBConfig( local->display, local->config32 ); + + D_INFO( "GLX/Surfaces: Using visual 0x%02lx (24bit) and 0x%02lx (32bit)\n", info24->visualid, info32->visualid ); + + XUnlockDisplay( local->display ); + + + pthread_key_create( &local->context_key, destroy_context ); + pthread_key_create( &local->context_key2, destroy_context ); + + D_MAGIC_SET( local, glxPoolLocalData ); + + return DFB_OK; +} + +static DFBResult +GetLocalPixmap( glxPoolLocalData *local, + glxAllocationData *alloc, + CoreSurfaceAllocation *allocation, + LocalPixmap **ret_pixmap ) +{ + LocalPixmap *pixmap; + CoreSurface *surface; + CoreSurfaceBuffer *buffer; + + surface = allocation->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + buffer = allocation->buffer; + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + pixmap = direct_hash_lookup( local->pixmaps, alloc->pixmap ); + if (!pixmap) { + pixmap = D_CALLOC( 1, sizeof(LocalPixmap) ); + if (!pixmap) + return D_OOM(); + + pixmap->pixmap = alloc->pixmap; + pixmap->config = (alloc->depth == 24) ? local->config24 : local->config32; + + /* + * Create a GLXPixmap + */ + int attribs[] = { + GLX_TEXTURE_FORMAT_EXT, (alloc->depth == 24) ? GLX_TEXTURE_FORMAT_RGB_EXT : GLX_TEXTURE_FORMAT_RGBA_EXT, + GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_RECTANGLE_EXT, + None + }; + + + XLockDisplay( local->display ); + + pixmap->drawable = glXCreatePixmap( local->display, pixmap->config, alloc->pixmap, attribs ); + if (!pixmap->drawable) { + D_ERROR( "GLX/Surfaces: Could not create %dx%d (depth %d) GLXPixmap!\n", + surface->config.size.w, surface->config.size.h, alloc->depth ); + XUnlockDisplay( local->display ); + D_FREE( pixmap ); + return DFB_FAILURE; + } + + D_DEBUG_AT( GLX_Surfaces, " -> drawable 0x%lx\n", pixmap->drawable ); + + /* + * Create a GC (for writing to pixmap) + */ + pixmap->gc = XCreateGC( local->display, alloc->pixmap, 0, NULL ); + + D_DEBUG_AT( GLX_Surfaces, " -> gc 0x%lx\n", pixmap->drawable ); + + XUnlockDisplay( local->display ); + + + /* + * Create a texture object + */ + glGenTextures( 1, &pixmap->buffer.texture ); + + + D_DEBUG_AT( GLX_Pixmaps, " NEW GLXPixmap 0x%lx for 0x%lx [%4dx%4d] %-10s\n", pixmap->drawable, alloc->pixmap, + surface->config.size.w, surface->config.size.h, dfb_pixelformat_name(buffer->format) ); + D_DEBUG_AT( GLX_Surfaces, " -> GLXPixmap 0x%lx [%4dx%4d] %-10s (%u)\n", pixmap->drawable, + surface->config.size.w, surface->config.size.h, dfb_pixelformat_name(buffer->format), + pixmap->buffer.texture ); + + D_MAGIC_SET( pixmap, LocalPixmap ); + D_MAGIC_SET( &pixmap->buffer, GLBufferData ); + + direct_hash_insert( local->pixmaps, alloc->pixmap, pixmap ); + } + else + D_MAGIC_ASSERT( pixmap, LocalPixmap ); + + *ret_pixmap = pixmap; + + return DFB_OK; +} + +static void +ReleasePixmap( glxPoolLocalData *local, + LocalPixmap *pixmap ) +{ + D_MAGIC_ASSERT( local, glxPoolLocalData ); + D_MAGIC_ASSERT( pixmap, LocalPixmap ); + + if (pixmap->bound) { + D_DEBUG_AT( GLX_Pixmaps, " RELEASE 0x%08lx from %p\n", pixmap->drawable, pixmap->bound ); + + local->ReleaseTexImageEXT( local->display, pixmap->drawable, GLX_FRONT_EXT ); + + pixmap->bound = NULL; + } +} + +static void +DestroyPixmap( glxPoolLocalData *local, + LocalPixmap *pixmap ) +{ + D_MAGIC_ASSERT( local, glxPoolLocalData ); + D_MAGIC_ASSERT( pixmap, LocalPixmap ); + + D_DEBUG_AT( GLX_Pixmaps, " DESTROY 0x%08lx (%d)\n", pixmap->drawable, pixmap->buffer.texture ); + + glXWaitGL(); + + ReleasePixmap( local, pixmap ); + + glXWaitX(); + + glDeleteTextures( 1, &pixmap->buffer.texture ); + + XFreeGC( local->display, pixmap->gc ); + + glXDestroyPixmap( local->display, pixmap->drawable ); + + direct_hash_remove( local->pixmaps, pixmap->pixmap ); + + D_MAGIC_CLEAR( pixmap ); + D_MAGIC_CLEAR( &pixmap->buffer ); + + D_FREE( pixmap ); +} + +/**********************************************************************************************************************/ + +static int +glxPoolDataSize( void ) +{ + return sizeof(glxPoolData); +} + +static int +glxPoolLocalDataSize( void ) +{ + return sizeof(glxPoolLocalData); +} + +static int +glxAllocationDataSize( void ) +{ + return sizeof(glxAllocationData); +} + +static DFBResult +glxInitPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data, + CoreSurfacePoolDescription *ret_desc ) +{ + glxPoolLocalData *local = pool_local; + DFBX11 *x11 = system_data; + + D_DEBUG_AT( GLX_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_ASSERT( ret_desc != NULL ); + + ret_desc->caps = CSPCAPS_NONE; + ret_desc->access[CSAID_GPU] = CSAF_READ | CSAF_WRITE; + ret_desc->types = CSTF_LAYER | CSTF_WINDOW | CSTF_CURSOR | CSTF_FONT | CSTF_SHARED | CSTF_EXTERNAL; + ret_desc->priority = CSPP_DEFAULT; + + /* For showing our X11 window */ + ret_desc->access[CSAID_LAYER0] = CSAF_READ; + + /* For user contexts via DirectFBGL */ + ret_desc->access[CSAID_ACCEL1] = CSAF_READ | CSAF_WRITE; + + snprintf( ret_desc->name, DFB_SURFACE_POOL_DESC_NAME_LENGTH, "GLX Drawables" ); + + + return InitLocal( local, x11 ); +} + +static DFBResult +glxJoinPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data ) +{ + glxPoolLocalData *local = pool_local; + DFBX11 *x11 = system_data; + + D_DEBUG_AT( GLX_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + + + return InitLocal( local, x11 ); +} + +static DFBResult +glxDestroyPool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + D_DEBUG_AT( GLX_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + + return DFB_OK; +} + +static DFBResult +glxLeavePool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + D_DEBUG_AT( GLX_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + + return DFB_OK; +} + +static DFBResult +glxTestConfig( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + const CoreSurfaceConfig *config ) +{ + glxPoolLocalData *local = pool_local; + + D_MAGIC_ASSERT( local, glxPoolLocalData ); + + if (!local->configs) + return DFB_UNSUPPORTED; + + return DFB_OK; +} + +static DFBResult +glxAllocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + CoreSurface *surface; + glxPoolLocalData *local = pool_local; + glxAllocationData *alloc = alloc_data; + + D_DEBUG_AT( GLX_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( local, glxPoolLocalData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + XLockDisplay( local->display ); + + alloc->depth = DFB_COLOR_BITS_PER_PIXEL( buffer->format ) + DFB_ALPHA_BITS_PER_PIXEL( buffer->format ); + + /* + * Create a pixmap + */ + alloc->pixmap = XCreatePixmap( local->display, DefaultRootWindow( local->display ), + surface->config.size.w, surface->config.size.h, alloc->depth ); + if (!alloc->pixmap) { + D_ERROR( "GLX/Surfaces: Could not create %dx%d (depth %d) pixmap!\n", + surface->config.size.w, surface->config.size.h, alloc->depth ); + + XUnlockDisplay( local->display ); + + return DFB_FAILURE; + } + + D_DEBUG_AT( GLX_Surfaces, " -> pixmap 0x%lx\n", alloc->pixmap ); + + D_DEBUG_AT( GLX_Pixmaps, " NEW Pixmap 0x%lx [%4dx%4d] %-10s\n", alloc->pixmap, + surface->config.size.w, surface->config.size.h, dfb_pixelformat_name(buffer->format) ); + + XUnlockDisplay( local->display ); + + + /* Pseudo calculation */ + dfb_surface_calc_buffer_size( surface, 8, 2, NULL, &allocation->size ); + + D_MAGIC_SET( alloc, glxAllocationData ); + + return DFB_OK; +} + +static DFBResult +glxDeallocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + LocalPixmap *pixmap; + glxPoolLocalData *local = pool_local; + glxAllocationData *alloc = alloc_data; + + D_DEBUG_AT( GLX_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( local, glxPoolLocalData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + D_MAGIC_ASSERT( alloc, glxAllocationData ); + + CORE_SURFACE_ALLOCATION_ASSERT( allocation ); + + XLockDisplay( local->display ); + + pixmap = direct_hash_lookup( local->pixmaps, alloc->pixmap ); + if (pixmap) + DestroyPixmap( local, pixmap ); + + XFreePixmap( local->display, alloc->pixmap ); + + XUnlockDisplay( local->display ); + + D_MAGIC_CLEAR( alloc ); + + return DFB_OK; +} + +static DFBResult +glxLock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + DFBResult ret; + LocalPixmap *pixmap; + glxPoolLocalData *local = pool_local; + glxAllocationData *alloc = alloc_data; + + D_DEBUG_AT( GLX_Surfaces, "%s( %p )\n", __FUNCTION__, allocation ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( local, glxPoolLocalData ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, glxAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + ret = GetLocalPixmap( local, alloc, allocation, &pixmap ); + if (ret) + return ret; + + if (lock->accessor == CSAID_GPU || lock->accessor == CSAID_ACCEL1) { + ThreadContext *ctx; + + ctx = pthread_getspecific( (lock->accessor == CSAID_GPU) ? local->context_key : local->context_key2 ); + if (!ctx) { + ctx = D_CALLOC( 1, sizeof(ThreadContext) ); + if (!ctx) + return D_OOM(); + + ctx->display = local->display; + + XLockDisplay( local->display ); + + ctx->context = glXCreateNewContext( local->display, pixmap->config, GLX_RGBA_TYPE, NULL, GL_TRUE ); + if (!ctx->context) { + D_ERROR( "GLX: Could not create GLXContext!\n" ); + XUnlockDisplay( local->display ); + D_FREE( ctx ); + return DFB_FAILURE; + } + + XUnlockDisplay( local->display ); + + pthread_setspecific( (lock->accessor == CSAID_GPU) ? local->context_key : local->context_key2, ctx ); + + D_DEBUG_AT( GLX_Surfaces, " -> NEW CONTEXT %p\n", ctx->context ); + } + + if (lock->access & CSAF_WRITE) { + if (ctx->context != glXGetCurrentContext() || ctx->drawable != pixmap->drawable) { + D_DEBUG_AT( GLX_Surfaces, " -> MAKE CURRENT 0x%08lx <- 0x%08lx\n", pixmap->drawable, glXGetCurrentDrawable() ); + + if (ctx->drawable != pixmap->drawable) { + ctx->drawable = pixmap->drawable; + + pixmap->buffer.flags |= GLBF_UPDATE_TARGET; + } + + XLockDisplay( local->display ); + + glXMakeContextCurrent( local->display, pixmap->drawable, pixmap->drawable, ctx->context ); + pixmap->current = ctx->context; + + ReleasePixmap( local, pixmap ); + + XUnlockDisplay( local->display ); + } + } + else { + if (pixmap->bound != ctx->context) { + D_DEBUG_AT( GLX_Surfaces, " -> BIND TEXTURE 0x%08lx (%d)\n", pixmap->drawable, pixmap->buffer.texture ); + + XLockDisplay( local->display ); + + ReleasePixmap( local, pixmap ); + + glEnable( GL_TEXTURE_RECTANGLE_ARB ); + glBindTexture( GL_TEXTURE_RECTANGLE_ARB, pixmap->buffer.texture ); + + local->BindTexImageEXT( local->display, pixmap->drawable, GLX_FRONT_EXT, NULL ); + pixmap->bound = ctx->context; + + XUnlockDisplay( local->display ); + + pixmap->buffer.flags |= GLBF_UPDATE_TEXTURE; + } + } + + lock->handle = &pixmap->buffer; + } + else + lock->handle = pixmap; + + return DFB_OK; +} + +static DFBResult +glxUnlock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ +#if 0 + DFBResult ret; + LocalPixmap *pixmap; + glxPoolLocalData *local = pool_local; + glxAllocationData *alloc = alloc_data; + + D_DEBUG_AT( GLX_Surfaces, "%s( %p )\n", __FUNCTION__, allocation ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( local, glxPoolLocalData ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, glxAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + ret = GetLocalPixmap( local, alloc, allocation, &pixmap ); + if (ret) + return ret; + + if (lock->accessor == CSAID_GPU) { + XLockDisplay( local->display ); + + if (lock->access & CSAF_WRITE) { +// D_DEBUG_AT( GLX_Surfaces, " -> UNMAKE CURRENT 0x%08lx <- 0x%08lx\n", pixmap->drawable, glXGetCurrentDrawable() ); + +// glXMakeContextCurrent( local->display, None, None, NULL ); +// pixmap->current = NULL; + } + else { + D_DEBUG_AT( GLX_Surfaces, " -> UNBIND TEXTURE 0x%08lx (%d)\n", pixmap->drawable, pixmap->buffer.texture ); + + ReleasePixmap( local, pixmap ); + } + + XUnlockDisplay( local->display ); + } + +#endif + return DFB_OK; +} + +static DFBResult +glxRead( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + void *destination, + int pitch, + const DFBRectangle *rect ) +{ + XImage *image; + XImage *sub; + glxPoolLocalData *local = pool_local; + glxAllocationData *alloc = alloc_data; + + D_DEBUG_AT( GLX_Surfaces, "%s( %p )\n", __FUNCTION__, allocation ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( local, glxPoolLocalData ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, glxAllocationData ); + D_ASSERT( destination != NULL ); + D_ASSERT( pitch >= 0 ); + DFB_RECTANGLE_ASSERT( rect ); + + D_DEBUG_AT( GLX_Surfaces, " => %p 0x%08lx [%4d,%4d-%4dx%4d]\n", alloc, alloc->pixmap, DFB_RECTANGLE_VALS(rect) ); + + XLockDisplay( local->display ); + + image = XCreateImage( local->display, (alloc->depth == 24) ? local->visual24 : local->visual32, + alloc->depth, ZPixmap, 0, destination, rect->w, rect->h, 32, pitch ); + if (!image) { + D_ERROR( "GLX/Surfaces: XCreateImage( %dx%d, depth %d ) failed!\n", rect->w, rect->h, alloc->depth ); + XUnlockDisplay( local->display ); + return DFB_FAILURE; + } + + glXWaitGL(); + + sub = XGetSubImage( local->display, alloc->pixmap, rect->x, rect->y, rect->w, rect->h, ~0, ZPixmap, image, 0, 0 ); + + glXWaitX(); + + /* FIXME: Why the X-hell is XDestroyImage() freeing *MY* data? */ + image->data = NULL; + XDestroyImage( image ); + + XUnlockDisplay( local->display ); + + if (!sub) { + D_ERROR( "GLX/Surfaces: XGetSubImage( %d,%d-%dx%d ) failed!\n", DFB_RECTANGLE_VALS(rect) ); + return DFB_FAILURE; + } + + return DFB_OK; +} + +static DFBResult +glxWrite( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + const void *source, + int pitch, + const DFBRectangle *rect ) +{ + DFBResult ret; + LocalPixmap *pixmap; + CoreSurface *surface; + XImage *image; + glxPoolLocalData *local = pool_local; + glxAllocationData *alloc = alloc_data; + + D_DEBUG_AT( GLX_Surfaces, "%s( %p )\n", __FUNCTION__, allocation ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( local, glxPoolLocalData ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, glxAllocationData ); + D_ASSERT( source != NULL ); + D_ASSERT( pitch >= 0 ); + DFB_RECTANGLE_ASSERT( rect ); + + D_DEBUG_AT( GLX_Surfaces, " <= %p 0x%08lx [%4d,%4d-%4dx%4d]\n", alloc, alloc->pixmap, DFB_RECTANGLE_VALS(rect) ); + + surface = allocation->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + ret = GetLocalPixmap( local, alloc, allocation, &pixmap ); + if (ret) + return ret; + + XLockDisplay( local->display ); + + image = XCreateImage( local->display, (alloc->depth == 24) ? local->visual24 : local->visual32, + alloc->depth, ZPixmap, 0, (void*) source, rect->w, rect->h, 32, pitch ); + if (!image) { + D_ERROR( "GLX/Surfaces: XCreateImage( %dx%d, depth %d ) failed!\n", rect->w, rect->h, alloc->depth ); + XUnlockDisplay( local->display ); + return DFB_FAILURE; + } + + glXWaitGL(); + + XPutImage( local->display, alloc->pixmap, pixmap->gc, image, 0, 0, rect->x, rect->y, rect->w, rect->h ); + + glXWaitX(); + + /* FIXME: Why the X-hell is XDestroyImage() freeing *MY* data? */ + image->data = NULL; + XDestroyImage( image ); + + XUnlockDisplay( local->display ); + + return DFB_OK; +} + +const SurfacePoolFuncs glxSurfacePoolFuncs = { + .PoolDataSize = glxPoolDataSize, + .PoolLocalDataSize = glxPoolLocalDataSize, + .AllocationDataSize = glxAllocationDataSize, + + .InitPool = glxInitPool, + .JoinPool = glxJoinPool, + .DestroyPool = glxDestroyPool, + .LeavePool = glxLeavePool, + + .TestConfig = glxTestConfig, + + .AllocateBuffer = glxAllocateBuffer, + .DeallocateBuffer = glxDeallocateBuffer, + + .Lock = glxLock, + .Unlock = glxUnlock, + + .Read = glxRead, + .Write = glxWrite, +}; + diff --git a/Source/DirectFB/systems/x11/glx_surface_pool.h b/Source/DirectFB/systems/x11/glx_surface_pool.h new file mode 100755 index 0000000..d244526 --- /dev/null +++ b/Source/DirectFB/systems/x11/glx_surface_pool.h @@ -0,0 +1,79 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __X11SYSTEM__GLX_SURFACE_POOL_H__ +#define __X11SYSTEM__GLX_SURFACE_POOL_H__ + + +#include + +#include + +#include + +extern const SurfacePoolFuncs glxSurfacePoolFuncs; + + +typedef struct { + int magic; + + /* Shared resource */ + Pixmap pixmap; + int depth; +} glxAllocationData; + +typedef struct { + int magic; + + GLBufferData buffer; + + /* Shared resource */ + Pixmap pixmap; + + /* Process local data */ + GC gc; + + GLXFBConfig config; + GLXDrawable drawable; + + /* Bound to a thread's context? */ + GLXContext current; + GLXContext bound; +} LocalPixmap; + +typedef struct { + Display *display; + + /* Thread local data */ + GLXContext context; + + GLXDrawable drawable; +} ThreadContext; + +#endif + diff --git a/Source/DirectFB/systems/x11/primary.c b/Source/DirectFB/systems/x11/primary.c new file mode 100755 index 0000000..2e12d8a --- /dev/null +++ b/Source/DirectFB/systems/x11/primary.c @@ -0,0 +1,664 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include + +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +#include +#include + +#ifdef USE_GLX +#include +#include "glx_surface_pool.h" +#endif + +#include "xwindow.h" +#include "x11.h" +#include "primary.h" + + +D_DEBUG_DOMAIN( X11_Layer, "X11/Layer", "X11 Layer" ); +D_DEBUG_DOMAIN( X11_Update, "X11/Update", "X11 Update" ); + +/**********************************************************************************************************************/ + +static DFBResult +dfb_x11_create_window( DFBX11 *x11, const CoreLayerRegionConfig *config ) +{ + int ret; + DFBX11Shared *shared = x11->shared; + + D_ASSERT( config != NULL ); + + shared->setmode.config = *config; + + if (fusion_call_execute( &shared->call, FCEF_NONE, X11_CREATE_WINDOW, &shared->setmode, &ret )) + return DFB_FUSION; + + return ret; +} + +static DFBResult +dfb_x11_destroy_window( DFBX11 *x11 ) +{ + int ret; + DFBX11Shared *shared = x11->shared; + + if (fusion_call_execute( &shared->call, FCEF_NONE, X11_DESTROY_WINDOW, NULL, &ret )) + return DFB_FUSION; + + return ret; +} + +static DFBResult +dfb_x11_update_screen( DFBX11 *x11, const DFBRegion *region, CoreSurfaceBufferLock *lock ) +{ + int ret; + DFBX11Shared *shared = x11->shared; + + DFB_REGION_ASSERT( region ); + D_ASSERT( lock != NULL ); + + /* FIXME: Just a hot fix! */ + while (shared->update.lock) + usleep( 10000 ); + + shared->update.region = *region; + shared->update.lock = lock; + + if (fusion_call_execute( &shared->call, FCEF_NODIRECT, X11_UPDATE_SCREEN, &shared->update, &ret )) + return DFB_FUSION; + + return ret; +} + +static DFBResult +dfb_x11_set_palette( DFBX11 *x11, CorePalette *palette ) +{ + int ret; + DFBX11Shared *shared = x11->shared; + + D_ASSERT( palette != NULL ); + + if (fusion_call_execute( &shared->call, FCEF_NONE, X11_SET_PALETTE, palette, &ret )) + return DFB_FUSION; + + return ret; +} + +/**********************************************************************************************************************/ + +static DFBResult +primaryInitScreen( CoreScreen *screen, + CoreGraphicsDevice *device, + void *driver_data, + void *screen_data, + DFBScreenDescription *description ) +{ + D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); + + /* Set the screen capabilities. */ + description->caps = DSCCAPS_NONE; + + /* Set the screen name. */ + snprintf( description->name, + DFB_SCREEN_DESC_NAME_LENGTH, "X11 Primary Screen" ); + + return DFB_OK; +} + +static DFBResult +primaryGetScreenSize( CoreScreen *screen, + void *driver_data, + void *screen_data, + int *ret_width, + int *ret_height ) +{ + DFBX11 *x11 = driver_data; + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); + + *ret_width = shared->screen_size.w; + *ret_height = shared->screen_size.h; + + return DFB_OK; +} + +ScreenFuncs x11PrimaryScreenFuncs = { + .InitScreen = primaryInitScreen, + .GetScreenSize = primaryGetScreenSize, +}; + +/******************************************************************************/ + +static int +primaryLayerDataSize( void ) +{ + return 0; +} + +static int +primaryRegionDataSize( void ) +{ + return 0; +} + +static DFBResult +primaryInitLayer( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *config, + DFBColorAdjustment *adjustment ) +{ + DFBX11 *x11 = driver_data; + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); + + /* 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 = shared->screen_size.w; + + if (dfb_config->mode.height) + config->height = dfb_config->mode.height; + else + config->height = shared->screen_size.h; + + 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 { + int depth = DefaultDepthOfScreen( x11->screenptr ); + + switch (depth) { + case 15: + config->pixelformat = DSPF_RGB555; + break; + case 16: + config->pixelformat = DSPF_RGB16; + break; + case 24: + config->pixelformat = DSPF_RGB32; + break; + case 32: + config->pixelformat = DSPF_ARGB; + break; + default: + printf(" Unsupported X11 screen depth %d \n",depth); + return DFB_UNSUPPORTED; + } + } + + return DFB_OK; +} + +static DFBResult +primaryTestRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags *failed ) +{ + CoreLayerRegionConfigFlags fail = 0; + + D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); + + switch (config->buffermode) { + case DLBM_FRONTONLY: + case DLBM_BACKSYSTEM: + case DLBM_BACKVIDEO: + case DLBM_TRIPLE: + break; + + default: + fail |= CLRCF_BUFFERMODE; + break; + } + + switch (config->format) { + case DSPF_RGB16: + case DSPF_NV16: + case DSPF_RGB444: + case DSPF_ARGB4444: + case DSPF_RGBA4444: + case DSPF_RGB555: + case DSPF_ARGB1555: + case DSPF_BGR555: + case DSPF_RGB24: + case DSPF_RGB32: + case DSPF_ARGB: + case DSPF_AYUV: + break; + + default: + fail |= CLRCF_FORMAT; + 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 ) +{ + DFBResult ret; + DFBX11 *x11 = driver_data; + + D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); + + ret = dfb_x11_create_window( x11, config ); + if (ret) + return ret; + + if (palette) + dfb_x11_set_palette( x11, palette ); + + return DFB_OK; +} + +static DFBResult +primaryRemoveRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data ) +{ + DFBX11 *x11 = driver_data; + + D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); + + dfb_x11_destroy_window( x11 ); + + return DFB_OK; +} + +static DFBResult +primaryFlipRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + DFBSurfaceFlipFlags flags, + CoreSurfaceBufferLock *lock ) +{ + DFBX11 *x11 = driver_data; + DFBRegion region = DFB_REGION_INIT_FROM_DIMENSION( &surface->config.size ); + + D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); + + dfb_surface_flip( surface, false ); + + return dfb_x11_update_screen( x11, ®ion, lock ); +} + +static DFBResult +primaryUpdateRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + const DFBRegion *update, + CoreSurfaceBufferLock *lock ) +{ + DFBX11 *x11 = driver_data; + DFBRegion region = DFB_REGION_INIT_FROM_DIMENSION( &surface->config.size ); + + D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); + + if (update && !dfb_region_region_intersect( ®ion, update )) + return DFB_OK; + + return dfb_x11_update_screen( x11, ®ion, lock ); +} + +DisplayLayerFuncs x11PrimaryLayerFuncs = { + .LayerDataSize = primaryLayerDataSize, + .RegionDataSize = primaryRegionDataSize, + .InitLayer = primaryInitLayer, + + .TestRegion = primaryTestRegion, + .AddRegion = primaryAddRegion, + .SetRegion = primarySetRegion, + .RemoveRegion = primaryRemoveRegion, + .FlipRegion = primaryFlipRegion, + .UpdateRegion = primaryUpdateRegion, +}; + +/******************************************************************************/ + +static DFBResult +update_screen( DFBX11 *x11, const DFBRectangle *clip, CoreSurfaceBufferLock *lock ) +{ + void *dst; + void *src; + unsigned int offset = 0; + XWindow *xw; + XImage *ximage; + CoreSurface *surface; + CoreSurfaceAllocation *allocation; + DFBX11Shared *shared; + DFBRectangle rect; + bool direct = false; + + D_ASSERT( x11 != NULL ); + DFB_RECTANGLE_ASSERT( clip ); + + D_DEBUG_AT( X11_Update, "%s( %4d,%4d-%4dx%4d )\n", __FUNCTION__, DFB_RECTANGLE_VALS( clip ) ); + + CORE_SURFACE_BUFFER_LOCK_ASSERT( lock ); + + shared = x11->shared; + D_ASSERT( shared != NULL ); + + XLockDisplay( x11->display ); + + xw = shared->xw; + if (!xw) { + XUnlockDisplay( x11->display ); + return DFB_OK; + } + + allocation = lock->allocation; + CORE_SURFACE_ALLOCATION_ASSERT( allocation ); + + surface = allocation->surface; + D_ASSERT( surface != NULL ); + + + rect.x = rect.y = 0; + rect.w = xw->width; + rect.h = xw->height; + + if (!dfb_rectangle_intersect( &rect, clip )) { + XUnlockDisplay( x11->display ); + return DFB_OK; + } + + D_DEBUG_AT( X11_Update, " -> %4d,%4d-%4dx%4d\n", DFB_RECTANGLE_VALS( &rect ) ); + +#ifdef USE_GLX + /* Check for GLX allocation... */ + if (allocation->pool == shared->glx_pool && lock->handle) { + LocalPixmap *pixmap = lock->handle; + + D_MAGIC_ASSERT( pixmap, LocalPixmap ); + + /* ...and just call SwapBuffers... */ + //D_DEBUG_AT( X11_Update, " -> Calling glXSwapBuffers( 0x%lx )...\n", alloc->drawable ); + //glXSwapBuffers( x11->display, alloc->drawable ); + + + D_DEBUG_AT( X11_Update, " -> Copying from GLXPixmap...\n" ); + + glXWaitGL(); + + XCopyArea( x11->display, pixmap->pixmap, xw->window, xw->gc, + rect.x, rect.y, rect.w, rect.h, rect.x, rect.y ); + + glXWaitX(); + + XUnlockDisplay( x11->display ); + + return DFB_OK; + } +#endif + + /* Check for our special native allocation... */ + if (allocation->pool == shared->x11image_pool && lock->handle) { + x11Image *image = lock->handle; + + D_MAGIC_ASSERT( image, x11Image ); + + /* ...and directly XShmPutImage from that. */ + ximage = image->ximage; + + direct = true; + } + else { + /* ...or copy or convert into XShmImage or XImage allocated with the XWindow. */ + ximage = xw->ximage; + offset = xw->ximage_offset; + + xw->ximage_offset = (offset ? 0 : ximage->height / 2); + + dst = xw->virtualscreen + rect.x * xw->bpp + (rect.y + offset) * ximage->bytes_per_line; + src = lock->addr + DFB_BYTES_PER_LINE( surface->config.format, rect.x ) + rect.y * lock->pitch; + + switch (xw->depth) { + case 32: + dfb_convert_to_argb( surface->config.format, src, lock->pitch, + surface->config.size.h, dst, ximage->bytes_per_line, rect.w, rect.h ); + break; + + case 24: + dfb_convert_to_rgb32( surface->config.format, src, lock->pitch, + surface->config.size.h, dst, ximage->bytes_per_line, rect.w, rect.h ); + break; + + case 16: + dfb_convert_to_rgb16( surface->config.format, src, lock->pitch, + surface->config.size.h, dst, ximage->bytes_per_line, rect.w, rect.h ); + break; + + case 15: + dfb_convert_to_rgb555( surface->config.format, src, lock->pitch, + surface->config.size.h, dst, ximage->bytes_per_line, rect.w, rect.h ); + break; + + default: + D_ONCE( "unsupported depth %d", xw->depth ); + } + } + + D_ASSERT( ximage != NULL ); + + + /* Wait for previous data to be processed... */ + XSync( x11->display, False ); + + /* ...and immediately queue or send the next! */ + if (x11->use_shm) { + /* Just queue the command, it's XShm :) */ + XShmPutImage( xw->display, xw->window, xw->gc, ximage, + rect.x, rect.y + offset, rect.x, rect.y, rect.w, rect.h, False ); + + /* Make sure the queue has really happened! */ + XFlush( x11->display ); + } + else + /* Initiate transfer of buffer... */ + XPutImage( xw->display, xw->window, xw->gc, ximage, + rect.x, rect.y + offset, rect.x, rect.y, rect.w, rect.h ); + + /* Wait for display if single buffered and not converted... */ + if (direct && !(surface->config.caps & DSCAPS_FLIPPING)) + XSync( x11->display, False ); + + XUnlockDisplay( x11->display ); + + return DFB_OK; +} + +/******************************************************************************/ + +DFBResult +dfb_x11_create_window_handler( DFBX11 *x11, CoreLayerRegionConfig *config ) +{ + XWindow *xw; + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Layer, "%s( %p )\n", __FUNCTION__, config ); + + D_DEBUG_AT( X11_Layer, " -> %4dx%4d %s\n", config->width, config->height, dfb_pixelformat_name(config->format) ); + + XLockDisplay( x11->display ); + + xw = shared->xw; + if (xw != NULL) { + if (xw->width == config->width && xw->height == config->height) { + XUnlockDisplay( x11->display ); + return DFB_OK; + } + + shared->xw = NULL; + dfb_x11_close_window( x11, xw ); + } + + bool bSucces = dfb_x11_open_window( x11, &xw, 0, 0, config->width, config->height, config->format ); + + /* Set video mode */ + if ( !bSucces ) { + D_ERROR( "DirectFB/X11: Couldn't open %dx%d window!\n", config->width, config->height ); + + XUnlockDisplay( x11->display ); + return DFB_FAILURE; + } + else + shared->xw = xw; + + XUnlockDisplay( x11->display ); + return DFB_OK; +} + +DFBResult +dfb_x11_destroy_window_handler( DFBX11 *x11 ) +{ + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Layer, "%s()\n", __FUNCTION__ ); + + XLockDisplay( x11->display ); + + if (shared->xw) { + XWindow *xw = shared->xw; + + shared->xw = NULL; + + dfb_x11_close_window( x11, xw ); + } + + XSync( x11->display, False ); + + XUnlockDisplay( x11->display ); + + return DFB_OK; +} + +DFBResult +dfb_x11_update_screen_handler( DFBX11 *x11, UpdateScreenData *data ) +{ + DFBRectangle rect; + + D_DEBUG_AT( X11_Update, "%s( %p )\n", __FUNCTION__, data ); + + rect = DFB_RECTANGLE_INIT_FROM_REGION( &data->region ); + + if (data->lock) + update_screen( x11, &rect, data->lock ); + + data->lock = NULL; + + return DFB_OK; +} + +DFBResult +dfb_x11_set_palette_handler( DFBX11 *x11, CorePalette *palette ) +{ + return DFB_OK; +} + diff --git a/Source/DirectFB/systems/x11/primary.h b/Source/DirectFB/systems/x11/primary.h new file mode 100755 index 0000000..a145d83 --- /dev/null +++ b/Source/DirectFB/systems/x11/primary.h @@ -0,0 +1,39 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __X11__PRIMARY_H__ +#define __X11__PRIMARY_H__ + +#include +#include + +extern ScreenFuncs x11PrimaryScreenFuncs; +extern DisplayLayerFuncs x11PrimaryLayerFuncs; + +#endif // __X11__PRIMARY_H__ + diff --git a/Source/DirectFB/systems/x11/surfacemanager.c b/Source/DirectFB/systems/x11/surfacemanager.c new file mode 100755 index 0000000..e9f697a --- /dev/null +++ b/Source/DirectFB/systems/x11/surfacemanager.c @@ -0,0 +1,559 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#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 ); + + 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 ); + + 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/x11/surfacemanager.h b/Source/DirectFB/systems/x11/surfacemanager.h new file mode 100755 index 0000000..e6136c5 --- /dev/null +++ b/Source/DirectFB/systems/x11/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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +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 + diff --git a/Source/DirectFB/systems/x11/vpsmem_surface_pool.c b/Source/DirectFB/systems/x11/vpsmem_surface_pool.c new file mode 100755 index 0000000..0cf505d --- /dev/null +++ b/Source/DirectFB/systems/x11/vpsmem_surface_pool.c @@ -0,0 +1,421 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include + +#include + +#include +#include + +#include + +#include + +#include "x11.h" +#include "surfacemanager.h" + +D_DEBUG_DOMAIN( VPSMem_Surfaces, "VPSMem/Surfaces", "VPSMem Framebuffer Surface Pool" ); +D_DEBUG_DOMAIN( VPSMem_SurfLock, "VPSMem/SurfLock", "VPSMem Framebuffer Surface Pool Locks" ); + +/**********************************************************************************************************************/ + +typedef struct { + int magic; + + SurfaceManager *manager; + + void *mem; + unsigned int length; +} VPSMemPoolData; + +typedef struct { + int magic; + + CoreDFB *core; +} VPSMemPoolLocalData; + +typedef struct { + int magic; + + int offset; + int pitch; + int size; + + Chunk *chunk; +} VPSMemAllocationData; + +/**********************************************************************************************************************/ + +static int +vpsmemPoolDataSize( void ) +{ + return sizeof(VPSMemPoolData); +} + +static int +vpsmemPoolLocalDataSize( void ) +{ + return sizeof(VPSMemPoolLocalData); +} + +static int +vpsmemAllocationDataSize( void ) +{ + return sizeof(VPSMemAllocationData); +} + +static DFBResult +vpsmemInitPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data, + CoreSurfacePoolDescription *ret_desc ) +{ + DFBResult ret; + VPSMemPoolData *data = pool_data; + VPSMemPoolLocalData *local = pool_local; + DFBX11 *x11 = system_data; + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( VPSMem_Surfaces, "%s()\n", __FUNCTION__ ); + + D_ASSERT( core != NULL ); + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_ASSERT( data != NULL ); + D_ASSERT( local != NULL ); + D_ASSERT( ret_desc != NULL ); + + data->mem = SHMALLOC( shared->data_shmpool, shared->vpsmem_length ); + if (!data->mem) { + shared->vpsmem_length = 0; + return D_OOSHM(); + } + + data->length = shared->vpsmem_length; + + ret = dfb_surfacemanager_create( core, data->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->types = CSTF_LAYER | CSTF_WINDOW | CSTF_CURSOR | CSTF_FONT | CSTF_SHARED | CSTF_EXTERNAL; + ret_desc->priority = CSPP_DEFAULT; + ret_desc->size = data->length; + + /* For testing... */ + ret_desc->access[CSAID_ACCEL1] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + ret_desc->access[CSAID_ACCEL2] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + ret_desc->access[CSAID_ACCEL3] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + ret_desc->access[CSAID_ACCEL4] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + + snprintf( ret_desc->name, DFB_SURFACE_POOL_DESC_NAME_LENGTH, "Virtual Physical" ); + + local->core = core; + + D_MAGIC_SET( data, VPSMemPoolData ); + D_MAGIC_SET( local, VPSMemPoolLocalData ); + + return DFB_OK; +} + +static DFBResult +vpsmemJoinPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data ) +{ + VPSMemPoolData *data = pool_data; + VPSMemPoolLocalData *local = pool_local; + + D_DEBUG_AT( VPSMem_Surfaces, "%s()\n", __FUNCTION__ ); + + D_ASSERT( core != NULL ); + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VPSMemPoolData ); + D_ASSERT( local != NULL ); + + (void) data; + + local->core = core; + + D_MAGIC_SET( local, VPSMemPoolLocalData ); + + return DFB_OK; +} + +static DFBResult +vpsmemDestroyPool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + VPSMemPoolData *data = pool_data; + VPSMemPoolLocalData *local = pool_local; + + D_DEBUG_AT( VPSMem_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VPSMemPoolData ); + D_MAGIC_ASSERT( local, VPSMemPoolLocalData ); + + dfb_surfacemanager_destroy( data->manager ); + + D_MAGIC_CLEAR( data ); + D_MAGIC_CLEAR( local ); + + return DFB_OK; +} + +static DFBResult +vpsmemLeavePool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + VPSMemPoolData *data = pool_data; + VPSMemPoolLocalData *local = pool_local; + + D_DEBUG_AT( VPSMem_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VPSMemPoolData ); + D_MAGIC_ASSERT( local, VPSMemPoolLocalData ); + + (void) data; + + D_MAGIC_CLEAR( local ); + + return DFB_OK; +} + +static DFBResult +vpsmemTestConfig( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + const CoreSurfaceConfig *config ) +{ + DFBResult ret; + CoreSurface *surface; + VPSMemPoolData *data = pool_data; + VPSMemPoolLocalData *local = pool_local; + + D_DEBUG_AT( VPSMem_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VPSMemPoolData ); + D_MAGIC_ASSERT( local, VPSMemPoolLocalData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + ret = dfb_surfacemanager_allocate( local->core, data->manager, buffer, NULL, NULL ); + + D_DEBUG_AT( VPSMem_Surfaces, " -> %s\n", DirectFBErrorString(ret) ); + + return ret; +} + +static DFBResult +vpsmemAllocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + DFBResult ret; + Chunk *chunk; + CoreSurface *surface; + VPSMemPoolData *data = pool_data; + VPSMemPoolLocalData *local = pool_local; + VPSMemAllocationData *alloc = alloc_data; + + D_DEBUG_AT( VPSMem_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VPSMemPoolData ); + D_MAGIC_ASSERT( local, VPSMemPoolLocalData ); + 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 = surface->config.size.h * alloc->pitch; + + alloc->chunk = chunk; + + D_DEBUG_AT( VPSMem_Surfaces, " -> offset %d, pitch %d, size %d (%d)\n", + alloc->offset, alloc->pitch, alloc->size, chunk->length ); + + D_ASSERT( chunk->length >= alloc->size ); + + alloc->size = chunk->length; + + allocation->size = alloc->size; + allocation->offset = alloc->offset; + + D_MAGIC_SET( alloc, VPSMemAllocationData ); + + return DFB_OK; +} + +static DFBResult +vpsmemDeallocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + VPSMemPoolData *data = pool_data; + VPSMemAllocationData *alloc = alloc_data; + + D_DEBUG_AT( VPSMem_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VPSMemPoolData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + D_MAGIC_ASSERT( alloc, VPSMemAllocationData ); + + dfb_surfacemanager_deallocate( data->manager, alloc->chunk ); + + D_MAGIC_CLEAR( alloc ); + + return DFB_OK; +} + +static DFBResult +vpsmemMuckOut( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer ) +{ + CoreSurface *surface; + VPSMemPoolData *data = pool_data; + VPSMemPoolLocalData *local = pool_local; + + D_DEBUG_AT( VPSMem_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VPSMemPoolData ); + D_MAGIC_ASSERT( local, VPSMemPoolLocalData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + return dfb_surfacemanager_displace( local->core, data->manager, buffer ); +} + +static DFBResult +vpsmemLock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + VPSMemPoolData *data = pool_data; + VPSMemAllocationData *alloc = alloc_data; + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VPSMemPoolData ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, VPSMemAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + D_DEBUG_AT( VPSMem_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer ); + + lock->pitch = alloc->pitch; + lock->offset = alloc->offset; + lock->addr = data->mem + alloc->offset; + lock->phys = dfb_config->video_phys + alloc->offset; + + D_DEBUG_AT( VPSMem_SurfLock, " -> offset %lu, pitch %d, addr %p, phys 0x%08lx\n", + lock->offset, lock->pitch, lock->addr, lock->phys ); + + return DFB_OK; +} + +static DFBResult +vpsmemUnlock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + VPSMemAllocationData *alloc = alloc_data; + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, VPSMemAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + D_DEBUG_AT( VPSMem_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer ); + + (void) alloc; + + return DFB_OK; +} + +const SurfacePoolFuncs vpsmemSurfacePoolFuncs = { + .PoolDataSize = vpsmemPoolDataSize, + .PoolLocalDataSize = vpsmemPoolLocalDataSize, + .AllocationDataSize = vpsmemAllocationDataSize, + + .InitPool = vpsmemInitPool, + .JoinPool = vpsmemJoinPool, + .DestroyPool = vpsmemDestroyPool, + .LeavePool = vpsmemLeavePool, + + .TestConfig = vpsmemTestConfig, + .AllocateBuffer = vpsmemAllocateBuffer, + .DeallocateBuffer = vpsmemDeallocateBuffer, + + .MuckOut = vpsmemMuckOut, + + .Lock = vpsmemLock, + .Unlock = vpsmemUnlock, +}; + diff --git a/Source/DirectFB/systems/x11/vpsmem_surface_pool.h b/Source/DirectFB/systems/x11/vpsmem_surface_pool.h new file mode 100755 index 0000000..915469b --- /dev/null +++ b/Source/DirectFB/systems/x11/vpsmem_surface_pool.h @@ -0,0 +1,37 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __X11SYSTEM__VPSMEM_SURFACE_POOL_H__ +#define __X11SYSTEM__VPSMEM_SURFACE_POOL_H__ + +#include + +extern const SurfacePoolFuncs vpsmemSurfacePoolFuncs; + +#endif + diff --git a/Source/DirectFB/systems/x11/x11.c b/Source/DirectFB/systems/x11/x11.c new file mode 100755 index 0000000..62d329c --- /dev/null +++ b/Source/DirectFB/systems/x11/x11.c @@ -0,0 +1,570 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + + +#include "primary.h" +#include "xwindow.h" +#include "x11.h" +#include "x11_surface_pool.h" +#include "x11_surface_pool_bridge.h" + +#ifdef USE_GLX +#include "glx_surface_pool.h" +#endif + +#include "vpsmem_surface_pool.h" + +#include + +D_DEBUG_DOMAIN( X11_Core, "X11/Core", "Main X11 system functions" ); + +DFB_CORE_SYSTEM( x11 ) + + +static VideoMode modes[] = { + { .xres = 320, .yres = 200 }, + { .xres = 320, .yres = 240 }, + { .xres = 512, .yres = 384 }, + { .xres = 640, .yres = 480 }, + { .xres = 768, .yres = 576 }, + + { .xres = 1024, .yres = 576 }, // 16:9 + { .xres = 1024, .yres = 600 }, // Where does that mode come from? :-) + { .xres = 1024, .yres = 768 }, // 4:3 + + { .xres = 1280, .yres = 720 }, // 16:9 + { .xres = 1280, .yres = 960 }, // 4:3 + { .xres = 1280, .yres = 1024 }, // 5:4 + + { .xres = 1440, .yres = 810 }, // 16:9 + { .xres = 1440, .yres = 1080 }, // 4:3 + + { .xres = 1600, .yres = 900 }, // 16:9, obviously :) + { .xres = 1600, .yres = 1200 }, // 4:3 + + { .xres = 1920, .yres = 1080 }, // 16:9 + { .xres = 1920, .yres = 1200 }, // 16:10 + + { .xres = 0, .yres = 0 } +}; + +/**********************************************************************************************************************/ + +static FusionCallHandlerResult call_handler( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ); + +/**********************************************************************************************************************/ + +static DFBResult +InitLocal( DFBX11 *x11, DFBX11Shared *shared, CoreDFB *core ) +{ + int i, n; + + XInitThreads(); + + x11->shared = shared; + x11->core = core; + + x11->display = XOpenDisplay(getenv("DISPLAY")); + if (!x11->display) { + D_ERROR("X11: Error in XOpenDisplay for '%s'\n", getenv("DISPLAY")); + return DFB_INIT; + } + + x11->screenptr = DefaultScreenOfDisplay(x11->display); + x11->screennum = DefaultScreen(x11->display); + + for (i=0; iscreenptr->ndepths; i++) { + const Depth *depth = &x11->screenptr->depths[i]; + + for (n=0; nnvisuals; n++) { + Visual *visual = &depth->visuals[n]; + + D_DEBUG_AT( X11_Core, "[Visual %d] ID 0x%02lx, depth %d, RGB 0x%06lx/0x%06lx/0x%06lx, %d bpRGB, %d entr.\n", + n, visual->visualid, depth->depth, + visual->red_mask, visual->green_mask, visual->blue_mask, + visual->bits_per_rgb, visual->map_entries ); + + switch (depth->depth) { + case 32: + if (visual->red_mask == 0xff0000 && + visual->green_mask == 0x00ff00 && + visual->blue_mask == 0x0000ff && + !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)]) + x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_ARGB)] = visual; + break; + + case 24: + if (visual->red_mask == 0xff0000 && + visual->green_mask == 0x00ff00 && + visual->blue_mask == 0x0000ff && + !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)]) + x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB32)] = visual; + break; + + case 16: + if (visual->red_mask == 0xf800 && + visual->green_mask == 0x07e0 && + visual->blue_mask == 0x001f && + !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)]) + x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB16)] = visual; + break; + + case 15: + if (visual->red_mask == 0x7c00 && + visual->green_mask == 0x03e0 && + visual->blue_mask == 0x001f && + !x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB555)]) + x11->visuals[DFB_PIXELFORMAT_INDEX(DSPF_RGB555)] = visual; + break; + } + } + } + + if (XShmQueryExtension( x11->display )) + XShmQueryVersion( x11->display, &x11->xshm_major, &x11->xshm_minor, &x11->use_shm ); + + + x11->screen = dfb_screens_register( NULL, x11, &x11PrimaryScreenFuncs ); + + dfb_layers_register( x11->screen, x11, &x11PrimaryLayerFuncs ); + + return DFB_OK; +} + +/**********************************************************************************************************************/ + +static void +system_get_info( CoreSystemInfo *info ) +{ + info->type = CORE_X11; + info->caps = CSCAPS_ACCELERATION; + + D_DEBUG_AT( X11_Core, "%s()\n", __FUNCTION__ ); + + snprintf( info->name, DFB_CORE_SYSTEM_INFO_NAME_LENGTH, "X11" ); +} + +DFBX11 *dfb_x11 = NULL; + +static DFBResult +system_initialize( CoreDFB *core, void **data ) +{ + DFBResult ret; + DFBX11 *x11; + DFBX11Shared *shared; + + D_DEBUG_AT( X11_Core, "%s()\n", __FUNCTION__ ); + + x11 = D_CALLOC( 1, sizeof(DFBX11) ); + if (!x11) + return D_OOM(); + + shared = SHCALLOC( dfb_core_shmpool( core ), 1, sizeof(DFBX11Shared) ); + if (!shared) { + D_FREE( x11 ); + return D_OOSHM(); + } + + + /* + * Local init (master and slave) + */ + ret = InitLocal( x11, shared, core ); + if (ret) { + SHFREE( dfb_core_shmpool( core ), shared ); + D_FREE( x11 ); + return ret; + } + + + /* + * Shared init (master only) + */ + shared->data_shmpool = dfb_core_shmpool_data( core ); + + shared->screen_size.w = x11->screenptr->width; + shared->screen_size.h = x11->screenptr->height; + + fusion_skirmish_init( &shared->lock, "X11 System", dfb_core_world(core) ); + + fusion_call_init( &shared->call, call_handler, x11, dfb_core_world(core) ); + + + /* + * Must be set before initializing the pools! + */ + *data = x11; + + dfb_x11 = x11; + + /* + * Master init + */ + dfb_surface_pool_initialize( core, &x11SurfacePoolFuncs, &shared->x11image_pool ); + +#ifdef USE_GLX + dfb_surface_pool_initialize( core, &glxSurfacePoolFuncs, &shared->glx_pool ); +#endif + + if (dfb_config->video_length) { + shared->vpsmem_length = dfb_config->video_length; + + dfb_surface_pool_initialize( core, &vpsmemSurfacePoolFuncs, &shared->vpsmem_pool ); + } + +#ifdef USE_GLX + dfb_surface_pool_bridge_initialize( core, &x11SurfacePoolBridgeFuncs, x11, &shared->x11_pool_bridge ); +#endif + + fusion_arena_add_shared_field( dfb_core_arena( core ), "x11", shared ); + + return DFB_OK; +} + +static DFBResult +system_join( CoreDFB *core, void **data ) +{ + DFBResult ret; + void *ptr; + DFBX11 *x11; + DFBX11Shared *shared; + + D_DEBUG_AT( X11_Core, "%s()\n", __FUNCTION__ ); + + x11 = D_CALLOC( 1, sizeof(DFBX11) ); + if (!x11) + return D_OOM(); + + fusion_arena_get_shared_field( dfb_core_arena( core ), "x11", &ptr ); + shared = ptr; + + + /* + * Local init (master and slave) + */ + ret = InitLocal( x11, shared, core ); + if (ret) { + D_FREE( x11 ); + return ret; + } + + + /* + * Must be set before joining the pools! + */ + *data = x11; + + + /* + * Slave init + */ + if (shared->x11image_pool) + dfb_surface_pool_join( core, shared->x11image_pool, &x11SurfacePoolFuncs ); + +#ifdef USE_GLX + if (shared->glx_pool) + dfb_surface_pool_join( core, shared->glx_pool, &glxSurfacePoolFuncs ); +#endif + + if (shared->vpsmem_pool) + dfb_surface_pool_join( core, shared->vpsmem_pool, &vpsmemSurfacePoolFuncs ); + +#ifdef USE_GLX + if (shared->x11_pool_bridge) + dfb_surface_pool_bridge_join( core, shared->x11_pool_bridge, &x11SurfacePoolBridgeFuncs, x11 ); +#endif + + return DFB_OK; +} + +static DFBResult +system_shutdown( bool emergency ) +{ + DFBX11 *x11 = dfb_system_data(); + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Core, "%s()\n", __FUNCTION__ ); + + /* + * Master deinit + */ + if (shared->x11_pool_bridge) + dfb_surface_pool_bridge_destroy( shared->x11_pool_bridge ); + + if (shared->vpsmem_pool) + dfb_surface_pool_destroy( shared->vpsmem_pool ); + + if (shared->glx_pool) + dfb_surface_pool_destroy( shared->glx_pool ); + + if (shared->x11image_pool) + dfb_surface_pool_destroy( shared->x11image_pool ); + + + /* + * Shared deinit (master only) + */ + fusion_call_destroy( &shared->call ); + + fusion_skirmish_prevail( &shared->lock ); + + if (shared->xw) + dfb_x11_close_window( x11, shared->xw ); + + fusion_skirmish_destroy( &shared->lock ); + + + SHFREE( dfb_core_shmpool( x11->core ), shared ); + + + /* + * Local deinit (master and slave) + */ + if (x11->display) + XCloseDisplay( x11->display ); + + D_FREE( x11 ); + + return DFB_OK; +} + +static DFBResult +system_leave( bool emergency ) +{ + DFBX11 *x11 = dfb_system_data(); + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Core, "%s()\n", __FUNCTION__ ); + + /* + * Slave deinit + */ + if (shared->x11_pool_bridge) + dfb_surface_pool_bridge_leave( shared->x11_pool_bridge ); + + if (shared->vpsmem_pool) + dfb_surface_pool_leave( shared->vpsmem_pool ); + + if (shared->glx_pool) + dfb_surface_pool_leave( shared->glx_pool ); + + if (shared->x11image_pool) + dfb_surface_pool_leave( shared->x11image_pool ); + + + /* + * Local deinit (master and slave) + */ + if (x11->display) + XCloseDisplay( x11->display ); + + D_FREE( x11 ); + + return DFB_OK; +} + +static DFBResult +system_suspend( void ) +{ + return DFB_UNIMPLEMENTED; +} + +static DFBResult +system_resume( void ) +{ + return DFB_UNIMPLEMENTED; +} + +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( void ) +{ + return dfb_config->accelerator; +} + +static VideoMode * +system_get_modes( void ) +{ + return modes; +} + +static VideoMode * +system_get_current_mode( void ) +{ + return &modes[0]; /* FIXME */ +} + +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 0; +} + +static void * +system_video_memory_virtual( unsigned int offset ) +{ + return NULL; +} + +static unsigned int +system_videoram_length( void ) +{ + return 0; +} + +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 ) +{ +} + +static void +system_get_deviceid( unsigned int *ret_vendor_id, + unsigned int *ret_device_id ) +{ +} + +static FusionCallHandlerResult +call_handler( int caller, + int call_arg, + void *call_ptr, + void *ctx, + unsigned int serial, + int *ret_val ) +{ + DFBX11 *x11 = ctx; + + switch (call_arg) { + case X11_CREATE_WINDOW: + *ret_val = dfb_x11_create_window_handler( x11, call_ptr ); + break; + + case X11_DESTROY_WINDOW: + *ret_val = dfb_x11_destroy_window_handler( x11 ); + break; + + case X11_UPDATE_SCREEN: + *ret_val = dfb_x11_update_screen_handler( x11, call_ptr ); + break; + + case X11_SET_PALETTE: + *ret_val = dfb_x11_set_palette_handler( x11, call_ptr ); + break; + + case X11_IMAGE_INIT: + *ret_val = dfb_x11_image_init_handler( x11, call_ptr ); + break; + + case X11_IMAGE_DESTROY: + *ret_val = dfb_x11_image_destroy_handler( x11, call_ptr ); + break; + + default: + D_BUG( "unknown call" ); + *ret_val = DFB_BUG; + break; + } + + return FCHR_RETURN; +} + diff --git a/Source/DirectFB/systems/x11/x11.h b/Source/DirectFB/systems/x11/x11.h new file mode 100755 index 0000000..4743f1a --- /dev/null +++ b/Source/DirectFB/systems/x11/x11.h @@ -0,0 +1,116 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __X11SYSTEM__X11_H__ +#define __X11SYSTEM__X11_H__ + +#include +#include +#include +#include +#include +#include + +#include "x11image.h" +#include "xwindow.h" + +typedef struct { + CoreLayerRegionConfig config; +} SetModeData; + +typedef struct { + DFBRegion region; + + CoreSurfaceBufferLock *lock; +} UpdateScreenData; + + +typedef struct { + UpdateScreenData update; + SetModeData setmode; + + FusionSkirmish lock; + FusionCall call; + + FusionSHMPoolShared *data_shmpool; + + CoreSurfacePool *x11image_pool; + + CoreSurfacePool *glx_pool; /* only used for GL */ + + CoreSurfacePool *vpsmem_pool; + unsigned int vpsmem_length; + + CoreSurfacePoolBridge *x11_pool_bridge; + +// CoreSurface *primary; + DFBDimension screen_size; + + XWindow *xw; +} DFBX11Shared; + +struct __DFB_X11 { + DFBX11Shared *shared; + + CoreDFB *core; + CoreScreen *screen; + + Bool use_shm; + int xshm_major; + int xshm_minor; + + Display *display; + Screen *screenptr; + int screennum; + + Visual *visuals[DFB_NUM_PIXELFORMATS]; +}; + +typedef enum { + X11_CREATE_WINDOW, + X11_UPDATE_SCREEN, + X11_SET_PALETTE, + X11_IMAGE_INIT, + X11_IMAGE_DESTROY, + X11_DESTROY_WINDOW, +} DFBX11Call; + + + +DFBResult dfb_x11_create_window_handler ( DFBX11 *x11, CoreLayerRegionConfig *config ); +DFBResult dfb_x11_destroy_window_handler( DFBX11 *x11 ); + +DFBResult dfb_x11_update_screen_handler ( DFBX11 *x11, UpdateScreenData *data ); +DFBResult dfb_x11_set_palette_handler ( DFBX11 *x11, CorePalette *palette ); + +DFBResult dfb_x11_image_init_handler ( DFBX11 *x11, x11Image *image ); +DFBResult dfb_x11_image_destroy_handler ( DFBX11 *x11, x11Image *image ); + + +#endif //__X11SYSTEM__X11_H__ + diff --git a/Source/DirectFB/systems/x11/x11_surface_pool.c b/Source/DirectFB/systems/x11/x11_surface_pool.c new file mode 100755 index 0000000..4936f2a --- /dev/null +++ b/Source/DirectFB/systems/x11/x11_surface_pool.c @@ -0,0 +1,369 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include +#include +#include + +#include + +#include + +#include "x11.h" +#include "x11image.h" +#include "x11_surface_pool.h" + +D_DEBUG_DOMAIN( X11_Surfaces, "X11/Surfaces", "X11 System Surface Pool" ); + +/**********************************************************************************************************************/ + +typedef struct { +} x11PoolData; + +typedef struct { + pthread_mutex_t lock; + DirectHash *hash; + + DFBX11 *x11; +} x11PoolLocalData; + +/**********************************************************************************************************************/ + +static int +x11PoolDataSize( void ) +{ + return sizeof(x11PoolData); +} + +static int +x11PoolLocalDataSize( void ) +{ + return sizeof(x11PoolLocalData); +} + +static int +x11AllocationDataSize( void ) +{ + return sizeof(x11AllocationData); +} + +static DFBResult +x11InitPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data, + CoreSurfacePoolDescription *ret_desc ) +{ + DFBResult ret; + x11PoolLocalData *local = pool_local; + DFBX11 *x11 = system_data; + + D_DEBUG_AT( X11_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_ASSERT( ret_desc != NULL ); + + local->x11 = x11; + + ret_desc->caps = CSPCAPS_VIRTUAL; + ret_desc->access[CSAID_CPU] = 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_ULTIMATE; + + /* For showing our X11 window */ + ret_desc->access[CSAID_LAYER0] = CSAF_READ; + + snprintf( ret_desc->name, DFB_SURFACE_POOL_DESC_NAME_LENGTH, "X11 Shm Images" ); + + ret = direct_hash_create( 7, &local->hash ); + if (ret) { + D_DERROR( ret, "X11/Surfaces: Could not create local hash table!\n" ); + return ret; + } + + pthread_mutex_init( &local->lock, NULL ); + + return DFB_OK; +} + +static DFBResult +x11JoinPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data ) +{ + DFBResult ret; + x11PoolLocalData *local = pool_local; + DFBX11 *x11 = system_data; + + D_DEBUG_AT( X11_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + + local->x11 = x11; + + ret = direct_hash_create( 7, &local->hash ); + if (ret) { + D_DERROR( ret, "X11/Surfaces: Could not create local hash table!\n" ); + return ret; + } + + pthread_mutex_init( &local->lock, NULL ); + + return DFB_OK; +} + +static DFBResult +x11DestroyPool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + x11PoolLocalData *local = pool_local; + + D_DEBUG_AT( X11_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + + pthread_mutex_destroy( &local->lock ); + + direct_hash_destroy( local->hash ); + + return DFB_OK; +} + +static DFBResult +x11LeavePool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + x11PoolLocalData *local = pool_local; + + D_DEBUG_AT( X11_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + + pthread_mutex_destroy( &local->lock ); + + direct_hash_destroy( local->hash ); + + return DFB_OK; +} + +static DFBResult +x11TestConfig( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + const CoreSurfaceConfig *config ) +{ + x11PoolLocalData *local = pool_local; + DFBX11 *x11 = local->x11; + DFBX11Shared *shared = x11->shared; + + /* Provide a fallback only if no virtual physical pool is allocated... */ + if (!shared->vpsmem_length) + return DFB_OK; + + /* Pass NULL image for probing */ + return x11ImageInit( x11, NULL, config->size.w, config->size.h, config->format ); +} + +static DFBResult +x11AllocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + CoreSurface *surface; + x11AllocationData *alloc = alloc_data; + x11PoolLocalData *local = pool_local; + DFBX11 *x11 = local->x11; + + D_DEBUG_AT( X11_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + if (x11ImageInit( x11, &alloc->image, surface->config.size.w, surface->config.size.h, surface->config.format ) == DFB_OK) { + alloc->real = true; + alloc->pitch = alloc->image.pitch; + + allocation->size = surface->config.size.h * alloc->image.pitch; + } + else + dfb_surface_calc_buffer_size( surface, 8, 2, &alloc->pitch, &allocation->size ); + + return DFB_OK; +} + +static DFBResult +x11DeallocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + x11AllocationData *alloc = alloc_data; + x11PoolLocalData *local = pool_local; + DFBX11 *x11 = local->x11; + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + CORE_SURFACE_ALLOCATION_ASSERT( allocation ); + + if (alloc->real) + return x11ImageDestroy( x11, &alloc->image ); + + if (alloc->ptr) + SHFREE( shared->data_shmpool, alloc->ptr ); + + return DFB_OK; +} + +static DFBResult +x11Lock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + DFBResult ret; + x11PoolLocalData *local = pool_local; + x11AllocationData *alloc = alloc_data; + DFBX11 *x11 = local->x11; + DFBX11Shared *shared = x11->shared; + CoreSurfaceBuffer *buffer; + CoreSurface *surface; + + D_DEBUG_AT( X11_Surfaces, "%s( %p )\n", __FUNCTION__, allocation ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + buffer = allocation->buffer; + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + D_ASSERT( local->hash != NULL ); + + pthread_mutex_lock( &local->lock ); + + if (alloc->real) { + void *addr = direct_hash_lookup( local->hash, alloc->image.seginfo.shmid ); + + if (!addr) { + ret = x11ImageAttach( &alloc->image, &addr ); + if (ret) { + D_DERROR( ret, "X11/Surfaces: x11ImageAttach() failed!\n" ); + pthread_mutex_unlock( &local->lock ); + return ret; + } + + direct_hash_insert( local->hash, alloc->image.seginfo.shmid, addr ); + + /* FIXME: When to remove/detach? */ + } + + lock->addr = addr; + lock->handle = &alloc->image; + } + else { + if (!alloc->ptr) { + alloc->ptr = SHCALLOC( shared->data_shmpool, 1, allocation->size ); + if (!alloc->ptr) + return D_OOSHM(); + } + + lock->addr = alloc->ptr; + } + + lock->pitch = alloc->pitch; + + pthread_mutex_unlock( &local->lock ); + + return DFB_OK; +} + +static DFBResult +x11Unlock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + D_DEBUG_AT( X11_Surfaces, "%s( %p )\n", __FUNCTION__, allocation ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + /* FIXME: Check overhead of attach/detach per lock/unlock. */ + + return DFB_OK; +} + +const SurfacePoolFuncs x11SurfacePoolFuncs = { + .PoolDataSize = x11PoolDataSize, + .PoolLocalDataSize = x11PoolLocalDataSize, + .AllocationDataSize = x11AllocationDataSize, + + .InitPool = x11InitPool, + .JoinPool = x11JoinPool, + .DestroyPool = x11DestroyPool, + .LeavePool = x11LeavePool, + + .TestConfig = x11TestConfig, + + .AllocateBuffer = x11AllocateBuffer, + .DeallocateBuffer = x11DeallocateBuffer, + + .Lock = x11Lock, + .Unlock = x11Unlock, +}; + diff --git a/Source/DirectFB/systems/x11/x11_surface_pool.h b/Source/DirectFB/systems/x11/x11_surface_pool.h new file mode 100755 index 0000000..b660931 --- /dev/null +++ b/Source/DirectFB/systems/x11/x11_surface_pool.h @@ -0,0 +1,47 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __X11SYSTEM__X11_SURFACE_POOL_H__ +#define __X11SYSTEM__X11_SURFACE_POOL_H__ + +#include + +#include "x11image.h" + +extern const SurfacePoolFuncs x11SurfacePoolFuncs; + +typedef struct { + bool real; + x11Image image; + + void *ptr; + int pitch; +} x11AllocationData; + +#endif + diff --git a/Source/DirectFB/systems/x11/x11_surface_pool_bridge.c b/Source/DirectFB/systems/x11/x11_surface_pool_bridge.c new file mode 100755 index 0000000..ce2537e --- /dev/null +++ b/Source/DirectFB/systems/x11/x11_surface_pool_bridge.c @@ -0,0 +1,331 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include +#include +#include + +#include + +#include + +#include "x11.h" +#include "x11image.h" +#include "glx_surface_pool.h" +#include "x11_surface_pool.h" + +D_DEBUG_DOMAIN( X11_Bridge, "X11/Bridge", "X11 System Surface Pool Bridge" ); + +/**********************************************************************************************************************/ + +typedef struct { +} x11PoolBridgeData; + +typedef struct { + DFBX11 *x11; + Display *display; +} x11PoolBridgeLocalData; + +typedef struct { +} x11PoolTransferData; + +/**********************************************************************************************************************/ + +static int +x11PoolBridgeDataSize( void ) +{ + return sizeof(x11PoolBridgeData); +} + +static int +x11PoolBridgeLocalDataSize( void ) +{ + return sizeof(x11PoolBridgeLocalData); +} + +static int +x11PoolTransferDataSize( void ) +{ + return sizeof(x11PoolTransferData); +} + +static DFBResult +x11InitPoolBridge( CoreDFB *core, + CoreSurfacePoolBridge *bridge, + void *bridge_data, + void *bridge_local, + void *context, + CoreSurfacePoolBridgeDescription *ret_desc ) +{ + x11PoolBridgeLocalData *local = bridge_local; + DFBX11 *x11 = context; + + D_DEBUG_AT( X11_Bridge, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( bridge, CoreSurfacePoolBridge ); + D_ASSERT( bridge_local != NULL ); + D_ASSERT( context != NULL ); + D_ASSERT( ret_desc != NULL ); + + local->x11 = x11; + local->display = x11->display; + + ret_desc->caps = CSPBCAPS_NONE; + + snprintf( ret_desc->name, DFB_SURFACE_POOL_BRIDGE_DESC_NAME_LENGTH, "X11 Pool Bridge" ); + + return DFB_OK; +} + +static DFBResult +x11JoinPoolBridge( CoreDFB *core, + CoreSurfacePoolBridge *bridge, + void *bridge_data, + void *bridge_local, + void *context ) +{ + x11PoolBridgeLocalData *local = bridge_local; + DFBX11 *x11 = context; + + D_DEBUG_AT( X11_Bridge, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( bridge, CoreSurfacePoolBridge ); + D_ASSERT( bridge_local != NULL ); + D_ASSERT( context != NULL ); + + local->x11 = x11; + local->display = x11->display; + + return DFB_OK; +} + +static DFBResult +x11DestroyPoolBridge( CoreSurfacePoolBridge *bridge, + void *bridge_data, + void *bridge_local ) +{ + D_DEBUG_AT( X11_Bridge, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( bridge, CoreSurfacePoolBridge ); + + return DFB_OK; +} + +static DFBResult +x11LeavePoolBridge( CoreSurfacePoolBridge *bridge, + void *bridge_data, + void *bridge_local ) +{ + D_DEBUG_AT( X11_Bridge, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( bridge, CoreSurfacePoolBridge ); + + return DFB_OK; +} + +static DFBResult +x11CheckTransfer( CoreSurfacePoolBridge *bridge, + void *bridge_data, + void *bridge_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *from, + CoreSurfaceAllocation *to ) +{ + x11PoolBridgeLocalData *local = bridge_local; + DFBX11 *x11 = local->x11; + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Bridge, "%s()\n", __FUNCTION__ ); + + if (from->pool == shared->x11image_pool && to->pool == shared->glx_pool) { + x11AllocationData *alloc = from->data; + + if (alloc->real) { + /* ARGB does not work (BadMatch) */ + if (buffer->format == DSPF_RGB32) + return DFB_OK; + } + } + else if (from->pool == shared->glx_pool && to->pool == shared->x11image_pool) { + x11AllocationData *alloc = to->data; + + if (alloc->real) { + /* ARGB does not work (BadMatch) */ + if (buffer->format == DSPF_RGB32) + return DFB_OK; + } + } + + return DFB_UNSUPPORTED; +} + +static DFBResult +x11StartTransfer( CoreSurfacePoolBridge *bridge, + void *bridge_data, + void *bridge_local, + CoreSurfacePoolTransfer *transfer, + void *transfer_data ) +{ + DFBResult ret; + int i; + CoreSurfaceBufferLock lock; + LocalPixmap *pixmap; + x11PoolBridgeLocalData *local = bridge_local; + DFBX11 *x11 = local->x11; + DFBX11Shared *shared = x11->shared; + CoreSurfaceAllocation *from = transfer->from; + CoreSurfaceAllocation *to = transfer->to; + + D_DEBUG_AT( X11_Bridge, "%s()\n", __FUNCTION__ ); + + if (from->pool == shared->x11image_pool && to->pool == shared->glx_pool) { + x11AllocationData *alloc = from->data; + + D_ASSERT( alloc->real ); + + dfb_surface_buffer_lock_init( &lock, CSAID_ANY, CSAF_WRITE ); + + ret = dfb_surface_pool_lock( to->pool, to, &lock ); + if (ret) { + dfb_surface_buffer_lock_deinit( &lock ); + return ret; + } + + pixmap = lock.handle; + D_MAGIC_ASSERT( pixmap, LocalPixmap ); + + + XLockDisplay( local->display ); + + for (i=0; inum_rects; i++) { + const DFBRectangle *rect = &transfer->rects[i]; + + D_DEBUG_AT( X11_Bridge, " -> XCopyArea( %4d,%4d-%4dx%4d )\n", rect->x, rect->y, rect->w, rect->h ); + + XCopyArea( local->display, alloc->image.pixmap, pixmap->pixmap, pixmap->gc, + rect->x, rect->y, rect->w, rect->h, rect->x, rect->y ); + } + + XFlush( local->display ); + + XUnlockDisplay( local->display ); + + + dfb_surface_pool_unlock( to->pool, to, &lock ); + + dfb_surface_buffer_lock_deinit( &lock ); + + return DFB_OK; + } + + if (from->pool == shared->glx_pool && to->pool == shared->x11image_pool) { + x11AllocationData *alloc = to->data; + + D_ASSERT( alloc->real ); + + dfb_surface_buffer_lock_init( &lock, CSAID_ANY, CSAF_READ ); + + ret = dfb_surface_pool_lock( from->pool, from, &lock ); + if (ret) { + dfb_surface_buffer_lock_deinit( &lock ); + return ret; + } + + pixmap = lock.handle; + D_MAGIC_ASSERT( pixmap, LocalPixmap ); + + + XLockDisplay( local->display ); + + glFinish(); + + for (i=0; inum_rects; i++) { + const DFBRectangle *rect = &transfer->rects[i]; + + D_DEBUG_AT( X11_Bridge, " -> XCopyArea( %4d,%4d-%4dx%4d )\n", rect->x, rect->y, rect->w, rect->h ); + + XCopyArea( local->display, pixmap->pixmap, alloc->image.pixmap, alloc->image.gc, + rect->x, rect->y, rect->w, rect->h, rect->x, rect->y ); + } + + XFlush( local->display ); + + XUnlockDisplay( local->display ); + + + dfb_surface_pool_unlock( from->pool, from, &lock ); + + dfb_surface_buffer_lock_deinit( &lock ); + + return DFB_OK; + } + + return DFB_BUG; +} + +static DFBResult +x11FinishTransfer( CoreSurfacePoolBridge *bridge, + void *bridge_data, + void *bridge_local, + CoreSurfacePoolTransfer *transfer, + void *transfer_data ) +{ + x11PoolBridgeLocalData *local = bridge_local; + + D_DEBUG_AT( X11_Bridge, "%s()\n", __FUNCTION__ ); + + XLockDisplay( local->display ); + + XSync( local->display, False ); + + XUnlockDisplay( local->display ); + + return DFB_OK; +} + + +const SurfacePoolBridgeFuncs x11SurfacePoolBridgeFuncs = { + .PoolBridgeDataSize = x11PoolBridgeDataSize, + .PoolBridgeLocalDataSize = x11PoolBridgeLocalDataSize, + .PoolTransferDataSize = x11PoolTransferDataSize, + + .InitPoolBridge = x11InitPoolBridge, + .JoinPoolBridge = x11JoinPoolBridge, + .DestroyPoolBridge = x11DestroyPoolBridge, + .LeavePoolBridge = x11LeavePoolBridge, + + .CheckTransfer = x11CheckTransfer, + + .StartTransfer = x11StartTransfer, + .FinishTransfer = x11FinishTransfer, +}; + diff --git a/Source/DirectFB/systems/x11/x11_surface_pool_bridge.h b/Source/DirectFB/systems/x11/x11_surface_pool_bridge.h new file mode 100755 index 0000000..cebb5dc --- /dev/null +++ b/Source/DirectFB/systems/x11/x11_surface_pool_bridge.h @@ -0,0 +1,37 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __X11SYSTEM__X11_SURFACE_POOL_BRIDGE_H__ +#define __X11SYSTEM__X11_SURFACE_POOL_BRIDGE_H__ + +#include + +extern const SurfacePoolBridgeFuncs x11SurfacePoolBridgeFuncs; + +#endif + diff --git a/Source/DirectFB/systems/x11/x11image.c b/Source/DirectFB/systems/x11/x11image.c new file mode 100755 index 0000000..acf36f0 --- /dev/null +++ b/Source/DirectFB/systems/x11/x11image.c @@ -0,0 +1,231 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include + +#include "x11.h" +#include "x11image.h" + +/**********************************************************************************************************************/ + +DFBResult x11ImageInit( DFBX11 *x11, + x11Image *image, + int width, + int height, + DFBSurfacePixelFormat format ) +{ + int ret; + Visual *visual; + DFBX11Shared *shared = x11->shared; + + if (!x11->use_shm) + return DFB_UNSUPPORTED; + + /* Lookup visual. */ + visual = x11->visuals[DFB_PIXELFORMAT_INDEX(format)]; + if (!visual) + return DFB_UNSUPPORTED; + + /* For probing. */ + if (!image) + return DFB_OK; + + image->width = width; + image->height = height; + image->format = format; + image->depth = DFB_COLOR_BITS_PER_PIXEL( format ); + + D_MAGIC_SET( image, x11Image ); + + if (fusion_call_execute( &shared->call, FCEF_NONE, X11_IMAGE_INIT, image, &ret )) { + D_MAGIC_CLEAR( image ); + return DFB_FUSION; + } + + if (ret) { + D_DERROR( ret, "X11/Image: X11_IMAGE_INIT call failed!\n" ); + D_MAGIC_CLEAR( image ); + return ret; + } + + return DFB_OK; +} + +DFBResult +x11ImageDestroy( DFBX11 *x11, + x11Image *image ) +{ + int ret; + DFBX11Shared *shared = x11->shared; + + D_MAGIC_ASSERT( image, x11Image ); + + if (fusion_call_execute( &shared->call, FCEF_NONE, X11_IMAGE_DESTROY, image, &ret )) + return DFB_FUSION; + + if (ret) { + D_DERROR( ret, "X11/Image: X11_IMAGE_DESTROY call failed!\n" ); + return ret; + } + + D_MAGIC_CLEAR( image ); + + return DFB_OK; +} + +DFBResult +x11ImageAttach( x11Image *image, + void **ret_addr ) +{ + void *addr; + + D_MAGIC_ASSERT( image, x11Image ); + D_ASSERT( ret_addr != NULL ); + + /* FIXME: We also need to DETACH! */ + + addr = shmat( image->seginfo.shmid, NULL, 0 ); + if (!addr) { + int erno = errno; + + D_PERROR( "X11/Image: shmat( %d ) failed!\n", image->seginfo.shmid ); + + return errno2result( erno ); + } + + *ret_addr = addr; + + return DFB_OK; +} + +/**********************************************************************************************************************/ + +DFBResult +dfb_x11_image_init_handler( DFBX11 *x11, x11Image *image ) +{ + Visual *visual; + XImage *ximage; + + D_MAGIC_ASSERT( image, x11Image ); + + if (!x11->use_shm) + return DFB_UNSUPPORTED; + + /* Lookup visual. */ + visual = x11->visuals[DFB_PIXELFORMAT_INDEX(image->format)]; + if (!visual) + return DFB_UNSUPPORTED; + + image->visual = visual; + + XLockDisplay( x11->display ); + + ximage = XShmCreateImage( x11->display, image->visual, image->depth, + ZPixmap, NULL, &image->seginfo, image->width, image->height ); + if (!ximage) { + D_ERROR( "X11/ShmImage: Error creating shared image (XShmCreateImage)!\n"); + XUnlockDisplay( x11->display ); + return DFB_FAILURE; + } + + /* we firstly create our shared memory segment with the size we need, and + correct permissions for the owner, the group and the world --> 0777 */ + image->seginfo.shmid = shmget( IPC_PRIVATE, + ximage->bytes_per_line * ximage->height, + IPC_CREAT | 0777 ); + if (image->seginfo.shmid < 0) + goto error; + + /* Then, we have to attach the segment to our process, and we let the + function search the correct memory place --> NULL. It's safest ! */ + image->seginfo.shmaddr = shmat( image->seginfo.shmid, NULL, 0 ); + if (!image->seginfo.shmaddr) + goto error_shmat; + + ximage->data = image->seginfo.shmaddr; + + /* We set the buffer in Read and Write mode */ + image->seginfo.readOnly = False; + + if (!XShmAttach( x11->display, &image->seginfo )) + goto error_xshmattach; + + image->ximage = ximage; + image->pitch = ximage->bytes_per_line; + + image->pixmap = XShmCreatePixmap( x11->display, DefaultRootWindow(x11->display), ximage->data, + &image->seginfo, image->width, image->height, image->depth ); + + image->gc = XCreateGC( x11->display, image->pixmap, 0, NULL ); + + XUnlockDisplay( x11->display ); + + return DFB_OK; + + +error_xshmattach: + shmdt( image->seginfo.shmaddr ); + +error_shmat: + shmctl( image->seginfo.shmid, IPC_RMID, NULL ); + +error: + XDestroyImage( ximage ); + + XUnlockDisplay( x11->display ); + + return DFB_FAILURE; +} + +DFBResult +dfb_x11_image_destroy_handler( DFBX11 *x11, x11Image *image ) +{ + D_MAGIC_ASSERT( image, x11Image ); + + XLockDisplay( x11->display ); + + XFreeGC( x11->display, image->gc ); + XFreePixmap( x11->display, image->pixmap ); + + XShmDetach( x11->display, &image->seginfo ); + + XDestroyImage( image->ximage ); + + XUnlockDisplay( x11->display ); + + shmdt( image->seginfo.shmaddr ); + + shmctl( image->seginfo.shmid, IPC_RMID, NULL ); + + return DFB_OK; +} + diff --git a/Source/DirectFB/systems/x11/x11image.h b/Source/DirectFB/systems/x11/x11image.h new file mode 100755 index 0000000..3872ef7 --- /dev/null +++ b/Source/DirectFB/systems/x11/x11image.h @@ -0,0 +1,76 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __X11SYSTEM__X11IMAGE_H__ +#define __X11SYSTEM__X11IMAGE_H__ + +#include /* fundamentals X datas structures */ +#include /* datas definitions for various functions */ +#include /* for a perfect use of keyboard events */ + +#include +#include +#include + +#include "x11types.h" + + +typedef struct { + int magic; + + int width; + int height; + DFBSurfacePixelFormat format; + + int depth; + Visual* visual; + + XImage* ximage; + int pitch; + + XShmSegmentInfo seginfo; + + Pixmap pixmap; + GC gc; +} x11Image; + + +DFBResult x11ImageInit ( DFBX11 *x11, + x11Image *image, + int width, + int height, + DFBSurfacePixelFormat format ); + +DFBResult x11ImageDestroy( DFBX11 *x11, + x11Image *image ); + +DFBResult x11ImageAttach ( x11Image *image, + void **ret_addr ); + +#endif /* __X11SYSTEM__X11IMAGE_H__ */ + diff --git a/Source/DirectFB/systems/x11/x11input.c b/Source/DirectFB/systems/x11/x11input.c new file mode 100755 index 0000000..0b711e0 --- /dev/null +++ b/Source/DirectFB/systems/x11/x11input.c @@ -0,0 +1,768 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include + +#include +#include +#include + +#include + +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "xwindow.h" + +#include "primary.h" +#include "x11.h" + +#define DFB_INPUTDRIVER_HAS_SENSITIVITY + +#include + +D_DEBUG_DOMAIN( X11_Input, "X11/Input", "X11 Input/Key/Mouse handling" ); + +DFB_INPUT_DRIVER( x11input ) + + +extern DFBX11 *dfb_x11; + +/* + * declaration of private data + */ +typedef struct { + CoreInputDevice* device; + DirectThread* thread; + DFBX11* x11; + bool stop; +} X11InputData; + + +static DFBInputEvent motionX = { + .type = DIET_UNKNOWN, + .axisabs = 0, +}; + +static DFBInputEvent motionY = { + .type = DIET_UNKNOWN, + .axisabs = 0, +}; + +static void +motion_compress( int x, int y, const XEvent *xEvent ) +{ + if (motionX.axisabs != x) { + motionX.type = DIET_AXISMOTION; + motionX.flags = DIEF_AXISABS | DIEF_TIMESTAMP; + motionX.axis = DIAI_X; + motionX.axisabs = x; + + motionX.timestamp.tv_sec = xEvent->xmotion.time / 1000; + motionX.timestamp.tv_usec = (xEvent->xmotion.time % 1000) * 1000; + } + + if (motionY.axisabs != y) { + motionY.type = DIET_AXISMOTION; + motionY.flags = DIEF_AXISABS | DIEF_TIMESTAMP; + motionY.axis = DIAI_Y; + motionY.axisabs = y; + + motionY.timestamp.tv_sec = xEvent->xmotion.time / 1000; + motionY.timestamp.tv_usec = (xEvent->xmotion.time % 1000) * 1000; + } +} + +static void +motion_realize( X11InputData *data ) +{ + if (motionX.type != DIET_UNKNOWN) { + if (motionY.type != DIET_UNKNOWN) + motionX.flags |= DIEF_FOLLOW; + + if (dfb_x11->shared->xw) { + motionX.flags |= DIEF_MIN | DIEF_MAX; + motionX.min = 0; + motionX.max = dfb_x11->shared->xw->width - 1; + } + + dfb_input_dispatch( data->device, &motionX ); + + motionX.type = DIET_UNKNOWN; + } + + if (motionY.type != DIET_UNKNOWN) { + if (dfb_x11->shared->xw) { + motionY.flags |= DIEF_MIN | DIEF_MAX; + motionY.min = 0; + motionY.max = dfb_x11->shared->xw->height - 1; + } + + dfb_input_dispatch( data->device, &motionY ); + + motionY.type = DIET_UNKNOWN; + } +} + +static DFBInputDeviceKeyIdentifier +xsymbol_to_id( KeySym xKeySymbol ) +{ + switch (xKeySymbol) { + case XK_a : return DIKI_A; + case XK_b : return DIKI_B; + case XK_c : return DIKI_C; + case XK_d : return DIKI_D; + case XK_e : return DIKI_E; + case XK_f : return DIKI_F; + case XK_g : return DIKI_G; + case XK_h : return DIKI_H; + case XK_i : return DIKI_I; + case XK_j : return DIKI_J; + case XK_k : return DIKI_K; + case XK_l : return DIKI_L; + case XK_m : return DIKI_M; + case XK_n : return DIKI_N; + case XK_o : return DIKI_O; + case XK_p : return DIKI_P; + case XK_q : return DIKI_Q; + case XK_r : return DIKI_R; + case XK_s : return DIKI_S; + case XK_t : return DIKI_T; + case XK_u : return DIKI_U; + case XK_v : return DIKI_V; + case XK_w : return DIKI_W; + case XK_x : return DIKI_X; + case XK_y : return DIKI_Y; + case XK_z : return DIKI_Z; + case XK_0 : return DIKI_0; + case XK_1 : return DIKI_1; + case XK_2 : return DIKI_2; + case XK_3 : return DIKI_3; + case XK_4 : return DIKI_4; + case XK_5 : return DIKI_5; + case XK_6 : return DIKI_6; + case XK_7 : return DIKI_7; + case XK_8 : return DIKI_8; + case XK_9 : return DIKI_9; + case XK_F1 : return DIKI_F1; + case XK_F2 : return DIKI_F2; + case XK_F3 : return DIKI_F3; + case XK_F4 : return DIKI_F4; + case XK_F5 : return DIKI_F5; + case XK_F6 : return DIKI_F6; + case XK_F7 : return DIKI_F7; + case XK_F8 : return DIKI_F8; + case XK_F9 : return DIKI_F9; + case XK_F10 : return DIKI_F10; + case XK_F11 : return DIKI_F11; + case XK_F12 : return DIKI_F12; + + case XK_Shift_L : return DIKI_SHIFT_L; + case XK_Shift_R : return DIKI_SHIFT_R; + case XK_Control_L : return DIKI_CONTROL_L; + case XK_Control_R : return DIKI_CONTROL_R; + case XK_Alt_L : return DIKI_ALT_L; + case XK_Alt_R : return DIKI_ALT_R; + case XK_Meta_L : return DIKI_META_L; + case XK_Meta_R : return DIKI_META_R; + case XK_Super_L : return DIKI_SUPER_L; + case XK_Super_R : return DIKI_SUPER_R; + case XK_Hyper_L : return DIKI_HYPER_L; + case XK_Hyper_R : return DIKI_HYPER_R; + case XK_Mode_switch : return DIKI_ALT_R; + + case XK_Caps_Lock : return DIKI_CAPS_LOCK; + case XK_Num_Lock : return DIKI_NUM_LOCK; + case XK_Scroll_Lock : return DIKI_SCROLL_LOCK; + + case XK_Escape : return DIKI_ESCAPE; + case XK_Left : return DIKI_LEFT; + case XK_Right : return DIKI_RIGHT; + case XK_Up : return DIKI_UP; + case XK_Down : return DIKI_DOWN; + + case XK_Tab : return DIKI_TAB; + case XK_ISO_Left_Tab : return DIKI_TAB; + case XK_Return : return DIKI_ENTER; + case XK_space : return DIKI_SPACE; + case XK_BackSpace : return DIKI_BACKSPACE; + case XK_Insert : return DIKI_INSERT; + case XK_Delete : return DIKI_DELETE; + case XK_Home : return DIKI_HOME; + case XK_End : return DIKI_END; + case XK_Page_Up : return DIKI_PAGE_UP; + case XK_Page_Down : return DIKI_PAGE_DOWN; + case XK_Print : return DIKI_PRINT; + case XK_Pause : return DIKI_PAUSE; + + /* The labels on these keys depend on the type of keyboard. + * We've choosen the names from a US keyboard layout. The + * comments refer to the ISO 9995 terminology. + */ + case XK_quoteleft : return DIKI_QUOTE_LEFT; /* TLDE */ + case XK_minus : return DIKI_MINUS_SIGN; /* AE11 */ + case XK_equal : return DIKI_EQUALS_SIGN; /* AE12 */ + case XK_bracketleft : return DIKI_BRACKET_LEFT; /* AD11 */ + case XK_bracketright : return DIKI_BRACKET_RIGHT;/* AD12 */ + case XK_backslash : return DIKI_BACKSLASH; /* BKSL */ + case XK_semicolon : return DIKI_SEMICOLON; /* AC10 */ + case XK_quoteright : return DIKI_QUOTE_RIGHT; /* AC11 */ + case XK_comma : return DIKI_COMMA; /* AB08 */ + case XK_period : return DIKI_PERIOD; /* AB09 */ + case XK_slash : return DIKI_SLASH; /* AB10 */ + case XK_less : return DIKI_LESS_SIGN; /* 103rd */ + + case XK_KP_Divide : return DIKI_KP_DIV; + case XK_KP_Multiply : return DIKI_KP_MULT; + case XK_KP_Subtract : return DIKI_KP_MINUS; + case XK_KP_Add : return DIKI_KP_PLUS; + case XK_KP_Enter : return DIKI_KP_ENTER; + case XK_KP_Space : return DIKI_KP_SPACE; + case XK_KP_Tab : return DIKI_KP_TAB; + case XK_KP_F1 : return DIKI_KP_F1; + case XK_KP_F2 : return DIKI_KP_F2; + case XK_KP_F3 : return DIKI_KP_F3; + case XK_KP_F4 : return DIKI_KP_F4; + case XK_KP_Equal : return DIKI_KP_EQUAL; + case XK_KP_Separator : return DIKI_KP_SEPARATOR; + + case XK_KP_Delete : return DIKI_KP_DECIMAL; + case XK_KP_Insert : return DIKI_KP_0; + case XK_KP_End : return DIKI_KP_1; + case XK_KP_Down : return DIKI_KP_2; + case XK_KP_Page_Down : return DIKI_KP_3; + case XK_KP_Left : return DIKI_KP_4; + case XK_KP_Begin : return DIKI_KP_5; + case XK_KP_Right : return DIKI_KP_6; + case XK_KP_Home : return DIKI_KP_7; + case XK_KP_Up : return DIKI_KP_8; + case XK_KP_Page_Up : return DIKI_KP_9; + + case XK_KP_Decimal : return DIKI_KP_DECIMAL; + case XK_KP_0 : return DIKI_KP_0; + case XK_KP_1 : return DIKI_KP_1; + case XK_KP_2 : return DIKI_KP_2; + case XK_KP_3 : return DIKI_KP_3; + case XK_KP_4 : return DIKI_KP_4; + case XK_KP_5 : return DIKI_KP_5; + case XK_KP_6 : return DIKI_KP_6; + case XK_KP_7 : return DIKI_KP_7; + case XK_KP_8 : return DIKI_KP_8; + case XK_KP_9 : return DIKI_KP_9; + + case 0 : break; + + default: + D_DEBUG_AT( X11_Input, "Unknown key symbol 0x%lx\n", xKeySymbol); + } + + return DIKI_UNKNOWN; +} + +static DFBInputDeviceKeySymbol +xsymbol_to_symbol( KeySym xKeySymbol ) +{ + if (xKeySymbol >= 0x20 && xKeySymbol <= 0xff) + return xKeySymbol; + + if (xKeySymbol >= XK_F1 && xKeySymbol <= XK_F35) + return DFB_FUNCTION_KEY( xKeySymbol - XK_F1 + 1 ); + + switch (xKeySymbol) { + case XK_Shift_L : return DIKS_SHIFT; + case XK_Shift_R : return DIKS_SHIFT; + case XK_Control_L : return DIKS_CONTROL; + case XK_Control_R : return DIKS_CONTROL; + case XK_Alt_L : return DIKS_ALT; + case XK_Alt_R : return DIKS_ALT; + case XK_Meta_L : return DIKS_META; + case XK_Meta_R : return DIKS_META; + case XK_Super_L : return DIKS_SUPER; + case XK_Super_R : return DIKS_SUPER; + case XK_Hyper_L : return DIKS_HYPER; + case XK_Hyper_R : return DIKS_HYPER; + case XK_Mode_switch : return DIKS_ALTGR; + + case XK_Caps_Lock : return DIKS_CAPS_LOCK; + case XK_Num_Lock : return DIKS_NUM_LOCK; + case XK_Scroll_Lock : return DIKS_SCROLL_LOCK; + + case XK_Escape : return DIKS_ESCAPE; + case XK_Left : return DIKS_CURSOR_LEFT; + case XK_Right : return DIKS_CURSOR_RIGHT; + case XK_Up : return DIKS_CURSOR_UP; + case XK_Down : return DIKS_CURSOR_DOWN; + + case XK_Tab : return DIKS_TAB; + case XK_ISO_Left_Tab : return DIKS_TAB; + case XK_Return : return DIKS_ENTER; + case XK_space : return DIKS_SPACE; + case XK_BackSpace : return DIKS_BACKSPACE; + case XK_Insert : return DIKS_INSERT; + case XK_Delete : return DIKS_DELETE; + case XK_Home : return DIKS_HOME; + case XK_End : return DIKS_END; + case XK_Page_Up : return DIKS_PAGE_UP; + case XK_Page_Down : return DIKS_PAGE_DOWN; + case XK_Print : return DIKS_PRINT; + case XK_Pause : return DIKS_PAUSE; + + case XK_KP_Divide : return DIKS_SLASH; + case XK_KP_Multiply : return DIKS_ASTERISK; + case XK_KP_Subtract : return DIKS_MINUS_SIGN; + case XK_KP_Add : return DIKS_PLUS_SIGN; + case XK_KP_Enter : return DIKS_ENTER; + case XK_KP_Space : return DIKS_SPACE; + case XK_KP_Tab : return DIKS_TAB; + case XK_KP_F1 : return DIKS_F1; + case XK_KP_F2 : return DIKS_F2; + case XK_KP_F3 : return DIKS_F3; + case XK_KP_F4 : return DIKS_F4; + case XK_KP_Equal : return DIKS_EQUALS_SIGN; + case XK_KP_Separator : return DIKS_COLON; /* FIXME: what is a separator */ + + case XK_KP_Delete : return DIKS_DELETE; + case XK_KP_Insert : return DIKS_INSERT; + case XK_KP_End : return DIKS_END; + case XK_KP_Down : return DIKS_CURSOR_DOWN; + case XK_KP_Page_Down : return DIKS_PAGE_DOWN; + case XK_KP_Left : return DIKS_CURSOR_LEFT; + case XK_KP_Begin : return DIKS_BEGIN; + case XK_KP_Right : return DIKS_CURSOR_RIGHT; + case XK_KP_Home : return DIKS_HOME; + case XK_KP_Up : return DIKS_CURSOR_UP; + case XK_KP_Page_Up : return DIKS_PAGE_UP; + + case XK_KP_Decimal : return DIKS_PERIOD; + case XK_KP_0 : return DIKS_0; + case XK_KP_1 : return DIKS_1; + case XK_KP_2 : return DIKS_2; + case XK_KP_3 : return DIKS_3; + case XK_KP_4 : return DIKS_4; + case XK_KP_5 : return DIKS_5; + case XK_KP_6 : return DIKS_6; + case XK_KP_7 : return DIKS_7; + case XK_KP_8 : return DIKS_8; + case XK_KP_9 : return DIKS_9; + + case 0 : break; + + default: + D_DEBUG("X11: Unknown key symbol 0x%lx\n", xKeySymbol); + } + + return DIKS_NULL; +} + + + +static void handleMouseEvent(XEvent* pXEvent, X11InputData* pData) +{ + static int iMouseEventCount = 0; + DFBInputEvent dfbEvent; + if (pXEvent->type == MotionNotify) { + motion_compress( pXEvent->xmotion.x, pXEvent->xmotion.y, pXEvent ); + ++iMouseEventCount; + } + + if ( pXEvent->type == ButtonPress || pXEvent->type == ButtonRelease ) { + if ( pXEvent->type == ButtonPress ) + dfbEvent.type = DIET_BUTTONPRESS; + else + dfbEvent.type = DIET_BUTTONRELEASE; + + dfbEvent.flags = DIEF_TIMESTAMP; + + /* Get pressed button */ + switch ( pXEvent->xbutton.button ) { + case 1: + dfbEvent.button = DIBI_LEFT; + break; + case 2: + dfbEvent.button = DIBI_MIDDLE; + break; + case 3: + dfbEvent.button = DIBI_RIGHT; + break; + //Wheel events + case 4: /*up*/ + case 5: /*down*/ + case 6: /*left*/ + case 7: /*right*/ + if (pXEvent->type == ButtonPress) { + dfbEvent.type = DIET_AXISMOTION; + dfbEvent.flags = DIEF_AXISREL; + dfbEvent.axis = DIAI_Z; + /*SCROLL UP*/ + if ( pXEvent->xbutton.button == 4 ) { + dfbEvent.axisrel = -1; + } + /*SCROLL DOWN */ + else if (pXEvent->xbutton.button == 5) { + dfbEvent.axisrel = 1; + } + /*SCROLL LEFT*/ + else if (pXEvent->xbutton.button == 6) { + dfbEvent.axis = DIAI_X; + dfbEvent.axisrel = -1; + } + /*SCROLL RIGHT*/ + else if (pXEvent->xbutton.button == 7 ) { + dfbEvent.axis = DIAI_X; + dfbEvent.axisrel = 1; + } + } + else + return; + break; + default: + break; + } + + dfbEvent.timestamp.tv_sec = pXEvent->xbutton.time / 1000; + dfbEvent.timestamp.tv_usec = (pXEvent->xbutton.time % 1000) * 1000; + + dfb_input_dispatch( pData->device, &dfbEvent ); + ++iMouseEventCount; + } +} + +static void +handle_expose( const XExposeEvent *expose ) +{ + CoreLayer *layer = dfb_layer_at( DLID_PRIMARY ); + const DisplayLayerFuncs *funcs = layer->funcs; + CoreLayerContext *context; + + D_ASSERT( funcs != NULL ); + D_ASSERT( funcs->UpdateRegion != NULL ); + + /* Get the currently active context. */ + if (dfb_layer_get_active_context( layer, &context ) == DFB_OK) { + CoreLayerRegion *region; + + /* Get the first region. */ + if (dfb_layer_context_get_primary_region( context, + false, ®ion ) == DFB_OK) + { + /* Lock the region to avoid tearing due to concurrent updates. */ + dfb_layer_region_lock( region ); + + /* Get the surface of the region. */ + if (region->surface && region->surface_lock.buffer) { + DFBRegion update = { expose->x, expose->y, + expose->x + expose->width - 1, + expose->y + expose->height - 1 }; + + funcs->UpdateRegion( layer, layer->driver_data, layer->layer_data, + region->region_data, region->surface, &update, ®ion->surface_lock ); + } + + /* Unlock the region. */ + dfb_layer_region_unlock( region ); + + /* Release the region. */ + dfb_layer_region_unref( region ); + } + + /* Release the context. */ + dfb_layer_context_unref( context ); + } +} + +/* + * Input thread reading from device. + * Generates events on incoming data. + */ +static void* +x11EventThread( DirectThread *thread, void *driver_data ) +{ + X11InputData *data = driver_data; + DFBX11 *x11 = data->x11; + DFBX11Shared *shared = x11->shared; + + while (!data->stop) { + unsigned int pull = 23; + XEvent xEvent; + DFBInputEvent dfbEvent; + + /* FIXME: Detect key repeats, we're receiving KeyPress, KeyRelease, KeyPress, KeyRelease... !!?? */ + + if (!shared->xw || !shared->xw->window) { + /* no window, so no event */ + usleep( 50000 ); + continue; + } + + usleep( 10000 ); + + XLockDisplay( x11->display ); + + while (!data->stop && pull-- && XPending( x11->display )) { + XNextEvent( x11->display, &xEvent ); + + XUnlockDisplay( x11->display ); + + D_DEBUG_AT( X11_Input, "Event received: %d\n", xEvent.type ); + + switch (xEvent.type) { + case ButtonPress: + case ButtonRelease: + motion_realize( data ); + case MotionNotify: + handleMouseEvent( &xEvent, data ); // crash ??? + break; + + case KeyPress: + case KeyRelease: { + motion_realize( data ); + + dfbEvent.type = (xEvent.type == KeyPress) ? DIET_KEYPRESS : DIET_KEYRELEASE; + dfbEvent.flags = DIEF_KEYCODE | DIEF_TIMESTAMP; + dfbEvent.key_code = xEvent.xkey.keycode; + + dfbEvent.timestamp.tv_sec = xEvent.xkey.time / 1000; + dfbEvent.timestamp.tv_usec = (xEvent.xkey.time % 1000) * 1000; + + dfb_input_dispatch( data->device, &dfbEvent ); + break; + } + + case Expose: + handle_expose( &xEvent.xexpose ); + break; + + case DestroyNotify: + /* this event is mainly to unblock XNextEvent. */ + break; + + default: + break; + } + + XLockDisplay( x11->display ); + } + + XUnlockDisplay( x11->display ); + + if (!data->stop) + motion_realize( data ); + } + + return NULL; +} + +/* exported symbols */ + +/* + * Return the number of available devices. + * Called once during initialization of DirectFB. + */ +static int +driver_get_available( void ) +{ + return dfb_system_type() == CORE_X11; +} + +/* + * Fill out general information about this driver. + * Called once during initialization of DirectFB. + */ +static void +driver_get_info( InputDriverInfo *info ) +{ + /* fill driver info structure */ + snprintf ( info->name, DFB_INPUT_DRIVER_INFO_NAME_LENGTH, "X11 Input Driver" ); + snprintf ( info->vendor, DFB_INPUT_DRIVER_INFO_VENDOR_LENGTH, "directfb.org" ); + + info->version.major = 0; + info->version.minor = 1; +} + +/* + * Open the device, fill out information about it, + * allocate and fill private data, start input thread. + * Called during initialization, resuming or taking over mastership. + */ +static DFBResult +driver_open_device( CoreInputDevice *device, + unsigned int number, + InputDeviceInfo *info, + void **driver_data ) +{ + X11InputData *data; + DFBX11 *x11 = dfb_system_data(); + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Input, "%s()\n", __FUNCTION__ ); + + fusion_skirmish_prevail( &shared->lock ); + + fusion_skirmish_dismiss( &shared->lock ); + + /* set device vendor and name */ + snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "XServer" ); + snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "X11 Input" ); + + /* set one of the primary input device IDs */ + info->prefered_id = DIDID_KEYBOARD; + + /* set type flags */ + info->desc.type = DIDTF_JOYSTICK | DIDTF_KEYBOARD | DIDTF_MOUSE; + + /* set capabilities */ + info->desc.caps = DICAPS_ALL; + + /* enable translation of fake raw hardware keycodes */ + info->desc.min_keycode = 8; + info->desc.max_keycode = 255; + + + /* allocate and fill private data */ + data = D_CALLOC( 1, sizeof(X11InputData) ); + + data->device = device; + data->x11 = x11; + + /* start input thread */ + data->thread = direct_thread_create( DTT_INPUT, x11EventThread, data, "X11 Input" ); + + /* set private data pointer */ + *driver_data = data; + + return DFB_OK; +} + +/* + * Fetch one entry from the device's keymap if supported. + * this does a fake mapping based on the orginal DFB code + */ +static DFBResult +driver_get_keymap_entry( CoreInputDevice *device, + void *driver_data, + DFBInputDeviceKeymapEntry *entry ) +{ + int i; + X11InputData *data = driver_data; + DFBX11 *x11 = data->x11; + + XLockDisplay( x11->display ); + + for (i=0; i<4; i++) { + KeySym xSymbol = XKeycodeToKeysym( x11->display, entry->code, i ); + + if (i == 0) + entry->identifier = xsymbol_to_id( xSymbol ); + + entry->symbols[i] = xsymbol_to_symbol( xSymbol ); + } + + XUnlockDisplay( x11->display ); + + /* is CapsLock effective? */ + if (entry->identifier >= DIKI_A && entry->identifier <= DIKI_Z) + entry->locks |= DILS_CAPS; + + /* is NumLock effective? */ + if (entry->identifier >= DIKI_KP_DECIMAL && entry->identifier <= DIKI_KP_9) + entry->locks |= DILS_NUM; + + return DFB_OK; +} + +/* + * End thread, close device and free private data. + */ +static DFBResult +driver_set_sensitivity( CoreInputDevice *device, + void *driver_data, + int sensitivity ) +{ + D_DEBUG_AT( X11_Input, "%s( %d )\n", __FUNCTION__, sensitivity ); + + return DFB_OK; +} + +/* + * End thread, close device and free private data. + */ +static void +driver_close_device( void *driver_data ) +{ + X11InputData *data = driver_data; + DFBX11 *x11 = data->x11; + DFBX11Shared *shared = x11->shared; + + D_DEBUG_AT( X11_Input, "%s()\n", __FUNCTION__ ); + + /* stop input thread */ + data->stop = true; + + XLockDisplay( x11->display ); + + if (shared->xw) { + XWindow *xw = shared->xw; + + shared->xw = NULL; + + /* the window must generate an event, otherwise the input thread will not end */ + dfb_x11_close_window( x11, xw ); + } + + XSync( x11->display, False ); + + XUnlockDisplay( x11->display ); + + /* it is possible that this "close" function is called from the same + * thread that the input device is actually running on. + * This happens when you e.g. click the close box with your mouse. + * As a fix, we check if we are this thread. */ + if (data->thread != direct_thread_self()) { + direct_thread_join( data->thread ); + direct_thread_destroy( data->thread ); + } + + /* free private data */ + D_FREE ( data ); +} + diff --git a/Source/DirectFB/systems/x11/x11types.h b/Source/DirectFB/systems/x11/x11types.h new file mode 100755 index 0000000..872f9db --- /dev/null +++ b/Source/DirectFB/systems/x11/x11types.h @@ -0,0 +1,35 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __SYSTEMS_X11TYPES_H__ +#define __SYSTEMS_X11TYPES_H__ + +typedef struct __DFB_X11 DFBX11; + +#endif /* __SYSTEMS_X11TYPES_H__ */ + diff --git a/Source/DirectFB/systems/x11/xwindow.c b/Source/DirectFB/systems/x11/xwindow.c new file mode 100755 index 0000000..ce5e1fe --- /dev/null +++ b/Source/DirectFB/systems/x11/xwindow.c @@ -0,0 +1,294 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 + +#include +#include +#include + +#include + +#include + +#include "x11.h" + +D_DEBUG_DOMAIN( X11_Window, "X11/Window", "X11 Window handling" ); + +static bool use_shm = true; + +static int +error_handler_shm( Display *display, XErrorEvent *event ) +{ + if (use_shm) { + D_INFO( "X11/Display: Error! Disabling XShm.\n" ); + + use_shm = false; + } + + return 0; +} + + +static int error_code = 0; + +static int +error_handler( Display *display, XErrorEvent *event ) +{ + char buf[512]; + + D_DEBUG_AT( X11_Window, "%s()\n", __FUNCTION__ ); + + XGetErrorText( display, event->error_code, buf, sizeof(buf) ); + + D_ERROR( "X11/Window: Error! %s\n", buf ); + + error_code = event->error_code; + + return 0; +} + +Bool +dfb_x11_open_window( DFBX11 *x11, XWindow** ppXW, int iXPos, int iYPos, int iWidth, int iHeight, DFBSurfacePixelFormat format ) +{ + XWindow *xw; + XSetWindowAttributes attr = { .background_pixmap = 0 }; + + D_DEBUG_AT( X11_Window, "Creating %4dx%4d %s window...\n", iWidth, iHeight, dfb_pixelformat_name(format) ); + + xw = D_CALLOC( 1, sizeof(XWindow) ); + if (!xw) + return D_OOM(); + + /* We set the structure as needed for our window */ + xw->width = iWidth; + xw->height = iHeight; + xw->display = x11->display; + + xw->screenptr = DefaultScreenOfDisplay(xw->display); + xw->screennum = DefaultScreen(xw->display); + xw->depth = DefaultDepthOfScreen(xw->screenptr); + xw->visual = DefaultVisualOfScreen(xw->screenptr); + + attr.event_mask = + ButtonPressMask + | ButtonReleaseMask + | PointerMotionMask + | KeyPressMask + | KeyReleaseMask + | ExposureMask + | StructureNotifyMask; + + XLockDisplay( x11->display ); + + XSetErrorHandler( error_handler ); + + error_code = 0; + + xw->window = XCreateWindow( xw->display, + RootWindowOfScreen(xw->screenptr), + iXPos, iYPos, iWidth, iHeight, 0, xw->depth, InputOutput, + xw->visual, CWEventMask, &attr ); + XSync( xw->display, False ); + if (!xw->window || error_code) { + D_FREE( xw ); + XUnlockDisplay( x11->display ); + return False; + } + + + XSizeHints Hints; + + /* + * Here we inform the function of what we are going to change for the + * window (there's also PPosition but it's obsolete) + */ + Hints.flags = PSize | PMinSize | PMaxSize; + + /* + * Now we set the structure to the values we need for width & height. + * For esthetic reasons we set Width=MinWidth=MaxWidth. + * The same goes for Height. You can try whith differents values, or + * let's use Hints.flags=Psize; and resize your window.. + */ + Hints.min_width = Hints.max_width = Hints.base_width = xw->width; + Hints.min_height = Hints.max_height = Hints.base_height = xw->height; + + /* Now we can set the size hints for the specified window */ + XSetWMNormalHints(xw->display,xw->window,&Hints); + + /* We change the title of the window (default:Untitled) */ + XStoreName(xw->display,xw->window,"DFB X11 system window"); + + xw->gc = XCreateGC(xw->display, xw->window, 0, NULL); + + // Create a null cursor + XColor fore; + XColor back; + char zero = 0; + + xw->pixmp1 = XCreateBitmapFromData( xw->display, xw->window, &zero, 1, 1 ); + xw->pixmp2 = XCreateBitmapFromData( xw->display, xw->window, &zero, 1, 1 ); + + xw->NullCursor = XCreatePixmapCursor( xw->display, xw->pixmp1, xw->pixmp2, &fore, &back, 0, 0 ); + + XDefineCursor( xw->display, xw->window, xw->NullCursor ); + + + /* maps the window and raises it to the top of the stack */ + XMapRaised( xw->display, xw->window ); + + + if (x11->use_shm) { + // Shared memory + xw->shmseginfo=(XShmSegmentInfo *)D_CALLOC(1, sizeof(XShmSegmentInfo)); + if (!xw->shmseginfo) { + x11->use_shm = false; + goto no_shm; + } + + xw->ximage=XShmCreateImage(xw->display, xw->visual, xw->depth, ZPixmap, + NULL,xw->shmseginfo, xw->width, xw->height * 2); + XSync( xw->display, False ); + if (!xw->ximage || error_code) { + D_ERROR("X11: Error creating shared image (XShmCreateImage) \n"); + x11->use_shm = false; + D_FREE(xw->shmseginfo); + error_code = 0; + goto no_shm; + } + + xw->bpp = (xw->ximage->bits_per_pixel + 7) / 8; + + /* we firstly create our shared memory segment with the size we need, and + correct permissions for the owner, the group and the world --> 0777 */ + xw->shmseginfo->shmid=shmget(IPC_PRIVATE, + xw->ximage->bytes_per_line * xw->ximage->height * 2, + IPC_CREAT|0777); + + if (xw->shmseginfo->shmid<0) { + x11->use_shm = false; + XDestroyImage(xw->ximage); + D_FREE(xw->shmseginfo); + goto no_shm; + } + + /* Then, we have to attach the segment to our process, and we let the + function search the correct memory place --> NULL. It's safest ! */ + xw->shmseginfo->shmaddr = shmat( xw->shmseginfo->shmid, NULL, 0 ); + if (!xw->shmseginfo->shmaddr) { + x11->use_shm = false; + shmctl(xw->shmseginfo->shmid,IPC_RMID,NULL); + XDestroyImage(xw->ximage); + D_FREE(xw->shmseginfo); + goto no_shm; + } + + /* We set the buffer in Read and Write mode */ + xw->shmseginfo->readOnly=False; + + xw->virtualscreen= xw->ximage->data = xw->shmseginfo->shmaddr; + + + XSetErrorHandler( error_handler_shm ); + + XShmAttach(x11->display,xw->shmseginfo); + + XShmPutImage(x11->display, xw->window, xw->gc, xw->ximage, + 0, 0, 0, 0, 1, 1, False); + + XSync(x11->display, False); + + XSetErrorHandler( error_handler ); + + if (!x11->use_shm) { + shmdt(xw->shmseginfo->shmaddr); + shmctl(xw->shmseginfo->shmid,IPC_RMID,NULL); + XDestroyImage(xw->ximage); + D_FREE(xw->shmseginfo); + } + } + +no_shm: + if (!x11->use_shm) { + int pitch; + + xw->bpp = (xw->depth > 16) ? 4 : + (xw->depth > 8) ? 2 : 1; + + pitch = (xw->bpp * xw->width + 3) & ~3; + + /* Use malloc(), not D_MALLOC() here, because XCreateImage() + * will call free() on this data. + */ + xw->virtualscreen = malloc ( 2 * xw->height * pitch ); + + xw->ximage = XCreateImage( xw->display, xw->visual, xw->depth, ZPixmap, 0, + xw->virtualscreen, xw->width, xw->height * 2, 32, pitch ); + XSync( xw->display, False ); + if (!xw->ximage || error_code) { + D_ERROR( "X11/Window: XCreateImage( Visual %02lu, depth %d, size %dx%d, buffer %p [%d] ) failed!\n", + xw->visual->visualid, xw->depth, xw->width, xw->height * 2, xw->virtualscreen, pitch ); + XFreeGC(xw->display,xw->gc); + XDestroyWindow(xw->display,xw->window); + XSetErrorHandler( NULL ); + XUnlockDisplay( x11->display ); + D_FREE( xw ); + return False; + } + } + + XSetErrorHandler( NULL ); + + XUnlockDisplay( x11->display ); + + D_INFO( "X11/Display: %ssing XShm.\n", x11->use_shm ? "U" : "Not u" ); + + (*ppXW) = xw; + + return True; +} + +void +dfb_x11_close_window( DFBX11 *x11, XWindow* xw ) +{ + if (x11->use_shm) { + XShmDetach(xw->display, xw->shmseginfo); + shmdt(xw->shmseginfo->shmaddr); + shmctl(xw->shmseginfo->shmid,IPC_RMID,NULL); + D_FREE(xw->shmseginfo); + } + + XDestroyImage(xw->ximage); + + XFreeGC(xw->display,xw->gc); + XDestroyWindow(xw->display,xw->window); + + D_FREE(xw); +} + diff --git a/Source/DirectFB/systems/x11/xwindow.h b/Source/DirectFB/systems/x11/xwindow.h new file mode 100755 index 0000000..9eddfd7 --- /dev/null +++ b/Source/DirectFB/systems/x11/xwindow.h @@ -0,0 +1,77 @@ +/* + (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 , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + 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 __SYSTEMS_XWINDOW_H__ +#define __SYSTEMS_XWINDOW_H__ + +#include /* fundamentals X datas structures */ +#include /* datas definitions for various functions */ +#include /* for a perfect use of keyboard events */ + +#include +#include +#include + +#include "x11types.h" + + +typedef struct { + Display* display; + Window window; + Screen* screenptr; + int screennum; + Visual* visual; + GC gc; + XImage* ximage; + int ximage_offset; + Colormap colormap; + + XShmSegmentInfo* shmseginfo; + unsigned char* videomemory; + + char* virtualscreen; + int videoaccesstype; + + int width; + int height; + int depth; + int bpp; + + /* (Null) cursor stuff*/ + Pixmap pixmp1; + Pixmap pixmp2; + Cursor NullCursor; +} XWindow; + +Bool dfb_x11_open_window ( DFBX11 *x11, XWindow** ppXW, int iXPos, int iYPos, int iWidth, int iHeight, DFBSurfacePixelFormat format ); +void dfb_x11_close_window( DFBX11 *x11, XWindow* pXW ); + + + +#endif /* __SYSTEMS_XWINDOW_H__ */ + -- cgit