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/davinci/Makefile.am | 77 + Source/DirectFB/gfxdrivers/davinci/Makefile.in | 771 ++++++++ Source/DirectFB/gfxdrivers/davinci/Makefile.kernel | 6 + Source/DirectFB/gfxdrivers/davinci/c64xdump.c | 117 ++ Source/DirectFB/gfxdrivers/davinci/davinci_2d.c | 1050 ++++++++++ Source/DirectFB/gfxdrivers/davinci/davinci_2d.h | 79 + Source/DirectFB/gfxdrivers/davinci/davinci_c64x.c | 2053 ++++++++++++++++++++ Source/DirectFB/gfxdrivers/davinci/davinci_c64x.h | 935 +++++++++ .../gfxdrivers/davinci/davinci_gfxdriver.c | 343 ++++ .../gfxdrivers/davinci/davinci_gfxdriver.h | 169 ++ Source/DirectFB/gfxdrivers/davinci/davinci_osd.c | 681 +++++++ Source/DirectFB/gfxdrivers/davinci/davinci_osd.h | 53 + .../DirectFB/gfxdrivers/davinci/davinci_osd_pool.c | 394 ++++ .../DirectFB/gfxdrivers/davinci/davinci_osd_pool.h | 39 + .../DirectFB/gfxdrivers/davinci/davinci_screen.c | 124 ++ .../DirectFB/gfxdrivers/davinci/davinci_screen.h | 39 + Source/DirectFB/gfxdrivers/davinci/davinci_video.c | 744 +++++++ Source/DirectFB/gfxdrivers/davinci/davinci_video.h | 58 + .../gfxdrivers/davinci/davinci_video_pool.c | 393 ++++ .../gfxdrivers/davinci/davinci_video_pool.h | 39 + Source/DirectFB/gfxdrivers/davinci/davincifb.h | 581 ++++++ Source/DirectFB/gfxdrivers/davinci/directfbrc | 56 + .../gfxdrivers/davinci/kernel-module/Makefile | 34 + .../gfxdrivers/davinci/kernel-module/c64x/Makefile | 2 + .../gfxdrivers/davinci/kernel-module/c64x/c64x.c | 507 +++++ .../davinci/kernel-module/include/linux/c64x.h | 281 +++ .../ti-davinci-2.6.10-mvl401-fbio_set_start.patch | 123 ++ 27 files changed, 9748 insertions(+) create mode 100755 Source/DirectFB/gfxdrivers/davinci/Makefile.am create mode 100755 Source/DirectFB/gfxdrivers/davinci/Makefile.in create mode 100755 Source/DirectFB/gfxdrivers/davinci/Makefile.kernel create mode 100755 Source/DirectFB/gfxdrivers/davinci/c64xdump.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_2d.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_2d.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_c64x.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_c64x.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_gfxdriver.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_gfxdriver.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_osd.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_osd.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_osd_pool.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_osd_pool.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_screen.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_screen.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_video.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_video.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_video_pool.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/davinci_video_pool.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/davincifb.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/directfbrc create mode 100755 Source/DirectFB/gfxdrivers/davinci/kernel-module/Makefile create mode 100755 Source/DirectFB/gfxdrivers/davinci/kernel-module/c64x/Makefile create mode 100755 Source/DirectFB/gfxdrivers/davinci/kernel-module/c64x/c64x.c create mode 100755 Source/DirectFB/gfxdrivers/davinci/kernel-module/include/linux/c64x.h create mode 100755 Source/DirectFB/gfxdrivers/davinci/patches/ti-davinci-2.6.10-mvl401-fbio_set_start.patch (limited to 'Source/DirectFB/gfxdrivers/davinci') diff --git a/Source/DirectFB/gfxdrivers/davinci/Makefile.am b/Source/DirectFB/gfxdrivers/davinci/Makefile.am new file mode 100755 index 0000000..d291092 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/Makefile.am @@ -0,0 +1,77 @@ +## Makefile.am for DirectFB/src/core/gfxcards/davinci + +EXTRA_DIST = \ + directfbrc \ + Makefile.kernel \ + kernel-module/c64x/Makefile \ + kernel-module/c64x/c64x.c \ + kernel-module/Makefile \ + kernel-module/include/linux/c64x.h \ + patches/ti-davinci-2.6.10-mvl401-fbio_set_start.patch + +INCLUDES = \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/systems \ + -I$(srcdir)/kernel-module/include + +bin_PROGRAMS = c64xdump + +lib_LTLIBRARIES = libdavinci_c64x.la + +davinci_LTLIBRARIES = libdirectfb_davinci.la + +if BUILD_STATIC +davinci_DATA = $(davinci_LTLIBRARIES:.la=.o) +endif + +davincidir = $(MODULEDIR)/gfxdrivers +includedir = @INCLUDEDIR@ +includelinuxdir = @INCLUDEDIR@/linux + +include_HEADERS = \ + davincifb.h \ + davinci_c64x.h \ + davinci_gfxdriver.h + +includelinux_HEADERS = \ + kernel-module/include/linux/c64x.h + +libdavinci_c64x_la_SOURCES = \ + davinci_c64x.c + +libdavinci_c64x_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la + +libdirectfb_davinci_la_SOURCES = \ + davinci_2d.c \ + davinci_2d.h \ + davinci_gfxdriver.c \ + davinci_osd.c \ + davinci_osd.h \ + davinci_osd_pool.c \ + davinci_osd_pool.h \ + davinci_screen.c \ + davinci_screen.h \ + davinci_video.c \ + davinci_video.h \ + davinci_video_pool.c \ + davinci_video_pool.h + +libdirectfb_davinci_la_LDFLAGS = \ + -module \ + -avoid-version \ + $(DFB_LDFLAGS) + +libdirectfb_davinci_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/src/libdirectfb.la \ + $(builddir)/libdavinci_c64x.la + +c64xdump_SOURCES = c64xdump.c +c64xdump_LDADD = $(top_builddir)/lib/direct/libdirect.la + +include $(top_srcdir)/rules/libobject.make diff --git a/Source/DirectFB/gfxdrivers/davinci/Makefile.in b/Source/DirectFB/gfxdrivers/davinci/Makefile.in new file mode 100755 index 0000000..9e46327 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/Makefile.in @@ -0,0 +1,771 @@ +# 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@ +bin_PROGRAMS = c64xdump$(EXEEXT) +DIST_COMMON = $(include_HEADERS) $(includelinux_HEADERS) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/rules/libobject.make +subdir = gfxdrivers/davinci +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)$(davincidir)" "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(bindir)" "$(DESTDIR)$(davincidir)" \ + "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includelinuxdir)" +davinciLTLIBRARIES_INSTALL = $(INSTALL) +libLTLIBRARIES_INSTALL = $(INSTALL) +LTLIBRARIES = $(davinci_LTLIBRARIES) $(lib_LTLIBRARIES) +libdavinci_c64x_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la +am_libdavinci_c64x_la_OBJECTS = davinci_c64x.lo +libdavinci_c64x_la_OBJECTS = $(am_libdavinci_c64x_la_OBJECTS) +libdirectfb_davinci_la_DEPENDENCIES = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/src/libdirectfb.la \ + $(builddir)/libdavinci_c64x.la +am_libdirectfb_davinci_la_OBJECTS = davinci_2d.lo davinci_gfxdriver.lo \ + davinci_osd.lo davinci_osd_pool.lo davinci_screen.lo \ + davinci_video.lo davinci_video_pool.lo +libdirectfb_davinci_la_OBJECTS = $(am_libdirectfb_davinci_la_OBJECTS) +libdirectfb_davinci_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libdirectfb_davinci_la_LDFLAGS) $(LDFLAGS) -o $@ +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_c64xdump_OBJECTS = c64xdump.$(OBJEXT) +c64xdump_OBJECTS = $(am_c64xdump_OBJECTS) +c64xdump_DEPENDENCIES = $(top_builddir)/lib/direct/libdirect.la +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 = $(libdavinci_c64x_la_SOURCES) \ + $(libdirectfb_davinci_la_SOURCES) $(c64xdump_SOURCES) +DIST_SOURCES = $(libdavinci_c64x_la_SOURCES) \ + $(libdirectfb_davinci_la_SOURCES) $(c64xdump_SOURCES) +davinciDATA_INSTALL = $(INSTALL_DATA) +DATA = $(davinci_DATA) +includeHEADERS_INSTALL = $(INSTALL_HEADER) +includelinuxHEADERS_INSTALL = $(INSTALL_HEADER) +HEADERS = $(include_HEADERS) $(includelinux_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +ASFLAGS = @ASFLAGS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIR = @DATADIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DFB_CFLAGS_OMIT_FRAME_POINTER = @DFB_CFLAGS_OMIT_FRAME_POINTER@ +DFB_INTERNAL_CFLAGS = @DFB_INTERNAL_CFLAGS@ +DFB_LDFLAGS = @DFB_LDFLAGS@ +DFB_SMOOTH_SCALING = @DFB_SMOOTH_SCALING@ +DIRECTFB_BINARY_AGE = @DIRECTFB_BINARY_AGE@ +DIRECTFB_CSOURCE = @DIRECTFB_CSOURCE@ +DIRECTFB_INTERFACE_AGE = @DIRECTFB_INTERFACE_AGE@ +DIRECTFB_MAJOR_VERSION = @DIRECTFB_MAJOR_VERSION@ +DIRECTFB_MICRO_VERSION = @DIRECTFB_MICRO_VERSION@ +DIRECTFB_MINOR_VERSION = @DIRECTFB_MINOR_VERSION@ +DIRECTFB_VERSION = @DIRECTFB_VERSION@ +DIRECT_BUILD_DEBUG = @DIRECT_BUILD_DEBUG@ +DIRECT_BUILD_DEBUGS = @DIRECT_BUILD_DEBUGS@ +DIRECT_BUILD_GETTID = @DIRECT_BUILD_GETTID@ +DIRECT_BUILD_NETWORK = @DIRECT_BUILD_NETWORK@ +DIRECT_BUILD_STDBOOL = @DIRECT_BUILD_STDBOOL@ +DIRECT_BUILD_TEXT = @DIRECT_BUILD_TEXT@ +DIRECT_BUILD_TRACE = @DIRECT_BUILD_TRACE@ +DSYMUTIL = @DSYMUTIL@ +DYNLIB = @DYNLIB@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +FREETYPE_PROVIDER = @FREETYPE_PROVIDER@ +FUSION_BUILD_KERNEL = @FUSION_BUILD_KERNEL@ +FUSION_BUILD_MULTI = @FUSION_BUILD_MULTI@ +FUSION_MESSAGE_SIZE = @FUSION_MESSAGE_SIZE@ +GIF_PROVIDER = @GIF_PROVIDER@ +GREP = @GREP@ +HAVE_LINUX = @HAVE_LINUX@ +INCLUDEDIR = @INCLUDEDIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTERNALINCLUDEDIR = @INTERNALINCLUDEDIR@ +JPEG_PROVIDER = @JPEG_PROVIDER@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBJPEG = @LIBJPEG@ +LIBOBJS = @LIBOBJS@ +LIBPNG = @LIBPNG@ +LIBPNG_CONFIG = @LIBPNG_CONFIG@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_AGE = @LT_AGE@ +LT_BINARY = @LT_BINARY@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAN2HTML = @MAN2HTML@ +MKDIR_P = @MKDIR_P@ +MODULEDIR = @MODULEDIR@ +MODULEDIRNAME = @MODULEDIRNAME@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +OSX_LIBS = @OSX_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PNG_PROVIDER = @PNG_PROVIDER@ +RANLIB = @RANLIB@ +RUNTIME_SYSROOT = @RUNTIME_SYSROOT@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_LIBS = @SDL_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOPATH = @SOPATH@ +STRIP = @STRIP@ +SYSCONFDIR = @SYSCONFDIR@ +SYSFS_LIBS = @SYSFS_LIBS@ +THREADFLAGS = @THREADFLAGS@ +THREADLIB = @THREADLIB@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +VERSION = @VERSION@ +VNC_CFLAGS = @VNC_CFLAGS@ +VNC_CONFIG = @VNC_CONFIG@ +VNC_LIBS = @VNC_LIBS@ +X11_CFLAGS = @X11_CFLAGS@ +X11_LIBS = @X11_LIBS@ +ZLIB_LIBS = @ZLIB_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @INCLUDEDIR@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = \ + directfbrc \ + Makefile.kernel \ + kernel-module/c64x/Makefile \ + kernel-module/c64x/c64x.c \ + kernel-module/Makefile \ + kernel-module/include/linux/c64x.h \ + patches/ti-davinci-2.6.10-mvl401-fbio_set_start.patch + +INCLUDES = \ + -I$(top_builddir)/include \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/lib \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/systems \ + -I$(srcdir)/kernel-module/include + +lib_LTLIBRARIES = libdavinci_c64x.la +davinci_LTLIBRARIES = libdirectfb_davinci.la +@BUILD_STATIC_TRUE@davinci_DATA = $(davinci_LTLIBRARIES:.la=.o) +davincidir = $(MODULEDIR)/gfxdrivers +includelinuxdir = @INCLUDEDIR@/linux +include_HEADERS = \ + davincifb.h \ + davinci_c64x.h \ + davinci_gfxdriver.h + +includelinux_HEADERS = \ + kernel-module/include/linux/c64x.h + +libdavinci_c64x_la_SOURCES = \ + davinci_c64x.c + +libdavinci_c64x_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la + +libdirectfb_davinci_la_SOURCES = \ + davinci_2d.c \ + davinci_2d.h \ + davinci_gfxdriver.c \ + davinci_osd.c \ + davinci_osd.h \ + davinci_osd_pool.c \ + davinci_osd_pool.h \ + davinci_screen.c \ + davinci_screen.h \ + davinci_video.c \ + davinci_video.h \ + davinci_video_pool.c \ + davinci_video_pool.h + +libdirectfb_davinci_la_LDFLAGS = \ + -module \ + -avoid-version \ + $(DFB_LDFLAGS) + +libdirectfb_davinci_la_LIBADD = \ + $(top_builddir)/lib/direct/libdirect.la \ + $(top_builddir)/src/libdirectfb.la \ + $(builddir)/libdavinci_c64x.la + +c64xdump_SOURCES = c64xdump.c +c64xdump_LDADD = $(top_builddir)/lib/direct/libdirect.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/davinci/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu gfxdrivers/davinci/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-davinciLTLIBRARIES: $(davinci_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(davincidir)" || $(MKDIR_P) "$(DESTDIR)$(davincidir)" + @list='$(davinci_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(davinciLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(davincidir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(davinciLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(davincidir)/$$f"; \ + else :; fi; \ + done + +uninstall-davinciLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(davinci_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(davincidir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(davincidir)/$$p"; \ + done + +clean-davinciLTLIBRARIES: + -test -z "$(davinci_LTLIBRARIES)" || rm -f $(davinci_LTLIBRARIES) + @list='$(davinci_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + f=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + p=$(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_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 +libdavinci_c64x.la: $(libdavinci_c64x_la_OBJECTS) $(libdavinci_c64x_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libdavinci_c64x_la_OBJECTS) $(libdavinci_c64x_la_LIBADD) $(LIBS) +libdirectfb_davinci.la: $(libdirectfb_davinci_la_OBJECTS) $(libdirectfb_davinci_la_DEPENDENCIES) + $(libdirectfb_davinci_la_LINK) -rpath $(davincidir) $(libdirectfb_davinci_la_OBJECTS) $(libdirectfb_davinci_la_LIBADD) $(LIBS) +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +c64xdump$(EXEEXT): $(c64xdump_OBJECTS) $(c64xdump_DEPENDENCIES) + @rm -f c64xdump$(EXEEXT) + $(LINK) $(c64xdump_OBJECTS) $(c64xdump_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c64xdump.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/davinci_2d.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/davinci_c64x.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/davinci_gfxdriver.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/davinci_osd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/davinci_osd_pool.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/davinci_screen.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/davinci_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/davinci_video_pool.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-davinciDATA: $(davinci_DATA) + @$(NORMAL_INSTALL) + test -z "$(davincidir)" || $(MKDIR_P) "$(DESTDIR)$(davincidir)" + @list='$(davinci_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(davinciDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(davincidir)/$$f'"; \ + $(davinciDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(davincidir)/$$f"; \ + done + +uninstall-davinciDATA: + @$(NORMAL_UNINSTALL) + @list='$(davinci_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(davincidir)/$$f'"; \ + rm -f "$(DESTDIR)$(davincidir)/$$f"; \ + done +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" + @list='$(include_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ + $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ + rm -f "$(DESTDIR)$(includedir)/$$f"; \ + done +install-includelinuxHEADERS: $(includelinux_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(includelinuxdir)" || $(MKDIR_P) "$(DESTDIR)$(includelinuxdir)" + @list='$(includelinux_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(includelinuxHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includelinuxdir)/$$f'"; \ + $(includelinuxHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includelinuxdir)/$$f"; \ + done + +uninstall-includelinuxHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(includelinux_HEADERS)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(includelinuxdir)/$$f'"; \ + rm -f "$(DESTDIR)$(includelinuxdir)/$$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) $(PROGRAMS) $(DATA) $(HEADERS) +install-binPROGRAMS: install-libLTLIBRARIES + +installdirs: + for dir in "$(DESTDIR)$(davincidir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(davincidir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includelinuxdir)"; 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-binPROGRAMS clean-davinciLTLIBRARIES clean-generic \ + clean-libLTLIBRARIES clean-libtool 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-davinciDATA install-davinciLTLIBRARIES \ + install-includeHEADERS install-includelinuxHEADERS + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS install-libLTLIBRARIES + +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-binPROGRAMS uninstall-davinciDATA \ + uninstall-davinciLTLIBRARIES uninstall-includeHEADERS \ + uninstall-includelinuxHEADERS uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-davinciLTLIBRARIES clean-generic clean-libLTLIBRARIES \ + clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am \ + install-davinciDATA install-davinciLTLIBRARIES install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-includeHEADERS \ + install-includelinuxHEADERS install-info install-info-am \ + install-libLTLIBRARIES install-man install-pdf install-pdf-am \ + install-ps install-ps-am 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-binPROGRAMS \ + uninstall-davinciDATA uninstall-davinciLTLIBRARIES \ + uninstall-includeHEADERS uninstall-includelinuxHEADERS \ + uninstall-libLTLIBRARIES + +%.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/davinci/Makefile.kernel b/Source/DirectFB/gfxdrivers/davinci/Makefile.kernel new file mode 100755 index 0000000..f58d56e --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/Makefile.kernel @@ -0,0 +1,6 @@ +CROSS_COMPILE = arm-v4t-linux-gnueabi- +KERNEL_SOURCE = $(shell pwd)/../../../linux-davinci-2.6 +KERNEL_BUILD = $(KERNEL_SOURCE) + +all: + $(MAKE) -C kernel-module KERNEL_SOURCE=$(KERNEL_SOURCE) KERNEL_BUILD=$(KERNEL_BUILD) diff --git a/Source/DirectFB/gfxdrivers/davinci/c64xdump.c b/Source/DirectFB/gfxdrivers/davinci/c64xdump.c new file mode 100755 index 0000000..f70c8e0 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/c64xdump.c @@ -0,0 +1,117 @@ +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#define C64X_DEVICE "/dev/c64x" +#define C64X_DEVICE0 "/dev/c64x0" +#define C64X_QLEN direct_page_align( sizeof(c64xTaskControl) ) +#define C64X_MLEN direct_page_align( 0x2000000 ) + +static const char *state_names[] = { "DONE", "ERROR", "TODO", "RUNNING" }; + +// manual (examples) +//#define DAVINCI_C64X_IDLE_MAX (567087584/10) +//#define DAVINCI_C64X_IDLE_MAX (59457217) + +// auto +#ifndef DAVINCI_C64X_IDLE_MAX +#define DAVINCI_C64X_IDLE_MAX (0) +#endif + +int main (int argc, char *argv[]) +{ + int fd; + void *mem; + c64xTaskControl *ctl; + c64xTask *queue; + int idle_max = DAVINCI_C64X_IDLE_MAX; + uint32_t idle_last = 0; + long long stamp_last = 0; + + fd = direct_try_open( C64X_DEVICE, C64X_DEVICE0, O_RDONLY, true ); + if (fd < 0) + return -1; + + ctl = mmap( NULL, C64X_QLEN, PROT_READ, MAP_SHARED, fd, 0 ); + if (ctl == MAP_FAILED) { + D_PERROR( "C64XDump: Mapping %lu bytes at %lu via '%s' failed!\n", C64X_QLEN, 0UL, C64X_DEVICE ); + close( fd ); + return -2; + } + + mem = mmap( NULL, C64X_MLEN, PROT_READ, MAP_SHARED, fd, C64X_QLEN ); + if (mem == MAP_FAILED) { + D_PERROR( "C64XDump: Mapping %lu bytes at %lu via '%s' failed!\n", C64X_MLEN, C64X_QLEN, C64X_DEVICE ); + munmap( (void*)ctl, C64X_QLEN ); + close( fd ); + return -2; + } + + queue = mem + (0x8fe00000 - 0x8e000000); + + while (1) { + usleep( 250000 ); + + int loadx = 1000; + uint32_t counter = ctl->idlecounter; + long long stamp = direct_clock_get_abs_micros(); + uint32_t ql_dsp = ctl->QL_dsp; + uint32_t ql_arm = ctl->QL_arm; + uint32_t qh_dsp = ctl->QH_dsp; + uint32_t qh_arm = ctl->QH_arm; + uint32_t task = queue[ql_dsp & C64X_QUEUE_MASK].c64x_function; + int dl, dh; + + dl = ql_arm - ql_dsp; + if (dl < 0) + dl += C64X_QUEUE_LENGTH; + + dh = qh_arm - qh_dsp; + if (dh < 0) + dh += C64X_QUEUE_LENGTH; + + printf( "\e[H\e[J" ); + printf( "High Q: arm %5d - dsp %5d = %d\n", qh_arm, qh_dsp, dh ); + printf( "Low Q: arm %5d - dsp %5d = %d\n", ql_arm, ql_dsp, dl ); + + printf( " (%08x: func %d - %s)\n", + task, (task >> 2) & 0x3fff, state_names[task & 3] ); + + printf( "Counter: %u\n", counter ); + + if (counter >= idle_last && idle_last) { + long long int cdiff = counter - idle_last; + long long int tdiff = stamp - stamp_last; + + long long int diff = cdiff * 1200000 / tdiff; + +#if !DAVINCI_C64X_IDLE_MAX + if (diff > idle_max) + idle_max = diff; +#endif + + loadx = (idle_max - diff) * 1000 / idle_max; + } + + if (idle_max) + printf( "Load: %d.%d%% (idle_max %d)\n", loadx / 10, loadx % 10, idle_max ); + + idle_last = counter; + stamp_last = stamp; + } + + + munmap( (void*)mem, C64X_MLEN ); + munmap( (void*)ctl, C64X_QLEN ); + close( fd ); + + return 0; +} diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_2d.c b/Source/DirectFB/gfxdrivers/davinci/davinci_2d.c new file mode 100755 index 0000000..7b97fb7 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_2d.c @@ -0,0 +1,1050 @@ +/* + TI Davinci driver - 2D Acceleration + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include + +#include + +#include +#include +#include + +#include +#include + +#include + +#include "davinci_2d.h" +#include "davinci_gfxdriver.h" + + +D_DEBUG_DOMAIN( Davinci_2D, "Davinci/2D", "Davinci 2D Acceleration" ); + +/* + * State validation flags. + * + * There's no prefix because of the macros below. + */ +enum { + DESTINATION = 0x00000001, + FILLCOLOR = 0x00000002, + + SOURCE = 0x00000010, + SOURCE_MULT = 0x00000020, + + BLIT_BLEND_SUB = 0x00010000, + DRAW_BLEND_SUB = 0x00020000, + + ALL = 0x00030033 +}; + +/* + * State handling macros. + */ + +#define DAVINCI_VALIDATE(flags) do { ddev->v_flags |= (flags); } while (0) +#define DAVINCI_INVALIDATE(flags) do { ddev->v_flags &= ~(flags); } while (0) + +#define DAVINCI_CHECK_VALIDATE(flag) do { \ + if (! (ddev->v_flags & flag)) \ + davinci_validate_##flag( ddev, state ); \ + } while (0) + +/**************************************************************************************************/ + +static bool davinciFillRectangle16( void *drv, + void *dev, + DFBRectangle *rect ); + +static bool davinciFillRectangle32( void *drv, + void *dev, + DFBRectangle *rect ); + +static bool davinciFillRectangleBlend32( void *drv, + void *dev, + DFBRectangle *rect ); + +static bool davinciBlit16 ( void *drv, + void *dev, + DFBRectangle *srect, + int dx, + int dy ); + +static bool davinciBlit32to16 ( void *drv, + void *dev, + DFBRectangle *srect, + int dx, + int dy ); + +static bool davinciBlit32 ( void *drv, + void *dev, + DFBRectangle *srect, + int dx, + int dy ); + +static bool davinciBlitKeyed16 ( void *drv, + void *dev, + DFBRectangle *srect, + int dx, + int dy ); + +static bool davinciBlitKeyed32 ( void *drv, + void *dev, + DFBRectangle *srect, + int dx, + int dy ); + +static bool davinciBlitBlend32 ( void *drv, + void *dev, + DFBRectangle *srect, + int dx, + int dy ); + +/**************************************************************************************************/ + +static inline int +get_blit_blend_sub_function( const CardState *state ) +{ + DFBSurfaceBlittingFlags flags = state->blittingflags & ~DSBLIT_COLORIZE; + + if (state->dst_blend == DSBF_INVSRCALPHA) { + switch (state->src_blend) { + case DSBF_SRCALPHA: + if (flags == DSBLIT_BLEND_ALPHACHANNEL) + return C64X_BLEND_SRC_INVSRC; + break; + + case DSBF_ONE: + switch (flags) { + case DSBLIT_BLEND_ALPHACHANNEL: + return C64X_BLEND_ONE_INVSRC; + + case DSBLIT_BLEND_ALPHACHANNEL | + DSBLIT_SRC_PREMULTIPLY: + return C64X_BLEND_ONE_INVSRC_PREMULT_SRC; + + case DSBLIT_BLEND_ALPHACHANNEL | + DSBLIT_BLEND_COLORALPHA | + DSBLIT_SRC_PREMULTCOLOR: + return C64X_BLEND_ONE_INVSRC_PREMULT_ALPHA; + + default: + break; + } + break; + + default: + break; + } + } + + return -1; +} + +static inline int +get_draw_blend_sub_function( const CardState *state ) +{ + DFBSurfaceDrawingFlags flags = state->drawingflags; + + if (state->dst_blend == DSBF_INVSRCALPHA) { + switch (state->src_blend) { + case DSBF_SRCALPHA: + if (flags == DSDRAW_BLEND) + return C64X_BLEND_SRC_INVSRC; + break; + + case DSBF_ONE: + switch (flags) { + case DSDRAW_BLEND: + return C64X_BLEND_ONE_INVSRC; + + case DSDRAW_BLEND | + DSDRAW_SRC_PREMULTIPLY: + return C64X_BLEND_ONE_INVSRC_PREMULT_SRC; + + default: + break; + } + break; + + default: + break; + } + } + + return -1; +} + +/**************************************************************************************************/ + +/* + * Called by davinciSetState() to ensure that the destination registers are properly set + * for execution of rendering functions. + */ +static inline void +davinci_validate_DESTINATION( DavinciDeviceData *ddev, + CardState *state ) +{ + /* Remember destination parameters for usage in rendering functions. */ + ddev->dst_addr = state->dst.addr; + ddev->dst_phys = state->dst.phys; + ddev->dst_size = state->dst.allocation->size; + ddev->dst_pitch = state->dst.pitch; + ddev->dst_format = state->dst.buffer->format; + ddev->dst_bpp = DFB_BYTES_PER_PIXEL( ddev->dst_format ); + + D_DEBUG_AT( Davinci_2D, " => DESTINATION: 0x%08lx\n", ddev->dst_phys ); + + /* Set the flag. */ + DAVINCI_VALIDATE( DESTINATION ); +} + +/* + * Called by davinciSetState() to ensure that the color register is properly set + * for execution of rendering functions. + */ +static inline void +davinci_validate_FILLCOLOR( DavinciDeviceData *ddev, + CardState *state ) +{ + switch (ddev->dst_format) { + case DSPF_ARGB: + case DSPF_RGB32: + ddev->fillcolor = ddev->color_argb; + break; + + case DSPF_RGB16: + ddev->fillcolor = PIXEL_RGB16( state->color.r, + state->color.g, + state->color.b ); + + ddev->fillcolor |= ddev->fillcolor << 16; + break; + + case DSPF_UYVY: { + int y, u, v; + + RGB_TO_YCBCR( state->color.r, state->color.g, state->color.b, y, u, v ); + + ddev->fillcolor = PIXEL_UYVY( y, u, v ); + break; + } + + default: + D_BUG( "unexpected format %s", dfb_pixelformat_name(ddev->dst_format) ); + return; + } + + D_DEBUG_AT( Davinci_2D, " => FILLCOLOR: 0x%08lx\n", ddev->fillcolor ); + + /* Set the flag. */ + DAVINCI_VALIDATE( FILLCOLOR ); +} + +/* + * Called by davinciSetState() to ensure that the source registers are properly set + * for execution of blitting functions. + */ +static inline void +davinci_validate_SOURCE( DavinciDeviceData *ddev, + CardState *state ) +{ + /* Remember source parameters for usage in rendering functions. */ + ddev->src_addr = state->src.addr; + ddev->src_phys = state->src.phys; + ddev->src_pitch = state->src.pitch; + ddev->src_format = state->src.buffer->format; + ddev->src_bpp = DFB_BYTES_PER_PIXEL( ddev->src_format ); + + D_DEBUG_AT( Davinci_2D, " => SOURCE: 0x%08lx\n", ddev->src_phys ); + + /* Set the flag. */ + DAVINCI_VALIDATE( SOURCE ); +} + +/* + * Called by davinciSetState() to ensure that the source ARGB modulation is properly set + * for execution of blitting functions. + */ +static inline void +davinci_validate_SOURCE_MULT( DavinciDeviceData *ddev, + CardState *state ) +{ + switch (ddev->dst_format) { + case DSPF_ARGB: + if (state->blittingflags & DSBLIT_COLORIZE) + ddev->source_mult = 0xff000000 | ddev->color_argb; + else + ddev->source_mult = 0xffffffff; + break; + + default: + D_BUG( "unexpected format %s", dfb_pixelformat_name(ddev->dst_format) ); + return; + } + + D_DEBUG_AT( Davinci_2D, " => SOURCE_MULT: 0x%08lx\n", ddev->source_mult ); + + /* Set the flag. */ + DAVINCI_VALIDATE( SOURCE_MULT ); +} + +/* + * Called by davinciSetState() to ensure that the blend sub function index is valid + * for execution of blitting functions. + */ +static inline void +davinci_validate_BLIT_BLEND_SUB( DavinciDeviceData *ddev, + CardState *state ) +{ + int index = get_blit_blend_sub_function( state ); + + if (index < 0) { + D_BUG( "unexpected state" ); + return; + } + + /* Set blend sub function index. */ + ddev->blit_blend_sub_function = index; + + D_DEBUG_AT( Davinci_2D, " => BLIT_BLEND_SUB: %d\n", index ); + + /* Set the flag. */ + DAVINCI_VALIDATE( BLIT_BLEND_SUB ); +} + +/* + * Called by davinciSetState() to ensure that the blend sub function index is valid + * for execution of drawing functions. + */ +static inline void +davinci_validate_DRAW_BLEND_SUB( DavinciDeviceData *ddev, + CardState *state ) +{ + int index = get_draw_blend_sub_function( state ); + + if (index < 0) { + D_BUG( "unexpected state" ); + return; + } + + /* Set blend sub function index. */ + ddev->draw_blend_sub_function = index; + + D_DEBUG_AT( Davinci_2D, " => DRAW_BLEND_SUB: %d\n", index ); + + /* Set the flag. */ + DAVINCI_VALIDATE( DRAW_BLEND_SUB ); +} + +/**************************************************************************************************/ + +/* + * Wait for the blitter to be idle. + * + * This function is called before memory that has been written to by the hardware is about to be + * accessed by the CPU (software driver) or another hardware entity like video encoder (by Flip()). + * It can also be called by applications explicitly, e.g. at the end of a benchmark loop to include + * execution time of queued commands in the measurement. + */ +DFBResult +davinciEngineSync( void *drv, void *dev ) +{ + DFBResult ret; + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s()\n", __FUNCTION__ ); + + if (!ddev->synced) { + D_DEBUG_AT( Davinci_2D, " -> syncing...\n" ); + + ret = davinci_c64x_wait_low( &ddrv->c64x ); + if (ret) { + D_DEBUG_AT( Davinci_2D, " -> ERROR (%s)\n", DirectFBErrorString(ret) ); + return ret; + } + + D_DEBUG_AT( Davinci_2D, " => syncing done.\n" ); + + ddev->synced = true; + } + else + D_DEBUG_AT( Davinci_2D, " => already synced!\n" ); + + return DFB_OK; +} + +/* + * Reset the graphics engine. + */ +void +davinciEngineReset( void *drv, void *dev ) +{ + D_DEBUG_AT( Davinci_2D, "%s()\n", __FUNCTION__ ); +} + +/* + * Start processing of queued commands if required. + * + * This function is called before returning from the graphics core to the application. + * Usually that's after each rendering function. The only functions causing multiple commands + * to be queued with a single emition at the end are DrawString(), TileBlit(), BatchBlit(), + * DrawLines() and possibly FillTriangle() which is emulated using multiple FillRectangle() calls. + */ +void +davinciEmitCommands( void *drv, void *dev ) +{ + DFBResult ret; + DavinciDeviceData *ddev = dev; + DavinciDriverData *ddrv = drv; + + D_DEBUG_AT( Davinci_2D, "%s()\n", __FUNCTION__ ); + + ret = davinci_c64x_emit_tasks( &ddrv->c64x, &ddrv->tasks, C64X_TEF_RESET ); + if (ret) + D_DERROR( ret, "Davinci/Driver: Error emitting local task buffer!\n" ); + + ddev->synced = false; +} + +/* + * Invalidate the DSP's read cache. + */ +void +davinciFlushTextureCache( void *drv, void *dev ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s()\n", __FUNCTION__ ); + + /* Bad workaround */ + davinci_c64x_blit_32( &ddrv->c64x, dfb_config->video_phys, 1024, dfb_config->video_phys, 1024, 256, 64 ); + + /* These don't work */ +// davinci_c64x_wb_inv_range( &ddrv->c64x, dfb_config->video_phys, +// dfb_config->video_length, 2 ); + +// davinci_c64x_wb_inv_range( &ddrv->c64x, ddev->fix[OSD0].smem_start, +// ddev->fix[OSD0].smem_len, 2 ); +} + +/* + * Check for acceleration of 'accel' using the given 'state'. + */ +void +davinciCheckState( void *drv, + void *dev, + CardState *state, + DFBAccelerationMask accel ) +{ + D_DEBUG_AT( Davinci_2D, "%s( state %p, accel 0x%08x ) <- dest %p\n", + __FUNCTION__, state, accel, state->destination ); + + /* Return if the desired function is not supported at all. */ + if (accel & ~(DAVINCI_SUPPORTED_DRAWINGFUNCTIONS | DAVINCI_SUPPORTED_BLITTINGFUNCTIONS)) + return; + + /* Return if the destination format is not supported. */ + switch (state->destination->config.format) { + case DSPF_UYVY: + case DSPF_RGB16: + case DSPF_RGB32: + case DSPF_ARGB: + break; + + default: + return; + } + + /* Check if drawing or blitting is requested. */ + if (DFB_DRAWING_FUNCTION( accel )) { + /* Return if unsupported drawing flags are set. */ + if (state->drawingflags & ~DAVINCI_SUPPORTED_DRAWINGFLAGS) + return; + + /* Limited blending support. */ + if (state->drawingflags & (DSDRAW_BLEND | DSDRAW_SRC_PREMULTIPLY)) { + if (state->destination->config.format != DSPF_ARGB) + return; + + if (get_draw_blend_sub_function( state ) < 0) + return; + } + } + else { + /* Return if unsupported blitting flags are set. */ + if (state->blittingflags & ~DAVINCI_SUPPORTED_BLITTINGFLAGS) + return; + + /* No other flags supported when color keying is used. */ + if ((state->blittingflags & DSBLIT_SRC_COLORKEY) && state->blittingflags != DSBLIT_SRC_COLORKEY) + return; + + /* Return if the source format is not supported. */ + switch (state->source->config.format) { + case DSPF_UYVY: + case DSPF_RGB16: + /* Only color keying for these formats. */ + if (state->blittingflags & ~DSBLIT_SRC_COLORKEY) + return; + /* No format conversion supported. */ + if (state->source->config.format != state->destination->config.format) + return; + break; + + case DSPF_RGB32: + /* Only color keying for these formats. */ + if (state->blittingflags & ~DSBLIT_SRC_COLORKEY) + return; + /* fall through */ + case DSPF_ARGB: + /* Only few blending combinations are valid. */ + if ((state->blittingflags & ~DSBLIT_SRC_COLORKEY) && get_blit_blend_sub_function( state ) < 0) + return; + /* Only ARGB/RGB32 -> RGB16 conversion (without any flag). */ + if (state->source->config.format != state->destination->config.format && + (state->destination->config.format != DSPF_RGB16 || state->blittingflags)) + return; + break; + + default: + return; + } + + /* Checks per function. */ + switch (accel) { + case DFXL_STRETCHBLIT: + /* No flags supported with StretchBlit(). */ + if (state->blittingflags) + return; + + /* Only (A)RGB at 32 bit supported. */ + if (state->source->config.format != DSPF_ARGB && state->source->config.format != DSPF_RGB32) + return; + + break; + + default: + break; + } + } + + /* Enable acceleration of the function. */ + state->accel |= accel; + + D_DEBUG_AT( Davinci_2D, " => accel 0x%08x\n", state->accel ); +} + +/* + * Make sure that the hardware is programmed for execution of 'accel' according to the 'state'. + */ +void +davinciSetState( void *drv, + void *dev, + GraphicsDeviceFuncs *funcs, + CardState *state, + DFBAccelerationMask accel ) +{ + DavinciDeviceData *ddev = dev; + StateModificationFlags modified = state->mod_hw; + + D_DEBUG_AT( Davinci_2D, "%s( state %p, accel 0x%08x ) <- dest %p, modified 0x%08x\n", + __FUNCTION__, state, accel, state->destination, modified ); + + /* + * 1) Invalidate hardware states + * + * Each modification to the hw independent state invalidates one or more hardware states. + */ + + /* Simply invalidate all? */ + if (modified == SMF_ALL) { + D_DEBUG_AT( Davinci_2D, " <- ALL\n" ); + + DAVINCI_INVALIDATE( ALL ); + } + else if (modified) { + /* Invalidate destination settings. */ + if (modified & SMF_DESTINATION) { + D_DEBUG_AT( Davinci_2D, " <- DESTINATION | FILLCOLOR\n" ); + + DAVINCI_INVALIDATE( DESTINATION | FILLCOLOR ); + } + else if (modified & SMF_COLOR) { + D_DEBUG_AT( Davinci_2D, " <- FILLCOLOR\n" ); + + DAVINCI_INVALIDATE( FILLCOLOR ); + } + + /* Invalidate source settings. */ + if (modified & SMF_SOURCE) { + D_DEBUG_AT( Davinci_2D, " <- SOURCE\n" ); + + DAVINCI_INVALIDATE( SOURCE ); + } + + /* Invalidate source color(ize) settings. */ + if (modified & (SMF_BLITTING_FLAGS | SMF_COLOR)) { + D_DEBUG_AT( Davinci_2D, " <- SOURCE_MULT\n" ); + + DAVINCI_INVALIDATE( SOURCE_MULT ); + } + + /* Invalidate blend function for blitting. */ + if (modified & (SMF_BLITTING_FLAGS | SMF_SRC_BLEND | SMF_DST_BLEND)) { + D_DEBUG_AT( Davinci_2D, " <- BLIT_BLEND_SUB\n" ); + + DAVINCI_INVALIDATE( BLIT_BLEND_SUB ); + } + + /* Invalidate blend function for drawing. */ + if (modified & (SMF_DRAWING_FLAGS | SMF_SRC_BLEND | SMF_DST_BLEND)) { + D_DEBUG_AT( Davinci_2D, " <- DRAW_BLEND_SUB\n" ); + + DAVINCI_INVALIDATE( DRAW_BLEND_SUB ); + } + } + + /* + * Just keep these values, no computations needed here. + * Values used by state validation or rendering functions. + */ + ddev->blitting_flags = state->blittingflags; + ddev->clip = state->clip; + ddev->color = state->color; + ddev->colorkey = state->src_colorkey; + ddev->color_argb = PIXEL_ARGB( state->color.a, + state->color.r, + state->color.g, + state->color.b ); + + /* + * 2) Validate hardware states + * + * Each function has its own set of states that need to be validated. + */ + + /* Always requiring valid destination... */ + DAVINCI_CHECK_VALIDATE( DESTINATION ); + + /* Depending on the function... */ + switch (accel) { + case DFXL_FILLRECTANGLE: + D_DEBUG_AT( Davinci_2D, " -> FILLRECTANGLE\n" ); + + /* Validate blend sub function index for drawing... */ + if (state->drawingflags & (DSDRAW_BLEND | DSDRAW_SRC_PREMULTIPLY)) + DAVINCI_CHECK_VALIDATE( DRAW_BLEND_SUB ); + else + /* ...or just validate fill color. */ + DAVINCI_CHECK_VALIDATE( FILLCOLOR ); + + /* Choose function. */ + switch (DFB_BYTES_PER_PIXEL( state->destination->config.format )) { + case 2: + funcs->FillRectangle = davinciFillRectangle16; + break; + + case 4: + if (state->drawingflags & (DSDRAW_BLEND | DSDRAW_SRC_PREMULTIPLY)) + funcs->FillRectangle = davinciFillRectangleBlend32; + else + funcs->FillRectangle = davinciFillRectangle32; + break; + + default: + D_BUG( "unexpected destination bpp %d", + DFB_BYTES_PER_PIXEL( state->destination->config.format ) ); + break; + } + + /* + * 3) Tell which functions can be called without further validation, i.e. SetState() + * + * When the hw independent state is changed, this collection is reset. + */ + state->set |= DAVINCI_SUPPORTED_DRAWINGFUNCTIONS; + break; + + case DFXL_BLIT: + D_DEBUG_AT( Davinci_2D, " -> BLIT\n" ); + + /* ...require valid source. */ + DAVINCI_CHECK_VALIDATE( SOURCE ); + + /* Validate blend sub function index for blitting. */ + if (state->blittingflags & DSBLIT_BLEND_ALPHACHANNEL) { + DAVINCI_CHECK_VALIDATE( BLIT_BLEND_SUB ); + + /* Validate ARGB source modulator. */ + DAVINCI_CHECK_VALIDATE( SOURCE_MULT ); + } + + /* Choose function. */ + switch (DFB_BYTES_PER_PIXEL( state->destination->config.format )) { + case 2: + if (state->blittingflags & DSBLIT_SRC_COLORKEY) + funcs->Blit = davinciBlitKeyed16; + else if (state->source->config.format == DSPF_ARGB || + state->source->config.format == DSPF_RGB32) + funcs->Blit = davinciBlit32to16; + else + funcs->Blit = davinciBlit16; + break; + + case 4: + if (state->blittingflags & DSBLIT_SRC_COLORKEY) + funcs->Blit = davinciBlitKeyed32; + else if (state->blittingflags & DSBLIT_BLEND_ALPHACHANNEL) + funcs->Blit = davinciBlitBlend32; + else + funcs->Blit = davinciBlit32; + break; + + default: + D_BUG( "unexpected destination bpp %d", + DFB_BYTES_PER_PIXEL( state->destination->config.format ) ); + break; + } + + /* + * 3) Tell which functions can be called without further validation, i.e. SetState() + * + * When the hw independent state is changed, this collection is reset. + */ + state->set |= DFXL_BLIT; + break; + + case DFXL_STRETCHBLIT: + D_DEBUG_AT( Davinci_2D, " -> STRETCHBLIT\n" ); + + /* ...require valid source. */ + DAVINCI_CHECK_VALIDATE( SOURCE ); + + /* Choose function. */ +#if 0 // only 32bit, statically set in driver_init_driver() + switch (state->destination->config.format) { + case DSPF_ARGB: + case DSPF_RGB32: + funcs->StretchBlit = davinciStretchBlit32; + break; + + default: + D_BUG( "unexpected destination format %s", + dfb_pixelformat_name( state->destination->config.format ) ); + break; + } +#endif + + /* + * 3) Tell which functions can be called without further validation, i.e. SetState() + * + * When the hw independent state is changed, this collection is reset. + */ + state->set |= DFXL_STRETCHBLIT; + break; + + default: + D_BUG( "unexpected drawing/blitting function" ); + break; + } + + /* + * 4) Clear modification flags + * + * All flags have been evaluated in 1) and remembered for further validation. + * If the hw independent state is not modified, this function won't get called + * for subsequent rendering functions, unless they aren't defined by 3). + */ + state->mod_hw = 0; +} + +/**********************************************************************************************************************/ +/**********************************************************************************************************************/ + +/* + * Render a filled rectangle using the current hardware state. + */ +static bool +davinciFillRectangle16( void *drv, void *dev, DFBRectangle *rect ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d )\n", __FUNCTION__, DFB_RECTANGLE_VALS(rect) ); + + /* FIXME: Optimize in DSP. */ + if ((rect->x | rect->w) & 1) + davinci_c64x_fill_16__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * rect->y + ddev->dst_bpp * rect->x, + ddev->dst_pitch, + rect->w, rect->h, + ddev->fillcolor ); + else + davinci_c64x_fill_32__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * rect->y + ddev->dst_bpp * rect->x, + ddev->dst_pitch, + rect->w/2, rect->h, + ddev->fillcolor ); + + return true; +} + +static bool +davinciFillRectangle32( void *drv, void *dev, DFBRectangle *rect ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d )\n", __FUNCTION__, DFB_RECTANGLE_VALS(rect) ); + + if (ddev->dst_format == DSPF_ARGB && ddev->color.a == 0xff) + davinci_c64x_blit_blend_32__L( &ddrv->tasks, + C64X_BLEND_ONE_INVSRC, + ddev->dst_phys + ddev->dst_pitch * rect->y + ddev->dst_bpp * rect->x, + ddev->dst_pitch, + 0, + 0, + rect->w, rect->h, + ddev->color_argb, + 0xff ); + else + davinci_c64x_fill_32__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * rect->y + ddev->dst_bpp * rect->x, + ddev->dst_pitch, + rect->w, rect->h, + ddev->fillcolor ); + + return true; +} + +/**********************************************************************************************************************/ + +static bool +davinciFillRectangleBlend32( void *drv, void *dev, DFBRectangle *rect ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d )\n", __FUNCTION__, DFB_RECTANGLE_VALS(rect) ); + + davinci_c64x_blit_blend_32__L( &ddrv->tasks, + ddev->draw_blend_sub_function, + ddev->dst_phys + ddev->dst_pitch * rect->y + ddev->dst_bpp * rect->x, + ddev->dst_pitch, + 0, + 0, + rect->w, rect->h, + ddev->color_argb, + 0xff ); + + return true; +} + +/**********************************************************************************************************************/ +/**********************************************************************************************************************/ + +/* + * Blit a rectangle using the current hardware state. + */ +static bool +davinciBlit16( void *drv, void *dev, DFBRectangle *rect, int dx, int dy ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d <- %4d,%4d )\n", + __FUNCTION__, dx, dy, rect->w, rect->h, rect->x, rect->y ); + + /* FIXME: Optimize in DSP. */ + if ((dx | rect->x | rect->w) & 1) + davinci_c64x_blit_16__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * dy + ddev->dst_bpp * dx, + ddev->dst_pitch, + ddev->src_phys + ddev->src_pitch * rect->y + ddev->src_bpp * rect->x, + ddev->src_pitch, + rect->w, rect->h ); + else + davinci_c64x_blit_32__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * dy + ddev->dst_bpp * dx, + ddev->dst_pitch, + ddev->src_phys + ddev->src_pitch * rect->y + ddev->src_bpp * rect->x, + ddev->src_pitch, + rect->w/2, rect->h ); + + return true; +} + +static bool +davinciBlit32( void *drv, void *dev, DFBRectangle *rect, int dx, int dy ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d <- %4d,%4d )\n", + __FUNCTION__, dx, dy, rect->w, rect->h, rect->x, rect->y ); + + davinci_c64x_blit_32__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * dy + ddev->dst_bpp * dx, + ddev->dst_pitch, + ddev->src_phys + ddev->src_pitch * rect->y + ddev->src_bpp * rect->x, + ddev->src_pitch, + rect->w, rect->h ); + + return true; +} + +/**********************************************************************************************************************/ + +static bool +davinciBlit32to16( void *drv, void *dev, DFBRectangle *rect, int dx, int dy ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d <- %4d,%4d )\n", + __FUNCTION__, dx, dy, rect->w, rect->h, rect->x, rect->y ); + + davinci_c64x_dither_argb__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * dy + ddev->dst_bpp * dx, + DAVINCI_C64X_MEM, + ddev->dst_pitch, + ddev->src_phys + ddev->src_pitch * rect->y + ddev->src_bpp * rect->x, + ddev->src_pitch, + rect->w, rect->h ); + + return true; +} + +/**********************************************************************************************************************/ + +static bool +davinciBlitKeyed16( void *drv, void *dev, DFBRectangle *rect, int dx, int dy ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d <- %4d,%4d ) <- key 0x%04lx\n", + __FUNCTION__, dx, dy, rect->w, rect->h, rect->x, rect->y, ddev->colorkey ); + + davinci_c64x_blit_keyed_16__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * dy + ddev->dst_bpp * dx, + ddev->dst_pitch, + ddev->src_phys + ddev->src_pitch * rect->y + ddev->src_bpp * rect->x, + ddev->src_pitch, + rect->w, rect->h, + ddev->colorkey, + (1 << DFB_COLOR_BITS_PER_PIXEL( ddev->dst_format )) - 1 ); + + return true; +} + +static bool +davinciBlitKeyed32( void *drv, void *dev, DFBRectangle *rect, int dx, int dy ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d <- %4d,%4d ) <- key 0x%08lx\n", + __FUNCTION__, dx, dy, rect->w, rect->h, rect->x, rect->y, ddev->colorkey ); + + davinci_c64x_blit_keyed_32__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * dy + ddev->dst_bpp * dx, + ddev->dst_pitch, + ddev->src_phys + ddev->src_pitch * rect->y + ddev->src_bpp * rect->x, + ddev->src_pitch, + rect->w, rect->h, + ddev->colorkey, + (1 << DFB_COLOR_BITS_PER_PIXEL( ddev->dst_format )) - 1 ); + + return true; +} + +/**********************************************************************************************************************/ + +static bool +davinciBlitBlend32( void *drv, void *dev, DFBRectangle *rect, int dx, int dy ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d <- %4d,%4d )\n", + __FUNCTION__, dx, dy, rect->w, rect->h, rect->x, rect->y ); + + davinci_c64x_blit_blend_32__L( &ddrv->tasks, + ddev->blit_blend_sub_function, + ddev->dst_phys + ddev->dst_pitch * dy + ddev->dst_bpp * dx, + ddev->dst_pitch, + ddev->src_phys + ddev->src_pitch * rect->y + ddev->src_bpp * rect->x, + ddev->src_pitch, + rect->w, rect->h, + ddev->source_mult, + ddev->color.a ); + + return true; +} + +/**********************************************************************************************************************/ +/**********************************************************************************************************************/ + +bool +davinciStretchBlit32( void *drv, void *dev, DFBRectangle *srect, DFBRectangle *drect ) +{ + DavinciDriverData *ddrv = drv; + DavinciDeviceData *ddev = dev; + + DFBRegion clip = DFB_REGION_INIT_FROM_RECTANGLE( drect ); + + D_DEBUG_AT( Davinci_2D, "%s( %4d,%4d-%4dx%4d <- %4d,%4d-%4dx%4d )\n", + __FUNCTION__, DFB_RECTANGLE_VALS(drect), DFB_RECTANGLE_VALS(srect) ); + + if (!dfb_region_region_intersect( &clip, &ddev->clip )) + return true; + + dfb_region_translate( &clip, -drect->x, -drect->y ); + + davinci_c64x_stretch_32__L( &ddrv->tasks, + ddev->dst_phys + ddev->dst_pitch * drect->y + ddev->dst_bpp * drect->x, + ddev->dst_pitch, + ddev->src_phys + ddev->src_pitch * srect->y + ddev->src_bpp * srect->x, + ddev->src_pitch, + drect->w, drect->h, + srect->w, srect->h, + &clip ); + + return true; +} + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_2d.h b/Source/DirectFB/gfxdrivers/davinci/davinci_2d.h new file mode 100755 index 0000000..881c179 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_2d.h @@ -0,0 +1,79 @@ +/* + TI Davinci driver - 2D Acceleration + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + 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 __DAVINCI_2D_H__ +#define __DAVINCI_2D_H__ + + +#define DAVINCI_SUPPORTED_DRAWINGFLAGS (DSDRAW_BLEND |\ + DSDRAW_SRC_PREMULTIPLY) + +#define DAVINCI_SUPPORTED_DRAWINGFUNCTIONS (DFXL_FILLRECTANGLE) + +#define DAVINCI_SUPPORTED_BLITTINGFLAGS (DSBLIT_BLEND_ALPHACHANNEL |\ + DSBLIT_BLEND_COLORALPHA |\ + DSBLIT_COLORIZE |\ + DSBLIT_SRC_COLORKEY |\ + DSBLIT_SRC_PREMULTIPLY |\ + DSBLIT_SRC_PREMULTCOLOR) + +#define DAVINCI_SUPPORTED_BLITTINGFUNCTIONS (DFXL_BLIT | DFXL_STRETCHBLIT) + + +DFBResult davinciEngineSync ( void *drv, + void *dev ); + +void davinciEngineReset ( void *drv, + void *dev ); + +void davinciEmitCommands ( void *drv, + void *dev ); + +void davinciFlushTextureCache( void *drv, + void *dev ); + +void davinciCheckState ( void *drv, + void *dev, + CardState *state, + DFBAccelerationMask accel ); + +void davinciSetState ( void *drv, + void *dev, + GraphicsDeviceFuncs *funcs, + CardState *state, + DFBAccelerationMask accel ); + +bool davinciStretchBlit32 ( void *drv, + void *dev, + DFBRectangle *srect, + DFBRectangle *drect ); + +#endif + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_c64x.c b/Source/DirectFB/gfxdrivers/davinci/davinci_c64x.c new file mode 100755 index 0000000..431ffdd --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_c64x.c @@ -0,0 +1,2053 @@ +/* + TI Davinci driver - C64X+ DSP Library + + (c) Copyright 2008 directfb.org + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp and + Olaf Dreesen . + + All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + + 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 + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "davinci_c64x.h" + + +/**********************************************************************************************************************/ + +#define C64X_DEVICE "/dev/c64x" +#define C64X_DEVICE0 "/dev/c64x0" +#define C64X_QLEN direct_page_align( sizeof(c64xTaskControl) ) +#define C64X_MLEN direct_page_align( 0x2000000 ) + +__attribute__((noinline)) +static void +davinci_c64x_queue_error( DavinciC64x *c64x, const char *msg ) +{ + c64xTaskControl *ctl = c64x->ctl; + uint32_t dsp = ctl->QL_dsp; + uint32_t arm = ctl->QL_arm; + uint32_t armp = (arm-1) & C64X_QUEUE_MASK; + c64xTask *dsp_task = &c64x->QueueL[dsp]; + c64xTask *arm_task = &c64x->QueueL[arm]; + c64xTask *armp_task = &c64x->QueueL[armp]; + + D_PERROR( "Davinci/C64X+: %s [DSP %d / %d (%s), ARM %d / %d (%s) <- %d / %d (%s)]\n", + msg, + dsp, + (dsp_task->c64x_function >> 2) & 0x3fff, + state_names[dsp_task->c64x_function & 3], + arm, + (arm_task->c64x_function >> 2) & 0x3fff, + state_names[arm_task->c64x_function & 3], + armp, + (armp_task->c64x_function >> 2) & 0x3fff, + state_names[armp_task->c64x_function & 3] ); +} + +/* + +1. Idle Case + + ARM ARM + DSP DSP + | . . . . . . . . | | . . . . . . . . | free = length-1 + + +2. Busy Case (ARM after) + + ARM ARM + DSP DSP + | o . . . . . . . | | . o o . . . . . | free = length-1 - arm + dsp + + +3. Busy Case (ARM before) + + ARM ARM + DSP DSP + | . . . . . o o o | | o o . . . . . o | free = dsp - arm - 1 + + +4. Full Case (ARM after) + + ARM + DSP + | o o o o o o o . | free = 0 + + +5. Full Case (ARM before) + + ARM ARM + DSP DSP + | o o o o o . o o | | . o o o o o o o | free = 0 + +*/ + +DFBResult +davinci_c64x_emit_tasks( DavinciC64x *c64x, + DavinciC64xTasks *tasks, + DavinciC64xEmitFlags flags ) +{ + c64xTaskControl *ctl = c64x->ctl; + uint32_t arm = ctl->QL_arm; + unsigned int emitted = 0; + unsigned int timeout = 23; + + D_MAGIC_ASSERT( tasks, DavinciC64xTasks ); + + while (emitted < tasks->num_tasks) { + uint32_t dsp = ctl->QL_dsp; + int free; + + if (arm == dsp) + free = C64X_QUEUE_LENGTH - 1; + else if (arm > dsp) + free = C64X_QUEUE_LENGTH - 1 - arm + dsp; + else + free = dsp - arm - 1; + + if (free) { + int emit = MIN( free, tasks->num_tasks - emitted ); + int copy = MIN( emit, C64X_QUEUE_LENGTH - arm ); + + memcpy( (void*) &c64x->QueueL[arm], (void*) &tasks->tasks[emitted], sizeof(c64xTask) * copy ); + + if (copy < emit) { + memcpy( (void*) &c64x->QueueL[0], (void*) &tasks->tasks[emitted+copy], sizeof(c64xTask) * (emit - copy) ); + + arm = (emit - copy); + } + else + arm = (arm + copy) & C64X_QUEUE_MASK; + + mb(); + + ctl->QL_arm = arm; + + mb(); + + emitted += emit; + + timeout = 23; + } + else { + if (!timeout--) { + davinci_c64x_queue_error( c64x, "Emit Timeout!" ); + return DFB_TIMEOUT; + } + + usleep( 7000 ); + } + } + + if (flags & C64X_TEF_RESET) + tasks->num_tasks = 0; + + return DFB_OK; +} + +DFBResult +davinci_c64x_tasks_init( DavinciC64xTasks *tasks, + unsigned int size ) +{ + tasks->tasks = D_MALLOC( sizeof(c64xTask) * size ); + if (!tasks->tasks) + return D_OOM(); + + tasks->max_tasks = size; + tasks->num_tasks = 0; + + D_MAGIC_SET( tasks, DavinciC64xTasks ); + + return DFB_OK; +} + +DFBResult +davinci_c64x_tasks_destroy( DavinciC64xTasks *tasks ) +{ + D_MAGIC_ASSERT( tasks, DavinciC64xTasks ); + D_ASSERT( tasks->tasks != NULL ); + + D_FREE( (void*) tasks->tasks ); + + tasks->tasks = NULL; + + D_MAGIC_CLEAR( tasks ); + + return DFB_OK; +} + +DFBResult +davinci_c64x_wait_low( DavinciC64x *c64x ) +{ + DFBResult ret; + c64xTaskControl *ctl = c64x->ctl; + + while (ctl->QL_dsp != ctl->QL_arm) { + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_function = C64X_FLAG_TODO | C64X_FLAG_INTERRUPT; + + c64x_submit_task( c64x, task ); + + if (ioctl( c64x->fd, C64X_IOCTL_WAIT_LOW )) { + c64xTask *dsp_task = &c64x->QueueL[ctl->QL_dsp]; + + ret = errno2result( errno ); + D_PERROR( "Davinci/C64X+: C64X_IOCTL_WAIT_LOW failed! [DSP %d / %d (%s), ARM %d / %d (%s)]\n", + ctl->QL_dsp, + (dsp_task->c64x_function >> 2) & 0x3fff, + state_names[dsp_task->c64x_function & 3], + ctl->QL_arm, + (task->c64x_function >> 2) & 0x3fff, + state_names[task->c64x_function & 3] ); + return ret; + } + } + + return DFB_OK; +} + +/**********************************************************************************************************************/ +/* Benchmarking or Testing */ +/**********************************************************************************************************************/ + +#if 1 +#define BRINTF(x...) do { direct_log_printf( NULL, x ); } while (0) +#else +#define BRINTF(x...) printf( x ) +#endif + +static void +bench_mem( const char *name, + void *ptr, + int length, + bool copy, + bool from ) +{ + int i, num; + long long t1, t2, dt, total; + char buf[0x100]; + + if (length > sizeof(buf)) + length = sizeof(buf); + + num = 0x2000000 / length; + + t1 = direct_clock_get_abs_micros(); + + if (copy) { + if (from) + for (i=0; imem + 0x01000000; + int *src = c64x->mem + 0x01100000; + + +#if 0 + src[num++] = DVA_BLOCK_WORD( 100, 0, 1 ); + src[num++] = DVA_BLOCK_WORD( 200, 0, 0 ); + src[num++] = DVA_BLOCK_WORD( 210, 1, 0 ); + src[num++] = DVA_BLOCK_WORD( 220, 2, 1 ); + src[num++] = DVA_BLOCK_WORD( 300, 0, 1 ); + src[num++] = DVA_BLOCK_WORD( 400, 0, 0 ); + src[num++] = DVA_BLOCK_WORD( 410, 1, 1 ); + src[num++] = DVA_BLOCK_WORD( 500, 0, 0 ); + src[num++] = DVA_BLOCK_WORD( 510, 63, 1 ); + src[num++] = DVA_BLOCK_WORD( 600, 63, 1 ); +#else + src[num++] = DVA_BLOCK_WORD(136, 0, 0); + src[num++] = DVA_BLOCK_WORD(-12, 8, 0); + src[num++] = DVA_BLOCK_WORD(7, 16, 0); + src[num++] = DVA_BLOCK_WORD(-2, 24, 1); + + src[num++] = DVA_BLOCK_WORD(136, 0, 0); + src[num++] = DVA_BLOCK_WORD(-12, 8, 0); + src[num++] = DVA_BLOCK_WORD(7, 16, 0); + src[num++] = DVA_BLOCK_WORD(-2, 24, 1); + + + src[num++] = DVA_BLOCK_WORD(1076, 0, 0); + src[num++] = DVA_BLOCK_WORD(-204, 8, 0); + src[num++] = DVA_BLOCK_WORD(-168, 16, 0); + src[num++] = DVA_BLOCK_WORD(-129, 24, 0); + src[num++] = DVA_BLOCK_WORD(-100, 32, 0); + src[num++] = DVA_BLOCK_WORD(-40, 40, 0); + src[num++] = DVA_BLOCK_WORD(-14, 48, 1); +#if 1 + src[num++] = DVA_BLOCK_WORD(1068, 0, 0); + src[num++] = DVA_BLOCK_WORD(2, 1, 0); + src[num++] = DVA_BLOCK_WORD(-202, 8, 0); + src[num++] = DVA_BLOCK_WORD(-168, 16, 0); + src[num++] = DVA_BLOCK_WORD(-2, 9, 0); + src[num++] = DVA_BLOCK_WORD(-129, 24, 0); + src[num++] = DVA_BLOCK_WORD(-97, 32, 0); + src[num++] = DVA_BLOCK_WORD(-40, 40, 0); + src[num++] = DVA_BLOCK_WORD(-13, 48, 1); +#else + src[num++] = DVA_BLOCK_WORD(1068, 0, 0); +// src[num++] = DVA_BLOCK_WORD(2, 1, 0); + src[num++] = DVA_BLOCK_WORD(-202, 8, 0); + src[num++] = DVA_BLOCK_WORD(-1, 16, 0); +// src[num++] = DVA_BLOCK_WORD(-2, 9, 0); + src[num++] = DVA_BLOCK_WORD(-1, 24, 0); + src[num++] = DVA_BLOCK_WORD(-97, 32, 1); +// src[num++] = DVA_BLOCK_WORD(-40, 40, 0); +// src[num++] = DVA_BLOCK_WORD(-13, 48, 1); +#endif + + src[num++] = DVA_BLOCK_WORD(1048, 0, 0); + src[num++] = DVA_BLOCK_WORD(-26, 8, 0); + src[num++] = DVA_BLOCK_WORD(4, 16, 0); + src[num++] = DVA_BLOCK_WORD(5, 24, 0); + src[num++] = DVA_BLOCK_WORD(-4, 32, 1); + + src[num++] = DVA_BLOCK_WORD(996, 0, 0); + src[num++] = DVA_BLOCK_WORD(24, 8, 0); + src[num++] = DVA_BLOCK_WORD(-2, 24, 0); + src[num++] = DVA_BLOCK_WORD(3, 32, 0); + src[num++] = DVA_BLOCK_WORD(-4, 48, 1); +#endif + + BRINTF("\n"); + BRINTF("\n\n.======================== Testing load_block (dct_type_interlaced: %s) ========================.\n", + dct_type_interlaced ? "yes" : "no"); + BRINTF("\n"); + BRINTF( "SOURCE (DVABlockWords)\n" ); + BRINTF("\n"); + + for (i=0; i> 16, (src[i] >> 1) & 0x3f, src[i] & 1); + + BRINTF("\n\n"); + + + memset( dst, 0x55, 0x100000 ); + + + // test routine + davinci_c64x_load_block( c64x, DAVINCI_C64X_MEM+0x01100000, 10, dct_type_interlaced ? 0x7f : 0x3f ); + + // copy idct buffer to memory where we can read it + davinci_c64x_blit_16( c64x, DAVINCI_C64X_MEM+0x01000000, 0, 0xf065c0, 0, 16 * 24, 1 ); + + davinci_c64x_write_back_all( c64x ); + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + + BRINTF( "-> IDCT BUFFER (16x16 + [ 8x8 8x8 ] shorts)\n" ); + BRINTF("\n"); + + for (i=0; i<16*24; i++) { + BRINTF("%5d ", dst[i] ); + if ((i&15)==15) { + BRINTF("\n"); + } + if ((i&255)==255) { + BRINTF("\n"); + } + } + + BRINTF("\n\n"); + +#if 1 + s16 *blocks = c64x->mem + 0x01200000; + int offset = 0; + + memset( blocks, 0, 1024 ); + + for (i=0; i> 1) & 0x3f)] = src[i] >> 16; + + if (src[i] & 1) + offset += 64; + } + + memset( dst, 0x55, 0x100000 ); + + // test routine + for (i=0; i<6; i++) + davinci_c64x_dva_idct( c64x, DAVINCI_C64X_MEM+0x01000000 + i*128, 16, DAVINCI_C64X_MEM+0x01200000 + i*128 ); + + davinci_c64x_write_back_all( c64x ); + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + + BRINTF( "-> SINGLE IDCT (59) BLOCKS (6x 8x8 shorts)\n" ); + BRINTF("\n"); + + for (i=0; i<6*64; i++) { + BRINTF("%5d ", dst[i] ); + if ((i&7)==7) { + BRINTF("\n"); + } + if ((i&63)==63) { + BRINTF("\n"); + } + } + + BRINTF("\n\n"); +#endif + +#if 0 +// s16 blocks[384]; +// int offset = 0; + offset = 0; + + memset( blocks, 0, 1024 ); + + for (i=0; i> 1) & 0x3f)] = src[i] >> 16; + + if (src[i] & 1) { + int n; + + for (n = 0; n < 8; n++) + idct_row (blocks + offset + 8 * n); + + for (n = 0; n < 8; n++) + idct_col (blocks + offset + n); + + offset += 64; + } + } + + BRINTF( "-> REFERENCE IDCT BLOCKS (6x 8x8 shorts)\n" ); + BRINTF("\n"); + + for (i=0; i<6*64; i++) { + BRINTF("%5d ", blocks[i] ); + if ((i&7)==7) { + BRINTF("\n"); + } + if ((i&63)==63) { + BRINTF("\n"); + } + } + + BRINTF("\n\n"); +#endif +} + +static inline void +bench_dezigzag( DavinciC64x *c64x ) +{ + int i, num; + long long t1, t2, dt, total; + //int length = 0x10000; + + num = 0x200000;// / length; + + short *p = c64x->mem + 0x1000000; + + for (i=0; i<64; i++) { + p[i] = i; + BRINTF("%3d ", p[i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_function = C64X_DEZIGZAG | C64X_FLAG_TODO; + + task->c64x_arg[0] = (DAVINCI_C64X_MEM+0x01000000)+0x200000; + task->c64x_arg[1] = (DAVINCI_C64X_MEM+0x01000000)+0x000000; + //task->c64x_arg[2] = length/4; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + p = c64x->mem + 0x1200000; + for (i=0; i<64; i++) { + BRINTF("%3d ", p[i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + dt = t2 - t1; + total = num;// * length; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "de_zigzag()", total * 1000000ULL / dt ); +} + +#define DUMP_PIXELS 1 + +static inline void +bench_blend_argb( DavinciC64x *c64x, int sub ) +{ + int i, num; + long long t1, t2, dt, total; + + num = 1;//0x20000; + + u32 *src = c64x->mem + 0x1000000; + u32 *dst = c64x->mem + 0x1200000; + + BRINTF( "\nTESTING BLEND_32 SUB %d\n", sub ); + + BRINTF( "\nSOURCE " ); + + for (i=0; i> 24, (src[i] >> 16) & 0xff, (src[i] >> 8) & 0xff, src[i] & 0xff); + if (i%8==7) { + BRINTF("\n"); + } + } + + BRINTF( "\nDESTINATION " ); + + for (i=0; i> 24, (dst[i] >> 16) & 0xff, (dst[i] >> 8) & 0xff, dst[i] & 0xff); + if (i%8==7) { + BRINTF("\n"); + } + } + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_function = C64X_BLEND_32 | C64X_FLAG_TODO | (sub << 16); + + task->c64x_arg[0] = (DAVINCI_C64X_MEM+0x01000000)+0x200000; + task->c64x_arg[1] = 32; + task->c64x_arg[2] = (DAVINCI_C64X_MEM+0x01000000)+0x000000; + task->c64x_arg[3] = 32; + task->c64x_arg[4] = 8; + task->c64x_arg[5] = 8; + task->c64x_arg[6] = 0x80; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + BRINTF( "\n\nDESTINATION (AFTER) " ); + + for (i=0; i> 24, (dst[i] >> 16) & 0xff, (dst[i] >> 8) & 0xff, dst[i] & 0xff); + if (i%8==7) { + BRINTF("\n"); + } + } + + BRINTF("\n\n"); + + dt = t2 - t1; + total = num; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "blend_32(8x8)", total * 1000000ULL / dt ); +} + +static inline void +bench_fetch_uyvy( DavinciC64x *c64x, bool interleave, int xoff, int yoff ) { + int i, x, y, num=1; + long long t1, t2, dt, total; + u8 *yuv = c64x->mem + 0x1000000; + u8 *src = c64x->mem + 0x1200000; + + BRINTF("\n\n\n.======================== Testing fetch_uyvy (inter %d, xoff %d, yoff %d) ========================.\n\n", + interleave, xoff, yoff); + + for (y=0; y<20; y++) { + for (x=0; x<40; x++) { + int val = (y*40)+x; + src[y*1440 + x] = val; + BRINTF("%02x ", val&0xff); + } + BRINTF("\n"); + } + BRINTF("\n"); + + memset( yuv, 0xAA, 0x100000 ); + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_arg[0] = (DAVINCI_C64X_MEM+0x01000000)+0x000000; + task->c64x_arg[1] = (DAVINCI_C64X_MEM+0x01000000)+0x200000 + yoff*1440 + xoff * 2; + task->c64x_arg[2] = 1440; + + task->c64x_function = (21 << 2) | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_write_back_all( c64x ); + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + BRINTF( "\n\nDESTINATION\n\nY:\n" ); + for (y=0;y<27;y++) { + if (y==18) BRINTF("\nUV:\n"); + for (x=0;x<32;x++) { + BRINTF("%02x ",yuv[y*32+x]); + } + BRINTF("\n"); + } + + dt = t2 - t1; + total = num; + + D_INFO("\n\nDavinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "blend_fetch_uyvy(16x16)", total * 1000000ULL / dt ); +} +#if 0 +static inline void +bench_fetch_uyvy( DavinciC64x *c64x, bool interleave, int xoff, int yoff ) +{ + int i, x, y, num; + long long t1, t2, dt, total; + + num = 1;//0x20000; + + u8 *yuv = c64x->mem + 0x1000000; + u8 *src = c64x->mem + 0x1200000; + + BRINTF("\n"); + BRINTF("\n\n.======================== Testing fetch_uyvy (inter %d, xoff %d, yoff %d) ========================.\n", + interleave, xoff, yoff); + BRINTF("\n"); + BRINTF( "SOURCE (20x20)\n" ); + + for (y=0; y<20; y++) { + for (x=0; x<40; x++) { + int val = (x & 1) ? (x * 4 + y*0x10) : (x/4 + 0x40 + (x&2) * 0x10 + y*0x08); + + src[y*1440 + x] = val; + + BRINTF("%02x ", val&0xff); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + memset( yuv, 0x55, 0x100000 ); + + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_function = (19 << 2) | C64X_FLAG_TODO; + + task->c64x_arg[0] = (DAVINCI_C64X_MEM+0x01000000)+0x000000; + task->c64x_arg[1] = (DAVINCI_C64X_MEM+0x01000000)+0x200000 + yoff*1440 + xoff * 2; + task->c64x_arg[2] = 1440; + task->c64x_arg[3] = 16; + task->c64x_arg[4] = interleave ? 1 : 0; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + + BRINTF( "\n\nDESTINATION (17x18 / [9x9 9x9])\n" ); + + for (y=0; y<18; y++) { + for (x=0; x<17; x++) { + BRINTF("%02x ", yuv[y*32 + x]); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<9; y++) { + for (x=0; x<9; x++) { + BRINTF("%02x ", yuv[y*32 + x + 32*18]); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<9; y++) { + for (x=0; x<9; x++) { + BRINTF("%02x ", yuv[y*32 + x + 32*18+16]); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + BRINTF("\n\n"); + + dt = t2 - t1; + total = num; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "blend_fetch_uyvy(16x16)", total * 1000000ULL / dt ); +} +#endif + +#if 0 +static inline void +bench_put_idct( DavinciC64x *c64x, int dct_type ) +{ + int i, num; + long long t1, t2, dt, total; + //int length = 0x10000; + + num = 0x10000;// / length; + + u8 *dst = c64x->mem + 0x01000000; + int *src = c64x->mem + 0x01200000; + + src[0] = DVA_BLOCK_WORD( 100, 0, 1 ); + src[1] = DVA_BLOCK_WORD( 200, 0, 0 ); + src[2] = DVA_BLOCK_WORD( 210, 1, 0 ); + src[3] = DVA_BLOCK_WORD( 220, 2, 1 ); + src[4] = DVA_BLOCK_WORD( 300, 0, 1 ); + src[5] = DVA_BLOCK_WORD( 400, 0, 0 ); + src[6] = DVA_BLOCK_WORD( 410, 1, 1 ); + src[7] = DVA_BLOCK_WORD( 500, 0, 0 ); + src[8] = DVA_BLOCK_WORD( 510, 63, 1 ); + src[9] = DVA_BLOCK_WORD( 600, 63, 1 ); + + BRINTF("\n"); + BRINTF("\n\n.======================== Testing put_idct (%d) ========================.\n", dct_type); + BRINTF("\n"); + + memset( dst, 0x55, 0x100000 ); + + for (i=0; i<10; i++) { + BRINTF("0x%08x (%d, %d, %d)\n", (u32)src[i], src[i] >> 16, (src[i] >> 1) & 0x3f, src[i] & 1); + } + + BRINTF("\n"); + + t1 = direct_clock_get_abs_micros(); + + { + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_function = C64X_LOAD_BLOCK | C64X_FLAG_TODO; + + task->c64x_arg[0] = DAVINCI_C64X_MEM+0x1200000; + task->c64x_arg[1] = 10; + task->c64x_arg[2] = 0x3f; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_blit_16( c64x, (DAVINCI_C64X_MEM+0x01000000), 0, 0xf06180, 0, 384, 1 ); + davinci_c64x_blit_16( c64x, (DAVINCI_C64X_MEM+0x01100000), 0, 0xf06480, 0, 384/2, 1 ); + + davinci_c64x_put_uyvy_16x16( c64x, (DAVINCI_C64X_MEM+0x01300000), 32, 0xf06180, 0 ); + + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + + for (i=0; i<384; i++) { + BRINTF("%5d ", dst[i] ); + if (i%8==7) { + BRINTF("\n"); + } + if (i%64==63) { + BRINTF("\n"); + } + } + + BRINTF("\n\n"); + + + for (i=0; i<384; i++) { + BRINTF("%3d ", duv[i] ); + if (i%8==7) { + BRINTF("\n"); + } + if (i%64==63) { + BRINTF("\n"); + } + } + + BRINTF("\n\n"); + + for (i=0; i<16*16*2; i++) { + BRINTF("%02x ", duy[i]); + + if (i%32==31) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + dt = t2 - t1; + total = num;// * length; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "block_load()", total * 1000000ULL / dt ); +} +#endif + +static inline void +bench_put_mc( DavinciC64x *c64x, bool interleave ) +{ + int x, y, i, num; + long long t1, t2, dt, total; + + num = 1;//720/16*576/16; + + u8 *dst = c64x->mem + 0x1000000; + u8 *src = c64x->mem + 0x1200000; + + BRINTF("\n"); + BRINTF("\n\n.======================== Testing put_mc (%d) ========================.\n", interleave); + BRINTF("\n"); + BRINTF("SOURCE (16x16 / [8x8 8x8]\n"); + + for (y=0; y<16; y++) { + for (x=0; x<16; x++) { + u8 val = (x << 4) + y; + src[y*16 + x] = val; + BRINTF("%02x ", val); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<8; y++) { + for (x=0; x<8; x++) { + u8 val = (x << 4) + y*2; + src[y*16 + x + 16*16] = val; + BRINTF("%02x ", val); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<8; y++) { + for (x=0; x<8; x++) { + u8 val = (x << 4) + y*2; + src[y*16 + x + 16*16 + 8] = val; + BRINTF("%02x ", val); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + memset( dst, 0x55, 0x100000 ); + + davinci_c64x_blit_32( c64x, C64X_MC_BUFFER_Y, 16, DAVINCI_C64X_MEM+0x1200000, 16, 4, 24 ); + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_function = C64X_PUT_MC_UYVY_16x16 | C64X_FLAG_TODO; + + task->c64x_arg[0] = DAVINCI_C64X_MEM+0x1000000; + task->c64x_arg[1] = 1440; + task->c64x_arg[2] = interleave ? 1 : 0; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + + BRINTF("\n"); + BRINTF("DESTINATION (16x16 UYVY)\n"); + + for (y=0; y<16; y++) { + for (x=0; x<32; x++) + BRINTF("%02x ", dst[y*1440 + x]); + + BRINTF("\n"); + } + + BRINTF("\n\n"); + + dt = t2 - t1; + total = num; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "put_mc_16x16()", total * 1000000ULL / dt ); +} + +static inline void +bench_put_sum( DavinciC64x *c64x, bool interleave ) +{ + int x, y, i, num; + long long t1, t2, dt, total; + + num = 1;//720/16*576/16; + + u8 *dst = c64x->mem + 0x1000000; + u8 *src = c64x->mem + 0x1200000; + u32 *words = c64x->mem + 0x1100000; + + BRINTF("\n"); + BRINTF("\n\n.======================== Testing put_sum (%d) ========================.\n", interleave); + BRINTF("\n"); + BRINTF("WORDS (6x IDCT with one value)\n"); + + words[0] = DVA_BLOCK_WORD( 0, 0, 1 ); + words[1] = DVA_BLOCK_WORD( 50, 0, 1 ); + words[2] = DVA_BLOCK_WORD( 100, 0, 1 ); + words[3] = DVA_BLOCK_WORD( 150, 0, 1 ); + words[4] = DVA_BLOCK_WORD( 200, 0, 1 ); + words[5] = DVA_BLOCK_WORD( 250, 0, 1 ); + + BRINTF("\n"); + BRINTF("\n"); + + memset( dst, 0x55, 0x100000 ); + + for (i=0; i<6; i++) { + BRINTF("0x%08x (%d, %d, %d)\n", (u32)words[i], words[i] >> 16, (words[i] >> 1) & 0x3f, words[i] & 1); + } + + { + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_function = C64X_LOAD_BLOCK | C64X_FLAG_TODO; + + task->c64x_arg[0] = DAVINCI_C64X_MEM+0x1100000; + task->c64x_arg[1] = 6; + task->c64x_arg[2] = 0x3f; + + c64x_submit_task( c64x, task ); + } + + BRINTF("\n"); + BRINTF("SOURCE (16x16 / [8x8 8x8]\n"); + + for (y=0; y<16; y++) { + for (x=0; x<16; x++) { + u8 val = (x << 4) + y; + src[y*16 + x] = val; + BRINTF("%02x ", val); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<8; y++) { + for (x=0; x<8; x++) { + u8 val = (x << 4) + y*2; + src[y*16 + x + 16*16] = val; + BRINTF("%02x ", val); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<8; y++) { + for (x=0; x<8; x++) { + u8 val = (x << 4) + y*2; + src[y*16 + x + 16*16 + 8] = val; + BRINTF("%02x ", val); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + memset( dst, 0x55, 0x100000 ); + + davinci_c64x_blit_32( c64x, C64X_MC_BUFFER_Y, 16, DAVINCI_C64X_MEM+0x1200000, 16, 4, 24 ); + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_function = C64X_PUT_SUM_UYVY_16x16 | C64X_FLAG_TODO; + + task->c64x_arg[0] = DAVINCI_C64X_MEM+0x1000000; + task->c64x_arg[1] = 1440; + task->c64x_arg[2] = interleave ? 1 : 0; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + + BRINTF("\n"); + BRINTF("DESTINATION (16x16 UYVY)\n"); + + for (y=0; y<16; y++) { + for (x=0; x<32; x++) + BRINTF("%02x ", dst[y*1440 + x]); + + BRINTF("\n"); + } + + BRINTF("\n\n"); + + dt = t2 - t1; + total = num; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "put_sum_16x16()", total * 1000000ULL / dt ); +} + +static inline void +bench_sat_mc( DavinciC64x *c64x ) +{ + int x, y, i, num; + long long t1, t2, dt, total; + + num = 1;//720/16*576/16; + + u8 *dst = c64x->mem + 0x1000000; + u8 *src = c64x->mem + 0x1200000; + + BRINTF("\n\n.======================== Testing sat_mc ========================.\n"); + BRINTF("\n"); + BRINTF("SOURCE (16x16 / [8x8 8x8]\n"); + + for (y=0; y<16; y++) { + for (x=0; x<16; x++) { + u8 val = (x << 4) + y; + src[y*16 + x] = val; + BRINTF("%02x ", val); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<8; y++) { + for (x=0; x<8; x++) { + u8 val = (x << 4) + y*2; + src[y*16 + x + 16*16] = val; + BRINTF("%02x ", val); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<8; y++) { + for (x=0; x<8; x++) { + u8 val = (x << 4) + y*2; + src[y*16 + x + 16*16 + 8] = val; + BRINTF("%02x ", val); + } + + BRINTF("\n"); + } + + BRINTF("\n"); + + memset( dst, 0x55, 0x100000 ); + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_function = (57 << 2) | C64X_FLAG_TODO; + + task->c64x_arg[0] = DAVINCI_C64X_MEM+0x1000000; + task->c64x_arg[1] = DAVINCI_C64X_MEM+0x1200000; + task->c64x_arg[2] = 16; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + + BRINTF("\n"); + BRINTF("DESTINATION (16x16 / [8x8 8x8]\n"); + + for (y=0; y<16; y++) { + for (x=0; x<16; x++) + BRINTF("%02x ", dst[y*16 + x]); + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<8; y++) { + for (x=0; x<8; x++) + BRINTF("%02x ", dst[y*16 + x + 16*16]); + + BRINTF("\n"); + } + + BRINTF("\n"); + + for (y=0; y<8; y++) { + for (x=0; x<8; x++) + BRINTF("%02x ", dst[y*16 + x + 16*16 + 8]); + + BRINTF("\n"); + } + + BRINTF("\n\n"); + + dt = t2 - t1; + total = num; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "sat_mc_16x16()", total * 1000000ULL / dt ); +} + +static inline void +bench_uyvy_1( DavinciC64x *c64x, bool progressive ) +{ + c64xTask *task; + int i, num; + long long t1, t2, dt, total; + + num = 720/16*576/16; + + u8 *u = c64x->mem + 0x1200000; + u8 *p = c64x->mem + 0x1000000; + + BRINTF("\n\n\n.======================== Testing put_uyvy (%s) ========================.\n\n", + progressive ? "progressive" : "interlaced"); + + for (i=0; i<256; i++) { + p[i] = i - 128; + BRINTF("Y%-3d ", p[i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + for (i=0; i<64; i++) { + p[256+i] = i-32; + BRINTF("U%-3d ", p[256+i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + for (i=0; i<64; i++) { + p[320+i] = i-32; + BRINTF("V%-3d ", p[320+i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + for (i=0; i<384; i++) { + BRINTF("%4d ", p[i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + memset( u, 0x55, 720*576*2 ); + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_function = C64X_PUT_UYVY_16x16 | C64X_FLAG_TODO; + + task->c64x_arg[0] = (DAVINCI_C64X_MEM+0x01000000)+0x200000+i*16*16*2; + task->c64x_arg[1] = 720 * 2; + task->c64x_arg[2] = (DAVINCI_C64X_MEM+0x01000000); + task->c64x_arg[3] = 0; + + c64x_submit_task( c64x, task ); + } + + BRINTF("\n"); + + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + for (i=0; i<16*16*2; i++) { + BRINTF("%02x ", u[i/32*720*2 + i%32]); + + if (i%32==31) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + dt = t2 - t1; + total = num; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "put_uyvy_16x16()", total * 1000000ULL / dt ); +} + +static inline void +bench_uyvy_2( DavinciC64x *c64x, bool progressive ) +{ + c64xTask *task; + int i, num; + long long t1, t2, dt, total; + + num = 1;//720/16*576/16; + + u8 *u = c64x->mem + 0x0200000; + u8 *p = c64x->mem + 0x0000000; + + BRINTF("\n\n\n.======================== Testing put_uyvy (%s) ========================.\n\n", + progressive ? "progressive" : "interlaced"); + + for (i=0; i<256; i++) { + p[i] = i/8; + BRINTF("Y%-3d ", p[i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + for (i=0; i<64; i++) { + p[256+i] = i/8 + 128; + BRINTF("U%-3d ", p[256+i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + for (i=0; i<64; i++) { + p[320+i] = i/8 + 240; + BRINTF("V%-3d ", p[320+i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + for (i=0; i<384; i++) { + BRINTF("%4d ", p[i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + memset( u, 0x55, 720*576*2 ); + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_function = C64X_PUT_UYVY_16x16 | C64X_FLAG_TODO; + + task->c64x_arg[0] = DAVINCI_C64X_MEM+0x200000+i*16*16*2; + task->c64x_arg[1] = 720 * 2; + task->c64x_arg[2] = DAVINCI_C64X_MEM; + task->c64x_arg[3] = 0; + + c64x_submit_task( c64x, task ); + } + + BRINTF("\n"); + + davinci_c64x_write_back_all( c64x ); + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + for (i=0; i<16*16*2; i++) { + BRINTF("%02x ", u[i/32*720*2 + i%32]); + + if (i%32==31) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + dt = t2 - t1; + total = num; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "put_uyvy_16x16()", total * 1000000ULL / dt ); +} + +static inline void +bench_uyvy_3( DavinciC64x *c64x, bool progressive ) +{ + c64xTask *task; + int i, num; + long long t1, t2, dt, total; + + num = 1;//720/16*576/16; + + u8 *u = c64x->mem + 0x1200000; + u8 *p = c64x->mem + 0x1000000; + + BRINTF("\n\n\n.======================== Testing put_uyvy (%s) ========================.\n\n", + progressive ? "progressive" : "interlaced"); + + for (i=0; i<256; i++) { + p[i] = i%8; + BRINTF("Y%-3d ", p[i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + for (i=0; i<64; i++) { + p[256+i] = i%8 + 128; + BRINTF("U%-3d ", p[256+i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + for (i=0; i<64; i++) { + p[320+i] = i%8 + 240; + BRINTF("V%-3d ", p[320+i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + for (i=0; i<384; i++) { + BRINTF("%4d ", p[i]); + if (i%8==7) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + memset( u, 0x55, 720*576*2 ); + + t1 = direct_clock_get_abs_micros(); + + for (i=0; ic64x_function = C64X_PUT_UYVY_16x16 | C64X_FLAG_TODO; + + task->c64x_arg[0] = (DAVINCI_C64X_MEM+0x01000000)+0x200000+i*16*16*2; + task->c64x_arg[1] = 720 * 2; + task->c64x_arg[2] = (DAVINCI_C64X_MEM+0x01000000); + task->c64x_arg[3] = 0; + + c64x_submit_task( c64x, task ); + } + + BRINTF("\n"); + + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + for (i=0; i<16*16*2; i++) { + BRINTF("%02x ", u[i/32*720*2 + i%32]); + + if (i%32==31) { + BRINTF("\n"); + } + } + + BRINTF("\n"); + + dt = t2 - t1; + total = num; + + D_INFO( "Davinci/C64X: BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "put_uyvy_16x16()", total * 1000000ULL / dt ); +} + +static inline void +bench_mc( DavinciC64x *c64x, int func, int w, int h, bool avg, const char *name ) +{ + int i, x, y, num; + long long t1, t2, dt, total; + + num = 0x1;//0000; + + u8 *dst = c64x->mem + 0x1200000; + u8 *dsr = c64x->mem + 0x1100000; + u8 *src = c64x->mem + 0x1000000; + + BRINTF("\n\n.============ Testing %s ============.\n", name); + BRINTF("\n"); + BRINTF("SRC REF\n"); + + for (y=0; yc64x_function = (func << 2) | C64X_FLAG_TODO; + + task->c64x_arg[0] = DAVINCI_C64X_MEM + 0x01200000; + task->c64x_arg[1] = 32; + task->c64x_arg[2] = DAVINCI_C64X_MEM + 0x01000000; + task->c64x_arg[3] = DAVINCI_C64X_MEM + 0x01100000; + task->c64x_arg[4] = 32; + task->c64x_arg[5] = h; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + BRINTF("-> DST\n"); + + for (y=0; yc64x_function = (63 << 2) | C64X_FLAG_TODO; + + task->c64x_arg[0] = nom; + task->c64x_arg[1] = den; + + c64x_submit_task( c64x, task ); + + davinci_c64x_wait_low( c64x ); + + BRINTF("%x / %x = %x\n\n\n", nom, den, task->c64x_return); +} + +static inline void +bench_dither_argb( DavinciC64x *c64x ) +{ + int i, x, y, num, w = 8, h = 17; + long long t1, t2, dt, total; + + num = 0x10000; + + u16 *dr = c64x->mem + 0x1200000; + u8 *da = c64x->mem + 0x1100000; + u32 *src = c64x->mem + 0x1000000; + + BRINTF("\n\n.======================== Testing dither_argb ========================.\n"); + BRINTF("\n"); + BRINTF("SOURCE ARGB\n"); + + for (y=0; yc64x_function = C64X_DITHER_ARGB | C64X_FLAG_TODO; + + task->c64x_arg[0] = DAVINCI_C64X_MEM + 0x01200000; + task->c64x_arg[1] = DAVINCI_C64X_MEM + 0x01100000; + task->c64x_arg[2] = 64; + task->c64x_arg[3] = DAVINCI_C64X_MEM + 0x01000000; + task->c64x_arg[4] = 128; + task->c64x_arg[5] = w; + task->c64x_arg[6] = h; + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + BRINTF("-> DST RGB\n"); + + for (y=0; y DST ALPHA\n"); + + for (y=0; y> 4); + } + BRINTF("\n"); + } + + BRINTF("\n"); + + dt = t2 - t1; + total = num; + + BRINTF( "BENCHMARK on DSP - %-15s %lld Calls/sec\n", + "dither_argb", total * 1000000ULL / dt ); +} + + + + +/**********************************************************************************************************************/ +/*** 32 bit scaler ****************************************************************************************************/ +/**********************************************************************************************************************/ + +typedef struct { + DFBRegion clip; + const void *colors; + ulong protect; + ulong key; +} StretchCtx; + +typedef void (*StretchHVx)( void *dst, + int dpitch, + const void *src, + int spitch, + int width, + int height, + int dst_width, + int dst_height, + const StretchCtx *ctx ); + +#define STRETCH_NONE 0 +#define STRETCH_SRCKEY 1 +#define STRETCH_PROTECT 2 +#define STRETCH_SRCKEY_PROTECT 3 +#define STRETCH_NUM 4 + +typedef struct { + struct { + StretchHVx up[STRETCH_NUM]; + StretchHVx down[STRETCH_NUM]; + } f[DFB_NUM_PIXELFORMATS]; +} StretchFunctionTable; + + +#define DST_FORMAT DSPF_ARGB +#define TABLE_NAME stretch_32 +#define FUNC_NAME(UPDOWN,K,P,F) stretch_32_ ## UPDOWN ## _ ## K ## P ## _ ## F +#define SHIFT_R8 8 +#define SHIFT_L8 8 +#define X_00FF00FF 0x00ff00ff +#define X_FF00FF00 0xff00ff00 +#define MASK_RGB 0x00ffffff +#define HAS_ALPHA + +#include + +#undef DST_FORMAT +#undef TABLE_NAME +#undef FUNC_NAME +#undef SHIFT_R8 +#undef SHIFT_L8 +#undef X_00FF00FF +#undef X_FF00FF00 +#undef MASK_RGB +#undef HAS_ALPHA + + +static inline void +bench_stretch_32( DavinciC64x *c64x, int sw, int sh, int dw, int dh ) +{ + int i, x, y, num; + long long t1, t2, dt, total; + bool down = (dw < sw) && (dh < sh); + +#if 0 + int SW = (sw + 5) & ~3; + int SH = (sh + 5) & ~3; + int DW = (dw + 5) & ~3; + int DH = (dh + 5) & ~3; +#else + int SW = sw; + int SH = sh; + int DW = dw; + int DH = dh; +#endif + + num = 1;//0x10000; + + u32 cpu[DW * DH]; + u32 *dst = c64x->mem + 0x1200000; + u32 *src = c64x->mem + 0x1000000; + + memset( src, 0x55, 0x100000 ); + + for (y=0; y %dx%d ) ========================.\n", sw, sh, dw, dh); + BRINTF("\n"); + BRINTF("SOURCE IMAGE (%dx%d) [%dx%d]\n", sw, sh, SW, SH); + + for (y=0; yc64x_function = (down ? + C64X_STRETCH_32_down : + C64X_STRETCH_32_up ) | C64X_FLAG_TODO; + + task->c64x_arg[0] = DAVINCI_C64X_MEM + 0x1200000; + task->c64x_arg[1] = DAVINCI_C64X_MEM + 0x1000000; + task->c64x_arg[2] = (DW * 4) | ((SW * 4) << 16); + task->c64x_arg[3] = dh | (dw << 16); + task->c64x_arg[4] = sh | (sw << 16); + task->c64x_arg[5] = (dw - 1) | ((dh - 1) << 16); + task->c64x_arg[6] = 0 | (0 << 16); + + c64x_submit_task( c64x, task ); + } + + davinci_c64x_write_back_all( c64x ); + + davinci_c64x_wait_low( c64x ); + + t2 = direct_clock_get_abs_micros(); + + + BRINTF("-> DSP RESULT (%dx%d) [%dx%d]\n", dw, dh, DW, DH); + + for (y=0; y CPU RESULT (%dx%d) [%dx%d]\n", dw, dh, DW, DH); + + for (y=0; yfd = fd; + c64x->ctl = map_q; + c64x->mem = map_m; + c64x->QueueL = map_m + 0x01e00000; + + D_INFO( "Davinci/C64X: Low ARM %d / DSP %d, High ARM %d / DSP %d\n", + c64x->ctl->QL_arm, c64x->ctl->QL_dsp, c64x->ctl->QH_arm, c64x->ctl->QH_dsp ); + + D_MAGIC_SET( c64x, DavinciC64x ); + +if (getenv("C64X_TEST")) { +// test_load_block( c64x, false ); + +// test_load_block( c64x, true ); + +// bench_dither_argb( c64x ); + +#if 0 + bench_uyvy_1( c64x, true ); + bench_uyvy_1( c64x, false ); + bench_uyvy_2( c64x, true ); + bench_uyvy_2( c64x, false ); + bench_uyvy_3( c64x, true ); + bench_uyvy_3( c64x, false ); +#endif + +#if 0 + bench_blend_argb( c64x, 0 ); + bench_blend_argb( c64x, 1 ); + bench_blend_argb( c64x, 2 ); + bench_blend_argb( c64x, 3 ); +#endif + +#if 0 + bench_stretch_32( c64x, 2, 1, 16, 1 ); + bench_stretch_32( c64x, 2, 2, 16, 2 ); + + bench_stretch_32( c64x, 2, 1, 3, 1 ); + bench_stretch_32( c64x, 4, 1, 6, 1 ); + + bench_stretch_32( c64x, 3, 1, 2, 1 ); + bench_stretch_32( c64x, 6, 1, 4, 1 ); +#endif + +#if 1 + bench_fetch_uyvy( c64x, false, 0, 0 ); + bench_fetch_uyvy( c64x, false, 1, 0 ); + bench_fetch_uyvy( c64x, false, 0, 1 ); + bench_fetch_uyvy( c64x, false, 1, 1 ); + bench_fetch_uyvy( c64x, true, 0, 0 ); + bench_fetch_uyvy( c64x, true, 1, 0 ); + bench_fetch_uyvy( c64x, true, 0, 1 ); + bench_fetch_uyvy( c64x, true, 1, 1 ); +#endif + +#if 0 + bench_put_mc( c64x, false ); + bench_put_mc( c64x, true ); + + bench_put_sum( c64x, false ); + bench_put_sum( c64x, true ); + + bench_sat_mc( c64x ); +#endif + +#if 0 + bench_mc( c64x, 32, 8, 8, false, "mc_put_o_8" ); + bench_mc( c64x, 33, 8, 8, false, "mc_put_x_8" ); + bench_mc( c64x, 34, 8, 8, false, "mc_put_y_8" ); + bench_mc( c64x, 35, 8, 8, false, "mc_put_xy_8" ); + bench_mc( c64x, 36, 16, 16, false, "mc_put_o_16" ); + bench_mc( c64x, 37, 16, 16, false, "mc_put_x_16" ); + bench_mc( c64x, 38, 16, 16, false, "mc_put_y_16" ); + bench_mc( c64x, 39, 16, 16, false, "mc_put_xy_16" ); +#endif + +#if 0 + bench_mc( c64x, 40, 8, 8, true, "mc_avg_o_8" ); + bench_mc( c64x, 41, 8, 8, true, "mc_avg_x_8" ); + bench_mc( c64x, 42, 8, 8, true, "mc_avg_y_8" ); + bench_mc( c64x, 43, 8, 8, true, "mc_avg_xy_8" ); + bench_mc( c64x, 44, 16, 16, true, "mc_avg_o_16" ); + bench_mc( c64x, 45, 16, 16, true, "mc_avg_x_16" ); + bench_mc( c64x, 46, 16, 16, true, "mc_avg_y_16" ); + bench_mc( c64x, 47, 16, 16, true, "mc_avg_xy_16" ); +#endif + +#if 0 + bench_div( c64x, 1, 3 ); + bench_div( c64x, 1000, 333 ); + bench_div( c64x, 1000, 334 ); + bench_div( c64x, 6666, 2222 ); + bench_div( c64x, 1234, 1234 ); + bench_div( c64x, 4000, 0 ); + bench_div( c64x, 5000, 0 ); + bench_div( c64x, 10000, 3 ); + bench_div( c64x, 14, 3 ); + bench_div( c64x, 0x10000, 0x1000 ); + bench_div( c64x, 0x1000, 0x100 ); + bench_div( c64x, 0x100000, 2 ); +#endif +} + + return DFB_OK; + + +error: + if (map_q) + munmap( map_q, C64X_QLEN ); + + close( fd ); + + return ret; +} + +DFBResult +davinci_c64x_close( DavinciC64x *c64x ) +{ + D_MAGIC_ASSERT( c64x, DavinciC64x ); + + munmap( (void*) c64x->mem, C64X_MLEN ); + munmap( (void*) c64x->ctl, C64X_QLEN ); + + close( c64x->fd ); + + D_MAGIC_CLEAR( c64x ); + + return DFB_OK; +} + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_c64x.h b/Source/DirectFB/gfxdrivers/davinci/davinci_c64x.h new file mode 100755 index 0000000..682da22 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_c64x.h @@ -0,0 +1,935 @@ +/* + TI Davinci driver - C64X+ DSP Library + + (c) Copyright 2008 directfb.org + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp and + Olaf Dreesen . + + All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + + 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 + General Public License for more details. + + You should have received a copy of the GNU 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 __DAVINCI_C64X_H__ +#define __DAVINCI_C64X_H__ + +#include + +#include + +#include +#include + +#include + +#define mb() __asm__ __volatile__ ("" : : : "memory") + +/**********************************************************************************************************************/ + +typedef struct { + int magic; + + int fd; + c64xTaskControl *ctl; + void *mem; + + c64xTask *QueueL; +} DavinciC64x; + +typedef struct { + int magic; + unsigned int max_tasks; + unsigned int num_tasks; + c64xTask *tasks; +} DavinciC64xTasks; + +typedef enum { + C64X_TEF_NONE = 0x0000, + C64X_TEF_RESET = 0x0001 +} DavinciC64xEmitFlags; + +/**********************************************************************************************************************/ + +DFBResult davinci_c64x_open ( DavinciC64x *c64x ); + +DFBResult davinci_c64x_close ( DavinciC64x *c64x ); + +DFBResult davinci_c64x_wait_low( DavinciC64x *c64x ); + +/**********************************************************************************************************************/ + +DFBResult davinci_c64x_tasks_init ( DavinciC64xTasks *tasks, + unsigned int size ); + +DFBResult davinci_c64x_tasks_destroy( DavinciC64xTasks *tasks ); + +/**********************************************************************************************************************/ + +DFBResult davinci_c64x_emit_tasks( DavinciC64x *c64x, + DavinciC64xTasks *tasks, + DavinciC64xEmitFlags flags ); + +/**********************************************************************************************************************/ + +static const char *state_names[] = { "DONE", "ERROR", "TODO", "RUNNING" }; + +static inline c64xTask * +c64x_get_task( DavinciC64x *c64x ) +{ + c64xTaskControl *ctl = c64x->ctl; + uint32_t idx = ctl->QL_arm; + uint32_t next = (idx + 1) & C64X_QUEUE_MASK; + c64xTask *task = &c64x->QueueL[idx]; + int loops = 0; + uint32_t idle = 0; + + /* Wait for the entry (and next) to be processed by the DSP (rare case). */ + while (task->c64x_flags & C64X_FLAG_TODO || ctl->QL_dsp == next) { + if (loops > 666 || (idle && ctl->idlecounter - idle > 666)) { + c64xTask *dsp_task = &c64x->QueueL[ctl->QL_dsp]; + + D_PERROR( "Davinci/C64X+: Blocked! [DSP %d / %d (%s), ARM %d / %d (%s)]\n", + ctl->QL_dsp, + (dsp_task->c64x_function >> 2) & 0x3fff, + state_names[dsp_task->c64x_function & 3], + ctl->QL_arm, + (task->c64x_function >> 2) & 0x3fff, + state_names[task->c64x_function & 3] ); + + break; + } + + idle = ctl->idlecounter; + + /* Queue is full, waiting 10-20ms should not be too bad. */ + if (loops++ > 10) + usleep( 5000 ); + } + + return task; +} + +static inline void +c64x_submit_task( DavinciC64x *c64x, c64xTask *task ) +{ + c64xTaskControl *ctl = c64x->ctl; + uint32_t idx = ctl->QL_arm; + uint32_t next = (idx + 1) & C64X_QUEUE_MASK; + + mb(); + + ctl->QL_arm = next; + + mb(); +} + +/**********************************************************************************************************************/ + +static inline void +davinci_c64x_wb_inv_range( DavinciC64x *c64x, + unsigned long start, + u32 length, + u32 func ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = start; + task->c64x_arg[1] = length; + task->c64x_arg[2] = func; + + task->c64x_function = C64X_WB_INV_RANGE | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_write_back_all( DavinciC64x *c64x ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_function = C64X_WRITE_BACK_ALL | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +/**********************************************************************************************************************/ + +static inline void +davinci_c64x_load_block__L( DavinciC64xTasks *tasks, + unsigned long words, + u32 num, + u32 flags ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = words; + task->c64x_arg[1] = num; + task->c64x_arg[2] = flags; + + task->c64x_function = C64X_LOAD_BLOCK | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_load_block( DavinciC64x *c64x, + unsigned long words, + u32 num, + u32 flags ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = words; + task->c64x_arg[1] = num; + task->c64x_arg[2] = flags; + + task->c64x_function = C64X_LOAD_BLOCK | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_fetch_uyvy( DavinciC64x *c64x, + unsigned long dest, + unsigned long source, + u32 pitch, + u32 height, + u32 flags ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = source; + task->c64x_arg[2] = pitch; + task->c64x_arg[3] = height; + task->c64x_arg[4] = flags; + + task->c64x_function = C64X_FETCH_UYVY | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_mc( DavinciC64x *c64x, + unsigned long dest, + u32 dpitch, + unsigned long source0, + unsigned long source1, + u32 spitch, + u32 height, + int func ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = dpitch; + task->c64x_arg[2] = source0; + task->c64x_arg[3] = source1; + task->c64x_arg[4] = spitch; + task->c64x_arg[5] = height; + + task->c64x_function = func | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_put_idct_uyvy_16x16__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 pitch, + u32 flags ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = flags; + + task->c64x_function = C64X_PUT_IDCT_UYVY_16x16 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_put_idct_uyvy_16x16( DavinciC64x *c64x, + unsigned long dest, + u32 pitch, + u32 flags ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = flags; + + task->c64x_function = C64X_PUT_IDCT_UYVY_16x16 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_put_mc_uyvy_16x16__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 pitch, + u32 flags ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = flags; + + task->c64x_function = C64X_PUT_MC_UYVY_16x16 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_put_mc_uyvy_16x16( DavinciC64x *c64x, + unsigned long dest, + u32 pitch, + u32 flags ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = flags; + + task->c64x_function = C64X_PUT_MC_UYVY_16x16 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_put_sum_uyvy_16x16__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 pitch, + u32 flags ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = flags; + + task->c64x_function = C64X_PUT_SUM_UYVY_16x16 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_put_sum_uyvy_16x16( DavinciC64x *c64x, + unsigned long dest, + u32 pitch, + u32 flags ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = flags; + + task->c64x_function = C64X_PUT_SUM_UYVY_16x16 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_dva_begin_frame__L( DavinciC64xTasks *tasks, + u32 pitch, + unsigned long current, + unsigned long past, + unsigned long future, + u32 flags ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = pitch; + task->c64x_arg[1] = current; + task->c64x_arg[2] = past; + task->c64x_arg[3] = future; + task->c64x_arg[4] = flags; + + task->c64x_function = C64X_DVA_BEGIN_FRAME | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_dva_begin_frame( DavinciC64x *c64x, + u32 pitch, + unsigned long current, + unsigned long past, + unsigned long future, + u32 flags ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = pitch; + task->c64x_arg[1] = current; + task->c64x_arg[2] = past; + task->c64x_arg[3] = future; + task->c64x_arg[4] = flags; + + task->c64x_function = C64X_DVA_BEGIN_FRAME | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_dva_motion_block__L( DavinciC64xTasks *tasks, + unsigned long macroblock ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = macroblock; + + task->c64x_function = C64X_DVA_MOTION_BLOCK | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_dva_motion_block( DavinciC64x *c64x, + unsigned long macroblock ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = macroblock; + + task->c64x_function = C64X_DVA_MOTION_BLOCK | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +/**********************************************************************************************************************/ + +static inline void +davinci_c64x_dva_idct( DavinciC64x *c64x, + unsigned long dest, + u32 pitch, + unsigned long source ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = source; + + task->c64x_function = C64X_DVA_IDCT | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +/**********************************************************************************************************************/ + +static inline void +davinci_c64x_put_uyvy_16x16( DavinciC64x *c64x, + unsigned long dest, + u32 pitch, + unsigned long source, + u32 flags ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = source; + task->c64x_arg[3] = flags; + + task->c64x_function = C64X_PUT_UYVY_16x16 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_dither_argb__L( DavinciC64xTasks *tasks, + unsigned long dst_rgb, + unsigned long dst_alpha, + u32 dst_pitch, + unsigned long source, + u32 src_pitch, + u32 width, + u32 height ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dst_rgb; + task->c64x_arg[1] = dst_alpha; + task->c64x_arg[2] = dst_pitch; + task->c64x_arg[3] = source; + task->c64x_arg[4] = src_pitch; + task->c64x_arg[5] = width; + task->c64x_arg[6] = height; + + task->c64x_function = C64X_DITHER_ARGB | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_dither_argb( DavinciC64x *c64x, + unsigned long dst_rgb, + unsigned long dst_alpha, + u32 dst_pitch, + unsigned long source, + u32 src_pitch, + u32 width, + u32 height ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dst_rgb; + task->c64x_arg[1] = dst_alpha; + task->c64x_arg[2] = dst_pitch; + task->c64x_arg[3] = source; + task->c64x_arg[4] = src_pitch; + task->c64x_arg[5] = width; + task->c64x_arg[6] = height; + + task->c64x_function = C64X_DITHER_ARGB | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_fill_16__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 pitch, + u32 width, + u32 height, + u32 value ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = width; + task->c64x_arg[3] = height; + task->c64x_arg[4] = value; + + task->c64x_function = C64X_FILL_16 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_fill_16( DavinciC64x *c64x, + unsigned long dest, + u32 pitch, + u32 width, + u32 height, + u32 value ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = width; + task->c64x_arg[3] = height; + task->c64x_arg[4] = value; + + task->c64x_function = C64X_FILL_16 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_fill_32__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 pitch, + u32 width, + u32 height, + u32 value ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = width; + task->c64x_arg[3] = height; + task->c64x_arg[4] = value; + + task->c64x_function = C64X_FILL_32 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_fill_32( DavinciC64x *c64x, + unsigned long dest, + u32 pitch, + u32 width, + u32 height, + u32 value ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = pitch; + task->c64x_arg[2] = width; + task->c64x_arg[3] = height; + task->c64x_arg[4] = value; + + task->c64x_function = C64X_FILL_32 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_blit_16__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = dpitch; + task->c64x_arg[2] = src; + task->c64x_arg[3] = spitch; + task->c64x_arg[4] = width; + task->c64x_arg[5] = height; + + task->c64x_function = C64X_COPY_16 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_blit_16( DavinciC64x *c64x, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = dpitch; + task->c64x_arg[2] = src; + task->c64x_arg[3] = spitch; + task->c64x_arg[4] = width; + task->c64x_arg[5] = height; + + task->c64x_function = C64X_COPY_16 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_blit_32__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = dpitch; + task->c64x_arg[2] = src; + task->c64x_arg[3] = spitch; + task->c64x_arg[4] = width; + task->c64x_arg[5] = height; + + task->c64x_function = C64X_COPY_32 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_blit_32( DavinciC64x *c64x, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = dpitch; + task->c64x_arg[2] = src; + task->c64x_arg[3] = spitch; + task->c64x_arg[4] = width; + task->c64x_arg[5] = height; + + task->c64x_function = C64X_COPY_32 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_stretch_32__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 dw, + u32 dh, + u32 sw, + u32 sh, + const DFBRegion *clip ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = src; + task->c64x_arg[2] = dpitch | (spitch << 16); + task->c64x_arg[3] = dh | (dw << 16); + task->c64x_arg[4] = sh | (sw << 16); + task->c64x_arg[5] = clip->x2 | (clip->y2 << 16); + task->c64x_arg[6] = clip->x1 | (clip->y1 << 16); + + if (sw > dw && sh > dh) + task->c64x_function = C64X_STRETCH_32_down | C64X_FLAG_TODO; + else + task->c64x_function = C64X_STRETCH_32_up | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_stretch_32( DavinciC64x *c64x, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 dw, + u32 dh, + u32 sw, + u32 sh, + const DFBRegion *clip ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = src; + task->c64x_arg[2] = dpitch | (spitch << 16); + task->c64x_arg[3] = dh | (dw << 16); + task->c64x_arg[4] = sh | (sw << 16); + task->c64x_arg[5] = clip->x2 | (clip->y2 << 16); + task->c64x_arg[6] = clip->x1 | (clip->y1 << 16); + + if (sw > dw && sh > dh) + task->c64x_function = C64X_STRETCH_32_down | C64X_FLAG_TODO; + else + task->c64x_function = C64X_STRETCH_32_up | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_blit_blend_32__L( DavinciC64xTasks *tasks, + u32 sub_func, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height, + u32 argb, + u8 alpha ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = dpitch; + task->c64x_arg[2] = src; + task->c64x_arg[3] = spitch; + task->c64x_arg[4] = width | (height << 16); + task->c64x_arg[5] = argb; + task->c64x_arg[6] = alpha; + + task->c64x_function = (sub_func << 16) | C64X_BLEND_32 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_blit_blend_32( DavinciC64x *c64x, + u32 sub_func, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height, + u32 argb, + u8 alpha ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = dpitch; + task->c64x_arg[2] = src; + task->c64x_arg[3] = spitch; + task->c64x_arg[4] = width | (height << 16); + task->c64x_arg[5] = argb; + task->c64x_arg[6] = alpha; + + task->c64x_function = (sub_func << 16) | C64X_BLEND_32 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_blit_keyed_16__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height, + u32 key, + u32 mask ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = (dpitch << 16) | (spitch & 0xffff); + task->c64x_arg[2] = src; + task->c64x_arg[3] = width; + task->c64x_arg[4] = height; + task->c64x_arg[5] = key; + task->c64x_arg[6] = mask; + + task->c64x_function = C64X_COPY_KEYED_16 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_blit_keyed_16( DavinciC64x *c64x, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height, + u32 key, + u32 mask ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = (dpitch << 16) | (spitch & 0xffff); + task->c64x_arg[2] = src; + task->c64x_arg[3] = width; + task->c64x_arg[4] = height; + task->c64x_arg[5] = key; + task->c64x_arg[6] = mask; + + task->c64x_function = C64X_COPY_KEYED_16 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +static inline void +davinci_c64x_blit_keyed_32__L( DavinciC64xTasks *tasks, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height, + u32 key, + u32 mask ) +{ + c64xTask *task = &tasks->tasks[tasks->num_tasks]; + + D_ASSERT( tasks->num_tasks < tasks->max_tasks ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = (dpitch << 16) | (spitch & 0xffff); + task->c64x_arg[2] = src; + task->c64x_arg[3] = width; + task->c64x_arg[4] = height; + task->c64x_arg[5] = key; + task->c64x_arg[6] = mask; + + task->c64x_function = C64X_COPY_KEYED_32 | C64X_FLAG_TODO; + + tasks->num_tasks++; +} + +static inline void +davinci_c64x_blit_keyed_32( DavinciC64x *c64x, + unsigned long dest, + u32 dpitch, + unsigned long src, + u32 spitch, + u32 width, + u32 height, + u32 key, + u32 mask ) +{ + c64xTask *task = c64x_get_task( c64x ); + + task->c64x_arg[0] = dest; + task->c64x_arg[1] = (dpitch << 16) | (spitch & 0xffff); + task->c64x_arg[2] = src; + task->c64x_arg[3] = width; + task->c64x_arg[4] = height; + task->c64x_arg[5] = key; + task->c64x_arg[6] = mask; + + task->c64x_function = C64X_COPY_KEYED_32 | C64X_FLAG_TODO; + + c64x_submit_task( c64x, task ); +} + +#endif + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_gfxdriver.c b/Source/DirectFB/gfxdrivers/davinci/davinci_gfxdriver.c new file mode 100755 index 0000000..eef72d1 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_gfxdriver.c @@ -0,0 +1,343 @@ +/* + TI Davinci driver - Graphics Driver + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include "davincifb.h" + +#include "davinci_2d.h" +#include "davinci_gfxdriver.h" +#include "davinci_osd.h" +#include "davinci_osd_pool.h" +#include "davinci_screen.h" +#include "davinci_video.h" +#include "davinci_video_pool.h" + + +#include + +DFB_GRAPHICS_DRIVER( davinci ) + +/**********************************************************************************************************************/ + +static DFBResult +open_fb( DavinciDriverData *ddrv, + DavinciDeviceData *ddev, + unsigned int fbnum ) +{ + int ret; + char buf1[16]; + char buf2[16]; + DavinciFB *fb; + struct fb_var_screeninfo var; + + D_ASSERT( ddrv != NULL ); + D_ASSERT( ddev != NULL ); + D_ASSERT( fbnum < D_ARRAY_SIZE(ddrv->fb) ); + D_ASSERT( fbnum < D_ARRAY_SIZE(ddev->fix) ); + + fb = &ddrv->fb[fbnum]; + + fb->num = fbnum; + + snprintf( buf1, sizeof(buf1), "/dev/fb%u", fbnum ); + snprintf( buf2, sizeof(buf2), "/dev/fb/%u", fbnum ); + + fb->fd = direct_try_open( buf1, buf2, O_RDWR, true ); + if (fb->fd < 0) + return DFB_INIT; + + ret = ioctl( fb->fd, FBIOGET_VSCREENINFO, &var ); + if (ret) { + D_PERROR( "Davinci/Driver: FBIOGET_VSCREENINFO (fb%d) failed!\n", fbnum ); + close( fb->fd ); + return DFB_INIT; + } + + ret = ioctl( fb->fd, FBIOGET_FSCREENINFO, &ddev->fix[fbnum] ); + if (ret) { + D_PERROR( "Davinci/Driver: FBIOGET_FSCREENINFO (fb%d) failed!\n", fbnum ); + close( fb->fd ); + return DFB_INIT; + } + + fb->size = ddev->fix[fbnum].smem_len; + + fb->mem = mmap( NULL, fb->size, PROT_READ | PROT_WRITE, MAP_SHARED, fb->fd, 0 ); + if (fb->mem == MAP_FAILED) { + D_PERROR( "Davinci/Driver: mmap (fb%d, length %d) failed!\n", fbnum, fb->size ); + close( fb->fd ); + return DFB_INIT; + } + + D_INFO( "Davinci/Driver: Mapped fb%d with length %u at %p to %p\n", + fbnum, fb->size, (void*)ddev->fix[fbnum].smem_start, fb->mem ); + + return DFB_OK; +} + +static void +close_fb( DavinciFB *fb ) +{ + munmap( fb->mem, fb->size ); + close( fb->fd ); +} + +/**********************************************************************************************************************/ + +static int +driver_probe( CoreGraphicsDevice *device ) +{ + int ret; + int fd; + vpbe_fb_videomode_t videomode; + + switch (dfb_system_type()) { + case CORE_DEVMEM: + case CORE_TI_CMEM: + if (dfb_config->accelerator == 6400) + return 1; + break; + + default: + return 0; + } + + fd = direct_try_open( "/dev/fb0", "/dev/fb/0", O_RDWR, true ); + if (fd < 0) + return 0; + + ret = ioctl( fd, FBIO_GET_TIMING, &videomode); + + close( fd ); + + if (ret) { + D_PERROR( "Davinci/Driver: FBIO_GET_TIMING failed!\n" ); + return 0; + } + + if (videomode.xres > 768 || videomode.yres > 576 || videomode.fps > 60) { + D_ERROR( "Davinci/Driver: Invalid mode %dx%d @%d!\n", videomode.xres, videomode.yres, videomode.fps ); + return 0; + } + + if (strncmp( (char*)videomode.name, "PAL", 3 ) && + strncmp( (char*)videomode.name, "NTSC", 4 )) + { + D_ERROR( "Davinci/Driver: Unknown mode name '%s'!\n", videomode.name ); + return 0; + } + + return 1; +} + +static void +driver_get_info( CoreGraphicsDevice *device, + GraphicsDriverInfo *info ) +{ + /* fill driver info structure */ + snprintf( info->name, + DFB_GRAPHICS_DRIVER_INFO_NAME_LENGTH, + "TI Davinci Driver" ); + + snprintf( info->vendor, + DFB_GRAPHICS_DRIVER_INFO_VENDOR_LENGTH, + "Telio AG" ); + + info->version.major = 0; + info->version.minor = 4; + + info->driver_data_size = sizeof(DavinciDriverData); + info->device_data_size = sizeof(DavinciDeviceData); +} + +static DFBResult +driver_init_driver( CoreGraphicsDevice *device, + GraphicsDeviceFuncs *funcs, + void *driver_data, + void *device_data, + CoreDFB *core ) +{ + DFBResult ret; + DavinciDriverData *ddrv = driver_data; + DavinciDeviceData *ddev = device_data; + bool master = dfb_core_is_master( core ); + + ddrv->ddev = ddev; + ddrv->core = core; + + ret = open_fb( ddrv, ddev, OSD0 ); + if (ret) + return ret; + + ret = open_fb( ddrv, ddev, VID0 ); + if (ret) + goto error_fb1; + + ret = open_fb( ddrv, ddev, OSD1 ); + if (ret) + goto error_fb2; + + ret = open_fb( ddrv, ddev, VID1 ); + if (ret) + goto error_fb3; + + ret = davinci_c64x_open( &ddrv->c64x ); + if (ret) + D_WARN( "running without DSP acceleration" ); + else { + ret = davinci_c64x_tasks_init( &ddrv->tasks, 2048 ); + if (ret) { + D_DERROR( ret, "Davinci/Driver: Error initializing local task buffer!\n" ); + return ret; + } + + ddrv->c64x_present = true; + + /* initialize function pointers */ + funcs->EngineSync = davinciEngineSync; + funcs->EngineReset = davinciEngineReset; + funcs->EmitCommands = davinciEmitCommands; + funcs->FlushTextureCache = davinciFlushTextureCache; + funcs->CheckState = davinciCheckState; + funcs->SetState = davinciSetState; + funcs->StretchBlit = davinciStretchBlit32; + } + + ddrv->screen = dfb_screens_register( device, driver_data, &davinciScreenFuncs ); + + ddrv->osd = dfb_layers_register( ddrv->screen, driver_data, &davinciOSDLayerFuncs ); + ddrv->video = dfb_layers_register( ddrv->screen, driver_data, &davinciVideoLayerFuncs ); + + if (!master) { + dfb_surface_pool_join( core, ddev->osd_pool, &davinciOSDSurfacePoolFuncs ); +// dfb_surface_pool_join( core, ddev->video_pool, &davinciVideoSurfacePoolFuncs ); + } + + if (!dfb_config->software_only && funcs->CheckState) { + dfb_config->font_format = DSPF_ARGB; + dfb_config->font_premult = true; + } + + return DFB_OK; + +error_fb3: + close_fb( &ddrv->fb[OSD1] ); + +error_fb2: + close_fb( &ddrv->fb[VID0] ); + +error_fb1: + close_fb( &ddrv->fb[OSD0] ); + + return DFB_INIT; +} + +static DFBResult +driver_init_device( CoreGraphicsDevice *device, + GraphicsDeviceInfo *device_info, + void *driver_data, + void *device_data ) +{ + DavinciDriverData *ddrv = driver_data; + DavinciDeviceData *ddev = device_data; + + /* fill device info */ + snprintf( device_info->vendor, DFB_GRAPHICS_DEVICE_INFO_VENDOR_LENGTH, "Texas Instruments" ); + snprintf( device_info->name, DFB_GRAPHICS_DEVICE_INFO_NAME_LENGTH, "Davinci" ); + + /* device limitations */ + device_info->limits.surface_byteoffset_alignment = 64; + device_info->limits.surface_bytepitch_alignment = 32; + + if (ddrv->c64x_present) { + device_info->caps.flags = 0; + device_info->caps.accel = DAVINCI_SUPPORTED_DRAWINGFUNCTIONS | + DAVINCI_SUPPORTED_BLITTINGFUNCTIONS; + device_info->caps.drawing = DAVINCI_SUPPORTED_DRAWINGFLAGS; + device_info->caps.blitting = DAVINCI_SUPPORTED_BLITTINGFLAGS; + device_info->caps.clip = DFXL_STRETCHBLIT; + } + + dfb_surface_pool_initialize( ddrv->core, &davinciOSDSurfacePoolFuncs, &ddev->osd_pool ); +// dfb_surface_pool_initialize( ddrv->core, &davinciVideoSurfacePoolFuncs, &ddev->video_pool ); + + return DFB_OK; +} + +static void +driver_close_device( CoreGraphicsDevice *device, + void *driver_data, + void *device_data ) +{ +} + +static void +driver_close_driver( CoreGraphicsDevice *device, + void *driver_data ) +{ + DavinciDriverData *ddrv = driver_data; + + if (ddrv->c64x_present) { + davinci_c64x_tasks_destroy( &ddrv->tasks ); + + davinci_c64x_close( &ddrv->c64x ); + } + + close_fb( &ddrv->fb[VID1] ); + close_fb( &ddrv->fb[OSD1] ); + close_fb( &ddrv->fb[VID0] ); + close_fb( &ddrv->fb[OSD0] ); +} + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_gfxdriver.h b/Source/DirectFB/gfxdrivers/davinci/davinci_gfxdriver.h new file mode 100755 index 0000000..4ca79b3 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_gfxdriver.h @@ -0,0 +1,169 @@ +/* + TI Davinci driver - Graphics Driver + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + 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 __DAVINCI_GFXDRIVER_H__ +#define __DAVINCI_GFXDRIVER_H__ + +#include +#include + +#include + +#include "davincifb.h" + +#include "davinci_c64x.h" + + +typedef struct { + /* validation flags */ + int v_flags; + + /* cached/computed values */ + void *dst_addr; + unsigned long dst_phys; + unsigned int dst_size; + unsigned long dst_pitch; + DFBSurfacePixelFormat dst_format; + unsigned long dst_bpp; + + void *src_addr; + unsigned long src_phys; + unsigned long src_pitch; + DFBSurfacePixelFormat src_format; + unsigned long src_bpp; + + unsigned long source_mult; + + unsigned long fillcolor; + + int blit_blend_sub_function; + int draw_blend_sub_function; + + DFBColor color; + unsigned long color_argb; + unsigned long colorkey; + + DFBSurfaceBlittingFlags blitting_flags; + + DFBRegion clip; + + /** Add shared data here... **/ + struct fb_fix_screeninfo fix[4]; + + CoreSurfacePool *osd_pool; + CoreSurfacePool *video_pool; + + bool synced; +} DavinciDeviceData; + + +typedef struct { + int num; + int fd; + void *mem; + int size; +} DavinciFB; + +typedef struct { + DavinciDeviceData *ddev; + + CoreDFB *core; + + CoreScreen *screen; + CoreLayer *osd; + CoreLayer *video; + + DavinciFB fb[4]; + + DavinciC64x c64x; + bool c64x_present; + + DavinciC64xTasks tasks; +} DavinciDriverData; + + +static inline DFBResult +davincifb_pan_display( const DavinciFB *fb, + struct fb_var_screeninfo *var, + const CoreSurfaceBufferLock *lock, + DFBSurfaceFlipFlags flags, + int x, + int y ) +{ + int ret; + + if (lock) { +#ifdef FBIO_SET_START + CoreSurfaceBuffer *buffer = lock->buffer; + struct fb_set_start set_start; + + /* physical mode */ + set_start.offset = -1; + set_start.sync = (flags & DSFLIP_ONSYNC) ? 1 : 0; + + /* life's so easy */ + set_start.physical = lock->phys + DFB_BYTES_PER_LINE( buffer->format, x ) + y * lock->pitch; + + ret = ioctl( fb->fd, FBIO_SET_START, &set_start ); + if (ret < 0) + D_DEBUG( "FBIO_SET_START (0x%08lx, sync %llu) failed!\n", + set_start.physical, set_start.sync ); + + if (ret == 0) { + if (flags & DSFLIP_WAIT) + ioctl( fb->fd, FBIO_WAITFORVSYNC ); + + return DFB_OK; + } + + /* fallback */ +#endif + var->xoffset = x; /* poor version */ + var->yoffset = y + lock->offset / lock->pitch; + } + else { + var->xoffset = x; + var->yoffset = y; + } + + var->activate = /*(flags & DSFLIP_ONSYNC) ? FB_ACTIVATE_VBL :*/ FB_ACTIVATE_NOW; + + ret = ioctl( fb->fd, FBIOPAN_DISPLAY, var ); + if (ret) + D_PERROR( "Davinci/FB: FBIOPAN_DISPLAY (fb%d - %d,%d) failed!\n", + fb->num, var->xoffset, var->yoffset ); + + if (flags & DSFLIP_WAIT) + ioctl( fb->fd, FBIO_WAITFORVSYNC ); + + return DFB_OK; +} + +#endif diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_osd.c b/Source/DirectFB/gfxdrivers/davinci/davinci_osd.c new file mode 100755 index 0000000..2effb2e --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_osd.c @@ -0,0 +1,681 @@ +/* + TI Davinci driver - Graphics Layer + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include "davincifb.h" + +#include "davinci_gfxdriver.h" +#include "davinci_osd.h" + + +#define D_OSDERROR(x...) do {} while (0) + + +D_DEBUG_DOMAIN( Davinci_OSD, "Davinci/OSD", "TI Davinci OSD" ); + +/**********************************************************************************************************************/ + +static int +osdLayerDataSize( void ) +{ + return sizeof(DavinciOSDLayerData); +} + +static DFBResult +osdInitLayer( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *config, + DFBColorAdjustment *adjustment ) +{ + int ret; + DavinciDriverData *ddrv = driver_data; + DavinciOSDLayerData *dosd = layer_data; + + D_DEBUG_AT( Davinci_OSD, "%s()\n", __FUNCTION__ ); + + ret = ioctl( ddrv->fb[OSD0].fd, FBIOGET_VSCREENINFO, &dosd->var0 ); + if (ret) { + D_PERROR( "Davinci/OSD: FBIOGET_VSCREENINFO (fb%d) failed!\n", OSD0 ); + return DFB_INIT; + } + + ret = ioctl( ddrv->fb[OSD1].fd, FBIOGET_VSCREENINFO, &dosd->var1 ); + if (ret) { + D_PERROR( "Davinci/OSD: FBIOGET_VSCREENINFO (fb%d) failed!\n", OSD1 ); + return DFB_INIT; + } + + ret = ioctl( ddrv->fb[OSD0].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", OSD0, 0 ); + + ret = ioctl( ddrv->fb[OSD1].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", OSD1, 0 ); + + /* set capabilities and type */ + description->caps = DLCAPS_SURFACE | DLCAPS_ALPHACHANNEL | DLCAPS_OPACITY | DLCAPS_SCREEN_POSITION | + DLCAPS_SRC_COLORKEY; + description->type = DLTF_GRAPHICS; + + /* set name */ + snprintf( description->name, DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, "TI Davinci OSD" ); + + /* fill out the default configuration */ + config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | + DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE | DLCONF_OPTIONS; + config->width = 640; + config->height = 480; + config->pixelformat = DSPF_RGB16; + config->buffermode = DLBM_FRONTONLY; + config->options = DLOP_ALPHACHANNEL; + + return DFB_OK; +} + +static DFBResult +osdTestRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags *failed ) +{ + CoreLayerRegionConfigFlags fail = 0; + + D_DEBUG_AT( Davinci_OSD, "%s()\n", __FUNCTION__ ); + + if (config->options & ~DAVINCI_OSD_SUPPORTED_OPTIONS) + fail |= CLRCF_OPTIONS; + + switch (config->format) { + case DSPF_RGB444: + case DSPF_RGB555: + case DSPF_RGB16: + case DSPF_RGB32: + case DSPF_ARGB4444: + case DSPF_ARGB1555: + case DSPF_ARGB: + break; + + default: + fail |= CLRCF_FORMAT; + } + + if (config->width < 8 || config->width > 1920) + fail |= CLRCF_WIDTH; + + if (config->height < 8 || config->height > 1080) + fail |= CLRCF_HEIGHT; + + if (config->dest.x < 0 || config->dest.y < 0) + fail |= CLRCF_DEST; + + if (config->dest.x + config->dest.w > 1920) + fail |= CLRCF_DEST; + + if (config->dest.y + config->dest.h > 1080) + fail |= CLRCF_DEST; + + if (failed) + *failed = fail; + + if (fail) + return DFB_UNSUPPORTED; + + return DFB_OK; +} + +static DFBResult +osdSetRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags updated, + CoreSurface *surface, + CorePalette *palette, + CoreSurfaceBufferLock *lock ) +{ + int ret; + DavinciDriverData *ddrv = driver_data; + DavinciDeviceData *ddev = ddrv->ddev; + DavinciOSDLayerData *dosd = layer_data; + + D_DEBUG_AT( Davinci_OSD, "%s()\n", __FUNCTION__ ); + + D_ASSERT( ddrv != NULL ); + D_ASSERT( ddev != NULL ); + D_ASSERT( dosd != NULL ); + + ret = ioctl( ddrv->fb[OSD0].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", OSD0, 0 ); + + ret = ioctl( ddrv->fb[OSD1].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", OSD1, 0 ); + + ioctl( ddrv->fb[OSD0].fd, FBIO_WAITFORVSYNC ); + + /* Update blend parameters? */ + if (updated & (CLRCF_OPTIONS | CLRCF_OPACITY | CLRCF_SRCKEY | CLRCF_FORMAT)) { + vpbe_blink_option_t blink = {0}; + vpbe_bitmap_blend_params_t blend = {0}; + + D_DEBUG_AT( Davinci_OSD, " -> %s\n", dfb_pixelformat_name( config->format ) ); + + if (config->options & DLOP_SRC_COLORKEY) { + blend.enable_colorkeying = 1; + blend.colorkey = dfb_color_to_pixel( DSPF_RGB16, + config->src_key.r, + config->src_key.g, + config->src_key.b ); + + D_DEBUG_AT( Davinci_OSD, " -> color key 0x%02x (%02x %02x %02x)\n", + blend.colorkey, config->src_key.r, config->src_key.g, config->src_key.b ); + } + else if (config->options & DLOP_OPACITY) { + blend.bf = config->opacity >> 5; + + D_DEBUG_AT( Davinci_OSD, " -> opacity %d/7\n", blend.bf ); + } + else + blend.bf = 7; + + ret = ioctl( ddrv->fb[OSD0].fd, FBIO_SET_BITMAP_BLEND_FACTOR, &blend ); + if (ret) + D_PERROR( "Davinci/OSD: FBIO_SET_BITMAP_BLEND_FACTOR (fb%d)!\n", OSD0 ); + + if (config->options & DLOP_ALPHACHANNEL) + dosd->alpha = DFB_PIXELFORMAT_HAS_ALPHA( config->format ); + else + dosd->alpha = 0; + + D_DEBUG_AT( Davinci_OSD, " -> %salpha channel\n", dosd->alpha ? "" : "no " ); + + if (dosd->alpha) { + if (ioctl( ddrv->fb[OSD0].fd, FBIO_ENABLE_DISABLE_ATTRIBUTE_WIN, dosd->alpha )) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_ATTRIBUTE_WIN (fb%d - %d)!\n", OSD0, dosd->alpha ); + } + + if (ioctl( ddrv->fb[OSD1].fd, FBIO_SET_BLINK_INTERVAL, &blink )) + D_OSDERROR( "Davinci/OSD: FBIO_SET_BLINK_INTERVAL (fb%d - disable)!\n", OSD1 ); + } + + /* Update size? */ + if (updated & (CLRCF_WIDTH | CLRCF_HEIGHT | CLRCF_BUFFERMODE)) { + vpbe_window_position_t win_pos; + + D_DEBUG_AT( Davinci_OSD, " -> %dx%d\n", config->width, config->height ); + +/*********************************** Start workaround ***********************************/ + win_pos.xpos = 0; + win_pos.ypos = 0; + + ret = ioctl( ddrv->fb[OSD0].fd, FBIO_SETPOS, &win_pos ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_SETPOS (fb%d - %d,%d) failed!\n", OSD0, win_pos.xpos, win_pos.ypos ); + + ret = ioctl( ddrv->fb[OSD1].fd, FBIO_SETPOS, &win_pos ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_SETPOS (fb%d - %d,%d) failed!\n", OSD1, win_pos.xpos, win_pos.ypos ); + + updated |= CLRCF_DEST; + + dosd->var0.yoffset = dosd->var1.yoffset = 0; +/*********************************** End workaround ***********************************/ + + /* Set width and height. */ + dosd->var0.xres = config->width; + dosd->var0.yres = config->height; + dosd->var1.xres = config->width; + dosd->var1.yres = config->height; + + dosd->var0.yres_virtual = ddrv->fb[OSD0].size / ddev->fix[OSD0].line_length; + + ret = ioctl( ddrv->fb[OSD0].fd, FBIOPUT_VSCREENINFO, &dosd->var0 ); + if (ret) + D_PERROR( "Davinci/OSD: FBIOPUT_VSCREENINFO (fb%d) failed!\n", OSD0 ); + + ret = ioctl( ddrv->fb[OSD1].fd, FBIOPUT_VSCREENINFO, &dosd->var1 ); + if (ret) + D_PERROR( "Davinci/OSD: FBIOPUT_VSCREENINFO (fb%d) failed!\n", OSD1 ); + } + + /* Update position? */ + if (updated & CLRCF_DEST) { + vpbe_window_position_t win_pos; + + D_DEBUG_AT( Davinci_OSD, " -> %d, %d\n", config->dest.x, config->dest.y ); + + /* Set horizontal and vertical offset. */ + win_pos.xpos = config->dest.x; + win_pos.ypos = config->dest.y; + + ret = ioctl( ddrv->fb[OSD0].fd, FBIO_SETPOS, &win_pos ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_SETPOS (fb%d - %d,%d) failed!\n", OSD0, config->dest.x, config->dest.y ); + + ret = ioctl( ddrv->fb[OSD1].fd, FBIO_SETPOS, &win_pos ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_SETPOS (fb%d - %d,%d) failed!\n", OSD1, config->dest.x, config->dest.y ); + } + + davincifb_pan_display( &ddrv->fb[OSD0], &dosd->var0, + (config->format == DSPF_RGB16) ? lock : NULL, DSFLIP_NONE, 0, 0 ); + + ret = ioctl( ddrv->fb[OSD0].fd, FBIOGET_FSCREENINFO, &ddev->fix[OSD0] ); + if (ret) + D_PERROR( "Davinci/OSD: FBIOGET_FSCREENINFO (fb%d) failed!\n", OSD0 ); + + ret = ioctl( ddrv->fb[OSD1].fd, FBIOGET_FSCREENINFO, &ddev->fix[OSD1] ); + if (ret) + D_PERROR( "Davinci/OSD: FBIOGET_FSCREENINFO (fb%d) failed!\n", OSD1 ); + + dosd->enable = true; + + if (ioctl( ddrv->fb[OSD0].fd, FBIO_ENABLE_DISABLE_ATTRIBUTE_WIN, 0 )) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_ATTRIBUTE_WIN (fb%d - %d)!\n", OSD0, 0 ); + + return DFB_OK; +} + +static DFBResult +osdRemoveRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data ) +{ + int ret; + DavinciDriverData *ddrv = driver_data; + DavinciOSDLayerData *dosd = layer_data; + + D_DEBUG_AT( Davinci_OSD, "%s()\n", __FUNCTION__ ); + + D_ASSERT( ddrv != NULL ); + + ret = ioctl( ddrv->fb[OSD0].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", OSD0, 0 ); + + ret = ioctl( ddrv->fb[OSD1].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", OSD1, 0 ); + + dosd->enable = false; + + return DFB_OK; +} + +static void +update_buffers( DavinciDriverData *ddrv, + DavinciDeviceData *ddev, + CoreSurface *surface, + CoreSurfaceBufferLock *lock, + const DFBRegion *update ) +{ + DFBRectangle rect; + CoreSurfaceBuffer *buffer; + + D_ASSERT( ddrv != NULL ); + D_ASSERT( ddev != NULL ); + D_ASSERT( surface != NULL ); + D_ASSERT( lock != NULL ); + DFB_REGION_ASSERT_IF( update ); + + buffer = lock->buffer; + D_ASSERT( buffer != NULL ); + + if (update) { + rect = DFB_RECTANGLE_INIT_FROM_REGION( update ); + + if (rect.x & 1) { + rect.x &= ~1; + rect.w++; + } + + if (rect.w & 1) + rect.w++; + } + else { + rect.x = 0; + rect.y = 0; + rect.w = surface->config.size.w; + rect.h = surface->config.size.h; + } + + /* Can we use the DSP? */ + if (ddrv->c64x_present) { + int i; + int lines = ddev->fix[OSD0].line_length == ddev->fix[OSD1].line_length ? rect.h : 1; + unsigned long rgb = ddev->fix[OSD0].smem_start + rect.x * 2 + rect.y * ddev->fix[OSD0].line_length; + unsigned long alpha = ddev->fix[OSD1].smem_start + rect.x / 2 + rect.y * ddev->fix[OSD1].line_length; + unsigned long src = lock->phys + rect.x * 4 + rect.y * lock->pitch; + + //D_ASSUME( ddev->fix[OSD0].line_length == ddev->fix[OSD1].line_length ); + + dfb_gfxcard_lock( GDLF_NONE ); + + /* Dither ARGB to RGB16+A3 using the DSP. */ + for (i=0; i rect.h - i) + lines = rect.h - i; + + davinci_c64x_dither_argb__L( &ddrv->tasks, rgb, alpha, + ddev->fix[OSD0].line_length, src, lock->pitch, rect.w, lines ); + + if (ddev->fix[OSD0].line_length != ddev->fix[OSD1].line_length && lines > 1) { + davinci_c64x_blit_32__L( &ddrv->tasks, + alpha + ddev->fix[OSD1].line_length, ddev->fix[OSD1].line_length, + alpha + ddev->fix[OSD0].line_length, ddev->fix[OSD0].line_length, + rect.w/2, lines - 1 ); + } + + rgb += lines * ddev->fix[OSD0].line_length; + alpha += lines * ddev->fix[OSD1].line_length; + src += lines * lock->pitch; + } + + /* Flush the write cache. */ + davinci_c64x_write_back_all( &ddrv->c64x ); + + + davinci_c64x_emit_tasks( &ddrv->c64x, &ddrv->tasks, C64X_TEF_RESET ); + + + dfb_gfxcard_unlock(); + } + else { + u32 *src32 = lock->addr + rect.y * lock->pitch + DFB_BYTES_PER_LINE( buffer->format, rect.x ); + int sp4 = lock->pitch / 4; + u32 *dst32 = ddrv->fb[OSD0].mem + rect.y * ddev->fix[OSD0].line_length + rect.x * 2; + int dp4 = ddev->fix[OSD0].line_length / 4; + u8 *dst8 = ddrv->fb[OSD1].mem + rect.y * ddev->fix[OSD1].line_length + rect.x / 2; + int dp = ddev->fix[OSD1].line_length; + int w2 = rect.w / 2; + u32 z = 0; + + switch (buffer->format) { + case DSPF_ARGB4444: + while (rect.h--) { + int x; + + for (x=0; x> 1) | + ((src32[x] & 0x000f000f) << 1) | ((src32[x] & 0x00080008) >> 3); + + dst8[x] = ((src32[x] & 0xe0000000) >> 29) | ((src32[x] & 0x0000e000) >> 9); + } + + src32 += sp4; + dst32 += dp4; + dst8 += dp; + } + break; + + case DSPF_ARGB1555: + while (rect.h--) { + int x; + + for (x=0; x> 8) | + ((s0 & 0x0000fc00) >> 5) | + ((s0 & 0x000000f8) >> 3) | + ((s1 & 0x00f80000) << 8) | + ((s1 & 0x0000fc00) << 11) | + ((s1 & 0x000000f8) << 13) ; + +#ifndef DAVINCI_NO_DITHER + if ((s0 & s1) >> 24 == 0xff) + dst8[x] = 0x77; + else { + register int pt, da; + + z ^= ((z << 13) | (z >> 19)); + z += 0x87654321; + pt = s0 - ((s0 & 0xf8000000) >> 3); + da = (((pt >> 29) & 0x07) + ( ((z&0x1f) - ((pt >> 24) & 0x1f))>>31 )) << 4; + + z ^= ((z << 13) | (z >> 19)); + z += 0x87654321; + pt = s1 - ((s1 & 0xf8000000) >> 3); + da |= (((pt >> 29) & 0x07) + ( ((z&0x1f) - ((pt >> 24) & 0x1f))>>31 )); + + + dst8[x] = da; + } +#else + dst8[x] = ((s0 & 0xe0000000) >> 25) | + ((s1 & 0xe0000000) >> 29) ; +#endif + } + + src32 += sp4; + dst32 += dp4; + dst8 += dp; + } + break; + + default: + D_ONCE( "unsupported format" ); + } + } +} + +static void +update_rgb( DavinciDriverData *ddrv, + DavinciDeviceData *ddev, + CoreSurface *surface, + CoreSurfaceBufferLock *lock, + const DFBRegion *update ) +{ + DFBRectangle rect; + CoreSurfaceBuffer *buffer; + + D_ASSERT( ddrv != NULL ); + D_ASSERT( ddev != NULL ); + D_ASSERT( surface != NULL ); + D_ASSERT( lock != NULL ); + DFB_REGION_ASSERT_IF( update ); + + buffer = lock->buffer; + D_ASSERT( buffer != NULL ); + + if (update) + rect = DFB_RECTANGLE_INIT_FROM_REGION( update ); + else { + rect.x = 0; + rect.y = 0; + rect.w = surface->config.size.w; + rect.h = surface->config.size.h; + } + + dfb_convert_to_rgb16( buffer->format, + lock->addr + rect.y * lock->pitch + DFB_BYTES_PER_LINE( buffer->format, rect.x ), + lock->pitch, + surface->config.size.h, + ddrv->fb[OSD0].mem + rect.y * ddev->fix[OSD0].line_length + rect.x * 2, + ddev->fix[OSD0].line_length, + rect.w, rect.h ); +} + +static void +enable_osd( DavinciDriverData *ddrv, + DavinciOSDLayerData *dosd ) +{ + if (!dosd->enable) + return; + + ioctl( ddrv->fb[OSD0].fd, FBIO_WAITFORVSYNC ); + + if (ioctl( ddrv->fb[OSD0].fd, FBIO_ENABLE_DISABLE_ATTRIBUTE_WIN, dosd->alpha )) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_ATTRIBUTE_WIN (fb%d - %d)!\n", OSD0, dosd->alpha ); + + if (ioctl( ddrv->fb[OSD0].fd, FBIO_ENABLE_DISABLE_WIN, 1 )) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", OSD0, 1 ); + + if (ioctl( ddrv->fb[OSD1].fd, FBIO_ENABLE_DISABLE_WIN, dosd->alpha )) + D_OSDERROR( "Davinci/OSD: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", OSD1, dosd->alpha ); + + dosd->enable = false; +} + +static DFBResult +osdFlipRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + DFBSurfaceFlipFlags flags, + CoreSurfaceBufferLock *lock ) +{ + CoreSurfaceBuffer *buffer; + DavinciDriverData *ddrv = driver_data; + DavinciDeviceData *ddev = ddrv->ddev; + DavinciOSDLayerData *dosd = layer_data; + + D_DEBUG_AT( Davinci_OSD, "%s()\n", __FUNCTION__ ); + + D_ASSERT( surface != NULL ); + D_ASSERT( lock != NULL ); + D_ASSERT( ddrv != NULL ); + D_ASSERT( ddev != NULL ); + + buffer = lock->buffer; + D_ASSERT( buffer != NULL ); + + if (buffer->format != DSPF_RGB16) { + if (DFB_PIXELFORMAT_HAS_ALPHA( buffer->format )) + update_buffers( ddrv, ddev, surface, lock, NULL ); + else + update_rgb( ddrv, ddev, surface, lock, NULL ); + } + else + davincifb_pan_display( &ddrv->fb[OSD0], &dosd->var0, lock, flags, 0, 0 ); + + dfb_surface_flip( surface, false ); + + enable_osd( ddrv, dosd ); + + return DFB_OK; +} + +static DFBResult +osdUpdateRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + const DFBRegion *update, + CoreSurfaceBufferLock *lock ) +{ + CoreSurfaceBuffer *buffer; + DavinciDriverData *ddrv = driver_data; + DavinciDeviceData *ddev = ddrv->ddev; + DavinciOSDLayerData *dosd = layer_data; + + D_DEBUG_AT( Davinci_OSD, "%s()\n", __FUNCTION__ ); + + D_ASSERT( surface != NULL ); + D_ASSERT( lock != NULL ); + D_ASSERT( ddrv != NULL ); + D_ASSERT( ddev != NULL ); + + buffer = lock->buffer; + D_ASSERT( buffer != NULL ); + + if (buffer->format != DSPF_RGB16) { + if (DFB_PIXELFORMAT_HAS_ALPHA( buffer->format )) + update_buffers( ddrv, ddev, surface, lock, update ); + else + update_rgb( ddrv, ddev, surface, lock, update ); + } + + enable_osd( ddrv, dosd ); + + return DFB_OK; +} + +const DisplayLayerFuncs davinciOSDLayerFuncs = { + .LayerDataSize = osdLayerDataSize, + .InitLayer = osdInitLayer, + + .TestRegion = osdTestRegion, + .SetRegion = osdSetRegion, + .RemoveRegion = osdRemoveRegion, + .FlipRegion = osdFlipRegion, + .UpdateRegion = osdUpdateRegion, +}; + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_osd.h b/Source/DirectFB/gfxdrivers/davinci/davinci_osd.h new file mode 100755 index 0000000..4487b7f --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_osd.h @@ -0,0 +1,53 @@ +/* + TI Davinci driver - Graphics Layer + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + 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 __DAVINCI_OSD_H__ +#define __DAVINCI_OSD_H__ + +#include + +#include + +#define DAVINCI_OSD_SUPPORTED_OPTIONS (DLOP_ALPHACHANNEL | DLOP_OPACITY | DLOP_SRC_COLORKEY) + + +typedef struct { + struct fb_var_screeninfo var0; + struct fb_var_screeninfo var1; + + bool alpha; + bool enable; +} DavinciOSDLayerData; + + +extern const DisplayLayerFuncs davinciOSDLayerFuncs; + +#endif + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_osd_pool.c b/Source/DirectFB/gfxdrivers/davinci/davinci_osd_pool.c new file mode 100755 index 0000000..6744adb --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_osd_pool.c @@ -0,0 +1,394 @@ +/* + TI Davinci driver - OSD0 FB Memory for direct RGB16 mode + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (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 "davincifb.h" + +#include "davinci_gfxdriver.h" + +D_DEBUG_DOMAIN( OSD_Surfaces, "OSD/Surfaces", "OSD Framebuffer Surface Pool" ); +D_DEBUG_DOMAIN( OSD_SurfLock, "OSD/SurfLock", "OSD Framebuffer Surface Pool Locks" ); + +/**********************************************************************************************************************/ + +typedef struct { + int magic; +} OSDPoolData; + +typedef struct { + int magic; + + CoreDFB *core; + void *mem; + unsigned long phys; +} OSDPoolLocalData; + +typedef struct { + int magic; + + int offset; + int pitch; + int size; +} OSDAllocationData; + +/**********************************************************************************************************************/ + +static int +osdPoolDataSize( void ) +{ + return sizeof(OSDPoolData); +} + +static int +osdPoolLocalDataSize( void ) +{ + return sizeof(OSDPoolLocalData); +} + +static int +osdAllocationDataSize( void ) +{ + return sizeof(OSDAllocationData); +} + +static DFBResult +osdInitPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data, + CoreSurfacePoolDescription *ret_desc ) +{ + OSDPoolData *data = pool_data; + OSDPoolLocalData *local = pool_local; + DavinciDriverData *ddrv = dfb_gfxcard_get_driver_data(); + DavinciDeviceData *ddev = dfb_gfxcard_get_device_data(); + + D_DEBUG_AT( OSD_Surfaces, "%s()\n", __FUNCTION__ ); + + D_ASSERT( core != NULL ); + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_ASSERT( data != NULL ); + D_ASSERT( local != NULL ); + D_ASSERT( ret_desc != NULL ); + + ret_desc->caps = CSPCAPS_NONE; + ret_desc->types = CSTF_LAYER | CSTF_SHARED | CSTF_EXTERNAL; + ret_desc->priority = CSPP_PREFERED; + + ret_desc->access[CSAID_CPU] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + ret_desc->access[CSAID_GPU] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + ret_desc->access[CSAID_LAYER0] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + + snprintf( ret_desc->name, DFB_SURFACE_POOL_DESC_NAME_LENGTH, "OSD Pool" ); + + local->core = core; + local->mem = ddrv->fb[OSD0].mem; + local->phys = ddev->fix[OSD0].smem_start; + + D_MAGIC_SET( data, OSDPoolData ); + D_MAGIC_SET( local, OSDPoolLocalData ); + + return DFB_OK; +} + +static DFBResult +osdJoinPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data ) +{ + OSDPoolData *data = pool_data; + OSDPoolLocalData *local = pool_local; + DavinciDriverData *ddrv = dfb_gfxcard_get_driver_data(); + DavinciDeviceData *ddev = dfb_gfxcard_get_device_data(); + + D_DEBUG_AT( OSD_Surfaces, "%s()\n", __FUNCTION__ ); + + D_ASSERT( core != NULL ); + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, OSDPoolData ); + D_ASSERT( local != NULL ); + + (void) data; + + local->core = core; + local->mem = ddrv->fb[OSD0].mem; + local->phys = ddev->fix[OSD0].smem_start; + + D_MAGIC_SET( local, OSDPoolLocalData ); + + return DFB_OK; +} + +static DFBResult +osdDestroyPool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + OSDPoolData *data = pool_data; + OSDPoolLocalData *local = pool_local; + + D_DEBUG_AT( OSD_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, OSDPoolData ); + D_MAGIC_ASSERT( local, OSDPoolLocalData ); + + D_MAGIC_CLEAR( data ); + D_MAGIC_CLEAR( local ); + + return DFB_OK; +} + +static DFBResult +osdLeavePool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + OSDPoolData *data = pool_data; + OSDPoolLocalData *local = pool_local; + + D_DEBUG_AT( OSD_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, OSDPoolData ); + D_MAGIC_ASSERT( local, OSDPoolLocalData ); + + (void) data; + + D_MAGIC_CLEAR( local ); + + return DFB_OK; +} + +static DFBResult +osdTestConfig( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + const CoreSurfaceConfig *config ) +{ + CoreSurface *surface; + OSDPoolData *data = pool_data; + OSDPoolLocalData *local = pool_local; + + D_DEBUG_AT( OSD_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, OSDPoolData ); + D_MAGIC_ASSERT( local, OSDPoolLocalData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + (void) data; + (void) local; + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + if ((surface->type & CSTF_LAYER) && surface->resource_id == DLID_PRIMARY && surface->config.format == DSPF_RGB16) + return DFB_OK; + + return DFB_UNSUPPORTED; +} + +static DFBResult +osdAllocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + CoreSurface *surface; + OSDPoolData *data = pool_data; + OSDPoolLocalData *local = pool_local; + OSDAllocationData *alloc = alloc_data; + DavinciDeviceData *ddev = dfb_gfxcard_get_device_data(); + + D_DEBUG_AT( OSD_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, OSDPoolData ); + D_MAGIC_ASSERT( local, OSDPoolLocalData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + (void) data; + (void) local; + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + if ((surface->type & CSTF_LAYER) && surface->resource_id == DLID_PRIMARY && surface->config.format == DSPF_RGB16) { + int index = dfb_surface_buffer_index( buffer ); + + alloc->pitch = ddev->fix[OSD0].line_length; + alloc->size = surface->config.size.h * alloc->pitch; + alloc->offset = index * alloc->size; + + D_DEBUG_AT( OSD_Surfaces, " -> index %d, offset %d, pitch %d, size %d\n", + index, alloc->offset, alloc->pitch, alloc->size ); + + allocation->size = alloc->size; + allocation->offset = alloc->offset; + + D_MAGIC_SET( alloc, OSDAllocationData ); + + return DFB_OK; + } + + return DFB_BUG; +} + +static DFBResult +osdDeallocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + OSDPoolData *data = pool_data; + OSDAllocationData *alloc = alloc_data; + + D_DEBUG_AT( OSD_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, OSDPoolData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + D_MAGIC_ASSERT( alloc, OSDAllocationData ); + + (void) data; + + D_MAGIC_CLEAR( alloc ); + + return DFB_OK; +} + +static DFBResult +osdLock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + OSDPoolLocalData *local = pool_local; + OSDAllocationData *alloc = alloc_data; + DavinciDeviceData *ddev = dfb_gfxcard_get_device_data(); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, OSDAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + D_DEBUG_AT( OSD_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer ); + + int index = alloc->offset / alloc->size; + int height = alloc->size / alloc->pitch; + + alloc->pitch = ddev->fix[OSD0].line_length; + alloc->size = height * alloc->pitch; + alloc->offset = index * alloc->size; + + allocation->size = alloc->size; + allocation->offset = alloc->offset; + + lock->pitch = alloc->pitch; + lock->offset = alloc->offset; + lock->addr = local->mem + alloc->offset; + lock->phys = local->phys + alloc->offset; + + D_DEBUG_AT( OSD_SurfLock, " -> offset %lu, pitch %d, addr %p, phys 0x%08lx\n", + lock->offset, lock->pitch, lock->addr, lock->phys ); + + return DFB_OK; +} + +static DFBResult +osdUnlock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + OSDAllocationData *alloc = alloc_data; + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, OSDAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + D_DEBUG_AT( OSD_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer ); + + (void) alloc; + + return DFB_OK; +} + +const SurfacePoolFuncs davinciOSDSurfacePoolFuncs = { + .PoolDataSize = osdPoolDataSize, + .PoolLocalDataSize = osdPoolLocalDataSize, + .AllocationDataSize = osdAllocationDataSize, + + .InitPool = osdInitPool, + .JoinPool = osdJoinPool, + .DestroyPool = osdDestroyPool, + .LeavePool = osdLeavePool, + + .TestConfig = osdTestConfig, + .AllocateBuffer = osdAllocateBuffer, + .DeallocateBuffer = osdDeallocateBuffer, + + .Lock = osdLock, + .Unlock = osdUnlock, +}; + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_osd_pool.h b/Source/DirectFB/gfxdrivers/davinci/davinci_osd_pool.h new file mode 100755 index 0000000..05316db --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_osd_pool.h @@ -0,0 +1,39 @@ +/* + TI Davinci driver - OSD0 FB Memory for direct RGB16 mode + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + 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 __DAVINCI_OSD_POOL_H__ +#define __DAVINCI_OSD_POOL_H__ + +#include + +extern const SurfacePoolFuncs davinciOSDSurfacePoolFuncs; + +#endif + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_screen.c b/Source/DirectFB/gfxdrivers/davinci/davinci_screen.c new file mode 100755 index 0000000..65fd751 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_screen.c @@ -0,0 +1,124 @@ +/* + TI Davinci driver - Primary Screen + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include + +#include +#include + +#include + +#include + +#include +#include + +#include + +#include "davincifb.h" + +#include "davinci_gfxdriver.h" +#include "davinci_screen.h" + + +D_DEBUG_DOMAIN( Davinci_Screen, "Davinci/Screen", "TI Davinci Screen" ); + +/**********************************************************************************************************************/ + +static DFBResult +davinciInitScreen( CoreScreen *screen, + CoreGraphicsDevice *device, + void *driver_data, + void *screen_data, + DFBScreenDescription *description ) +{ + D_DEBUG_AT( Davinci_Screen, "%s()\n", __FUNCTION__ ); + + /* Set the screen capabilities. */ + description->caps = DSCCAPS_VSYNC; + + /* Set the screen name. */ + snprintf( description->name, DFB_SCREEN_DESC_NAME_LENGTH, "TI Davinci Screen" ); + + return DFB_OK; +} + +static DFBResult +davinciGetScreenSize( CoreScreen *screen, + void *driver_data, + void *screen_data, + int *ret_width, + int *ret_height ) +{ + int ret; + vpbe_fb_videomode_t mode; + DavinciDriverData *ddrv = driver_data; + + D_DEBUG_AT( Davinci_Screen, "%s()\n", __FUNCTION__ ); + + D_ASSERT( ret_width != NULL ); + D_ASSERT( ret_height != NULL ); + + ret = ioctl( ddrv->fb[OSD0].fd, FBIO_GET_TIMING, &mode ); + if (ret) { + D_PERROR( "%s: FBIO_GET_TIMING (fb%d, OSD0) failed!\n", __func__, OSD0 ); + return DFB_INIT; + } + + *ret_width = mode.xres; + *ret_height = mode.yres; + + return DFB_OK; +} + +static DFBResult +davinciWaitVSync( CoreScreen *screen, + void *driver_data, + void *screen_data ) +{ + DavinciDriverData *ddrv = driver_data; + + D_DEBUG_AT( Davinci_Screen, "%s()\n", __FUNCTION__ ); + + ioctl( ddrv->fb[OSD0].fd, FBIO_WAITFORVSYNC ); + + return DFB_OK; +} + +ScreenFuncs davinciScreenFuncs = { + .InitScreen = davinciInitScreen, + .GetScreenSize = davinciGetScreenSize, + .WaitVSync = davinciWaitVSync, +}; + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_screen.h b/Source/DirectFB/gfxdrivers/davinci/davinci_screen.h new file mode 100755 index 0000000..1aa2494 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_screen.h @@ -0,0 +1,39 @@ +/* + TI Davinci driver - Primary Screen + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + 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 __DAVINCI_SCREEN_H__ +#define __DAVINCI_SCREEN_H__ + +#include + +extern ScreenFuncs davinciScreenFuncs; + +#endif + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_video.c b/Source/DirectFB/gfxdrivers/davinci/davinci_video.c new file mode 100755 index 0000000..1a284a0 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_video.c @@ -0,0 +1,744 @@ +/* + TI Davinci driver - Video Layer + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +//#define DIRECT_ENABLE_DEBUG + +#include + +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include "davincifb.h" + +#include "davinci_gfxdriver.h" +#include "davinci_video.h" + + +#define D_VIDERROR(x...) do {} while (0) + + +D_DEBUG_DOMAIN( Davinci_Video, "Davinci/Video", "TI Davinci Video" ); + +/**********************************************************************************************************************/ + +static DFBResult ShowBuffer( DavinciDriverData *ddrv, + DavinciVideoLayerData *dvid, + CoreSurfaceBufferLock *lock, + const DFBRectangle *area, + DFBSurfaceFlipFlags flags ); + +static void SetupResizerParams( vpfe_resizer_params_t *params, + int srcWidth, int srcHeight, + int outWidth, int outHeight, + int *ret_outWidth, + int *ret_outHeight ); + +/**********************************************************************************************************************/ + +static int +videoLayerDataSize( void ) +{ + return sizeof(DavinciVideoLayerData); +} + +static DFBResult +videoInitLayer( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *config, + DFBColorAdjustment *adjustment ) +{ + int ret; + DavinciDriverData *ddrv = driver_data; + DavinciVideoLayerData *dvid = layer_data; + + D_DEBUG_AT( Davinci_Video, "%s()\n", __FUNCTION__ ); + + /* Initialize with configuration from VID0 to start with a fullscreen (unscaled) layer */ + ret = ioctl( ddrv->fb[VID0].fd, FBIOGET_VSCREENINFO, &dvid->var ); + if (ret) { + D_PERROR( "Davinci/Video: FBIOGET_VSCREENINFO (fb%d) failed!\n", VID0 ); + return DFB_INIT; + } + + /* Disable VID0 (unused) */ + ret = ioctl( ddrv->fb[VID0].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_VIDERROR( "Davinci/Video: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", VID0, 0 ); + + /* Disable VID1 (our layer) */ + ret = ioctl( ddrv->fb[VID1].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_VIDERROR( "Davinci/Video: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", VID1, 0 ); + + /* set capabilities and type */ + description->caps = DLCAPS_SURFACE | DLCAPS_SCREEN_LOCATION; + description->type = DLTF_VIDEO | DLTF_STILL_PICTURE; + + /* set name */ + snprintf( description->name, DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, "TI Davinci Video" ); + + /* fill out the default configuration */ + config->flags = DLCONF_WIDTH | DLCONF_HEIGHT | + DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE | DLCONF_OPTIONS; + config->width = dvid->var.xres; + config->height = dvid->var.yres; + config->pixelformat = DSPF_UYVY; + config->buffermode = DLBM_FRONTONLY; + config->options = DLOP_NONE; + + return DFB_OK; +} + +static DFBResult +videoTestRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags *failed ) +{ + CoreLayerRegionConfigFlags fail = 0; + + D_DEBUG_AT( Davinci_Video, "%s()\n", __FUNCTION__ ); + + DFB_CORE_LAYER_REGION_CONFIG_DEBUG_AT( Davinci_Video, config ); + + if (config->options & ~DAVINCI_VIDEO_SUPPORTED_OPTIONS) + fail |= CLRCF_OPTIONS; + + switch (config->format) { + case DSPF_UYVY: + break; + + default: + fail |= CLRCF_FORMAT; + } + + if (config->width < 8 || config->width > 1920) + fail |= CLRCF_WIDTH; + + if (config->height < 8 || config->height > 1080) + fail |= CLRCF_HEIGHT; + + if (config->dest.x < 0 || config->dest.y < 0) + fail |= CLRCF_DEST; + + if (config->dest.x + config->dest.w > 1920) + fail |= CLRCF_DEST; + + if (config->dest.y + config->dest.h > 1080) + fail |= CLRCF_DEST; + + if (failed) + *failed = fail; + + if (fail) { + D_DEBUG_AT( Davinci_Video, " -> FAILED (0x%08x)\n", fail ); + return DFB_UNSUPPORTED; + } + + D_DEBUG_AT( Davinci_Video, " -> OK\n" ); + + return DFB_OK; +} + +static DFBResult +videoSetRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags updated, + CoreSurface *surface, + CorePalette *palette, + CoreSurfaceBufferLock *lock ) +{ + int ret; + DavinciDriverData *ddrv = driver_data; + DavinciDeviceData *ddev = ddrv->ddev; + DavinciVideoLayerData *dvid = layer_data; + CoreLayerRegionConfig *old = &dvid->config; + + D_DEBUG_AT( Davinci_Video, "%s( updated 0x%08x, surface %p )\n", __FUNCTION__, updated, surface ); + + DFB_CORE_LAYER_REGION_CONFIG_DEBUG_AT( Davinci_Video, config ); + + D_ASSERT( ddrv != NULL ); + D_ASSERT( ddev != NULL ); + D_ASSERT( dvid != NULL ); + + /* Update output size? */ + if ((updated & CLRCF_DEST) && (config->dest.w != old->dest.w || config->dest.h != old->dest.h)) { + vpbe_window_position_t win_pos; + + D_DEBUG_AT( Davinci_Video, " => dest %4dx%4d\n", config->dest.w, config->dest.h ); + + ret = ioctl( ddrv->fb[VID1].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_VIDERROR( "Davinci/Video: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", VID1, 0 ); + + dvid->enabled = false; + +/*********************************** Start workaround ***********************************/ + win_pos.xpos = 0; + win_pos.ypos = 0; + + ret = ioctl( ddrv->fb[VID1].fd, FBIO_SETPOS, &win_pos ); + if (ret) + D_VIDERROR( "Davinci/Video: FBIO_SETPOS (fb%d - %d,%d) failed!\n", VID1, win_pos.xpos, win_pos.ypos ); + + dvid->var.yoffset = 0; +/*********************************** End workaround ***********************************/ + + /* Set output width and height. */ + dvid->var.xres = config->dest.w; + dvid->var.yres = config->dest.h; + + dvid->var.yres_virtual = ddrv->fb[VID1].size / lock->pitch; + + ret = ioctl( ddrv->fb[VID1].fd, FBIOPUT_VSCREENINFO, &dvid->var ); + if (ret) + D_PERROR( "Davinci/Video: FBIOPUT_VSCREENINFO (fb%d) failed!\n", VID1 ); + + /* Read back new pitch etc. */ + ret = ioctl( ddrv->fb[VID1].fd, FBIOGET_FSCREENINFO, &ddev->fix[VID1] ); + if (ret) + D_PERROR( "Davinci/Video: FBIOGET_FSCREENINFO (fb%d) failed!\n", VID1 ); + } + + /* Update output position? */ + if (updated & CLRCF_DEST) { + vpbe_window_position_t win_pos; + + D_DEBUG_AT( Davinci_Video, " => dest %4d,%4d\n", config->dest.x, config->dest.y ); + + if (dvid->enabled) + ioctl( ddrv->fb[VID1].fd, FBIO_WAITFORVSYNC ); + + /* Set horizontal and vertical offset. */ + win_pos.xpos = config->dest.x; + win_pos.ypos = config->dest.y; + + ret = ioctl( ddrv->fb[VID1].fd, FBIO_SETPOS, &win_pos ); + if (ret) + D_VIDERROR( "Davinci/Video: FBIO_SETPOS (fb%d - %d,%d) failed!\n", VID1, config->dest.x, config->dest.y ); + } + + /* Update format? */ + if (updated & CLRCF_FORMAT) { + vpbe_video_config_params_t params; + + params.cb_cr_order = (config->format == DSPF_YUY2) ? 1 : 0; + + params.exp_info.horizontal = VPBE_DISABLE; + params.exp_info.vertical = VPBE_DISABLE; + + ret = ioctl( ddrv->fb[VID1].fd, FBIO_SET_VIDEO_CONFIG_PARAMS, ¶ms ); + if (ret) + D_VIDERROR( "Davinci/Video: FBIO_SET_VIDEO_CONFIG_PARAMS (fb%d - %s) failed!\n", + VID1, params.cb_cr_order ? "CrCb" : "CbCr" ); + } + + /* Update scaling parameters? */ + if ((updated & (CLRCF_SOURCE | CLRCF_DEST)) && + (config->source.w != old->source.w || config->source.h != old->source.h || + config->dest.w != old->dest.w || config->dest.h != old->dest.h) && + (config->dest.w != config->source.w || config->dest.h != config->source.h)) + { + D_DEBUG_AT( Davinci_Video, " => scaling %4dx%4d -> %4dx%4d\n", + config->source.w, config->source.h, config->dest.w, config->dest.h ); + + SetupResizerParams( &dvid->resizer, config->source.w, config->source.h, + config->dest.w, config->dest.h, &dvid->resized.w, &dvid->resized.h ); + + dvid->offset.x = (config->dest.w - dvid->resized.w) / 2; + dvid->offset.y = (config->dest.h - dvid->resized.h) / 2; + + D_DEBUG_AT( Davinci_Video, " => resized %4dx%4d, centered %d,%d\n", + dvid->resized.w, dvid->resized.h, dvid->offset.x, dvid->offset.y ); + + dvid->offset.x += dvid->offset.x & 1; /* Round up to multiple of two */ + + D_DEBUG_AT( Davinci_Video, " => offset %4d,%4d\n", dvid->offset.x, dvid->offset.y ); + + davincifb_pan_display( &ddrv->fb[VID1], &dvid->var, NULL, DSFLIP_NONE, 0, 0 ); + } + + dvid->enable = true; + dvid->config = *config; + + return DFB_OK; +} + +static DFBResult +videoRemoveRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data ) +{ + int ret; + DavinciDriverData *ddrv = driver_data; + DavinciVideoLayerData *dvid = layer_data; + + D_DEBUG_AT( Davinci_Video, "%s()\n", __FUNCTION__ ); + + D_ASSERT( ddrv != NULL ); + + ret = ioctl( ddrv->fb[VID1].fd, FBIO_ENABLE_DISABLE_WIN, 0 ); + if (ret) + D_VIDERROR( "Davinci/Video: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", VID1, 0 ); + + dvid->enabled = false; + dvid->enable = false; + + return DFB_OK; +} + +static DFBResult +videoFlipRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + DFBSurfaceFlipFlags flags, + CoreSurfaceBufferLock *lock ) +{ + DFBResult ret; + DavinciDriverData *ddrv = driver_data; + DavinciVideoLayerData *dvid = layer_data; + + D_ASSERT( surface != NULL ); + D_ASSERT( lock != NULL ); + D_ASSERT( ddrv != NULL ); + D_ASSERT( dvid != NULL ); + + D_DEBUG_AT( Davinci_Video, "%s( 0x%08lx [%d] 0x%04x [%4dx%4d] )\n", __FUNCTION__, + lock->phys, lock->pitch, flags, dvid->config.width, dvid->config.height ); + + ret = ShowBuffer( ddrv, dvid, lock, NULL, flags ); + if (ret) + return ret; + + dfb_surface_flip( surface, false ); + + return DFB_OK; +} + +static DFBResult +videoUpdateRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreSurface *surface, + const DFBRegion *update, + CoreSurfaceBufferLock *lock ) +{ + DavinciDriverData *ddrv = driver_data; + DavinciVideoLayerData *dvid = layer_data; + + D_ASSERT( surface != NULL ); + D_ASSERT( lock != NULL ); + D_ASSERT( ddrv != NULL ); + D_ASSERT( dvid != NULL ); + + if (update) { + DFBRectangle area = DFB_RECTANGLE_INIT_FROM_REGION( update ); + + D_DEBUG_AT( Davinci_Video, "%s( 0x%08lx [%d], %4d,%4d-%4dx%4d )\n", __FUNCTION__, + lock->phys, lock->pitch, DFB_RECTANGLE_VALS( &area ) ); + + if (!dfb_rectangle_intersect( &area, &dvid->config.source )) { + D_DEBUG_AT( Davinci_Video, " -> NO INTERSECTION with %4d,%4d-%4dx%4d\n", + DFB_RECTANGLE_VALS( &dvid->config.source ) ); + + return DFB_OK; + } + + if (!DFB_RECTANGLE_EQUAL( area, dvid->config.source )) + return ShowBuffer( ddrv, dvid, lock, &area, DSFLIP_NONE ); + } + else + D_DEBUG_AT( Davinci_Video, "%s( 0x%08lx [%d], %4dx%4d )\n", __FUNCTION__, + lock->phys, lock->pitch, dvid->config.width, dvid->config.height ); + + return ShowBuffer( ddrv, dvid, lock, NULL, DSFLIP_NONE ); +} + +const DisplayLayerFuncs davinciVideoLayerFuncs = { + .LayerDataSize = videoLayerDataSize, + .InitLayer = videoInitLayer, + + .TestRegion = videoTestRegion, + .SetRegion = videoSetRegion, + .RemoveRegion = videoRemoveRegion, + .FlipRegion = videoFlipRegion, + .UpdateRegion = videoUpdateRegion, +}; + +/*********************************************************************************************************************** +** Frame Output +*/ + +static void +enable_video( DavinciDriverData *ddrv, + DavinciVideoLayerData *dvid ) +{ + if (dvid->enable && !dvid->enabled) { + ioctl( ddrv->fb[VID1].fd, FBIO_WAITFORVSYNC ); + + if (ioctl( ddrv->fb[VID1].fd, FBIO_ENABLE_DISABLE_WIN, 1 )) + D_VIDERROR( "Davinci/Video: FBIO_ENABLE_DISABLE_WIN (fb%d - %d)!\n", VID1, 1 ); + + dvid->enabled = true; + } +} + +static DFBResult +ShowBuffer( DavinciDriverData *ddrv, + DavinciVideoLayerData *dvid, + CoreSurfaceBufferLock *lock, + const DFBRectangle *area, + DFBSurfaceFlipFlags flags ) +{ + const CoreLayerRegionConfig *config = &dvid->config; + + if (area) + D_DEBUG_AT( Davinci_Video, "%s( 0x%08lx [%d], %4d,%4d-%4dx%4d )\n", __FUNCTION__, + lock->phys, lock->pitch, DFB_RECTANGLE_VALS( area ) ); + else + D_DEBUG_AT( Davinci_Video, "%s( 0x%08lx [%d] )\n", __FUNCTION__, lock->phys, lock->pitch ); + + if (config->dest.w == config->source.w && config->dest.h == config->source.h) { + /* + * Unscaled video, buffer displayed directly + */ + D_DEBUG_AT( Davinci_Video, " -> unscaled %4dx%4d <- %4d,%4d [%4dx%4d]\n", + config->source.w, config->source.h, config->source.x, config->source.y, + config->width, config->height ); + + /* Partial update, assuming proper buffer is shown, saving system calls */ + if (area && dvid->enabled) + return DFB_OK; + + davincifb_pan_display( &ddrv->fb[VID1], &dvid->var, lock, flags, config->source.x, config->source.y ); + } + else { + int ret; + DavinciDeviceData *ddev = ddrv->ddev; + CoreSurfaceBuffer *buffer = lock->buffer; + vpfe_resizer_params_t *params = &dvid->resizer; + + /* + * Scaled video, buffer scaled to output buffer by resizer + */ + D_DEBUG_AT( Davinci_Video, " -> scaled %4dx%4d -> %4dx%4d <- %4d,%4d [%4dx%4d]\n", + config->source.w, config->source.h, config->dest.w, config->dest.h, + config->source.x, config->source.y, config->width, config->height ); + + /* FIXME: Implement scaled partial updates! */ + if (area) + D_UNIMPLEMENTED(); + + params->sdr_inoff = lock->pitch; + params->sdr_inadd = lock->phys + DFB_BYTES_PER_LINE( buffer->format, config->source.x ) + + config->source.y * params->sdr_inoff; + + params->sdr_outoff = ddev->fix[VID1].line_length; + params->sdr_outadd = ddev->fix[VID1].smem_start + dvid->offset.x * 2 + + dvid->offset.y * params->sdr_outoff; + + params->in_start = (params->sdr_outadd & 0x1f) / 2; + params->sdr_outadd &= ~0x1f; + + D_DEBUG_AT( Davinci_Video, " -> FBIO_RESIZER running...\n" ); + + ret = ioctl( ddrv->fb[VID1].fd, FBIO_RESIZER, params ); + if (ret) + D_VIDERROR( "Davinci/Video: FBIO_RESIZER (fb%d)!\n", VID1 ); + + D_DEBUG_AT( Davinci_Video, " => FBIO_RESIZER returned %d\n", ret ); + } + + enable_video( ddrv, dvid ); + + return DFB_OK; +} + +/*********************************************************************************************************************** +** Scaling Setup +*/ + +static int +limitInput(int rsz,int inSize,int outSize,int* pInSize) +{ + int phases; + int phaseShift; + int taps; + int phaseMask; + int coarseShift; + int halfCoarse; + int tmp; + + do { + if (rsz<=512) { + //1/2x to 4x resize uses 8 phase, 4 taps + phaseShift = 3; + taps = 4; + } + else { + //4-phase, 7 taps + phaseShift = 2; + taps = 7; + } + phases = 1<>8) + taps; + if (tmp <= inSize) break; + rsz--; + } while (1); + + *pInSize = tmp; + + return rsz; +} + +static void +SetupCoef(unsigned int* pCoef,int rsz) +{ + int startCoef; + int highCoef; + int c; + int phases; + int taps; + if (rsz<=512) { + //1/2x to 4x resize uses 8 phase, 4 taps + highCoef = 0x100; + c=1; + phases=8; + taps=4; + } + else { + //4-phase, 7 taps + if (rsz<=(256*3)) { + highCoef = 0x100/2; c=2; + } + else { + highCoef = 0x100/4; c=1; + } + phases=4; + taps=7; + } + startCoef = highCoef>>1; + while (phases) { + int prev = startCoef; + int tapNum=0; + int rem=256 - startCoef; + while ( tapNum < (c-1)) { + *pCoef++ = 0; + tapNum+=2; + } + if (c&1) { + *pCoef++ = prev<<16; + tapNum+=2; + } + else { + tapNum++; + } + while ( tapNum < taps) { + int min = (rem (highCoef>>3)) startCoef -= (highCoef>>3); + else { + startCoef = highCoef; c++; + } + phases--; + } +} + +#define SDRAM_SRC (1<<28) +#define BILINEAR (1<<29) + +static void +SetupResizerParams( vpfe_resizer_params_t *params, + int srcWidth, int srcHeight, + int outWidth, int outHeight, + int *ret_outWidth, + int *ret_outHeight ) +{ + int rsz; + int hrsz; + int vrsz; + int tmp; + + D_DEBUG_AT( Davinci_Video, "%s( %4dx%4d->%4dx%4d )\n", __FUNCTION__, srcWidth, srcHeight, outWidth, outHeight ); + + params->sdr_inadd = 0; + params->sdr_inoff = 0; + + params->sdr_outadd = 0; + params->sdr_outoff = 0; + + params->in_start = (0<<16)|(0); + params->yenh = 0; + + params->rsz_cnt = SDRAM_SRC; + + + + + //find scale factor + rsz = (srcWidth<<8)/outWidth; + if (rsz<64) { + //too much upscaling, reduce destination size + rsz = 64; + } + else if (rsz>1024) { + //too much down scaling, reduce source size + rsz=1024; + srcWidth = (outWidth * rsz)>>8; + } + + tmp = ((srcWidth<<8)+255)/rsz; + if (tmp > outWidth) tmp = outWidth; + tmp &= ~1; //force even + if (rsz>256) { + //upsize in vertical direction requires a multiple of 16 bytes (8 pixels) + tmp &= ~0x7; + } + do { + int t; + hrsz = limitInput(rsz,srcWidth,tmp,&t); + if (hrsz>=64) { + srcWidth = t; + break; + } + tmp-=2; + } while (1); + outWidth = tmp; + + if (srcWidth==outWidth) { + int i=0; + params->rsz_cnt |= ((256-1)<<0); //1 to 1 + params->in_size = (srcWidth+3); //4 taps + while (i<16) { + params->hfilt[i] = i? 0 : 0x100; //2 coefficient written at a time + i++; + } + } + else { + SetupCoef(¶ms->hfilt[0],hrsz); + params->rsz_cnt |= ((hrsz-1)<<0) | ((hrsz<256)? BILINEAR : 0); + params->in_size = (srcWidth); + } + + + + + //find scale factor + rsz = (srcHeight<<8)/outHeight; + if (rsz<64) { + //too much upscaling, reduce destination size + rsz = 64; + } + else if (rsz>1024) { + //too much down scaling, reduce source size + rsz=1024; + srcHeight = (outHeight * rsz)>>8; + } + + tmp = ((srcHeight<<8)+255)/rsz; + if (tmp > outHeight) tmp = outHeight; + do { + int t; + vrsz = limitInput(rsz,srcHeight,tmp,&t); + if (vrsz>=64) { + srcHeight = t; + break; + } + tmp--; + } while (1); + outHeight = tmp; + + if (srcHeight==outHeight) { + int i=0; + params->rsz_cnt |= ((256-1)<<10); //1 to 1 + params->in_size |= ((srcHeight+3)<<16); //4 taps + while (i<16) { + params->vfilt[i] = i? 0 : 0x100; //2 coefficient written at a time + i++; + } + } + else { + SetupCoef(¶ms->vfilt[0],vrsz); + params->rsz_cnt |= ((vrsz-1)<<10); + params->in_size |= (srcHeight<<16); + } + + + params->out_size = (outHeight<<16)|(outWidth); + + D_DEBUG_AT( Davinci_Video, " => %4dx%4d->%4dx%4d\n", srcWidth, srcHeight, outWidth, outHeight ); + + if (ret_outWidth) + *ret_outWidth = outWidth; + + if (ret_outHeight) + *ret_outHeight = outHeight; +} + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_video.h b/Source/DirectFB/gfxdrivers/davinci/davinci_video.h new file mode 100755 index 0000000..7d6e206 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_video.h @@ -0,0 +1,58 @@ +/* + TI Davinci driver - Video Layer + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + 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 __DAVINCI_VIDEO_H__ +#define __DAVINCI_VIDEO_H__ + +#include + +#include + +#define DAVINCI_VIDEO_SUPPORTED_OPTIONS (DLOP_NONE) + + +typedef struct { + struct fb_var_screeninfo var; + + bool enable; + bool enabled; + + CoreLayerRegionConfig config; + + vpfe_resizer_params_t resizer; + DFBDimension resized; + DFBPoint offset; +} DavinciVideoLayerData; + + +extern const DisplayLayerFuncs davinciVideoLayerFuncs; + +#endif + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_video_pool.c b/Source/DirectFB/gfxdrivers/davinci/davinci_video_pool.c new file mode 100755 index 0000000..f0f45b5 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_video_pool.c @@ -0,0 +1,393 @@ +/* + TI Davinci driver - VID1 FB Memory for direct UYVY mode + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (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 "davincifb.h" + +#include "davinci_gfxdriver.h" + +D_DEBUG_DOMAIN( Video_Surfaces, "Video/Surfaces", "Video Framebuffer Surface Pool" ); +D_DEBUG_DOMAIN( Video_SurfLock, "Video/SurfLock", "Video Framebuffer Surface Pool Locks" ); + +/**********************************************************************************************************************/ + +typedef struct { + int magic; +} VideoPoolData; + +typedef struct { + int magic; + + CoreDFB *core; + void *mem; + unsigned long phys; +} VideoPoolLocalData; + +typedef struct { + int magic; + + int offset; + int pitch; + int size; +} VideoAllocationData; + +/**********************************************************************************************************************/ + +static int +videoPoolDataSize( void ) +{ + return sizeof(VideoPoolData); +} + +static int +videoPoolLocalDataSize( void ) +{ + return sizeof(VideoPoolLocalData); +} + +static int +videoAllocationDataSize( void ) +{ + return sizeof(VideoAllocationData); +} + +static DFBResult +videoInitPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data, + CoreSurfacePoolDescription *ret_desc ) +{ + VideoPoolData *data = pool_data; + VideoPoolLocalData *local = pool_local; + DavinciDriverData *ddrv = dfb_gfxcard_get_driver_data(); + DavinciDeviceData *ddev = dfb_gfxcard_get_device_data(); + + D_DEBUG_AT( Video_Surfaces, "%s()\n", __FUNCTION__ ); + + D_ASSERT( core != NULL ); + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_ASSERT( data != NULL ); + D_ASSERT( local != NULL ); + D_ASSERT( ret_desc != NULL ); + + ret_desc->caps = CSPCAPS_NONE; + ret_desc->types = CSTF_LAYER | CSTF_SHARED | CSTF_EXTERNAL; + ret_desc->priority = CSPP_DEFAULT; + + ret_desc->access[CSAID_CPU] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + ret_desc->access[CSAID_GPU] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + ret_desc->access[CSAID_LAYER1] = CSAF_READ | CSAF_WRITE | CSAF_SHARED; + + snprintf( ret_desc->name, DFB_SURFACE_POOL_DESC_NAME_LENGTH, "Video Pool" ); + + local->core = core; + local->mem = ddrv->fb[VID1].mem; + local->phys = ddev->fix[VID1].smem_start; + + D_MAGIC_SET( data, VideoPoolData ); + D_MAGIC_SET( local, VideoPoolLocalData ); + + return DFB_OK; +} + +static DFBResult +videoJoinPool( CoreDFB *core, + CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + void *system_data ) +{ + VideoPoolData *data = pool_data; + VideoPoolLocalData *local = pool_local; + DavinciDriverData *ddrv = dfb_gfxcard_get_driver_data(); + DavinciDeviceData *ddev = dfb_gfxcard_get_device_data(); + + D_DEBUG_AT( Video_Surfaces, "%s()\n", __FUNCTION__ ); + + D_ASSERT( core != NULL ); + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VideoPoolData ); + D_ASSERT( local != NULL ); + + (void) data; + + local->core = core; + local->mem = ddrv->fb[VID1].mem; + local->phys = ddev->fix[VID1].smem_start; + + D_MAGIC_SET( local, VideoPoolLocalData ); + + return DFB_OK; +} + +static DFBResult +videoDestroyPool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + VideoPoolData *data = pool_data; + VideoPoolLocalData *local = pool_local; + + D_DEBUG_AT( Video_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VideoPoolData ); + D_MAGIC_ASSERT( local, VideoPoolLocalData ); + + D_MAGIC_CLEAR( data ); + D_MAGIC_CLEAR( local ); + + return DFB_OK; +} + +static DFBResult +videoLeavePool( CoreSurfacePool *pool, + void *pool_data, + void *pool_local ) +{ + VideoPoolData *data = pool_data; + VideoPoolLocalData *local = pool_local; + + D_DEBUG_AT( Video_Surfaces, "%s()\n", __FUNCTION__ ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VideoPoolData ); + D_MAGIC_ASSERT( local, VideoPoolLocalData ); + + (void) data; + + D_MAGIC_CLEAR( local ); + + return DFB_OK; +} + +static DFBResult +videoTestConfig( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + const CoreSurfaceConfig *config ) +{ + CoreSurface *surface; + VideoPoolData *data = pool_data; + VideoPoolLocalData *local = pool_local; + + D_DEBUG_AT( Video_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VideoPoolData ); + D_MAGIC_ASSERT( local, VideoPoolLocalData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + (void) data; + (void) local; + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + if ((surface->type & CSTF_LAYER) && surface->resource_id == 1) + return DFB_OK; + + return DFB_UNSUPPORTED; +} + +static DFBResult +videoAllocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + CoreSurface *surface; + VideoPoolData *data = pool_data; + VideoPoolLocalData *local = pool_local; + VideoAllocationData *alloc = alloc_data; + DavinciDeviceData *ddev = dfb_gfxcard_get_device_data(); + + D_DEBUG_AT( Video_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VideoPoolData ); + D_MAGIC_ASSERT( local, VideoPoolLocalData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + + (void) data; + (void) local; + + surface = buffer->surface; + D_MAGIC_ASSERT( surface, CoreSurface ); + + if ((surface->type & CSTF_LAYER) && surface->resource_id == 1) { + int index = dfb_surface_buffer_index( buffer ); + + alloc->pitch = ddev->fix[VID1].line_length; + alloc->size = surface->config.size.h * alloc->pitch; + alloc->offset = index * alloc->size; + + D_DEBUG_AT( Video_Surfaces, " -> offset %d, pitch %d, size %d\n", alloc->offset, alloc->pitch, alloc->size ); + + allocation->size = alloc->size; + allocation->offset = alloc->offset; + + D_MAGIC_SET( alloc, VideoAllocationData ); + + return DFB_OK; + } + + return DFB_BUG; +} + +static DFBResult +videoDeallocateBuffer( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceBuffer *buffer, + CoreSurfaceAllocation *allocation, + void *alloc_data ) +{ + VideoPoolData *data = pool_data; + VideoAllocationData *alloc = alloc_data; + + D_DEBUG_AT( Video_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( data, VideoPoolData ); + D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); + D_MAGIC_ASSERT( alloc, VideoAllocationData ); + + (void) data; + + D_MAGIC_CLEAR( alloc ); + + return DFB_OK; +} + +static DFBResult +videoLock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + VideoPoolLocalData *local = pool_local; + VideoAllocationData *alloc = alloc_data; + DavinciDeviceData *ddev = dfb_gfxcard_get_device_data(); + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, VideoAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + D_DEBUG_AT( Video_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer ); + + int index = alloc->offset / alloc->size; + int height = alloc->size / alloc->pitch; + + alloc->pitch = ddev->fix[VID1].line_length; + alloc->size = height * alloc->pitch; + alloc->offset = index * alloc->size; + + allocation->size = alloc->size; + allocation->offset = alloc->offset; + + lock->pitch = alloc->pitch; + lock->offset = alloc->offset; + lock->addr = local->mem + alloc->offset; + lock->phys = local->phys + alloc->offset; + + D_DEBUG_AT( Video_SurfLock, " -> offset %lu, pitch %d, addr %p, phys 0x%08lx\n", + lock->offset, lock->pitch, lock->addr, lock->phys ); + + return DFB_OK; +} + +static DFBResult +videoUnlock( CoreSurfacePool *pool, + void *pool_data, + void *pool_local, + CoreSurfaceAllocation *allocation, + void *alloc_data, + CoreSurfaceBufferLock *lock ) +{ + VideoAllocationData *alloc = alloc_data; + + D_MAGIC_ASSERT( pool, CoreSurfacePool ); + D_MAGIC_ASSERT( allocation, CoreSurfaceAllocation ); + D_MAGIC_ASSERT( alloc, VideoAllocationData ); + D_MAGIC_ASSERT( lock, CoreSurfaceBufferLock ); + + D_DEBUG_AT( Video_SurfLock, "%s( %p )\n", __FUNCTION__, lock->buffer ); + + (void) alloc; + + return DFB_OK; +} + +const SurfacePoolFuncs davinciVideoSurfacePoolFuncs = { + .PoolDataSize = videoPoolDataSize, + .PoolLocalDataSize = videoPoolLocalDataSize, + .AllocationDataSize = videoAllocationDataSize, + + .InitPool = videoInitPool, + .JoinPool = videoJoinPool, + .DestroyPool = videoDestroyPool, + .LeavePool = videoLeavePool, + + .TestConfig = videoTestConfig, + .AllocateBuffer = videoAllocateBuffer, + .DeallocateBuffer = videoDeallocateBuffer, + + .Lock = videoLock, + .Unlock = videoUnlock, +}; + diff --git a/Source/DirectFB/gfxdrivers/davinci/davinci_video_pool.h b/Source/DirectFB/gfxdrivers/davinci/davinci_video_pool.h new file mode 100755 index 0000000..dd60b12 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davinci_video_pool.h @@ -0,0 +1,39 @@ +/* + TI Davinci driver - VID1 FB Memory for direct UYVY mode + + (c) Copyright 2007 Telio AG + + Written by Denis Oliver Kropp + + Code is derived from VMWare driver. + + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + 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 __DAVINCI_VIDEO_POOL_H__ +#define __DAVINCI_VIDEO_POOL_H__ + +#include + +extern const SurfacePoolFuncs davinciVideoSurfacePoolFuncs; + +#endif + diff --git a/Source/DirectFB/gfxdrivers/davinci/davincifb.h b/Source/DirectFB/gfxdrivers/davinci/davincifb.h new file mode 100755 index 0000000..35eb169 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/davincifb.h @@ -0,0 +1,581 @@ +/* + * Copyright (C) 2006 Texas Instruments Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option)any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * File: davincifb.h + */ + +#ifndef DAVINVI_VPBE_H +#define DAVINVI_VPBE_H + +/* include Linux files */ +#include + +/* define the custom FBIO_WAITFORVSYNC ioctl */ +#define FBIO_WAITFORVSYNC _IOW('F', 0x20, u_int32_t) +#define FBIO_SETATTRIBUTE _IOW('F', 0x21, struct fb_fillrect) + +/* Backported IOCTLS. */ +#define FBIO_SETPOSX _IOW('F', 0x22, u_int32_t) +#define FBIO_SETPOSY _IOW('F', 0x23, u_int32_t) +#define FBIO_SETZOOM _IOW('F', 0x24, struct zoom_params) +#define FBIO_GETSTD _IOR('F', 0x25, u_int32_t) +#define FBIO_RESIZER _IOW('F', 0x26, struct vpfe_resizer_params) +#define FBIO_SYNC _IOW('F', 0x27, u_int32_t) + +typedef struct zoom_params { + u_int32_t window_id; + u_int32_t zoom_h; + u_int32_t zoom_v; +} zoom_params_t; + +typedef struct vpfe_resizer_params +{ + u_int32_t rsz_cnt; //busy-lock + u_int32_t out_size; //busy-lock + u_int32_t in_start; //busy-lock + u_int32_t in_size; //busy-lock + u_int32_t sdr_inadd; //shadowed + u_int32_t sdr_inoff; //shadowed + u_int32_t sdr_outadd; //shadowed + u_int32_t sdr_outoff; //shadowed + u_int32_t hfilt[16]; //busy-lock + u_int32_t vfilt[16]; //busy-lock + u_int32_t yenh; //busy-lock +} vpfe_resizer_params_t; + +typedef struct fb_set_start { + int offset; /* offset from smem_start */ + unsigned long physical; /* absolute physical address when offset < 0 */ + + u_int64_t sync; /* input: target sync counter for change or 0 for no sync at all, + output: sync counter of actual change or 0 if still pending */ +} fb_set_start_t; + + +#ifdef _IOC_TYPECHECK +#undef _IOC_TYPECHECK +#define _IOC_TYPECHECK(x) (sizeof(x)) +#endif + +#define RAM_CLUT_SIZE 256*3 +#define FBIO_ENABLE_DISABLE_WIN \ + _IOW('F', 0x30, unsigned char) +#define FBIO_SET_BITMAP_BLEND_FACTOR \ + _IOW('F', 0x31, vpbe_bitmap_blend_params_t) +#define FBIO_SET_BITMAP_WIN_RAM_CLUT \ + _IOW('F', 0x32, unsigned char)*RAM_CLUT_SIZE) +#define FBIO_ENABLE_DISABLE_ATTRIBUTE_WIN \ + _IOW('F', 0x33, unsigned int) +#define FBIO_GET_BLINK_INTERVAL \ + _IOR('F', 0x34, vpbe_blink_option_t) +#define FBIO_SET_BLINK_INTERVAL \ + _IOW('F', 0x35, vpbe_blink_option_t) +#define FBIO_GET_VIDEO_CONFIG_PARAMS \ + _IOR('F', 0x36, vpbe_video_config_params_t) +#define FBIO_SET_VIDEO_CONFIG_PARAMS \ + _IOW('F', 0x37, vpbe_video_config_params_t) +#define FBIO_GET_BITMAP_CONFIG_PARAMS \ + _IOR('F', 0x38, vpbe_bitmap_config_params_t) +#define FBIO_SET_BITMAP_CONFIG_PARAMS \ + _IOW('F', 0x39, vpbe_bitmap_config_params_t) +#define FBIO_SET_DCLK \ + _IOW('F', 0x40, vpbe_dclk_t) +#define FBIO_SET_INTERFACE \ + _IOW('F', 0x41, unsigned char) +#define FBIO_GET_INTERFACE \ + _IOR('F', 0x42, unsigned char) +#define FBIO_QUERY_TIMING \ + _IOWR('F', 0x43, struct vpbe_mode_info) +#define FBIO_SET_TIMING \ + _IOW('F', 0x44, struct vpbe_fb_videomode) +#define FBIO_GET_TIMING \ + _IOR('F', 0x45, struct vpbe_fb_videomode) +#define FBIO_SET_VENC_CLK_SOURCE \ + _IOW('F', 0x46, unsigned char) +#define FBIO_SET_BACKG_COLOR \ + _IOW('F', 0x47, vpbe_backg_color_t) +#define FBIO_ENABLE_DISPLAY \ + _IOW('F', 0x48, unsigned char) +#define FBIO_SETPOS \ + _IOW('F', 0x49, u_int32_t) +#define FBIO_SET_CURSOR \ + _IOW('F', 0x50, struct fb_cursor) +#define FBIO_SET_START \ + _IOW('F', 0x66, struct fb_set_start) + +/* + * Defines and Constants + */ +#ifdef __KERNEL__ +#define DAVINCIFB_DEVICE "davincifb" +#define DAVINCIFB_DRIVER "davincifb" + +#define MULTIPLE_BUFFERING 1 + +#ifdef MULTIPLE_BUFFERING +#define DOUBLE_BUF 2 +#define TRIPLE_BUF 3 +#else +#define DOUBLE_BUF 1 +#define TRIPLE_BUF 1 +#endif + +/* usage: if (is_win(info->fix.id, OSD0)) ... */ +#define is_win(name, x) ((strcmp(name, x ## _FBNAME) == 0) ? 1 : 0) + +/* + * display controller register I/O routines + */ +u32 dispc_reg_in(u32 offset); +u32 dispc_reg_out(u32 offset, u32 val); +u32 dispc_reg_merge(u32 offset, u32 val, u32 mask); + +#endif /*__KERNEL__*/ + +/* Error return codes */ +#define VPBE_INVALID_PARA_VALUE 700 +#define VPBE_WRONG_WINDOW_ID 701 +#define VPBE_CURRENTLY_IN_REQUIRED_MODE 702 +#define VPBE_INSUFFICIENT_CLUT_VALUES 703 +#define VPBE_CLUT_WRITE_TIMEOUT 704 +#define VPBE_VID0_BUF_ADR_NULL 705 +#define VPBE_WINDOW_NOT_DISABLED 706 +#define VPBE_WINDOW_NOT_ENABLED 707 + +#ifndef __KERNEL__ +/* Window ID definations */ +#define OSD0 0 +#define VID0 1 +#define OSD1 2 +#define VID1 3 +#endif + +/* There are 4 framebuffers, each represented by an fb_info and + * a dm_win_info structure */ +#define OSD0_FBNAME "dm_osd0_fb" +#define OSD1_FBNAME "dm_osd1_fb" +#define VID0_FBNAME "dm_vid0_fb" +#define VID1_FBNAME "dm_vid1_fb" + +/* FIXME: Digital LCD RGB matrix coefficients */ +#define DLCD_DGY_VAL 0 +#define DLCD_DRV_VAL 0 +#define DLCD_DGU_VAL 0 +#define DLCD_DBU_VAL 0 + +/* Defines for bitmap format */ +#define VPBE_BITMAP_BIT_1 1 +#define VPBE_BITMAP_BIT_2 2 +#define VPBE_BITMAP_BIT_4 4 +#define VPBE_BITMAP_BIT_8 8 +#define VPBE_BITMAP_RGB565 16 +#define VPBE_VIDEO_YUV422 16 +#define VPBE_VIDEO_RGB888 24 + +/* Defines foe cursor parameter validation*/ +#define MAX_CURSOR_WIDTH 0x3FF +#define MAX_CURSOR_HEIGHT 0x1FF +#define MAX_CURSOR_LINEWIDTH 7 + +#define BASEX 0x80 +#define BASEY 0x12 +#define BASEX_DLCD 0x59 +#define BASEY_DLCD 0x22 + +/* + * Enumerations + */ +/* Enum for blending factor */ +typedef enum vpbe_blend_factor { + OSD_CONTRIBUTION_ZERO = 0, + OSD_CONTRIBUTION_1_BY_8 = 1, + OSD_CONTRIBUTION_2_BY_8 = 2, + OSD_CONTRIBUTION_3_BY_8 = 3, + OSD_CONTRIBUTION_4_BY_8 = 4, + OSD_CONTRIBUTION_5_BY_8 = 5, + OSD_CONTRIBUTION_6_BY_8 = 6, + OSD_CONTRIBUTION_ONE = 7 +} vpbe_blend_factor_t; + +/* Enum for Boolean variables */ +typedef enum { + SET_0 = 0, + SET_1 = 1 +} CB_CR_ORDER, ATTRIBUTE, ROM_RAM_CLUT; + +/* Defines for Display Interface */ +#define PRGB 0 +#define COMPOSITE 1 +#define SVIDEO 2 +#define COMPONENT 3 +#define RGB 4 +#define YCC16 5 +#define YCC8 6 +#define SRGB 7 +#define EPSON 8 +#define CASIO1G 9 +#define UDISP 10 +#define STN 11 +#define VPBE_MAX_INTERFACES 12 + +/* Defines for Display Mode */ +#define LCD 0 +#define NTSC 1 +#define PAL 2 +#define P525 3 +#define P625 4 + +#define DEFAULT_MODE 0 +#define P480 0 +#define P400 1 +#define P350 2 +#define NON_EXISTING_MODE 255 +/* Enable/Disable enum */ +typedef enum { + VPBE_DISABLE = 0, + VPBE_ENABLE = 1 +} ATTENUATION, TRANSPARENCY, EXPANSION, BLINKING; + +typedef enum clk_source { + CLK_SOURCE_CLK27 = 0, + CLK_SOURCE_CLK54 = 1, + CLK_SOURCE_VPBECLK = 2 +} CLK_SOURCE; + +/* + * Structures and Union Definitions + */ + +/* Structure for transparency and the blending factor for the bitmap window */ +typedef struct vpbe_bitmap_blend_params { + unsigned int colorkey; /* color key to be blend */ + unsigned int enable_colorkeying; /* enable color keying */ + unsigned int bf; /* valid range from 0 to 7 only. */ +} vpbe_bitmap_blend_params_t; + +/* Structure for window expansion */ +typedef struct vpbe_win_expansion { + EXPANSION horizontal; + EXPANSION vertical; /* 1: Enable 0:disable */ +} vpbe_win_expansion_t; + +/* Structure for OSD window blinking options */ +typedef struct vpbe_blink_option { + BLINKING blinking; /* 1: Enable blinking 0: Disable */ + unsigned int interval; /* Valid only if blinking is 1 */ +} vpbe_blink_option_t; + +/* Structure for DCLK parameters */ +typedef struct vpbe_dclk { + unsigned char dclk_pattern_width; + unsigned int dclk_pattern0; + unsigned int dclk_pattern1; + unsigned int dclk_pattern2; + unsigned int dclk_pattern3; +} vpbe_dclk_t; + +/* Structure for display format */ +typedef struct vpbe_display_format { + unsigned char interface; /* Output interface type */ + unsigned char mode; /* output mode */ +} vpbe_display_format_t; + +/* Structure for background color */ +typedef struct vpbe_backg_color { + unsigned char clut_select; /* 2: RAM CLUT 1:ROM1 CLUT 0:ROM0 CLUT */ + unsigned char color_offset; /* index of color */ +} vpbe_backg_color_t; + +/* Structure for Video window configurable parameters */ +typedef struct vpbe_video_config_params { + CB_CR_ORDER cb_cr_order; /*Cb/Cr order in input data for a pixel. */ + /* 0: cb cr 1: cr cb */ + vpbe_win_expansion_t exp_info; /* HZ/VT Expansion enable disable */ +} vpbe_video_config_params_t; + +/*Union of structures giving the CLUT index for the 1, 2, 4 bit bitmap values.*/ +typedef union vpbe_clut_idx { + struct _for_4bit_bimap { + unsigned char bitmap_val_0; + unsigned char bitmap_val_1; + unsigned char bitmap_val_2; + unsigned char bitmap_val_3; + unsigned char bitmap_val_4; + unsigned char bitmap_val_5; + unsigned char bitmap_val_6; + unsigned char bitmap_val_7; + unsigned char bitmap_val_8; + unsigned char bitmap_val_9; + unsigned char bitmap_val_10; + unsigned char bitmap_val_11; + unsigned char bitmap_val_12; + unsigned char bitmap_val_13; + unsigned char bitmap_val_14; + unsigned char bitmap_val_15; + } for_4bit_bimap; + struct _for_2bit_bimap { + unsigned char bitmap_val_0; + unsigned char dummy0[4]; + unsigned char bitmap_val_1; + unsigned char dummy1[4]; + unsigned char bitmap_val_2; + unsigned char dummy2[4]; + unsigned char bitmap_val_3; + } for_2bit_bimap; + struct _for_1bit_bimap { + unsigned char bitmap_val_0; + unsigned char dummy0[14]; + unsigned char bitmap_val_1; + } for_1bit_bimap; +} vpbe_clut_idx_t; + +/* Structure for bitmap window configurable parameters */ +typedef struct vpbe_bitmap_config_params { + /* Only for bitmap width = 1,2,4 bits */ + vpbe_clut_idx_t clut_idx; + /* Attenuation value for YUV o/p for bitmap window */ + unsigned char attenuation_enable; + /* 0: ROM DM270, 1:ROM DM320, 2:RAM CLUT */ + unsigned char clut_select; +} vpbe_bitmap_config_params_t; + +/* Unioun for video/OSD configuration parameters */ +typedef union vpbe_conf_params { + + struct vpbe_video_params { + CB_CR_ORDER cb_cr_order; + /* HZ/VT Expansion enable disable */ + vpbe_win_expansion_t exp_info; + } video_params; + + struct vpbe_bitmap_params { + /* Attenuation value for YUV o/p */ + ATTENUATION attenuation_enable; + /* 0: ROM DM270, 1: ROM DM320, 2:RAM CLUT */ + unsigned char clut_select; + /* Only for bitmap width = 1,2,4 bits */ + vpbe_clut_idx_t clut_idx; + /* 0: OSD window is bitmap window */ + /* 1: OSD window is attribute window */ + ATTRIBUTE enable_attribute; + /* To hold bps value. + Used to switch back from attribute to bitmap. */ + unsigned int stored_bits_per_pixel; + /* Blending information */ + vpbe_bitmap_blend_params_t blend_info; + /* OSD Blinking information */ + vpbe_blink_option_t blink_info; + } bitmap_params; + +} vpbe_conf_params_t; + +typedef struct vpbe_video_params vpbe_video_params_t; +typedef struct vpbe_bitmap_params vpbe_bitmap_params_t; + +/* Structure to hold window position */ +typedef struct vpbe_window_position { + unsigned int xpos; /* X position of the window */ + unsigned int ypos; /* Y position of the window */ +} vpbe_window_position_t; + +#ifdef __KERNEL__ +/* Structure for each window */ +typedef struct vpbe_dm_win_info { + struct fb_info info; + vpbe_window_position_t win_pos; /* X,Y position of window */ + /* Size of window is already there in var_info structure. */ + + dma_addr_t fb_base_phys; /*framebuffer area */ + unsigned int fb_base; /*window memory pointer */ + unsigned int fb_size; /*memory size */ + unsigned int pseudo_palette[17]; + int alloc_fb_mem; + /*flag to identify if framebuffer area is fixed or not */ + unsigned long sdram_address; + struct vpbe_dm_info *dm; + unsigned char window_enable; /*Additions for all windows */ + zoom_params_t zoom; /*Zooming parameters */ + unsigned char field_frame_select; /*To select Field or frame */ + unsigned char numbufs; /*Number of buffers valid 2 or 3 */ + vpbe_conf_params_t conf_params; + /*window configuration parameter union pointer */ +} vpbe_dm_win_info_t; +#endif /*__KERNEL__*/ + +/* + * Videmode structure for display interface and mode settings + */ +typedef struct vpbe_fb_videomode { + unsigned char name[10]; /* Mode name ( NTSC , PAL) */ + unsigned int vmode; /* FB_MODE_INTERLACED or FB_MODE_NON_INTERLACED */ + unsigned int xres; /* X Resolution of the display */ + unsigned int yres; /* Y Resolution of the display */ + unsigned int fps; /* frames per second */ + /* Timing Parameters applicable for std = 0 only */ + unsigned int left_margin; + unsigned int right_margin; + unsigned int upper_margin; + unsigned int lower_margin; + unsigned int hsync_len; + unsigned int vsync_len; + unsigned int sync; /* 0: hsync -ve/vsync -ve */ + /*1: hsync -ve/vsync +ve */ + /*2: hsync +ve/vsync -ve */ + /*3: hsync +ve/vsync +ve */ + unsigned int basepx; /* Display x,y start position */ + unsigned int basepy; +/* 1= Mode s available in modelist 0=Mode is not available in modelist */ + unsigned int std; +} vpbe_fb_videomode_t; + +/* Structure to interface videomode to application*/ +typedef struct vpbe_mode_info { + vpbe_fb_videomode_t vid_mode; + unsigned char interface; + unsigned char mode_idx; +} vpbe_mode_info_t; + +#ifdef __KERNEL__ +/* + * Structure for the driver holding information of windows, + * memory base addresses etc. + */ +typedef struct vpbe_dm_info { + vpbe_dm_win_info_t *osd0; + vpbe_dm_win_info_t *osd1; + vpbe_dm_win_info_t *vid0; + vpbe_dm_win_info_t *vid1; + +/* to map the registers */ + dma_addr_t mmio_base_phys; + unsigned int mmio_base; + unsigned int mmio_size; + + wait_queue_head_t vsync_wait; + unsigned int vsync_cnt; + int timeout; + + /* this is the function that configures the output device (NTSC/PAL/LCD) + * for the required output format (composite/s-video/component/rgb) + */ + void (*output_device_config) (void); + + struct device *dev; + + vpbe_backg_color_t backg; /* background color */ + vpbe_dclk_t dclk; /*DCLK parameters */ + vpbe_display_format_t display; /*Display interface and mode */ + vpbe_fb_videomode_t videomode; /*Cuurent videomode */ + char ram_clut[256][3]; /*RAM CLUT array */ + struct fb_cursor cursor; /* cursor config params from fb.h */ +/*Flag that indicates whether any of the display is enabled or not*/ + int display_enable; +} vpbe_dm_info_t; + +/* + * Functions Definitions for 'davincifb' module + */ +int vpbe_mem_alloc_window_buf(vpbe_dm_win_info_t *); +int vpbe_mem_release_window_buf(vpbe_dm_win_info_t *); +void init_display_function(vpbe_display_format_t *); +int vpbe_mem_alloc_struct(vpbe_dm_win_info_t **); +void set_vid0_default_conf(void); +void set_vid1_default_conf(void); +void set_osd0_default_conf(void); +void set_osd1_default_conf(void); +void set_cursor_default_conf(void); +void set_dm_default_conf(void); +void set_win_enable(char *, unsigned int); +int within_vid0_limits(u32, u32, u32, u32); +void vpbe_set_display_default(void); +#ifdef __KERNEL__ +void set_win_position(char *, u32, u32, u32, u32); +void change_win_param(int); +void set_interlaced(char *, unsigned int); +#endif /* __KERNEL__ */ + +/* + * Function definations for 'osd' module + */ + +int vpbe_enable_window(vpbe_dm_win_info_t *); +int vpbe_disable_window(vpbe_dm_win_info_t *); +int vpbe_vid_osd_select_field_frame(u8 *, u8); +int vpbe_bitmap_set_blend_factor(u8 *, vpbe_bitmap_blend_params_t *); +int vpbe_bitmap_set_ram_clut(void); +int vpbe_enable_disable_attribute_window(u32); +int vpbe_get_blinking(u8 *, vpbe_blink_option_t *); +int vpbe_set_blinking(u8 *, vpbe_blink_option_t *); +int vpbe_set_vid_params(u8 *, vpbe_video_config_params_t *); +int vpbe_get_vid_params(u8 *, vpbe_video_config_params_t *); +int vpbe_bitmap_get_params(u8 *, vpbe_bitmap_config_params_t *); +int vpbe_bitmap_set_params(u8 *, vpbe_bitmap_config_params_t *); +int vpbe_set_cursor_params(struct fb_cursor *); +int vpbe_set_vid_expansion(vpbe_win_expansion_t *); +int vpbe_set_dclk(vpbe_dclk_t *); +int vpbe_set_display_format(vpbe_display_format_t *); +int vpbe_set_backg_color(vpbe_backg_color_t *); +int vpbe_set_interface(u8); +int vpbe_query_mode(vpbe_mode_info_t *); +int vpbe_set_mode(struct vpbe_fb_videomode *); +int vpbe_set_venc_clk_source(u8); +void set_vid0_default_conf(void); +void set_osd0_default_conf(void); +void set_vid1_default_conf(void); +void set_osd1_default_conf(void); +void set_cursor_default_conf(void); +void set_dm_default_conf(void); +/* + * Function definations for 'venc' module + */ + +void davincifb_ntsc_composite_config(void); +void davincifb_ntsc_svideo_config(void); +void davincifb_ntsc_component_config(void); +void davincifb_pal_composite_config(void); +void davincifb_pal_svideo_config(void); +void davincifb_pal_component_config(void); + +void vpbe_davincifb_ntsc_rgb_config(void); +void vpbe_davincifb_pal_rgb_config(void); +void vpbe_davincifb_525p_component_config(void); +void vpbe_davincifb_625p_component_config(void); + +void vpbe_enable_venc(int); +void vpbe_enable_dacs(int); +/* + * Function definations for 'dlcd' module + */ +void vpbe_davincifb_480p_prgb_config(void); +void vpbe_davincifb_400p_prgb_config(void); +void vpbe_davincifb_350p_prgb_config(void); +void vpbe_set_display_timing(struct vpbe_fb_videomode *); + +void vpbe_enable_lcd(int); +/* + * Following functions are not implemented + */ +void vpbe_davincifb_default_ycc16_config(void); +void vpbe_davincifb_default_ycc8_config(void); +void vpbe_davincifb_default_srgb_config(void); +void vpbe_davincifb_default_epson_config(void); +void vpbe_davincifb_default_casio_config(void); +void vpbe_davincifb_default_UDISP_config(void); +void vpbe_davincifb_default_STN_config(void); +#endif /*__KERNEL__*/ + +#endif /* End of #ifndef DAVINCI_VPBE_H */ diff --git a/Source/DirectFB/gfxdrivers/davinci/directfbrc b/Source/DirectFB/gfxdrivers/davinci/directfbrc new file mode 100755 index 0000000..4025926 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/directfbrc @@ -0,0 +1,56 @@ +# +# WM/System +wm = sawman +system = devmem +video-phys = 87000000 +video-length = 16777216 + +# +# Use 640x480 by default (all visible) +mode = 640x480 + +# +# Shared Memory Mount Point +tmpfs = /tmp + +# +# Disable Cursor +no-cursor + +# +# Disable Layer Initialization +no-init-layer = 0 + +# +# Graphics Layer +#init-layer = 0 +#layer-size = 720x576 +#layer-format = RGB16 +#layer-stacking = middle,upper +#layer-bg-color = 000000 +#layer-src-key = 000000 +#layer-buffer-mode = backvideo + +# +# Video Layer +#init-layer = 1 +#layer-size = 720x576 +#layer-format = UYVY +#layer-stacking = lower +#layer-bg-color = 0000ff +#layer-buffer-mode = frontonly +#layer-bg-image = /usr/local/share/images/bg_flower.jpg + +# +# Scaling +smooth-upscale +smooth-downscale + +# +# Debug domains +#debug = Davinci/OSD +#debug = LiTE/Window +#debug = SaWMan/Auto +#debug = Core/GraphicsOps +#debug = Core/Layers +#debug = Core/Surface diff --git a/Source/DirectFB/gfxdrivers/davinci/kernel-module/Makefile b/Source/DirectFB/gfxdrivers/davinci/kernel-module/Makefile new file mode 100755 index 0000000..cb2965a --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/kernel-module/Makefile @@ -0,0 +1,34 @@ +KERNEL_VERSION = $(shell uname -r) +KERNEL_MODLIB = /lib/modules/$(KERNEL_VERSION) +KERNEL_BUILD = $(KERNEL_MODLIB)/build +KERNEL_SOURCE = $(KERNEL_MODLIB)/source + +SUB=c64x + +export CONFIG_DAVINCI_C64X=m + +ifeq ($(shell test -e $(KERNEL_BUILD)/include/linux/autoconf.h && echo yes),yes) + AUTOCONF_H = -include $(KERNEL_BUILD)/include/linux/autoconf.h +endif + +ifeq ($(shell test -e $(KERNEL_BUILD)/include/linux/config.h && echo yes),yes) + CPPFLAGS += -DHAVE_LINUX_CONFIG_H +endif + +CPPFLAGS += -DMODULE + +.PHONY: all install clean + +it all: + $(MAKE) -C $(KERNEL_BUILD) \ + KCPPFLAGS="$(CPPFLAGS) -I$(shell pwd)/include -I$(KERNEL_BUILD)/include" \ + SUBDIRS=$(shell pwd)/$(SUB) ARCH=arm CROSS_COMPILE=arm-v4t-linux-gnueabi- modules + +install: all + +clean: + $(RM) -r $(SUB)/.tmp_versions $(SUB)/Module.symvers + find $(SUB) -name *.o -o -name *.ko -o -name .*.cmd -o -name *.mod.* | xargs rm -f + +so: it + find $(SUB) -name "*.ko" | xargs strip -x -R .comment -R .note diff --git a/Source/DirectFB/gfxdrivers/davinci/kernel-module/c64x/Makefile b/Source/DirectFB/gfxdrivers/davinci/kernel-module/c64x/Makefile new file mode 100755 index 0000000..8d211a5 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/kernel-module/c64x/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_DAVINCI_C64X) += c64x.o + diff --git a/Source/DirectFB/gfxdrivers/davinci/kernel-module/c64x/c64x.c b/Source/DirectFB/gfxdrivers/davinci/kernel-module/c64x/c64x.c new file mode 100755 index 0000000..bbbbfe9 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/kernel-module/c64x/c64x.c @@ -0,0 +1,507 @@ +/* + TI Davinci driver - C64X+ DSP Kernel Module + + (c) Copyright 2007 Telio AG + + Written by Olaf Dreesen . + + All rights reserved. + + This module is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + + 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 + General Public License for more details. + + You should have received a copy of the GNU 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 + +#define C64X_IRQ + +MODULE_LICENSE("GPL v2"); +//MODULE_LICENSE("Propietary"); +MODULE_AUTHOR("Olaf Dreesen "); +MODULE_DESCRIPTION("A little c64+ handling module."); + +#define C_MOD_MAJOR 400 +#define C_MOD_NUM_DEV 1 +#define C_MOD_NAME "c64x" +#define F_NAME "c64x_drv.bin" + +#define CODE_BASE 0x00800000 + +/* DDR2: + * + * transfer buffer + */ +#define R_BASE DAVINCI_C64X_MEM +#define R_LEN 0x02000000 + +/* L2RAM: + * + * 0x00800000 - 0x0080FFFF C64x+ + * 0x11800000 - 0x1180FFFF ARM + */ +#define D_BASE 0x11800000 +#define D_LEN 0x00010000 + +/* L1DRAM: + * + * 0x00F04000 - 0x00F0FFFF C64x+ + * 0x11F04000 - 0x11F0FFFF ARM + * + * Queue controls @ 0x00F04000 (4096 Bytes) + */ +#define Q_BASE 0x11F04000 +#define Q_LEN 0x00001000 + +#define HQueueDSP (l1dram[0x00>>2]) +#define HQueueARM (l1dram[0x04>>2]) +#define LQueueDSP (l1dram[0x08>>2]) +#define LQueueARM (l1dram[0x0C>>2]) +#define DSPidle (l1dram[0x10>>2]) + +/* IO Register needed: + * + * 0x01C40008 DSPBOOTADDR DSP Boot Address + * 0x01C40010 INTGEN Interrupt Generator + * 0x01C40038 CHP_SHRTSW DSP Power + * 0x01C4169C MDCFG39 DSP Module config + * 0x01C41A9C MDCTL39 DSP Module control + */ +#define IO_BASE 0x01c40000 +#define IO_LEN 0x00010000 + +#define DSPBOOTADDR (mmr[0x0008>>2]) +#define INTGEN (mmr[0x0010>>2]) +#define CHP_SHRTSW (mmr[0x0038>>2]) +#define MDCFG39 (mmr[0x169C>>2]) +#define MDCTL39 (mmr[0x1A9C>>2]) + +MODULE_FIRMWARE(F_NAME); + +static dev_t dev_major; +static struct cdev*dev_cdev; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) +static struct class*dev_class; +#else +static struct class_simple*dev_class; +#endif + +static volatile unsigned int*mmr=0; +static unsigned char*l2ram=0; +static volatile unsigned int*l1dram=0; +static volatile void*dram=0; +static volatile c64xTaskControl*c64xctl=0; +static volatile c64xTask*queue_l=0; + +#ifdef C64X_IRQ +static int dev_irq=46; +static DECLARE_WAIT_QUEUE_HEAD( wait_irq ); + +/* IRQ */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 21) +static irqreturn_t dev_irq_handler(int irq,void*dev_id) { +#else +static irqreturn_t dev_irq_handler(int irq,void*dev_id,struct pt_regs*regs) { +#endif + wake_up_all( &wait_irq ); + return IRQ_HANDLED; +} +#endif + +static u32 opencnt=0; + +/* char-dev */ +static int dev_open(struct inode*inode,struct file*filp) { + if (opencnt++==0) { + DSPidle=0; + MDCTL39=0x00000103; /* Go! Go, go Go! */ + while(DSPidle==0); + } + return 0; +} +static int dev_release(struct inode*inode,struct file*filp) { + if (--opencnt==0) { + MDCTL39=0x00000000; /* local reset */ + } + return 0; +} + +static ssize_t dev_write(struct file*filp,const char __user*buffer,size_t len,loff_t*off) { + long ret=0; + unsigned long offset=*off; + if (offset=D_LEN) { len=D_LEN-offset; } +// printk(KERN_INFO "c64x+ : read got offset %08lx %08lx\n",offset,(long)len); + ret=len; + *off+=len; + } + return ret; +} +static ssize_t dev_read(struct file*filp,char __user*buffer,size_t len,loff_t*off) { + long ret=0; + unsigned long offset=*off; + if (offset=D_LEN) { len=D_LEN-offset; } +// printk(KERN_INFO "c64x+ : read got offset %08lx %08lx\n",offset,(long)len); + ret=len; + ret-=copy_to_user(buffer,(l2ram+offset),len); + *off+=len; + } + return ret; +} + +static int dev_mmap(struct file * file, struct vm_area_struct * vma) { + size_t size=vma->vm_end-vma->vm_start; + if (vma->vm_pgoff) { + if (size!=R_LEN) return -EINVAL; +#if defined(pgprot_writecombine) + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); +#else + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); +#endif + if (remap_pfn_range(vma, + vma->vm_start, + R_BASE>>PAGE_SHIFT, + size, + vma->vm_page_prot)) + return -EAGAIN; + } + else { + if (size!=Q_LEN) return -EINVAL; + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + if (remap_pfn_range(vma, + vma->vm_start, + Q_BASE>>PAGE_SHIFT, + size, + vma->vm_page_prot)) + return -EAGAIN; + } + return 0; +} + +static void +c64x_dump( const char *condition ) +{ + static const char *state_names[] = { "DONE", "ERROR", "TODO", "RUNNING" }; + + uint32_t ql_dsp = c64xctl->QL_dsp; + uint32_t ql_arm = c64xctl->QL_arm; + uint32_t tl_dsp = queue_l[ql_dsp & C64X_QUEUE_MASK].c64x_function; + uint32_t tl_arm = queue_l[ql_arm & C64X_QUEUE_MASK].c64x_function; + int dl; + + dl = ql_arm - ql_dsp; + if (dl < 0) + dl += C64X_QUEUE_LENGTH; + + printk( "C64X+ Queue: %s\n" + " [DSP %d / %d (%s), ARM %d / %d (%s)] <- %d pending\n", + condition, + ql_dsp, (tl_dsp >> 2) & 0x3fff, state_names[tl_dsp & 3], + ql_arm, (tl_arm >> 2) & 0x3fff, state_names[tl_arm & 3], + dl ); +} + +static int +c64x_wait_low( void ) +{ + int ret; + int num = 0; + /* Keep reference values for comparison. */ + u32 idle = c64xctl->idlecounter; + u32 dsp = c64xctl->QL_dsp; + + /* Wait for equal pointers... */ + while (dsp != c64xctl->QL_arm) { + /* ...each time for a 1/50 second... */ + ret = wait_event_interruptible_timeout( wait_irq, c64xctl->QL_dsp == c64xctl->QL_arm, HZ/50 ); + if (ret < 0) + return ret; + + /* ...if after that 1/50 second still the same command is running... */ + if (!ret && c64xctl->QL_dsp == dsp) { + /* ...and almost one second elapsed in total, or the DSP felt idle... */ + if (++num > 42 || c64xctl->idlecounter != idle) { + /* ...timeout! */ + printk( KERN_ERR "c64x+ : timeout waiting for idle queue\n" ); + c64x_dump( "TIMEOUT!!!" ); + return -ETIMEDOUT; + } + } + else { + /* Different command running, reset total elapsed time. */ + num = 0; + } + + /* Update reference values. */ + idle = c64xctl->idlecounter; + dsp = c64xctl->QL_dsp; + } + + return 0; +} + +static int dev_ioctl(struct inode *i, struct file *f, unsigned int cmd, unsigned long arg) { + switch (cmd) { + case C64X_IOCTL_RESET: + MDCTL39=0x00000000; /* local reset */ + mdelay(10); + DSPidle=0; + MDCTL39=0x00000103; + break; + case C64X_IOCTL_WAIT_LOW: + return c64x_wait_low(); + default: + printk(KERN_INFO "c64x+ : unknown ioctl : cmd=%08x\n",cmd); + return -EAGAIN; + break; + } + return 0; +} +static struct file_operations dev_file_ops={ + .owner = THIS_MODULE, + .open = dev_open, + .release = dev_release, + .read = dev_read, + .write = dev_write, + .mmap = dev_mmap, + .ioctl = dev_ioctl, +}; + +/* INIT */ +static __initdata struct device dev_device = { + .bus_id = "c64x0", +}; +static int __init dev_init(void) { + int ret=-EIO; + u8 *at; + const struct firmware*fw = NULL; + + printk(KERN_INFO "c64x+ : module load\n"); + + if ((dram=ioremap(R_BASE,R_LEN))==0) { + printk(KERN_ERR "c64x+ : module couldn't get memory\n"); + goto err0; + } + printk(KERN_INFO "c64x+ : module got memory @ %p\n",dram); + queue_l = dram + 0x01e00000; + + /* get the 'device' memory */ + if ((mmr=ioremap(IO_BASE,IO_LEN))==0) { + printk(KERN_ERR "c64x+ : module couldn't get IO-MMR\n"); + goto err0; + } + printk(KERN_INFO "c64x+ : DSP bootaddr: %08x\n",DSPBOOTADDR); + printk(KERN_INFO "c64x+ : got mmr %p %08x %08x\n",mmr,MDCTL39,MDCFG39); + + printk(KERN_INFO "c64x+ : switch state: %08x\n",CHP_SHRTSW); + + MDCTL39=0x00000000; /* local reset */ + mdelay(10); + DSPBOOTADDR=CODE_BASE; /* set DSP base address */ + +// printk(KERN_INFO "c64x+ : check0: %p %08x %08x\n",mmr,MDCTL39,MDCFG39); + + /* get the 'device' memory */ + if ((l1dram=ioremap(Q_BASE,Q_LEN))==0) { + printk(KERN_ERR "c64x+ : module couldn't get L1 dsp-memory\n"); + goto err1; + } + printk(KERN_INFO "c64x+ : module got L1D @ %p\n",l1dram); + c64xctl = (volatile void*)l1dram; + + if ((l2ram=ioremap(D_BASE,D_LEN))==0) { + printk(KERN_ERR "c64x+ : module couldn't get L2 dsp-memory\n"); + goto err2; + } + printk(KERN_INFO "c64x+ : module got L2 @ %p\n",l2ram); + + /* request firmware */ + device_initialize(&dev_device); + ret=device_add(&dev_device); + if (ret) { + printk(KERN_ERR "c64x+ : device_add failed\n"); + goto err3; + } + printk(KERN_INFO "c64x+ : module requesting firmware '%s'\n",F_NAME); + ret=request_firmware(&fw,F_NAME,&dev_device); + printk(KERN_INFO "c64x+ : module got fw %p\n",fw); + if (ret) { + printk(KERN_ERR "c64x+ : no firmware upload (timeout or file not found?)\n"); + device_del(&dev_device); + goto err3; + } + printk(KERN_INFO "c64x+ : firmware upload %p %zd\n",fw->data,fw->size); + if (fw->size>32767) { + printk(KERN_ERR "c64x+ : firmware too big! 32767 is maximum (for now)\n"); + release_firmware(fw); + device_del(&dev_device); + goto err3; + } + if (memcmp(fw->data+8,"C64x+DV",8)) { + printk(KERN_ERR "c64x+ : firmware signature missing\n"); + release_firmware(fw); + device_del(&dev_device); + goto err3; + } + at = fw->data + fw->size; + while ((ulong)--at > (ulong)fw->data) { + if (*at == '@') + break; + } + if (at == fw->data) { + printk(KERN_ERR "c64x+ : firmware tag missing\n"); + release_firmware(fw); + device_del(&dev_device); + goto err3; + } + printk(KERN_NOTICE "c64x+ : got firmware of length %d at %p with tag '%*s' of length %d at %p+1\n", + fw->size, fw->data, + (int)((ulong)(fw->data + fw->size) - (ulong)at - 1), at + 1, + (int)((ulong)(fw->data + fw->size) - (ulong)at - 1), at ); + /* move firmware into the hardware buffer here. */ + memcpy(l2ram,fw->data,fw->size); + release_firmware(fw); + device_del(&dev_device); + +#if 0 + /* release DSP */ + printk(KERN_INFO "c64x+ : check1: %p %08x %08x\n",mmr,MDCTL39,MDCFG39); + MDCTL39=0x00000103; /* Hopefully run... */ + printk(KERN_INFO "c64x+ : check2: %p %08x %08x\n",mmr,MDCTL39,MDCFG39); + printk(KERN_INFO "c64x+ : check3: %08x\n",DSPBOOTADDR); +#endif + + /* register char-dev */ + dev_major=MKDEV(C_MOD_MAJOR,0); + ret=register_chrdev_region(dev_major,C_MOD_NUM_DEV,C_MOD_NAME); + if (ret) { + printk(KERN_ERR "c64x+ : can't get chrdev %d\n",C_MOD_MAJOR); + goto err3; + } + + /* allocate cdev */ + dev_cdev=cdev_alloc(); + dev_cdev->ops=&dev_file_ops; + /* cdev_init(&dev_data.cdev,&dev_file_ops); */ + ret=cdev_add(dev_cdev,dev_major,1); + if (ret) { + printk(KERN_ERR "c64x+ : can't allocate cdev\n"); + goto err4; + } + +#ifdef C64X_IRQ + /* allocate interrupt slot */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 21) + ret=request_irq(dev_irq,dev_irq_handler,IRQF_DISABLED,C_MOD_NAME,NULL); +#else + ret=request_irq(dev_irq,dev_irq_handler,SA_INTERRUPT ,C_MOD_NAME,NULL); +#endif + if (ret) { + printk(KERN_ERR "c64x+ : can't get IRQ %d\n",dev_irq); + goto err5; + } +#endif + + /* tell sysfs/udev */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) + dev_class=class_create(THIS_MODULE,C_MOD_NAME); +#else + dev_class=class_simple_create(THIS_MODULE,C_MOD_NAME); +#endif + if (IS_ERR(dev_class)) { + ret=PTR_ERR(dev_class); + printk(KERN_ERR "c64x+ : can't allocate class\n"); + goto err6; + } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) + class_device_create(dev_class,NULL,dev_major,NULL,C_MOD_NAME"%d",0); +#else + class_simple_device_add(dev_class,dev_major,NULL,C_MOD_NAME"%d",0); +#endif + + printk(KERN_INFO "c64x+ : module load finished\n"); + return 0; + /* error out */ +err6: +#ifdef C64X_IRQ + free_irq(dev_irq,0); +err5: +#endif + cdev_del(dev_cdev); +err4: + unregister_chrdev_region(dev_major,1); +err3: + iounmap(l2ram); +err2: + iounmap((void*)l1dram); +err1: + iounmap((void*)mmr); +err0: + if (dram) + iounmap((void*)dram); + return ret; +} +module_init(dev_init); + +/* EXIT */ +static void __exit dev_exit(void) { + /* Put the DSP into Reset */ + MDCTL39=0x00000000; + /* release the DSP memory */ + iounmap((void*)mmr); + iounmap((void*)l1dram); + iounmap(l2ram); + /* release all the other resources */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) + class_device_destroy(dev_class,dev_major); + class_destroy(dev_class); +#else + class_simple_device_remove(dev_major); + class_simple_destroy(dev_class); +#endif +#ifdef C64X_IRQ + free_irq(dev_irq,0); +#endif + cdev_del(dev_cdev); + unregister_chrdev_region(dev_major,C_MOD_NUM_DEV); +} +module_exit(dev_exit); + diff --git a/Source/DirectFB/gfxdrivers/davinci/kernel-module/include/linux/c64x.h b/Source/DirectFB/gfxdrivers/davinci/kernel-module/include/linux/c64x.h new file mode 100755 index 0000000..6117404 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/kernel-module/include/linux/c64x.h @@ -0,0 +1,281 @@ +/* + TI Davinci driver - C64X+ DSP Firmware Interface + + (c) Copyright 2008 directfb.org + (c) Copyright 2007 Telio AG + + Written by Olaf Dreesen and + Denis Oliver Kropp . + + All rights reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + + 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 + General Public License for more details. + + You should have received a copy of the GNU 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 __C64X_H__ +#define __C64X_H__ + +#ifndef __KERNEL__ +#include +#endif + + +#ifndef DAVINCI_C64X_MEM +#define DAVINCI_C64X_MEM 0x8e000000 +#endif + + +typedef volatile struct { + uint32_t c64x_function; + uint32_t c64x_arg[7]; +} c64xTask; + + +#define c64x_return c64x_arg[0] +#define c64x_errno c64x_arg[1] + +#define c64x_flags c64x_function + +typedef enum { + C64X_STATE_DONE = 0, + C64X_STATE_ERROR = 1, + C64X_STATE_TODO = 2, + C64X_STATE_RUNNING = 3 +} C64XTaskState; + +typedef enum { + C64X_FLAG_RUN = 1, + C64X_FLAG_TODO = 2, + C64X_FLAG_INTERRUPT = 0x80000000 +} C64XTaskFlags; + +#define C64X_TASK_STATE(task) ((task)->c64x_flags & 3) + +typedef volatile struct { + uint32_t QH_dsp; + uint32_t QH_arm; + uint32_t QL_dsp; + uint32_t QL_arm; + uint32_t idlecounter; +} c64xTaskControl; + +#define C64X_QUEUE_LENGTH 0x4000 +#define C64X_QUEUE_MASK 0x3fff + + +typedef enum { + C64X_BLEND_SRC_INVSRC = 2, /* old school fader on all channels including alpha on itself */ + C64X_BLEND_ONE_INVSRC = 1, /* SrcOver using premultiplied alpha channel */ + C64X_BLEND_ONE_INVSRC_PREMULT_SRC = 0, /* SrcOver doing premultiplication of source S[rgb] with S[a] */ + C64X_BLEND_ONE_INVSRC_PREMULT_ALPHA = 3, /* SrcOver with Alpha using premultiplied alpha channel, + but doing premultiplication of S[rgb] with Alpha */ +} C64XBlendSubFunction; + +typedef enum { + C64X_FLUSH_WRITE_BACK, + C64X_FLUSH_WB_INVALIDATE, + C64X_FLUSH_INVALIDATE +} C64XFlushFunction; + +#define C64X_IOCTL_RESET _IO( 'c', 0 ) +#define C64X_IOCTL_WAIT_LOW _IO( 'c', 1 ) + + +/* function macro */ +#define _C64XFUNC(val) (((val)&0x3fff)<<2) + + +#define C64X_NOP _C64XFUNC(0) + +/* +void c64x_dither_argb(u32*dst_rgb, u8*dst_alpha, u32 dst_pitch, u32*src, u32 src_pitch, u32 width, u32 height); +*/ +#define C64X_DITHER_ARGB _C64XFUNC(1) + +/* +void c64x_fill_16(u16*dst, u32 pitch, u32 width, u32 height, u16 val); +void c64x_fill_32(u32*dst, u32 pitch, u32 width, u32 height, u32 val); +*/ +#define C64X_FILL_16 _C64XFUNC(2) +#define C64X_FILL_32 _C64XFUNC(3) + +/* +void c64x_copy_16(u16*dst, u32 dst_pitch, u16*src, u32 src_pitch, u32 width, u32 height); +void c64x_copy_32(u32*dst, u32 dst_pitch, u32*src, u32 src_pitch, u32 width, u32 height); +*/ +#define C64X_COPY_16 _C64XFUNC(4) +#define C64X_COPY_32 _C64XFUNC(5) + +/* +void c64x_blend_32(u32*dst, u32 dst_pitch, u32*src, u32 src_pitch, u32 width, u32 height, u8 alpha); +*/ +//#define C64X_BLEND_16 _C64XFUNC(6) +#define C64X_BLEND_32 _C64XFUNC(7) + +/* +void c64x_copy_keyed_16(u16*dst, u32 pitches, u16*src, u32 width, u32 height, u16 key, u16 mask); +void c64x_copy_keyed_32(u32*dst, u32 pitches, u32*src, u32 width, u32 height, u32 key, u32 mask); +*/ +#define C64X_COPY_KEYED_16 _C64XFUNC(8) +#define C64X_COPY_KEYED_32 _C64XFUNC(9) + +/* +void c64x_stretch_32(u32 *dst, u32 *src, u32 pitches, u32 dsize, u32 ssize, u32 clip2, u32 clip1); +*/ +#define C64X_STRETCH_32_up _C64XFUNC(10) +#define C64X_STRETCH_32_down _C64XFUNC(11) + + +/* +void c64x_wb_inv_range(u32 *start, u32 len, C64XFlushFunction func); +*/ +#define C64X_WB_INV_RANGE _C64XFUNC(14) + + +/* +void c64x_write_back_all(void); +*/ +#define C64X_WRITE_BACK_ALL _C64XFUNC(15) + + + +/* +void c64x_load_block(s32*blockwords, u32 num_words, u32 cbp); +*/ +#define C64X_LOAD_BLOCK _C64XFUNC(48) + +/* +void c64x_put_idct_uyvy_16x16(u16*dst, u32 pitch, u32 flags); +*/ +#define C64X_PUT_IDCT_UYVY_16x16 _C64XFUNC(49) + +/* +void c64x_put_mc_uyvy_16x16(u16*dst, u32 pitch, u32 flags); +*/ +#define C64X_PUT_MC_UYVY_16x16 _C64XFUNC(50) + +/* +void c64x_put_sum_uyvy_16x16(u16*dst, u32 pitch, u32 flags); +*/ +#define C64X_PUT_SUM_UYVY_16x16 _C64XFUNC(51) + +/* +void c64x_dva_begin_frame(u32 pitch, u16 *current, u16 *past, u16 *future, u32 flags); +*/ +#define C64X_DVA_BEGIN_FRAME _C64XFUNC(52) + +/* +void c64x_dva_motion(DVAMacroBlock *macroblock); +*/ +#define C64X_DVA_MOTION_BLOCK _C64XFUNC(53) + +/* +void c64x_dva_idct(u16* dst, u32 pitch, u16* src); +*/ +#define C64X_DVA_IDCT _C64XFUNC(59) + + + +/* + * INTERNAL - for testing + */ +#define C64X_FETCH_BUFFER_PITCH 32 +#define C64X_TEMP_BUFFER_PITCH 32 +#define C64X_MC_BUFFER_PITCH 16 +#define C64X_IDCT_BUFFER_PITCH 32 + +#define C64X_FETCH_BUFFER_Y(n) (0xf05840 + ((n) << 10)) +#define C64X_FETCH_BUFFER_U(n) (C64X_FETCH_BUFFER_Y(n) + 18*C64X_FETCH_BUFFER_PITCH) +#define C64X_FETCH_BUFFER_V(n) (C64X_FETCH_BUFFER_U(n) + 16) + +#define C64X_FETCH_BUFFER0_Y C64X_FETCH_BUFFER_Y(0) +#define C64X_FETCH_BUFFER0_U C64X_FETCH_BUFFER_U(0) +#define C64X_FETCH_BUFFER0_V C64X_FETCH_BUFFER_V(0) + +#define C64X_FETCH_BUFFER1_Y C64X_FETCH_BUFFER_Y(1) +#define C64X_FETCH_BUFFER1_U C64X_FETCH_BUFFER_U(1) +#define C64X_FETCH_BUFFER1_V C64X_FETCH_BUFFER_V(1) + +#define C64X_TEMP_BUFFER_Y 0xf06040 +#define C64X_TEMP_BUFFER_U (C64X_TEMP_BUFFER_Y + 16*C64X_TEMP_BUFFER_PITCH) +#define C64X_TEMP_BUFFER_V (C64X_TEMP_BUFFER_U + 8) + +#define C64X_MC_BUFFER_Y 0xf06440 +#define C64X_MC_BUFFER_U (C64X_MC_BUFFER_Y + 16*C64X_MC_BUFFER_PITCH) +#define C64X_MC_BUFFER_V (C64X_MC_BUFFER_U + 8) + +#define C64X_MC_BUFFER_Y_ (C64X_MC_BUFFER_Y + C64X_MC_BUFFER_PITCH) +#define C64X_MC_BUFFER_U_ (C64X_MC_BUFFER_U + C64X_MC_BUFFER_PITCH) +#define C64X_MC_BUFFER_V_ (C64X_MC_BUFFER_V + C64X_MC_BUFFER_PITCH) + +#define C64X_IDCT_BUFFER_Y 0xf06a40 +#define C64X_IDCT_BUFFER_U (C64X_IDCT_BUFFER_Y + 16*C64X_IDCT_BUFFER_PITCH) +#define C64X_IDCT_BUFFER_V (C64X_IDCT_BUFFER_U + 8) + + +/* OBSOLETE +void c64x_dezigzag(u16*dst, u16*src); +*/ +#define C64X_DEZIGZAG _C64XFUNC(16) + +/* OBSOLETE +void c64x_dealternate(u16*dst, u16*src); +*/ +#define C64X_DEALTERNATE _C64XFUNC(17) + +/* +void c64x_put_uyvy_16x16(u16*dst, u32 pitch, u8*src, u32 flags); +*/ +#define C64X_PUT_UYVY_16x16 _C64XFUNC(18) + +/* +void c64x_fetch_uyvy(u8 *dst, u8 *src, u32 spitch, u32 height); +*/ +#define C64X_FETCH_UYVY _C64XFUNC(19) + +/* +void mc_put_o_8 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height); +void mc_put_x_8 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height); +void mc_put_y_8 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height); +void mc_put_xy_8 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height); +*/ +#define C64X_MC_PUT_8(avgX,avgY) _C64XFUNC(32+(avgX)+(avgY)+(avgY)) + +/* +void mc_put_o_16 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height); +void mc_put_x_16 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height); +void mc_put_y_16 (u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height); +void mc_put_xy_16(u8*dst, u32 dstride, u8*ref_src, u8*ignored, u32 rstride, u32 height); +*/ +#define C64X_MC_PUT_16(avgX,avgY) _C64XFUNC(36+(avgX)+(avgY)+(avgY)) + +/* +void mc_avg_o_8 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height); +void mc_avg_x_8 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height); +void mc_avg_y_8 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height); +void mc_avg_xy_8 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height); +*/ +#define C64X_MC_AVG_8(avgX,avgY) _C64XFUNC(40+(avgX)+(avgY)+(avgY)) + +/* +void mc_avg_o_16 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height); +void mc_avg_x_16 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height); +void mc_avg_y_16 (u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height); +void mc_avg_xy_16(u8*dst, u32 dstride, u8*ref_src, u8*ref_dst, u32 rstride, u32 height); +*/ +#define C64X_MC_AVG_16(avgX,avgY) _C64XFUNC(44+(avgX)+(avgY)+(avgY)) + + +#endif diff --git a/Source/DirectFB/gfxdrivers/davinci/patches/ti-davinci-2.6.10-mvl401-fbio_set_start.patch b/Source/DirectFB/gfxdrivers/davinci/patches/ti-davinci-2.6.10-mvl401-fbio_set_start.patch new file mode 100755 index 0000000..60c2730 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/davinci/patches/ti-davinci-2.6.10-mvl401-fbio_set_start.patch @@ -0,0 +1,123 @@ +Index: include/video/davincifb.h +=================================================================== +--- include/video/davincifb.h (revision 765) ++++ include/video/davincifb.h (working copy) +@@ -40,6 +40,21 @@ + u_int32_t zoom_v; + } zoom_params_t; + ++ ++typedef struct fb_set_start { ++ int offset; /* offset from smem_start */ ++ unsigned long physical; /* absolute physical address when offset < 0 */ ++ ++ u_int64_t sync; /* input: target sync counter for change or 0 for no sync at all, ++ output: sync counter of actual change or 0 if still pending */ ++} fb_set_start_t; ++ ++ ++#ifdef _IOC_TYPECHECK ++#undef _IOC_TYPECHECK ++#define _IOC_TYPECHECK(x) (sizeof(x)) ++#endif ++ + #define RAM_CLUT_SIZE 256*3 + #define FBIO_ENABLE_DISABLE_WIN \ + _IOW('F', 0x30, unsigned char) +@@ -83,6 +98,8 @@ + _IOW('F', 0x49, u_int32_t) + #define FBIO_SET_CURSOR \ + _IOW('F', 0x50, struct fb_cursor) ++#define FBIO_SET_START \ ++ _IOW('F', 0x66, struct fb_set_start) + + /* + * Defines and Constants +Index: drivers/video/davincifb.c +=================================================================== +--- drivers/video/davincifb.c (revision 765) ++++ drivers/video/davincifb.c (working copy) +@@ -1095,6 +1095,58 @@ + return 0; + } + ++static int ++davincifb_set_start( struct fb_set_start *set, struct fb_info *info ) ++{ ++ struct vpbe_dm_win_info *win = (struct vpbe_dm_win_info *) info->par; ++ unsigned long start = 0; ++ ++ /* Physical mode (absolute address)? */ ++ if (set->offset < 0) { ++ start = set->physical; ++ ++ /* FIXME: address checks */ ++ } ++ else { ++ /* Offset mode (from frame buffer device base). */ ++ if (set->offset + info->var.yres * info->fix.line_length >= win->fb_size) ++ return -EFAULT; ++ ++ start = win->fb_base_phys + set->offset; ++ } ++ ++ /* Set on explicit sync count? */ ++ if (set->sync > 1) { ++ if (set->sync <= dm->vsync_cnt) { ++ set_sdram_params( info->fix.id, start, info->fix.line_length ); ++ win->sdram_address = start; ++ ++ set->sync = dm->vsync_cnt; ++ } ++ else { ++ /* FIXME: No queue yet. */ ++ win->sdram_address = start; ++ ++ set->sync = 0; ++ } ++ } ++ /* Set on next sync? */ ++ else if (set->sync) { ++ win->sdram_address = start; ++ ++ set->sync = 0; ++ } ++ /* Set now! */ ++ else { ++ set_sdram_params( info->fix.id, start, info->fix.line_length ); ++ win->sdram_address = start; ++ ++ set->sync = dm->vsync_cnt; ++ } ++ ++ return 0; ++} ++ + /* + * davincifb_ioctl - handler for private ioctls. + */ +@@ -1105,6 +1157,7 @@ + struct vpbe_dm_win_info *w = (struct vpbe_dm_win_info *)info->par; + void __user *argp = (void __user *)arg; + struct fb_fillrect rect; ++ struct fb_set_start set_start; + zoom_params_t zoom; + int retval = 0; + long std = 0; +@@ -1414,6 +1467,16 @@ + return -EINVAL; + break; + ++ case FBIO_SET_START: ++ if (copy_from_user(&set_start, argp, sizeof(set_start))) ++ return -EFAULT; ++ retval = davincifb_set_start( &set_start, &w->info ); ++ if (retval) ++ return retval; ++ if (copy_to_user(argp, &set_start, sizeof(set_start))) ++ return -EFAULT; ++ break; ++ + default: + retval = -EINVAL; + break; -- cgit