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/gfxdrivers/savage/Makefile.am | 45 + Source/DirectFB/gfxdrivers/savage/Makefile.in | 611 ++++++++++++++ Source/DirectFB/gfxdrivers/savage/mmio.h | 98 +++ Source/DirectFB/gfxdrivers/savage/savage.c | 346 ++++++++ Source/DirectFB/gfxdrivers/savage/savage.h | 145 ++++ Source/DirectFB/gfxdrivers/savage/savage2000.c | 199 +++++ Source/DirectFB/gfxdrivers/savage/savage2000.h | 105 +++ Source/DirectFB/gfxdrivers/savage/savage3d.c | 561 +++++++++++++ Source/DirectFB/gfxdrivers/savage/savage3d.h | 121 +++ Source/DirectFB/gfxdrivers/savage/savage4.c | 599 ++++++++++++++ Source/DirectFB/gfxdrivers/savage/savage4.h | 146 ++++ Source/DirectFB/gfxdrivers/savage/savage_bci.h | 208 +++++ .../gfxdrivers/savage/savage_streams_old.c | 916 +++++++++++++++++++++ .../gfxdrivers/savage/savage_streams_old.h | 142 ++++ 14 files changed, 4242 insertions(+) create mode 100755 Source/DirectFB/gfxdrivers/savage/Makefile.am create mode 100755 Source/DirectFB/gfxdrivers/savage/Makefile.in create mode 100755 Source/DirectFB/gfxdrivers/savage/mmio.h create mode 100755 Source/DirectFB/gfxdrivers/savage/savage.c create mode 100755 Source/DirectFB/gfxdrivers/savage/savage.h create mode 100755 Source/DirectFB/gfxdrivers/savage/savage2000.c create mode 100755 Source/DirectFB/gfxdrivers/savage/savage2000.h create mode 100755 Source/DirectFB/gfxdrivers/savage/savage3d.c create mode 100755 Source/DirectFB/gfxdrivers/savage/savage3d.h create mode 100755 Source/DirectFB/gfxdrivers/savage/savage4.c create mode 100755 Source/DirectFB/gfxdrivers/savage/savage4.h create mode 100755 Source/DirectFB/gfxdrivers/savage/savage_bci.h create mode 100755 Source/DirectFB/gfxdrivers/savage/savage_streams_old.c create mode 100755 Source/DirectFB/gfxdrivers/savage/savage_streams_old.h (limited to 'Source/DirectFB/gfxdrivers/savage') diff --git a/Source/DirectFB/gfxdrivers/savage/Makefile.am b/Source/DirectFB/gfxdrivers/savage/Makefile.am new file mode 100755 index 0000000..3479720 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/Makefile.am @@ -0,0 +1,45 @@ +## Makefile.am for DirectFB-internal/gfxdrivers/savage + +INCLUDES = \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/systems \ + -I$(top_srcdir)/src + +savage_LTLIBRARIES = libdirectfb_savage.la + +if BUILD_STATIC +savage_DATA = $(savage_LTLIBRARIES:.la=.o) +endif + +savagedir = $(MODULEDIR)/gfxdrivers + +libdirectfb_savage_la_SOURCES = \ + mmio.h \ + savage.c \ + savage.h \ + savage3d.c \ + savage3d.h \ + savage4.c \ + savage4.h \ + savage2000.c \ + savage2000.h \ + savage_bci.h \ + savage_streams_old.c \ + savage_streams_old.h + +libdirectfb_savage_la_LDFLAGS = \ + -module \ + -avoid-version \ + $(DFB_LDFLAGS) + +libdirectfb_savage_la_LIBADD = \ + -lm \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/src/libdirectfb.la + + +include $(top_srcdir)/rules/libobject.make + diff --git a/Source/DirectFB/gfxdrivers/savage/Makefile.in b/Source/DirectFB/gfxdrivers/savage/Makefile.in new file mode 100755 index 0000000..943a241 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/Makefile.in @@ -0,0 +1,611 @@ +# 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 = gfxdrivers/savage +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)$(savagedir)" "$(DESTDIR)$(savagedir)" +savageLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(savage_LTLIBRARIES) +libdirectfb_savage_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/src/libdirectfb.la +am_libdirectfb_savage_la_OBJECTS = savage.lo savage3d.lo savage4.lo \ + savage2000.lo savage_streams_old.lo +libdirectfb_savage_la_OBJECTS = $(am_libdirectfb_savage_la_OBJECTS) +libdirectfb_savage_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_savage_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_savage_la_SOURCES) +DIST_SOURCES = $(libdirectfb_savage_la_SOURCES) +savageDATA_INSTALL = $(INSTALL_DATA) +DATA = $(savage_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_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/systems \ + -I$(top_srcdir)/src + +savage_LTLIBRARIES = libdirectfb_savage.la +@BUILD_STATIC_TRUE@savage_DATA = $(savage_LTLIBRARIES:.la=.o) +savagedir = $(MODULEDIR)/gfxdrivers +libdirectfb_savage_la_SOURCES = \ + mmio.h \ + savage.c \ + savage.h \ + savage3d.c \ + savage3d.h \ + savage4.c \ + savage4.h \ + savage2000.c \ + savage2000.h \ + savage_bci.h \ + savage_streams_old.c \ + savage_streams_old.h + +libdirectfb_savage_la_LDFLAGS = \ + -module \ + -avoid-version \ + $(DFB_LDFLAGS) + +libdirectfb_savage_la_LIBADD = \ + -lm \ + $(top_builddir)/lib/direct/libdirect.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 gfxdrivers/savage/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu gfxdrivers/savage/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-savageLTLIBRARIES: $(savage_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(savagedir)" || $(MKDIR_P) "$(DESTDIR)$(savagedir)" + @list='$(savage_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(savageLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(savagedir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(savageLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(savagedir)/$$f"; \ + else :; fi; \ + done + +uninstall-savageLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(savage_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(savagedir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(savagedir)/$$p"; \ + done + +clean-savageLTLIBRARIES: + -test -z "$(savage_LTLIBRARIES)" || rm -f $(savage_LTLIBRARIES) + @list='$(savage_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_savage.la: $(libdirectfb_savage_la_OBJECTS) $(libdirectfb_savage_la_DEPENDENCIES) + $(libdirectfb_savage_la_LINK) -rpath $(savagedir) $(libdirectfb_savage_la_OBJECTS) $(libdirectfb_savage_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/savage.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/savage2000.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/savage3d.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/savage4.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/savage_streams_old.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-savageDATA: $(savage_DATA) + @$(NORMAL_INSTALL) + test -z "$(savagedir)" || $(MKDIR_P) "$(DESTDIR)$(savagedir)" + @list='$(savage_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(savageDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(savagedir)/$$f'"; \ + $(savageDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(savagedir)/$$f"; \ + done + +uninstall-savageDATA: + @$(NORMAL_UNINSTALL) + @list='$(savage_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(savagedir)/$$f'"; \ + rm -f "$(DESTDIR)$(savagedir)/$$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)$(savagedir)" "$(DESTDIR)$(savagedir)"; 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-savageLTLIBRARIES \ + 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-savageDATA install-savageLTLIBRARIES + +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-savageDATA uninstall-savageLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-savageLTLIBRARIES 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-savageDATA install-savageLTLIBRARIES install-strip \ + 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-savageDATA \ + uninstall-savageLTLIBRARIES + +%.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/gfxdrivers/savage/mmio.h b/Source/DirectFB/gfxdrivers/savage/mmio.h new file mode 100755 index 0000000..a589cc7 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/mmio.h @@ -0,0 +1,98 @@ +/* + (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 __SAVAGE__MMIO_H__ +#define __SAVAGE__MMIO_H__ + +#include + +typedef u8 uint8; +typedef u16 uint16; +typedef u32 uint32; + +typedef s8 sint8; +typedef s16 sint16; +typedef s32 sint32; + +#if 0 + +static inline void +savage_out32(volatile uint8 *mmioaddr, uint32 reg, uint32 value) +{ + *((uint32*)(mmioaddr+reg)) = value; +} + +static inline volatile uint32 +savage_in32(volatile uint8 *mmioaddr, uint32 reg) +{ + return *((uint32*)(mmioaddr+reg)); +} + +static inline void +savage_out16(volatile uint8 *mmioaddr, uint32 reg, uint16 value) +{ + *((uint16*)(mmioaddr+reg)) = value; +} + +#else + +#define savage_out32(mmio, reg, value) (*((volatile uint32 *) ((mmio)+(reg))) = (uint32)(value)) +#define savage_in32(mmio, reg) (*((volatile uint32 *) ((mmio)+(reg)))) +#define savage_out16(mmio, reg, value) (*((volatile uint16 *) ((mmio)+(reg))) = (uint16)(value)) + +#endif + +#if 0 + +static inline void +vga_out8(volatile uint8 *mmioaddr, uint16 reg, uint8 value) +{ + *((uint8*)(mmioaddr+0x8000+reg)) = value; +} + +static inline void +vga_out16(volatile uint8 *mmioaddr, uint16 reg, uint16 value) +{ + *((uint8*)(mmioaddr+0x8000+reg)) = value; +} + +static inline volatile uint8 +vga_in8(volatile uint8 *mmioaddr, uint16 reg) +{ + return *((uint8*)(mmioaddr+0x8000+reg)); +} + +#else + +#define vga_out8(mmio, reg, value) (*((volatile uint8 *) ((mmio)+0x8000+(reg))) = (uint8)(value)) +#define vga_out16(mmio, reg, value) (*((volatile uint16 *) ((mmio)+0x8000+(reg))) = (uint16)(value)) +#define vga_in8(mmio, reg) (*((volatile uint8 *) ((mmio)+0x8000+(reg)))) + +#endif + +#endif /* __SAVAGE__MMIO_H__ */ diff --git a/Source/DirectFB/gfxdrivers/savage/savage.c b/Source/DirectFB/gfxdrivers/savage/savage.c new file mode 100755 index 0000000..dffb8e3 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage.c @@ -0,0 +1,346 @@ +/* + (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ä , + Claudio Ciccani and + Alex Song . + + 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 + +DFB_GRAPHICS_DRIVER( savage ) + +#include "savage.h" +#include "savage3d.h" +#include "savage4.h" +#include "savage2000.h" +#include "savage_bci.h" + +/* exported symbols */ + +static int +driver_probe( CoreGraphicsDevice *device ) +{ + switch (dfb_gfxcard_get_accelerator( device )) { + case FB_ACCEL_SAVAGE3D: /* Savage3D series */ + case FB_ACCEL_SAVAGE3D_MV: + case FB_ACCEL_SAVAGE_MX_MV: + case FB_ACCEL_SAVAGE_MX: + case FB_ACCEL_SAVAGE_IX_MV: + case FB_ACCEL_SAVAGE_IX: + return 1; + + case FB_ACCEL_SAVAGE4: /* Savage4 series */ + case FB_ACCEL_PROSAVAGE_PM: + case FB_ACCEL_PROSAVAGE_KM: + case FB_ACCEL_S3TWISTER_P: + case FB_ACCEL_S3TWISTER_K: + return 1; + + case FB_ACCEL_SAVAGE2000: /* Savage 2000 */ + return 1; + } + + return 0; +} + +static void +driver_get_info( CoreGraphicsDevice *device, + GraphicsDriverInfo *info ) +{ + /* fill driver info structure */ + snprintf( info->name, + DFB_GRAPHICS_DRIVER_INFO_NAME_LENGTH, + "Savage Driver" ); + + snprintf( info->vendor, + DFB_GRAPHICS_DRIVER_INFO_VENDOR_LENGTH, + "directfb.org" ); + + /* some defaults, each driver has it's own version */ + info->version.major = 0; + info->version.minor = 3; + + info->driver_data_size = sizeof (SavageDriverData); + info->device_data_size = sizeof (SavageDeviceData); + + switch (dfb_gfxcard_get_accelerator( device )) { + case FB_ACCEL_SAVAGE3D: /* Savage3D series */ + case FB_ACCEL_SAVAGE3D_MV: + case FB_ACCEL_SAVAGE_MX_MV: + case FB_ACCEL_SAVAGE_MX: + case FB_ACCEL_SAVAGE_IX_MV: + case FB_ACCEL_SAVAGE_IX: + savage3d_get_info( device, info ); + break; + + case FB_ACCEL_SAVAGE4: /* Savage4 series */ + case FB_ACCEL_PROSAVAGE_PM: + case FB_ACCEL_PROSAVAGE_KM: + case FB_ACCEL_S3TWISTER_P: + case FB_ACCEL_S3TWISTER_K: + savage4_get_info( device, info ); + break; + + case FB_ACCEL_SAVAGE2000: /* Savage 2000 */ + savage2000_get_info( device, info ); + break; + } +} + + +static DFBResult +driver_init_driver( CoreGraphicsDevice *device, + GraphicsDeviceFuncs *funcs, + void *driver_data, + void *device_data, + CoreDFB *core ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + + sdrv->mmio_base = (volatile u8*) dfb_gfxcard_map_mmio( device, 0, -1 ); + if (!sdrv->mmio_base) + return DFB_IO; + + sdrv->bci_base = (volatile u32*)(sdrv->mmio_base + BCI_BUFFER_OFFSET); + + switch (dfb_gfxcard_get_accelerator( device )) { + case FB_ACCEL_SAVAGE3D: /* Savage3D series */ + case FB_ACCEL_SAVAGE3D_MV: + case FB_ACCEL_SAVAGE_MX_MV: + case FB_ACCEL_SAVAGE_MX: + case FB_ACCEL_SAVAGE_IX_MV: + case FB_ACCEL_SAVAGE_IX: + return savage3d_init_driver( device, funcs, driver_data ); + + case FB_ACCEL_SAVAGE4: /* Savage4 series */ + case FB_ACCEL_PROSAVAGE_PM: + case FB_ACCEL_PROSAVAGE_KM: + case FB_ACCEL_S3TWISTER_P: + case FB_ACCEL_S3TWISTER_K: + return savage4_init_driver( device, funcs, driver_data ); + + case FB_ACCEL_SAVAGE2000: /* Savage 2000 */ + return savage2000_init_driver( device, funcs, driver_data ); + } + + return DFB_BUG; +} + +static DFBResult +driver_init_device( CoreGraphicsDevice *device, + GraphicsDeviceInfo *device_info, + void *driver_data, + void *device_data ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + SavageDeviceData *sdev = (SavageDeviceData*) device_data; + volatile u8 *mmio = sdrv->mmio_base; + + /* use polling for syncing, artefacts occur otherwise */ + dfb_config->pollvsync_after = 1; + + sdev->accel_id = dfb_gfxcard_get_accelerator( device ); + + switch (sdev->accel_id) { + case FB_ACCEL_SAVAGE3D: /* Savage3D series */ + case FB_ACCEL_SAVAGE3D_MV: + case FB_ACCEL_SAVAGE_MX_MV: + case FB_ACCEL_SAVAGE_MX: + case FB_ACCEL_SAVAGE_IX_MV: + case FB_ACCEL_SAVAGE_IX: + savage3d_init_device( device, device_info, + driver_data, device_data ); + break; + + case FB_ACCEL_SAVAGE4: /* Savage4 series */ + case FB_ACCEL_PROSAVAGE_PM: + case FB_ACCEL_PROSAVAGE_KM: + case FB_ACCEL_S3TWISTER_P: + case FB_ACCEL_S3TWISTER_K: + savage4_init_device( device, device_info, + driver_data, device_data ); + break; + + case FB_ACCEL_SAVAGE2000: /* Savage 2000 */ + savage2000_init_device( device, device_info, + driver_data, device_data ); + break; + default: + D_BUG("unexpected accelerator id"); + return DFB_BUG; + } + + /* Turn on 16-bit register access. */ + + vga_out8( mmio, 0x3d4, 0x31); + vga_out8( mmio, 0x3d5, 0x0c); + + /* Set stride to use GBD. */ + + vga_out8( mmio, 0x3d4, 0x50); + vga_out8( mmio, 0x3d5, vga_in8( mmio, 0x3d5 ) | 0xC1); + + /* Enable 2D engine. */ + + vga_out8( mmio, 0x3d4, 0x40 ); + vga_out8( mmio, 0x3d5, 0x01 ); + + + savage_out32( mmio, MONO_PAT_0, ~0 ); + savage_out32( mmio, MONO_PAT_1, ~0 ); + + /* Setup plane masks */ + savage_out32( mmio, 0x8128, ~0 ); /* enable all write planes */ + savage_out32( mmio, 0x812C, ~0 ); /* enable all read planes */ + savage_out16( mmio, 0x8134, 0x27 ); + savage_out16( mmio, 0x8136, 0x07 ); + + return DFB_OK; +} + +static void +driver_close_device( CoreGraphicsDevice *device, + void *driver_data, + void *device_data ) +{ + SavageDeviceData *sdev = (SavageDeviceData*) device_data; + + (void) sdev; + + switch (dfb_gfxcard_get_accelerator( device )) { + case FB_ACCEL_SAVAGE3D: /* Savage3D series */ + case FB_ACCEL_SAVAGE3D_MV: + case FB_ACCEL_SAVAGE_MX_MV: + case FB_ACCEL_SAVAGE_MX: + case FB_ACCEL_SAVAGE_IX_MV: + case FB_ACCEL_SAVAGE_IX: + savage3d_close_device( device, driver_data, device_data ); + break; + + case FB_ACCEL_SAVAGE4: /* Savage4 series */ + case FB_ACCEL_PROSAVAGE_PM: + case FB_ACCEL_PROSAVAGE_KM: + case FB_ACCEL_S3TWISTER_P: + case FB_ACCEL_S3TWISTER_K: + savage4_close_device( device, driver_data, device_data ); + break; + + case FB_ACCEL_SAVAGE2000: /* Savage 2000 */ + savage2000_close_device( device, driver_data, device_data ); + break; + } + + D_DEBUG( "DirectFBSavage: FIFO Performance Monitoring:\n" ); + D_DEBUG( "DirectFBSavage: %9d savage_waitfifo calls\n", + sdev->waitfifo_calls ); + D_DEBUG( "DirectFBSavage: %9d savage_waitidle calls\n", + sdev->waitidle_calls ); + D_DEBUG( "DirectFBSavage: %9d register writes (savage_waitfifo sum)\n", + sdev->waitfifo_sum ); + D_DEBUG( "DirectFBSavage: %9d FIFO wait cycles (depends on CPU)\n", + sdev->fifo_waitcycles ); + D_DEBUG( "DirectFBSavage: %9d IDLE wait cycles (depends on CPU)\n", + sdev->idle_waitcycles ); + D_DEBUG( "DirectFBSavage: %9d FIFO space cache hits(depends on CPU)\n", + sdev->fifo_cache_hits ); + D_DEBUG( "DirectFBSavage: Conclusion:\n" ); + D_DEBUG( "DirectFBSavage: Average register writes/savage_waitfifo " + "call: %.2f\n", + sdev->waitfifo_sum/(float)(sdev->waitfifo_calls) ); + D_DEBUG( "DirectFBSavage: Average wait cycles/savage_waitfifo call:" + " %.2f\n", + sdev->fifo_waitcycles/(float)(sdev->waitfifo_calls) ); + D_DEBUG( "DirectFBSavage: Average wait cycles/savage_waitidle call:" + " %.2f\n", + sdev->idle_waitcycles/(float)(sdev->waitidle_calls) ); + D_DEBUG( "DirectFBSavage: Average fifo space cache hits: %02d%%\n", + (int)(100 * sdev->fifo_cache_hits/ + (float)(sdev->waitfifo_calls)) ); +} + +static void +driver_close_driver( CoreGraphicsDevice *device, + void *driver_data ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + + switch (dfb_gfxcard_get_accelerator( device )) { + case FB_ACCEL_SAVAGE3D: /* Savage3D series */ + case FB_ACCEL_SAVAGE3D_MV: + case FB_ACCEL_SAVAGE_MX_MV: + case FB_ACCEL_SAVAGE_MX: + case FB_ACCEL_SAVAGE_IX_MV: + case FB_ACCEL_SAVAGE_IX: + savage3d_close_driver( device, driver_data ); + break; + + case FB_ACCEL_SAVAGE4: /* Savage4 series */ + case FB_ACCEL_PROSAVAGE_PM: + case FB_ACCEL_PROSAVAGE_KM: + case FB_ACCEL_S3TWISTER_P: + case FB_ACCEL_S3TWISTER_K: + savage4_close_driver( device, driver_data ); + break; + + case FB_ACCEL_SAVAGE2000: /* Savage 2000 */ + savage2000_close_driver( device, driver_data ); + break; + } + + dfb_gfxcard_unmap_mmio( device, sdrv->mmio_base, -1 ); +} + diff --git a/Source/DirectFB/gfxdrivers/savage/savage.h b/Source/DirectFB/gfxdrivers/savage/savage.h new file mode 100755 index 0000000..2b9b7c8 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage.h @@ -0,0 +1,145 @@ +/* + (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 __SAVAGE_H__ +#define __SAVAGE_H__ + +#include + +#define SRC_BASE 0xa4d4 +#define DEST_BASE 0xa4d8 +#define CLIP_L_R 0xa4dc +#define CLIP_T_B 0xa4e0 +#define DEST_SRC_STR 0xa4e4 +#define MONO_PAT_0 0xa4e8 +#define MONO_PAT_1 0xa4ec + + +#define BCI_BUFFER_OFFSET 0x10000 + +#define MAXFIFO 0x7f00 + +typedef struct { + unsigned int accel_id; + + unsigned int waitfifo_sum; + unsigned int waitfifo_calls; + unsigned int waitidle_calls; + unsigned int fifo_waitcycles; + unsigned int idle_waitcycles; + unsigned int fifo_cache_hits; + + unsigned int fifo_space; + + unsigned int bci_ptr; +} SavageDeviceData; + +typedef struct { + volatile u8 *mmio_base; + volatile u32 *bci_base; +} SavageDriverData; + + +#if 0 +typedef struct S3SAVDRAWCTRLtag { + hwUI32 uED:1; // Enable Dithering + hwUI32 uUVO:1; // UV Offset Enable (add 0.5 to u and v + hwUI32 uBCM:2; // Backface Cull Mode + // 00 - reserved + // 01 - disable culling + // 10 - cull clockwise + // 11 - cull counterclockwise + hwUI32 uTVC:1; // vertex counter reset 1 - reset it + hwUI32 uSM:1; // Shade Mode 0 - gouraud, 1 - flat (color at vertex 0) + hwUI32 uESS:1; // Enable Specular + hwUI32 uDABM:3; // Destination Alpha Blend Mode look below + hwUI32 uSABM:3; // Source Alpha Blend Mode look below + hwUI32 uReserved1:1; + hwUI32 uATC:3; // Alpha Test Compare look below + hwUI32 uEAT:1; // Enable Alpha Test + hwUI32 uAlphaRef:8; // Alpha Reference Value + hwUI32 uTBC:3; // Texture Blending Control (look below) + hwUI32 uFDW:1; // Flush Destination Writes + hwUI32 uFZW:1; // Flush Z Writes + hwUI32 uIM:1; // Interpolaton Mode 1 - linear color and fog interpolation +} S3SAVDRAWCTRL, *PS3SAVDRAWCTRL; +#endif + +#define DRAWCTRL_ENABLE_DITHERING 0x00000001 +#define DRAWCTRL_ENABLE_UV_OFFSET 0x00000002 +#define DRAWCTRL_CULL_REVERSED 0x00000000 +#define DRAWCTRL_CULL_NONE 0x00000004 +#define DRAWCTRL_CULL_CLOCKWISE 0x00000008 +#define DRAWCTRL_CULL_COUNTERCLOCKWISE 0x0000000C +#define DRAWCTRL_VERTEX_COUNTER_RESET 0x00000010 +#define DRAWCTRL_SHADE_GOURAUD 0x00000000 +#define DRAWCTRL_SHADE_FLAT 0x00000020 +#define DRAWCTRL_ENABLE_SPECULAR 0x00000040 +#define DRAWCTRL_ENABLE_ALPHA_TEST 0x00020000 +#define DRAWCTRL_FLUSH_DESTINATION_WRITES 0x20000000 +#define DRAWCTRL_FLUSH_Z_WRITES 0x40000000 +#define DRAWCTRL_COLOR_AND_FOG_INTERPOLATION 0x80000000 + +#define DRAWCTRL_DABM_ZERO (0 << 7) +#define DRAWCTRL_DABM_ONE (1 << 7) +#define DRAWCTRL_DABM_SOURCE_COLOR (2 << 7) +#define DRAWCTRL_DABM_ONE_MINUS_SOURCE_COLOR (3 << 7) +#define DRAWCTRL_DABM_SOURCE_ALPHA (4 << 7) +#define DRAWCTRL_DABM_ONE_MINUS_SOURCE_ALPHA (5 << 7) +#define DRAWCTRL_DABM_6 (6 << 7) +#define DRAWCTRL_DABM_7 (7 << 7) + +#define DRAWCTRL_SABM_ZERO (0 << 10) +#define DRAWCTRL_SABM_ONE (1 << 10) +#define DRAWCTRL_SABM_DEST_COLOR (2 << 10) +#define DRAWCTRL_SABM_ONE_MINUS_DEST_COLOR (3 << 10) +#define DRAWCTRL_SABM_SOURCE_ALPHA (4 << 10) +#define DRAWCTRL_SABM_ONE_MINUS_SOURCE_ALPHA (5 << 10) +#define DRAWCTRL_SABM_6 (6 << 10) +#define DRAWCTRL_SABM_7 (7 << 10) + +#define DRAWCTRL_ATC_NEVER (0 << 14) +#define DRAWCTRL_ATC_LESS (1 << 14) +#define DRAWCTRL_ATC_EQUAL (2 << 14) +#define DRAWCTRL_ATC_LEQUAL (3 << 14) +#define DRAWCTRL_ATC_GREATER (4 << 14) +#define DRAWCTRL_ATC_NOTEQUAL (5 << 14) +#define DRAWCTRL_ATC_GEQUAL (6 << 14) +#define DRAWCTRL_ATC_ALWAYS (7 << 14) + +#define DRAWCTRL_TBC_DECAL (0 << 26) +#define DRAWCTRL_TBC_MODULATE (1 << 26) +#define DRAWCTRL_TBC_DECALALPHA (2 << 26) +#define DRAWCTRL_TBC_MODULATEALPHA (3 << 26) +#define DRAWCTRL_TBC_4 (4 << 26) +#define DRAWCTRL_TBC_5 (5 << 26) +#define DRAWCTRL_TBC_COPY (6 << 26) +#define DRAWCTRL_TBC_7 (7 << 26) + + +#endif diff --git a/Source/DirectFB/gfxdrivers/savage/savage2000.c b/Source/DirectFB/gfxdrivers/savage/savage2000.c new file mode 100755 index 0000000..0f06ed1 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage2000.c @@ -0,0 +1,199 @@ +/* + (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 "savage.h" +#include "savage2000.h" +#include "mmio.h" + + +/* state validation */ + + +/* required implementations */ + +static DFBResult savage2000EngineSync( void *drv, void *dev ) +{ + Savage2000DriverData *sdrv = (Savage2000DriverData*) drv; + Savage2000DeviceData *sdev = (Savage2000DeviceData*) dev; + + savage2000_waitidle( sdrv, sdev ); + + return DFB_OK; +} + +#define SAVAGE2000_DRAWING_FLAGS \ + (DSDRAW_NOFX) + +#define SAVAGE2000_DRAWING_FUNCTIONS \ + (DFXL_NONE) + +#define SAVAGE2000_BLITTING_FLAGS \ + (DSBLIT_NOFX) + +#define SAVAGE2000_BLITTING_FUNCTIONS \ + (DFXL_NONE) + + +static void savage2000CheckState( void *drv, void *dev, + CardState *state, DFBAccelerationMask accel ) +{ +} + +static void savage2000SetState( void *drv, void *dev, + GraphicsDeviceFuncs *funcs, + CardState *state, DFBAccelerationMask accel ) +{ +} + +static bool savage2000FillRectangle( void *drv, void *dev, DFBRectangle *rect ) +{ + return false; +} + +static bool savage2000DrawRectangle( void *drv, void *dev, DFBRectangle *rect ) +{ + return false; +} + +static bool savage2000DrawLine( void *drv, void *dev, DFBRegion *line ) +{ + return false; +} + +static bool savage2000FillTriangle( void *drv, void *dev, DFBTriangle *tri ) +{ + return false; +} + +static bool savage2000Blit( void *drv, void *dev, + DFBRectangle *rect, int dx, int dy ) +{ + return false; +} + +static bool savage2000StretchBlit( void *drv, void *dev, + DFBRectangle *sr, DFBRectangle *dr ) +{ + return false; +} + +/* exported symbols */ + +void +savage2000_get_info( CoreGraphicsDevice *device, + GraphicsDriverInfo *info ) +{ + info->version.major = 0; + info->version.minor = 0; + + info->driver_data_size = sizeof (Savage2000DriverData); + info->device_data_size = sizeof (Savage2000DeviceData); +} + +DFBResult +savage2000_init_driver( CoreGraphicsDevice *device, + GraphicsDeviceFuncs *funcs, + void *driver_data ) +{ + funcs->CheckState = savage2000CheckState; + funcs->SetState = savage2000SetState; + funcs->EngineSync = savage2000EngineSync; + + funcs->FillRectangle = savage2000FillRectangle; + funcs->DrawRectangle = savage2000DrawRectangle; + funcs->DrawLine = savage2000DrawLine; + funcs->FillTriangle = savage2000FillTriangle; + funcs->Blit = savage2000Blit; + funcs->StretchBlit = savage2000StretchBlit; + + return DFB_OK; +} + +DFBResult +savage2000_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, "Savage2000 Series" ); + + snprintf( device_info->vendor, + DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "S3" ); + + + device_info->caps.flags = 0; + device_info->caps.accel = SAVAGE2000_DRAWING_FUNCTIONS | + SAVAGE2000_BLITTING_FUNCTIONS; + device_info->caps.drawing = SAVAGE2000_DRAWING_FLAGS; + device_info->caps.blitting = SAVAGE2000_BLITTING_FLAGS; + + device_info->limits.surface_byteoffset_alignment = 2048; + device_info->limits.surface_pixelpitch_alignment = 32; + + return DFB_OK; +} + +void +savage2000_close_device( CoreGraphicsDevice *device, + void *driver_data, + void *device_data ) +{ +} + +void +savage2000_close_driver( CoreGraphicsDevice *device, + void *driver_data ) +{ +} + diff --git a/Source/DirectFB/gfxdrivers/savage/savage2000.h b/Source/DirectFB/gfxdrivers/savage/savage2000.h new file mode 100755 index 0000000..de67737 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage2000.h @@ -0,0 +1,105 @@ +/* + (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 __SAVAGE2000_H__ +#define __SAVAGE2000_H__ + +#include + +#include "savage.h" +#include "mmio.h" + +typedef struct { + SavageDeviceData s; +} Savage2000DeviceData; + +typedef struct { + SavageDriverData s; +} Savage2000DriverData; + +void +savage2000_get_info( CoreGraphicsDevice *device, + GraphicsDriverInfo *info ); + +DFBResult +savage2000_init_driver( CoreGraphicsDevice *device, + GraphicsDeviceFuncs *funcs, + void *driver_data ); + +DFBResult +savage2000_init_device( CoreGraphicsDevice *device, + GraphicsDeviceInfo *device_info, + void *driver_data, + void *device_data ); + +void +savage2000_close_device( CoreGraphicsDevice *device, + void *driver_data, + void *device_data ); + +void +savage2000_close_driver( CoreGraphicsDevice *device, + void *driver_data ); + + +#undef FIFOSTATUS +#define FIFOSTATUS 0x48C60 + +/* Wait for fifo space */ +static inline void +savage2000_waitfifo(Savage2000DriverData *sdrv, + Savage2000DeviceData *sdev, int space) +{ + uint32 slots = MAXFIFO - space; + volatile u8 *mmio = sdrv->s.mmio_base; + + sdev->s.waitfifo_sum += space; + sdev->s.waitfifo_calls++; + + if ((savage_in32(mmio, FIFOSTATUS) & 0x000fffff) > slots) { + do { + sdev->s.fifo_waitcycles++; + } while (savage_in32(mmio, FIFOSTATUS) > slots); + } + else { + sdev->s.fifo_cache_hits++; + } +} + +/* Wait for idle accelerator */ +static inline void +savage2000_waitidle(Savage2000DriverData *sdrv, Savage2000DeviceData *sdev) +{ + sdev->s.waitidle_calls++; + + while (savage_in32(sdrv->s.mmio_base, FIFOSTATUS) & 0x009fffff) { + sdev->s.idle_waitcycles++; + } +} + +#endif diff --git a/Source/DirectFB/gfxdrivers/savage/savage3d.c b/Source/DirectFB/gfxdrivers/savage/savage3d.c new file mode 100755 index 0000000..4117b0e --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage3d.c @@ -0,0 +1,561 @@ +/* + (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 "savage.h" +#include "savage_bci.h" +#include "savage3d.h" +#include "mmio.h" +#include "savage_streams_old.h" + + + +/* required implementations */ + +static DFBResult savage3DEngineSync( void *drv, void *dev ) +{ + Savage3DDriverData *sdrv = (Savage3DDriverData*) drv; + Savage3DDeviceData *sdev = (Savage3DDeviceData*) dev; + + savage3D_waitidle( sdrv, sdev ); + + return DFB_OK; +} + +#define SAVAGE3D_DRAWING_FLAGS \ + (DSDRAW_NOFX) + +#define SAVAGE3D_DRAWING_FUNCTIONS \ + (DFXL_FILLRECTANGLE | DFXL_DRAWRECTANGLE | DFXL_DRAWLINE) + +#define SAVAGE3D_BLITTING_FLAGS \ + (DSBLIT_SRC_COLORKEY) + +#define SAVAGE3D_BLITTING_FUNCTIONS \ + (DFXL_BLIT) + + +static inline void savage3D_validate_gbd( Savage3DDriverData *sdrv, + Savage3DDeviceData *sdev, + CardState *state ) +{ + u32 BitmapDescriptor; + CoreSurface *destination; + int bpp; + + + if (sdev->v_gbd) + return; + + destination = state->destination; + bpp = DFB_BYTES_PER_PIXEL(destination->config.format); + + BitmapDescriptor = BCI_BD_BW_DISABLE | 8 | 1; + BCI_BD_SET_BPP( BitmapDescriptor, bpp * 8 ); + BCI_BD_SET_STRIDE( BitmapDescriptor, state->dst.pitch / bpp ); + + /* strange effects if we don't wait here for the Savage3D being idle */ + savage3D_waitidle( sdrv, sdev ); + + savage3D_waitfifo( sdrv, sdev, 4 ); + + BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_GBD1 ); + BCI_SEND( state->dst.offset ); + + BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_GBD2 ); + BCI_SEND( BitmapDescriptor ); + + sdev->v_gbd = 1; +} + +static inline void savage3D_validate_pbd( Savage3DDriverData *sdrv, + Savage3DDeviceData *sdev, + CardState *state ) +{ + u32 BitmapDescriptor; + CoreSurface *source; + int bpp; + + + if (sdev->v_pbd) + return; + + source = state->source; + bpp = DFB_BYTES_PER_PIXEL(source->config.format); + + BitmapDescriptor = BCI_BD_BW_DISABLE; + BCI_BD_SET_BPP( BitmapDescriptor, bpp * 8 ); + BCI_BD_SET_STRIDE( BitmapDescriptor, state->src.pitch / bpp ); + + + savage3D_waitfifo( sdrv, sdev, 4 ); + + BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_PBD1 ); + BCI_SEND( state->src.offset ); + + BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_PBD2 ); + BCI_SEND( BitmapDescriptor ); + + sdev->v_pbd = 1; +} + +static inline void savage3D_validate_color( Savage3DDriverData *sdrv, + Savage3DDeviceData *sdev, + CardState *state ) +{ + if (sdev->v_color) + return; + + savage3D_waitfifo( sdrv, sdev, 2 ); + + BCI_SEND( BCI_CMD_NOP | BCI_CMD_SEND_COLOR ); + + switch (state->destination->config.format) { + case DSPF_A8: + BCI_SEND( state->color.a ); + break; + case DSPF_ARGB1555: + BCI_SEND( PIXEL_ARGB1555(state->color.a, + state->color.r, + state->color.g, + state->color.b) ); + break; + case DSPF_RGB16: + BCI_SEND( PIXEL_RGB16(state->color.r, + state->color.g, + state->color.b) ); + break; + case DSPF_RGB32: + BCI_SEND( PIXEL_RGB32(state->color.r, + state->color.g, + state->color.b) ); + break; + case DSPF_ARGB: + BCI_SEND( PIXEL_ARGB(state->color.a, + state->color.r, + state->color.g, + state->color.b) ); + break; + default: + D_ONCE( "unsupported destination format" ); + break; + } + + sdev->v_color = 1; +} + +static inline void savage3D_set_clip( Savage3DDriverData *sdrv, + Savage3DDeviceData *sdev, + DFBRegion *clip ) +{ + savage3D_waitfifo( sdrv, sdev, 3 ); + + BCI_SEND( BCI_CMD_NOP | BCI_CMD_CLIP_NEW ); + + BCI_SEND( BCI_CLIP_TL( clip->y1, clip->x1 ) ); + BCI_SEND( BCI_CLIP_BR( clip->y2, clip->x2 ) ); +} + +static void savage3DCheckState( void *drv, void *dev, + CardState *state, DFBAccelerationMask accel ) +{ + switch (state->destination->config.format) { + case DSPF_ARGB1555: + case DSPF_RGB16: + case DSPF_RGB32: + case DSPF_ARGB: + break; + default: + return; + } + + if (DFB_DRAWING_FUNCTION( accel )) { + if (state->drawingflags & ~SAVAGE3D_DRAWING_FLAGS) + return; + + state->accel |= SAVAGE3D_DRAWING_FUNCTIONS; + } + else { + if (state->source->config.format != state->destination->config.format) + return; + + if (state->blittingflags & ~SAVAGE3D_BLITTING_FLAGS) + return; + + state->accel |= SAVAGE3D_BLITTING_FUNCTIONS; + } +} + + +static void savage3DSetState( void *drv, void *dev, + GraphicsDeviceFuncs *funcs, + CardState *state, DFBAccelerationMask accel ) +{ + Savage3DDriverData *sdrv = (Savage3DDriverData*) drv; + Savage3DDeviceData *sdev = (Savage3DDeviceData*) dev; + + if (state->mod_hw) { + if (state->mod_hw & SMF_DESTINATION) + sdev->v_gbd = sdev->v_color = 0; + else if (state->mod_hw & SMF_COLOR) + sdev->v_color = 0; + + if (state->mod_hw & SMF_SOURCE) + sdev->v_pbd = 0; + } + + savage3D_validate_gbd( sdrv, sdev, state ); + + switch (accel) { + case DFXL_FILLRECTANGLE: + case DFXL_DRAWRECTANGLE: + case DFXL_DRAWLINE: + case DFXL_FILLTRIANGLE: + savage3D_validate_color( sdrv, sdev, state ); + + state->set |= SAVAGE3D_DRAWING_FUNCTIONS; + break; + + case DFXL_BLIT: + case DFXL_STRETCHBLIT: + savage3D_validate_pbd( sdrv, sdev, state ); + + state->set |= SAVAGE3D_BLITTING_FUNCTIONS; + break; + + default: + D_BUG( "unexpected drawing/blitting function!" ); + return; + } + + if (state->mod_hw & SMF_BLITTING_FLAGS) { + if (state->blittingflags & DSBLIT_SRC_COLORKEY) + sdev->Cmd_Src_Transparent = BCI_CMD_SRC_TRANSPARENT | + BCI_CMD_SEND_COLOR; + else + sdev->Cmd_Src_Transparent = 0; + } + + if (state->mod_hw & SMF_CLIP) + savage3D_set_clip( sdrv, sdev, &state->clip ); + + if (state->mod_hw & SMF_SRC_COLORKEY) + sdev->src_colorkey = state->src_colorkey; + + state->mod_hw = 0; +} + +static bool savage3DFillRectangle( void *drv, void *dev, DFBRectangle *rect ) +{ + Savage3DDriverData *sdrv = (Savage3DDriverData*) drv; + Savage3DDeviceData *sdev = (Savage3DDeviceData*) dev; + + savage3D_waitfifo( sdrv, sdev, 3 ); + + BCI_SEND( BCI_CMD_RECT | BCI_CMD_CLIP_CURRENT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( BCI_X_Y(rect->x, rect->y) ); + BCI_SEND( BCI_W_H(rect->w, rect->h) ); + + return true; +} + +static bool savage3DDrawRectangle( void *drv, void *dev, DFBRectangle *rect ) +{ + Savage3DDriverData *sdrv = (Savage3DDriverData*) drv; + Savage3DDeviceData *sdev = (Savage3DDeviceData*) dev; + + savage3D_waitfifo( sdrv, sdev, 12 ); + + /* first line */ + BCI_SEND( BCI_CMD_RECT | BCI_CMD_CLIP_CURRENT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( BCI_X_Y( rect->x, rect->y) ); + BCI_SEND( BCI_W_H( 1 , rect->h) ); + + /* second line */ + BCI_SEND( BCI_CMD_RECT | BCI_CMD_CLIP_CURRENT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( BCI_X_Y( rect->x, rect->y) ); + BCI_SEND( BCI_W_H( rect->w , 1 ) ); + + /* third line */ + BCI_SEND( BCI_CMD_RECT | BCI_CMD_CLIP_CURRENT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( BCI_X_Y( rect->x, rect->y+rect->h-1 ) ); + BCI_SEND( BCI_W_H( rect->w , 1 ) ); + + /* fourth line */ + BCI_SEND( BCI_CMD_RECT | BCI_CMD_CLIP_CURRENT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( BCI_X_Y( rect->x+rect->w-1, rect->y ) ); + BCI_SEND( BCI_W_H( 1 , rect->h ) ); + + return true; +} + +static bool savage3DDrawLine( void *drv, void *dev, DFBRegion *line ) +{ + Savage3DDriverData *sdrv = (Savage3DDriverData*) drv; + Savage3DDeviceData *sdev = (Savage3DDeviceData*) dev; + + int dx, dy; + int min, max, xp, yp, ym; + + + dx = line->x2 - line->x1; + dy = line->y2 - line->y1; + + xp = (dx >= 0); + if (!xp) + dx = -dx; + + yp = (dy >= 0); + if (!yp) + dy = -dy; + + ym = (dy > dx); + if (ym) { + max = dy + 1; + min = dx; + } + else { + max = dx + 1; + min = dy; + } + + savage3D_waitfifo( sdrv, sdev, 4 ); + + BCI_SEND( BCI_CMD_LINE_LAST_PIXEL | BCI_CMD_CLIP_CURRENT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( BCI_LINE_X_Y( line->x1, line->y1 ) ); + BCI_SEND( BCI_LINE_STEPS( 2 * (min - max), 2 * min ) ); + BCI_SEND( BCI_LINE_MISC( max, ym, xp, yp, 2 * min - max ) ); + + return true; +} + +static bool savage3DFillTriangle( void *drv, void *dev, DFBTriangle *tri ) +{ + return false; +} + +static bool savage3DBlit( void *drv, void *dev, + DFBRectangle *rect, int dx, int dy ) +{ + Savage3DDriverData *sdrv = (Savage3DDriverData*) drv; + Savage3DDeviceData *sdev = (Savage3DDeviceData*) dev; + + u32 cmd = ( BCI_CMD_RECT | sdev->Cmd_Src_Transparent | + BCI_CMD_CLIP_CURRENT | BCI_CMD_DEST_GBD | + BCI_CMD_SRC_PBD_COLOR | (0xcc << 16) ); + + if (dx < rect->x) { + cmd |= BCI_CMD_RECT_XP; + } + else { + dx += rect->w - 1; + rect->x += rect->w - 1; + } + + if (dy < rect->y) { + cmd |= BCI_CMD_RECT_YP; + } + else { + dy += rect->h - 1; + rect->y += rect->h - 1; + } + + savage3D_waitfifo( sdrv, sdev, sdev->Cmd_Src_Transparent ? 5 : 4 ); + + BCI_SEND( cmd ); + + /* we always have to send the colorkey, + but at least it does not clobber the fill color */ + if (sdev->Cmd_Src_Transparent) + BCI_SEND( sdev->src_colorkey ); + + BCI_SEND( BCI_X_Y( rect->x, rect->y ) ); + BCI_SEND( BCI_X_Y( dx, dy ) ); + BCI_SEND( BCI_W_H( rect->w, rect->h ) ); + + return true; +} + +static bool savage3DStretchBlit( void *drv, void *dev, + DFBRectangle *sr, DFBRectangle *dr ) +{ + return false; +} + +static void savage3DAfterSetVar( void *drv, void *dev ) +{ +} + +/* exported symbols */ + +void +savage3d_get_info( CoreGraphicsDevice *device, + GraphicsDriverInfo *info ) +{ + info->version.major = 0; + info->version.minor = 3; + + info->driver_data_size = sizeof (Savage3DDriverData); + info->device_data_size = sizeof (Savage3DDeviceData); +} + +DFBResult +savage3d_init_driver( CoreGraphicsDevice *device, + GraphicsDeviceFuncs *funcs, + void *driver_data ) +{ + funcs->CheckState = savage3DCheckState; + funcs->SetState = savage3DSetState; + funcs->EngineSync = savage3DEngineSync; + funcs->AfterSetVar = savage3DAfterSetVar; + + funcs->FillRectangle = savage3DFillRectangle; + funcs->DrawRectangle = savage3DDrawRectangle; + funcs->DrawLine = savage3DDrawLine; + funcs->FillTriangle = savage3DFillTriangle; + funcs->Blit = savage3DBlit; + funcs->StretchBlit = savage3DStretchBlit; + + return DFB_OK; +} + +DFBResult +savage3d_init_device( CoreGraphicsDevice *device, + GraphicsDeviceInfo *device_info, + void *driver_data, + void *device_data ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + volatile u8 *mmio = sdrv->mmio_base; + + unsigned long cobIndex; /* size index */ + unsigned long cobSize; /* size in bytes */ + unsigned long cobOffset; /* offset in frame buffer */ + + /* fill device info */ + snprintf( device_info->name, + DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH, "Savage3D Series" ); + + snprintf( device_info->vendor, + DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "S3" ); + + + device_info->caps.flags = CCF_CLIPPING; + device_info->caps.accel = SAVAGE3D_DRAWING_FUNCTIONS | + SAVAGE3D_BLITTING_FUNCTIONS; + device_info->caps.drawing = SAVAGE3D_DRAWING_FLAGS; + device_info->caps.blitting = SAVAGE3D_BLITTING_FLAGS; + + device_info->limits.surface_byteoffset_alignment = 2048; + device_info->limits.surface_pixelpitch_alignment = 32; + + + cobIndex = 7; + cobSize = 0x400 << cobIndex; + cobOffset = dfb_gfxcard_reserve_memory( device, cobSize ); + + + /* savage_out32( 0x8504, 0x00008000 ); */ + + /* Disable BCI */ + savage_out32( mmio, 0x48C18, + savage_in32( mmio, 0x48C18 ) & 0x3FF0); + + /* Setup BCI command overflow buffer */ + savage_out32( mmio, 0x48C14, (cobOffset >> 11) | (cobIndex << 29)); + + /* Program shadow status update. */ + savage_out32( mmio, 0x48C10, 0x78207220); + savage_out32( mmio, 0x48C0C, 0); + + /* Enable BCI and command overflow buffer */ + savage_out32( mmio, 0x48C18, savage_in32( mmio, 0x48C18 ) | 0x0C); + + return DFB_OK; +} + +void +savage3d_close_device( CoreGraphicsDevice *device, + void *driver_data, + void *device_data ) +{ +} + +void +savage3d_close_driver( CoreGraphicsDevice *device, + void *driver_data ) +{ +} + diff --git a/Source/DirectFB/gfxdrivers/savage/savage3d.h b/Source/DirectFB/gfxdrivers/savage/savage3d.h new file mode 100755 index 0000000..d693c34 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage3d.h @@ -0,0 +1,121 @@ +/* + (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 __SAVAGE3D_H__ +#define __SAVAGE3D_H__ + +#include + +#include "savage.h" +#include "mmio.h" + + +typedef struct { + SavageDeviceData s; + + /* state validation */ + int v_gbd; /* destination */ + int v_pbd; /* source */ + int v_color; /* opaque fill color */ + + /* saved values */ + u32 Cmd_Src_Transparent; + u32 src_colorkey; +} Savage3DDeviceData; + +typedef struct { + SavageDriverData s; +} Savage3DDriverData; + + +void +savage3d_get_info( CoreGraphicsDevice *device, + GraphicsDriverInfo *info ); + +DFBResult +savage3d_init_driver( CoreGraphicsDevice *device, + GraphicsDeviceFuncs *funcs, + void *driver_data ); + +DFBResult +savage3d_init_device( CoreGraphicsDevice *device, + GraphicsDeviceInfo *device_info, + void *driver_data, + void *device_data ); + +void +savage3d_close_device( CoreGraphicsDevice *device, + void *driver_data, + void *device_data ); + +void +savage3d_close_driver( CoreGraphicsDevice *device, + void *driver_data ); + + +#define FIFOSTATUS 0x48C00 +#define TILEDAPERTURE0 0x48C40 +#define TILEDAPERTURE1 0x48C44 +#define TILEDAPERTURE2 0x48C48 +#define TILEDAPERTURE3 0x48C4C +#define TILEDAPERTURE4 0x48C50 +#define TILEDAPERTURE5 0x48C54 + + +/* Wait for fifo space */ +static inline void +savage3D_waitfifo(Savage3DDriverData *sdrv, Savage3DDeviceData *sdev, int space) +{ + uint32 slots = MAXFIFO - space; + volatile u8 *mmio = sdrv->s.mmio_base; + + sdev->s.waitfifo_sum += space; + sdev->s.waitfifo_calls++; + + if ((savage_in32(mmio, FIFOSTATUS) & 0x0000ffff) > slots) { + do { + sdev->s.fifo_waitcycles++; + } while ((savage_in32(mmio, FIFOSTATUS) & 0x0000ffff) > slots); + } + else { + sdev->s.fifo_cache_hits++; + } +} + +/* Wait for idle accelerator */ +static inline void +savage3D_waitidle(Savage3DDriverData *sdrv, Savage3DDeviceData *sdev) +{ + sdev->s.waitidle_calls++; + + while ((savage_in32(sdrv->s.mmio_base, FIFOSTATUS) & 0x0008ffff) != 0x80000) { + sdev->s.idle_waitcycles++; + } +} + +#endif diff --git a/Source/DirectFB/gfxdrivers/savage/savage4.c b/Source/DirectFB/gfxdrivers/savage/savage4.c new file mode 100755 index 0000000..2026fe7 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage4.c @@ -0,0 +1,599 @@ +/* + (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 "savage.h" +#include "savage4.h" +#include "mmio.h" +#include "savage_bci.h" +/* + * (comment stolen from xfree86 savage driver). + * There are two different streams engines used in the Savage line. + * The old engine is in the 3D, 4, Pro, and Twister. + * The new engine is in the 2000, MX, IX, and Super. + */ +#include "savage_streams_old.h" + +/* #define SAVAGE_DEBUG */ +#ifdef SAVAGE_DEBUG +#define SVGDBG(x...) fprintf(stderr, "savage4:" x) +#else +#define SVGDBG(x...) +#endif + +/* required implementations */ + +static DFBResult savage4EngineSync( void *drv, void *dev ) +{ + Savage4DriverData *sdrv = (Savage4DriverData*) drv; + Savage4DeviceData *sdev = (Savage4DeviceData*) dev; + + SVGDBG("savage4enginesync\n"); + savage4_waitidle( sdrv, sdev ); + + return DFB_OK; +} + +#define SAVAGE4_DRAWING_FLAGS \ + (DSDRAW_NOFX) + +#define SAVAGE4_DRAWING_FUNCTIONS \ + (DFXL_FILLRECTANGLE | DFXL_DRAWRECTANGLE | DFXL_DRAWLINE) + +#define SAVAGE4_BLITTING_FLAGS \ + (DSBLIT_SRC_COLORKEY) + +#define SAVAGE4_BLITTING_FUNCTIONS \ + (DFXL_BLIT) + + +static inline void savage4_validate_gbd( Savage4DriverData *sdrv, + Savage4DeviceData *sdev, + CardState *state ) +{ + u32 BitmapDescriptor; + CoreSurface *destination; + int bpp; + + if (sdev->v_gbd) + return; + + destination = state->destination; + bpp = DFB_BYTES_PER_PIXEL(destination->config.format); + + BitmapDescriptor = BCI_BD_BW_DISABLE | 8 | 1; + BCI_BD_SET_BPP( BitmapDescriptor, bpp * 8 ); + BCI_BD_SET_STRIDE( BitmapDescriptor, state->dst.pitch / bpp ); + + /* strange effects if we don't wait here for the Savage4 being idle */ + savage4_waitidle( sdrv, sdev ); + + BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_GBD1 ); + BCI_SEND( state->dst.offset ); + + BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_GBD2 ); + BCI_SEND( BitmapDescriptor ); + + sdev->v_gbd = 1; +} + +static inline void savage4_validate_pbd( Savage4DriverData *sdrv, + Savage4DeviceData *sdev, + CardState *state ) +{ + u32 BitmapDescriptor; + CoreSurface *source; + int bpp; + + if (sdev->v_pbd) + return; + + source = state->source; + bpp = DFB_BYTES_PER_PIXEL(source->config.format); + + BitmapDescriptor = BCI_BD_BW_DISABLE; + BCI_BD_SET_BPP( BitmapDescriptor, bpp * 8 ); + BCI_BD_SET_STRIDE( BitmapDescriptor, state->src.pitch / bpp ); + + + savage4_waitidle( sdrv, sdev ); + + BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_PBD1 ); + BCI_SEND( state->src.offset ); + + BCI_SEND( BCI_CMD_SETREG | (1 << 16) | BCI_PBD2 ); + BCI_SEND( BitmapDescriptor ); + + sdev->v_pbd = 1; +} + +static inline void savage4_validate_color( Savage4DeviceData *sdev, + CardState *state ) +{ + if (sdev->v_color) + return; + + switch (state->destination->config.format) { + case DSPF_A8: + sdev->Fill_Color = state->color.a; + break; + case DSPF_ARGB1555: + sdev->Fill_Color = PIXEL_ARGB1555(state->color.a, + state->color.r, + state->color.g, + state->color.b); + break; + case DSPF_RGB16: + sdev->Fill_Color = PIXEL_RGB16(state->color.r, + state->color.g, + state->color.b); + break; + case DSPF_RGB32: + sdev->Fill_Color = PIXEL_RGB32(state->color.r, + state->color.g, + state->color.b); + break; + case DSPF_ARGB: + sdev->Fill_Color = PIXEL_ARGB(state->color.a, + state->color.r, + state->color.g, + state->color.b); + break; + case DSPF_RGB332: + sdev->Fill_Color = PIXEL_RGB332(state->color.r, + state->color.g, + state->color.b); + break; + default: + D_BUG( "unexpected destination format" ); + break; + } + + sdev->v_color = 1; +} + +static inline void savage4_set_clip( Savage4DriverData *sdrv, + Savage4DeviceData *sdev, + DFBRegion *clip ) +{ + SVGDBG("savage4_set_clip x1:%i y1:%i x2:%i y2:%i\n", + clip->x1, clip->y1, clip->x2, clip->y2); + savage4_waitfifo( sdrv, sdev, 3 ); + + BCI_SEND( BCI_CMD_NOP | BCI_CMD_CLIP_NEW ); + + BCI_SEND( BCI_CLIP_TL( clip->y1, clip->x1 ) ); + BCI_SEND( BCI_CLIP_BR( clip->y2, clip->x2 ) ); +} + +static void savage4CheckState( void *drv, void *dev, + CardState *state, DFBAccelerationMask accel ) +{ + SVGDBG("savage4checkstate\n"); + switch (state->destination->config.format) { + case DSPF_ARGB1555: + case DSPF_RGB16: + case DSPF_RGB32: + case DSPF_ARGB: + case DSPF_RGB332: + break; + default: + return; + } + + if (DFB_DRAWING_FUNCTION( accel )) { + if (state->drawingflags & ~SAVAGE4_DRAWING_FLAGS) + return; + + state->accel |= SAVAGE4_DRAWING_FUNCTIONS; + } + else { + if (state->source->config.format != state->destination->config.format) + return; + + if (state->blittingflags & ~SAVAGE4_BLITTING_FLAGS) + return; + + state->accel |= SAVAGE4_BLITTING_FUNCTIONS; + } +} + +static void savage4SetState( void *drv, void *dev, + GraphicsDeviceFuncs *funcs, + CardState *state, DFBAccelerationMask accel ) +{ + Savage4DriverData *sdrv = (Savage4DriverData*) drv; + Savage4DeviceData *sdev = (Savage4DeviceData*) dev; + + SVGDBG("savage4setstate\n"); + if (state->mod_hw) { + if (state->mod_hw & SMF_DESTINATION) + sdev->v_gbd = sdev->v_color = 0; + else if (state->mod_hw & SMF_COLOR) + sdev->v_color = 0; + + if (state->mod_hw & SMF_SOURCE) + sdev->v_pbd = 0; + } + + savage4_validate_gbd( sdrv, sdev, state ); + + switch (accel) { + case DFXL_FILLRECTANGLE: + case DFXL_DRAWRECTANGLE: + case DFXL_DRAWLINE: + case DFXL_FILLTRIANGLE: + savage4_validate_color( sdev, state ); + + state->set |= SAVAGE4_DRAWING_FUNCTIONS; + break; + + case DFXL_BLIT: + case DFXL_STRETCHBLIT: + savage4_validate_pbd( sdrv, sdev, state ); + + state->set |= SAVAGE4_BLITTING_FUNCTIONS; + break; + + default: + D_BUG( "unexpected drawing/blitting function!" ); + return; + } + + if (state->mod_hw & SMF_BLITTING_FLAGS) { + if (state->blittingflags & DSBLIT_SRC_COLORKEY) + sdev->Cmd_Src_Transparent = BCI_CMD_SRC_TRANSPARENT | + BCI_CMD_SEND_COLOR; + else + sdev->Cmd_Src_Transparent = 0; + } + + if (state->mod_hw & SMF_CLIP) + savage4_set_clip( sdrv, sdev, &state->clip ); + + if (state->mod_hw & SMF_SRC_COLORKEY) + sdev->src_colorkey = state->src_colorkey; + + state->mod_hw = 0; +} + + +static bool savage4FillRectangle( void *drv, void *dev, DFBRectangle *rect ) +{ + Savage4DriverData *sdrv = (Savage4DriverData*) drv; + Savage4DeviceData *sdev = (Savage4DeviceData*) dev; + + savage4_waitfifo( sdrv, sdev, 4 ); + + BCI_SEND( BCI_CMD_RECT | BCI_CMD_SEND_COLOR | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | BCI_CMD_CLIP_CURRENT | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( sdev->Fill_Color ); + + BCI_SEND( BCI_X_Y(rect->x, rect->y) ); + BCI_SEND( BCI_W_H(rect->w, rect->h) ); + + return true; +} + +static bool savage4DrawRectangle( void *drv, void *dev, DFBRectangle *rect ) +{ + Savage4DriverData *sdrv = (Savage4DriverData*) drv; + Savage4DeviceData *sdev = (Savage4DeviceData*) dev; + + savage4_waitfifo( sdrv, sdev, 13 ); + + /* first line */ + BCI_SEND( BCI_CMD_RECT | BCI_CMD_SEND_COLOR | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( sdev->Fill_Color ); + + BCI_SEND( BCI_X_Y( rect->x, rect->y) ); + BCI_SEND( BCI_W_H( 1 , rect->h) ); + + /* second line */ + BCI_SEND( BCI_CMD_RECT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( BCI_X_Y( rect->x, rect->y) ); + BCI_SEND( BCI_W_H( rect->w , 1 ) ); + + /* third line */ + BCI_SEND( BCI_CMD_RECT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( BCI_X_Y( rect->x, rect->y+rect->h-1 ) ); + BCI_SEND( BCI_W_H( rect->w , 1 ) ); + + + /* fourth line */ + BCI_SEND( BCI_CMD_RECT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( BCI_X_Y( rect->x+rect->w-1, rect->y ) ); + BCI_SEND( BCI_W_H( 1 , rect->h ) ); + + return true; +} + +static bool savage4DrawLine( void *drv, void *dev, DFBRegion *line ) +{ + Savage4DriverData *sdrv = (Savage4DriverData*) drv; + Savage4DeviceData *sdev = (Savage4DeviceData*) dev; + + int dx, dy; + int min, max, xp, yp, ym; + + + dx = line->x2 - line->x1; + dy = line->y2 - line->y1; + + xp = (dx >= 0); + if (!xp) + dx = -dx; + + yp = (dy >= 0); + if (!yp) + dy = -dy; + + ym = (dy > dx); + if (ym) { + max = dy + 1; + min = dx; + } + else { + max = dx + 1; + min = dy; + } + + savage4_waitfifo( sdrv, sdev, 5 ); + + BCI_SEND( BCI_CMD_LINE_LAST_PIXEL | BCI_CMD_CLIP_CURRENT | + BCI_CMD_RECT_XP | BCI_CMD_RECT_YP | BCI_CMD_SEND_COLOR | + BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID | (0xcc << 16) ); + + BCI_SEND( sdev->Fill_Color ); + + BCI_SEND( BCI_LINE_X_Y( line->x1, line->y1 ) ); + BCI_SEND( BCI_LINE_STEPS( 2 * (min - max), 2 * min ) ); + BCI_SEND( BCI_LINE_MISC( max, ym, xp, yp, 2 * min - max ) ); + + return true; +} + +static bool savage4FillTriangle( void *drv, void *dev, DFBTriangle *tri ) +{ + return false; +} + +static bool savage4Blit( void *drv, void *dev, + DFBRectangle *rect, int dx, int dy ) +{ + Savage4DriverData *sdrv = (Savage4DriverData*) drv; + Savage4DeviceData *sdev = (Savage4DeviceData*) dev; + + u32 cmd = ( BCI_CMD_RECT | sdev->Cmd_Src_Transparent | + BCI_CMD_CLIP_CURRENT | BCI_CMD_DEST_GBD | + BCI_CMD_SRC_PBD_COLOR | (0xcc << 16) ); + + SVGDBG("savage4Blit x:%i y:%i w:%i h:%i dx:%i dy:%i\n", + rect->x, rect->y, rect->w, rect->h, dx, dy); + + if (dx < rect->x && dx >= 0) { + cmd |= BCI_CMD_RECT_XP; /* left to right */ + } + else { + dx += rect->w - 1; + rect->x += rect->w - 1; + } + + if (dy < rect->y && dy >= 0) { + cmd |= BCI_CMD_RECT_YP; /* top to bottom */ + } + else { + dy += rect->h - 1; + rect->y += rect->h - 1; + } + + savage4_waitfifo( sdrv, sdev, sdev->Cmd_Src_Transparent ? 5 : 4 ); + + BCI_SEND( cmd ); + + /* we always have to send the colorkey, + but at least it does not clobber the fill color */ + if (sdev->Cmd_Src_Transparent) + BCI_SEND( sdev->src_colorkey ); + + BCI_SEND( BCI_X_Y( rect->x, rect->y ) ); + BCI_SEND( BCI_X_Y( dx, dy ) ); + BCI_SEND( BCI_W_H( rect->w, rect->h ) ); + + return true; +} + +static bool savage4StretchBlit( void *drv, void *dev, + DFBRectangle *sr, DFBRectangle *dr ) +{ + return false; +} + +static void savage4AfterSetVar( void *drv, void *dev ) +{ + SVGDBG("savage4aftersetvar\n"); +} + +/* exported symbols */ + +void +savage4_get_info( CoreGraphicsDevice *device, + GraphicsDriverInfo *info ) +{ + SVGDBG("savage4getinfo\n"); + info->version.major = 0; + info->version.minor = 3; + + info->driver_data_size = sizeof (Savage4DriverData); + info->device_data_size = sizeof (Savage4DeviceData); +} + +DFBResult +savage4_init_driver( CoreGraphicsDevice *device, + GraphicsDeviceFuncs *funcs, + void *driver_data ) +{ + SVGDBG("savage4initdriver\n"); + funcs->CheckState = savage4CheckState; + funcs->SetState = savage4SetState; + funcs->EngineSync = savage4EngineSync; + + funcs->AfterSetVar = savage4AfterSetVar; + + funcs->FillRectangle = savage4FillRectangle; + funcs->DrawRectangle = savage4DrawRectangle; + funcs->DrawLine = savage4DrawLine; + funcs->FillTriangle = savage4FillTriangle; + funcs->Blit = savage4Blit; + funcs->StretchBlit = savage4StretchBlit; + + /* setup primary layer functions */ +// dfb_layers_hook_primary(device, driver_data, &savagePrimaryFuncs, +// &savage_pfuncs, &savage_pdriver_data); + + /* setup secondary layer functions */ + // dfb_layers_register(device, driver_data, &savageSecondaryFuncs); + + return DFB_OK; +} + +DFBResult +savage4_init_device( CoreGraphicsDevice *device, + GraphicsDeviceInfo *device_info, + void *driver_data, + void *device_data ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + volatile u8 *mmio = sdrv->mmio_base; + + SVGDBG("savage4initdevice\n"); + + /* fill device info */ + snprintf( device_info->name, + DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH, "Savage4 Series" ); + + snprintf( device_info->vendor, + DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "S3" ); + + + device_info->caps.flags = CCF_CLIPPING; + device_info->caps.accel = SAVAGE4_DRAWING_FUNCTIONS | + SAVAGE4_BLITTING_FUNCTIONS; + device_info->caps.drawing = SAVAGE4_DRAWING_FLAGS; + device_info->caps.blitting = SAVAGE4_BLITTING_FLAGS; + + device_info->limits.surface_byteoffset_alignment = 2048; + device_info->limits.surface_pixelpitch_alignment = 32; + + + vga_out8( mmio, 0x3d4, CR_SYSCONF ); + vga_out8( mmio, 0x3d5, CR_SYSCONF_ENABLE_2D_ENGINE_IO_ACCESS ); + + vga_out8( mmio, 0x3d4, CR_MEMCONF ); + vga_out8( mmio, 0x3d5, CR_MEMCONF_ENABLE_VGA_16BIT_IO_ACCESS | + CR_MEMCONF_ENHANCED_MODE_MEMORY_MAPPING ); + + + /* Setup plane masks */ + savage_out32( mmio, SAVAGE_2D_WRITE_MASK, ~0 ); + savage_out32( mmio, SAVAGE_2D_READ_MASK, ~0 ); + savage_out16( mmio, SAVAGE_2D_BACKGROUND_MIX, 0x03 ); + savage_out16( mmio, SAVAGE_2D_FOREGROUND_MIX, 0x27 ); + + /* Disable BCI */ + savage_out32( mmio, SAVAGE_COMMAND_OVERFLOW_BUFFER_POINTERS, + (savage_in32( mmio, 0x48C18)) & 0x3FF0); + + /* Program shadow status update */ + savage_out32( mmio, 0x48C10, 0x00700040); + + savage_out32( mmio, 0x48C0C, 0); + + /* Enable BCI without the COB */ + savage_out32( mmio, SAVAGE_COMMAND_OVERFLOW_BUFFER_POINTERS, + (savage_in32( mmio, 0x48C18)) | 0x08); + + return DFB_OK; +} + +void +savage4_close_device( CoreGraphicsDevice *device, + void *driver_data, + void *device_data ) +{ + SVGDBG("savage4closedevice\n"); +} + +void +savage4_close_driver( CoreGraphicsDevice *device, + void *driver_data ) +{ + SVGDBG("savage4closedriver\n"); +} +/* end of code */ diff --git a/Source/DirectFB/gfxdrivers/savage/savage4.h b/Source/DirectFB/gfxdrivers/savage/savage4.h new file mode 100755 index 0000000..ca46f9f --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage4.h @@ -0,0 +1,146 @@ +/* + (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 __SAVAGE4_H__ +#define __SAVAGE4_H__ + +#include + +#include "mmio.h" + +typedef struct { + SavageDeviceData s; + + /* state validation */ + int v_gbd; /* destination */ + int v_pbd; /* source */ + int v_color; /* opaque fill color */ + + /* saved values */ + u32 Cmd_Src_Transparent; + u32 Fill_Color; + u32 src_colorkey; +} Savage4DeviceData; + +typedef struct { + SavageDriverData s; +} Savage4DriverData; + + +void +savage4_get_info( CoreGraphicsDevice *device, + GraphicsDriverInfo *info ); + +DFBResult +savage4_init_driver( CoreGraphicsDevice *device, + GraphicsDeviceFuncs *funcs, + void *driver_data ); + +DFBResult +savage4_init_device( CoreGraphicsDevice *device, + GraphicsDeviceInfo *device_info, + void *driver_data, + void *device_data ); + +void +savage4_close_device( CoreGraphicsDevice *device, + void *driver_data, + void *device_data ); + +void +savage4_close_driver( CoreGraphicsDevice *device, + void *driver_data ); + + +#define CR_MEMCONF 0x31 +#define CR_MEMCONF_ENABLE_VGA_16BIT_IO_ACCESS 0x04 +#define CR_MEMCONF_ENHANCED_MODE_MEMORY_MAPPING 0x08 + +#define CR_SYSCONF 0x40 +#define CR_SYSCONF_ENABLE_2D_ENGINE_IO_ACCESS 0x01 + + +#define SAVAGE_2D_WRITE_MASK 0x8128 +#define SAVAGE_2D_READ_MASK 0x812C +#define SAVAGE_2D_BACKGROUND_MIX 0x8134 +#define SAVAGE_2D_FOREGROUND_MIX 0x8136 + + +/* Configuration/Status Registers */ + +#define SAVAGE_STATUS_WORD0 0x48C00 +#define SAVAGE_STATUS_WORD1 0x48C04 +#define SAVAGE_STATUS_WORD2 0x48C08 +#define SAVAGE_SHADOW_STATUS_ADDRESS 0x48C0C +#define SAVAGE_COMMAND_BUFFER_THRESHOLDS 0x48C10 +#define SAVAGE_COMMAND_OVERFLOW_BUFFER 0x48C14 +#define SAVAGE_COMMAND_OVERFLOW_BUFFER_POINTERS 0x48C18 +#define SAVAGE_VERTEX_BUFFER_ADDRESS 0x48C20 +#define SAVAGE_BCI_POWER_MANAGEMENT 0x48C24 +#define SAVAGE_TILED_SURFACE0 0x48C40 +#define SAVAGE_TILED_SURFACE1 0x48C44 +#define SAVAGE_TILED_SURFACE2 0x48C48 +#define SAVAGE_TILED_SURFACE3 0x48C4C +#define SAVAGE_TILED_SURFACE4 0x48C50 +#define SAVAGE_ALTERNATE_STATUS_WORD0 0x48C60 +#define SAVAGE_ALTERNATE_STATUS_WORD1 0x48C64 + + +/* Wait for fifo space */ +static inline void +savage4_waitfifo(Savage4DriverData *sdrv, Savage4DeviceData *sdev, int space) +{ + uint32 slots = MAXFIFO - space; + volatile u8 *mmio = sdrv->s.mmio_base; + + sdev->s.waitfifo_sum += space; + sdev->s.waitfifo_calls++; + + if ((savage_in32(mmio, SAVAGE_ALTERNATE_STATUS_WORD0) & 0x001fffff) > slots) { + do { + sdev->s.fifo_waitcycles++; + } while ((savage_in32(mmio, SAVAGE_ALTERNATE_STATUS_WORD0) & 0x001fffff) > slots); + } + else { + sdev->s.fifo_cache_hits++; + } +} + +/* Wait for idle accelerator */ +static inline void +savage4_waitidle(Savage4DriverData *sdrv, Savage4DeviceData *sdev) +{ + sdev->s.waitidle_calls++; + + while ((savage_in32(sdrv->s.mmio_base, SAVAGE_ALTERNATE_STATUS_WORD0) & 0x00a00000) != 0x00a00000) { + sdev->s.idle_waitcycles++; + } +} + + +#endif diff --git a/Source/DirectFB/gfxdrivers/savage/savage_bci.h b/Source/DirectFB/gfxdrivers/savage/savage_bci.h new file mode 100755 index 0000000..12ff14a --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage_bci.h @@ -0,0 +1,208 @@ +/* + (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 _S3BCI_H_ +#define _S3BCI_H_ + +#define REVERSE_BYTE_ORDER32(dword) {\ + unsigned int temp; \ + dword = (temp & 0xFF) << 24; \ + dword |= (temp & 0xFF00) << 8; \ + dword |= (temp & 0xFF0000) >> 8; \ + dword |= (temp & 0xFF000000) >> 24; } + + +#define BCI_SIZE 0x4000 + +#define BCI_SEND(dw) { \ + if (sdev->s.bci_ptr == BCI_SIZE) sdev->s.bci_ptr = 0; \ + sdrv->s.bci_base[sdev->s.bci_ptr++] = (u32)(dw); \ + } + +#define BCI_SENDF(dw) { \ + if (sdev->s.bci_ptr == BCI_SIZE) sdev->s.bci_ptr = 0; \ + ((float*)sdrv->s.bci_base)[sdev->s.bci_ptr++] = (float)(dw); \ + } + + +#define BCI_CMD_NOP 0x40000000 +//#define BCI_CMD_SETREG 0x96000000 /* 8}CMD | 8}count | 16}index */ +#define BCI_CMD_RECT 0x48000000 +#define BCI_CMD_RECT_XP 0x01000000 +#define BCI_CMD_RECT_YP 0x02000000 +#define BCI_CMD_SCANLINE 0x50000000 +#define BCI_CMD_LINE 0x5C000000 +#define BCI_CMD_LINE_LAST_PIXEL 0x58000000 +#define BCI_CMD_BYTE_TEXT 0x63000000 +#define BCI_CMD_NT_BYTE_TEXT 0x67000000 +#define BCI_CMD_BIT_TEXT 0x6C000000 +#define BCI_CMD_GET_ROP(cmd) (((cmd) >> 16) & 0xFF) +#define BCI_CMD_SET_ROP(cmd, rop) ((cmd) |= ((rop & 0xFF) << 16)) +#define BCI_CMD_SEND_COLOR 0x00008000 + +#define BCI_CMD_CLIP_NONE 0x00000000 +#define BCI_CMD_CLIP_CURRENT 0x00002000 +#define BCI_CMD_CLIP_LR 0x00004000 +#define BCI_CMD_CLIP_NEW 0x00006000 + +#define BCI_CMD_DEST_GBD 0x00000000 +#define BCI_CMD_DEST_PBD 0x00000800 +#define BCI_CMD_DEST_PBD_NEW 0x00000C00 +#define BCI_CMD_DEST_SBD 0x00001000 +#define BCI_CMD_DEST_SBD_NEW 0x00001400 + +#define BCI_CMD_SRC_TRANSPARENT 0x00000200 +#define BCI_CMD_SRC_SOLID 0x00000000 +#define BCI_CMD_SRC_GBD 0x00000020 +#define BCI_CMD_SRC_COLOR 0x00000040 +#define BCI_CMD_SRC_MONO 0x00000060 +#define BCI_CMD_SRC_PBD_COLOR 0x00000080 +#define BCI_CMD_SRC_PBD_MONO 0x000000A0 +#define BCI_CMD_SRC_PBD_COLOR_NEW 0x000000C0 +#define BCI_CMD_SRC_PBD_MONO_NEW 0x000000E0 +#define BCI_CMD_SRC_SBD_COLOR 0x00000100 +#define BCI_CMD_SRC_SBD_MONO 0x00000120 +#define BCI_CMD_SRC_SBD_COLOR_NEW 0x00000140 +#define BCI_CMD_SRC_SBD_MONO_NEW 0x00000160 + +#define BCI_CMD_PAT_TRANSPARENT 0x00000010 +#define BCI_CMD_PAT_NONE 0x00000000 +#define BCI_CMD_PAT_COLOR 0x00000002 +#define BCI_CMD_PAT_MONO 0x00000003 +#define BCI_CMD_PAT_PBD_COLOR 0x00000004 +#define BCI_CMD_PAT_PBD_MONO 0x00000005 +#define BCI_CMD_PAT_PBD_COLOR_NEW 0x00000006 +#define BCI_CMD_PAT_PBD_MONO_NEW 0x00000007 +#define BCI_CMD_PAT_SBD_COLOR 0x00000008 +#define BCI_CMD_PAT_SBD_MONO 0x00000009 +#define BCI_CMD_PAT_SBD_COLOR_NEW 0x0000000A +#define BCI_CMD_PAT_SBD_MONO_NEW 0x0000000B + +#define BCI_BD_BW_DISABLE 0x10000000 +#define BCI_BD_TILE_MASK 0x03000000 +#define BCI_BD_TILE_NONE 0x00000000 +#define BCI_BD_TILE_16 0x02000000 +#define BCI_BD_TILE_32 0x04000000 +#define BCI_BD_GET_BPP(bd) (((bd) >> 16) & 0xFF) +#define BCI_BD_SET_BPP(bd, bpp) ((bd) |= (((bpp) & 0xFF) << 16)) +#define BCI_BD_GET_STRIDE(bd) ((bd) & 0xFFFF) +#define BCI_BD_SET_STRIDE(bd, st) ((bd) |= ((st) & 0xFFFF)) + +#define BCI_W_H(w, h) (((h) << 16) | ((w) & 0xFFF)) +#define BCI_X_Y(x, y) (((y) << 16) | ((x) & 0xFFF)) +#define BCI_X_W(x, y) (((w) << 16) | ((x) & 0xFFF)) +#define BCI_CLIP_LR(l, r) (((r) << 16) | ((l) & 0xFFF)) +#define BCI_CLIP_TL(t, l) (((t) << 16) | ((l) & 0xFFF)) +#define BCI_CLIP_BR(b, r) (((b) << 16) | ((r) & 0xFFF)) + +#define BCI_LINE_X_Y(x, y) (((y) << 16) | ((x) & 0xFFFF)) +#define BCI_LINE_STEPS(diag, axi) (((axi) << 16) | ((diag) & 0xFFFF)) +#define BCI_LINE_MISC(maj, ym, xp, yp, err) \ +(((maj) & 0xFFF) | (((ym) & 1) << 13) | \ +(((xp) & 1) << 14) | (((yp) & 1) << 15) | \ +((err) << 16)) + + +/* definition of BCI register indices */ +#define BCI_VERTEX0 0x00 +#define BCI_VERTEX1 0x08 +#define BCI_VERTEX2 0x10 +#define BCI_TEXPALADDR 0x18 +#define BCI_COLORKEY 0x19 +#define BCI_TEXADDR 0x1A +#define BCI_TEXDESC 0x1B +#define BCI_TEXCTRL 0x1C +#define BCI_FOGTABLE 0x20 +#define BCI_FOGCTRL 0x30 +#define BCI_DRAWCTRL 0x31 +#define BCI_ZBCTRL 0x32 +#define BCI_ZBADDR 0x33 +#define BCI_DESTCTRL 0x34 +#define BCI_SCSTART 0x35 +#define BCI_SCEND 0x36 +#define BCI_ZWATER 0x37 +#define BCI_DWATER 0x38 + + + +// 8}CMD|8}count|16}skipflags +#define BCI_CMD_TRILIST 0x80000000L +#define BCI_CMD_TRISTRIP 0x82000000L +#define BCI_CMD_TRIFAN 0x84000000L +#define BCI_CMD_QUADLIST 0x86000000L +// or this one with previous commands if this vertex list +// is continuation of previous one +#define BCI_CMD_CONTINUE 0x01000000L +// set any register that has bci index 8}CMD|8}count|16}index +#define BCI_CMD_SETREG 0x96000000L +// update shadow status 8}CMD|24}tag +#define BCI_CMD_UPDSHADOW 0x98000000L + +#define BCI_CMD_WAIT 0xC0000000L +#define BCI_WAIT_3D_IDLE 0x00010000L +#define BCI_WAIT_2D_IDLE 0x00020000L +#define BCI_WAIT_PAGEFLIP 0x01000000L +#define BCI_WAIT_SCANLINE 0x02000000L + +#define BCI_SKIP_Z 0x01 +#define BCI_SKIP_W 0x02 +#define BCI_SKIP_DIFFUSE 0x04 +#define BCI_SKIP_SPECULAR 0x08 +#define BCI_SKIP_U 0x10 +#define BCI_SKIP_V 0x20 + +/* definition of BCI register indices */ +#define BCI_VERTEX0 0x00 +#define BCI_VERTEX1 0x08 +#define BCI_VERTEX2 0x10 +#define BCI_TEXPALADDR 0x18 +#define BCI_COLORKEY 0x19 +#define BCI_TEXADDR 0x1A +#define BCI_TEXDESC 0x1B +#define BCI_TEXCTRL 0x1C +#define BCI_FOGTABLE 0x20 +#define BCI_FOGCTRL 0x30 +#define BCI_DRAWCTRL 0x31 +#define BCI_ZBCTRL 0x32 +#define BCI_ZBADDR 0x33 +#define BCI_DESTCTRL 0x34 +#define BCI_SCSTART 0x35 +#define BCI_SCEND 0x36 +#define BCI_ZWATER 0x37 +#define BCI_DWATER 0x38 + +/* 2D regs */ +#define BCI_GBD1 0xE0 +#define BCI_GBD2 0xE1 +#define BCI_PBD1 0xE2 +#define BCI_PBD2 0xE3 +#define BCI_SBD1 0xE4 +#define BCI_SBD2 0xE5 + + +#endif /* _S3BCI_H_ */ diff --git a/Source/DirectFB/gfxdrivers/savage/savage_streams_old.c b/Source/DirectFB/gfxdrivers/savage/savage_streams_old.c new file mode 100755 index 0000000..72673a2 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage_streams_old.c @@ -0,0 +1,916 @@ +/* + (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 "savage.h" +#include "savage_streams_old.h" +#include "mmio.h" +#include "savage_bci.h" + +/* #define SAVAGE_DEBUG */ +#ifdef SAVAGE_DEBUG + #define SVGDBG(x...) fprintf(stderr, "savage_streams_old:" x) +#else + #define SVGDBG(x...) +#endif + +typedef struct { + DFBRectangle dest; + CoreLayerRegionConfig config; + int video_pitch; + + struct { + /* secondary stream registers */ + u32 SSTREAM_CTRL; + u32 SSTREAM_H_SCALE; + u32 BLEND_CTRL; + u32 SSTREAM_MULTIBUF; + u32 SSTREAM_FB_ADDR0; + u32 SSTREAM_FB_ADDR1; + u32 SSTREAM_STRIDE; + u32 SSTREAM_V_SCALE; + u32 SSTREAM_V_INIT_VALUE; + u32 SSTREAM_SRC_LINE_COUNT; + u32 SSTREAM_WIN_START; + u32 SSTREAM_WIN_SIZE; + u32 SSTREAM_FB_CB_ADDR; + u32 SSTREAM_FB_CR_ADDR; + u32 SSTREAM_CBCR_STRIDE; + u32 SSTREAM_FB_SIZE; + u32 SSTREAM_FB_ADDR2; + u32 CHROMA_KEY_CONTROL; + u32 CHROMA_KEY_UPPER_BOUND; + } regs; +} SavageSecondaryLayerData; + +typedef struct { + CoreLayerRegionConfig config; + CoreSurfaceBufferLock *lock; + bool init; + + struct { + /* primary stream registers */ + u32 PSTREAM_CTRL; + u32 PSTREAM_FB_ADDR0; + u32 PSTREAM_FB_ADDR1; + u32 PSTREAM_STRIDE; + u32 PSTREAM_WIN_START; + u32 PSTREAM_WIN_SIZE; + u32 PSTREAM_FB_SIZE; + } regs; +} SavagePrimaryLayerData; + +DisplayLayerFuncs savage_pfuncs; +void *savage_pdriver_data; + +/* function prototypes */ +static void +secondary_set_regs (SavageDriverData *sdrv, + SavageSecondaryLayerData *slay); +static void +secondary_calc_regs(SavageDriverData *sdrv, + SavageSecondaryLayerData *slay, + CoreLayer *layer, + CoreLayerRegionConfig *config, + CoreSurface *surface, + CoreSurfaceBufferLock *lock); + +static DFBResult +savage_secondary_calc_colorkey( SavageDriverData *sdrv, + SavageSecondaryLayerData *slay, + CoreLayerRegionConfig *config, + const DFBColorKey *key, + DFBSurfacePixelFormat format ); +static void +primary_set_regs (SavageDriverData *sdrv, + SavagePrimaryLayerData *play); +static void +primary_calc_regs (SavageDriverData *sdrv, + SavagePrimaryLayerData *play, + CoreLayer *layer, + CoreLayerRegionConfig *config, + CoreSurface *surface, + CoreSurfaceBufferLock *lock); + +static inline +void waitretrace (void) +{ + iopl(3); + while ((inb (0x3da) & 0x8)) + ; + + while (!(inb (0x3da) & 0x8)) + ; +} + +static void +streamOnOff(SavageDriverData * sdrv, int on) +{ + volatile u8 *mmio = sdrv->mmio_base; + + waitretrace(); + + if (on) { + vga_out8( mmio, 0x3d4, 0x23 ); + vga_out8( mmio, 0x3d5, 0x00 ); + + vga_out8( mmio, 0x3d4, 0x26 ); + vga_out8( mmio, 0x3d5, 0x00 ); + + /* turn on stream operation */ + vga_out8( mmio, 0x3d4, 0x67 ); + vga_out8( mmio, 0x3d5, 0x0c ); + } + else { + /* turn off stream operation */ + vga_out8( mmio, 0x3d4, 0x67 ); + vga_out8( mmio, 0x3d5, vga_in8( mmio, 0x3d5 ) & ~0x0c ); + } +} + +/* secondary layer functions */ +static int +savageSecondaryLayerDataSize( void ) +{ + SVGDBG("savageSecondaryLayerDataSize\n"); + return sizeof(SavageSecondaryLayerData); +} + +static DFBResult +savageSecondaryInitLayer( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *default_config, + DFBColorAdjustment *default_adj ) +{ + SVGDBG("savageSecondaryInitLayer\n"); + + /* set capabilities and type */ + description->caps = DLCAPS_SURFACE | DLCAPS_SCREEN_LOCATION | + DLCAPS_BRIGHTNESS | DLCAPS_CONTRAST | + DLCAPS_OPACITY | DLCAPS_HUE | DLCAPS_SATURATION | + DLCAPS_ALPHACHANNEL | DLCAPS_SRC_COLORKEY | + DLCAPS_DST_COLORKEY; + description->type = DLTF_GRAPHICS | DLTF_VIDEO | DLTF_STILL_PICTURE; + + /* set name */ + snprintf(description->name, DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, + "Savage Secondary Stream"); + + /* fill out the default configuration */ + default_config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | + DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE | + DLCONF_OPTIONS; + default_config->width = 640; + default_config->height = 480; + default_config->pixelformat = DSPF_YUY2; + default_config->buffermode = DLBM_FRONTONLY; + default_config->options = DLOP_NONE; + + /* fill out default color adjustment, + only fields set in flags will be accepted from applications */ + default_adj->flags = DCAF_BRIGHTNESS | DCAF_CONTRAST | + DCAF_HUE | DCAF_SATURATION; + default_adj->brightness = 0x8000; + default_adj->contrast = 0x8000; + default_adj->hue = 0x8000; + default_adj->saturation = 0x8000; + + return DFB_OK; +} + +static DFBResult +savageSecondaryRemoveRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + volatile u8 *mmio = sdrv->mmio_base; + + SVGDBG("savageSecondaryRemoveRegion\n"); + + /* put primary stream on top of secondary stream */ + savage_out32(mmio, SAVAGE_BLEND_CONTROL, + SAVAGE_BLEND_CONTROL_COMP_PSTREAM); + + return DFB_OK; +} + +static DFBResult +savageSecondaryTestRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags *failed ) +{ + CoreLayerRegionConfigFlags fail = 0; + + SVGDBG("savageSecondaryTestRegion\n"); + + /* check for unsupported options */ + /* savage only supports one option at a time */ + switch (config->options) { + case DLOP_NONE: + case DLOP_ALPHACHANNEL: + case DLOP_SRC_COLORKEY: + case DLOP_DST_COLORKEY: + case DLOP_OPACITY: + break; + default: + fail |= CLRCF_OPTIONS; + break; + } + + /* check pixel format */ + switch (config->format) { + case DSPF_ARGB1555: + case DSPF_RGB16: + case DSPF_RGB24: + case DSPF_RGB32: + case DSPF_YUY2: + case DSPF_UYVY: + case DSPF_I420: + case DSPF_YV12: + break; + default: + fail |= CLRCF_FORMAT; + } + + /* check width */ + if (config->width > 2048 || config->width < 1) + fail |= CLRCF_WIDTH; + + /* check height */ + if (config->height > 2048 || config->height < 1) + fail |= CLRCF_HEIGHT; + + switch (config->format) { + case DSPF_YUY2: + case DSPF_UYVY: + case DSPF_I420: + case DSPF_YV12: + /* secondary is in YUV format */ + if (config->dest.w < (config->source.w / 2)) + fail |= CLRCF_SOURCE | CLRCF_DEST; + if (config->dest.h < (config->source.h / 32)) + fail |= CLRCF_SOURCE | CLRCF_DEST; + break; + default: + /* secondary is in RGB format */ + if (config->dest.w < config->source.w) + fail |= CLRCF_SOURCE | CLRCF_DEST; + if (config->dest.h < config->source.h) + fail |= CLRCF_SOURCE | CLRCF_DEST; + break; + } + + /* write back failing fields */ + if (failed) + *failed = fail; + + /* return failure if any field failed */ + if (fail) + return DFB_UNSUPPORTED; + + return DFB_OK; +} + +static DFBResult +savageSecondarySetRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags updated, + CoreSurface *surface, + CorePalette *palette, + CoreSurfaceBufferLock *lock ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + SavageSecondaryLayerData *slay = (SavageSecondaryLayerData*) layer_data; + + SVGDBG("savageSecondarySetConfiguration w:%i h:%i bpp:%i\n", + config->width, config->height, + DFB_BYTES_PER_PIXEL(config->pixelformat) * 8); + + /* remember configuration */ + slay->config = *config; + + switch (config->options & (DLOP_SRC_COLORKEY | DLOP_DST_COLORKEY)) { + case DLOP_SRC_COLORKEY: + savage_secondary_calc_colorkey(sdrv, slay, config, &config->src_key, + config->format); + break; + case DLOP_DST_COLORKEY: + savage_secondary_calc_colorkey(sdrv, slay, config, &config->dst_key, + dfb_primary_layer_pixelformat()); + break; + default: + slay->regs.CHROMA_KEY_CONTROL = 0; + slay->regs.CHROMA_KEY_UPPER_BOUND = 0; + break; + } + + secondary_calc_regs(sdrv, slay, layer, config, surface, lock); + + secondary_set_regs(sdrv, slay); + + return DFB_OK; +} + +static void +savage_secondary_calc_opacity( SavageDriverData *sdrv, + SavageSecondaryLayerData *slay, + CoreLayerRegionConfig *config ) +{ + u8 opacity = config->opacity; + + switch (opacity) { + case 0: + /* put primary stream on top of secondary stream */ + slay->regs.BLEND_CTRL = SAVAGE_BLEND_CONTROL_COMP_PSTREAM; + break; + case 0xFF: + /* put secondary stream on top of primary stream */ + slay->regs.BLEND_CTRL = SAVAGE_BLEND_CONTROL_COMP_SSTREAM; + break; + default: + /* reverse opacity */ + opacity = 7 - (opacity >> 5); + + /* for some reason opacity can not be zero */ + if (opacity == 0) + opacity = 1; + + /* dissolve primary and secondary stream */ + slay->regs.BLEND_CTRL = SAVAGE_BLEND_CONTROL_COMP_DISSOLVE | KP_KS(opacity,0); + break; + } +} + +static DFBResult +savage_secondary_calc_colorkey( SavageDriverData *sdrv, + SavageSecondaryLayerData *slay, + CoreLayerRegionConfig *config, + const DFBColorKey *key, + DFBSurfacePixelFormat format ) +{ + u32 reg; + + switch (format) { + case DSPF_ARGB1555: + case DSPF_RGB16: + reg = 0x14000000; + break; + case DSPF_RGB24: + case DSPF_RGB32: + reg = 0x17000000; + break; + default: + return DFB_UNSUPPORTED; + } + + slay->regs.CHROMA_KEY_CONTROL = reg | (key->r << 16) | (key->g << 8) | (key->b); + slay->regs.CHROMA_KEY_UPPER_BOUND = 0x00000000 | (key->r << 16) | (key->g << 8) | (key->b); + + return DFB_OK; +} + + +static DFBResult +savageSecondaryFlipRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + DFBSurfaceFlipFlags flags, + CoreSurfaceBufferLock *lock ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + SavageSecondaryLayerData *slay = (SavageSecondaryLayerData*) layer_data; + + SVGDBG("savageSecondaryFlipRegion\n"); + + dfb_surface_flip( surface, false ); + + secondary_calc_regs(sdrv, slay, layer, &slay->config, surface, lock); + secondary_set_regs(sdrv, slay); + + if (flags & DSFLIP_WAIT) + dfb_screen_wait_vsync( dfb_screens_at( DSCID_PRIMARY ) ); + + return DFB_OK; +} + + +static DFBResult +savageSecondarySetColorAdjustment( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBColorAdjustment *adj ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + SavageSecondaryLayerData *slay = (SavageSecondaryLayerData*) layer_data; + volatile u8 *mmio = sdrv->mmio_base; + + SVGDBG("savageSecondaryColorAdjustment b:%i c:%i h:%i s:%i\n", + adj->brightness, adj->contrast, adj->hue, adj->saturation); + + if ((slay->regs.SSTREAM_FB_SIZE & 0x00400000) == 0) { + /* secondary is in YUV format */ + u32 reg; + long sat = adj->saturation * 16 / 65536; + double hue = (adj->hue - 0x8000) * 3.141592654 / 32768.0; + unsigned char hs1 = ((char)(sat * cos(hue))) & 0x1f; + unsigned char hs2 = ((char)(sat * sin(hue))) & 0x1f; + + reg = 0x80008000 | (adj->brightness >> 8) | + ((adj->contrast & 0xf800) >> 3) | (hs1 << 16) | (hs2 << 24); + + savage_out32(mmio, SAVAGE_COLOR_ADJUSTMENT, reg); + + return DFB_OK; + } + else { + /* secondary is in RGB format */ + return DFB_UNSUPPORTED; + } +} + +DisplayLayerFuncs savageSecondaryFuncs = { + .LayerDataSize = savageSecondaryLayerDataSize, + .InitLayer = savageSecondaryInitLayer, + .RemoveRegion = savageSecondaryRemoveRegion, + .TestRegion = savageSecondaryTestRegion, + .SetRegion = savageSecondarySetRegion, + .FlipRegion = savageSecondaryFlipRegion, + .SetColorAdjustment = savageSecondarySetColorAdjustment, +}; + +/* secondary internal */ +static void +secondary_set_regs(SavageDriverData *sdrv, SavageSecondaryLayerData *slay) +{ + volatile u8 *mmio = sdrv->mmio_base; + + SVGDBG("secondary_set_regs\n"); + + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_CONTROL, + slay->regs.SSTREAM_CTRL); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_HORIZONTAL_SCALING, + slay->regs.SSTREAM_H_SCALE); + savage_out32(mmio, SAVAGE_BLEND_CONTROL, + slay->regs.BLEND_CTRL); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_MULTIPLE_BUFFER_SUPPORT, + slay->regs.SSTREAM_MULTIBUF); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_ADDRESS0, + slay->regs.SSTREAM_FB_ADDR0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_ADDRESS1, + slay->regs.SSTREAM_FB_ADDR1); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_ADDRESS2, + slay->regs.SSTREAM_FB_ADDR2); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_SIZE, + slay->regs.SSTREAM_FB_SIZE); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_STRIDE, + slay->regs.SSTREAM_STRIDE); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_VERTICAL_SCALING, + slay->regs.SSTREAM_V_SCALE); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_SOURCE_LINE_COUNT, + slay->regs.SSTREAM_SRC_LINE_COUNT); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_VERTICAL_INITIAL_VALUE, + slay->regs.SSTREAM_V_INIT_VALUE); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_WINDOW_START, + slay->regs.SSTREAM_WIN_START); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_WINDOW_SIZE, + slay->regs.SSTREAM_WIN_SIZE); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FB_CB_ADDRESS, + slay->regs.SSTREAM_FB_CB_ADDR); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FB_CR_ADDRESS, + slay->regs.SSTREAM_FB_CR_ADDR); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_CBCR_STRIDE, + slay->regs.SSTREAM_CBCR_STRIDE); + + savage_out32(mmio, SAVAGE_CHROMA_KEY_CONTROL, + slay->regs.CHROMA_KEY_CONTROL); + savage_out32(mmio, SAVAGE_CHROMA_KEY_UPPER_BOUND, + slay->regs.CHROMA_KEY_UPPER_BOUND); + + /* Set FIFO L2 on second stream. */ + { + int pitch = slay->video_pitch; + unsigned char cr92; + + SVGDBG("FIFO L2 pitch:%i\n", pitch); + pitch = (pitch + 7) / 8; + vga_out8(mmio, 0x3d4, 0x92); + cr92 = vga_in8( mmio, 0x3d5); + vga_out8(mmio, 0x3d5, (cr92 & 0x40) | (pitch >> 8) | 0x80); + vga_out8(mmio, 0x3d4, 0x93); + vga_out8(mmio, 0x3d5, pitch); + } +} + +static void +secondary_calc_regs(SavageDriverData *sdrv, + SavageSecondaryLayerData *slay, + CoreLayer *layer, + CoreLayerRegionConfig *config, + CoreSurface *surface, + CoreSurfaceBufferLock *lock) +{ + DFBRectangle *source = &config->source; + DFBRectangle *dest = &config->dest; + + /* source size */ + const int src_w = source->w; + const int src_h = source->h; + /* destination size */ + const int drw_w = dest->w; + const int drw_h = dest->h; + + SVGDBG("secondary_calc_regs x:%i y:%i w:%i h:%i\n", + dest->x, dest->y, dest->w, dest->h); + SVGDBG("w:%i h:%i pitch:%i video.offset:%x\n", + source->w, source->h, lock->pitch, lock->offset); + + slay->video_pitch = 1; + slay->regs.SSTREAM_FB_SIZE = (((lock->pitch * + surface->config.size.h) / 8) - 1) & 0x003fffff; + + switch (surface->config.format) { + case DSPF_ARGB1555: + SVGDBG("secondary set to DSPF_ARGB1555\n"); + slay->regs.SSTREAM_FB_SIZE |= 0x00400000; + slay->regs.SSTREAM_CTRL = SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_KRGB16; + break; + case DSPF_RGB16: + SVGDBG("secondary set to DSPF_RGB16\n"); + slay->regs.SSTREAM_FB_SIZE |= 0x00400000; + slay->regs.SSTREAM_CTRL = SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_RGB16; + break; + case DSPF_RGB24: + SVGDBG("secondary set to DSPF_RGB24\n"); + slay->regs.SSTREAM_FB_SIZE |= 0x00400000; + slay->regs.SSTREAM_CTRL = SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_RGB24; + break; + case DSPF_RGB32: + SVGDBG("secondary set to DSPF_RGB32\n"); + slay->regs.SSTREAM_FB_SIZE |= 0x00400000; + slay->regs.SSTREAM_CTRL = SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_RGB32; + break; + case DSPF_YUY2: + SVGDBG("secondary set to DSPF_YUY2\n"); + slay->regs.SSTREAM_CTRL = SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_YCbCr422; + break; + case DSPF_UYVY: + SVGDBG("secondary set to DSPF_UYVY\n"); + slay->regs.SSTREAM_CTRL = SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_CbYCrY422; + break; + case DSPF_I420: + SVGDBG("secondary set to DSPF_I420\n"); + slay->video_pitch = 2; + slay->regs.SSTREAM_CTRL = SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_YCbCr420; + slay->regs.SSTREAM_FB_CB_ADDR = lock->offset + + (surface->config.size.h * lock->pitch); + slay->regs.SSTREAM_FB_CR_ADDR = slay->regs.SSTREAM_FB_CB_ADDR + + ((surface->config.size.h * lock->pitch)/4); + slay->regs.SSTREAM_CBCR_STRIDE = ((lock->pitch/2) + & 0x00001fff); + break; + case DSPF_YV12: + SVGDBG("secondary set to DSPF_YV12\n"); + slay->video_pitch = 2; + slay->regs.SSTREAM_CTRL = SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_YCbCr420; + slay->regs.SSTREAM_FB_CR_ADDR = lock->offset + + surface->config.size.h * lock->pitch; + slay->regs.SSTREAM_FB_CB_ADDR = slay->regs.SSTREAM_FB_CR_ADDR + + (surface->config.size.h * lock->pitch)/4; + slay->regs.SSTREAM_CBCR_STRIDE = ((lock->pitch/2) + & 0x00001fff); + break; + default: + D_BUG("unexpected secondary pixelformat"); + return; + } + + slay->regs.SSTREAM_CTRL |= src_w; + + switch (config->options) { + case DLOP_ALPHACHANNEL: + SVGDBG("secondary option DLOP_ALPHACHANNEL\n"); + slay->regs.BLEND_CTRL = SAVAGE_BLEND_CONTROL_COMP_ALPHA; + break; + case DLOP_SRC_COLORKEY: + SVGDBG("secondary option DLOP_SRC_COLORKEY\n"); + slay->regs.BLEND_CTRL = SAVAGE_BLEND_CONTROL_COMP_SCOLORKEY; + break; + case DLOP_DST_COLORKEY: + SVGDBG("secondary option DLOP_DST_COLORKEY\n"); + slay->regs.BLEND_CTRL = SAVAGE_BLEND_CONTROL_COMP_PCOLORKEY; + break; + case DLOP_OPACITY: + SVGDBG("secondary option DLOP_OPACITY\n"); + savage_secondary_calc_opacity( sdrv, slay, config ); + break; + case DLOP_NONE: + SVGDBG("secondary option default\n"); + slay->regs.BLEND_CTRL = SAVAGE_BLEND_CONTROL_COMP_SSTREAM; + break; + default: + D_BUG("unexcpected layer option"); + } + + slay->regs.SSTREAM_H_SCALE = ((32768 * src_w) / drw_w) & 0x0000FFFF; + slay->regs.SSTREAM_V_SCALE = ((32768 * src_h) / drw_h) & 0x000FFFFF; + slay->regs.SSTREAM_V_INIT_VALUE = 0; + slay->regs.SSTREAM_SRC_LINE_COUNT = src_h & 0x7ff; + slay->regs.SSTREAM_MULTIBUF = 0; + slay->regs.SSTREAM_FB_ADDR0 = lock->offset & 0x01ffffff; + slay->regs.SSTREAM_FB_ADDR1 = 0; + slay->regs.SSTREAM_FB_ADDR2 = 0; + slay->regs.SSTREAM_STRIDE = lock->pitch & 0x00001fff; + slay->regs.SSTREAM_WIN_START = OS_XY(dest->x, dest->y); + slay->regs.SSTREAM_WIN_SIZE = OS_WH(drw_w, drw_h); + + /* remember pitch */ + slay->video_pitch *= lock->pitch; +} + +/* primary layer functions */ +static int +savagePrimaryLayerDataSize( void ) +{ + SVGDBG("savagePrimaryLayerDataSize\n"); + return sizeof(SavagePrimaryLayerData); +} + +static DFBResult +savagePrimaryInitLayer( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *default_config, + DFBColorAdjustment *default_adj ) +{ + SavagePrimaryLayerData *play = (SavagePrimaryLayerData*) layer_data; + DFBResult ret; + + SVGDBG("savagePrimaryInitLayer w:%i h:%i bpp:%i\n", + dfb_config->mode.width, dfb_config->mode.height, + dfb_config->mode.depth); + + /* call the original initialization function first */ + ret = savage_pfuncs.InitLayer (layer, driver_data, layer_data, + description, default_config, default_adj); + if (ret) + return ret; + + /* set name */ + snprintf(description->name, DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, + "Savage Primary Stream"); + + /* add support for options */ + default_config->flags |= DLCONF_OPTIONS; + default_config->options = DLOP_NONE; + + /* add capabilities */ + description->caps |= DLCAPS_SCREEN_LOCATION; + + play->init = false; + + return DFB_OK; +} + +static DFBResult +savagePrimarySetRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags updated, + CoreSurface *surface, + CorePalette *palette, + CoreSurfaceBufferLock *lock ) +{ + SavageDriverData *sdrv = (SavageDriverData*) driver_data; + SavagePrimaryLayerData *play = (SavagePrimaryLayerData*) layer_data; + DFBResult ret; + + SVGDBG("savagePrimarySetConfiguration w:%i h:%i bpp:%i\n", + config->width, config->height, + DFB_BYTES_PER_PIXEL(config->format) * 8); + + ret = savage_pfuncs.SetRegion(layer, driver_data, layer_data, region_data, + config, updated, surface, palette, lock); + if (ret != DFB_OK) + return ret; + + /* remember configuration */ + play->config = *config; + play->lock = lock; + + primary_calc_regs(sdrv, play, layer, config, surface, lock); + primary_set_regs(sdrv, play); + + return DFB_OK; +} + +DisplayLayerFuncs savagePrimaryFuncs = { + .LayerDataSize = savagePrimaryLayerDataSize, + .InitLayer = savagePrimaryInitLayer, + .SetRegion = savagePrimarySetRegion, +}; + +/* primary internal */ +static void +primary_set_regs(SavageDriverData *sdrv, SavagePrimaryLayerData *play) +{ + volatile u8 *mmio = sdrv->mmio_base; + + SVGDBG("primary_set_regs\n"); + + /* turn streams on */ + streamOnOff(sdrv, 1); + + /* setup primary stream */ + savage_out32(mmio, SAVAGE_PRIMARY_STREAM_WINDOW_START, + play->regs.PSTREAM_WIN_START); + savage_out32(mmio, SAVAGE_PRIMARY_STREAM_WINDOW_SIZE, + play->regs.PSTREAM_WIN_SIZE); + savage_out32(mmio, SAVAGE_PRIMARY_STREAM_FRAME_BUFFER_ADDRESS0, + play->regs.PSTREAM_FB_ADDR0); + savage_out32(mmio, SAVAGE_PRIMARY_STREAM_FRAME_BUFFER_ADDRESS1, + play->regs.PSTREAM_FB_ADDR1); + savage_out32(mmio, SAVAGE_PRIMARY_STREAM_STRIDE, + play->regs.PSTREAM_STRIDE); + savage_out32(mmio, SAVAGE_PRIMARY_STREAM_CONTROL, + play->regs.PSTREAM_CTRL); + savage_out32(mmio, SAVAGE_PRIMARY_STREAM_FRAME_BUFFER_SIZE, + play->regs.PSTREAM_FB_SIZE); + + if (!play->init) { + /* tweak */ + /* fifo fetch delay register */ + vga_out8( mmio, 0x3d4, 0x85 ); + SVGDBG( "cr85: 0x%02x\n", vga_in8( mmio, 0x3d5 ) ); + vga_out8( mmio, 0x3d5, 0x00 ); + + /* force high priority for display channel memory */ + vga_out8( mmio, 0x3d4, 0x88 ); + SVGDBG( "cr88: 0x%02x\n", vga_in8( mmio, 0x3d5 ) ); + vga_out8( mmio, 0x3d5, vga_in8( mmio, 0x3d5 ) & ~0x01 ); + + /* primary stream timeout register */ + vga_out8( mmio, 0x3d4, 0x71 ); + SVGDBG( "cr71: 0x%02x\n", vga_in8( mmio, 0x3d5 ) ); + + /* secondary stream timeout register */ + vga_out8( mmio, 0x3d4, 0x73 ); + SVGDBG( "cr73: 0x%02x\n", vga_in8( mmio, 0x3d5 ) ); + + /* set primary stream to use memory mapped io */ + vga_out8( mmio, 0x3d4, 0x69 ); + SVGDBG( "cr69: 0x%02x\n", vga_in8( mmio, 0x3d5 ) ); + vga_out8( mmio, 0x3d5, vga_in8( mmio, 0x3d5 ) | 0x80 ); + + /* enable certain registers to be loaded on vsync */ + vga_out8( mmio, 0x3d4, 0x51 ); + SVGDBG( "cr51: 0x%02x\n", vga_in8( mmio, 0x3d5 ) ); + vga_out8( mmio, 0x3d5, vga_in8( mmio, 0x3d5 ) | 0x80 ); + + /* setup secondary stream */ + savage_out32(mmio, SAVAGE_CHROMA_KEY_CONTROL, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_CONTROL, 0); + savage_out32(mmio, SAVAGE_CHROMA_KEY_UPPER_BOUND, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_HORIZONTAL_SCALING, 0); + savage_out32(mmio, SAVAGE_COLOR_ADJUSTMENT, 0); + savage_out32(mmio, SAVAGE_BLEND_CONTROL, 1 << 24); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_MULTIPLE_BUFFER_SUPPORT, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_ADDRESS0, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_ADDRESS1, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_ADDRESS2, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_SIZE, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_STRIDE, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_VERTICAL_SCALING, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_SOURCE_LINE_COUNT, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_VERTICAL_INITIAL_VALUE, 0); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_WINDOW_START, + OS_XY(0xfffe, 0xfffe)); + savage_out32(mmio, SAVAGE_SECONDARY_STREAM_WINDOW_SIZE, + OS_WH(10,2)); + + play->init = true; + } +} + +static void +primary_calc_regs(SavageDriverData *sdrv, + SavagePrimaryLayerData *play, + CoreLayer *layer, + CoreLayerRegionConfig *config, + CoreSurface *surface, + CoreSurfaceBufferLock *lock) +{ + DFBRectangle *dest = &config->dest; + + SVGDBG("primary_calc_regs w:%i h:%i pitch:%i video.offset:%x\n", + surface->config.size.w, surface->config.size.h, lock->pitch, lock->offset); + + switch (surface->config.format) { + case DSPF_ARGB1555: + SVGDBG("primary set to DSPF_ARGB1555\n"); + play->regs.PSTREAM_CTRL = SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_KRGB16; + break; + case DSPF_RGB16: + SVGDBG("primary set to DSPF_RGB16\n"); + play->regs.PSTREAM_CTRL = SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_RGB16; + break; + case DSPF_RGB24: + SVGDBG("primary set to DSPF_RGB24 (unaccelerated)\n"); + play->regs.PSTREAM_CTRL = SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_RGB24; + break; + case DSPF_RGB32: + SVGDBG("primary set to DSPF_RGB32\n"); + play->regs.PSTREAM_CTRL = SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_RGB32; + break; + case DSPF_ARGB: + SVGDBG("primary set to DSPF_ARGB\n"); + play->regs.PSTREAM_CTRL = SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_ARGB; + break; + case DSPF_RGB332: + SVGDBG("primary set to DSPF_RGB332\n"); + play->regs.PSTREAM_CTRL = SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_CLUT; + break; + default: + D_BUG("unexpected primary pixelformat"); + return; + } + + play->regs.PSTREAM_FB_ADDR0 = lock->offset & 0x01ffffff; + play->regs.PSTREAM_FB_ADDR1 = 0; + play->regs.PSTREAM_STRIDE = lock->pitch & 0x00001fff; + play->regs.PSTREAM_WIN_START = OS_XY(dest->x, dest->y); + play->regs.PSTREAM_WIN_SIZE = OS_WH(dest->w, dest->h); + play->regs.PSTREAM_FB_SIZE = (((lock->pitch * + surface->config.size.h) / 8) - 1) & 0x003fffff; +} +/* end of code */ diff --git a/Source/DirectFB/gfxdrivers/savage/savage_streams_old.h b/Source/DirectFB/gfxdrivers/savage/savage_streams_old.h new file mode 100755 index 0000000..e58cfb8 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/savage/savage_streams_old.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 __SAVAGE_STREAMS_OLD_H__ +#define __SAVAGE_STREAMS_OLD_H__ + +#include "savage.h" +#include + +extern DisplayLayerFuncs savageSecondaryFuncs; +extern DisplayLayerFuncs savagePrimaryFuncs; +extern DisplayLayerFuncs savage_pfuncs; +extern void *savage_pdriver_data; + +/* Streams Processor Registers */ +#define SAVAGE_PRIMARY_STREAM_CONTROL 0x8180 +#define SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_CLUT 0x00000000 +#define SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_ARGB 0x01000000 +#define SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_KRGB16 0x03000000 +#define SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_RGB16 0x05000000 +#define SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_RGB24 0x06000000 +#define SAVAGE_PRIMARY_STREAM_CONTROL_PSIDF_RGB32 0x07000000 +#define SAVAGE_PRIMARY_STREAM_CONTROL_PSFC_NOT_FILTERED 0x00000000 +#define SAVAGE_PRIMARY_STREAM_CONTROL_PSFC_REP_BOTH 0x10000000 +#define SAVAGE_PRIMARY_STREAM_CONTROL_PSFC_HOR_INTERPOLATE 0x20000000 + +#define SAVAGE_CHROMA_KEY_CONTROL 0x8184 + +#define SAVAGE_GENLOCK_CONTROL 0x8188 + +#define SAVAGE_SECONDARY_STREAM_CONTROL 0x8190 +#define SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_CbYCrY422 0x00000000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_YCbCr422 0x01000000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_YUV422 0x02000000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_KRGB16 0x03000000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_YCbCr420 0x04000000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_RGB16 0x05000000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_RGB24 0x06000000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_SSIDF_RGB32 0x07000000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_H_DOWNSCALE4 0x00020000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_H_DOWNSCALE8 0x00030000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_H_DOWNSCALE16 0x00040000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_H_DOWNSCALE32 0x00050000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_H_DOWNSCALE64 0x00060000 +#define SAVAGE_SECONDARY_STREAM_CONTROL_LUMA_ONLY_INTERPOL 0x80000000 + +#define SAVAGE_CHROMA_KEY_UPPER_BOUND 0x8194 + +#define SAVAGE_SECONDARY_STREAM_HORIZONTAL_SCALING 0x8198 + +#define SAVAGE_COLOR_ADJUSTMENT 0x819C + +#define SAVAGE_BLEND_CONTROL 0x81a0 +#define SAVAGE_BLEND_CONTROL_COMP_SSTREAM 0x00000000 +#define SAVAGE_BLEND_CONTROL_COMP_PSTREAM 0x01000000 +#define SAVAGE_BLEND_CONTROL_COMP_DISSOLVE 0x02000000 +#define SAVAGE_BLEND_CONTROL_COMP_FADE 0x03000000 +#define SAVAGE_BLEND_CONTROL_COMP_ALPHA 0x04000000 +#define SAVAGE_BLEND_CONTROL_COMP_PCOLORKEY 0x05000000 +#define SAVAGE_BLEND_CONTROL_COMP_SCOLORKEY 0x06000000 +#define KP_KS(kp,ks) ((kp<<10)|(ks<<2)) + +#define SAVAGE_PRIMARY_STREAM_FRAME_BUFFER_ADDRESS0 0x81c0 + +#define SAVAGE_PRIMARY_STREAM_FRAME_BUFFER_ADDRESS1 0x81c4 + +#define SAVAGE_PRIMARY_STREAM_STRIDE 0x81c8 + +#define SAVAGE_SECONDARY_STREAM_MULTIPLE_BUFFER_SUPPORT 0x81cc + +#define SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_ADDRESS0 0x81d0 + +#define SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_ADDRESS1 0x81d4 + +#define SAVAGE_SECONDARY_STREAM_STRIDE 0x81d8 + +#define SAVAGE_SECONDARY_STREAM_VERTICAL_SCALING 0x81e0 + +#define SAVAGE_SECONDARY_STREAM_VERTICAL_INITIAL_VALUE 0x81e4 + +#define SAVAGE_SECONDARY_STREAM_SOURCE_LINE_COUNT 0x81e8 + +#define SAVAGE_STREAMS_FIFO 0x81ec + +#define SAVAGE_PRIMARY_STREAM_WINDOW_START 0x81f0 + +#define SAVAGE_PRIMARY_STREAM_WINDOW_SIZE 0x81f4 + +#define SAVAGE_SECONDARY_STREAM_WINDOW_START 0x81f8 + +#define SAVAGE_SECONDARY_STREAM_WINDOW_SIZE 0x81fc + +#define SAVAGE_PRIMARY_STREAM_FIFO_MONITOR0 0x8200 + +#define SAVAGE_SECONDARY_STREAM_FIFO_MONITOR0 0x8204 + +#define SAVAGE_SECONDARY_STREAM_FB_CB_ADDRESS 0x8208 + +#define SAVAGE_SECONDARY_STREAM_FB_CR_ADDRESS 0x820C + +#define SAVAGE_PRIMARY_STREAM_FIFO_MONITOR1 0x8210 + +#define SAVAGE_SECONDARY_STREAM_FIFO_MONITOR1 0x8214 + +#define SAVAGE_SECONDARY_STREAM_CBCR_STRIDE 0x8218 + +#define SAVAGE_PRIMARY_STREAM_FRAME_BUFFER_SIZE 0x8300 + +#define SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_SIZE 0x8304 + +#define SAVAGE_SECONDARY_STREAM_FRAME_BUFFER_ADDRESS2 0x8308 + +/* macros */ +#define OS_XY(x,y) (((x+1)<<16)|(y+1)) +#define OS_WH(x,y) (((x-1)<<16)|(y)) + +#endif /* __SAVAGE_STREAMS_OLD_H__ */ -- cgit