From 0db741a5ee19fb8a89dc17c770ca2bdfa4da8d05 Mon Sep 17 00:00:00 2001 From: Paul Jeong Date: Fri, 25 Feb 2011 15:43:42 +0900 Subject: Initial X11 drivers for Mali DDK --- src/Makefile.am | 35 ++ src/Makefile.in | 567 ++++++++++++++++++++++++++ src/mali_def.h | 28 ++ src/mali_dri.c | 347 ++++++++++++++++ src/mali_dri.h | 36 ++ src/mali_exa.c | 523 ++++++++++++++++++++++++ src/mali_exa.h | 59 +++ src/mali_fbdev.c | 1196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mali_fbdev.h | 97 +++++ src/mali_lcd.c | 276 +++++++++++++ 10 files changed, 3164 insertions(+) create mode 100644 src/Makefile.am create mode 100644 src/Makefile.in create mode 100644 src/mali_def.h create mode 100644 src/mali_dri.c create mode 100644 src/mali_dri.h create mode 100644 src/mali_exa.c create mode 100644 src/mali_exa.h create mode 100644 src/mali_fbdev.c create mode 100644 src/mali_fbdev.h create mode 100644 src/mali_lcd.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..24e6981 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,35 @@ +# Copyright 2005 Adam Jackson. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +# this is obnoxious: +# -module lets us name the module exactly how we want +# -avoid-version prevents gratuitous .0.0.0 version numbers on the end +# _ladir passes a dummy rpath to libtool so the thing will actually link +# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. +AM_CFLAGS = @XORG_CFLAGS@ +mali_drv_la_LTLIBRARIES = mali_drv.la +mali_drv_la_LDFLAGS = -module -avoid-version +mali_drv_ladir = @moduledir@/drivers + +mali_drv_la_SOURCES = \ + mali_fbdev.c \ + mali_exa.c \ + mali_dri.c \ + mali_lcd.c diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..86f5c43 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,567 @@ +# Makefile.in generated by automake 1.11 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@ + +# Copyright 2005 Adam Jackson. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@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@ +subdir = src +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_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 = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(mali_drv_ladir)" +LTLIBRARIES = $(mali_drv_la_LTLIBRARIES) +mali_drv_la_LIBADD = +am_mali_drv_la_OBJECTS = mali_fbdev.lo mali_exa.lo mali_lcd.lo mali_dri.lo +mali_drv_la_OBJECTS = $(am_mali_drv_la_OBJECTS) +mali_drv_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(mali_drv_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +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 = $(mali_drv_la_SOURCES) +DIST_SOURCES = $(mali_drv_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +AMTAR = @AMTAR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRIVER_NAME = @DRIVER_NAME@ +DSYMUTIL = @DSYMUTIL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +NMEDIT = @NMEDIT@ +OBJEXT = @OBJEXT@ +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@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_LIBS = @XORG_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@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# this is obnoxious: +# -module lets us name the module exactly how we want +# -avoid-version prevents gratuitous .0.0.0 version numbers on the end +# _ladir passes a dummy rpath to libtool so the thing will actually link +# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. +AM_CFLAGS = @XORG_CFLAGS@ +mali_drv_la_LTLIBRARIES = mali_drv.la +mali_drv_la_LDFLAGS = -module -avoid-version +mali_drv_ladir = @moduledir@/drivers +mali_drv_la_SOURCES = \ + mali_fbdev.c \ + mali_exa.c \ + mali_lcd.c \ + mali_dri.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/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 +$(am__aclocal_m4_deps): +install-mali_drv_laLTLIBRARIES: $(mali_drv_la_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(mali_drv_ladir)" || $(MKDIR_P) "$(DESTDIR)$(mali_drv_ladir)" + @list='$(mali_drv_la_LTLIBRARIES)'; test -n "$(mali_drv_ladir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(mali_drv_ladir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(mali_drv_ladir)"; \ + } + +uninstall-mali_drv_laLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(mali_drv_la_LTLIBRARIES)'; test -n "$(mali_drv_ladir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(mali_drv_ladir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(mali_drv_ladir)/$$f"; \ + done + +clean-mali_drv_laLTLIBRARIES: + -test -z "$(mali_drv_la_LTLIBRARIES)" || rm -f $(mali_drv_la_LTLIBRARIES) + @list='$(mali_drv_la_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 +mali_drv.la: $(mali_drv_la_OBJECTS) $(mali_drv_la_DEPENDENCIES) + $(mali_drv_la_LINK) -rpath $(mali_drv_ladir) $(mali_drv_la_OBJECTS) $(mali_drv_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mali.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(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@ $(am__mv) $(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@ $(am__mv) $(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 + +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; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + 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; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + 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)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__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 "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$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) +installdirs: + for dir in "$(DESTDIR)$(mali_drv_ladir)"; 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) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_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-mali_drv_laLTLIBRARIES clean-generic 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 + +html-am: + +info: info-am + +info-am: + +install-data-am: install-mali_drv_laLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +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-mali_drv_laLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean \ + clean-mali_drv_laLTLIBRARIES clean-generic 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-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-mali_drv_laLTLIBRARIES install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-mali_drv_laLTLIBRARIES + + +# 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/src/mali_def.h b/src/mali_def.h new file mode 100644 index 0000000..b0f3177 --- /dev/null +++ b/src/mali_def.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _MALI_DEF_H_ +#define _MALI_DEF_H_ +#include "exa.h" + +Bool maliSetupExa( ScreenPtr pScreen, ExaDriverPtr exa, int xres, int yres, unsigned char *virt ); +#endif diff --git a/src/mali_dri.c b/src/mali_dri.c new file mode 100644 index 0000000..937fee5 --- /dev/null +++ b/src/mali_dri.c @@ -0,0 +1,347 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "mali_dri.h" + +#define IGNORE( a ) ( a = a ) + +#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32) + + +extern XF86ModuleData dri2ModuleData; + +typedef struct +{ + PixmapPtr pPixmap; + unsigned int attachment; + Bool isPageFlipped; +} MaliDRI2BufferPrivateRec, *MaliDRI2BufferPrivatePtr; + +static DRI2Buffer2Ptr MaliDRI2CreateBuffer( DrawablePtr pDraw, unsigned int attachment, unsigned int format ) +{ + ScreenPtr pScreen = pDraw->pScreen; + DRI2Buffer2Ptr buffer; + MaliDRI2BufferPrivatePtr privates; + PixmapPtr pPixmap; + PrivPixmap *privPixmap; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MaliPtr fPtr = MALIPTR(pScrn); + + buffer = calloc(1, sizeof *buffer); + if ( NULL == buffer ) return NULL; + + privates = calloc(1, sizeof *privates); + if ( NULL == privates ) + { + free( buffer ); + return NULL; + } + + /* initialize privates info to default values */ + privates->pPixmap = NULL; + privates->attachment = attachment; + privates->isPageFlipped = FALSE; + + /* initialize buffer info to default values */ + buffer->attachment = attachment; + buffer->driverPrivate = privates; + buffer->format = format; + buffer->flags = 0; + + if ( DRI2CanFlip( pDraw ) && fPtr->use_pageflipping && DRAWABLE_PIXMAP != pDraw->type) + { + ump_secure_id ump_id = UMP_INVALID_SECURE_ID; + + if ( (fPtr->fb_lcd_var.yres*2) > fPtr->fb_lcd_var.yres_virtual ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] lcd driver does not have enough virtual y resolution. Need: %i Have: %i\n", + __FUNCTION__, __LINE__, fPtr->fb_lcd_var.yres*2, fPtr->fb_lcd_var.yres_virtual ); + return NULL; + } + + (void)ioctl(fPtr->fb_lcd_fd, GET_UMP_SECURE_ID, &ump_id ); + + if ( UMP_INVALID_SECURE_ID == ump_id ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to retrieve UMP memory handle for flipping\n", __FUNCTION__, __LINE__ ); + + free( buffer ); + free( privates ); + return NULL; + } + + buffer->name = ump_id; + + if ( DRI2BufferBackLeft == attachment ) + { + /* Use the "flags" attribute in order to provide EGL with enough information to offset the provided UMP memory for this buffer + * Flags will only be set in cases where it is possible to do page flipping instead of offscreen rendering with EXA copy + * Offset is set to the second virtual screen, in y direction + * Example: + * Physical resolution: 1366 x 768 + * Virtual resolution: 1366 x 1536 + * Offset: 768 + */ + buffer->flags = (fPtr->fb_lcd_var.xres_virtual * fPtr->fb_lcd_var.bits_per_pixel/8) * fPtr->fb_lcd_var.yres; + + /* make sure the display offset is set to a known state */ + if ( ioctl( fPtr->fb_lcd_fd, FBIOGET_VSCREENINFO, &fPtr->fb_lcd_var ) < 0 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] failed in FBIOGET_VSCREENINFO\n", __FUNCTION__, __LINE__ ); + free( buffer ); + free( privates ); + return NULL; + } + + fPtr->fb_lcd_var.yoffset = fPtr->fb_lcd_var.yres; + fPtr->fb_lcd_var.activate = FB_ACTIVATE_NOW; + + if ( ioctl( fPtr->fb_lcd_fd, FBIOPUT_VSCREENINFO, &fPtr->fb_lcd_var ) < 0 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] failed in FBIOPUT_VSCREENINFO\n", __FUNCTION__, __LINE__ ); + free( buffer ); + free( privates ); + return NULL; + } + } + + if ( DRAWABLE_PIXMAP == pDraw->type ) pPixmap = (PixmapPtr)pDraw; + else pPixmap = pScreen->GetWindowPixmap( (WindowPtr) pDraw ); + + privates->isPageFlipped = TRUE; + + pPixmap->refcnt++; + + buffer->pitch = pPixmap->devKind; + if ( 0 == buffer->pitch ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] Warning: Autocalculating pitch\n", __FUNCTION__, __LINE__ ); + buffer->pitch = ( (pPixmap->drawable.width*pPixmap->drawable.bitsPerPixel) + 7 ) / 8; + } + buffer->cpp = pPixmap->drawable.bitsPerPixel / 8; + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] Enabled Page Flipping (pitch: %i flags: %i width: %i height: %i)\n", __FUNCTION__, __LINE__, buffer->pitch, buffer->flags, pPixmap->drawable.width, pPixmap->drawable.height ); + + ioctl( fPtr->fb_lcd_fd, FBIOGET_VSCREENINFO, &fPtr->fb_lcd_var ); + } + else + { + if ( DRI2BufferFrontLeft == attachment ) + { + if ( DRAWABLE_PIXMAP == pDraw->type ) pPixmap = (PixmapPtr)pDraw; + else pPixmap = pScreen->GetWindowPixmap( (WindowPtr) pDraw ); + + pPixmap->refcnt++; + } + else + { + /* create a new pixmap for the offscreen data */ + pPixmap = (*pScreen->CreatePixmap)( pScreen, pDraw->width, pDraw->height, (format != 0) ? format : pDraw->depth, 0 ); + if ( NULL == pPixmap ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] unable to allocate pixmap\n", __FUNCTION__, __LINE__ ); + free( buffer ); + free( privates ); + return NULL; + } + + exaMoveInPixmap(pPixmap); + } + + privates->pPixmap = pPixmap; + privPixmap = (PrivPixmap *)exaGetPixmapDriverPrivate( pPixmap ); + buffer->pitch = pPixmap->devKind; + buffer->cpp = pPixmap->drawable.bitsPerPixel / 8; + buffer->name = ump_secure_id_get( privPixmap->mem_info->handle ); + } + + return buffer; +} + +static void MaliDRI2DestroyBuffer( DrawablePtr pDraw, DRI2Buffer2Ptr buffer ) +{ + ScreenPtr pScreen = pDraw->pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MaliPtr fPtr = MALIPTR(pScrn); + + if ( NULL != buffer ) + { + MaliDRI2BufferPrivatePtr private = buffer->driverPrivate; + ScreenPtr pScreen = pDraw->pScreen; + + if ( NULL != private ) + { + if ( TRUE == private->isPageFlipped ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "[%s:%d] Setting back to zero offset\n", __FUNCTION__, __LINE__ ); + fPtr->fb_lcd_var.yoffset = 0; + fPtr->fb_lcd_var.activate = FB_ACTIVATE_NOW; + + if ( ioctl( fPtr->fb_lcd_fd, FBIOPUT_VSCREENINFO, &fPtr->fb_lcd_var ) < 0 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_WARNING, "[%s:%d] failed in FBIOPUT_VSCREENINFO\n", __FUNCTION__, __LINE__ ); + } + } + if( NULL != private->pPixmap ) (*pScreen->DestroyPixmap)(private->pPixmap); + } + + free( private ); + free( buffer ); + } +} + +static void MaliDRI2CopyRegion( DrawablePtr pDraw, RegionPtr pRegion, DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer ) +{ + GCPtr pGC; + RegionPtr copyRegion; + ScreenPtr pScreen = pDraw->pScreen; + MaliDRI2BufferPrivatePtr srcPrivate = pSrcBuffer->driverPrivate; + MaliDRI2BufferPrivatePtr dstPrivate = pDstBuffer->driverPrivate; + DrawablePtr src = (srcPrivate->attachment == DRI2BufferFrontLeft) ? pDraw : &srcPrivate->pPixmap->drawable; + DrawablePtr dst = (dstPrivate->attachment == DRI2BufferFrontLeft) ? pDraw : &dstPrivate->pPixmap->drawable; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MaliPtr fPtr = MALIPTR(pScrn); + + if ( TRUE == dstPrivate->isPageFlipped && TRUE == srcPrivate->isPageFlipped ) + { + fPtr->fb_lcd_var.yoffset = (fPtr->fb_lcd_var.yoffset + fPtr->fb_lcd_var.yres) % (fPtr->fb_lcd_var.yres*2); + + +#if 1 + if ( ioctl( fPtr->fb_lcd_fd, FBIOPUT_VSCREENINFO, &fPtr->fb_lcd_var ) < 0 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_WARNING, "[%s:%d] failed in FBIOPUT_VSCREENINFO (offset: %i)\n", __FUNCTION__, __LINE__, fPtr->fb_lcd_var.yoffset ); + } + + if ( fPtr->use_pageflipping_vsync ) + { + fPtr->fb_lcd_var.activate = FB_ACTIVATE_VBL; + if ( ioctl( fPtr->fb_lcd_fd, FBIO_WAITFORVSYNC, 0 ) < 0 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_WARNING, "[%s:%d] failed in FBIO_WAITFORVSYNC\n", __FUNCTION__, __LINE__ ); + } + } +#else + if ( ioctl( fPtr->fb_lcd_fd, FBIOPAN_DISPLAY, &fPtr->fb_lcd_var ) < 0 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_WARNING, "[%s:%d] failed in FBIOPAN_DISPLAY (offset: %i)\n", __FUNCTION__, __LINE__, fPtr->fb_lcd_var.yoffset ); + } +#endif + ioctl( fPtr->fb_lcd_fd, FBIOGET_VSCREENINFO, &fPtr->fb_lcd_var ); + + return; + } + + if ( DRI2BufferFakeFrontLeft == srcPrivate->attachment || DRI2BufferFakeFrontLeft == dstPrivate->attachment ) return; + + pGC = GetScratchGC(pDraw->depth, pScreen); + + copyRegion = REGION_CREATE( pScreen, NULL, 0 ); + REGION_COPY( pScreen, copyRegion, pRegion ); + (*pGC->funcs->ChangeClip)(pGC, CT_REGION, copyRegion, 0 ); + ValidateGC( dst, pGC ); + (*pGC->ops->CopyArea)( src, dst, pGC, 0, 0, pDraw->width, pDraw->height, 0, 0 ); + + FreeScratchGC(pGC); +} + +Bool MaliDRI2ScreenInit( ScreenPtr pScreen ) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MaliPtr fPtr = MALIPTR(pScrn); + DRI2InfoRec info; + int dri2_major = 2, dri2_minor = 0, i; + struct stat sbuf; + dev_t d; + char *p; + + if ( xf86LoaderCheckSymbol( "DRI2Version") ) DRI2Version( &dri2_major, &dri2_minor ); + + if ( dri2_minor < 1 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "%s requires DRI2 module version 1.1.0 or later\n", __func__); + return FALSE; + } + + xf86DrvMsg( pScrn->scrnIndex, X_INFO, "DRI2 version: %i.%i\n", dri2_major, dri2_minor ); + + + /* extract deviceName */ + info.fd = fPtr->drm_fd; + fstat( info.fd, &sbuf ); + d = sbuf.st_rdev; + + p = fPtr->deviceName; + for ( i=0; iscrnIndex, X_ERROR, "%s failed to open drm device\n", __func__ ); + return FALSE; + } + + + info.driverName = "Mali DRI2"; + info.deviceName = p; + +#if DRI2INFOREC_VERSION == 1 + info.version = 1; + info.CreateBuffers = MaliDRI2CreateBuffers; + info.DestroyBuffers = MaliDRI2DestroyBuffers; +#elif DRI2INFOREC_VERSION == 2 + info.version = 2; + info.CreateBuffer = MaliDRI2CreateBuffer; + info.DestroyBuffer = MaliDRI2DestroyBuffer; +#else + info.version = 3; + info.CreateBuffer = MaliDRI2CreateBuffer; + info.DestroyBuffer = MaliDRI2DestroyBuffer; +#endif + + info.CopyRegion = MaliDRI2CopyRegion; + + if ( FALSE == DRI2ScreenInit( pScreen, &info ) ) return FALSE; + + return TRUE; +} + +void MaliDRI2CloseScreen( ScreenPtr pScreen ) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MaliPtr fPtr = MALIPTR(pScrn); + + DRI2CloseScreen( pScreen ); + + fPtr->dri_render = DRI_NONE; +} diff --git a/src/mali_dri.h b/src/mali_dri.h new file mode 100644 index 0000000..4dbd126 --- /dev/null +++ b/src/mali_dri.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _MALI_DRI_H_ +#define _MALI_DRI_H_ + +#include "xf86.h" +#include "xf86drm.h" +#include "xf86_OSproc.h" +#include "xf86Priv.h" +#include "xorg-server.h" + +#include "mali_fbdev.h" +#include "mali_exa.h" +#include "dri2.h" + +#endif /* _MALI_DRI_H_ */ diff --git a/src/mali_exa.c b/src/mali_exa.c new file mode 100644 index 0000000..5138e62 --- /dev/null +++ b/src/mali_exa.c @@ -0,0 +1,523 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include "mali_exa.h" +#include "mali_fbdev.h" + +static struct mali_info mi; + +#ifdef USE_TRACING +#define TRACE_ENTER() xf86DrvMsg(mi.pScrn->scrnIndex, X_INFO, "%s: ENTER\n", __FUNCTION__) +#define TRACE_EXIT() xf86DrvMsg(mi.pScrn->scrnIndex, X_INFO, "%s: EXIT\n", __FUNCTION__) +#else +#define TRACE_ENTER() +#define TRACE_EXIT() +#endif + +#define MALI_EXA_FUNC(s) exa->s = mali ## s +#define IGNORE( a ) ( a = a ); +#define MALI_ALIGN( value, base ) (((value) + ((base) - 1)) & ~((base) - 1)) + +static int fd_fbdev = -1; + +static Bool maliPrepareSolid( PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg ) +{ + TRACE_ENTER(); + IGNORE( pPixmap ); + IGNORE( alu ); + IGNORE( planemask ); + IGNORE( fg ); + TRACE_EXIT(); + + return FALSE; +} + +static void maliSolid( PixmapPtr pPixmap, int x1, int y1, int x2, int y2 ) +{ + TRACE_ENTER(); + IGNORE( pPixmap ); + IGNORE( x1 ); + IGNORE( y1 ); + IGNORE( x2 ); + IGNORE( y2 ); + TRACE_EXIT(); +} + +static void maliDoneSolid( PixmapPtr pPixmap ) +{ + TRACE_ENTER(); + IGNORE( pPixmap ); + TRACE_EXIT(); +} + +static Bool maliPrepareCopy( PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir, int alu, Pixel planemask ) +{ + TRACE_ENTER(); + IGNORE( pSrcPixmap ); + IGNORE( pDstPixmap ); + IGNORE( xdir ); + IGNORE( ydir ); + IGNORE( alu ); + IGNORE( planemask ); + TRACE_EXIT(); + + return FALSE; +} + +static void maliCopy( PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, int width, int height ) +{ + TRACE_ENTER(); + IGNORE( pDstPixmap ); + IGNORE( srcX ); + IGNORE( srcY ); + IGNORE( dstX ); + IGNORE( dstY ); + IGNORE( width ); + IGNORE( height ); + TRACE_EXIT(); +} + +static void maliDoneCopy( PixmapPtr pDstPixmap ) +{ + TRACE_ENTER(); + IGNORE( pDstPixmap ); + TRACE_EXIT(); +} + +static void maliWaitMarker( ScreenPtr pScreen, int marker ) +{ + TRACE_ENTER(); + IGNORE( pScreen ); + IGNORE( marker ); + TRACE_EXIT(); +} + +static void* maliCreatePixmap(ScreenPtr pScreen, int size, int align ) +{ + PrivPixmap *privPixmap = calloc(1, sizeof(PrivPixmap)); + + TRACE_ENTER(); + IGNORE( pScreen ); + IGNORE( size ); + IGNORE( align ); + privPixmap->bits_per_pixel = 0; + TRACE_EXIT(); + + return privPixmap; +} + +static void maliDestroyPixmap(ScreenPtr pScreen, void *driverPriv ) +{ + PrivPixmap *privPixmap = (PrivPixmap *)driverPriv; + + TRACE_ENTER(); + IGNORE( pScreen ); + if ( NULL != privPixmap->mem_info ) + { + ump_reference_release(privPixmap->mem_info->handle); + free( privPixmap->mem_info ); + privPixmap->mem_info = NULL; + free( privPixmap ); + } + TRACE_EXIT(); +} + +static Bool maliModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth, int bitsPerPixel, int devKind, pointer pPixData) +{ + unsigned int size; + PrivPixmap *privPixmap = (PrivPixmap *)exaGetPixmapDriverPrivate(pPixmap); + mali_mem_info *mem_info; + + TRACE_ENTER(); + + if (!pPixmap) + { + TRACE_EXIT(); + return FALSE; + } + + miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData); + + if (pPixData == mi.fb_virt) + { + ump_secure_id ump_id = UMP_INVALID_SECURE_ID; + + privPixmap->isFrameBuffer = TRUE; + + mem_info = privPixmap->mem_info; + if ( mem_info ) + { + TRACE_EXIT(); + return TRUE; + } + + /* create new mem_info for the on-screen buffer */ + mem_info = calloc(1, sizeof(*mem_info)); + if (!mem_info) + { + xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to allocate for memory metadata\n", __FUNCTION__, __LINE__); + TRACE_EXIT(); + return FALSE; + } + + /* get the secure ID for the framebuffer */ + (void)ioctl( fd_fbdev, GET_UMP_SECURE_ID, &ump_id ); + + if ( UMP_INVALID_SECURE_ID == ump_id) + { + free( mem_info ); + privPixmap->mem_info = NULL; + xf86DrvMsg( mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] UMP failed to retrieve secure id\n", __FUNCTION__, __LINE__); + TRACE_EXIT(); + return FALSE; + } + + mem_info->handle = ump_handle_create_from_secure_id( ump_id ); + if ( UMP_INVALID_MEMORY_HANDLE == mem_info->handle ) + { + xf86DrvMsg( mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] UMP failed to create handle from secure id\n", __FUNCTION__, __LINE__); + free( mem_info ); + privPixmap->mem_info = NULL; + TRACE_EXIT(); + return FALSE; + } + + size = exaGetPixmapPitch(pPixmap) * pPixmap->drawable.height; + mem_info->usize = size; + + privPixmap->mem_info = mem_info; + if( bitsPerPixel != 0 ) privPixmap->bits_per_pixel = bitsPerPixel; + + TRACE_EXIT(); + return TRUE; + } + else + { + privPixmap->isFrameBuffer = FALSE; + } + + if ( pPixData ) + { + if ( privPixmap->mem_info != NULL ) + { + TRACE_EXIT(); + return TRUE; + } + + TRACE_EXIT(); + return FALSE; + } + + pPixmap->devKind = ( (pPixmap->drawable.width*pPixmap->drawable.bitsPerPixel) + 7 ) / 8; + pPixmap->devKind = MALI_ALIGN( pPixmap->devKind, 8 ); + + size = exaGetPixmapPitch(pPixmap) * pPixmap->drawable.height; + + /* allocate pixmap data */ + mem_info = privPixmap->mem_info; + + if ( mem_info && mem_info->usize == size ) + { + TRACE_EXIT(); + return TRUE; + } + + if ( mem_info && mem_info->usize != 0 ) + { + ump_reference_release(mem_info->handle); + mem_info->handle = NULL; + memset(privPixmap, 0, sizeof(*privPixmap)); + + TRACE_EXIT(); + return TRUE; + } + + if (!size) + { + TRACE_EXIT(); + return TRUE; + } + + if ( NULL == mem_info ) + { + mem_info = calloc(1, sizeof(*mem_info)); + if (!mem_info) + { + xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to allocate memory metadata\n", __FUNCTION__, __LINE__); + TRACE_EXIT(); + return FALSE; + } + } + + mem_info->handle = ump_ref_drv_allocate( size, UMP_REF_DRV_CONSTRAINT_PHYSICALLY_LINEAR ); + if ( UMP_INVALID_MEMORY_HANDLE == mem_info->handle ) + { + xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to allocate UMP memory (%i bytes)\n", __FUNCTION__, __LINE__, size); + TRACE_EXIT(); + return FALSE; + } + + mem_info->usize = size; + privPixmap->mem_info = mem_info; + privPixmap->mem_info->usize = size; + privPixmap->bits_per_pixel = 16; + + TRACE_EXIT(); + + return TRUE; +} + +static Bool maliPixmapIsOffscreen( PixmapPtr pPix ) +{ + ScreenPtr pScreen = pPix->drawable.pScreen; + PrivPixmap *privPixmap = (PrivPixmap *)exaGetPixmapDriverPrivate(pPix); + + TRACE_ENTER(); + + if (pScreen->GetScreenPixmap(pScreen) == pPix ) + { + TRACE_EXIT(); + return TRUE; + } + + if ( privPixmap ) + { + TRACE_EXIT(); + return pPix->devPrivate.ptr ? FALSE : TRUE; + } + + TRACE_EXIT(); + + return FALSE; +} + +static Bool maliPrepareAccess(PixmapPtr pPix, int index) +{ + PrivPixmap *privPixmap = (PrivPixmap *)exaGetPixmapDriverPrivate(pPix); + mali_mem_info *mem_info; + + TRACE_ENTER(); + IGNORE( index ); + + if ( !privPixmap ) + { + xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] Failed to get private pixmap data\n", __FUNCTION__, __LINE__); + TRACE_EXIT(); + return FALSE; + } + + + mem_info = privPixmap->mem_info; + if ( NULL != mem_info ) + { + if ( privPixmap->refs == 0 ) + { + privPixmap->addr = (unsigned long)ump_mapped_pointer_get( mem_info->handle ); + } + } + else + { + xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] No mem_info on pixmap\n", __FUNCTION__, __LINE__); + TRACE_EXIT(); + return FALSE; + } + + pPix->devPrivate.ptr = (void *)(privPixmap->addr); + if ( NULL == pPix->devPrivate.ptr ) + { + xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] cpu address not set\n", __FUNCTION__, __LINE__); + TRACE_EXIT(); + return FALSE; + } + + privPixmap->refs++; + TRACE_EXIT(); + + return TRUE; +} + +static void maliFinishAccess(PixmapPtr pPix, int index) +{ + PrivPixmap *privPixmap = (PrivPixmap *)exaGetPixmapDriverPrivate(pPix); + mali_mem_info *mem_info; + + TRACE_ENTER(); + IGNORE( index ); + + if ( !privPixmap ) + { + TRACE_EXIT(); + return; + } + + if ( !pPix ) + { + TRACE_EXIT(); + return; + } + + mem_info = privPixmap->mem_info; + + if ( !privPixmap->isFrameBuffer ) + { + if ( privPixmap->refs == 1 ) + { + if ( NULL != mem_info ) ump_mapped_pointer_release( mem_info->handle ); + } + } + + pPix->devPrivate.ptr = NULL; + privPixmap->refs--; + + TRACE_EXIT(); +} + +static Bool maliCheckComposite( int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture ) +{ + TRACE_ENTER(); + IGNORE( op ); + IGNORE( pSrcPicture ); + IGNORE( pMaskPicture ); + IGNORE( pDstPicture ); + TRACE_EXIT(); + + return FALSE; +} + +static Bool maliPrepareComposite( int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrcPixmap, PixmapPtr pMask, PixmapPtr pDstPixmap ) +{ + TRACE_ENTER(); + IGNORE( op ); + IGNORE( pSrcPicture ); + IGNORE( pMaskPicture ); + IGNORE( pDstPicture ); + IGNORE( pSrcPixmap ); + IGNORE( pMask ); + IGNORE( pDstPixmap ); + TRACE_EXIT(); + + return FALSE; +} + +static void maliComposite( PixmapPtr pDstPixmap, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int width, int height) +{ + TRACE_ENTER(); + IGNORE( pDstPixmap ); + IGNORE( srcX ); + IGNORE( srcY ); + IGNORE( maskX ); + IGNORE( maskY ); + IGNORE( dstX ); + IGNORE( dstY ); + IGNORE( width ); + IGNORE( height ); + TRACE_EXIT(); +} + +static void maliDoneComposite( PixmapPtr pDst ) +{ + TRACE_ENTER(); + IGNORE( pDst ); + TRACE_EXIT(); +} + + +static void maliDumpInfo() +{ + xf86DrvMsg(mi.pScrn->scrnIndex, X_INFO, "XRES: %i YRES: %i PHYS: 0x%x VIRT: 0x%x\n", mi.fb_xres, mi.fb_yres, (int)mi.fb_phys, (int)mi.fb_virt); +} + +Bool maliSetupExa( ScreenPtr pScreen, ExaDriverPtr exa, int xres, int yres, unsigned char *virt ) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MaliPtr fPtr = MALIPTR(pScrn); + + if ( NULL == exa ) return FALSE; + + memset(&mi, 0, sizeof(mi)); + mi.pScrn = pScrn; + mi.fb_xres = xres; + mi.fb_yres = yres; + mi.fb_phys = pScrn->memPhysBase; + mi.fb_virt = virt; + + TRACE_ENTER(); + + maliDumpInfo(); + + exa->exa_major = 2; + exa->exa_minor = 0; + exa->memoryBase = fPtr->fbmem; + exa->maxX = fPtr->fb_lcd_var.xres_virtual; + exa->maxY = fPtr->fb_lcd_var.yres_virtual; + exa->flags = EXA_OFFSCREEN_PIXMAPS | EXA_HANDLES_PIXMAPS | EXA_SUPPORTS_PREPARE_AUX; + exa->offScreenBase = (fPtr->fb_lcd_fix.line_length*fPtr->fb_lcd_var.yres); + exa->memorySize = fPtr->fb_lcd_fix.smem_len; + exa->pixmapOffsetAlign = 4096; + exa->pixmapPitchAlign = 8; + + fd_fbdev = fPtr->fb_lcd_fd; + + maliDumpInfo(); + + MALI_EXA_FUNC(PrepareSolid); + MALI_EXA_FUNC(Solid); + MALI_EXA_FUNC(DoneSolid); + + MALI_EXA_FUNC(PrepareCopy); + MALI_EXA_FUNC(Copy); + MALI_EXA_FUNC(DoneCopy); + + MALI_EXA_FUNC(CheckComposite); + MALI_EXA_FUNC(PrepareComposite); + MALI_EXA_FUNC(Composite); + MALI_EXA_FUNC(DoneComposite); + + MALI_EXA_FUNC(WaitMarker); + + MALI_EXA_FUNC(CreatePixmap); + MALI_EXA_FUNC(DestroyPixmap); + MALI_EXA_FUNC(ModifyPixmapHeader); + MALI_EXA_FUNC(PixmapIsOffscreen); + + MALI_EXA_FUNC(PrepareAccess); + MALI_EXA_FUNC(FinishAccess); + + if ( UMP_OK != ump_open() ) + { + xf86DrvMsg(mi.pScrn->scrnIndex, X_ERROR, "[%s:%d] failed to open UMP subsystem\n", __FUNCTION__, __LINE__); + TRACE_EXIT(); + return FALSE; + } + + + xf86DrvMsg(mi.pScrn->scrnIndex, X_INFO, "Mali EXA driver is loaded successfully\n"); + TRACE_EXIT(); + + return TRUE; +} diff --git a/src/mali_exa.h b/src/mali_exa.h new file mode 100644 index 0000000..43017fb --- /dev/null +++ b/src/mali_exa.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _MALI_EXA_H_ +#define _MALI_EXA_H_ + +#include +#include +#include "xf86.h" +#include "exa.h" + +/* Change this ioctl according to your specific UMP integration with LCD kernel driver */ +#define GET_UMP_SECURE_ID _IOWR('m', 310, unsigned int) + +struct mali_info +{ + ScrnInfoPtr pScrn; + unsigned long fb_phys; + unsigned char *fb_virt; + int fb_xres; + int fb_yres; + int fd; +}; + +typedef struct +{ + ump_handle handle; + unsigned long usize; +} mali_mem_info; + +typedef struct +{ + Bool isFrameBuffer; + int refs; + int bits_per_pixel; + unsigned long addr; + mali_mem_info *mem_info; +} PrivPixmap; + +#endif /* _MALI_EXA_H_ */ diff --git a/src/mali_fbdev.c b/src/mali_fbdev.c new file mode 100644 index 0000000..fecbd7e --- /dev/null +++ b/src/mali_fbdev.c @@ -0,0 +1,1196 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xf86.h" +#include "xf86cmap.h" +#include +#include "xf86xv.h" +#include "xf86Crtc.h" +#include "micmap.h" + +#include "mali_def.h" +#include "mali_fbdev.h" +#include "exa.h" + +#define TRACE_ENTER(str) \ + do { if (1) ErrorF("mali: " str " %d\n",pScrn->scrnIndex); } while (0) +#define TRACE_EXIT(str) \ + do { if (1) ErrorF("mali: " str " done\n"); } while (0) +#define TRACE(str) \ + do { if (1) ErrorF("mali trace: " str "\n"); } while (0) +#define IGNORE( a ) ( a = a ); +#define PAGE_MASK (~(getpagesize() - 1)) +#define MALI_VERSION 4000 +#define MALI_NAME "MALI" +#define MALI_DRIVER_NAME "mali" + +static const OptionInfoRec * MaliAvailableOptions(int chipid, int busid); +static void MaliIdentify(int flags); +static Bool MaliProbe(DriverPtr drv, int flags); +static Bool MaliPreInit(ScrnInfoPtr pScrn, int flags); +static Bool MaliScreenInit(int Index, ScreenPtr pScreen, int argc, char **argv); +static Bool MaliCloseScreen(int scrnIndex, ScreenPtr pScreen); + +static int pix24bpp = 0; +static int malihwPrivateIndex = -1; + +static Bool debug = FALSE; + + +_X_EXPORT DriverRec MALI = { + MALI_VERSION, + MALI_DRIVER_NAME, + MaliIdentify, + MaliProbe, + MaliAvailableOptions, + NULL, + 0, + NULL, + NULL, + NULL, +}; + +/* Supported "chipsets" */ +static SymTabRec MaliChipsets[] = { + { 0, "mali" }, + {-1, NULL } +}; + +/* Supported options */ +typedef enum { + OPTION_DEBUG, + OPTION_DRI2, + OPTION_DRI2_PAGE_FLIP, + OPTION_DRI2_WAIT_VSYNC, +} FBDevOpts; + +static const OptionInfoRec MaliOptions[] = { + { OPTION_DEBUG, "debug", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DRI2, "DRI2", OPTV_BOOLEAN, {0}, TRUE }, + { OPTION_DRI2_PAGE_FLIP, "DRI2_PAGE_FLIP", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DRI2_WAIT_VSYNC, "DRI2_WAIT_VSYNC", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } +}; + + +#ifdef XFree86LOADER + +MODULESETUPPROTO(MaliSetup); + +static XF86ModuleVersionInfo MaliVersRec = +{ + "mali", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + NULL, + {0,0,0,0} +}; + +_X_EXPORT XF86ModuleData maliModuleData = { &MaliVersRec, MaliSetup, NULL }; + +pointer MaliSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + static Bool setupDone = FALSE; + + TRACE("MaliSetup"); + + IGNORE(opts); + IGNORE(errmin); + + if (!setupDone) + { + setupDone = TRUE; + xf86AddDriver(&MALI, module, HaveDriverFuncs); + return (pointer)1; + } + else + { + if (errmaj) *errmaj = LDR_ONCEONLY; + return NULL; + } +} + +#endif /* XFree86LOADER */ + + +static Bool MaliGetRec(ScrnInfoPtr pScrn) +{ + TRACE("MaliGetRec"); + + if (pScrn->driverPrivate != NULL) return TRUE; + + pScrn->driverPrivate = xnfcalloc(sizeof(MaliRec), 1); + + return TRUE; +} + +static void MaliFreeRec(ScrnInfoPtr pScrn) +{ + TRACE("MaliFreeRec"); + + if (pScrn->driverPrivate == NULL) return; + free(pScrn->driverPrivate); + pScrn->driverPrivate = NULL; +} + +Bool MaliHWGetRec( ScrnInfoPtr pScrn ) +{ + MaliHWPtr fPtr; + + if ( malihwPrivateIndex < 0 ) malihwPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); + + if ( MALIHWPTR(pScrn) != NULL ) return TRUE; + + fPtr = MALIHWPTRLVAL(pScrn) = xnfcalloc( sizeof(MaliHWRec), 1 ); + + return TRUE; +} + +void MaliHWFreeRec( ScrnInfoPtr pScrn ) +{ + if ( malihwPrivateIndex < 0 ) return; + + if ( MALIHWPTR( pScrn ) == NULL ) return; + + free( MALIHWPTR( pScrn ) ); + MALIHWPTRLVAL( pScrn ) = NULL; +} + +static const OptionInfoRec * MaliAvailableOptions(int chipid, int busid) +{ + TRACE("MaliAvailableOptions"); + IGNORE(chipid); + IGNORE(busid); + + return MaliOptions; +} + +static void MaliIdentify(int flags) +{ + TRACE("MaliIdentify"); + IGNORE(flags); + + xf86PrintChipsets(MALI_NAME, "driver for Mali Framebuffer", MaliChipsets); +} + +static Bool fbdev_crtc_config_resize( ScrnInfoPtr scrn, int width, int height ) +{ + xf86DrvMsg(scrn->scrnIndex, X_INFO, "%s: width = %d height = %d\n", __FUNCTION__, width, height); + + scrn->virtualX = width; + scrn->virtualY = height; + + return TRUE; +} + +static void mali_check_dri_options( ScrnInfoPtr pScrn ) +{ + MaliPtr fPtr = MALIPTR(pScrn); + + fPtr->dri_render = DRI_NONE; + + if ( !xf86ReturnOptValBool(fPtr->Options, OPTION_DRI2, TRUE) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_CONFIG, "DRI disabled. No support in config file\n"); + fPtr->dri_render = DRI_DISABLED; + } + + if ( xf86ReturnOptValBool(fPtr->Options, OPTION_DRI2_PAGE_FLIP, FALSE ) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_CONFIG, "DRI Fullscreen page flip enabled\n"); + fPtr->use_pageflipping = TRUE; + } + else + { + xf86DrvMsg( pScrn->scrnIndex, X_CONFIG, "DRI Fullscreen page flip disabled. No support in config file\n"); + } + + if ( xf86ReturnOptValBool(fPtr->Options, OPTION_DRI2_WAIT_VSYNC, FALSE ) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_CONFIG, "DRI Fullscreen page flip VSYNC'd\n"); + fPtr->use_pageflipping_vsync = TRUE; + } + else + { + xf86DrvMsg( pScrn->scrnIndex, X_CONFIG, "DRI Fullscreen page flip VSYNC disabled\n"); + } + + if ( pScrn->depth != 16 && pScrn->depth != 24 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_CONFIG, "DRI is disabled since display does not run at 16bpp or 24bpp\n" ); + fPtr->dri_render = DRI_DISABLED; + } +} + +static void mali_check_exa_options( ScrnInfoPtr pScrn ) +{ + MaliPtr fPtr = MALIPTR(pScrn); + + IGNORE(fPtr); + + /* EXA specific options checked here */ +} + +static void mali_check_misc_options( ScrnInfoPtr pScrn ) +{ + MaliPtr fPtr = MALIPTR(pScrn); + + if ( xf86ReturnOptValBool(fPtr->Options, OPTION_DEBUG, FALSE ) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_CONFIG, "DEBUG output enabled\n"); + debug = TRUE; + } +} + +static const xf86CrtcConfigFuncsRec fbdev_crtc_config_funcs = +{ + .resize = fbdev_crtc_config_resize, +}; + +static void FBDev_crtc_config( ScrnInfoPtr pScrn ) +{ + xf86CrtcConfigPtr xf86_config; + int max_width, max_height; + TRACE("FBDev_crtc_config"); + + /* Allocate an xf86CrtcConfig */ + xf86CrtcConfigInit (pScrn, &fbdev_crtc_config_funcs); + xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + + max_width = 2048; + max_height = 2048; + + xf86CrtcSetSizeRange (pScrn, 640, 480, max_width, max_height); + TRACE_EXIT("FBDev_crtc_config"); +} + +static int mali_open( int scrnIndex, char *device, char **namep ) +{ + int fd; + struct fb_fix_screeninfo fix; + + + if ( device ) + { + fd = open( device, O_RDWR, 0 ); + } + else + { + device = getenv( "FRAMEBUFFER" ); + if ( ( NULL == device ) || ( ( fd = open(device, O_RDWR, 0 ) ) == -1 ) ) + { + device = "/dev/fb0"; + fd = open( device, O_RDWR, 0 ); + } + } + + if ( fd == -1 ) + { + xf86DrvMsg( scrnIndex, X_ERROR, "open %s: %s\n", device, strerror(errno) ); + return -1; + } + + if ( namep ) + { + if ( -1 == ioctl( fd, FBIOGET_FSCREENINFO, (void *)(&fix)) ) + { + *namep = NULL; + xf86DrvMsg( scrnIndex, X_ERROR, "FBIOGET_FSCREENINFO: %s\n", strerror( errno ) ); + return -1; + } + else + { + *namep = xnfalloc( 16 ); + strncpy( *namep, fix.id, 16 ); + } + } + + return fd; +} + +static void calculateFbmem_len(MaliHWPtr fPtr) +{ + fPtr->fboff = (unsigned long) fPtr->fix.smem_start & ~PAGE_MASK; + fPtr->fbmem_len = (fPtr->fboff+fPtr->fix.smem_len+~PAGE_MASK) & PAGE_MASK; +} + +int MaliHWGetLineLength( ScrnInfoPtr pScrn ) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + TRACE("MaliHWGetLineLength"); + + if ( fPtr->fix.line_length ) return fPtr->fix.line_length; + + return fPtr->var.xres_virtual * fPtr->var.bits_per_pixel/8; +} + +void* MaliHWMapVidmem(ScrnInfoPtr pScrn) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + + TRACE("MaliHWMapVidmem"); + + if ( NULL == fPtr->fbmem ) + { + calculateFbmem_len( fPtr ); + fPtr->fbmem = mmap( NULL, fPtr->fbmem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fPtr->fd, 0 ); + if ( -1 == (long)fPtr->fbmem ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "mmap fbmem: %s\n", strerror(errno) ); + fPtr->fbmem = NULL; + } + else + { + } + } + + pScrn->memPhysBase = (unsigned long)fPtr->fix.smem_start & (unsigned long)(PAGE_MASK); + pScrn->fbOffset = (unsigned long)fPtr->fix.smem_start & (unsigned long)(~PAGE_MASK); + + return fPtr->fbmem; +} + +Bool MaliHWSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool check) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + + TRACE("MaliHWSetMode"); + IGNORE(fPtr); + IGNORE(mode); + IGNORE(check); + + return TRUE; +} + +int MaliHWLinearOffset(ScrnInfoPtr pScrn) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + + TRACE("MaliHWLinearOffset"); + + return fPtr->fboff; +} + +Bool MaliHWUnmapVidmem(ScrnInfoPtr pScrn) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + + TRACE("MaliHWUnmapVidmem"); + if (NULL != fPtr->fbmem) + { + if (-1 == munmap(fPtr->fbmem, fPtr->fbmem_len)) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "munmap fbmem: %s\n", strerror(errno)); + fPtr->fbmem = NULL; + } + + return TRUE; +} + +Bool MaliHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + + TRACE("MaliHWModeInit"); + + pScrn->vtSema = TRUE; + + if (!MaliHWSetMode(pScrn, mode, FALSE)) return FALSE; + + if (0 != ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "FBIOGET_FSCREENINFO: %s\n", strerror(errno)); + return FALSE; + } + + if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->var))) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "FBIOGET_VSCREENINFO: %s\n", strerror(errno)); + return FALSE; + } + + if (pScrn->defaultVisual == TrueColor || pScrn->defaultVisual == DirectColor) + { + pScrn->offset.red = fPtr->var.red.offset; + pScrn->offset.green = fPtr->var.green.offset; + pScrn->offset.blue = fPtr->var.blue.offset; + pScrn->mask.red = ((1 << fPtr->var.red.length) - 1) << fPtr->var.red.offset; + pScrn->mask.green = ((1 << fPtr->var.green.length) - 1) << fPtr->var.green.offset; + pScrn->mask.blue = ((1 << fPtr->var.blue.length) - 1) << fPtr->var.blue.offset; + } + + return TRUE; +} + +void MaliHWSave(ScrnInfoPtr pScrn) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + + TRACE("MaliHWSave"); + if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->saved_var))) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "FBIOGET_VSCREENINFO: %s\n", strerror(errno)); +} + +void MaliHWRestore(ScrnInfoPtr pScrn) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + + TRACE("MaliHWRestore"); + if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->saved_var))) xf86DrvMsg(pScrn->scrnIndex, X_ERROR,"FBIOPUT_VSCREENINFO: %s\n", strerror(errno)); +} + +Bool MaliHWProbe( char *device, char **namep ) +{ + TRACE("MaliHWProbe"); + + if ( -1 == mali_open( -1, device, namep ) ) return FALSE; + + return TRUE; +} + +void MaliHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, VisualPtr pVisual) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + struct fb_cmap cmap; + unsigned short red,green,blue; + int i; + + TRACE("MaliHWLoadPalette"); + IGNORE(pVisual); + + cmap.len = 1; + cmap.red = &red; + cmap.green = &green; + cmap.blue = &blue; + cmap.transp = NULL; + for (i = 0; i < numColors; i++) + { + cmap.start = indices[i]; + red = (colors[indices[i]].red << 8) | colors[indices[i]].red; + green = (colors[indices[i]].green << 8) | colors[indices[i]].green; + blue = (colors[indices[i]].blue << 8) | colors[indices[i]].blue; + if (-1 == ioctl(fPtr->fd,FBIOPUTCMAP,(void*)&cmap)) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "FBIOPUTCMAP: %s\n", strerror(errno)); + } +} + +Bool MaliHWSaveScreen(ScreenPtr pScreen, int mode) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MaliHWPtr fPtr = MALIHWPTR(pScrn); + unsigned long unblank; + + TRACE("MaliHWSaveScreen"); + + if (!pScrn->vtSema) return TRUE; + + unblank = xf86IsUnblank(mode); + + if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)(1-unblank))) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "FBIOBLANK: %s\n", strerror(errno)); + return FALSE; + } + + return TRUE; +} + +ModeStatus MaliHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + TRACE("MaliHWValidMode"); + IGNORE(verbose); + IGNORE(flags); + + if (!MaliHWSetMode(pScrn, mode, TRUE)) return MODE_BAD; + + return MODE_OK; +} + +Bool MaliHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + TRACE("MaliHWSwitchMode"); + IGNORE(flags); + + if (!MaliHWSetMode(pScrn, mode, FALSE)) return FALSE; + + return TRUE; +} + +void MaliHWAdjustFrame(int scrnIndex, int x, int y, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + MaliHWPtr fPtr = MALIHWPTR(pScrn); + + TRACE("MaliHWAdjustFrame"); + IGNORE(flags); + + if ( x < 0 || x + fPtr->var.xres > fPtr->var.xres_virtual || y < 0 || y + fPtr->var.yres > fPtr->var.yres_virtual ) return; + + fPtr->var.xoffset = x; + fPtr->var.yoffset = y; + if ( -1 == ioctl( fPtr->fd, FBIOPAN_DISPLAY, (void*)&fPtr->var) ) + { + xf86DrvMsgVerb(scrnIndex, X_WARNING, 5, "FBIOPAN_DISPLAY: %s\n", strerror(errno)); + } +} + +Bool MaliHWEnterVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + TRACE("MaliHWEnterVT"); + IGNORE(flags); + + if (!MaliHWModeInit(pScrn, pScrn->currentMode)) return FALSE; + MaliHWAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + + return TRUE; +} + +void MaliHWLeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + + TRACE("MaliHWLeaveVT"); + IGNORE(flags); + + MaliHWRestore(pScrn); +} + +void MaliHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + unsigned long fbmode; + + TRACE("MaliHWDPMSSet"); + IGNORE(flags); + + if (!pScrn->vtSema) return; + + switch (mode) + { + case 0/*DPMSModeOn*/: + fbmode = 0; + break; + case 1/*DPMSModeStandby*/: + fbmode = 2; + break; + case 2/*DPMSModeSuspend*/: + fbmode = 3; + break; + case 3/*DPMSModeOff*/: + fbmode = 4; + break; + default: + return; + } + + if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)fbmode)) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "FBIOBLANK: %s\n", strerror(errno)); + } +} + +xf86SwitchModeProc *MaliHWSwitchModeWeak( void ) { return MaliHWSwitchMode; } +xf86AdjustFrameProc *MaliHWAdjustFrameWeak(void) { return MaliHWAdjustFrame; } +xf86EnterVTProc *MaliHWEnterVTWeak(void) { return MaliHWEnterVT; } +xf86LeaveVTProc *MaliHWLeaveVTWeak(void) { return MaliHWLeaveVT; } +xf86ValidModeProc *MaliHWValidModeWeak(void) { return MaliHWValidMode; } +xf86DPMSSetProc *MaliHWDPMSSetWeak(void) { return MaliHWDPMSSet; } +xf86LoadPaletteProc *MaliHWLoadPaletteWeak(void) { return MaliHWLoadPalette; } +SaveScreenProcPtr MaliHWSaveScreenWeak(void) { return MaliHWSaveScreen; } + + +static Bool MaliProbe( DriverPtr drv, int flags ) +{ + int i, numDevSections, entity; + Bool foundScreen = FALSE; + ScrnInfoPtr pScrn; + GDevPtr *devSections; + char *dev = "/dev/fb0"; + + TRACE("MaliProbe"); + + if (flags & PROBE_DETECT) return FALSE; + + if ((numDevSections = xf86MatchDevice(MALI_DRIVER_NAME, &devSections)) <= 0) return FALSE; + + for (i = 0; i < numDevSections; i++) + { + dev = xf86FindOptionValue( devSections[i]->options, "fbdev" ); + if ( MaliHWProbe( dev, NULL ) ) + { + pScrn = NULL; + entity = xf86ClaimFbSlot( drv, 0, devSections[i], TRUE ); + pScrn = xf86ConfigFbEntity( pScrn, 0, entity, NULL, NULL, NULL, NULL ); + if (pScrn) + { + foundScreen = TRUE; + + pScrn->driverVersion = MALI_VERSION; + pScrn->driverName = MALI_DRIVER_NAME; + pScrn->name = MALI_NAME; + pScrn->Probe = MaliProbe; + pScrn->PreInit = MaliPreInit; + pScrn->ScreenInit = MaliScreenInit; + + pScrn->SwitchMode = MaliHWSwitchModeWeak(); + pScrn->AdjustFrame = MaliHWAdjustFrameWeak(); + pScrn->EnterVT = MaliHWEnterVTWeak(); + pScrn->LeaveVT = MaliHWLeaveVTWeak(); + pScrn->ValidMode = MaliHWValidModeWeak(); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "using %s\n", dev ? dev : "default device"); + } + } + } + free(devSections); + + return foundScreen; +} + +Bool MaliHWInit( ScrnInfoPtr pScrn, char *device ) +{ + MaliHWPtr fPtr; + + TRACE("MaliHWInit"); + + MaliHWGetRec( pScrn ); + fPtr = MALIHWPTR( pScrn ); + fPtr->fd = mali_open( pScrn->scrnIndex,device,NULL ); + + if ( -1 == fPtr->fd ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "Failed to open framebuffer!\n" ); + return FALSE; + } + + if ( -1 == ioctl( fPtr->fd, FBIOGET_FSCREENINFO, (void *)(&fPtr->fix) ) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "Failed to get fixed info!\n" ); + return FALSE; + } + + if ( -1 == ioctl( fPtr->fd, FBIOGET_VSCREENINFO, (void *)(&fPtr->var) ) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "Failed to get var info!\n" ); + return FALSE; + } + + return TRUE; + +} + +int MaliHWGetDepth( ScrnInfoPtr pScrn, int *fbbpp ) +{ + MaliHWPtr fPtr = MALIHWPTR( pScrn ); + + TRACE("MaliHWGetDepth"); + + if ( fbbpp ) *fbbpp = fPtr->var.bits_per_pixel; + + if ( fPtr->fix.visual == FB_VISUAL_TRUECOLOR || fPtr->fix.visual == FB_VISUAL_DIRECTCOLOR ) + { + return fPtr->var.red.length + fPtr->var.green.length + fPtr->var.blue.length; + } + + return fPtr->var.bits_per_pixel; +} + +int MaliHWGetVidmem( ScrnInfoPtr pScrn ) +{ + MaliHWPtr fPtr = MALIHWPTR( pScrn ); + TRACE("HWGetVidmem"); + + return fPtr->fix.smem_len; +} + +char *MaliHWGetName( ScrnInfoPtr pScrn ) +{ + MaliHWPtr fPtr = MALIHWPTR( pScrn ); + TRACE("MaliHWGetName"); + + return fPtr->fix.id; +} + +int MaliHWGetFD( ScrnInfoPtr pScrn ) +{ + MaliHWPtr fPtr; + TRACE("MaliHWGetFD"); + + MaliHWGetRec(pScrn); + fPtr = MALIHWPTR(pScrn); + + return fPtr->fd; +} + +void MaliHWSetVideoModes(ScrnInfoPtr pScrn) +{ + char **modename; + DisplayModePtr mode, this, last = pScrn->modes; + + TRACE("MaliHWSetVideoModes"); + + if ( NULL == pScrn->display->modes ) return; + + pScrn->virtualX = pScrn->display->virtualX; + pScrn->virtualY = pScrn->display->virtualY; + + for (modename = pScrn->display->modes; *modename != NULL; modename++) + { + for (mode = pScrn->monitor->Modes; mode != NULL; mode = mode->next) + if (0 == strcmp(mode->name,*modename)) break; + if (NULL == mode) + { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tmode \"%s\" not found\n", *modename); + continue; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tmodename \"%s\" mode->name \"%s\"\n", *modename, mode->name); + if (!MaliHWSetMode(pScrn, mode, TRUE)) + { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tmode \"%s\" test failed\n", *modename); + continue; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tmode \"%s\" ok\n", *modename); + + if (pScrn->virtualX < mode->HDisplay) pScrn->virtualX = mode->HDisplay; + if (pScrn->virtualY < mode->VDisplay) pScrn->virtualY = mode->VDisplay; + + if (NULL == pScrn->modes) + { + this = pScrn->modes = xf86DuplicateMode(mode); + this->next = this; + this->prev = this; + } + else + { + this = xf86DuplicateMode(mode); + this->next = pScrn->modes; + this->prev = last; + last->next = this; + pScrn->modes->prev = this; + } + last = this; + } +} + +void MaliHWUseBuildinMode(ScrnInfoPtr pScrn) +{ + MaliHWPtr fPtr = MALIHWPTR(pScrn); + + TRACE("MaliHWUseBuildinMode"); + pScrn->modes = &fPtr->buildin; + pScrn->virtualX = pScrn->display->virtualX; + pScrn->virtualY = pScrn->display->virtualY; + if (pScrn->virtualX < fPtr->buildin.HDisplay) pScrn->virtualX = fPtr->buildin.HDisplay; + if (pScrn->virtualY < fPtr->buildin.VDisplay) pScrn->virtualY = fPtr->buildin.VDisplay; +} + +static void mali_drm_close_master( ScrnInfoPtr pScrn ) +{ + MaliPtr fPtr = MALIPTR(pScrn); + if ( fPtr && fPtr->drm_fd > 0 ) + { + + xf86DrvMsg( pScrn->scrnIndex, X_INFO, "closing DRM device\n"); + drmClose( fPtr->drm_fd ); + fPtr->drm_fd = -1; + } +} + +static Bool mali_drm_open_master( ScrnInfoPtr pScrn ) +{ + MaliPtr fPtr = MALIPTR(pScrn); + drmSetVersion sv; + int err; + + fPtr->drm_fd = drmOpen("mali_drm", NULL ); + if ( fPtr->drm_fd == -1 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "%s Unable to open DRM: %s\n", __func__, strerror(errno)); + return FALSE; + } + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "%s DRM OPEN (fd: 0x%x)\n", __func__, fPtr->drm_fd ); + + sv.drm_di_major = 1; + sv.drm_di_minor = 1; + sv.drm_dd_major = -1; + sv.drm_dd_minor = -1; + + err = drmSetInterfaceVersion( fPtr->drm_fd, &sv ); + if ( err != 0 ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "%s DRM failed to interface version\n", __func__ ); + drmClose( fPtr->drm_fd ); + fPtr->drm_fd = -1; + return FALSE; + } + + + return TRUE; +} + + +static Bool MaliPreInit(ScrnInfoPtr pScrn, int flags) +{ + MaliPtr fPtr; + int default_depth, fbbpp; + + TRACE("MaliPreInit"); + + if (flags & PROBE_DETECT) return FALSE; + + /* Check the number of entities, and fail if it isn't one. */ + if (pScrn->numEntities != 1) return FALSE; + + pScrn->monitor = pScrn->confScreen->monitor; + + MaliGetRec(pScrn); + fPtr = MALIPTR(pScrn); + + fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); + fPtr->dri_open = FALSE; + fPtr->dri_render = DRI_NONE; + fPtr->use_pageflipping = FALSE; + fPtr->use_pageflipping_vsync = FALSE; + + /* open device */ + if ( !MaliHWInit( pScrn, xf86FindOptionValue( fPtr->pEnt->device->options,"fbdev" ) ) ) return FALSE; + + default_depth = MaliHWGetDepth(pScrn,&fbbpp); + if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, fbbpp, Support24bppFb | Support32bppFb | SupportConvert32to24 | SupportConvert24to32)) return FALSE; + xf86PrintDepthBpp(pScrn); + + + /* Get the depth24 pixmap format */ + if (pScrn->depth == 24 && pix24bpp == 0) pix24bpp = xf86GetBppFromDepth(pScrn, 24); + + /* color weight */ + if (pScrn->depth > 8) + { + rgb zeros = { 0, 0, 0 }; + if (!xf86SetWeight(pScrn, zeros, zeros)) return FALSE; + } + + /* visual init */ + if (!xf86SetDefaultVisual(pScrn, -1)) return FALSE; + + /* We don't currently support DirectColor at > 8bpp */ + if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "requested default visual (%s) is not supported at depth %d\n", xf86GetVisualName(pScrn->defaultVisual), pScrn->depth); + return FALSE; + } + + { + Gamma zeros = {0.0, 0.0, 0.0}; + + if (!xf86SetGamma(pScrn,zeros)) + { + return FALSE; + } + } + + pScrn->progClock = TRUE; + pScrn->rgbBits = 8; + pScrn->chipset = "mali"; + pScrn->videoRam = MaliHWGetVidmem(pScrn); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "hardware: %s (video memory: %dkB)\n", MaliHWGetName(pScrn), pScrn->videoRam/1024); + + /* handle options */ + xf86CollectOptions(pScrn, NULL); + if (!(fPtr->Options = malloc(sizeof(MaliOptions)))) return FALSE; + + memcpy(fPtr->Options, MaliOptions, sizeof(MaliOptions)); + xf86ProcessOptions(pScrn->scrnIndex, fPtr->pEnt->device->options, fPtr->Options); + + mali_check_dri_options( pScrn ); + + if ( fPtr->dri_render == DRI_NONE && FALSE == mali_drm_open_master( pScrn ) ) + { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to be master of DRM!\n"); + return FALSE; + } + + mali_check_dri_options( pScrn ); + mali_check_exa_options( pScrn ); + mali_check_misc_options( pScrn ); + + + fPtr->fb_lcd_fd = MaliHWGetFD( pScrn ); + + if ( ioctl( fPtr->fb_lcd_fd, FBIOGET_FSCREENINFO, &fPtr->fb_lcd_fix ) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "FBIOGET_FSCREENINFO failed!\n" ); + return FALSE; + } + + if ( ioctl( fPtr->fb_lcd_fd, FBIOGET_VSCREENINFO, &fPtr->fb_lcd_var ) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "FBIOGET_VSCREENINFO failed!\n" ); + return FALSE; + } + + pScrn->frameX0 = 0; + pScrn->frameY0 = 0; + pScrn->frameX1 = fPtr->fb_lcd_var.xres; + pScrn->frameY1 = fPtr->fb_lcd_var.yres; + + FBDev_crtc_config( pScrn ); + + if ( !FBDEV_lcd_init( pScrn ) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "FBDev_lcd_init failed!\n" ); + return FALSE; + } + + if ( !xf86InitialConfiguration( pScrn, TRUE ) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "xf86InitialConfiguration failed!\n" ); + return FALSE; + } + + pScrn->displayWidth = pScrn->virtualX; + + xf86PrintModes( pScrn ); + xf86SetDpi( pScrn, 0, 0 ); + + if ( xf86LoadSubModule( pScrn, "fb" ) == NULL ) + { + MaliFreeRec( pScrn ); + return FALSE; + } + + return TRUE; +} + + +static Bool MaliScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MaliPtr fPtr = MALIPTR(pScrn); + VisualPtr visual; + int init_picture = 0; + int ret, flags; + + TRACE("MaliScreenInit"); + IGNORE(argc); + IGNORE(argv); + +#if DEBUG + ErrorF("\tbitsPerPixel=%d, depth=%d, defaultVisual=%s\n\tmask: %x,%x,%x, offset: %d,%d,%d\n", + pScrn->bitsPerPixel, + pScrn->depth, + xf86GetVisualName(pScrn->defaultVisual), + pScrn->mask.red,pScrn->mask.green,pScrn->mask.blue, + pScrn->offset.red,pScrn->offset.green,pScrn->offset.blue); +#endif + + if ( fPtr->dri_render == DRI_NONE ) + { + if ( TRUE == MaliDRI2ScreenInit( pScreen ) ) + { + fPtr->dri_render = DRI_2; + fPtr->dri_open = TRUE; + } + else xf86DrvMsg(scrnIndex,X_ERROR,"DRI2 initialization failed\n"); + } + + if (NULL == (fPtr->fbmem = MaliHWMapVidmem(pScrn))) + { + xf86DrvMsg(scrnIndex,X_ERROR,"mapping of video memory failed\n"); + return FALSE; + } + fPtr->fboff = MaliHWLinearOffset(pScrn); + + MaliHWSave(pScrn); + + if (!MaliHWModeInit(pScrn, pScrn->currentMode)) + { + xf86DrvMsg(scrnIndex,X_ERROR,"mode initialization failed\n"); + return FALSE; + } + MaliHWSaveScreen(pScreen, SCREEN_SAVER_ON); + MaliHWAdjustFrame(scrnIndex,0,0,0); + + /* mi layer */ + miClearVisualTypes(); + if (pScrn->bitsPerPixel > 8) + { + if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits, TrueColor)) + { + xf86DrvMsg(scrnIndex,X_ERROR,"visual type setup failed for %d bits per pixel [1]\n", pScrn->bitsPerPixel); + return FALSE; + } + } + else + { + if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) + { + xf86DrvMsg(scrnIndex,X_ERROR,"visual type setup failed for %d bits per pixel [2]\n", pScrn->bitsPerPixel); + return FALSE; + } + } + if (!miSetPixmapDepths()) + { + xf86DrvMsg(scrnIndex,X_ERROR,"pixmap depth setup failed\n"); + return FALSE; + } + + + fPtr->fbstart = fPtr->fbmem + fPtr->fboff; + + ret = fbScreenInit(pScreen, fPtr->fbstart, pScrn->virtualX, + pScrn->virtualY, pScrn->xDpi, + pScrn->yDpi, pScrn->displayWidth, + pScrn->bitsPerPixel); + init_picture = 1; + + if (pScrn->bitsPerPixel > 8) + { + /* Fixup RGB ordering */ + visual = pScreen->visuals + pScreen->numVisuals; + while (--visual >= pScreen->visuals) + { + if ((visual->class | DynamicClass) == DirectColor) + { + visual->offsetRed = pScrn->offset.red; + visual->offsetGreen = pScrn->offset.green; + visual->offsetBlue = pScrn->offset.blue; + visual->redMask = pScrn->mask.red; + visual->greenMask = pScrn->mask.green; + visual->blueMask = pScrn->mask.blue; + } + } + } + + /* must be after RGB ordering fixed */ + if (init_picture && !fbPictureInit(pScreen, NULL, 0)) xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Render extension initialisation failed\n"); + + xf86SetBlackWhitePixels(pScreen); + + xf86LoadSubModule(pScrn, "exa"); + fPtr->exa = exaDriverAlloc(); + + if ( maliSetupExa( pScreen, fPtr->exa, pScrn->virtualX, pScrn->virtualY, fPtr->fbmem ) ) + { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Initializing EXA Driver!\n"); + exaDriverInit( pScreen, fPtr->exa ); + } + else + { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed allocating EXA Driver!\n"); + free( fPtr->exa ); + fPtr->exa = NULL; + } + + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); + + /* software cursor */ + miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); + + xf86SetDesiredModes(pScrn); + + if ( !xf86CrtcScreenInit(pScreen) ) + { + xf86DrvMsg( pScrn->scrnIndex, X_ERROR, "xf86CrtcScreenInit failed\n"); + return FALSE; + } + + if (!miCreateDefColormap(pScreen)) + { + xf86DrvMsg(scrnIndex, X_ERROR, + "internal error: miCreateDefColormap failed in FBDevScreenInit()\n"); + return FALSE; + } + + flags = CMAP_PALETTED_TRUECOLOR; + + if(!xf86HandleColormaps(pScreen, 256, 8, MaliHWLoadPaletteWeak(), NULL, flags)) return FALSE; + + xf86DPMSInit(pScreen, MaliHWDPMSSetWeak(), 0); + + pScreen->SaveScreen = MaliHWSaveScreenWeak(); + + /* Wrap the current CloseScreen function */ + fPtr->CloseScreen = pScreen->CloseScreen; + pScreen->CloseScreen = MaliCloseScreen; + + { + XF86VideoAdaptorPtr *ptr; + + int n = xf86XVListGenericAdaptors(pScrn,&ptr); + if (n) xf86XVScreenInit(pScreen,ptr,n); + } + + return TRUE; +} + +static Bool MaliCloseScreen(int scrnIndex, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + MaliPtr fPtr = MALIPTR(pScrn); + TRACE("MaliCloseScreen"); + + MaliHWRestore(pScrn); + MaliHWUnmapVidmem(pScrn); + pScrn->vtSema = FALSE; + + pScreen->CreateScreenResources = fPtr->CreateScreenResources; + pScreen->CloseScreen = fPtr->CloseScreen; + + (*pScreen->CloseScreen)(scrnIndex, pScreen); + + if ( fPtr->dri_open && fPtr->dri_render == DRI_2 ) + { + fPtr->dri_open = FALSE; + MaliDRI2CloseScreen( pScreen ); + mali_drm_close_master( pScrn ); + } + + return TRUE; +} + diff --git a/src/mali_fbdev.h b/src/mali_fbdev.h new file mode 100644 index 0000000..4ab0eda --- /dev/null +++ b/src/mali_fbdev.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _MALI_FBDEV_DRIVER_H_ +#define _MALI_FBDEV_DRIVER_H_ + +#include +#include +#include "exa.h" + +#define DPMSModeOn 0 +#define DPMSModeStandby 1 +#define DPMSModeSuspend 2 +#define DPMSModeOff 3 + +enum dri_type +{ + DRI_DISABLED, + DRI_NONE, + DRI_2, +}; + +typedef struct { + unsigned char *fbstart; + unsigned char *fbmem; + int fboff; + int lineLength; + CreateScreenResourcesProcPtr CreateScreenResources; + void (*PointerMoved)(int index, int x, int y); + CloseScreenProcPtr CloseScreen; + EntityInfoPtr pEnt; + OptionInfoPtr Options; + int fb_lcd_fd; + struct fb_fix_screeninfo fb_lcd_fix; + struct fb_var_screeninfo fb_lcd_var; + ExaDriverPtr exa; + int dri_render; + Bool dri_open; + int drm_fd; + char deviceName[64]; + Bool use_pageflipping; + Bool use_pageflipping_vsync; +} MaliRec, *MaliPtr; + +typedef struct { + char *device; + int fd; + void *fbmem; + unsigned int fbmem_len; + unsigned int fboff; + struct fb_fix_screeninfo fix; + struct fb_var_screeninfo var; + struct fb_var_screeninfo saved_var; + DisplayModeRec buildin; + int xres; + int yres; +} MaliHWRec, *MaliHWPtr; + +#define MALIPTR(p) ((MaliPtr)((p)->driverPrivate)) +#define MALIHWPTRLVAL(p) (p)->privates[malihwPrivateIndex].ptr +#define MALIHWPTR(p) ((MaliHWPtr)(MALIHWPTRLVAL(p))) + +//#define MALI_DEBUG_MSG_ENABLE + +#ifdef MALI_DEBUG_MSG_ENABLE +#define MALIDBGMSG(type, format, args...) xf86Msg(type, format, args) +#else +#define MALIDBGMSG(type, format, args...) +#endif + + +Bool FBDEV_lcd_init(ScrnInfoPtr pScrn); + +Bool MaliDRI2ScreenInit( ScreenPtr pScreen ); +void MaliDRI2CloseScreen( ScreenPtr pScreen ); + +#endif /* _MALI_FBDEV_DRIVER_H_ */ + diff --git a/src/mali_lcd.c b/src/mali_lcd.c new file mode 100644 index 0000000..1aba1bd --- /dev/null +++ b/src/mali_lcd.c @@ -0,0 +1,276 @@ +/* + * Copyright (C) 2010 ARM Limited. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include "xf86.h" +#include "xf86Crtc.h" + +#include "mali_fbdev.h" +#define IGNORE(a) (a=a) + +static void fbdev_lcd_crtc_dpms(xf86CrtcPtr crtc, int mode) +{ + IGNORE(crtc); + IGNORE(mode); +} + +static Bool fbdev_lcd_crtc_lock(xf86CrtcPtr crtc) +{ + IGNORE( crtc ); + + return TRUE; +} + +static void fbdev_lcd_crtc_unlock(xf86CrtcPtr crtc) +{ + IGNORE( crtc ); +} + +static Bool fbdev_lcd_crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode, DisplayModePtr adjusted_mode) +{ + IGNORE( crtc ); + IGNORE( mode ); + IGNORE( adjusted_mode ); + + return TRUE; +} + +static void fbdev_lcd_crtc_prepare(xf86CrtcPtr crtc) +{ + IGNORE( crtc ); +} + +static void fbdev_lcd_crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode, DisplayModePtr adjusted_mode, int x, int y) +{ + IGNORE( crtc ); + IGNORE( mode ); + IGNORE( adjusted_mode ); + IGNORE( x ); + IGNORE( y ); +} + +static void fbdev_lcd_crtc_commit(xf86CrtcPtr crtc) +{ + IGNORE( crtc ); +} + +static void fbdev_lcd_crtc_gamma_set(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue, int size) +{ + IGNORE( crtc ); + IGNORE( red ); + IGNORE( green ); + IGNORE( blue ); + IGNORE( size ); +} + +static void fbdev_lcd_crtc_set_origin(xf86CrtcPtr crtc, int x, int y) +{ + IGNORE( crtc ); + IGNORE( x ); + IGNORE( y ); +} + +static const xf86CrtcFuncsRec fbdev_lcd_crtc_funcs = +{ + .dpms = fbdev_lcd_crtc_dpms, + .save = NULL, + .restore = NULL, + .lock = fbdev_lcd_crtc_lock, + .unlock = fbdev_lcd_crtc_unlock, + .mode_fixup = fbdev_lcd_crtc_mode_fixup, + .prepare = fbdev_lcd_crtc_prepare, + .mode_set = fbdev_lcd_crtc_mode_set, + .commit = fbdev_lcd_crtc_commit, + .gamma_set = fbdev_lcd_crtc_gamma_set, + .shadow_allocate = NULL, + .shadow_create = NULL, + .shadow_destroy = NULL, + .set_cursor_colors = NULL, + .set_cursor_position = NULL, + .show_cursor = NULL, + .hide_cursor = NULL, + .load_cursor_image = NULL, + .load_cursor_argb = NULL, + .destroy = NULL, + .set_mode_major = NULL, + .set_origin = fbdev_lcd_crtc_set_origin, +}; + +static void fbdev_lcd_output_dpms(xf86OutputPtr output, int mode) +{ + MaliPtr fPtr = MALIPTR(output->scrn); + + if ( mode == DPMSModeOn ) + { + ioctl(fPtr->fb_lcd_fd, FBIOBLANK, FB_BLANK_UNBLANK); + } + else if( mode == DPMSModeOff ) + { + ioctl(fPtr->fb_lcd_fd, FBIOBLANK, FB_BLANK_POWERDOWN); + } +} + +static void fbdev_lcd_output_save(xf86OutputPtr output) +{ + IGNORE( output ); +} + +static void fbdev_lcd_output_restore(xf86OutputPtr output) +{ + IGNORE( output ); +} + +static int fbdev_lcd_output_mode_valid(xf86OutputPtr output, DisplayModePtr pMode) +{ + MaliPtr fPtr = MALIPTR(output->scrn); + + if( (pMode->HDisplay == (int)fPtr->fb_lcd_var.xres) && (pMode->VDisplay == (int)fPtr->fb_lcd_var.yres) ) return MODE_OK; + + return MODE_ERROR; +} + +static Bool fbdev_lcd_output_mode_fixup(xf86OutputPtr output, DisplayModePtr mode, DisplayModePtr adjusted_mode) +{ + IGNORE( output ); + IGNORE( mode ); + IGNORE( adjusted_mode ); + + return TRUE; +} + +static void fbdev_lcd_output_prepare(xf86OutputPtr output) +{ + IGNORE( output ); +} + +static void fbdev_lcd_output_commit(xf86OutputPtr output) +{ + output->funcs->dpms(output, DPMSModeOn); +} + +static void fbdev_lcd_output_mode_set(xf86OutputPtr output, DisplayModePtr mode, DisplayModePtr adjusted_mode) +{ + IGNORE( output ); + IGNORE( mode ); + IGNORE( adjusted_mode ); +} + +static xf86OutputStatus fbdev_lcd_output_detect(xf86OutputPtr output) +{ + IGNORE( output ); + + return XF86OutputStatusConnected; +} + +static DisplayModePtr fbdev_lcd_output_get_modes(xf86OutputPtr output) +{ + MaliPtr fPtr = MALIPTR(output->scrn); + DisplayModePtr mode_ptr; + + unsigned int hactive_s = fPtr->fb_lcd_var.xres; + unsigned int vactive_s = fPtr->fb_lcd_var.yres; + + mode_ptr = xnfcalloc(1, sizeof(DisplayModeRec)); + + mode_ptr->HDisplay = hactive_s; + mode_ptr->HSyncStart = hactive_s + 20; + mode_ptr->HSyncEnd = hactive_s + 40; + mode_ptr->HTotal = hactive_s + 80; + + mode_ptr->VDisplay = vactive_s; + mode_ptr->VSyncStart = vactive_s + 20; + mode_ptr->VSyncEnd = vactive_s + 40; + mode_ptr->VTotal = vactive_s + 80; + + mode_ptr->VRefresh = 60.0; + + mode_ptr->Clock = (int) (mode_ptr->VRefresh * mode_ptr->VTotal * mode_ptr->HTotal / 1000.0); + + mode_ptr->type = M_T_DRIVER; + + xf86SetModeDefaultName(mode_ptr); + + mode_ptr->next = NULL; + mode_ptr->prev = NULL; + + return mode_ptr; +} + +#ifdef RANDR_GET_CRTC_INTERFACE +static xf86CrtcPtr fbdev_lcd_output_get_crtc(xf86OutputPtr output) +{ + return output->crtc; +} +#endif + +static void fbdev_lcd_output_destroy(xf86OutputPtr output) +{ + IGNORE( output ); +} + +static const xf86OutputFuncsRec fbdev_lcd_output_funcs = +{ + .create_resources = NULL, + .dpms = fbdev_lcd_output_dpms, + .save = fbdev_lcd_output_save, + .restore = fbdev_lcd_output_restore, + .mode_valid = fbdev_lcd_output_mode_valid, + .mode_fixup = fbdev_lcd_output_mode_fixup, + .prepare = fbdev_lcd_output_prepare, + .commit = fbdev_lcd_output_commit, + .mode_set = fbdev_lcd_output_mode_set, + .detect = fbdev_lcd_output_detect, + .get_modes = fbdev_lcd_output_get_modes, +#ifdef RANDR_12_INTERFACE + .set_property = NULL, +#endif +#ifdef RANDR_13_INTERFACE + .get_property = NULL, +#endif +#ifdef RANDR_GET_CRTC_INTERFACE + .get_crtc = fbdev_lcd_output_get_crtc, +#endif + .destroy = fbdev_lcd_output_destroy, +}; + + +Bool FBDEV_lcd_init(ScrnInfoPtr pScrn) +{ + xf86CrtcPtr crtc; + xf86OutputPtr output; + + crtc = xf86CrtcCreate(pScrn, &fbdev_lcd_crtc_funcs); + + if(crtc == NULL) return FALSE; + + output = xf86OutputCreate(pScrn, &fbdev_lcd_output_funcs, "LCD"); + + if(output == NULL) return FALSE; + + output->possible_crtcs = (1 << 0); + + return TRUE; +} -- cgit v1.2.3